| | |
| | |
| | |
| | |
| | |
| |
|
| | import { execSync } from 'node:child_process'; |
| | import { readFileSync, writeFileSync } from 'node:fs'; |
| | import { resolve } from 'node:path'; |
| |
|
| | |
| |
|
| | function run(command) { |
| | console.log(`> ${command}`); |
| | execSync(command, { stdio: 'inherit' }); |
| | } |
| |
|
| | function readJson(filePath) { |
| | return JSON.parse(readFileSync(filePath, 'utf-8')); |
| | } |
| |
|
| | function writeJson(filePath, data) { |
| | writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n'); |
| | } |
| |
|
| | |
| | const versionType = process.argv[2]; |
| | if (!versionType) { |
| | console.error('Error: No version type specified.'); |
| | console.error('Usage: npm run version <patch|minor|major|prerelease>'); |
| | process.exit(1); |
| | } |
| |
|
| | |
| | run(`npm version ${versionType} --no-git-tag-version --allow-same-version`); |
| |
|
| | |
| | const workspacesToExclude = []; |
| | const lsOutput = JSON.parse( |
| | execSync('npm ls --workspaces --json --depth=0').toString(), |
| | ); |
| | const allWorkspaces = Object.keys(lsOutput.dependencies || {}); |
| | const workspacesToVersion = allWorkspaces.filter( |
| | (wsName) => !workspacesToExclude.includes(wsName), |
| | ); |
| |
|
| | for (const workspaceName of workspacesToVersion) { |
| | run( |
| | `npm version ${versionType} --workspace ${workspaceName} --no-git-tag-version --allow-same-version`, |
| | ); |
| | } |
| |
|
| | |
| | const rootPackageJsonPath = resolve(process.cwd(), 'package.json'); |
| | const newVersion = readJson(rootPackageJsonPath).version; |
| |
|
| | |
| | const rootPackageJson = readJson(rootPackageJsonPath); |
| | if (rootPackageJson.config?.sandboxImageUri) { |
| | rootPackageJson.config.sandboxImageUri = |
| | rootPackageJson.config.sandboxImageUri.replace(/:.*$/, `:${newVersion}`); |
| | console.log(`Updated sandboxImageUri in root to use version ${newVersion}`); |
| | writeJson(rootPackageJsonPath, rootPackageJson); |
| | } |
| |
|
| | |
| | const cliPackageJsonPath = resolve(process.cwd(), 'packages/cli/package.json'); |
| | const cliPackageJson = readJson(cliPackageJsonPath); |
| | if (cliPackageJson.config?.sandboxImageUri) { |
| | cliPackageJson.config.sandboxImageUri = |
| | cliPackageJson.config.sandboxImageUri.replace(/:.*$/, `:${newVersion}`); |
| | console.log( |
| | `Updated sandboxImageUri in cli package to use version ${newVersion}`, |
| | ); |
| | writeJson(cliPackageJsonPath, cliPackageJson); |
| | } |
| |
|
| | |
| | run('npm install'); |
| |
|
| | console.log(`Successfully bumped versions to v${newVersion}.`); |
| |
|