@collectui/cli 0.2.14 → 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.14",
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,19 +1,20 @@
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
 
@@ -25,15 +26,17 @@ export async function libsCmd(flags, rest, reporter) {
25
26
  const isOwned = owned ? owned.has(lib.site) : null;
26
27
  rows.push({
27
28
  site: lib.site,
28
- cli: isOwned === false ? "not owned" : keys.cli ? "bound" : "—",
29
- mcp: isOwned === false ? "—" : keys.mcp ? "bound" : lib.mcp ? "—" : "generic",
29
+ cli: isOwned === false ? "-" : keys.cli ? "bound" : "-",
30
+ mcp: isOwned === false ? "-" : keys.mcp ? "bound" : lib.mcp ? "-" : "generic",
30
31
  name: lib.siteName,
31
32
  owned: isOwned === null ? "?" : isOwned ? "yes" : "no",
32
- registries: (lib.registries ?? []).map((r) => r.scope).join(", ") || "—",
33
- mcpServer: lib.mcp ?? (lib.shadcnUiMcp ? "shadcn (generic)" : "—"),
33
+ registries: (lib.registries ?? []).map((r) => r.scope).join(", ") || "-",
34
+ mcpServer: lib.mcp ?? (lib.shadcnUiMcp ? "shadcn (generic)" : "-"),
34
35
  });
35
36
  }
36
37
 
38
+ spin?.stop(me ? `Account ${me.account?.username ?? me.account?.uid}` : "Catalog (not logged in)");
39
+
37
40
  if (reporter.json) {
38
41
  reporter.result({ account: me?.account ?? null, libraries: rows });
39
42
  return;
@@ -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
+ }