Skip to content

Commit 4aa1540

Browse files
committed
Format and lint
1 parent 80b1b1b commit 4aa1540

31 files changed

+259
-140
lines changed

.eslintrc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parser: "@typescript-eslint/parser"
22
env:
33
browser: true
4-
es6: true # Map, etc.
4+
es6: true # Map, etc.
55
mocha: true
66
node: true
77

.github/workflows/ci.yml

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
name: ci
2-
on: [push, pull_request]
2+
on: [push, pull_request, release]
33

44
jobs:
5+
fmt:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v1
9+
10+
- name: Get yarn cache directory path
11+
id: yarn-cache-dir-path
12+
run: echo "::set-output name=dir::$(yarn cache dir)"
13+
- uses: actions/cache@v1
14+
id: yarn-cache
15+
with:
16+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
17+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
18+
restore-keys: |
19+
${{ runner.os }}-yarn-
20+
21+
- name: Run yarn fmt
22+
uses: ./ci/image
23+
with:
24+
args: yarn && yarn fmt
25+
526
lint:
627
runs-on: ubuntu-latest
728
steps:
829
- uses: actions/checkout@v1
930

10-
- name: get yarn cache directory path
31+
- name: Get yarn cache directory path
1132
id: yarn-cache-dir-path
1233
run: echo "::set-output name=dir::$(yarn cache dir)"
1334
- uses: actions/cache@v1
@@ -18,7 +39,28 @@ jobs:
1839
restore-keys: |
1940
${{ runner.os }}-yarn-
2041
21-
- name: yarn lint
42+
- name: Run yarn lint
2243
uses: ./ci/image
2344
with:
2445
args: yarn && yarn lint
46+
47+
release-amd64:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v1
51+
52+
- name: Get yarn cache directory path
53+
id: yarn-cache-dir-path
54+
run: echo "::set-output name=dir::$(yarn cache dir)"
55+
- uses: actions/cache@v1
56+
id: yarn-cache
57+
with:
58+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
59+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
60+
restore-keys: |
61+
${{ runner.os }}-yarn-
62+
63+
- name: Run release.sh
64+
uses: ./ci/image
65+
with:
66+
args: yarn && yarn vscode && ./ci/release.sh

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ reset VS Code then run `yarn patch:apply`.
7474
## Security
7575

7676
### Authentication
77+
7778
By default `code-server` enables password authentication using a randomly
7879
generated password. You can set the `PASSWORD` environment variable to use your
7980
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
8283
authentication.
8384

8485
### Encrypting traffic with HTTPS
86+
8587
If you aren't doing SSL termination elsewhere you can directly give
8688
`code-server` a certificate with `code-server --cert` followed by the path to
8789
your certificate. Additionally, you can use certificate keys with `--cert-key`

ci/build.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Builder {
2626
this.ensureArgument("rootPath", this.rootPath)
2727
this.codeServerVersion = this.ensureArgument(
2828
"codeServerVersion",
29-
process.env.VERSION || require(path.join(this.rootPath, "package.json")).version
29+
process.env.VERSION || require(path.join(this.rootPath, "package.json")).version,
3030
)
3131
}
3232

