diff --git a/scripts/build.ts b/scripts/build.ts index ef8001d2..1977285d 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -246,18 +246,11 @@ class Builder { await this.task("copying vs code into build directory", async () => { await fs.mkdirp(vscodeBuildPath) await Promise.all([ - (async (): Promise => { - await fs.move( - path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`), - path.join(vscodeBuildPath, "out") - ) - await fs.remove(path.join(vscodeBuildPath, "out/vs/server/browser/workbench.html")) - await fs.move( - path.join(vscodeBuildPath, "out/vs/server/browser/workbench-build.html"), - path.join(vscodeBuildPath, "out/vs/server/browser/workbench.html") - ) - })(), - await fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")), + fs.move( + path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`), + path.join(vscodeBuildPath, "out") + ), + fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")), ]) }) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index a139bd68..afc7c10f 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -418,7 +418,7 @@ index d0f6e6b18a..1966fd297d 100644 - diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts new file mode 100644 -index 0000000000..8e7c5af184 +index 0000000000..3a62205b38 --- /dev/null +++ b/src/vs/server/browser/client.ts @@ -0,0 +1,162 @@ @@ -532,12 +532,12 @@ index 0000000000..8e7c5af184 + if (!window.isSecureContext) { + (services.get(INotificationService) as INotificationService).notify({ + severity: Severity.Warning, -+ message: "code-server is being accessed over an insecure domain. Some functionality may not work as expected.", ++ message: 'code-server is being accessed over an insecure domain. Some functionality may not work as expected.', + actions: { + primary: [{ -+ id: "understand", -+ label: "I understand", -+ tooltip: "", ++ id: 'understand', ++ label: 'I understand', ++ tooltip: '', + class: undefined, + enabled: true, + checked: true, @@ -679,165 +679,6 @@ index 0000000000..0d2e93edae + this.disposed = true; + } +} -diff --git a/src/vs/server/browser/workbench-build.html b/src/vs/server/browser/workbench-build.html -new file mode 100644 -index 0000000000..50f48cd74c ---- /dev/null -+++ b/src/vs/server/browser/workbench-build.html -@@ -0,0 +1,92 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/src/vs/server/browser/workbench.html b/src/vs/server/browser/workbench.html -new file mode 100644 -index 0000000000..47d76f388b ---- /dev/null -+++ b/src/vs/server/browser/workbench.html -@@ -0,0 +1,55 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ diff --git a/src/vs/server/browser/worker.ts b/src/vs/server/browser/worker.ts new file mode 100644 index 0000000000..0ba93cc070 diff --git a/src/node/app/server.tsx b/src/node/app/server.tsx index 2d42ca26..0cb6eefd 100644 --- a/src/node/app/server.tsx +++ b/src/node/app/server.tsx @@ -19,7 +19,7 @@ export class MainHttpProvider extends HttpProvider { ): Promise { if (base === "/static") { const response = await this.getResource(this.rootPath, requestPath) - if (this.options.commit && this.options.commit !== "development") { + if (!this.isDev) { response.cache = true } return response @@ -41,7 +41,7 @@ export class MainHttpProvider extends HttpProvider { const response = await this.getUtf8Resource(this.rootPath, "src/browser/index.html") response.content = response.content - .replace(/{{COMMIT}}/g, this.options.commit || "development") + .replace(/{{COMMIT}}/g, this.options.commit) .replace(/"{{OPTIONS}}"/g, `'${JSON.stringify(options)}'`) .replace(/{{COMPONENT}}/g, ReactDOMServer.renderToString()) return response diff --git a/src/node/entry.ts b/src/node/entry.ts index 34f0a2e6..2187b396 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -23,7 +23,7 @@ const main = async (args: Args = {}): Promise => { const auth = args.auth || AuthType.Password const originalPassword = auth === AuthType.Password && (process.env.PASSWORD || (await generatePassword())) - let commit = "development" + let commit: string | undefined try { commit = require("../../package.json").commit } catch (error) { @@ -36,7 +36,7 @@ const main = async (args: Args = {}): Promise => { basePath: args["base-path"], cert: args.cert, certKey: args["cert-key"], - commit, + commit: commit || "development", host: args.host || (args.auth === AuthType.Password && typeof args.cert !== "undefined" ? "0.0.0.0" : "localhost"), password: originalPassword ? hash(originalPassword) : undefined, port: typeof args.port !== "undefined" ? parseInt(args.port, 10) : 8080, diff --git a/src/node/http.ts b/src/node/http.ts index df0b89d0..019f7892 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -112,7 +112,7 @@ export interface HttpProviderOptions { readonly base: string readonly auth: AuthType readonly password?: string - readonly commit?: string + readonly commit: string } /** @@ -150,6 +150,10 @@ export abstract class HttpProvider { request: http.IncomingMessage ): Promise + protected get isDev(): boolean { + return this.options.commit === "development" + } + /** * Return the specified path with the base path prepended. */ diff --git a/src/node/vscode/error.html b/src/node/vscode/error.html new file mode 100644 index 00000000..800305e4 --- /dev/null +++ b/src/node/vscode/error.html @@ -0,0 +1,24 @@ + + + + + + + code-server + + + + + + + +
+ {{ERROR}} +
+ + + diff --git a/src/node/vscode/server.ts b/src/node/vscode/server.ts index e0c73637..c7609238 100644 --- a/src/node/vscode/server.ts +++ b/src/node/vscode/server.ts @@ -128,7 +128,11 @@ export class VscodeHttpProvider extends HttpProvider { if (!this.authenticated(request)) { return { redirect: "/login" } } - return this.getRoot(request, query) + try { + return await this.getRoot(request, query) + } catch (error) { + return this.getErrorRoot(error) + } case "/static": { switch (requestPath) { case "/out/vs/workbench/services/extensions/worker/extensionHostWorkerMain.js": { @@ -171,7 +175,7 @@ export class VscodeHttpProvider extends HttpProvider { private async getRoot(request: http.IncomingMessage, query: querystring.ParsedUrlQuery): Promise { const settings = await this.settings.read() const [response, options] = await Promise.all([ - this.getUtf8Resource(this.serverRootPath, "browser/workbench.html"), + await this.getUtf8Resource(this.rootPath, `src/node/vscode/workbench${!this.isDev ? "-build" : ""}.html`), this.initialize({ args: this.args, query, @@ -201,4 +205,13 @@ export class VscodeHttpProvider extends HttpProvider { .replace(`"{{NLS_CONFIGURATION}}"`, `'${JSON.stringify(options.nlsConfiguration)}'`), } } + + private async getErrorRoot(error: Error): Promise { + const response = await this.getUtf8Resource(this.rootPath, "src/node/vscode/error.html") + const message = `VS Code failed to load. ${ + this.isDev ? "It might not have finished compiling (check for 'Finished compilation' in the output)." : "" + }

${error}` + response.content = response.content.replace(/{{COMMIT}}/g, this.options.commit).replace(/{{ERROR}}/g, message) + return response + } } diff --git a/src/node/vscode/workbench-build.html b/src/node/vscode/workbench-build.html new file mode 100644 index 00000000..8347bf4e --- /dev/null +++ b/src/node/vscode/workbench-build.html @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/node/vscode/workbench.html b/src/node/vscode/workbench.html new file mode 100644 index 00000000..4cdb7160 --- /dev/null +++ b/src/node/vscode/workbench.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +