From 3e39bf52b33188e15226877e22f2a6b5b95039ca Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Tue, 10 Sep 2019 11:58:49 +0300 Subject: [PATCH] Add devfile and doc for developing of Che Theia remote plugin mechanism (#413) * Add devfile and doc for developing of Che Theia remote plugin mechanism Signed-off-by: Mykola Morhun * chore(CONTRIBUTING.md): improve toc and title --- CONTRIBUTING.md | 39 ++++++- .../devfile.yaml | 100 ++++++++++++++++++ 2 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 extensions/eclipse-che-theia-plugin-remote/devfile.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 48980f2a2..ac8f5df79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,16 @@ Contribute to Che-Theia ================ +Table of contents + + - [Introduction](#introduction) + - [Devfiles](#devfiles) + - [Contribute to Theia or Che-Theia extensions or built-in Che-Theia plugins](#contribute-to-theia-or-che-theia-extensions-or-built-in-che-theia-plugins) + - [Just want to build the plugin and run with the existing Theia image](#just-want-to-build-the-plugin-and-run-with-the-existing-theia-image) + - [How to develop Che Theia remote plugin mechanism](#how-to-develop-che-theia-remote-plugin-mechanism) + +## Introduction + There are 3 contribution points: - Theia - Che-Theia extensions @@ -19,7 +29,7 @@ Devfile could be launched through a factory or [chectl](https://github.com/che-i $ chectl workspace:start -f devfiles/che-theia-all.devfile.yaml ``` -## Devfile for contributing to Theia or Che-Theia extensions or Che-plugins +## Contribute to Theia or Che-Theia extensions or built-in Che-Theia plugins > Note that this devfile is going to evolve very soon and be splitted into multiple devfiles. The devfile: [/devfiles/che-theia-all.devfile.yaml](./devfiles/che-theia-all.devfile.yaml) @@ -129,10 +139,33 @@ To start che-theia in `dev-mode` with yarn (not using the production che-theia g Running dev theia would be located in the che-dev container and `theia-dev-flow` endpoint: ![Che-Theia-dev-endpoint](https://raw.githubusercontent.com/eclipse/che-theia/assets/theia-dev-flow-endpoint.png) - - ### Just want to build the plugin and run with the existing Theia image If you do not have any changes on Theia or Che-theia extension, you could just build the plugins with `build ... containers-plugin` or `build ... factory-plugin` and run these plugins with the existing che-theia app: `run ... HOSTED che-theia + container-plugin` or `run ... HOSTED che-theia + factory-plugin` + +## How to develop Che Theia remote plugin mechanism + +_Please note, this section provides a flow how to develop remote plugin mechanism in Che Theia, but not a remote plugin._ + +First, create a workspace from prepared [devfile](https://github.com/eclipse/che-theia/blob/master/extensions/eclipse-che-theia-plugin-remote/devfile.yaml), which could be found in the `eclipse-che-theia-plugin-remote` extension folder. +When workspace is ready: + - Init Che Theia. This could be done with `che:theia init` command in `/projects/theia` folder or run the init command. + Che Theia sources will be awailable at `/projects/theia/che/che-theia`. + - Now one may make changes in Che Theia remote plugin mechanism in both (Che Theia and Remote plugin) sides. + - Build Che Theia from `theia-dev` container by executing `yarn` in `/projects/theia` folder or by running corresponding command. + - Put binaries (*.theia or *.vsix) of your remote plugin(s) into `/projects/remote-plugins/` directory. + Note that the plugin(s) shouldn't have any external dependencies. + For example, [this sample plugin](https://github.com/eclipse/che-theia-samples/tree/master/samples/hello-world-backend-plugin) might be used. + Or a user may generate one using `Generate Hello World plugin package` command. + - Run dev Che Theia and Remote plugins endpoint in `theia-dev` and `theia-remote-runtime-dev` containers correspondingly. + One may use predefined commands to start them. + - Open `theia-dev` route from `My Workspace` panel and test chenges. + +Also it is possible to run watchers for remote plugin mechanism. +In `theia-dev` container run `npx run watch @eclipse-che/theia-remote` from `/projects/theia` folder to recompile the extension on changes made. +Also run `yarn watch` in `/projects/theia/examples/assembly` to bring the changes to Che Theia binaries. +If needed one may start watchers in plugin API extension: `npx run watch @theia/plugin-ext` from `/projects/theia` directory. +The commands for these actions are also available. +But please note, you have to restart server to which changes is made. diff --git a/extensions/eclipse-che-theia-plugin-remote/devfile.yaml b/extensions/eclipse-che-theia-plugin-remote/devfile.yaml new file mode 100644 index 000000000..459515590 --- /dev/null +++ b/extensions/eclipse-che-theia-plugin-remote/devfile.yaml @@ -0,0 +1,100 @@ +apiVersion: 1.0.0 +metadata: + name: che-theia-remote-dev +projects: + - name: theia + source: + type: git + location: 'https://github.com/theia-ide/theia.git' +components: + - type: cheEditor + id: eclipse/che-theia/next + alias: theia-editor + - type: chePlugin + id: eclipse/che-machine-exec-plugin/next + - type: chePlugin + id: che-incubator/typescript/latest + memoryLimit: 2Gi + - type: dockerimage + image: eclipse/che-theia-dev:next + alias: theia-dev + mountSources: true + env: + - name: THEIA_PLUGIN_ENDPOINT_DISCOVERY_PORT + value: '2504' + memoryLimit: 3Gi + - type: dockerimage + image: eclipse/che-theia-dev:next + alias: theia-remote-runtime-dev + mountSources: true + env: + - name: THEIA_PLUGIN_ENDPOINT_DISCOVERY_PORT + value: '2504' + - name: THEIA_PLUGINS + value: 'local-dir:///projects/remote-plugins/' + memoryLimit: 1Gi +commands: + - name: Init Che Theia + actions: + - type: exec + component: theia-dev + command: 'che:theia init' + workdir: /projects/theia + - name: Clean Che Theia + actions: + - type: exec + component: theia-dev + command: 'che:theia clean' + workdir: /projects/theia + - name: Generate Hello World plugin package + actions: + - type: exec + component: theia-dev + command: 'yes | yo @theia/plugin && cp y/y.theia /projects/remote-plugins/hello-world-plugin.theia && rm -rf /tmp/y' + workdir: /tmp + - name: Build Che Theia + actions: + - type: exec + component: theia-dev + command: 'yarn' + workdir: /projects/theia + - name: Watch changes in Theia Remote Extension + actions: + - type: exec + component: theia-dev + command: 'npx run watch @eclipse-che/theia-remote' + workdir: /projects/theia + - name: Watch changes in Theia Plugin API Extension + actions: + - type: exec + component: theia-dev + command: 'npx run watch @theia/plugin-ext' + workdir: /projects/theia + - name: Watch changes in Theia assembly + actions: + - type: exec + component: theia-dev + command: 'yarn watch' + workdir: /projects/theia/examples/assembly + - name: Run Dev Theia + actions: + - type: exec + component: theia-dev + command: 'yarn theia start --hostname=0.0.0.0 --port=3130' + workdir: /projects/theia/examples/assembly + - name: Run Remote Theia Plugin Endpoint + actions: + - type: exec + component: theia-remote-runtime-dev + command: 'node plugin-remote.js' + workdir: /projects/theia/che/che-theia/extensions/eclipse-che-theia-plugin-remote/lib/node + - name: Terminate all in Dev Theia + actions: + - type: exec + component: theia-dev + command: 'killall node' + - name: Terminate all in Remote Theia Plugin Endpoint + actions: + - type: exec + component: theia-remote-runtime-dev + command: 'killall node'