From eaec4b3f2cddf616c1937e0808c7874b1677c44f Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 21 Apr 2021 22:55:59 +0200 Subject: [PATCH] workbench embedder API: developmentOptions --- src/vs/code/browser/workbench/workbench.ts | 7 ---- src/vs/workbench/browser/window.ts | 2 +- .../environment/browser/environmentService.ts | 15 ++++---- .../common/webExtensionsScannerService.ts | 24 +++++++++++-- src/vs/workbench/workbench.web.api.ts | 34 +++++++++++++------ 5 files changed, 53 insertions(+), 29 deletions(-) diff --git a/src/vs/code/browser/workbench/workbench.ts b/src/vs/code/browser/workbench/workbench.ts index 096b7d6d35f..6ed6d35c3c8 100644 --- a/src/vs/code/browser/workbench/workbench.ts +++ b/src/vs/code/browser/workbench/workbench.ts @@ -413,13 +413,6 @@ class WindowIndicator implements IWindowIndicator { const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = JSON.parse(configElementAttribute); - // Revive static extension locations - if (Array.isArray(config.staticExtensions)) { - config.staticExtensions.forEach(extension => { - extension.extensionLocation = URI.revive(extension.extensionLocation); - }); - } - // Find workspace to open and payload let foundWorkspace = false; let workspace: IWorkspace; diff --git a/src/vs/workbench/browser/window.ts b/src/vs/workbench/browser/window.ts index 56782daaea3..d5309f23de0 100644 --- a/src/vs/workbench/browser/window.ts +++ b/src/vs/workbench/browser/window.ts @@ -115,7 +115,7 @@ export class BrowserWindow extends Disposable { private create(): void { // Driver - if (this.environmentService.options?.driver) { + if (this.environmentService.options?.developmentOptions?.enableSmokeTestDriver) { (async () => this._register(await registerWindowDriver()))(); } diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 5497d3f9e11..c6db8c1cf08 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -282,16 +282,15 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment extensionDevelopmentLocationURI: undefined, extensionDevelopmentKind: undefined }; - - if (this.options.staticExtensions) { - const extensionDevelopmentLocations = this.options.staticExtensions.filter(s => s.isUnderDevelopment).map(e => e.extensionLocation); - if (extensionDevelopmentLocations.length) { - extensionHostDebugEnvironment.extensionDevelopmentLocationURI = extensionDevelopmentLocations; + const developmentOptions = this.options.developmentOptions; + if (developmentOptions) { + if (developmentOptions.extensions?.length) { + extensionHostDebugEnvironment.extensionDevelopmentLocationURI = developmentOptions.extensions.map(e => URI.revive(e.extensionLocation)); extensionHostDebugEnvironment.isExtensionDevelopment = true; } - } - if (this.options.extensionTestsPath) { - extensionHostDebugEnvironment.extensionTestsLocationURI = URI.revive(this.options.extensionTestsPath); + if (developmentOptions) { + extensionHostDebugEnvironment.extensionTestsLocationURI = URI.revive(developmentOptions.extensionTestsPath); + } } // Fill in selected extra environmental properties diff --git a/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts b/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts index ccc55f3df26..bbb350ca7e0 100644 --- a/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts +++ b/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts @@ -97,6 +97,23 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten return result; } + /** + * All dev extesnions + */ + private getDevExtensions(): IScannedExtension[] { + const devExtensions = this.environmentService.options?.developmentOptions?.extensions; + const result: IScannedExtension[] = []; + if (Array.isArray(devExtensions)) { + for (const e of devExtensions) { + const scannedExtension = this.parseStaticExtension(e, false, true); + if (scannedExtension) { + result.push(scannedExtension); + } + } + } + return result; + } + private async readDefaultExtensions(): Promise { const defaultUserWebExtensions = await this.readDefaultUserWebExtensions(); const extensions: IScannedExtension[] = []; @@ -106,20 +123,21 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten extensions.push(scannedExtension); } } - return extensions.concat(this.getStaticExtensions(false)); + return extensions.concat(this.getStaticExtensions(false), this.getDevExtensions()); } private parseStaticExtension(e: IStaticExtension, builtin: boolean, isUnderDevelopment: boolean): IScannedExtension | null { + const extensionLocation = URI.revive(e.extensionLocation); try { return { identifier: { id: getGalleryExtensionId(e.packageJSON.publisher, e.packageJSON.name) }, - location: e.extensionLocation, + location: extensionLocation, type: builtin ? ExtensionType.System : ExtensionType.User, packageJSON: e.packageJSON, isUnderDevelopment }; } catch (error) { - this.logService.error(`Error while parsing extension ${e.extensionLocation.toString()}`); + this.logService.error(`Error while parsing extension ${extensionLocation.toString()}`); this.logService.error(error); } return null; diff --git a/src/vs/workbench/workbench.web.api.ts b/src/vs/workbench/workbench.web.api.ts index 685761c86a3..eb2bf21a974 100644 --- a/src/vs/workbench/workbench.web.api.ts +++ b/src/vs/workbench/workbench.web.api.ts @@ -26,8 +26,8 @@ interface IResourceUriProvider { interface IStaticExtension { packageJSON: IExtensionManifest; - extensionLocation: URI; - isUnderDevelopment?: boolean; + extensionLocation: UriComponents; + isBuiltin?: boolean; } interface ICommonTelemetryPropertiesResolver { @@ -321,11 +321,6 @@ interface IWorkbenchConstructionOptions { */ readonly staticExtensions?: ReadonlyArray; - /** - * Location of a module containing extension tests to run once the workbench is open. - */ - readonly extensionTestsPath?: URI; - /** * [TEMPORARY]: This will be removed soon. * Enable inlined extensions. @@ -415,12 +410,31 @@ interface IWorkbenchConstructionOptions { */ readonly logLevel?: LogLevel; + //#endregion + + //#region development options + + readonly developmentOptions?: IDevelopmentOptions; + + //#endregion + +} + +interface IDevelopmentOptions { + /** + * Location of a module containing extension tests to run once the workbench is open. + */ + readonly extensionTestsPath?: URI; + + /** + * Add extensions under development. + */ + readonly extensions?: ReadonlyArray; + /** * Whether to enable the smoke test driver. */ - readonly driver?: boolean; - - //#endregion + readonly enableSmokeTestDriver?: boolean; } interface IPerformanceMark {