@qpfai/pf-gate-cli 1.0.7 → 1.0.9
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/README.md
CHANGED
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-02-16T21:
|
|
3
|
+
"generatedAt": "2026-02-16T21:44:07.077Z",
|
|
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": "
|
|
7
|
+
"sha256": "4907460d6b40f0332da0f60d167343205609c422e6648c605116ffa44d058989"
|
|
8
8
|
}
|
package/lib/main.mjs
CHANGED
|
@@ -14,7 +14,8 @@ const PACKAGE_ROOT = path.resolve(__dirname, "..");
|
|
|
14
14
|
const ARTIFACT_MANIFEST_PATH = path.join(PACKAGE_ROOT, "artifacts", "python-wheel.json");
|
|
15
15
|
const INSTALL_STATE_NAME = "install-state.json";
|
|
16
16
|
const PYTHON_CANDIDATES = ["python3.13", "python3", "python"];
|
|
17
|
-
const
|
|
17
|
+
const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
18
|
+
const UPDATE_CHECK_TIMEOUT_MS = 6000;
|
|
18
19
|
|
|
19
20
|
function isWindows() {
|
|
20
21
|
return process.platform === "win32";
|
|
@@ -141,7 +142,25 @@ export function compareVersions(left, right) {
|
|
|
141
142
|
return 0;
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
function
|
|
145
|
+
function configuredNpmRegistry() {
|
|
146
|
+
const fromEnv = String(process.env.PF_GATE_NPM_REGISTRY || "").trim();
|
|
147
|
+
if (fromEnv) {
|
|
148
|
+
return fromEnv.replace(/\/+$/, "");
|
|
149
|
+
}
|
|
150
|
+
return DEFAULT_NPM_REGISTRY;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function debugUpdateEnabled() {
|
|
154
|
+
return String(process.env.PF_GATE_DEBUG_UPDATE_CHECK || "").trim() === "1";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function debugUpdate(message) {
|
|
158
|
+
if (debugUpdateEnabled()) {
|
|
159
|
+
console.log(`[PF Gate update-check] ${message}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function fetchJson(url, timeoutMs = UPDATE_CHECK_TIMEOUT_MS) {
|
|
145
164
|
return new Promise((resolve) => {
|
|
146
165
|
const request = https.get(
|
|
147
166
|
url,
|
|
@@ -177,10 +196,7 @@ function fetchJson(url, timeoutMs = 2500) {
|
|
|
177
196
|
});
|
|
178
197
|
}
|
|
179
198
|
|
|
180
|
-
|
|
181
|
-
const encoded = encodeURIComponent(packageName);
|
|
182
|
-
const url = `${NPM_REGISTRY}/-/package/${encoded}/dist-tags`;
|
|
183
|
-
const payload = await fetchJson(url);
|
|
199
|
+
export function latestFromDistTags(payload) {
|
|
184
200
|
if (!payload || typeof payload !== "object") {
|
|
185
201
|
return null;
|
|
186
202
|
}
|
|
@@ -191,6 +207,61 @@ async function fetchLatestVersion(packageName) {
|
|
|
191
207
|
return latest;
|
|
192
208
|
}
|
|
193
209
|
|
|
210
|
+
export function parseNpmViewVersion(raw) {
|
|
211
|
+
const text = String(raw || "").trim();
|
|
212
|
+
if (!text) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const parsed = JSON.parse(text);
|
|
217
|
+
if (typeof parsed === "string" && parsed.trim()) {
|
|
218
|
+
return parsed.trim();
|
|
219
|
+
}
|
|
220
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
221
|
+
const first = String(parsed[0] || "").trim();
|
|
222
|
+
return first || null;
|
|
223
|
+
}
|
|
224
|
+
} catch (_error) {
|
|
225
|
+
// npm can return plain text; fall through.
|
|
226
|
+
}
|
|
227
|
+
const firstLine = text.split(/\r?\n/, 1)[0] || "";
|
|
228
|
+
const candidate = firstLine.replace(/^["']|["']$/g, "").trim();
|
|
229
|
+
return candidate || null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function fetchLatestVersionFromNpmCli(packageName, registry) {
|
|
233
|
+
const probe = runCapture("npm", [
|
|
234
|
+
"view",
|
|
235
|
+
`${packageName}@latest`,
|
|
236
|
+
"version",
|
|
237
|
+
"--json",
|
|
238
|
+
"--registry",
|
|
239
|
+
registry,
|
|
240
|
+
]);
|
|
241
|
+
if (!probe.ok) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return parseNpmViewVersion(probe.output);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function fetchLatestVersion(packageName, registry) {
|
|
248
|
+
const encoded = encodeURIComponent(packageName);
|
|
249
|
+
const url = `${registry}/-/package/${encoded}/dist-tags`;
|
|
250
|
+
debugUpdate(`fetch ${url}`);
|
|
251
|
+
const payload = await fetchJson(url);
|
|
252
|
+
const latest = latestFromDistTags(payload);
|
|
253
|
+
if (latest) {
|
|
254
|
+
debugUpdate(`dist-tags latest=${latest}`);
|
|
255
|
+
return latest;
|
|
256
|
+
}
|
|
257
|
+
debugUpdate("dist-tags unavailable; falling back to npm view");
|
|
258
|
+
const fallback = fetchLatestVersionFromNpmCli(packageName, registry);
|
|
259
|
+
if (fallback) {
|
|
260
|
+
debugUpdate(`npm view latest=${fallback}`);
|
|
261
|
+
}
|
|
262
|
+
return fallback;
|
|
263
|
+
}
|
|
264
|
+
|
|
194
265
|
function canPrompt() {
|
|
195
266
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
196
267
|
}
|
|
@@ -217,13 +288,18 @@ async function promptYesNo(question, defaultYes = true) {
|
|
|
217
288
|
|
|
218
289
|
async function maybeOfferCliUpdate(metadata) {
|
|
219
290
|
if (String(process.env.PF_GATE_DISABLE_UPDATE_CHECK || "").trim() === "1") {
|
|
291
|
+
debugUpdate("disabled via PF_GATE_DISABLE_UPDATE_CHECK=1");
|
|
220
292
|
return false;
|
|
221
293
|
}
|
|
222
|
-
const
|
|
294
|
+
const registry = configuredNpmRegistry();
|
|
295
|
+
debugUpdate(`current=${metadata.version}, package=${metadata.name}, registry=${registry}`);
|
|
296
|
+
const latestVersion = await fetchLatestVersion(metadata.name, registry);
|
|
223
297
|
if (!latestVersion) {
|
|
298
|
+
debugUpdate("unable to resolve latest version");
|
|
224
299
|
return false;
|
|
225
300
|
}
|
|
226
301
|
if (compareVersions(latestVersion, metadata.version) <= 0) {
|
|
302
|
+
debugUpdate(`up-to-date (latest=${latestVersion})`);
|
|
227
303
|
return false;
|
|
228
304
|
}
|
|
229
305
|
console.log(
|
|
@@ -237,7 +313,7 @@ async function maybeOfferCliUpdate(metadata) {
|
|
|
237
313
|
console.log(`Updating ${metadata.name}...`);
|
|
238
314
|
const result = spawnSync(
|
|
239
315
|
"npm",
|
|
240
|
-
["i", "-g", `${metadata.name}@latest`, "--registry",
|
|
316
|
+
["i", "-g", `${metadata.name}@latest`, "--registry", registry],
|
|
241
317
|
{ stdio: "inherit" }
|
|
242
318
|
);
|
|
243
319
|
if (result.error || (result.status ?? 1) !== 0) {
|
|
@@ -449,8 +525,13 @@ export async function runCli(args) {
|
|
|
449
525
|
const runtimeRoot = ensureRuntimeInstalled(metadata.version);
|
|
450
526
|
const pythonPath = runtimePythonPath(runtimeRoot);
|
|
451
527
|
const resolvedArgs = args.length === 0 ? ["Gate"] : args;
|
|
528
|
+
const childEnv = {
|
|
529
|
+
...process.env,
|
|
530
|
+
PF_GATE_CLI_VERSION: metadata.version,
|
|
531
|
+
};
|
|
452
532
|
const child = spawnSync(pythonPath, runtimeLauncherArgs(resolvedArgs), {
|
|
453
533
|
stdio: "inherit",
|
|
534
|
+
env: childEnv,
|
|
454
535
|
});
|
|
455
536
|
if (child.error) {
|
|
456
537
|
throw child.error;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qpfai/pf-gate-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "PF Gate terminal launcher with first-run runtime bootstrap.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"PF": "bin/pf.mjs",
|
|
9
|
+
"pf": "bin/pf.mjs",
|
|
9
10
|
"pf-gate": "bin/pf.mjs"
|
|
10
11
|
},
|
|
11
12
|
"files": [
|