Set vscodeCommitId in package.json to track which vscode commit the package has been built from.

This commit is contained in:
Henning Dieterichs 2023-02-09 16:13:46 +01:00
parent 71ac097e61
commit ccb646cca9
No known key found for this signature in database
GPG key ID: 771381EFFDB9EC06
7 changed files with 75 additions and 15 deletions

View file

@ -0,0 +1,71 @@
import { readFile } from 'fs/promises';
import { join, resolve } from 'path';
import { getNightlyVersion, group, run, writeJsonFile } from '../lib';
import { PackageJson } from './types';
const selfPath = __dirname;
const rootPath = join(selfPath, '..', '..');
const monacoEditorPackageJsonPath = resolve(rootPath, 'package.json');
const monacoEditorCorePackageJsonPath = resolve(
rootPath,
'node_modules',
'monaco-editor-core',
'package.json'
);
async function prepareMonacoEditorReleaseStableOrNightly() {
const monacoEditorPackageJson = JSON.parse(
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
) as PackageJson;
let version: string;
const arg = process.argv[2];
if (arg === 'stable') {
version = monacoEditorPackageJson.version;
} else if (arg === 'nightly') {
version = getNightlyVersion(monacoEditorPackageJson.version);
} else {
throw new Error('Invalid argument');
}
await prepareMonacoEditorRelease(version);
// npm package is now in ./release, ready to be published
}
async function prepareMonacoEditorRelease(monacoEditorCoreVersion: string) {
await group('npm ci', async () => {
await run('npm ci', { cwd: resolve(rootPath, 'webpack-plugin') });
});
await group('Set Version & Update monaco-editor-core Version', async () => {
const packageJson = JSON.parse(
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
) as PackageJson;
packageJson.version = monacoEditorCoreVersion;
packageJson.devDependencies['monaco-editor-core'] = monacoEditorCoreVersion;
await writeJsonFile(monacoEditorPackageJsonPath, packageJson);
});
await group('npm install to pick up monaco-editor-core', async () => {
await run('npm install', { cwd: rootPath });
});
await group('Setting vscode commitId from monaco-editor-core', async () => {
const monacoEditorCorePackageJson = JSON.parse(
await readFile(monacoEditorCorePackageJsonPath, { encoding: 'utf-8' })
) as PackageJson;
const packageJson = JSON.parse(
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
) as PackageJson;
packageJson.vscodeCommitId = monacoEditorCorePackageJson.vscodeCommitId;
await writeJsonFile(monacoEditorPackageJsonPath, packageJson);
});
await group('Building & Testing', async () => {
await run(resolve(selfPath, './monaco-editor.sh'), { cwd: rootPath });
});
}
prepareMonacoEditorReleaseStableOrNightly();