@collectui/cli 0.2.14 → 0.2.16

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.14",
3
+ "version": "0.2.16",
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,23 +1,35 @@
1
1
  import { LIBS, ownedLibs, resolveLibKeys } from "../catalog.mjs";
2
- import { formatTable } from "../report.mjs";
2
+ import { formatTable, startSpin } from "../report.mjs";
3
3
  import { loadMe } from "./common.mjs";
4
4
 
5
5
  /**
6
6
  * cui libs 精简三列:SITE + CLI KEY + MCP KEY(MCP 值区分专属 bound / 通用 generic)
7
7
  * cui libs --verbose 完整表格(registries/MCP server 名等内部细节)
8
- * 加载态用静态提示行——clack spinner 每帧整行重绘,部分终端观感闪烁。
8
+ * 未拥有的行两列均为 "-";加载态为行内覆写 spinner(不闪)。
9
9
  */
10
10
  export async function libsCmd(flags, rest, reporter) {
11
11
  const interactive = !reporter.headless && !reporter.json;
12
- if (interactive) reporter.info("Loading your account from Dash…");
12
+ const spin = interactive ? startSpin("Loading your account from Dash…") : null;
13
13
  let me = null;
14
14
  try {
15
15
  me = await loadMe(flags, reporter, { required: false });
16
16
  } catch (error) {
17
+ spin?.stop();
17
18
  reporter.warn(`Could not load account (${error.message}); showing catalog only.`);
18
19
  }
19
20
 
20
21
  const owned = me ? new Set(ownedLibs(me).map((lib) => lib.site)) : null;
22
+ // 账号里拥有但不属于 shadcn registry 体系的库(自带独立安装器,如 threeui/heroui/
23
+ // aura)——本 CLI 管不到,但必须点名说明,不然用户以为少了
24
+ const knownSites = new Set(LIBS.map((lib) => lib.site));
25
+ const extraOwned = me
26
+ ? [
27
+ ...new Set([
28
+ ...(me.sites ?? []).map((s) => s.slug),
29
+ ...(me.keys ?? []).map((k) => k.site).filter(Boolean),
30
+ ]),
31
+ ].filter((slug) => !knownSites.has(slug))
32
+ : [];
21
33
  const rows = [];
22
34
 
23
35
  for (const lib of LIBS) {
@@ -25,15 +37,17 @@ export async function libsCmd(flags, rest, reporter) {
25
37
  const isOwned = owned ? owned.has(lib.site) : null;
26
38
  rows.push({
27
39
  site: lib.site,
28
- cli: isOwned === false ? "not owned" : keys.cli ? "bound" : "—",
29
- mcp: isOwned === false ? "—" : keys.mcp ? "bound" : lib.mcp ? "—" : "generic",
40
+ cli: isOwned === false ? "-" : keys.cli ? "bound" : "-",
41
+ mcp: isOwned === false ? "-" : keys.mcp ? "bound" : lib.mcp ? "-" : "generic",
30
42
  name: lib.siteName,
31
43
  owned: isOwned === null ? "?" : isOwned ? "yes" : "no",
32
- registries: (lib.registries ?? []).map((r) => r.scope).join(", ") || "—",
33
- mcpServer: lib.mcp ?? (lib.shadcnUiMcp ? "shadcn (generic)" : "—"),
44
+ registries: (lib.registries ?? []).map((r) => r.scope).join(", ") || "-",
45
+ mcpServer: lib.mcp ?? (lib.shadcnUiMcp ? "shadcn (generic)" : "-"),
34
46
  });
35
47
  }
36
48
 
49
+ spin?.stop(me ? `Account ${me.account?.username ?? me.account?.uid}` : "Catalog (not logged in)");
50
+
37
51
  if (reporter.json) {
38
52
  reporter.result({ account: me?.account ?? null, libraries: rows });
39
53
  return;
@@ -58,6 +72,13 @@ export async function libsCmd(flags, rest, reporter) {
58
72
  { key: "mcp", header: "MCP KEY" },
59
73
  ])
60
74
  );
75
+ if (extraOwned.length) {
76
+ reporter.info(
77
+ `Your account also owns ${extraOwned.length} librar${extraOwned.length === 1 ? "y" : "ies"} ` +
78
+ `outside the shadcn registry system (${extraOwned.join(", ")}) — ` +
79
+ `they install via their own tooling and are not managed by this CLI.`
80
+ );
81
+ }
61
82
  if (!me) {
62
83
  reporter.info("Run `cui login` to see which libraries your account owns and to bind keys.");
63
84
  }
@@ -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
+ }