@collectui/cli 0.2.34 → 0.2.36

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.34",
3
+ "version": "0.2.36",
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
@@ -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
  }
@@ -15,7 +15,6 @@ import {
15
15
  planManifest,
16
16
  planScaffold,
17
17
  runShadcnCommand,
18
- SHADCN_TEMPLATES,
19
18
  } from "../scaffold.mjs";
20
19
  import { includeDashMcp, chooseClients, collectShadcnFlags, detectClientApp, selectLibs } from "./common.mjs";
21
20
 
@@ -253,9 +252,11 @@ export async function runSetup({ flags, rest = [], reporter, mode }) {
253
252
  mcpServers: mcpEntries.map((e) => e.serverName),
254
253
  next: [
255
254
  mode === "init" && !hasComponents ? `cd ${cs.show(target)}` : null,
256
- // 只有 CLI 没自动装(--no-install / configure 模式)才提示安装;
257
- // 自动装过的场景不再出现——装完了还叫人装是语义矛盾(2026-12-06 用户反馈)
258
- install ? null : `${pm} install`,
255
+ // 只有 CLI 没自动装、且项目里确实没有 node_modules 才提示安装
256
+ // (configure 到已装过依赖的老项目不该再出现这行——2026-12-06 实报)
257
+ install || existsSync(join(target, "node_modules"))
258
+ ? null
259
+ : `${pm} install`,
259
260
  // 按实际选的库逐个给 add 示例——用户配了几个库就列几行
260
261
  ...units.slice(0, 3).map((u) => `cui add ${u.site} <component>`),
261
262
  ].filter(Boolean),