Skip to content

Commit be20061

Browse files
authored
Merge branch 'main' into patch-2
2 parents 8ef2f78 + 9d9f3a4 commit be20061

File tree

16 files changed

+85
-119
lines changed

16 files changed

+85
-119
lines changed

.eslintrc.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ rules:
3636
import/order:
3737
[error, { alphabetize: { order: "asc" }, groups: [["builtin", "external", "internal"], "parent", "sibling"] }]
3838
no-async-promise-executor: off
39-
# This isn't a real module, just types, which apparently doesn't resolve.
40-
import/no-unresolved: [error, { ignore: ["express-serve-static-core"] }]
4139

4240
settings:
43-
# Does not work with CommonJS unfortunately.
44-
import/ignore:
45-
- env-paths
46-
- xdg-basedir
41+
import/resolver:
42+
typescript:
43+
alwaysTryTypes: true

ci/dev/watch.ts

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { spawn, fork, ChildProcess } from "child_process"
22
import del from "del"
33
import { promises as fs } from "fs"
44
import * as path from "path"
5-
import { CompilationStats, onLine, OnLineCallback, VSCodeCompileStatus } from "../../src/node/util"
5+
import { CompilationStats, onLine, OnLineCallback } from "../../src/node/util"
66

77
interface DevelopmentCompilers {
88
[key: string]: ChildProcess | undefined
@@ -52,24 +52,18 @@ class Watcher {
5252
plugins: this.paths.pluginDir ? spawn("yarn", ["build", "--watch"], { cwd: this.paths.pluginDir }) : undefined,
5353
}
5454

55-
private vscodeCompileStatus = VSCodeCompileStatus.Loading
56-
5755
public async initialize(): Promise<void> {
5856
for (const event of ["SIGINT", "SIGTERM"]) {
5957
process.on(event, () => this.dispose(0))
6058
}
6159

62-
if (!this.hasVerboseLogging) {
63-
console.log("\n[Watcher]", "Compiler logs will be minimal. Pass --log to show all output.")
64-
}
65-
6660
this.cleanFiles()
6761

6862
for (const [processName, devProcess] of Object.entries(this.compilers)) {
6963
if (!devProcess) continue
7064

7165
devProcess.on("exit", (code) => {
72-
this.log(`[${processName}]`, "Terminated unexpectedly")
66+
console.log(`[${processName}]`, "Terminated unexpectedly")
7367
this.dispose(code)
7468
})
7569

@@ -91,33 +85,14 @@ class Watcher {
9185
//#region Line Parsers
9286

9387
private parseVSCodeLine: OnLineCallback = (strippedLine, originalLine) => {
94-
if (!strippedLine.includes("watch-extensions") || this.hasVerboseLogging) {
95-
console.log("[VS Code]", originalLine)
96-
}
88+
if (!strippedLine.length) return
89+
90+
console.log("[VS Code]", originalLine)
9791

98-
switch (this.vscodeCompileStatus) {
99-
case VSCodeCompileStatus.Loading:
100-
// Wait for watch-client since "Finished compilation" will appear multiple
101-
// times before the client starts building.
102-
if (strippedLine.includes("Starting 'watch-client'")) {
103-
console.log("[VS Code] 🚧 Compiling 🚧", "(This may take a moment!)")
104-
this.vscodeCompileStatus = VSCodeCompileStatus.Compiling
105-
}
106-
break
107-
case VSCodeCompileStatus.Compiling:
108-
if (strippedLine.includes("Finished compilation")) {
109-
console.log("[VS Code] ✨ Finished compiling! ✨", "(Refresh your web browser ♻️)")
110-
this.vscodeCompileStatus = VSCodeCompileStatus.Compiled
111-
112-
this.emitCompilationStats()
113-
this.reloadWebServer()
114-
}
115-
break
116-
case VSCodeCompileStatus.Compiled:
117-
console.log("[VS Code] 🔔 Finished recompiling! 🔔", "(Refresh your web browser ♻️)")
118-
this.emitCompilationStats()
119-
this.reloadWebServer()
120-
break
92+
if (strippedLine.includes("Finished compilation with")) {
93+
console.log("[VS Code] ✨ Finished compiling! ✨", "(Refresh your web browser ♻️)")
94+
this.emitCompilationStats()
95+
this.reloadWebServer()
12196
}
12297
}
12398

@@ -128,7 +103,6 @@ class Watcher {
128103

129104
if (strippedLine.includes("Watching for file changes")) {
130105
console.log("[Compiler][Code Server]", "Finished compiling!", "(Refresh your web browser ♻️)")
131-
132106
this.reloadWebServer()
133107
}
134108
}
@@ -153,11 +127,7 @@ class Watcher {
153127
private cleanFiles(): Promise<string[]> {
154128
console.log("[Watcher]", "Cleaning files from previous builds...")
155129

156-
return del([
157-
"out/**/*",
158-
// Included because the cache can sometimes enter bad state when debugging compiled files.
159-
".cache/**/*",
160-
])
130+
return del(["out/**/*"])
161131
}
162132

163133
/**
@@ -166,31 +136,22 @@ class Watcher {
166136
*/
167137
private emitCompilationStats(): Promise<void> {
168138
const stats: CompilationStats = {
169-
status: this.vscodeCompileStatus,
170139
lastCompiledAt: new Date(),
171140
}
172141

173-
this.log("Writing watcher stats...")
142+
console.log("Writing watcher stats...")
174143
return fs.writeFile(this.paths.compilationStatsFile, JSON.stringify(stats, null, 2))
175144
}
176145

177-
private log(...entries: string[]) {
178-
process.stdout.write(entries.join(" "))
179-
}
180-
181146
private dispose(code: number | null): void {
182147
for (const [processName, devProcess] of Object.entries(this.compilers)) {
183-
this.log(`[${processName}]`, "Killing...\n")
148+
console.log(`[${processName}]`, "Killing...\n")
184149
devProcess?.removeAllListeners()
185150
devProcess?.kill()
186151
}
187152
process.exit(typeof code === "number" ? code : 0)
188153
}
189154

190-
private get hasVerboseLogging() {
191-
return process.argv.includes("--log")
192-
}
193-
194155
//#endregion
195156
}
196157

docs/CONTRIBUTING.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,31 @@ Here are these steps you should follow to get your dev environment setup:
8484

8585
1. `git clone https://github.com/cdr/code-server.git` - Clone `code-server`
8686
2. `git clone https://github.com/cdr/vscode.git` - Clone `vscode`
87-
3. `cd vscode && git checkout code-server-v2` - checkout the branch we use (not the default)
88-
4. `cd vscode && yarn install` - install the dependencies in the `vscode` repo
89-
5. `cd code-server && yarn install` - install the dependencies in the `code-server` repo
90-
6. `cd vscode && yarn link` - use `yarn` to create a symlink to the `vscode` repo (`code-oss-dev` package)
91-
7. `cd code-server && yarn link code-oss-dev --modules-folder vendor/modules` - links your local `vscode` repo (`code-oss-dev` package) inside your local version of code-server
92-
8. `cd code-server && yarn watch` - this will spin up code-server on localhost:8080 which you can start developing. It will live reload changes to the source.
87+
3. `cd vscode && yarn install` - install the dependencies in the `vscode` repo
88+
4. `cd code-server && yarn install` - install the dependencies in the `code-server` repo
89+
5. `cd vscode && yarn link` - use `yarn` to create a symlink to the `vscode` repo (`code-oss-dev` package)
90+
6. `cd code-server && yarn link code-oss-dev --modules-folder vendor/modules` - links your local `vscode` repo (`code-oss-dev` package) inside your local version of code-server
91+
7. `cd code-server && yarn watch` - this will spin up code-server on localhost:8080 which you can start developing. It will live reload changes to the source.
9392

9493
### Updates to VS Code
9594

96-
If changes are made and merged into `code-server-v2` in the `cdr/vscode` repo, then you'll need to update the version in the `code-server` repo by following these steps:
95+
If changes are made and merged into `main` in the [`cdr/vscode`](https://github.com/cdr/vscode) repo, then you'll need to update the version in the `code-server` repo by following these steps:
9796

9897
1. Update the package tag listed in `vendor/package.json`:
9998

10099
```json
101100
{
102101
"devDependencies": {
103-
"vscode": "cdr/vscode#X.XX.X-code-server"
102+
"vscode": "cdr/vscode#<latest-commit-sha>"
104103
}
105104
}
106105
```
107106

108-
1. From the code-server **project root**, run `yarn install`.
107+
2. From the code-server **project root**, run `yarn install`.
109108
Then, test code-server locally to make sure everything works.
110-
1. Check the Node.js version that's used by Electron (which is shipped with VS
109+
3. Check the Node.js version that's used by Electron (which is shipped with VS
111110
Code. If necessary, update your version of Node.js to match.
112-
1. Open a PR
111+
4. Open a PR
113112

114113
> Watch for updates to
115114
> `vendor/modules/code-oss-dev/src/vs/code/browser/workbench/workbench.html`. You may need to

docs/MAINTAINING.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Docker](#docker)
2020
- [Homebrew](#homebrew)
2121
- [npm](#npm)
22+
- [Syncing with Upstream VS Code](#syncing-with-upstream-vs-code)
2223
- [Testing](#testing)
2324
- [Documentation](#documentation)
2425
- [Troubleshooting](#troubleshooting)
@@ -126,8 +127,7 @@ the issue.
126127

127128
### Merge strategies
128129

129-
For most things, we recommend the **squash and merge** strategy. If you're
130-
updating `lib/vscode`, we suggest using the **rebase and merge** strategy. There
130+
For most things, we recommend the **squash and merge** strategy. There
131131
may be times where **creating a merge commit** makes sense as well. Use your
132132
best judgment. If you're unsure, you can always discuss in the PR with the team.
133133

@@ -215,6 +215,18 @@ We publish code-server as a npm package [here](https://www.npmjs.com/package/cod
215215

216216
This is currently automated with the release process.
217217

218+
## Syncing with Upstream VS Code
219+
220+
The VS Code portion of code-server lives under [`cdr/vscode`](https://github.com/cdr/vscode). To update VS Code for code-server, follow these steps:
221+
222+
1. `git checkout -b vscode-update` - Create a new branch locally based off `main`
223+
2. `git fetch upstream` - Fetch upstream (VS Code)'s latest `main` branch
224+
3. `git merge upstream/main` - Merge it locally
225+
1. If there are merge conflicts, fix them locally
226+
4. Open a PR merging your branch (`vscode-update`) into `main` and add the code-server review team
227+
228+
Ideally, our fork stays as close to upstream as possible. See the differences between our fork and upstream [here](https://github.com/microsoft/vscode/compare/main...cdr:main).
229+
218230
## Testing
219231

220232
Our testing structure is laid out under our [Contributing docs](https://coder.com/docs/code-server/latest/CONTRIBUTING#test).

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"doctoc": "^2.0.0",
5757
"eslint": "^7.7.0",
5858
"eslint-config-prettier": "^8.1.0",
59-
"eslint-import-resolver-alias": "^1.1.2",
59+
"eslint-import-resolver-typescript": "^2.5.0",
6060
"eslint-plugin-import": "^2.18.2",
6161
"eslint-plugin-prettier": "^4.0.0",
6262
"prettier": "^2.2.1",
@@ -94,7 +94,7 @@
9494
"pem": "^1.14.2",
9595
"proxy-agent": "^5.0.0",
9696
"proxy-from-env": "^1.1.0",
97-
"qs": "6.10.1",
97+
"qs": "6.10.2",
9898
"rotating-file-stream": "^3.0.0",
9999
"safe-buffer": "^5.1.1",
100100
"safe-compare": "^1.1.4",

src/node/entry.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
11
import { logger } from "@coder/logger"
22
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
3-
import { commit, pkgName, version } from "./constants"
3+
import { commit, version } from "./constants"
44
import { openInExistingInstance, runCodeServer, runVsCodeCli, shouldSpawnCliProcess } from "./main"
55
import { monkeyPatchProxyProtocols } from "./proxy_agent"
6-
import { loadAMDModule } from "./util"
76
import { isChild, wrapper } from "./wrapper"
87

9-
const cliPipe = process.env["VSCODE_IPC_HOOK_CLI"] as string
10-
const cliCommand = process.env["VSCODE_CLIENT_COMMAND"] as string
11-
128
async function entry(): Promise<void> {
139
monkeyPatchProxyProtocols()
1410

15-
if (cliPipe || cliCommand) {
16-
const remoteAgentMain = await loadAMDModule<CodeServerLib.RemoteCLIMain>("vs/server/remoteCli", "main")
17-
18-
remoteAgentMain(
19-
{
20-
productName: pkgName,
21-
version,
22-
commit,
23-
executableName: pkgName,
24-
},
25-
process.argv.slice(2),
26-
)
27-
return
28-
}
29-
3011
// There's no need to check flags like --help or to spawn in an existing
3112
// instance for the child process because these would have already happened in
3213
// the parent and the child wouldn't have been spawned. We also get the

src/node/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as expressCore from "express-serve-static-core"
44
import * as http from "http"
55
import * as net from "net"
66
import path from "path"
7-
import qs from "qs"
7+
import * as qs from "qs"
88
import { Disposable } from "../common/emitter"
99
import { CookieKeys, HttpCode, HttpError } from "../common/http"
1010
import { normalize } from "../common/util"

src/node/routes/pathProxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request, Response } from "express"
22
import * as path from "path"
3-
import qs from "qs"
3+
import * as qs from "qs"
44
import * as pluginapi from "../../../typings/pluginapi"
55
import { HttpCode, HttpError } from "../../common/http"
66
import { normalize } from "../../common/util"

src/node/util.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,7 @@ export const loadAMDModule = async <T>(amdPath: string, exportName: string): Pro
524524
return module[exportName] as T
525525
}
526526

527-
export const enum VSCodeCompileStatus {
528-
Loading = "Loading",
529-
Compiling = "Compiling",
530-
Compiled = "Compiled",
531-
}
532-
533527
export interface CompilationStats {
534-
status: VSCodeCompileStatus
535528
lastCompiledAt: Date
536529
}
537530

src/node/wsRouter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ export function Router(): WebsocketRouter {
5050
return new WebsocketRouter()
5151
}
5252

53+
// eslint-disable-next-line import/no-named-as-default-member -- the typings are not updated correctly
5354
export const wss = new Websocket.Server({ noServer: true })

test/unit/node/proxy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import bodyParser from "body-parser"
1+
import * as bodyParser from "body-parser"
22
import * as express from "express"
33
import * as http from "http"
44
import nodeFetch from "node-fetch"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
settings: {
3+
"import/resolver": {
4+
typescript: {
5+
project: __dirname,
6+
},
7+
},
8+
},
9+
}

test/unit/node/test-plugin/.eslintrc.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

vendor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"postinstall": "./postinstall.sh"
88
},
99
"devDependencies": {
10-
"code-oss-dev": "cdr/vscode#5e0c6f3b95ed032e62c49101ae502a46c62ef202"
10+
"code-oss-dev": "cdr/vscode#c2a251c6afaa13fbebf97fcd8a68192f8cf46031"
1111
}
1212
}

vendor/yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ clone-response@^1.0.2:
296296
dependencies:
297297
mimic-response "^1.0.0"
298298

299-
code-oss-dev@cdr/vscode#5e0c6f3b95ed032e62c49101ae502a46c62ef202:
299+
code-oss-dev@cdr/vscode#c2a251c6afaa13fbebf97fcd8a68192f8cf46031:
300300
version "1.61.1"
301-
resolved "https://codeload.github.com/cdr/vscode/tar.gz/5e0c6f3b95ed032e62c49101ae502a46c62ef202"
301+
resolved "https://codeload.github.com/cdr/vscode/tar.gz/c2a251c6afaa13fbebf97fcd8a68192f8cf46031"
302302
dependencies:
303303
"@microsoft/applicationinsights-web" "^2.6.4"
304304
"@vscode/sqlite3" "4.0.12"

0 commit comments

Comments
 (0)