From 601cd4a8beebe70cb934015733f5703e5a648111 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Thu, 30 May 2019 17:25:45 +0300 Subject: [PATCH 1/2] Clean up theia-endpoint-runtime directory structure Signed-off-by: Anatoliy Bazko --- che-theia-init-sources.yml | 2 +- dockerfiles/theia-endpoint-runtime/.gitignore | 2 - dockerfiles/theia-endpoint-runtime/Dockerfile | 8 +- dockerfiles/theia-endpoint-runtime/build.sh | 8 + .../theia-endpoint-runtime/package.json | 34 -- .../src/node/dummy-trace-logger.ts | 96 ----- .../src/node/hosted-plugin-remote.ts | 180 ---------- .../src/node/plugin-discovery.ts | 176 ---------- .../src/node/plugin-remote-backend-module.ts | 29 -- .../src/node/plugin-remote-init.ts | 331 ------------------ .../src/node/plugin-remote-mapping.ts | 81 ----- .../src/node/plugin-remote.ts | 30 -- .../src/node/remote-metadata-processor.ts | 36 -- .../src/node/server-plugin-proxy-runner.ts | 58 --- .../src/node/terminal-container-aware.ts | 66 ---- .../src/node/websocket.ts | 117 ------- .../theia-endpoint-runtime/tsconfig.json | 16 - .../tsfmt.json | 0 .../tslint.json | 0 19 files changed, 13 insertions(+), 1257 deletions(-) delete mode 100644 dockerfiles/theia-endpoint-runtime/package.json delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/dummy-trace-logger.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/hosted-plugin-remote.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/plugin-discovery.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-backend-module.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-init.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-mapping.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/plugin-remote.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/remote-metadata-processor.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/server-plugin-proxy-runner.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/terminal-container-aware.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/src/node/websocket.ts delete mode 100644 dockerfiles/theia-endpoint-runtime/tsconfig.json rename {dockerfiles/theia-endpoint-runtime => extensions/eclipse-che-theia-plugin-remote}/tsfmt.json (100%) rename {dockerfiles/theia-endpoint-runtime => extensions/eclipse-che-theia-plugin-remote}/tslint.json (100%) diff --git a/che-theia-init-sources.yml b/che-theia-init-sources.yml index 3530905cc..989c818d6 100644 --- a/che-theia-init-sources.yml +++ b/che-theia-init-sources.yml @@ -1,7 +1,7 @@ sources: - source: https://github.com/eclipse/che-theia extensions: - - dockerfiles/theia-endpoint-runtime + - extensions/eclipse-che-theia-plugin-remote - extensions/eclipse-che-theia-plugin - extensions/eclipse-che-theia-plugin-ext - extensions/eclipse-che-theia-terminal diff --git a/dockerfiles/theia-endpoint-runtime/.gitignore b/dockerfiles/theia-endpoint-runtime/.gitignore index 86213de7c..9d991d754 100644 --- a/dockerfiles/theia-endpoint-runtime/.gitignore +++ b/dockerfiles/theia-endpoint-runtime/.gitignore @@ -1,8 +1,6 @@ theia-plugin-ext docker-build -node_modules .browser_modules -lib *.log *-app/* !*-app/package.json diff --git a/dockerfiles/theia-endpoint-runtime/Dockerfile b/dockerfiles/theia-endpoint-runtime/Dockerfile index 6b29376b7..27baf5307 100644 --- a/dockerfiles/theia-endpoint-runtime/Dockerfile +++ b/dockerfiles/theia-endpoint-runtime/Dockerfile @@ -36,16 +36,16 @@ ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/theia-ide/theia/g ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/eclipse/che-theia/git/refs/head /tmp/branch_info.json # Grab dependencies -COPY /package.json /home/workspace/packages/theia-remote/ +COPY /docker-build/theia-plugin-remote/package.json /home/workspace/packages/theia-remote/ RUN cd /home/workspace/packages/theia-remote/ && yarn install --ignore-scripts # Compile COPY /docker-build/configs /home/workspace/configs -COPY *.json /home/workspace/packages/theia-remote/ -COPY /src /home/workspace/packages/theia-remote/src +COPY /docker-build/theia-plugin-remote/*.json /home/workspace/packages/theia-remote/ +COPY /docker-build/theia-plugin-remote/src /home/workspace/packages/theia-remote/src COPY /docker-build/theia-plugin-ext /home/workspace/packages/theia-plugin-ext COPY /docker-build/theia-plugin /home/workspace/packages/theia-plugin -COPY /tsconfig.json /home/workspace/packages/theia-plugin/tsconfig.json +COPY /docker-build/theia-plugin-remote/tsconfig.json /home/workspace/packages/theia-plugin/tsconfig.json COPY /etc/package.json /home/workspace RUN cd /home/workspace/ && yarn install diff --git a/dockerfiles/theia-endpoint-runtime/build.sh b/dockerfiles/theia-endpoint-runtime/build.sh index 6c3377db9..a71f7a76a 100755 --- a/dockerfiles/theia-endpoint-runtime/build.sh +++ b/dockerfiles/theia-endpoint-runtime/build.sh @@ -35,6 +35,14 @@ cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-ext/webpack.config. echo "Copying ${base_dir}/../../configs --> ${LOCAL_ASSEMBLY_DIR}/configs" cp -r "${base_dir}/../../configs/." "${LOCAL_ASSEMBLY_DIR}/configs" +echo "Copying ${base_dir}/../../extensions/eclipse-che-theia-plugin-remote --> ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" +mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote +cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote/src/" +cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" +cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tsconfig.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" +cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tsfmt.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" +cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tslint.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" + init --name:theia-endpoint-runtime "$@" build diff --git a/dockerfiles/theia-endpoint-runtime/package.json b/dockerfiles/theia-endpoint-runtime/package.json deleted file mode 100644 index 50b05c9c2..000000000 --- a/dockerfiles/theia-endpoint-runtime/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@eclipse-che/theia-remote", - "author": "Florent Benoit", - "version": "0.0.1", - "license": "EPL-2.0", - "files": [ - "lib", - "src" - ], - "dependencies": { - "@theia/plugin-ext": "next", - "@theia/plugin-ext-vscode": "next", - "@theia/core": "next" - }, - "devDependencies": { - "typescript-formatter": "7.2.2", - "concurrently": "^3.5.0" - }, - "scripts": { - "prepare": "yarn clean && yarn build", - "clean": "rimraf lib", - "format": "tsfmt -r --useTsfmt ../../configs/tsfmt.json", - "lint": "tslint -c ../../configs/tslint.json --project tsconfig.json", - "lint:fix": "tslint -c ../../configs/tslint.json --fix --project .", - "compile": "tsc", - "build": "concurrently -n \"format,lint,compile\" -c \"red,green,blue\" \"yarn format\" \"yarn lint:fix\" \"yarn compile\"", - "watch": "tsc -w" - }, - "theiaExtensions": [ - { - "backend": "lib/node/plugin-remote-backend-module" - } - ] -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/dummy-trace-logger.ts b/dockerfiles/theia-endpoint-runtime/src/node/dummy-trace-logger.ts deleted file mode 100644 index c10adef22..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/dummy-trace-logger.ts +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { ILogger } from '@theia/core/lib/common'; -import { Loggable } from '@theia/core'; -import { injectable } from 'inversify'; - -/** - * Dummty trace logger used to provide a logger with inversify. - */ -@injectable() -export class DummyTraceLogger implements ILogger { - - async log(logLevel: number, loggable: Loggable): Promise { - // do nothing - } - - async setLogLevel(logLevel: number): Promise { - - } - async getLogLevel(): Promise { - return 0; - } - async isEnabled(logLevel: number): Promise { - return true; - } - async ifEnabled(logLevel: number): Promise { - } - async isTrace(): Promise { - return true; - } - async ifTrace(): Promise { - } - async isDebug(): Promise { - return true; - } - async ifDebug(): Promise { - } - async isInfo(): Promise { - return true; - } - async ifInfo(): Promise { - } - async isWarn(): Promise { - return true; - } - async ifWarn(): Promise { - } - async isError(): Promise { - return true; - } - async ifError(): Promise { - } - async isFatal(): Promise { - return true; - } - async ifFatal(): Promise { - } - child(name: string): ILogger { - return this; - } - - // tslint:disable-next-line:no-any - async trace(message: any, ...params: any[]): Promise { - console.trace(message, ...params); - } - - // tslint:disable-next-line:no-any - async debug(message: any, ...params: any[]): Promise { - console.debug(message, ...params); - } - // tslint:disable-next-line:no-any - async info(message: any, ...params: any[]): Promise { - console.info(message, ...params); - } - // tslint:disable-next-line:no-any - async warn(message: any, ...params: any[]): Promise { - console.warn(message, ...params); - } - // tslint:disable-next-line:no-any - async error(message: any, ...params: any[]): Promise { - console.error(message, ...params); - } - // tslint:disable-next-line:no-any - async fatal(message: any, ...params: any[]): Promise { - console.error(message, ...params); - } - -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/hosted-plugin-remote.ts b/dockerfiles/theia-endpoint-runtime/src/node/hosted-plugin-remote.ts deleted file mode 100644 index 10d537841..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/hosted-plugin-remote.ts +++ /dev/null @@ -1,180 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { injectable, inject, postConstruct } from 'inversify'; -import { ILogger } from '@theia/core/lib/common'; -import { HostedPluginClient, PluginMetadata } from '@theia/plugin-ext'; -import { HostedPluginMapping } from './plugin-remote-mapping'; -import { Websocket } from './websocket'; -import { getPluginId } from '@theia/plugin-ext/lib/common'; -import { PluginDiscovery } from './plugin-discovery'; - -/** - * Class handling remote connection for executing plug-ins. - * @author Florent Benoit - */ -@injectable() -export class HostedPluginRemote { - - private client: HostedPluginClient; - - @inject(ILogger) - protected readonly logger: ILogger; - - @inject(HostedPluginMapping) - protected hostedPluginMapping: HostedPluginMapping; - - /** - * mapping between endpoint name and the websockets - */ - private endpointsSockets = new Map(); - - /** - * mapping between endpoint's name and the websocket endpoint - */ - private pluginsMetadata: Map = new Map(); - - @postConstruct() - protected postConstruct(): void { - this.setupDiscovery(); - this.setupWebsocket(); - } - - public clientClosed(): void { - - Array.from(this.endpointsSockets.values()).forEach(websocket => { - websocket.send(JSON.stringify({ - 'internal': { - 'method': 'stop' - } - })); - websocket.close(); - }); - } - - /** - * Called when a client is connecting to this endpoint - */ - public setClient(client: HostedPluginClient): void { - this.client = client; - } - - /** - * Handle discovery of other endpoints on same network. - */ - protected setupDiscovery(): void { - const pluginDiscovery = new PluginDiscovery(this.logger); - pluginDiscovery.onNewEndpoint = announceRequest => { - const endpointAdress = announceRequest.websocketAddress; - // only accept new endpoint address - if (!this.endpointsSockets.has(endpointAdress)) { - this.logger.debug(`Adding a new remote endpoint from ${endpointAdress}`); - this.connect(endpointAdress); - } - }; - pluginDiscovery.discover(); - } - - /** - * Handle the creation of connection to remote endpoints. - */ - setupWebsocket(): void { - this.hostedPluginMapping.getEndPoints().forEach(endpointAdress => this.connect(endpointAdress)); - } - - connect(endpointAdress: string) { - this.logger.debug(`Establish websocket connection to ${endpointAdress}`); - const websocket = new Websocket(this.logger, endpointAdress); - this.endpointsSockets.set(endpointAdress, websocket); - websocket.onMessage = (messageRaw: string) => { - const parsed = JSON.parse(messageRaw); - if (parsed.internal) { - this.handleLocalMessage(parsed.internal); - return; - } - this.sendToClient(messageRaw); - }; - - // when websocket is opened, send the order - websocket.onOpen = event => { - websocket.send(JSON.stringify({ - 'internal': { - 'endpointName': endpointAdress, - 'metadata': 'request' - } - })); - }; - } - - /** - * Checks if the given pluginID has a remote endpoint - */ - hasEndpoint(pluginID: string): boolean { - return this.hostedPluginMapping.hasEndpoint(pluginID); - } - - /** - * Handle the mesage to remotely send to a ws endpoint - * @param jsonMessage the given message - */ - // tslint:disable-next-line:no-any - onMessage(jsonMessage: any): void { - // do the routing depending on the plugin's endpoint - const pluginId = jsonMessage.pluginID; - - // socket ? - const endpoint = this.hostedPluginMapping.getPluginsEndPoints().get(pluginId); - if (!endpoint) { - this.logger.error('no endpoint configured for the given plugin', pluginId, 'skipping message'); - return; - } - const websocket = this.endpointsSockets.get(endpoint); - websocket!.send(JSON.stringify(jsonMessage.content)); - } - - /** - * Handle a local message - * @param message the message to analyze locally and not sending back to client - */ - // tslint:disable-next-line:no-any - handleLocalMessage(jsonMessage: any): void { - if (jsonMessage.metadata && jsonMessage.metadata.result) { - const metadatas: PluginMetadata[] = jsonMessage.metadata.result; - this.pluginsMetadata.set(jsonMessage.endpointName, metadatas); - // add the mapping retreived from external plug-in if not defined - metadatas.forEach(metadata => { - const entryName = getPluginId(metadata.model); - if (!this.hostedPluginMapping.getPluginsEndPoints().has(entryName)) { - this.hostedPluginMapping.getPluginsEndPoints().set(entryName, jsonMessage.endpointName); - } - }); - } - } - - /** - * Send the given message back to the client - * @param message the message to send - */ - // tslint:disable-next-line:no-any - sendToClient(message: any) { - if (this.client) { - this.client.postMessage(message); - } - - } - - /** - * Return plugin metadata found remotely - */ - async getExtraPluginMetadata(): Promise { - return [].concat.apply([], [...this.pluginsMetadata.values()]); - } - -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/plugin-discovery.ts b/dockerfiles/theia-endpoint-runtime/src/node/plugin-discovery.ts deleted file mode 100644 index 7c3cfc3ba..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/plugin-discovery.ts +++ /dev/null @@ -1,176 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import * as dgram from 'dgram'; -import { ILogger } from '@theia/core/lib/common'; - -/** - * Class handling discovery of nodes - * @author Florent Benoit - */ -export class PluginDiscovery { - - /** - * Default Multicast PORT. - */ - private static readonly DEFAULT_MULTICAST_PORT = '2503'; - - /** - * Default Multicast address. - */ - private static readonly DEFAULT_MULTICAST_ADDRESS = '225.0.0.3'; - - /** - * Multicast socket. - */ - private socket: dgram.Socket; - - /** - * port number for multicast discovery. - */ - private discoveryPort: number; - - /** - * port number for multicast discovery. - */ - private discoveryAddress: string; - - /** - * Unique identifier of ourself used to communicate with others - */ - private discoveryName: string; - - constructor(private readonly logger: ILogger, private readonly endpointPort?: number) { - this.discoveryName = `discovery[${Math.random().toString(36).substring(7)}]`; - } - - /** - * Enter in discovery mode. - * On start, it will : - * - request others to announce themselves - * - announce himself if endpoint. - */ - discover() { - - // if discovery is disabled, do not proceed with discover. - const discoveryDisabled = process.env.THEIA_PLUGIN_DISCOVERY_DISABLE || 'false'; - if (discoveryDisabled === 'true') { - this.logger.warn('Plugin discovery is disabled.'); - return; - } - - // configured port number - this.discoveryPort = parseInt(process.env.THEIA_PLUGIN_ENDPOINT_DISCOVERY_PORT || PluginDiscovery.DEFAULT_MULTICAST_PORT, 10); - - // configured adress - this.discoveryAddress = process.env.THEIA_PLUGIN_ENDPOINT_DISCOVERY_ADDRESS || PluginDiscovery.DEFAULT_MULTICAST_ADDRESS; - this.socket = dgram.createSocket({ type: 'udp4', reuseAddr: true }); - this.socket.bind(this.discoveryPort); - - // start to listen - this.socket.on('listening', () => { - this.socket.addMembership(this.discoveryAddress); - // announce if we're an endpoint - if (this.endpointPort) { - this.announceMySelf(); - } - this.requestEndpoints(); - }); - - // handle messages - this.socket.on('message', (msg: Buffer) => { - - // receive order - const jsonMessage: DiscoveryMessage = JSON.parse(msg.toString()); - - // ignore ourself - if (this.discoveryName === jsonMessage.id) { - return; - } - - // handle message based on the type - switch (jsonMessage.type) { - case 'REQUEST_ENDPOINTS': - // need to announce ourself but only if we're an endpoint - if (this.endpointPort) { - this.announceMySelf(); - } - break; - - case 'ANNOUNCE_ENDPOINT': - this.onNewEndpoint(JSON.parse(jsonMessage.content)); - break; - } - - }); - - } - - /** - * Sends the given message to the multicast discovery address. - */ - protected send(message: DiscoveryMessage) { - this.socket.send(JSON.stringify(message), this.discoveryPort, this.discoveryAddress); - } - - /** - * Greeting message announcing ourself to the others. - */ - protected announceMySelf() { - - const announceRequest: DiscoveryAnnounceRequest = { - websocketAddress: `ws://localhost:${this.endpointPort}` - }; - const announceMessage: DiscoveryMessage = { - id: this.discoveryName, - type: 'ANNOUNCE_ENDPOINT', - content: JSON.stringify(announceRequest) - }; - this.send(announceMessage); - - } - - /** - * Request message asking others to announce. - */ - protected requestEndpoints() { - - const announceMessage: DiscoveryMessage = { - id: this.discoveryName, - type: 'REQUEST_ENDPOINTS', - content: '' - }; - this.send(announceMessage); - - } - - // callback used when a new endpoint is registered - public onNewEndpoint(discoveryAnnounceRequest: DiscoveryAnnounceRequest) { } - -} - -/** - * Announce Request message format - */ -interface DiscoveryAnnounceRequest { - websocketAddress: string; -} - -/** - * Discovery message format - */ -interface DiscoveryMessage { - id: string, - - type: 'REQUEST_ENDPOINTS' | 'ANNOUNCE_ENDPOINT', - - content: string - -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-backend-module.ts b/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-backend-module.ts deleted file mode 100644 index 283342698..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-backend-module.ts +++ /dev/null @@ -1,29 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { ContainerModule } from 'inversify'; -import { HostedPluginRemote } from './hosted-plugin-remote'; -import { ServerPluginProxyRunner } from './server-plugin-proxy-runner'; -import { MetadataProcessor, ServerPluginRunner } from '@theia/plugin-ext/lib/common'; -import { RemoteMetadataProcessor } from './remote-metadata-processor'; -import { HostedPluginMapping } from './plugin-remote-mapping'; -import { ConnectionContainerModule } from '@theia/core/lib/node/messaging/connection-container-module'; - -const localModule = ConnectionContainerModule.create(({ bind }) => { - bind(HostedPluginRemote).toSelf().inSingletonScope(); - bind(ServerPluginRunner).to(ServerPluginProxyRunner).inSingletonScope(); -}); - -export default new ContainerModule(bind => { - bind(HostedPluginMapping).toSelf().inSingletonScope(); - bind(MetadataProcessor).to(RemoteMetadataProcessor).inSingletonScope(); - bind(ConnectionContainerModule).toConstantValue(localModule); -} -); diff --git a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-init.ts b/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-init.ts deleted file mode 100644 index d36e3a799..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-init.ts +++ /dev/null @@ -1,331 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import 'reflect-metadata'; -import * as http from 'http'; -import * as ws from 'ws'; -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, PluginMetadata } from '@theia/plugin-ext'; -import pluginVscodeBackendModule from '@theia/plugin-ext-vscode/lib/node/plugin-vscode-backend-module'; -import { RPCProtocolImpl } from '@theia/plugin-ext/lib/api/rpc-protocol'; -import { PluginDeployerHandler } from '@theia/plugin-ext/lib/common'; -import { PluginHostRPC } from '@theia/plugin-ext/lib/hosted/node/plugin-host-rpc'; -import { HostedPluginReader } from '@theia/plugin-ext/lib/hosted/node/plugin-reader'; -import pluginExtBackendModule from '@theia/plugin-ext/lib/plugin-ext-backend-module'; -import { Container, inject, injectable } from 'inversify'; -import { DummyTraceLogger } from './dummy-trace-logger'; -import pluginRemoteBackendModule from './plugin-remote-backend-module'; -import { TerminalContainerAware } from './terminal-container-aware'; -import { PluginDiscovery } from './plugin-discovery'; - -interface CheckAliveWS extends ws { - alive: boolean; -} - -@injectable() -export class PluginRemoteInit { - - // check alive - private static readonly CHECK_ALIVE_TIMEOUT = 30000; - - /** - * Max number of trying new port - */ - private static readonly MAX_RETRIES = 100; - - /** - * number of retries for finding port - */ - private retries: number = 0; - - /** - * Instance of the server for websocket - */ - private webSocketServer: ws.Server; - - /** - * store session ID - */ - private sessionId = 0; - - constructor(private pluginPort: number) { - - } - - async init(): Promise { - - this.webSocketServer = await this.initWebSocket(); - this.initWebsocketServer(); - - // Create inversify container - const inversifyContainer = new Container(); - - // bind logger to make it work - inversifyContainer.bind(ILogger).to(DummyTraceLogger).inSingletonScope(); - - // Bind Plug-in system - inversifyContainer.load(pluginExtBackendModule); - - // Bind VsCode system - inversifyContainer.load(pluginVscodeBackendModule); - - // override handler to our own class - inversifyContainer.bind(PluginDeployerHandlerImpl).toSelf().inSingletonScope(); - inversifyContainer.rebind(PluginDeployerHandler).toService(PluginDeployerHandlerImpl); - - // bind local stuff - inversifyContainer.load(pluginRemoteBackendModule); - - inversifyContainer.bind('plugin.port').toConstantValue(this.pluginPort); - - // start the deployer - const pluginDeployer = inversifyContainer.get(PluginDeployer); - pluginDeployer.start(); - - // display message about process being started - console.log(`Theia Endpoint ${process.pid}/pid listening on port`, this.pluginPort); - } - - initWebsocketServer() { - this.webSocketServer.on('connection', (socket: CheckAliveWS, request: http.IncomingMessage) => { - socket.alive = true; - socket.on('pong', () => socket.alive = true); - this.handleConnection(socket, request); - }); - setInterval(() => { - this.webSocketServer.clients.forEach((socket: CheckAliveWS) => { - if (socket.alive === false) { - return socket.terminate(); - } - socket.alive = false; - socket.ping(); - }); - }, PluginRemoteInit.CHECK_ALIVE_TIMEOUT); - } - - async handlePortInUse(): Promise { - // increment pluginPort - this.pluginPort++; - - if (this.retries > PluginRemoteInit.MAX_RETRIES) { - throw new Error(`Try to find a free port but aborting after trying ${this.retries} unsuccessful times.`); - } - this.retries++; - - // retry - return this.initWebSocket(); - } - - async initWebSocket(): Promise { - // start websocket server - const websocketServer = new ws.Server({ port: this.pluginPort }); - - return new Promise((resolve, reject) => { - // if port is already in use, try a new port of report the error - // tslint:disable-next-line:no-any - websocketServer.on('error', (error: any) => { - // if port is specified, respect it and does not try to find a new free port. - if (error.code === 'EADDRINUSE' && !process.env.THEIA_PLUGIN_ENDPOINT_PORT) { - try { - const portInUse = this.handlePortInUse(); - resolve(portInUse); - } catch (error) { - reject(error); - } - } else { - reject(new Error(`The port ${this.pluginPort} is already in used. \ -Please specify another port or do not set THEIA_PLUGIN_ENDPOINT_PORT env var \ -to pick-up automatically a free port`)); - } - }); - - // it is listening, resolve promise. - websocketServer.on('listening', () => { - resolve(websocketServer); - }); - }); - } - - // create a new client on top of socket - newClient(id: number, socket: ws): WebSocketClient { - const emitter = new Emitter(); - const webSocketClient = new WebSocketClient(id, socket, emitter); - webSocketClient.rpc = new RPCProtocolImpl({ - onMessage: emitter.event, - // send messages to this client - send: (m: {}) => { - webSocketClient.send(m); - } - }); - - const pluginHostRPC = new PluginHostRPC(webSocketClient.rpc); - pluginHostRPC.initialize(); - webSocketClient.pluginHostRPC = pluginHostRPC; - - // override window.createTerminal to be container aware - // tslint:disable-next-line:no-any - new TerminalContainerAware().overrideTerminal((webSocketClient.rpc as any).locals[MAIN_RPC_CONTEXT.TERMINAL_EXT.id]); - // tslint:disable-next-line:no-any - new TerminalContainerAware().overrideTerminalCreationOptionForDebug((webSocketClient.rpc as any).locals[MAIN_RPC_CONTEXT.DEBUG_EXT.id]); - - return webSocketClient; - } - - // Handle the connection received - handleConnection(socket: ws, request: http.IncomingMessage): void { - // create channel for discussing with this new client - const channelId = this.sessionId++; - const client = this.newClient(channelId, socket); - webSocketClients.set(channelId, client); - - socket.on('error', err => { - }); - - socket.on('close', (code, reason) => { - webSocketClients.delete(channelId); - }); - - socket.on('message', async (data: ws.Data) => { - const jsonParsed = JSON.parse(data.toString()); - - // handle local call - if (jsonParsed.internal) { - - // asked to stop plug-ins - if (jsonParsed.internal.method && jsonParsed.internal.method === 'stop') { - try { - // wait to stop plug-ins - await client.pluginHostRPC.stopContext(); - - // ok now we can dispose the emitter - client.disposeEmitter(); - } catch (e) { - console.error(e); - } - return; - } - - // asked to grab metadata, send them - if (jsonParsed.internal.metadata && 'request' === jsonParsed.internal.metadata) { - // apply host on all local metadata - currentBackendPluginsMetadata.forEach(metadata => metadata.host = jsonParsed.internal.endpointName); - const metadataResult = { - 'internal': { - 'endpointName': jsonParsed.internal.endpointName, - 'metadata': { - 'result': currentBackendPluginsMetadata - } - } - }; - - client.send(metadataResult); - } - return; - } - - // send what is inside the message (wrapped message) - client.fire(jsonParsed); - - }); - } -} - -/** - * Wrapper for adding Message ID on every message that is sent. - */ -class WebSocketClient { - - public rpc: RPCProtocolImpl; - - public pluginHostRPC: PluginHostRPC; - - // tslint:disable-next-line:no-any - constructor(private readonly id: number, private socket: ws, private readonly emitter: Emitter) { - } - - public getIdentifier(): number { - return this.id; - } - - // message is a JSON entry - // tslint:disable-next-line:no-any - send(message: any) { - try { - this.socket.send(JSON.stringify(message)); - } catch (error) { - console.log('error socket while sending', error, message); - } - } - - disposeEmitter(): void { - this.emitter.dispose(); - } - - // tslint:disable-next-line:no-any - fire(message: any) { - try { - this.emitter.fire(message); - } catch (error) { - console.log('error socket while sending', error, message); - } - } - -} - -// list of clients -const webSocketClients = new Map(); - -const currentBackendPluginsMetadata: PluginMetadata[] = []; - -@injectable() -class PluginDeployerHandlerImpl implements PluginDeployerHandler { - - @inject(ILogger) - protected readonly logger: ILogger; - - @inject('plugin.port') - protected readonly pluginPort: number; - - // announced ? - private announced = false; - - constructor( - @inject(HostedPluginReader) private readonly reader: HostedPluginReader, - ) { - this.reader.initialize(); - } - - async deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise { - if (frontendPlugins.length > 0) { - logger.error('Frontend plug-in cannot be deployed in sidecar container'); - } - } - - async deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise { - for (const plugin of backendPlugins) { - const metadata = await this.reader.getPluginMetadata(plugin.path()); - if (metadata) { - currentBackendPluginsMetadata.push(metadata); - const path = metadata.model.entryPoint.backend || plugin.path(); - this.logger.info(`Backend plug-in "${metadata.model.name}@${metadata.model.version}" from "${path} is now available"`); - } - } - - // ok now we're ready to announce as plugins have been deployed - if (!this.announced) { - const pluginDiscovery = new PluginDiscovery(this.logger, this.pluginPort); - pluginDiscovery.discover(); - this.announced = true; - } - - } -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-mapping.ts b/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-mapping.ts deleted file mode 100644 index c973a00a3..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote-mapping.ts +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { injectable, inject, postConstruct } from 'inversify'; -import { ILogger } from '@theia/core'; - -/** - * Class handling mapping between plug-in and endpoints - * @author Florent Benoit - */ -@injectable() -export class HostedPluginMapping { - - private static ENDPOINT_ENV_VAR_PREFIX: string = 'THEIA_PLUGIN_REMOTE_ENDPOINT_'; - - @inject(ILogger) - protected readonly logger: ILogger; - - // list of endpoints - private endpoints: string[]; - - // mapping between plugin's id and the websocket endpoint - private pluginsEndpoints = new Map(); - - /** - * Post construct setup. Parse ENV variables to grab endpoints. - */ - @postConstruct() - protected setup(): void { - - // Grab endpoints from env var - const pluginEndpointKeys: string[] = Object.keys(process.env).filter(key => key.startsWith(HostedPluginMapping.ENDPOINT_ENV_VAR_PREFIX)); - pluginEndpointKeys.forEach(key => { - this.pluginsEndpoints.set(key.substring(HostedPluginMapping.ENDPOINT_ENV_VAR_PREFIX.length), process.env[key] || ''); - }); - this.endpoints = pluginEndpointKeys.map(key => process.env[key] || ''); - if (this.endpoints.length > 0) { - this.logger.info('Plugins Endpoints are ', this.endpoints); - } - if (this.pluginsEndpoints.size > 0) { - this.logger.info('Plugins Mapping Endpoints are ', this.pluginsEndpoints); - } - } - - /** - * Checks if the given pluginID has a remote endpoint - */ - hasEndpoint(pluginID: string): boolean { - return this.pluginsEndpoints.has(pluginID); - } - - /** - * Gets endpoint for given id - * @param pluginID for plugin-id - */ - getEndpoint(pluginID: string): string | undefined { - return this.pluginsEndpoints.get(pluginID); - } - - /** - * Gets the endpoints - */ - getEndPoints(): string[] { - return this.endpoints; - } - - /** - * Gets the pluging endpoints - */ - getPluginsEndPoints(): Map { - return this.pluginsEndpoints; - } - -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote.ts b/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote.ts deleted file mode 100644 index 6505ff04b..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/plugin-remote.ts +++ /dev/null @@ -1,30 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { PluginRemoteInit } from './plugin-remote-init'; - -/** - * Entry point of a Remote Endpoint. It is executed as a new separate nodejs process. - * It is using inversify to bind all the stuff. - * @author Florent Benoit - */ - -process.on('SIGINT', () => { - process.exit(); -}); - -// configured port number -const pluginPort = parseInt(process.env.THEIA_PLUGIN_ENDPOINT_PORT || '2503', 10); - -// start endpoint -const pluginRemoteInit = new PluginRemoteInit(pluginPort); -pluginRemoteInit.init().catch(error => { - console.error('Error while starting endpoint: ', error); -}); diff --git a/dockerfiles/theia-endpoint-runtime/src/node/remote-metadata-processor.ts b/dockerfiles/theia-endpoint-runtime/src/node/remote-metadata-processor.ts deleted file mode 100644 index 0fbac8a5e..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/remote-metadata-processor.ts +++ /dev/null @@ -1,36 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { injectable, inject } from 'inversify'; -import { ILogger } from '@theia/core/lib/common'; -import { MetadataProcessor, PluginMetadata, getPluginId } from '@theia/plugin-ext'; -import { HostedPluginMapping } from './plugin-remote-mapping'; - -/** - * Add on top of metadata the endpoint host - * @author Florent Benoit - */ -@injectable() -export class RemoteMetadataProcessor implements MetadataProcessor { - - @inject(ILogger) - protected readonly logger: ILogger; - - @inject(HostedPluginMapping) - protected hostedPluginMapping: HostedPluginMapping; - - process(pluginMetadata: PluginMetadata): void { - const pluginID = getPluginId(pluginMetadata.model); - if (this.hostedPluginMapping.hasEndpoint(pluginID)) { - pluginMetadata.host = this.hostedPluginMapping.getEndpoint(pluginID)!.replace(/\W/g, '_'); - } - } - -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/server-plugin-proxy-runner.ts b/dockerfiles/theia-endpoint-runtime/src/node/server-plugin-proxy-runner.ts deleted file mode 100644 index 7c39ab54d..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/server-plugin-proxy-runner.ts +++ /dev/null @@ -1,58 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import { injectable, inject } from 'inversify'; -import { HostedPluginClient, ServerPluginRunner, PluginMetadata } from '@theia/plugin-ext/lib/common/plugin-protocol'; -import { HostedPluginRemote } from './hosted-plugin-remote'; - -/** - * Proxy runner being a facade for loading plugins locally or remotely - */ -@injectable() -export class ServerPluginProxyRunner implements ServerPluginRunner { - - @inject(HostedPluginRemote) - protected readonly hostedPluginRemote: HostedPluginRemote; - - private defaultRunner: ServerPluginRunner; - - public setDefault(defaultRunner: ServerPluginRunner): void { - this.defaultRunner = defaultRunner; - } - - public setClient(client: HostedPluginClient): void { - this.hostedPluginRemote.setClient(client); - } - - public clientClosed(): void { - this.hostedPluginRemote.clientClosed(); - } - - // tslint:disable-next-line:no-any - public acceptMessage(jsonMessage: any): boolean { - return jsonMessage.pluginID !== undefined; - } - - // tslint:disable-next-line:no-any - public onMessage(jsonMessage: any): void { - // do routing on the message - if (this.hostedPluginRemote.hasEndpoint(jsonMessage.pluginID)) { - this.hostedPluginRemote.onMessage(jsonMessage); - } else { - this.defaultRunner.onMessage(jsonMessage.content); - } - - } - - getExtraPluginMetadata(): Promise { - return this.hostedPluginRemote.getExtraPluginMetadata(); - } - -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/terminal-container-aware.ts b/dockerfiles/theia-endpoint-runtime/src/node/terminal-container-aware.ts deleted file mode 100644 index 1044a162b..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/terminal-container-aware.ts +++ /dev/null @@ -1,66 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import * as theia from '@theia/plugin'; -import { TerminalServiceExtImpl } from '@theia/plugin-ext/lib/plugin/terminal-ext'; -import { DebugExtImpl } from '@theia/plugin-ext/lib/plugin/node/debug/debug'; - -/** - * Allow to override createTerminal to be container-aware and then create terminal to the sidecar container - */ -export class TerminalContainerAware { - - /** - * Intercept the original method by adding the CHE_MACHINE_NAME as attribute (if exists) - */ - overrideTerminal(terminalServiceExt: TerminalServiceExtImpl) { - // bind createTerminal to the scope 'this' of the terminalServiceExt. - const originalCreateTerminal = terminalServiceExt.createTerminal.bind(terminalServiceExt); - - const createTerminal = (nameOrOptions: theia.TerminalOptions | (string | undefined), shellPath?: string, shellArgs?: string[]) => { - let options: theia.TerminalOptions; - if (typeof nameOrOptions === 'object') { - options = nameOrOptions; - } else { - options = { - name: nameOrOptions, - shellPath: shellPath, - shellArgs: shellArgs, - attributes: {} - }; - } - - // add machine name if exists - if (process.env.CHE_MACHINE_NAME) { - if (!options.attributes) { - options.attributes = {}; - } - options.attributes['CHE_MACHINE_NAME'] = process.env.CHE_MACHINE_NAME; - } - - return originalCreateTerminal(options, shellPath, shellArgs); - }; - - // override terminal - terminalServiceExt.createTerminal = createTerminal; - } - - overrideTerminalCreationOptionForDebug(debugExt: DebugExtImpl) { - debugExt.doGetTerminalCreationOptions = (debugType: string) => { - const options: theia.TerminalOptions = { - attributes: { - 'CHE_MACHINE_NAME': process.env.CHE_MACHINE_NAME - } - }; - - return Promise.resolve(options); - }; - } -} diff --git a/dockerfiles/theia-endpoint-runtime/src/node/websocket.ts b/dockerfiles/theia-endpoint-runtime/src/node/websocket.ts deleted file mode 100644 index 192ee3bb6..000000000 --- a/dockerfiles/theia-endpoint-runtime/src/node/websocket.ts +++ /dev/null @@ -1,117 +0,0 @@ -/********************************************************************* - * Copyright (c) 2018-2019 Red Hat, Inc. - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - **********************************************************************/ - -import * as WS from 'ws'; -import { ILogger } from '@theia/core'; - -/** - * Websocket class wapper on top of ws package in order to handle reconnect in case of failures - */ -export class Websocket { - - /** - * Logger. - */ - private readonly logger: ILogger; - - /** - * Delay/interval before trying to reconnect (2 seconds) - */ - private static RECONNECT_INTERVAL: number = 2000; - - /** - * Instance of the websocket library. (keeping it private) - */ - private instance: WS; - - /** - * URL on which we want to be connected - */ - private readonly url: string; - - /** - * Open URL when constructing it. - */ - constructor(logger: ILogger, url: string) { - this.logger = logger; - this.url = url; - this.open(); - } - - /** - * Open the websocket. If error, try to reconnect - * If success, register the callbacks. - */ - open() { - this.instance = new WS(this.url); - - // When open, add our callback - this.instance.on('open', () => { - this.onOpen(this.url); - }); - - // on message callback - this.instance.on('message', (data: WS.Data) => { - this.onMessage(data); - }); - - // if closed, check error code - this.instance.on('close', (code: number, reason: string) => { - switch (code) { - case 1000: - break; - default: - // reconnect if closed not normally - this.reconnect(reason); - break; - } - this.onClose(reason); - }); - // tslint:disable-next-line:no-any - this.instance.on('error', (e: any) => { - switch (e.code) { - case 'ECONNREFUSED': - this.reconnect(e); - break; - default: - this.onError(e); - break; - } - }); - } - public send(data: WS.Data) { - try { - this.instance.send(data); - } catch (e) { - this.instance.emit('error', e); - } - } - private reconnect(reason: string) { - this.logger.debug(`WebSocket: Reconnecting in ${Websocket.RECONNECT_INTERVAL}ms due to ${reason}`); - this.instance.removeAllListeners(); - setTimeout(() => { - this.logger.debug('WebSocket: Reconnecting...'); - this.open(); - }, Websocket.RECONNECT_INTERVAL); - } - - // Empty callbacks that can be overrided by clients - public onOpen(url: string) { } - public onMessage(data: WS.Data) { } - private onError(e: Error) { } - private onClose(reason: string) { } - - /*** - * Closing websocket with proper error code. - */ - public close(): void { - this.instance.close(1000); - } -} diff --git a/dockerfiles/theia-endpoint-runtime/tsconfig.json b/dockerfiles/theia-endpoint-runtime/tsconfig.json deleted file mode 100644 index f505b5de3..000000000 --- a/dockerfiles/theia-endpoint-runtime/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../configs/base.tsconfig", - "compilerOptions": { - "skipLibCheck": true, - "jsx": "react", - "lib": [ - "es6", - "dom" - ], - "rootDir": "src", - "outDir": "lib" - }, - "include": [ - "src" - ] -} diff --git a/dockerfiles/theia-endpoint-runtime/tsfmt.json b/extensions/eclipse-che-theia-plugin-remote/tsfmt.json similarity index 100% rename from dockerfiles/theia-endpoint-runtime/tsfmt.json rename to extensions/eclipse-che-theia-plugin-remote/tsfmt.json diff --git a/dockerfiles/theia-endpoint-runtime/tslint.json b/extensions/eclipse-che-theia-plugin-remote/tslint.json similarity index 100% rename from dockerfiles/theia-endpoint-runtime/tslint.json rename to extensions/eclipse-che-theia-plugin-remote/tslint.json From f708b12ace448a90c774e4ca58b8502958f4362e Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Fri, 31 May 2019 11:45:03 +0300 Subject: [PATCH 2/2] fix Signed-off-by: Anatoliy Bazko --- dockerfiles/theia-endpoint-runtime/build.sh | 2 - .../tsfmt.json | 19 ---- .../tslint.json | 106 ------------------ yarn.lock | 6 +- 4 files changed, 3 insertions(+), 130 deletions(-) delete mode 100644 extensions/eclipse-che-theia-plugin-remote/tsfmt.json delete mode 100644 extensions/eclipse-che-theia-plugin-remote/tslint.json diff --git a/dockerfiles/theia-endpoint-runtime/build.sh b/dockerfiles/theia-endpoint-runtime/build.sh index a71f7a76a..cf2882fd4 100755 --- a/dockerfiles/theia-endpoint-runtime/build.sh +++ b/dockerfiles/theia-endpoint-runtime/build.sh @@ -40,8 +40,6 @@ mkdir ${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/src/." "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote/src/" cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/package.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tsconfig.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" -cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tsfmt.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" -cp -r "${base_dir}/../../extensions/eclipse-che-theia-plugin-remote/tslint.json" "${LOCAL_ASSEMBLY_DIR}/theia-plugin-remote" init --name:theia-endpoint-runtime "$@" diff --git a/extensions/eclipse-che-theia-plugin-remote/tsfmt.json b/extensions/eclipse-che-theia-plugin-remote/tsfmt.json deleted file mode 100644 index 5f3b5286a..000000000 --- a/extensions/eclipse-che-theia-plugin-remote/tsfmt.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "baseIndentSize": 0, - "newLineCharacter": "\n", - "indentSize": 4, - "tabSize": 4, - "indentStyle": 4, - "convertTabsToSpaces": true, - "insertSpaceAfterCommaDelimiter": true, - "insertSpaceAfterSemicolonInForStatements": true, - "insertSpaceBeforeAndAfterBinaryOperators": true, - "insertSpaceAfterKeywordsInControlFlowStatements": true, - "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, - "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, - "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, - "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, - "placeOpenBraceOnNewLineForFunctions": false, - "placeOpenBraceOnNewLineForControlBlocks": false -} - diff --git a/extensions/eclipse-che-theia-plugin-remote/tslint.json b/extensions/eclipse-che-theia-plugin-remote/tslint.json deleted file mode 100644 index 80f107a60..000000000 --- a/extensions/eclipse-che-theia-plugin-remote/tslint.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "defaultSeverity": "error", - "rules": { - "arrow-parens": [ - true, - "ban-single-arg-parens" - ], - "arrow-return-shorthand": [ - true, - "multiline" - ], - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "eofline": true, - "file-header": [ - true, - "SPDX-License-Identifier: EPL-2\\.0" - ], - "forin": true, - "indent": [ - true, - "spaces", - 4 - ], - "interface-over-type-literal": true, - "jsdoc-format": [ - true, - "check-multiline-start" - ], - "max-line-length": [ - true, - 180 - ], - "no-any": true, - "no-consecutive-blank-lines": true, - "no-construct": true, - "no-magic-numbers": false, - "no-null-keyword": true, - "no-shadowed-variable": true, - "no-string-throw": true, - "no-trailing-whitespace": true, - "no-unused-expression": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "one-variable-per-declaration": true, - "prefer-const": [ - true, - { - "destructuring": "all" - } - ], - "quotemark": [ - true, - "single", - "jsx-single", - "avoid-escape", - "avoid-template" - ], - "radix": false, - "semicolon": [ - true, - "always", - "ignore-interfaces" - ], - "space-before-function-paren": [ - true, - { - "anonymous": "always" - } - ], - "trailing-comma": false, - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": false, - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } -} diff --git a/yarn.lock b/yarn.lock index d7537d2a6..2eb769373 100644 --- a/yarn.lock +++ b/yarn.lock @@ -41,9 +41,9 @@ integrity sha512-0j10nNc7aT18srs7R38mipyi4DjrGQ+bXBmvf2vLTFJGAqhl8V7pB9HsFUq0CYHd8t+gwfwfH0cUmZHdPcJRjA== "@eclipse-che/plugin@latest": - version "0.0.1-1559186331" - resolved "https://registry.npmjs.org/@eclipse-che/plugin/-/plugin-0.0.1-1559186331.tgz#3722d63b41851c025d466c818a433f4e3ec9c0cd" - integrity sha512-u+mGcjXdBAiJ6BWxUEfgISxwmc2PYFwVUEI0wGEH3+5mH+houozjzUZNyEgobNMV6XBXbd/GaKmq+JAXdz7Fbw== + version "0.0.1-1559290690" + resolved "https://registry.npmjs.org/@eclipse-che/plugin/-/plugin-0.0.1-1559290690.tgz#34116c28e873a5d1d15be465e788d4618c066e36" + integrity sha512-CZcMyEk9ybM76+XQ9qkQg/TopSVEtGbxyrtX+KmbKjNxEzC1jYch1P8+Ye/p4cSRh6PbyMiUne1oV9YGUk92JA== dependencies: "@eclipse-che/api" latest