From 8023ebdcf4ad6117eabbd886372f58deee79a096 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 6 Oct 2022 10:26:16 -0700 Subject: [PATCH 01/16] fix: add handle for resolveExternalUri This adds a fix to properly handle `resolveExternalUri` which is used by extensions like Tabnine. --- patches/proxy-uri.diff | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index c5ed301b2b5e..23c898b89743 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -98,3 +98,66 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/terminalE // Merge config (settings) and ShellLaunchConfig environments mergeEnvironments(env, allowedEnvFromConfig); +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 { relativeRoot } from 'vs/server/node/webClientServer'; + + interface ICredential { + service: string; +@@ -485,6 +486,7 @@ function doCreateUri(path: string, query + }); + } + ++ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/") + return URI.parse(window.location.href).with({ path, query }); + } + +@@ -496,7 +498,7 @@ function doCreateUri(path: string, query + if (!configElement || !configElementAttribute) { + throw new Error('Missing web configuration element'); + } +- const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = JSON.parse(configElementAttribute); ++ const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host } + + // Create workbench + create(document.body, { +@@ -506,6 +508,32 @@ function doCreateUri(path: string, query + } : undefined, + workspaceProvider: WorkspaceProvider.create(config), + urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute), +- credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider() // with a remote, we don't use a local credentials provider ++ credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider(), // with a remote, we don't use a local credentials provider ++ resolveExternalUri: (uri: URI): Promise => { ++ // TODO@jsjoeio - how do we make it relative to work when hosted on subpath? ++ const baseUrl = `${window.location.protocol}//${window.location.host}` ++ let resolvedUri = uri ++ ++ // NOTE@jsjoeio - this isn't exhaustive ++ // also doesn't handle if not http or https i.e. ws ++ const localhostMatch = uri.toString().includes("localhost") ++ if (localhostMatch) { ++ // Source: extractLocalHostUriMetaDataForPortMapping ++ const matches = /^(localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)$/.exec(uri.authority) ++ const port = matches && +matches[2] ++ if (port) { ++ // Use code-server's built in /proxy/ ++ resolvedUri = URI.parse(`${baseUrl}/proxy/${port}`) ++ } else { ++ // If here probably means no port found ++ // Assume 80 for HTTP and 443 for HTTPS ++ const isHttps = uri.scheme === "https" ++ resolvedUri = URI.parse(`${baseUrl}/proxy/${isHttps ? "443" : "80"}`) ++ } ++ } ++ ++ // If not localhost, return unmodified ++ return Promise.resolve(resolvedUri) ++ } + }); + })(); From 398a784ca714b66363ddd43414de5ca745e3e19d Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 6 Oct 2022 11:33:37 -0700 Subject: [PATCH 02/16] fixup!: update patch --- patches/proxy-uri.diff | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index 23c898b89743..f19cfc9e8619 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -106,7 +106,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts 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 { relativeRoot } from 'vs/server/node/webClientServer'; ++import { extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/tunnel/common/tunnel'; interface ICredential { service: string; @@ -127,33 +127,23 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts // Create workbench create(document.body, { -@@ -506,6 +508,32 @@ function doCreateUri(path: string, query +@@ -506,6 +508,22 @@ function doCreateUri(path: string, query } : undefined, workspaceProvider: WorkspaceProvider.create(config), urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute), - credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider() // with a remote, we don't use a local credentials provider + credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider(), // with a remote, we don't use a local credentials provider + resolveExternalUri: (uri: URI): Promise => { -+ // TODO@jsjoeio - how do we make it relative to work when hosted on subpath? -+ const baseUrl = `${window.location.protocol}//${window.location.host}` + let resolvedUri = uri ++ const localhostMatch = extractLocalHostUriMetaDataForPortMapping(uri) + -+ // NOTE@jsjoeio - this isn't exhaustive -+ // also doesn't handle if not http or https i.e. ws -+ const localhostMatch = uri.toString().includes("localhost") + if (localhostMatch) { -+ // Source: extractLocalHostUriMetaDataForPortMapping -+ const matches = /^(localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)$/.exec(uri.authority) -+ const port = matches && +matches[2] -+ if (port) { -+ // Use code-server's built in /proxy/ -+ resolvedUri = URI.parse(`${baseUrl}/proxy/${port}`) -+ } else { -+ // If here probably means no port found -+ // Assume 80 for HTTP and 443 for HTTPS -+ const isHttps = uri.scheme === "https" -+ resolvedUri = URI.parse(`${baseUrl}/proxy/${isHttps ? "443" : "80"}`) ++ let baseUrl = `${window.location.protocol}//${window.location.host}` ++ if (config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) { ++ baseUrl = new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString() + } ++ // Use code-server's built in /proxy/ ++ resolvedUri = URI.parse(`${baseUrl}/proxy/${localhostMatch.port}`) + } + + // If not localhost, return unmodified From a06563f3c0843855c011fc38625974660194ef87 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 6 Oct 2022 11:45:46 -0700 Subject: [PATCH 03/16] fixup!: force update proxy patch --- patches/proxy-uri.diff | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index f19cfc9e8619..c43c3982d00f 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -110,24 +110,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts interface ICredential { service: string; -@@ -485,6 +486,7 @@ function doCreateUri(path: string, query - }); - } - -+ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/") - return URI.parse(window.location.href).with({ path, query }); - } - -@@ -496,7 +498,7 @@ function doCreateUri(path: string, query - if (!configElement || !configElementAttribute) { - throw new Error('Missing web configuration element'); - } -- const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = JSON.parse(configElementAttribute); -+ const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host } - - // Create workbench - create(document.body, { -@@ -506,6 +508,22 @@ function doCreateUri(path: string, query +@@ -507,6 +508,22 @@ function doCreateUri(path: string, query } : undefined, workspaceProvider: WorkspaceProvider.create(config), urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute), From 343927cadda698852f5ebea1b542afc5039df195 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 6 Oct 2022 11:56:53 -0700 Subject: [PATCH 04/16] fixup!: use proxyEndpointTemplate else manually add --- patches/proxy-uri.diff | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index c43c3982d00f..db2bc74323e6 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -110,7 +110,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts interface ICredential { service: string; -@@ -507,6 +508,22 @@ function doCreateUri(path: string, query +@@ -507,6 +508,23 @@ function doCreateUri(path: string, query } : undefined, workspaceProvider: WorkspaceProvider.create(config), urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute), @@ -123,10 +123,11 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts + if (localhostMatch) { + let baseUrl = `${window.location.protocol}//${window.location.host}` + if (config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) { -+ baseUrl = new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString() ++ resolvedUri = URI.parse(new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString()) ++ } else { ++ // Manually use code-server's built in /proxy/ ++ resolvedUri = URI.parse(`${baseUrl}/proxy/${localhostMatch.port}`) + } -+ // Use code-server's built in /proxy/ -+ resolvedUri = URI.parse(`${baseUrl}/proxy/${localhostMatch.port}`) + } + + // If not localhost, return unmodified From b0fdbadf7392b078dbe0a66f8498cd32fe5aa000 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 6 Oct 2022 11:59:12 -0700 Subject: [PATCH 05/16] fixup!: throw error if productConfiguration missing --- patches/proxy-uri.diff | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index db2bc74323e6..b37ad55d2686 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -110,7 +110,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts interface ICredential { service: string; -@@ -507,6 +508,23 @@ function doCreateUri(path: string, query +@@ -507,6 +508,21 @@ function doCreateUri(path: string, query } : undefined, workspaceProvider: WorkspaceProvider.create(config), urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute), @@ -121,12 +121,10 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts + const localhostMatch = extractLocalHostUriMetaDataForPortMapping(uri) + + if (localhostMatch) { -+ let baseUrl = `${window.location.protocol}//${window.location.host}` + if (config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) { + resolvedUri = URI.parse(new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString()) + } else { -+ // Manually use code-server's built in /proxy/ -+ resolvedUri = URI.parse(`${baseUrl}/proxy/${localhostMatch.port}`) ++ throw new Error(`Failed to resolve external URI: ${uri.toString()}. Could not determine base url because productConfiguration missing.`) + } + } + From 21cb2de18577d426c01547af5b7bb97e057fed65 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 7 Oct 2022 11:12:05 -0700 Subject: [PATCH 06/16] feat(testing): add asExternalUri This modifies the test extension used in e2e test by registering a new command for testing `asExternalUri`. --- test/e2e/extensions/test-extension/extension.ts | 17 +++++++++++++++++ test/e2e/extensions/test-extension/package.json | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/test/e2e/extensions/test-extension/extension.ts b/test/e2e/extensions/test-extension/extension.ts index ea962efbdd84..ea4a1f896ce6 100644 --- a/test/e2e/extensions/test-extension/extension.ts +++ b/test/e2e/extensions/test-extension/extension.ts @@ -2,6 +2,7 @@ import * as vscode from "vscode" export function activate(context: vscode.ExtensionContext) { vscode.window.showInformationMessage("test extension loaded") + // Test extension context.subscriptions.push( vscode.commands.registerCommand("codeServerTest.proxyUri", () => { if (process.env.VSCODE_PROXY_URI) { @@ -11,4 +12,20 @@ export function activate(context: vscode.ExtensionContext) { } }), ) + + // asExternalUri extension + context.subscriptions.push( + vscode.commands.registerCommand("codeServerTest.asExternalUri", async () => { + const input = await vscode.window.showInputBox({ + prompt: "URL to pass through to asExternalUri", + }) + + if (input) { + const output = await vscode.env.asExternalUri(vscode.Uri.parse(input)) + vscode.window.showInformationMessage(`input: ${input} output: ${output}`) + } else { + vscode.window.showErrorMessage(`Failed to run test case. No input provided.`) + } + }), + ) } diff --git a/test/e2e/extensions/test-extension/package.json b/test/e2e/extensions/test-extension/package.json index 8aca8815ac9f..77482689f4c4 100644 --- a/test/e2e/extensions/test-extension/package.json +++ b/test/e2e/extensions/test-extension/package.json @@ -17,6 +17,11 @@ "command": "codeServerTest.proxyUri", "title": "Get proxy URI", "category": "code-server" + }, + { + "command": "codeServerTest.asExternalUri", + "title": "asExternalUri test", + "category": "code-server" } ] }, From fb3fecfc44f70c787739c80537ef1f36ad08cb84 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 7 Oct 2022 14:54:53 -0700 Subject: [PATCH 07/16] feat: add e2e test for asExternalUri --- test/e2e/asExternalUri.test.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/e2e/asExternalUri.test.ts diff --git a/test/e2e/asExternalUri.test.ts b/test/e2e/asExternalUri.test.ts new file mode 100644 index 000000000000..e3085ef03457 --- /dev/null +++ b/test/e2e/asExternalUri.test.ts @@ -0,0 +1,26 @@ +import * as path from "path" +import { getMaybeProxiedCodeServer } from "../utils/helpers" +import { describe, test, expect } from "./baseFixture" + +// TODO@jsjoeio - account for proxy + +const flags = ["--extensions-dir", path.join(__dirname, "./extensions")] +describe("asExternalUri", flags, {}, () => { + test("should use /proxy/port", async ({ codeServerPage }) => { + // Given + const port = "3000" + const input = `http://localhost:${port}` + const address = await getMaybeProxiedCodeServer(codeServerPage) + const expected = `${address}/proxy/${port}` + + // When + await codeServerPage.waitForTestExtensionLoaded() + await codeServerPage.executeCommandViaMenus("code-server: asExternalUri test") + await codeServerPage.page.type(".quick-input-widget", input) + await codeServerPage.page.keyboard.press("Enter") + + // Then + const text = await codeServerPage.page.locator("text=output").first().textContent() + expect(text).toBe(`Info: input: ${input} output: ${expected}`) + }) +}) From 8acd21f9a1e98a01b203ee24de4fbe5fbf4ca24d Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 7 Oct 2022 14:55:08 -0700 Subject: [PATCH 08/16] docs: update playwright setup comments --- test/playwright.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/playwright.config.ts b/test/playwright.config.ts index bcaa86540ef5..c555f0960909 100644 --- a/test/playwright.config.ts +++ b/test/playwright.config.ts @@ -8,6 +8,7 @@ import path from "path" // yarn test:e2e --workers 1 # Run with one worker // yarn test:e2e --project Chromium # Only run on Chromium // yarn test:e2e --grep login # Run tests matching "login" +// PWDEBUG=1 yarn test:e2e # Run Playwright inspector const config: PlaywrightTestConfig = { testDir: path.join(__dirname, "e2e"), // Search for tests in this directory. timeout: 60000, // Each test is given 60 seconds. From 02a950911e733d9b5487488f8886a07334bebddf Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 7 Oct 2022 15:06:27 -0700 Subject: [PATCH 09/16] feat: add support for VSCODE_PROXY_URI --- patches/proxy-uri.diff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index b37ad55d2686..83eb77e7ccc4 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 rootEndpoint: base, updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined, -+ proxyEndpointTemplate: base + '/proxy/{{port}}', ++ proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}', embedderIdentifier: 'server-distro', extensionsGallery: this._productService.extensionsGallery, }, From a4ed6927f7d3d333a70d5f943f208a4b3760dc6e Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 7 Oct 2022 15:06:56 -0700 Subject: [PATCH 10/16] chore: refresh patches --- patches/disable-downloads.diff | 11 +++++++++++ patches/service-worker.diff | 15 --------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/patches/disable-downloads.diff b/patches/disable-downloads.diff index 3ed71ac83009..467eb2cbca63 100644 --- a/patches/disable-downloads.diff +++ b/patches/disable-downloads.diff @@ -86,6 +86,17 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts _wrapWebWorkerExtHostInIframe, developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, +@@ -319,6 +320,10 @@ export class WebClientServer { + updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, + logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined, + proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}', ++ serviceWorker: { ++ scope: vscodeBase + '/', ++ path: base + '/_static/out/browser/serviceWorker.js', ++ }, + embedderIdentifier: 'server-distro', + extensionsGallery: this._productService.extensionsGallery, + }, Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts diff --git a/patches/service-worker.diff b/patches/service-worker.diff index 967e51b7dda7..330883e4ea40 100644 --- a/patches/service-worker.diff +++ b/patches/service-worker.diff @@ -17,21 +17,6 @@ Index: code-server/lib/vscode/src/vs/base/common/product.ts readonly version: string; readonly date?: string; -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 -@@ -319,6 +319,10 @@ export class WebClientServer { - updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, - logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined, - proxyEndpointTemplate: base + '/proxy/{{port}}', -+ serviceWorker: { -+ scope: vscodeBase + '/', -+ path: base + '/_static/out/browser/serviceWorker.js', -+ }, - embedderIdentifier: 'server-distro', - extensionsGallery: this._productService.extensionsGallery, - }, Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts From 7a75bd08007b226ee6d31d9a9ef0e23165deb938 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 7 Oct 2022 15:14:49 -0700 Subject: [PATCH 11/16] feat: add test for VSCODE_PROXY_URI --- test/e2e/asExternalUri.test.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/e2e/asExternalUri.test.ts b/test/e2e/asExternalUri.test.ts index e3085ef03457..608a6dfbcf33 100644 --- a/test/e2e/asExternalUri.test.ts +++ b/test/e2e/asExternalUri.test.ts @@ -2,8 +2,6 @@ import * as path from "path" import { getMaybeProxiedCodeServer } from "../utils/helpers" import { describe, test, expect } from "./baseFixture" -// TODO@jsjoeio - account for proxy - const flags = ["--extensions-dir", path.join(__dirname, "./extensions")] describe("asExternalUri", flags, {}, () => { test("should use /proxy/port", async ({ codeServerPage }) => { @@ -24,3 +22,27 @@ describe("asExternalUri", flags, {}, () => { expect(text).toBe(`Info: input: ${input} output: ${expected}`) }) }) + +describe( + "asExternalUri", + flags, + { VSCODE_PROXY_URI: "https://{{port}}-main-workspace-name-user-name.coder.com" }, + () => { + test("should use VSCODE_PROXY_URI", async ({ codeServerPage }) => { + // Given + const port = "3000" + const input = `http://localhost:${port}` + const expected = `https://${port}-main-workspace-name-user-name.coder.com/` + + // When + await codeServerPage.waitForTestExtensionLoaded() + await codeServerPage.executeCommandViaMenus("code-server: asExternalUri test") + await codeServerPage.page.type(".quick-input-widget", input) + await codeServerPage.page.keyboard.press("Enter") + + // Then + const text = await codeServerPage.page.locator("text=output").first().textContent() + expect(text).toBe(`Info: input: ${input} output: ${expected}`) + }) + }, +) From cfb487e2797ccae4f31679cb9c5cc1e0d975cb72 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 10 Oct 2022 14:19:39 -0700 Subject: [PATCH 12/16] chore: add metadata to lang extension --- .../package.json | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json index 4f4aff17b307..fa341714713a 100644 --- a/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json +++ b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json @@ -1,32 +1,38 @@ { - "name": "vscode-language-pack-es", - "displayName": "Spanish Language Pack for Visual Studio Code", - "description": "Language pack extension for Spanish", - "version": "1.70.0", - "publisher": "MS-CEINTL", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/vscode-loc" - }, - "engines": { - "vscode": "^1.70.0" - }, - "categories": [ - "Language Packs" - ], - "contributes": { - "localizations": [ - { - "languageId": "es", - "languageName": "Spanish", - "localizedLanguageName": "español", - "translations": [ - { - "id": "vscode", - "path": "./translations/main.i18n.json" - } - ] - } - ] - } -} + "name": "vscode-language-pack-es", + "displayName": "Spanish Language Pack for Visual Studio Code", + "description": "Language pack extension for Spanish", + "version": "1.70.0", + "publisher": "MS-CEINTL", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/vscode-loc" + }, + "engines": { + "vscode": "^1.70.0" + }, + "categories": [ + "Language Packs" + ], + "contributes": { + "localizations": [ + { + "languageId": "es", + "languageName": "Spanish", + "localizedLanguageName": "español", + "translations": [ + { + "id": "vscode", + "path": "./translations/main.i18n.json" + } + ] + } + ] + }, + "__metadata": { + "id": "47e020a1-33db-4cc0-a1b4-42f97781749a", + "publisherDisplayName": "MS-CEINTL", + "publisherId": "0b0882c3-aee3-4d7c-b5f9-872f9be0a115", + "isPreReleaseVersion": false + } +} \ No newline at end of file From 3e57d2c45865b2b490b8a507f9b92e7501cf7a25 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 13 Oct 2022 10:44:16 -0700 Subject: [PATCH 13/16] fixup!: fix part of service-worker patch --- patches/service-worker.diff | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/patches/service-worker.diff b/patches/service-worker.diff index 330883e4ea40..ce902f64c2f1 100644 --- a/patches/service-worker.diff +++ b/patches/service-worker.diff @@ -50,3 +50,18 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts + } + } } +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 +@@ -319,6 +319,10 @@ export class WebClientServer { + updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, + logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined, + proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}', ++ serviceWorker: { ++ scope: vscodeBase + '/', ++ path: base + '/_static/out/browser/serviceWorker.js', ++ }, + embedderIdentifier: 'server-distro', + extensionsGallery: this._productService.extensionsGallery, + }, From 64984bdabd9858d4a7d148e203c2c7fa00a6037c Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 13 Oct 2022 10:47:41 -0700 Subject: [PATCH 14/16] fixup!: remove e2e test, update patch notes --- patches/proxy-uri.diff | 9 +++++++ test/e2e/asExternalUri.test.ts | 48 ---------------------------------- 2 files changed, 9 insertions(+), 48 deletions(-) delete mode 100644 test/e2e/asExternalUri.test.ts diff --git a/patches/proxy-uri.diff b/patches/proxy-uri.diff index 83eb77e7ccc4..4065d48744e1 100644 --- a/patches/proxy-uri.diff +++ b/patches/proxy-uri.diff @@ -10,6 +10,15 @@ extensions, use --extensions-dir, or symlink it). This has e2e tests. +For the `asExternalUri` changes, you'll need to test manually by: +1. running code-server with the test extension +2. Command Palette > code-server: asExternalUri test +3. input a url like http://localhost:3000 +4. it should show a notification and show output as /proxy/3000 + +Do the same thing but set `VSCODE_PROXY_URI: "https://{{port}}-main-workspace-name-user-name.coder.com"` +and the output should replace `{{port}}` with port used in input url. + Index: code-server/lib/vscode/src/vs/base/common/product.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/base/common/product.ts diff --git a/test/e2e/asExternalUri.test.ts b/test/e2e/asExternalUri.test.ts deleted file mode 100644 index 608a6dfbcf33..000000000000 --- a/test/e2e/asExternalUri.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import * as path from "path" -import { getMaybeProxiedCodeServer } from "../utils/helpers" -import { describe, test, expect } from "./baseFixture" - -const flags = ["--extensions-dir", path.join(__dirname, "./extensions")] -describe("asExternalUri", flags, {}, () => { - test("should use /proxy/port", async ({ codeServerPage }) => { - // Given - const port = "3000" - const input = `http://localhost:${port}` - const address = await getMaybeProxiedCodeServer(codeServerPage) - const expected = `${address}/proxy/${port}` - - // When - await codeServerPage.waitForTestExtensionLoaded() - await codeServerPage.executeCommandViaMenus("code-server: asExternalUri test") - await codeServerPage.page.type(".quick-input-widget", input) - await codeServerPage.page.keyboard.press("Enter") - - // Then - const text = await codeServerPage.page.locator("text=output").first().textContent() - expect(text).toBe(`Info: input: ${input} output: ${expected}`) - }) -}) - -describe( - "asExternalUri", - flags, - { VSCODE_PROXY_URI: "https://{{port}}-main-workspace-name-user-name.coder.com" }, - () => { - test("should use VSCODE_PROXY_URI", async ({ codeServerPage }) => { - // Given - const port = "3000" - const input = `http://localhost:${port}` - const expected = `https://${port}-main-workspace-name-user-name.coder.com/` - - // When - await codeServerPage.waitForTestExtensionLoaded() - await codeServerPage.executeCommandViaMenus("code-server: asExternalUri test") - await codeServerPage.page.type(".quick-input-widget", input) - await codeServerPage.page.keyboard.press("Enter") - - // Then - const text = await codeServerPage.page.locator("text=output").first().textContent() - expect(text).toBe(`Info: input: ${input} output: ${expected}`) - }) - }, -) From fb7bcb814c481d3a71173a22f13b0e2a7f0a5cbd Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 13 Oct 2022 10:49:21 -0700 Subject: [PATCH 15/16] fixup!: refresh disable-downloads --- patches/disable-downloads.diff | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/patches/disable-downloads.diff b/patches/disable-downloads.diff index 467eb2cbca63..3ed71ac83009 100644 --- a/patches/disable-downloads.diff +++ b/patches/disable-downloads.diff @@ -86,17 +86,6 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts _wrapWebWorkerExtHostInIframe, developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, -@@ -319,6 +320,10 @@ export class WebClientServer { - updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined, - logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined, - proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}', -+ serviceWorker: { -+ scope: vscodeBase + '/', -+ path: base + '/_static/out/browser/serviceWorker.js', -+ }, - embedderIdentifier: 'server-distro', - extensionsGallery: this._productService.extensionsGallery, - }, Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts From d763c1cdc19365af1059d3b75cbcd1ab584d23f6 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 13 Oct 2022 11:03:56 -0700 Subject: [PATCH 16/16] fixup!: formatting --- .../package.json | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json index fa341714713a..2b69924413dc 100644 --- a/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json +++ b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json @@ -1,38 +1,38 @@ { - "name": "vscode-language-pack-es", - "displayName": "Spanish Language Pack for Visual Studio Code", - "description": "Language pack extension for Spanish", - "version": "1.70.0", - "publisher": "MS-CEINTL", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/vscode-loc" - }, - "engines": { - "vscode": "^1.70.0" - }, - "categories": [ - "Language Packs" - ], - "contributes": { - "localizations": [ - { - "languageId": "es", - "languageName": "Spanish", - "localizedLanguageName": "español", - "translations": [ - { - "id": "vscode", - "path": "./translations/main.i18n.json" - } - ] - } - ] - }, - "__metadata": { - "id": "47e020a1-33db-4cc0-a1b4-42f97781749a", - "publisherDisplayName": "MS-CEINTL", - "publisherId": "0b0882c3-aee3-4d7c-b5f9-872f9be0a115", - "isPreReleaseVersion": false - } -} \ No newline at end of file + "name": "vscode-language-pack-es", + "displayName": "Spanish Language Pack for Visual Studio Code", + "description": "Language pack extension for Spanish", + "version": "1.70.0", + "publisher": "MS-CEINTL", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/vscode-loc" + }, + "engines": { + "vscode": "^1.70.0" + }, + "categories": [ + "Language Packs" + ], + "contributes": { + "localizations": [ + { + "languageId": "es", + "languageName": "Spanish", + "localizedLanguageName": "español", + "translations": [ + { + "id": "vscode", + "path": "./translations/main.i18n.json" + } + ] + } + ] + }, + "__metadata": { + "id": "47e020a1-33db-4cc0-a1b4-42f97781749a", + "publisherDisplayName": "MS-CEINTL", + "publisherId": "0b0882c3-aee3-4d7c-b5f9-872f9be0a115", + "isPreReleaseVersion": false + } +}