Skip to content

Commit

Permalink
[vscode] add builtins to example applications
Browse files Browse the repository at this point in the history
- adds the vscode `builtin` extensions to the example applications (browser, and electron).
- missing extension functionality will need to be replaced by appropriate vscode extensions.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Jan 16, 2020
1 parent 30e88c8 commit 1402d42
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cache:
- /tmp/vscode-ripgrep-cache-1.5.7
- dev-packages/application-manager/node_modules
- dev-packages/application-package/node_modules
- dev-packages/cli/node_modules
- dev-packages/electron/node_modules
- examples/api-samples/node_modules
- examples/browser/node_modules
Expand Down
6 changes: 6 additions & 0 deletions dev-packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
"dependencies": {
"@theia/application-manager": "^0.14.0",
"@theia/application-package": "^0.14.0",
"@types/mkdirp": "^0.5.2",
"@types/requestretry": "^1.12.3",
"mkdirp": "^0.5.0",
"requestretry": "^3.1.0",
"tar": "^4.0.0",
"unzip-stream": "^0.3.0",
"yargs": "^11.1.0"
}
}
93 changes: 93 additions & 0 deletions dev-packages/cli/src/download-plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/********************************************************************************
* Copyright (C) 2020 Ericsson and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import * as fs from 'fs';
import * as path from 'path';
import * as process from 'process';
import * as request from 'requestretry';
import * as mkdirp from 'mkdirp';
import * as tar from 'tar';
import * as zlib from 'zlib';

const unzip = require('unzip-stream');

export default function downloadPlugins(): void {

console.log('Downloading plugins...');

// Resolve the `package.json` at the current working directory.
const pck = require(path.resolve(process.cwd(), 'package.json'));

// Resolve the directory for which to download the plugins.
const pluginsDir = pck.theiaPluginsDir || 'plugins';

for (const plugin in pck.theiaPlugins) {
if (!plugin) {
continue;
}
const targetPath = path.join(process.cwd(), pluginsDir, plugin);

// Skip plugins which have previously been downloaded.
if (!isDownloaded(targetPath)) {
console.log(plugin + ': already downloaded');
continue;
}

const pluginUrl = pck.theiaPlugins[plugin];
console.log(plugin + ': downloading from ' + pluginUrl);

const download: request.RequestPromise = request({
...pck.requestOptions,
url: pluginUrl,
maxAttempts: 5,
retryDelay: 2000,
retryStrategy: request.RetryStrategies.HTTPOrNetworkError
// tslint:disable-next-line:no-any
}, (err: any, response: any) => {
if (err) {
console.error(plugin + ': failed to download', err);
} else {
console.log(plugin + ': downloaded successfully' + (response.attempts > 1 ? ` after ${response.attempts} attempts` : ''));
}
});

if (pluginUrl.endsWith('gz')) {
mkdirp(targetPath, () => { });
const gunzip = zlib.createGunzip({
finishFlush: zlib.Z_SYNC_FLUSH,
flush: zlib.Z_SYNC_FLUSH
});
const untar = tar.x({ cwd: targetPath });
download.pipe(gunzip).pipe(untar);
} else {
download.pipe(unzip.Extract({ path: targetPath }));
}
}
}

/**
* Determine if the resource for the given path is already downloaded.
* @param path the resource path.
*
* @returns `true` if the resource is already downloaded, else `false`.
*/
function isDownloaded(dirPath: fs.PathLike): boolean {
try {
return !fs.readdirSync(dirPath).length;
} catch (e) {
return true;
}
}
4 changes: 3 additions & 1 deletion dev-packages/cli/src/theia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as yargs from 'yargs';
import { ApplicationPackageManager, rebuild } from '@theia/application-manager';
import { ApplicationProps } from '@theia/application-package';
import checkHoisted from './check-hoisting';
import downloadPlugins from './download-plugins';

process.on('unhandledRejection', (reason, promise) => {
throw reason;
Expand Down Expand Up @@ -139,7 +140,8 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
process.exit(1);
}
}
});
})
.command({ command: 'download:plugins', handler: () => downloadPlugins() });

