@bpmnkit/cli 0.0.15 → 0.0.17
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 +5 -0
- package/dist/commands/index.js +22 -4
- package/dist/commands/lint.js +65 -0
- package/dist/commands/plugin.js +244 -0
- package/dist/commands/story.js +42 -0
- package/dist/commands/test.js +77 -0
- package/dist/commands/worker.js +4 -2
- package/dist/plugin-loader.js +89 -0
- package/dist/run.js +33 -7
- package/dist/tui.js +593 -23
- package/package.json +7 -5
package/dist/run.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { appendAuditEntry, createAdminClientFromProfile, createClientFromProfile, getActiveName, getProfile, } from "@bpmnkit/profiles";
|
|
2
2
|
import { parseArgs } from "./args.js";
|
|
3
|
-
import { commandGroups } from "./commands/index.js";
|
|
3
|
+
import { apiGroups, commandGroups, pinnedGroups, pluginGroup, profileGroup, } from "./commands/index.js";
|
|
4
4
|
import { getRuntimeCompletions } from "./completion.js";
|
|
5
5
|
import { printCommandHelp, printGlobalHelp, printGroupHelp, printVersion } from "./help.js";
|
|
6
6
|
import { createNullWriter, createOutputWriter, printRawResponse } from "./output.js";
|
|
7
|
+
import { loadPlugins } from "./plugin-loader.js";
|
|
7
8
|
import { runProfileManager } from "./profile-tui.js";
|
|
8
9
|
import { runSettingsManager } from "./settings-tui.js";
|
|
9
10
|
import { runAskTui, runGroupTui, runMainTui } from "./tui.js";
|
|
@@ -47,6 +48,10 @@ function printError(msg, colors) {
|
|
|
47
48
|
}
|
|
48
49
|
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
49
50
|
export async function run(argv) {
|
|
51
|
+
// Load plugin-contributed groups and merge with built-in groups.
|
|
52
|
+
// Failures are isolated inside loadPlugins — a broken plugin cannot crash the CLI.
|
|
53
|
+
const pluginGroups = await loadPlugins();
|
|
54
|
+
const allGroups = [...commandGroups, profileGroup, pluginGroup, ...pluginGroups];
|
|
50
55
|
// ── Completion protocol ───────────────────────────────────────────────────
|
|
51
56
|
// casen --complete <cursorWordIndex> -- <words...>
|
|
52
57
|
const completeIdx = argv.indexOf("--complete");
|
|
@@ -54,7 +59,7 @@ export async function run(argv) {
|
|
|
54
59
|
const cursorIdx = Number(argv[completeIdx + 1] ?? "0");
|
|
55
60
|
const dashDash = argv.indexOf("--", completeIdx + 2);
|
|
56
61
|
const words = dashDash >= 0 ? argv.slice(dashDash + 1) : [];
|
|
57
|
-
const suggestions = getRuntimeCompletions(
|
|
62
|
+
const suggestions = getRuntimeCompletions(allGroups, cursorIdx, words);
|
|
58
63
|
process.stdout.write(`${suggestions.join("\n")}\n`);
|
|
59
64
|
return;
|
|
60
65
|
}
|
|
@@ -73,11 +78,17 @@ export async function run(argv) {
|
|
|
73
78
|
// ── Top-level: main menu TUI or help ─────────────────────────────────────
|
|
74
79
|
if (positional.length === 0) {
|
|
75
80
|
if (wantHelp) {
|
|
76
|
-
printGlobalHelp(
|
|
81
|
+
printGlobalHelp(allGroups, colors);
|
|
77
82
|
}
|
|
78
83
|
else {
|
|
79
84
|
const { name: pName, info: pInfo } = buildProfileInfo(profileName);
|
|
80
|
-
await runMainTui(
|
|
85
|
+
await runMainTui(
|
|
86
|
+
// Order: pinned → plugins (tagged) → api groups
|
|
87
|
+
[
|
|
88
|
+
...pinnedGroups,
|
|
89
|
+
...pluginGroups.map((g) => ({ ...g, _plugin: true })),
|
|
90
|
+
...apiGroups,
|
|
91
|
+
], () => Promise.resolve(createClientFromProfile(profileName)), () => Promise.resolve(createAdminClientFromProfile(profileName)), { profile: pName, profileInfo: pInfo });
|
|
81
92
|
}
|
|
82
93
|
return;
|
|
83
94
|
}
|
|
@@ -85,12 +96,27 @@ export async function run(argv) {
|
|
|
85
96
|
const getAdminClient = () => Promise.resolve(createAdminClientFromProfile(profileName));
|
|
86
97
|
// ── Find group ────────────────────────────────────────────────────────────
|
|
87
98
|
const groupToken = positional[0] ?? "";
|
|
88
|
-
const group =
|
|
99
|
+
const group = allGroups.find((g) => g.name === groupToken || g.aliases?.includes(groupToken));
|
|
89
100
|
if (!group) {
|
|
90
101
|
printError(`Unknown resource: "${groupToken}". Run \`casen --help\` to see all resources.`, colors);
|
|
91
102
|
process.exitCode = 1;
|
|
92
103
|
return;
|
|
93
104
|
}
|
|
105
|
+
// ── worker: treat positional[1] as the job type argument ─────────────────
|
|
106
|
+
if (group.name === "worker" && positional.length >= 2 && !wantHelp) {
|
|
107
|
+
const output = createOutputWriter(outputFormat, noColor);
|
|
108
|
+
const ctx = {
|
|
109
|
+
positional: positional.slice(1),
|
|
110
|
+
flags,
|
|
111
|
+
output,
|
|
112
|
+
getClient,
|
|
113
|
+
getAdminClient,
|
|
114
|
+
};
|
|
115
|
+
const cmd = group.commands[0];
|
|
116
|
+
if (cmd)
|
|
117
|
+
await cmd.run(ctx);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
94
120
|
// ── ask: join remaining positionals as the query ─────────────────────────
|
|
95
121
|
if (group.name === "ask" && positional.length >= 2 && !wantHelp) {
|
|
96
122
|
const queryWords = positional.slice(1);
|
|
@@ -111,7 +137,7 @@ export async function run(argv) {
|
|
|
111
137
|
if (positional.length === 1 && !wantHelp) {
|
|
112
138
|
if (group.name === "ask") {
|
|
113
139
|
const { name: pName, info: pInfo } = buildProfileInfo(profileName);
|
|
114
|
-
await runAskTui(
|
|
140
|
+
await runAskTui(allGroups, getClient, getAdminClient, {
|
|
115
141
|
profile: pName,
|
|
116
142
|
profileInfo: pInfo,
|
|
117
143
|
});
|
|
@@ -124,7 +150,7 @@ export async function run(argv) {
|
|
|
124
150
|
}
|
|
125
151
|
else if (group.name !== "completion") {
|
|
126
152
|
const { name: pName, info: pInfo } = buildProfileInfo(profileName);
|
|
127
|
-
await runGroupTui(group,
|
|
153
|
+
await runGroupTui(group, allGroups, getClient, getAdminClient, {
|
|
128
154
|
profile: pName,
|
|
129
155
|
profileInfo: pInfo,
|
|
130
156
|
});
|