Format and lint

This commit is contained in:
Anmol Sethi 2020-02-14 19:46:00 -05:00
parent 80b1b1b672
commit 4aa15401c3
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
31 changed files with 260 additions and 141 deletions

View File

@ -1,13 +1,13 @@
name: ci name: ci
on: [push, pull_request] on: [push, pull_request, release]
jobs: jobs:
lint: fmt:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: get yarn cache directory path - name: Get yarn cache directory path
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)" run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1 - uses: actions/cache@v1
@ -18,7 +18,49 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-yarn- ${{ runner.os }}-yarn-
- name: yarn lint - name: Run yarn fmt
uses: ./ci/image
with:
args: yarn && yarn fmt
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Run yarn lint
uses: ./ci/image uses: ./ci/image
with: with:
args: yarn && yarn lint args: yarn && yarn lint
release-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Run release.sh
uses: ./ci/image
with:
args: yarn && yarn vscode && ./ci/release.sh

View File

@ -74,6 +74,7 @@ reset VS Code then run `yarn patch:apply`.
## Security ## Security
### Authentication ### Authentication
By default `code-server` enables password authentication using a randomly By default `code-server` enables password authentication using a randomly
generated password. You can set the `PASSWORD` environment variable to use your generated password. You can set the `PASSWORD` environment variable to use your
own instead or use `--auth none` to disable password authentication. own instead or use `--auth none` to disable password authentication.
@ -82,6 +83,7 @@ Do not expose `code-server` to the open internet without some form of
authentication. authentication.
### Encrypting traffic with HTTPS ### Encrypting traffic with HTTPS
If you aren't doing SSL termination elsewhere you can directly give If you aren't doing SSL termination elsewhere you can directly give
`code-server` a certificate with `code-server --cert` followed by the path to `code-server` a certificate with `code-server --cert` followed by the path to
your certificate. Additionally, you can use certificate keys with `--cert-key` your certificate. Additionally, you can use certificate keys with `--cert-key`

View File

