-
Notifications
You must be signed in to change notification settings - Fork 52
chore: Remove lerna #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+572
−4,864
Merged
chore: Remove lerna #895
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ yarn-error.log | |
| *.tgz | ||
|
|
||
| .nxcache | ||
| .nx | ||
| packages/**/yarn.lock | ||
|
|
||
| .DS_Store | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| function readJson(filePath) { | ||
| return JSON.parse(fs.readFileSync(filePath, "utf-8")); | ||
| } | ||
|
|
||
| /** | ||
| * Bumps the version of all workspace packages and their internal dependencies. | ||
| * This replicates the behavior of: | ||
| * lerna version --force-publish --exact --no-git-tag-version --no-push --include-merged-tags --yes <newVersion> | ||
| * | ||
| * Specifically: | ||
| * - Updates `version` in every workspace package.json to newVersion | ||
| * - Updates all internal workspace dependency references (dependencies, devDependencies, peerDependencies) | ||
| * to the new exact version (no ^ or ~ prefix), matching lerna's --exact flag | ||
| * - --force-publish: all packages are updated regardless of whether they changed | ||
| * - No git tags, commits, or pushes are made | ||
| */ | ||
| function bumpVersions(rootDir, newVersion) { | ||
| const rootPkgPath = path.join(rootDir, "package.json"); | ||
| const rootPkg = JSON.parse(fs.readFileSync(rootPkgPath, "utf-8")); | ||
| const workspaces = rootPkg.workspaces; | ||
|
|
||
| if (!workspaces || !Array.isArray(workspaces)) { | ||
| throw new Error("Could not find workspaces in root package.json"); | ||
| } | ||
|
|
||
| // Read all workspace package.json files upfront. | ||
| // This ensures we fail early if any workspace is unreadable, | ||
| // before writing any changes (no partial updates). | ||
| const workspacePackages = []; | ||
| const workspaceNames = new Set(); | ||
| for (const workspace of workspaces) { | ||
| const pkgPath = path.join(rootDir, workspace, "package.json"); | ||
| const pkg = readJson(pkgPath); | ||
| workspaceNames.add(pkg.name); | ||
| workspacePackages.push({ pkgPath, pkg }); | ||
| } | ||
|
|
||
| // Apply version bumps | ||
| for (const { pkgPath, pkg } of workspacePackages) { | ||
| pkg.version = newVersion; | ||
|
|
||
| // Update internal workspace dependency versions (exact, no ^) | ||
| // This covers dependencies, devDependencies, and peerDependencies | ||
| for (const depType of ["dependencies", "devDependencies", "peerDependencies"]) { | ||
| if (!pkg[depType]) { | ||
| continue; | ||
| } | ||
|
|
||
| for (const [dep, ver] of Object.entries(pkg[depType])) { | ||
| // Update all workspace dependencies to the new exact version, | ||
| // matching lerna's --force-publish --exact behavior | ||
| if (workspaceNames.has(dep) && !ver.startsWith("workspace:")) { | ||
| pkg[depType][dep] = newVersion; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); | ||
| } | ||
|
|
||
| return workspacePackages.length; | ||
| } | ||
|
|
||
| // CLI entry point | ||
| if (require.main === module) { | ||
| const newVersion = process.argv[2]; | ||
|
|
||
| if (!newVersion) { | ||
| console.error("Usage: node scripts/bump-version.js <new-version>"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const rootDir = path.join(__dirname, ".."); | ||
| const updatedCount = bumpVersions(rootDir, newVersion); | ||
|
|
||
| // Write a .version file used by the gitflow sync workflow to detect version bumps | ||
| const versionFile = { | ||
| _comment: | ||
| "Auto-generated by scripts/bump-version.js. Used by the gitflow sync workflow to detect version bumps. Do not edit manually.", | ||
| version: newVersion, | ||
| }; | ||
| fs.writeFileSync( | ||
| path.join(rootDir, ".version.json"), | ||
| JSON.stringify(versionFile, null, 2) + "\n" | ||
| ); | ||
|
|
||
| console.log(`Updated ${updatedCount} packages to version ${newVersion}`); | ||
| } | ||
|
|
||
| module.exports = { bumpVersions }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.