@cosmicdrift/kumiko-cli 0.336.1 → 0.337.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/changes.json +6 -0
- package/src/commands/consumer.ts +40 -52
- package/src/commands/project.ts +20 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.337.1",
|
|
4
4
|
"description": "CLI for Kumiko apps. `bunx @cosmicdrift/kumiko-cli new app <name>` scaffolds a runnable workspace; `add feature <name>` mounts a feature; `check` runs boot validation plus the guard suites with the step list derived from kumiko.json; `agent lint`, `project` and `consumer` operate on an existing app.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
39
|
-
"@cosmicdrift/kumiko-dev-server": "0.
|
|
40
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
41
|
-
"@cosmicdrift/kumiko-guards": "0.
|
|
42
|
-
"@cosmicdrift/kumiko-repo-manifest": "0.
|
|
43
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
38
|
+
"@cosmicdrift/kumiko-bundled-features": "0.337.1",
|
|
39
|
+
"@cosmicdrift/kumiko-dev-server": "0.337.1",
|
|
40
|
+
"@cosmicdrift/kumiko-framework": "0.337.1",
|
|
41
|
+
"@cosmicdrift/kumiko-guards": "0.337.1",
|
|
42
|
+
"@cosmicdrift/kumiko-repo-manifest": "0.337.1",
|
|
43
|
+
"@cosmicdrift/kumiko-testing": "0.337.1",
|
|
44
44
|
"zod": "^4.4.3"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.337.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "project and consumer validate the subcommand before any database work",
|
|
6
|
+
"detail": "`kumiko project` and `kumiko consumer` now reject an unknown or missing subcommand with the usage text before importing the config or touching the database. A failing state-table DDL no longer leaks the connection pool and is reported as an error with exit code 1."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.335.0",
|
|
4
10
|
"type": "fix",
|
package/src/commands/consumer.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { join } from "node:path";
|
|
|
2
2
|
import { loadAppConfig } from "./load-app-config";
|
|
3
3
|
import type { CliCommand, CliCommandContext } from "./types";
|
|
4
4
|
|
|
5
|
+
const CONSUMER_SUBCOMMANDS = ["list", "status", "restart", "disable", "enable", "skip"] as const;
|
|
6
|
+
type ConsumerSubcommand = (typeof CONSUMER_SUBCOMMANDS)[number];
|
|
7
|
+
|
|
8
|
+
function isConsumerSubcommand(value: string | undefined): value is ConsumerSubcommand {
|
|
9
|
+
return CONSUMER_SUBCOMMANDS.some((known) => known === value);
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
export const consumerCommand: CliCommand = {
|
|
6
13
|
id: "consumer",
|
|
7
14
|
description: "Manage event consumers (list | status | restart | disable | enable | skip)",
|
|
@@ -10,6 +17,13 @@ export const consumerCommand: CliCommand = {
|
|
|
10
17
|
const sub = ctx.argv[0];
|
|
11
18
|
const arg = ctx.argv[1];
|
|
12
19
|
|
|
20
|
+
if (!isConsumerSubcommand(sub)) {
|
|
21
|
+
ctx.out.err("");
|
|
22
|
+
ctx.out.err(` Usage: kumiko consumer <${CONSUMER_SUBCOMMANDS.join(" | ")}> <name>`);
|
|
23
|
+
ctx.out.err("");
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
const configPath = join(ctx.cwd, "kumiko.config.ts");
|
|
14
28
|
if (!(await Bun.file(configPath).exists())) {
|
|
15
29
|
ctx.out.err("");
|
|
@@ -43,42 +57,34 @@ export const consumerCommand: CliCommand = {
|
|
|
43
57
|
} = await import("@cosmicdrift/kumiko-framework/pipeline");
|
|
44
58
|
|
|
45
59
|
const registry = createRegistry(config.features);
|
|
46
|
-
const { db, close } = createDbConnection(databaseUrl);
|
|
47
|
-
await createEventConsumerStateTable(db);
|
|
48
|
-
|
|
49
60
|
const registeredConsumerNames = [
|
|
50
61
|
SSE_BROADCAST_CONSUMER_NAME,
|
|
51
62
|
SEARCH_CONSUMER_NAME,
|
|
52
63
|
...registry.getAllMultiStreamProjections().keys(),
|
|
53
64
|
];
|
|
54
|
-
|
|
55
|
-
const printOutcome = (prefix: string, state: { name: string; status: string }): void => {
|
|
56
|
-
ctx.out.log("");
|
|
57
|
-
ctx.out.log(` ✓ ${prefix} ${state.name} → ${state.status}`);
|
|
58
|
-
ctx.out.log("");
|
|
59
|
-
};
|
|
65
|
+
const { db, close } = createDbConnection(databaseUrl);
|
|
60
66
|
|
|
61
67
|
try {
|
|
68
|
+
await createEventConsumerStateTable(db);
|
|
62
69
|
switch (sub) {
|
|
63
70
|
case "list":
|
|
64
71
|
return await listConsumers(ctx, db, registeredConsumerNames, listConsumersWithState);
|
|
65
72
|
case "status":
|
|
66
73
|
return await showConsumerStatus(ctx, db, arg, registeredConsumerNames, getConsumerState);
|
|
67
74
|
case "restart":
|
|
68
|
-
return await
|
|
75
|
+
return await transitionOne(ctx, "restart", arg, "restarted", (name) =>
|
|
76
|
+
restartConsumer(db, name),
|
|
77
|
+
);
|
|
69
78
|
case "disable":
|
|
70
|
-
return await
|
|
79
|
+
return await transitionOne(ctx, "disable", arg, "disabled", (name) =>
|
|
80
|
+
disableConsumer(db, name),
|
|
81
|
+
);
|
|
71
82
|
case "enable":
|
|
72
|
-
return await
|
|
73
|
-
|
|
74
|
-
return await skipOne(ctx, db, arg, skipPoisonEvent, printOutcome);
|
|
75
|
-
default:
|
|
76
|
-
ctx.out.log("");
|
|
77
|
-
ctx.out.log(
|
|
78
|
-
" Usage: kumiko consumer <list | status | restart | disable | enable | skip> <name>",
|
|
83
|
+
return await transitionOne(ctx, "enable", arg, "enabled", (name) =>
|
|
84
|
+
enableConsumer(db, name),
|
|
79
85
|
);
|
|
80
|
-
|
|
81
|
-
return
|
|
86
|
+
case "skip":
|
|
87
|
+
return await skipOne(ctx, db, arg, skipPoisonEvent);
|
|
82
88
|
}
|
|
83
89
|
} catch (e) {
|
|
84
90
|
ctx.out.err("");
|
|
@@ -163,43 +169,26 @@ async function showConsumerStatus(
|
|
|
163
169
|
return 0;
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
async function
|
|
172
|
+
async function transitionOne(
|
|
167
173
|
ctx: CliCommandContext,
|
|
168
|
-
|
|
174
|
+
sub: string,
|
|
169
175
|
arg: string | undefined,
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
verb: string,
|
|
177
|
+
transition: (name: string) => Promise<{ name: string; status: string }>,
|
|
172
178
|
): Promise<number> {
|
|
173
|
-
if (!arg) return usage(ctx,
|
|
174
|
-
|
|
175
|
-
printOutcome("restarted", state);
|
|
179
|
+
if (!arg) return usage(ctx, sub);
|
|
180
|
+
printOutcome(ctx, verb, await transition(arg));
|
|
176
181
|
return 0;
|
|
177
182
|
}
|
|
178
183
|
|
|
179
|
-
|
|
184
|
+
function printOutcome(
|
|
180
185
|
ctx: CliCommandContext,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const state = await disableConsumer(db, arg);
|
|
188
|
-
printOutcome("disabled", state);
|
|
189
|
-
return 0;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async function enableOne(
|
|
193
|
-
ctx: CliCommandContext,
|
|
194
|
-
db: import("@cosmicdrift/kumiko-framework/db").DbConnection,
|
|
195
|
-
arg: string | undefined,
|
|
196
|
-
enableConsumer: typeof import("@cosmicdrift/kumiko-framework/pipeline").enableConsumer,
|
|
197
|
-
printOutcome: (prefix: string, state: { name: string; status: string }) => void,
|
|
198
|
-
): Promise<number> {
|
|
199
|
-
if (!arg) return usage(ctx, "enable");
|
|
200
|
-
const state = await enableConsumer(db, arg);
|
|
201
|
-
printOutcome("enabled", state);
|
|
202
|
-
return 0;
|
|
186
|
+
prefix: string,
|
|
187
|
+
state: { name: string; status: string },
|
|
188
|
+
): void {
|
|
189
|
+
ctx.out.log("");
|
|
190
|
+
ctx.out.log(` ✓ ${prefix} ${state.name} → ${state.status}`);
|
|
191
|
+
ctx.out.log("");
|
|
203
192
|
}
|
|
204
193
|
|
|
205
194
|
async function skipOne(
|
|
@@ -207,7 +196,6 @@ async function skipOne(
|
|
|
207
196
|
db: import("@cosmicdrift/kumiko-framework/db").DbConnection,
|
|
208
197
|
arg: string | undefined,
|
|
209
198
|
skipPoisonEvent: typeof import("@cosmicdrift/kumiko-framework/pipeline").skipPoisonEvent,
|
|
210
|
-
printOutcome: (prefix: string, state: { name: string; status: string }) => void,
|
|
211
199
|
): Promise<number> {
|
|
212
200
|
if (!arg) return usage(ctx, "skip");
|
|
213
201
|
const state = await skipPoisonEvent(db, arg);
|
|
@@ -216,7 +204,7 @@ async function skipOne(
|
|
|
216
204
|
ctx.out.log(` ~ ${state.name}: cursor already at head — nothing to skip.`);
|
|
217
205
|
ctx.out.log("");
|
|
218
206
|
} else {
|
|
219
|
-
printOutcome(`skipped event ${state.skippedEventId},`, state);
|
|
207
|
+
printOutcome(ctx, `skipped event ${state.skippedEventId},`, state);
|
|
220
208
|
}
|
|
221
209
|
return 0;
|
|
222
210
|
}
|
package/src/commands/project.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { join } from "node:path";
|
|
|
2
2
|
import { loadAppConfig } from "./load-app-config";
|
|
3
3
|
import type { CliCommand, CliCommandContext } from "./types";
|
|
4
4
|
|
|
5
|
+
const PROJECT_SUBCOMMANDS = ["list", "status", "rebuild"] as const;
|
|
6
|
+
type ProjectSubcommand = (typeof PROJECT_SUBCOMMANDS)[number];
|
|
7
|
+
|
|
8
|
+
function isProjectSubcommand(value: string | undefined): value is ProjectSubcommand {
|
|
9
|
+
return PROJECT_SUBCOMMANDS.some((known) => known === value);
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
export const projectCommand: CliCommand = {
|
|
6
13
|
id: "project",
|
|
7
14
|
description: "Manage projections (list | status <name> | rebuild <name>)",
|
|
@@ -10,6 +17,13 @@ export const projectCommand: CliCommand = {
|
|
|
10
17
|
const sub = ctx.argv[0];
|
|
11
18
|
const arg = ctx.argv[1];
|
|
12
19
|
|
|
20
|
+
if (!isProjectSubcommand(sub)) {
|
|
21
|
+
ctx.out.err("");
|
|
22
|
+
ctx.out.err(" Usage: kumiko project <list | status <name> | rebuild <name>>");
|
|
23
|
+
ctx.out.err("");
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
const configPath = join(ctx.cwd, "kumiko.config.ts");
|
|
14
28
|
if (!(await Bun.file(configPath).exists())) {
|
|
15
29
|
ctx.out.err("");
|
|
@@ -44,9 +58,9 @@ export const projectCommand: CliCommand = {
|
|
|
44
58
|
|
|
45
59
|
const registry = createRegistry(config.features);
|
|
46
60
|
const { db, close } = createDbConnection(databaseUrl);
|
|
47
|
-
await createProjectionStateTable(db);
|
|
48
61
|
|
|
49
62
|
try {
|
|
63
|
+
await createProjectionStateTable(db);
|
|
50
64
|
switch (sub) {
|
|
51
65
|
case "list":
|
|
52
66
|
return await listProjections(ctx, db, registry, listProjectionsWithState);
|
|
@@ -54,12 +68,12 @@ export const projectCommand: CliCommand = {
|
|
|
54
68
|
return await showProjectionStatus(ctx, db, arg, registry, getProjectionState);
|
|
55
69
|
case "rebuild":
|
|
56
70
|
return await rebuildOne(ctx, db, arg, registry, rebuildProjection);
|
|
57
|
-
default:
|
|
58
|
-
ctx.out.log("");
|
|
59
|
-
ctx.out.log(" Usage: kumiko project <list | status <name> | rebuild <name>>");
|
|
60
|
-
ctx.out.log("");
|
|
61
|
-
return 1;
|
|
62
71
|
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
ctx.out.err("");
|
|
74
|
+
ctx.out.err(` ✗ ${e instanceof Error ? e.message : String(e)}`);
|
|
75
|
+
ctx.out.err("");
|
|
76
|
+
return 1;
|
|
63
77
|
} finally {
|
|
64
78
|
await close();
|
|
65
79
|
}
|