Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
fix(deployment): Fix the plugin-remote init which is missing now a me…
Browse files Browse the repository at this point in the history
…thod (#676)

* fix(deployment): Fix the plugin-remote init which is missing now a method

Change-Id: I22e1a15dae39153f1d3b5cf55b6a6f6d31711c17
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
Co-authored-by: Artem Zatsarynnyi <azatsary@redhat.com>
  • Loading branch information
benoitf and azatsarynnyy authored Mar 19, 2020
1 parent c393f53 commit 4c09edc
Show file tree
Hide file tree
Showing 4 changed files with 407 additions and 354 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'reflect-metadata';
import * as http from 'http';
import * as theia from '@theia/plugin';
import * as ws from 'ws';
import * as fs from 'fs';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as os from 'os';
import { logger } from '@theia/core';
Expand Down Expand Up @@ -385,6 +385,8 @@ class PluginDeployerHandlerImpl implements PluginDeployerHandler {
// announced ?
private announced = false;

private readonly deployedLocations = new Map<string, Set<string>>();

/**
* Managed plugin metadata backend entries.
*/
Expand Down Expand Up @@ -460,20 +462,42 @@ class PluginDeployerHandlerImpl implements PluginDeployerHandler {
}

const metadata = this.reader.readMetadata(manifest);

const deployedLocations = this.deployedLocations.get(metadata.model.id) || new Set<string>();
deployedLocations.add(entry.rootPath);
this.deployedLocations.set(metadata.model.id, deployedLocations);

if (this.deployedBackendPlugins.has(metadata.model.id)) {
return;
}

const deployed: DeployedPlugin = { metadata };
const { type } = entry;
const deployed: DeployedPlugin = { metadata, type };
deployed.contributes = this.reader.readContribution(manifest);
this.deployedBackendPlugins.set(metadata.model.id, deployed);
currentBackendDeployedPlugins.push(deployed);
this.logger.info(`Deploying ${entryPoint} plugin "${metadata.model.name}@${metadata.model.version}" from "${metadata.model.entryPoint[entryPoint] || pluginPath}"`);
} catch (e) {
console.error(`Failed to deploy ${entryPoint} plugin from '${pluginPath}' path`, e);
}
}

async undeployPlugin(pluginId: string): Promise<boolean> {
this.deployedBackendPlugins.delete(pluginId);
const deployedLocations = this.deployedLocations.get(pluginId);
if (!deployedLocations) {
return false;
}
this.deployedLocations.delete(pluginId);
for (const location of deployedLocations) {
try {
await fs.remove(location);
} catch (e) {
console.error(`[${pluginId}]: failed to undeploy from "${location}", reason`, e);
}
}
return true;
}

}

class OutputChannelLogCallback implements LogCallback {
Expand Down
1 change: 0 additions & 1 deletion plugins/github-auth-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@eclipse-che/plugin": "0.0.1",
"rimraf": "2.6.2",
"typescript-formatter": "7.2.2",
"typescript": "2.9.2",
"ts-loader": "^4.1.0"
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion plugins/telemetry-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@eclipse-che/plugin": "0.0.1",
"rimraf": "2.6.2",
"typescript-formatter": "7.2.2",
"typescript": "2.9.2",
"ts-loader": "^4.1.0"
},
"scripts": {
Expand Down
Loading

0 comments on commit 4c09edc

Please sign in to comment.