@qpfai/pf-gate-cli 1.0.2 → 1.0.5

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-16T19:11:19.187Z",
3
+ "generatedAt": "2026-02-16T19:55:04.750Z",
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": "30ef4c0fdd6ada01a9edcdffbacf3a6a3d7c0e676ab1e13670362594caa84b7f"
7
+ "sha256": "140b406d1c04dd8c12c29aa7c0506651e85dfa1fea51177a47f15a3190611447"
8
8
  }
package/lib/main.mjs CHANGED
@@ -27,6 +27,10 @@ function runtimePythonPath(runtimeRoot) {
27
27
  return path.join(runtimeRoot, ".venv", "bin", "python");
28
28
  }
29
29
 
30
+ function runtimeVenvPath(runtimeRoot) {
31
+ return path.join(runtimeRoot, ".venv");
32
+ }
33
+
30
34
  function runtimePipArgs(runtimeRoot) {
31
35
  return ["-m", "pip"];
32
36
  }
@@ -72,6 +76,31 @@ function runChecked(command, args, options = {}) {
72
76
  }
73
77
  }
74
78
 
79
+ function runCheckedCapture(command, args, options = {}) {
80
+ const result = spawnSync(command, args, {
81
+ stdio: "pipe",
82
+ encoding: "utf-8",
83
+ ...options,
84
+ });
85
+ if (result.stdout) {
86
+ process.stdout.write(String(result.stdout));
87
+ }
88
+ if (result.stderr) {
89
+ process.stderr.write(String(result.stderr));
90
+ }
91
+ if (result.error) {
92
+ throw result.error;
93
+ }
94
+ if ((result.status ?? 1) !== 0) {
95
+ const combined = `${String(result.stdout || "")}\n${String(result.stderr || "")}`;
96
+ const error = new Error(
97
+ `Command failed (${result.status}): ${command} ${args.join(" ")}`
98
+ );
99
+ error.commandOutput = combined;
100
+ throw error;
101
+ }
102
+ }
103
+
75
104
  function runCapture(command, args) {
76
105
  const result = spawnSync(command, args, {
77
106
  stdio: "pipe",
@@ -336,6 +365,15 @@ function ensureVirtualenv(runtimeRoot, bootstrapPython) {
336
365
  runChecked(bootstrapPython, ["-m", "venv", path.join(runtimeRoot, ".venv")]);
337
366
  }
338
367
 
368
+ function recreateVirtualenv(runtimeRoot, bootstrapPython) {
369
+ const venvPath = runtimeVenvPath(runtimeRoot);
370
+ if (fs.existsSync(venvPath)) {
371
+ fs.rmSync(venvPath, { recursive: true, force: true });
372
+ }
373
+ console.log("PF Gate bootstrap: recreating runtime virtual environment...");
374
+ runChecked(bootstrapPython, ["-m", "venv", venvPath]);
375
+ }
376
+
339
377
  function installRuntime(runtimeRoot, source, cliVersion) {
340
378
  const pythonPath = runtimePythonPath(runtimeRoot);
341
379
  const skipPipUpgrade = String(process.env.PF_GATE_SKIP_PIP_UPGRADE || "").trim() === "1";
@@ -345,7 +383,7 @@ function installRuntime(runtimeRoot, source, cliVersion) {
345
383
  }
346
384
  console.log("PF Gate bootstrap: installing PF Gate runtime...");
347
385
  if (source.kind === "wheel") {
348
- runChecked(pythonPath, [
386
+ runCheckedCapture(pythonPath, [
349
387
  ...runtimePipArgs(runtimeRoot),
350
388
  "install",
351
389
  "--upgrade",
@@ -353,7 +391,7 @@ function installRuntime(runtimeRoot, source, cliVersion) {
353
391
  source.wheelPath,
354
392
  ]);
355
393
  } else {
356
- runChecked(pythonPath, [
394
+ runCheckedCapture(pythonPath, [
357
395
  ...runtimePipArgs(runtimeRoot),
358
396
  "install",
359
397
  "--upgrade",
@@ -385,7 +423,13 @@ function ensureRuntimeInstalled(cliVersion) {
385
423
  if (!isRuntimeHealthy(runtimeRoot, source, cliVersion)) {
386
424
  const bootstrapPython = resolvePython();
387
425
  ensureVirtualenv(runtimeRoot, bootstrapPython);
388
- installRuntime(runtimeRoot, source, cliVersion);
426
+ try {
427
+ installRuntime(runtimeRoot, source, cliVersion);
428
+ } catch (error) {
429
+ console.log("PF Gate bootstrap: runtime install failed. Retrying with a clean environment...");
430
+ recreateVirtualenv(runtimeRoot, bootstrapPython);
431
+ installRuntime(runtimeRoot, source, cliVersion);
432
+ }
389
433
  }
390
434
  return runtimeRoot;
391
435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qpfai/pf-gate-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "PF Gate terminal launcher with first-run runtime bootstrap.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",