@rubytech/taskmaster 1.0.83 → 1.0.84
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/build-info.json +3 -3
- package/package.json +1 -1
- package/scripts/postinstall.js +58 -0
package/dist/build-info.json
CHANGED
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -254,12 +254,70 @@ function applyPatchFile({ patchPath, targetDir }) {
|
|
|
254
254
|
applyPatchSet({ patchText, targetDir });
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
/**
|
|
258
|
+
* On Linux global installs (including upgrades), ensure platform dependencies
|
|
259
|
+
* that the original install may have missed are present. Runs as root since
|
|
260
|
+
* `sudo npm install -g` passes root to postinstall.
|
|
261
|
+
*/
|
|
262
|
+
function ensurePlatformDeps() {
|
|
263
|
+
if (process.platform !== "linux") return;
|
|
264
|
+
// Only run for global installs (deployed devices), not local dev
|
|
265
|
+
const isGlobal =
|
|
266
|
+
process.env.npm_config_global === "true" ||
|
|
267
|
+
// npm 9+ sets this instead
|
|
268
|
+
(getRepoRoot().includes("/lib/node_modules/") && !fs.existsSync(path.join(getRepoRoot(), ".git")));
|
|
269
|
+
if (!isGlobal) return;
|
|
270
|
+
|
|
271
|
+
const deps = [
|
|
272
|
+
{
|
|
273
|
+
name: "tailscale",
|
|
274
|
+
check: "tailscale",
|
|
275
|
+
install: ["sh", "-c", "curl -fsSL https://tailscale.com/install.sh | sh"],
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "avahi-daemon",
|
|
279
|
+
check: "avahi-browse",
|
|
280
|
+
install: ["apt-get", "install", "-y", "avahi-daemon", "avahi-utils"],
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
|
|
284
|
+
for (const dep of deps) {
|
|
285
|
+
const exists = spawnSync("command", ["-v", dep.check], { shell: true, stdio: "ignore" });
|
|
286
|
+
if (exists.status === 0) continue;
|
|
287
|
+
console.log(`[postinstall] Installing ${dep.name}...`);
|
|
288
|
+
const result = spawnSync(dep.install[0], dep.install.slice(1), {
|
|
289
|
+
stdio: "inherit",
|
|
290
|
+
timeout: 120_000,
|
|
291
|
+
});
|
|
292
|
+
if (result.status === 0) {
|
|
293
|
+
console.log(`[postinstall] ${dep.name} installed`);
|
|
294
|
+
} else {
|
|
295
|
+
console.warn(`[postinstall] ${dep.name} install failed (continuing)`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Ensure hostname resolves in /etc/hosts (prevents sudo timeouts)
|
|
300
|
+
try {
|
|
301
|
+
const hostname = spawnSync("hostname", [], { encoding: "utf-8" }).stdout.trim();
|
|
302
|
+
if (hostname) {
|
|
303
|
+
const hosts = fs.readFileSync("/etc/hosts", "utf-8");
|
|
304
|
+
if (!hosts.includes(hostname)) {
|
|
305
|
+
fs.appendFileSync("/etc/hosts", `\n127.0.1.1\t${hostname}\n`);
|
|
306
|
+
console.log(`[postinstall] Added ${hostname} to /etc/hosts`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
// non-critical
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
257
314
|
function main() {
|
|
258
315
|
const repoRoot = getRepoRoot();
|
|
259
316
|
process.chdir(repoRoot);
|
|
260
317
|
|
|
261
318
|
ensureExecutable(path.join(repoRoot, "dist", "entry.js"));
|
|
262
319
|
setupGitHooks({ repoRoot });
|
|
320
|
+
ensurePlatformDeps();
|
|
263
321
|
|
|
264
322
|
if (!shouldApplyPnpmPatchedDependenciesFallback()) {
|
|
265
323
|
return;
|