@aipanel/core 1.2.17 → 1.2.19

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.
@@ -48,7 +48,8 @@ export declare function findGitRoot(startDir: string, maxDepth?: number): string
48
48
  */
49
49
  export declare function checkCliInstalled(bin: string): Promise<boolean>;
50
50
  /**
51
- * 获取某 CLI 版本号(<bin> --version 的第一行,败路返回 null)
51
+ * 获取某 CLI 版本号(<bin> --version,退出码 0 时取 stdout 首段,stdout 为空回退 stderr;败路返回 null)
52
+ * stderr 回退:部分 CLI(如个别平台的 dsh)把版本打在 stderr,仅读 stdout 会误判为“未解析出版本”。
52
53
  */
53
54
  export declare function getCliVersion(bin: string): Promise<string | null>;
54
55
  /** 孤儿进程清理配置(提供商的 check/kill 统一实现) */
@@ -141,12 +141,20 @@ async function checkCliInstalled(bin) {
141
141
  function getCliVersion(bin) {
142
142
  return new Promise((resolve) => {
143
143
  const proc = spawn(bin, ["--version"], { stdio: "pipe", shell: true });
144
- let output = "";
144
+ let stdout = "";
145
+ let stderr = "";
145
146
  proc.stdout?.on("data", (data) => {
146
- output += data.toString();
147
+ stdout += data.toString();
148
+ });
149
+ proc.stderr?.on("data", (data) => {
150
+ stderr += data.toString();
147
151
  });
148
152
  proc.on("close", (code) => {
149
- resolve(code === 0 && output.trim() ? output.trim() : null);
153
+ if (code !== 0) {
154
+ resolve(null);
155
+ return;
156
+ }
157
+ resolve(stdout.trim() || stderr.trim() || null);
150
158
  });
151
159
  proc.on("error", () => resolve(null));
152
160
  });
@@ -184,7 +192,13 @@ function killOrphansOnWindows(resolve, options, label, timer) {
184
192
  log.debug(`Using Windows method to find orphan ${label} processes`);
185
193
  const proc = spawn(
186
194
  "wmic",
187
- ["process", "where", `name="${options.winName}"`, "get", "processid,parentprocessid,commandline"],
195
+ [
196
+ "process",
197
+ "where",
198
+ `name="${options.winName}"`,
199
+ "get",
200
+ "processid,parentprocessid,commandline"
201
+ ],
188
202
  { stdio: "pipe" }
189
203
  );
190
204
  let output = "";
@@ -178,12 +178,20 @@ async function checkCliInstalled(bin) {
178
178
  function getCliVersion(bin) {
179
179
  return new Promise((resolve) => {
180
180
  const proc = (0, import_node_child_process.spawn)(bin, ["--version"], { stdio: "pipe", shell: true });
181
- let output = "";
181
+ let stdout = "";
182
+ let stderr = "";
182
183
  proc.stdout?.on("data", (data) => {
183
- output += data.toString();
184
+ stdout += data.toString();
185
+ });
186
+ proc.stderr?.on("data", (data) => {
187
+ stderr += data.toString();
184
188
  });
185
189
  proc.on("close", (code) => {
186
- resolve(code === 0 && output.trim() ? output.trim() : null);
190
+ if (code !== 0) {
191
+ resolve(null);
192
+ return;
193
+ }
194
+ resolve(stdout.trim() || stderr.trim() || null);
187
195
  });
188
196
  proc.on("error", () => resolve(null));
189
197
  });
@@ -221,7 +229,13 @@ function killOrphansOnWindows(resolve, options, label, timer) {
221
229
  log.debug(`Using Windows method to find orphan ${label} processes`);
222
230
  const proc = (0, import_node_child_process.spawn)(
223
231
  "wmic",
224
- ["process", "where", `name="${options.winName}"`, "get", "processid,parentprocessid,commandline"],
232
+ [
233
+ "process",
234
+ "where",
235
+ `name="${options.winName}"`,
236
+ "get",
237
+ "processid,parentprocessid,commandline"
238
+ ],
225
239
  { stdio: "pipe" }
226
240
  );
227
241
  let output = "";
@@ -48,7 +48,8 @@ export declare function findGitRoot(startDir: string, maxDepth?: number): string
48
48
  */
49
49
  export declare function checkCliInstalled(bin: string): Promise<boolean>;
50
50
  /**
51
- * 获取某 CLI 版本号(<bin> --version 的第一行,败路返回 null)
51
+ * 获取某 CLI 版本号(<bin> --version,退出码 0 时取 stdout 首段,stdout 为空回退 stderr;败路返回 null)
52
+ * stderr 回退:部分 CLI(如个别平台的 dsh)把版本打在 stderr,仅读 stdout 会误判为“未解析出版本”。
52
53
  */
53
54
  export declare function getCliVersion(bin: string): Promise<string | null>;
54
55
  /** 孤儿进程清理配置(提供商的 check/kill 统一实现) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/core",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "lib/index.cjs",