@collectui/cli 0.2.12 → 0.2.13
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 +1 -1
- package/src/commands/libs.mjs +43 -10
package/package.json
CHANGED
package/src/commands/libs.mjs
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
1
2
|
import { LIBS, ownedLibs, resolveLibKeys } from "../catalog.mjs";
|
|
2
3
|
import { formatTable } from "../report.mjs";
|
|
3
4
|
import { loadMe } from "./common.mjs";
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* cui libs 精简两列:SITE + 状态(拥有/key 绑定一眼可见,窄终端不折行)
|
|
8
|
+
* cui libs --verbose 完整表格(registries/MCP server 等内部细节)
|
|
9
|
+
*/
|
|
5
10
|
export async function libsCmd(flags, rest, reporter) {
|
|
11
|
+
// 网络往返数秒——TTY 下 spinner 明示在取数,不然像卡死
|
|
12
|
+
let spinner = null;
|
|
13
|
+
if (!reporter.headless && !reporter.json) {
|
|
14
|
+
spinner = p.spinner();
|
|
15
|
+
spinner.start("Loading your account from Dash…");
|
|
16
|
+
}
|
|
6
17
|
let me = null;
|
|
7
18
|
try {
|
|
8
19
|
me = await loadMe(flags, reporter, { required: false });
|
|
9
20
|
} catch (error) {
|
|
10
|
-
|
|
21
|
+
spinner?.stop(`Could not load account (${error.message}); showing catalog only.`, 1);
|
|
22
|
+
spinner = null;
|
|
23
|
+
} finally {
|
|
24
|
+
spinner?.stop(
|
|
25
|
+
me?.account?.username ? `Account ${me.account.username}` : "Catalog (not logged in)"
|
|
26
|
+
);
|
|
11
27
|
}
|
|
12
28
|
|
|
13
29
|
const owned = me ? new Set(ownedLibs(me).map((lib) => lib.site)) : null;
|
|
@@ -15,8 +31,19 @@ export async function libsCmd(flags, rest, reporter) {
|
|
|
15
31
|
|
|
16
32
|
for (const lib of LIBS) {
|
|
17
33
|
const keys = me ? resolveLibKeys(lib, me) : { cli: null, mcp: null };
|
|
34
|
+
const keyBits = [
|
|
35
|
+
keys.cli ? "cli" : null,
|
|
36
|
+
keys.mcp ? "mcp" : null,
|
|
37
|
+
].filter(Boolean);
|
|
18
38
|
rows.push({
|
|
19
39
|
site: lib.site,
|
|
40
|
+
status: owned
|
|
41
|
+
? owned.has(lib.site)
|
|
42
|
+
? keyBits.length
|
|
43
|
+
? `owned · ${keyBits.join(" + ")} key${keyBits.length > 1 ? "s" : ""}`
|
|
44
|
+
: "owned · no keys bound"
|
|
45
|
+
: "—"
|
|
46
|
+
: "?",
|
|
20
47
|
name: lib.siteName,
|
|
21
48
|
owned: owned ? (owned.has(lib.site) ? "yes" : "no") : "?",
|
|
22
49
|
cli: keys.cli ? "bound" : "—",
|
|
@@ -31,17 +58,23 @@ export async function libsCmd(flags, rest, reporter) {
|
|
|
31
58
|
return;
|
|
32
59
|
}
|
|
33
60
|
|
|
61
|
+
const verbose = Boolean(flags.verbose || flags.v);
|
|
34
62
|
reporter.note(
|
|
35
63
|
me ? `Account ${me.account?.username ?? me.account?.uid}` : "Catalog (not logged in)",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
verbose
|
|
65
|
+
? formatTable(rows, [
|
|
66
|
+
{ key: "site", header: "SITE" },
|
|
67
|
+
{ key: "name", header: "LIBRARY" },
|
|
68
|
+
{ key: "owned", header: "OWNED" },
|
|
69
|
+
{ key: "cli", header: "CLI KEY" },
|
|
70
|
+
{ key: "mcp", header: "MCP KEY" },
|
|
71
|
+
{ key: "registries", header: "REGISTRIES" },
|
|
72
|
+
{ key: "mcpServer", header: "MCP SERVER" },
|
|
73
|
+
])
|
|
74
|
+
: formatTable(rows, [
|
|
75
|
+
{ key: "site", header: "SITE" },
|
|
76
|
+
{ key: "status", header: "STATUS" },
|
|
77
|
+
])
|
|
45
78
|
);
|
|
46
79
|
if (!me) {
|
|
47
80
|
reporter.info("Run `cui login` to see which libraries your account owns and to bind keys.");
|