mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Enforce vscode and ads version check when installing extensions (#4267)
* engine check when install extension * gallery install/update and vsix install * FIX COMMENTS * Fix the detail not loading issue when version is invalid * add more comments and adress PR comments * add install telemetry for install from vsix scenario * correct the name of the version property for telemetry
This commit is contained in:
@@ -191,6 +191,13 @@ export class InstallAction extends Action {
|
||||
return this.notificationService.error(err);
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Prompt the user that the current ADS version is not compatible with the extension,
|
||||
// return here as in this scenario it doesn't make sense for the user to download manually.
|
||||
if(err && err.code === INSTALL_ERROR_INCOMPATIBLE) {
|
||||
return this.notificationService.error(err);
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
|
||||
return promptDownloadManually(extension.gallery, localize('failedToInstall', "Failed to install \'{0}\'.", extension.id), err, this.instantiationService, this.notificationService, this.openerService);
|
||||
@@ -418,6 +425,13 @@ export class UpdateAction extends Action {
|
||||
return this.notificationService.error(err);
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Prompt the user that the current ADS version is not compatible with the extension,
|
||||
// return here as in this scenario it doesn't make sense for the user to download manually.
|
||||
if(err && err.code === INSTALL_ERROR_INCOMPATIBLE) {
|
||||
return this.notificationService.error(err);
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
|
||||
return promptDownloadManually(extension.gallery, localize('failedToUpdate', "Failed to update \'{0}\'.", extension.id), err, this.instantiationService, this.notificationService, this.openerService);
|
||||
|
||||
@@ -13,9 +13,10 @@ import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IPager, mapPager, singlePagePager } from 'vs/base/common/paging';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension, IQueryOptions, IExtensionManifest,
|
||||
InstallExtensionEvent, DidInstallExtensionEvent, LocalExtensionType, DidUninstallExtensionEvent, IExtensionEnablementService, IExtensionIdentifier, EnablementState, IExtensionManagementServerService
|
||||
InstallExtensionEvent, DidInstallExtensionEvent, LocalExtensionType, DidUninstallExtensionEvent, IExtensionEnablementService, IExtensionIdentifier, EnablementState, IExtensionManagementServerService, INSTALL_ERROR_INCOMPATIBLE
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionIdFromLocal, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, areSameExtensions, getMaliciousExtensionsSet, getLocalExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -39,6 +40,11 @@ import * as resources from 'vs/base/common/resources';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import pkg from 'vs/platform/node/package';
|
||||
import { isEngineValid } from 'vs/platform/extensions/node/extensionValidator';
|
||||
import { ExtensionManagementError } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
|
||||
interface IExtensionStateProvider<T> {
|
||||
(extension: Extension): T;
|
||||
}
|
||||
@@ -703,6 +709,13 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
||||
if (extensionIdentifier) {
|
||||
this.checkAndEnableDisabledDependencies(extensionIdentifier);
|
||||
}
|
||||
}
|
||||
// {{SQL CARBON EDIT}}
|
||||
// This is the error handler when installing local VSIX file.
|
||||
// Prompt the user about the error detail.
|
||||
, (error) => {
|
||||
this.notificationService.error(error);
|
||||
return Promise.reject(error);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -721,6 +734,15 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
||||
return Promise.reject(new Error('Missing gallery'));
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// This is the execution path for install/update extension from marketplace.
|
||||
// Check both the vscode version and azure data studio version
|
||||
// The check is added here because we want to fail fast instead of downloading the VSIX and then fail.
|
||||
if (gallery.properties.engine && (!isEngineValid(gallery.properties.engine, product.vscodeVersion)
|
||||
|| (gallery.properties.azDataEngine && !isEngineValid(gallery.properties.azDataEngine, pkg.version)))) {
|
||||
return Promise.reject(new ExtensionManagementError(nls.localize('incompatible', "Unable to install version '{2}' of extension '{0}' as it is not compatible with Azure Data Studio '{1}'.", extension.id, pkg.version, gallery.version), INSTALL_ERROR_INCOMPATIBLE));
|
||||
}
|
||||
|
||||
return this.installWithProgress(
|
||||
// {{SQL CARBON EDIT}}
|
||||
() => {
|
||||
|
||||
@@ -24,7 +24,7 @@ export interface IExtensionDescription {
|
||||
readonly engines: {
|
||||
vscode: string;
|
||||
// {{SQL CARBON EDIT}}
|
||||
sqlops?: string;
|
||||
azdata?: string;
|
||||
};
|
||||
readonly main?: string;
|
||||
readonly contributes?: { [point: string]: any; };
|
||||
|
||||
@@ -89,8 +89,8 @@ class ExtensionManifestParser extends ExtensionManifestHandler {
|
||||
manifest.uuid = manifest.__metadata.id;
|
||||
}
|
||||
// {{SQL CARBON EDIT}}
|
||||
if (manifest.engines && !manifest.engines.sqlops) {
|
||||
manifest.engines.sqlops = '*';
|
||||
if (manifest.engines && !manifest.engines.azdata) {
|
||||
manifest.engines.azdata = '*';
|
||||
}
|
||||
delete manifest.__metadata;
|
||||
return manifest;
|
||||
|
||||
Reference in New Issue
Block a user