Skip to content

Commit

Permalink
Added uninstall behaviour
Browse files Browse the repository at this point in the history
plus smaller bugfixes and adapted versions

Signed-off-by: jbicker <jan.bicker@typefox.io>
  • Loading branch information
jbicker committed Dec 6, 2019
1 parent 968f4c0 commit cea37e7
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@theia/typescript": "^0.13.0",
"@theia/userstorage": "^0.13.0",
"@theia/variable-resolver": "^0.13.0",
"@theia/vsx-registry": "^0.13.0",
"@theia/workspace": "^0.13.0"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@theia/typescript": "^0.13.0",
"@theia/userstorage": "^0.13.0",
"@theia/variable-resolver": "^0.13.0",
"@theia/vsx-registry": "^0.13.0",
"@theia/workspace": "^0.13.0"
},
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ export interface PluginDeployerHandler {
deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise<void>;
deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise<void>;

removeDeployedPluginId(pluginId: string): void;

getPluginDependencies(pluginToBeInstalled: PluginDeployerEntry): Promise<PluginDependencies | undefined>
}

Expand Down Expand Up @@ -670,6 +672,8 @@ export interface PluginServer {
*/
deploy(pluginEntry: string): Promise<void>;

undeploy(pluginId: string): Promise<void>;

setStorageValue(key: string, value: KeysToAnyValues, kind: PluginStorageKind): Promise<boolean>;
getStorageValue(key: string, kind: PluginStorageKind): Promise<KeysToAnyValues>;
getAllStorageValues(kind: PluginStorageKind): Promise<KeysToKeysToAnyValue>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler {
return [...this.deployedBackendPlugins.keys()];
}

removeDeployedPluginId(pluginId: string): void {
if (this.deployedBackendPlugins.get(pluginId)) {
this.deployedBackendPlugins.delete(pluginId);
}
if (this.deployedFrontendPlugins.get(pluginId)) {
this.deployedFrontendPlugins.delete(pluginId);
}
}

getDeployedPlugin(pluginId: string): DeployedPlugin | undefined {
const metadata = this.deployedBackendPlugins.get(pluginId);
if (metadata) {
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-ext/src/main/node/plugin-deployer-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export class PluginDeployerImpl implements PluginDeployer {

}

public async undeploy(pluginId: string): Promise<void> {
this.pluginDeployerHandler.removeDeployedPluginId(pluginId);
this.onDidDeployEmitter.fire();
}

public async deploy(pluginEntry: string): Promise<void> {
await this.deployMultipleEntries([pluginEntry]);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/main/node/plugin-server-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class PluginServerHandler implements PluginServer {
return this.pluginDeployer.deploy(pluginEntry);
}

undeploy(pluginId: string): Promise<void> {
return this.pluginDeployer.undeploy(pluginId);
}

setStorageValue(key: string, value: KeysToAnyValues, kind: PluginStorageKind): Promise<boolean> {
return this.pluginsKeyValueStorage.set(key, value, kind);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/vsx-registry/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@theia/vsx-registry",
"version": "0.12.0",
"version": "0.13.0",
"description": "Theia - VSX Registry",
"dependencies": {
"@theia/core": "^0.12.0",
"@theia/plugin-ext": "^0.12.0",
"@theia/core": "^0.13.0",
"@theia/plugin-ext": "^0.13.0",
"@types/sanitize-html": "^1.13.31",
"@types/showdown": "^1.7.1",
"sanitize-html": "^1.14.1",
Expand Down Expand Up @@ -42,7 +42,7 @@
"test": "theiaext test"
},
"devDependencies": {
"@theia/ext-scripts": "^0.12.0"
"@theia/ext-scripts": "^0.13.0"
},
"nyc": {
"extends": "../../configs/nyc.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ export class VSXRegistryListWidget extends ReactWidget {
this.title.label = this.options.label;

this.model.onExtensionsChanged(() => {
this.extensions = this.model.getExtensionsByLocation(this.options.location);
this.update();
this.updateExtensionList();
});
this.updateExtensionList();
}

protected updateExtensionList(): void {
this.extensions = this.model.getExtensionsByLocation(this.options.location);
this.update();
}

protected render(): React.ReactNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class VSXRegistryWidget extends ViewContainer {
});
this.panel.node.tabIndex = -1;
layout.addWidget(this.vscxSearchbar);
this.vscxSearchbar.update();
layout.addWidget(this.panel);
}
}
9 changes: 4 additions & 5 deletions packages/vsx-registry/src/browser/vsx-registry-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ export class VSXRegistryService {
protected async init(): Promise<void> {
this.vsxRegistryPreferences.onPreferenceChanged(e => {
this.apiUrl = this.vsxRegistryPreferences['vsx-registry.api-url'];
this.toDispose.push(this.pluginSupport.onDidChangePlugins(() => this.updateInstalled()));
this.updateSearch();
this.updateInstalled();
});
this.toDispose.push(this.pluginSupport.onDidChangePlugins(() => this.updateInstalled()));
}

protected createEndpoint(arr: string[], queries?: { key: string, value: string | number }[]): string {
Expand Down Expand Up @@ -100,10 +101,8 @@ export class VSXRegistryService {
}

async uninstall(extension: VSCodeExtensionPart): Promise<void> {
let res: () => void;
const p = new Promise<void>(r => res = r);
setTimeout(() => res(), 3000);
return p;
const id = extension.publisher.toLowerCase() + '.' + extension.name.toLowerCase();
await this.pluginServer.undeploy(id);
}

async outdated(): Promise<VSCodeExtensionPart[]> {
Expand Down

0 comments on commit cea37e7

Please sign in to comment.