@sixb/cli 0.1.21 → 0.1.23
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 +18 -3
- 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.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 +2 -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 -244
- 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 +19 -18
- 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} +27 -18
- 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} +17 -12
- 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 +4 -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 -33
- package/src/commands/typegen.tsx +0 -18
- package/src/lib/role-view.ts +0 -49
- package/src/ui/index.tsx +0 -1398
- /package/src/commands/{dev.tsx → dev.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadSixbFromEntry } from "../lib/loadSixb"
|
|
2
2
|
import { resolveRuntimeEntry } from "../lib/production"
|
|
3
3
|
import { stopSixbProviders } from "../lib/runtime"
|
|
4
|
-
import {
|
|
4
|
+
import { lakeCleanupView, renderStatic, withTask } from "../ui"
|
|
5
5
|
|
|
6
6
|
const DEFAULT_RETENTION = "7 days"
|
|
7
7
|
|
|
@@ -36,7 +36,7 @@ interface LakeMaintenanceProvider {
|
|
|
36
36
|
|
|
37
37
|
export async function runLakeCleanup(options: LakeCleanupOptions = {}) {
|
|
38
38
|
const entry = await resolveRuntimeEntry({ entry: options.entry })
|
|
39
|
-
const sixb = await loadSixbFromEntry(entry)
|
|
39
|
+
const sixb = await withTask("lake cleanup", "Loading project", () => loadSixbFromEntry(entry))
|
|
40
40
|
|
|
41
41
|
try {
|
|
42
42
|
const lakeStorage = sixb.lakeStorage
|
|
@@ -50,16 +50,21 @@ export async function runLakeCleanup(options: LakeCleanupOptions = {}) {
|
|
|
50
50
|
// Objects hold the rows of the version each projection applied, and their markings are read
|
|
51
51
|
// from it: the lake keeps those versions too. Without them, cleanup does not run.
|
|
52
52
|
const applied = await sixb.storage.ontology.sources.listActive({ projectId: sixb.projectId })
|
|
53
|
-
const report = await
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
const report = await withTask(
|
|
54
|
+
"lake cleanup",
|
|
55
|
+
options.dryRun ? "Measuring" : "Cleaning up",
|
|
56
|
+
() =>
|
|
57
|
+
lakeStorage.runMaintenance({
|
|
58
|
+
dryRun: options.dryRun ?? false,
|
|
59
|
+
expireOlderThan,
|
|
60
|
+
deleteOlderThan,
|
|
61
|
+
protect: applied.map(({ datasetVersion }) => ({
|
|
62
|
+
datasetId: datasetVersion.datasetId,
|
|
63
|
+
versionId: datasetVersion.versionId,
|
|
64
|
+
})),
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
await renderStatic(lakeCleanupView({ projectId: sixb.id, report }))
|
|
63
68
|
} finally {
|
|
64
69
|
await stopSixbProviders(sixb)
|
|
65
70
|
}
|
|
@@ -2,8 +2,11 @@ import { hostname } from "node:os"
|
|
|
2
2
|
import { CliError, createInstanceApiClient, writeJson } from "@sixb/cli-core"
|
|
3
3
|
import { type SixbSessionTokens, startSixbDeviceLogin } from "@sixb/client"
|
|
4
4
|
import { normalizeApiUrl } from "../lib/api-client"
|
|
5
|
+
import { openUrl } from "../lib/open-url"
|
|
5
6
|
import { assertProfileName, updateConfig } from "../lib/profiles"
|
|
6
|
-
import {
|
|
7
|
+
import { keyValueResultView, renderStatic, withTask } from "../ui"
|
|
8
|
+
import { canRunLive } from "../ui/live/can-run-live"
|
|
9
|
+
import { glyph, paint, palette, tone } from "../ui/theme"
|
|
7
10
|
|
|
8
11
|
export interface LoginCommandOptions {
|
|
9
12
|
readonly apiUrl?: string
|
|
@@ -13,11 +16,13 @@ export interface LoginCommandOptions {
|
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export async function runLogin(options: LoginCommandOptions = {}): Promise<void> {
|
|
16
|
-
|
|
19
|
+
const requested =
|
|
20
|
+
options.apiUrl?.trim() || (canRunLive() && !options.json ? await askForApiUrl() : "")
|
|
21
|
+
if (!requested) {
|
|
17
22
|
throw new Error("Usage: sixb login <api-url> [--profile <name>] [--token-stdin]")
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
const apiUrl = normalizeApiUrl(
|
|
25
|
+
const apiUrl = normalizeApiUrl(requested)
|
|
21
26
|
let token: string | undefined
|
|
22
27
|
let session: SixbSessionTokens | undefined
|
|
23
28
|
let projectId: string
|
|
@@ -29,7 +34,7 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
|
|
|
29
34
|
if (options.tokenStdin) {
|
|
30
35
|
token = await readTokenFromStdin()
|
|
31
36
|
} else {
|
|
32
|
-
session = await authorizeDevice(apiUrl)
|
|
37
|
+
session = await authorizeDevice(apiUrl, options.json === true)
|
|
33
38
|
}
|
|
34
39
|
projectId = await fetchProject(apiUrl, token ?? session?.accessToken)
|
|
35
40
|
}
|
|
@@ -57,46 +62,47 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
|
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
await renderStatic(
|
|
60
|
-
|
|
61
|
-
title
|
|
62
|
-
items
|
|
65
|
+
keyValueResultView({
|
|
66
|
+
title: `Logged in with profile "${profile}"`,
|
|
67
|
+
items: [
|
|
63
68
|
{ label: "Project", value: projectId },
|
|
64
69
|
{ label: "API", value: apiUrl },
|
|
65
70
|
{
|
|
66
71
|
label: "Authentication",
|
|
67
72
|
value: session ? "signed in" : token ? "stored token" : "not required",
|
|
68
73
|
},
|
|
69
|
-
]
|
|
70
|
-
|
|
74
|
+
],
|
|
75
|
+
})
|
|
71
76
|
)
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
async function
|
|
79
|
+
async function askForApiUrl(): Promise<string> {
|
|
80
|
+
const { promptText } = await import("../ui/live/prompt")
|
|
81
|
+
return promptText({
|
|
82
|
+
command: "login",
|
|
83
|
+
label: "API URL",
|
|
84
|
+
defaultValue: "http://localhost:3001",
|
|
85
|
+
hint: "Where the Sixb API answers, such as https://api.example.com",
|
|
86
|
+
validate: (value) => (URL.canParse(value) ? null : "That is not a URL."),
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function authorizeDevice(apiUrl: string, json: boolean): Promise<SixbSessionTokens> {
|
|
75
91
|
const login = await startSixbDeviceLogin({
|
|
76
92
|
baseUrl: apiUrl,
|
|
77
93
|
clientName: `sixb CLI on ${hostname()}`,
|
|
78
94
|
})
|
|
79
|
-
|
|
80
|
-
process.stderr.write(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const command =
|
|
89
|
-
process.platform === "darwin"
|
|
90
|
-
? ["open", url]
|
|
91
|
-
: process.platform === "win32"
|
|
92
|
-
? ["cmd.exe", "/c", "start", "", url]
|
|
93
|
-
: ["xdg-open", url]
|
|
94
|
-
try {
|
|
95
|
-
const process = Bun.spawn({ cmd: command, stdout: "ignore", stderr: "ignore" })
|
|
96
|
-
await process.exited
|
|
97
|
-
} catch {
|
|
98
|
-
// The URL and confirmation code were printed, so manual completion remains available.
|
|
95
|
+
// On stderr, so `--json` output stays only the result.
|
|
96
|
+
process.stderr.write(
|
|
97
|
+
`\n ${tone.blue(glyph.arrow)} Opening ${tone.url(login.verificationUriComplete)}\n` +
|
|
98
|
+
` Confirm code: ${paint(login.userCode, { color: palette.blue, bold: true })}\n\n`
|
|
99
|
+
)
|
|
100
|
+
if (process.env.SIXB_CLI_NO_BROWSER !== "1") await openUrl(login.verificationUriComplete)
|
|
101
|
+
if (json || !process.stdout.isTTY) {
|
|
102
|
+
process.stderr.write("Waiting for browser authorization...\n")
|
|
103
|
+
return login.complete()
|
|
99
104
|
}
|
|
105
|
+
return withTask("login", "Waiting for you to approve it in the browser", () => login.complete())
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
async function fetchProject(apiUrl: string, token?: string): Promise<string> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeJson } from "@sixb/cli-core"
|
|
2
2
|
import { signOutSixbSession } from "@sixb/client"
|
|
3
3
|
import { profileSessionStore, readConfig, requireProfile, updateConfig } from "../lib/profiles"
|
|
4
|
-
import {
|
|
4
|
+
import { keyValueResultView, renderStatic } from "../ui"
|
|
5
5
|
|
|
6
6
|
export interface LogoutCommandOptions {
|
|
7
7
|
readonly profile?: string
|
|
@@ -33,9 +33,9 @@ export async function runLogout(options: LogoutCommandOptions = {}): Promise<voi
|
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
35
|
await renderStatic(
|
|
36
|
-
|
|
37
|
-
title
|
|
38
|
-
items
|
|
39
|
-
|
|
36
|
+
keyValueResultView({
|
|
37
|
+
title: `Removed profile "${name}"`,
|
|
38
|
+
items: [{ label: "Profile", value: name }],
|
|
39
|
+
})
|
|
40
40
|
)
|
|
41
41
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
waitForWorkerFailure,
|
|
9
9
|
} from "../lib/runtime"
|
|
10
10
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
11
|
-
import {
|
|
11
|
+
import { printStopping, renderCliError, renderStatic, roleView, startTask } from "../ui"
|
|
12
12
|
|
|
13
13
|
export interface OrchestratorOptions {
|
|
14
14
|
entry?: string
|
|
@@ -19,13 +19,7 @@ export async function runOrchestrator(options: OrchestratorOptions = {}) {
|
|
|
19
19
|
process.env.NODE_ENV = "production"
|
|
20
20
|
|
|
21
21
|
const loaded = await loadProductionSixb({ entry: options.entry, role: "orchestrator" })
|
|
22
|
-
const app =
|
|
23
|
-
<LoadingView
|
|
24
|
-
title="Starting sixb orchestrator"
|
|
25
|
-
subtitle={loaded.entry}
|
|
26
|
-
status="Starting orchestrator"
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
22
|
+
const app = startTask("orchestrator", "Starting orchestrator")
|
|
29
23
|
|
|
30
24
|
let sixb: LoadedSixbHost | null = loaded.sixb
|
|
31
25
|
let runtime: RunningOrchestratorRuntime | null = null
|
|
@@ -34,14 +28,7 @@ export async function runOrchestrator(options: OrchestratorOptions = {}) {
|
|
|
34
28
|
const migration = await migrateStorageForRole(sixb, {
|
|
35
29
|
role: "orchestrator",
|
|
36
30
|
noMigrate: options.noMigrate,
|
|
37
|
-
onStart: () =>
|
|
38
|
-
app.rerender(
|
|
39
|
-
<LoadingView
|
|
40
|
-
title="Starting sixb orchestrator"
|
|
41
|
-
subtitle={loaded.entry}
|
|
42
|
-
status="Migrating storage"
|
|
43
|
-
/>
|
|
44
|
-
),
|
|
31
|
+
onStart: () => app.step("Migrating storage"),
|
|
45
32
|
})
|
|
46
33
|
|
|
47
34
|
runtime = await startOrchestratorRuntime(sixb)
|
|
@@ -51,21 +38,21 @@ export async function runOrchestrator(options: OrchestratorOptions = {}) {
|
|
|
51
38
|
warnings.push("No orchestrator routes are registered; the orchestrator process is idle.")
|
|
52
39
|
}
|
|
53
40
|
|
|
54
|
-
app.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
items
|
|
60
|
-
storage
|
|
61
|
-
warnings
|
|
62
|
-
|
|
41
|
+
app.stop()
|
|
42
|
+
await renderStatic(
|
|
43
|
+
roleView({
|
|
44
|
+
command: "orchestrator",
|
|
45
|
+
name: sixb.id,
|
|
46
|
+
items: [{ label: "role", value: "event-to-queue dispatcher" }],
|
|
47
|
+
storage: migration.summary,
|
|
48
|
+
warnings,
|
|
49
|
+
})
|
|
63
50
|
)
|
|
64
51
|
|
|
65
52
|
await Promise.race([
|
|
66
53
|
runUntilSignal(async () => {
|
|
67
|
-
app.
|
|
68
|
-
|
|
54
|
+
app.stop()
|
|
55
|
+
printStopping("orchestrator")
|
|
69
56
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
70
57
|
if (sixb) {
|
|
71
58
|
await stopSixbProviders(sixb)
|
|
@@ -75,7 +62,7 @@ export async function runOrchestrator(options: OrchestratorOptions = {}) {
|
|
|
75
62
|
waitForWorkerFailure(runtime.orchestratorWorker),
|
|
76
63
|
])
|
|
77
64
|
} catch (error) {
|
|
78
|
-
app.
|
|
65
|
+
app.stop()
|
|
79
66
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
80
67
|
if (sixb) {
|
|
81
68
|
await stopSixbProviders(sixb)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { writeJson } from "@sixb/cli-core"
|
|
2
2
|
import { readConfig, requireProfile, updateConfig } from "../lib/profiles"
|
|
3
|
-
import {
|
|
3
|
+
import { keyValueResultView, renderStatic, tableResultView } from "../ui"
|
|
4
|
+
import { canRunLive } from "../ui/live/can-run-live"
|
|
5
|
+
import { glyph, tone } from "../ui/theme"
|
|
4
6
|
|
|
5
7
|
export interface ProfileCommandOptions {
|
|
6
8
|
readonly action?: string
|
|
@@ -34,18 +36,17 @@ async function listProfiles(options: ProfileCommandOptions): Promise<void> {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
await renderStatic(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
profile.current ? "*" : "",
|
|
39
|
+
tableResultView({
|
|
40
|
+
headers: ["", "Profile", "Project", "API", "Token"],
|
|
41
|
+
rows: profiles.map((profile) => [
|
|
42
|
+
profile.current ? tone.blue(glyph.live) : " ",
|
|
42
43
|
profile.name,
|
|
43
44
|
profile.projectId,
|
|
44
45
|
profile.apiUrl,
|
|
45
46
|
profile.authenticated ? "yes" : "no",
|
|
46
|
-
])
|
|
47
|
-
emptyMessage
|
|
48
|
-
|
|
47
|
+
]),
|
|
48
|
+
emptyMessage: "No profiles. Run `sixb login <api-url>`.",
|
|
49
|
+
})
|
|
49
50
|
)
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -68,20 +69,20 @@ async function showProfile(options: ProfileCommandOptions): Promise<void> {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
await renderStatic(
|
|
71
|
-
|
|
72
|
-
title
|
|
73
|
-
items
|
|
72
|
+
keyValueResultView({
|
|
73
|
+
title: `Profile "${name}"`,
|
|
74
|
+
items: [
|
|
74
75
|
{ label: "Current", value: result.current ? "yes" : "no" },
|
|
75
76
|
{ label: "Project", value: result.projectId },
|
|
76
77
|
{ label: "API", value: result.apiUrl },
|
|
77
78
|
{ label: "Stored token", value: result.authenticated ? "yes" : "no" },
|
|
78
|
-
]
|
|
79
|
-
|
|
79
|
+
],
|
|
80
|
+
})
|
|
80
81
|
)
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
async function selectProfile(options: ProfileCommandOptions): Promise<void> {
|
|
84
|
-
const name = options.name?.trim()
|
|
85
|
+
const name = options.name?.trim() || (canRunLive() && !options.json ? await pickProfile() : "")
|
|
85
86
|
if (!name) throw new Error("Usage: sixb profile use <name>")
|
|
86
87
|
await updateConfig((config) => {
|
|
87
88
|
requireProfile(config, name)
|
|
@@ -93,9 +94,27 @@ async function selectProfile(options: ProfileCommandOptions): Promise<void> {
|
|
|
93
94
|
return
|
|
94
95
|
}
|
|
95
96
|
await renderStatic(
|
|
96
|
-
|
|
97
|
-
title
|
|
98
|
-
items
|
|
99
|
-
|
|
97
|
+
keyValueResultView({
|
|
98
|
+
title: `Using profile "${name}"`,
|
|
99
|
+
items: [{ label: "Profile", value: name }],
|
|
100
|
+
})
|
|
100
101
|
)
|
|
101
102
|
}
|
|
103
|
+
|
|
104
|
+
/** Lets the person pick a saved profile; `""` when there is none to pick. */
|
|
105
|
+
async function pickProfile(): Promise<string> {
|
|
106
|
+
const config = await readConfig()
|
|
107
|
+
const names = Object.keys(config.profiles).sort((left, right) => left.localeCompare(right))
|
|
108
|
+
if (names.length === 0) return ""
|
|
109
|
+
const { promptSelect } = await import("../ui/live/prompt")
|
|
110
|
+
return promptSelect({
|
|
111
|
+
command: "profile use",
|
|
112
|
+
label: "Profile",
|
|
113
|
+
choices: names.map((name) => ({
|
|
114
|
+
label: name,
|
|
115
|
+
value: name,
|
|
116
|
+
detail: `${config.profiles[name]?.apiUrl ?? ""}${name === config.currentProfile ? " (current)" : ""}`,
|
|
117
|
+
})),
|
|
118
|
+
initial: Math.max(0, names.indexOf(config.currentProfile ?? "")),
|
|
119
|
+
})
|
|
120
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
waitForWorkerFailure,
|
|
9
9
|
} from "../lib/runtime"
|
|
10
10
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
11
|
-
import {
|
|
11
|
+
import { printStopping, renderCliError, renderStatic, roleView, startTask } from "../ui"
|
|
12
12
|
|
|
13
13
|
export interface RulesOptions {
|
|
14
14
|
entry?: string
|
|
@@ -19,9 +19,7 @@ export async function runRules(options: RulesOptions = {}) {
|
|
|
19
19
|
process.env.NODE_ENV = "production"
|
|
20
20
|
|
|
21
21
|
const loaded = await loadProductionSixb({ entry: options.entry, role: "rules" })
|
|
22
|
-
const app =
|
|
23
|
-
<LoadingView title="Starting sixb rules" subtitle={loaded.entry} status="Starting rules" />
|
|
24
|
-
)
|
|
22
|
+
const app = startTask("rules", "Starting rules")
|
|
25
23
|
|
|
26
24
|
let sixb: LoadedSixbHost | null = loaded.sixb
|
|
27
25
|
let runtime: RunningRulesRuntime | null = null
|
|
@@ -30,14 +28,7 @@ export async function runRules(options: RulesOptions = {}) {
|
|
|
30
28
|
const migration = await migrateStorageForRole(sixb, {
|
|
31
29
|
role: "rules",
|
|
32
30
|
noMigrate: options.noMigrate,
|
|
33
|
-
onStart: () =>
|
|
34
|
-
app.rerender(
|
|
35
|
-
<LoadingView
|
|
36
|
-
title="Starting sixb rules"
|
|
37
|
-
subtitle={loaded.entry}
|
|
38
|
-
status="Migrating storage"
|
|
39
|
-
/>
|
|
40
|
-
),
|
|
31
|
+
onStart: () => app.step("Migrating storage"),
|
|
41
32
|
})
|
|
42
33
|
|
|
43
34
|
runtime = await startRulesRuntime(sixb)
|
|
@@ -45,21 +36,21 @@ export async function runRules(options: RulesOptions = {}) {
|
|
|
45
36
|
const warnings =
|
|
46
37
|
runtime.rulesWorker === null ? ["No rules are registered; the rules process is idle."] : []
|
|
47
38
|
|
|
48
|
-
app.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
items
|
|
54
|
-
storage
|
|
55
|
-
warnings
|
|
56
|
-
|
|
39
|
+
app.stop()
|
|
40
|
+
await renderStatic(
|
|
41
|
+
roleView({
|
|
42
|
+
command: "rules",
|
|
43
|
+
name: sixb.id,
|
|
44
|
+
items: [{ label: "role", value: "rules evaluation" }],
|
|
45
|
+
storage: migration.summary,
|
|
46
|
+
warnings,
|
|
47
|
+
})
|
|
57
48
|
)
|
|
58
49
|
|
|
59
50
|
await Promise.race([
|
|
60
51
|
runUntilSignal(async () => {
|
|
61
|
-
app.
|
|
62
|
-
|
|
52
|
+
app.stop()
|
|
53
|
+
printStopping("rules")
|
|
63
54
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
64
55
|
if (sixb) {
|
|
65
56
|
await stopSixbProviders(sixb)
|
|
@@ -69,7 +60,7 @@ export async function runRules(options: RulesOptions = {}) {
|
|
|
69
60
|
waitForWorkerFailure(runtime.rulesWorker),
|
|
70
61
|
])
|
|
71
62
|
} catch (error) {
|
|
72
|
-
app.
|
|
63
|
+
app.stop()
|
|
73
64
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
74
65
|
if (sixb) {
|
|
75
66
|
await stopSixbProviders(sixb)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
stopSixbProviders,
|
|
8
8
|
} from "../lib/runtime"
|
|
9
9
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
10
|
-
import {
|
|
10
|
+
import { printStopping, renderCliError, renderStatic, roleView, startTask } from "../ui"
|
|
11
11
|
|
|
12
12
|
export interface SchedulerOptions {
|
|
13
13
|
entry?: string
|
|
@@ -18,13 +18,7 @@ export async function runScheduler(options: SchedulerOptions = {}) {
|
|
|
18
18
|
process.env.NODE_ENV = "production"
|
|
19
19
|
|
|
20
20
|
const loaded = await loadProductionSixb({ entry: options.entry, role: "scheduler" })
|
|
21
|
-
const app =
|
|
22
|
-
<LoadingView
|
|
23
|
-
title="Starting sixb scheduler"
|
|
24
|
-
subtitle={loaded.entry}
|
|
25
|
-
status="Starting scheduler"
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
21
|
+
const app = startTask("scheduler", "Starting scheduler")
|
|
28
22
|
|
|
29
23
|
let sixb: LoadedSixbHost | null = loaded.sixb
|
|
30
24
|
let runtime: RunningSchedulerRuntime | null = null
|
|
@@ -33,31 +27,24 @@ export async function runScheduler(options: SchedulerOptions = {}) {
|
|
|
33
27
|
const migration = await migrateStorageForRole(sixb, {
|
|
34
28
|
role: "scheduler",
|
|
35
29
|
noMigrate: options.noMigrate,
|
|
36
|
-
onStart: () =>
|
|
37
|
-
app.rerender(
|
|
38
|
-
<LoadingView
|
|
39
|
-
title="Starting sixb scheduler"
|
|
40
|
-
subtitle={loaded.entry}
|
|
41
|
-
status="Migrating storage"
|
|
42
|
-
/>
|
|
43
|
-
),
|
|
30
|
+
onStart: () => app.step("Migrating storage"),
|
|
44
31
|
})
|
|
45
32
|
|
|
46
33
|
runtime = await startSchedulerRuntime(sixb)
|
|
47
34
|
|
|
48
|
-
app.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
items
|
|
54
|
-
storage
|
|
55
|
-
|
|
35
|
+
app.stop()
|
|
36
|
+
await renderStatic(
|
|
37
|
+
roleView({
|
|
38
|
+
command: "scheduler",
|
|
39
|
+
name: sixb.id,
|
|
40
|
+
items: [{ label: "role", value: "schedule event producer" }],
|
|
41
|
+
storage: migration.summary,
|
|
42
|
+
})
|
|
56
43
|
)
|
|
57
44
|
|
|
58
45
|
await runUntilSignal(async () => {
|
|
59
|
-
app.
|
|
60
|
-
|
|
46
|
+
app.stop()
|
|
47
|
+
printStopping("scheduler")
|
|
61
48
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
62
49
|
if (sixb) {
|
|
63
50
|
await stopSixbProviders(sixb)
|
|
@@ -65,7 +52,7 @@ export async function runScheduler(options: SchedulerOptions = {}) {
|
|
|
65
52
|
sixb = null
|
|
66
53
|
})
|
|
67
54
|
} catch (error) {
|
|
68
|
-
app.
|
|
55
|
+
app.stop()
|
|
69
56
|
await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
|
|
70
57
|
if (sixb) {
|
|
71
58
|
await stopSixbProviders(sixb)
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@sixb/client"
|
|
11
11
|
import { createCliSixbClient, unwrapSixbApiResult } from "../lib/api-client"
|
|
12
12
|
import { resolveProfileApiClientConfig } from "../lib/profile-api-client"
|
|
13
|
-
import {
|
|
13
|
+
import { keyValueResultView, renderStatic, secretResultView, tableResultView } from "../ui"
|
|
14
14
|
import {
|
|
15
15
|
assertSignedIn,
|
|
16
16
|
formatDate,
|
|
@@ -70,13 +70,12 @@ async function listServiceAccounts(options: ServiceAccountCommandOptions) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
await renderStatic(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/>
|
|
73
|
+
tableResultView({
|
|
74
|
+
subtitle: `${result.serviceAccounts.length} visible`,
|
|
75
|
+
headers: ["Name", "ID", "Status", "Groups", "Updated"],
|
|
76
|
+
rows: result.serviceAccounts.map(serviceAccountRow),
|
|
77
|
+
emptyMessage: "No service accounts.",
|
|
78
|
+
})
|
|
80
79
|
)
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -108,15 +107,15 @@ async function createServiceAccount(options: ServiceAccountCommandOptions) {
|
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
await renderStatic(
|
|
111
|
-
|
|
112
|
-
title
|
|
113
|
-
items
|
|
110
|
+
keyValueResultView({
|
|
111
|
+
title: "Created service account",
|
|
112
|
+
items: [
|
|
114
113
|
{ label: "Name", value: result.serviceAccount.name },
|
|
115
114
|
{ label: "ID", value: result.serviceAccount.id },
|
|
116
115
|
{ label: "Status", value: result.serviceAccount.status },
|
|
117
116
|
{ label: "Groups", value: formatGroups(result.serviceAccount.groupIds) },
|
|
118
|
-
]
|
|
119
|
-
|
|
117
|
+
],
|
|
118
|
+
})
|
|
120
119
|
)
|
|
121
120
|
}
|
|
122
121
|
|
|
@@ -140,14 +139,14 @@ async function disableServiceAccount(options: ServiceAccountCommandOptions) {
|
|
|
140
139
|
}
|
|
141
140
|
|
|
142
141
|
await renderStatic(
|
|
143
|
-
|
|
144
|
-
title
|
|
145
|
-
items
|
|
142
|
+
keyValueResultView({
|
|
143
|
+
title: "Disabled service account",
|
|
144
|
+
items: [
|
|
146
145
|
{ label: "Name", value: result.serviceAccount.name },
|
|
147
146
|
{ label: "ID", value: result.serviceAccount.id },
|
|
148
147
|
{ label: "Status", value: result.serviceAccount.status },
|
|
149
|
-
]
|
|
150
|
-
|
|
148
|
+
],
|
|
149
|
+
})
|
|
151
150
|
)
|
|
152
151
|
}
|
|
153
152
|
|
|
@@ -190,20 +189,19 @@ async function listServiceAccountTokens(options: ServiceAccountCommandOptions) {
|
|
|
190
189
|
}
|
|
191
190
|
|
|
192
191
|
await renderStatic(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
rows={result.accessTokens.map((token) => [
|
|
192
|
+
tableResultView({
|
|
193
|
+
subtitle: serviceAccountId,
|
|
194
|
+
headers: ["Name", "ID", "Status", "Groups", "Last used", "Expires"],
|
|
195
|
+
rows: result.accessTokens.map((token) => [
|
|
198
196
|
token.name,
|
|
199
197
|
token.id,
|
|
200
198
|
token.status,
|
|
201
199
|
formatGroups(token.groupIds),
|
|
202
200
|
formatDate(token.lastUsedAt),
|
|
203
201
|
formatDate(token.expiresAt),
|
|
204
|
-
])
|
|
205
|
-
emptyMessage
|
|
206
|
-
|
|
202
|
+
]),
|
|
203
|
+
emptyMessage: "No service-account tokens.",
|
|
204
|
+
})
|
|
207
205
|
)
|
|
208
206
|
}
|
|
209
207
|
|
|
@@ -240,17 +238,17 @@ async function createServiceAccountToken(options: ServiceAccountCommandOptions)
|
|
|
240
238
|
}
|
|
241
239
|
|
|
242
240
|
await renderStatic(
|
|
243
|
-
|
|
244
|
-
title
|
|
245
|
-
subtitle
|
|
246
|
-
items
|
|
241
|
+
secretResultView({
|
|
242
|
+
title: "Created service-account token",
|
|
243
|
+
subtitle: serviceAccountId,
|
|
244
|
+
items: [
|
|
247
245
|
{ label: "Name", value: result.accessToken.name },
|
|
248
246
|
{ label: "ID", value: result.accessToken.id },
|
|
249
247
|
{ label: "Expires", value: formatDate(result.accessToken.expiresAt) },
|
|
250
248
|
{ label: "Groups", value: formatGroups(result.accessToken.groupIds) },
|
|
251
|
-
]
|
|
252
|
-
secret
|
|
253
|
-
|
|
249
|
+
],
|
|
250
|
+
secret: result.tokenValue,
|
|
251
|
+
})
|
|
254
252
|
)
|
|
255
253
|
}
|
|
256
254
|
|
|
@@ -278,15 +276,15 @@ async function revokeServiceAccountToken(options: ServiceAccountCommandOptions)
|
|
|
278
276
|
}
|
|
279
277
|
|
|
280
278
|
await renderStatic(
|
|
281
|
-
|
|
282
|
-
title
|
|
283
|
-
subtitle
|
|
284
|
-
items
|
|
279
|
+
keyValueResultView({
|
|
280
|
+
title: "Revoked service-account token",
|
|
281
|
+
subtitle: serviceAccountId,
|
|
282
|
+
items: [
|
|
285
283
|
{ label: "Name", value: result.accessToken.name },
|
|
286
284
|
{ label: "ID", value: result.accessToken.id },
|
|
287
285
|
{ label: "Status", value: result.accessToken.status },
|
|
288
|
-
]
|
|
289
|
-
|
|
286
|
+
],
|
|
287
|
+
})
|
|
290
288
|
)
|
|
291
289
|
}
|
|
292
290
|
|