@paradow/ledge 0.15.0 → 0.16.0
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/README.md +7 -3
- package/dist/cli/{attach-Y4OMZXAH.js → attach-5H727FCW.js} +4 -4
- package/dist/cli/{bridge-6K523KUX.js → bridge-LXMOQN6Q.js} +1 -1
- package/dist/cli/chunk-CBKKOJIG.js +6 -0
- package/dist/cli/{chunk-CU2E3W4L.js → chunk-DBSCO3HI.js} +66 -27
- package/dist/cli/{chunk-PXO4FFJR.js → chunk-DEXDXDO4.js} +1 -1
- package/dist/cli/{chunk-KGEF6OIU.js → chunk-H36JD4E3.js} +61 -10
- package/dist/cli/{chunk-4IBQ4PG6.js → chunk-MQICEVKR.js} +3 -3
- package/dist/cli/{chunk-2LQITRTR.js → chunk-Q5WWH7FG.js} +50 -9
- package/dist/cli/{chunk-IMSPQUFC.js → chunk-QJVODYJ5.js} +2 -2
- package/dist/cli/{chunk-DXVHFVJI.js → chunk-S4ANPQGA.js} +27 -15
- package/dist/cli/{chunk-NKYJF3VT.js → chunk-TB47EHML.js} +2 -2
- package/dist/cli/{daemon-NIEJZDEC.js → daemon-HWAHX4RR.js} +406 -62
- package/dist/cli/{hook-BGIM76EW.js → hook-LY2YTK5U.js} +27 -13
- package/dist/cli/index.js +17 -12
- package/dist/cli/{launch-JS74JGW6.js → launch-UQEFFPBN.js} +4 -4
- package/dist/cli/{send-JX6O7AQR.js → send-EY63XQXI.js} +4 -4
- package/dist/cli/{setup-2GROTY6B.js → setup-3N2EOJXS.js} +7 -5
- package/dist/cli/{status-Q6TQXVLF.js → status-ZQSYXILE.js} +2 -2
- package/dist/cli/{uninstall-JCX7QXU2.js → uninstall-W2OMKU3B.js} +9 -4
- package/dist/cli/{version-X45HSUBB.js → version-5DA7G7HN.js} +1 -1
- package/dist/cli/{who-KAAEASAA.js → who-VGIMGQNS.js} +3 -3
- package/package.json +1 -1
- package/dist/cli/chunk-EHHYRQWY.js +0 -6
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-R5462SQM.js";
|
|
8
8
|
|
|
9
9
|
// src/cli/setup.ts
|
|
10
|
-
import { readFile as readFile2, writeFile, mkdir, rename, realpath, rm, stat, lstat, readlink
|
|
10
|
+
import { readFile as readFile2, writeFile, mkdir, rename, realpath, rm, stat, lstat, readlink } from "fs/promises";
|
|
11
11
|
import { execFile } from "child_process";
|
|
12
12
|
import { homedir, userInfo } from "os";
|
|
13
13
|
import { join, dirname } from "path";
|
|
@@ -237,14 +237,23 @@ async function isDir(path) {
|
|
|
237
237
|
return false;
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
var BIN_MARK = "#!/bin/sh\n# Written by `ledge setup`";
|
|
241
|
+
var shQuote = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
242
|
+
async function writeBin(opts) {
|
|
241
243
|
const st = await lstat(opts.link).catch(() => null);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
const was = st?.isSymbolicLink() ? await readlink(opts.link) : null;
|
|
245
|
+
if (was !== null && !was.endsWith("/dist/cli/index.js")) return null;
|
|
246
|
+
const current = st && was === null && st.isFile() ? await readFile2(opts.link, "utf8").catch(() => "") : "";
|
|
247
|
+
if (st && was === null && !current.startsWith(BIN_MARK)) return null;
|
|
248
|
+
const script = `${BIN_MARK}: the hooks run \`ledge\` wherever node is not on the PATH.
|
|
249
|
+
exec ${shQuote(opts.node)} ${shQuote(opts.target)} "$@"
|
|
250
|
+
`;
|
|
251
|
+
if (current === script) return null;
|
|
252
|
+
await mkdir(dirname(opts.link), { recursive: true });
|
|
253
|
+
const tmp = `${opts.link}.tmp`;
|
|
254
|
+
await writeFile(tmp, script, { mode: 493 });
|
|
255
|
+
await rename(tmp, opts.link);
|
|
256
|
+
return `${opts.link} runs ${opts.target} with ${opts.node}${was !== null ? ` (was a link to ${was})` : ""}`;
|
|
248
257
|
}
|
|
249
258
|
async function runSetup(opts = {}) {
|
|
250
259
|
const out = [];
|
|
@@ -262,13 +271,15 @@ async function runSetup(opts = {}) {
|
|
|
262
271
|
if (!await isDir(cursorDir)) out.push(`Cursor Agent not found (${cursorDir} missing), Cursor Agent hooks skipped`);
|
|
263
272
|
else if (await mergeJsonFile(join(cursorDir, "hooks.json"), mergeCursorHooks, "hooks.json")) out.push(`Cursor Agent hooks added in ${join(cursorDir, "hooks.json")}`);
|
|
264
273
|
else out.push("Cursor Agent hooks already present");
|
|
265
|
-
if ((opts.service ?? true) && !process.argv[1]?.endsWith(".ts")) {
|
|
266
|
-
const line = await relinkBin({ link: join(homedir(), ".local", "bin", "ledge"), target: await realpath(process.argv[1]) });
|
|
267
|
-
if (line) out.push(line);
|
|
268
|
-
}
|
|
269
274
|
if (opts.service ?? true) {
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
const cli = opts.cli ?? process.argv[1] ?? "";
|
|
276
|
+
if (cli.endsWith(".ts")) out.push("systemd service skipped: run setup from the built CLI (pnpm --filter @paradow/ledge build, then ledge setup)");
|
|
277
|
+
else {
|
|
278
|
+
const script = await realpath(cli);
|
|
279
|
+
const line = await writeBin({ link: opts.link ?? join(homedir(), ".local", "bin", "ledge"), node: process.execPath, target: script });
|
|
280
|
+
if (line) out.push(line);
|
|
281
|
+
out.push(...await installService({ script, unitDir: opts.unitDir, run: opts.run }));
|
|
282
|
+
}
|
|
272
283
|
}
|
|
273
284
|
return out;
|
|
274
285
|
}
|
|
@@ -286,7 +297,8 @@ export {
|
|
|
286
297
|
stopDetachedDaemon,
|
|
287
298
|
installService,
|
|
288
299
|
isDir,
|
|
289
|
-
|
|
300
|
+
BIN_MARK,
|
|
301
|
+
writeBin,
|
|
290
302
|
runSetup,
|
|
291
303
|
inDaemonService,
|
|
292
304
|
tmuxServerAtRisk
|