Skip to content

Add support for a YAML config file #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ rules:
# For overloads.
no-dupe-class-members: off
"@typescript-eslint/no-use-before-define": off
"@typescript-eslint/no-non-null-assertion": off

settings:
# Does not work with CommonJS unfortunately.
import/ignore:
- env-paths
- xdg-basedir
2 changes: 2 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ You can disable minification by setting `MINIFY=`.
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
- Entrypoint script for code-server for .deb and .rpm
- [./build/code-server.service](./build/code-server.service)
- systemd user service packaged into the debs and rpms
- [./build/release-github-draft.sh](./build/release-github-draft.sh) (`yarn release:github-draft`)
- Uses [hub](https://github.com/github/hub) to create a draft release with a template description
- [./build/release-github-assets.sh](./build/release-github-assets.sh) (`yarn release:github-assets`)
Expand Down
11 changes: 11 additions & 0 deletions ci/build/code-server.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=code-server
After=network.target

[Service]
Type=exec
ExecStart=/usr/bin/code-server
Restart=always

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions ci/build/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ license: "MIT"
bindir: "/usr/bin"
files:
./ci/build/code-server-nfpm.sh: /usr/bin/code-server
./ci/build/code-server.service: /usr/lib/systemd/user/code-server.service
./release-static/**/*: "/usr/lib/code-server/"
93 changes: 87 additions & 6 deletions ci/dev/vscode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,88 @@ index e73dd4d9e8..e3192b3a0d 100644
build/node_modules
coverage/
diff --git a/.yarnrc b/.yarnrc
index d86b284e83..a7300dbfb9 100644
deleted file mode 100644
index d86b284e83..0000000000
--- a/.yarnrc
+++ b/.yarnrc
@@ -1,3 +1,3 @@
+++ /dev/null
@@ -1,3 +0,0 @@
-disturl "https://atom.io/download/electron"
-target "7.2.4"
-runtime "electron"
+disturl "http://nodejs.org/dist"
+target "12.16.3"
+runtime "node"
diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js
index f2ea1bd370..2dc6da34fb 100644
--- a/build/gulpfile.reh.js
+++ b/build/gulpfile.reh.js
@@ -52,6 +52,7 @@ gulp.task('vscode-reh-web-linux-x64-min', noop);
gulp.task('vscode-reh-web-linux-alpine-min', noop);

function getNodeVersion() {
+ return process.versions.node
const yarnrc = fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8');
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
return target;
diff --git a/build/lib/electron.js b/build/lib/electron.js
index abf6baab41..8a1d1bad13 100644
--- a/build/lib/electron.js
+++ b/build/lib/electron.js
@@ -17,6 +17,7 @@ const root = path.dirname(path.dirname(__dirname));
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8'));
const commit = util.getVersion(root);
function getElectronVersion() {
+ return process.versions.node;
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
return target;
diff --git a/build/lib/electron.ts b/build/lib/electron.ts
index 86c7afcf31..0663b4c28d 100644
--- a/build/lib/electron.ts
+++ b/build/lib/electron.ts
@@ -20,6 +20,7 @@ const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf
const commit = util.getVersion(root);

export function getElectronVersion(): string {
+ return process.versions.node
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
const target = /^target "(.*)"$/m.exec(yarnrc)![1];
return target;
diff --git a/build/lib/node.js b/build/lib/node.js
index 403ae3d965..738ee8cee0 100644
--- a/build/lib/node.js
+++ b/build/lib/node.js
@@ -5,11 +5,8 @@
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
-const fs = require("fs");
const root = path.dirname(path.dirname(__dirname));
-const yarnrcPath = path.join(root, 'remote', '.yarnrc');
-const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
-const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)[1];
+const version = process.versions.node;
const node = process.platform === 'win32' ? 'node.exe' : 'node';
const nodePath = path.join(root, '.build', 'node', `v${version}`, `${process.platform}-${process.arch}`, node);
console.log(nodePath);
diff --git a/build/lib/node.ts b/build/lib/node.ts
index 6439703446..c53dccf4dc 100644
--- a/build/lib/node.ts
+++ b/build/lib/node.ts
@@ -4,13 +4,10 @@
*--------------------------------------------------------------------------------------------*/

import * as path from 'path';
-import * as fs from 'fs';

const root = path.dirname(path.dirname(__dirname));
-const yarnrcPath = path.join(root, 'remote', '.yarnrc');
-const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
-const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)![1];
+const version = process.versions.node;
const node = process.platform === 'win32' ? 'node.exe' : 'node';
const nodePath = path.join(root, '.build', 'node', `v${version}`, `${process.platform}-${process.arch}`, node);

-console.log(nodePath);
\ No newline at end of file
+console.log(nodePath);
diff --git a/build/npm/postinstall.js b/build/npm/postinstall.js
index 7a2320d828..5768890636 100644
--- a/build/npm/postinstall.js
Expand Down Expand Up @@ -166,6 +238,15 @@ index 91b3b92678..f76f2c1548 100644
"urlProtocol": "code-oss",
"extensionAllowedProposedApi": [
"ms-vscode.vscode-js-profile-table",
diff --git a/remote/.yarnrc b/remote/.yarnrc
deleted file mode 100644
index 1e16cde724..0000000000
--- a/remote/.yarnrc
+++ /dev/null
@@ -1,3 +0,0 @@
-disturl "http://nodejs.org/dist"
-target "12.4.0"
-runtime "node"
diff --git a/src/vs/base/common/network.ts b/src/vs/base/common/network.ts
index e4546b2cf6..9df12239fb 100644
--- a/src/vs/base/common/network.ts
Expand Down
2 changes: 2 additions & 0 deletions ci/steps/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ main() {
fi

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

Expand Down
6 changes: 3 additions & 3 deletions doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ code-server crashes can be helpful.
### Where is the data directory?

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

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

## Enterprise

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/adm-zip": "^0.4.32",
"@types/fs-extra": "^8.0.1",
"@types/http-proxy": "^1.17.4",
"@types/js-yaml": "^3.12.3",
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.7",
"@types/parcel-bundler": "^1.12.1",
Expand All @@ -55,8 +56,7 @@
"stylelint": "^13.0.0",
"stylelint-config-recommended": "^3.0.0",
"ts-node": "^8.4.1",
"typescript": "3.7.2",
"yarn": "^1.22.4"
"typescript": "3.7.2"
},
"resolutions": {
"@types/node": "^12.12.7",
Expand All @@ -66,16 +66,20 @@
"dependencies": {
"@coder/logger": "1.1.11",
"adm-zip": "^0.4.14",
"env-paths": "^2.2.0",
"fs-extra": "^8.1.0",
"http-proxy": "^1.18.0",
"httpolyglot": "^0.1.2",
"js-yaml": "^3.13.1",
"limiter": "^1.1.5",
"pem": "^1.14.2",
"safe-compare": "^1.1.4",
"semver": "^7.1.3",
"tar": "^6.0.1",
"tar-fs": "^2.0.0",
"ws": "^7.2.0"
"ws": "^7.2.0",
"xdg-basedir": "^4.0.0",
"yarn": "^1.22.4"
},
"bin": {
"code-server": "out/node/entry.js"
Expand Down
2 changes: 1 addition & 1 deletion src/browser/pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="card-box">
<div class="header">
<h1 class="main">Welcome to code-server</h1>
<div class="sub">Please log in below. Check code-server's logs for the generated password.</div>
<div class="sub">Please log in below. {{PASSWORD_MSG}}</div>
</div>
<div class="content">
<form class="login-form" method="post">
Expand Down
17 changes: 15 additions & 2 deletions src/node/app/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as http from "http"
import * as limiter from "limiter"
import * as querystring from "querystring"
import { HttpCode, HttpError } from "../../common/http"
import { AuthType, HttpProvider, HttpResponse, Route } from "../http"
import { hash } from "../util"
import { AuthType, HttpProvider, HttpProviderOptions, HttpResponse, Route } from "../http"
import { hash, humanPath } from "../util"

interface LoginPayload {
password?: string
Expand All @@ -18,6 +18,14 @@ interface LoginPayload {
* Login HTTP provider.
*/
export class LoginHttpProvider extends HttpProvider {
public constructor(
options: HttpProviderOptions,
private readonly configFile: string,
private readonly envPassword: boolean,
) {
super(options)
}

public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> {
if (this.options.auth !== AuthType.Password || !this.isRoot(route)) {
throw new HttpError("Not found", HttpCode.NotFound)
Expand Down Expand Up @@ -46,6 +54,11 @@ export class LoginHttpProvider extends HttpProvider {
public async getRoot(route: Route, error?: Error): Promise<HttpResponse> {
const response = await this.getUtf8Resource(this.rootPath, "src/browser/pages/login.html")
response.content = response.content.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : "")
let passwordMsg = `Check the config file at ${humanPath(this.configFile)} for the password.`
if (this.envPassword) {
passwordMsg = "Password was set from $PASSWORD."
}
response.content = response.content.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
return this.replaceTemplates(route, response)
}

Expand Down
Loading