Skip to content

Commit 7147725

Browse files
committed
Fix VS Code product configuration not loading
1 parent 2564190 commit 7147725

File tree

3 files changed

+27
-58
lines changed

3 files changed

+27
-58
lines changed

scripts/build.ts

+20-50
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,7 @@ class Builder {
172172
])
173173
})
174174

175-
await this.copyDependencies("code-server", this.rootPath, this.buildPath)
176-
177-
await this.task("writing final code-server package.json", async () => {
178-
const json = JSON.parse(await fs.readFile(path.join(this.buildPath, "package.json"), "utf8"))
179-
return fs.writeFile(
180-
path.join(this.buildPath, "package.json"),
181-
JSON.stringify(
182-
{
183-
...json,
184-
commit,
185-
},
186-
null,
187-
2
188-
)
189-
)
190-
})
175+
await this.copyDependencies("code-server", this.rootPath, this.buildPath, commit)
191176
}
192177

193178
private async buildVscode(commit: string): Promise<void> {
@@ -214,34 +199,6 @@ class Builder {
214199
})
215200
}
216201

217-
const { productJson, packageJson } = await this.task("generating vs code product configuration", async () => {
218-
const merge = async (name: string, json: { [key: string]: string } = {}): Promise<{ [key: string]: string }> => {
219-
return {
220-
...JSON.parse(await fs.readFile(path.join(this.vscodeSourcePath, `${name}.json`), "utf8")),
221-
...json,
222-
}
223-
}
224-
225-
const date = new Date().toISOString()
226-
const [packageJson, productJson] = await Promise.all([merge("package", {}), merge("product", { commit, date })])
227-
228-
return { productJson, packageJson }
229-
})
230-
231-
await this.task("inserting vs code product configuration", async () => {
232-
const filePath = path.join(this.vscodeSourcePath, "out-build/vs/platform/product/common/product.js")
233-
return fs.writeFile(
234-
filePath,
235-
(await fs.readFile(filePath, "utf8")).replace(
236-
"{ /*BUILD->INSERT_PRODUCT_CONFIGURATION*/}",
237-
JSON.stringify({
238-
version: packageJson.version,
239-
...productJson,
240-
})
241-
)
242-
)
243-
})
244-
245202
const vscodeBuildPath = path.join(this.buildPath, "lib/vscode")
246203
await this.task("copying vs code into build directory", async () => {
247204
await fs.mkdirp(vscodeBuildPath)
@@ -254,14 +211,10 @@ class Builder {
254211
])
255212
})
256213

257-
await this.copyDependencies("vs code", this.vscodeSourcePath, vscodeBuildPath)
258-
259-
await this.task("writing final vs code product.json", () => {
260-
return fs.writeFile(path.join(vscodeBuildPath, "product.json"), JSON.stringify(productJson, null, 2))
261-
})
214+
await this.copyDependencies("vs code", this.vscodeSourcePath, vscodeBuildPath, commit)
262215
}
263216

264-
private async copyDependencies(name: string, sourcePath: string, buildPath: string): Promise<void> {
217+
private async copyDependencies(name: string, sourcePath: string, buildPath: string, commit: string): Promise<void> {
265218
await this.task(`copying ${name} dependencies`, async () => {
266219
return Promise.all(
267220
["node_modules", "package.json", "yarn.lock"].map((fileName) => {
@@ -270,6 +223,23 @@ class Builder {
270223
)
271224
})
272225

226+
const fileName = name === "code-server" ? "package" : "product"
227+
await this.task("writing final ${name} ${fileName}.json", async () => {
228+
const json = JSON.parse(await fs.readFile(path.join(sourcePath, `${fileName}.json`), "utf8"))
229+
return fs.writeFile(
230+
path.join(buildPath, `${fileName}.json`),
231+
JSON.stringify(
232+
{
233+
...json,
234+
commit,
235+
date: new Date().toISOString(),
236+
},
237+
null,
238+
2
239+
)
240+
)
241+
})
242+
273243
if (process.env.MINIFY) {
274244
await this.task(`restricting ${name} to production dependencies`, async () => {
275245
return util.promisify(cp.exec)("yarn --production --ignore-scripts", { cwd: buildPath })

scripts/vscode.patch

+6-7
Original file line numberDiff line numberDiff line change
@@ -2108,10 +2108,10 @@ index 0000000000..3c74512192
21082108
+}
21092109
diff --git a/src/vs/server/node/server.ts b/src/vs/server/node/server.ts
21102110
new file mode 100644
2111-
index 0000000000..81d275a80a
2111+
index 0000000000..ac6bbc8e98
21122112
--- /dev/null
21132113
+++ b/src/vs/server/node/server.ts
2114-
@@ -0,0 +1,253 @@
2114+
@@ -0,0 +1,252 @@
21152115
+import * as net from 'net';
21162116
+import * as path from 'path';
21172117
+import { Emitter } from 'vs/base/common/event';
@@ -2161,6 +2161,7 @@ index 0000000000..81d275a80a
21612161
+import { ExtensionEnvironmentChannel, FileProviderChannel, NodeProxyService } from 'vs/server/node/channel';
21622162
+import { Connection, ExtensionHostConnection, ManagementConnection } from 'vs/server/node/connection';
21632163
+import { TelemetryClient } from 'vs/server/node/insights';
2164+
+import { logger } from 'vs/server/node/logger';
21642165
+import { getLocaleFromConfig, getNlsConfiguration } from 'vs/server/node/nls';
21652166
+import { Protocol } from 'vs/server/node/protocol';
21662167
+import { getUriTransformer } from 'vs/server/node/util';
@@ -2193,11 +2194,9 @@ index 0000000000..81d275a80a
21932194
+ logLevel: getLogLevel(environment),
21942195
+ },
21952196
+ remoteUserDataUri: transformer.transformOutgoing(URI.file(environment.userDataPath)),
2196-
+ productConfiguration: {
2197-
+ extensionsGallery: product.extensionsGallery,
2198-
+ },
2197+
+ productConfiguration: product,
21992198
+ nlsConfiguration: await getNlsConfiguration(environment.args.locale || await getLocaleFromConfig(environment.userDataPath), environment.userDataPath),
2200-
+ commit: product.commit || '',
2199+
+ commit: product.commit || 'development',
22012200
+ };
22022201
+ }
22032202
+
@@ -2222,7 +2221,7 @@ index 0000000000..81d275a80a
22222221
+
22232222
+ private async connect(message: ConnectionTypeRequest, protocol: Protocol): Promise<void> {
22242223
+ if (product.commit && message.commit !== product.commit) {
2225-
+ throw new Error(`Version mismatch (${message.commit} instead of ${product.commit})`);
2224+
+ logger.warn(`Version mismatch (${message.commit} instead of ${product.commit})`);
22262225
+ }
22272226
+
22282227
+ switch (message.desiredConnectionType) {

src/node/vscode/workbench-build.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<!-- Workbench Icon/Manifest/CSS -->
2222
<link rel="icon" href="../static-{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
2323
<link rel="manifest" href="../static-{{COMMIT}}/src/browser/media/manifest.json" crossorigin="use-credentials">
24-
<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="../static-{{COMMIT}}/out/vs/workbench/workbench.web.api.css">
24+
<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="./static-{{COMMIT}}/out/vs/workbench/workbench.web.api.css">
2525
<link rel="apple-touch-icon" href="../static-{{COMMIT}}/src/browser/media/code-server.png" />
2626
<meta name="apple-mobile-web-app-capable" content="yes">
2727

0 commit comments

Comments
 (0)