@collectui/cli 0.2.44 → 0.2.45

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 +12 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collectui/cli",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
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,8 +9,11 @@
9
9
  * (stdout 只出逐行 JSON event,Agent 直接消费)。所有动作经 ChangeSet:
10
10
  * 先展示计划再落盘,`--dry-run` 只看不写,密钥全程脱敏。
11
11
  */
12
+ import { mkdirSync } from "node:fs";
12
13
  import { homedir } from "node:os";
14
+ import { join } from "node:path";
13
15
  import { parseArgv } from "./args.mjs";
16
+ import { configDir } from "./config.mjs";
14
17
  import { CLI_NAME, CLI_VERSION } from "./version.mjs";
15
18
  import { collectSecrets, readConfig, resolveToken } from "./config.mjs";
16
19
  import { CliError, usageError } from "./errors.mjs";
@@ -209,12 +212,18 @@ async function main() {
209
212
  process.cwd();
210
213
  } catch {
211
214
  try {
212
- process.chdir(homedir());
215
+ // 切到 CLI 自己的家目录(2026-12-07 用户定:不落 ~ 而落 ~/.collectui)
216
+ const safeDir = join(configDir());
217
+ mkdirSync(safeDir, { recursive: true });
218
+ process.chdir(safeDir);
213
219
  reporter.warn(
214
- `Your terminal's directory no longer exists — the CLI moved itself to ~. Run \`cd ~\` in your shell when convenient.`
220
+ `Your terminal's directory no longer exists — the CLI moved itself to ~/.collectui. Run \`cd ~\` in your shell when convenient.`
215
221
  );
216
222
  } catch {
217
- // chdir 也失败极罕见,继续
223
+ // 兜底 home;再失败极罕见,继续
224
+ try {
225
+ process.chdir(homedir());
226
+ } catch {}
218
227
  }
219
228
  }
220
229
  if (token) reporter.addSecrets([token]);