Skip to content

Commit

Permalink
Update scripts for publishing lite mode
Browse files Browse the repository at this point in the history
- using r18gs as peer dependency
  • Loading branch information
mayank1513 committed Jun 9, 2024
1 parent 01532c7 commit d0087e2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .tkb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"1dRWJhy45E1Rq5wZAmPHt": {
"id": "1dRWJhy45E1Rq5wZAmPHt",
"description": "Update README as required",
"columnId": "column-todo"
"columnId": "column-done"
},
"5vS1JNXoMhDl5IBljwh2v": {
"id": "5vS1JNXoMhDl5IBljwh2v",
Expand All @@ -89,12 +89,12 @@
"0499BqWDwJ5cxqtC9Nr82": {
"id": "0499BqWDwJ5cxqtC9Nr82",
"description": "Feel free to star this template, contribute, and/or sponsor the [`terborepo-template`](https://github.com/react18-tools/turborepo-template) project or my [other open-source work](https://github.com/sponsors/mayank1513)",
"columnId": "column-todo"
"columnId": "column-done"
},
"IjuAtNquJ4-Ut874rHKIW": {
"id": "IjuAtNquJ4-Ut874rHKIW",
"description": "You can also fork the [`terborepo-template`](https://github.com/react18-tools/turborepo-template/fork) and add your package to `scripts/featured.json`\n - If approved, your package will be automatically added to FEATURED.md and also published on the home page of this repo.",
"columnId": "column-todo"
"columnId": "column-done"
},
"t5d22lVYbF7GuQHzv6DRO": {
"id": "t5d22lVYbF7GuQHzv6DRO",
Expand Down Expand Up @@ -125,6 +125,11 @@
"id": "ltOP38szvwpGAruTRbxOq",
"description": "ServerTarget\n- to sync theme with the help of server components --- avoid jitter of unthemed page",
"columnId": "column-done"
},
"hBTyeXLx4fIQE1q5qatqF": {
"id": "hBTyeXLx4fIQE1q5qatqF",
"description": "Add publish scripts for lite version",
"columnId": "column-done"
}
},
"columns": [
Expand All @@ -143,13 +148,10 @@
"id": "column-todo",
"title": "To do",
"tasksIds": [
"1dRWJhy45E1Rq5wZAmPHt",
"5vS1JNXoMhDl5IBljwh2v",
"55DAZwduwTvlaxaJC8hlX",
"FDFqCQvLm2mUlnTJ3Gna5",
"O1qAByMoxhHOR-a_guL91",
"0499BqWDwJ5cxqtC9Nr82",
"IjuAtNquJ4-Ut874rHKIW"
"O1qAByMoxhHOR-a_guL91"
]
},
{
Expand All @@ -163,7 +165,11 @@
"id": "column-done",
"title": "Done",
"tasksIds": [
"hBTyeXLx4fIQE1q5qatqF",
"1dRWJhy45E1Rq5wZAmPHt",
"_BfuX7quWBANpDK1bI7YM",
"IjuAtNquJ4-Ut874rHKIW",
"0499BqWDwJ5cxqtC9Nr82",
"ltOP38szvwpGAruTRbxOq",
"bjrSIW2boIWsI4h74nxXl",
"1jEMZiPKJSVpEMu6ZxfpX",
Expand Down
29 changes: 29 additions & 0 deletions scripts/lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

const fs = require("node:fs");
const path = require("node:path");
const config = require("./rebrand.config.json");

const packageJson = require("../lib/package.json");

const ref = packageJson.name;
packageJson.peerDependencies.r18gs = `${packageJson.dependencies.r18gs.split(".")[0]}`;
delete packageJson.dependencies.r18gs;
if (Object.keys(packageJson.devDependencies).length === 0) delete packageJson.devDependencies;
packageJson.name = `${ref}-lite`;

fs.writeFileSync(
path.resolve(__dirname, "../lib/package.json"),
JSON.stringify(packageJson, null, 2),
);

const readMePath = path.resolve(__dirname, "../lib", "README.md");

let readMe = fs.readFileSync(readMePath, { encoding: "utf8" });
const tmp = "!---";
const { owner, repo } = config;
readMe = readMe.replace(new RegExp(`${owner}/${repo}`, "g"), tmp);
readMe = readMe.replace(new RegExp(ref, "g"), packageJson.name);
readMe = readMe.replace(new RegExp(tmp, "g"), `${owner}/${repo}`);
readMe = readMe.replace(/## Want Lite Version(.|\n|\r)*You need `r18gs` as a peer-dependency/m, "");
fs.writeFileSync(readMePath, readMe);
3 changes: 3 additions & 0 deletions scripts/manual-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,6 @@ execSync(`cd lib && pnpm build && npm publish --provenance --access public --tag
execSync(
`gh release create ${NEW_VERSION} --generate-notes${isLatestRelease ? " --latest" : ""} -n "$(sed '1,/^## /d;/^## /,$d' CHANGELOG.md)" --title "Release v${NEW_VERSION}"`,
);

execSync("node ./scripts/lite.js");
execSync(`cd lib && pnpm build && npm publish --provenance --access public --tag ${tag}`);
3 changes: 3 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ execSync("cd lib && pnpm build && npm publish --provenance --access public");
execSync(
`gh release create ${VERSION} --generate-notes --latest -n "$(sed '1,/^## /d;/^## /,$d' CHANGELOG.md)" --title "Release v${VERSION}"`,
);

execSync("node ./scripts/lite.js");
execSync("cd lib && pnpm build && npm publish --provenance --access public");

0 comments on commit d0087e2

Please sign in to comment.