diff options
author | Sandeep Somavarapu <sasomava@microsoft.com> | 2022-03-08 19:59:57 +0300 |
---|---|---|
committer | Sandeep Somavarapu <sasomava@microsoft.com> | 2022-03-08 19:59:57 +0300 |
commit | 422665c68ac14e92019fe533f46199024fd250ea (patch) | |
tree | eda734d0298d4732b6a75a546f0a98f6ab106f34 /src/vs | |
parent | 92f4bd7894c3b790d37b1eec3c7fb5e5f8618f70 (diff) |
- store target platform in local extension
- show update action for extensions with outdated target platform
Diffstat (limited to 'src/vs')
7 files changed, 41 insertions, 10 deletions
diff --git a/src/vs/platform/extensionManagement/common/extensionManagement.ts b/src/vs/platform/extensionManagement/common/extensionManagement.ts index 0778ba407ab..49906652ff2 100644 --- a/src/vs/platform/extensionManagement/common/extensionManagement.ts +++ b/src/vs/platform/extensionManagement/common/extensionManagement.ts @@ -266,6 +266,7 @@ export interface IGalleryMetadata { publisherId: string; publisherDisplayName: string; isPreReleaseVersion: boolean; + targetPlatform?: TargetPlatform; } export type Metadata = Partial<IGalleryMetadata & { isMachineScoped: boolean; isBuiltin: boolean; preRelease: boolean; installedTimestamp: number }>; @@ -277,6 +278,7 @@ export interface ILocalExtension extends IExtension { installedTimestamp?: number; isPreReleaseVersion: boolean; preRelease: boolean; + targetPlatform: TargetPlatform; } export const enum SortBy { diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index c522d9c1de2..98a4571640e 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -324,6 +324,7 @@ class InstallGalleryExtensionTask extends AbstractInstallExtensionTask { id: extension.identifier.uuid, publisherId: extension.publisherId, publisherDisplayName: extension.publisherDisplayName, + targetPlatform: extension.properties.targetPlatform }; let zipPath: string | undefined; diff --git a/src/vs/platform/extensionManagement/node/extensionsScanner.ts b/src/vs/platform/extensionManagement/node/extensionsScanner.ts index 593ae22edfc..07b924e45bd 100644 --- a/src/vs/platform/extensionManagement/node/extensionsScanner.ts +++ b/src/vs/platform/extensionManagement/node/extensionsScanner.ts @@ -20,7 +20,7 @@ import * as pfs from 'vs/base/node/pfs'; import { extract, ExtractError } from 'vs/base/node/zip'; import { localize } from 'vs/nls'; import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; -import { ExtensionManagementError, ExtensionManagementErrorCode, Metadata, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement'; +import { ExtensionManagementError, ExtensionManagementErrorCode, Metadata, ILocalExtension, TargetPlatform } from 'vs/platform/extensionManagement/common/extensionManagement'; import { areSameExtensions, ExtensionIdentifierWithVersion, getGalleryExtensionId, groupByExtension } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { localizeManifest } from 'vs/platform/extensionManagement/common/extensionNls'; import { ExtensionType, IExtensionIdentifier, IExtensionManifest, UNDEFINED_PUBLISHER } from 'vs/platform/extensions/common/extensions'; @@ -336,6 +336,7 @@ export class ExtensionsScanner extends Disposable { local.preRelease = !!metadata?.preRelease; local.isBuiltin = local.type === ExtensionType.System || !!metadata?.isBuiltin; local.installedTimestamp = metadata?.installedTimestamp; + local.targetPlatform = metadata?.targetPlatform ?? TargetPlatform.UNDEFINED; } private async removeUninstalledExtensions(): Promise<void> { diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index 8f6e11bee28..e4d00340619 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -745,14 +745,14 @@ export class UpdateAction extends ExtensionAction { if (!this.extension) { this.enabled = false; this.class = UpdateAction.DisabledClass; - this.label = this.getUpdateLabel(); + this.label = this.getLabel(); return; } if (this.extension.type !== ExtensionType.User) { this.enabled = false; this.class = UpdateAction.DisabledClass; - this.label = this.getUpdateLabel(); + this.label = this.getLabel(); return; } @@ -761,7 +761,7 @@ export class UpdateAction extends ExtensionAction { this.enabled = canInstall && isInstalled && this.extension.outdated; this.class = this.enabled ? UpdateAction.EnabledClass : UpdateAction.DisabledClass; - this.label = this.extension.outdated ? this.getUpdateLabel(this.extension.latestVersion) : this.getUpdateLabel(); + this.label = this.getLabel(this.extension); } override async run(): Promise<any> { @@ -781,8 +781,14 @@ export class UpdateAction extends ExtensionAction { } } - private getUpdateLabel(version?: string): string { - return version ? localize('updateTo', "Update to {0}", version) : localize('updateAction', "Update"); + private getLabel(extension?: IExtension): string { + if (!extension?.outdated) { + return localize('updateAction', "Update"); + } + if (extension.outdatedTargetPlatform) { + return localize('updateToTargetPlatformVersion', "Update to {0} version", TargetPlatformToString(extension.gallery!.properties.targetPlatform)); + } + return localize('updateToLatestVersion', "Update to {0}", extension.latestVersion); } } diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts index 4919f111cc4..264bb9fbc74 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts @@ -15,7 +15,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IExtensionGalleryService, ILocalExtension, IGalleryExtension, IQueryOptions, InstallExtensionEvent, DidUninstallExtensionEvent, IExtensionIdentifier, InstallOperation, InstallOptions, WEB_EXTENSION_TAG, InstallExtensionResult, - IExtensionsControlManifest, InstallVSIXOptions, IExtensionInfo, IExtensionQueryOptions + IExtensionsControlManifest, InstallVSIXOptions, IExtensionInfo, IExtensionQueryOptions, TargetPlatform } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer, IWorkbenchExtensionManagementService, DefaultIconPath } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; import { getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, areSameExtensions, groupByExtension, ExtensionIdentifierWithVersion, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; @@ -202,7 +202,26 @@ class Extension implements IExtension { } get outdated(): boolean { - return !!this.gallery && this.type === ExtensionType.User && semver.gt(this.latestVersion, this.version) && (this.local?.preRelease || !this.gallery?.properties.isPreReleaseVersion); + if (!this.gallery || !this.local) { + return false; + } + if (this.type !== ExtensionType.User) { + return false; + } + if (!this.local.preRelease && this.gallery.properties.isPreReleaseVersion) { + return false; + } + if (semver.gt(this.latestVersion, this.version)) { + return true; + } + if (this.outdatedTargetPlatform) { + return true; + } + return false; + } + + get outdatedTargetPlatform(): boolean { + return !!this.local && !!this.gallery && this.local.targetPlatform !== TargetPlatform.UNDEFINED && this.local.targetPlatform !== this.gallery.properties.targetPlatform && semver.eq(this.latestVersion, this.version); } get telemetryData(): any { @@ -436,7 +455,7 @@ class Extensions extends Disposable { if (extension.local && !extension.local.identifier.uuid) { extension.local = await this.updateMetadata(extension.local, gallery); } - if (!extension.gallery || extension.gallery.version !== gallery.version) { + if (!extension.gallery || extension.gallery.version !== gallery.version || extension.gallery.properties.targetPlatform !== gallery.properties.targetPlatform) { extension.gallery = gallery; this._onChange.fire({ extension }); hasChanged = true; diff --git a/src/vs/workbench/contrib/extensions/common/extensions.ts b/src/vs/workbench/contrib/extensions/common/extensions.ts index b6744153baf..b3846d038fc 100644 --- a/src/vs/workbench/contrib/extensions/common/extensions.ts +++ b/src/vs/workbench/contrib/extensions/common/extensions.ts @@ -61,6 +61,7 @@ export interface IExtension { readonly rating?: number; readonly ratingCount?: number; readonly outdated: boolean; + readonly outdatedTargetPlatform: boolean; readonly enablementState: EnablementState; readonly tags: readonly string[]; readonly categories: readonly string[]; diff --git a/src/vs/workbench/services/extensionManagement/common/webExtensionManagementService.ts b/src/vs/workbench/services/extensionManagement/common/webExtensionManagementService.ts index c8210fb8179..e9acbbe1ace 100644 --- a/src/vs/workbench/services/extensionManagement/common/webExtensionManagementService.ts +++ b/src/vs/workbench/services/extensionManagement/common/webExtensionManagementService.ts @@ -111,7 +111,8 @@ function toLocalExtension(extension: IScannedExtension): ILocalExtension { publisherDisplayName: metadata.publisherDisplayName || null, installedTimestamp: metadata.installedTimestamp, isPreReleaseVersion: !!metadata.isPreReleaseVersion, - preRelease: !!metadata.preRelease + preRelease: !!metadata.preRelease, + targetPlatform: TargetPlatform.WEB }; } |