@@ -208,7 +208,7 @@ class Builder {
208208
await Promise.all([
209209
fs.move(
210210
path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`),
211-
path.join(vscodeBuildPath, "out")
211+
path.join(vscodeBuildPath, "out"),
212212
),
213213
fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")),
214214
])
@@ -225,7 +225,7 @@ class Builder {
225225
return Promise.all(
226226
["node_modules", "package.json", "yarn.lock"].map((fileName) => {
227227
return fs.copy(path.join(sourcePath, fileName), path.join(buildPath, fileName))
228-
})
228+
}),
229229
)
230230
})
231231

@@ -240,8 +240,8 @@ class Builder {
240240
...merge,
241241
},
242242
null,
243-
2
244-
)
243+
2,
244+
),
245245
)
246246
})
247247

@@ -290,7 +290,7 @@ class Builder {
290290
await fs.copyFile(path.join(this.vscodeSourcePath, "LICENSE.txt"), path.join(archivePath, "LICENSE.txt"))
291291
await fs.copyFile(
292292
path.join(this.vscodeSourcePath, "ThirdPartyNotices.txt"),
293-
path.join(archivePath, "ThirdPartyNotices.txt")
293+
path.join(archivePath, "ThirdPartyNotices.txt"),
294294
)
295295

296296
if ((await this.target()) === "darwin") {

ci/fmt.sh

+29-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,35 @@
33
set -euo pipefail
44

55
main() {
6-
shfmt -i 2 -w -s -sr $$(git ls-files "*.sh")
7-
prettier --write --loglevel=warn $$(git ls-files "*.js" "*.ts" "*.tsx" "*.html" "*.json" "*.css" "*.md" "*.toml" "*.yaml" "*.yml")
8-
if [[ "$CI" != "" && $$(git ls-files --other --modified --exclude-standard) != "" ]]; then
9-
echo "Files need generation or are formatted incorrectly:"
10-
git -c color.ui=always status | grep --color=no '\[31m'
11-
echo "Please run the following locally:"
12-
echo " make fmt"
13-
exit 1
14-
fi
6+
if [[ ${CI-} ]]; then
7+
cd "$(dirname "$0")/.."
8+
./ci/vscode.sh
9+
fi
10+
11+
shfmt -i 2 -w -s -sr $(git ls-files "*.sh")
12+
13+
local prettierExts
14+
prettierExts=(
15+
"*.js"
16+
"*.ts"
17+
"*.tsx"
18+
"*.html"
19+
"*.json"
20+
"*.css"
21+
"*.md"
22+
"*.toml"
23+
"*.yaml"
24+
"*.yml"
25+
)
26+
prettier --write --loglevel=warn $(git ls-files "${prettierExts[@]}")
27+
28+
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
29+
echo "Files need generation or are formatted incorrectly:"
30+
git -c color.ui=always status | grep --color=no '\[31m'
31+
echo "Please run the following locally:"
32+
echo " yarn fmt"
33+
exit 1
34+
fi
1535
}
1636

1737
main "$@"

ci/image/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_li
99

1010
COPY entrypoint.sh /bin/entrypoint.sh
1111

12+
ENV PAGER=cat
13+
ENV CI=true
14+
1215
ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"]

ci/lint.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
set -euo pipefail
44

55
main() {
6-
eslint --max-warnings=0 --fix $$(git ls-files "*.ts" "*.tsx" "*.js")
7-
stylelint --fix $$(git ls-files "*.css")
6+
if [[ ${CI-} ]]; then
7+
cd "$(dirname "$0")/.."
8+
./ci/vscode.sh
9+
fi
10+
11+
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js")
12+
stylelint --fix $(git ls-files "*.css")
13+
tsc --noEmit
814
}
915

1016
main "$@"

ci/release.bash renamed to ci/release.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function main() {
88
cd "$(dirname "${0}")/.."
99

1010
local code_server_version=${VERSION:-${TRAVIS_TAG:-${DRONE_TAG:-}}}
11-
if [[ -z $code_server_version ]] ; then
11+
if [[ -z $code_server_version ]]; then
1212
code_server_version=$(grep version ./package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[:space:]')
1313
fi
1414
export VERSION=$code_server_version
@@ -17,33 +17,33 @@ function main() {
1717
export YARN_CACHE_FOLDER
1818

1919
# Always minify and package on tags since that's when releases are pushed.
20-
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
20+
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then
2121
export MINIFY="true"
2222
export PACKAGE="true"
2323
fi
2424

2525
yarn build
2626
yarn binary
27-
if [[ -n ${PACKAGE:-} ]] ; then
27+
if [[ -n ${PACKAGE:-} ]]; then
2828
yarn package
2929
fi
3030

3131
cd binaries
3232

33-
if [[ -n ${STRIP_BIN_TARGET:-} ]] ; then
33+
if [[ -n ${STRIP_BIN_TARGET:-} ]]; then
3434
# In this case provide plainly named binaries.
35-
for binary in code-server* ; do
35+
for binary in code-server*; do
3636
echo "Moving $binary to code-server"
3737
mv "$binary" code-server
3838
done
39-
elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
39+
elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then
4040
# Prepare directory for uploading binaries on release.
41-
for binary in code-server* ; do
41+
for binary in code-server*; do
4242
mkdir -p "../binary-upload"
4343

4444
local prefix="code-server-$code_server_version-"
4545
local target="${binary#$prefix}"
46-
if [[ $target == "linux-x86_64" ]] ; then
46+
if [[ $target == "linux-x86_64" ]]; then
4747
echo "Copying $binary to ../binary-upload/latest-linux"
4848
cp "$binary" "../binary-upload/latest-linux"
4949
fi

ci/tsconfig.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"extends": "../tsconfig.json",
3-
"include": [
4-
"./**/*.ts"
5-
]
3+
"include": ["./**/*.ts"]
64
}

ci/vscode.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ main() {
1010
git submodule update --init
1111

1212
# If the patch fails to apply, then it's likely already applied
13-
yarn vscode:patch &>/dev/null || true
13+
yarn vscode:patch &> /dev/null || true
1414

1515
# Install VS Code dependencies.
1616
(cd lib/vscode && yarn)

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
"vscode": "ci/vscode.sh",
88
"vscode:patch": "cd ./lib/vscode && git apply ../../ci/vscode.patch",
99
"vscode:diff": "cd ./lib/vscode && git diff HEAD > ../../ci/vscode.patch",
10-
1110
"test": "mocha -r ts-node/register ./test/*.test.ts",
12-
1311
"lint": "ci/lint.sh",
1412
"fmt": "ci/fmt.sh",
15-
1613
"runner": "cd ./scripts && NODE_OPTIONS=--max_old_space_size=32384 ts-node ./build.ts",
1714
"build": "yarn runner build",
1815
"watch": "yarn runner watch",

src/browser/media/manifest.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"display": "fullscreen",
66
"background-color": "#fff",
77
"description": "Run editors on a remote server.",
8-
"icons": [{
9-
"src": "./code-server.png",
10-
"sizes": "384x384",
11-
"type": "image/png"
12-
}]
8+
"icons": [
9+
{
10+
"src": "./code-server.png",
11+
"sizes": "384x384",
12+
"type": "image/png"
13+
}
14+
]
1315
}

src/browser/pages/app.html

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
6-
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;">
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
8+
/>
9+
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;" />
710
<title>code-server — {{APP_NAME}}</title>
811
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
9-
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials">
12+
<link
13+
rel="manifest"
14+
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
15+
crossorigin="use-credentials"
16+
/>
1017
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
11-
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet">
12-
<meta id="coder-options" data-settings="{{OPTIONS}}">
18+
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet" />
19+
<meta id="coder-options" data-settings="{{OPTIONS}}" />
1320
</head>
1421
<body>
1522
<script src="{{BASE}}/static-{{COMMIT}}/dist/app.js"></script>

src/browser/pages/error.html

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
6-
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;">
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
8+
/>
9+
<meta http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:;" />
710
<title>code-server {{ERROR_TITLE}}</title>
811
<link rel="icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
9-
<link rel="manifest" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials">
12+
<link
13+
rel="manifest"
14+
href="{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
15+
crossorigin="use-credentials"
16+
/>
1017
<link rel="apple-touch-icon" href="{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png" />
11-
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet">
18+
<link href="{{BASE}}/static-{{COMMIT}}/dist/app.css" rel="stylesheet" />
1219
</head>
1320
<body>
1421
<div class="center-container">
@@ -18,7 +25,7 @@ <h2 class="header">{{ERROR_HEADER}}</h2>
1825
{{ERROR_BODY}}
1926
</div>
2027
<div class="links">
21-
<a class="link" href="{{BASE}}">go home</a
28+
<a class="link" href="{{BASE}}">go home</a>
2229
</div>
2330
</div>
2431
</div>

src/browser/pages/global.css

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ body {
1010
background: #272727;
1111
color: #f4f4f4;
1212
margin: 0;
13-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
13+
font-family:
14+
-apple-system,
15+
BlinkMacSystemFont,
16+
"Segoe UI",
17+
Roboto,
18+
Helvetica,
19+
Arial,
20+
sans-serif,
21+
"Apple Color Emoji",
22+
"Segoe UI Emoji",
23+
"Segoe UI Symbol";
1424
overflow: hidden;
1525
}
1626

0 commit comments

Comments
 (0)