@collectui/cli 0.2.13 → 0.2.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collectui/cli",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "One CLI for every shadcn library on CollectUI Dash — login once, configure registries & MCP, scaffold agent-ready projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,29 +1,21 @@
1
- import * as p from "@clack/prompts";
2
1
  import { LIBS, ownedLibs, resolveLibKeys } from "../catalog.mjs";
3
- import { formatTable } from "../report.mjs";
2
+ import { formatTable, startSpin } from "../report.mjs";
4
3
  import { loadMe } from "./common.mjs";
5
4
 
6
5
  /**
7
- * cui libs 精简两列:SITE + 状态(拥有/key 绑定一眼可见,窄终端不折行)
8
- * cui libs --verbose 完整表格(registries/MCP server 等内部细节)
6
+ * cui libs 精简三列:SITE + CLI KEY + MCP KEY(MCP 值区分专属 bound / 通用 generic)
7
+ * cui libs --verbose 完整表格(registries/MCP server 名等内部细节)
8
+ * 未拥有的行两列均为 "-";加载态为行内覆写 spinner(不闪)。
9
9
  */
10
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
- }
11
+ const interactive = !reporter.headless && !reporter.json;
12
+ const spin = interactive ? startSpin("Loading your account from Dash…") : null;
17
13
  let me = null;
18
14
  try {
19
15
  me = await loadMe(flags, reporter, { required: false });
20
16
  } catch (error) {
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
- );
17
+ spin?.stop();
18
+ reporter.warn(`Could not load account (${error.message}); showing catalog only.`);
27
19
  }
28
20
 
29
21
  const owned = me ? new Set(ownedLibs(me).map((lib) => lib.site)) : null;
@@ -31,28 +23,20 @@ export async function libsCmd(flags, rest, reporter) {
31
23
 
32
24
  for (const lib of LIBS) {
33
25
  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);
26
+ const isOwned = owned ? owned.has(lib.site) : null;
38
27
  rows.push({
39
28
  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
- : "?",
29
+ cli: isOwned === false ? "-" : keys.cli ? "bound" : "-",
30
+ mcp: isOwned === false ? "-" : keys.mcp ? "bound" : lib.mcp ? "-" : "generic",
47
31
  name: lib.siteName,
48
- owned: owned ? (owned.has(lib.site) ? "yes" : "no") : "?",
49
- cli: keys.cli ? "bound" : "—",
50
- mcp: keys.mcp ? "bound" : "—",
51
- registries: (lib.registries ?? []).map((r) => r.scope).join(", ") || "—",
52
- mcpServer: lib.mcp ?? (lib.shadcnUiMcp ? "shadcn (generic)" : "—"),
32
+ owned: isOwned === null ? "?" : isOwned ? "yes" : "no",
33
+ registries: (lib.registries ?? []).map((r) => r.scope).join(", ") || "-",
34
+ mcpServer: lib.mcp ?? (lib.shadcnUiMcp ? "shadcn (generic)" : "-"),
53
35
  });
54
36
  }
55
37
 
38
+ spin?.stop(me ? `Account ${me.account?.username ?? me.account?.uid}` : "Catalog (not logged in)");
39
+
56
40
  if (reporter.json) {
57
41
  reporter.result({ account: me?.account ?? null, libraries: rows });
58
42
  return;
@@ -73,7 +57,8 @@ export async function libsCmd(flags, rest, reporter) {
73
57
  ])
74
58
  : formatTable(rows, [
75
59
  { key: "site", header: "SITE" },
76
- { key: "status", header: "STATUS" },
60
+ { key: "cli", header: "CLI KEY" },
61
+ { key: "mcp", header: "MCP KEY" },
77
62
  ])
78
63
  );
79
64
  if (!me) {
@@ -1,7 +1,7 @@
1
1
  import { CLI_VERSION } from "../version.mjs";
2
2
  import { compareVersions, fetchLatestVersion, runManualUpdate } from "../update.mjs";
3
3
  import { CliError } from "../errors.mjs";
4
- import * as p from "@clack/prompts";
4
+ import { startSpin } from "../report.mjs";
5
5
 
6
6
  /**
7
7
  * cui update 手动立即更新(前台,看着跑)
@@ -37,14 +37,13 @@ export async function updateCmd(flags, _rest, reporter) {
37
37
  return;
38
38
  }
39
39
 
40
- const sp = p.spinner();
41
- sp.start(`Installing @collectui/cli@latest (${CLI_VERSION} → ${latest})`);
40
+ const spin = startSpin(`Installing @collectui/cli@latest (${CLI_VERSION} → ${latest})`);
42
41
  const res = await runManualUpdate();
43
42
  if (!res || res.status !== 0) {
44
- sp.stop("npm install failed", 1);
43
+ spin.stop();
45
44
  throw npmFail(res);
46
45
  }
47
- sp.stop(`Installed ${latest}`, 0);
46
+ spin.stop(`Installed ${latest}`);
48
47
  if (reporter.headless) reporter.result({ ...summary, updated: true });
49
48
  reporter.outro(`Updated to ${latest}. Re-run commands to pick it up.`);
50
49
  }
package/src/report.mjs CHANGED
@@ -220,3 +220,25 @@ export function formatTable(rows, columns) {
220
220
  for (const row of rows) out.push(line(columns.map((c) => row[c.key] ?? "")));
221
221
  return out.join("\n");
222
222
  }
223
+
224
+ /**
225
+ * 行内覆写式 spinner:braille 帧 + `\r\x1b[K` 单次整串写入(不做整行
226
+ * clear + 光标复位,那是 clack spinner 在部分终端闪烁的根源)。
227
+ * 仅 TTY 用;stop(finalMessage) 清行后打印终态(省略则只清行)。
228
+ */
229
+ export function startSpin(message) {
230
+ if (!process.stdout.isTTY) return { stop: () => {} };
231
+ const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
232
+ let i = 0;
233
+ const timer = setInterval(() => {
234
+ process.stdout.write(`\r\x1b[K${frames[i % frames.length]} ${message}`);
235
+ i += 1;
236
+ }, 90);
237
+ return {
238
+ stop(finalMessage) {
239
+ clearInterval(timer);
240
+ process.stdout.write(`\r\x1b[K`);
241
+ if (finalMessage != null) console.log(finalMessage);
242
+ },
243
+ };
244
+ }