mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 01:25:37 -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:
@@ -14,9 +14,13 @@ import pkg from 'vs/platform/node/package';
|
||||
import * as fs from 'fs';
|
||||
import * as paths from 'path';
|
||||
import * as os from 'os';
|
||||
import { whenDeleted } from 'vs/base/node/pfs';
|
||||
|
||||
function shouldSpawnCliProcess(argv: ParsedArgs): boolean {
|
||||
return argv['list-extensions'] || !!argv['install-extension'] || !!argv['uninstall-extension'];
|
||||
return !!argv['install-source']
|
||||
|| !!argv['list-extensions']
|
||||
|| !!argv['install-extension']
|
||||
|| !!argv['uninstall-extension'];
|
||||
}
|
||||
|
||||
interface IMainCli {
|
||||
@@ -105,14 +109,7 @@ export function main(argv: string[]): TPromise<void> {
|
||||
child.once('exit', () => c(null));
|
||||
|
||||
// Complete when wait marker file is deleted
|
||||
const interval = setInterval(() => {
|
||||
fs.exists(waitMarkerFilePath, exists => {
|
||||
if (!exists) {
|
||||
clearInterval(interval);
|
||||
c(null);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
whenDeleted(waitMarkerFilePath).done(c, c);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { localize } from 'vs/nls';
|
||||
import product from 'vs/platform/node/product';
|
||||
import pkg from 'vs/platform/node/package';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { sequence } from 'vs/base/common/async';
|
||||
@@ -16,7 +17,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { EnvironmentService, getInstallSourcePath } from 'vs/platform/environment/node/environmentService';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, IExtensionManifest, IGalleryExtension, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
||||
@@ -33,8 +34,8 @@ import { mkdirp } from 'vs/base/node/pfs';
|
||||
import { IChoiceService } from 'vs/platform/message/common/message';
|
||||
import { ChoiceCliService } from 'vs/platform/message/node/messageCli';
|
||||
|
||||
const notFound = id => localize('notFound', "Extension '{0}' not found.", id);
|
||||
const notInstalled = id => localize('notInstalled', "Extension '{0}' is not installed.", id);
|
||||
const notFound = (id: string) => localize('notFound', "Extension '{0}' not found.", id);
|
||||
const notInstalled = (id: string) => localize('notInstalled', "Extension '{0}' is not installed.", id);
|
||||
const useId = localize('useId', "Make sure you use the full extension ID, including the publisher, eg: {0}", 'ms-vscode.csharp');
|
||||
|
||||
function getId(manifest: IExtensionManifest, withVersion?: boolean): string {
|
||||
@@ -50,6 +51,7 @@ type Task = { (): TPromise<void> };
|
||||
class Main {
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@IExtensionManagementService private extensionManagementService: IExtensionManagementService,
|
||||
@IExtensionGalleryService private extensionGalleryService: IExtensionGalleryService
|
||||
) { }
|
||||
@@ -57,7 +59,9 @@ class Main {
|
||||
run(argv: ParsedArgs): TPromise<any> {
|
||||
// TODO@joao - make this contributable
|
||||
|
||||
if (argv['list-extensions']) {
|
||||
if (argv['install-source']) {
|
||||
return this.setInstallSource(argv['install-source']);
|
||||
} else if (argv['list-extensions']) {
|
||||
return this.listExtensions(argv['show-versions']);
|
||||
} else if (argv['install-extension']) {
|
||||
const arg = argv['install-extension'];
|
||||
@@ -71,6 +75,13 @@ class Main {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private setInstallSource(installSource: string): TPromise<any> {
|
||||
return new TPromise<void>((c, e) => {
|
||||
const path = getInstallSourcePath(this.environmentService.userDataPath);
|
||||
fs.writeFile(path, installSource.slice(0, 30), 'utf8', err => err ? e(err) : c(null));
|
||||
});
|
||||
}
|
||||
|
||||
private listExtensions(showVersions: boolean): TPromise<any> {
|
||||
return this.extensionManagementService.getInstalled(LocalExtensionType.User).then(extensions => {
|
||||
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
|
||||
@@ -99,7 +110,7 @@ class Main {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
return this.extensionGalleryService.query({ names: [id] })
|
||||
return this.extensionGalleryService.query({ names: [id], source: 'cli' })
|
||||
.then<IPager<IGalleryExtension>>(null, err => {
|
||||
if (err.responseText) {
|
||||
try {
|
||||
@@ -122,7 +133,7 @@ class Main {
|
||||
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
|
||||
console.log(localize('installing', "Installing..."));
|
||||
|
||||
return this.extensionManagementService.installFromGallery(extension, false)
|
||||
return this.extensionManagementService.installFromGallery(extension)
|
||||
.then(() => console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.version)));
|
||||
});
|
||||
});
|
||||
@@ -161,7 +172,7 @@ export function main(argv: ParsedArgs): TPromise<void> {
|
||||
const envService = accessor.get(IEnvironmentService);
|
||||
|
||||
return TPromise.join([envService.appSettingsHome, envService.extensionsPath].map(p => mkdirp(p))).then(() => {
|
||||
const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt } = envService;
|
||||
const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt, installSource } = envService;
|
||||
|
||||
const services = new ServiceCollection();
|
||||
services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
|
||||
@@ -170,7 +181,7 @@ export function main(argv: ParsedArgs): TPromise<void> {
|
||||
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
|
||||
services.set(IChoiceService, new SyncDescriptor(ChoiceCliService));
|
||||
|
||||
if (isBuilt && !extensionDevelopmentPath && product.enableTelemetry) {
|
||||
if (isBuilt && !extensionDevelopmentPath && !envService.args['disable-telemetry'] && product.enableTelemetry) {
|
||||
const appenders: AppInsightsAppender[] = [];
|
||||
|
||||
if (product.aiConfig && product.aiConfig.asimovKey) {
|
||||
@@ -183,7 +194,7 @@ export function main(argv: ParsedArgs): TPromise<void> {
|
||||
|
||||
const config: ITelemetryServiceConfig = {
|
||||
appender: combinedAppender(...appenders),
|
||||
commonProperties: resolveCommonProperties(product.commit, pkg.version),
|
||||
commonProperties: resolveCommonProperties(product.commit, pkg.version, installSource),
|
||||
piiPaths: [appRoot, extensionsPath]
|
||||
};
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ function getUnixShellEnvironment(): TPromise<typeof process.env> {
|
||||
delete env['ELECTRON_NO_ATTACH_CONSOLE'];
|
||||
}
|
||||
|
||||
// https://github.com/Microsoft/vscode/issues/22593#issuecomment-336050758
|
||||
delete env['XDG_RUNTIME_DIR'];
|
||||
|
||||
c(env);
|
||||
} catch (err) {
|
||||
e(err);
|
||||
|
||||
@@ -11,6 +11,7 @@ import * as platform from 'vs/base/common/platform';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import { OpenContext } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IResolvedWorkspace } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export interface ISimpleWindow {
|
||||
openedWorkspace?: IWorkspaceIdentifier;
|
||||
@@ -62,7 +63,7 @@ function findWindowOnFilePath<W extends ISimpleWindow>(windows: W[], filePath: s
|
||||
for (let i = 0; i < workspaceWindows.length; i++) {
|
||||
const window = workspaceWindows[i];
|
||||
const resolvedWorkspace = workspaceResolver(window.openedWorkspace);
|
||||
if (resolvedWorkspace && resolvedWorkspace.folders.some(folder => paths.isEqualOrParent(filePath, folder.path, !platform.isLinux /* ignorecase */))) {
|
||||
if (resolvedWorkspace && resolvedWorkspace.folders.some(folder => folder.uri.scheme === Schemas.file && paths.isEqualOrParent(filePath, folder.uri.fsPath, !platform.isLinux /* ignorecase */))) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
@@ -165,4 +166,4 @@ export function findWindowOnWorkspaceOrFolderPath<W extends ISimpleWindow>(windo
|
||||
|
||||
return false;
|
||||
})[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user