@ -26,7 +26,7 @@ class Builder {
this.ensureArgument("rootPath", this.rootPath) this.ensureArgument("rootPath", this.rootPath)
this.codeServerVersion = this.ensureArgument( this.codeServerVersion = this.ensureArgument(
"codeServerVersion", "codeServerVersion",
process.env.VERSION || require(path.join(this.rootPath, "package.json")).version process.env.VERSION || require(path.join(this.rootPath, "package.json")).version,
) )
} }
@ -208,7 +208,7 @@ class Builder {
await Promise.all([ await Promise.all([
fs.move( fs.move(
path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`), path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`),
path.join(vscodeBuildPath, "out") path.join(vscodeBuildPath, "out"),
), ),
fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")), fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")),
]) ])
@ -225,7 +225,7 @@ class Builder {
return Promise.all( return Promise.all(
["node_modules", "package.json", "yarn.lock"].map((fileName) => { ["node_modules", "package.json", "yarn.lock"].map((fileName) => {
return fs.copy(path.join(sourcePath, fileName), path.join(buildPath, fileName)) return fs.copy(path.join(sourcePath, fileName), path.join(buildPath, fileName))
}) }),
) )
}) })
@ -240,8 +240,8 @@ class Builder {
...merge, ...merge,
}, },
null, null,
2 2,
) ),
) )
}) })
@ -290,7 +290,7 @@ class Builder {
await fs.copyFile(path.join(this.vscodeSourcePath, "LICENSE.txt"), path.join(archivePath, "LICENSE.txt")) await fs.copyFile(path.join(this.vscodeSourcePath, "LICENSE.txt"), path.join(archivePath, "LICENSE.txt"))
await fs.copyFile( await fs.copyFile(
path.join(this.vscodeSourcePath, "ThirdPartyNotices.txt"), path.join(this.vscodeSourcePath, "ThirdPartyNotices.txt"),
path.join(archivePath, "ThirdPartyNotices.txt") path.join(archivePath, "ThirdPartyNotices.txt"),
) )
if ((await this.target()) === "darwin") { if ((await this.target()) === "darwin") {

View File

@ -3,13 +3,33 @@
set -euo pipefail set -euo pipefail
main() { main() {
shfmt -i 2 -w -s -sr $$(git ls-files "*.sh") if [[ ${CI-} ]]; then
prettier --write --loglevel=warn $$(git ls-files "*.js" "*.ts" "*.tsx" "*.html" "*.json" "*.css" "*.md" "*.toml" "*.yaml" "*.yml") cd "$(dirname "$0")/.."
if [[ "$CI" != "" && $$(git ls-files --other --modified --exclude-standard) != "" ]]; then ./ci/vscode.sh
fi
shfmt -i 2 -w -s -sr $(git ls-files "*.sh")
local prettierExts
prettierExts=(
"*.js"
"*.ts"
"*.tsx"
"*.html"
"*.json"
"*.css"
"*.md"
"*.toml"
"*.yaml"
"*.yml"
)
prettier --write --loglevel=warn $(git ls-files "${prettierExts[@]}")
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
echo "Files need generation or are formatted incorrectly:" echo "Files need generation or are formatted incorrectly:"
git -c color.ui=always status | grep --color=no '\[31m' git -c color.ui=always status | grep --color=no '\[31m'
echo "Please run the following locally:" echo "Please run the following locally:"
echo " make fmt" echo " yarn fmt"
exit 1 exit 1
fi fi
} }

View File

@ -9,4 +9,7 @@ RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_li
COPY entrypoint.sh /bin/entrypoint.sh COPY entrypoint.sh /bin/entrypoint.sh
ENV PAGER=cat
ENV CI=true
ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"] ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"]

View File

@ -3,8 +3,14 @@
set -euo pipefail set -euo pipefail
main() { main() {
eslint --max-warnings=0 --fix $$(git ls-files "*.ts" "*.tsx" "*.js") if [[ ${CI-} ]]; then
stylelint --fix $$(git ls-files "*.css") cd "$(dirname "$0")/.."
./ci/vscode.sh
fi
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js")
stylelint --fix $(git ls-files "*.css")
tsc --noEmit
} }
main "$@" main "$@"

View File

@ -1,6 +1,4 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"include": [ "include": ["./**/*.ts"]
"./**/*.ts"
]
} }

View File

@ -7,12 +7,9 @@
"vscode": "ci/vscode.sh", "vscode": "ci/vscode.sh",
"vscode:patch": "cd ./lib/vscode && git apply ../../ci/vscode.patch", "vscode:patch": "cd ./lib/vscode && git apply ../../ci/vscode.patch",
"vscode:diff": "cd ./lib/vscode && git diff HEAD > ../../ci/vscode.patch", "vscode:diff": "cd ./lib/vscode && git diff HEAD > ../../ci/vscode.patch",
"test": "mocha -r ts-node/register ./test/*.test.ts", "test": "mocha -r ts-node/register ./test/*.test.ts",
"lint": "ci/lint.sh", "lint": "ci/lint.sh",
"fmt": "ci/fmt.sh", "fmt": "ci/fmt.sh",
"runner": "cd ./scripts && NODE_OPTIONS=--max_old_space_size=32384 ts-node ./build.ts", "runner": "cd ./scripts && NODE_OPTIONS=--max_old_space_size=32384 ts-node ./build.ts",
"build": "yarn runner build", "build": "yarn runner build",
"watch": "yarn runner watch", "watch": "yarn runner watch",

View File

@ -5,9 +5,11 @@
"display": "fullscreen", "display": "fullscreen",
"background-color": "#fff", "background-color": "#fff",
"description": "Run editors on a remote server.", "description": "Run editors on a remote server.",
"icons": [{ "icons": [
{
"src": "./code-server.png", "src": "./code-server.png",
"sizes": "384x384", "sizes": "384x384",
"type": "image/png" "type": "image/png"
}] }
]
} }

View File

