Skip to content

Commit 8626bed

Browse files
authored
Merge pull request #1619 from cdr/config
Add support for a YAML config file
2 parents 95ac0dd + dc632ac commit 8626bed

17 files changed

+370
-71
lines changed

.eslintrc.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ rules:
2222
# For overloads.
2323
no-dupe-class-members: off
2424
"@typescript-eslint/no-use-before-define": off
25+
"@typescript-eslint/no-non-null-assertion": off
26+
27+
settings:
28+
# Does not work with CommonJS unfortunately.
29+
import/ignore:
30+
- env-paths
31+
- xdg-basedir

ci/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ You can disable minification by setting `MINIFY=`.
7878
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
7979
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
8080
- Entrypoint script for code-server for .deb and .rpm
81+
- [./build/code-server.service](./build/code-server.service)
82+
- systemd user service packaged into the debs and rpms
8183
- [./build/release-github-draft.sh](./build/release-github-draft.sh) (`yarn release:github-draft`)
8284
- Uses [hub](https://github.com/github/hub) to create a draft release with a template description
8385
- [./build/release-github-assets.sh](./build/release-github-assets.sh) (`yarn release:github-assets`)

ci/build/code-server.service

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=code-server
3+
After=network.target
4+
5+
[Service]
6+
Type=exec
7+
ExecStart=/usr/bin/code-server
8+
Restart=always
9+
10+
[Install]
11+
WantedBy=multi-user.target

ci/build/nfpm.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ license: "MIT"
1313
bindir: "/usr/bin"
1414
files:
1515
./ci/build/code-server-nfpm.sh: /usr/bin/code-server
16+
./ci/build/code-server.service: /usr/lib/systemd/user/code-server.service
1617
./release-static/**/*: "/usr/lib/code-server/"

ci/dev/vscode.patch

+87-6
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,88 @@ index e73dd4d9e8..e3192b3a0d 100644
1111
build/node_modules
1212
coverage/
1313
diff --git a/.yarnrc b/.yarnrc
14-
index d86b284e83..a7300dbfb9 100644
14+
deleted file mode 100644
15+
index d86b284e83..0000000000
1516
--- a/.yarnrc
16-
+++ b/.yarnrc
17-
@@ -1,3 +1,3 @@
17+
+++ /dev/null
18+
@@ -1,3 +0,0 @@
1819
-disturl "https://atom.io/download/electron"
1920
-target "7.2.4"
2021
-runtime "electron"
21-
+disturl "http://nodejs.org/dist"
22-
+target "12.16.3"
23-
+runtime "node"
22+
diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js
23+
index f2ea1bd370..2dc6da34fb 100644
24+
--- a/build/gulpfile.reh.js
25+
+++ b/build/gulpfile.reh.js
26+
@@ -52,6 +52,7 @@ gulp.task('vscode-reh-web-linux-x64-min', noop);
27+
gulp.task('vscode-reh-web-linux-alpine-min', noop);
28+
29+
function getNodeVersion() {
30+
+ return process.versions.node
31+
const yarnrc = fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8');
32+
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
33+
return target;
34+
diff --git a/build/lib/electron.js b/build/lib/electron.js
35+
index abf6baab41..8a1d1bad13 100644
36+
--- a/build/lib/electron.js
37+
+++ b/build/lib/electron.js
38+
@@ -17,6 +17,7 @@ const root = path.dirname(path.dirname(__dirname));
39+
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8'));
40+
const commit = util.getVersion(root);
41+
function getElectronVersion() {
42+
+ return process.versions.node;
43+
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
44+
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
45+
return target;
46+
diff --git a/build/lib/electron.ts b/build/lib/electron.ts
47+
index 86c7afcf31..0663b4c28d 100644
48+
--- a/build/lib/electron.ts
49+
+++ b/build/lib/electron.ts
50+
@@ -20,6 +20,7 @@ const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf
51+
const commit = util.getVersion(root);
52+
53+
export function getElectronVersion(): string {
54+
+ return process.versions.node
55+
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
56+
const target = /^target "(.*)"$/m.exec(yarnrc)![1];
57+
return target;
58+
diff --git a/build/lib/node.js b/build/lib/node.js
59+
index 403ae3d965..738ee8cee0 100644
60+
--- a/build/lib/node.js
61+
+++ b/build/lib/node.js
62+
@@ -5,11 +5,8 @@
63+
*--------------------------------------------------------------------------------------------*/
64+
Object.defineProperty(exports, "__esModule", { value: true });
65+
const path = require("path");
66+
-const fs = require("fs");
67+
const root = path.dirname(path.dirname(__dirname));
68+
-const yarnrcPath = path.join(root, 'remote', '.yarnrc');
69+
-const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
70+
-const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)[1];
71+
+const version = process.versions.node;
72+
const node = process.platform === 'win32' ? 'node.exe' : 'node';
73+
const nodePath = path.join(root, '.build', 'node', `v${version}`, `${process.platform}-${process.arch}`, node);
74+
console.log(nodePath);
75+
diff --git a/build/lib/node.ts b/build/lib/node.ts
76+
index 6439703446..c53dccf4dc 100644
77+
--- a/build/lib/node.ts
78+
+++ b/build/lib/node.ts
79+
@@ -4,13 +4,10 @@
80+
*--------------------------------------------------------------------------------------------*/
81+
82+
import * as path from 'path';
83+
-import * as fs from 'fs';
84+
85+
const root = path.dirname(path.dirname(__dirname));
86+
-const yarnrcPath = path.join(root, 'remote', '.yarnrc');
87+
-const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
88+
-const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)![1];
89+
+const version = process.versions.node;
90+
const node = process.platform === 'win32' ? 'node.exe' : 'node';
91+
const nodePath = path.join(root, '.build', 'node', `v${version}`, `${process.platform}-${process.arch}`, node);
92+
93+
-console.log(nodePath);
94+
\ No newline at end of file
95+
+console.log(nodePath);
2496
diff --git a/build/npm/postinstall.js b/build/npm/postinstall.js
2597
index 7a2320d828..5768890636 100644
2698
--- a/build/npm/postinstall.js
@@ -166,6 +238,15 @@ index 91b3b92678..f76f2c1548 100644
166238
"urlProtocol": "code-oss",
167239
"extensionAllowedProposedApi": [
168240
"ms-vscode.vscode-js-profile-table",
241+
diff --git a/remote/.yarnrc b/remote/.yarnrc
242+
deleted file mode 100644
243+
index 1e16cde724..0000000000
244+
--- a/remote/.yarnrc
245+
+++ /dev/null
246+
@@ -1,3 +0,0 @@
247+
-disturl "http://nodejs.org/dist"
248+
-target "12.4.0"
249+
-runtime "node"
169250
diff --git a/src/vs/base/common/network.ts b/src/vs/base/common/network.ts
170251
index e4546b2cf6..9df12239fb 100644
171252
--- a/src/vs/base/common/network.ts

ci/steps/publish-npm.sh

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ main() {
1010
fi
1111

1212
download_artifact npm-package ./release
13+
# https://github.com/actions/upload-artifact/issues/38
14+
chmod +x $(grep -rl '^#!/.\+' release)
1315
yarn publish --non-interactive release
1416
}
1517

doc/FAQ.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ code-server crashes can be helpful.
168168
### Where is the data directory?
169169

170170
If the `XDG_DATA_HOME` environment variable is set the data directory will be
171-
`$XDG_DATA_HOME/code-server`. Otherwise the default is:
171+
`$XDG_DATA_HOME/code-server`. Otherwise:
172172

173-
1. Linux: `~/.local/share/code-server`.
174-
2. Mac: `~/Library/Application\ Support/code-server`.
173+
1. Unix: `~/.local/share/code-server`
174+
1. Windows: `%APPDATA%\Local\code-server\Data`
175175

176176
## Enterprise
177177

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@types/adm-zip": "^0.4.32",
3434
"@types/fs-extra": "^8.0.1",
3535
"@types/http-proxy": "^1.17.4",
36+
"@types/js-yaml": "^3.12.3",
3637
"@types/mocha": "^5.2.7",
3738
"@types/node": "^12.12.7",
3839
"@types/parcel-bundler": "^1.12.1",
@@ -55,8 +56,7 @@
5556
"stylelint": "^13.0.0",
5657
"stylelint-config-recommended": "^3.0.0",
5758
"ts-node": "^8.4.1",
58-
"typescript": "3.7.2",
59-
"yarn": "^1.22.4"
59+
"typescript": "3.7.2"
6060
},
6161
"resolutions": {
6262
"@types/node": "^12.12.7",
@@ -66,16 +66,20 @@
6666
"dependencies": {
6767
"@coder/logger": "1.1.11",
6868
"adm-zip": "^0.4.14",
69+
"env-paths": "^2.2.0",
6970
"fs-extra": "^8.1.0",
7071
"http-proxy": "^1.18.0",
7172
"httpolyglot": "^0.1.2",
73+
"js-yaml": "^3.13.1",
7274
"limiter": "^1.1.5",
7375
"pem": "^1.14.2",
7476
"safe-compare": "^1.1.4",
7577
"semver": "^7.1.3",
7678
"tar": "^6.0.1",
7779
"tar-fs": "^2.0.0",
78-
"ws": "^7.2.0"
80+
"ws": "^7.2.0",
81+
"xdg-basedir": "^4.0.0",
82+
"yarn": "^1.22.4"
7983
},
8084
"bin": {
8185
"code-server": "out/node/entry.js"

src/browser/pages/login.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div class="card-box">
2727
<div class="header">
2828
<h1 class="main">Welcome to code-server</h1>
29-
<div class="sub">Please log in below. Check code-server's logs for the generated password.</div>
29+
<div class="sub">Please log in below. {{PASSWORD_MSG}}</div>
3030
</div>
3131
<div class="content">
3232
<form class="login-form" method="post">

src/node/app/login.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as http from "http"
22
import * as limiter from "limiter"
33
import * as querystring from "querystring"
44
import { HttpCode, HttpError } from "../../common/http"
5-
import { AuthType, HttpProvider, HttpResponse, Route } from "../http"
6-
import { hash } from "../util"
5+
import { AuthType, HttpProvider, HttpProviderOptions, HttpResponse, Route } from "../http"
6+
import { hash, humanPath } from "../util"
77

88
interface LoginPayload {
99
password?: string
@@ -18,6 +18,14 @@ interface LoginPayload {
1818
* Login HTTP provider.
1919
*/
2020
export class LoginHttpProvider extends HttpProvider {
21+
public constructor(
22+
options: HttpProviderOptions,
23+
private readonly configFile: string,
24+
private readonly envPassword: boolean,
25+
) {
26+
super(options)
27+
}
28+
2129
public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> {
2230
if (this.options.auth !== AuthType.Password || !this.isRoot(route)) {
2331
throw new HttpError("Not found", HttpCode.NotFound)
@@ -46,6 +54,11 @@ export class LoginHttpProvider extends HttpProvider {
4654
public async getRoot(route: Route, error?: Error): Promise<HttpResponse> {
4755
const response = await this.getUtf8Resource(this.rootPath, "src/browser/pages/login.html")
4856
response.content = response.content.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : "")
57+
let passwordMsg = `Check the config file at ${humanPath(this.configFile)} for the password.`
58+
if (this.envPassword) {
59+
passwordMsg = "Password was set from $PASSWORD."
60+
}
61+
response.content = response.content.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
4962
return this.replaceTemplates(route, response)
5063
}
5164

0 commit comments

Comments
 (0)