mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 03:28:33 -05:00
Merge from vscode 10492ba146318412cbee8b76a8c630f226914734
This commit is contained in:
@@ -6,7 +6,97 @@
|
||||
import * as minimist from 'minimist';
|
||||
import * as os from 'os';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
|
||||
export interface ParsedArgs {
|
||||
_: string[];
|
||||
'folder-uri'?: string[]; // undefined or array of 1 or more
|
||||
'file-uri'?: string[]; // undefined or array of 1 or more
|
||||
_urls?: string[];
|
||||
help?: boolean;
|
||||
version?: boolean;
|
||||
telemetry?: boolean;
|
||||
status?: boolean;
|
||||
wait?: boolean;
|
||||
waitMarkerFilePath?: string;
|
||||
diff?: boolean;
|
||||
add?: boolean;
|
||||
goto?: boolean;
|
||||
'new-window'?: boolean;
|
||||
'unity-launch'?: boolean; // Always open a new window, except if opening the first window or opening a file or folder as part of the launch.
|
||||
'reuse-window'?: boolean;
|
||||
locale?: string;
|
||||
'user-data-dir'?: string;
|
||||
'prof-startup'?: boolean;
|
||||
'prof-startup-prefix'?: string;
|
||||
'prof-append-timers'?: string;
|
||||
verbose?: boolean;
|
||||
trace?: boolean;
|
||||
'trace-category-filter'?: string;
|
||||
'trace-options'?: string;
|
||||
log?: string;
|
||||
logExtensionHostCommunication?: boolean;
|
||||
'extensions-dir'?: string;
|
||||
'builtin-extensions-dir'?: string;
|
||||
extensionDevelopmentPath?: string[]; // // undefined or array of 1 or more local paths or URIs
|
||||
extensionTestsPath?: string; // either a local path or a URI
|
||||
'inspect-extensions'?: string;
|
||||
'inspect-brk-extensions'?: string;
|
||||
debugId?: string;
|
||||
'inspect-search'?: string;
|
||||
'inspect-brk-search'?: string;
|
||||
'disable-extensions'?: boolean;
|
||||
'disable-extension'?: string[]; // undefined or array of 1 or more
|
||||
'list-extensions'?: boolean;
|
||||
'show-versions'?: boolean;
|
||||
'category'?: string;
|
||||
'install-extension'?: string[]; // undefined or array of 1 or more
|
||||
'uninstall-extension'?: string[]; // undefined or array of 1 or more
|
||||
'locate-extension'?: string[]; // undefined or array of 1 or more
|
||||
'enable-proposed-api'?: string[]; // undefined or array of 1 or more
|
||||
'open-url'?: boolean;
|
||||
'skip-getting-started'?: boolean;
|
||||
'disable-restore-windows'?: boolean;
|
||||
'disable-telemetry'?: boolean;
|
||||
'export-default-configuration'?: string;
|
||||
'install-source'?: string;
|
||||
'disable-updates'?: boolean;
|
||||
'disable-crash-reporter'?: boolean;
|
||||
'skip-add-to-recently-opened'?: boolean;
|
||||
'max-memory'?: string;
|
||||
'file-write'?: boolean;
|
||||
'file-chmod'?: boolean;
|
||||
'driver'?: string;
|
||||
'driver-verbose'?: boolean;
|
||||
remote?: string;
|
||||
'disable-user-env-probe'?: boolean;
|
||||
'force'?: boolean;
|
||||
'force-user-env'?: boolean;
|
||||
'sync'?: 'on' | 'off';
|
||||
|
||||
// {{SQL CARBON EDIT}} Start
|
||||
aad?: boolean;
|
||||
database?: string;
|
||||
integrated?: boolean;
|
||||
server?: string;
|
||||
user?: string;
|
||||
command?: string;
|
||||
// {{SQL CARBON EDIT}} End
|
||||
|
||||
// chromium command line args: https://electronjs.org/docs/all#supported-chrome-command-line-switches
|
||||
'no-proxy-server'?: boolean;
|
||||
'proxy-server'?: string;
|
||||
'proxy-bypass-list'?: string;
|
||||
'proxy-pac-url'?: string;
|
||||
'inspect'?: string;
|
||||
'inspect-brk'?: string;
|
||||
'js-flags'?: string;
|
||||
'disable-gpu'?: boolean;
|
||||
'nolazy'?: boolean;
|
||||
'force-device-scale-factor'?: string;
|
||||
'force-renderer-accessibility'?: boolean;
|
||||
'ignore-certificate-errors'?: boolean;
|
||||
'allow-insecure-localhost'?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This code is also used by standalone cli's. Avoid adding any other dependencies.
|
||||
@@ -89,8 +179,6 @@ export const OPTIONS: OptionDescriptions<Required<ParsedArgs>> = {
|
||||
'driver': { type: 'string' },
|
||||
'logExtensionHostCommunication': { type: 'boolean' },
|
||||
'skip-getting-started': { type: 'boolean' },
|
||||
'skip-release-notes': { type: 'boolean' },
|
||||
'sticky-quickinput': { type: 'boolean' },
|
||||
'disable-restore-windows': { type: 'boolean' },
|
||||
'disable-telemetry': { type: 'boolean' },
|
||||
'disable-updates': { type: 'boolean' },
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
import * as assert from 'assert';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ParsedArgs } from '../common/environment';
|
||||
import { MIN_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/node/files';
|
||||
import { parseArgs, ErrorReporter, OPTIONS } from 'vs/platform/environment/node/argv';
|
||||
import { parseArgs, ErrorReporter, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
|
||||
function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): ParsedArgs {
|
||||
const errorReporter: ErrorReporter = {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEnvironmentService, ParsedArgs, IDebugParams, IExtensionHostDebugParams, BACKUPS } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService, IDebugParams, IExtensionHostDebugParams, BACKUPS } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import * as crypto from 'crypto';
|
||||
import * as paths from 'vs/base/node/paths';
|
||||
import * as os from 'os';
|
||||
@@ -16,64 +17,37 @@ import { isWindows, isLinux } from 'vs/base/common/platform';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
// Read this before there's any chance it is overwritten
|
||||
// Related to https://github.com/Microsoft/vscode/issues/30624
|
||||
export const xdgRuntimeDir = process.env['XDG_RUNTIME_DIR'];
|
||||
export interface INativeEnvironmentService extends IEnvironmentService {
|
||||
args: ParsedArgs;
|
||||
|
||||
function getNixIPCHandle(userDataPath: string, type: string): string {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
appRoot: string;
|
||||
execPath: string;
|
||||
|
||||
if (xdgRuntimeDir && !vscodePortable) {
|
||||
const scope = crypto.createHash('md5').update(userDataPath).digest('hex').substr(0, 8);
|
||||
return path.join(xdgRuntimeDir, `vscode-${scope}-${product.version}-${type}.sock`);
|
||||
}
|
||||
appSettingsHome: URI;
|
||||
userDataPath: string;
|
||||
userHome: URI;
|
||||
machineSettingsResource: URI;
|
||||
backupWorkspacesPath: string;
|
||||
nodeCachedDataDir?: string;
|
||||
|
||||
return path.join(userDataPath, `${product.version}-${type}.sock`);
|
||||
mainIPCHandle: string;
|
||||
sharedIPCHandle: string;
|
||||
|
||||
installSourcePath: string;
|
||||
|
||||
extensionsPath?: string;
|
||||
builtinExtensionsPath: string;
|
||||
|
||||
globalStorageHome: string;
|
||||
workspaceStorageHome: string;
|
||||
|
||||
driverHandle?: string;
|
||||
driverVerbose: boolean;
|
||||
|
||||
disableUpdates: boolean;
|
||||
}
|
||||
|
||||
function getWin32IPCHandle(userDataPath: string, type: string): string {
|
||||
const scope = crypto.createHash('md5').update(userDataPath).digest('hex');
|
||||
|
||||
return `\\\\.\\pipe\\${scope}-${product.version}-${type}-sock`;
|
||||
}
|
||||
|
||||
function getIPCHandle(userDataPath: string, type: string): string {
|
||||
if (isWindows) {
|
||||
return getWin32IPCHandle(userDataPath, type);
|
||||
}
|
||||
|
||||
return getNixIPCHandle(userDataPath, type);
|
||||
}
|
||||
|
||||
function getCLIPath(execPath: string, appRoot: string, isBuilt: boolean): string {
|
||||
|
||||
// Windows
|
||||
if (isWindows) {
|
||||
if (isBuilt) {
|
||||
return path.join(path.dirname(execPath), 'bin', `${product.applicationName}.cmd`);
|
||||
}
|
||||
|
||||
return path.join(appRoot, 'scripts', 'code-cli.bat');
|
||||
}
|
||||
|
||||
// Linux
|
||||
if (isLinux) {
|
||||
if (isBuilt) {
|
||||
return path.join(path.dirname(execPath), 'bin', `${product.applicationName}`);
|
||||
}
|
||||
|
||||
return path.join(appRoot, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
// macOS
|
||||
if (isBuilt) {
|
||||
return path.join(appRoot, 'bin', 'code');
|
||||
}
|
||||
|
||||
return path.join(appRoot, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
export class EnvironmentService implements IEnvironmentService {
|
||||
export class EnvironmentService implements INativeEnvironmentService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
@@ -90,7 +64,7 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
readonly logsPath: string;
|
||||
|
||||
@memoize
|
||||
get userHome(): string { return os.homedir(); }
|
||||
get userHome(): URI { return URI.file(os.homedir()); }
|
||||
|
||||
@memoize
|
||||
get userDataPath(): string {
|
||||
@@ -117,6 +91,9 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
@memoize
|
||||
get userDataSyncLogResource(): URI { return URI.file(path.join(this.logsPath, 'userDataSync.log')); }
|
||||
|
||||
@memoize
|
||||
get sync(): 'on' | 'off' { return this.args.sync === 'off' ? 'off' : 'on'; }
|
||||
|
||||
@memoize
|
||||
get machineSettingsResource(): URI { return resources.joinPath(URI.file(path.join(this.userDataPath, 'Machine')), 'settings.json'); }
|
||||
|
||||
@@ -139,7 +116,7 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
return URI.file(path.join(vscodePortable, 'argv.json'));
|
||||
}
|
||||
|
||||
return URI.file(path.join(this.userHome, product.dataFolderName, 'argv.json'));
|
||||
return resources.joinPath(this.userHome, product.dataFolderName, 'argv.json');
|
||||
}
|
||||
|
||||
@memoize
|
||||
@@ -188,7 +165,7 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
return path.join(vscodePortable, 'extensions');
|
||||
}
|
||||
|
||||
return path.join(this.userHome, product.dataFolderName, 'extensions');
|
||||
return resources.joinPath(this.userHome, product.dataFolderName, 'extensions').fsPath;
|
||||
}
|
||||
|
||||
@memoize
|
||||
@@ -252,7 +229,7 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
|
||||
get isBuilt(): boolean { return !process.env['VSCODE_DEV']; }
|
||||
get verbose(): boolean { return !!this._args.verbose; }
|
||||
get log(): string | undefined { return this._args.log; }
|
||||
get logLevel(): string | undefined { return this._args.log; }
|
||||
|
||||
@memoize
|
||||
get mainIPCHandle(): string { return getIPCHandle(this.userDataPath, 'main'); }
|
||||
@@ -272,6 +249,8 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
get driverHandle(): string | undefined { return this._args['driver']; }
|
||||
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
|
||||
|
||||
get disableTelemetry(): boolean { return !!this._args['disable-telemetry']; }
|
||||
|
||||
constructor(private _args: ParsedArgs, private _execPath: string) {
|
||||
if (!process.env['VSCODE_LOGS']) {
|
||||
const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '');
|
||||
@@ -288,6 +267,63 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
}
|
||||
}
|
||||
|
||||
// Read this before there's any chance it is overwritten
|
||||
// Related to https://github.com/Microsoft/vscode/issues/30624
|
||||
export const xdgRuntimeDir = process.env['XDG_RUNTIME_DIR'];
|
||||
|
||||
function getNixIPCHandle(userDataPath: string, type: string): string {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
|
||||
if (xdgRuntimeDir && !vscodePortable) {
|
||||
const scope = crypto.createHash('md5').update(userDataPath).digest('hex').substr(0, 8);
|
||||
return path.join(xdgRuntimeDir, `vscode-${scope}-${product.version}-${type}.sock`);
|
||||
}
|
||||
|
||||
return path.join(userDataPath, `${product.version}-${type}.sock`);
|
||||
}
|
||||
|
||||
function getWin32IPCHandle(userDataPath: string, type: string): string {
|
||||
const scope = crypto.createHash('md5').update(userDataPath).digest('hex');
|
||||
|
||||
return `\\\\.\\pipe\\${scope}-${product.version}-${type}-sock`;
|
||||
}
|
||||
|
||||
function getIPCHandle(userDataPath: string, type: string): string {
|
||||
if (isWindows) {
|
||||
return getWin32IPCHandle(userDataPath, type);
|
||||
}
|
||||
|
||||
return getNixIPCHandle(userDataPath, type);
|
||||
}
|
||||
|
||||
function getCLIPath(execPath: string, appRoot: string, isBuilt: boolean): string {
|
||||
|
||||
// Windows
|
||||
if (isWindows) {
|
||||
if (isBuilt) {
|
||||
return path.join(path.dirname(execPath), 'bin', `${product.applicationName}.cmd`);
|
||||
}
|
||||
|
||||
return path.join(appRoot, 'scripts', 'code-cli.bat');
|
||||
}
|
||||
|
||||
// Linux
|
||||
if (isLinux) {
|
||||
if (isBuilt) {
|
||||
return path.join(path.dirname(execPath), 'bin', `${product.applicationName}`);
|
||||
}
|
||||
|
||||
return path.join(appRoot, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
// macOS
|
||||
if (isBuilt) {
|
||||
return path.join(appRoot, 'bin', 'code');
|
||||
}
|
||||
|
||||
return path.join(appRoot, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): IExtensionHostDebugParams {
|
||||
return parseDebugPort(args['inspect-extensions'], args['inspect-brk-extensions'], 5870, isBuild, args.debugId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user