Skip to content

Commit 85d2225

Browse files
kylecarbscode-asher
authored andcommitted
Featureful (#31)
* Fix loading within the CLI * Remove app * Remove promise handle * Add initial travis file * Add libxkbfile dependency * Add libxkbfile-dev * Add build script * Fix malformed bash statement * Remove yarn from script * Improve build script * Extract upx before usage * Only run upx if on linux * Ensure resource directory exists * Pack runnable binary * Export binary with platform * Improve build process * Install upx before running install script * Update typescript version before running nexe * Add os.release() function for multi-platform support * Update travis.yml to improve deployment * Add on CI * Update to v1.31.0 * Add libsecret * Update build target * Skip cleanup * Fix built-in extensions * Add basics for apps * Create custom DNS server * Fix forking within CLI. Fixes TS language features * Fix filename resolve * Fix default extensions path * Add custom dialog * Store workspace path * Remove outfiles * Cleanup * Always authed outside of CLI * Use location.host for client * Remove useless app interface * Remove debug file for building wordlist * Use chromes tcp host * Update patch * Build browser app before packaging * Replace all css containing file:// URLs, fix webviews * Fix save * Fix mkdir
1 parent bdd2408 commit 85d2225

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5204
-264
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
lib
22
node_modules
33
dist
4+
out

.travis.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: node_js
2+
node_js:
3+
- 8.9.3
4+
matrix:
5+
include:
6+
- os: linux
7+
dist: ubuntu
8+
- os: osx
9+
- os: windows
10+
before_install:
11+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev libsecret-1-dev;
12+
fi
13+
script:
14+
- scripts/build.sh
15+
deploy:
16+
provider: releases
17+
skip_cleanup: true
18+
api_key:
19+
secure: T/yqCIeqLifteriv8D3CnehNFzSBP309GZqeUfyx8Q+xSQEttA9Enxl+Qw9GkdedYTN4J56iucHIac6CwcvKSKIXqk80CeSEW0BNxZs5wIgv4rRMMy/GAX0NBWKNOkoGlH8M6VyQcM7eY2iGAn1EX755PHalk6rWwfsauRANOQyb2DXQBan5C0YUnogq2qcW1xkIwlXH7l0Ekbtego0f6QPv0rSyOcL1LKm6xk0Aq+xLNKJkT6TSL6xYpkPlZLjnql09Nspkqs6NehWlft2n09bHqAtjNnWw9OYCvxp8mdHeTE5uShuEqYPzdYU5LVFoE7wElI8uqS66noaA18ytZYGw2IrY6GZcn+wtR6WyM2+YXl2HclL1/Fs6Vn8+zwq2IBZchBNv3KJSn1dxiqLlD/s6YQyni17x/9FhtFoNUvsbY5zSC1xrnNQBQWFg0TRnoC9rPR+7hQtT1+5+CvRxpvcNWnPuA22919PFE79ejJulPmsnyF+YLs9c6APJgOpOO1f6fKt5Mcb02dubPqGcQ9NbqUUNTl4IUvEtjG0LnFAgEGerxAcsdnUTxzBVf0LJLlhRKW1BigUTbRwfUJL1DN0mWg9cg7fL5VqrogvNq3uRguxOsYr+bcHDbimQSAY3No3fAkTTqQSJh56Dx57/Un18KxuOTiRB9de1RtiudsI=
20+
file: packages/server/cli-$TRAVIS_OS_NAME
21+
on:
22+
repo: codercom/vscode-online
23+
all_branches: true

build/tasks.ts

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
import { register, run } from "@coder/runner";
2+
import * as fs from "fs";
3+
import * as fse from "fs-extra";
4+
import * as path from "path";
5+
import * as zlib from "zlib";
6+
7+
const libPath = path.join(__dirname, "../lib");
8+
const vscodePath = path.join(libPath, "vscode");
9+
const pkgsPath = path.join(__dirname, "../packages");
10+
const defaultExtensionsPath = path.join(libPath, "VSCode-linux-x64/resources/app/extensions");
11+
12+
const buildServerBinary = register("build:server:binary", async (runner) => {
13+
await ensureInstalled();
14+
await copyForDefaultExtensions();
15+
await Promise.all([
16+
buildBootstrapFork(),
17+
buildWeb(),
18+
buildDefaultExtensions(),
19+
buildServerBundle(),
20+
buildAppBrowser(),
21+
]);
22+
23+
await buildServerBinaryPackage();
24+
});
25+
26+
const buildServerBinaryPackage = register("build:server:binary:package", async (runner) => {
27+
const cliPath = path.join(pkgsPath, "server");
28+
runner.cwd = cliPath;
29+
if (!fs.existsSync(path.join(cliPath, "out"))) {
30+
throw new Error("Cannot build binary without web bundle built");
31+
}
32+
await buildServerBinaryCopy();
33+
const resp = await runner.execute("npm", ["run", "build:nexe"]);
34+
if (resp.exitCode !== 0) {
35+
throw new Error(`Failed to package binary: ${resp.stderr}`);
36+
}
37+
});
38+
39+
const buildServerBinaryCopy = register("build:server:binary:copy", async (runner) => {
40+
const cliPath = path.join(pkgsPath, "server");
41+
const cliBuildPath = path.join(cliPath, "build");
42+
fse.removeSync(cliBuildPath);
43+
fse.mkdirpSync(path.join(cliBuildPath, "extensions"));
44+
const bootstrapForkPath = path.join(pkgsPath, "vscode", "bin", "bootstrap-fork.js");
45+
const webOutputPath = path.join(pkgsPath, "web", "out");
46+
const browserAppOutputPath = path.join(pkgsPath, "app", "browser", "out");
47+
const nodePtyModule = path.join(pkgsPath, "protocol", "node_modules", "node-pty", "build", "Release", "pty.node");
48+
49+
if (!fs.existsSync(nodePtyModule)) {
50+
throw new Error("Could not find pty.node. Ensure all packages have been installed");
51+
}
52+
if (!fs.existsSync(webOutputPath)) {
53+
throw new Error("Web bundle must be built");
54+
}
55+
if (!fs.existsSync(defaultExtensionsPath)) {
56+
throw new Error("Default extensions must be built");
57+
}
58+
if (!fs.existsSync(bootstrapForkPath)) {
59+
throw new Error("Bootstrap fork must exist");
60+
}
61+
fse.copySync(defaultExtensionsPath, path.join(cliBuildPath, "extensions"));
62+
fs.writeFileSync(path.join(cliBuildPath, "bootstrap-fork.js.gz"), zlib.gzipSync(fs.readFileSync(bootstrapForkPath)));
63+
const cpDir = (dir: string, subdir: "auth" | "unauth", rootPath: string): void => {
64+
const stat = fs.statSync(dir);
65+
if (stat.isDirectory()) {
66+
const paths = fs.readdirSync(dir);
67+
paths.forEach((p) => cpDir(path.join(dir, p), subdir, rootPath));
68+
} else if (stat.isFile()) {
69+
const newPath = path.join(cliBuildPath, "web", subdir, path.relative(rootPath, dir));
70+
fse.mkdirpSync(path.dirname(newPath));
71+
fs.writeFileSync(newPath + ".gz", zlib.gzipSync(fs.readFileSync(dir)));
72+
} else {
73+
// Nothing
74+
}
75+
};
76+
cpDir(webOutputPath, "auth", webOutputPath);
77+
cpDir(browserAppOutputPath, "unauth", browserAppOutputPath);
78+
fse.mkdirpSync(path.join(cliBuildPath, "modules"));
79+
fse.copySync(nodePtyModule, path.join(cliBuildPath, "modules", "pty.node"));
80+
});
81+
82+
const buildServerBundle = register("build:server:bundle", async (runner) => {
83+
const cliPath = path.join(pkgsPath, "server");
84+
runner.cwd = cliPath;
85+
await runner.execute("npm", ["run", "build:webpack"]);
86+
});
87+
88+
const buildBootstrapFork = register("build:bootstrap-fork", async (runner) => {
89+
await ensureInstalled();
90+
await ensurePatched();
91+
92+
const vscodePkgPath = path.join(pkgsPath, "vscode");
93+
runner.cwd = vscodePkgPath;
94+
await runner.execute("npm", ["run", "build:bootstrap-fork"]);
95+
});
96+
97+
const buildAppBrowser = register("build:app:browser", async (runner) => {
98+
await ensureInstalled();
99+
100+
const appPath = path.join(pkgsPath, "app/browser");
101+
runner.cwd = appPath;
102+
fse.removeSync(path.join(appPath, "out"));
103+
await runner.execute("npm", ["run", "build"]);
104+
});
105+
106+
const buildWeb = register("build:web", async (runner) => {
107+
await ensureInstalled();
108+
await ensurePatched();
109+
110+
const webPath = path.join(pkgsPath, "web");
111+
runner.cwd = webPath;
112+
fse.removeSync(path.join(webPath, "out"));
113+
await runner.execute("npm", ["run", "build"]);
114+
});
115+
116+
const extDirPath = path.join("lib", "vscode-default-extensions");
117+
const copyForDefaultExtensions = register("build:copy-vscode", async (runner) => {
118+
if (!fs.existsSync(defaultExtensionsPath)) {
119+
await ensureClean();
120+
fse.removeSync(extDirPath);
121+
fse.copySync(vscodePath, extDirPath);
122+
}
123+
});
124+
125+
const buildDefaultExtensions = register("build:default-extensions", async (runner) => {
126+
if (!fs.existsSync(defaultExtensionsPath)) {
127+
await copyForDefaultExtensions();
128+
runner.cwd = extDirPath;
129+
const resp = await runner.execute("npx", ["gulp", "vscode-linux-x64"]);
130+
if (resp.exitCode !== 0) {
131+
throw new Error(`Failed to build default extensions: ${resp.stderr}`);
132+
}
133+
}
134+
});
135+
136+
const ensureInstalled = register("vscode:install", async (runner) => {
137+
await ensureCloned();
138+
139+
runner.cwd = vscodePath;
140+
const install = await runner.execute("yarn", []);
141+
if (install.exitCode !== 0) {
142+
throw new Error(`Failed to install vscode dependencies: ${install.stderr}`);
143+
}
144+
});
145+
146+
const ensureCloned = register("vscode:clone", async (runner) => {
147+
if (fs.existsSync(vscodePath)) {
148+
await ensureClean();
149+
} else {
150+
fs.mkdirSync(libPath);
151+
runner.cwd = libPath;
152+
const clone = await runner.execute("git", ["clone", "https://github.com/microsoft/vscode"]);
153+
if (clone.exitCode !== 0) {
154+
throw new Error(`Failed to clone: ${clone.exitCode}`);
155+
}
156+
}
157+
158+
runner.cwd = vscodePath;
159+
const checkout = await runner.execute("git", ["checkout", "tags/1.31.0"]);
160+
if (checkout.exitCode !== 0) {
161+
throw new Error(`Failed to checkout: ${checkout.stderr}`);
162+
}
163+
});
164+
165+
const ensureClean = register("vscode:clean", async (runner) => {
166+
runner.cwd = vscodePath;
167+
168+
const status = await runner.execute("git", ["status", "--porcelain"]);
169+
if (status.stdout.trim() !== "") {
170+
const clean = await runner.execute("git", ["clean", "-f", "-d", "-X"]);
171+
if (clean.exitCode !== 0) {
172+
throw new Error(`Failed to clean git repository: ${clean.stderr}`);
173+
}
174+
const removeUnstaged = await runner.execute("git", ["checkout", "--", "."]);
175+
if (removeUnstaged.exitCode !== 0) {
176+
throw new Error(`Failed to remove unstaged files: ${removeUnstaged.stderr}`);
177+
}
178+
}
179+
});
180+
181+
const ensurePatched = register("vscode:patch", async (runner) => {
182+
if (!fs.existsSync(vscodePath)) {
183+
throw new Error("vscode must be cloned to patch");
184+
}
185+
await ensureClean();
186+
187+
runner.cwd = vscodePath;
188+
const patchPath = path.join(__dirname, "../scripts/vscode.patch");
189+
const apply = await runner.execute("git", ["apply", "--unidiff-zero", patchPath]);
190+
if (apply.exitCode !== 0) {
191+
throw new Error(`Failed to apply patches: ${apply.stderr}`);
192+
}
193+
});
194+
195+
run();

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
"description": "Run VS Code remotely.",
77
"scripts": {
88
"build:rules": "cd ./rules && tsc -p .",
9-
"vscode:clone": "mkdir -p ./lib && test -d ./lib/vscode || git clone https://github.com/Microsoft/vscode/ ./lib/vscode",
10-
"vscode:install": "cd ./lib/vscode && git checkout tags/1.30.1 && yarn",
11-
"vscode": "npm-run-all vscode:*",
129
"packages:install": "cd ./packages && yarn",
13-
"postinstall": "npm-run-all --parallel vscode packages:install build:rules",
14-
"start": "cd ./packages/server && yarn start",
10+
"postinstall": "npm-run-all --parallel packages:install build:rules",
11+
"start": "cd ./packages/server && yarn start",
12+
"task": "ts-node -r tsconfig-paths/register build/tasks.ts",
1513
"test": "cd ./packages && yarn test"
1614
},
1715
"devDependencies": {
16+
"@types/fs-extra": "^5.0.4",
1817
"@types/node": "^10.12.18",
1918
"@types/trash": "^4.3.1",
2019
"crypto-browserify": "^3.12.0",
2120
"css-loader": "^2.1.0",
2221
"file-loader": "^3.0.1",
2322
"fork-ts-checker-webpack-plugin": "^0.5.2",
23+
"fs-extra": "^7.0.1",
2424
"happypack": "^5.0.1",
2525
"html-webpack-plugin": "^3.2.0",
2626
"http-browserify": "^1.7.0",
@@ -35,6 +35,7 @@
3535
"style-loader": "^0.23.1",
3636
"ts-loader": "^5.3.3",
3737
"ts-node": "^7.0.1",
38+
"tsconfig-paths": "^3.8.0",
3839
"tslint": "^5.12.1",
3940
"typescript": "^3.2.2",
4041
"typescript-tslint-plugin": "^0.2.1",

packages/app/browser/package.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@coder/app",
3+
"scripts": {
4+
"start": "../../../node_modules/.bin/webpack-dev-server --config ./webpack.config.js",
5+
"build": "../../../node_modules/.bin/webpack --config ./webpack.config.js"
6+
},
7+
"dependencies": {
8+
"material-components-web": "^0.44.0"
9+
}
10+
}

packages/app/browser/src/app.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
6+
<title>Coder</title>
7+
</head>
8+
9+
<body>
10+
<div class="login">
11+
<div class="back">
12+
<- Back </div> <h4 class="title">AWS Cloud</h4>
13+
<h2 class="subtitle">
14+
Enter server password
15+
</h2>
16+
<div class="mdc-text-field">
17+
<input type="password" id="password" class="mdc-text-field__input" required>
18+
<label class="mdc-floating-label" for="password">Password</label>
19+
<div class="mdc-line-ripple"></div>
20+
</div>
21+
<div class="mdc-text-field-helper-line">
22+
<div class="mdc-text-field-helper-text">helper text</div>
23+
</div>
24+
<div class="mdc-form-field">
25+
<div class="mdc-checkbox">
26+
<input type="checkbox" class="mdc-checkbox__native-control" id="remember" />
27+
<div class="mdc-checkbox__background">
28+
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
29+
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59" />
30+
</svg>
31+
<div class="mdc-checkbox__mixedmark"></div>
32+
</div>
33+
</div>
34+
<label for="remember">Remember Me</label>
35+
</div>
36+
<button id="submit" class="mdc-button mdc-button--unelevated">
37+
<span class="mdc-button__label">Enter IDE</span>
38+
</button>
39+
</div>
40+
</div>
41+
</body>
42+
43+
</html>

0 commit comments

Comments
 (0)