@mutmutco/hub 4.0.5 → 4.0.6

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.
Files changed (2) hide show
  1. package/dist/index.cjs +44 -4
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -212,6 +212,17 @@ function resolveNpm(env = process.env) {
212
212
  return cachedNpm;
213
213
  }
214
214
  }
215
+ const bundled = (0, import_node_path2.join)((0, import_node_path2.dirname)(process.execPath), "..", "lib", "node_modules", "npm", "bin", "npm-cli.js");
216
+ if ((0, import_node_fs2.existsSync)(bundled)) {
217
+ cachedNpm = { kind: "node-script", script: bundled };
218
+ return cachedNpm;
219
+ }
220
+ const located = (0, import_node_child_process.spawnSync)("/bin/sh", ["-lc", "command -v npm"], { encoding: "utf8", windowsHide: true });
221
+ const resolved = (located.stdout ?? "").trim().split("\n").map((line) => line.trim()).find(Boolean);
222
+ if (located.status === 0 && resolved && (0, import_node_fs2.existsSync)(resolved)) {
223
+ cachedNpm = { kind: "command", command: resolved };
224
+ return cachedNpm;
225
+ }
215
226
  cachedNpm = { kind: "command", command: "npm" };
216
227
  return cachedNpm;
217
228
  }
@@ -1975,12 +1986,24 @@ code = shell.Run("""${vbsQuote(nodeExe)}"" ""${vbsQuote(hubDist)}"" update", 0,
1975
1986
  WScript.Quit code
1976
1987
  `;
1977
1988
  }
1978
- function launcherSh(nodeExe, hubDist) {
1989
+ function loginPath(fallback = process.env.PATH ?? "") {
1990
+ const probe = (0, import_node_child_process9.spawnSync)("/bin/sh", ["-lc", 'printf %s "$PATH"'], { encoding: "utf8", windowsHide: true, timeout: 1e4 });
1991
+ const captured = (probe.status === 0 ? probe.stdout ?? "" : "").trim();
1992
+ const source = captured || fallback;
1993
+ const durable = source.split(":").filter((entry) => entry && !/^\/(?:private\/)?(?:tmp|var\/folders)\//.test(entry));
1994
+ return [...new Set(durable)].join(":");
1995
+ }
1996
+ function launcherSh(nodeExe, hubDist, capturedPath = loginPath()) {
1979
1997
  const shQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
1998
+ const pathLine = capturedPath ? `PATH=${shQuote(capturedPath)}:"$PATH"
1999
+ export PATH
2000
+ ` : "";
1980
2001
  return `#!/bin/sh
1981
2002
  # MMI Hub maintenance launcher \u2014 generated by \`mmi-hub autoupdate on\`.
1982
2003
  # The exit code is propagated and reported by \`mmi-hub status\`.
1983
- exec ${shQuote(nodeExe)} ${shQuote(hubDist)} update
2004
+ # PATH is the one captured when autoupdate was enabled: a scheduler's PATH is not the interactive
2005
+ # one, and every surface below is reached through a command that lives outside it (#5278).
2006
+ ${pathLine}exec ${shQuote(nodeExe)} ${shQuote(hubDist)} update
1984
2007
  `;
1985
2008
  }
1986
2009
  function taskXml(launcherPath, workDir, userId, startBoundary) {
@@ -2235,9 +2258,23 @@ function installWindowsTask(env) {
2235
2258
  }
2236
2259
  return { ok: true, detail: `enabled "${TASK_NAME}" \u2014 ${CADENCE} \u2192 ${hubDist}` };
2237
2260
  }
2261
+ function refreshPosixLauncher(env) {
2262
+ const hubDist = globalDist(env, "@mutmutco/hub", "dist/index.cjs");
2263
+ if (!hubDist) return null;
2264
+ const paths = ensureState(env);
2265
+ const launcherPath = (0, import_node_path12.join)(paths.root, POSIX_LAUNCHER_FILE);
2266
+ const desired = launcherSh(process.execPath, hubDist);
2267
+ if (readFileOrNull(launcherPath) === desired) return null;
2268
+ (0, import_node_fs14.writeFileSync)(launcherPath, desired, "utf8");
2269
+ (0, import_node_fs14.chmodSync)(launcherPath, 493);
2270
+ return launcherPath;
2271
+ }
2238
2272
  function installLaunchd(env) {
2239
2273
  const current = darwinSchedulerStatus(env);
2240
- if (current.ok) return { ok: true, detail: `already enabled \u2014 ${current.detail}` };
2274
+ if (current.ok) {
2275
+ const refreshed = refreshPosixLauncher(env);
2276
+ return { ok: true, detail: refreshed ? `already enabled; launcher refreshed \u2014 ${current.detail}` : `already enabled \u2014 ${current.detail}` };
2277
+ }
2241
2278
  const hubDist = globalDist(env, "@mutmutco/hub", "dist/index.cjs");
2242
2279
  if (!hubDist) return { ok: false, detail: "cannot resolve the global @mutmutco/hub dist \u2014 run `npm install -g @mutmutco/hub` first" };
2243
2280
  const paths = ensureState(env);
@@ -2258,7 +2295,10 @@ function installLaunchd(env) {
2258
2295
  }
2259
2296
  function installSystemdTimer(env) {
2260
2297
  const current = linuxSchedulerStatus(env);
2261
- if (current.ok) return { ok: true, detail: `already enabled \u2014 ${current.detail}` };
2298
+ if (current.ok) {
2299
+ const refreshed = refreshPosixLauncher(env);
2300
+ return { ok: true, detail: refreshed ? `already enabled; launcher refreshed \u2014 ${current.detail}` : `already enabled \u2014 ${current.detail}` };
2301
+ }
2262
2302
  const hubDist = globalDist(env, "@mutmutco/hub", "dist/index.cjs");
2263
2303
  if (!hubDist) return { ok: false, detail: "cannot resolve the global @mutmutco/hub dist \u2014 run `npm install -g @mutmutco/hub` first" };
2264
2304
  const paths = ensureState(env);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutmutco/hub",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "description": "Install and maintain the MMI CLI and every present host surface from one release-gated Hub command.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",