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
9 changes: 0 additions & 9 deletions lerna.json

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-tsdoc": "^0.2.17",
"lerna": "^7.1.4",
"markdownlint": "^0.25.1",
"markdownlint-cli": "^0.31.1",
"prettier": "2.8.4",
Expand All @@ -45,7 +44,7 @@
},
"scripts": {
"build:all": "NODE_OPTIONS='--max-old-space-size=4096' yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references' 'yarn turbo run prepack'",
"build:tarball": "yarn lerna run build:tarball",
"build:tarball": "yarn turbo run build:tarball",
"test": "yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references --check' 'yarn turbo run test --concurrency=1 --continue'",
"test:watch": "yarn turbo run test:watch",
"test:update": "yarn turbo run test:update",
Expand Down
88 changes: 88 additions & 0 deletions scripts/bump-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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.
* Replicates the behavior of:
* lerna version --force-publish --exact --no-git-tag-version --no-push --yes <newVersion>
*
* - Updates `version` in every workspace package.json to newVersion
* - Updates all internal workspace dependency references to the new exact version
* - No git tags, commits, or pushes are made
*/
function bumpVersions(rootDir, newVersion) {
const rootPkgPath = path.join(rootDir, 'package.json');
const rootPkg = readJson(rootPkgPath);
const workspaceGlobs = rootPkg.workspaces;

if (!workspaceGlobs || !Array.isArray(workspaceGlobs)) {
throw new Error('Could not find workspaces array in root package.json');
}

// Resolve workspace globs to actual directories
const workspaceDirs = [];
for (const glob of workspaceGlobs) {
// Handle simple globs like "packages/*" and "packages/plugins/*"
const baseDir = glob.replace(/\/\*$/, '');
const fullBase = path.join(rootDir, baseDir);
if (!fs.existsSync(fullBase)) continue;
const entries = fs.readdirSync(fullBase, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory()) {
const pkgJsonPath = path.join(fullBase, entry.name, 'package.json');
if (fs.existsSync(pkgJsonPath)) {
workspaceDirs.push(path.join(baseDir, entry.name));
}
}
}
}

// Read all workspace package.json files upfront to fail early
const workspacePackages = [];
const workspaceNames = new Set();
for (const dir of workspaceDirs) {
const pkgPath = path.join(rootDir, dir, '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;

for (const depType of ['dependencies', 'devDependencies', 'peerDependencies']) {
if (!pkg[depType]) continue;

for (const [dep, ver] of Object.entries(pkg[depType])) {
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);
console.log(`Updated ${updatedCount} packages to version ${newVersion}`);
}

module.exports = { bumpVersions };
13 changes: 2 additions & 11 deletions scripts/craft-pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ cd $SCRIPT_DIR/..
OLD_VERSION=${CRAFT_OLD_VERSION}
NEW_VERSION=${CRAFT_NEW_VERSION}


# Do not tag and commit changes made by "npm version"
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}"
4 changes: 3 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"globalDependencies": [
".eslintrc.js",
".prettierrc",
"lerna.json",
"vite.config.defaults.ts",
"tsconfig.json"
],
Expand Down Expand Up @@ -38,6 +37,9 @@
"cache": false,
"passThroughEnv": ["CLEAR_DIST_DIR"]
},
"build:tarball": {
"dependsOn": ["prepack"]
},
Comment thread
chargome marked this conversation as resolved.
"lint": {},
"typings": {},
"check-types": {}
Expand Down
Loading
Loading