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

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

Merged
merged 3 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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