Merge vscode source through 1.62 release (#19981)

* Build breaks 1

* Build breaks

* Build breaks

* Build breaks

* More build breaks

* Build breaks (#2512)

* Runtime breaks

* Build breaks

* Fix dialog location break

* Update typescript

* Fix ASAR break issue

* Unit test breaks

* Update distro

* Fix breaks in ADO builds (#2513)

* Bump to node 16

* Fix hygiene errors

* Bump distro

* Remove reference to node type

* Delete vscode specific extension

* Bump to node 16 in CI yaml

* Skip integration tests in CI builds (while fixing)

* yarn.lock update

* Bump moment dependency in remote yarn

* Fix drop-down chevron style

* Bump to node 16

* Remove playwrite from ci.yaml

* Skip building build scripts in hygine check
This commit is contained in:
Karl Burtram
2022-07-11 14:09:32 -07:00
committed by GitHub
parent fa0fcef303
commit 26455e9113
1876 changed files with 72050 additions and 37997 deletions

View File

@@ -86,8 +86,11 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
'extensionDevelopmentPath': { type: 'string[]' },
'extensionDevelopmentKind': { type: 'string[]' },
'extensionTestsPath': { type: 'string' },
'extensionEnvironment': { type: 'string' },
'debugId': { type: 'string' },
'debugRenderer': { type: 'boolean' },
'inspect-ptyhost': { type: 'string' },
'inspect-brk-ptyhost': { type: 'string' },
'inspect-search': { type: 'string', deprecates: 'debugSearch' },
'inspect-brk-search': { type: 'string', deprecates: 'debugBrkSearch' },
'export-default-configuration': { type: 'string' },

View File

@@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import { spawn } from 'child_process';
import * as path from 'path';
import { basename } from 'vs/base/common/path';
import { localize } from 'vs/nls';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { canceled, isPromiseCanceledError } from 'vs/base/common/errors';
@@ -14,11 +15,25 @@ import { getSystemShell } from 'vs/base/node/shell';
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { isLaunchedFromCli } from 'vs/platform/environment/node/argvHelper';
import { ILogService } from 'vs/platform/log/common/log';
import { Promises } from 'vs/base/common/async';
/**
* The maximum of time we accept to wait on resolving the shell
* environment before giving up. This ensures we are not blocking
* other tasks from running for a too long time period.
*/
const MAX_SHELL_RESOLVE_TIME = 10000;
let unixShellEnvPromise: Promise<typeof process.env> | undefined = undefined;
/**
* We need to get the environment from a user's shell.
* This should only be done when Code itself is not launched
* from within a shell.
*
* Will throw an error if:
* - we hit a timeout of `MAX_SHELL_RESOLVE_TIME`
* - any other error from spawning a shell to figure out the environment
*/
export async function resolveShellEnv(logService: ILogService, args: NativeParsedArgs, env: IProcessEnvironment): Promise<typeof process.env> {
@@ -55,28 +70,24 @@ export async function resolveShellEnv(logService: ILogService, args: NativeParse
// subsequent calls since this operation can be
// expensive (spawns a process).
if (!unixShellEnvPromise) {
unixShellEnvPromise = new Promise(async resolve => {
unixShellEnvPromise = Promises.withAsyncBody<NodeJS.ProcessEnv>(async (resolve, reject) => {
const cts = new CancellationTokenSource();
// Give up resolving shell env after 10 seconds
// Give up resolving shell env after some time
const timeout = setTimeout(() => {
logService.error(`[resolve shell env] Could not resolve shell environment within 10 seconds. Proceeding without shell environment...`);
cts.dispose(true);
resolve({});
}, 10000);
reject(new Error(localize('resolveShellEnvTimeout', "Unable to resolve your shell environment in a reasonable time. Please review your shell configuration.")));
}, MAX_SHELL_RESOLVE_TIME);
// Resolve shell env and handle errors
try {
const shellEnv = await doResolveUnixShellEnv(logService, cts.token);
resolve(shellEnv);
resolve(await doResolveUnixShellEnv(logService, cts.token));
} catch (error) {
if (!isPromiseCanceledError(error)) {
logService.error(`[resolve shell env] Unable to resolve shell environment (${error}). Proceeding without shell environment...`);
if (!isPromiseCanceledError(error) && !cts.token.isCancellationRequested) {
reject(new Error(localize('resolveShellEnvError', "Unable to resolve your shell environment: {0}", toErrorMessage(error))));
} else {
resolve({});
}
resolve({});
} finally {
clearTimeout(timeout);
cts.dispose();
@@ -88,35 +99,33 @@ export async function resolveShellEnv(logService: ILogService, args: NativeParse
}
}
let unixShellEnvPromise: Promise<typeof process.env> | undefined = undefined;
async function doResolveUnixShellEnv(logService: ILogService, token: CancellationToken): Promise<typeof process.env> {
const promise = new Promise<typeof process.env>(async (resolve, reject) => {
const runAsNode = process.env['ELECTRON_RUN_AS_NODE'];
logService.trace('getUnixShellEnvironment#runAsNode', runAsNode);
const runAsNode = process.env['ELECTRON_RUN_AS_NODE'];
logService.trace('getUnixShellEnvironment#runAsNode', runAsNode);
const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE'];
logService.trace('getUnixShellEnvironment#noAttach', noAttach);
const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE'];
logService.trace('getUnixShellEnvironment#noAttach', noAttach);
const mark = generateUuid().replace(/-/g, '').substr(0, 12);
const regex = new RegExp(mark + '(.*)' + mark);
const mark = generateUuid().replace(/-/g, '').substr(0, 12);
const regex = new RegExp(mark + '(.*)' + mark);
const env = {
...process.env,
ELECTRON_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
};
const env = {
...process.env,
ELECTRON_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
};
logService.trace('getUnixShellEnvironment#env', env);
const systemShellUnix = await getSystemShell(OS, env);
logService.trace('getUnixShellEnvironment#shell', systemShellUnix);
logService.trace('getUnixShellEnvironment#env', env);
const systemShellUnix = await getSystemShell(OS, env);
logService.trace('getUnixShellEnvironment#shell', systemShellUnix);
return new Promise<typeof process.env>((resolve, reject) => {
if (token.isCancellationRequested) {
return reject(canceled);
return reject(canceled());
}
// handle popular non-POSIX shells
const name = path.basename(systemShellUnix);
const name = basename(systemShellUnix);
let command: string, shellArgs: Array<string>;
if (/^pwsh(-preview)?$/.test(name)) {
// Older versions of PowerShell removes double quotes sometimes so we use "double single quotes" which is how
@@ -125,7 +134,12 @@ async function doResolveUnixShellEnv(logService: ILogService, token: Cancellatio
shellArgs = ['-Login', '-Command'];
} else {
command = `'${process.execPath}' -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`;
shellArgs = ['-ilc'];
if (name === 'tcsh') {
shellArgs = ['-ic'];
} else {
shellArgs = ['-ilc'];
}
}
logService.trace('getUnixShellEnvironment#spawn', JSON.stringify(shellArgs), command);
@@ -139,12 +153,12 @@ async function doResolveUnixShellEnv(logService: ILogService, token: Cancellatio
token.onCancellationRequested(() => {
child.kill();
return reject(canceled);
return reject(canceled());
});
child.on('error', err => {
logService.error('getUnixShellEnvironment#errorChildProcess', toErrorMessage(err));
resolve({});
reject(err);
});
const buffers: Buffer[] = [];
@@ -163,7 +177,7 @@ async function doResolveUnixShellEnv(logService: ILogService, token: Cancellatio
}
if (code || signal) {
return reject(new Error(`Failed to get environment (code ${code}, signal ${signal})`));
return reject(new Error(localize('resolveShellEnvExitError', "Unexpected exit code from spawned shell (code {0}, signal {1})", code, signal)));
}
const match = regex.exec(raw);
@@ -195,12 +209,4 @@ async function doResolveUnixShellEnv(logService: ILogService, token: Cancellatio
}
});
});
try {
return await promise;
} catch (error) {
logService.error('getUnixShellEnvironment#error', toErrorMessage(error));
return {}; // ignore any errors
}
}