From c75d401424983adc227c390d0f2a3eb6022133c6 Mon Sep 17 00:00:00 2001 From: Vladyslav Zhukovskyi Date: Thu, 13 Feb 2020 16:56:25 +0200 Subject: [PATCH] Consume VS Code built-in extension Signed-off-by: Vladyslav Zhukovskyi --- dockerfiles/theia/Dockerfile | 1 - dockerfiles/theia/build.sh | 7 --- generator/src/foreach_yarn | 43 +++++++++++++---- generator/src/init.ts | 18 +++++++ generator/src/templates/assembly-package.mst | 1 - generator/src/templates/theiaPlugins.json | 49 ++++++++++++++++++++ generator/src/yargs.ts | 1 + 7 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 generator/src/templates/theiaPlugins.json diff --git a/dockerfiles/theia/Dockerfile b/dockerfiles/theia/Dockerfile index 120ccf70b..5dbbfffbb 100644 --- a/dockerfiles/theia/Dockerfile +++ b/dockerfiles/theia/Dockerfile @@ -96,7 +96,6 @@ RUN if [ -z $GITHUB_TOKEN ]; then unset GITHUB_TOKEN; fi && \ # Add yeoman generator & vscode git plug-ins COPY asset-untagged-c11870b25a17d20bb7a7-theia_yeoman_plugin.theia /home/theia-dev/theia-source-code/production/plugins/theia_yeoman_plugin.theia -COPY asset-vscode-git-1.3.0.1.vsix /home/theia-dev/theia-source-code/production/plugins/vscode-git-1.3.0.1.vsix # change permissions RUN find production -exec sh -c "chgrp 0 {}; chmod g+rwX {}" \; 2>log.txt diff --git a/dockerfiles/theia/build.sh b/dockerfiles/theia/build.sh index bcf01680b..4f0550a86 100755 --- a/dockerfiles/theia/build.sh +++ b/dockerfiles/theia/build.sh @@ -27,13 +27,6 @@ if [ ! -f "${THEIA_YEOMAN_PLUGIN}" ]; then curl -L -o ${THEIA_YEOMAN_PLUGIN} https://github.com/eclipse/theia-yeoman-plugin/releases/download/untagged-c11870b25a17d20bb7a7/theia_yeoman_plugin.theia fi -# VS Code git plug-in -VSCODE_GIT_PLUGIN="${DIR}/asset-vscode-git-1.3.0.1.vsix" -if [ ! -f "${VSCODE_GIT_PLUGIN}" ]; then - curl -L -o ${VSCODE_GIT_PLUGIN} https://github.com/che-incubator/vscode-git/releases/download/1.30.1/vscode-git-1.3.0.1.vsix -fi - - init --name:theia "$@" if [ "${CDN_PREFIX:-}" != "" ]; then diff --git a/generator/src/foreach_yarn b/generator/src/foreach_yarn index e8c6c06cd..52247d2b5 100755 --- a/generator/src/foreach_yarn +++ b/generator/src/foreach_yarn @@ -9,32 +9,44 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ const fs = require('fs'); +const path = require('path'); const spawnSync = require('child_process').spawnSync; const currentDir = __dirname; const targetDir = `${__dirname}/../production/plugins` mkdirSyncRecursive(targetDir); -fs.readdirSync(currentDir).forEach((pluginFolderName) => { - console.log(pluginFolderName); - const pluginFolderPath = `${currentDir}/${pluginFolderName}`; - if (fs.existsSync(`${pluginFolderPath}/package.json`)) { - console.log(`\n✍️ Running \`yarn\` on ${pluginFolderPath}`); + +fs.readdirSync(currentDir).forEach((pluginEntryName) => { + console.log(`\n✍️ Process plugin ${pluginEntryName}`); + + const pluginEntryPath = `${currentDir}/${pluginEntryName}`; + + if (fs.existsSync(`${pluginEntryPath}/package.json`)) { + console.log(`\n✍️ Running \`yarn\` on ${pluginEntryPath}`); + const r = spawnSync('yarn', [], { - cwd: `${pluginFolderPath}`, + cwd: `${pluginEntryPath}`, detached: true, stdio: "inherit" }); + if (r.status === 1) { process.exit(1); } - - fs.readdirSync(`${pluginFolderPath}`).forEach((fileName) => { + + fs.readdirSync(`${pluginEntryPath}`).forEach((fileName) => { if(fileName.endsWith('.theia')){ - console.log(`\n✍️ Copying ${pluginFolderPath}/${fileName} theia package to ${targetDir}/${fileName}`); - fs.copyFileSync(`${pluginFolderPath}/${fileName}`, `${targetDir}/${fileName}`); + console.log(`\n✍️ Copying ${pluginEntryPath}/${fileName} theia package to ${targetDir}/${fileName}`); + fs.copyFileSync(`${pluginEntryPath}/${fileName}`, `${targetDir}/${fileName}`); } }) + } else if (pluginEntryName.endsWith('.vsix') || pluginEntryName.endsWith('.tar.gz')) { + console.log(`\n✍️ Copying ${pluginEntryPath} VSCode built-in extension to ${targetDir}/${pluginEntryName}`); + fs.copyFileSync(`${pluginEntryPath}`, `${targetDir}/${pluginEntryName}`); + } else if (fs.existsSync(`${pluginEntryPath}/extension.vsixmanifest`)) { + console.log(`\n✍️ Copying ${pluginEntryPath} VSCode built-in unpacked extension to ${targetDir}/${pluginEntryName}`); + copyFolderSync(`${pluginEntryPath}`, `${targetDir}/${pluginEntryName}`); } }); @@ -45,3 +57,14 @@ function mkdirSyncRecursive(dir) { curPath.length > 0 && !fs.existsSync(curPath) ? fs.mkdirSync(curPath) : null; } }; + +function copyFolderSync(from, to) { + fs.mkdirSync(to); + fs.readdirSync(from).forEach(element => { + if (fs.lstatSync(path.join(from, element)).isFile()) { + fs.copyFileSync(path.join(from, element), path.join(to, element)); + } else { + copyFolderSync(path.join(from, element), path.join(to, element)); + } + }); +} diff --git a/generator/src/init.ts b/generator/src/init.ts index dfb8d8fbe..18f6d3e64 100644 --- a/generator/src/init.ts +++ b/generator/src/init.ts @@ -85,4 +85,22 @@ export class Init { await fs.writeFile(theiaPackagePath, json); } + async updatePluginsConfigurtion(): Promise { + const theiaPackagePath = path.join(this.rootFolder, 'package.json'); + const theiaPackage = await readPkg(theiaPackagePath); + + theiaPackage['theiaPlugins'] = await this.getPluginsList(); + + const json = JSON.stringify(theiaPackage, undefined, 2); + await fs.writeFile(theiaPackagePath, json); + } + + private async getPluginsList(): Promise { + const srcDir = path.resolve(__dirname, '../src'); + const templateDir = path.join(srcDir, 'templates'); + const pluginsJsonContent = await fs.readFile(path.join(templateDir, 'theiaPlugins.json')); + + return JSON.parse(pluginsJsonContent.toString()); + } + } diff --git a/generator/src/templates/assembly-package.mst b/generator/src/templates/assembly-package.mst index 91c00a997..93dfdf7bb 100644 --- a/generator/src/templates/assembly-package.mst +++ b/generator/src/templates/assembly-package.mst @@ -42,7 +42,6 @@ "@theia/process": "^{{ version }}", "@theia/search-in-workspace": "^{{ version }}", "@theia/task": "^{{ version }}", - "@theia/textmate-grammars": "^{{ version }}", "@theia/tslint": "^{{ version }}", "@theia/userstorage": "^{{ version }}", "@theia/variable-resolver": "^{{ version }}", diff --git a/generator/src/templates/theiaPlugins.json b/generator/src/templates/theiaPlugins.json new file mode 100644 index 000000000..f2ddc0140 --- /dev/null +++ b/generator/src/templates/theiaPlugins.json @@ -0,0 +1,49 @@ +{ + "vscode-builtin-bat": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/bat-1.39.1-prel.vsix", + "vscode-builtin-clojure": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/clojure-1.39.1-prel.vsix", + "vscode-builtin-coffeescript": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/coffeescript-1.39.1-prel.vsix", + "vscode-builtin-configuration-editing": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/configuration-editing-1.39.1-prel.vsix", + "vscode-builtin-cpp": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/cpp-1.39.1-prel.vsix", + "vscode-builtin-csharp": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/csharp-1.39.1-prel.vsix", + "vscode-builtin-css": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/css-1.39.1-prel.vsix", + "vscode-builtin-debug-auto-launch": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/debug-auto-launch-1.39.1-prel.vsix", + "vscode-builtin-docker": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/docker-1.39.1-prel.vsix", + "vscode-builtin-fsharp": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/fsharp-1.39.1-prel.vsix", + "vscode-builtin-go": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/go-1.39.1-prel.vsix", + "vscode-builtin-groovy": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/groovy-1.39.1-prel.vsix", + "vscode-builtin-grunt": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/grunt-1.39.1-prel.vsix", + "vscode-builtin-gulp": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/gulp-1.39.1-prel.vsix", + "vscode-builtin-handlebars": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/handlebars-1.39.1-prel.vsix", + "vscode-builtin-hlsl": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/hlsl-1.39.1-prel.vsix", + "vscode-builtin-html": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/html-1.39.1-prel.vsix", + "vscode-builtin-ini": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/ini-1.39.1-prel.vsix", + "vscode-builtin-jake": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/jake-1.39.1-prel.vsix", + "vscode-builtin-java": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/java-1.39.1-prel.vsix", + "vscode-builtin-javascript": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/javascript-1.39.1-prel.vsix", + "vscode-builtin-json": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/json-1.39.1-prel.vsix", + "vscode-builtin-less": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/less-1.39.1-prel.vsix", + "vscode-builtin-log": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/log-1.39.1-prel.vsix", + "vscode-builtin-lua": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/lua-1.39.1-prel.vsix", + "vscode-builtin-make": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/make-1.39.1-prel.vsix", + "vscode-builtin-markdown": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/markdown-1.39.1-prel.vsix", + "vscode-builtin-npm": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/npm-1.39.1-prel.vsix", + "vscode-builtin-objective-c": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/objective-c-1.39.1-prel.vsix", + "vscode-builtin-perl": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/perl-1.39.1-prel.vsix", + "vscode-builtin-powershell": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/powershell-1.39.1-prel.vsix", + "vscode-builtin-pug": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/pug-1.39.1-prel.vsix", + "vscode-builtin-python": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/python-1.39.1-prel.vsix", + "vscode-builtin-r": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/r-1.39.1-prel.vsix", + "vscode-builtin-razor": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/razor-1.39.1-prel.vsix", + "vscode-builtin-ruby": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/ruby-1.39.1-prel.vsix", + "vscode-builtin-rust": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/rust-1.39.1-prel.vsix", + "vscode-builtin-scss": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/scss-1.39.1-prel.vsix", + "vscode-builtin-shaderlab": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/shaderlab-1.39.1-prel.vsix", + "vscode-builtin-shellscript": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/shellscript-1.39.1-prel.vsix", + "vscode-builtin-sql": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/sql-1.39.1-prel.vsix", + "vscode-builtin-swift": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/swift-1.39.1-prel.vsix", + "vscode-builtin-typescript": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/typescript-1.39.1-prel.vsix", + "vscode-builtin-vb": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/vb-1.39.1-prel.vsix", + "vscode-builtin-xml": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/xml-1.39.1-prel.vsix", + "vscode-builtin-yaml": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/yaml-1.39.1-prel.vsix", + "vscode-git": "https://github.com/che-incubator/vscode-git/releases/download/vscode-git-1.30.1_0.0.1/vscode-git-1.30.1_0.0.1.vsix" +} diff --git a/generator/src/yargs.ts b/generator/src/yargs.ts index 2b0847541..e331bd94c 100644 --- a/generator/src/yargs.ts +++ b/generator/src/yargs.ts @@ -40,6 +40,7 @@ const commandArgs = yargs const version = await init.getCurrentVersion(); await init.generate(); await init.updadeBuildConfiguration(); + await init.updatePluginsConfigurtion(); const extensions = new InitSources(process.cwd(), packagesFolder, pluginsFolder, cheFolder, assemblyFolder, version); await extensions.initSourceLocationAliases(args.alias); await extensions.readConfigurationAndGenerate(args.config, args.dev);