@sixb/cli 0.1.21 → 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.
Files changed (129) hide show
  1. package/README.md +18 -3
  2. package/dist/commands/api.d.ts.map +1 -1
  3. package/dist/commands/app.d.ts.map +1 -1
  4. package/dist/commands/build.d.ts.map +1 -1
  5. package/dist/commands/check.d.ts.map +1 -1
  6. package/dist/commands/db-migrate.d.ts.map +1 -1
  7. package/dist/commands/deploy.d.ts.map +1 -1
  8. package/dist/commands/desktop.d.ts +15 -0
  9. package/dist/commands/desktop.d.ts.map +1 -0
  10. package/dist/commands/dev-runner.d.ts +4 -0
  11. package/dist/commands/dev-runner.d.ts.map +1 -1
  12. package/dist/commands/dev.d.ts.map +1 -1
  13. package/dist/commands/init.d.ts.map +1 -1
  14. package/dist/commands/lake-check.d.ts.map +1 -1
  15. package/dist/commands/lake-cleanup.d.ts.map +1 -1
  16. package/dist/commands/login.d.ts.map +1 -1
  17. package/dist/commands/logout.d.ts.map +1 -1
  18. package/dist/commands/orchestrator.d.ts.map +1 -1
  19. package/dist/commands/profile.d.ts.map +1 -1
  20. package/dist/commands/rules.d.ts.map +1 -1
  21. package/dist/commands/scheduler.d.ts.map +1 -1
  22. package/dist/commands/service-account.d.ts.map +1 -1
  23. package/dist/commands/status.d.ts.map +1 -1
  24. package/dist/commands/token.d.ts.map +1 -1
  25. package/dist/commands/typegen.d.ts.map +1 -1
  26. package/dist/commands/worker-group.d.ts +2 -0
  27. package/dist/commands/worker-group.d.ts.map +1 -1
  28. package/dist/commands/worker.d.ts +2 -0
  29. package/dist/commands/worker.d.ts.map +1 -1
  30. package/dist/lib/command-line.d.ts +22 -2
  31. package/dist/lib/command-line.d.ts.map +1 -1
  32. package/dist/lib/deploy-release.d.ts +3 -1
  33. package/dist/lib/deploy-release.d.ts.map +1 -1
  34. package/dist/lib/desktop.d.ts +26 -0
  35. package/dist/lib/desktop.d.ts.map +1 -0
  36. package/dist/lib/dev-messages.d.ts +43 -0
  37. package/dist/lib/dev-messages.d.ts.map +1 -0
  38. package/dist/lib/dev-supervisor.d.ts +27 -0
  39. package/dist/lib/dev-supervisor.d.ts.map +1 -1
  40. package/dist/lib/open-url.d.ts +3 -0
  41. package/dist/lib/open-url.d.ts.map +1 -0
  42. package/dist/lib/role-lifecycle.d.ts.map +1 -1
  43. package/dist/lib/runtime.d.ts +2 -0
  44. package/dist/lib/runtime.d.ts.map +1 -1
  45. package/dist/lib/worker-concurrency.d.ts +11 -0
  46. package/dist/lib/worker-concurrency.d.ts.map +1 -1
  47. package/dist/lib/worker-registry.d.ts +2 -0
  48. package/dist/lib/worker-registry.d.ts.map +1 -1
  49. package/dist/ui/deploy-screens.d.ts +48 -0
  50. package/dist/ui/deploy-screens.d.ts.map +1 -0
  51. package/dist/ui/index.d.ts +28 -244
  52. package/dist/ui/index.d.ts.map +1 -1
  53. package/dist/ui/layout.d.ts +65 -0
  54. package/dist/ui/layout.d.ts.map +1 -0
  55. package/dist/ui/live/ansi.d.ts +8 -0
  56. package/dist/ui/live/ansi.d.ts.map +1 -0
  57. package/dist/ui/live/can-run-live.d.ts +6 -0
  58. package/dist/ui/live/can-run-live.d.ts.map +1 -0
  59. package/dist/ui/live/components.d.ts +17 -0
  60. package/dist/ui/live/components.d.ts.map +1 -0
  61. package/dist/ui/live/deploy.d.ts +22 -0
  62. package/dist/ui/live/deploy.d.ts.map +1 -0
  63. package/dist/ui/live/dev.d.ts +47 -0
  64. package/dist/ui/live/dev.d.ts.map +1 -0
  65. package/dist/ui/live/prompt.d.ts +30 -0
  66. package/dist/ui/live/prompt.d.ts.map +1 -0
  67. package/dist/ui/live/session.d.ts +27 -0
  68. package/dist/ui/live/session.d.ts.map +1 -0
  69. package/dist/ui/screens.d.ts +136 -0
  70. package/dist/ui/screens.d.ts.map +1 -0
  71. package/dist/ui/theme.d.ts +58 -0
  72. package/dist/ui/theme.d.ts.map +1 -0
  73. package/package.json +19 -18
  74. package/src/commands/{api.tsx → api.ts} +18 -27
  75. package/src/commands/{app.tsx → app.ts} +14 -18
  76. package/src/commands/build.ts +70 -0
  77. package/src/commands/{check.tsx → check.ts} +27 -18
  78. package/src/commands/db-migrate.ts +32 -0
  79. package/src/commands/{deploy.tsx → deploy.ts} +109 -102
  80. package/src/commands/desktop.ts +71 -0
  81. package/src/commands/{dev-runner.tsx → dev-runner.ts} +67 -33
  82. package/src/commands/{init.tsx → init.ts} +19 -8
  83. package/src/commands/lake-check.ts +36 -0
  84. package/src/commands/{lake-cleanup.tsx → lake-cleanup.ts} +17 -12
  85. package/src/commands/{login.tsx → login.ts} +36 -30
  86. package/src/commands/{logout.tsx → logout.ts} +5 -5
  87. package/src/commands/{orchestrator.tsx → orchestrator.ts} +15 -28
  88. package/src/commands/{profile.tsx → profile.ts} +38 -19
  89. package/src/commands/{rules.tsx → rules.ts} +15 -24
  90. package/src/commands/{scheduler.tsx → scheduler.ts} +14 -27
  91. package/src/commands/{service-account.tsx → service-account.ts} +37 -39
  92. package/src/commands/{status.tsx → status.ts} +8 -8
  93. package/src/commands/{token.tsx → token.ts} +19 -20
  94. package/src/commands/typegen.ts +18 -0
  95. package/src/commands/{worker-group.tsx → worker-group.ts} +40 -29
  96. package/src/commands/{worker.tsx → worker.ts} +30 -22
  97. package/src/index.tsx +22 -1
  98. package/src/lib/command-line.ts +108 -57
  99. package/src/lib/deploy-release.ts +17 -1
  100. package/src/lib/desktop.ts +52 -0
  101. package/src/lib/dev-messages.ts +44 -0
  102. package/src/lib/dev-supervisor.ts +132 -12
  103. package/src/lib/open-url.ts +15 -0
  104. package/src/lib/role-lifecycle.ts +2 -3
  105. package/src/lib/runtime.ts +4 -0
  106. package/src/lib/worker-concurrency.ts +31 -0
  107. package/src/lib/worker-registry.ts +4 -0
  108. package/src/ui/README.md +54 -0
  109. package/src/ui/deploy-screens.ts +360 -0
  110. package/src/ui/index.ts +158 -0
  111. package/src/ui/layout.ts +245 -0
  112. package/src/ui/live/ansi.ts +103 -0
  113. package/src/ui/live/can-run-live.ts +9 -0
  114. package/src/ui/live/components.tsx +81 -0
  115. package/src/ui/live/deploy.tsx +170 -0
  116. package/src/ui/live/dev.tsx +522 -0
  117. package/src/ui/live/prompt.tsx +205 -0
  118. package/src/ui/live/session.ts +103 -0
  119. package/src/ui/screens.ts +490 -0
  120. package/src/ui/theme.ts +122 -0
  121. package/dist/lib/role-view.d.ts +0 -21
  122. package/dist/lib/role-view.d.ts.map +0 -1
  123. package/src/commands/build.tsx +0 -65
  124. package/src/commands/db-migrate.tsx +0 -30
  125. package/src/commands/lake-check.tsx +0 -33
  126. package/src/commands/typegen.tsx +0 -18
  127. package/src/lib/role-view.ts +0 -49
  128. package/src/ui/index.tsx +0 -1398
  129. /package/src/commands/{dev.tsx → dev.ts} +0 -0
