diff --git a/.editorconfig b/.editorconfig index 65705d954..0f6dc9448 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,4 +3,9 @@ root = true [*] indent_style = space trim_trailing_whitespace = true + +# The indent size used in the `package.json` file cannot be changed +# https://github.com/npm/npm/pull/3180#issuecomment-16336516 +[{*.yml,*.yaml,package.json}] +indent_style = space indent_size = 2 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf02bc67e..abcca10b1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -54,10 +54,6 @@ jobs: run: yarn lint if: success() - - name: Run code-server unit tests - run: yarn test:unit - if: success() - - name: Upload coverage report to Codecov run: yarn coverage if: success() @@ -408,6 +404,9 @@ jobs: rm -r node_modules/playwright yarn install --check-files + - name: Run end-to-end tests + run: yarn test:unit + - name: Run end-to-end tests run: yarn test:e2e diff --git a/.prettierrc.yaml b/.prettierrc.yaml index a0634116d..bf4b4a7d2 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -2,3 +2,16 @@ printWidth: 120 semi: false trailingComma: all arrowParens: always +singleQuote: false +useTabs: false + +overrides: + # Attempt to keep VScode's existing code style intact. + - files: "vendor/modules/code-oss-dev/**/*.ts" + options: + # No limit defined upstream. + printWidth: 10000 + semi: true + singleQuote: true + useTabs: true + arrowParens: avoid diff --git a/ci/build/build-code-server.sh b/ci/build/build-code-server.sh index e61264c37..b3b1967a6 100755 --- a/ci/build/build-code-server.sh +++ b/ci/build/build-code-server.sh @@ -37,10 +37,6 @@ main() { chmod +x ./lib/linkup set -e fi - - yarn browserify out/browser/register.js -o out/browser/register.browserified.js - yarn browserify out/browser/pages/login.js -o out/browser/pages/login.browserified.js - yarn browserify out/browser/pages/vscode.js -o out/browser/pages/vscode.browserified.js } main "$@" diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index 09d59aed9..f7b7df266 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -81,8 +81,8 @@ bundle_vscode() { rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions" mkdir -p "$VSCODE_OUT_PATH/resources/"{linux,web} - rsync "$VSCODE_SRC_PATH/resources/linux/code.png" "$VSCODE_OUT_PATH/resources/linux/code.png" - rsync "$VSCODE_SRC_PATH/resources/web/callback.html" "$VSCODE_OUT_PATH/resources/web/callback.html" + rsync "$VSCODE_SRC_PATH/resources/linux/" "$VSCODE_OUT_PATH/resources/linux/" + rsync "$VSCODE_SRC_PATH/resources/web/" "$VSCODE_OUT_PATH/resources/web/" # Add the commit and date and enable telemetry. This just makes telemetry # available; telemetry can still be disabled by flag or setting. diff --git a/ci/build/build-vscode.sh b/ci/build/build-vscode.sh index ca35d4f3b..91e83e7f0 100755 --- a/ci/build/build-vscode.sh +++ b/ci/build/build-vscode.sh @@ -11,8 +11,10 @@ main() { cd vendor/modules/code-oss-dev - yarn gulp compile-build compile-extensions-build compile-extension-media + yarn gulp compile-build compile-extensions-build compile-extension-media compile-web + yarn gulp optimize --gulpfile ./coder.js + if [[ $MINIFY ]]; then yarn gulp minify --gulpfile ./coder.js fi diff --git a/ci/dev/watch.ts b/ci/dev/watch.ts index a0c116ec2..6b783f406 100644 --- a/ci/dev/watch.ts +++ b/ci/dev/watch.ts @@ -1,6 +1,4 @@ -import browserify from "browserify" import * as cp from "child_process" -import * as fs from "fs" import * as path from "path" import { onLine } from "../../src/node/util" @@ -8,7 +6,7 @@ async function main(): Promise { try { const watcher = new Watcher() await watcher.watch() - } catch (error) { + } catch (error: any) { console.error(error.message) process.exit(1) } @@ -38,6 +36,9 @@ class Watcher { } const vscode = cp.spawn("yarn", ["watch"], { cwd: this.vscodeSourcePath }) + + const vscodeWebExtensions = cp.spawn("yarn", ["watch-web"], { cwd: this.vscodeSourcePath }) + const tsc = cp.spawn("tsc", ["--watch", "--pretty", "--preserveWatchOutput"], { cwd: this.rootPath }) const plugin = process.env.PLUGIN_DIR ? cp.spawn("yarn", ["build", "--watch"], { cwd: process.env.PLUGIN_DIR }) @@ -48,6 +49,10 @@ class Watcher { vscode.removeAllListeners() vscode.kill() + Watcher.log("killing vs code web extension watcher") + vscodeWebExtensions.removeAllListeners() + vscodeWebExtensions.kill() + Watcher.log("killing tsc") tsc.removeAllListeners() tsc.kill() @@ -75,10 +80,17 @@ class Watcher { Watcher.log("vs code watcher terminated unexpectedly") cleanup(code) }) + + vscodeWebExtensions.on("exit", (code) => { + Watcher.log("vs code extension watcher terminated unexpectedly") + cleanup(code) + }) + tsc.on("exit", (code) => { Watcher.log("tsc terminated unexpectedly") cleanup(code) }) + if (plugin) { plugin.on("exit", (code) => { Watcher.log("plugin terminated unexpectedly") @@ -86,18 +98,14 @@ class Watcher { }) } + vscodeWebExtensions.stderr.on("data", (d) => process.stderr.write(d)) vscode.stderr.on("data", (d) => process.stderr.write(d)) tsc.stderr.on("data", (d) => process.stderr.write(d)) + if (plugin) { plugin.stderr.on("data", (d) => process.stderr.write(d)) } - const browserFiles = [ - path.join(this.rootPath, "out/browser/register.js"), - path.join(this.rootPath, "out/browser/pages/login.js"), - path.join(this.rootPath, "out/browser/pages/vscode.js"), - ] - let startingVscode = false let startedVscode = false onLine(vscode, (line, original) => { @@ -120,7 +128,6 @@ class Watcher { console.log("[tsc]", original) } if (line.includes("Watching for file changes")) { - bundleBrowserCode(browserFiles) restartServer() } }) @@ -139,19 +146,4 @@ class Watcher { } } -function bundleBrowserCode(inputFiles: string[]) { - console.log(`[browser] bundling...`) - inputFiles.forEach(async (path: string) => { - const outputPath = path.replace(".js", ".browserified.js") - browserify() - .add(path) - .bundle() - .on("error", function (error: Error) { - console.error(error.toString()) - }) - .pipe(fs.createWriteStream(outputPath)) - }) - console.log(`[browser] done bundling`) -} - main() diff --git a/package.json b/package.json index a236c6e75..1b0c1277b 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,6 @@ "main": "out/node/entry.js", "devDependencies": { "@schemastore/package": "^0.0.6", - "@types/body-parser": "^1.19.0", - "@types/browserify": "^12.0.36", "@types/compression": "^1.7.0", "@types/cookie-parser": "^1.4.2", "@types/express": "^4.17.8", @@ -48,13 +46,11 @@ "@types/safe-compare": "^1.1.0", "@types/semver": "^7.1.0", "@types/split2": "^3.2.0", - "@types/tar-fs": "^2.0.0", - "@types/tar-stream": "^2.1.0", + "@types/trusted-types": "^2.0.2", "@types/ws": "^8.0.0", "@typescript-eslint/eslint-plugin": "^4.7.0", "@typescript-eslint/parser": "^4.7.0", "audit-ci": "^4.0.0", - "browserify": "^17.0.0", "codecov": "^3.8.3", "doctoc": "^2.0.0", "eslint": "^7.7.0", @@ -68,7 +64,7 @@ "stylelint": "^13.0.0", "stylelint-config-recommended": "^5.0.0", "ts-node": "^10.0.0", - "typescript": "^4.1.3" + "typescript": "^4.4.0-dev.20210528" }, "resolutions": { "ansi-regex": "^5.0.1", @@ -85,7 +81,6 @@ "dependencies": { "@coder/logger": "1.1.16", "argon2": "^0.28.0", - "body-parser": "^1.19.0", "compression": "^1.7.4", "cookie-parser": "^1.4.5", "env-paths": "^2.2.0", @@ -103,7 +98,6 @@ "safe-compare": "^1.1.4", "semver": "^7.1.3", "split2": "^3.2.2", - "tar-fs": "^2.0.0", "ws": "^8.0.0", "xdg-basedir": "^4.0.0", "yarn": "^1.22.4" diff --git a/src/browser/media/manifest.json b/src/browser/media/manifest.json deleted file mode 100644 index a16709e1e..000000000 --- a/src/browser/media/manifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "code-server", - "short_name": "code-server", - "start_url": "{{BASE}}", - "display": "fullscreen", - "background-color": "#fff", - "description": "Run editors on a remote server.", - "icons": [ - { - "src": "{{CS_STATIC_BASE}}/src/browser/media/pwa-icon-192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "{{CS_STATIC_BASE}}/src/browser/media/pwa-icon-512.png", - "type": "image/png", - "sizes": "512x512" - } - ] -} diff --git a/src/browser/pages/error.html b/src/browser/pages/error.html index 56e03e27a..1ff716d40 100644 --- a/src/browser/pages/error.html +++ b/src/browser/pages/error.html @@ -10,10 +10,11 @@ http-equiv="Content-Security-Policy" content="style-src 'self'; manifest-src 'self'; img-src 'self' data:; font-src 'self' data:;" /> + {{ERROR_TITLE}} - code-server - + @@ -30,6 +31,5 @@ - diff --git a/src/browser/pages/login.html b/src/browser/pages/login.html index 896927e38..f8837c8f3 100644 --- a/src/browser/pages/login.html +++ b/src/browser/pages/login.html @@ -13,7 +13,7 @@ code-server login - + @@ -30,7 +30,6 @@