Merge pull request #45533 from oriash93/oriash93/45072

Support for updating extensions from CLI
This commit is contained in:
Sandeep Somavarapu
2018-07-02 15:06:07 +02:00
committed by GitHub

View File

@@ -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 semver from 'semver';
import { TPromise } from 'vs/base/common/winjs.base';
import { sequence } from 'vs/base/common/async';
@@ -114,13 +115,6 @@ class Main {
.filter(e => !/\.vsix$/i.test(e))
.map(id => () => {
return this.extensionManagementService.getInstalled(LocalExtensionType.User).then(installed => {
const isInstalled = installed.some(e => getId(e.manifest) === id);
if (isInstalled) {
console.log(localize('alreadyInstalled', "Extension '{0}' is already installed.", id));
return TPromise.as(null);
}
return this.extensionGalleryService.query({ names: [id], source: 'cli' })
.then<IPager<IGalleryExtension>>(null, err => {
if (err.responseText) {
@@ -141,8 +135,26 @@ class Main {
return TPromise.wrapError(new Error(`${notFound(id)}\n${useId}`));
}
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
console.log(localize('installing', "Installing..."));
const isInstalled = installed.some(e => getId(e.manifest) === id);
if (isInstalled) {
const installedExtension = installed.filter(e => getId(e.manifest) === id)[0];
const installedVersion = installedExtension.manifest.version;
const newestVersion = extension.version;
const shouldUpdate = semver.gt(newestVersion, installedVersion);
if (shouldUpdate) {
console.log(localize('foundNewerVersion', "Installed version is '{0}', found newer version '{1}' in the marketplace.", installedVersion, newestVersion));
console.log(localize('updating', "Updating..."));
} else {
console.log(localize('alreadyUpdated', "Installed version is the latest version."));
return TPromise.as(null);
}
}
else {
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
console.log(localize('installing', "Installing..."));
}
return this.extensionManagementService.installFromGallery(extension)
.then(