Fix #52077
This commit is contained in:
parent
79b64c4f81
commit
c473c552f6
6 changed files with 29 additions and 26 deletions
|
@ -13,6 +13,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
|
|||
import { join } from 'vs/base/common/paths';
|
||||
import { Limiter } from 'vs/base/common/async';
|
||||
import { fromNodeEventEmitter, anyEvent, mapEvent, debounceEvent } from 'vs/base/common/event';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export class ExtensionsLifecycle extends Disposable {
|
||||
|
||||
|
@ -36,7 +37,7 @@ export class ExtensionsLifecycle extends Disposable {
|
|||
}
|
||||
|
||||
private parseUninstallScript(extension: ILocalExtension): { uninstallHook: string, args: string[] } {
|
||||
if (extension.manifest && extension.manifest['scripts'] && typeof extension.manifest['scripts']['vscode:uninstall'] === 'string') {
|
||||
if (extension.location.scheme === Schemas.file && extension.manifest && extension.manifest['scripts'] && typeof extension.manifest['scripts']['vscode:uninstall'] === 'string') {
|
||||
const uninstallScript = (<string>extension.manifest['scripts']['vscode:uninstall']).split(' ');
|
||||
if (uninstallScript.length < 2 || uninstallScript[0] !== 'node' || !uninstallScript[1]) {
|
||||
this.logService.warn(extension.identifier.id, 'Uninstall script should be a node script');
|
||||
|
|
|
@ -658,7 +658,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
}
|
||||
|
||||
private preUninstallExtension(extension: ILocalExtension): TPromise<void> {
|
||||
return pfs.exists(extension.location.path)
|
||||
return pfs.exists(extension.location.fsPath)
|
||||
.then(exists => exists ? null : TPromise.wrapError(new Error(nls.localize('notExists', "Could not find extension"))))
|
||||
.then(() => {
|
||||
this.logService.info('Uninstalling extension:', extension.identifier.id);
|
||||
|
@ -788,7 +788,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
|
||||
private removeExtension(extension: ILocalExtension, type: string): TPromise<void> {
|
||||
this.logService.trace(`Deleting ${type} extension from disk`, extension.identifier.id);
|
||||
return pfs.rimraf(extension.location.path).then(() => this.logService.info('Deleted from disk', extension.identifier.id));
|
||||
return pfs.rimraf(extension.location.fsPath).then(() => this.logService.info('Deleted from disk', extension.identifier.id));
|
||||
}
|
||||
|
||||
private isUninstalled(id: string): TPromise<boolean> {
|
||||
|
|
|
@ -17,6 +17,7 @@ import { isValidLocalization, ILocalizationsService, LanguageType } from 'vs/pla
|
|||
import product from 'vs/platform/node/product';
|
||||
import { distinct, equals } from 'vs/base/common/arrays';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
interface ILanguagePack {
|
||||
hash: string;
|
||||
|
@ -138,7 +139,7 @@ class LanguagePacksCache extends Disposable {
|
|||
private createLanguagePacksFromExtension(languagePacks: { [language: string]: ILanguagePack }, extension: ILocalExtension): void {
|
||||
const extensionIdentifier = { id: getGalleryExtensionIdFromLocal(extension), uuid: extension.identifier.uuid };
|
||||
for (const localizationContribution of extension.manifest.contributes.localizations) {
|
||||
if (isValidLocalization(localizationContribution)) {
|
||||
if (extension.location.scheme === Schemas.file && isValidLocalization(localizationContribution)) {
|
||||
let languagePack = languagePacks[localizationContribution.languageId];
|
||||
if (!languagePack) {
|
||||
languagePack = { hash: '', extensions: [], translations: {} };
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import * as nls from 'vs/nls';
|
||||
import { readFile } from 'vs/base/node/pfs';
|
||||
import * as semver from 'semver';
|
||||
import * as path from 'path';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { index } from 'vs/base/common/arrays';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
@ -40,6 +39,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
|||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { groupBy } from 'vs/base/common/collections';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { join } from 'vs/base/common/paths';
|
||||
|
||||
interface IExtensionStateProvider<T> {
|
||||
(extension: Extension): T;
|
||||
|
@ -138,7 +138,7 @@ class Extension implements IExtension {
|
|||
|
||||
private get localIconUrl(): string {
|
||||
if (this.local && this.local.manifest.icon) {
|
||||
return this.local.location.with({ path: path.join(this.local.location.path, this.local.manifest.icon) }).toString();
|
||||
return this.local.location.with({ path: join(this.local.location.path, this.local.manifest.icon) }).toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import { IWindowService } from 'vs/platform/windows/common/windows';
|
|||
import { URLService } from 'vs/platform/url/common/urlService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { ExtensionManagementServerService } from 'vs/workbench/services/extensions/node/extensionManagementServerService';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
suite('ExtensionsActions Test', () => {
|
||||
|
||||
|
@ -94,14 +95,14 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Install action is disabled when there is no extension', () => {
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
|
||||
assert.ok(!testObject.enabled);
|
||||
});
|
||||
|
||||
test('Test Install action when state is installed', () => {
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a');
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
return workbenchService.queryLocal()
|
||||
|
@ -119,7 +120,7 @@ suite('ExtensionsActions Test', () => {
|
|||
|
||||
test('Test Install action when state is installing', () => {
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return workbenchService.queryGallery()
|
||||
|
@ -135,7 +136,7 @@ suite('ExtensionsActions Test', () => {
|
|||
|
||||
test('Test Install action when state is uninstalled', () => {
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return workbenchService.queryGallery()
|
||||
|
@ -147,7 +148,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test Install action when extension is system action', () => {
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a', {}, { type: LocalExtensionType.System });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -161,7 +162,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test Install action when extension doesnot has gallery', () => {
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.InstallAction = instantiationService.createInstance(ExtensionsActions.InstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a');
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -242,14 +243,14 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test CombinedInstallAction when there is no extension', () => {
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
|
||||
assert.ok(!testObject.enabled);
|
||||
assert.equal('extension-action prominent install no-extension', testObject.class);
|
||||
});
|
||||
|
||||
test('Test CombinedInstallAction when extension is system extension', () => {
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a', {}, { type: LocalExtensionType.System });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -263,7 +264,7 @@ suite('ExtensionsActions Test', () => {
|
|||
|
||||
test('Test CombinedInstallAction when installAction is enabled', () => {
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
||||
|
@ -277,7 +278,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test CombinedInstallAction when unInstallAction is enabled', () => {
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a');
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -291,7 +292,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test CombinedInstallAction when state is installing', () => {
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
|
||||
const gallery = aGalleryExtension('a');
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
|
@ -307,7 +308,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test CombinedInstallAction when state is uninstalling', () => {
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.CombinedInstallAction = instantiationService.createInstance(ExtensionsActions.CombinedInstallAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a');
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -322,13 +323,13 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test UpdateAction when there is no extension', () => {
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
|
||||
assert.ok(!testObject.enabled);
|
||||
});
|
||||
|
||||
test('Test UpdateAction when extension is uninstalled', () => {
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const gallery = aGalleryExtension('a', { version: '1.0.0' });
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
|
||||
return instantiationService.get(IExtensionsWorkbenchService).queryGallery()
|
||||
|
@ -339,7 +340,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test UpdateAction when extension is installed and not outdated', () => {
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a', { version: '1.0.0' });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -353,7 +354,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test UpdateAction when extension is installed outdated and system extension', () => {
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a', { version: '1.0.0' }, { type: LocalExtensionType.System });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -367,7 +368,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test UpdateAction when extension is installed outdated and user extension', () => {
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a', { version: '1.0.0' });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
@ -381,7 +382,7 @@ suite('ExtensionsActions Test', () => {
|
|||
});
|
||||
|
||||
test('Test UpdateAction when extension is installing and outdated and user extension', () => {
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) });
|
||||
const testObject: ExtensionsActions.UpdateAction = instantiationService.createInstance(ExtensionsActions.UpdateAction, <IExtensionManagementServer>{ extensionManagementService: null, location: URI.from({ scheme: Schemas.file }) });
|
||||
const local = aLocalExtension('a', { version: '1.0.0' });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ export class ExtensionManagementServerService implements IExtensionManagementSer
|
|||
constructor(
|
||||
localExtensionManagementService: IExtensionManagementService
|
||||
) {
|
||||
this.extensionManagementServers = [{ extensionManagementService: localExtensionManagementService, location: URI.from({ scheme: 'vscode-local', authority: 'local' }) }];
|
||||
this.extensionManagementServers = [{ extensionManagementService: localExtensionManagementService, location: URI.from({ scheme: Schemas.file }) }];
|
||||
}
|
||||
|
||||
getExtensionManagementServer(location: URI): IExtensionManagementServer {
|
||||
|
@ -37,7 +37,7 @@ export class SingleServerExtensionManagementServerService implements IExtensionM
|
|||
}
|
||||
|
||||
getExtensionManagementServer(location: URI): IExtensionManagementServer {
|
||||
location = location.scheme === Schemas.file ? URI.from({ scheme: 'vscode-local', authority: 'local' }) : location;
|
||||
location = location.scheme === Schemas.file ? URI.from({ scheme: Schemas.file }) : location;
|
||||
return this.extensionManagementServers.filter(server => location.authority === server.location.authority)[0];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue