@usagefleet/cli 1.2.108 → 1.2.109
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/dist/release.js +1 -1
- package/dist/service.js +29 -9
- package/package.json +1 -1
package/dist/release.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by .github/workflows/release.yml.
|
|
2
|
-
export const RELEASE_VERSION = "1.2.
|
|
2
|
+
export const RELEASE_VERSION = "1.2.109";
|
package/dist/service.js
CHANGED
|
@@ -63,20 +63,20 @@ export function looksLikeCompiledBinary(scriptPath, execPath) {
|
|
|
63
63
|
}
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
|
+
function real(p) {
|
|
67
|
+
try {
|
|
68
|
+
return realpathSync(p);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return p;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
66
74
|
/** The `usagefleet` a shell would run, when that is NOT this install — e.g. the
|
|
67
75
|
* standalone binary a pre-npm release left in /usr/local/bin, which sits ahead
|
|
68
76
|
* of the npm prefix on most PATHs and would keep answering after an upgrade.
|
|
69
77
|
* Only the first hit matters: that is the one the shell picks. */
|
|
70
78
|
export function shadowingBinary(pathEnv, self) {
|
|
71
79
|
const name = process.platform === 'win32' ? 'usagefleet.exe' : 'usagefleet';
|
|
72
|
-
const real = (p) => {
|
|
73
|
-
try {
|
|
74
|
-
return realpathSync(p);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
return p;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
80
|
for (const dir of (pathEnv || '').split(delimiter).filter(Boolean)) {
|
|
81
81
|
const candidate = join(dir, name);
|
|
82
82
|
if (existsSync(candidate)) {
|
|
@@ -85,6 +85,26 @@ export function shadowingBinary(pathEnv, self) {
|
|
|
85
85
|
}
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
|
+
/** The node path to bake into the service definition. `execPath` is the real
|
|
89
|
+
* binary, and under Homebrew that is a versioned keg
|
|
90
|
+
* (`/opt/homebrew/Cellar/node/26.7.0/bin/node`) which the next `brew upgrade`
|
|
91
|
+
* deletes. The running collector survives on its open file, but the moment it
|
|
92
|
+
* stops launchd can no longer spawn it (EX_CONFIG, penalty box) and the
|
|
93
|
+
* machine silently drops off the fleet until the next `login` — every prompt
|
|
94
|
+
* it sends from then on reads as unattributed. Brew keeps
|
|
95
|
+
* `<prefix>/opt/<formula>` pointing at the formula's current keg, so that name
|
|
96
|
+
* is what survives. Not verified against `execPath`: after an upgrade the two
|
|
97
|
+
* differ by design, and the version brew now links is the one to run. Other
|
|
98
|
+
* managers (nvm, fnm, asdf) keep old versions installed, so their versioned
|
|
99
|
+
* paths are left alone. */
|
|
100
|
+
export function stableNodePath(execPath) {
|
|
101
|
+
const keg = /^(.*)\/Cellar\/(node(?:@[^/]+)?)\/[^/]+\/bin\/node$/.exec(execPath);
|
|
102
|
+
if (!keg) {
|
|
103
|
+
return execPath;
|
|
104
|
+
}
|
|
105
|
+
const stable = join(keg[1], 'opt', keg[2], 'bin', 'node');
|
|
106
|
+
return existsSync(stable) ? stable : execPath;
|
|
107
|
+
}
|
|
88
108
|
/** Program + leading args to launch `watch`. npm installs a script, so this is
|
|
89
109
|
* normally an absolute node plus the global package path — both survive PATH
|
|
90
110
|
* being nearly empty, which is what launchd and systemd hand the service. */
|
|
@@ -95,7 +115,7 @@ function programArgs() {
|
|
|
95
115
|
// re-invokable script, so the service launches the executable itself.
|
|
96
116
|
return [process.execPath, 'watch'];
|
|
97
117
|
}
|
|
98
|
-
return [process.execPath, script, 'watch'];
|
|
118
|
+
return [stableNodePath(process.execPath), script, 'watch'];
|
|
99
119
|
}
|
|
100
120
|
function macPlistPath() {
|
|
101
121
|
return join(homedir(), 'Library', 'LaunchAgents', `${LABEL}.plist`);
|