From 40778b15ca19178c63ea97c5ae1f93bfb08d466d Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 14 May 2020 21:30:34 -0400 Subject: [PATCH] Add code-server version into VS Code about Closes #1506 --- ci/build/npm-postinstall.sh | 4 ++-- ci/dev/vscode.patch | 37 +++++++++++++++++++++++++++++++++++-- src/node/app/vscode.ts | 2 ++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index 6f0df6a8..171ce824 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -2,8 +2,6 @@ set -eu main() { - cd lib/vscode - case "${npm_config_user_agent-}" in npm*) # We are running under npm. if [ "${npm_config_unsafe_perm-}" != "true" ]; then @@ -16,6 +14,8 @@ main() { ;; esac + cd lib/vscode + # We have to rename node_modules.bundled to node_modules. # The bundled modules were renamed originally to avoid being ignored by yarn. node_modules="$(find . -depth -name "node_modules.bundled")" diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index ac70e7bf..9aa241fc 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -653,6 +653,19 @@ index 87a3b99c70..09e2c93172 100644 } // Node: AMD loader +diff --git a/src/vs/platform/product/common/productService.ts b/src/vs/platform/product/common/productService.ts +index 266aa69fc6..e9b51f5fde 100644 +--- a/src/vs/platform/product/common/productService.ts ++++ b/src/vs/platform/product/common/productService.ts +@@ -25,6 +25,8 @@ export interface IBuiltInExtension { + export type ConfigurationSyncStore = { url: string, authenticationProviders: IStringDictionary<{ scopes: string[] }> }; + + export interface IProductConfiguration { ++ readonly codeServerVersion?: string; ++ + readonly version: string; + readonly date?: string; + readonly quality?: string; diff --git a/src/vs/platform/remote/browser/browserSocketFactory.ts b/src/vs/platform/remote/browser/browserSocketFactory.ts index d0f6e6b18a..1966fd297d 100644 --- a/src/vs/platform/remote/browser/browserSocketFactory.ts @@ -1328,10 +1341,10 @@ index 0000000000..56331ff1fc +require('../../bootstrap-amd').load('vs/server/entry'); diff --git a/src/vs/server/ipc.d.ts b/src/vs/server/ipc.d.ts new file mode 100644 -index 0000000000..d4771351de +index 0000000000..0a9c95d50e --- /dev/null +++ b/src/vs/server/ipc.d.ts -@@ -0,0 +1,116 @@ +@@ -0,0 +1,117 @@ +/** + * External interfaces for integration into code-server over IPC. No vs imports + * should be made in this file. @@ -1434,6 +1447,7 @@ index 0000000000..d4771351de + }; + readonly remoteUserDataUri: UriComponents; + readonly productConfiguration: { ++ codeServerVersion?: string; + readonly extensionsGallery?: { + readonly serviceUrl: string; + readonly itemUrl: string; @@ -3185,6 +3199,25 @@ index f2ca5011dd..4683e80a68 100644 } catch (e) { console.error('Could not rewrite csp'); } +diff --git a/src/vs/workbench/services/dialogs/browser/dialogService.ts b/src/vs/workbench/services/dialogs/browser/dialogService.ts +index 6b42535bff..88b7e3c3ea 100644 +--- a/src/vs/workbench/services/dialogs/browser/dialogService.ts ++++ b/src/vs/workbench/services/dialogs/browser/dialogService.ts +@@ -124,11 +124,12 @@ export class DialogService implements IDialogService { + async about(): Promise { + const detailString = (useAgo: boolean): string => { + return nls.localize('aboutDetail', +- "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}", ++ "code-server: v{4}\n VS Code: v{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', + ); + }; + diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 7ed6e9e21a..223fa72662 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts diff --git a/src/node/app/vscode.ts b/src/node/app/vscode.ts index 9ecdcd80..6dafe6f6 100644 --- a/src/node/app/vscode.ts +++ b/src/node/app/vscode.ts @@ -192,6 +192,8 @@ export class VscodeHttpProvider extends HttpProvider { response.content = response.content.replace(//g, "") } + options.productConfiguration.codeServerVersion = require("../../../package.json").version + response.content = response.content .replace(`"{{REMOTE_USER_DATA_URI}}"`, `'${JSON.stringify(options.remoteUserDataUri)}'`) .replace(`"{{PRODUCT_CONFIGURATION}}"`, `'${JSON.stringify(options.productConfiguration)}'`)