Skip to content

Commit 368fd26

Browse files
committed
chore: Remove lerna
1 parent f551c70 commit 368fd26

File tree

6 files changed

+562
-4852
lines changed

6 files changed

+562
-4852
lines changed

lerna.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

nx.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@
3535
"build:npm": {
3636
"dependsOn": ["build", "^build"]
3737
}
38+
},
39+
"cacheDirectory": ".nxcache",
40+
"tui": {
41+
"autoExit": true
3842
}
3943
}

package.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
"homepage": "https://github.com/getsentry/sentry-javascript-bundler-plugins",
77
"private": true,
88
"workspaces": [
9-
"packages/*"
9+
"packages/babel-plugin-component-annotate",
10+
"packages/bundler-plugin-core",
11+
"packages/dev-utils",
12+
"packages/e2e-tests",
13+
"packages/esbuild-plugin",
14+
"packages/eslint-configs",
15+
"packages/integration-tests",
16+
"packages/playground",
17+
"packages/rollup-plugin",
18+
"packages/tsconfigs",
19+
"packages/vite-plugin",
20+
"packages/webpack-plugin"
1021
],
1122
"scripts": {
1223
"build": "nx run-many --target=build --all",
@@ -26,14 +37,10 @@
2637
"fix:formatting": "oxfmt ."
2738
},
2839
"devDependencies": {
29-
"@nrwl/cli": "14.5.10",
30-
"@nrwl/workspace": "14.5.10",
31-
"lerna": "^6.6.2",
3240
"minimatch": "^10.2.2",
3341
"npm-run-all": "^4.1.5",
34-
"nx": "14.5.10",
42+
"nx": "^22.5.2",
3543
"oxfmt": "^0.33.0",
36-
"pretty-quick": "^3.1.3",
3744
"ts-node": "^10.9.2"
3845
},
3946
"volta": {

scripts/bump-version.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
function readJson(filePath) {
5+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
6+
}
7+
8+
/**
9+
* Bumps the version of all workspace packages and their internal dependencies.
10+
* This replicates the behavior of:
11+
* lerna version --force-publish --exact --no-git-tag-version --no-push --include-merged-tags --yes <newVersion>
12+
*
13+
* Specifically:
14+
* - Updates `version` in every workspace package.json to newVersion
15+
* - Updates all internal workspace dependency references (dependencies, devDependencies, peerDependencies)
16+
* to the new exact version (no ^ or ~ prefix), matching lerna's --exact flag
17+
* - --force-publish: all packages are updated regardless of whether they changed
18+
* - No git tags, commits, or pushes are made
19+
*/
20+
function bumpVersions(rootDir, newVersion) {
21+
const rootPkgPath = path.join(rootDir, 'package.json');
22+
const rootPkg = JSON.parse(fs.readFileSync(rootPkgPath, 'utf-8'));
23+
const workspaces = rootPkg.workspaces;
24+
25+
if (!workspaces || !Array.isArray(workspaces)) {
26+
throw new Error('Could not find workspaces in root package.json');
27+
}
28+
29+
// Read all workspace package.json files upfront.
30+
// This ensures we fail early if any workspace is unreadable,
31+
// before writing any changes (no partial updates).
32+
const workspacePackages = [];
33+
const workspaceNames = new Set();
34+
for (const workspace of workspaces) {
35+
const pkgPath = path.join(rootDir, workspace, 'package.json');
36+
const pkg = readJson(pkgPath);
37+
workspaceNames.add(pkg.name);
38+
workspacePackages.push({ pkgPath, pkg });
39+
}
40+
41+
// Apply version bumps
42+
for (const { pkgPath, pkg } of workspacePackages) {
43+
pkg.version = newVersion;
44+
45+
// Update internal workspace dependency versions (exact, no ^)
46+
// This covers dependencies, devDependencies, and peerDependencies
47+
for (const depType of ['dependencies', 'devDependencies', 'peerDependencies']) {
48+
if (!pkg[depType]) {
49+
continue;
50+
}
51+
52+
for (const [dep, ver] of Object.entries(pkg[depType])) {
53+
// Update all workspace dependencies to the new exact version,
54+
// matching lerna's --force-publish --exact behavior
55+
if (workspaceNames.has(dep) && !ver.startsWith('workspace:')) {
56+
pkg[depType][dep] = newVersion;
57+
}
58+
}
59+
}
60+
61+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
62+
}
63+
64+
return workspacePackages.length;
65+
}
66+
67+
// CLI entry point
68+
if (require.main === module) {
69+
const newVersion = process.argv[2];
70+
71+
if (!newVersion) {
72+
console.error('Usage: node scripts/bump-version.js <new-version>');
73+
process.exit(1);
74+
}
75+
76+
const rootDir = path.join(__dirname, '..');
77+
const updatedCount = bumpVersions(rootDir, newVersion);
78+
79+
// Write a .version file used by the gitflow sync workflow to detect version bumps
80+
const versionFile = {
81+
_comment:
82+
'Auto-generated by scripts/bump-version.js. Used by the gitflow sync workflow to detect version bumps. Do not edit manually.',
83+
version: newVersion,
84+
};
85+
fs.writeFileSync(path.join(rootDir, '.version.json'), JSON.stringify(versionFile, null, 2) + '\n');
86+
87+
console.log(`Updated ${updatedCount} packages to version ${newVersion}`);
88+
}
89+
90+
module.exports = { bumpVersions };

scripts/craft-pre-release.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,5 @@ NEW_VERSION="${2}"
1111
export npm_config_git_tag_version=false
1212

1313
yarn install --frozen-lockfile
14-
# --force-publish - force publish all packages, this will skip the lerna changed check for changed packages and forces a package that didn't have a git diff change to be updated.
15-
# --exact - specify updated dependencies in updated packages exactly (with no punctuation), instead of as semver compatible (with a ^).
16-
# --no-git-tag-version - don't commit changes to package.json files and don't tag the release.
17-
# --no-push - don't push committed and tagged changes.
18-
# --include-merged-tags - include tags from merged branches when detecting changed packages.
19-
# --yes - skip all confirmation prompts
20-
yarn lerna version --force-publish --exact --no-git-tag-version --no-push --include-merged-tags --yes "${NEW_VERSION}"
14+
# Bump version in all workspace packages (exact versions, no git tags or commits)
15+
node scripts/bump-version.js "${NEW_VERSION}"

0 commit comments

Comments
 (0)