Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Feb 1, 2019
0 parents commit 4ddc3f9
Show file tree
Hide file tree
Showing 20 changed files with 10,498 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
node_modules_backup
.browser_modules
lib
*.log
*-app/*
!*-app/package.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vscode"]
path = vscode
url = https://github.com/Microsoft/vscode.git
6 changes: 6 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image:
file: Dockerfile
ports:
- port: 3000
tasks:
- init: yarn
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vscode
3 changes: 3 additions & 0 deletions .theia/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Browser Backend",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/browser-app/lib/**/*.js",
"${workspaceRoot}/browser-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/electron-app/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM gitpod/workspace-full:latest

# install dependencies
USER root
RUN apt-get update \
&& apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev libgconf2-4 libnss3 libgtk-3-dev libasound2-dev twm \
&& apt-get clean && rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
USER gitpod
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# vscode-builtin-extensions

This extension contributes built-in VS Code extensions to Theia.

## Getting started

Install [nvm](https://github.com/creationix/nvm#install-script).

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash

Install npm and node.

nvm install 8
nvm use 8

Install yarn.

npm install -g yarn

## Running the browser example

yarn rebuild:browser
cd browser-app
yarn start

Open http://localhost:3000 in the browser.

## Running the Electron example

yarn rebuild:electron
cd electron-app
yarn start

## Developing with the browser example

Start watching of vscode-builtin-extensions.

cd vscode-builtin-extensions
yarn watch

Start watching of the browser example.

yarn rebuild:browser
cd browser-app
yarn watch

Launch `Start Browser Backend` configuration from VS code.

Open http://localhost:3000 in the browser.

## Developing with the Electron example

Start watching of vscode-builtin-extensions.

cd vscode-builtin-extensions
yarn watch

Start watching of the electron example.

yarn rebuild:electron
cd electron-app
yarn watch

Launch `Start Electron Backend` configuration from VS code.

## Publishing vscode-builtin-extensions

Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).

npm login

Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).

npx lerna publish
19 changes: 19 additions & 0 deletions browser-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"vscode-builtin-extensions": "0.0.0"
},
"devDependencies": {
"@theia/cli": "0.4.0-next.c5d44a81"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "browser"
}
}
44 changes: 44 additions & 0 deletions bundle-extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @ts-check
const fs = require('fs');
const cp = require('child_process');
const path = require('path');
const rimraf = require('./vscode/node_modules/rimraf');
const vfs = require('./vscode/node_modules/vinyl-fs');
const ext = require('./vscode/build/lib/extensions');

const backupNodeModules = () => {
const move = (src, dest) => fs.existsSync(src) && fs.renameSync(src, dest);
const nodeModules = path.join(__dirname, 'node_modules');
const nodeModulesBackup = path.join(__dirname, 'node_modules_backup');
move(nodeModules, nodeModulesBackup);
return () => move(nodeModulesBackup, nodeModules);
}
const revertNodeModules = backupNodeModules();
process.on('exit', revertNodeModules);
process.on('SIGINT', revertNodeModules);
process.on('SIGTERM', revertNodeModules);
const extensionsPath = path.join(__dirname, 'vscode-builtin-extensions/extensions');
rimraf.sync(extensionsPath);
// @ts-ignore
ext.packageExtensionsStream().pipe(vfs.dest(path.dirname(extensionsPath))).on('end', async () => {
// see why exlcuded https://github.com/theia-ide/theia/issues/3815#issuecomment-452686623
rimraf.sync(path.join(extensionsPath, 'configuration-editing'));
rimraf.sync(path.join(extensionsPath, 'css-language-features'));
rimraf.sync(path.join(extensionsPath, 'html-language-features'));
rimraf.sync(path.join(extensionsPath, 'extension-editing'));
rimraf.sync(path.join(extensionsPath, 'grunt'));
rimraf.sync(path.join(extensionsPath, 'gulp'));
await run('yarn', ['install', '--production'], path.join(extensionsPath, 'debug-auto-launch'));
await run('yarn', ['install', '--production'], path.join(extensionsPath, 'ms-vscode.node-debug'));
await run('yarn', ['install', '--production'], path.join(extensionsPath, 'ms-vscode.node-debug2'));
});

function run(command, args, cwd) {
// @ts-ignore
return new Promise(resolve => {
const p = cp.spawn(command, args, { cwd });
p.stdout.on('data', data => console.log(String(data)));
p.stderr.on('data', data => console.error(String(data)));
p.on('close', resolve);
});
}
19 changes: 19 additions & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"vscode-builtin-extensions": "0.0.0"
},
"devDependencies": {
"@theia/cli": "0.4.0-next.c5d44a81"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "electron"
}
}
11 changes: 11 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lerna": "2.4.0",
"version": "0.0.0",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
"run": {
"stream": true
}
}
}
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"scripts": {
"prepare": "yarn build:extensions && yarn bundle:extensions && yarn build",
"build": "lerna run prepare",
"build:extensions": "cd vscode && yarn && npx gulp compile-extensions-build",
"bundle:extensions": "cd vscode && node ../bundle-extensions.js",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron"
},
"devDependencies": {
"lerna": "2.4.0"
},
"workspaces": [
"vscode-builtin-extensions",
"browser-app",
"electron-app"
]
}
1 change: 1 addition & 0 deletions vscode
Submodule vscode added at dea870
1 change: 1 addition & 0 deletions vscode-builtin-extensions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions
30 changes: 30 additions & 0 deletions vscode-builtin-extensions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "vscode-builtin-extensions",
"keywords": [
"theia-extension"
],
"version": "0.0.0",
"files": [
"lib",
"src",
"extensions"
],
"dependencies": {
"@theia/plugin-ext-vscode": "0.4.0-next.c5d44a81"
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
},
"theiaExtensions": [
{
"backend": "lib/node/vscode-builtin-extensions-backend-module"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as path from 'path';
import { injectable } from 'inversify';
import { PluginDeployerEntry, PluginDeployerDirectoryHandler, PluginDeployerDirectoryHandlerContext, PluginDeployerEntryType } from '@theia/plugin-ext';

@injectable()
export class VSCodeBuiltinExtensionDirectoryHandler implements PluginDeployerDirectoryHandler {

accept(plugin: PluginDeployerEntry): boolean {
const pck = this.resolvePackage(plugin);
return !!pck && !!pck.engines && !!pck.engines.vscode;
}

protected resolvePackage(plugin: PluginDeployerEntry): {
engines?: {
[engine: string]: string
}
} | undefined {
let pck = plugin.getValue('package.json');
if (pck) {
return pck;
}
try {
pck = require(path.join(plugin.path(), 'package.json'));
if (pck) {
plugin.storeValue('package.json', pck);
}
return pck;
} catch {
return undefined;
}
}

async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
context.pluginEntry().accept(PluginDeployerEntryType.BACKEND);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as path from 'path';
import { ContainerModule } from 'inversify';
import { PluginDeployerDirectoryHandler } from '@theia/plugin-ext';
import { VSCodeBuiltinExtensionDirectoryHandler } from './vscode-builtin-extension-directory-handler';

let plugins = `local-dir://${path.resolve(__dirname, '../../extensions')}`;
if (process.env.THEIA_DEFAULT_PLUGINS) {
plugins += ',' + process.env.THEIA_DEFAULT_PLUGINS;
}
process.env.THEIA_DEFAULT_PLUGINS = plugins;

export default new ContainerModule(bind => {
bind(PluginDeployerDirectoryHandler).to(VSCodeBuiltinExtensionDirectoryHandler).inSingletonScope();
});
Loading

0 comments on commit 4ddc3f9

Please sign in to comment.