@outerlayer/cli 0.5.0 → 0.6.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/CHANGELOG.md +17 -0
- package/README.md +9 -0
- package/dist/{agent-setup-IFH3FB5X.js → agent-setup-USZ2SAXC.js} +2 -2
- package/dist/build-info.json +1 -1
- package/dist/{check-AXCXDYO2.js → check-CCVPBN7A.js} +26 -14
- package/dist/{chunk-5Y3QQRUH.js → chunk-3DD6AOWC.js} +37 -0
- package/dist/{chunk-WOBNRVQT.js → chunk-3DEVYTNQ.js} +1 -1
- package/dist/{chunk-L24G4PLP.js → chunk-43J3M6KB.js} +486 -21
- package/dist/{chunk-FC7TMRNA.js → chunk-4NLKY4WR.js} +2 -2
- package/dist/{lima-XN65D7GN.js → chunk-77MM5RYD.js} +0 -1
- package/dist/{chunk-D2KWEAN6.js → chunk-7DBI6SNT.js} +1 -1
- package/dist/{chunk-QDQEUVUF.js → chunk-AIW6GLET.js} +1 -1
- package/dist/{chunk-EX6M5JPR.js → chunk-ANK2B36Y.js} +131 -15
- package/dist/{chunk-RMAZ2NWA.js → chunk-BNMCXPG7.js} +14 -2
- package/dist/{chunk-UFFXNXLQ.js → chunk-FA2BOX4O.js} +31 -29
- package/dist/chunk-FBTE2A2X.js +38 -0
- package/dist/{chunk-DVDEBNQJ.js → chunk-GQD22KKN.js} +17 -6
- package/dist/{chunk-BCJNHMZT.js → chunk-HHJDN6AU.js} +18 -3
- package/dist/{chunk-JLDZTG3A.js → chunk-IASWYRVG.js} +1 -1
- package/dist/{install-cmd-7WXOIFDO.js → chunk-JWOQNNN2.js} +0 -1
- package/dist/{chunk-ZLB7GCTY.js → chunk-MIGEDH5P.js} +19 -11
- package/dist/{chunk-OHFDWLJP.js → chunk-MXB5VB4Y.js} +18 -6
- package/dist/chunk-NQXFAGHU.js +211 -0
- package/dist/chunk-OUUINEYB.js +27 -0
- package/dist/{chunk-OR6AEEDO.js → chunk-PMAMOSTP.js} +3 -3
- package/dist/{chunk-RJ467PDQ.js → chunk-RBOMWNOG.js} +1 -1
- package/dist/{chunk-4NMBDRBS.js → chunk-RZSF5B46.js} +289 -130
- package/dist/chunk-T6OIJQRT.js +31 -0
- package/dist/chunk-UGP76IZ5.js +34 -0
- package/dist/{chunk-EGABNHZG.js → chunk-UMFWVGJO.js} +148 -18
- package/dist/{chunk-RWOTHXYE.js → chunk-VMJ3MMBX.js} +206 -71
- package/dist/chunk-YYYRBYWG.js +32 -0
- package/dist/chunk-ZILGTTY6.js +75 -0
- package/dist/{cli-NNWPFP5S.js → cli-7WCNPBYC.js} +147 -69
- package/dist/command-ARFK3OYF.js +162 -0
- package/dist/{config-XVJYZ4IQ.js → config-HL2AIR3K.js} +1 -1
- package/dist/{connect-cmd-OJBFHZWP.js → connect-cmd-PCESZLTR.js} +4 -4
- package/dist/{context-adopt-UMA4O5NY.js → context-adopt-G5JAELE7.js} +2 -2
- package/dist/{context-materialize-G2FUFC72.js → context-materialize-3HLPZAF6.js} +2 -2
- package/dist/{dist-WDV7U7UJ.js → dist-RDLP4GGJ.js} +1 -1
- package/dist/{doctor-J3GIMR7K.js → doctor-VOMYOHQU.js} +47 -13
- package/dist/{emit-artifact-cmd-FDWYKURA.js → emit-artifact-cmd-TBF46VXZ.js} +6 -7
- package/dist/{emit-criteria-cmd-OCXHLK34.js → emit-criteria-cmd-3427XKFW.js} +3 -3
- package/dist/{emit-finding-cmd-POW7PKIA.js → emit-finding-cmd-GSI75K36.js} +3 -3
- package/dist/{emit-result-cmd-ID35SH53.js → emit-result-cmd-3PRQKB55.js} +6 -7
- package/dist/{hook-fast-EYENPK6F.js → hook-fast-NJBBZQ5Q.js} +1 -1
- package/dist/index.js +3 -2
- package/dist/{init-CZX7ZDWF.js → init-OHYFIKZD.js} +27 -56
- package/dist/{init-3ZQLFPNC.js → init-WVR4BZQ4.js} +8 -8
- package/dist/{init-cmd-W5NOLQPX.js → init-cmd-HMFNIFPI.js} +7 -7
- package/dist/inspect-XAUSB7L3.js +63 -0
- package/dist/install-DSUZE2TJ.js +13 -0
- package/dist/install-cmd-453C7IZT.js +8 -0
- package/dist/lima-7NPCNGWT.js +6 -0
- package/dist/{loop-VGM772I7.js → loop-UAJB34KA.js} +26 -11
- package/dist/{machine-5WEJA36F.js → machine-2JOWGRSZ.js} +7 -7
- package/dist/record-C43U4PKS.js +7 -0
- package/dist/session-sender-ED26V45B.js +28 -0
- package/dist/{status-KBDVUYQ3.js → status-6WNXX2O7.js} +42 -10
- package/dist/{sync-cmd-SWQ5KLPL.js → sync-cmd-YONVGUYS.js} +6 -7
- package/dist/{watch-3YW6Z3DQ.js → watch-HHKAF26L.js} +6 -7
- package/dist/{work-claim-cmd-BQPPURBW.js → work-claim-cmd-LXBZTMJA.js} +6 -6
- package/dist/{work-cmd-NUR4CAG6.js → work-cmd-OVNF44FY.js} +3 -3
- package/dist/{work-comment-cmd-6TTTYGHM.js → work-comment-cmd-6DGQNTAH.js} +3 -3
- package/dist/{work-launch-YI4CJDAP.js → work-launch-R5HTAP6X.js} +1 -1
- package/dist/{work-open-pr-cmd-KZ7QQFLD.js → work-open-pr-cmd-FCZHFHZS.js} +4 -4
- package/dist/{work-pr-cmd-QNUBE6IQ.js → work-pr-cmd-QJJVHZDC.js} +2 -2
- package/package.json +2 -1
- package/dist/chunk-ZOC7JSYC.js +0 -83
- package/dist/{chunk-XDDW4FRS.js → chunk-OIRNH6UO.js} +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { statfsSync } from 'fs';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
|
|
6
|
+
createRequire(import.meta.url);
|
|
7
|
+
function freeBytes(path, statfs = statfsSync) {
|
|
8
|
+
let at = path;
|
|
9
|
+
for (; ; ) {
|
|
10
|
+
try {
|
|
11
|
+
const stats = statfs(at);
|
|
12
|
+
return Number(stats.bavail) * Number(stats.bsize);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
if (err.code !== "ENOENT") return void 0;
|
|
15
|
+
const parent = dirname(at);
|
|
16
|
+
if (parent === at) return void 0;
|
|
17
|
+
at = parent;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
var UNITS = ["B", "KB", "MB", "GB", "TB"];
|
|
22
|
+
function formatBytes(bytes) {
|
|
23
|
+
let value = Math.max(0, bytes);
|
|
24
|
+
let unit = 0;
|
|
25
|
+
while (value >= 1024 && unit < UNITS.length - 1) {
|
|
26
|
+
value /= 1024;
|
|
27
|
+
unit++;
|
|
28
|
+
}
|
|
29
|
+
return unit === 0 ? `${Math.round(value)} B` : `${value.toFixed(1)} ${UNITS[unit]}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { formatBytes, freeBytes };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { LiveUploader } from './chunk-UMFWVGJO.js';
|
|
4
|
+
import { CaptureDaemon } from './chunk-ANK2B36Y.js';
|
|
5
|
+
import { parseWorkItemEnv } from './chunk-GQD22KKN.js';
|
|
6
|
+
import { spoolDir } from './chunk-FA2BOX4O.js';
|
|
7
|
+
import { homeFromEnv } from './chunk-VNVZDWO3.js';
|
|
8
|
+
import { mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
11
|
+
createRequire(import.meta.url);
|
|
12
|
+
var SENDER_STOP_WAIT_MS = 25e3;
|
|
13
|
+
var RESCAN_MS = 3e4;
|
|
14
|
+
function senderPidfile(home, item) {
|
|
15
|
+
return join(spoolDir(home), `session-sender-${item}.pid`);
|
|
16
|
+
}
|
|
17
|
+
async function startSessionSender(opts = {}) {
|
|
18
|
+
const env = opts.env ?? process.env;
|
|
19
|
+
const stderr = opts.stderr ?? ((s) => void process.stderr.write(s));
|
|
20
|
+
const parsed = parseWorkItemEnv(env.OUTERLAYER_WORK);
|
|
21
|
+
const jobDir = env.OUTERLAYER_JOB_DIR;
|
|
22
|
+
if ("reason" in parsed || !jobDir) {
|
|
23
|
+
throw new Error("a session sender runs inside a runner job: OUTERLAYER_WORK must name the item and OUTERLAYER_JOB_DIR the job");
|
|
24
|
+
}
|
|
25
|
+
const home = opts.home ?? homeFromEnv(env);
|
|
26
|
+
const uploader = new LiveUploader({
|
|
27
|
+
home,
|
|
28
|
+
env,
|
|
29
|
+
fetchImpl: opts.fetchImpl,
|
|
30
|
+
sleepImpl: opts.sleepImpl,
|
|
31
|
+
debounceMs: opts.debounceMs,
|
|
32
|
+
stderr,
|
|
33
|
+
build: { item: parsed.number, jobDir },
|
|
34
|
+
onUnauthorized: opts.onFatal
|
|
35
|
+
});
|
|
36
|
+
const onLog = (event) => {
|
|
37
|
+
if (event.type === "changed" && event.file !== void 0) uploader.notify(event.file);
|
|
38
|
+
if (event.type === "error") stderr(`error ${event.file}: ${event.detail}
|
|
39
|
+
`);
|
|
40
|
+
};
|
|
41
|
+
const daemon = new CaptureDaemon({ ...opts.root === void 0 ? {} : { root: opts.root }, watchOnly: true, rescanMs: RESCAN_MS, onLog });
|
|
42
|
+
const pidfile = senderPidfile(home, parsed.number);
|
|
43
|
+
try {
|
|
44
|
+
mkdirSync(spoolDir(home), { recursive: true });
|
|
45
|
+
writeFileSync(pidfile, String(process.pid));
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
await daemon.start();
|
|
49
|
+
let stopped;
|
|
50
|
+
return {
|
|
51
|
+
stop: () => stopped ??= (async () => {
|
|
52
|
+
daemon.rescanNow();
|
|
53
|
+
await uploader.stop(opts.stopWaitMs ?? SENDER_STOP_WAIT_MS);
|
|
54
|
+
await daemon.stop();
|
|
55
|
+
rmSync(pidfile, { force: true });
|
|
56
|
+
})()
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function runSessionSender() {
|
|
60
|
+
let sender;
|
|
61
|
+
const exit = async (code) => {
|
|
62
|
+
await sender?.stop().catch(() => void 0);
|
|
63
|
+
process.exit(code);
|
|
64
|
+
};
|
|
65
|
+
sender = await startSessionSender({ onFatal: () => void exit(1) });
|
|
66
|
+
process.on("SIGTERM", () => void exit(0));
|
|
67
|
+
process.on("SIGINT", () => void exit(0));
|
|
68
|
+
process.on("unhandledRejection", (reason) => {
|
|
69
|
+
process.stderr.write(`session-sender: unhandled error, continuing: ${String(reason)}
|
|
70
|
+
`);
|
|
71
|
+
});
|
|
72
|
+
await new Promise(() => void 0);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { runSessionSender, senderPidfile, startSessionSender };
|