Skip to content

Commit 6eb70ca

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Fix error when shared process exits with null Add flags for customizing user data dir and extensions dir (coder#420) Initialize backup service (coder#419) Add port in use message (coder#418) Improve CI caching (coder#416) Update notes title
2 parents 149ec62 + e12fcd3 commit 6eb70ca

File tree

21 files changed

+264
-108
lines changed

21 files changed

+264
-108
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist
44
out
55
.DS_Store
66
release
7+
.cache

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ env:
99
matrix:
1010
include:
1111
- os: linux
12-
dist: ubuntu
12+
dist: trusty
1313
- os: osx
1414
before_install:
1515
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev
1616
libsecret-1-dev; fi
17+
- npm install -g yarn@1.12.3
1718
script:
1819
- scripts/build.sh
1920
before_deploy:
@@ -39,4 +40,8 @@ deploy:
3940
repo: devonlineco/code-server
4041
all_branches: true
4142
condition: $TRAVIS_BRANCH =~ ^master|testing|stable$
42-
cache: yarn
43+
cache:
44+
yarn: true
45+
timeout: 1000
46+
directories:
47+
- .cache

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ How to [secure your setup](/doc/security/ssl.md).
6363
- Electron and Chrome OS applications to bridge the gap between local<->remote.
6464
- Run VS Code unit tests against our builds to ensure features work as expected.
6565
66-
### Notes
66+
### Extensions
6767
6868
At the moment we can't use the official VSCode Marketplace. We've created a custom extension marketplace focused around open-sourced extensions. However, if you have access to the `.vsix` file, you can manually install the extension.
6969

build/tasks.ts

Lines changed: 34 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import * as fse from "fs-extra";
44
import * as os from "os";
55
import * as path from "path";
66
import * as zlib from "zlib";
7+
import * as https from "https";
8+
import * as tar from "tar";
79

810
const isWin = os.platform() === "win32";
911
const libPath = path.join(__dirname, "../lib");
1012
const vscodePath = path.join(libPath, "vscode");
13+
const defaultExtensionsPath = path.join(libPath, "extensions");
1114
const pkgsPath = path.join(__dirname, "../packages");
12-
const defaultExtensionsPath = path.join(libPath, "VSCode-linux-x64/resources/app/extensions");
1315
const vscodeVersion = process.env.VSCODE_VERSION || "1.32.0";
16+
const vsSourceUrl = `https://codesrv-ci.cdr.sh/vstar-${vscodeVersion}.tar.gz`;
1417

1518
const buildServerBinary = register("build:server:binary", async (runner) => {
1619
await ensureInstalled();
17-
await copyForDefaultExtensions();
1820
await Promise.all([
1921
buildBootstrapFork(),
2022
buildWeb(),
21-
buildDefaultExtensions(),
2223
buildServerBundle(),
2324
buildAppBrowser(),
2425
]);
@@ -129,97 +130,50 @@ const buildWeb = register("build:web", async (runner) => {
129130
await runner.execute(isWin ? "npm.cmd" : "npm", ["run", "build"]);
130131
});
131132

132-
const extDirPath = path.join("lib", "vscode-default-extensions");
133-
const copyForDefaultExtensions = register("build:copy-vscode", async (runner) => {
134-
if (!fs.existsSync(defaultExtensionsPath)) {
135-
await ensureClean();
136-
await ensureInstalled();
137-
await new Promise((resolve, reject): void => {
138-
fse.remove(extDirPath, (err) => {
139-
if (err) {
140-
return reject(err);
141-
}
142-
143-
resolve();
144-
});
145-
});
146-
await new Promise((resolve, reject): void => {
147-
fse.copy(vscodePath, extDirPath, (err) => {
148-
if (err) {
149-
return reject(err);
150-
}
151-
152-
resolve();
153-
});
154-
});
155-
}
156-
});
157-
158-
const buildDefaultExtensions = register("build:default-extensions", async (runner) => {
159-
if (!fs.existsSync(defaultExtensionsPath)) {
160-
await copyForDefaultExtensions();
161-
runner.cwd = extDirPath;
162-
const resp = await runner.execute(isWin ? "npx.cmd" : "npx", [isWin ? "gulp.cmd" : "gulp", "vscode-linux-x64", "--max-old-space-size=32384"]);
163-
if (resp.exitCode !== 0) {
164-
throw new Error(`Failed to build default extensions: ${resp.stderr}`);
165-
}
166-
}
167-
});
168-
169133
const ensureInstalled = register("vscode:install", async (runner) => {
170-
await ensureCloned();
134+
runner.cwd = libPath;
171135

172-
runner.cwd = vscodePath;
173-
const install = await runner.execute(isWin ? "yarn.cmd" : "yarn", []);
174-
if (install.exitCode !== 0) {
175-
throw new Error(`Failed to install vscode dependencies: ${install.stderr}`);
176-
}
177-
});
136+
if (fs.existsSync(vscodePath) && fs.existsSync(defaultExtensionsPath)) {
137+
const pkgVersion = JSON.parse(fs.readFileSync(path.join(vscodePath, "package.json")).toString("utf8")).version;
138+
if (pkgVersion === vscodeVersion) {
139+
runner.cwd = vscodePath;
178140

179-
const ensureCloned = register("vscode:clone", async (runner) => {
180-
if (fs.existsSync(vscodePath)) {
181-
await ensureClean();
182-
} else {
183-
fse.mkdirpSync(libPath);
184-
runner.cwd = libPath;
185-
const clone = await runner.execute("git", ["clone", "https://github.com/microsoft/vscode", "--branch", vscodeVersion, "--single-branch", "--depth=1"]);
186-
if (clone.exitCode !== 0) {
187-
throw new Error(`Failed to clone: ${clone.exitCode}`);
141+
const reset = await runner.execute("git", ["reset", "--hard"]);
142+
if (reset.exitCode !== 0) {
143+
throw new Error(`Failed to clean git repository: ${reset.stderr}`);
144+
}
145+
146+
return;
188147
}
189148
}
190149

191-
runner.cwd = vscodePath;
192-
const checkout = await runner.execute("git", ["checkout", vscodeVersion]);
193-
if (checkout.exitCode !== 0) {
194-
throw new Error(`Failed to checkout: ${checkout.stderr}`);
195-
}
196-
});
150+
fse.removeSync(libPath);
151+
fse.mkdirpSync(libPath);
197152

198-
const ensureClean = register("vscode:clean", async (runner) => {
199-
runner.cwd = vscodePath;
153+
await new Promise<void>((resolve, reject): void => {
154+
https.get(vsSourceUrl, (res) => {
155+
if (res.statusCode !== 200) {
156+
return reject(res.statusMessage);
157+
}
200158

201-
const status = await runner.execute("git", ["status", "--porcelain"]);
202-
if (status.stdout.trim() !== "") {
203-
const clean = await runner.execute("git", ["clean", "-f", "-d", "-X"]);
204-
if (clean.exitCode !== 0) {
205-
throw new Error(`Failed to clean git repository: ${clean.stderr}`);
206-
}
207-
const removeUnstaged = await runner.execute("git", ["checkout", "--", "."]);
208-
if (removeUnstaged.exitCode !== 0) {
209-
throw new Error(`Failed to remove unstaged files: ${removeUnstaged.stderr}`);
210-
}
211-
}
212-
const fetch = await runner.execute("git", ["fetch", "--prune"]);
213-
if (fetch.exitCode !== 0) {
214-
throw new Error(`Failed to fetch latest changes: ${fetch.stderr}`);
215-
}
159+
res.pipe(tar.x({
160+
C: libPath,
161+
}).on("finish", () => {
162+
resolve();
163+
}).on("error", (err: Error) => {
164+
reject(err);
165+
}));
166+
}).on("error", (err) => {
167+
reject(err);
168+
});
169+
});
216170
});
217171

218172
const ensurePatched = register("vscode:patch", async (runner) => {
219173
if (!fs.existsSync(vscodePath)) {
220174
throw new Error("vscode must be cloned to patch");
221175
}
222-
await ensureClean();
176+
await ensureInstalled();
223177

224178
runner.cwd = vscodePath;
225179
const patchPath = path.join(__dirname, "../scripts/vscode.patch");

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"devDependencies": {
1616
"@types/fs-extra": "^5.0.4",
1717
"@types/node": "^10.12.18",
18+
"@types/tar": "^4.0.0",
1819
"@types/trash": "^4.3.1",
20+
"cache-loader": "^2.0.1",
1921
"cross-env": "^5.2.0",
2022
"crypto-browserify": "^3.12.0",
2123
"css-loader": "^2.1.0",
@@ -34,6 +36,8 @@
3436
"sass-loader": "^7.1.0",
3537
"string-replace-loader": "^2.1.1",
3638
"style-loader": "^0.23.1",
39+
"tar": "^4.4.8",
40+
"terser-webpack-plugin": "^1.2.3",
3741
"ts-loader": "^5.3.3",
3842
"ts-node": "^7.0.1",
3943
"tsconfig-paths": "^3.8.0",

packages/protocol/src/browser/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ export class Client {
271271
workingDirectory: init.getWorkingDirectory(),
272272
os: protoToOperatingSystem(init.getOperatingSystem()),
273273
shell: init.getShell(),
274+
extensionsDirectory: init.getExtensionsDirectory(),
274275
builtInExtensionsDirectory: init.getBuiltinExtensionsDir(),
275276
};
276277
this.initDataEmitter.emit(this._initData);

packages/protocol/src/common/connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface InitData {
2323
readonly homeDirectory: string;
2424
readonly tmpDirectory: string;
2525
readonly shell: string;
26+
readonly extensionsDirectory: string;
2627
readonly builtInExtensionsDirectory: string;
2728
}
2829

packages/protocol/src/node/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ServerOptions {
1414
readonly dataDirectory: string;
1515
readonly cacheDirectory: string;
1616
readonly builtInExtensionsDirectory: string;
17+
readonly extensionsDirectory: string;
1718
readonly fork?: ForkProvider;
1819
}
1920

@@ -93,6 +94,7 @@ export class Server {
9394
initMsg.setDataDirectory(this.options.dataDirectory);
9495
initMsg.setWorkingDirectory(this.options.workingDirectory);
9596
initMsg.setBuiltinExtensionsDir(this.options.builtInExtensionsDirectory);
97+
initMsg.setExtensionsDirectory(this.options.extensionsDirectory);
9698
initMsg.setHomeDirectory(os.homedir());
9799
initMsg.setTmpDirectory(os.tmpdir());
98100
initMsg.setOperatingSystem(platformToProto(os.platform()));

packages/protocol/src/proto/client.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ message WorkingInit {
4141
OperatingSystem operating_system = 5;
4242
string shell = 6;
4343
string builtin_extensions_dir = 7;
44+
string extensions_directory = 8;
4445
}

packages/protocol/src/proto/client_pb.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export class WorkingInit extends jspb.Message {
132132
getBuiltinExtensionsDir(): string;
133133
setBuiltinExtensionsDir(value: string): void;
134134

135+
getExtensionsDirectory(): string;
136+
setExtensionsDirectory(value: string): void;
137+
135138
serializeBinary(): Uint8Array;
136139
toObject(includeInstance?: boolean): WorkingInit.AsObject;
137140
static toObject(includeInstance: boolean, msg: WorkingInit): WorkingInit.AsObject;
@@ -151,6 +154,7 @@ export namespace WorkingInit {
151154
operatingSystem: WorkingInit.OperatingSystem,
152155
shell: string,
153156
builtinExtensionsDir: string,
157+
extensionsDirectory: string,
154158
}
155159

156160
export enum OperatingSystem {

packages/protocol/src/proto/client_pb.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,8 @@ proto.WorkingInit.toObject = function(includeInstance, msg) {
794794
workingDirectory: jspb.Message.getFieldWithDefault(msg, 4, ""),
795795
operatingSystem: jspb.Message.getFieldWithDefault(msg, 5, 0),
796796
shell: jspb.Message.getFieldWithDefault(msg, 6, ""),
797-
builtinExtensionsDir: jspb.Message.getFieldWithDefault(msg, 7, "")
797+
builtinExtensionsDir: jspb.Message.getFieldWithDefault(msg, 7, ""),
798+
extensionsDirectory: jspb.Message.getFieldWithDefault(msg, 8, "")
798799
};
799800

800801
if (includeInstance) {
@@ -859,6 +860,10 @@ proto.WorkingInit.deserializeBinaryFromReader = function(msg, reader) {
859860
var value = /** @type {string} */ (reader.readString());
860861
msg.setBuiltinExtensionsDir(value);
861862
break;
863+
case 8:
864+
var value = /** @type {string} */ (reader.readString());
865+
msg.setExtensionsDirectory(value);
866+
break;
862867
default:
863868
reader.skipField();
864869
break;
@@ -937,6 +942,13 @@ proto.WorkingInit.serializeBinaryToWriter = function(message, writer) {
937942
f
938943
);
939944
}
945+
f = message.getExtensionsDirectory();
946+
if (f.length > 0) {
947+
writer.writeString(
948+
8,
949+
f
950+
);
951+
}
940952
};
941953

942954

@@ -1054,4 +1066,19 @@ proto.WorkingInit.prototype.setBuiltinExtensionsDir = function(value) {
10541066
};
10551067

10561068

1069+
/**
1070+
* optional string extensions_directory = 8;
1071+
* @return {string}
1072+
*/
1073+
proto.WorkingInit.prototype.getExtensionsDirectory = function() {
1074+
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, ""));
1075+
};
1076+
1077+
1078+
/** @param {string} value */
1079+
proto.WorkingInit.prototype.setExtensionsDirectory = function(value) {
1080+
jspb.Message.setProto3StringField(this, 8, value);
1081+
};
1082+
1083+
10571084
goog.object.extend(exports, proto);

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build:binary": "ts-node scripts/nbin.ts"
1010
},
1111
"dependencies": {
12-
"@coder/nbin": "^1.0.4",
12+
"@coder/nbin": "^1.0.5",
1313
"commander": "^2.19.0",
1414
"express": "^4.16.4",
1515
"express-static-gzip": "^1.1.3",

0 commit comments

Comments
 (0)