@sixb/cli 0.1.20 → 0.1.22
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/README.md +21 -4
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/db-migrate.d.ts.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/desktop.d.ts +15 -0
- package/dist/commands/desktop.d.ts.map +1 -0
- package/dist/commands/dev-runner.d.ts +4 -0
- package/dist/commands/dev-runner.d.ts.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/lake-check.d.ts.map +1 -1
- package/dist/commands/lake-cleanup.d.ts +2 -0
- package/dist/commands/lake-cleanup.d.ts.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/orchestrator.d.ts.map +1 -1
- package/dist/commands/profile.d.ts.map +1 -1
- package/dist/commands/rules.d.ts.map +1 -1
- package/dist/commands/scheduler.d.ts.map +1 -1
- package/dist/commands/service-account.d.ts.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/token.d.ts.map +1 -1
- package/dist/commands/typegen.d.ts.map +1 -1
- package/dist/commands/worker-group.d.ts +2 -0
- package/dist/commands/worker-group.d.ts.map +1 -1
- package/dist/commands/worker.d.ts +2 -0
- package/dist/commands/worker.d.ts.map +1 -1
- package/dist/lib/command-line.d.ts +22 -2
- package/dist/lib/command-line.d.ts.map +1 -1
- package/dist/lib/deploy-release.d.ts +3 -1
- package/dist/lib/deploy-release.d.ts.map +1 -1
- package/dist/lib/desktop.d.ts +26 -0
- package/dist/lib/desktop.d.ts.map +1 -0
- package/dist/lib/dev-messages.d.ts +43 -0
- package/dist/lib/dev-messages.d.ts.map +1 -0
- package/dist/lib/dev-supervisor.d.ts +27 -0
- package/dist/lib/dev-supervisor.d.ts.map +1 -1
- package/dist/lib/open-url.d.ts +3 -0
- package/dist/lib/open-url.d.ts.map +1 -0
- package/dist/lib/role-lifecycle.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts +10 -0
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/worker-concurrency.d.ts +11 -0
- package/dist/lib/worker-concurrency.d.ts.map +1 -1
- package/dist/lib/worker-registry.d.ts +2 -0
- package/dist/lib/worker-registry.d.ts.map +1 -1
- package/dist/ui/deploy-screens.d.ts +48 -0
- package/dist/ui/deploy-screens.d.ts.map +1 -0
- package/dist/ui/index.d.ts +28 -233
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/layout.d.ts +65 -0
- package/dist/ui/layout.d.ts.map +1 -0
- package/dist/ui/live/ansi.d.ts +8 -0
- package/dist/ui/live/ansi.d.ts.map +1 -0
- package/dist/ui/live/can-run-live.d.ts +6 -0
- package/dist/ui/live/can-run-live.d.ts.map +1 -0
- package/dist/ui/live/components.d.ts +17 -0
- package/dist/ui/live/components.d.ts.map +1 -0
- package/dist/ui/live/deploy.d.ts +22 -0
- package/dist/ui/live/deploy.d.ts.map +1 -0
- package/dist/ui/live/dev.d.ts +47 -0
- package/dist/ui/live/dev.d.ts.map +1 -0
- package/dist/ui/live/prompt.d.ts +30 -0
- package/dist/ui/live/prompt.d.ts.map +1 -0
- package/dist/ui/live/session.d.ts +27 -0
- package/dist/ui/live/session.d.ts.map +1 -0
- package/dist/ui/screens.d.ts +136 -0
- package/dist/ui/screens.d.ts.map +1 -0
- package/dist/ui/theme.d.ts +58 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/package.json +21 -19
- package/src/commands/{api.tsx → api.ts} +18 -27
- package/src/commands/{app.tsx → app.ts} +14 -18
- package/src/commands/build.ts +70 -0
- package/src/commands/{check.tsx → check.ts} +74 -19
- package/src/commands/db-migrate.ts +32 -0
- package/src/commands/{deploy.tsx → deploy.ts} +109 -102
- package/src/commands/desktop.ts +71 -0
- package/src/commands/{dev-runner.tsx → dev-runner.ts} +67 -33
- package/src/commands/{init.tsx → init.ts} +19 -8
- package/src/commands/lake-check.ts +36 -0
- package/src/commands/{lake-cleanup.tsx → lake-cleanup.ts} +24 -8
- package/src/commands/{login.tsx → login.ts} +36 -30
- package/src/commands/{logout.tsx → logout.ts} +5 -5
- package/src/commands/{orchestrator.tsx → orchestrator.ts} +15 -28
- package/src/commands/{profile.tsx → profile.ts} +38 -19
- package/src/commands/{rules.tsx → rules.ts} +15 -24
- package/src/commands/{scheduler.tsx → scheduler.ts} +14 -27
- package/src/commands/{service-account.tsx → service-account.ts} +37 -39
- package/src/commands/{status.tsx → status.ts} +8 -8
- package/src/commands/{token.tsx → token.ts} +19 -20
- package/src/commands/typegen.ts +18 -0
- package/src/commands/{worker-group.tsx → worker-group.ts} +40 -29
- package/src/commands/{worker.tsx → worker.ts} +30 -22
- package/src/index.tsx +22 -1
- package/src/lib/command-line.ts +108 -57
- package/src/lib/deploy-release.ts +17 -1
- package/src/lib/desktop.ts +52 -0
- package/src/lib/dev-messages.ts +44 -0
- package/src/lib/dev-supervisor.ts +132 -12
- package/src/lib/open-url.ts +15 -0
- package/src/lib/role-lifecycle.ts +2 -3
- package/src/lib/runtime.ts +21 -0
- package/src/lib/worker-concurrency.ts +31 -0
- package/src/lib/worker-registry.ts +4 -0
- package/src/ui/README.md +54 -0
- package/src/ui/deploy-screens.ts +360 -0
- package/src/ui/index.ts +158 -0
- package/src/ui/layout.ts +245 -0
- package/src/ui/live/ansi.ts +103 -0
- package/src/ui/live/can-run-live.ts +9 -0
- package/src/ui/live/components.tsx +81 -0
- package/src/ui/live/deploy.tsx +170 -0
- package/src/ui/live/dev.tsx +522 -0
- package/src/ui/live/prompt.tsx +205 -0
- package/src/ui/live/session.ts +103 -0
- package/src/ui/screens.ts +490 -0
- package/src/ui/theme.ts +122 -0
- package/dist/lib/role-view.d.ts +0 -21
- package/dist/lib/role-view.d.ts.map +0 -1
- package/src/commands/build.tsx +0 -65
- package/src/commands/db-migrate.tsx +0 -30
- package/src/commands/lake-check.tsx +0 -20
- package/src/commands/typegen.tsx +0 -18
- package/src/lib/role-view.ts +0 -49
- package/src/ui/index.tsx +0 -1363
- /package/src/commands/{dev.tsx → dev.ts} +0 -0
|
@@ -34,18 +34,18 @@ import {
|
|
|
34
34
|
workflowPath,
|
|
35
35
|
} from "../lib/github-ci"
|
|
36
36
|
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
renderCliError,
|
|
46
|
-
renderPersistent,
|
|
37
|
+
cliErrorView,
|
|
38
|
+
deployAccessView,
|
|
39
|
+
deployChecksView,
|
|
40
|
+
deployCiView,
|
|
41
|
+
deployCompleteView,
|
|
42
|
+
deployReleaseView,
|
|
43
|
+
deployStatusView,
|
|
44
|
+
deployStepLine,
|
|
47
45
|
renderStatic,
|
|
46
|
+
withTask,
|
|
48
47
|
} from "../ui"
|
|
48
|
+
import { canRunLive } from "../ui/live/can-run-live"
|
|
49
49
|
|
|
50
50
|
export interface DeployOptions {
|
|
51
51
|
readonly dryRun?: boolean
|
|
@@ -61,27 +61,29 @@ export async function runDeploy(options: DeployOptions = {}): Promise<void> {
|
|
|
61
61
|
if (options.dryRun) {
|
|
62
62
|
const release = buildDeployRelease(config, { bunVersion: await resolveBunVersion(cwd) })
|
|
63
63
|
if (options.json) return writeJson(release)
|
|
64
|
-
await renderStatic(
|
|
65
|
-
<DeployReleaseView release={release} configPath={relative(cwd, path) || path} />
|
|
66
|
-
)
|
|
64
|
+
await renderStatic(deployReleaseView({ release, configPath: relative(cwd, path) || path }))
|
|
67
65
|
return
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
const deployStartedAt = Date.now()
|
|
69
|
+
const { source, release, checks } = await withTask("deploy", "Packing source", async (task) => {
|
|
70
|
+
const source = await packSource(cwd, options.ref)
|
|
71
|
+
const release = buildDeployRelease(config, {
|
|
72
|
+
bunVersion: await resolveBunVersion(cwd, source),
|
|
73
|
+
})
|
|
74
|
+
// Stop before uploading anything when the target already says the deploy cannot work.
|
|
75
|
+
task.step(`Checking ${location(config)}`)
|
|
76
|
+
const checks = await config.target.check(release, {
|
|
77
|
+
name: config.name,
|
|
78
|
+
projectPath: source.projectPath,
|
|
79
|
+
})
|
|
80
|
+
return { source, release, checks }
|
|
77
81
|
})
|
|
78
82
|
if (checks.some(blocksDeploy)) {
|
|
79
|
-
await renderStatic(
|
|
80
|
-
<DeployChecksView name={config.name} location={location(config)} checks={checks} />
|
|
81
|
-
)
|
|
83
|
+
await renderStatic(deployChecksView({ name: config.name, location: location(config), checks }))
|
|
82
84
|
process.exit(1)
|
|
83
85
|
}
|
|
84
|
-
const progress = createProgress(release, {
|
|
86
|
+
const progress = await createProgress(release, {
|
|
85
87
|
commit: source.commit,
|
|
86
88
|
ref: source.ref,
|
|
87
89
|
dirty: source.dirty,
|
|
@@ -93,17 +95,20 @@ export async function runDeploy(options: DeployOptions = {}): Promise<void> {
|
|
|
93
95
|
report: progress.report,
|
|
94
96
|
})
|
|
95
97
|
} catch (error) {
|
|
96
|
-
progress.fail()
|
|
97
98
|
const failed = progress.state.labels[progress.state.current ?? -1]
|
|
98
|
-
await
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
await progress.fail(
|
|
100
|
+
cliErrorView(error, {
|
|
101
|
+
title: failed ? `Deploy failed at "${failed}"` : "Deploy failed",
|
|
102
|
+
details: progress.state.output,
|
|
103
|
+
})
|
|
104
|
+
)
|
|
102
105
|
process.exit(1)
|
|
103
106
|
}
|
|
104
|
-
progress.finish(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
await progress.finish(
|
|
108
|
+
deployCompleteView({
|
|
109
|
+
release,
|
|
110
|
+
seconds: (Date.now() - deployStartedAt) / 1000,
|
|
111
|
+
})
|
|
107
112
|
)
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -111,15 +116,13 @@ export async function runDeployCheck(options: { readonly json?: boolean; readonl
|
|
|
111
116
|
const cwd = options.cwd ?? process.cwd()
|
|
112
117
|
const { config } = await loadDeployConfig(cwd)
|
|
113
118
|
const release = buildDeployRelease(config, { bunVersion: await resolveBunVersion(cwd) })
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
const projectPath = await projectPathOf(cwd)
|
|
120
|
+
const checks = await withTask("deploy check", `Checking ${location(config)}`, () =>
|
|
121
|
+
config.target.check(release, { name: config.name, projectPath })
|
|
122
|
+
)
|
|
118
123
|
if (options.json) writeJson(checks)
|
|
119
124
|
else
|
|
120
|
-
await renderStatic(
|
|
121
|
-
<DeployChecksView name={config.name} location={location(config)} checks={checks} />
|
|
122
|
-
)
|
|
125
|
+
await renderStatic(deployChecksView({ name: config.name, location: location(config), checks }))
|
|
123
126
|
if (checks.some(blocksDeploy)) process.exitCode = 1
|
|
124
127
|
}
|
|
125
128
|
|
|
@@ -144,9 +147,7 @@ export async function runDeploySetup(options: {
|
|
|
144
147
|
})
|
|
145
148
|
}
|
|
146
149
|
const checks = await config.target.check(release, context)
|
|
147
|
-
await renderStatic(
|
|
148
|
-
<DeployChecksView name={config.name} location={location(config)} checks={checks} />
|
|
149
|
-
)
|
|
150
|
+
await renderStatic(deployChecksView({ name: config.name, location: location(config), checks }))
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
export async function runDeployAccess(options: {
|
|
@@ -165,16 +166,16 @@ export async function runDeployAccess(options: {
|
|
|
165
166
|
if (options.action === "list") {
|
|
166
167
|
const keys = await access.list(context)
|
|
167
168
|
if (options.json) return writeJson(keys)
|
|
168
|
-
return renderStatic(
|
|
169
|
+
return renderStatic(deployAccessView({ title: `Keys for ${location(config)}`, keys }))
|
|
169
170
|
}
|
|
170
171
|
if (options.action === "add") {
|
|
171
172
|
const added: DeployAccessKey[] = []
|
|
172
173
|
for (const key of await publicKeys(options.value ?? ""))
|
|
173
174
|
added.push(await access.add(key, context))
|
|
174
|
-
return renderStatic(
|
|
175
|
+
return renderStatic(deployAccessView({ title: "Authorized", keys: added }))
|
|
175
176
|
}
|
|
176
177
|
const removed = await access.remove(options.value ?? "", context)
|
|
177
|
-
return renderStatic(
|
|
178
|
+
return renderStatic(deployAccessView({ title: "Revoked", keys: removed }))
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/**
|
|
@@ -236,24 +237,23 @@ export async function runDeployCi(options: { readonly branch?: string; readonly
|
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
await renderStatic(
|
|
239
|
-
|
|
240
|
-
name
|
|
241
|
-
repo
|
|
242
|
-
environment
|
|
243
|
-
branch
|
|
244
|
-
credential
|
|
245
|
-
secrets
|
|
246
|
-
retired
|
|
247
|
-
workflow
|
|
240
|
+
deployCiView({
|
|
241
|
+
name: config.name,
|
|
242
|
+
repo: repo.name,
|
|
243
|
+
environment: CI_ENVIRONMENT,
|
|
244
|
+
branch,
|
|
245
|
+
credential: credential.description,
|
|
246
|
+
secrets: Object.values(secrets),
|
|
247
|
+
retired,
|
|
248
|
+
workflow: {
|
|
248
249
|
path,
|
|
249
250
|
state: existing === null ? "written" : existing === workflow ? "unchanged" : "kept",
|
|
250
|
-
}
|
|
251
|
-
token
|
|
251
|
+
},
|
|
252
|
+
token:
|
|
252
253
|
privateSubmodules.length > 0 && !(await hasSecret(repo, SUBMODULE_TOKEN_SECRET))
|
|
253
254
|
? { name: SUBMODULE_TOKEN_SECRET, submodules: privateSubmodules }
|
|
254
|
-
: null
|
|
255
|
-
|
|
256
|
-
/>
|
|
255
|
+
: null,
|
|
256
|
+
})
|
|
257
257
|
)
|
|
258
258
|
}
|
|
259
259
|
|
|
@@ -287,10 +287,12 @@ function location(config: DeployConfig): string {
|
|
|
287
287
|
|
|
288
288
|
export async function runDeployStatus(options: { readonly json?: boolean; readonly cwd?: string }) {
|
|
289
289
|
const { config } = await loadDeployConfig(options.cwd)
|
|
290
|
-
const status = await
|
|
290
|
+
const status = await withTask("deploy status", `Asking ${config.target.location}`, () =>
|
|
291
|
+
config.target.status({ name: config.name })
|
|
292
|
+
)
|
|
291
293
|
if (options.json) return writeJson(status)
|
|
292
294
|
await renderStatic(
|
|
293
|
-
|
|
295
|
+
deployStatusView({ name: config.name, location: config.target.location, status })
|
|
294
296
|
)
|
|
295
297
|
}
|
|
296
298
|
|
|
@@ -324,11 +326,11 @@ export async function runDeployControl(options: {
|
|
|
324
326
|
const { config } = await loadDeployConfig(options.cwd)
|
|
325
327
|
await config.target.control(options.action, options.service, { name: config.name })
|
|
326
328
|
await renderStatic(
|
|
327
|
-
|
|
328
|
-
name
|
|
329
|
-
location
|
|
330
|
-
status
|
|
331
|
-
|
|
329
|
+
deployStatusView({
|
|
330
|
+
name: config.name,
|
|
331
|
+
location: config.target.location,
|
|
332
|
+
status: await config.target.status({ name: config.name }),
|
|
333
|
+
})
|
|
332
334
|
)
|
|
333
335
|
}
|
|
334
336
|
|
|
@@ -336,68 +338,73 @@ export async function runDeployControl(options: {
|
|
|
336
338
|
* Follows the target's progress: a live view in a terminal, one line per step and output line
|
|
337
339
|
* elsewhere, so CI logs read top to bottom.
|
|
338
340
|
*/
|
|
339
|
-
function createProgress(
|
|
341
|
+
async function createProgress(
|
|
340
342
|
release: DeployRelease,
|
|
341
343
|
source: { readonly commit: string; readonly ref: string; readonly dirty: boolean }
|
|
342
344
|
) {
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
labels: [],
|
|
350
|
-
done: 0,
|
|
351
|
-
current: null,
|
|
352
|
-
output: [],
|
|
353
|
-
outcome: "running",
|
|
345
|
+
const location = `${release.target.kind} ${release.target.location}`
|
|
346
|
+
const state = {
|
|
347
|
+
labels: [] as string[],
|
|
348
|
+
current: null as number | null,
|
|
349
|
+
/** The latest output lines of the step running now, kept when it fails. */
|
|
350
|
+
output: [] as string[],
|
|
354
351
|
}
|
|
355
|
-
const live =
|
|
356
|
-
|
|
352
|
+
const live = canRunLive()
|
|
353
|
+
? await (await import("../ui/live/deploy")).startLiveDeploy({
|
|
354
|
+
name: release.name,
|
|
355
|
+
location,
|
|
356
|
+
...source,
|
|
357
|
+
})
|
|
358
|
+
: null
|
|
357
359
|
const started = new Map<number, number>()
|
|
358
|
-
const
|
|
360
|
+
const seconds = (index: number) =>
|
|
361
|
+
((Date.now() - (started.get(index) ?? Date.now())) / 1000).toFixed(1)
|
|
359
362
|
|
|
360
363
|
if (!live) {
|
|
361
|
-
console.log(`Deploying ${release.name} ${source.commit.slice(0, 12)} to ${
|
|
364
|
+
console.log(`Deploying ${release.name} ${source.commit.slice(0, 12)} to ${location}`)
|
|
362
365
|
if (source.dirty) console.log("Uncommitted changes are not deployed.")
|
|
363
366
|
}
|
|
364
367
|
|
|
365
368
|
return {
|
|
366
369
|
state,
|
|
367
370
|
report(event: DeployEvent) {
|
|
368
|
-
if (event.type === "steps")
|
|
371
|
+
if (event.type === "steps") {
|
|
372
|
+
state.labels = [...event.labels]
|
|
373
|
+
live?.steps(state.labels)
|
|
374
|
+
}
|
|
369
375
|
if (event.type === "step" && event.status === "running") {
|
|
370
376
|
// A step's output is what explains its failure; earlier steps' would bury it.
|
|
371
377
|
state.output = []
|
|
372
378
|
state.current = event.index
|
|
373
379
|
started.set(event.index, Date.now())
|
|
374
|
-
if (
|
|
380
|
+
if (live) live.running(event.index)
|
|
381
|
+
else console.log(`▸ ${state.labels[event.index]}`)
|
|
375
382
|
}
|
|
376
383
|
if (event.type === "step" && event.status === "done") {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const seconds = ((Date.now() - (started.get(event.index) ?? Date.now())) / 1000).toFixed(
|
|
380
|
-
1
|
|
381
|
-
)
|
|
382
|
-
console.log(`✓ ${state.labels[event.index]} (${seconds}s)`)
|
|
383
|
-
}
|
|
384
|
+
if (live) live.done(event.index, seconds(event.index))
|
|
385
|
+
else console.log(deployStepLine(state.labels[event.index] ?? "", seconds(event.index)))
|
|
384
386
|
}
|
|
385
387
|
if (event.type === "output") {
|
|
386
388
|
state.output = [...state.output, event.line].slice(-12)
|
|
387
|
-
if (
|
|
389
|
+
if (live) live.output(event.line)
|
|
390
|
+
else console.log(` ${event.line}`)
|
|
388
391
|
}
|
|
389
|
-
render()
|
|
390
392
|
},
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
/** Ends the progress with the screen that explains how it ended. */
|
|
394
|
+
async fail(report: string) {
|
|
395
|
+
if (live) {
|
|
396
|
+
await live.failed(
|
|
397
|
+
state.current,
|
|
398
|
+
state.current === null ? null : seconds(state.current),
|
|
399
|
+
report
|
|
400
|
+
)
|
|
401
|
+
} else {
|
|
402
|
+
await renderStatic(report)
|
|
403
|
+
}
|
|
395
404
|
},
|
|
396
|
-
finish() {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
render()
|
|
400
|
-
app?.unmount()
|
|
405
|
+
async finish(report: string) {
|
|
406
|
+
if (live) await live.finished(report)
|
|
407
|
+
else await renderStatic(report)
|
|
401
408
|
},
|
|
402
409
|
}
|
|
403
410
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { join } from "node:path"
|
|
2
|
+
import { DEPLOY_CONFIG_FILE, loadDeployConfig } from "../lib/deploy-config"
|
|
3
|
+
import { deployPublicOrigins } from "../lib/deploy-release"
|
|
4
|
+
import { loadDesktop } from "../lib/desktop"
|
|
5
|
+
import { SixbCliError } from "../lib/errors"
|
|
6
|
+
import { configuredOrigin } from "../lib/public-origin"
|
|
7
|
+
import { keyValueResultView, renderStatic } from "../ui"
|
|
8
|
+
|
|
9
|
+
export interface DesktopBuildOptions {
|
|
10
|
+
readonly apiPublicOrigin?: string
|
|
11
|
+
readonly appPublicOrigin?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Packages the deployed app as a desktop app for this machine. */
|
|
15
|
+
export async function runDesktopBuild(options: DesktopBuildOptions = {}): Promise<void> {
|
|
16
|
+
const projectRoot = process.cwd()
|
|
17
|
+
const desktop = await loadDesktop(projectRoot)
|
|
18
|
+
const origins = await deployedOrigins(projectRoot, options)
|
|
19
|
+
const built = await desktop.buildDesktopApp({
|
|
20
|
+
projectRoot,
|
|
21
|
+
appUrl: origins.app,
|
|
22
|
+
apiOrigin: origins.api,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
await renderStatic(
|
|
26
|
+
keyValueResultView({
|
|
27
|
+
title: "Built the desktop app",
|
|
28
|
+
items: [
|
|
29
|
+
{ label: "Opens", value: origins.app },
|
|
30
|
+
{ label: "Output", value: built.path },
|
|
31
|
+
],
|
|
32
|
+
message: built.signed
|
|
33
|
+
? undefined
|
|
34
|
+
: "Unsigned: people who download it are warned before it opens. See @sixb/desktop's README to sign it.",
|
|
35
|
+
})
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Where the desktop app connects, found the way the production roles find their public origins:
|
|
41
|
+
* flags, then `SIXB_APP_PUBLIC_ORIGIN` and `SIXB_API_PUBLIC_ORIGIN`, then the deployment.
|
|
42
|
+
*/
|
|
43
|
+
export async function deployedOrigins(
|
|
44
|
+
projectRoot: string,
|
|
45
|
+
options: DesktopBuildOptions
|
|
46
|
+
): Promise<{ readonly app: string; readonly api: string }> {
|
|
47
|
+
const app = configuredOrigin(
|
|
48
|
+
options.appPublicOrigin,
|
|
49
|
+
"SIXB_APP_PUBLIC_ORIGIN",
|
|
50
|
+
"app public origin"
|
|
51
|
+
)
|
|
52
|
+
const api = configuredOrigin(
|
|
53
|
+
options.apiPublicOrigin,
|
|
54
|
+
"SIXB_API_PUBLIC_ORIGIN",
|
|
55
|
+
"API public origin"
|
|
56
|
+
)
|
|
57
|
+
const deployed =
|
|
58
|
+
(!app || !api) && (await Bun.file(join(projectRoot, DEPLOY_CONFIG_FILE)).exists())
|
|
59
|
+
? deployPublicOrigins((await loadDeployConfig(projectRoot)).config)
|
|
60
|
+
: {}
|
|
61
|
+
|
|
62
|
+
const origins = { app: app ?? deployed.app, api: api ?? deployed.api }
|
|
63
|
+
if (!origins.app || !origins.api) {
|
|
64
|
+
throw new SixbCliError("[SixbCLI] The desktop app needs to know where the app is deployed.", {
|
|
65
|
+
remediation:
|
|
66
|
+
`Describe the deployment in ${DEPLOY_CONFIG_FILE}, or set SIXB_APP_PUBLIC_ORIGIN and ` +
|
|
67
|
+
"SIXB_API_PUBLIC_ORIGIN.",
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
return { app: origins.app, api: origins.api }
|
|
71
|
+
}
|
|
@@ -14,12 +14,23 @@ import {
|
|
|
14
14
|
resolveBrowserTopology,
|
|
15
15
|
servedUrl,
|
|
16
16
|
} from "../lib/browser-topology"
|
|
17
|
+
import {
|
|
18
|
+
DEV_UI_ENV,
|
|
19
|
+
type DevChildMessage,
|
|
20
|
+
type DevReadyView,
|
|
21
|
+
type DevStartupStep,
|
|
22
|
+
} from "../lib/dev-messages"
|
|
23
|
+
import { errorMessage, errorRemediation } from "../lib/errors"
|
|
17
24
|
import { type LoadedSixbHost, loadSixbFromEntry } from "../lib/loadSixb"
|
|
18
25
|
import { stopQuietly } from "../lib/role-lifecycle"
|
|
19
26
|
import { startSixbRuntime, stopSixbProviders } from "../lib/runtime"
|
|
20
27
|
import { generateProjectTypes } from "../lib/typegen"
|
|
21
|
-
import {
|
|
22
|
-
|
|
28
|
+
import {
|
|
29
|
+
resolveSubagentConcurrency,
|
|
30
|
+
resolveVectorConcurrency,
|
|
31
|
+
resolveWorkerConcurrency,
|
|
32
|
+
} from "../lib/worker-concurrency"
|
|
33
|
+
import { devView, renderCliError, renderStatic, startTask } from "../ui"
|
|
23
34
|
|
|
24
35
|
export interface DevOptions {
|
|
25
36
|
entry?: string
|
|
@@ -32,6 +43,10 @@ export interface DevOptions {
|
|
|
32
43
|
agentTurnTimeout?: string
|
|
33
44
|
concurrency?: readonly string[]
|
|
34
45
|
vectorConcurrency?: string
|
|
46
|
+
subagentConcurrency?: string
|
|
47
|
+
subagentConcurrencyPerRun?: string
|
|
48
|
+
/** Also open the app in a desktop window. The supervisor does, so the window outlives restarts. */
|
|
49
|
+
desktop?: boolean
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
export async function runDevRuntime(options: DevOptions = {}) {
|
|
@@ -40,11 +55,20 @@ export async function runDevRuntime(options: DevOptions = {}) {
|
|
|
40
55
|
const agentTurnTimeoutMs = resolveAgentTurnTimeoutMs(options.agentTurnTimeout)
|
|
41
56
|
const workerConcurrency = resolveWorkerConcurrency(options.concurrency)
|
|
42
57
|
const vectorConcurrency = resolveVectorConcurrency(options.vectorConcurrency)
|
|
58
|
+
const subagents = resolveSubagentConcurrency({
|
|
59
|
+
perWorker: options.subagentConcurrency,
|
|
60
|
+
perRun: options.subagentConcurrencyPerRun,
|
|
61
|
+
})
|
|
43
62
|
const entry = resolve(options.entry ?? "sixb.config.ts")
|
|
44
63
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
64
|
+
// Under a supervisor that draws the live footer, this process reports and prints nothing.
|
|
65
|
+
const reportOnly = process.env[DEV_UI_ENV] === "footer"
|
|
66
|
+
const send = (message: DevChildMessage) => process.send?.(message)
|
|
67
|
+
const task = reportOnly ? null : startTask("dev", "Generating types")
|
|
68
|
+
const step = (name: DevStartupStep) => {
|
|
69
|
+
if (reportOnly) send({ type: "status", step: name })
|
|
70
|
+
else task?.step(name)
|
|
71
|
+
}
|
|
48
72
|
|
|
49
73
|
let customAppServer: CustomAppDevServer | null = null
|
|
50
74
|
let sixb: LoadedSixbHost | null = null
|
|
@@ -59,8 +83,10 @@ export async function runDevRuntime(options: DevOptions = {}) {
|
|
|
59
83
|
process.on("SIGTERM", requestShutdown)
|
|
60
84
|
|
|
61
85
|
try {
|
|
86
|
+
step("Generating types")
|
|
62
87
|
await generateProjectTypes({ entry })
|
|
63
88
|
abort.signal.throwIfAborted()
|
|
89
|
+
step("Loading project")
|
|
64
90
|
const host: LoadedSixbHost = await loadSixbFromEntry(entry)
|
|
65
91
|
sixb = host
|
|
66
92
|
abort.signal.throwIfAborted()
|
|
@@ -102,9 +128,7 @@ export async function runDevRuntime(options: DevOptions = {}) {
|
|
|
102
128
|
cohostWorkers: true,
|
|
103
129
|
api: {
|
|
104
130
|
start: () => {
|
|
105
|
-
|
|
106
|
-
<LoadingView title="Starting sixb" subtitle={entry} status="Starting server" />
|
|
107
|
-
)
|
|
131
|
+
step("Starting server")
|
|
108
132
|
return server.start()
|
|
109
133
|
},
|
|
110
134
|
stop: () => server.stop(),
|
|
@@ -113,48 +137,58 @@ export async function runDevRuntime(options: DevOptions = {}) {
|
|
|
113
137
|
agentTurnTimeoutMs,
|
|
114
138
|
workerConcurrency,
|
|
115
139
|
vectorConcurrency,
|
|
140
|
+
...subagents,
|
|
116
141
|
})
|
|
117
142
|
abort.signal.throwIfAborted()
|
|
118
143
|
|
|
119
|
-
|
|
144
|
+
step("Starting app")
|
|
120
145
|
const devApp = await startDevApp(customApp, { host: topology.host, port: topology.appPort })
|
|
121
146
|
customAppServer = devApp.server
|
|
122
147
|
abort.signal.throwIfAborted()
|
|
123
148
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
/>
|
|
142
|
-
)
|
|
149
|
+
const view: DevReadyView = {
|
|
150
|
+
name: sixb.id,
|
|
151
|
+
apiUrl: apiUrl(topology),
|
|
152
|
+
apiDocsUrl: apiDocsUrl(topology),
|
|
153
|
+
wsUrl: apiEventsUrl(topology),
|
|
154
|
+
appUrl: customAppServer ? servedUrl(topology) : null,
|
|
155
|
+
workers: [
|
|
156
|
+
{ type: "agent", worker: runtime.agentWorker },
|
|
157
|
+
{ type: "projection", worker: runtime.projectionWorker },
|
|
158
|
+
{ type: "pipeline", worker: runtime.pipelineWorker },
|
|
159
|
+
{ type: "workflow", worker: runtime.workflowWorker },
|
|
160
|
+
{ type: "sync", worker: runtime.syncWorker },
|
|
161
|
+
].flatMap(({ type, worker }) => (worker ? [{ type, concurrency: worker.concurrency }] : [])),
|
|
162
|
+
warnings: devApp.warning ? [devApp.warning, ...runtime.warnings] : runtime.warnings,
|
|
163
|
+
}
|
|
164
|
+
task?.stop()
|
|
165
|
+
if (!reportOnly) await renderStatic(devView(view))
|
|
143
166
|
|
|
144
167
|
process.env.SIXB_DEV_READY = "1"
|
|
145
|
-
|
|
168
|
+
send({
|
|
169
|
+
type: "ready",
|
|
170
|
+
watchesApp: customAppServer?.watchesSources ?? false,
|
|
171
|
+
app: customAppServer
|
|
172
|
+
? { url: servedUrl(topology), apiOrigin: topology.apiPublicOrigin }
|
|
173
|
+
: null,
|
|
174
|
+
view,
|
|
175
|
+
})
|
|
146
176
|
|
|
147
177
|
await Promise.race([stopped, runtime.waitForWorkerFailure()])
|
|
148
178
|
} catch (error) {
|
|
149
179
|
if (!abort.signal.aborted) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
180
|
+
const remediation = errorRemediation(error)
|
|
181
|
+
send({
|
|
182
|
+
type: "startup-error",
|
|
183
|
+
error: { message: errorMessage(error), ...(remediation ? { remediation } : {}) },
|
|
184
|
+
})
|
|
185
|
+
task?.stop()
|
|
186
|
+
if (!reportOnly) await renderCliError(error)
|
|
153
187
|
process.exitCode = 1
|
|
154
188
|
}
|
|
155
189
|
} finally {
|
|
156
190
|
process.env.SIXB_DEV_READY = ""
|
|
157
|
-
|
|
191
|
+
task?.stop()
|
|
158
192
|
await stopQuietly(() => customAppServer?.stop() ?? Promise.resolve())
|
|
159
193
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
160
194
|
if (sixb && !runtimeOwnsProviders) await stopSixbProviders(sixb)
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { relative, sep } from "node:path"
|
|
2
2
|
import { scaffoldProject } from "create-sixb/scaffold"
|
|
3
|
-
import {
|
|
3
|
+
import { initView, renderStatic } from "../ui"
|
|
4
|
+
import { canRunLive } from "../ui/live/can-run-live"
|
|
4
5
|
|
|
5
6
|
export async function runInit(dir?: string): Promise<void> {
|
|
6
|
-
const
|
|
7
|
+
const target = dir ?? (canRunLive() ? await askForDirectory() : ".")
|
|
8
|
+
const result = await scaffoldProject(target, { allowExisting: true })
|
|
7
9
|
|
|
8
10
|
await renderStatic(
|
|
9
|
-
|
|
10
|
-
name
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/>
|
|
11
|
+
initView({
|
|
12
|
+
name: result.name,
|
|
13
|
+
files: result.files,
|
|
14
|
+
commands: nextStepsFor(result.targetDir),
|
|
15
|
+
})
|
|
15
16
|
)
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
async function askForDirectory(): Promise<string> {
|
|
20
|
+
const { promptText } = await import("../ui/live/prompt")
|
|
21
|
+
return promptText({
|
|
22
|
+
command: "init",
|
|
23
|
+
label: "Project directory",
|
|
24
|
+
defaultValue: ".",
|
|
25
|
+
hint: "A new folder for the project, or . for this one",
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
function nextStepsFor(targetDir: string): string[] {
|
|
19
30
|
const target = relative(process.cwd(), targetDir)
|
|
20
31
|
const commands: string[] = []
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { errorMessage } from "../lib/errors"
|
|
2
|
+
import { loadSixbFromEntry } from "../lib/loadSixb"
|
|
3
|
+
import { resolveRuntimeEntry } from "../lib/production"
|
|
4
|
+
import {
|
|
5
|
+
checkRuntimeLakeDefinitions,
|
|
6
|
+
checkRuntimePipelineMarkings,
|
|
7
|
+
readAppliedMarkingNotices,
|
|
8
|
+
stopSixbProviders,
|
|
9
|
+
} from "../lib/runtime"
|
|
10
|
+
import { lakeCheckView, renderStatic, withTask } from "../ui"
|
|
11
|
+
|
|
12
|
+
export interface LakeCheckOptions {
|
|
13
|
+
entry?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function runLakeCheck(options: LakeCheckOptions = {}) {
|
|
17
|
+
const entry = await resolveRuntimeEntry({ entry: options.entry })
|
|
18
|
+
const sixb = await withTask("lake check", "Loading project", () => loadSixbFromEntry(entry))
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const warnings = await withTask("lake check", "Checking datasets", async (task) => {
|
|
22
|
+
await checkRuntimeLakeDefinitions(sixb)
|
|
23
|
+
task.step("Checking markings")
|
|
24
|
+
await checkRuntimePipelineMarkings(sixb)
|
|
25
|
+
|
|
26
|
+
// The code is right; what projections applied before it is a warning until they reproject.
|
|
27
|
+
return readAppliedMarkingNotices(sixb).catch((error: unknown) => [
|
|
28
|
+
`[SixbCLI] Could not read the dataset versions projections applied: ${errorMessage(error)}`,
|
|
29
|
+
])
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
await renderStatic(lakeCheckView({ projectId: sixb.id, warnings }))
|
|
33
|
+
} finally {
|
|
34
|
+
await stopSixbProviders(sixb)
|
|
35
|
+
}
|
|
36
|
+
}
|