mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Set vscodeCommitId in package.json to track which vscode commit the package has been built from.
This commit is contained in:
parent
71ac097e61
commit
ccb646cca9
7 changed files with 75 additions and 15 deletions
|
|
@ -34,7 +34,7 @@ extends:
|
||||||
- script: npm ci
|
- script: npm ci
|
||||||
displayName: Install NPM dependencies
|
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
|
displayName: Setup, Build & Test monaco-editor-core
|
||||||
|
|
||||||
tag: next
|
tag: next
|
||||||
|
|
@ -48,7 +48,7 @@ extends:
|
||||||
- script: npm ci
|
- script: npm ci
|
||||||
displayName: Install NPM dependencies
|
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
|
displayName: Setup, Build & Test monaco-editor
|
||||||
|
|
||||||
tag: next
|
tag: next
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ extends:
|
||||||
- script: npm ci
|
- script: npm ci
|
||||||
displayName: Install NPM dependencies
|
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
|
displayName: Setup, Build & Test monaco-editor-core
|
||||||
|
|
||||||
tag: latest
|
tag: latest
|
||||||
|
|
@ -50,7 +50,7 @@ extends:
|
||||||
- script: npm ci
|
- script: npm ci
|
||||||
displayName: Install NPM dependencies
|
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
|
displayName: Setup, Build & Test monaco-editor
|
||||||
|
|
||||||
tag: latest
|
tag: latest
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { mkdir, rm } from 'fs/promises';
|
import { mkdir, rm } from 'fs/promises';
|
||||||
import { join, resolve } from 'path';
|
import { join, resolve } from 'path';
|
||||||
import { group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib';
|
import { group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib';
|
||||||
|
import { PackageJson } from './types';
|
||||||
|
|
||||||
const selfPath = __dirname;
|
const selfPath = __dirname;
|
||||||
const rootPath = join(selfPath, '..', '..');
|
const rootPath = join(selfPath, '..', '..');
|
||||||
|
|
@ -37,9 +38,17 @@ async function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string
|
||||||
|
|
||||||
await rm(dependenciesPath, { force: true, recursive: true });
|
await rm(dependenciesPath, { force: true, recursive: true });
|
||||||
|
|
||||||
|
let vscodeCommitId: string;
|
||||||
|
|
||||||
await group('Checkout vscode', async () => {
|
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 group('Checkout vscode-loc', async () => {
|
||||||
await gitShallowClone(
|
await gitShallowClone(
|
||||||
// Must be a sibling to the vscode repository
|
// Must be a sibling to the vscode repository
|
||||||
|
|
@ -54,8 +63,10 @@ async function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string
|
||||||
vscodePath,
|
vscodePath,
|
||||||
'./build/monaco/package.json'
|
'./build/monaco/package.json'
|
||||||
);
|
);
|
||||||
const packageJson = require(monacoEditorCorePackageJsonSourcePath) as { version: string };
|
const packageJson = require(monacoEditorCorePackageJsonSourcePath) as PackageJson;
|
||||||
packageJson.version = version;
|
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);
|
await writeJsonFile(monacoEditorCorePackageJsonSourcePath, packageJson);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1,15 +1,22 @@
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import { join, resolve } from 'path';
|
import { join, resolve } from 'path';
|
||||||
import { getNightlyVersion, group, run, writeJsonFile } from '../lib';
|
import { getNightlyVersion, group, run, writeJsonFile } from '../lib';
|
||||||
|
import { PackageJson } from './types';
|
||||||
|
|
||||||
const selfPath = __dirname;
|
const selfPath = __dirname;
|
||||||
const rootPath = join(selfPath, '..', '..');
|
const rootPath = join(selfPath, '..', '..');
|
||||||
const monacoEditorPackageJsonPath = resolve(rootPath, 'package.json');
|
const monacoEditorPackageJsonPath = resolve(rootPath, 'package.json');
|
||||||
|
const monacoEditorCorePackageJsonPath = resolve(
|
||||||
|
rootPath,
|
||||||
|
'node_modules',
|
||||||
|
'monaco-editor-core',
|
||||||
|
'package.json'
|
||||||
|
);
|
||||||
|
|
||||||
async function prepareMonacoEditorReleaseStableOrNightly() {
|
async function prepareMonacoEditorReleaseStableOrNightly() {
|
||||||
const monacoEditorPackageJson = JSON.parse(
|
const monacoEditorPackageJson = JSON.parse(
|
||||||
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
|
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
|
||||||
) as { version: string };
|
) as PackageJson;
|
||||||
|
|
||||||
let version: string;
|
let version: string;
|
||||||
|
|
||||||
|
|
@ -27,18 +34,32 @@ async function prepareMonacoEditorReleaseStableOrNightly() {
|
||||||
// npm package is now in ./release, ready to be published
|
// 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 group('npm ci', async () => {
|
||||||
await run('npm ci', { cwd: resolve(rootPath, 'webpack-plugin') });
|
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(
|
const packageJson = JSON.parse(
|
||||||
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
|
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
|
||||||
) as { version: string; devDependencies: Record<string, string> };
|
) as PackageJson;
|
||||||
packageJson.version = version;
|
packageJson.version = monacoEditorCoreVersion;
|
||||||
packageJson.devDependencies['monaco-editor-core'] = version;
|
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 writeJsonFile(monacoEditorPackageJsonPath, packageJson);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# execute `npm install` to pick up local monaco-editor-core
|
|
||||||
npm install
|
|
||||||
# Install OS Dependencies for Playwright
|
# Install OS Dependencies for Playwright
|
||||||
sudo npm run playwright-install-deps
|
sudo npm run playwright-install-deps
|
||||||
# Check prettier
|
# Check prettier
|
||||||
|
|
|
||||||
6
scripts/ci/types.ts
Normal file
6
scripts/ci/types.ts
Normal file
|
|
@ -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 });
|
await mkdir(targetPath, { recursive: true });
|
||||||
const options: RunOptions = { cwd: targetPath };
|
const options: RunOptions = { cwd: targetPath };
|
||||||
await run('git init', options);
|
await run('git init', options);
|
||||||
await run(`git remote add origin ${repositoryUrl}`, options);
|
await run(`git remote add origin ${repositoryUrl}`, options);
|
||||||
await run(`git fetch --depth 1 origin ${ref}`, options);
|
await run(`git fetch --depth 1 origin ${ref}`, options);
|
||||||
await run(`git checkout ${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> {
|
export async function group(name: string, body: () => Promise<void>): Promise<void> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue