@collectui/cli 0.2.10 → 0.2.12

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.10",
3
+ "version": "0.2.12",
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
@@ -76,15 +76,15 @@ Global options:
76
76
  --version, -V Show version
77
77
 
78
78
  Examples:
79
- collectui login
80
- collectui libs --json
81
- collectui init --libs reui,arc --yes --no-install # fresh verify project under the OS temp dir
82
- collectui init /tmp/my-app --libs all --yes --no-install
83
- collectui configure . --libs all --dry-run
84
- collectui add reui data-grid
85
- collectui mcp show --json
86
- collectui dash repos --json
87
- COLLECTUI_TOKEN=dpat_... collectui whoami --json
79
+ cui login
80
+ cui libs --json
81
+ cui init --libs reui,arc --yes --no-install # fresh verify project under the OS temp dir
82
+ cui init /tmp/my-app --libs all --yes --no-install
83
+ cui configure . --libs all --dry-run
84
+ cui add reui data-grid
85
+ cui mcp show --json
86
+ cui dash repos --json
87
+ COLLECTUI_TOKEN=dpat_... cui whoami --json
88
88
 
89
89
  Environment:
90
90
  COLLECTUI_TOKEN Dash PAT (headless/CI)
@@ -157,7 +157,7 @@ async function main() {
157
157
  }
158
158
  const command = findCommand(name);
159
159
  if (!command) {
160
- throw usageError(`Unknown command "${name}".`, "Run `collectui help` to see the command list.");
160
+ throw usageError(`Unknown command "${name}".`, "Run `cui help` to see the command list.");
161
161
  }
162
162
  const rest = positionals.slice(1);
163
163
  const token = resolveToken(flags);
@@ -8,26 +8,26 @@ import { detectProjectRoot, mergeRegistries, parseEnvText } from "../project.mjs
8
8
  import { loadMe } from "./common.mjs";
9
9
 
10
10
  /**
11
- * collectui add <lib> <component...>
11
+ * cui add <lib> <component...>
12
12
  * 全部库都走 shadcn registry 通道:npx shadcn@latest add @scope/<component> --yes
13
13
  */
14
14
  export async function addCmd(flags, rest, reporter) {
15
15
  const libSlug = rest[0];
16
16
  const rawComponents = rest.slice(1);
17
17
  if (!libSlug || rawComponents.length === 0) {
18
- throw usageError("Usage: collectui add <library> <component...>", {
19
- hint: "Examples: collectui add reui data-grid · collectui add arc pro/dock · collectui add studio blocks/hero-01",
18
+ throw usageError("Usage: cui add <library> <component...>", {
19
+ hint: "Examples: cui add reui data-grid · cui add arc pro/dock · cui add studio blocks/hero-01",
20
20
  });
21
21
  }
22
22
 
23
23
  const lib = libBySlug(libSlug);
24
- if (!lib) throw usageError(`Unknown library "${libSlug}".`, { hint: "Run `collectui libs`." });
24
+ if (!lib) throw usageError(`Unknown library "${libSlug}".`, { hint: "Run `cui libs`." });
25
25
 
26
26
  const detected = detectProjectRoot(flags.cwd ? resolve(String(flags.cwd)) : process.cwd());
27
27
  const root = detected.root;
28
28
  if (!existsSync(join(root, "components.json"))) {
29
29
  throw new CliError(`No components.json under ${root}.`, {
30
- hint: "Run `collectui init` first, or --cwd into a shadcn project.",
30
+ hint: "Run `cui init` first, or --cwd into a shadcn project.",
31
31
  });
32
32
  }
33
33
 
@@ -72,14 +72,14 @@ function addViaRegistry({ flags, reporter, lib, rawComponents, root, cliKey, fil
72
72
  if (flags["no-auto-configure"]) {
73
73
  throw new CliError(
74
74
  `${root} is missing registry scope(s): ${missing.join(", ")}.`,
75
- { hint: `Run \`collectui configure ${root} --libs ${lib.site}\` first.` }
75
+ { hint: `Run \`cui configure ${root} --libs ${lib.site}\` first.` }
76
76
  );
77
77
  }
78
78
  if (flags.print) {
79
79
  reporter.warn(`Missing registry scope(s) ${missing.join(", ")} — a real run would auto-configure them.`);
80
80
  } else if (!cliKey && needsKey) {
81
81
  throw new CliError(`Cannot auto-configure ${lib.siteName}: no CLI key is bound.`, {
82
- hint: "Run `collectui configure` after binding a key in Dash.",
82
+ hint: "Run `cui configure` after binding a key in Dash.",
83
83
  });
84
84
  }
85
85
  }
@@ -15,7 +15,7 @@ export function requireToken(flags, reporter) {
15
15
  const token = resolveToken(flags);
16
16
  if (!token) {
17
17
  throw authError("Not logged in.", {
18
- hint: "Run `collectui login` (opens Dash in your browser), or pass --token / set COLLECTUI_TOKEN.",
18
+ hint: "Run `cui login` (opens Dash in your browser), or pass --token / set COLLECTUI_TOKEN.",
19
19
  });
20
20
  }
21
21
  reporter?.addSecrets([token]);
@@ -8,7 +8,7 @@ export async function dashCmd(flags, rest, reporter) {
8
8
  const sub = rest[0] ?? "me";
9
9
  if (!ALLOWED.has(sub)) {
10
10
  throw usageError(`Unknown dash subcommand "${sub}".`, {
11
- hint: "Usage: collectui dash <me|repos|download|feedback|tools|call>",
11
+ hint: "Usage: cui dash <me|repos|download|feedback|tools|call>",
12
12
  });
13
13
  }
14
14
  const token = requireToken(flags, reporter);
@@ -42,7 +42,7 @@ export async function dashCmd(flags, rest, reporter) {
42
42
 
43
43
  if (sub === "download") {
44
44
  const repo = rest[1];
45
- if (!repo) throw usageError("Usage: collectui dash download <owner/repo>");
45
+ if (!repo) throw usageError("Usage: cui dash download <owner/repo>");
46
46
  const result = await dashMcpTool(token, "download_repo", { repo }, { reporter });
47
47
  if (reporter.json) reporter.result(result);
48
48
  else {
@@ -61,7 +61,7 @@ export async function dashCmd(flags, rest, reporter) {
61
61
 
62
62
  if (sub === "feedback") {
63
63
  const message = rest.slice(1).join(" ").trim();
64
- if (!message) throw usageError("Usage: collectui dash feedback <message> [--site reui]");
64
+ if (!message) throw usageError("Usage: cui dash feedback <message> [--site reui]");
65
65
  const result = await dashMcpTool(
66
66
  token,
67
67
  "submit_feedback",
@@ -75,7 +75,7 @@ export async function dashCmd(flags, rest, reporter) {
75
75
 
76
76
  if (sub === "call") {
77
77
  const name = rest[1];
78
- if (!name) throw usageError("Usage: collectui dash call <tool> [--args '<json>']");
78
+ if (!name) throw usageError("Usage: cui dash call <tool> [--args '<json>']");
79
79
  let args = {};
80
80
  if (flags.args) {
81
81
  try {
@@ -21,7 +21,7 @@ export async function doctorCmd(flags, rest, reporter) {
21
21
 
22
22
  const token = resolveToken(flags);
23
23
  const source = tokenSource(flags);
24
- add("credentials", token ? "ok" : "fail", token ? `PAT from ${source}` : "no PAT (run collectui login)");
24
+ add("credentials", token ? "ok" : "fail", token ? `PAT from ${source}` : "no PAT (run cui login)");
25
25
 
26
26
  let me = null;
27
27
  if (token) {
@@ -44,6 +44,6 @@ export async function libsCmd(flags, rest, reporter) {
44
44
  ])
45
45
  );
46
46
  if (!me) {
47
- reporter.info("Run `collectui login` to see which libraries your account owns and to bind keys.");
47
+ reporter.info("Run `cui login` to see which libraries your account owns and to bind keys.");
48
48
  }
49
49
  }
@@ -103,7 +103,7 @@ async function dashMcpCommand(sub, flags, rest, reporter) {
103
103
 
104
104
  if (sub === "call") {
105
105
  const name = rest[0];
106
- if (!name) throw usageError("Usage: collectui mcp call <tool> [--args '<json>']");
106
+ if (!name) throw usageError("Usage: cui mcp call <tool> [--args '<json>']");
107
107
  let args = {};
108
108
  if (flags.args) {
109
109
  try {
@@ -141,7 +141,7 @@ async function dashMcpCommand(sub, flags, rest, reporter) {
141
141
 
142
142
  if (sub === "download") {
143
143
  const repo = rest[0];
144
- if (!repo) throw usageError("Usage: collectui mcp download <owner/repo>");
144
+ if (!repo) throw usageError("Usage: cui mcp download <owner/repo>");
145
145
  const result = await dashMcpTool(token, "download_repo", { repo }, { reporter });
146
146
  if (reporter.json) reporter.result(result);
147
147
  else {
@@ -163,7 +163,7 @@ async function dashMcpCommand(sub, flags, rest, reporter) {
163
163
 
164
164
  if (sub === "feedback") {
165
165
  const message = rest.join(" ").trim();
166
- if (!message) throw usageError("Usage: collectui mcp feedback <message> [--site reui,arc]");
166
+ if (!message) throw usageError("Usage: cui mcp feedback <message> [--site reui,arc]");
167
167
  const result = await dashMcpTool(
168
168
  token,
169
169
  "submit_feedback",
@@ -178,7 +178,7 @@ async function dashMcpCommand(sub, flags, rest, reporter) {
178
178
  throw usageError(`Unknown mcp subcommand "${sub}".`, { hint: MCP_HELP });
179
179
  }
180
180
 
181
- const MCP_HELP = `Usage: collectui mcp <show|init|tools|call|me|repos|download|feedback>
181
+ const MCP_HELP = `Usage: cui mcp <show|init|tools|call|me|repos|download|feedback>
182
182
 
183
183
  show Print MCP server config for the selected libraries and clients
184
184
  init Write/merge MCP configs (same as configure's MCP step)
@@ -66,7 +66,7 @@ export async function runSetup({ flags, rest = [], reporter, mode }) {
66
66
  if (reporter.headless) {
67
67
  throw new CliError("Not logged in (headless).", {
68
68
  code: 3,
69
- hint: "Pass --token dpat_... or set COLLECTUI_TOKEN. `collectui login` opens Dash for you in a terminal.",
69
+ hint: "Pass --token dpat_... or set COLLECTUI_TOKEN. `cui login` opens Dash for you in a terminal.",
70
70
  });
71
71
  }
72
72
  reporter.info("No saved session — starting login first.");
@@ -104,7 +104,7 @@ export async function runSetup({ flags, rest = [], reporter, mode }) {
104
104
 
105
105
  if (mode === "configure" && !hasComponents) {
106
106
  throw new CliError(`${target} has no components.json.`, {
107
- hint: "Point at a shadcn project, or run `collectui init` to create one.",
107
+ hint: "Point at a shadcn project, or run `cui init` to create one.",
108
108
  });
109
109
  }
110
110
  if (mode === "init" && hasComponents) {
@@ -206,8 +206,8 @@ export async function runSetup({ flags, rest = [], reporter, mode }) {
206
206
  next: [
207
207
  mode === "init" && !hasComponents ? `cd ${target}` : null,
208
208
  install ? `dependencies installing via ${pm}` : "npm install (if dependencies are missing)",
209
- `collectui add ${units[0]?.site ?? "<site>"} <component>`,
210
- "collectui doctor",
209
+ `cui add ${units[0]?.site ?? "<site>"} <component>`,
210
+ "cui doctor",
211
211
  ].filter(Boolean),
212
212
  };
213
213
  if (reporter.headless) {
@@ -1,10 +1,11 @@
1
1
  import { CLI_VERSION } from "../version.mjs";
2
2
  import { compareVersions, fetchLatestVersion, runManualUpdate } from "../update.mjs";
3
3
  import { CliError } from "../errors.mjs";
4
+ import * as p from "@clack/prompts";
4
5
 
5
6
  /**
6
- * collectui update 手动立即更新(前台,看着跑)
7
- * collectui update --check 只查不更(打 registry,不走缓存)
7
+ * cui update 手动立即更新(前台,看着跑)
8
+ * cui update --check 只查不更(打 registry,不走缓存)
8
9
  */
9
10
  export async function updateCmd(flags, _rest, reporter) {
10
11
  reporter.step(1, 2, "Checking npm for the latest @collectui/cli");
@@ -24,13 +25,36 @@ export async function updateCmd(flags, _rest, reporter) {
24
25
  return;
25
26
  }
26
27
 
27
- reporter.step(2, 2, `Installing @collectui/cli@latest (${CLI_VERSION} → ${latest})`);
28
- const res = runManualUpdate();
28
+ // TTY 下 spinner 转着等 npm(输出捕获不插框);headless 直接 info
29
+ if (reporter.headless) {
30
+ reporter.info(`Installing @collectui/cli@latest (${CLI_VERSION} → ${latest}) via npm …`);
31
+ const res = await runManualUpdate();
32
+ if (!res || res.status !== 0) {
33
+ throw npmFail(res);
34
+ }
35
+ if (reporter.headless) reporter.result({ ...summary, updated: true });
36
+ reporter.outro(`Updated to ${latest}. Re-run commands to pick it up.`);
37
+ return;
38
+ }
39
+
40
+ const sp = p.spinner();
41
+ sp.start(`Installing @collectui/cli@latest (${CLI_VERSION} → ${latest})`);
42
+ const res = await runManualUpdate();
29
43
  if (!res || res.status !== 0) {
30
- throw new CliError(`npm install failed${res?.status ? ` (exit ${res.status})` : ""}.`, {
31
- hint: "Run `npm i -g @collectui/cli` manually to see the npm error; check global-prefix permissions (sudo/nvm).",
32
- });
44
+ sp.stop("npm install failed", 1);
45
+ throw npmFail(res);
33
46
  }
47
+ sp.stop(`Installed ${latest}`, 0);
34
48
  if (reporter.headless) reporter.result({ ...summary, updated: true });
35
49
  reporter.outro(`Updated to ${latest}. Re-run commands to pick it up.`);
36
50
  }
51
+
52
+ function npmFail(res) {
53
+ const detail = `${res?.stderr ?? ""}${res?.stdout ?? ""}`.trim().split("\n").slice(-5).join("\n");
54
+ return new CliError(
55
+ `npm install failed${res?.status ? ` (exit ${res.status})` : ""}${detail ? `:\n${detail}` : "."}`,
56
+ {
57
+ hint: "Check global-prefix permissions (sudo/nvm), or run `npm i -g @collectui/cli` directly.",
58
+ }
59
+ );
60
+ }
package/src/http.mjs CHANGED
@@ -109,7 +109,7 @@ export async function jsonRequest(url, options = {}) {
109
109
  code: out.res.status === 401 || out.res.status === 403 ? 3 : 1,
110
110
  hint:
111
111
  out.res.status === 401
112
- ? "Run `collectui login` again (or pass --token) — your PAT may be missing, revoked or expired."
112
+ ? "Run `cui login` again (or pass --token) — your PAT may be missing, revoked or expired."
113
113
  : undefined,
114
114
  });
115
115
  }
@@ -155,7 +155,7 @@ export async function mcpCall({ base, token, method, params, reporter, id = 1 })
155
155
  } catch {
156
156
  if (out.res.status === 404) {
157
157
  throw new CliError("Dash MCP is not enabled for this server/account (HTTP 404).", {
158
- hint: "Ask the operator to enable dashFeatures.mcpServer, or use `collectui whoami` / the REST API instead.",
158
+ hint: "Ask the operator to enable dashFeatures.mcpServer, or use `cui whoami` / the REST API instead.",
159
159
  });
160
160
  }
161
161
  if (!out.res.ok) {
@@ -167,7 +167,7 @@ export async function mcpCall({ base, token, method, params, reporter, id = 1 })
167
167
  if (!out.res.ok) {
168
168
  if (out.res.status === 404) {
169
169
  throw new CliError("Dash MCP is not enabled for this server/account (HTTP 404).", {
170
- hint: "Ask the operator to enable dashFeatures.mcpServer, or use `collectui whoami` / the REST API instead.",
170
+ hint: "Ask the operator to enable dashFeatures.mcpServer, or use `cui whoami` / the REST API instead.",
171
171
  });
172
172
  }
173
173
  throw new CliError(
package/src/login.mjs CHANGED
@@ -37,7 +37,7 @@ export function saveSession(token, me, { reporter } = {}) {
37
37
  * 1. 本地起 127.0.0.1 回调监听(带随机 secret 路径 + state 校验)
38
38
  * 2. 打开 Dash 的 /authorize 授权页(登录态下点一次「授权」,Dash 建好 PAT
39
39
  * 并把明文 redirect 回本机回调,全程无需复制粘贴)
40
- * 3. 无浏览器场景(CI / 远程 / ssh)用 `collectui login --pat` 粘贴 PAT,
40
+ * 3. 无浏览器场景(CI / 远程 / ssh)用 `cui login --pat` 粘贴 PAT,
41
41
  * 或 headless 下 --token / COLLECTUI_TOKEN / stdin
42
42
  *
43
43
  * 无头模式(--json / 非 TTY):从 --token / 环境变量 / stdin 取 PAT,绝不弹交互。
@@ -115,10 +115,10 @@ export async function login({
115
115
  });
116
116
  }
117
117
  } else {
118
- reporter.warn("--no-verify: token saved without checking it. Run `collectui whoami` to verify.");
118
+ reporter.warn("--no-verify: token saved without checking it. Run `cui whoami` to verify.");
119
119
  }
120
120
  saveSession(token, me, { reporter });
121
- reporter.outro("Login complete. Try `collectui libs`.");
121
+ reporter.outro("Login complete. Try `cui libs`.");
122
122
  return { token, me };
123
123
  }
124
124
 
package/src/mcp.mjs CHANGED
@@ -105,7 +105,7 @@ export function buildMcpEntries({ units, me, dashToken, registryBase, dashBase,
105
105
  key: dashToken,
106
106
  });
107
107
  } else {
108
- reporter?.warn("No Dash PAT; collectui-dash MCP was skipped. Run `collectui login` to add it.");
108
+ reporter?.warn("No Dash PAT; collectui-dash MCP was skipped. Run `cui login` to add it.");
109
109
  }
110
110
  }
111
111
 
package/src/project.mjs CHANGED
@@ -184,7 +184,7 @@ export function planProjectConfig(cs, { projectDir, units, me, registryBase, for
184
184
  const componentsPath = join(projectDir, "components.json");
185
185
  if (!cs.exists(componentsPath)) {
186
186
  throw new CliError(`No components.json in ${projectDir}.`, {
187
- hint: "Run `collectui init` to scaffold a project, or point --cwd at an existing shadcn project.",
187
+ hint: "Run `cui init` to scaffold a project, or point --cwd at an existing shadcn project.",
188
188
  });
189
189
  }
190
190
  const before = cs.readJson(componentsPath, {});
package/src/scaffold.mjs CHANGED
@@ -149,10 +149,10 @@ ${manifest.mcpClients.map((c) => `- ${c}`).join("\n") || "- (none)"}
149
149
 
150
150
  ## Commands
151
151
 
152
- - Configure another library: \`collectui configure . --libs <site>\`
153
- - Install a component: \`collectui add <site> <component>\`
154
- - Re-check setup: \`collectui doctor\`
155
- - Dash account: \`collectui whoami\`
152
+ - Configure another library: \`cui configure . --libs <site>\`
153
+ - Install a component: \`cui add <site> <component>\`
154
+ - Re-check setup: \`cui doctor\`
155
+ - Dash account: \`cui whoami\`
156
156
 
157
157
  Secrets live in \`.env.local\` and the MCP config files (both are gitignored by
158
158
  the scaffold). Never commit them.
@@ -250,7 +250,7 @@ export default function App() {
250
250
  <main className="flex min-h-screen flex-col items-center justify-center gap-4 bg-background text-foreground">
251
251
  <h1 className="font-semibold text-2xl">CollectUI project</h1>
252
252
  <p className="text-muted-foreground text-sm">
253
- Run <code className="font-mono">collectui add &lt;site&gt; &lt;component&gt;</code> to install components.
253
+ Run <code className="font-mono">cui add &lt;site&gt; &lt;component&gt;</code> to install components.
254
254
  </p>
255
255
  <Button>Ready</Button>
256
256
  </main>
@@ -418,7 +418,7 @@ dist/
418
418
  .mcp.json
419
419
  .cursor/mcp.json
420
420
  .vscode/mcp.json
421
- # MCP configs above may contain access tokens; regenerate them with \`collectui configure\`.
421
+ # MCP configs above may contain access tokens; regenerate them with \`cui configure\`.
422
422
  `;
423
423
 
424
424
  const README = (name) => `# ${name}
@@ -436,15 +436,15 @@ npm run dev
436
436
  ## Install components
437
437
 
438
438
  \`\`\`bash
439
- collectui add <site> <component>
440
- # e.g. collectui add reui data-grid
439
+ cui add <site> <component>
440
+ # e.g. cui add reui data-grid
441
441
  # or: npx shadcn@latest add @reui/data-grid
442
442
  \`\`\`
443
443
 
444
444
  ## Add another library
445
445
 
446
446
  \`\`\`bash
447
- collectui configure . --libs <site>
447
+ cui configure . --libs <site>
448
448
  \`\`\`
449
449
 
450
450
  See \`.collectui/environment.md\` for the machine-readable setup record.
package/src/update.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { spawnSync } from "node:child_process";
1
+ import { spawn } from "node:child_process";
2
2
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { configDir } from "./config.mjs";
@@ -9,7 +9,7 @@ import { CLI_VERSION } from "./version.mjs";
9
9
  * 更新检查(2026-12-01 起只提醒不自动装):
10
10
  * - CLI 是一次性进程,没有「后台周期任务」——每次运行命令时即时异步查一次 npm
11
11
  * (与命令并行,命令结束时最多再等 1 秒收结果)
12
- * - 发现新版 → 打一行显式提醒,装不装由用户跑 `collectui update` 决定
12
+ * - 发现新版 → 打一行显式提醒,装不装由用户跑 `cui update` 决定
13
13
  * - headless/--json 完全不碰(Agent/CI 输出契约不被搅动);npx 临时跑不需要
14
14
  * - COLLECTUI_NO_AUTO_UPDATE=1:连检查带提示全静默(CI 显式意图)
15
15
  */
@@ -100,7 +100,7 @@ export function startBackgroundUpdate(reporter, deps = {}) {
100
100
  const cache = readUpdateCache();
101
101
  if (cache.latest && compareVersions(cache.latest, CLI_VERSION) > 0) {
102
102
  reporter.info(
103
- `⬆ ${NPM_PACKAGE} ${CLI_VERSION} → ${cache.latest} available — run \`collectui update\` to upgrade.`
103
+ `⬆ ${NPM_PACKAGE} ${CLI_VERSION} → ${cache.latest} available — run \`cui update\` to upgrade.`
104
104
  );
105
105
  notified = true;
106
106
  }
@@ -109,7 +109,7 @@ export function startBackgroundUpdate(reporter, deps = {}) {
109
109
  writeUpdateCache({ lastCheck: Date.now(), latest });
110
110
  if (!notified && compareVersions(latest, CLI_VERSION) > 0) {
111
111
  reporter.info(
112
- `⬆ ${NPM_PACKAGE} ${CLI_VERSION} → ${latest} available — run \`collectui update\` to upgrade.`
112
+ `⬆ ${NPM_PACKAGE} ${CLI_VERSION} → ${latest} available — run \`cui update\` to upgrade.`
113
113
  );
114
114
  notified = true;
115
115
  }
@@ -118,8 +118,25 @@ export function startBackgroundUpdate(reporter, deps = {}) {
118
118
  return { done };
119
119
  }
120
120
 
121
- /** 手动更新(`collectui update`):前台跑,人看着进度。runner 可注入(测试)。 */
121
+ /** 手动更新(`cui update`):异步 spawn + 捕获输出(不 inherit——往 clack 的
122
+ * frame 里插行会把边框打断;捕获后失败时调用方直接展示 stderr)。
123
+ * runner 可注入(测试):返回 { status, stdout, stderr }(或其 Promise)。 */
122
124
  export function runManualUpdate({ runner } = {}) {
123
- const run = runner ?? ((args) => spawnSync("npm", args, { stdio: "inherit", shell: process.platform === "win32" }));
124
- return run(["install", "-g", `${NPM_PACKAGE}@latest`]);
125
+ if (runner) return runner(["install", "-g", `${NPM_PACKAGE}@latest`]);
126
+ return new Promise((resolve) => {
127
+ const child = spawn("npm", ["install", "-g", `${NPM_PACKAGE}@latest`], {
128
+ stdio: ["ignore", "pipe", "pipe"],
129
+ shell: process.platform === "win32",
130
+ });
131
+ let out = "";
132
+ let err = "";
133
+ child.stdout?.on("data", (d) => {
134
+ out += d;
135
+ });
136
+ child.stderr?.on("data", (d) => {
137
+ err += d;
138
+ });
139
+ child.on("close", (code) => resolve({ status: code, stdout: out, stderr: err }));
140
+ child.on("error", (e) => resolve({ status: 1, stderr: String(e) }));
141
+ });
125
142
  }