@ -2,14 +2,21 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <meta
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;"> name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;" />
<title>code-server — {{APP_NAME}}</title> <title>code-server — {{APP_NAME}}</title>
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" /> <link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials"> <link
rel="manifest"
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin="use-credentials"
/>
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" /> <link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet"> <link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet" />
<meta id="coder-options" data-settings="{{OPTIONS}}"> <meta id="coder-options" data-settings="{{OPTIONS}}" />
</head> </head>
<body> <body>
<script src="{{BASE}}/static-{{COMMIT}}/dist/app.js"></script> <script src="{{BASE}}/static-{{COMMIT}}/dist/app.js"></script>

View File

@ -2,13 +2,20 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <meta
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;"> name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;" />
<title>code-server {{ERROR_TITLE}}</title> <title>code-server {{ERROR_TITLE}}</title>
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" /> <link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials"> <link
rel="manifest"
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin="use-credentials"
/>
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" /> <link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet"> <link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet" />
</head> </head>
<body> <body>
<div class="center-container"> <div class="center-container">
@ -18,7 +25,7 @@
{{ERROR_BODY}} {{ERROR_BODY}}
</div> </div>
<div class="links"> <div class="links">
<a class="link" href="{{BASE}}">go home</a <a class="link" href="{{BASE}}">go home</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -10,7 +10,17 @@ body {
background: #272727; background: #272727;
color: #f4f4f4; color: #f4f4f4;
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-family:
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Helvetica,
Arial,
sans-serif,
"Apple Color Emoji",
"Segoe UI Emoji",
"Segoe UI Symbol";
overflow: hidden; overflow: hidden;
} }

View File

@ -2,14 +2,21 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <meta
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;"> name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;" />
<title>code-server</title> <title>code-server</title>
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" /> <link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials"> <link
rel="manifest"
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin="use-credentials"
/>
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" /> <link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet"> <link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet" />
<meta id="coder-options" data-settings="{{OPTIONS}}"> <meta id="coder-options" data-settings="{{OPTIONS}}" />
</head> </head>
<body> <body>
<div class="center-container"> <div class="center-container">

View File

@ -2,13 +2,23 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <meta
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; script-src 'unsafe-inline'; manifest-src 'self'; img-src 'self' data:;"> name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta
http-equiv="Content-Security-Policy"
content="style-src 'self'; script-src 'unsafe-inline'; manifest-src 'self'; img-src 'self' data:;"
/>
<title>code-server login</title> <title>code-server login</title>
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" /> <link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials"> <link
rel="manifest"
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin="use-credentials"
/>
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" /> <link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet"> <link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet" />
</head> </head>
<body> <body>
<div class="center-container"> <div class="center-container">
@ -22,7 +32,8 @@
<div class="field"> <div class="field">
<!-- The onfocus code places the cursor at the end of the value. --> <!-- The onfocus code places the cursor at the end of the value. -->
<input <input
required autofocus required
autofocus
value="{{VALUE}}" value="{{VALUE}}"
onfocus="const value=this.value;this.value='';this.value=value;" onfocus="const value=this.value;this.value='';this.value=value;"
class="password" class="password"

View File

