appostle-installer 0.1.42 → 0.1.43

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.
@@ -9960,14 +9960,30 @@ async function runInteractive(command, args = [], options = {}) {
9960
9960
  await execa(command, args, { stdio: "inherit", ...options });
9961
9961
  }
9962
9962
  var cachedNeedsSudo = null;
9963
+ var cachedGlobalPrefix;
9964
+ async function npmGlobalPrefix() {
9965
+ if (cachedGlobalPrefix !== void 0) return cachedGlobalPrefix;
9966
+ try {
9967
+ const { stdout } = await execa("npm", ["prefix", "-g"]);
9968
+ const prefix = stdout.trim();
9969
+ return cachedGlobalPrefix = prefix || null;
9970
+ } catch {
9971
+ return cachedGlobalPrefix = null;
9972
+ }
9973
+ }
9974
+ async function npmGlobalBinDir() {
9975
+ const prefix = await npmGlobalPrefix();
9976
+ if (!prefix) return null;
9977
+ if (currentPlatform() === "win32") return prefix;
9978
+ return `${prefix}/bin`;
9979
+ }
9963
9980
  async function npmGlobalNeedsSudo() {
9964
9981
  if (cachedNeedsSudo !== null) return cachedNeedsSudo;
9965
9982
  if (currentPlatform() === "win32") return cachedNeedsSudo = false;
9966
9983
  if (process.getuid?.() === 0) return cachedNeedsSudo = false;
9984
+ const prefix = await npmGlobalPrefix();
9985
+ if (!prefix) return cachedNeedsSudo = false;
9967
9986
  try {
9968
- const { stdout } = await execa("npm", ["prefix", "-g"]);
9969
- const prefix = stdout.trim();
9970
- if (!prefix) return cachedNeedsSudo = false;
9971
9987
  accessSync(prefix, constants4.W_OK);
9972
9988
  return cachedNeedsSudo = false;
9973
9989
  } catch {
@@ -9976,7 +9992,8 @@ async function npmGlobalNeedsSudo() {
9976
9992
  }
9977
9993
  async function npmInstallGlobal(packages) {
9978
9994
  const useSudo = await npmGlobalNeedsSudo();
9979
- const args = ["install", "-g", ...packages];
9995
+ const prefix = await npmGlobalPrefix();
9996
+ const args = ["install", "-g", ...prefix ? ["--prefix", prefix] : [], ...packages];
9980
9997
  if (useSudo) {
9981
9998
  await runInteractive("sudo", ["-E", "npm", ...args]);
9982
9999
  } else {
@@ -9994,6 +10011,14 @@ function resolvePackagedAppostleBin() {
9994
10011
  }
9995
10012
  return null;
9996
10013
  }
10014
+ var LAUNCHD_BASE_PATH = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin";
10015
+ var SYSTEMD_BASE_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
10016
+ function composeDaemonPath(npmBin, basePath) {
10017
+ if (!npmBin) return basePath;
10018
+ const parts = basePath.split(":").filter(Boolean);
10019
+ if (parts.includes(npmBin)) return basePath;
10020
+ return [npmBin, ...parts].join(":");
10021
+ }
9997
10022
  async function installAppostleGlobal() {
9998
10023
  await npmInstallGlobal([`${INSTALLER_PACKAGE}@latest`]);
9999
10024
  }
@@ -10110,6 +10135,7 @@ async function installLaunchd() {
10110
10135
  const plistPath = path6.join(osHome, "Library", "LaunchAgents", "agency.ohlord.appostle.plist");
10111
10136
  const logPath = path6.join(osHome, "Library", "Logs", "appostle.log");
10112
10137
  const appostleBin = resolvePackagedAppostleBin() ?? await resolveBinary("appostle") ?? "/usr/local/bin/appostle";
10138
+ const daemonPath = composeDaemonPath(await npmGlobalBinDir(), LAUNCHD_BASE_PATH);
10113
10139
  const plist = `<?xml version="1.0" encoding="UTF-8"?>
10114
10140
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
10115
10141
  <plist version="1.0">
@@ -10128,7 +10154,7 @@ async function installLaunchd() {
10128
10154
  <key>StandardErrorPath</key><string>${logPath}</string>
10129
10155
  <key>EnvironmentVariables</key>
10130
10156
  <dict>
10131
- <key>PATH</key><string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
10157
+ <key>PATH</key><string>${daemonPath}</string>
10132
10158
  <key>HOME</key><string>${osHome}</string>
10133
10159
  <key>NODE_ENV</key><string>production</string>
10134
10160
  <key>APPOSTLE_RELAY_ENDPOINT</key><string>${APPOSTLE_RELAY_ENDPOINT}</string>
@@ -10271,6 +10297,7 @@ async function installSystemdSystem() {
10271
10297
  const unitPath = "/etc/systemd/system/appostle.service";
10272
10298
  const appostleBin = resolvePackagedAppostleBin() ?? await resolveBinary("appostle") ?? "/usr/bin/appostle";
10273
10299
  const logPath = path6.join(osHome, ".local", "state", "appostle", "daemon.log");
10300
+ const daemonPath = composeDaemonPath(await npmGlobalBinDir(), SYSTEMD_BASE_PATH);
10274
10301
  const unit = `[Unit]
10275
10302
  Description=Appostle Daemon
10276
10303
  After=network.target
@@ -10283,6 +10310,7 @@ Restart=always
10283
10310
  RestartSec=2
10284
10311
  Environment=NODE_ENV=production
10285
10312
  Environment=HOME=${osHome}
10313
+ Environment=PATH=${daemonPath}
10286
10314
  Environment=APPOSTLE_RELAY_ENDPOINT=${APPOSTLE_RELAY_ENDPOINT}
10287
10315
  StandardOutput=append:${logPath}
10288
10316
  StandardError=append:${logPath}