mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 19:18:32 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -9,7 +9,6 @@ import * as assert from 'assert';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ParsedArgs } from '../common/environment';
|
||||
import product from 'vs/platform/node/product';
|
||||
|
||||
const options: minimist.Opts = {
|
||||
string: [
|
||||
@@ -23,8 +22,12 @@ const options: minimist.Opts = {
|
||||
'debugId',
|
||||
'debugPluginHost',
|
||||
'debugBrkPluginHost',
|
||||
'debugSearch',
|
||||
'debugBrkSearch',
|
||||
'open-url',
|
||||
'enable-proposed-api'
|
||||
'enable-proposed-api',
|
||||
'export-default-configuration',
|
||||
'install-source'
|
||||
],
|
||||
boolean: [
|
||||
'help',
|
||||
@@ -44,7 +47,11 @@ const options: minimist.Opts = {
|
||||
'list-extensions',
|
||||
'show-versions',
|
||||
'nolazy',
|
||||
'skip-getting-started'
|
||||
'skip-getting-started',
|
||||
'sticky-quickopen',
|
||||
'disable-telemetry',
|
||||
'disable-updates',
|
||||
'disable-crash-reporter'
|
||||
],
|
||||
alias: {
|
||||
add: 'a',
|
||||
@@ -60,6 +67,8 @@ const options: minimist.Opts = {
|
||||
'extensions-dir': 'extensionHomePath',
|
||||
'debugPluginHost': 'inspect-extensions',
|
||||
'debugBrkPluginHost': 'inspect-brk-extensions',
|
||||
'debugSearch': 'inspect-search',
|
||||
'debugBrkSearch': 'inspect-brk-search',
|
||||
}
|
||||
};
|
||||
|
||||
@@ -125,7 +134,7 @@ export const optionsHelp: { [name: string]: string; } = {
|
||||
'-r, --reuse-window': localize('reuseWindow', "Force opening a file or folder in the last active window."),
|
||||
'--user-data-dir <dir>': localize('userDataDir', "Specifies the directory that user data is kept in, useful when running as root."),
|
||||
'--verbose': localize('verbose', "Print verbose output (implies --wait)."),
|
||||
'-w, --wait': localize('wait', "Wait for the window to be closed before returning."),
|
||||
'-w, --wait': localize('wait', "Wait for the files to be closed before returning."),
|
||||
'--extensions-dir <dir>': localize('extensionHomePath', "Set the root path for extensions."),
|
||||
'--list-extensions': localize('listExtensions', "List the installed extensions."),
|
||||
'--show-versions': localize('showVersions', "Show versions of installed extensions, when using --list-extension."),
|
||||
@@ -138,11 +147,6 @@ export const optionsHelp: { [name: string]: string; } = {
|
||||
'-h, --help': localize('help', "Print usage.")
|
||||
};
|
||||
|
||||
// TODO@Ben multi root
|
||||
if (product.quality === 'stable') {
|
||||
delete optionsHelp['-a, --add'];
|
||||
}
|
||||
|
||||
export function formatOptions(options: { [name: string]: string; }, columns: number): string {
|
||||
let keys = Object.keys(options);
|
||||
let argLength = Math.max.apply(null, keys.map(k => k.length)) + 2/*left padding*/ + 1/*right padding*/;
|
||||
|
||||
@@ -3,58 +3,47 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService, ParsedArgs, IDebugParams, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
|
||||
import * as crypto from 'crypto';
|
||||
import * as paths from 'vs/base/node/paths';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { generateUuid, isUUID } from 'vs/base/common/uuid';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import pkg from 'vs/platform/node/package';
|
||||
import product from 'vs/platform/node/product';
|
||||
|
||||
function getUniqueUserId(): string {
|
||||
let username: string;
|
||||
if (process.platform === 'win32') {
|
||||
username = process.env.USERNAME;
|
||||
} else {
|
||||
username = process.env.USER;
|
||||
}
|
||||
|
||||
if (!username) {
|
||||
return ''; // fail gracefully if there is no user name
|
||||
}
|
||||
|
||||
// use sha256 to ensure the userid value can be used in filenames and are unique
|
||||
return crypto.createHash('sha256').update(username).digest('hex').substr(0, 6);
|
||||
}
|
||||
// Read this before there's any chance it is overwritten
|
||||
// Related to https://github.com/Microsoft/vscode/issues/30624
|
||||
const xdgRuntimeDir = process.env['XDG_RUNTIME_DIR'];
|
||||
|
||||
function getNixIPCHandle(userDataPath: string, type: string): string {
|
||||
if (process.env['XDG_RUNTIME_DIR']) {
|
||||
return path.join(process.env['XDG_RUNTIME_DIR'], `${pkg.name}-${pkg.version}-${type}.sock`);
|
||||
if (xdgRuntimeDir) {
|
||||
return path.join(xdgRuntimeDir, `${pkg.name}-${pkg.version}-${type}.sock`);
|
||||
}
|
||||
|
||||
return path.join(userDataPath, `${pkg.version}-${type}.sock`);
|
||||
}
|
||||
|
||||
function getWin32IPCHandle(type: string): string {
|
||||
// Support to run VS Code multiple times as different user
|
||||
// by making the socket unique over the logged in user
|
||||
const userId = getUniqueUserId();
|
||||
const name = product.applicationName + (userId ? `-${userId}` : '');
|
||||
|
||||
return `\\\\.\\pipe\\${name}-${pkg.version}-${type}-sock`;
|
||||
function getWin32IPCHandle(userDataPath: string, type: string): string {
|
||||
const scope = crypto.createHash('md5').update(userDataPath).digest('hex');
|
||||
return `\\\\.\\pipe\\${scope}-${pkg.version}-${type}-sock`;
|
||||
}
|
||||
|
||||
function getIPCHandle(userDataPath: string, type: string): string {
|
||||
if (process.platform === 'win32') {
|
||||
return getWin32IPCHandle(type);
|
||||
return getWin32IPCHandle(userDataPath, type);
|
||||
} else {
|
||||
return getNixIPCHandle(userDataPath, type);
|
||||
}
|
||||
}
|
||||
|
||||
export function getInstallSourcePath(userDataPath: string): string {
|
||||
return path.join(userDataPath, 'installSource');
|
||||
}
|
||||
|
||||
export class EnvironmentService implements IEnvironmentService {
|
||||
|
||||
_serviceBrand: any;
|
||||
@@ -111,7 +100,10 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
get skipGettingStarted(): boolean { return this._args['skip-getting-started']; }
|
||||
|
||||
@memoize
|
||||
get debugExtensionHost(): { port: number; break: boolean; debugId: string } { return parseExtensionHostPort(this._args, this.isBuilt); }
|
||||
get debugExtensionHost(): IExtensionHostDebugParams { return parseExtensionHostPort(this._args, this.isBuilt); }
|
||||
|
||||
@memoize
|
||||
get debugSearch(): IDebugParams { return parseSearchPort(this._args, this.isBuilt); }
|
||||
|
||||
get isBuilt(): boolean { return !process.env['VSCODE_DEV']; }
|
||||
get verbose(): boolean { return this._args.verbose; }
|
||||
@@ -139,32 +131,55 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
get sharedIPCHandle(): string { return getIPCHandle(this.userDataPath, 'shared'); }
|
||||
|
||||
@memoize
|
||||
get nodeCachedDataDir(): string { return this.isBuilt ? path.join(this.userDataPath, 'CachedData', product.commit) : undefined; }
|
||||
get nodeCachedDataDir(): string { return this.isBuilt ? path.join(this.userDataPath, 'CachedData', product.commit || new Array(41).join('0')) : undefined; }
|
||||
|
||||
get disableUpdates(): boolean { return !!this._args['disable-updates']; }
|
||||
get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; }
|
||||
|
||||
readonly machineUUID: string;
|
||||
|
||||
readonly installSource: string;
|
||||
|
||||
constructor(private _args: ParsedArgs, private _execPath: string) {
|
||||
const machineIdPath = path.join(this.userDataPath, 'machineid');
|
||||
|
||||
try {
|
||||
this.machineUUID = fs.readFileSync(machineIdPath, 'utf8');
|
||||
|
||||
if (!isUUID(this.machineUUID)) {
|
||||
throw new Error('Not a UUID');
|
||||
}
|
||||
} catch (err) {
|
||||
this.machineUUID = generateUuid();
|
||||
|
||||
try {
|
||||
fs.writeFileSync(machineIdPath, this.machineUUID);
|
||||
fs.writeFileSync(machineIdPath, this.machineUUID, 'utf8');
|
||||
} catch (err) {
|
||||
console.warn('Could not store machine ID');
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this.installSource = fs.readFileSync(getInstallSourcePath(this.userDataPath), 'utf8').slice(0, 30);
|
||||
} catch (err) {
|
||||
this.installSource = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): { port: number; break: boolean; debugId: string } {
|
||||
const portStr = args.debugBrkPluginHost || args.debugPluginHost;
|
||||
const port = Number(portStr) || (!isBuild ? 5870 : null);
|
||||
const brk = port ? Boolean(!!args.debugBrkPluginHost) : false;
|
||||
return { port, break: brk, debugId: args.debugId };
|
||||
export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): IExtensionHostDebugParams {
|
||||
return parseDebugPort(args.debugPluginHost, args.debugBrkPluginHost, 5870, isBuild, args.debugId);
|
||||
}
|
||||
|
||||
export function parseSearchPort(args: ParsedArgs, isBuild: boolean): IDebugParams {
|
||||
return parseDebugPort(args.debugSearch, args.debugBrkSearch, 5876, isBuild);
|
||||
}
|
||||
|
||||
export function parseDebugPort(debugArg: string, debugBrkArg: string, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
|
||||
const portStr = debugBrkArg || debugArg;
|
||||
const port = Number(portStr) || (!isBuild ? defaultBuildPort : null);
|
||||
const brk = port ? Boolean(!!debugBrkArg) : false;
|
||||
return { port, break: brk, debugId };
|
||||
}
|
||||
|
||||
function parsePathArg(arg: string, process: NodeJS.Process): string {
|
||||
|
||||
Reference in New Issue
Block a user