@ -4,28 +4,38 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="font-src 'self'; connect-src 'self' https:; default-src ws: wss: 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; img-src 'self' data:;"> <meta
http-equiv="Content-Security-Policy"
content="font-src 'self'; connect-src 'self' https:; default-src ws: wss: 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; img-src 'self' data:;"
/>
<!-- Disable pinch zooming --> <!-- Disable pinch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<!-- Workbench Configuration --> <!-- Workbench Configuration -->
<meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}"> <meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}" />
<!-- Workarounds/Hacks (remote user data uri) --> <!-- Workarounds/Hacks (remote user data uri) -->
<meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}"> <meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}" />
<meta id="vscode-remote-commit" data-settings="{{COMMIT}}"> <meta id="vscode-remote-commit" data-settings="{{COMMIT}}" />
<meta id="vscode-remote-product-configuration" data-settings="{{PRODUCT_CONFIGURATION}}"> <meta id="vscode-remote-product-configuration" data-settings="{{PRODUCT_CONFIGURATION}}" />
<meta id="vscode-remote-nls-configuration" data-settings="{{NLS_CONFIGURATION}}"> <meta id="vscode-remote-nls-configuration" data-settings="{{NLS_CONFIGURATION}}" />
<!-- Workbench Icon/Manifest/CSS --> <!-- Workbench Icon/Manifest/CSS -->
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" /> <link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials"> <link
rel="manifest"
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin="use-credentials"
/>
<!-- PROD_ONLY <!-- PROD_ONLY
<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="{{VS_BASE}}/static-{{COMMIT}}/out/vs/workbench/workbench.web.api.css"> <link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="{{VS_BASE}}/static-{{COMMIT}}/out/vs/workbench/workbench.web.api.css">
END_PROD_ONLY --> END_PROD_ONLY -->
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" /> <link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes" />
<!-- Prefetch to avoid waterfall --> <!-- Prefetch to avoid waterfall -->
<!-- PROD_ONLY <!-- PROD_ONLY
@ -33,53 +43,53 @@
END_PROD_ONLY --> END_PROD_ONLY -->
</head> </head>
<body aria-label=""> <body aria-label=""></body>
</body>
<!-- Startup (do not modify order of script tags!) --> <!-- Startup (do not modify order of script tags!) -->
<script> <script>
const parts = window.location.pathname.replace(/^\//g, "").split("/") const parts = window.location.pathname.replace(/^\//g, "").split("/")
parts[parts.length - 1] = "{{VS_BASE}}" parts[parts.length - 1] = "{{VS_BASE}}"
const url = new URL(window.location.origin + "/" + parts.join("/")) const url = new URL(window.location.origin + "/" + parts.join("/"))
const el = document.getElementById('vscode-remote-commit'); const el = document.getElementById("vscode-remote-commit")
const commit = el ? el.getAttribute('data-settings') : ""; const commit = el ? el.getAttribute("data-settings") : ""
const staticBase = url.href + '/static-' + commit; const staticBase = url.href + "/static-" + commit
let nlsConfig; let nlsConfig
try { try {
nlsConfig = JSON.parse(document.getElementById('vscode-remote-nls-configuration').getAttribute('data-settings')); nlsConfig = JSON.parse(document.getElementById("vscode-remote-nls-configuration").getAttribute("data-settings"))
if (nlsConfig._resolvedLanguagePackCoreLocation) { if (nlsConfig._resolvedLanguagePackCoreLocation) {
const bundles = Object.create(null); const bundles = Object.create(null)
nlsConfig.loadBundle = (bundle, language, cb) => { nlsConfig.loadBundle = (bundle, language, cb) => {
let result = bundles[bundle]; let result = bundles[bundle]
if (result) { if (result) {
return cb(undefined, result); return cb(undefined, result)
} }
// FIXME: Only works if path separators are /. // FIXME: Only works if path separators are /.
const path = nlsConfig._resolvedLanguagePackCoreLocation const path = nlsConfig._resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json"
+ '/' + bundle.replace(/\//g, '!') + '.nls.json';
fetch(`${url.href}/resource/?path=${encodeURIComponent(path)}`) fetch(`${url.href}/resource/?path=${encodeURIComponent(path)}`)
.then((response) => response.json()) .then((response) => response.json())
.then((json) => { .then((json) => {
bundles[bundle] = json; bundles[bundle] = json
cb(undefined, json); cb(undefined, json)
}) })
.catch(cb); .catch(cb)
}; }
}
} catch (error) {
/* Probably fine. */
} }
} catch (error) { /* Probably fine. */ }
self.require = { self.require = {
baseUrl: `${staticBase}/out`, baseUrl: `${staticBase}/out`,
paths: { paths: {
'vscode-textmate': `${staticBase}/node_modules/vscode-textmate/release/main`, "vscode-textmate": `${staticBase}/node_modules/vscode-textmate/release/main`,
'onigasm-umd': `${staticBase}/node_modules/onigasm-umd/release/main`, "onigasm-umd": `${staticBase}/node_modules/onigasm-umd/release/main`,
'xterm': `${staticBase}/node_modules/xterm/lib/xterm.js`, xterm: `${staticBase}/node_modules/xterm/lib/xterm.js`,
'xterm-addon-search': `${staticBase}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`, "xterm-addon-search": `${staticBase}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-web-links': `${staticBase}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`, "xterm-addon-web-links": `${staticBase}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
'xterm-addon-webgl': `${staticBase}/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, "xterm-addon-webgl": `${staticBase}/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
'semver-umd': `${staticBase}/node_modules/semver-umd/lib/semver-umd.js`, "semver-umd": `${staticBase}/node_modules/semver-umd/lib/semver-umd.js`,
}, },
'vs/nls': nlsConfig, "vs/nls": nlsConfig,
}; }
</script> </script>
<script src="{{VS_BASE}}/static-{{COMMIT}}/out/vs/loader.js"></script> <script src="{{VS_BASE}}/static-{{COMMIT}}/out/vs/loader.js"></script>
<!-- PROD_ONLY <!-- PROD_ONLY
@ -87,6 +97,6 @@
<script src="{{VS_BASE}}/static-{{COMMIT}}/out/vs/workbench/workbench.web.api.js"></script> <script src="{{VS_BASE}}/static-{{COMMIT}}/out/vs/workbench/workbench.web.api.js"></script>
END_PROD_ONLY --> END_PROD_ONLY -->
<script> <script>
require(['vs/code/browser/workbench/workbench'], function() {}); require(["vs/code/browser/workbench/workbench"], function() {})
</script> </script>
</html> </html>

View File

@ -159,7 +159,7 @@ export class ReconnectingSocket {
const socket = new WebSocket( const socket = new WebSocket(
`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${this.customPath || location.pathname}${ `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${this.customPath || location.pathname}${
location.search ? `?${location.search}` : "" location.search ? `?${location.search}` : ""
}` }`,
) )
const reject = (): void => { const reject = (): void => {

View File

@ -68,7 +68,7 @@ export class ApiHttpProvider extends HttpProvider {
route: Route, route: Route,
request: http.IncomingMessage, request: http.IncomingMessage,
socket: net.Socket, socket: net.Socket,
head: Buffer head: Buffer,
): Promise<true | undefined> { ): Promise<true | undefined> {
if (!this.authenticated(request)) { if (!this.authenticated(request)) {
throw new Error("not authenticated") throw new Error("not authenticated")
@ -120,7 +120,7 @@ export class ApiHttpProvider extends HttpProvider {
route: Route, route: Route,
request: http.IncomingMessage, request: http.IncomingMessage,
socket: net.Socket, socket: net.Socket,
head: Buffer head: Buffer,
): Promise<true> { ): Promise<true> {
const sessionId = route.requestPath.replace(/^\//, "") const sessionId = route.requestPath.replace(/^\//, "")
logger.debug("connecting session", field("sessionId", sessionId)) logger.debug("connecting session", field("sessionId", sessionId))
@ -149,8 +149,8 @@ export class ApiHttpProvider extends HttpProvider {
Buffer.from( Buffer.from(
JSON.stringify({ JSON.stringify({
protocol: "TODO", protocol: "TODO",
}) }),
) ),
) )
return true return true

View File

@ -63,7 +63,7 @@ export class MainHttpProvider extends HttpProvider {
base: this.base(route), base: this.base(route),
logLevel: logger.level, logLevel: logger.level,
}, },
(app && app.name) || "" (app && app.name) || "",
) )
} }
@ -80,11 +80,11 @@ export class MainHttpProvider extends HttpProvider {
.replace(/{{APP_LIST:RUNNING}}/g, this.getAppRows(recent.running)) .replace(/{{APP_LIST:RUNNING}}/g, this.getAppRows(recent.running))
.replace( .replace(
/{{APP_LIST:EDITORS}}/g, /{{APP_LIST:EDITORS}}/g,
this.getAppRows(apps.filter((app) => app.categories && app.categories.includes("Editor"))) this.getAppRows(apps.filter((app) => app.categories && app.categories.includes("Editor"))),
) )
.replace( .replace(
/{{APP_LIST:OTHER}}/g, /{{APP_LIST:OTHER}}/g,
this.getAppRows(apps.filter((app) => !app.categories || !app.categories.includes("Editor"))) this.getAppRows(apps.filter((app) => !app.categories || !app.categories.includes("Editor"))),
) )
return response return response
} }

View File

@ -109,7 +109,7 @@ export class LoginHttpProvider extends HttpProvider {
remoteAddress: request.connection.remoteAddress, remoteAddress: request.connection.remoteAddress,
userAgent: request.headers["user-agent"], userAgent: request.headers["user-agent"],
timestamp: Math.floor(new Date().getTime() / 1000), timestamp: Math.floor(new Date().getTime() / 1000),
}) }),
) )
throw new Error("Incorrect password") throw new Error("Incorrect password")

