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
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@ -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, {
|
||||
commit,
|
||||
version: process.env.VERSION,
|
||||
version: this.codeServerVersion,
|
||||
})
|
||||
}
|
||||
|
||||
@ -204,13 +204,17 @@ class Builder {
|
||||
|
||||
const vscodeBuildPath = path.join(this.buildPath, "lib/vscode")
|
||||
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([
|
||||
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")),
|
||||
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.
|
||||
*/
|
||||
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({
|
||||
mainFile: path.join(this.buildPath, "out/node/entry.js"),
|
||||
target: await this.target(),
|
||||
|
@ -46,6 +46,7 @@
|
||||
.block-row > .item > .icon {
|
||||
height: 1rem;
|
||||
margin-right: 5px;
|
||||
vertical-align: top;
|
||||
width: 1rem;
|
||||
}
|
||||
|
||||
|
@ -21,25 +21,36 @@
|
||||
<body>
|
||||
<div class="center-container">
|
||||
<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">
|
||||
<h2 class="header">Running Applications</h2>
|
||||
{{APP_LIST:RUNNING}}
|
||||
<h2 class="header">Launch</h2>
|
||||
<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 class="info-block">
|
||||
<h2 class="header">Update</h2>
|
||||
<h2 class="header">Version</h2>
|
||||
{{UPDATE:NAME}}
|
||||
</div>
|
||||
|
||||
<div class="info-block">
|
||||
<h2 class="header">Editors</h2>
|
||||
{{APP_LIST:EDITORS}}
|
||||
</div>
|
||||
<!-- <div class="info-block"> -->
|
||||
<!-- <h2 class="header">Editors</h2> -->
|
||||
<!-- {{APP_LIST:EDITORS}} -->
|
||||
<!-- </div> -->
|
||||
|
||||
<div class="info-block">
|
||||
<h2 class="header">Other</h2>
|
||||
{{APP_LIST:OTHER}}
|
||||
</div>
|
||||
<!-- <div class="info-block"> -->
|
||||
<!-- <h2 class="header">Other</h2> -->
|
||||
<!-- {{APP_LIST:OTHER}} -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -11,6 +11,7 @@ const getVscodeVersion = (): string => {
|
||||
|
||||
export const Vscode: Application = {
|
||||
categories: ["Editor"],
|
||||
installed: true,
|
||||
name: "VS Code",
|
||||
path: "/vscode",
|
||||
version: getVscodeVersion(),
|
||||
@ -23,5 +24,5 @@ export const findApplications = 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 vscode = await this.fork()
|
||||
|
||||
logger.debug("Setting up VS Code...")
|
||||
logger.debug("setting up vs code...")
|
||||
return new Promise<WorkbenchOptions>((resolve, reject) => {
|
||||
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
|
||||
? resolve(message.options)
|
||||
: reject(new Error("Unexpected response during initialization"))
|
||||
@ -51,7 +51,7 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||
|
||||
private fork(): Promise<cp.ChildProcess> {
|
||||
if (!this._vscode) {
|
||||
logger.debug("Forking VS Code...")
|
||||
logger.debug("forking vs code...")
|
||||
const vscode = cp.fork(path.join(this.serverRootPath, "fork"))
|
||||
vscode.on("error", (error) => {
|
||||
logger.error(error.message)
|
||||
@ -64,7 +64,7 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||
|
||||
this._vscode = new Promise((resolve, reject) => {
|
||||
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"
|
||||
? resolve(vscode)
|
||||
: reject(new Error("Unexpected response waiting for ready response"))
|
||||
|
@ -198,16 +198,17 @@ export const parse = (argv: string[]): 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.log = "trace"
|
||||
} else if (!args.log) {
|
||||
} else if (!args.log && process.env.LOG_LEVEL) {
|
||||
args.log = process.env.LOG_LEVEL
|
||||
} else if (args.log) {
|
||||
process.env.LOG_LEVEL = args.log
|
||||
}
|
||||
|
||||
// Ensure this passes down to forked processes.
|
||||
process.env.LOG_LEVEL = args.log
|
||||
|
||||
switch (args.log) {
|
||||
case "trace":
|
||||
logger.level = Level.Trace
|
||||
|
@ -110,7 +110,7 @@ if (args.help) {
|
||||
process.exit(0)
|
||||
} else if (args["list-extensions"] || args["install-extension"] || args["uninstall-extension"]) {
|
||||
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"), [], {
|
||||
env: {
|
||||
...process.env,
|
||||
|
@ -4,6 +4,10 @@ import { parse } from "../src/node/cli"
|
||||
import { xdgLocalDir } from "../src/node/util"
|
||||
|
||||
describe("cli", () => {
|
||||
beforeEach(() => {
|
||||
delete process.env.LOG_LEVEL
|
||||
})
|
||||
|
||||
it("should set defaults", () => {
|
||||
assert.deepEqual(parse([]), {
|
||||
_: [],
|
||||
@ -86,6 +90,29 @@ describe("cli", () => {
|
||||
verbose: 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", () => {
|
||||
|
Reference in New Issue
Block a user