// see https://github.com/yargs/yargs/issues/287#issuecomment-314463783
// tslint:disable-next-line:no-any
Expand Down
6 changes: 0 additions & 6 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
"@theia/console": "^0.14.0",
"@theia/core": "^0.14.0",
"@theia/debug": "^0.14.0",
"@theia/debug-nodejs": "^0.14.0",
"@theia/editor": "^0.14.0",
"@theia/editor-preview": "^0.14.0",
"@theia/editorconfig": "^0.14.0",
"@theia/file-search": "^0.14.0",
"@theia/filesystem": "^0.14.0",
"@theia/getting-started": "^0.14.0",
"@theia/git": "^0.14.0",
"@theia/java": "^0.14.0",
"@theia/java-debug": "^0.14.0",
"@theia/json": "^0.14.0",
"@theia/keymaps": "^0.14.0",
"@theia/languages": "^0.14.0",
Expand All @@ -48,15 +45,12 @@
"@theia/preferences": "^0.14.0",
"@theia/preview": "^0.14.0",
"@theia/process": "^0.14.0",
"@theia/python": "^0.14.0",
"@theia/scm": "^0.14.0",
"@theia/search-in-workspace": "^0.14.0",
"@theia/task": "^0.14.0",
"@theia/terminal": "^0.14.0",
"@theia/textmate-grammars": "^0.14.0",
"@theia/tslint": "^0.14.0",
"@theia/typehierarchy": "^0.14.0",
"@theia/typescript": "^0.14.0",
"@theia/userstorage": "^0.14.0",
"@theia/variable-resolver": "^0.14.0",
"@theia/workspace": "^0.14.0"
Expand Down
6 changes: 0 additions & 6 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
"@theia/console": "^0.14.0",
"@theia/core": "^0.14.0",
"@theia/debug": "^0.14.0",
"@theia/debug-nodejs": "^0.14.0",
"@theia/editor": "^0.14.0",
"@theia/editor-preview": "^0.14.0",
"@theia/editorconfig": "^0.14.0",
"@theia/file-search": "^0.14.0",
"@theia/filesystem": "^0.14.0",
"@theia/getting-started": "^0.14.0",
"@theia/git": "^0.14.0",
"@theia/java": "^0.14.0",
"@theia/java-debug": "^0.14.0",
"@theia/json": "^0.14.0",
"@theia/keymaps": "^0.14.0",
"@theia/languages": "^0.14.0",
Expand All @@ -45,15 +42,12 @@
"@theia/preferences": "^0.14.0",
"@theia/preview": "^0.14.0",
"@theia/process": "^0.14.0",
"@theia/python": "^0.14.0",
"@theia/scm": "^0.14.0",
"@theia/search-in-workspace": "^0.14.0",
"@theia/task": "^0.14.0",
"@theia/terminal": "^0.14.0",
"@theia/textmate-grammars": "^0.14.0",
"@theia/tslint": "^0.14.0",
"@theia/typehierarchy": "^0.14.0",
"@theia/typescript": "^0.14.0",
"@theia/userstorage": "^0.14.0",
"@theia/variable-resolver": "^0.14.0",
"@theia/workspace": "^0.14.0"
Expand Down
71 changes: 68 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"scripts": {
"postinstall": "node scripts/post-install.js",
"prepare": "node scripts/skip-prepare || ( yarn prepare:travis && yarn rebuild:clean && yarn build:clean && yarn prepare:hoisting )",
"prepare": "node scripts/skip-prepare || ( yarn prepare:travis && yarn rebuild:clean && yarn build:clean && yarn prepare:hoisting ) && yarn download:plugins",
"prepare:travis": "node scripts/prepare-travis",
"prepare:hoisting": "theia check:hoisted -s",
"preinstall": "node-gyp install",
Expand All @@ -70,11 +70,76 @@
"next:publish": "lerna publish --exact --canary=next --npm-tag=next --yes",
"publish:check": "node scripts/check-publish.js",
"start:browser": "yarn rebuild:browser && run start \"@theia/example-browser\"",
"start:electron": "yarn rebuild:electron && run start \"@theia/example-electron\""
"start:electron": "yarn rebuild:electron && run start \"@theia/example-electron\"",
"download:plugins": "theia download:plugins"
},
"workspaces": [
"dev-packages/*",
"packages/*",
"examples/*"
]
],
"theiaPluginsDir": "plugins",
"theiaPlugins": {
"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-emmet": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/emmet-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-merge-conflicts": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/merge-conflict-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-node-debug": "https://github.com/theia-ide/vscode-node-debug/releases/download/v1.35.3/node-debug-1.35.3.vsix",
"vscode-builtin-node-debug2": "https://github.com/theia-ide/vscode-node-debug2/releases/download/v1.33.0/node-debug2-1.33.0.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-theme-abyss": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-abyss-1.39.1-prel.vsix",
"vscode-builtin-theme-defaults": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-defaults-1.39.1-prel.vsix",
"vscode-builtin-theme-kimbie-dark": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-kimbie-dark-1.39.1-prel.vsix",
"vscode-builtin-theme-monokai": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-monokai-1.39.1-prel.vsix",
"vscode-builtin-theme-dimmed": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-monokai-dimmed-1.39.1-prel.vsix",
"vscode-builtin-theme-quietlight": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-quietlight-1.39.1-prel.vsix",
"vscode-builtin-theme-red": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-red-1.39.1-prel.vsix",
"vscode-builtin-theme-solarized-dark": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-solarized-dark-1.39.1-prel.vsix",
"vscode-builtin-theme-tomorrow-night-blue": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/theme-tomorrow-night-blue-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-typescript-language-features": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/typescript-language-features-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-icon-theme-seti": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/vscode-theme-seti-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"
}
}
17 changes: 16 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,13 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/mkdirp@^0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f"
integrity sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==
dependencies:
"@types/node" "*"

"@types/mocha@^2.2.41":
version "2.2.48"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab"
Expand Down Expand Up @@ -1176,7 +1183,7 @@
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/request@^2.0.3":
"@types/request@*", "@types/request@^2.0.3":
version "2.48.4"
resolved "https://registry.yarnpkg.com/@types/request/-/request-2.48.4.tgz#df3d43d7b9ed3550feaa1286c6eabf0738e6cf7e"
integrity sha512-W1t1MTKYR8PxICH+A4HgEIPuAC3sbljoEVfyZbeFJJDbr30guDspJri2XOaM2E+Un7ZjrihaDi7cf6fPa2tbgw==
Expand All @@ -1186,6 +1193,14 @@
"@types/tough-cookie" "*"
form-data "^2.5.0"

"@types/requestretry@^1.12.3":
version "1.12.5"
resolved "https://registry.yarnpkg.com/@types/requestretry/-/requestretry-1.12.5.tgz#c8abf9eb173a9c61d7099ca378acca3e8a483007"
integrity sha512-iEs/MpRq8E+4V4wu9OseeHI0AtgLns4a+/jukKOjUJmVh36Ai+r4E5603pQwRx6mQrS0dhuq319crz8Q9lyBkA==
dependencies:
"@types/node" "*"
"@types/request" "*"

"@types/rimraf@^2.0.2":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.3.tgz#0199a46af106729ba14213fda7b981278d8c84f2"
Expand Down

0 comments on commit 1402d42

Please sign in to comment.