View File

@ -102,7 +102,7 @@ export class VscodeHttpProvider extends HttpProvider {
"Upgrade: websocket", "Upgrade: websocket",
"Connection: Upgrade", "Connection: Upgrade",
`Sec-WebSocket-Accept: ${reply}`, `Sec-WebSocket-Accept: ${reply}`,
].join("\r\n") + "\r\n\r\n" ].join("\r\n") + "\r\n\r\n",
) )
const vscode = await this._vscode const vscode = await this._vscode
@ -146,7 +146,7 @@ export class VscodeHttpProvider extends HttpProvider {
const response = await this.getUtf8Resource(this.vsRootPath, route.requestPath) const response = await this.getUtf8Resource(this.vsRootPath, route.requestPath)
response.content = response.content.replace( response.content = response.content.replace(
/{{COMMIT}}/g, /{{COMMIT}}/g,
this.workbenchOptions ? this.workbenchOptions.commit : "" this.workbenchOptions ? this.workbenchOptions.commit : "",
) )
response.cache = true response.cache = true
return response return response
@ -186,7 +186,7 @@ export class VscodeHttpProvider extends HttpProvider {
settings.lastVisited, settings.lastVisited,
this.args._ && this.args._.length > 0 ? { url: this.args._[0] } : undefined, this.args._ && this.args._.length > 0 ? { url: this.args._[0] } : undefined,
], ],
remoteAuthority remoteAuthority,
) )
const [response, options] = await Promise.all([ const [response, options] = await Promise.all([
await this.getUtf8Resource(this.rootPath, "src/browser/pages/vscode.html"), await this.getUtf8Resource(this.rootPath, "src/browser/pages/vscode.html"),
@ -229,7 +229,7 @@ export class VscodeHttpProvider extends HttpProvider {
*/ */
private async getFirstValidPath( private async getFirstValidPath(
startPaths: Array<{ url?: string | string[]; workspace?: boolean } | undefined>, startPaths: Array<{ url?: string | string[]; workspace?: boolean } | undefined>,
remoteAuthority: string remoteAuthority: string,
): Promise<StartPath | undefined> { ): Promise<StartPath | undefined> {
for (let i = 0; i < startPaths.length; ++i) { for (let i = 0; i < startPaths.length; ++i) {
const startPath = startPaths[i] const startPath = startPaths[i]

View File

@ -92,13 +92,13 @@ export const optionDescriptions = (): string[] => {
long: k.length > prev.long ? k.length : prev.long, long: k.length > prev.long ? k.length : prev.long,
short: v.short && v.short.length > prev.short ? v.short.length : prev.short, short: v.short && v.short.length > prev.short ? v.short.length : prev.short,
}), }),
{ short: 0, long: 0 } { short: 0, long: 0 },
) )
return entries.map( return entries.map(
([k, v]) => ([k, v]) =>
`${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k}${" ".repeat( `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k}${" ".repeat(
widths.long - k.length widths.long - k.length,
)} ${v.description}${typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : ""}` )} ${v.description}${typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : ""}`,
) )
} }

View File

@ -66,7 +66,7 @@ const main = async (args: Args): Promise<void> => {
logger.info( logger.info(
typeof args.cert === "string" typeof args.cert === "string"
? ` - Using provided certificate${args["cert-key"] ? " and key" : ""} for HTTPS` ? ` - Using provided certificate${args["cert-key"] ? " and key" : ""} for HTTPS`
: ` - Using generated certificate and key for HTTPS` : ` - Using generated certificate and key for HTTPS`,
) )
} else { } else {
logger.info(" - Not serving HTTPS") logger.info(" - Not serving HTTPS")

View File

@ -142,7 +142,7 @@ export abstract class HttpProvider {
route: Route, route: Route,
request: http.IncomingMessage, request: http.IncomingMessage,
socket: net.Socket, socket: net.Socket,
head: Buffer head: Buffer,
): Promise<true | undefined> ): Promise<true | undefined>
/** /**
@ -380,7 +380,7 @@ export class HttpServer {
cert: this.options.cert && fs.readFileSync(this.options.cert), cert: this.options.cert && fs.readFileSync(this.options.cert),
key: this.options.certKey && fs.readFileSync(this.options.certKey), key: this.options.certKey && fs.readFileSync(this.options.certKey),
}, },
this.onRequest this.onRequest,
) )
} else { } else {
this.server = http.createServer(this.onRequest) this.server = http.createServer(this.onRequest)
@ -420,7 +420,7 @@ export class HttpServer {
commit: this.options.commit, commit: this.options.commit,
password: this.options.password, password: this.options.password,
}, },
a1 a1,
) )
this.providers.set(`/${endpoint}`, p) this.providers.set(`/${endpoint}`, p)
return p return p

View File

@ -14,7 +14,7 @@ const getXdgDataDir = (): string => {
case "darwin": case "darwin":
return path.join( return path.join(
process.env.XDG_DATA_HOME || path.join(os.homedir(), "Library/Application Support"), process.env.XDG_DATA_HOME || path.join(os.homedir(), "Library/Application Support"),
"code-server" "code-server",
) )
default: default:
return path.join(process.env.XDG_DATA_HOME || path.join(os.homedir(), ".local/share"), "code-server") return path.join(process.env.XDG_DATA_HOME || path.join(os.homedir(), ".local/share"), "code-server")

View File

@ -76,7 +76,7 @@ export class IpcMain {
`${child ? "wrapper" : "inner process"} ${process.pid} received message from ${ `${child ? "wrapper" : "inner process"} ${process.pid} received message from ${
child ? child.pid : this.parentPid child ? child.pid : this.parentPid
}`, }`,
field("message", message) field("message", message),
) )
if (message.type === "handshake") { if (message.type === "handshake") {
target.removeListener("message", onMessage) target.removeListener("message", onMessage)
@ -122,7 +122,7 @@ export const ipcMain = (): IpcMain => {
_ipcMain = new IpcMain( _ipcMain = new IpcMain(
typeof process.env.CODE_SERVER_PARENT_PID !== "undefined" typeof process.env.CODE_SERVER_PARENT_PID !== "undefined"
? parseInt(process.env.CODE_SERVER_PARENT_PID) ? parseInt(process.env.CODE_SERVER_PARENT_PID)
: undefined : undefined,
) )
} }
return _ipcMain return _ipcMain

View File

@ -73,7 +73,7 @@ describe("cli", () => {
"user-data-dir": path.resolve("bar"), "user-data-dir": path.resolve("bar"),
verbose: true, verbose: true,
version: true, version: true,
} },
) )
}) })

View File

@ -20,8 +20,5 @@
"rootDir": "./src", "rootDir": "./src",
"typeRoots": ["./node_modules/@types", "./typings"] "typeRoots": ["./node_modules/@types", "./typings"]
}, },
"include": [ "include": ["./src/**/*.ts", "./src/**/*.tsx"]
"./src/**/*.ts",
"./src/**/*.tsx"
]
} }

View File

@ -5,6 +5,6 @@ declare module "httpolyglot" {
function createServer(requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void): http.Server function createServer(requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void): http.Server
function createServer( function createServer(
options: https.ServerOptions, options: https.ServerOptions,
requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void,
): https.Server ): https.Server
} }