Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log
*.tgz

.nxcache
.nx
packages/**/yarn.lock

.DS_Store
Expand Down
6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

22 changes: 10 additions & 12 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test"],
"cacheDirectory": ".nxcache"
}
}
},
"namedInputs": {
"sharedGlobals": ["{workspaceRoot}/*.js", "{workspaceRoot}/*.json", "{workspaceRoot}/yarn.lock"]
},
"targetDefaults": {
"build": {
"inputs": ["sharedGlobals"],
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist"]
"outputs": ["{projectRoot}/dist"],
"cache": true
},
"lint": {
"inputs": ["sharedGlobals"],
"dependsOn": ["^build", "build"],
"outputs": []
"outputs": [],
"cache": true
},
"test": {
"inputs": ["sharedGlobals"],
"outputs": []
"outputs": [],
"cache": true
},
"check:types": {
"inputs": ["sharedGlobals"],
Expand All @@ -35,5 +29,9 @@
"build:npm": {
"dependsOn": ["build", "^build"]
}
},
"cacheDirectory": ".nxcache",
"tui": {
"autoExit": true
}
}
19 changes: 13 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
"homepage": "https://github.com/getsentry/sentry-javascript-bundler-plugins",
"private": true,
"workspaces": [
"packages/*"
"packages/babel-plugin-component-annotate",
"packages/bundler-plugin-core",
"packages/dev-utils",
"packages/e2e-tests",
"packages/esbuild-plugin",
"packages/eslint-configs",
"packages/integration-tests",
"packages/playground",
"packages/rollup-plugin",
"packages/tsconfigs",
"packages/vite-plugin",
"packages/webpack-plugin"
],
"scripts": {
"build": "nx run-many --target=build --all",
Expand All @@ -26,14 +37,10 @@
"fix:formatting": "oxfmt ."
},
"devDependencies": {
"@nrwl/cli": "14.5.10",
"@nrwl/workspace": "14.5.10",
"lerna": "^6.6.2",
"minimatch": "^10.2.2",
"npm-run-all": "^4.1.5",
"nx": "14.5.10",
"nx": "22.5.2",
"oxfmt": "^0.33.0",
"pretty-quick": "^3.1.3",
"ts-node": "^10.9.2"
},
"volta": {
Expand Down
93 changes: 93 additions & 0 deletions scripts/bump-version.js
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 };
9 changes: 2 additions & 7 deletions scripts/craft-pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@ NEW_VERSION="${2}"
export npm_config_git_tag_version=false

yarn install --frozen-lockfile
# --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.
# --exact - specify updated dependencies in updated packages exactly (with no punctuation), instead of as semver compatible (with a ^).
# --no-git-tag-version - don't commit changes to package.json files and don't tag the release.
# --no-push - don't push committed and tagged changes.
# --include-merged-tags - include tags from merged branches when detecting changed packages.
# --yes - skip all confirmation prompts
yarn lerna version --force-publish --exact --no-git-tag-version --no-push --include-merged-tags --yes "${NEW_VERSION}"
# Bump version in all workspace packages (exact versions, no git tags or commits)
node scripts/bump-version.js "${NEW_VERSION}"
Loading
Loading