@collectui/cli 0.2.34 → 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 +1 -1
- package/src/args.mjs +1 -0
- package/src/cli.mjs +2 -0
- package/src/commands/init.mjs +26 -0
package/package.json
CHANGED
package/src/args.mjs
CHANGED
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
|
package/src/commands/init.mjs
CHANGED
|
@@ -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
|
}
|