@collectui/cli 0.2.41 → 0.2.42

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.41",
3
+ "version": "0.2.42",
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",
@@ -2,6 +2,7 @@ import { existsSync, rmSync, statSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { displayPath } from "../changes.mjs";
5
+ import { shellInside } from "./migrate.mjs";
5
6
  import { runSetup } from "./setup.mjs";
6
7
 
7
8
  /**
@@ -21,6 +22,11 @@ export async function initCmd(flags, rest, reporter) {
21
22
  String(flags.name ?? "collectui-app").replace(/[\\/]+/g, "-")
22
23
  );
23
24
  if (existsSync(target) && statSync(target).isDirectory()) {
25
+ if (shellInside(target)) {
26
+ reporter.warn(
27
+ `Your terminal is inside ${displayPath(target)} — cd out (e.g. \`cd ~\`) right after this command, or the next command will crash with ENOENT.`
28
+ );
29
+ }
24
30
  rmSync(target, { recursive: true, force: true });
25
31
  reporter.info(`Removed previous project at ${displayPath(target)} — starting fresh.`);
26
32
  }
@@ -56,6 +56,7 @@ export async function migrateCmd(flags, rest, reporter) {
56
56
  return;
57
57
  }
58
58
 
59
+ warnShellInside(source, reporter);
59
60
  mkdirSync(resolve(dest, ".."), { recursive: true });
60
61
  let moved;
61
62
  try {
@@ -111,12 +112,33 @@ export async function cleanCmd(flags, rest, reporter) {
111
112
  return;
112
113
  }
113
114
  for (const t of targets) {
115
+ warnShellInside(t, reporter);
114
116
  rmSync(t, { recursive: true, force: true });
115
117
  reporter.success(`Deleted ${displayPath(t)}`);
116
118
  }
117
119
  reporter.outro(`Cleaned ${targets.length} director${targets.length === 1 ? "y" : "ies"}.`);
118
120
  }
119
121
 
122
+
123
+ /** shell 的 cwd 是否在将被删除/移走的目录内(删除后下一条命令会 uv_cwd 崩,
124
+ * 2026-12-07 用户实锤:npx 直接 ENOENT)——删除前提示先 cd 出去 */
125
+ export function shellInside(path) {
126
+ try {
127
+ const cwd = process.cwd();
128
+ return cwd === path || cwd.startsWith(path + "/");
129
+ } catch {
130
+ return false;
131
+ }
132
+ }
133
+
134
+ function warnShellInside(path, reporter) {
135
+ if (shellInside(path)) {
136
+ reporter.warn(
137
+ `Your terminal is still inside ${displayPath(path)} — after it is removed, cd elsewhere (e.g. \`cd ~\`) before running any other command.`
138
+ );
139
+ }
140
+ }
141
+
120
142
  /** tmpdir 下带 .collectui/project.json 标志的目录清单(名字升序) */
121
143
  function cuiTmpProjects() {
122
144
  const out = [];