Skip to content

Commit a413abf

Browse files
committed
Add dir creation and fix cli
It seems VS Code explodes when certain directories do not exist so import the reh agent instead of the server component since it creates the directories (require patching thus the VS Code update). Also the CLI (for installing extensions) did not seem to be working so point that to the same place since it also exports a function for running that part of the CLI.
1 parent 914aad2 commit a413abf

File tree

5 files changed

+15
-42
lines changed

5 files changed

+15
-42
lines changed

src/node/entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function entry(): Promise<void> {
7575
}
7676

7777
if (await shouldSpawnCliProcess(args)) {
78-
return runVsCodeCli()
78+
return runVsCodeCli(args)
7979
}
8080

8181
const socketPath = await shouldOpenInExistingInstance(cliArgs)

src/node/main.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { plural } from "../common/util"
66
import { createApp, ensureAddress } from "./app"
77
import { AuthType, DefaultedArgs, Feature } from "./cli"
88
import { coderCloudBind } from "./coder_cloud"
9-
import { commit, version, vsRootPath } from "./constants"
9+
import { commit, version } from "./constants"
1010
import { register } from "./routes"
1111
import { humanPath, isFile, loadAMDModule, open } from "./util"
1212

@@ -26,37 +26,14 @@ export const shouldSpawnCliProcess = async (args: CodeServerLib.ServerParsedArgs
2626
* such as when managing extensions.
2727
* @deprecated This should be removed when code-server merges with lib/vscode.
2828
*/
29-
export const runVsCodeCli = async (): Promise<void> => {
29+
export const runVsCodeCli = async (args: DefaultedArgs): Promise<void> => {
3030
logger.debug("Running VS Code CLI")
3131

32-
// Delete `VSCODE_CWD` very early even before
33-
// importing bootstrap files. We have seen
34-
// reports where `code .` would use the wrong
35-
// current working directory due to our variable
36-
// somehow escaping to the parent shell
37-
// (https://github.com/microsoft/vscode/issues/126399)
38-
delete process.env["VSCODE_CWD"]
39-
40-
const bootstrap = require(path.join(vsRootPath, "out", "bootstrap"))
41-
const bootstrapNode = require(path.join(vsRootPath, "out", "bootstrap-node"))
42-
const product = require(path.join(vsRootPath, "product.json"))
43-
44-
// Avoid Monkey Patches from Application Insights
45-
bootstrap.avoidMonkeyPatchFromAppInsights()
46-
47-
// Enable portable support
48-
bootstrapNode.configurePortable(product)
49-
50-
// Enable ASAR support
51-
bootstrap.enableASARSupport()
52-
53-
// Signal processes that we got launched as CLI
54-
process.env["VSCODE_CLI"] = "1"
55-
56-
const cliProcessMain = await loadAMDModule<CodeServerLib.IMainCli["main"]>("vs/code/node/cli", "initialize")
32+
// See ../../vendor/modules/code-oss-dev/src/vs/server/main.js.
33+
const spawnCli = await loadAMDModule<CodeServerLib.SpawnCli>("vs/server/remoteExtensionHostAgent", "spawnCli")
5734

5835
try {
59-
await cliProcessMain(process.argv)
36+
await spawnCli(args)
6037
} catch (error: any) {
6138
logger.error("Got error from VS Code", error)
6239
}

src/node/routes/vscode.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,15 @@ export const createVSServerRouter = async (args: DefaultedArgs): Promise<VSServe
4141
process.env["VSCODE_DEV"] = "1"
4242

4343
const createVSServer = await loadAMDModule<CodeServerLib.CreateServer>(
44-
"vs/server/remoteExtensionHostAgentServer",
44+
"vs/server/remoteExtensionHostAgent",
4545
"createServer",
4646
)
4747

48-
const codeServerMain = await createVSServer(
49-
null,
50-
{
51-
...args,
52-
protocol: args["cert"] || args.link ? "https:" : "http:",
53-
connectionToken: "0000",
54-
},
55-
args["user-data-dir"],
56-
)
48+
const codeServerMain = await createVSServer(null, {
49+
...args,
50+
protocol: args["cert"] || args.link ? "https:" : "http:",
51+
connectionToken: "0000",
52+
})
5753

5854
const router = express.Router()
5955
const wsRouter = WsRouter()

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#57c765fee66863583e48081244e18e7a79ca61a0"
10+
"code-oss-dev": "cdr/vscode#122c0fa63769cf71c5fda4eee156e3c9fb57c3c0"
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#57c765fee66863583e48081244e18e7a79ca61a0:
299+
code-oss-dev@cdr/vscode#122c0fa63769cf71c5fda4eee156e3c9fb57c3c0:
300300
version "1.61.1"
301-
resolved "https://codeload.github.com/cdr/vscode/tar.gz/57c765fee66863583e48081244e18e7a79ca61a0"
301+
resolved "https://codeload.github.com/cdr/vscode/tar.gz/122c0fa63769cf71c5fda4eee156e3c9fb57c3c0"
302302
dependencies:
303303
"@microsoft/applicationinsights-web" "^2.6.4"
304304
"@vscode/sqlite3" "4.0.12"

0 commit comments

Comments
 (0)