提交 60798fda 编写于 作者: J Joao Moreno

remove galleryInformation

上级 f5cbb9fe
......@@ -94,7 +94,7 @@ class Main {
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
console.log(localize('installing', "Installing..."));
return this.extensionManagementService.install(extension.manifest).then(() => {
return this.extensionManagementService.install(extension).then(() => {
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.manifest.version));
});
});
......
......@@ -40,7 +40,6 @@ export interface IGalleryMetadata {
}
export interface IExtension extends IExtensionManifest {
galleryInformation?: IGalleryMetadata;
path?: string;
}
......@@ -86,7 +85,7 @@ export interface IExtensionManagementService {
onUninstallExtension: Event<string>;
onDidUninstallExtension: Event<string>;
install(extension: IExtensionManifest): TPromise<void>;
install(extension: IGalleryExtension): TPromise<void>;
install(zipPath: string): TPromise<void>;
uninstall(extension: IExtension): TPromise<void>;
getInstalled(includeDuplicateVersions?: boolean): TPromise<IExtension[]>;
......
......@@ -7,7 +7,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc';
import { IExtensionManagementService, IExtension, DidInstallExtensionEvent } from './extensionManagement';
import { IExtensionManagementService, IExtension, IGalleryExtension, DidInstallExtensionEvent } from './extensionManagement';
import Event from 'vs/base/common/event';
export interface IExtensionManagementChannel extends IChannel {
......@@ -56,7 +56,7 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
private _onDidUninstallExtension = eventFromCall<string>(this.channel, 'event:onDidUninstallExtension');
get onDidUninstallExtension(): Event<string> { return this._onDidUninstallExtension; }
install(extension: IExtension): TPromise<void>;
install(extension: IGalleryExtension): TPromise<void>;
install(zipPath: string): TPromise<void>;
install(arg: any): TPromise<void> {
return this.channel.call('install', arg);
......
......@@ -15,7 +15,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { flatten } from 'vs/base/common/arrays';
import { extract, buffer } from 'vs/base/node/zip';
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { IExtensionManagementService, IExtension, IExtensionManifest, IGalleryMetadata, IGalleryVersion } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionManagementService, IExtension, IGalleryExtension, IExtensionManifest, IGalleryVersion } from 'vs/platform/extensionManagement/common/extensionManagement';
import { download, json, IRequestOptions } from 'vs/base/node/request';
import { getProxyAgent } from 'vs/base/node/proxy';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
......@@ -60,7 +60,7 @@ function validate(zipPath: string, extension?: IExtension, version = extension &
});
}
function createExtension(manifest: IExtensionManifest, galleryInformation?: IGalleryMetadata, path?: string): IExtension {
function createExtension(manifest: IExtensionManifest, path?: string): IExtension {
const extension: IExtension = {
name: manifest.name,
displayName: manifest.displayName || manifest.name,
......@@ -70,9 +70,9 @@ function createExtension(manifest: IExtensionManifest, galleryInformation?: IGal
description: manifest.description || ''
};
if (galleryInformation) {
extension.galleryInformation = galleryInformation;
}
// if (galleryInformation) {
// extension.galleryInformation = galleryInformation;
// }
if (path) {
extension.path = path;
......@@ -126,7 +126,7 @@ export class ExtensionManagementService implements IExtensionManagementService {
// ];
}
install(extension: IExtensionManifest): TPromise<void>;
install(extension: IGalleryExtension): TPromise<void>;
install(zipPath: string): TPromise<void>;
install(arg: any): TPromise<void> {
if (types.isString(arg)) {
......@@ -143,39 +143,35 @@ export class ExtensionManagementService implements IExtensionManagementService {
});
}
private installFromGallery(extension: IExtension): TPromise<void> {
const id = getExtensionId(extension);
const galleryInformation = extension.galleryInformation;
if (!galleryInformation) {
return TPromise.wrapError<void>(new Error(nls.localize('missingGalleryInformation', "Gallery information is missing")));
}
private installFromGallery(extension: IGalleryExtension): TPromise<void> {
const id = getExtensionId(extension.manifest);
this._onInstallExtension.fire(id);
return this.getLastValidExtensionVersion(extension, extension.galleryInformation.versions).then(versionInfo => {
return this.getLastValidExtensionVersion(extension).then(versionInfo => {
const version = versionInfo.version;
const url = versionInfo.downloadUrl;
const headers = versionInfo.downloadHeaders;
const zipPath = path.join(tmpdir(), galleryInformation.id);
const extensionPath = path.join(this.extensionsPath, getExtensionId(extension, version));
const manifestPath = path.join(extensionPath, 'package.json');
const zipPath = path.join(tmpdir(), extension.id);
const extensionPath = path.join(this.extensionsPath, getExtensionId(extension.manifest, version));
return this.request(url)
.then(opts => assign(opts, { headers }))
.then(opts => download(zipPath, opts))
.then(() => validate(zipPath, extension, version))
.then(manifest => extract(zipPath, extensionPath, { sourcePath: 'extension', overwrite: true }).then(() => manifest))
.then(manifest => assign({ __metadata: galleryInformation }, manifest))
.then(manifest => pfs.writeFile(manifestPath, JSON.stringify(manifest, null, '\t')))
.then(() => validate(zipPath, extension.manifest, version))
.then(manifest => extract(zipPath, extensionPath, { sourcePath: 'extension', overwrite: true }))
.then(() => this._onDidInstallExtension.fire({ id }))
.then<void>(null, error => { this._onDidInstallExtension.fire({ id, error }); return TPromise.wrapError(error); });
});
}
private getLastValidExtensionVersion(extension: IExtension, versions: IGalleryVersion[]): TPromise<IGalleryVersion> {
private getLastValidExtensionVersion(extension: IGalleryExtension): TPromise<IGalleryVersion> {
return this._getLastValidExtensionVersion(extension, extension.versions);
}
private _getLastValidExtensionVersion(extension: IGalleryExtension, versions: IGalleryVersion[]): TPromise<IGalleryVersion> {
if (!versions.length) {
return TPromise.wrapError(new Error(nls.localize('noCompatible', "Couldn't find a compatible version of {0} with this version of Code.", extension.displayName)));
return TPromise.wrapError(new Error(nls.localize('noCompatible', "Couldn't find a compatible version of {0} with this version of Code.", extension.manifest.displayName)));
}
const version = versions[0];
......@@ -189,7 +185,7 @@ export class ExtensionManagementService implements IExtensionManagementService {
};
if (!isValidExtensionVersion(pkg.version, desc, [])) {
return this.getLastValidExtensionVersion(extension, versions.slice(1));
return this._getLastValidExtensionVersion(extension, versions.slice(1));
}
return version;
......@@ -203,7 +199,7 @@ export class ExtensionManagementService implements IExtensionManagementService {
this._onInstallExtension.fire(id);
return extract(zipPath, extensionPath, { sourcePath: 'extension', overwrite: true })
.then(() => createExtension(manifest, (<any> manifest).__metadata, extensionPath))
.then(() => createExtension(manifest, extensionPath))
.then(extension => this._onDidInstallExtension.fire({ id }))
.then<void>(null, error => { this._onDidInstallExtension.fire({ id, error }); return TPromise.wrapError(error); });
});
......@@ -248,7 +244,7 @@ export class ExtensionManagementService implements IExtensionManagementService {
return limiter.queue(
() => pfs.readFile(path.join(extensionPath, 'package.json'), 'utf8')
.then(raw => parseManifest(raw))
.then(manifest => createExtension(manifest, (<any> manifest).__metadata, extensionPath))
.then(manifest => createExtension(manifest, extensionPath))
.then(null, () => null)
);
})))
......
......@@ -17,15 +17,17 @@ export function extensionEquals(one: IExtensionManifest, other: IExtensionManife
return one.publisher === other.publisher && one.name === other.name;
}
export function getTelemetryData(extension: IExtension): any {
return {
id: getExtensionId(extension),
name: extension.name,
galleryId: extension.galleryInformation ? extension.galleryInformation.id : null,
publisherId: extension.galleryInformation ? extension.galleryInformation.publisherId : null,
publisherName: extension.publisher,
publisherDisplayName: extension.galleryInformation ? extension.galleryInformation.publisherDisplayName : null
};
export function getTelemetryData(extension: any): any {
return {};
// TODO
// return {
// id: getExtensionId(extension),
// name: extension.name,
// galleryId: extension.galleryInformation ? extension.galleryInformation.id : null,
// publisherId: extension.galleryInformation ? extension.galleryInformation.publisherId : null,
// publisherName: extension.publisher,
// publisherDisplayName: extension.galleryInformation ? extension.galleryInformation.publisherDisplayName : null
// };
}
export function getOutdatedExtensions(extensionsService: IExtensionManagementService, galleryService: IExtensionGalleryService): TPromise<IExtension[]> {
......
......@@ -12,7 +12,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IMessageService } from 'vs/platform/message/common/message';
import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
import { IExtensionManagementService, IExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionManagementService, IExtension, IGalleryExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { extensionEquals, getTelemetryData } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
......@@ -123,11 +123,11 @@ export class InstallAction extends Action {
super('extensions.install', label, 'octicon octicon-cloud-download', true);
}
public run(extension: IExtension): TPromise<any> {
public run(extension: IGalleryExtension): TPromise<any> {
this.enabled = false;
return this.extensionManagementService.getInstalled()
.then(installed => installed.some(e => extensionEquals(e, extension)))
.then(installed => installed.some(e => extensionEquals(e, extension.manifest)))
.then(isUpdate => {
return this.extensionManagementService
.install(extension)
......@@ -137,10 +137,10 @@ export class InstallAction extends Action {
});
}
private onSuccess(extension: IExtension, isUpdate: boolean) {
private onSuccess(extension: IGalleryExtension, isUpdate: boolean) {
this.reportTelemetry(extension, isUpdate, true);
this.messageService.show(Severity.Info, {
message: nls.localize('success-installed', "'{0}' was successfully installed. Restart to enable it.", extension.displayName),
message: nls.localize('success-installed', "'{0}' was successfully installed. Restart to enable it.", extension.manifest.displayName),
actions: [
CloseAction,
this.instantiationService.createInstance(ReloadWindowAction, ReloadWindowAction.ID, nls.localize('restartNow', "Restart Now"))
......@@ -148,12 +148,12 @@ export class InstallAction extends Action {
});
}
private onError(err: Error, extension: IExtension, isUpdate: boolean) {
private onError(err: Error, extension: IGalleryExtension, isUpdate: boolean) {
this.reportTelemetry(extension, isUpdate, false);
this.messageService.show(Severity.Error, err);
}
private reportTelemetry(extension: IExtension, isUpdate: boolean, success: boolean) {
private reportTelemetry(extension: IGalleryExtension, isUpdate: boolean, success: boolean) {
const event = isUpdate ? 'extensionGallery:update' : 'extensionGallery:install';
const data = assign(getTelemetryData(extension), { success });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册