mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-19 17:58:39 +00:00
* feat: move from yarn to npm * chore: skip yarn.lock files * fix: playwright download * chore: fix compile and hygiene * chore: bump vsce@2.17.0 Refs8b49e9dfdf* test: update results for bat and sh colorizer tests * fix: add missing lock files for windows * fix: switch to legacy-peer-deps * chore: update markdown-it@14.1.0 Refs737c95a129esbuild step in extensions-ci-pr was previously using markdown-it from root which had userland punycode and was able to compile successfully. * ci: increase pr timeout for windows integration tests * chore: fix product build * build: ignore extension dev dependency for rcedit * build: fix working directory inside container * build: fix dependency generation * npm: update dependencies * ci: use global npmrc * ci: update cache * ci: setup global npmrc for private npm auth * build: fix extension bundling * chore: sync npm dependencies * ci: debug env variables for container * ci: fix win32 cli pipeline * build: fix npmrc config usage for build/ and remote/ dirs * fix: windows build * fix: container builds * fix: markdown-language-features tests and bundling ``` [03:58:22] Error: Command failed: /Users/demohan/.nvm/versions/node/v20.15.1/bin/node /Users/demohan/github/vscode/extensions/markdown-language-features/esbuild-notebook.js --outputRoot /Users/demohan/github/vscode/.build/extensions/markdown-language-features ✘ [ERROR] Could not resolve "punycode" extensions/markdown-language-features/node_modules/markdown-it/lib/index.js:14:27: 14 │ var punycode = require('punycode'); ╵ ~~~~~~~~~~ The package "punycode" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. ``` Adds userland package based onbeed9aee2c* fix: container builds for distro * chore: update yarn occurrences * fixup! chore: bump vsce@2.17.0 Uses the closest version to `main` branch that does not included3cc84cdecwhile still having the fix8b49e9dfdf* chore: sync npm dependencies * chore: sync npm dependencies * chore: sync npm dependencies * chore: throw error when yarn is used for installation * chore: add review feedback * chore: switch exec => run where needed * chore: npm sync dependencies * fix: markdown-language-features bundling ``` ✘ [ERROR] Could not resolve "punycode" extensions/markdown-language-features/node_modules/markdown-it/lib/index.js:14:27: 14 │ var punycode = require('punycode'); ╵ ~~~~~~~~~~ The package "punycode" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. ``` Adds missing userland package based on markdown-it/markdown-it@beed9ae, can be removed once we update markdown-it >= 14.1.0 * ci: rename no-yarn-lock-changes.yml * chore: sync npm dependencies * ci: restore no-yarn-lock-changes.yml We can disable it in a separate PR to keep the required checks happy and also need workflow edit perms. * chore: sync npm dependencies * ci: rebuild cache * ci: fix no-package-lock-changes.yml * chore: bump distro * chore: rm yarn.lock files * chore: rm yarn.lock files without dependencies * chore: add vscode-selfhost-import-aid to postinstall dirs * chore: bump distro
142 lines
4.5 KiB
JavaScript
142 lines
4.5 KiB
JavaScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const cp = require('child_process');
|
|
const { dirs } = require('./dirs');
|
|
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
const root = path.dirname(path.dirname(__dirname));
|
|
|
|
function log(dir, message) {
|
|
if (process.stdout.isTTY) {
|
|
console.log(`\x1b[34m[${dir}]\x1b[0m`, message);
|
|
} else {
|
|
console.log(`[${dir}]`, message);
|
|
}
|
|
}
|
|
|
|
function run(command, args, opts) {
|
|
log(opts.cwd || '.', '$ ' + command + ' ' + args.join(' '));
|
|
|
|
const result = cp.spawnSync(command, args, opts);
|
|
|
|
if (result.error) {
|
|
console.error(`ERR Failed to spawn process: ${result.error}`);
|
|
process.exit(1);
|
|
} else if (result.status !== 0) {
|
|
console.error(`ERR Process exited with code: ${result.status}`);
|
|
process.exit(result.status);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {string} dir
|
|
* @param {*} [opts]
|
|
*/
|
|
function npmInstall(dir, opts) {
|
|
opts = {
|
|
env: { ...process.env },
|
|
...(opts ?? {}),
|
|
cwd: dir,
|
|
stdio: 'inherit',
|
|
shell: true
|
|
};
|
|
|
|
const command = process.env['npm_command'] || 'install';
|
|
|
|
if (process.env['VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME'] && /^(.build\/distro\/npm\/)?remote$/.test(dir)) {
|
|
const userinfo = os.userInfo();
|
|
log(dir, `Installing dependencies inside container ${process.env['VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME']}...`);
|
|
|
|
opts.cwd = root;
|
|
if (process.env['npm_config_arch'] === 'arm64') {
|
|
run('sudo', ['docker', 'run', '--rm', '--privileged', 'multiarch/qemu-user-static', '--reset', '-p', 'yes'], opts);
|
|
}
|
|
run('sudo', ['docker', 'run', '-e', 'GITHUB_TOKEN', '-v', `${process.env['VSCODE_HOST_MOUNT']}:/root/vscode`, '-v', `${process.env['VSCODE_HOST_MOUNT']}/.build/.netrc:/root/.netrc`, '-w', path.resolve('/root/vscode', dir), process.env['VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME'], 'sh', '-c', `\"chown -R root:root ${path.resolve('/root/vscode', dir)} && npm i -g node-gyp-build && npm ci\"`], opts);
|
|
run('sudo', ['chown', '-R', `${userinfo.uid}:${userinfo.gid}`, `${path.resolve(root, dir)}`], opts);
|
|
} else {
|
|
log(dir, 'Installing dependencies...');
|
|
run(npm, [command], opts);
|
|
}
|
|
}
|
|
|
|
function setNpmrcConfig(dir, env) {
|
|
const npmrcPath = path.join(root, dir, '.npmrc');
|
|
const lines = fs.readFileSync(npmrcPath, 'utf8').split('\n');
|
|
|
|
for (const line of lines) {
|
|
const trimmedLine = line.trim();
|
|
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
|
const [key, value] = trimmedLine.split('=');
|
|
env[`npm_config_${key}`] = value.replace(/^"(.*)"$/, '$1');
|
|
}
|
|
}
|
|
|
|
if (dir === 'build') {
|
|
env['npm_config_target'] = process.versions.node;
|
|
env['npm_config_arch'] = process.arch;
|
|
}
|
|
}
|
|
|
|
for (let dir of dirs) {
|
|
|
|
if (dir === '') {
|
|
// already executed in root
|
|
continue;
|
|
}
|
|
|
|
let opts;
|
|
|
|
if (dir === 'build') {
|
|
opts = {
|
|
env: {
|
|
...process.env
|
|
},
|
|
}
|
|
if (process.env['CC']) { opts.env['CC'] = 'gcc'; }
|
|
if (process.env['CXX']) { opts.env['CXX'] = 'g++'; }
|
|
if (process.env['CXXFLAGS']) { opts.env['CXXFLAGS'] = ''; }
|
|
if (process.env['LDFLAGS']) { opts.env['LDFLAGS'] = ''; }
|
|
|
|
setNpmrcConfig('build', opts.env);
|
|
npmInstall('build', opts);
|
|
continue;
|
|
}
|
|
|
|
if (/^(.build\/distro\/npm\/)?remote$/.test(dir)) {
|
|
// node modules used by vscode server
|
|
opts = {
|
|
env: {
|
|
...process.env
|
|
},
|
|
}
|
|
if (process.env['VSCODE_REMOTE_CC']) {
|
|
opts.env['CC'] = process.env['VSCODE_REMOTE_CC'];
|
|
} else {
|
|
delete opts.env['CC'];
|
|
}
|
|
if (process.env['VSCODE_REMOTE_CXX']) {
|
|
opts.env['CXX'] = process.env['VSCODE_REMOTE_CXX'];
|
|
} else {
|
|
delete opts.env['CXX'];
|
|
}
|
|
if (process.env['CXXFLAGS']) { delete opts.env['CXXFLAGS']; }
|
|
if (process.env['CFLAGS']) { delete opts.env['CFLAGS']; }
|
|
if (process.env['LDFLAGS']) { delete opts.env['LDFLAGS']; }
|
|
if (process.env['VSCODE_REMOTE_CXXFLAGS']) { opts.env['CXXFLAGS'] = process.env['VSCODE_REMOTE_CXXFLAGS']; }
|
|
if (process.env['VSCODE_REMOTE_LDFLAGS']) { opts.env['LDFLAGS'] = process.env['VSCODE_REMOTE_LDFLAGS']; }
|
|
if (process.env['VSCODE_REMOTE_NODE_GYP']) { opts.env['npm_config_node_gyp'] = process.env['VSCODE_REMOTE_NODE_GYP']; }
|
|
|
|
setNpmrcConfig('remote', opts.env);
|
|
}
|
|
|
|
npmInstall(dir, opts);
|
|
}
|
|
|
|
cp.execSync('git config pull.rebase merges');
|
|
cp.execSync('git config blame.ignoreRevsFile .git-blame-ignore-revs');
|