Merge pull request #3539 from microsoft/hediet/live-heron

Set vscodeCommitId in package.json to track which vscode commit the package has been built from.
pull/3540/head
Henning Dieterichs 2 years ago committed by GitHub
commit beed7d171a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,7 +34,7 @@ extends:
- script: npm ci
displayName: Install NPM dependencies
- script: yarn ts-node ./scripts/ci/prepare-monaco-editor-core nightly
- script: yarn ts-node ./scripts/ci/monaco-editor-core-prepare nightly
displayName: Setup, Build & Test monaco-editor-core
tag: next
@ -48,7 +48,7 @@ extends:
- script: npm ci
displayName: Install NPM dependencies
- script: yarn ts-node ./scripts/ci/prepare-monaco-editor nightly
- script: yarn ts-node ./scripts/ci/monaco-editor-prepare nightly
displayName: Setup, Build & Test monaco-editor
tag: next

@ -36,7 +36,7 @@ extends:
- script: npm ci
displayName: Install NPM dependencies
- script: yarn ts-node ./scripts/ci/prepare-monaco-editor-core stable
- script: yarn ts-node ./scripts/ci/monaco-editor-core-prepare stable
displayName: Setup, Build & Test monaco-editor-core
tag: latest
@ -50,7 +50,7 @@ extends:
- script: npm ci
displayName: Install NPM dependencies
- script: yarn ts-node ./scripts/ci/prepare-monaco-editor stable
- script: yarn ts-node ./scripts/ci/monaco-editor-prepare stable
displayName: Setup, Build & Test monaco-editor
tag: latest

@ -1,6 +1,7 @@
import { mkdir, rm } from 'fs/promises';
import { join, resolve } from 'path';
import { group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib';
import { PackageJson } from './types';
const selfPath = __dirname;
const rootPath = join(selfPath, '..', '..');
@ -37,9 +38,17 @@ async function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string
await rm(dependenciesPath, { force: true, recursive: true });
let vscodeCommitId: string;
await group('Checkout vscode', async () => {
await gitShallowClone(vscodePath, 'https://github.com/microsoft/vscode.git', vscodeRef);
const result = await gitShallowClone(
vscodePath,
'https://github.com/microsoft/vscode.git',
vscodeRef
);
vscodeCommitId = result.commitId;
});
await group('Checkout vscode-loc', async () => {
await gitShallowClone(
// Must be a sibling to the vscode repository
@ -54,8 +63,10 @@ async function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string
vscodePath,
'./build/monaco/package.json'
);
const packageJson = require(monacoEditorCorePackageJsonSourcePath) as { version: string };
const packageJson = require(monacoEditorCorePackageJsonSourcePath) as PackageJson;
packageJson.version = version;
// This ensures we can always figure out which commit monaco-editor-core was built from
packageJson.vscodeCommitId = vscodeCommitId;
await writeJsonFile(monacoEditorCorePackageJsonSourcePath, packageJson);
});

@ -1,15 +1,22 @@
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 { version: string };
) as PackageJson;
let version: string;
@ -27,18 +34,32 @@ async function prepareMonacoEditorReleaseStableOrNightly() {
// npm package is now in ./release, ready to be published
}
async function prepareMonacoEditorRelease(version: string) {
async function prepareMonacoEditorRelease(monacoEditorCoreVersion: string) {
await group('npm ci', async () => {
await run('npm ci', { cwd: resolve(rootPath, 'webpack-plugin') });
});
await group('Set Version', async () => {
await group('Set Version & Update monaco-editor-core Version', async () => {
const packageJson = JSON.parse(
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
) as { version: string; devDependencies: Record<string, string> };
packageJson.version = version;
packageJson.devDependencies['monaco-editor-core'] = version;
) 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);
});

@ -1,8 +1,6 @@
#!/bin/bash
set -e
# execute `npm install` to pick up local monaco-editor-core
npm install
# Install OS Dependencies for Playwright
sudo npm run playwright-install-deps
# Check prettier

@ -0,0 +1,6 @@
export interface PackageJson {
version: string;
vscodeRef?: string;
vscodeCommitId?: string;
devDependencies: Record<string, string>;
}

@ -19,13 +19,37 @@ export async function run(command: string, options: RunOptions) {
});
}
export async function gitShallowClone(targetPath: string, repositoryUrl: string, ref: string) {
export async function runGetOutput(command: string, options: RunOptions): Promise<string> {
console.log(`Running ${command} in ${options.cwd}`);
return new Promise<string>((resolve, reject) => {
const process = spawn(command, { shell: true, cwd: options.cwd, stdio: 'pipe' });
let output = '';
process.stdout.on('data', (data) => {
output += data;
});
process.on('exit', (code) => {
if (code !== 0) {
reject(new Error(`Command ${command} exited with code ${code}`));
} else {
resolve(output);
}
});
});
}
export async function gitShallowClone(
targetPath: string,
repositoryUrl: string,
ref: string
): Promise<{ commitId: string }> {
await mkdir(targetPath, { recursive: true });
const options: RunOptions = { cwd: targetPath };
await run('git init', options);
await run(`git remote add origin ${repositoryUrl}`, options);
await run(`git fetch --depth 1 origin ${ref}`, options);
await run(`git checkout ${ref}`, options);
const commitId = await runGetOutput('git rev-parse HEAD', options);
return { commitId };
}
export async function group(name: string, body: () => Promise<void>): Promise<void> {

Loading…
Cancel
Save