@tolinax/ayoune-cli 2026.7.0 → 2026.7.1

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,11 +1,11 @@
1
- import { exec } from "child_process";
1
+ import { spawn } from "child_process";
2
2
  import chalk from "chalk";
3
3
  import { localStorage } from "./localStorage.js";
4
4
  const PKG_NAME = "@tolinax/ayoune-cli";
5
5
  const CHECK_INTERVAL_MS = 4 * 60 * 60 * 1000; // 4 hours
6
6
  /**
7
- * Non-blocking update check. Fires an async npm view in the background.
8
- * Shows cached notice immediately if one exists; refreshes the cache asynchronously.
7
+ * Non-blocking update check. Only uses cached data never spawns child processes
8
+ * during the CLI invocation. A detached background script refreshes the cache.
9
9
  */
10
10
  export function checkForUpdates(currentVersion) {
11
11
  try {
@@ -20,16 +20,32 @@ export function checkForUpdates(currentVersion) {
20
20
  const lastCheck = localStorage.getItem("updateCheckTimestamp");
21
21
  if (lastCheck && Date.now() - parseInt(lastCheck, 10) < CHECK_INTERVAL_MS)
22
22
  return;
23
- // Fire-and-forget: async check, never blocks startup
24
- exec(`npm view ${PKG_NAME} version`, { timeout: 5000 }, (err, stdout) => {
25
- if (err)
26
- return;
27
- const latest = stdout.trim();
28
- if (latest) {
29
- localStorage.setItem("updateCheckTimestamp", String(Date.now()));
30
- localStorage.setItem("updateCheckLatest", latest);
31
- }
23
+ // Mark as checked immediately to prevent duplicate spawns
24
+ localStorage.setItem("updateCheckTimestamp", String(Date.now()));
25
+ // Spawn a fully detached node process that fetches the version and writes to localStorage.
26
+ // detached + unref + stdio:ignore ensures no file locks are held by the parent.
27
+ const storagePath = localStorage._location || "";
28
+ const script = `
29
+ const https = require("https");
30
+ const fs = require("fs");
31
+ const path = require("path");
32
+ const url = "https://registry.npmjs.org/${PKG_NAME}/latest";
33
+ https.get(url, { headers: { "Accept": "application/json" }, timeout: 5000 }, (res) => {
34
+ let data = "";
35
+ res.on("data", (c) => data += c);
36
+ res.on("end", () => {
37
+ try {
38
+ const ver = JSON.parse(data).version;
39
+ if (ver) fs.writeFileSync(path.join("${storagePath.replace(/\\/g, "\\\\")}", "updateCheckLatest"), ver);
40
+ } catch {}
32
41
  });
42
+ }).on("error", () => {});
43
+ `;
44
+ const child = spawn(process.execPath, ["-e", script], {
45
+ detached: true,
46
+ stdio: "ignore",
47
+ });
48
+ child.unref();
33
49
  }
34
50
  catch (_a) {
35
51
  // Silently ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-cli",
3
- "version": "2026.7.0",
3
+ "version": "2026.7.1",
4
4
  "description": "CLI for the aYOUne Business-as-a-Service platform",
5
5
  "type": "module",
6
6
  "main": "./index.js",