package/src/ui/index.tsx DELETED
@@ -1,1398 +0,0 @@
1
- import type {
2
- DeployAccessKey,
3
- DeployCheck,
4
- DeployCommand,
5
- DeployRelease,
6
- DeployStatus,
7
- } from "@sixb/core/deploy"
8
- import { Box, render, Text } from "ink"
9
- import type React from "react"
10
- import { useEffect, useMemo, useState } from "react"
11
- import { CLI_EXAMPLES, type CliHelp, ROOT_HELP } from "../lib/command-line"
12
- import { errorMessage, errorRemediation } from "../lib/errors"
13
-
14
- // ─── Primitives ──────────────────────────────────────────────────────────────
15
-
16
- export async function renderStatic(view: React.ReactNode) {
17
- const app = render(<Box flexDirection="column">{view}</Box>, { exitOnCtrlC: false })
18
- // Let ink paint, then tear down explicitly. useApp().exit() + waitUntilExit()
19
- // stopped resolving in ink v6, which caused callers (e.g. `sixb worker`) to
20
- // hang and never reach their `process.exit(1)`, masking failures with exit 0.
21
- await new Promise<void>((resolve) => setImmediate(resolve))
22
- app.unmount()
23
- }
24
-
25
- export function renderPersistent(view: React.ReactNode) {
26
- return render(view, { exitOnCtrlC: false })
27
- }
28
-
29
- /**
30
- * Renders a caught failure the one way the CLI renders failures, so a remediation carried on
31
- * the error reaches the terminal without each caller remembering to pass it through.
32
- */
33
- export async function renderCliError(
34
- error: unknown,
35
- options: { readonly title?: string; readonly details?: readonly string[] } = {}
36
- ): Promise<void> {
37
- await renderStatic(
38
- <ErrorView
39
- {...(options.title ? { title: options.title } : {})}
40
- message={errorMessage(error)}
41
- {...(errorRemediation(error) ? { remediation: errorRemediation(error) } : {})}
42
- {...(options.details ? { details: options.details } : {})}
43
- />
44
- )
45
- }
46
-
47
- // The entrypoint and the app role render through these rather than JSX of their own: a module
48
- // with JSX loads React as soon as it is evaluated, and `app` loads neither React nor Ink outside a
49
- // terminal.
50
-
51
- export async function renderVersion(version: string): Promise<void> {
52
- await renderStatic(<VersionView version={version} />)
53
- }
54
-
55
- /** Root or command help, after the usage error that led to it when there is one. */
56
- export async function renderHelp(help: CliHelp, usageError?: string): Promise<void> {
57
- await renderStatic(
58
- help.path.length === 0 ? (
59
- <HelpView errorMessage={usageError} />
60
- ) : (
61
- <CommandHelpView help={help} errorMessage={usageError} />
62
- )
63
- )
64
- }
65
-
66
- export interface RoleStartupPanel {
67
- started(view: {
68
- readonly title: string
69
- readonly name: string
70
- readonly serviceName: string
71
- readonly items: KeyValueItem[]
72
- }): void
73
- unmount(): void
74
- }
75
-
76
- /** A long-running role's loading panel, replaced by its started view. */
77
- export function renderRoleStartup(loading: {
78
- readonly title: string
79
- readonly subtitle: string
80
- readonly status: string
81
- }): RoleStartupPanel {
82
- const app = renderPersistent(<LoadingView {...loading} />)
83
- return {
84
- started(view) {
85
- app.rerender(<RoleView {...view} />)
86
- },
87
- unmount() {
88
- app.unmount()
89
- },
90
- }
91
- }
92
-
93
- function SectionTitle({ children }: { children: React.ReactNode }) {
94
- return (
95
- <Text color="cyan" bold>
96
- {children}
97
- </Text>
98
- )
99
- }
100
-
101
- function Spacer() {
102
- return <Text> </Text>
103
- }
104
-
105
- function padLabel(label: string, width: number) {
106
- if (label.length >= width) return `${label} `
107
- return label.padEnd(width, " ")
108
- }
109
-
110
- export type KeyValueItem = { label: string; value: string }
111
-
112
- function isUrl(value: string): boolean {
113
- return /^(https?|wss?):\/\//.test(value)
114
- }
115
-
116
- function KeyValueList({
117
- items,
118
- labelWidth,
119
- }: {
120
- items: readonly KeyValueItem[]
121
- labelWidth?: number
122
- }) {
123
- const resolvedWidth = Math.max(labelWidth ?? 0, ...items.map((item) => item.label.length))
124
-
125
- return (
126
- <Box flexDirection="column">
127
- {items.map((item) => (
128
- <Text key={`${item.label}:${item.value}`}>
129
- <Text dimColor>{padLabel(item.label, resolvedWidth + 2)}</Text>
130
- <Text color={isUrl(item.value) ? "cyan" : undefined}>{item.value}</Text>
131
- </Text>
132
- ))}
133
- </Box>
134
- )
135
- }
136
-
137
- function Table({
138
- headers,
139
- rows,
140
- }: {
141
- headers: readonly string[]
142
- rows: readonly (readonly string[])[]
143
- }) {
144
- const widths = headers.map((header, index) =>
145
- Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0))
146
- )
147
-
148
- return (
149
- <Box flexDirection="column">
150
- <Text>
151
- {headers.map((header, index) => (
152
- <Text key={`${index}:${header}`} bold>
153
- {header.padEnd(widths[index] ?? header.length)}
154
- {index === headers.length - 1 ? "" : " "}
155
- </Text>
156
- ))}
157
- </Text>
158
- <Text dimColor>{widths.map((width) => "-".repeat(width)).join(" ")}</Text>
159
- {rows.map((row, rowIndex) => (
160
- <Text key={`${rowIndex}:${row.join(":")}`}>
161
- {row.map((value, index) => (
162
- <Text key={`${index}:${value}`}>
163
- {value.padEnd(widths[index] ?? value.length)}
164
- {index === row.length - 1 ? "" : " "}
165
- </Text>
166
- ))}
167
- </Text>
168
- ))}
169
- </Box>
170
- )
171
- }
172
-
173
- function Panel({
174
- title,
175
- meta,
176
- borderColor = "gray",
177
- children,
178
- }: {
179
- title: string
180
- meta?: React.ReactNode
181
- borderColor?: string
182
- children: React.ReactNode
183
- }) {
184
- return (
185
- <Box flexDirection="column" borderStyle="round" borderColor={borderColor} paddingX={1}>
186
- <Box justifyContent="space-between">
187
- <Text bold>{title}</Text>
188
- {meta ? <Box>{meta}</Box> : null}
189
- </Box>
190
- <Spacer />
191
- {children}
192
- </Box>
193
- )
194
- }
195
-
196
- export function KeyValueResultView({
197
- title,
198
- subtitle,
199
- items,
200
- titleColor = "green",
201
- message,
202
- }: {
203
- title: string
204
- subtitle?: string
205
- items: readonly KeyValueItem[]
206
- titleColor?: string
207
- message?: string
208
- }) {
209
- return (
210
- <Box flexDirection="column">
211
- <Text color={titleColor} bold>
212
- {title}
213
- </Text>
214
- {subtitle ? <Text dimColor>{subtitle}</Text> : null}
215
- <Spacer />
216
- <KeyValueList items={items} />
217
- {message ? (
218
- <>
219
- <Spacer />
220
- <Text dimColor>{message}</Text>
221
- </>
222
- ) : null}
223
- </Box>
224
- )
225
- }
226
-
227
- export function TableResultView({
228
- title,
229
- subtitle,
230
- headers,
231
- rows,
232
- emptyMessage,
233
- }: {
234
- title: string
235
- subtitle?: string
236
- headers: readonly string[]
237
- rows: readonly (readonly string[])[]
238
- emptyMessage: string
239
- }) {
240
- return (
241
- <Box flexDirection="column">
242
- <Text color="green" bold>
243
- {title}
244
- </Text>
245
- {subtitle ? <Text dimColor>{subtitle}</Text> : null}
246
- <Spacer />
247
- {rows.length > 0 ? (
248
- <Table headers={headers} rows={rows} />
249
- ) : (
250
- <Text dimColor>{emptyMessage}</Text>
251
- )}
252
- </Box>
253
- )
254
- }
255
-
256
- export function SecretResultView({
257
- title,
258
- subtitle,
259
- items,
260
- secretLabel = "Token",
261
- secret,
262
- message = "Store this token now. Sixb will not show it again.",
263
- }: {
264
- title: string
265
- subtitle?: string
266
- items: readonly KeyValueItem[]
267
- secretLabel?: string
268
- secret: string
269
- message?: string
270
- }) {
271
- return (
272
- <Box flexDirection="column">
273
- <Text color="green" bold>
274
- {title}
275
- </Text>
276
- {subtitle ? <Text dimColor>{subtitle}</Text> : null}
277
- <Spacer />
278
- <KeyValueList items={items} />
279
- <Spacer />
280
- <Panel title={secretLabel} borderColor="yellow">
281
- <Text>{secret}</Text>
282
- </Panel>
283
- {message ? (
284
- <>
285
- <Spacer />
286
- <Text dimColor>{message}</Text>
287
- </>
288
- ) : null}
289
- </Box>
290
- )
291
- }
292
-
293
- function ServicePanel({ name, items }: { name: string; items: KeyValueItem[] }) {
294
- return (
295
- <Box flexDirection="column">
296
- <Text bold>{name}</Text>
297
- <KeyValueList items={items} labelWidth={10} />
298
- </Box>
299
- )
300
- }
301
-
302
- /**
303
- * What the role did to the storage schema at startup, worded the same way by every
304
- * role. Absent when there was nothing to report, so a runtime without migrators does
305
- * not grow a panel that says nothing.
306
- */
307
- function StoragePanel({ summary }: { summary?: string | null }) {
308
- if (!summary) return null
309
-
310
- return (
311
- <>
312
- <Spacer />
313
- <ServicePanel name="Storage" items={[{ label: "Schema", value: summary }]} />
314
- </>
315
- )
316
- }
317
-
318
- function BulletList({ items, dim = false }: { items: readonly string[]; dim?: boolean }) {
319
- return (
320
- <Box flexDirection="column">
321
- {items.map((item, index) => (
322
- <Text key={`${index}:${item}`} dimColor={dim}>
323
- - {item}
324
- </Text>
325
- ))}
326
- </Box>
327
- )
328
- }
329
-
330
- function Spinner({ label }: { label: string }) {
331
- const frames = useMemo(() => ["|", "/", "-", "\\"], [])
332
- const [index, setIndex] = useState(0)
333
-
334
- useEffect(() => {
335
- const timer = setInterval(() => {
336
- setIndex((current) => (current + 1) % frames.length)
337
- }, 80)
338
-
339
- return () => clearInterval(timer)
340
- }, [frames.length])
341
-
342
- return (
343
- <Text>
344
- <Text color="cyan">{frames[index]}</Text> {label}
345
- </Text>
346
- )
347
- }
348
-
349
- // ─── Views ───────────────────────────────────────────────────────────────────
350
-
351
- export function LoadingView({
352
- title,
353
- subtitle,
354
- status,
355
- }: {
356
- title: string
357
- subtitle?: string
358
- status: string
359
- }) {
360
- return (
361
- <Box flexDirection="column">
362
- <Text color="green" bold>
363
- {title}
364
- </Text>
365
- {subtitle ? <Text dimColor>{subtitle}</Text> : null}
366
- <Spacer />
367
- <Text dimColor>Booting services</Text>
368
- <Spinner label={status} />
369
- </Box>
370
- )
371
- }
372
-
373
- export function HelpView({ errorMessage }: { errorMessage?: string }) {
374
- return (
375
- <Box flexDirection="column">
376
- <Text color="cyan" bold>
377
- sixb
378
- </Text>
379
- <Text dimColor>Real-time digital twin framework</Text>
380
- {errorMessage ? (
381
- <>
382
- <Spacer />
383
- <Text color="red">{errorMessage}</Text>
384
- </>
385
- ) : null}
386
- <Spacer />
387
- <SectionTitle>Usage</SectionTitle>
388
- <Text> {ROOT_HELP.usage}</Text>
389
- <Spacer />
390
- <SectionTitle>Commands</SectionTitle>
391
- <KeyValueList labelWidth={22} items={ROOT_HELP.commands} />
392
- <Spacer />
393
- <SectionTitle>Options</SectionTitle>
394
- <KeyValueList labelWidth={22} items={ROOT_HELP.options} />
395
- <Spacer />
396
- <SectionTitle>Examples</SectionTitle>
397
- <BulletList dim items={CLI_EXAMPLES} />
398
- </Box>
399
- )
400
- }
401
-
402
- export function CommandHelpView({ help, errorMessage }: { help: CliHelp; errorMessage?: string }) {
403
- return (
404
- <Box flexDirection="column">
405
- <Text color="cyan" bold>
406
- {help.path.length > 0 ? help.path.join(" ") : "sixb"}
407
- </Text>
408
- <Text dimColor>{help.summary}</Text>
409
- {errorMessage ? (
410
- <>
411
- <Spacer />
412
- <Text color="red">{errorMessage}</Text>
413
- </>
414
- ) : null}
415
- <Spacer />
416
- <SectionTitle>Usage</SectionTitle>
417
- <Text> {help.usage}</Text>
418
- {help.commands.length > 0 ? (
419
- <>
420
- <Spacer />
421
- <SectionTitle>Commands</SectionTitle>
422
- <KeyValueList items={help.commands} />
423
- </>
424
- ) : null}
425
- {help.options.length > 0 ? (
426
- <>
427
- <Spacer />
428
- <SectionTitle>Options</SectionTitle>
429
- <KeyValueList items={help.options} />
430
- </>
431
- ) : null}
432
- </Box>
433
- )
434
- }
435
-
436
- export function VersionView({ version }: { version: string }) {
437
- return <Text>{version}</Text>
438
- }
439
-
440
- export function ErrorView({
441
- title = "Error",
442
- message,
443
- remediation,
444
- details = [],
445
- }: {
446
- title?: string
447
- message: string
448
- /** What to do next. Rendered apart from the diagnosis, not appended to it. */
449
- remediation?: string
450
- details?: readonly string[]
451
- }) {
452
- return (
453
- <Box flexDirection="column">
454
- <Text color="red" bold>
455
- {title}
456
- </Text>
457
- <Spacer />
458
- <Panel title="Failure" borderColor="red">
459
- <Text>{message}</Text>
460
- </Panel>
461
- {remediation ? (
462
- <>
463
- <Spacer />
464
- <SectionTitle>Try this</SectionTitle>
465
- <Text>{remediation}</Text>
466
- </>
467
- ) : null}
468
- {details.length > 0 ? (
469
- <>
470
- <Spacer />
471
- <SectionTitle>Details</SectionTitle>
472
- <BulletList items={details} />
473
- </>
474
- ) : null}
475
- </Box>
476
- )
477
- }
478
-
479
- export function DevView({
480
- name,
481
- apiUrl,
482
- apiDocsUrl,
483
- wsUrl,
484
- appUrl,
485
- workers = [],
486
- warnings = [],
487
- }: {
488
- name: string
489
- apiUrl: string
490
- apiDocsUrl: string
491
- wsUrl: string
492
- /** `null` when the app could not start; a warning says why. */
493
- appUrl: string | null
494
- workers?: readonly { readonly type: string; readonly concurrency: number }[]
495
- warnings?: readonly string[]
496
- }) {
497
- const serverItems: KeyValueItem[] = [
498
- { label: "API", value: apiUrl },
499
- { label: "API docs", value: apiDocsUrl },
500
- { label: "Events", value: wsUrl },
501
- ]
502
-
503
- return (
504
- <Box flexDirection="column">
505
- <Text bold>sixb dev</Text>
506
- <Text dimColor>{name}</Text>
507
- <Spacer />
508
- <ServicePanel name="App" items={[{ label: "URL", value: appUrl ?? "not running" }]} />
509
- <Spacer />
510
- <ServicePanel name="Server" items={serverItems} />
511
- {workers.length > 0 ? (
512
- <>
513
- <Spacer />
514
- <ServicePanel
515
- name="Workers"
516
- items={workers.map((worker) => ({
517
- label: worker.type,
518
- value: `running · concurrency ${worker.concurrency}`,
519
- }))}
520
- />
521
- </>
522
- ) : null}
523
- {warnings.length > 0 ? (
524
- <>
525
- <Spacer />
526
- <Text color="yellow" bold>
527
- Warnings
528
- </Text>
529
- <BulletList items={warnings} />
530
- </>
531
- ) : null}
532
- <Spacer />
533
- <Text dimColor>ctrl+c to stop</Text>
534
- </Box>
535
- )
536
- }
537
-
538
- export function WorkerView({
539
- name,
540
- workerId,
541
- concurrency,
542
- storage,
543
- warnings = [],
544
- }: {
545
- name: string
546
- workerId: string
547
- concurrency: number
548
- storage?: string | null
549
- warnings?: readonly string[]
550
- }) {
551
- return (
552
- <Box flexDirection="column">
553
- <Text color="green" bold>
554
- Sixb worker started
555
- </Text>
556
- <Text dimColor>{name}</Text>
557
- <Spacer />
558
- <ServicePanel
559
- name="Worker"
560
- items={[
561
- { label: "ID", value: workerId },
562
- { label: "Concurrency", value: String(concurrency) },
563
- ]}
564
- />
565
- <StoragePanel summary={storage} />
566
- {warnings.length > 0 ? (
567
- <>
568
- <Spacer />
569
- <SectionTitle>Warnings</SectionTitle>
570
- <BulletList items={warnings} />
571
- </>
572
- ) : null}
573
- <Spacer />
574
- <Text dimColor>Press Ctrl+C to stop</Text>
575
- </Box>
576
- )
577
- }
578
-
579
- export function WorkerGroupView({
580
- name,
581
- workers,
582
- storage,
583
- warnings = [],
584
- }: {
585
- name: string
586
- workers: readonly { readonly type: string; readonly concurrency: number }[]
587
- storage?: string | null
588
- warnings?: readonly string[]
589
- }) {
590
- return (
591
- <Box flexDirection="column">
592
- <Text color="green" bold>
593
- Sixb worker group started
594
- </Text>
595
- <Text dimColor>{name}</Text>
596
- <Spacer />
597
- <ServicePanel
598
- name="Workers"
599
- items={workers.map((worker) => ({
600
- label: worker.type,
601
- value: `running · concurrency ${worker.concurrency}`,
602
- }))}
603
- />
604
- <StoragePanel summary={storage} />
605
- {warnings.length > 0 ? (
606
- <>
607
- <Spacer />
608
- <SectionTitle>Warnings</SectionTitle>
609
- <BulletList items={warnings} />
610
- </>
611
- ) : null}
612
- <Spacer />
613
- <Text dimColor>Press Ctrl+C to stop</Text>
614
- </Box>
615
- )
616
- }
617
-
618
- export function RoleView({
619
- title,
620
- name,
621
- serviceName,
622
- items,
623
- storage,
624
- warnings = [],
625
- }: {
626
- title: string
627
- name: string
628
- serviceName: string
629
- items: KeyValueItem[]
630
- storage?: string | null
631
- warnings?: readonly string[]
632
- }) {
633
- return (
634
- <Box flexDirection="column">
635
- <Text color="green" bold>
636
- {title}
637
- </Text>
638
- <Text dimColor>{name}</Text>
639
- <Spacer />
640
- <ServicePanel name={serviceName} items={items} />
641
- <StoragePanel summary={storage} />
642
- {warnings.length > 0 ? (
643
- <>
644
- <Spacer />
645
- <SectionTitle>Warnings</SectionTitle>
646
- <BulletList items={warnings} />
647
- </>
648
- ) : null}
649
- <Spacer />
650
- <Text dimColor>Press Ctrl+C to stop</Text>
651
- </Box>
652
- )
653
- }
654
-
655
- export function CheckView({
656
- projectId,
657
- storage,
658
- timeseries,
659
- broker,
660
- queues,
661
- projectValidation,
662
- markings,
663
- ontology,
664
- warnings,
665
- }: {
666
- projectId: string
667
- storage: { ok: boolean; message?: string }
668
- timeseries: { ok: boolean; message?: string }
669
- broker: { ok: boolean; message?: string }
670
- queues: { ok: boolean; message?: string }
671
- projectValidation?: { ok: boolean; message?: string }
672
- /**
673
- * The pipeline markings preflight: what SQL steps derive, checked against projections. A warning
674
- * reports projections whose applied version adds markings the code no longer declares.
675
- */
676
- markings?: { ok: boolean; warning?: boolean; message?: string }
677
- ontology?: { enabled: boolean; source: string; errors: number; warnings: number }
678
- warnings: readonly string[]
679
- }) {
680
- const validation = projectValidation ?? { ok: true, message: "ok" }
681
- const ontologyOk = (ontology?.errors ?? 0) === 0
682
- const markingsCheck = markings ?? { ok: true, message: "ok" }
683
- const allOk = [storage, timeseries, broker, queues, validation, markingsCheck].every(
684
- (row) => row.ok
685
- )
686
- const healthy = allOk && ontologyOk
687
-
688
- // The message wins when there is one, pass or fail: a probe that succeeded still says which
689
- // provider answered and whether its schema is current.
690
- function statusText(row: { ok: boolean; message?: string }): string {
691
- return row.message ?? (row.ok ? "ok" : "failed")
692
- }
693
-
694
- function statusColor(ok: boolean, warning = false): string {
695
- if (!ok) return "red"
696
- return warning ? "yellow" : "green"
697
- }
698
-
699
- return (
700
- <Box flexDirection="column">
701
- <Text color={healthy ? "green" : "red"} bold>
702
- {healthy ? "Sixb is healthy" : "Sixb has issues"}
703
- </Text>
704
- <Text dimColor>{projectId}</Text>
705
- <Spacer />
706
- <SectionTitle>Providers</SectionTitle>
707
- <Box flexDirection="column">
708
- <Text>
709
- <Text dimColor>{padLabel("Storage", 14)}</Text>
710
- <Text color={statusColor(storage.ok)}>{statusText(storage)}</Text>
711
- </Text>
712
- <Text>
713
- <Text dimColor>{padLabel("Timeseries", 14)}</Text>
714
- <Text color={statusColor(timeseries.ok)}>{statusText(timeseries)}</Text>
715
- </Text>
716
- <Text>
717
- <Text dimColor>{padLabel("Broker", 14)}</Text>
718
- <Text color={statusColor(broker.ok)}>{statusText(broker)}</Text>
719
- </Text>
720
- <Text>
721
- <Text dimColor>{padLabel("Queues", 14)}</Text>
722
- <Text color={statusColor(queues.ok)}>{statusText(queues)}</Text>
723
- </Text>
724
- <Text>
725
- <Text dimColor>{padLabel("Project", 14)}</Text>
726
- <Text color={statusColor(validation.ok)}>{statusText(validation)}</Text>
727
- </Text>
728
- <Text>
729
- <Text dimColor>{padLabel("Markings", 14)}</Text>
730
- <Text color={statusColor(markingsCheck.ok, markingsCheck.warning)}>
731
- {statusText(markingsCheck)}
732
- </Text>
733
- </Text>
734
- </Box>
735
- {ontology ? (
736
- <>
737
- <Spacer />
738
- <SectionTitle>Ontology</SectionTitle>
739
- <KeyValueList
740
- items={[
741
- { label: "Source", value: ontology.source },
742
- { label: "Errors", value: String(ontology.errors) },
743
- { label: "Warnings", value: String(ontology.warnings) },
744
- ]}
745
- />
746
- </>
747
- ) : null}
748
- {warnings.length > 0 ? (
749
- <>
750
- <Spacer />
751
- <SectionTitle>Warnings</SectionTitle>
752
- <BulletList items={warnings} />
753
- </>
754
- ) : null}
755
- </Box>
756
- )
757
- }
758
-
759
- export function BuildView({ entry, outdir }: { entry: string; outdir: string }) {
760
- return (
761
- <Box flexDirection="column">
762
- <Text color="green" bold>
763
- Built
764
- </Text>
765
- <Spacer />
766
- <KeyValueList
767
- items={[
768
- { label: "Entry", value: entry },
769
- { label: "Output", value: outdir },
770
- ]}
771
- />
772
- </Box>
773
- )
774
- }
775
-
776
- export function TypegenView({
777
- path,
778
- objectTypes,
779
- skipped,
780
- written,
781
- }: {
782
- path: string
783
- objectTypes: number
784
- skipped: boolean
785
- written: boolean
786
- }) {
787
- return (
788
- <Box flexDirection="column">
789
- <Text color="green" bold>
790
- Ontology types {skipped ? "skipped" : written ? "generated" : "current"}
791
- </Text>
792
- <Spacer />
793
- <KeyValueList
794
- items={[
795
- { label: "Output", value: path },
796
- { label: "Object types", value: String(objectTypes) },
797
- ]}
798
- />
799
- </Box>
800
- )
801
- }
802
-
803
- export function DbMigrateView({
804
- projectId,
805
- status,
806
- applied = [],
807
- }: {
808
- projectId: string
809
- status: "migrated" | "current" | "skipped"
810
- /** Migration step ids this run applied, named so the output can be checked. */
811
- applied?: readonly string[]
812
- }) {
813
- return (
814
- <Box flexDirection="column">
815
- <Text color="green" bold>
816
- Database migrations complete
817
- </Text>
818
- <Text dimColor>{projectId}</Text>
819
- <Spacer />
820
- <KeyValueList items={[{ label: "Storage", value: status }]} />
821
- {applied.length > 0 ? (
822
- <>
823
- <Spacer />
824
- <SectionTitle>Applied</SectionTitle>
825
- <BulletList items={applied} />
826
- </>
827
- ) : null}
828
- </Box>
829
- )
830
- }
831
-
832
- export function LakeCheckView({
833
- projectId,
834
- status,
835
- warnings = [],
836
- }: {
837
- projectId: string
838
- status: "ok"
839
- warnings?: readonly string[]
840
- }) {
841
- return (
842
- <Box flexDirection="column">
843
- <Text color="green" bold>
844
- Lake definitions compatible
845
- </Text>
846
- <Text dimColor>{projectId}</Text>
847
- <Spacer />
848
- <KeyValueList items={[{ label: "Lake", value: status }]} />
849
- {warnings.length > 0 ? (
850
- <>
851
- <Spacer />
852
- <SectionTitle>Warnings</SectionTitle>
853
- <BulletList items={warnings} />
854
- </>
855
- ) : null}
856
- </Box>
857
- )
858
- }
859
-
860
- export function DeployReleaseView({
861
- release,
862
- configPath,
863
- }: {
864
- release: DeployRelease
865
- configPath: string
866
- }) {
867
- const steps = [
868
- { label: "build", commands: release.steps.build },
869
- { label: "before start", commands: release.steps.beforeStart },
870
- ]
871
- const labelWidth =
872
- Math.max(
873
- ...release.services.map((service) => service.name.length),
874
- ...steps.map((step) => step.label.length)
875
- ) + 2
876
- const originWidth = Math.max(
877
- 0,
878
- ...release.services.map((service) => service.http?.publicOrigin.length ?? 0)
879
- )
880
- const origins = new Set(
881
- release.services.flatMap((service) => (service.http ? [service.http.publicOrigin] : []))
882
- )
883
- // The public origins already show beside their services; list only what the config set.
884
- const env = Object.entries(release.env).filter(
885
- ([key, value]) => !(key.endsWith("_PUBLIC_ORIGIN") && origins.has(value))
886
- )
887
-
888
- return (
889
- <Box flexDirection="column">
890
- <Text color="green" bold>
891
- {release.name} · dry run
892
- </Text>
893
- <Text dimColor>
894
- {release.target.kind} {release.target.location} · {configPath}
895
- </Text>
896
- <Spacer />
897
- <SectionTitle>Services</SectionTitle>
898
- {release.services.map((service) => (
899
- <Box key={service.name}>
900
- <Box width={labelWidth} flexShrink={0}>
901
- <Text bold>{service.name}</Text>
902
- </Box>
903
- <Box flexDirection="column">
904
- {service.http ? (
905
- <Text>
906
- <Text color="cyan">{padLabel(service.http.publicOrigin, originWidth + 2)}</Text>
907
- <Text dimColor>
908
- → {service.http.host}:{service.http.port}
909
- </Text>
910
- </Text>
911
- ) : (
912
- <Text dimColor>{describeDeployProcess(service)}</Text>
913
- )}
914
- <Text dimColor>{formatDeployCommand(service.command)}</Text>
915
- {Object.entries(service.env)
916
- .filter(([key, value]) => release.env[key] !== value)
917
- .map(([key, value]) => (
918
- <Text key={key} dimColor>
919
- {key}={value}
920
- </Text>
921
- ))}
922
- </Box>
923
- </Box>
924
- ))}
925
- <Spacer />
926
- <SectionTitle>Steps</SectionTitle>
927
- {steps.map((step) => (
928
- <Box key={step.label}>
929
- <Box width={labelWidth} flexShrink={0}>
930
- <Text bold>{step.label}</Text>
931
- </Box>
932
- <Text>{step.commands.map(formatDeployCommand).join(" → ")}</Text>
933
- </Box>
934
- ))}
935
- <Spacer />
936
- <SectionTitle>Environment</SectionTitle>
937
- {env.map(([key, value]) => (
938
- <Text key={key}>
939
- {key}={value}
940
- </Text>
941
- ))}
942
- {origins.size > 0 ? <Text dimColor>plus the public origins above</Text> : null}
943
- <Spacer />
944
- <Text dimColor>Nothing was deployed · --json prints the full release</Text>
945
- </Box>
946
- )
947
- }
948
-
949
- export interface DeployProgressState {
950
- readonly name: string
951
- readonly location: string
952
- readonly commit: string
953
- readonly ref: string
954
- readonly dirty: boolean
955
- readonly labels: readonly string[]
956
- /** How many steps have finished, in order. */
957
- readonly done: number
958
- readonly current: number | null
959
- /** The latest output lines, shown while a step runs and kept when one fails. */
960
- readonly output: readonly string[]
961
- readonly outcome: "running" | "done" | "failed"
962
- }
963
-
964
- export function DeployProgressView({ state }: { state: DeployProgressState }) {
965
- return (
966
- <Box flexDirection="column">
967
- <Text bold>
968
- {state.name} → {state.location}
969
- </Text>
970
- <Text dimColor>
971
- {state.commit.slice(0, 12)} · {state.ref}
972
- </Text>
973
- {state.dirty ? <Text color="yellow">Uncommitted changes are not deployed.</Text> : null}
974
- <Spacer />
975
- {state.labels.length === 0 ? (
976
- <Spinner label="Connecting…" />
977
- ) : (
978
- state.labels.map((label, index) => {
979
- if (index < state.done) {
980
- return (
981
- <Text key={`${index}:${label}`}>
982
- <Text color="green">✓</Text> {label}
983
- </Text>
984
- )
985
- }
986
- if (index === state.current && state.outcome === "failed") {
987
- return (
988
- <Text key={`${index}:${label}`} color="red">
989
- ✕ {label}
990
- </Text>
991
- )
992
- }
993
- if (index === state.current && state.outcome === "running") {
994
- return <Spinner key={`${index}:${label}`} label={label} />
995
- }
996
- return (
997
- <Text key={`${index}:${label}`} dimColor>
998
- · {label}
999
- </Text>
1000
- )
1001
- })
1002
- )}
1003
- {state.outcome === "running" && state.output.length > 0 ? (
1004
- <Box flexDirection="column" marginTop={1} paddingLeft={2}>
1005
- {state.output.slice(-6).map((line, index) => (
1006
- <Text key={`${index}:${line}`} dimColor wrap="truncate-end">
1007
- {line}
1008
- </Text>
1009
- ))}
1010
- </Box>
1011
- ) : null}
1012
- </Box>
1013
- )
1014
- }
1015
-
1016
- export function DeployCompleteView({
1017
- release,
1018
- commit,
1019
- ref,
1020
- }: {
1021
- release: DeployRelease
1022
- commit: string
1023
- ref: string
1024
- }) {
1025
- const urls = release.services.flatMap((service) =>
1026
- service.http ? [{ label: service.name, value: service.http.publicOrigin }] : []
1027
- )
1028
- return (
1029
- <Box flexDirection="column">
1030
- <Spacer />
1031
- <Text color="green" bold>
1032
- {release.name} deployed
1033
- </Text>
1034
- <Text dimColor>
1035
- {commit.slice(0, 12)} · {ref} · {release.target.kind} {release.target.location}
1036
- </Text>
1037
- {urls.length > 0 ? (
1038
- <>
1039
- <Spacer />
1040
- <KeyValueList items={urls} />
1041
- </>
1042
- ) : null}
1043
- </Box>
1044
- )
1045
- }
1046
-
1047
- export function DeployStatusView({
1048
- name,
1049
- location,
1050
- status,
1051
- }: {
1052
- name: string
1053
- location: string
1054
- status: DeployStatus
1055
- }) {
1056
- if (!status.release) {
1057
- return (
1058
- <Box flexDirection="column">
1059
- <Text bold>{name}</Text>
1060
- <Text dimColor>Nothing is deployed on {location} yet. Run `sixb deploy`.</Text>
1061
- </Box>
1062
- )
1063
- }
1064
- const healthy =
1065
- status.running && status.processes.every((process) => process.status === "running")
1066
- return (
1067
- <Box flexDirection="column">
1068
- <Text color={healthy ? "green" : "yellow"} bold>
1069
- {name} {healthy ? "is running" : status.running ? "needs attention" : "is stopped"}
1070
- </Text>
1071
- <Text dimColor>
1072
- {status.release.commit.slice(0, 12)} · {status.release.ref} · deployed{" "}
1073
- {formatAge(status.release.deployedAt)} by {status.release.deployedBy} · {location}
1074
- </Text>
1075
- <Spacer />
1076
- {status.processes.length > 0 ? (
1077
- <Table
1078
- headers={["Service", "Status", "PID", "CPU", "Memory", "Restarts", "Up"]}
1079
- rows={status.processes.map((process) => [
1080
- process.instance === 0 ? process.service : `${process.service}#${process.instance}`,
1081
- process.status,
1082
- process.pid === undefined ? "-" : String(process.pid),
1083
- process.cpuPercent === undefined ? "-" : `${process.cpuPercent.toFixed(1)}%`,
1084
- process.memoryBytes === undefined ? "-" : formatBytes(process.memoryBytes),
1085
- String(process.restarts),
1086
- process.status === "running" && process.startedAt
1087
- ? formatAge(process.startedAt, "")
1088
- : "-",
1089
- ])}
1090
- />
1091
- ) : (
1092
- <Text dimColor>The supervisor is not running.</Text>
1093
- )}
1094
- {status.processes
1095
- .filter((process) => process.lastError)
1096
- .map((process) => (
1097
- <Text key={`${process.service}#${process.instance}`} color="yellow">
1098
- {process.service}: {process.lastError}
1099
- </Text>
1100
- ))}
1101
- </Box>
1102
- )
1103
- }
1104
-
1105
- const CHECK_MARKS = {
1106
- ok: { glyph: "✓", color: "green" },
1107
- fixable: { glyph: "●", color: "yellow" },
1108
- manual: { glyph: "○", color: "yellow" },
1109
- warning: { glyph: "!", color: "yellow" },
1110
- } as const satisfies Record<DeployCheck["status"], { glyph: string; color: string }>
1111
-
1112
- export function DeployChecksView({
1113
- name,
1114
- location,
1115
- checks,
1116
- }: {
1117
- name: string
1118
- location: string
1119
- checks: readonly DeployCheck[]
1120
- }) {
1121
- const blocking = checks.filter((check) => check.status === "fixable" || check.status === "manual")
1122
- const warnings = checks.filter((check) => check.status === "warning")
1123
- const labelWidth = Math.max(...checks.map((check) => check.label.length)) + 2
1124
- const next = blocking.some((check) => check.status === "fixable")
1125
- ? "Next: sixb deploy setup"
1126
- : blocking.length > 0
1127
- ? "Next: the steps above, then sixb deploy check"
1128
- : "Next: sixb deploy"
1129
-
1130
- return (
1131
- <Box flexDirection="column">
1132
- <Text color={blocking.length > 0 ? "yellow" : "green"} bold>
1133
- {name}{" "}
1134
- {blocking.length > 0
1135
- ? `· ${blocking.length} to fix before deploying`
1136
- : `is ready to deploy${warnings.length > 0 ? ` · ${warnings.length} to look at` : ""}`}
1137
- </Text>
1138
- <Text dimColor>{location}</Text>
1139
- <Spacer />
1140
- {checks.map((check) => (
1141
- <Box key={check.id}>
1142
- <Box width={2} flexShrink={0}>
1143
- <Text color={CHECK_MARKS[check.status].color}>{CHECK_MARKS[check.status].glyph}</Text>
1144
- </Box>
1145
- <Box width={labelWidth} flexShrink={0}>
1146
- <Text>{check.label}</Text>
1147
- </Box>
1148
- <Box flexDirection="column">
1149
- <Text dimColor>{check.detail}</Text>
1150
- {check.remedy ? <Text color="cyan">{check.remedy}</Text> : null}
1151
- </Box>
1152
- </Box>
1153
- ))}
1154
- <Spacer />
1155
- <Text dimColor>{next}</Text>
1156
- </Box>
1157
- )
1158
- }
1159
-
1160
- export function DeployCiView({
1161
- name,
1162
- repo,
1163
- environment,
1164
- branch,
1165
- credential,
1166
- secrets,
1167
- retired,
1168
- workflow,
1169
- token,
1170
- }: {
1171
- name: string
1172
- repo: string
1173
- environment: string
1174
- branch: string
1175
- credential: string
1176
- secrets: readonly string[]
1177
- retired: readonly DeployAccessKey[]
1178
- workflow: { readonly path: string; readonly state: "written" | "unchanged" | "kept" }
1179
- token: {
1180
- readonly name: string
1181
- readonly submodules: readonly {
1182
- readonly path: string
1183
- readonly url: string
1184
- readonly repo: string | null
1185
- }[]
1186
- } | null
1187
- }) {
1188
- const rows: { label: string; ok: boolean; detail: string; remedy?: string }[] = [
1189
- { label: "Key", ok: true, detail: credential },
1190
- { label: "Secrets", ok: true, detail: secrets.join(", ") },
1191
- {
1192
- label: "Older keys",
1193
- ok: true,
1194
- detail:
1195
- retired.length === 0
1196
- ? "none to revoke"
1197
- : `revoked ${retired.map((key) => key.fingerprint).join(", ")}`,
1198
- },
1199
- {
1200
- label: "Workflow",
1201
- ok: true,
1202
- detail: {
1203
- written: workflow.path,
1204
- unchanged: `${workflow.path} (unchanged)`,
1205
- kept: `${workflow.path} (yours, kept: it differs from what this command writes; delete it and run again to start over)`,
1206
- }[workflow.state],
1207
- },
1208
- ...(token
1209
- ? [
1210
- {
1211
- label: "Token",
1212
- ok: false,
1213
- detail: `${token.submodules.map((submodule) => submodule.path).join(", ")} ${token.submodules.length === 1 ? "is" : "are"} private, and CI cannot read ${token.submodules.length === 1 ? "it" : "them"} with its own token.`,
1214
- remedy: `Create a fine-grained token with Contents: read on ${token.submodules.map((submodule) => submodule.repo ?? submodule.url).join(", ")}, then run \`gh secret set ${token.name} --env ${environment} --repo ${repo}\`.`,
1215
- },
1216
- ]
1217
- : []),
1218
- ]
1219
- const labelWidth = Math.max(...rows.map((row) => row.label.length)) + 2
1220
- const next =
1221
- workflow.state === "written"
1222
- ? `Next: commit ${workflow.path} and push to ${branch}.`
1223
- : `Next: push to ${branch} to deploy.`
1224
-
1225
- return (
1226
- <Box flexDirection="column">
1227
- <Text color={token ? "yellow" : "green"} bold>
1228
- {name} deploys from GitHub Actions on every push to {branch}
1229
- </Text>
1230
- <Text dimColor>
1231
- {repo} · environment {environment}
1232
- </Text>
1233
- <Spacer />
1234
- {rows.map((row) => (
1235
- <Box key={row.label}>
1236
- <Box width={2} flexShrink={0}>
1237
- <Text color={row.ok ? "green" : "yellow"}>{row.ok ? "✓" : "○"}</Text>
1238
- </Box>
1239
- <Box width={labelWidth} flexShrink={0}>
1240
- <Text>{row.label}</Text>
1241
- </Box>
1242
- <Box flexDirection="column">
1243
- <Text dimColor>{row.detail}</Text>
1244
- {row.remedy ? <Text color="cyan">{row.remedy}</Text> : null}
1245
- </Box>
1246
- </Box>
1247
- ))}
1248
- <Spacer />
1249
- <Text dimColor>{next}</Text>
1250
- </Box>
1251
- )
1252
- }
1253
-
1254
- export function DeployAccessView({
1255
- title,
1256
- keys,
1257
- }: {
1258
- title: string
1259
- keys: readonly DeployAccessKey[]
1260
- }) {
1261
- // Two lines a key: a fingerprint and a long comment do not fit side by side in 80 columns.
1262
- return (
1263
- <Box flexDirection="column">
1264
- <Text color="green" bold>
1265
- {title}
1266
- </Text>
1267
- <Spacer />
1268
- {keys.length === 0 ? <Text dimColor>No keys.</Text> : null}
1269
- {keys.map((key) => (
1270
- <Box key={key.fingerprint} flexDirection="column">
1271
- <Text>
1272
- {key.comment || "(no comment)"}
1273
- {key.restricted ? <Text color="yellow"> restricted</Text> : null}
1274
- </Text>
1275
- <Text dimColor>
1276
- {" "}
1277
- {key.type} {key.fingerprint}
1278
- </Text>
1279
- </Box>
1280
- ))}
1281
- </Box>
1282
- )
1283
- }
1284
-
1285
- function formatAge(iso: string, suffix = " ago"): string {
1286
- const seconds = Math.max(0, Math.round((Date.now() - Date.parse(iso)) / 1000))
1287
- const age =
1288
- seconds < 60
1289
- ? `${seconds}s`
1290
- : seconds < 3600
1291
- ? `${Math.floor(seconds / 60)}m`
1292
- : seconds < 86_400
1293
- ? `${Math.floor(seconds / 3600)}h`
1294
- : `${Math.floor(seconds / 86_400)}d`
1295
- return `${age}${suffix}`
1296
- }
1297
-
1298
- function formatBytes(bytes: number): string {
1299
- if (bytes >= 1024 ** 3) return `${(bytes / 1024 ** 3).toFixed(1)}G`
1300
- if (bytes >= 1024 ** 2) return `${(bytes / 1024 ** 2).toFixed(1)}M`
1301
- return `${Math.round(bytes / 1024)}K`
1302
- }
1303
-
1304
- function describeDeployProcess(service: DeployRelease["services"][number]): string {
1305
- const count = `${service.instances} ${service.instances === 1 ? "process" : "processes"}`
1306
- if (service.kind === "script") return `project script · ${count}`
1307
- // `worker-group` without worker types runs every type the project registers work for.
1308
- const namesWorkerTypes = service.command.args[1] && !service.command.args[1].startsWith("-")
1309
- if (service.kind === "workers" && !namesWorkerTypes) {
1310
- return `${count} · every worker type the project registers`
1311
- }
1312
- return count
1313
- }
1314
-
1315
- function formatDeployCommand(command: DeployCommand): string {
1316
- return [command.program, ...command.args].join(" ")
1317
- }
1318
-
1319
- export interface LakeCleanupReport {
1320
- readonly dryRun: boolean
1321
- readonly expireOlderThan: string
1322
- readonly deleteOlderThan: string
1323
- readonly snapshots: number
1324
- readonly keptSnapshots?: number
1325
- readonly oldFiles: number
1326
- readonly orphanedFiles: number
1327
- }
1328
-
1329
- export function LakeCleanupView({
1330
- projectId,
1331
- report,
1332
- }: {
1333
- projectId: string
1334
- report: LakeCleanupReport
1335
- }) {
1336
- return (
1337
- <Box flexDirection="column">
1338
- <Text color="green" bold>
1339
- {report.dryRun ? "Lake cleanup dry run complete" : "Lake cleanup complete"}
1340
- </Text>
1341
- <Text dimColor>{projectId}</Text>
1342
- <Spacer />
1343
- <KeyValueList
1344
- items={[
1345
- { label: "Dry run", value: String(report.dryRun) },
1346
- { label: "Expire older than", value: report.expireOlderThan },
1347
- { label: "Delete older than", value: report.deleteOlderThan },
1348
- { label: "Snapshots", value: String(report.snapshots) },
1349
- ...(report.keptSnapshots === undefined
1350
- ? []
1351
- : [{ label: "Kept snapshots", value: String(report.keptSnapshots) }]),
1352
- { label: "Old files", value: String(report.oldFiles) },
1353
- { label: "Orphaned files", value: String(report.orphanedFiles) },
1354
- ]}
1355
- />
1356
- </Box>
1357
- )
1358
- }
1359
-
1360
- export function InitView({
1361
- name,
1362
- targetDir,
1363
- files,
1364
- commands,
1365
- }: {
1366
- name: string
1367
- targetDir: string
1368
- files: string[]
1369
- commands: readonly string[]
1370
- }) {
1371
- return (
1372
- <Box flexDirection="column">
1373
- <Text color="green" bold>
1374
- Sixb initialized
1375
- </Text>
1376
- <Text dimColor>{name}</Text>
1377
- <Text dimColor>{targetDir}</Text>
1378
- <Spacer />
1379
- <SectionTitle>Files</SectionTitle>
1380
- <BulletList items={files} />
1381
- <Spacer />
1382
- <SectionTitle>Next steps</SectionTitle>
1383
- <CommandList commands={commands} />
1384
- </Box>
1385
- )
1386
- }
1387
-
1388
- function CommandList({ commands }: { commands: readonly string[] }) {
1389
- return (
1390
- <Box flexDirection="column">
1391
- {commands.map((command) => (
1392
- <Text key={command} color="cyan">
1393
- {` ${command}`}
1394
- </Text>
1395
- ))}
1396
- </Box>
1397
- )
1398
- }