diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fbb9ac0e..58112a67 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,7 +1,7 @@ parser: "@typescript-eslint/parser" env: browser: true - es6: true # Map, etc. + es6: true # Map, etc. mocha: true node: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5279a3e..4a9c0579 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,13 @@ name: ci -on: [push, pull_request] +on: [push, pull_request, release] jobs: - lint: + fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: get yarn cache directory path + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v1 @@ -18,7 +18,49 @@ jobs: restore-keys: | ${{ 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 with: 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 diff --git a/README.md b/README.md index b2a396a5..1abcd938 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ reset VS Code then run `yarn patch:apply`. ## Security ### Authentication + By default `code-server` enables password authentication using a randomly generated password. You can set the `PASSWORD` environment variable to use your 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. ### Encrypting traffic with HTTPS + 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 your certificate. Additionally, you can use certificate keys with `--cert-key` diff --git a/ci/build.ts b/ci/build.ts index 937dc8cb..47079161 100644 --- a/ci/build.ts +++ b/ci/build.ts @@ -26,7 +26,7 @@ class Builder { this.ensureArgument("rootPath", this.rootPath) this.codeServerVersion = this.ensureArgument( "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([ fs.move( 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")), ]) @@ -225,7 +225,7 @@ class Builder { return Promise.all( ["node_modules", "package.json", "yarn.lock"].map((fileName) => { return fs.copy(path.join(sourcePath, fileName), path.join(buildPath, fileName)) - }) + }), ) }) @@ -240,8 +240,8 @@ class Builder { ...merge, }, 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, "ThirdPartyNotices.txt"), - path.join(archivePath, "ThirdPartyNotices.txt") + path.join(archivePath, "ThirdPartyNotices.txt"), ) if ((await this.target()) === "darwin") { diff --git a/ci/fmt.sh b/ci/fmt.sh index 9f9c2315..762dbdd2 100755 --- a/ci/fmt.sh +++ b/ci/fmt.sh @@ -3,15 +3,35 @@ set -euo pipefail main() { - shfmt -i 2 -w -s -sr $$(git ls-files "*.sh") - prettier --write --loglevel=warn $$(git ls-files "*.js" "*.ts" "*.tsx" "*.html" "*.json" "*.css" "*.md" "*.toml" "*.yaml" "*.yml") - if [[ "$CI" != "" && $$(git ls-files --other --modified --exclude-standard) != "" ]]; then - echo "Files need generation or are formatted incorrectly:" - git -c color.ui=always status | grep --color=no '\[31m' - echo "Please run the following locally:" - echo " make fmt" - exit 1 - fi + if [[ ${CI-} ]]; then + cd "$(dirname "$0")/.." + ./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:" + git -c color.ui=always status | grep --color=no '\[31m' + echo "Please run the following locally:" + echo " yarn fmt" + exit 1 + fi } main "$@" diff --git a/ci/image/Dockerfile b/ci/image/Dockerfile index 6bef9e51..0f4977b3 100644 --- a/ci/image/Dockerfile +++ b/ci/image/Dockerfile @@ -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 +ENV PAGER=cat +ENV CI=true + ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"] diff --git a/ci/lint.sh b/ci/lint.sh index 5b60c894..bae79a1f 100755 --- a/ci/lint.sh +++ b/ci/lint.sh @@ -3,8 +3,14 @@ set -euo pipefail main() { - eslint --max-warnings=0 --fix $$(git ls-files "*.ts" "*.tsx" "*.js") - stylelint --fix $$(git ls-files "*.css") + if [[ ${CI-} ]]; then + 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 "$@" diff --git a/ci/release.bash b/ci/release.sh similarity index 79% rename from ci/release.bash rename to ci/release.sh index c288a10a..e84561b9 100755 --- a/ci/release.bash +++ b/ci/release.sh @@ -8,7 +8,7 @@ function main() { cd "$(dirname "${0}")/.." local code_server_version=${VERSION:-${TRAVIS_TAG:-${DRONE_TAG:-}}} - if [[ -z $code_server_version ]] ; then + if [[ -z $code_server_version ]]; then code_server_version=$(grep version ./package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[:space:]') fi export VERSION=$code_server_version @@ -17,33 +17,33 @@ function main() { export YARN_CACHE_FOLDER # Always minify and package on tags since that's when releases are pushed. - if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then + if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then export MINIFY="true" export PACKAGE="true" fi yarn build yarn binary - if [[ -n ${PACKAGE:-} ]] ; then + if [[ -n ${PACKAGE:-} ]]; then yarn package fi cd binaries - if [[ -n ${STRIP_BIN_TARGET:-} ]] ; then + if [[ -n ${STRIP_BIN_TARGET:-} ]]; then # In this case provide plainly named binaries. - for binary in code-server* ; do + for binary in code-server*; do echo "Moving $binary to code-server" mv "$binary" code-server done - elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then + elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then # Prepare directory for uploading binaries on release. - for binary in code-server* ; do + for binary in code-server*; do mkdir -p "../binary-upload" local prefix="code-server-$code_server_version-" local target="${binary#$prefix}" - if [[ $target == "linux-x86_64" ]] ; then + if [[ $target == "linux-x86_64" ]]; then echo "Copying $binary to ../binary-upload/latest-linux" cp "$binary" "../binary-upload/latest-linux" fi diff --git a/ci/tsconfig.json b/ci/tsconfig.json index d4b88657..5197ce27 100644 --- a/ci/tsconfig.json +++ b/ci/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../tsconfig.json", - "include": [ - "./**/*.ts" - ] + "include": ["./**/*.ts"] } diff --git a/ci/vscode.sh b/ci/vscode.sh index 4fd5ec78..ffacd812 100755 --- a/ci/vscode.sh +++ b/ci/vscode.sh @@ -10,7 +10,7 @@ main() { git submodule update --init # If the patch fails to apply, then it's likely already applied - yarn vscode:patch &>/dev/null || true + yarn vscode:patch &> /dev/null || true # Install VS Code dependencies. (cd lib/vscode && yarn) diff --git a/package.json b/package.json index 34a37365..1c1a3557 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,9 @@ "vscode": "ci/vscode.sh", "vscode:patch": "cd ./lib/vscode && git apply ../../ci/vscode.patch", "vscode:diff": "cd ./lib/vscode && git diff HEAD > ../../ci/vscode.patch", - "test": "mocha -r ts-node/register ./test/*.test.ts", - "lint": "ci/lint.sh", "fmt": "ci/fmt.sh", - "runner": "cd ./scripts && NODE_OPTIONS=--max_old_space_size=32384 ts-node ./build.ts", "build": "yarn runner build", "watch": "yarn runner watch", diff --git a/src/browser/media/manifest.json b/src/browser/media/manifest.json index 513304e1..c1879926 100644 --- a/src/browser/media/manifest.json +++ b/src/browser/media/manifest.json @@ -5,9 +5,11 @@ "display": "fullscreen", "background-color": "#fff", "description": "Run editors on a remote server.", - "icons": [{ - "src": "./code-server.png", - "sizes": "384x384", - "type": "image/png" - }] + "icons": [ + { + "src": "./code-server.png", + "sizes": "384x384", + "type": "image/png" + } + ] } diff --git a/src/browser/pages/app.html b/src/browser/pages/app.html index ce1b49b1..6f23348c 100644 --- a/src/browser/pages/app.html +++ b/src/browser/pages/app.html @@ -2,14 +2,21 @@
- - + +