Skip to content

Commit 7580a52

Browse files
committed
Clean up and refactor VSCode integration.
- Fixed linter/prettier mixups during development. - Cleaned up web config injection, removed separate NLS injection. - Cleaned up comments for use with intellisense - Updated types to more often use VScode's built in types. - Cleaned up URI helpers. - Organized connection classes into separate files. - Documented protocol usage, adding trace logging support. - Fleshed out partial support for remote debugging. - Updated tests.
1 parent 30dc47d commit 7580a52

File tree

81 files changed

+2565
-1930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2565
-1930
lines changed

.editorconfig

+5
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ root = true
33
[*]
44
indent_style = space
55
trim_trailing_whitespace = true
6+
7+
# The indent size used in the `package.json` file cannot be changed
8+
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
9+
[{*.yml,*.yaml,package.json}]
10+
indent_style = space
611
indent_size = 2

.prettierrc.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,16 @@ printWidth: 120
22
semi: false
33
trailingComma: all
44
arrowParens: always
5+
singleQuote: false
6+
useTabs: false
7+
8+
overrides:
9+
# Attempt to keep VScode's existing code style intact.
10+
- files: "lib/vscode/**/*.ts"
11+
options:
12+
# No limit defined upstream.
13+
printWidth: 10000
14+
semi: true
15+
singleQuote: true
16+
useTabs: true
17+
arrowParens: avoid

lib/vscode/.eslintrc.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,14 @@
802802
"target": "**/vs/server/**",
803803
"restrictions": [
804804
"vs/nls",
805+
// @coder Allow additional imports until our server structure aligns with upstream.
806+
"**/vs/code/**/{common,server,browser,node,electron-sandbox,electron-browser}/**",
805807
"**/vs/base/**/{common,node}/**",
806808
"**/vs/base/parts/**/{common,node}/**",
807809
"**/vs/platform/**/{common,node}/**",
808810
"**/vs/workbench/**/{common,node}/**",
811+
"**/vs/workbench/workbench.web.api",
809812
"**/vs/server/**",
810-
"@coder/logger", // NOTE@coder: add logger
811813
"*" // node modules
812814
]
813815
},

lib/vscode/.vscode/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@
8484
"editor.defaultFormatter": "vscode.typescript-language-features",
8585
"editor.formatOnSave": true,
8686
},
87+
// @coder Attempt to keep loose formatters inline with upstream's code style.
88+
"typescript.format.insertSpaceAfterConstructor": false,
89+
"javascript.format.insertSpaceAfterConstructor": false,
90+
"javascript.format.insertSpaceBeforeFunctionParenthesis": false,
91+
"typescript.format.insertSpaceBeforeFunctionParenthesis": false,
92+
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
93+
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
8794
"typescript.tsc.autoDetect": "off",
8895
"notebook.experimental.useMarkdownRenderer": true,
8996
"testing.autoRun.mode": "rerun",

lib/vscode/build/gulpfile.reh.js

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ BUILD_TARGETS.forEach(({ platform, arch }) => {
4242
});
4343

