Skip to content

Commit 57fc27b

Browse files
kylecarbscode-asher
authored andcommitted
Fix readdir for root path (#35)
* Fix readdir for root path * Fix merge of webpack conf * Fix travis.yml to deploy on master * Remove windows platform from travis.yml * Enable caching * mkdirpSync * Fix build script
1 parent 37ae893 commit 57fc27b

File tree

8 files changed

+84
-42
lines changed

8 files changed

+84
-42
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
language: node_js
2+
cache:
3+
yarn: true
4+
directories:
5+
- lib
26
node_js:
37
- 8.9.3
48
matrix:
59
include:
610
- os: linux
711
dist: ubuntu
812
- os: osx
9-
- os: windows
1013
before_install:
1114
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev libsecret-1-dev;
1215
fi
@@ -20,4 +23,4 @@ deploy:
2023
file: packages/server/cli-$TRAVIS_OS_NAME
2124
on:
2225
repo: codercom/vscode-online
23-
all_branches: true
26+
branch: master

build/tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const ensureCloned = register("vscode:clone", async (runner) => {
190190
if (fs.existsSync(vscodePath)) {
191191
await ensureClean();
192192
} else {
193-
fs.mkdirSync(libPath);
193+
fse.mkdirpSync(libPath);
194194
runner.cwd = libPath;
195195
const clone = await runner.execute("git", ["clone", "https://github.com/microsoft/vscode"]);
196196
if (clone.exitCode !== 0) {

packages/server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"files": [],
66
"scripts": {
77
"start": "node --max-old-space-size=32384 --require ts-node/register --require tsconfig-paths/register src/cli.ts",
8-
"build:webpack": "rm -rf ./out && export CLI=true && ../../node_modules/.bin/webpack --config ./webpack.config.js",
8+
"build:webpack": "rm -rf ./out && export CLI=true && UV_THREADPOOL_SIZE=100 node --max-old-space-size=32384 ../../node_modules/webpack/bin/webpack.js --config ./webpack.config.js",
99
"build:nexe": "node scripts/nexe.js",
1010
"build:bootstrap-fork": "cd ../vscode && npm run build:bootstrap-fork; mkdir -p ./packages/server/resources; cp ./bin/bootstrap-fork.js ../server/resources/bootstrap-fork.js",
1111
"build:default-extensions": "cd ../../lib/vscode && npx gulp vscode-linux-arm && cd ../.. && mkdir -p ./packages/server/resources/extensions; cp -r ./lib/VSCode-linux-arm/resources/app/extensions/* ./packages/server/resources/extensions/",
@@ -20,7 +20,6 @@
2020
"express-static-gzip": "^1.1.3",
2121
"httpolyglot": "^0.1.2",
2222
"mime-types": "^2.1.21",
23-
"nexe": "^2.0.0-rc.34",
2423
"node-netstat": "^1.6.0",
2524
"pem": "^1.14.1",
2625
"promise.prototype.finally": "^3.1.0",
@@ -34,6 +33,7 @@
3433
"@types/pem": "^1.9.4",
3534
"@types/ws": "^6.0.1",
3635
"fs-extra": "^7.0.1",
36+
"nexe": "^2.0.0-rc.34",
3737
"string-replace-webpack-plugin": "^0.1.3",
3838
"ts-node": "^7.0.1",
3939
"tsconfig-paths": "^3.7.0",

packages/server/scripts/nexe.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ const fs = require("fs");
22
const fse = require("fs-extra");
33
const os = require("os");
44
const path = require("path");
5+
6+
const nexePath = require.resolve("nexe");
7+
const shimPath = path.join(path.dirname(nexePath), "lib/steps/shim.js");
8+
let shimContent = fs.readFileSync(shimPath).toString();
9+
const replaceString = `global.nativeFs = { readdir: originalReaddir, readdirSync: originalReaddirSync };`;
10+
shimContent = shimContent.replace(/compiler\.options\.resources\.length[\s\S]*wrap\("(.*\\n)"/g, (om, a) => {
11+
return om.replace(a, `${a}${replaceString}`);
12+
});
13+
fs.writeFileSync(shimPath, shimContent);
14+
515
const nexe = require("nexe");
616

717
nexe.compile({
@@ -13,7 +23,7 @@ nexe.compile({
1323
* To include native extensions, do NOT install node_modules for each one. They
1424
* are not required as each extension is built using webpack.
1525
*/
16-
resources: [
26+
resources: [
1727
path.join(__dirname, "../package.json"),
1828
path.join(__dirname, "../build/**/*"),
1929
],

packages/server/src/cli.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ export class Entry extends Command {
7272
return requireFork(modulePath, JSON.parse(flags.args!), builtInExtensionsDir);
7373
}
7474

75-
if (buildDir && buildDir.startsWith(workingDir)) {
76-
logger.error("Cannot run binary inside of BUILD_DIR", field("build_dir", buildDir), field("cwd", process.cwd()));
77-
process.exit(1);
78-
}
79-
8075
if (!fs.existsSync(dataDir)) {
8176
fs.mkdirSync(dataDir);
8277
}

packages/server/src/fill.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import * as fs from "fs";
2+
import * as path from "path";
23
import * as util from "util";
3-
import { isCli } from "./constants";
4+
import { isCli, buildDir } from "./constants";
45

6+
// tslint:disable:no-any
7+
const nativeFs = (<any>global).nativeFs as typeof fs || {};
58
const oldAccess = fs.access;
69
const existsWithinBinary = (path: fs.PathLike): Promise<boolean> => {
710
return new Promise<boolean>((resolve): void => {
@@ -39,7 +42,7 @@ export const fillFs = (): void => {
3942

4043
const replaceNative = <T extends keyof typeof fs>(propertyName: T, func: (callOld: () => void, ...args: any[]) => any, customPromisify?: (...args: any[]) => Promise<any>): void => {
4144
const oldFunc = (<any>fs)[propertyName];
42-
fs[propertyName] = (...args: any[]) => {
45+
fs[propertyName] = (...args: any[]): any => {
4346
try {
4447
return func(() => {
4548
return oldFunc(...args);
@@ -49,7 +52,7 @@ export const fillFs = (): void => {
4952
}
5053
};
5154
if (customPromisify) {
52-
(<any>fs[propertyName])[util.promisify.custom] = (...args: any[]) => {
55+
(<any>fs[propertyName])[util.promisify.custom] = (...args: any[]): any => {
5356
return customPromisify(...args).catch((ex) => {
5457
throw ex;
5558
});
@@ -75,7 +78,7 @@ export const fillFs = (): void => {
7578

7679
return callOld();
7780
});
78-
}, (path) => new Promise((res) => fs.exists(path, res)));
81+
}, (path) => new Promise((res): void => fs.exists(path, res)));
7982

8083
replaceNative("open", (callOld, path: fs.PathLike, flags: string | Number, mode: any, callback: any) => {
8184
existsWithinBinary(path).then((exists) => {
@@ -110,7 +113,7 @@ export const fillFs = (): void => {
110113
callback();
111114
});
112115

113-
replaceNative("read", (callOld, fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void, ) => {
116+
replaceNative("read", (callOld, fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void) => {
114117
if (!fds.has(fd)) {
115118
return callOld();
116119
}
@@ -136,7 +139,7 @@ export const fillFs = (): void => {
136139
bytesRead: number;
137140
buffer: Buffer;
138141
}> => {
139-
return new Promise((res, rej) => {
142+
return new Promise((res, rej): void => {
140143
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
141144
if (err) {
142145
return rej(err);
@@ -149,4 +152,13 @@ export const fillFs = (): void => {
149152
});
150153
});
151154
});
155+
156+
replaceNative("readdir", (callOld, directory: string, callback: (err: NodeJS.ErrnoException, paths: string[]) => void) => {
157+
const relative = path.relative(directory, buildDir!);
158+
if (relative.startsWith("..")) {
159+
return callOld();
160+
}
161+
162+
return nativeFs.readdir(directory, callback);
163+
});
152164
};

packages/server/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const merge = require("webpack-merge");
44

55
module.exports = merge({
66
devtool: "none",
7-
mode: "development",
7+
mode: "production",
88
output: {
99
filename: "cli.js",
1010
path: path.join(__dirname, "./out"),

packages/server/yarn.lock

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ ajax-request@^1.2.0:
191191
utils-extend "^1.0.7"
192192

193193
ajv@^6.5.5:
194-
version "6.7.0"
195-
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.7.0.tgz#e3ce7bb372d6577bb1839f1dfdfcbf5ad2948d96"
196-
integrity sha512-RZXPviBTtfmtka9n9sy1N5M5b82CbxWIR6HIis4s3WQTXDJamc/0gpCWNGz6EWdWp4DOfjzJfhz/AS9zVPjjWg==
194+
version "6.9.2"
195+
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.9.2.tgz#4927adb83e7f48e5a32b45729744c71ec39c9c7b"
196+
integrity sha512-4UFy0/LgDo7Oa/+wOAlj44tp9K78u38E5/359eSrqEp1Z5PdVfimCcs7SluXMP755RUQu6d2b4AvF0R1C9RZjg==
197197
dependencies:
198198
fast-deep-equal "^2.0.1"
199199
fast-json-stable-stringify "^2.0.0"
@@ -433,9 +433,9 @@ big.js@^3.1.3:
433433
integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==
434434

435435
binary-extensions@^1.0.0:
436-
version "1.12.0"
437-
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14"
438-
integrity sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==
436+
version "1.13.0"
437+
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.0.tgz#9523e001306a32444b907423f1de2164222f6ab1"
438+
integrity sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw==
439439

440440
bl@^1.0.0:
441441
version "1.2.2"
@@ -1068,9 +1068,9 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
10681068
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
10691069

10701070
escodegen@^1.8.1:
1071-
version "1.11.0"
1072-
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.11.0.tgz#b27a9389481d5bfd5bec76f7bb1eb3f8f4556589"
1073-
integrity sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==
1071+
version "1.11.1"
1072+
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.11.1.tgz#c485ff8d6b4cdb89e27f4a856e91f118401ca510"
1073+
integrity sha512-JwiqFD9KdGVVpeuRa68yU3zZnBEOcPs0nKW7wZzXky8Z7tffdYUHbe11bPCV5jYlK6DVdKLWLm0f5I/QlL0Kmw==
10741074
dependencies:
10751075
esprima "^3.1.3"
10761076
estraverse "^4.2.0"
@@ -1468,9 +1468,9 @@ function-bind@^1.1.1:
14681468
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
14691469

14701470
fuse-box@^3.1.0:
1471-
version "3.6.0"
1472-
resolved "https://registry.yarnpkg.com/fuse-box/-/fuse-box-3.6.0.tgz#a4adf41a60855c7b0a0775b3095b6b0c2d35b011"
1473-
integrity sha512-j/lIXZHIiHv2w9gxOBj9k8vAORXt0GrPQt/zc4ttVG3WT5pQ0uaqpxu6m4Npwk4WgOjN4mieD3taK4S56Ol3Zw==
1471+
version "3.7.1"
1472+
resolved "https://registry.yarnpkg.com/fuse-box/-/fuse-box-3.7.1.tgz#d32879ceee4c8bcec9bbd8fcfe5b29e7142371cd"
1473+
integrity sha512-aM7t9bUcRpNNQu9M+YjXXzx9JSJQVPWeY+8iTyv7OhvJNWHrqqEWPzbn9OfcyFa2AfPwAUyC/uzWexBbjtTvsA==
14741474
dependencies:
14751475
acorn "^5.7.3"
14761476
acorn-jsx "^4.0.1"
@@ -1500,6 +1500,8 @@ fuse-box@^3.1.0:
15001500
request "^2.79.0"
15011501
shorthash "0.0.2"
15021502
source-map "^0.7.1"
1503+
sourcemap-blender "1.0.5"
1504+
stream-browserify "^2.0.1"
15031505
tslib "^1.8.0"
15041506
watch "^1.0.1"
15051507
ws "^1.1.1"
@@ -1551,9 +1553,9 @@ get-value@^2.0.3, get-value@^2.0.6:
15511553
integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=
15521554

15531555
getopts@^2.1.1:
1554-
version "2.2.3"
1555-
resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.3.tgz#11d229775e2ec2067ed8be6fcc39d9b4bf39cf7d"
1556-
integrity sha512-viEcb8TpgeG05+Nqo5EzZ8QR0hxdyrYDp6ZSTZqe2M/h53Bk036NmqG38Vhf5RGirC/Of9Xql+v66B2gp256SQ==
1556+
version "2.2.4"
1557+
resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.4.tgz#3137fe8a5fddf304904059a851bdc1c22f0f54fb"
1558+
integrity sha512-Rz7DGyomZjrenu9Jx4qmzdlvJgvrEFHXHvjK0FcZtcTC1U5FmES7OdZHUwMuSnEE6QvBvwse1JODKj7TgbSEjQ==
15571559

15581560
getpass@^0.1.1:
15591561
version "0.1.7"
@@ -1806,7 +1808,7 @@ inflight@^1.0.4:
18061808
once "^1.3.0"
18071809
wrappy "1"
18081810

1809-
inherits@2, [email protected], inherits@^2.0.1, inherits@~2.0.3:
1811+
inherits@2, [email protected], inherits@^2.0.1, inherits@~2.0.1, inherits@~2.0.3:
18101812
version "2.0.3"
18111813
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
18121814
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
@@ -2353,7 +2355,19 @@ mime-db@^1.28.0, mime-db@~1.37.0:
23532355
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8"
23542356
integrity sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==
23552357

2356-
mime-types@^2.1.12, mime-types@^2.1.21, mime-types@~2.1.18, mime-types@~2.1.19:
2358+
mime-db@~1.38.0:
2359+
version "1.38.0"
2360+
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.38.0.tgz#1a2aab16da9eb167b49c6e4df2d9c68d63d8e2ad"
2361+
integrity sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==
2362+
2363+
mime-types@^2.1.12, mime-types@~2.1.19:
2364+
version "2.1.22"
2365+
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.22.tgz#fe6b355a190926ab7698c9a0556a11199b2199bd"
2366+
integrity sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==
2367+
dependencies:
2368+
mime-db "~1.38.0"
2369+
2370+
mime-types@^2.1.21, mime-types@~2.1.18:
23572371
version "2.1.21"
23582372
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96"
23592373
integrity sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==
@@ -2552,9 +2566,9 @@ [email protected]:
25522566
sort-keys "^2.0.0"
25532567

25542568
npm-bundled@^1.0.1:
2555-
version "1.0.5"
2556-
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.5.tgz#3c1732b7ba936b3a10325aef616467c0ccbcc979"
2557-
integrity sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==
2569+
version "1.0.6"
2570+
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd"
2571+
integrity sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==
25582572

25592573
npm-conf@^1.1.0:
25602574
version "1.1.3"
@@ -2565,9 +2579,9 @@ npm-conf@^1.1.0:
25652579
pify "^3.0.0"
25662580

25672581
npm-packlist@^1.1.6:
2568-
version "1.2.0"
2569-
resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.2.0.tgz#55a60e793e272f00862c7089274439a4cc31fc7f"
2570-
integrity sha512-7Mni4Z8Xkx0/oegoqlcao/JpPCPEMtUvsmB0q7mgvlMinykJLSRTYuFqoQLYgGY8biuxIeiHO+QNJKbCfljewQ==
2582+
version "1.4.1"
2583+
resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.1.tgz#19064cdf988da80ea3cee45533879d90192bbfbc"
2584+
integrity sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==
25712585
dependencies:
25722586
ignore-walk "^3.0.1"
25732587
npm-bundled "^1.0.1"
@@ -3310,7 +3324,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1:
33103324
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
33113325
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
33123326

3313-
source-map@^0.7.1:
3327+
source-map@^0.7.1, source-map@^0.7.3:
33143328
version "0.7.3"
33153329
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
33163330
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
@@ -3362,6 +3376,14 @@ statuses@~1.4.0:
33623376
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087"
33633377
integrity sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==
33643378

3379+
stream-browserify@^2.0.1:
3380+
version "2.0.2"
3381+
resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b"
3382+
integrity sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==
3383+
dependencies:
3384+
inherits "~2.0.1"
3385+
readable-stream "^2.0.2"
3386+
33653387
strict-uri-encode@^1.0.0:
33663388
version "1.1.0"
33673389
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"

0 commit comments

Comments
 (0)