From 10e9ae9bc162b4ff66f12c84cb8bc6de5b5f00ed Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 22:09:26 +0000 Subject: [PATCH 01/49] chore: upgrade Code to 1.66 From a8eb7ebd1bc03cb9d62603a5a9e2546706e08a91 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 22:29:10 +0000 Subject: [PATCH 02/49] docs: update docs for Code upgrades --- docs/CONTRIBUTING.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index eaa4b736a770..7e7269b0a3cb 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,5 +1,6 @@ + # Contributing - [Requirements](#requirements) @@ -96,15 +97,18 @@ re-apply the patches. ### Version updates to Code 1. Update the `lib/vscode` submodule to the desired upstream version branch. -2. Apply the patches (`quilt push -a`) or restore your stashed changes. At this +1. `cd lib/vscode && git checkout release/1.66` +1. `cd ../../ && git submodule update --recursive` +1. `git add lib && git commit -m "chore: update Code"` +1. Apply the patches (`quilt push -a`) or restore your stashed changes. At this stage you may need to resolve conflicts. For example use `quilt push -f`, manually apply the rejected portions, then `quilt refresh`. -3. From the code-server **project root**, run `yarn install`. -4. Test code-server locally to make sure everything works. -5. Check the Node.js version that's used by Electron (which is shipped with VS +1. From the code-server **project root**, run `yarn install`. +1. Test code-server locally to make sure everything works. +1. Check the Node.js version that's used by Electron (which is shipped with VS Code. If necessary, update your version of Node.js to match. -6. Commit the updated submodule and patches to `code-server`. -7. Open a PR. +1. Commit the updated submodule and patches to `code-server`. +1. Open a PR. ### Patching Code From 4b8791613bcf1aa5588e043c4492c47f124d2356 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 22:31:27 +0000 Subject: [PATCH 03/49] fixup!: docs --- docs/CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 7e7269b0a3cb..f399694716d1 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -98,7 +98,6 @@ re-apply the patches. 1. Update the `lib/vscode` submodule to the desired upstream version branch. 1. `cd lib/vscode && git checkout release/1.66` -1. `cd ../../ && git submodule update --recursive` 1. `git add lib && git commit -m "chore: update Code"` 1. Apply the patches (`quilt push -a`) or restore your stashed changes. At this stage you may need to resolve conflicts. For example use `quilt push -f`, From 9c8fbf5f268e26efbf586138e8db997d29ca4a97 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 22:34:30 +0000 Subject: [PATCH 04/49] chore: update vscode submodule --- lib/vscode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vscode b/lib/vscode index c722ca6c7eed..dfd34e8260c2 160000 --- a/lib/vscode +++ b/lib/vscode @@ -1 +1 @@ -Subproject commit c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1 +Subproject commit dfd34e8260c270da74b5c2d86d61aee4b6d56977 From 173932b1387fc5b2af8fa2aed82d2c0423b982bf Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 23:39:40 +0000 Subject: [PATCH 05/49] chore: update integration patch --- patches/integration.diff | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/patches/integration.diff b/patches/integration.diff index d5348f06ae5a..876afef19be2 100644 --- a/patches/integration.diff +++ b/patches/integration.diff @@ -21,8 +21,12 @@ Index: code-server/lib/vscode/src/vs/server/node/server.main.ts import product from 'vs/platform/product/common/product'; import * as perf from 'vs/base/common/performance'; -@@ -33,37 +33,42 @@ const errorReporter: ErrorReporter = { - } +@@ -30,41 +30,46 @@ const errorReporter: ErrorReporter = { + + onDeprecatedOption: (deprecatedOption: string, message) => { + console.warn(`Option '${deprecatedOption}' is deprecated: ${message}`); +- } ++ }, }; -const args = parseArgs(process.argv.slice(2), serverOptions, errorReporter); @@ -34,6 +38,7 @@ Index: code-server/lib/vscode/src/vs/server/node/server.main.ts -const USER_DATA_PATH = join(REMOTE_DATA_FOLDER, 'data'); -const APP_SETTINGS_HOME = join(USER_DATA_PATH, 'User'); -const GLOBAL_STORAGE_HOME = join(APP_SETTINGS_HOME, 'globalStorage'); +-const LOCAL_HISTORY_HOME = join(APP_SETTINGS_HOME, 'History'); -const MACHINE_SETTINGS_HOME = join(USER_DATA_PATH, 'Machine'); -args['user-data-dir'] = USER_DATA_PATH; -const APP_ROOT = dirname(FileAccess.asFileUri('', require).fsPath); @@ -41,7 +46,7 @@ Index: code-server/lib/vscode/src/vs/server/node/server.main.ts -args['builtin-extensions-dir'] = BUILTIN_EXTENSIONS_FOLDER_PATH; -args['extensions-dir'] = args['extensions-dir'] || join(REMOTE_DATA_FOLDER, 'extensions'); - --[REMOTE_DATA_FOLDER, args['extensions-dir'], USER_DATA_PATH, APP_SETTINGS_HOME, MACHINE_SETTINGS_HOME, GLOBAL_STORAGE_HOME].forEach(f => { +-[REMOTE_DATA_FOLDER, args['extensions-dir'], USER_DATA_PATH, APP_SETTINGS_HOME, MACHINE_SETTINGS_HOME, GLOBAL_STORAGE_HOME, LOCAL_HISTORY_HOME].forEach(f => { - try { - if (!fs.existsSync(f)) { - fs.mkdirSync(f, { mode: 0o700 }); @@ -53,6 +58,7 @@ Index: code-server/lib/vscode/src/vs/server/node/server.main.ts + const USER_DATA_PATH = args['user-data-dir'] || join(REMOTE_DATA_FOLDER, 'data'); + const APP_SETTINGS_HOME = join(USER_DATA_PATH, 'User'); + const GLOBAL_STORAGE_HOME = join(APP_SETTINGS_HOME, 'globalStorage'); ++ const LOCAL_HISTORY_HOME = join(APP_SETTINGS_HOME, 'History'); + const MACHINE_SETTINGS_HOME = join(USER_DATA_PATH, 'Machine'); + args['user-data-dir'] = USER_DATA_PATH; + const APP_ROOT = dirname(FileAccess.asFileUri('', require).fsPath); @@ -60,14 +66,14 @@ Index: code-server/lib/vscode/src/vs/server/node/server.main.ts + args['builtin-extensions-dir'] = BUILTIN_EXTENSIONS_FOLDER_PATH; + args['extensions-dir'] = args['extensions-dir'] || join(REMOTE_DATA_FOLDER, 'extensions'); + -+ [REMOTE_DATA_FOLDER, args['extensions-dir'], USER_DATA_PATH, APP_SETTINGS_HOME, MACHINE_SETTINGS_HOME, GLOBAL_STORAGE_HOME].forEach(f => { ++ [REMOTE_DATA_FOLDER, args['extensions-dir'], USER_DATA_PATH, APP_SETTINGS_HOME, MACHINE_SETTINGS_HOME, GLOBAL_STORAGE_HOME, LOCAL_HISTORY_HOME].forEach(f => { + try { + if (!fs.existsSync(f)) { + fs.mkdirSync(f, { mode: 0o700 }); + } + } catch (err) { console.error(err); } + }); -+ return REMOTE_DATA_FOLDER ++ return REMOTE_DATA_FOLDER; +} /** @@ -261,9 +267,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 -@@ -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, +@@ -285,6 +285,7 @@ export class WebClientServer { + folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), + workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']), productConfiguration: >{ + codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', From a34e57c31a97cefb536db66cc91e4174932f6103 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 23:42:09 +0000 Subject: [PATCH 06/49] chore: update node-version patch --- patches/node-version.diff | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/patches/node-version.diff b/patches/node-version.diff index 9ee48e87f4f1..f811d64dbdff 100644 --- a/patches/node-version.diff +++ b/patches/node-version.diff @@ -11,7 +11,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js =================================================================== --- code-server.orig/lib/vscode/build/gulpfile.reh.js +++ code-server/lib/vscode/build/gulpfile.reh.js -@@ -124,9 +124,7 @@ const serverWithWebEntryPoints = [ +@@ -125,9 +125,7 @@ const serverWithWebEntryPoints = [ ]; function getNodeVersion() { @@ -35,7 +35,7 @@ Index: code-server/lib/vscode/build/lib/node.js -const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)[1]; +const version = process.versions.node; const platform = process.platform; - const arch = platform === 'darwin' ? 'x64' : process.arch; + const arch = process.arch; const node = platform === 'win32' ? 'node.exe' : 'node'; Index: code-server/lib/vscode/build/lib/node.ts =================================================================== @@ -51,7 +51,7 @@ Index: code-server/lib/vscode/build/lib/node.ts +const version = process.versions.node; const platform = process.platform; - const arch = platform === 'darwin' ? 'x64' : process.arch; + const arch = process.arch; Index: code-server/lib/vscode/build/lib/util.js =================================================================== --- code-server.orig/lib/vscode/build/lib/util.js @@ -71,7 +71,7 @@ Index: code-server/lib/vscode/build/lib/util.ts =================================================================== --- code-server.orig/lib/vscode/build/lib/util.ts +++ code-server/lib/vscode/build/lib/util.ts -@@ -371,9 +371,7 @@ export function streamToPromise(stream: +@@ -371,9 +371,7 @@ export function streamToPromise(stream: } export function getElectronVersion(): string { @@ -87,21 +87,3 @@ Index: code-server/lib/vscode/build/lib/util.ts return result; } - -Index: code-server/lib/vscode/remote/.yarnrc -=================================================================== ---- code-server.orig/lib/vscode/remote/.yarnrc -+++ /dev/null -@@ -1,4 +0,0 @@ --disturl "http://nodejs.org/dist" --target "14.16.0" --runtime "node" --build_from_source "true" -Index: code-server/lib/vscode/.yarnrc -=================================================================== ---- code-server.orig/lib/vscode/.yarnrc -+++ /dev/null -@@ -1,4 +0,0 @@ --disturl "https://electronjs.org/headers" --target "13.5.2" --runtime "electron" --build_from_source "true" From 557247ac7a51092cc38efe9ec8816786bdfe0b7a Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 23:51:28 +0000 Subject: [PATCH 07/49] chore: update github-auth patch They completely changed how auth is handled for GitHub in https://github.com/microsoft/vscode/pull/145424 so our patch may not work. Will need to test and revisit. --- patches/github-auth.diff | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/patches/github-auth.diff b/patches/github-auth.diff index 9e0af8094c38..2bb388e364a5 100644 --- a/patches/github-auth.diff +++ b/patches/github-auth.diff @@ -5,24 +5,11 @@ Microsoft's does not work with self-hosted instances so we run our own. Also add an extra set of scopes so that tokens provided via --github-auth will work for the PR extension. -Index: code-server/lib/vscode/extensions/github-authentication/src/githubServer.ts -=================================================================== ---- code-server.orig/lib/vscode/extensions/github-authentication/src/githubServer.ts -+++ code-server/lib/vscode/extensions/github-authentication/src/githubServer.ts -@@ -17,7 +17,7 @@ const localize = nls.loadMessageBundle() - const CLIENT_ID = '01ab8ac9400c4e429b23'; - - const NETWORK_ERROR = 'network error'; --const AUTH_RELAY_SERVER = 'vscode-auth.github.com'; -+const AUTH_RELAY_SERVER = 'auth.code-server.dev'; - // const AUTH_RELAY_STAGING_SERVER = 'client-auth-staging-14a768b.herokuapp.com'; - - class UriEventHandler extends vscode.EventEmitter implements vscode.UriHandler { 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 -@@ -274,7 +274,7 @@ export class WebClientServer { +@@ -277,7 +277,7 @@ export class WebClientServer { id: generateUuid(), providerId: 'github', accessToken: this._environmentService.args['github-auth'], From 86ca662ac155b74d92139657e0e7b8956acfc962 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 23:55:58 +0000 Subject: [PATCH 08/49] refactor: remove postinstall patch It appears they renamed postinstall.js to postinstall.mjs and removed the use of `rimraf` which means our patch is no longer needed! :tada: https://github.com/microsoft/vscode/commit/b0e8554cced292871a67748a18926cfd02f4e840 --- patches/series | 1 - 1 file changed, 1 deletion(-) diff --git a/patches/series b/patches/series index 79da7efdaf7b..f7a44e2366b2 100644 --- a/patches/series +++ b/patches/series @@ -12,7 +12,6 @@ proxy-uri.diff display-language.diff github-auth.diff unique-db.diff -post-install.diff log-level.diff local-storage.diff service-worker.diff From eeb57351bbeb05903e88c5e76ca5302e7e4ce7be Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:02:40 +0000 Subject: [PATCH 09/49] chore: refresh local-storage patch --- patches/local-storage.diff | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/local-storage.diff b/patches/local-storage.diff index 4c3c90da16ed..744540bbfafd 100644 --- a/patches/local-storage.diff +++ b/patches/local-storage.diff @@ -20,19 +20,19 @@ 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 -@@ -289,6 +289,7 @@ export class WebClientServer { +@@ -292,6 +292,7 @@ export class WebClientServer { enableSmokeTestDriver: this._environmentService.driverHandle === 'web' ? true : undefined, logLevel: this._logService.getLevel(), }, + userDataPath: this._environmentService.userDataPath, settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, - productConfiguration: >{ - rootEndpoint: base, + enableWorkspaceTrust: !this._environmentService.args['disable-workspace-trust'], + folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts +++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts -@@ -205,6 +205,11 @@ export interface IWorkbenchConstructionO +@@ -210,6 +210,11 @@ export interface IWorkbenchConstructionO */ readonly configurationDefaults?: Record; @@ -52,7 +52,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi get logFile(): URI { return joinPath(this.logsHome, 'window.log'); } @memoize -- get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.userData }); } +- get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.vscodeUserData }); } + get userRoamingDataHome(): URI { return joinPath(URI.file(this.userDataPath).with({ scheme: Schemas.vscodeRemote }), 'User'); } + + get userDataPath(): string { From ed378492d695a340ca8fbc2f662cc755d810719a Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:03:26 +0000 Subject: [PATCH 10/49] chore: refresh service-worker patch --- patches/service-worker.diff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/service-worker.diff b/patches/service-worker.diff index ed12d54494a4..db2bacd22ef1 100644 --- a/patches/service-worker.diff +++ b/patches/service-worker.diff @@ -21,7 +21,7 @@ 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 -@@ -298,6 +298,10 @@ export class WebClientServer { +@@ -304,6 +304,10 @@ export class WebClientServer { proxyEndpointTemplate: base + '/proxy/{{port}}', codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', From 40ba2b915dd21fc45c297ee4ec1c34b9406caf50 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:05:50 +0000 Subject: [PATCH 11/49] chore: bulk refresh patches --- patches/base-path.diff | 14 +++++++------- patches/disable-downloads.diff | 14 +++++++------- patches/display-language.diff | 14 +++++++------- patches/log-level.diff | 6 +++--- patches/logout.diff | 4 ++-- patches/marketplace.diff | 2 +- patches/proposed-api.diff | 4 ++-- patches/proxy-uri.diff | 4 ++-- patches/sourcemaps.diff | 6 +++--- patches/update-check.diff | 6 +++--- patches/webview.diff | 6 +++--- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/patches/base-path.diff b/patches/base-path.diff index c7d032b1810c..95bb8388eb78 100644 --- a/patches/base-path.diff +++ b/patches/base-path.diff @@ -159,7 +159,7 @@ 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 -@@ -252,7 +252,10 @@ export class WebClientServer { +@@ -253,7 +253,10 @@ export class WebClientServer { return res.end(); } @@ -171,7 +171,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts function escapeAttribute(value: string): string { return value.replace(/"/g, '"'); -@@ -272,6 +275,8 @@ export class WebClientServer { +@@ -275,6 +278,8 @@ export class WebClientServer { accessToken: this._environmentService.args['github-auth'], scopes: [['user:email'], ['repo']] } : undefined; @@ -180,15 +180,15 @@ 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, -@@ -279,6 +284,7 @@ export class WebClientServer { - developmentOptions: { enableSmokeTestDriver: this._environmentService.driverHandle === 'web' ? true : undefined }, - settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, +@@ -285,6 +290,7 @@ export class WebClientServer { + folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), + workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']), productConfiguration: >{ + rootEndpoint: base, codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', extensionsGallery: this._webExtensionResourceUrlTemplate ? { -@@ -291,7 +297,9 @@ export class WebClientServer { +@@ -297,7 +303,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\';', -@@ -370,3 +378,70 @@ export class WebClientServer { +@@ -376,3 +384,70 @@ export class WebClientServer { return res.end(data); } } diff --git a/patches/disable-downloads.diff b/patches/disable-downloads.diff index 3c4b87da9102..7568fcd0b6e5 100644 --- a/patches/disable-downloads.diff +++ b/patches/disable-downloads.diff @@ -12,7 +12,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts +++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts -@@ -210,6 +210,11 @@ export interface IWorkbenchConstructionO +@@ -215,6 +215,11 @@ export interface IWorkbenchConstructionO */ readonly userDataPath?: string @@ -66,7 +66,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts /* ----- server setup ----- */ -@@ -92,6 +93,7 @@ export interface ServerParsedArgs { +@@ -96,6 +97,7 @@ export interface ServerParsedArgs { 'disable-update-check'?: boolean; 'auth'?: string 'locale'?: string @@ -78,14 +78,14 @@ 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 -@@ -290,6 +290,7 @@ export class WebClientServer { +@@ -293,6 +293,7 @@ export class WebClientServer { logLevel: this._logService.getLevel(), }, userDataPath: this._environmentService.userDataPath, + isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'], settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, - productConfiguration: >{ - rootEndpoint: base, + enableWorkspaceTrust: !this._environmentService.args['disable-workspace-trust'], + folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts @@ -135,7 +135,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts +++ code-server/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts -@@ -21,7 +21,7 @@ import { CLOSE_SAVED_EDITORS_COMMAND_ID, +@@ -22,7 +22,7 @@ import { CLOSE_SAVED_EDITORS_COMMAND_ID, import { AutoSaveAfterShortDelayContext } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService'; import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService'; import { Schemas } from 'vs/base/common/network'; @@ -144,7 +144,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ThemeIcon } from 'vs/platform/theme/common/themeService'; -@@ -475,13 +475,16 @@ MenuRegistry.appendMenuItem(MenuId.Explo +@@ -476,13 +476,16 @@ MenuRegistry.appendMenuItem(MenuId.Explo id: DOWNLOAD_COMMAND_ID, title: DOWNLOAD_LABEL }, diff --git a/patches/display-language.diff b/patches/display-language.diff index 6bfc0c75d969..aad709545fb5 100644 --- a/patches/display-language.diff +++ b/patches/display-language.diff @@ -6,7 +6,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/serverServices.ts +++ code-server/lib/vscode/src/vs/server/node/serverServices.ts -@@ -188,6 +188,9 @@ export async function setupServerService +@@ -192,6 +192,9 @@ export async function setupServerService const channel = new ExtensionManagementChannel(extensionManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority)); socketServer.registerChannel('extensions', channel); @@ -94,7 +94,7 @@ Index: code-server/lib/vscode/src/vs/platform/environment/common/environmentServ =================================================================== --- code-server.orig/lib/vscode/src/vs/platform/environment/common/environmentService.ts +++ code-server/lib/vscode/src/vs/platform/environment/common/environmentService.ts -@@ -105,7 +105,7 @@ export abstract class AbstractNativeEnvi +@@ -108,7 +108,7 @@ export abstract class AbstractNativeEnvi return URI.file(join(vscodePortable, 'argv.json')); } @@ -168,7 +168,7 @@ 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 -@@ -26,6 +26,7 @@ import { URI } from 'vs/base/common/uri' +@@ -27,6 +27,7 @@ import { URI } from 'vs/base/common/uri' import { streamToBuffer } from 'vs/base/common/buffer'; import { IProductConfiguration } from 'vs/base/common/product'; import { isString } from 'vs/base/common/types'; @@ -176,7 +176,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts const textMimeType = { '.html': 'text/html', -@@ -277,6 +278,8 @@ export class WebClientServer { +@@ -280,6 +281,8 @@ export class WebClientServer { } : undefined; const base = relativeRoot(getOriginalUrl(req)) const vscodeBase = relativePath(getOriginalUrl(req)) @@ -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, -@@ -303,7 +306,8 @@ export class WebClientServer { +@@ -309,7 +312,8 @@ export class WebClientServer { }))) .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '') .replace(/{{BASE}}/g, base) @@ -207,7 +207,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts /* ----- server setup ----- */ -@@ -90,6 +91,7 @@ export interface ServerParsedArgs { +@@ -94,6 +95,7 @@ export interface ServerParsedArgs { /* ----- code-server ----- */ 'disable-update-check'?: boolean; 'auth'?: string @@ -252,7 +252,7 @@ Index: code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/workbench.web.main.ts +++ code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts -@@ -111,6 +111,10 @@ registerSingleton(IDiagnosticsService, N +@@ -112,6 +112,10 @@ registerSingleton(IDiagnosticsService, N //#region --- workbench contributions diff --git a/patches/log-level.diff b/patches/log-level.diff index ce99f08be7f8..8b4f125b5d43 100644 --- a/patches/log-level.diff +++ b/patches/log-level.diff @@ -7,7 +7,7 @@ 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 -@@ -285,7 +285,10 @@ export class WebClientServer { +@@ -288,7 +288,10 @@ export class WebClientServer { remoteAuthority, webviewEndpoint: vscodeBase + '/static/out/vs/workbench/contrib/webview/browser/pre', _wrapWebWorkerExtHostInIframe, @@ -17,5 +17,5 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts + logLevel: this._logService.getLevel(), + }, settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, - productConfiguration: >{ - rootEndpoint: base, + enableWorkspaceTrust: !this._environmentService.args['disable-workspace-trust'], + folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), diff --git a/patches/logout.diff b/patches/logout.diff index 47bb410023fb..1a8d0f00567b 100644 --- a/patches/logout.diff +++ b/patches/logout.diff @@ -28,7 +28,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts /* ----- server setup ----- */ -@@ -88,6 +89,7 @@ export const serverOptions: OptionDescri +@@ -92,6 +93,7 @@ export const serverOptions: OptionDescri export interface ServerParsedArgs { /* ----- code-server ----- */ 'disable-update-check'?: boolean; @@ -40,7 +40,7 @@ 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 -@@ -287,6 +287,7 @@ export class WebClientServer { +@@ -293,6 +293,7 @@ export class WebClientServer { productConfiguration: >{ rootEndpoint: base, updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, diff --git a/patches/marketplace.diff b/patches/marketplace.diff index 77f469f10c36..d6e799756320 100644 --- a/patches/marketplace.diff +++ b/patches/marketplace.diff @@ -32,7 +32,7 @@ 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 -@@ -287,14 +287,14 @@ export class WebClientServer { +@@ -293,14 +293,14 @@ export class WebClientServer { rootEndpoint: base, codeServerVersion: this._productService.codeServerVersion, embedderIdentifier: 'server-distro', diff --git a/patches/proposed-api.diff b/patches/proposed-api.diff index 5971d714ec73..ebd5deb57569 100644 --- a/patches/proposed-api.diff +++ b/patches/proposed-api.diff @@ -9,7 +9,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensions/common/abstra =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.ts +++ code-server/lib/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.ts -@@ -1163,7 +1163,7 @@ class ProposedApiController { +@@ -1471,7 +1471,7 @@ class ProposedApiController { this._envEnabledExtensions = new Set((_environmentService.extensionEnabledProposedApi ?? []).map(id => ExtensionIdentifier.toKey(id))); @@ -22,7 +22,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensions/common/extens =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/services/extensions/common/extensions.ts +++ code-server/lib/vscode/src/vs/workbench/services/extensions/common/extensions.ts -@@ -134,10 +134,7 @@ export interface IExtensionHost { +@@ -163,10 +163,7 @@ export interface IExtensionHost { } export function isProposedApiEnabled(extension: IExtensionDescription, proposal: ApiProposalName): boolean { diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index 1227dfaf9a9a..b153b20df00d 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -68,7 +68,7 @@ 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 -@@ -288,6 +288,7 @@ export class WebClientServer { +@@ -294,6 +294,7 @@ export class WebClientServer { rootEndpoint: base, updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, logoutEndpoint: this._environmentService.args['auth'] ? base + '/logout' : undefined, @@ -93,7 +93,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/terminalE =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts +++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts -@@ -390,7 +390,7 @@ export function createTerminalEnvironmen +@@ -388,7 +388,7 @@ export function createTerminalEnvironmen // Sanitize the environment, removing any undesirable VS Code and Electron environment // variables diff --git a/patches/sourcemaps.diff b/patches/sourcemaps.diff index cb2367e6a0f3..0c2e11116a87 100644 --- a/patches/sourcemaps.diff +++ b/patches/sourcemaps.diff @@ -10,7 +10,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js =================================================================== --- code-server.orig/lib/vscode/build/gulpfile.reh.js +++ code-server/lib/vscode/build/gulpfile.reh.js -@@ -197,8 +197,7 @@ function packageTask(type, platform, arc +@@ -189,8 +189,7 @@ function packageTask(type, platform, arc const src = gulp.src(sourceFolderName + '/**', { base: '.' }) .pipe(rename(function (path) { path.dirname = path.dirname.replace(new RegExp('^' + sourceFolderName), 'out'); })) @@ -20,7 +20,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js const workspaceExtensionPoints = ['debuggers', 'jsonValidation']; const isUIExtension = (manifest) => { -@@ -237,9 +236,9 @@ function packageTask(type, platform, arc +@@ -229,9 +228,9 @@ function packageTask(type, platform, arc .map(name => `.build/extensions/${name}/**`); const extensions = gulp.src(extensionPaths, { base: '.build', dot: true }); @@ -32,7 +32,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js let version = packageJson.version; const quality = product.quality; -@@ -374,7 +373,7 @@ function tweakProductForServerWeb(produc +@@ -366,7 +365,7 @@ function tweakProductForServerWeb(produc const minifyTask = task.define(`minify-vscode-${type}`, task.series( optimizeTask, util.rimraf(`out-vscode-${type}-min`), diff --git a/patches/update-check.diff b/patches/update-check.diff index 3e4d1dc09a52..4c11dcaef51d 100644 --- a/patches/update-check.diff +++ b/patches/update-check.diff @@ -100,8 +100,8 @@ 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,6 +286,7 @@ export class WebClientServer { - settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, +@@ -292,6 +292,7 @@ export class WebClientServer { + workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']), productConfiguration: >{ rootEndpoint: base, + updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, @@ -121,7 +121,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts /* ----- server setup ----- */ -@@ -84,6 +86,8 @@ export const serverOptions: OptionDescri +@@ -88,6 +90,8 @@ export const serverOptions: OptionDescri }; export interface ServerParsedArgs { diff --git a/patches/webview.diff b/patches/webview.diff index a4506b03b975..f8ecc65ebeee 100644 --- a/patches/webview.diff +++ b/patches/webview.diff @@ -21,7 +21,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts +++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts -@@ -176,7 +176,7 @@ export class BrowserWorkbenchEnvironment +@@ -179,7 +179,7 @@ export class BrowserWorkbenchEnvironment @memoize get webviewExternalEndpoint(): string { @@ -34,7 +34,7 @@ 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 -@@ -280,6 +280,7 @@ export class WebClientServer { +@@ -283,6 +283,7 @@ export class WebClientServer { const data = (await util.promisify(fs.readFile)(filePath)).toString() .replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeAttribute(JSON.stringify({ remoteAuthority, @@ -46,7 +46,7 @@ Index: code-server/lib/vscode/src/vs/workbench/common/webview.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/common/webview.ts +++ code-server/lib/vscode/src/vs/workbench/common/webview.ts -@@ -24,7 +24,7 @@ export const webviewResourceBaseHost = ' +@@ -22,7 +22,7 @@ export const webviewResourceBaseHost = ' export const webviewRootResourceAuthority = `vscode-resource.${webviewResourceBaseHost}`; From 8a6608aaebe5ed440ab90c18e28544513a720b7f Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:06:49 +0000 Subject: [PATCH 12/49] fixup!: docs formatting --- docs/CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index f399694716d1..527524b34745 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,6 +1,5 @@ - # Contributing - [Requirements](#requirements) From afc702e4752ef8542171b0d33c9a48d09e25f892 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:17:18 +0000 Subject: [PATCH 13/49] refactor: remove unused last-opened patch --- patches/last-opened.diff | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 patches/last-opened.diff diff --git a/patches/last-opened.diff b/patches/last-opened.diff deleted file mode 100644 index 71a1c9980db1..000000000000 --- a/patches/last-opened.diff +++ /dev/null @@ -1,8 +0,0 @@ -Remove last opened functionality - -This conflicts with our own handling of the last opened workspace. If we wanted -to switch to this we would need to pass through the disable-last-opened flag and -respect it here then remove our own redirction code that handles this. - -Our version might be better anyway since it puts the workspace in the URL. - From a0c0ea275130fea568d254b83247c370d5536e1f Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:31:55 +0000 Subject: [PATCH 14/49] fixup!: formatting docs --- docs/CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 527524b34745..805ae5c28d71 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -96,8 +96,8 @@ re-apply the patches. ### Version updates to Code 1. Update the `lib/vscode` submodule to the desired upstream version branch. -1. `cd lib/vscode && git checkout release/1.66` -1. `git add lib && git commit -m "chore: update Code"` + 1. `cd lib/vscode && git checkout release/1.66` + 1. `git add lib && git commit -m "chore: update Code"` 1. Apply the patches (`quilt push -a`) or restore your stashed changes. At this stage you may need to resolve conflicts. For example use `quilt push -f`, manually apply the rejected portions, then `quilt refresh`. From 4c79c9a5e77fc9ff1314f3c235bd0e8df50779d0 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:33:13 +0000 Subject: [PATCH 15/49] fixup!: formatting docs --- docs/CONTRIBUTING.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 805ae5c28d71..e04788f12543 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -97,16 +97,16 @@ re-apply the patches. 1. Update the `lib/vscode` submodule to the desired upstream version branch. 1. `cd lib/vscode && git checkout release/1.66` - 1. `git add lib && git commit -m "chore: update Code"` -1. Apply the patches (`quilt push -a`) or restore your stashed changes. At this + 2. `git add lib && git commit -m "chore: update Code"` +2. Apply the patches (`quilt push -a`) or restore your stashed changes. At this stage you may need to resolve conflicts. For example use `quilt push -f`, manually apply the rejected portions, then `quilt refresh`. -1. From the code-server **project root**, run `yarn install`. -1. Test code-server locally to make sure everything works. -1. Check the Node.js version that's used by Electron (which is shipped with VS +3. From the code-server **project root**, run `yarn install`. +4. Test code-server locally to make sure everything works. +5. Check the Node.js version that's used by Electron (which is shipped with VS Code. If necessary, update your version of Node.js to match. -1. Commit the updated submodule and patches to `code-server`. -1. Open a PR. +6. Commit the updated submodule and patches to `code-server`. +7. Open a PR. ### Patching Code From 8d6b613e9d779ba18d0297710614516cde108bcf Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 18:47:43 +0000 Subject: [PATCH 16/49] refactor: remove rsync postinstall --- ci/build/build-release.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index 07a879c28441..bafa81055ec9 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -146,7 +146,6 @@ EOF # Include global extension dependencies as well. rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json" rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions/yarn.lock" - rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions/postinstall.js" pushd "$VSCODE_OUT_PATH" symlink_asar From a5225d3e06ccce0a2f19cc9c5e985fa3f02a1914 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 20:12:58 +0000 Subject: [PATCH 17/49] Revert "refactor: remove rsync postinstall" This reverts commit 8d6b613e9d779ba18d0297710614516cde108bcf. --- ci/build/build-release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index bafa81055ec9..07a879c28441 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -146,6 +146,7 @@ EOF # Include global extension dependencies as well. rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json" rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions/yarn.lock" + rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions/postinstall.js" pushd "$VSCODE_OUT_PATH" symlink_asar From 202630dc19766e89858b0da0f2b8658bbc8de494 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 20:13:22 +0000 Subject: [PATCH 18/49] refactor: update postinstall.js to .mjs --- ci/build/build-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index 07a879c28441..e484b251888d 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -146,7 +146,7 @@ EOF # Include global extension dependencies as well. rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json" rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions/yarn.lock" - rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions/postinstall.js" + rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs" pushd "$VSCODE_OUT_PATH" symlink_asar From 5e98158c8bc70df7e84f6282b3ea17aa8c91c649 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 27 Apr 2022 16:09:46 -0700 Subject: [PATCH 19/49] feat(patches): add parent-origin bypass --- patches/parent-origin.diff | 25 +++++++++++++++++++++++++ patches/series | 1 + 2 files changed, 26 insertions(+) create mode 100644 patches/parent-origin.diff diff --git a/patches/parent-origin.diff b/patches/parent-origin.diff new file mode 100644 index 000000000000..c28e8b8c3d43 --- /dev/null +++ b/patches/parent-origin.diff @@ -0,0 +1,25 @@ +Remove parentOriginHash checko + +This fixes webviews from not working properly due to a change upstream. +Upstream added a check to ensure parent authority is encoded into the webview +origin. Since our webview origin is the parent authority, we can bypass this +check. + +Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js +=================================================================== +--- code-server.orig/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js ++++ code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js +@@ -339,12 +339,7 @@ const hostMessaging = new class HostMess + throw err instanceof Error ? err : new Error(String(err)); + } + +- if (hostname === parentOriginHash || hostname.startsWith(parentOriginHash + '.')) { +- // validation succeeded! +- return start(parentOrigin); +- } +- +- throw new Error(`Expected '${parentOriginHash}' as hostname or subdomain!`); ++ return start(parentOrigin); + } + }(); + diff --git a/patches/series b/patches/series index f7a44e2366b2..2216e27a4726 100644 --- a/patches/series +++ b/patches/series @@ -18,3 +18,4 @@ service-worker.diff connection-type.diff sourcemaps.diff disable-downloads.diff +parent-origin.diff From 013934dcb568d4006ca697904d37cfd95e1c012c Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 28 Apr 2022 09:35:29 -0700 Subject: [PATCH 20/49] docs(patches): add notes for testing store-socket --- patches/store-socket.diff | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/patches/store-socket.diff b/patches/store-socket.diff index 2bc60652c61a..5aa40ec6422c 100644 --- a/patches/store-socket.diff +++ b/patches/store-socket.diff @@ -3,6 +3,12 @@ Store a static reference to the IPC socket This lets us use it to open files inside code-server from outside of code-server. +To test this: +1. run code-server +2. open file outside of code-server i.e. `code-server Date: Thu, 28 Apr 2022 09:51:51 -0700 Subject: [PATCH 21/49] docs(patches): update testing info for node-version --- patches/node-version.diff | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/patches/node-version.diff b/patches/node-version.diff index f811d64dbdff..2779356ba19e 100644 --- a/patches/node-version.diff +++ b/patches/node-version.diff @@ -4,8 +4,12 @@ Previously it would use the yarnrc which results in builds that cannot run with the version of Node they were built with because the native modules are targeting the wrong version. -One way test this is to build in a fresh Docker container, run the build, then -try opening the built-in terminal. +To test this: + +1. build fresh Coder workspace +2. clone code-server +3. `yarn watch` +4. test built-in terminal Index: code-server/lib/vscode/build/gulpfile.reh.js =================================================================== From 31a354a34345309fadc475491b392d7601e51a32 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 28 Apr 2022 12:39:39 -0700 Subject: [PATCH 22/49] refactor(patches): delete github-auth.diff patch --- patches/series | 1 - 1 file changed, 1 deletion(-) diff --git a/patches/series b/patches/series index 2216e27a4726..be0936fce6f2 100644 --- a/patches/series +++ b/patches/series @@ -10,7 +10,6 @@ logout.diff store-socket.diff proxy-uri.diff display-language.diff -github-auth.diff unique-db.diff log-level.diff local-storage.diff From 35a18197e022c18a4b27697de712999f35ad3717 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 28 Apr 2022 16:50:27 -0700 Subject: [PATCH 23/49] docs(patches): add notes for testing connection-type --- patches/connection-type.diff | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/patches/connection-type.diff b/patches/connection-type.diff index 9f04bc29918d..2011a7862342 100644 --- a/patches/connection-type.diff +++ b/patches/connection-type.diff @@ -4,12 +4,18 @@ This allows the backend to distinguish them. In our case we use them to count a single "open" of Code so we need to be able to distinguish between web sockets from two instances and two web sockets used in a single instance. +To test this, +1. Run code-server +2. Open Network tab in Browser DevTools and look for websocket requests +3. You should see the connection type in the request url + + Index: code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts +++ code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts @@ -231,7 +231,7 @@ async function connectToRemoteExtensionH - + let socket: ISocket; try { - socket = await createSocket(options.logService, options.socketFactory, options.host, options.port, `reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`, `renderer-${connectionTypeToString(connectionType)}-${options.reconnectionToken}`, timeoutCancellationToken); From bdeb5212e8c7be6cadd109941b486a4bcdae69fa Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 28 Apr 2022 16:56:21 -0700 Subject: [PATCH 24/49] fixup!: delete github-auth patch --- patches/github-auth.diff | 105 --------------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 patches/github-auth.diff diff --git a/patches/github-auth.diff b/patches/github-auth.diff deleted file mode 100644 index 2bb388e364a5..000000000000 --- a/patches/github-auth.diff +++ /dev/null @@ -1,105 +0,0 @@ -Use our own GitHub auth relay server - -Microsoft's does not work with self-hosted instances so we run our own. - -Also add an extra set of scopes so that tokens provided via --github-auth will -work for the PR extension. - -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 -@@ -277,7 +277,7 @@ export class WebClientServer { - id: generateUuid(), - providerId: 'github', - accessToken: this._environmentService.args['github-auth'], -- scopes: [['user:email'], ['repo']] -+ scopes: [['read:user', 'user:email', 'repo'], ['user:email'], ['repo']] - } : undefined; - const base = relativeRoot(getOriginalUrl(req)) - const vscodeBase = relativePath(getOriginalUrl(req)) -Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts -=================================================================== ---- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts -+++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts -@@ -17,6 +17,7 @@ import { isFolderToOpen, isWorkspaceToOp - import { create, ICredentialsProvider, IURLCallbackProvider, IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from 'vs/workbench/workbench.web.main'; - import { posix } from 'vs/base/common/path'; - import { ltrim } from 'vs/base/common/strings'; -+import { equals as arrayEquals } from 'vs/base/common/arrays'; - - interface ICredential { - service: string; -@@ -24,6 +25,13 @@ interface ICredential { - password: string; - } - -+interface IToken { -+ accessToken: string -+ account?: { label: string } -+ id: string -+ scopes: string[] -+} -+ - class LocalStorageCredentialsProvider implements ICredentialsProvider { - - private static readonly CREDENTIALS_STORAGE_KEY = 'credentials.provider'; -@@ -51,6 +59,58 @@ class LocalStorageCredentialsProvider im - scopes, - accessToken: authSessionInfo!.accessToken - })))); -+ -+ // Add tokens for extensions to use. This works for extensions like the -+ // pull requests one or GitLens. -+ const extensionId = `vscode.${authSessionInfo.providerId}-authentication`; -+ const service = `${product.urlProtocol}${extensionId}`; -+ const account = `${authSessionInfo.providerId}.auth`; -+ // Oddly the scopes need to match exactly so we cannot just have one token -+ // with all the scopes, instead we have to duplicate the token for each -+ // expected set of scopes. -+ const tokens: IToken[] = authSessionInfo.scopes.map((scopes) => ({ -+ id: authSessionInfo!.id, -+ scopes: scopes.sort(), // Sort for comparing later. -+ accessToken: authSessionInfo!.accessToken, -+ })); -+ this.getPassword(service, account).then((raw) => { -+ let existing: { -+ content: IToken[] -+ } | undefined; -+ -+ if (raw) { -+ try { -+ const json = JSON.parse(raw); -+ json.content = JSON.parse(json.content); -+ existing = json; -+ } catch (error) { -+ console.log(error); -+ } -+ } -+ -+ // Keep tokens for account and scope combinations we do not have in case -+ // there is an extension that uses scopes we have not accounted for (in -+ // these cases the user will need to manually authenticate the extension -+ // through the UI) or the user has tokens for other accounts. -+ if (existing?.content) { -+ existing.content = existing.content.filter((existingToken) => { -+ const scopes = existingToken.scopes.sort(); -+ return !(tokens.find((token) => { -+ return arrayEquals(scopes, token.scopes) -+ && token.account?.label === existingToken.account?.label; -+ })) -+ }) -+ } -+ -+ return this.setPassword(service, account, JSON.stringify({ -+ extensionId, -+ ...(existing || {}), -+ content: JSON.stringify([ -+ ...tokens, -+ ...(existing?.content || []), -+ ]) -+ })); -+ }) - } - } - From c6e67f7a3e0275090bfb2f18df021d81510d979e Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 09:58:05 -0700 Subject: [PATCH 25/49] fixup!: update connection type testing --- patches/connection-type.diff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/connection-type.diff b/patches/connection-type.diff index 2011a7862342..050715c90ff5 100644 --- a/patches/connection-type.diff +++ b/patches/connection-type.diff @@ -6,8 +6,8 @@ from two instances and two web sockets used in a single instance. To test this, 1. Run code-server -2. Open Network tab in Browser DevTools and look for websocket requests -3. You should see the connection type in the request url +2. Open Network tab in Browser DevTools and filter for websocket requests +3. You should see the `type=` in the request url Index: code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts From d7a04476c1a2412a2f514be41868fdb43cbaa41e Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 10:37:04 -0700 Subject: [PATCH 26/49] docs(patches): add notes to insecure-notification.diff --- patches/insecure-notification.diff | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/patches/insecure-notification.diff b/patches/insecure-notification.diff index bc94e24b4644..1018360380d7 100644 --- a/patches/insecure-notification.diff +++ b/patches/insecure-notification.diff @@ -5,7 +5,12 @@ may think code-server is broken. Ideally there would be a notification at the point where these things are used instead of this though. To test access over something like an HTTP domain or an IP address (not -localhost). +localhost). For example: + +1. run code-server +2. use ngrok to expose code-server +3. access via HTTP +4. look for notification in bottom right Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts =================================================================== @@ -15,7 +20,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts import { Disposable } from 'vs/base/common/lifecycle'; +import { localize } from 'vs/nls'; +import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; - + export class CodeServerClient extends Disposable { constructor ( + @INotificationService private notificationService: INotificationService, From cf855aede59a184ea410aeb55eee92b8a6d5f23b Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 10:40:13 -0700 Subject: [PATCH 27/49] docs(patches): add nots for update-check.diff --- patches/update-check.diff | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/patches/update-check.diff b/patches/update-check.diff index 4c11dcaef51d..c36871094f81 100644 --- a/patches/update-check.diff +++ b/patches/update-check.diff @@ -3,6 +3,11 @@ Add a notification that lets you know when an update is out The easiest way to test this is probably to change the version in your package.json and delete the last notification storage item. +1. change version in root `package.json` +2. Open DevTools > Application > Storage (top-level) +3. Click "Clear site data" +4. See update notification + Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts @@ -14,7 +19,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; +import { IProductService } from 'vs/platform/product/common/productService'; +import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; - + export class CodeServerClient extends Disposable { constructor ( + @ILogService private logService: ILogService, @@ -93,7 +98,7 @@ Index: code-server/lib/vscode/src/vs/base/common/product.ts readonly codeServerVersion?: string readonly rootEndpoint?: string + readonly updateEndpoint?: string - + readonly version: string; readonly date?: string; Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts @@ -114,19 +119,19 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts +++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts @@ -11,6 +11,8 @@ import { refineServiceDecorator } from ' import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; - + export const serverOptions: OptionDescriptions = { + /* ----- code-server ----- */ + 'disable-update-check': { type: 'boolean' }, - + /* ----- server setup ----- */ - + @@ -88,6 +90,8 @@ export const serverOptions: OptionDescri }; - + export interface ServerParsedArgs { + /* ----- code-server ----- */ + 'disable-update-check'?: boolean; - + /* ----- server setup ----- */ - + From 5ef2c2733fcd22e2591c1402a2ee6b027de7b468 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 15:55:57 -0700 Subject: [PATCH 28/49] fixup!: remove comma in integration patch --- patches/integration.diff | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/patches/integration.diff b/patches/integration.diff index 876afef19be2..e8c1972383dd 100644 --- a/patches/integration.diff +++ b/patches/integration.diff @@ -21,12 +21,8 @@ Index: code-server/lib/vscode/src/vs/server/node/server.main.ts import product from 'vs/platform/product/common/product'; import * as perf from 'vs/base/common/performance'; -@@ -30,41 +30,46 @@ const errorReporter: ErrorReporter = { - - onDeprecatedOption: (deprecatedOption: string, message) => { - console.warn(`Option '${deprecatedOption}' is deprecated: ${message}`); -- } -+ }, +@@ -33,38 +33,43 @@ const errorReporter: ErrorReporter = { + } }; -const args = parseArgs(process.argv.slice(2), serverOptions, errorReporter); From f779d85431a62b16e01d695aaaa377415be2b4d9 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 16:11:42 -0700 Subject: [PATCH 29/49] fix(e2e): disable workspace trust --- test/e2e/models/CodeServer.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/e2e/models/CodeServer.ts b/test/e2e/models/CodeServer.ts index 53e2208d270b..8b3c4a4afd62 100644 --- a/test/e2e/models/CodeServer.ts +++ b/test/e2e/models/CodeServer.ts @@ -81,6 +81,9 @@ export class CodeServer { path.join(dir, "User/settings.json"), JSON.stringify({ "workbench.startupEditor": "none", + // NOTE@jsjoeio - needed to prevent Trust Policy prompt + // in end-to-end tests. + "security.workspace.trust.enabled": false, }), "utf8", ) From 7579dbbb06ba6c4b9a3e9ad94cdccfde15fcb5c7 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 16:44:22 -0700 Subject: [PATCH 30/49] refactor: add --no-default-rc for yarn install --- ci/build/npm-postinstall.sh | 2 +- ci/dev/postinstall.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index fd437a65228d..c3ef085bb526 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -92,7 +92,7 @@ symlink_asar() { vscode_yarn() { echo 'Installing Code dependencies...' cd lib/vscode - yarn --production --frozen-lockfile + yarn --production --frozen-lockfile --no-default-rc symlink_asar diff --git a/ci/dev/postinstall.sh b/ci/dev/postinstall.sh index 170cdb46fd66..5fc0dce0ff20 100755 --- a/ci/dev/postinstall.sh +++ b/ci/dev/postinstall.sh @@ -7,6 +7,9 @@ install-deps() { if [[ ${CI-} ]]; then args+=(--frozen-lockfile) fi + if [[ "$1" == "lib/vscode"]]; then + args+=(--no-default-rc) + fi # If there is no package.json then yarn will look upward and end up installing # from the root resulting in an infinite loop (this can happen if you have not # checked out the submodule yet for example). From 114485b8fc96ea64b32adccf6fc4fdb29b18131a Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 16:57:21 -0700 Subject: [PATCH 31/49] feat(patches): remove yarnrc in presinstall --- patches/node-version.diff | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/patches/node-version.diff b/patches/node-version.diff index 2779356ba19e..df5e89cf5e10 100644 --- a/patches/node-version.diff +++ b/patches/node-version.diff @@ -75,7 +75,7 @@ Index: code-server/lib/vscode/build/lib/util.ts =================================================================== --- code-server.orig/lib/vscode/build/lib/util.ts +++ code-server/lib/vscode/build/lib/util.ts -@@ -371,9 +371,7 @@ export function streamToPromise(stream: +@@ -371,9 +371,7 @@ export function streamToPromise(stream: } export function getElectronVersion(): string { @@ -91,3 +91,21 @@ Index: code-server/lib/vscode/build/lib/util.ts return result; } - +Index: code-server/lib/vscode/build/npm/preinstall.js +=================================================================== +--- code-server.orig/lib/vscode/build/npm/preinstall.js ++++ code-server/lib/vscode/build/npm/preinstall.js +@@ -32,6 +32,13 @@ if (!/yarn[\w-.]*\.c?js$|yarnpkg$/.test( + err = true; + } + ++fs.rmSync(path.join(__dirname, '..', '..', '.yarnrc'), { ++ force: true ++}); ++fs.rmSync(path.join(__dirname, '..', '..', 'remote', '.yarnrc'), { ++ force: true ++}); ++ + if (process.platform === 'win32') { + if (!hasSupportedVisualStudioVersion()) { + console.error('\033[1;31m*** Invalid C/C++ Compiler Toolchain. Please check https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites.\033[0;0m'); From 91de1fec13c901f63feffb40fbc35f08b7f4c8e0 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 16:58:58 -0700 Subject: [PATCH 32/49] fixup!: silly mistake --- ci/dev/postinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/dev/postinstall.sh b/ci/dev/postinstall.sh index 5fc0dce0ff20..a83fda555fa5 100755 --- a/ci/dev/postinstall.sh +++ b/ci/dev/postinstall.sh @@ -7,7 +7,7 @@ install-deps() { if [[ ${CI-} ]]; then args+=(--frozen-lockfile) fi - if [[ "$1" == "lib/vscode"]]; then + if [[ "$1" == "lib/vscode" ]]; then args+=(--no-default-rc) fi # If there is no package.json then yarn will look upward and end up installing From 63dfa8da25df00ef718e64a49c6bafdda81d79c1 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 17:03:25 -0700 Subject: [PATCH 33/49] docs: add note about KEEP_MODULES=1 --- docs/CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index e04788f12543..3e003f131dfc 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -132,6 +132,8 @@ yarn build:vscode yarn release ``` +_NOTE: this does not keep `node_modules`. If you want them to be kept, use `KEEP_MODULES=1 yarn release` (if you're testing in Coder, you'll want to do this)_ + Run your build: ```shell From 786f0872d63b6930354f867b155b82f97d831e06 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 29 Apr 2022 17:05:00 -0700 Subject: [PATCH 34/49] docs(patches): add testing notes for node-version --- patches/node-version.diff | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/patches/node-version.diff b/patches/node-version.diff index df5e89cf5e10..100a8cd6b2c9 100644 --- a/patches/node-version.diff +++ b/patches/node-version.diff @@ -8,7 +8,7 @@ To test this: 1. build fresh Coder workspace 2. clone code-server -3. `yarn watch` +3. `yarn build && yarn build:vscode && KEEP_MODULES=1 yarn release` 4. test built-in terminal Index: code-server/lib/vscode/build/gulpfile.reh.js @@ -17,14 +17,14 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js +++ code-server/lib/vscode/build/gulpfile.reh.js @@ -125,9 +125,7 @@ const serverWithWebEntryPoints = [ ]; - + function getNodeVersion() { - const yarnrc = fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8'); - const target = /^target "(.*)"$/m.exec(yarnrc)[1]; - return target; + return process.versions.node; } - + const nodeVersion = getNodeVersion(); Index: code-server/lib/vscode/build/lib/node.js =================================================================== @@ -47,13 +47,13 @@ Index: code-server/lib/vscode/build/lib/node.ts +++ code-server/lib/vscode/build/lib/node.ts @@ -7,9 +7,7 @@ import * as path from 'path'; import * as fs from 'fs'; - + const root = path.dirname(path.dirname(__dirname)); -const yarnrcPath = path.join(root, 'remote', '.yarnrc'); -const yarnrc = fs.readFileSync(yarnrcPath, 'utf8'); -const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)![1]; +const version = process.versions.node; - + const platform = process.platform; const arch = process.arch; Index: code-server/lib/vscode/build/lib/util.js @@ -75,16 +75,16 @@ Index: code-server/lib/vscode/build/lib/util.ts =================================================================== --- code-server.orig/lib/vscode/build/lib/util.ts +++ code-server/lib/vscode/build/lib/util.ts -@@ -371,9 +371,7 @@ export function streamToPromise(stream: +@@ -371,9 +371,7 @@ export function streamToPromise(stream: } - + export function getElectronVersion(): string { - const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8'); - const target = /^target "(.*)"$/m.exec(yarnrc)![1]; - return target; + return process.versions.node; } - + export function acquireWebNodePaths() { @@ -455,4 +453,3 @@ export function buildWebNodePaths(outDir result.taskName = 'build-web-node-paths'; @@ -98,7 +98,7 @@ Index: code-server/lib/vscode/build/npm/preinstall.js @@ -32,6 +32,13 @@ if (!/yarn[\w-.]*\.c?js$|yarnpkg$/.test( err = true; } - + +fs.rmSync(path.join(__dirname, '..', '..', '.yarnrc'), { + force: true +}); From 70ef582a8973c90bef11624b7126130dcc60634b Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 2 May 2022 18:12:58 +0000 Subject: [PATCH 35/49] refactor(patches): remove node-version It appears this is no longer needed due to the `remote/package.json` now which targets node rather than electron. --- patches/node-version.diff | 111 -------------------------------------- patches/series | 1 - 2 files changed, 112 deletions(-) delete mode 100644 patches/node-version.diff diff --git a/patches/node-version.diff b/patches/node-version.diff deleted file mode 100644 index 100a8cd6b2c9..000000000000 --- a/patches/node-version.diff +++ /dev/null @@ -1,111 +0,0 @@ -Patch the Node version to use the current version of Node - -Previously it would use the yarnrc which results in builds that cannot run with -the version of Node they were built with because the native modules are -targeting the wrong version. - -To test this: - -1. build fresh Coder workspace -2. clone code-server -3. `yarn build && yarn build:vscode && KEEP_MODULES=1 yarn release` -4. test built-in terminal - -Index: code-server/lib/vscode/build/gulpfile.reh.js -=================================================================== ---- code-server.orig/lib/vscode/build/gulpfile.reh.js -+++ code-server/lib/vscode/build/gulpfile.reh.js -@@ -125,9 +125,7 @@ const serverWithWebEntryPoints = [ - ]; - - function getNodeVersion() { -- const yarnrc = fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8'); -- const target = /^target "(.*)"$/m.exec(yarnrc)[1]; -- return target; -+ return process.versions.node; - } - - const nodeVersion = getNodeVersion(); -Index: code-server/lib/vscode/build/lib/node.js -=================================================================== ---- code-server.orig/lib/vscode/build/lib/node.js -+++ code-server/lib/vscode/build/lib/node.js -@@ -7,9 +7,7 @@ Object.defineProperty(exports, "__esModu - const path = require("path"); - const fs = require("fs"); - const root = path.dirname(path.dirname(__dirname)); --const yarnrcPath = path.join(root, 'remote', '.yarnrc'); --const yarnrc = fs.readFileSync(yarnrcPath, 'utf8'); --const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)[1]; -+const version = process.versions.node; - const platform = process.platform; - const arch = process.arch; - const node = platform === 'win32' ? 'node.exe' : 'node'; -Index: code-server/lib/vscode/build/lib/node.ts -=================================================================== ---- code-server.orig/lib/vscode/build/lib/node.ts -+++ code-server/lib/vscode/build/lib/node.ts -@@ -7,9 +7,7 @@ import * as path from 'path'; - import * as fs from 'fs'; - - const root = path.dirname(path.dirname(__dirname)); --const yarnrcPath = path.join(root, 'remote', '.yarnrc'); --const yarnrc = fs.readFileSync(yarnrcPath, 'utf8'); --const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)![1]; -+const version = process.versions.node; - - const platform = process.platform; - const arch = process.arch; -Index: code-server/lib/vscode/build/lib/util.js -=================================================================== ---- code-server.orig/lib/vscode/build/lib/util.js -+++ code-server/lib/vscode/build/lib/util.js -@@ -298,9 +298,7 @@ function streamToPromise(stream) { - } - exports.streamToPromise = streamToPromise; - function getElectronVersion() { -- const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8'); -- const target = /^target "(.*)"$/m.exec(yarnrc)[1]; -- return target; -+ return process.versions.node; - } - exports.getElectronVersion = getElectronVersion; - function acquireWebNodePaths() { -Index: code-server/lib/vscode/build/lib/util.ts -=================================================================== ---- code-server.orig/lib/vscode/build/lib/util.ts -+++ code-server/lib/vscode/build/lib/util.ts -@@ -371,9 +371,7 @@ export function streamToPromise(stream: - } - - export function getElectronVersion(): string { -- const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8'); -- const target = /^target "(.*)"$/m.exec(yarnrc)![1]; -- return target; -+ return process.versions.node; - } - - export function acquireWebNodePaths() { -@@ -455,4 +453,3 @@ export function buildWebNodePaths(outDir - result.taskName = 'build-web-node-paths'; - return result; - } -- -Index: code-server/lib/vscode/build/npm/preinstall.js -=================================================================== ---- code-server.orig/lib/vscode/build/npm/preinstall.js -+++ code-server/lib/vscode/build/npm/preinstall.js -@@ -32,6 +32,13 @@ if (!/yarn[\w-.]*\.c?js$|yarnpkg$/.test( - err = true; - } - -+fs.rmSync(path.join(__dirname, '..', '..', '.yarnrc'), { -+ force: true -+}); -+fs.rmSync(path.join(__dirname, '..', '..', 'remote', '.yarnrc'), { -+ force: true -+}); -+ - if (process.platform === 'win32') { - if (!hasSupportedVisualStudioVersion()) { - console.error('\033[1;31m*** Invalid C/C++ Compiler Toolchain. Please check https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites.\033[0;0m'); diff --git a/patches/series b/patches/series index be0936fce6f2..3d6ded00bb0a 100644 --- a/patches/series +++ b/patches/series @@ -1,5 +1,4 @@ integration.diff -node-version.diff base-path.diff proposed-api.diff marketplace.diff From 5b0f69ac8d99b94da5b258ebe251de09cfbdcc47 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 3 May 2022 20:32:18 +0000 Subject: [PATCH 36/49] fixup!: add cd ../.. to code upgrade instructions --- docs/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 3e003f131dfc..220bf5bf0b9e 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -96,7 +96,7 @@ re-apply the patches. ### Version updates to Code 1. Update the `lib/vscode` submodule to the desired upstream version branch. - 1. `cd lib/vscode && git checkout release/1.66` + 1. `cd lib/vscode && git checkout release/1.66 && cd ../..` 2. `git add lib && git commit -m "chore: update Code"` 2. Apply the patches (`quilt push -a`) or restore your stashed changes. At this stage you may need to resolve conflicts. For example use `quilt push -f`, From 687009dbd307ed9e1a6bb54cd5cdc376169fbdea Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 3 May 2022 20:33:22 +0000 Subject: [PATCH 37/49] fixup!: add note to yarn --production flag --- docs/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 220bf5bf0b9e..c12ff3020bd1 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -138,7 +138,7 @@ Run your build: ```shell cd release -yarn --production +yarn --production # Skip if you used KEEP_MODULES=1 # Runs the built JavaScript with Node. node . ``` From 0b34b5b776ef29d19deb1684529b7cbaa30d06fb Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 3 May 2022 21:38:49 +0000 Subject: [PATCH 38/49] fixup!: make parent-origin easier to upstream --- patches/parent-origin.diff | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/patches/parent-origin.diff b/patches/parent-origin.diff index c28e8b8c3d43..e49382483e6e 100644 --- a/patches/parent-origin.diff +++ b/patches/parent-origin.diff @@ -9,17 +9,16 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main. =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js +++ code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js -@@ -339,12 +339,7 @@ const hostMessaging = new class HostMess - throw err instanceof Error ? err : new Error(String(err)); - } +@@ -317,6 +317,12 @@ const hostMessaging = new class HostMess + const id = searchParams.get('id'); -- if (hostname === parentOriginHash || hostname.startsWith(parentOriginHash + '.')) { -- // validation succeeded! -- return start(parentOrigin); -- } -- -- throw new Error(`Expected '${parentOriginHash}' as hostname or subdomain!`); -+ return start(parentOrigin); - } - }(); + const hostname = location.hostname; ++ ++ // It is safe to run if we are on the same host. ++ const parent = new URL(parentOrigin) ++ if (parent.hostname == location.hostname) { ++ return start(parentOrigin) ++ } + if (!crypto.subtle) { + // cannot validate, not running in a secure context From 5d8628dbd8ec72ef96258e8fa7831771acaf880e Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 3 May 2022 15:36:56 -0700 Subject: [PATCH 39/49] Revert "refactor(patches): delete github-auth.diff patch" This reverts commit 31a354a34345309fadc475491b392d7601e51a32. --- patches/series | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/series b/patches/series index 3d6ded00bb0a..7b5d6f8a6994 100644 --- a/patches/series +++ b/patches/series @@ -9,6 +9,7 @@ logout.diff store-socket.diff proxy-uri.diff display-language.diff +github-auth.diff unique-db.diff log-level.diff local-storage.diff From 1945220c940b0a328bc4ebc8dd70e3bd25022f97 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 3 May 2022 15:37:11 -0700 Subject: [PATCH 40/49] Revert "fixup!: delete github-auth patch" This reverts commit bdeb5212e8c7be6cadd109941b486a4bcdae69fa. --- patches/github-auth.diff | 105 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 patches/github-auth.diff diff --git a/patches/github-auth.diff b/patches/github-auth.diff new file mode 100644 index 000000000000..2bb388e364a5 --- /dev/null +++ b/patches/github-auth.diff @@ -0,0 +1,105 @@ +Use our own GitHub auth relay server + +Microsoft's does not work with self-hosted instances so we run our own. + +Also add an extra set of scopes so that tokens provided via --github-auth will +work for the PR extension. + +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 +@@ -277,7 +277,7 @@ export class WebClientServer { + id: generateUuid(), + providerId: 'github', + accessToken: this._environmentService.args['github-auth'], +- scopes: [['user:email'], ['repo']] ++ scopes: [['read:user', 'user:email', 'repo'], ['user:email'], ['repo']] + } : undefined; + const base = relativeRoot(getOriginalUrl(req)) + const vscodeBase = relativePath(getOriginalUrl(req)) +Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts ++++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts +@@ -17,6 +17,7 @@ import { isFolderToOpen, isWorkspaceToOp + import { create, ICredentialsProvider, IURLCallbackProvider, IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from 'vs/workbench/workbench.web.main'; + import { posix } from 'vs/base/common/path'; + import { ltrim } from 'vs/base/common/strings'; ++import { equals as arrayEquals } from 'vs/base/common/arrays'; + + interface ICredential { + service: string; +@@ -24,6 +25,13 @@ interface ICredential { + password: string; + } + ++interface IToken { ++ accessToken: string ++ account?: { label: string } ++ id: string ++ scopes: string[] ++} ++ + class LocalStorageCredentialsProvider implements ICredentialsProvider { + + private static readonly CREDENTIALS_STORAGE_KEY = 'credentials.provider'; +@@ -51,6 +59,58 @@ class LocalStorageCredentialsProvider im + scopes, + accessToken: authSessionInfo!.accessToken + })))); ++ ++ // Add tokens for extensions to use. This works for extensions like the ++ // pull requests one or GitLens. ++ const extensionId = `vscode.${authSessionInfo.providerId}-authentication`; ++ const service = `${product.urlProtocol}${extensionId}`; ++ const account = `${authSessionInfo.providerId}.auth`; ++ // Oddly the scopes need to match exactly so we cannot just have one token ++ // with all the scopes, instead we have to duplicate the token for each ++ // expected set of scopes. ++ const tokens: IToken[] = authSessionInfo.scopes.map((scopes) => ({ ++ id: authSessionInfo!.id, ++ scopes: scopes.sort(), // Sort for comparing later. ++ accessToken: authSessionInfo!.accessToken, ++ })); ++ this.getPassword(service, account).then((raw) => { ++ let existing: { ++ content: IToken[] ++ } | undefined; ++ ++ if (raw) { ++ try { ++ const json = JSON.parse(raw); ++ json.content = JSON.parse(json.content); ++ existing = json; ++ } catch (error) { ++ console.log(error); ++ } ++ } ++ ++ // Keep tokens for account and scope combinations we do not have in case ++ // there is an extension that uses scopes we have not accounted for (in ++ // these cases the user will need to manually authenticate the extension ++ // through the UI) or the user has tokens for other accounts. ++ if (existing?.content) { ++ existing.content = existing.content.filter((existingToken) => { ++ const scopes = existingToken.scopes.sort(); ++ return !(tokens.find((token) => { ++ return arrayEquals(scopes, token.scopes) ++ && token.account?.label === existingToken.account?.label; ++ })) ++ }) ++ } ++ ++ return this.setPassword(service, account, JSON.stringify({ ++ extensionId, ++ ...(existing || {}), ++ content: JSON.stringify([ ++ ...tokens, ++ ...(existing?.content || []), ++ ]) ++ })); ++ }) + } + } + From 022c480dd0a894956d4dc4ee65017ca0646aa4dd Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 10:52:02 -0500 Subject: [PATCH 41/49] Merge webview origin patch into webview patch --- patches/series | 1 - patches/webview.diff | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/patches/series b/patches/series index 7b5d6f8a6994..93528fef3816 100644 --- a/patches/series +++ b/patches/series @@ -17,4 +17,3 @@ service-worker.diff connection-type.diff sourcemaps.diff disable-downloads.diff -parent-origin.diff diff --git a/patches/webview.diff b/patches/webview.diff index f8ecc65ebeee..c04847e1bf88 100644 --- a/patches/webview.diff +++ b/patches/webview.diff @@ -15,6 +15,9 @@ Since this code exists only for the authentication case we can just skip it when it is served from the current host as authentication is not a problem if the request is not cross-origin. +There is also an origin check we bypass (this seems to be related to how the +webview host is separate by default but we serve on the same host). + To test, open a few types of webviews (images, markdown, extension details, etc). Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts @@ -74,3 +77,20 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/servi switch (event.request.method) { case 'GET': case 'HEAD': +Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js +=================================================================== +--- code-server.orig/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js ++++ code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js +@@ -318,6 +318,12 @@ const hostMessaging = new class HostMess + + const hostname = location.hostname; + ++ // It is safe to run if we are on the same host. ++ const parent = new URL(parentOrigin) ++ if (parent.hostname === location.hostname) { ++ return start(parentOrigin) ++ } ++ + if (!crypto.subtle) { + // cannot validate, not running in a secure context + throw new Error(`Cannot validate in current context!`); From a78f8b5eb2b6caa0aba087b3fd25e35544fce201 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 10:59:04 -0500 Subject: [PATCH 42/49] Remove unused post-install patch --- patches/post-install.diff | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 patches/post-install.diff diff --git a/patches/post-install.diff b/patches/post-install.diff deleted file mode 100644 index dc8334e6ef01..000000000000 --- a/patches/post-install.diff +++ /dev/null @@ -1,26 +0,0 @@ -Replace rimraf with fs.rmSync in postinstall - -The postinstall gets ran when you install with npm but rimraf is a development -dependency so it will not exist. - -Index: code-server/lib/vscode/extensions/postinstall.js -=================================================================== ---- code-server.orig/lib/vscode/extensions/postinstall.js -+++ code-server/lib/vscode/extensions/postinstall.js -@@ -8,7 +8,6 @@ - - const fs = require('fs'); - const path = require('path'); --const rimraf = require('rimraf'); - - const root = path.join(__dirname, 'node_modules', 'typescript'); - -@@ -21,7 +20,7 @@ function processRoot() { - if (!toKeep.has(name)) { - const filePath = path.join(root, name); - console.log(`Removed ${filePath}`); -- rimraf.sync(filePath); -+ fs.rmSync(filePath, { recursive: true }); - } - } - } From 1ce5da3f9c49d90e232c919224f49b00cb76447f Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 10:59:31 -0500 Subject: [PATCH 43/49] Prevent builtin extensions from updating --- patches/disable-builtin-ext-update.diff | 30 +++++++++++++++++++++++++ patches/series | 1 + 2 files changed, 31 insertions(+) create mode 100644 patches/disable-builtin-ext-update.diff diff --git a/patches/disable-builtin-ext-update.diff b/patches/disable-builtin-ext-update.diff new file mode 100644 index 000000000000..4cee1361abe8 --- /dev/null +++ b/patches/disable-builtin-ext-update.diff @@ -0,0 +1,30 @@ +Prevent builtin extensions from being updated + +Updating builtin extensions from the marketplace prevents us from patching them +(for example out GitHub authentication patches). + +Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts ++++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +@@ -206,6 +206,9 @@ export class Extension implements IExten + if (!this.gallery || !this.local) { + return false; + } ++ if (this.type !== ExtensionType.User) { ++ return false; ++ } + if (!this.local.preRelease && this.gallery.properties.isPreReleaseVersion) { + return false; + } +@@ -1057,6 +1060,10 @@ export class ExtensionsWorkbenchService + // Skip if check updates only for builtin extensions and current extension is not builtin. + continue; + } ++ if (installed.type !== ExtensionType.User) { ++ // Never update builtin extensions. ++ continue; ++ } + if (installed.isBuiltin && !installed.local?.identifier.uuid) { + // Skip if the builtin extension does not have Marketplace id + continue; diff --git a/patches/series b/patches/series index 93528fef3816..5801db6aea36 100644 --- a/patches/series +++ b/patches/series @@ -3,6 +3,7 @@ base-path.diff proposed-api.diff marketplace.diff webview.diff +disable-builtin-ext-update.diff insecure-notification.diff update-check.diff logout.diff From 85e8183715d782bece8dfdd0c937264e8ca97a86 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 12:39:12 -0500 Subject: [PATCH 44/49] Refresh sourcemaps patch --- patches/sourcemaps.diff | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/sourcemaps.diff b/patches/sourcemaps.diff index 0c2e11116a87..03502650c23b 100644 --- a/patches/sourcemaps.diff +++ b/patches/sourcemaps.diff @@ -10,7 +10,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js =================================================================== --- code-server.orig/lib/vscode/build/gulpfile.reh.js +++ code-server/lib/vscode/build/gulpfile.reh.js -@@ -189,8 +189,7 @@ function packageTask(type, platform, arc +@@ -191,8 +191,7 @@ function packageTask(type, platform, arc const src = gulp.src(sourceFolderName + '/**', { base: '.' }) .pipe(rename(function (path) { path.dirname = path.dirname.replace(new RegExp('^' + sourceFolderName), 'out'); })) @@ -20,7 +20,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js const workspaceExtensionPoints = ['debuggers', 'jsonValidation']; const isUIExtension = (manifest) => { -@@ -229,9 +228,9 @@ function packageTask(type, platform, arc +@@ -231,9 +230,9 @@ function packageTask(type, platform, arc .map(name => `.build/extensions/${name}/**`); const extensions = gulp.src(extensionPaths, { base: '.build', dot: true }); @@ -32,7 +32,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js let version = packageJson.version; const quality = product.quality; -@@ -366,7 +365,7 @@ function tweakProductForServerWeb(produc +@@ -368,7 +367,7 @@ function tweakProductForServerWeb(produc const minifyTask = task.define(`minify-vscode-${type}`, task.series( optimizeTask, util.rimraf(`out-vscode-${type}-min`), From 9cbcfa912815af49bbd63a0a2b7347202c959637 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 13:48:01 -0500 Subject: [PATCH 45/49] Update Node to v16 This matches the version in ./lib/vscode/remote/.yarnrc. I changed the engine to exactly 16 since if you use any different version it will just not work since the modules will have been built for 16 (due to the .yarnrc). --- .github/workflows/ci.yaml | 30 +++++++++++++++--------------- ci/build/npm-postinstall.sh | 4 ++-- docs/android.md | 6 +++--- docs/npm.md | 6 +++--- package.json | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9dfc0f7f5773..6c25ae53567c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,10 +33,10 @@ jobs: fetch-depth: 0 submodules: true - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Install helm uses: azure/setup-helm@v2.1 @@ -74,10 +74,10 @@ jobs: fetch-depth: 0 submodules: true - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Fetch dependencies from cache id: cache-yarn @@ -116,10 +116,10 @@ jobs: - name: Patch Code run: quilt push -a - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Fetch dependencies from cache id: cache-yarn @@ -253,10 +253,10 @@ jobs: with: fetch-depth: 0 - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Install development tools run: | @@ -337,7 +337,7 @@ jobs: CXX: ${{ format('{0}-g++', matrix.prefix) }} LINK: ${{ format('{0}-g++', matrix.prefix) }} NPM_CONFIG_ARCH: ${{ matrix.arch }} - NODE_VERSION: v14.17.4 + NODE_VERSION: v16.13.0 steps: - name: Checkout repo @@ -345,10 +345,10 @@ jobs: with: fetch-depth: 0 - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Install nfpm run: | @@ -397,10 +397,10 @@ jobs: with: fetch-depth: 0 - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Install nfpm run: | @@ -446,10 +446,10 @@ jobs: fetch-depth: 0 submodules: true - - name: Install Node.js v14 + - name: Install Node.js v16 uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "16" - name: Fetch dependencies from cache id: cache-yarn diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index c3ef085bb526..d98bd992dcb3 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -33,8 +33,8 @@ main() { echo "USE AT YOUR OWN RISK!" fi - if [ "$major_node_version" -ne "${FORCE_NODE_VERSION:-14}" ]; then - echo "ERROR: code-server currently requires node v14." + if [ "$major_node_version" -ne "${FORCE_NODE_VERSION:-16}" ]; then + echo "ERROR: code-server currently requires node v16." if [ -n "$FORCE_NODE_VERSION" ]; then echo "However, you have overrided the version check to use v$FORCE_NODE_VERSION." fi diff --git a/docs/android.md b/docs/android.md index 41fd92dbe1f6..74bbcf503ab9 100644 --- a/docs/android.md +++ b/docs/android.md @@ -11,11 +11,11 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash ``` 6. Exit the terminal using `exit` and then reopen the terminal -7. Install and use Node.js 14: +7. Install and use Node.js 16: ```shell -nvm install 14 -nvm use 14 +nvm install 16 +nvm use 16 ``` 8. Install code-server globally on device with: `npm i -g code-server` diff --git a/docs/npm.md b/docs/npm.md index 27ceaf22f813..5b50235bb79f 100644 --- a/docs/npm.md +++ b/docs/npm.md @@ -22,8 +22,8 @@ includes installing instructions based on your operating system. ## Node.js version -We use the same major version of Node.js shipped with VSCode's Electron, -which is currently `14.x`. VS Code also [lists Node.js +We use the same major version of Node.js shipped with Code's remote, which is +currently `16.x`. VS Code also [lists Node.js requirements](https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites). Using other versions of Node.js [may lead to unexpected @@ -72,7 +72,7 @@ Proceed to [installing](#installing) ## FreeBSD ```sh -pkg install -y git python npm-node14 yarn-node14 pkgconf +pkg install -y git python npm-node16 yarn-node16 pkgconf pkg install -y libinotify ``` diff --git a/package.json b/package.json index 0d9e7ad9379c..be5253bb3026 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "browser-ide" ], "engines": { - "node": ">= 14" + "node": "16" }, "jest": { "transform": { From 694c44b8d4d9c42d7bb3191a13c67c2f5a2dbf4c Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 15:38:22 -0500 Subject: [PATCH 46/49] Replace fs.rmdir with fs.rm Node is showing a deprecation warning about it. --- src/node/socket.ts | 2 +- test/unit/node/cli.test.ts | 2 +- test/unit/node/socket.test.ts | 2 +- test/utils/helpers.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node/socket.ts b/src/node/socket.ts index 1651046d02b2..eb74d05ca14d 100644 --- a/src/node/socket.ts +++ b/src/node/socket.ts @@ -77,7 +77,7 @@ export class SocketProxyProvider { this.proxyPipe = pipe return Promise.all([ fs.mkdir(path.dirname(this.proxyPipe), { recursive: true }), - fs.rmdir(this.proxyPipe, { recursive: true }), + fs.rm(this.proxyPipe, { recursive: true }), ]) }) .then(() => { diff --git a/test/unit/node/cli.test.ts b/test/unit/node/cli.test.ts index 76ebb610f345..21b3842af81b 100644 --- a/test/unit/node/cli.test.ts +++ b/test/unit/node/cli.test.ts @@ -458,7 +458,7 @@ describe("cli", () => { beforeEach(async () => { delete process.env.VSCODE_IPC_HOOK_CLI - await fs.rmdir(vscodeIpcPath, { recursive: true }) + await fs.rm(vscodeIpcPath, { recursive: true }) }) it("should use existing if inside code-server", async () => { diff --git a/test/unit/node/socket.test.ts b/test/unit/node/socket.test.ts index b79696572451..f272384805bf 100644 --- a/test/unit/node/socket.test.ts +++ b/test/unit/node/socket.test.ts @@ -53,7 +53,7 @@ describe("SocketProxyProvider", () => { await fs.mkdir(path.join(tmpdir, "tests"), { recursive: true }) const socketPath = await provider.findFreeSocketPath(path.join(tmpdir, "tests/tls-socket-proxy")) - await fs.rmdir(socketPath, { recursive: true }) + await fs.rm(socketPath, { recursive: true }) return new Promise((_resolve) => { const resolved: { [key: string]: boolean } = { client: false, server: false } diff --git a/test/utils/helpers.ts b/test/utils/helpers.ts index be8f3a90da4d..c3e8f1f7f6a4 100644 --- a/test/utils/helpers.ts +++ b/test/utils/helpers.ts @@ -29,7 +29,7 @@ export function mockLogger() { */ export async function clean(testName: string): Promise { const dir = path.join(os.tmpdir(), `code-server/tests/${testName}`) - await fs.rmdir(dir, { recursive: true }) + await fs.rm(dir, { recursive: true }) } /** From e346fe20d4d002f8f332e12bf9d2c2be939fc5a6 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 15:41:14 -0500 Subject: [PATCH 47/49] Update github-auth patch The local credentials provider is no longer used when there is a remote so this code moved into the backend web credential provider. --- patches/github-auth.diff | 177 +++++++++++++++++++-------------------- 1 file changed, 88 insertions(+), 89 deletions(-) diff --git a/patches/github-auth.diff b/patches/github-auth.diff index 2bb388e364a5..53b98d0f422f 100644 --- a/patches/github-auth.diff +++ b/patches/github-auth.diff @@ -1,105 +1,104 @@ -Use our own GitHub auth relay server +Add the ability to provide a GitHub token -Microsoft's does not work with self-hosted instances so we run our own. +To test install the GitHub PR extension and start code-server with GITHUB_TOKEN +or set github-auth in the config file. The extension should be authenticated. -Also add an extra set of scopes so that tokens provided via --github-auth will -work for the PR extension. - -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 -@@ -277,7 +277,7 @@ export class WebClientServer { - id: generateUuid(), - providerId: 'github', - accessToken: this._environmentService.args['github-auth'], -- scopes: [['user:email'], ['repo']] -+ scopes: [['read:user', 'user:email', 'repo'], ['user:email'], ['repo']] - } : undefined; - const base = relativeRoot(getOriginalUrl(req)) - const vscodeBase = relativePath(getOriginalUrl(req)) -Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts +Index: code-server/lib/vscode/src/vs/platform/credentials/node/credentialsMainService.ts =================================================================== ---- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts -+++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts -@@ -17,6 +17,7 @@ import { isFolderToOpen, isWorkspaceToOp - import { create, ICredentialsProvider, IURLCallbackProvider, IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from 'vs/workbench/workbench.web.main'; - import { posix } from 'vs/base/common/path'; - import { ltrim } from 'vs/base/common/strings'; -+import { equals as arrayEquals } from 'vs/base/common/arrays'; - - interface ICredential { - service: string; -@@ -24,6 +25,13 @@ interface ICredential { - password: string; - } +--- code-server.orig/lib/vscode/src/vs/platform/credentials/node/credentialsMainService.ts ++++ code-server/lib/vscode/src/vs/platform/credentials/node/credentialsMainService.ts +@@ -5,18 +5,32 @@ + import { InMemoryCredentialsProvider } from 'vs/platform/credentials/common/credentials'; + import { ILogService } from 'vs/platform/log/common/log'; +-import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; ++import { IServerEnvironmentService } from 'vs/server/node/serverEnvironmentService'; + import { IProductService } from 'vs/platform/product/common/productService'; + import { BaseCredentialsMainService, KeytarModule } from 'vs/platform/credentials/common/credentialsMainService'; ++import { generateUuid } from 'vs/base/common/uuid'; ++import { equals as arrayEquals } from 'vs/base/common/arrays'; ++ +interface IToken { + accessToken: string + account?: { label: string } + id: string + scopes: string[] +} -+ - class LocalStorageCredentialsProvider implements ICredentialsProvider { - private static readonly CREDENTIALS_STORAGE_KEY = 'credentials.provider'; -@@ -51,6 +59,58 @@ class LocalStorageCredentialsProvider im - scopes, - accessToken: authSessionInfo!.accessToken - })))); + export class CredentialsWebMainService extends BaseCredentialsMainService { + + constructor( + @ILogService logService: ILogService, +- @INativeEnvironmentService private readonly environmentMainService: INativeEnvironmentService, ++ @IServerEnvironmentService private readonly environmentMainService: IServerEnvironmentService, + @IProductService private readonly productService: IProductService, + ) { + super(logService); ++ if (this.environmentMainService.args["github-auth"]) { ++ this.storeGitHubToken(this.environmentMainService.args["github-auth"]).catch((error) => { ++ this.logService.error('Failed to store provided GitHub token', error) ++ }) ++ } + } + + // If the credentials service is running on the server, we add a suffix -server to differentiate from the location that the +@@ -45,4 +59,59 @@ export class CredentialsWebMainService e + } + return this._keytarCache; + } ++ ++ private async storeGitHubToken(githubToken: string): Promise { ++ const extensionId = 'vscode.github-authentication'; ++ const service = `${await this.getSecretStoragePrefix()}${extensionId}`; ++ const account = 'github.auth'; ++ const scopes = [['read:user', 'user:email', 'repo']] ++ ++ // Oddly the scopes need to match exactly so we cannot just have one token ++ // with all the scopes, instead we have to duplicate the token for each ++ // expected set of scopes. ++ const tokens: IToken[] = scopes.map((scopes) => ({ ++ id: generateUuid(), ++ scopes: scopes.sort(), // Sort for comparing later. ++ accessToken: githubToken, ++ })); + -+ // Add tokens for extensions to use. This works for extensions like the -+ // pull requests one or GitLens. -+ const extensionId = `vscode.${authSessionInfo.providerId}-authentication`; -+ const service = `${product.urlProtocol}${extensionId}`; -+ const account = `${authSessionInfo.providerId}.auth`; -+ // Oddly the scopes need to match exactly so we cannot just have one token -+ // with all the scopes, instead we have to duplicate the token for each -+ // expected set of scopes. -+ const tokens: IToken[] = authSessionInfo.scopes.map((scopes) => ({ -+ id: authSessionInfo!.id, -+ scopes: scopes.sort(), // Sort for comparing later. -+ accessToken: authSessionInfo!.accessToken, -+ })); -+ this.getPassword(service, account).then((raw) => { -+ let existing: { -+ content: IToken[] -+ } | undefined; ++ const raw = await this.getPassword(service, account) + -+ if (raw) { -+ try { -+ const json = JSON.parse(raw); -+ json.content = JSON.parse(json.content); -+ existing = json; -+ } catch (error) { -+ console.log(error); -+ } -+ } ++ let existing: { ++ content: IToken[] ++ } | undefined; + -+ // Keep tokens for account and scope combinations we do not have in case -+ // there is an extension that uses scopes we have not accounted for (in -+ // these cases the user will need to manually authenticate the extension -+ // through the UI) or the user has tokens for other accounts. -+ if (existing?.content) { -+ existing.content = existing.content.filter((existingToken) => { -+ const scopes = existingToken.scopes.sort(); -+ return !(tokens.find((token) => { -+ return arrayEquals(scopes, token.scopes) -+ && token.account?.label === existingToken.account?.label; -+ })) -+ }) -+ } ++ if (raw) { ++ try { ++ const json = JSON.parse(raw); ++ json.content = JSON.parse(json.content); ++ existing = json; ++ } catch (error) { ++ this.logService.error('Failed to parse existing GitHub credentials', error) ++ } ++ } + -+ return this.setPassword(service, account, JSON.stringify({ -+ extensionId, -+ ...(existing || {}), -+ content: JSON.stringify([ -+ ...tokens, -+ ...(existing?.content || []), -+ ]) -+ })); ++ // Keep tokens for account and scope combinations we do not have in case ++ // there is an extension that uses scopes we have not accounted for (in ++ // these cases the user will need to manually authenticate the extension ++ // through the UI) or the user has tokens for other accounts. ++ if (existing?.content) { ++ existing.content = existing.content.filter((existingToken) => { ++ const scopes = existingToken.scopes.sort(); ++ return !(tokens.find((token) => { ++ return arrayEquals(scopes, token.scopes) ++ && token.account?.label === existingToken.account?.label; ++ })) + }) - } - } - ++ } ++ ++ return this.setPassword(service, account, JSON.stringify({ ++ extensionId, ++ ...(existing || {}), ++ content: JSON.stringify([ ++ ...tokens, ++ ...(existing?.content || []), ++ ]) ++ })); ++ } + } From 1ac2dcf80171136e48c5040c07f3d0d71dc4bb3e Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 16:04:20 -0500 Subject: [PATCH 48/49] Prevent fs.rm from erroring about non-existent files We were using fs.rmdir which presumably did not have the same behavior in v14 (in v16 fs.rmdir also errors). --- src/node/socket.ts | 2 +- test/unit/node/cli.test.ts | 2 +- test/unit/node/socket.test.ts | 2 +- test/utils/helpers.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node/socket.ts b/src/node/socket.ts index eb74d05ca14d..a56d9566e9dc 100644 --- a/src/node/socket.ts +++ b/src/node/socket.ts @@ -77,7 +77,7 @@ export class SocketProxyProvider { this.proxyPipe = pipe return Promise.all([ fs.mkdir(path.dirname(this.proxyPipe), { recursive: true }), - fs.rm(this.proxyPipe, { recursive: true }), + fs.rm(this.proxyPipe, { force: true, recursive: true }), ]) }) .then(() => { diff --git a/test/unit/node/cli.test.ts b/test/unit/node/cli.test.ts index 21b3842af81b..51e707001d8a 100644 --- a/test/unit/node/cli.test.ts +++ b/test/unit/node/cli.test.ts @@ -458,7 +458,7 @@ describe("cli", () => { beforeEach(async () => { delete process.env.VSCODE_IPC_HOOK_CLI - await fs.rm(vscodeIpcPath, { recursive: true }) + await fs.rm(vscodeIpcPath, { force: true, recursive: true }) }) it("should use existing if inside code-server", async () => { diff --git a/test/unit/node/socket.test.ts b/test/unit/node/socket.test.ts index f272384805bf..167691f7b7a7 100644 --- a/test/unit/node/socket.test.ts +++ b/test/unit/node/socket.test.ts @@ -53,7 +53,7 @@ describe("SocketProxyProvider", () => { await fs.mkdir(path.join(tmpdir, "tests"), { recursive: true }) const socketPath = await provider.findFreeSocketPath(path.join(tmpdir, "tests/tls-socket-proxy")) - await fs.rm(socketPath, { recursive: true }) + await fs.rm(socketPath, { force: true, recursive: true }) return new Promise((_resolve) => { const resolved: { [key: string]: boolean } = { client: false, server: false } diff --git a/test/utils/helpers.ts b/test/utils/helpers.ts index c3e8f1f7f6a4..3f9399d4b2c2 100644 --- a/test/utils/helpers.ts +++ b/test/utils/helpers.ts @@ -29,7 +29,7 @@ export function mockLogger() { */ export async function clean(testName: string): Promise { const dir = path.join(os.tmpdir(), `code-server/tests/${testName}`) - await fs.rm(dir, { recursive: true }) + await fs.rm(dir, { force: true, recursive: true }) } /** From 7d99254ac1af1270706590fdd1f297d747c42ca3 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 4 May 2022 16:29:23 -0500 Subject: [PATCH 49/49] Install Python 3 in CentOS CI container --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c25ae53567c..1e213f0ad433 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -261,7 +261,7 @@ jobs: - name: Install development tools run: | yum install -y epel-release centos-release-scl - yum install -y devtoolset-9-{make,gcc,gcc-c++} jq rsync + yum install -y devtoolset-9-{make,gcc,gcc-c++} jq rsync python3 - name: Install nfpm and envsubst run: |