4444
function getNodeVersion() {
45-
// NOTE@coder: Fix version due to .yarnrc removal.
46-
return process.versions.node;
4745
const yarnrc = fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8');
4846
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
4947
return target;

lib/vscode/build/hygiene.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ const copyrightHeaderLines = [
1919
' *--------------------------------------------------------------------------------------------*/',
2020
];
2121

22+
/**
23+
* @remark While this helps delineate Coder's additions to the upstream project,
24+
* this notice should be examined within the context of the application.
25+
* Code from both maintainers often overlaps.
26+
*/
27+
const coderCopyrightHeaderLines = [
28+
'/*---------------------------------------------------------------------------------------------',
29+
' * Copyright (c) Coder Technologies. All rights reserved.',
30+
' * Licensed under the MIT License. See License.txt in the project root for license information.',
31+
' *--------------------------------------------------------------------------------------------*/',
32+
];
33+
2234
function hygiene(some, linting = true) {
2335
const gulpeslint = require('gulp-eslint');
2436
const tsfmt = require('typescript-formatter');
@@ -62,7 +74,7 @@ function hygiene(some, linting = true) {
6274
const lines = file.__lines;
6375

6476
for (let i = 0; i < copyrightHeaderLines.length; i++) {
65-
if (lines[i] !== copyrightHeaderLines[i]) {
77+
if (lines[i] !== copyrightHeaderLines[i] && lines[i] !== coderCopyrightHeaderLines[i]) {
6678
console.error(file.relative + ': Missing or bad copyright statement');
6779
errorCount++;
6880
break;

lib/vscode/build/lib/node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const path = require("path");
88
const fs = require("fs");
99
const root = path.dirname(path.dirname(__dirname));
1010
const yarnrcPath = path.join(root, 'remote', '.yarnrc');
11-
// NOTE@coder: Fix version due to .yarnrc removal.
12-
const version = process.versions.node;
11+
const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
12+
const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)[1];
1313
const platform = process.platform;
1414
const arch = platform === 'darwin' ? 'x64' : process.arch;
1515
const node = platform === 'win32' ? 'node.exe' : 'node';

lib/vscode/build/lib/node.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as path from 'path';
7+
import * as fs from 'fs';
78

89
const root = path.dirname(path.dirname(__dirname));
10+
const yarnrcPath = path.join(root, 'remote', '.yarnrc');
11+
const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
12+
const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)![1];
913

10-
// NOTE@coder: Fix version due to .yarnrc removal.
11-
const version = process.versions.node;
1214
const platform = process.platform;
1315
const arch = platform === 'darwin' ? 'x64' : process.arch;
1416

lib/vscode/build/lib/util.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ export function streamToPromise(stream: NodeJS.ReadWriteStream): Promise<void> {
336336
}
337337

338338
export function getElectronVersion(): string {
339-
// NOTE@coder: Fix version due to .yarnrc removal.
340-
return process.versions.node;
339+
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
340+
const target = /^target "(.*)"$/m.exec(yarnrc)![1];
341+
return target;
341342
}

lib/vscode/build/lib/watch/yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ fsevents@~2.3.1:
148148
integrity sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw==
149149

150150
glob-parent@^5.1.1, glob-parent@~5.1.0:
151-
version "5.1.2"
152-
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
153-
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
151+
version "5.1.1"
152+
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229"
153+
integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==
154154
dependencies:
155155
is-glob "^4.0.1"
156156

lib/vscode/build/yarn.lock

+12-12
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,9 @@ entities@~2.0.0:
749749
integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==
750750

751751
esbuild@^0.12.6:
752-
version "0.12.6"
753-
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.12.6.tgz#85bc755c7cf3005d4f34b4f10f98049ce0ee67ce"
754-
integrity sha512-RDvVLvAjsq/kIZJoneMiUOH7EE7t2QaW7T3Q7EdQij14+bZbDq5sndb0tTanmHIFSqZVMBMMyqzVHkS3dJobeA==
752+
version "0.12.21"
753+
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.12.21.tgz#7ff32a9ac73ce4310f9cb61ea4c3da9756570d46"
754+
integrity sha512-7hyXbU3g94aREufI/5nls7Xcc+RGQeZWZApm6hoBaFvt2BPtpT4TjFMQ9Tb1jU8XyBGz00ShmiyflCogphMHFQ==
755755

756756
escape-string-regexp@^1.0.5:
757757
version "1.0.5"
@@ -1085,9 +1085,9 @@ mute-stream@~0.0.4:
10851085
integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=
10861086

10871087
normalize-url@^4.1.0:
1088-
version "4.5.1"
1089-
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a"
1090-
integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==
1088+
version "4.5.0"
1089+
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129"
1090+
integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==
10911091

10921092
nth-check@~1.0.1:
10931093
version "1.0.2"
@@ -1097,9 +1097,9 @@ nth-check@~1.0.1:
10971097
boolbase "~1.0.0"
10981098

10991099
object-inspect@^1.9.0:
1100-
version "1.10.3"
1101-
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369"
1102-
integrity sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==
1100+
version "1.11.0"
1101+
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1"
1102+
integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==
11031103

11041104
once@^1.3.0, once@^1.3.1, once@^1.4.0:
11051105
version "1.4.0"
@@ -1307,9 +1307,9 @@ [email protected]:
13071307
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
13081308

13091309
typed-rest-client@^1.8.4:
1310-
version "1.8.4"
1311-
resolved "https://registry.yarnpkg.com/typed-rest-client/-/typed-rest-client-1.8.4.tgz#ba3fb788e5b9322547406392533f12d660a5ced6"
1312-
integrity sha512-MyfKKYzk3I6/QQp6e1T50py4qg+c+9BzOEl2rBmQIpStwNUoqQ73An+Tkfy9YuV7O+o2mpVVJpe+fH//POZkbg==
1310+
version "1.8.5"
1311+
resolved "https://registry.yarnpkg.com/typed-rest-client/-/typed-rest-client-1.8.5.tgz#3d331f2761c2be0103bda71a7d19ab08533f3b5a"
1312+
integrity sha512-952/Aegu3lTqUAI1anbDLbewojnF/gh8at9iy1CIrfS1h/+MtNjB1Y9z6ZF5n2kZd+97em56lZ9uu7Zz3y/pwg==
13131313
dependencies:
13141314
qs "^6.9.1"
13151315
tunnel "0.0.6"

lib/vscode/coder.js

+41-36
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,71 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Coder Technologies. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
16
// This must be ran from VS Code's root.
2-
const gulp = require("gulp");
3-
const path = require("path");
4-
const _ = require("underscore");
5-
const buildfile = require("./src/buildfile");
6-
const common = require("./build/lib/optimize");
7-
const util = require("./build/lib/util");
7+
const gulp = require('gulp');
8+
const path = require('path');
9+
const _ = require('underscore');
10+
const buildfile = require('./src/buildfile');
11+
const common = require('./build/lib/optimize');
12+
const util = require('./build/lib/util');
813

914
const vscodeEntryPoints = _.flatten([
10-
buildfile.entrypoint("vs/workbench/workbench.web.api"),
11-
buildfile.entrypoint("vs/server/entry"),
15+
buildfile.entrypoint('vs/workbench/workbench.web.api'),
16+
buildfile.entrypoint('vs/server/entry'),
1217
buildfile.base,
1318
buildfile.workbenchWeb,
1419
buildfile.workerExtensionHost,
1520
buildfile.workerNotebook,
1621
buildfile.keyboardMaps,
1722
// See ./src/vs/workbench/buildfile.desktop.js
18-
buildfile.entrypoint("vs/platform/files/node/watcher/unix/watcherApp"),
19-
buildfile.entrypoint("vs/platform/files/node/watcher/nsfw/watcherApp"),
20-
buildfile.entrypoint('vs/platform/terminal/node/ptyHostMain'),
21-
buildfile.entrypoint("vs/workbench/services/extensions/node/extensionHostProcess"),
23+
buildfile.entrypoint('vs/platform/files/node/watcher/unix/watcherApp'),
24+
buildfile.entrypoint('vs/platform/files/node/watcher/nsfw/watcherApp'),
25+
buildfile.entrypoint(`vs/platform/terminal/node/ptyHostMain`),
26+
buildfile.entrypoint('vs/workbench/services/extensions/node/extensionHostProcess'),
2227
]);
2328

2429
// See ./build/gulpfile.vscode.js
2530
const vscodeResources = [
26-
"out-build/vs/server/fork.js",
27-
"!out-build/vs/server/doc/**",
28-
"out-build/vs/workbench/services/extensions/worker/extensionHostWorkerMain.js",
29-
"out-build/bootstrap.js",
30-
"out-build/bootstrap-fork.js",
31-
"out-build/bootstrap-amd.js",
31+
'out-build/vs/server/fork.js',
32+
'!out-build/vs/server/doc/**',
33+
'out-build/vs/workbench/services/extensions/worker/extensionHostWorkerMain.js',
34+
'out-build/bootstrap.js',
35+
'out-build/bootstrap-fork.js',
36+
'out-build/bootstrap-amd.js',
3237
'out-build/bootstrap-node.js',
3338
'out-build/vs/**/*.{svg,png,html,ttf,jpg}',
34-
"!out-build/vs/code/browser/workbench/*.html",
39+
'!out-build/vs/code/browser/workbench/*.html',
3540
'!out-build/vs/code/electron-browser/**',
36-
"out-build/vs/base/common/performance.js",
37-
"out-build/vs/base/node/languagePacks.js",
41+
'out-build/vs/base/common/performance.js',
42+
'out-build/vs/base/node/languagePacks.js',
3843
'out-build/vs/base/browser/ui/codicons/codicon/**',
3944
'out-build/vs/base/node/userDataPath.js',
40-
"out-build/vs/workbench/browser/media/*-theme.css",
41-
"out-build/vs/workbench/contrib/debug/**/*.json",
42-
"out-build/vs/workbench/contrib/externalTerminal/**/*.scpt",
43-
"out-build/vs/workbench/contrib/webview/browser/pre/*.js",
44-
"out-build/vs/**/markdown.css",
45-
"out-build/vs/workbench/contrib/tasks/**/*.json",
46-
"out-build/vs/platform/files/**/*.md",
47-
"!**/test/**"
45+
'out-build/vs/workbench/browser/media/*-theme.css',
46+
'out-build/vs/workbench/contrib/debug/**/*.json',
47+
'out-build/vs/workbench/contrib/externalTerminal/**/*.scpt',
48+
'out-build/vs/workbench/contrib/webview/browser/pre/*.js',
49+
'out-build/vs/**/markdown.css',
50+
'out-build/vs/workbench/contrib/tasks/**/*.json',
51+
'out-build/vs/platform/files/**/*.md',
52+
'!**/test/**'
4853
];
4954

50-
gulp.task("optimize", gulp.series(
51-
util.rimraf("out-vscode"),
55+
gulp.task('optimize', gulp.series(
56+
util.rimraf('out-vscode'),
5257
common.optimizeTask({
53-
src: "out-build",
58+
src: 'out-build',
5459
entryPoints: vscodeEntryPoints,
5560
resources: vscodeResources,
5661
loaderConfig: common.loaderConfig(),
57-
out: "out-vscode",
62+
out: 'out-vscode',
5863
inlineAmdImages: true,
5964
bundleInfo: undefined
6065
}),
6166
));
6267

63-
gulp.task("minify", gulp.series(
64-
util.rimraf("out-vscode-min"),
65-
common.minifyTask("out-vscode")
68+
gulp.task('minify', gulp.series(
69+
util.rimraf('out-vscode-min'),
70+
common.minifyTask('out-vscode')
6671
));

lib/vscode/extensions/github-authentication/src/githubServer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import { AuthProviderType } from './github';
1515
const localize = nls.loadMessageBundle();
1616

1717
export const NETWORK_ERROR = 'network error';
18-
// NOTE@coder: use our own auth relay (the commented one is microsoft's, not ours)
18+
/**
19+
* @coder Domain to our own auth relay.
20+
* @remark `AUTH_RELAY_STAGING_SERVER` comes from Microsoft's
21+
*/
1922
const AUTH_RELAY_SERVER = 'auth.code-server.dev';
2023
// const AUTH_RELAY_STAGING_SERVER = 'client-auth-staging-14a768b.herokuapp.com';
2124

lib/vscode/extensions/postinstall.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function processRoot() {
2525
}
2626
}
2727

28-
// Delete .bin so it doesn't contain broken symlinks that trip up nfpm.
28+
/** @coder: Delete .bin so it doesn't contain broken symlinks that trip up nfpm. */
2929
rimraf.sync(path.join(__dirname, 'node_modules', '.bin'));
3030
}
3131

lib/vscode/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"web": "node resources/web/code-web.js",
4646
"compile-web": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js compile-web",
4747
"watch-web": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js watch-web",
48+
"server": "node --max_old_space_size=4095 out/vs/server/entry.js",
4849
"eslint": "node build/eslint",
4950
"playwright-install": "node build/azure-pipelines/common/installPlaywright.js",
5051
"compile-build": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js compile-build",
@@ -91,6 +92,8 @@
9192
},
9293
"devDependencies": {
9394
"7zip": "0.0.6",
95+
"@types/proxy-from-env": "^1.0.1",
96+
"@types/tar-stream": "^2.2.1",
9497
"@types/applicationinsights": "0.20.0",
9598
"@types/chokidar": "2.1.3",
9699
"@types/cookie": "^0.3.3",

lib/vscode/product.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"licenseFileName": "LICENSE.txt",
2323
"reportIssueUrl": "https://github.com/cdr/code-server/issues/new",
2424
"urlProtocol": "code-oss",
25+
"webviewContentExternalBaseUrlTemplate": "https://{{uuid}}.vscode-webview.net/{{quality}}/{{commit}}/out/vs/workbench/contrib/webview/browser/pre/",
2526
"extensionAllowedProposedApi": [
2627
"ms-vscode.vscode-js-profile-flame",
2728
"ms-vscode.vscode-js-profile-table",
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Coder Technologies. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/**
7+
* @file this is a temporary type definition.
8+
* Upstream seems to be modifying the web module often and will likely switch to TypeScript.
9+
*/
10+
11+
import * as http from 'http';
12+
import { IServerWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
13+
14+
export function requestHandler(req: http.IncomingMessage, res: http.ServerResponse, webConfigJSON: IServerWorkbenchConstructionOptions): void;

0 commit comments

Comments
 (0)