@collectui/cli 0.2.33 → 0.2.35

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.33",
3
+ "version": "0.2.35",
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",
package/src/args.mjs CHANGED
@@ -23,6 +23,7 @@ const BOOLEAN_FLAGS = new Set([
23
23
  "deep",
24
24
  "quiet",
25
25
  "check",
26
+ "fresh",
26
27
  "monorepo",
27
28
  "pointer",
28
29
  "rtl",
package/src/cli.mjs CHANGED
@@ -40,6 +40,7 @@ Commands:
40
40
  logout Remove the saved PAT
41
41
  whoami, me Who you are + your libraries (ownership, CLI/MCP key status)
42
42
  init [dir] Scaffold a fresh shadcn project and configure libraries (no dir: OS temp dir)
43
+ init new Remove the previous temp project and start over (same as --fresh)
43
44
  configure [dir] Configure an existing shadcn project
44
45
  apply [dir] Apply an official shadcn preset to an existing project, then configure
45
46
  add <lib> <comp...> Install components with the library's channel
@@ -91,6 +92,7 @@ Examples:
91
92
  cui whoami --json
92
93
  cui init --libs reui,arc # default shadcn command, then configure
93
94
  cui init --template vite --no-install # built-in vite template instead
95
+ cui init new # remove the previous temp project, start over
94
96
  cui configure . --libs all --dry-run
95
97
  cui init --template next --preset b1VlIttI --monorepo --pointer # official scaffold
96
98
  cui apply --preset b1VlIttI # apply preset to the existing project here
@@ -70,22 +70,27 @@ export async function selectLibs({ flags, me, reporter }) {
70
70
  if (reporter.headless || flags.yes) {
71
71
  slugs = preferred.length ? preferred : owned.map((lib) => lib.site);
72
72
  } else {
73
+ // 默认全不选(2026-12-06 用户定案):选了就配选的;空选确认回默认
74
+ // (偏好集或全部已拥有)——摘要行只显示真正选中的
73
75
  const answer = await p.multiselect({
74
- message: "Which libraries do you want to configure?",
76
+ message:
77
+ "Which libraries do you want to configure? (space to select · enter to confirm · none = defaults)",
75
78
  options: owned.map((lib) => ({
76
79
  value: lib.site,
77
80
  label: `${lib.siteName} (${lib.site})`,
78
81
  })),
79
- initialValues: preferred.length
80
- ? preferred
81
- : owned.map((lib) => lib.site),
82
- required: true,
82
+ initialValues: [],
83
+ required: false,
83
84
  });
84
85
  if (p.isCancel(answer)) {
85
86
  p.cancel("Cancelled.");
86
87
  process.exit(0);
87
88
  }
88
- slugs = answer;
89
+ slugs = answer.length
90
+ ? answer
91
+ : preferred.length
92
+ ? preferred
93
+ : owned.map((lib) => lib.site);
89
94
  }
90
95
  } else {
91
96
  slugs = requested;
@@ -227,9 +232,9 @@ export async function chooseClients(flags, me, reporter, { interactive = true }
227
232
  }
228
233
  if (interactive && !flags.clients && !reporter.headless && !reporter.yes) {
229
234
  const chosen = await reporter.multiSelect(
230
- "Configure MCP for which agents? (confirm with none = all)",
235
+ "Configure MCP for which agents? (space to select · enter to confirm · none = all)",
231
236
  CLIENT_OPTIONS,
232
- { selected: clients }
237
+ { selected: [] }
233
238
  );
234
239
  if (chosen) clients = chosen.length ? chosen : ALL_CLIENTS;
235
240
  }
@@ -1,5 +1,31 @@
1
+ import { existsSync, rmSync, statSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { displayPath } from "../changes.mjs";
1
5
  import { runSetup } from "./setup.mjs";
2
6
 
7
+ /**
8
+ * cui init [dir] —— 默认临时目录全新项目;已有旧项目时切 configure 续配。
9
+ *
10
+ * cui init new / cui init --fresh(2026-12-06 用户需求):移除之前的临时项目
11
+ * 重新再来——只对默认临时目录目标生效,显式给目录时直接报错让用户自己决定
12
+ * (绝不静默删用户指定路径)。删除前打印删了什么,不给确认添堵(语义即重开)。
13
+ */
3
14
  export async function initCmd(flags, rest, reporter) {
15
+ const fresh =
16
+ Boolean(flags.fresh) ||
17
+ (rest.length === 1 && rest[0] === "new");
18
+ if (fresh) {
19
+ const target = join(
20
+ tmpdir(),
21
+ String(flags.name ?? "collectui-app").replace(/[\\/]+/g, "-")
22
+ );
23
+ if (existsSync(target) && statSync(target).isDirectory()) {
24
+ rmSync(target, { recursive: true, force: true });
25
+ reporter.info(`Removed previous project at ${displayPath(target)} — starting fresh.`);
26
+ }
27
+ // "new" 只是语义标记,不是目录名
28
+ return runSetup({ flags, rest: [], reporter, mode: "init" });
29
+ }
4
30
  return runSetup({ flags, rest, reporter, mode: "init" });
5
31
  }