Skip to content

Commit 46d6e17

Browse files
committed
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
1 parent 1aaa536 commit 46d6e17

File tree

9 files changed

+108
-25
lines changed

9 files changed

+108
-25
lines changed

.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
trim_trailing_whitespace = true
6+
indent_size = 2

ci/build.ts

+38-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class Builder {
174174

175175
await this.copyDependencies("code-server", this.rootPath, this.buildPath, {
176176
commit,
177-
version: process.env.VERSION,
177+
version: this.codeServerVersion,
178178
})
179179
}
180180

@@ -204,13 +204,17 @@ class Builder {
204204

205205
const vscodeBuildPath = path.join(this.buildPath, "lib/vscode")
206206
await this.task("copying vs code into build directory", async () => {
207-
await fs.mkdirp(vscodeBuildPath)
207+
await fs.mkdirp(path.join(vscodeBuildPath, "resources/linux"))
208208
await Promise.all([
209209
fs.move(
210210
path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`),
211211
path.join(vscodeBuildPath, "out"),
212212
),
213213
fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")),
214+
fs.copy(
215+
path.join(this.vscodeSourcePath, "resources/linux/code.png"),
216+
path.join(vscodeBuildPath, "resources/linux/code.png"),
217+
),
214218
])
215219
})
216220

@@ -256,6 +260,38 @@ class Builder {
256260
* Bundles the built code into a binary.
257261
*/
258262
private async binary(binaryName: string): Promise<void> {
263+
// Prepend code to the target which enables finding files within the binary.
264+
const prependLoader = async (relativeFilePath: string): Promise<void> => {
265+
const filePath = path.join(this.buildPath, relativeFilePath)
266+
const shim = `
267+
if (!global.NBIN_LOADED) {
268+
try {
269+
const nbin = require("nbin");
270+
nbin.shimNativeFs("${this.buildPath}");
271+
global.NBIN_LOADED = true;
272+
const path = require("path");
273+
const rg = require("vscode-ripgrep");
274+
rg.binaryRgPath = rg.rgPath;
275+
rg.rgPath = path.join(require("os").tmpdir(), "code-server", path.basename(rg.binaryRgPath));
276+
} catch (error) { /* Not in the binary. */ }
277+
}
278+
`
279+
const content = await fs.readFile(filePath, "utf8")
280+
if (!content.startsWith(shim)) {
281+
await fs.writeFile(filePath, shim + content)
282+
}
283+
}
284+
285+
await this.task("Prepending nbin loader", () => {
286+
return Promise.all([
287+
prependLoader("out/node/entry.js"),
288+
prependLoader("lib/vscode/out/vs/server/entry.js"),
289+
prependLoader("lib/vscode/out/vs/server/fork.js"),
290+
prependLoader("lib/vscode/out/bootstrap-fork.js"),
291+
prependLoader("lib/vscode/extensions/node_modules/typescript/lib/tsserver.js"),
292+
])
293+
})
294+
259295
const bin = new Binary({
260296
mainFile: path.join(this.buildPath, "out/node/entry.js"),
261297
target: await this.target(),

src/browser/pages/home.css

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
.block-row > .item > .icon {
4747
height: 1rem;
4848
margin-right: 5px;
49+
vertical-align: top;
4950
width: 1rem;
5051
}
5152

src/browser/pages/home.html

+22-11
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,36 @@
2121
<body>
2222
<div class="center-container">
2323
<div class="info-blocks">
24+
<!-- TEMP: Only VS Code for now. -->
25+
<!-- <div class="info-block"> -->
26+
<!-- <h2 class="header">Running Applications</h2> -->
27+
<!-- {{APP_LIST:RUNNING}} -->
28+
<!-- </div> -->
29+
2430
<div class="info-block">
25-
<h2 class="header">Running Applications</h2>
26-
{{APP_LIST:RUNNING}}
31+
<h2 class="header">Launch</h2>
32+
<div class="block-row">
33+
<a class="item -link" href="./vscode">
34+
<img class="icon" src="./static-{{COMMIT}}/lib/vscode/resources/linux/code.png" />
35+
VS Code
36+
</a>
37+
</div>
2738
</div>
2839

2940
<div class="info-block">
30-
<h2 class="header">Update</h2>
41+
<h2 class="header">Version</h2>
3142
{{UPDATE:NAME}}
3243
</div>
3344

34-
<div class="info-block">
35-
<h2 class="header">Editors</h2>
36-
{{APP_LIST:EDITORS}}
37-
</div>
45+
<!-- <div class="info-block"> -->
46+
<!-- <h2 class="header">Editors</h2> -->
47+
<!-- {{APP_LIST:EDITORS}} -->
48+
<!-- </div> -->
3849

39-
<div class="info-block">
40-
<h2 class="header">Other</h2>
41-
{{APP_LIST:OTHER}}
42-
</div>
50+
<!-- <div class="info-block"> -->
51+
<!-- <h2 class="header">Other</h2> -->
52+
<!-- {{APP_LIST:OTHER}} -->
53+
<!-- </div> -->
4354
</div>
4455
</div>
4556
</body>

src/node/app/bin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const getVscodeVersion = (): string => {
1111

1212
export const Vscode: Application = {
1313
categories: ["Editor"],
14+
installed: true,
1415
name: "VS Code",
1516
path: "/vscode",
1617
version: getVscodeVersion(),
@@ -23,5 +24,5 @@ export const findApplications = async (): Promise<ReadonlyArray<Application>> =>
2324
}
2425

2526
export const findWhitelistedApplications = async (): Promise<ReadonlyArray<Application>> => {
26-
return []
27+
return [Vscode]
2728
}

src/node/app/vscode.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ export class VscodeHttpProvider extends HttpProvider {
3535
const id = generateUuid()
3636
const vscode = await this.fork()
3737

38-
logger.debug("Setting up VS Code...")
38+
logger.debug("setting up vs code...")
3939
return new Promise<WorkbenchOptions>((resolve, reject) => {
4040
vscode.once("message", (message: VscodeMessage) => {
41-
logger.debug("Got message from VS Code", field("message", message))
41+
logger.debug("got message from vs code", field("message", message))
4242
return message.type === "options" && message.id === id
4343
? resolve(message.options)
4444
: reject(new Error("Unexpected response during initialization"))
@@ -51,7 +51,7 @@ export class VscodeHttpProvider extends HttpProvider {
5151

5252
private fork(): Promise<cp.ChildProcess> {
5353
if (!this._vscode) {
54-
logger.debug("Forking VS Code...")
54+
logger.debug("forking vs code...")
5555
const vscode = cp.fork(path.join(this.serverRootPath, "fork"))
5656
vscode.on("error", (error) => {
5757
logger.error(error.message)
@@ -64,7 +64,7 @@ export class VscodeHttpProvider extends HttpProvider {
6464

6565
this._vscode = new Promise((resolve, reject) => {
6666
vscode.once("message", (message: VscodeMessage) => {
67-
logger.debug("Got message from VS Code", field("message", message))
67+
logger.debug("got message from vs code", field("message", message))
6868
return message.type === "ready"
6969
? resolve(vscode)
7070
: reject(new Error("Unexpected response waiting for ready response"))

src/node/cli.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,17 @@ export const parse = (argv: string[]): Args => {
198198

199199
logger.debug("parsed command line", field("args", args))
200200

201-
if (process.env.LOG_LEVEL === "trace" || args.verbose) {
201+
// Ensure the environment variable and the flag are synced up. The flag takes
202+
// priority over the environment variable.
203+
if (args.log === "trace" || process.env.LOG_LEVEL === "trace" || args.verbose) {
204+
args.log = process.env.LOG_LEVEL = "trace"
202205
args.verbose = true
203-
args.log = "trace"
204-
} else if (!args.log) {
206+
} else if (!args.log && process.env.LOG_LEVEL) {
205207
args.log = process.env.LOG_LEVEL
208+
} else if (args.log) {
209+
process.env.LOG_LEVEL = args.log
206210
}
207211

208-
// Ensure this passes down to forked processes.
209-
process.env.LOG_LEVEL = args.log
210-
211212
switch (args.log) {
212213
case "trace":
213214
logger.level = Level.Trace

src/node/entry.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if (args.help) {
110110
process.exit(0)
111111
} else if (args["list-extensions"] || args["install-extension"] || args["uninstall-extension"]) {
112112
process.env.NBIN_BYPASS = "true"
113-
logger.debug("Forking VS Code CLI...")
113+
logger.debug("forking vs code cli...")
114114
const vscode = cp.fork(path.resolve(__dirname, "../../lib/vscode/out/vs/server/fork"), [], {
115115
env: {
116116
...process.env,

test/cli.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { parse } from "../src/node/cli"
44
import { xdgLocalDir } from "../src/node/util"
55

66
describe("cli", () => {
7+
beforeEach(() => {
8+
delete process.env.LOG_LEVEL
9+
})
10+
711
it("should set defaults", () => {
812
assert.deepEqual(parse([]), {
913
_: [],
@@ -86,6 +90,29 @@ describe("cli", () => {
8690
verbose: true,
8791
version: true,
8892
})
93+
assert.equal(process.env.LOG_LEVEL, "trace")
94+
})
95+
96+
it("should use log level env var", () => {
97+
process.env.LOG_LEVEL = "debug"
98+
assert.deepEqual(parse([]), {
99+
_: [],
100+
"extensions-dir": path.join(xdgLocalDir, "extensions"),
101+
"user-data-dir": xdgLocalDir,
102+
log: "debug",
103+
})
104+
assert.equal(process.env.LOG_LEVEL, "debug")
105+
})
106+
107+
it("should prefer --log to env var", () => {
108+
process.env.LOG_LEVEL = "debug"
109+
assert.deepEqual(parse(["--log", "info"]), {
110+
_: [],
111+
"extensions-dir": path.join(xdgLocalDir, "extensions"),
112+
"user-data-dir": xdgLocalDir,
113+
log: "info",
114+
})
115+
assert.equal(process.env.LOG_LEVEL, "info")
89116
})
90117

91118
it("should error if value isn't provided", () => {

0 commit comments

Comments
 (0)