From 5bc26e90cbf17c9e79d5646fd93838fc0082d9ab Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 31 Mar 2022 16:14:03 -0500 Subject: [PATCH] fix: version in about dialog (#5057) * Fix code-server version not appearing in other languages It needs to be separate from the localize call since the language version of that string is used and it will not include a spot for the code-server version. I also moved the "v" so we do not get "vUnknown". * Add code-server version to product configuration Before 1.64 the entire product configuration was sent to the client but that was removed so we have to add anything we want to use on the client, like the code-server version (used in the about dialog). Fixes #5027. * Refresh patches * Change version test to look for specific version This will catch if we are not sending the actual version to the client. --- patches/base-path.diff | 6 +++--- patches/display-language.diff | 2 +- patches/integration.diff | 24 ++++++++++++++++++++---- patches/logout.diff | 2 +- patches/marketplace.diff | 4 ++-- patches/proxy-uri.diff | 2 +- patches/service-worker.diff | 4 ++-- patches/update-check.diff | 2 +- test/e2e/openHelpAbout.test.ts | 7 ++++++- 9 files changed, 37 insertions(+), 16 deletions(-) diff --git a/patches/base-path.diff b/patches/base-path.diff index eb3008eb..9f3be6ed 100644 --- a/patches/base-path.diff +++ b/patches/base-path.diff @@ -185,10 +185,10 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, productConfiguration: >{ + rootEndpoint: base, + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', extensionsGallery: this._webExtensionResourceUrlTemplate ? { - ...this._productService.extensionsGallery, -@@ -290,7 +296,9 @@ export class WebClientServer { +@@ -291,7 +297,9 @@ export class WebClientServer { } : undefined } }))) @@ -199,7 +199,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts const cspDirectives = [ 'default-src \'self\';', -@@ -369,3 +377,70 @@ export class WebClientServer { +@@ -370,3 +378,70 @@ export class WebClientServer { return res.end(data); } } diff --git a/patches/display-language.diff b/patches/display-language.diff index 999c29b1..6bfc0c75 100644 --- a/patches/display-language.diff +++ b/patches/display-language.diff @@ -185,7 +185,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts const data = (await util.promisify(fs.readFile)(filePath)).toString() .replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeAttribute(JSON.stringify({ remoteAuthority, -@@ -302,7 +305,8 @@ export class WebClientServer { +@@ -303,7 +306,8 @@ export class WebClientServer { }))) .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '') .replace(/{{BASE}}/g, base) diff --git a/patches/integration.diff b/patches/integration.diff index 1be03618..d5348f06 100644 --- a/patches/integration.diff +++ b/patches/integration.diff @@ -104,18 +104,22 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandl =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.ts +++ code-server/lib/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.ts -@@ -144,11 +144,12 @@ export class BrowserDialogHandler implem +@@ -143,12 +143,15 @@ export class BrowserDialogHandler implem + async about(): Promise { const detailString = (useAgo: boolean): string => { - return localize('aboutDetail', +- return localize('aboutDetail', - "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}", -+ "code-server: v{4}\nCode: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}", ++ return localize('aboutCodeServerDetail', ++ "code-server: {0}", ++ this.productService.codeServerVersion ? `v${this.productService.codeServerVersion}` : 'Unknown' ++ ) + '\n' + localize('aboutDetail', ++ "Code: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}", this.productService.version || 'Unknown', this.productService.commit || 'Unknown', this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(new Date(this.productService.date), true) + ')' : ''}` : 'Unknown', - navigator.userAgent + navigator.userAgent, -+ this.productService.codeServerVersion || 'Unknown' ); }; @@ -253,3 +257,15 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html +Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts ++++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts +@@ -279,6 +279,7 @@ export class WebClientServer { + developmentOptions: { enableSmokeTestDriver: this._environmentService.driverHandle === 'web' ? true : undefined }, + settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, + productConfiguration: >{ ++ codeServerVersion: this._productService.codeServerVersion, + embedderIdentifier: 'server-distro', + extensionsGallery: this._webExtensionResourceUrlTemplate ? { + ...this._productService.extensionsGallery, diff --git a/patches/logout.diff b/patches/logout.diff index 7bbf73ef..47bb4100 100644 --- a/patches/logout.diff +++ b/patches/logout.diff @@ -45,9 +45,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts rootEndpoint: base, updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, + logoutEndpoint: this._environmentService.args['auth'] ? base + '/logout' : undefined, + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', extensionsGallery: { - ...this._productService.extensionsGallery, Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts diff --git a/patches/marketplace.diff b/patches/marketplace.diff index 17442fc1..77f469f1 100644 --- a/patches/marketplace.diff +++ b/patches/marketplace.diff @@ -32,9 +32,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts +++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts -@@ -286,14 +286,14 @@ export class WebClientServer { - productConfiguration: >{ +@@ -287,14 +287,14 @@ export class WebClientServer { rootEndpoint: base, + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', - extensionsGallery: this._webExtensionResourceUrlTemplate ? { + extensionsGallery: { diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index b46d733d..1227dfaf 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -73,9 +73,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, logoutEndpoint: this._environmentService.args['auth'] ? base + '/logout' : undefined, + proxyEndpointTemplate: base + '/proxy/{{port}}', + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', extensionsGallery: { - ...this._productService.extensionsGallery, Index: code-server/lib/vscode/src/vs/workbench/browser/web.main.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/web.main.ts diff --git a/patches/service-worker.diff b/patches/service-worker.diff index 18cdc6c9..ed12d544 100644 --- a/patches/service-worker.diff +++ b/patches/service-worker.diff @@ -21,9 +21,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts +++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts -@@ -297,6 +297,10 @@ export class WebClientServer { - logoutEndpoint: this._environmentService.args['auth'] ? base + '/logout' : undefined, +@@ -298,6 +298,10 @@ export class WebClientServer { proxyEndpointTemplate: base + '/proxy/{{port}}', + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', + serviceWorker: { + scope: vscodeBase + '/', diff --git a/patches/update-check.diff b/patches/update-check.diff index ccfd39d1..3e4d1dc0 100644 --- a/patches/update-check.diff +++ b/patches/update-check.diff @@ -105,9 +105,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts productConfiguration: >{ rootEndpoint: base, + updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', extensionsGallery: { - ...this._productService.extensionsGallery, Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts diff --git a/test/e2e/openHelpAbout.test.ts b/test/e2e/openHelpAbout.test.ts index 3720828b..74b54c81 100644 --- a/test/e2e/openHelpAbout.test.ts +++ b/test/e2e/openHelpAbout.test.ts @@ -1,3 +1,4 @@ +import { version } from "../../src/node/constants" import { describe, test, expect } from "./baseFixture" describe("Open Help > About", true, [], {}, () => { @@ -5,8 +6,12 @@ describe("Open Help > About", true, [], {}, () => { // Open using the menu. await codeServerPage.navigateMenus(["Help", "About"]) + const isDevMode = process.env.VSCODE_DEV === "1" + // Look for code-server info div. - const element = await codeServerPage.page.waitForSelector('div[role="dialog"] >> text=code-server') + const element = await codeServerPage.page.waitForSelector( + `div[role="dialog"] >> text=code-server: ${isDevMode ? "Unknown" : "v" + version}`, + ) expect(element).not.toBeNull() }) })