Skip to content
Merged
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: 6 additions & 3 deletions scripts/bump-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import * as fs from 'node:fs';
import { glob } from 'glob';
import * as path from 'node:path';
import * as yaml from 'yaml';
import { fileURLToPath } from 'node:url';

const excludes = ['packages/ide/vscode/package.json'];

const _dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));

function getWorkspacePackageJsonFiles(workspaceFile: string): string[] {
const workspaceYaml = fs.readFileSync(workspaceFile, 'utf8');
const workspace = yaml.parse(workspaceYaml) as { packages?: string[] };
Expand All @@ -23,7 +26,7 @@ function getWorkspacePackageJsonFiles(workspaceFile: string): string[] {
}

// include root package.json
files.add(path.resolve(__dirname, '../package.json'));
files.add(path.resolve(_dirname, '../package.json'));

const result = Array.from(files).filter((f) => !excludes.some((e) => f.endsWith(e)));
return result;
Expand All @@ -39,11 +42,11 @@ function incrementVersion(version: string): string {
}

// find all package.json files in the workspace
const workspaceFile = path.resolve(__dirname, '../pnpm-workspace.yaml');
const workspaceFile = path.resolve(_dirname, '../pnpm-workspace.yaml');
const packageFiles = getWorkspacePackageJsonFiles(workspaceFile);

// get version from root package.json
const rootPackageJson = path.resolve(__dirname, '../package.json');
const rootPackageJson = path.resolve(_dirname, '../package.json');
const rootPkg = JSON.parse(fs.readFileSync(rootPackageJson, 'utf8')) as { version?: string };
if (!rootPkg.version) throw new Error('No "version" key found in package.json');
const rootVersion = rootPkg.version;
Expand Down