From 5baf16622f0f38fea6595c2719a79b2e44d153fc Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 7 Feb 2020 16:37:59 -0600 Subject: [PATCH] Fix VS Code product configuration not loading --- scripts/build.ts | 71 +++++++++------------------- scripts/vscode.patch | 13 +++-- src/node/vscode/workbench-build.html | 2 +- 3 files changed, 30 insertions(+), 56 deletions(-) diff --git a/scripts/build.ts b/scripts/build.ts index 11f6b479..4088431b 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -172,21 +172,9 @@ class Builder { ]) }) - await this.copyDependencies("code-server", this.rootPath, this.buildPath) - - await this.task("writing final code-server package.json", async () => { - const json = JSON.parse(await fs.readFile(path.join(this.buildPath, "package.json"), "utf8")) - return fs.writeFile( - path.join(this.buildPath, "package.json"), - JSON.stringify( - { - ...json, - commit, - }, - null, - 2 - ) - ) + await this.copyDependencies("code-server", this.rootPath, this.buildPath, { + commit, + version: process.env.VERSION, }) } @@ -214,34 +202,6 @@ class Builder { }) } - const { productJson, packageJson } = await this.task("generating vs code product configuration", async () => { - const merge = async (name: string, json: { [key: string]: string } = {}): Promise<{ [key: string]: string }> => { - return { - ...JSON.parse(await fs.readFile(path.join(this.vscodeSourcePath, `${name}.json`), "utf8")), - ...json, - } - } - - const date = new Date().toISOString() - const [packageJson, productJson] = await Promise.all([merge("package", {}), merge("product", { commit, date })]) - - return { productJson, packageJson } - }) - - await this.task("inserting vs code product configuration", async () => { - const filePath = path.join(this.vscodeSourcePath, "out-build/vs/platform/product/common/product.js") - return fs.writeFile( - filePath, - (await fs.readFile(filePath, "utf8")).replace( - "{ /*BUILD->INSERT_PRODUCT_CONFIGURATION*/}", - JSON.stringify({ - version: packageJson.version, - ...productJson, - }) - ) - ) - }) - const vscodeBuildPath = path.join(this.buildPath, "lib/vscode") await this.task("copying vs code into build directory", async () => { await fs.mkdirp(vscodeBuildPath) @@ -254,14 +214,13 @@ class Builder { ]) }) - await this.copyDependencies("vs code", this.vscodeSourcePath, vscodeBuildPath) - - await this.task("writing final vs code product.json", () => { - return fs.writeFile(path.join(vscodeBuildPath, "product.json"), JSON.stringify(productJson, null, 2)) + await this.copyDependencies("vs code", this.vscodeSourcePath, vscodeBuildPath, { + commit, + date: new Date().toISOString(), }) } - private async copyDependencies(name: string, sourcePath: string, buildPath: string): Promise { + private async copyDependencies(name: string, sourcePath: string, buildPath: string, merge: object): Promise { await this.task(`copying ${name} dependencies`, async () => { return Promise.all( ["node_modules", "package.json", "yarn.lock"].map((fileName) => { @@ -270,6 +229,22 @@ class Builder { ) }) + const fileName = name === "code-server" ? "package" : "product" + await this.task(`writing final ${name} ${fileName}.json`, async () => { + const json = JSON.parse(await fs.readFile(path.join(sourcePath, `${fileName}.json`), "utf8")) + return fs.writeFile( + path.join(buildPath, `${fileName}.json`), + JSON.stringify( + { + ...json, + ...merge, + }, + null, + 2 + ) + ) + }) + if (process.env.MINIFY) { await this.task(`restricting ${name} to production dependencies`, async () => { return util.promisify(cp.exec)("yarn --production --ignore-scripts", { cwd: buildPath }) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 515390e2..05899ce9 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -2108,10 +2108,10 @@ index 0000000000..3c74512192 +} diff --git a/src/vs/server/node/server.ts b/src/vs/server/node/server.ts new file mode 100644 -index 0000000000..81d275a80a +index 0000000000..ac6bbc8e98 --- /dev/null +++ b/src/vs/server/node/server.ts -@@ -0,0 +1,253 @@ +@@ -0,0 +1,252 @@ +import * as net from 'net'; +import * as path from 'path'; +import { Emitter } from 'vs/base/common/event'; @@ -2161,6 +2161,7 @@ index 0000000000..81d275a80a +import { ExtensionEnvironmentChannel, FileProviderChannel, NodeProxyService } from 'vs/server/node/channel'; +import { Connection, ExtensionHostConnection, ManagementConnection } from 'vs/server/node/connection'; +import { TelemetryClient } from 'vs/server/node/insights'; ++import { logger } from 'vs/server/node/logger'; +import { getLocaleFromConfig, getNlsConfiguration } from 'vs/server/node/nls'; +import { Protocol } from 'vs/server/node/protocol'; +import { getUriTransformer } from 'vs/server/node/util'; @@ -2193,11 +2194,9 @@ index 0000000000..81d275a80a + logLevel: getLogLevel(environment), + }, + remoteUserDataUri: transformer.transformOutgoing(URI.file(environment.userDataPath)), -+ productConfiguration: { -+ extensionsGallery: product.extensionsGallery, -+ }, ++ productConfiguration: product, + nlsConfiguration: await getNlsConfiguration(environment.args.locale || await getLocaleFromConfig(environment.userDataPath), environment.userDataPath), -+ commit: product.commit || '', ++ commit: product.commit || 'development', + }; + } + @@ -2222,7 +2221,7 @@ index 0000000000..81d275a80a + + private async connect(message: ConnectionTypeRequest, protocol: Protocol): Promise { + if (product.commit && message.commit !== product.commit) { -+ throw new Error(`Version mismatch (${message.commit} instead of ${product.commit})`); ++ logger.warn(`Version mismatch (${message.commit} instead of ${product.commit})`); + } + + switch (message.desiredConnectionType) { diff --git a/src/node/vscode/workbench-build.html b/src/node/vscode/workbench-build.html index 0005fdae..6a417ce8 100644 --- a/src/node/vscode/workbench-build.html +++ b/src/node/vscode/workbench-build.html @@ -21,7 +21,7 @@ - + -- GitLab