@qpfai/pf-gate-cli 1.0.10 → 1.0.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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-02-16T21:46:58.234Z",
3
+ "generatedAt": "2026-02-16T22:10:25.756Z",
4
4
  "pythonPackage": "persons-field",
5
5
  "pythonPackageVersion": "1.0.0",
6
6
  "wheel": "persons_field-1.0.0-py3-none-any.whl",
7
- "sha256": "c5ff4e1e222ae3eb753b794d856736fa7b4e3285d19eca04b365686e57513b48"
7
+ "sha256": "edbb1d8ef8a972a060dda5e9cfcf9b8d7bd2db2cbbac44bc264bb8ed9140a94d"
8
8
  }
package/lib/main.mjs CHANGED
@@ -286,6 +286,79 @@ async function promptYesNo(question, defaultYes = true) {
286
286
  }
287
287
  }
288
288
 
289
+ function npmGlobalBinDir() {
290
+ const prefix = runCapture("npm", ["prefix", "-g"]);
291
+ if (!prefix.ok) {
292
+ return null;
293
+ }
294
+ const root = String(prefix.output || "").trim();
295
+ if (!root) {
296
+ return null;
297
+ }
298
+ return path.join(root, "bin");
299
+ }
300
+
301
+ function maybeHealBinCollision(output) {
302
+ const text = String(output || "");
303
+ if (!text.includes("EEXIST")) {
304
+ return false;
305
+ }
306
+ const binDir = npmGlobalBinDir();
307
+ if (!binDir) {
308
+ return false;
309
+ }
310
+ let removed = false;
311
+ for (const name of ["PF", "pf", "pf-gate"]) {
312
+ const candidate = path.join(binDir, name);
313
+ try {
314
+ if (fs.existsSync(candidate)) {
315
+ fs.rmSync(candidate, { force: true });
316
+ removed = true;
317
+ }
318
+ } catch (_error) {
319
+ // keep going and try remaining bins
320
+ }
321
+ }
322
+ if (removed) {
323
+ console.log("PF Gate updater: removed stale global CLI bin links; retrying install...");
324
+ }
325
+ return removed;
326
+ }
327
+
328
+ function installLatestCliPackage(packageName, registry) {
329
+ const args = ["i", "-g", `${packageName}@latest`, "--registry", registry];
330
+ const run = () =>
331
+ spawnSync("npm", args, {
332
+ stdio: "pipe",
333
+ encoding: "utf-8",
334
+ });
335
+
336
+ const writeOutput = (result) => {
337
+ if (result.stdout) {
338
+ process.stdout.write(String(result.stdout));
339
+ }
340
+ if (result.stderr) {
341
+ process.stderr.write(String(result.stderr));
342
+ }
343
+ };
344
+
345
+ let result = run();
346
+ writeOutput(result);
347
+ if (!result.error && (result.status ?? 1) === 0) {
348
+ return true;
349
+ }
350
+
351
+ const combined = `${String(result.stdout || "")}\n${String(result.stderr || "")}`;
352
+ if (maybeHealBinCollision(combined)) {
353
+ result = run();
354
+ writeOutput(result);
355
+ if (!result.error && (result.status ?? 1) === 0) {
356
+ return true;
357
+ }
358
+ }
359
+ return false;
360
+ }
361
+
289
362
  async function maybeOfferCliUpdate(metadata) {
290
363
  if (String(process.env.PF_GATE_DISABLE_UPDATE_CHECK || "").trim() === "1") {
291
364
  debugUpdate("disabled via PF_GATE_DISABLE_UPDATE_CHECK=1");
@@ -311,12 +384,8 @@ async function maybeOfferCliUpdate(metadata) {
311
384
  return false;
312
385
  }
313
386
  console.log(`Updating ${metadata.name}...`);
314
- const result = spawnSync(
315
- "npm",
316
- ["i", "-g", `${metadata.name}@latest`, "--registry", registry],
317
- { stdio: "inherit" }
318
- );
319
- if (result.error || (result.status ?? 1) !== 0) {
387
+ const installed = installLatestCliPackage(metadata.name, registry);
388
+ if (!installed) {
320
389
  console.log("Update failed. Continuing with current version.");
321
390
  return false;
322
391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qpfai/pf-gate-cli",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "PF Gate terminal launcher with first-run runtime bootstrap.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",