mirror of https://github.com/coder/code-server.git
Compare commits
9 Commits
acf98f4c28
...
4ed7ea437c
Author | SHA1 | Date |
---|---|---|
Olivier Benz | 4ed7ea437c | |
Asher | 1c009e0ac9 | |
Asher | ed3c4e79fc | |
Asher | 39d29fcf91 | |
Asher | 7b1ddc10cd | |
Asher | 90899f07f8 | |
Asher | 3f67c0ebed | |
Asher | 5eb1d84e48 | |
Asher | e4ceeabe69 |
|
@ -371,7 +371,7 @@ jobs:
|
|||
|
||||
- run: sudo ~/.cache/caddy/caddy start --config ./ci/Caddyfile
|
||||
|
||||
- run: CODE_SERVER_TEST_ENTRY=./release npm run test:e2e:proxy --global-timeout 840000
|
||||
- run: CODE_SERVER_TEST_ENTRY=./release npm run test:e2e:proxy
|
||||
|
||||
- if: always()
|
||||
run: sudo ~/.cache/caddy/caddy stop --config ./ci/Caddyfile
|
||||
|
|
|
@ -91,17 +91,17 @@ bundle_vscode() {
|
|||
|
||||
rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH"
|
||||
|
||||
# Use the package.json for the web/remote server. It does not have the right
|
||||
# version though so pull that from the main package.json.
|
||||
jq --slurp '.[0] * {version: .[1].version}' \
|
||||
# Merge the package.json for the web/remote server so we can include
|
||||
# dependencies, since we want to ship this via NPM.
|
||||
jq --slurp '.[0] * .[1]' \
|
||||
"$VSCODE_SRC_PATH/remote/package.json" \
|
||||
"$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
|
||||
|
||||
mv "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
|
||||
"$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged"
|
||||
mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json"
|
||||
cp "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
|
||||
|
||||
# Include global extension dependencies as well.
|
||||
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json"
|
||||
mv "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json"
|
||||
cp "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json"
|
||||
rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs"
|
||||
}
|
||||
|
||||
|
@ -119,15 +119,21 @@ create_shrinkwraps() {
|
|||
|
||||
# We first generate the shrinkwrap file for code-server itself - which is the
|
||||
# current directory.
|
||||
cp package-lock.json package-lock.json.temp
|
||||
npm shrinkwrap
|
||||
mv package-lock.json.temp package-lock.json
|
||||
|
||||
# Then the shrinkwrap files for the bundled VS Code.
|
||||
pushd "$VSCODE_SRC_PATH/remote/"
|
||||
cp package-lock.json package-lock.json.temp
|
||||
npm shrinkwrap
|
||||
mv package-lock.json.temp package-lock.json
|
||||
popd
|
||||
|
||||
pushd "$VSCODE_SRC_PATH/extensions/"
|
||||
cp package-lock.json package-lock.json.temp
|
||||
npm shrinkwrap
|
||||
mv package-lock.json.temp package-lock.json
|
||||
popd
|
||||
}
|
||||
|
||||
|
|
17
flake.lock
17
flake.lock
|
@ -20,18 +20,15 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1727104955,
|
||||
"narHash": "sha256-m6kgjR4zAwyMe1Pn4RGXLCzArtoBp1qzhb2AUlPeVh4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d266adc5a77ec8c10ed941c7251b2673004dbd62",
|
||||
"type": "github"
|
||||
"lastModified": 1724224976,
|
||||
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=",
|
||||
"path": "/nix/store/j8pbrsb3nybdap3hhg9kw0ffqd4rlbx6-source",
|
||||
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
|
|
|
@ -363,3 +363,16 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js
|
|||
|
||||
// Process monitor
|
||||
'out-build/vs/base/node/cpuUsage.sh',
|
||||
Index: code-server/lib/vscode/src/vs/workbench/workbench.web.main.internal.ts
|
||||
===================================================================
|
||||
--- code-server.orig/lib/vscode/src/vs/workbench/workbench.web.main.internal.ts
|
||||
+++ code-server/lib/vscode/src/vs/workbench/workbench.web.main.internal.ts
|
||||
@@ -52,7 +52,7 @@ import './services/dialogs/browser/fileD
|
||||
import './services/host/browser/browserHostService.js';
|
||||
import './services/lifecycle/browser/lifecycleService.js';
|
||||
import './services/clipboard/browser/clipboardService.js';
|
||||
-import './services/localization/browser/localeService.js';
|
||||
+import './services/localization/electron-sandbox/localeService.js';
|
||||
import './services/path/browser/pathService.js';
|
||||
import './services/themes/browser/browserHostColorSchemeService.js';
|
||||
import './services/encryption/browser/encryptionService.js';
|
||||
|
|
|
@ -17,9 +17,9 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|||
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
+import { localize } from 'vs/nls';
|
||||
+import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { Disposable } from "../../base/common/lifecycle.js";
|
||||
+import { localize } from '../../nls.js';
|
||||
+import { INotificationService, Severity } from '../../platform/notification/common/notification.js';
|
||||
|
||||
export class CodeServerClient extends Disposable {
|
||||
constructor (
|
||||
|
|
|
@ -126,7 +126,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|||
--- /dev/null
|
||||
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
@@ -0,0 +1,46 @@
|
||||
+import { Disposable } from 'vs/base/common/lifecycle';
|
||||
+import { Disposable } from "../../base/common/lifecycle.js";
|
||||
+
|
||||
+export class CodeServerClient extends Disposable {
|
||||
+ constructor (
|
||||
|
@ -272,98 +272,24 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|||
embedderIdentifier: 'server-distro',
|
||||
extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
|
||||
...this._productService.extensionsGallery,
|
||||
Index: code-server/lib/vscode/src/code-server.js
|
||||
Index: code-server/lib/vscode/src/server-main.js
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ code-server/lib/vscode/src/code-server.js
|
||||
@@ -0,0 +1,66 @@
|
||||
+// This is a copy of server-main.js (the parts we use), before it was converted
|
||||
+// to ESM. Directly importing it in code-server has proven difficult. We will
|
||||
+// need to to consider some new options going forward.
|
||||
+//
|
||||
+// 1. Convert code-server to ESM (best option?).
|
||||
+// 2. Do not import, fork a process, and communicate via IPC.
|
||||
+
|
||||
+// @ts-check
|
||||
+'use strict';
|
||||
+
|
||||
+/**
|
||||
+ * @import { INLSConfiguration } from './vs/nls'
|
||||
+ */
|
||||
+
|
||||
+// Keep bootstrap-amd.js from redefining 'fs'.
|
||||
+delete process.env['ELECTRON_RUN_AS_NODE'];
|
||||
+
|
||||
+const path = require('path');
|
||||
+const performance = require('perf_hooks').performance;
|
||||
+const bootstrapNode = require('./bootstrap-node');
|
||||
+const bootstrapAmd = require('./bootstrap-amd');
|
||||
+const { resolveNLSConfiguration } = require('./vs/base/node/nls');
|
||||
+const product = require('./bootstrap-meta').product;
|
||||
+const perf = require(`./vs/base/common/performance`);
|
||||
+
|
||||
+perf.mark('code/server/start');
|
||||
+// @ts-ignore
|
||||
+global.vscodeServerStartTime = performance.now();
|
||||
+
|
||||
+/**
|
||||
+ * @param {INLSConfiguration} nlsConfiguration
|
||||
+ * @returns { Promise<typeof import('./vs/server/node/server.main')> }
|
||||
+ */
|
||||
+function loadCode(nlsConfiguration) {
|
||||
+ return new Promise((resolve, reject) => {
|
||||
+
|
||||
+ /** @type {INLSConfiguration} */
|
||||
+ process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-amd` to pick up NLS messages
|
||||
+
|
||||
+ // See https://github.com/microsoft/vscode-remote-release/issues/6543
|
||||
+ // We would normally install a SIGPIPE listener in bootstrap-node.js
|
||||
+ // But in certain situations, the console itself can be in a broken pipe state
|
||||
+ // so logging SIGPIPE to the console will cause an infinite async loop
|
||||
+ process.env['VSCODE_HANDLES_SIGPIPE'] = 'true';
|
||||
+
|
||||
+ if (process.env['VSCODE_DEV']) {
|
||||
+ // When running out of sources, we need to load node modules from remote/node_modules,
|
||||
+ // which are compiled against nodejs, not electron
|
||||
+ process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules');
|
||||
+ bootstrapNode.devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
|
||||
+ } else {
|
||||
+ delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'];
|
||||
+ }
|
||||
+ bootstrapAmd.load('vs/server/node/server.main', resolve, reject);
|
||||
+ });
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @returns { Promise<typeof import('./vs/server/node/server.main')> }
|
||||
+ */
|
||||
--- code-server.orig/lib/vscode/src/server-main.js
|
||||
+++ code-server/lib/vscode/src/server-main.js
|
||||
@@ -339,4 +339,15 @@ function prompt(question) {
|
||||
});
|
||||
}
|
||||
|
||||
-start();
|
||||
+async function loadCodeWithNls() {
|
||||
+ const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
|
||||
+ return loadCode(nlsConfiguration);
|
||||
+}
|
||||
+
|
||||
+module.exports.loadCodeWithNls = loadCodeWithNls;
|
||||
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
|
||||
@@ -164,6 +164,7 @@ const serverWithWebEntryPoints = [
|
||||
|
||||
const commonJSEntryPoints = [
|
||||
'out-build/server-main.js',
|
||||
+ 'out-build/code-server.js',
|
||||
'out-build/server-cli.js',
|
||||
'out-build/bootstrap-fork.js',
|
||||
];
|
||||
Index: code-server/lib/vscode/src/tsconfig.json
|
||||
===================================================================
|
||||
--- code-server.orig/lib/vscode/src/tsconfig.json
|
||||
+++ code-server/lib/vscode/src/tsconfig.json
|
||||
@@ -36,6 +36,7 @@
|
||||
"./bootstrap-window.js",
|
||||
"./cli.js",
|
||||
"./main.js",
|
||||
+ "./code-server.js",
|
||||
"./server-main.js",
|
||||
"./server-cli.js",
|
||||
"./vs/base/common/jsonc.js",
|
||||
+// This alias prevents the name getting mangled during obfuscation which would
|
||||
+// make it difficult to import.
|
||||
+export { loadCodeWithNls as loadCodeWithNls };
|
||||
+
|
||||
+if (!process.env.CODE_SERVER_PARENT_PID) {
|
||||
+ start();
|
||||
+}
|
||||
|
|
|
@ -53,14 +53,14 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|||
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
@@ -1,11 +1,15 @@
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
+import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
+import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
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';
|
||||
import { Disposable } from "../../base/common/lifecycle.js";
|
||||
import { localize } from '../../nls.js';
|
||||
+import { MenuId, MenuRegistry } from '../../platform/actions/common/actions.js';
|
||||
+import { CommandsRegistry } from '../../platform/commands/common/commands.js';
|
||||
import { ILogService } from '../../platform/log/common/log.js';
|
||||
import { INotificationService, Severity } from '../../platform/notification/common/notification.js';
|
||||
import { IProductService } from '../../platform/product/common/productService.js';
|
||||
import { IStorageService, StorageScope, StorageTarget } from '../../platform/storage/common/storage.js';
|
||||
|
||||
export class CodeServerClient extends Disposable {
|
||||
+ static LOGOUT_COMMAND_ID = 'code-server.logout';
|
||||
|
|
|
@ -13,12 +13,12 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|||
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
||||
@@ -1,10 +1,16 @@
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
+import { ILogService } from 'vs/platform/log/common/log';
|
||||
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';
|
||||
import { Disposable } from "../../base/common/lifecycle.js";
|
||||
import { localize } from '../../nls.js';
|
||||
+import { ILogService } from '../../platform/log/common/log.js';
|
||||
import { INotificationService, Severity } from '../../platform/notification/common/notification.js';
|
||||
+import { IProductService } from '../../platform/product/common/productService.js';
|
||||
+import { IStorageService, StorageScope, StorageTarget } from '../../platform/storage/common/storage.js';
|
||||
|
||||
export class CodeServerClient extends Disposable {
|
||||
constructor (
|
||||
|
|
|
@ -49,7 +49,7 @@ export interface OpenCommandPipeArgs {
|
|||
export const runCodeCli = async (args: DefaultedArgs): Promise<void> => {
|
||||
logger.debug("Running Code CLI")
|
||||
try {
|
||||
const mod = require(path.join(vsRootPath, "out/code-server")) as VSCodeModule
|
||||
const mod = require(path.join(vsRootPath, "out/server-main")) as VSCodeModule
|
||||
const serverModule = await mod.loadCodeWithNls()
|
||||
await serverModule.spawnCli(await toCodeArgs(args))
|
||||
// Rather than have the caller handle errors and exit, spawnCli will exit
|
||||
|
|
|
@ -53,7 +53,13 @@ export type VSCodeModule = {
|
|||
* Load then create the VS Code server.
|
||||
*/
|
||||
async function loadVSCode(req: express.Request): Promise<IVSCodeServerAPI> {
|
||||
const mod = require(path.join(vsRootPath, "out/code-server")) as VSCodeModule
|
||||
// Since server-main.js is an ES module, we have to use `import`. However,
|
||||
// tsc will transpile this to `require` unless we change our module type,
|
||||
// which will also require that we switch to ESM, since a hybrid approach
|
||||
// breaks importing `rotating-file-stream` for some reason. To work around
|
||||
// this, use `eval` for now, but we should consider switching to ESM.
|
||||
const modPath = path.join(vsRootPath, "out/server-main.js")
|
||||
const mod = (await eval(`import("${modPath}")`)) as VSCodeModule
|
||||
const serverModule = await mod.loadCodeWithNls()
|
||||
return serverModule.createServer(null, {
|
||||
...(await toCodeArgs(req.args)),
|
||||
|
|
|
@ -11,11 +11,9 @@ function runTestExtensionTests() {
|
|||
await codeServerPage.waitForTestExtensionLoaded()
|
||||
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
|
||||
|
||||
await codeServerPage.page.waitForSelector("text=proxyUri", { timeout: 3000 })
|
||||
const text = await codeServerPage.page.locator("text=proxyUri").first().textContent()
|
||||
// Remove end slash in address
|
||||
// Remove end slash in address.
|
||||
const normalizedAddress = address.replace(/\/+$/, "")
|
||||
expect(text).toBe(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}/`)
|
||||
await codeServerPage.page.getByText(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}/`)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ describe("Webviews", ["--disable-workspace-trust"], {}, () => {
|
|||
|
||||
// It's an iframe within an iframe
|
||||
// so we have to do .frameLocator twice
|
||||
const renderedText = await codeServerPage.page
|
||||
.frameLocator("iframe.webview.ready")
|
||||
.frameLocator("#active-frame")
|
||||
.locator("text=Hello world")
|
||||
|
||||
expect(renderedText).toBeVisible()
|
||||
await expect(
|
||||
codeServerPage.page.frameLocator("iframe.webview.ready").frameLocator("#active-frame").getByText("Hello world"),
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"lib": ["es2022", "dom", "dom.iterable"],
|
||||
"target": "es6",
|
||||
"lib": ["es2020", "dom", "dom.iterable"],
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
|
|
Loading…
Reference in New Issue