mirror of https://git.tuxpa.in/a/code-server.git
Prepare for release
- Add VS Code icon - Trim dashboard to just display dedicated VS Code section - Version was getting unset during build - Add back nbin shim which I temporarily took out earlier - Update tests for log level env var changes
This commit is contained in:
parent
1aaa53622d
commit
46d6e17508
|
@ -0,0 +1,6 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
indent_size = 2
|
40
ci/build.ts
40
ci/build.ts
|
@ -174,7 +174,7 @@ class Builder {
|
||||||
|
|
||||||
await this.copyDependencies("code-server", this.rootPath, this.buildPath, {
|
await this.copyDependencies("code-server", this.rootPath, this.buildPath, {
|
||||||
commit,
|
commit,
|
||||||
version: process.env.VERSION,
|
version: this.codeServerVersion,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,13 +204,17 @@ class Builder {
|
||||||
|
|
||||||
const vscodeBuildPath = path.join(this.buildPath, "lib/vscode")
|
const vscodeBuildPath = path.join(this.buildPath, "lib/vscode")
|
||||||
await this.task("copying vs code into build directory", async () => {
|
await this.task("copying vs code into build directory", async () => {
|
||||||
await fs.mkdirp(vscodeBuildPath)
|
await fs.mkdirp(path.join(vscodeBuildPath, "resources/linux"))
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fs.move(
|
fs.move(
|
||||||
path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`),
|
path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`),
|
||||||
path.join(vscodeBuildPath, "out"),
|
path.join(vscodeBuildPath, "out"),
|
||||||
),
|
),
|
||||||
fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")),
|
fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")),
|
||||||
|
fs.copy(
|
||||||
|
path.join(this.vscodeSourcePath, "resources/linux/code.png"),
|
||||||
|
path.join(vscodeBuildPath, "resources/linux/code.png"),
|
||||||
|
),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -256,6 +260,38 @@ class Builder {
|
||||||
* Bundles the built code into a binary.
|
* Bundles the built code into a binary.
|
||||||
*/
|
*/
|
||||||
private async binary(binaryName: string): Promise<void> {
|
private async binary(binaryName: string): Promise<void> {
|
||||||
|
// Prepend code to the target which enables finding files within the binary.
|
||||||
|
const prependLoader = async (relativeFilePath: string): Promise<void> => {
|
||||||
|
const filePath = path.join(this.buildPath, relativeFilePath)
|
||||||
|
const shim = `
|
||||||
|
if (!global.NBIN_LOADED) {
|
||||||
|
try {
|
||||||
|
const nbin = require("nbin");
|
||||||
|
nbin.shimNativeFs("${this.buildPath}");
|
||||||
|
global.NBIN_LOADED = true;
|
||||||
|
const path = require("path");
|
||||||
|
const rg = require("vscode-ripgrep");
|
||||||
|
rg.binaryRgPath = rg.rgPath;
|
||||||
|
rg.rgPath = path.join(require("os").tmpdir(), "code-server", path.basename(rg.binaryRgPath));
|
||||||
|
} catch (error) { /* Not in the binary. */ }
|
||||||
|
}
|
||||||
|
`
|
||||||
|
const content = await fs.readFile(filePath, "utf8")
|
||||||
|
if (!content.startsWith(shim)) {
|
||||||
|
await fs.writeFile(filePath, shim + content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.task("Prepending nbin loader", () => {
|
||||||
|
return Promise.all([
|
||||||
|
prependLoader("out/node/entry.js"),
|
||||||
|
prependLoader("lib/vscode/out/vs/server/entry.js"),
|
||||||
|
prependLoader("lib/vscode/out/vs/server/fork.js"),
|
||||||
|
prependLoader("lib/vscode/out/bootstrap-fork.js"),
|
||||||
|
prependLoader("lib/vscode/extensions/node_modules/typescript/lib/tsserver.js"),
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
const bin = new Binary({
|
const bin = new Binary({
|
||||||
mainFile: path.join(this.buildPath, "out/node/entry.js"),
|
mainFile: path.join(this.buildPath, "out/node/entry.js"),
|
||||||
target: await this.target(),
|
target: await this.target(),
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
.block-row > .item > .icon {
|
.block-row > .item > .icon {
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
vertical-align: top;
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,25 +21,36 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="center-container">
|
<div class="center-container">
|
||||||
<div class="info-blocks">
|
<div class="info-blocks">
|
||||||
|
<!-- TEMP: Only VS Code for now. -->
|
||||||
|
<!-- <div class="info-block"> -->
|
||||||
|
<!-- <h2 class="header">Running Applications</h2> -->
|
||||||
|
<!-- {{APP_LIST:RUNNING}} -->
|
||||||
|
<!-- </div> -->
|
||||||
|
|
||||||
<div class="info-block">
|
<div class="info-block">
|
||||||
<h2 class="header">Running Applications</h2>
|
<h2 class="header">Launch</h2>
|
||||||
{{APP_LIST:RUNNING}}
|
<div class="block-row">
|
||||||
|
<a class="item -link" href="./vscode">
|
||||||
|
<img class="icon" src="./static-{{COMMIT}}/lib/vscode/resources/linux/code.png" />
|
||||||
|
VS Code
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-block">
|
<div class="info-block">
|
||||||
<h2 class="header">Update</h2>
|
<h2 class="header">Version</h2>
|
||||||
{{UPDATE:NAME}}
|
{{UPDATE:NAME}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-block">
|
<!-- <div class="info-block"> -->
|
||||||
<h2 class="header">Editors</h2>
|
<!-- <h2 class="header">Editors</h2> -->
|
||||||
{{APP_LIST:EDITORS}}
|
<!-- {{APP_LIST:EDITORS}} -->
|
||||||
</div>
|
<!-- </div> -->
|
||||||
|
|
||||||
<div class="info-block">
|
<!-- <div class="info-block"> -->
|
||||||
<h2 class="header">Other</h2>
|
<!-- <h2 class="header">Other</h2> -->
|
||||||
{{APP_LIST:OTHER}}
|
<!-- {{APP_LIST:OTHER}} -->
|
||||||
</div>
|
<!-- </div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -11,6 +11,7 @@ const getVscodeVersion = (): string => {
|
||||||
|
|
||||||
export const Vscode: Application = {
|
export const Vscode: Application = {
|
||||||
categories: ["Editor"],
|
categories: ["Editor"],
|
||||||
|
installed: true,
|
||||||
name: "VS Code",
|
name: "VS Code",
|
||||||
path: "/vscode",
|
path: "/vscode",
|
||||||
version: getVscodeVersion(),
|
version: getVscodeVersion(),
|
||||||
|
@ -23,5 +24,5 @@ export const findApplications = async (): Promise<ReadonlyArray<Application>> =>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const findWhitelistedApplications = async (): Promise<ReadonlyArray<Application>> => {
|
export const findWhitelistedApplications = async (): Promise<ReadonlyArray<Application>> => {
|
||||||
return []
|
return [Vscode]
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,10 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||||
const id = generateUuid()
|
const id = generateUuid()
|
||||||
const vscode = await this.fork()
|
const vscode = await this.fork()
|
||||||
|
|
||||||
logger.debug("Setting up VS Code...")
|
logger.debug("setting up vs code...")
|
||||||
return new Promise<WorkbenchOptions>((resolve, reject) => {
|
return new Promise<WorkbenchOptions>((resolve, reject) => {
|
||||||
vscode.once("message", (message: VscodeMessage) => {
|
vscode.once("message", (message: VscodeMessage) => {
|
||||||
logger.debug("Got message from VS Code", field("message", message))
|
logger.debug("got message from vs code", field("message", message))
|
||||||
return message.type === "options" && message.id === id
|
return message.type === "options" && message.id === id
|
||||||
? resolve(message.options)
|
? resolve(message.options)
|
||||||
: reject(new Error("Unexpected response during initialization"))
|
: reject(new Error("Unexpected response during initialization"))
|
||||||
|
@ -51,7 +51,7 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||||
|
|
||||||
private fork(): Promise<cp.ChildProcess> {
|
private fork(): Promise<cp.ChildProcess> {
|
||||||
if (!this._vscode) {
|
if (!this._vscode) {
|
||||||
logger.debug("Forking VS Code...")
|
logger.debug("forking vs code...")
|
||||||
const vscode = cp.fork(path.join(this.serverRootPath, "fork"))
|
const vscode = cp.fork(path.join(this.serverRootPath, "fork"))
|
||||||
vscode.on("error", (error) => {
|
vscode.on("error", (error) => {
|
||||||
logger.error(error.message)
|
logger.error(error.message)
|
||||||
|
@ -64,7 +64,7 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||||
|
|
||||||
this._vscode = new Promise((resolve, reject) => {
|
this._vscode = new Promise((resolve, reject) => {
|
||||||
vscode.once("message", (message: VscodeMessage) => {
|
vscode.once("message", (message: VscodeMessage) => {
|
||||||
logger.debug("Got message from VS Code", field("message", message))
|
logger.debug("got message from vs code", field("message", message))
|
||||||
return message.type === "ready"
|
return message.type === "ready"
|
||||||
? resolve(vscode)
|
? resolve(vscode)
|
||||||
: reject(new Error("Unexpected response waiting for ready response"))
|
: reject(new Error("Unexpected response waiting for ready response"))
|
||||||
|
|
|
@ -198,15 +198,16 @@ export const parse = (argv: string[]): Args => {
|
||||||
|
|
||||||
logger.debug("parsed command line", field("args", args))
|
logger.debug("parsed command line", field("args", args))
|
||||||
|
|
||||||
if (process.env.LOG_LEVEL === "trace" || args.verbose) {
|
// Ensure the environment variable and the flag are synced up. The flag takes
|
||||||
|
// priority over the environment variable.
|
||||||
|
if (args.log === "trace" || process.env.LOG_LEVEL === "trace" || args.verbose) {
|
||||||
|
args.log = process.env.LOG_LEVEL = "trace"
|
||||||
args.verbose = true
|
args.verbose = true
|
||||||
args.log = "trace"
|
} else if (!args.log && process.env.LOG_LEVEL) {
|
||||||
} else if (!args.log) {
|
|
||||||
args.log = process.env.LOG_LEVEL
|
args.log = process.env.LOG_LEVEL
|
||||||
}
|
} else if (args.log) {
|
||||||
|
|
||||||
// Ensure this passes down to forked processes.
|
|
||||||
process.env.LOG_LEVEL = args.log
|
process.env.LOG_LEVEL = args.log
|
||||||
|
}
|
||||||
|
|
||||||
switch (args.log) {
|
switch (args.log) {
|
||||||
case "trace":
|
case "trace":
|
||||||
|
|
|
@ -110,7 +110,7 @@ if (args.help) {
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
} else if (args["list-extensions"] || args["install-extension"] || args["uninstall-extension"]) {
|
} else if (args["list-extensions"] || args["install-extension"] || args["uninstall-extension"]) {
|
||||||
process.env.NBIN_BYPASS = "true"
|
process.env.NBIN_BYPASS = "true"
|
||||||
logger.debug("Forking VS Code CLI...")
|
logger.debug("forking vs code cli...")
|
||||||
const vscode = cp.fork(path.resolve(__dirname, "../../lib/vscode/out/vs/server/fork"), [], {
|
const vscode = cp.fork(path.resolve(__dirname, "../../lib/vscode/out/vs/server/fork"), [], {
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
|
|
|
@ -4,6 +4,10 @@ import { parse } from "../src/node/cli"
|
||||||
import { xdgLocalDir } from "../src/node/util"
|
import { xdgLocalDir } from "../src/node/util"
|
||||||
|
|
||||||
describe("cli", () => {
|
describe("cli", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
delete process.env.LOG_LEVEL
|
||||||
|
})
|
||||||
|
|
||||||
it("should set defaults", () => {
|
it("should set defaults", () => {
|
||||||
assert.deepEqual(parse([]), {
|
assert.deepEqual(parse([]), {
|
||||||
_: [],
|
_: [],
|
||||||
|
@ -86,6 +90,29 @@ describe("cli", () => {
|
||||||
verbose: true,
|
verbose: true,
|
||||||
version: true,
|
version: true,
|
||||||
})
|
})
|
||||||
|
assert.equal(process.env.LOG_LEVEL, "trace")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should use log level env var", () => {
|
||||||
|
process.env.LOG_LEVEL = "debug"
|
||||||
|
assert.deepEqual(parse([]), {
|
||||||
|
_: [],
|
||||||
|
"extensions-dir": path.join(xdgLocalDir, "extensions"),
|
||||||
|
"user-data-dir": xdgLocalDir,
|
||||||
|
log: "debug",
|
||||||
|
})
|
||||||
|
assert.equal(process.env.LOG_LEVEL, "debug")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should prefer --log to env var", () => {
|
||||||
|
process.env.LOG_LEVEL = "debug"
|
||||||
|
assert.deepEqual(parse(["--log", "info"]), {
|
||||||
|
_: [],
|
||||||
|
"extensions-dir": path.join(xdgLocalDir, "extensions"),
|
||||||
|
"user-data-dir": xdgLocalDir,
|
||||||
|
log: "info",
|
||||||
|
})
|
||||||
|
assert.equal(process.env.LOG_LEVEL, "info")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should error if value isn't provided", () => {
|
it("should error if value isn't provided", () => {
|
||||||
|
|
Loading…
Reference in New Issue