@spunto/build 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/script/index.ts +1 -0
- package/src/script/setup-script.ts +20 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spunto/build",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Spunto's shared Build engine — the devcontainer image protocol and VS Code extension registry clients, with no database, no HTTP framework and no UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/script/index.ts
CHANGED
|
@@ -1215,10 +1215,25 @@ export type StartScriptParams = {
|
|
|
1215
1215
|
* the image build used. Absent/unusable = Open VSX.
|
|
1216
1216
|
*/
|
|
1217
1217
|
extensionsGallery?: string | null
|
|
1218
|
+
/**
|
|
1219
|
+
* The port code-server listens on, 8080 by default (what every worker and the proxy's `code` host
|
|
1220
|
+
* assume). For a box where 8080 is taken by the host itself — a Blaxel sandbox's own API.
|
|
1221
|
+
*/
|
|
1222
|
+
idePort?: number
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/** code-server's port when the caller doesn't say otherwise. */
|
|
1226
|
+
export const DEFAULT_IDE_PORT = 8080
|
|
1227
|
+
|
|
1228
|
+
function idePortOf(port: number | undefined): number {
|
|
1229
|
+
if (port === undefined) return DEFAULT_IDE_PORT
|
|
1230
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(`idePort must be a TCP port, got ${port}`)
|
|
1231
|
+
return port
|
|
1218
1232
|
}
|
|
1219
1233
|
|
|
1220
1234
|
export function buildStartScript(params: StartScriptParams): { script: string; hasDinD: boolean } {
|
|
1221
1235
|
const { project, sshGatewayPublicKey, colorTabsByProject, extensionsGallery } = params
|
|
1236
|
+
const idePort = idePortOf(params.idePort)
|
|
1222
1237
|
const homeDir = "/home/vscode"
|
|
1223
1238
|
const username = "vscode"
|
|
1224
1239
|
|
|
@@ -1338,7 +1353,7 @@ export function buildStartScript(params: StartScriptParams): { script: string; h
|
|
|
1338
1353
|
// ── 4c. Restore the user's PORT secret for code-server's own terminal panel ─
|
|
1339
1354
|
// code-server reads $PORT to override --bind-addr (see § 5 below), so its
|
|
1340
1355
|
// whole process tree — including the integrated terminal it spawns — inherits
|
|
1341
|
-
// PORT
|
|
1356
|
+
// PORT=<idePort> unless corrected. `terminal.integrated.env.linux` lets VS Code
|
|
1342
1357
|
// inject env overrides into terminals it spawns without touching the server
|
|
1343
1358
|
// process itself, so a `PORT` project secret still reaches the user's shell.
|
|
1344
1359
|
// Uses code-server's own bundled node (guaranteed present regardless of the
|
|
@@ -1387,12 +1402,12 @@ export function buildStartScript(params: StartScriptParams): { script: string; h
|
|
|
1387
1402
|
"while true; do",
|
|
1388
1403
|
' VSCODE_PROXY_URI="${PUBLIC_PROTOCOL}://${WORKER_SLUG}-{{port}}.${BASE_DOMAIN}" \\',
|
|
1389
1404
|
// PORT is overridden here (not unset globally) so a project secret named
|
|
1390
|
-
// PORT can't make code-server bind elsewhere. This also leaks PORT
|
|
1405
|
+
// PORT can't make code-server bind elsewhere. This also leaks PORT=<idePort>
|
|
1391
1406
|
// into code-server's own process tree (its integrated terminal included) —
|
|
1392
1407
|
// § 4c above restores the original value for that terminal specifically.
|
|
1393
1408
|
// apps/agent/src/terminal.ts (dashboard's separate terminal feature) is a
|
|
1394
1409
|
// different process tree entirely and was never affected.
|
|
1395
|
-
|
|
1410
|
+
` PORT=${idePort} code-server --bind-addr 0.0.0.0:${idePort} --auth none /workspace 2>&1`,
|
|
1396
1411
|
' echo "[start] code-server exited ($?), restarting in 3s..."',
|
|
1397
1412
|
" sleep 3",
|
|
1398
1413
|
"done",
|
|
@@ -1491,6 +1506,7 @@ export type SetupPhase = {
|
|
|
1491
1506
|
// deleted once WORKER_SETUP_ORCHESTRATOR=agent becomes the default. See RFC 0017 §2.1.
|
|
1492
1507
|
export function buildContainerScript(params: StartScriptParams): { script: string; hasDinD: boolean } {
|
|
1493
1508
|
const { project, sshGatewayPublicKey, colorTabsByProject, extensionsGallery } = params
|
|
1509
|
+
const idePort = idePortOf(params.idePort)
|
|
1494
1510
|
const homeDir = "/home/vscode"
|
|
1495
1511
|
const username = "vscode"
|
|
1496
1512
|
|
|
@@ -1621,7 +1637,7 @@ export function buildContainerScript(params: StartScriptParams): { script: strin
|
|
|
1621
1637
|
...galleryExport(extensionsGallery),
|
|
1622
1638
|
"while true; do",
|
|
1623
1639
|
' VSCODE_PROXY_URI="${PUBLIC_PROTOCOL}://${WORKER_SLUG}-{{port}}.${BASE_DOMAIN}" \\',
|
|
1624
|
-
|
|
1640
|
+
` PORT=${idePort} code-server --bind-addr 0.0.0.0:${idePort} --auth none /workspace 2>&1`,
|
|
1625
1641
|
' echo "[start] code-server exited ($?), restarting in 3s..."',
|
|
1626
1642
|
" sleep 3",
|
|
1627
1643
|
"done",
|