@collectui/cli 0.2.43 → 0.2.44

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.mjs +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collectui/cli",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
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/cli.mjs CHANGED
@@ -9,6 +9,7 @@
9
9
  * (stdout 只出逐行 JSON event,Agent 直接消费)。所有动作经 ChangeSet:
10
10
  * 先展示计划再落盘,`--dry-run` 只看不写,密钥全程脱敏。
11
11
  */
12
+ import { homedir } from "node:os";
12
13
  import { parseArgv } from "./args.mjs";
13
14
  import { CLI_NAME, CLI_VERSION } from "./version.mjs";
14
15
  import { collectSecrets, readConfig, resolveToken } from "./config.mjs";
@@ -200,6 +201,22 @@ async function main() {
200
201
  const rest = positionals.slice(1);
201
202
  const token = resolveToken(flags);
202
203
  const reporter = makeReporter(flags, token);
204
+
205
+ // shell 卡在已删目录的全局自愈(2026-12-07 用户实锤两连:update 的 npm
206
+ // 子进程 uv_cwd 崩):任何命令进来,发现 cwd 已失效就把自己切回 home——
207
+ // 后续所有 spawn/update/文件操作不再崩;用户 shell 侧仍需 cd 一次
208
+ try {
209
+ process.cwd();
210
+ } catch {
211
+ try {
212
+ process.chdir(homedir());
213
+ reporter.warn(
214
+ `Your terminal's directory no longer exists — the CLI moved itself to ~. Run \`cd ~\` in your shell when convenient.`
215
+ );
216
+ } catch {
217
+ // chdir 也失败极罕见,继续
218
+ }
219
+ }
203
220
  if (token) reporter.addSecrets([token]);
204
221
 
205
222
  showBanner(reporter); // 开机画面:任何子命令(headless/--version 已在前面分流;help 走 printHelp 自带同款)