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

Modify 'configStorage' path for remote plugin #488

Merged
merged 1 commit into from
Oct 16, 2019
Merged
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 @@ -13,10 +13,11 @@ import * as http from 'http';
import * as ws from 'ws';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import { logger } from '@theia/core';
import { ILogger } from '@theia/core/lib/common';
import { Emitter } from '@theia/core/lib/common/event';
import { MAIN_RPC_CONTEXT, PluginDeployer, PluginDeployerEntry, PluginDependencies, DeployedPlugin, PluginEntryPoint } from '@theia/plugin-ext';
import { MAIN_RPC_CONTEXT, PluginDeployer, PluginDeployerEntry, PluginDependencies, DeployedPlugin, PluginEntryPoint, PluginManagerStartParams } from '@theia/plugin-ext';
import pluginVscodeBackendModule from '@theia/plugin-ext-vscode/lib/node/plugin-vscode-backend-module';
import { RPCProtocolImpl } from '@theia/plugin-ext/lib/common/rpc-protocol';
import { PluginDeployerHandler } from '@theia/plugin-ext/lib/common';
Expand All @@ -30,11 +31,16 @@ import { TerminalContainerAware } from './terminal-container-aware';
import { PluginDiscovery } from './plugin-discovery';
import { PluginReaderExtension } from './plugin-reader-extension';
import { Deferred } from '@theia/core/lib/common/promise-util';
import { PluginManagerExtImpl } from '@theia/plugin-ext/lib/plugin/plugin-manager';

interface CheckAliveWS extends ws {
alive: boolean;
}

function modifyPathToLocal(origPath: string): string {
return path.join(os.homedir(), origPath.substr(0, '/home/theia/'.length));
}

@injectable()
export class PluginRemoteInit {

Expand Down Expand Up @@ -99,6 +105,15 @@ export class PluginRemoteInit {

this.pluginReaderExtension = inversifyContainer.get(PluginReaderExtension);

// Modify 'configStorage' objects path, to use current user home directory
// in remote plugin image '/home/theia' doesn't exist
const originalStart = PluginManagerExtImpl.prototype.$start;
PluginManagerExtImpl.prototype.$start = async function (params: PluginManagerStartParams): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a hack: if the storage path is not in fact determined from the parameters, we should refactor the plugin API to make the storage path the responsiblity of the plugin runner.
I understand that we're trying to get this in urgently, so we do a solution in che-theia, but could we open an issue on the theia repo to do the refactoring?

params.configStorage = { hostLogPath: modifyPathToLocal(params.configStorage.hostLogPath), hostStoragePath: modifyPathToLocal(params.configStorage.hostLogPath) };
// call original method
return originalStart.call(this, params);
};

// display message about process being started
console.log(`Theia Endpoint ${process.pid}/pid listening on port`, this.pluginPort);
}
Expand Down