token-goat 2.6.35 → 2.8.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 +35 -7
- package/SECURITY.md +47 -16
- package/dist/{token-goat-chunk-I2KCEGIP.mjs → token-goat-chunk-2F6TFBZE.mjs} +1355 -408
- package/dist/token-goat-chunk-324QOJYZ.mjs +91 -0
- package/dist/{token-goat-chunk-K7W3P2TJ.mjs → token-goat-chunk-44Y77VHR.mjs} +425 -39
- package/dist/{token-goat-chunk-UIZVX3HN.mjs → token-goat-chunk-4KZILRZN.mjs} +2 -2
- package/dist/token-goat-chunk-5CVKO3DA.mjs +185 -0
- package/dist/token-goat-chunk-A62K4XW2.mjs +23 -0
- package/dist/{token-goat-chunk-SIHYQCTM.mjs → token-goat-chunk-AO6MFFTW.mjs} +331 -13
- package/dist/{token-goat-chunk-DRAIYVUI.mjs → token-goat-chunk-FBGBTICM.mjs} +4 -4
- package/dist/{token-goat-chunk-YF67EWRH.mjs → token-goat-chunk-J35AKWEQ.mjs} +5 -5
- package/dist/{token-goat-hook-chunk-4POU6OHK.mjs → token-goat-chunk-LVCBDJVE.mjs} +318 -51
- package/dist/token-goat-chunk-R4SR7MQY.mjs +486 -0
- package/dist/{token-goat-chunk-D5IZEGN2.mjs → token-goat-chunk-SRAR6DOK.mjs} +144 -147
- package/dist/{token-goat-hook-chunk-NIPXIAPA.mjs → token-goat-chunk-TUPJRK7R.mjs} +1 -1
- package/dist/{token-goat-chunk-HW4VUKJ5.mjs → token-goat-chunk-VXSYZGBA.mjs} +589 -141
- package/dist/{token-goat-chunk-DG53MVNJ.mjs → token-goat-chunk-WN5T5EW5.mjs} +212 -212
- package/dist/token-goat-hook.mjs +7 -7
- package/dist/token-goat.core.mjs +5 -5
- package/package.json +18 -15
- package/scripts/install-git-hooks.mjs +55 -0
- package/dist/token-goat-chunk-DQIT5JIF.mjs +0 -13659
- package/dist/token-goat-chunk-Y2NH6DGZ.mjs +0 -10048
- package/dist/token-goat-hook-chunk-2O7P4Z6Q.mjs +0 -6419
- package/dist/token-goat-hook-chunk-3AAH72SO.mjs +0 -15970
- package/dist/token-goat-hook-chunk-3QYSN4QV.mjs +0 -14764
- package/dist/token-goat-hook-chunk-BUOCULAM.mjs +0 -29
- package/dist/token-goat-hook-chunk-CRBMPT74.mjs +0 -900
- package/dist/token-goat-hook-chunk-D6UJEFHX.mjs +0 -153
- package/dist/token-goat-hook-chunk-J4HKWUWZ.mjs +0 -23
- package/dist/token-goat-hook-chunk-NXVT4F3S.mjs +0 -10406
- package/dist/token-goat-hook-chunk-RFRLWOQH.mjs +0 -11
- package/dist/token-goat-hook-chunk-VU6VGZBM.mjs +0 -706
- package/dist/token-goat-hook-chunk-XM4W3WCO.mjs +0 -18144
- package/dist/token-goat-hook-chunk-XUMIVYEN.mjs +0 -109
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
clearModuleCaches
|
|
5
|
-
} from "./token-goat-hook-chunk-BUOCULAM.mjs";
|
|
6
|
-
import "./token-goat-hook-chunk-RFRLWOQH.mjs";
|
|
7
|
-
|
|
8
|
-
// src/batch_serve.ts
|
|
9
|
-
function swapEnv(next) {
|
|
10
|
-
const before = { ...process.env };
|
|
11
|
-
for (const key of Object.keys(process.env)) if (!(key in next)) delete process.env[key];
|
|
12
|
-
for (const [key, value] of Object.entries(next)) process.env[key] = value;
|
|
13
|
-
return () => {
|
|
14
|
-
for (const key of Object.keys(process.env)) if (!(key in before)) delete process.env[key];
|
|
15
|
-
for (const [key, value] of Object.entries(before)) process.env[key] = value;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function captureOutput() {
|
|
19
|
-
let out = "";
|
|
20
|
-
let errText = "";
|
|
21
|
-
const realOut = process.stdout.write.bind(process.stdout);
|
|
22
|
-
const realErr = process.stderr.write.bind(process.stderr);
|
|
23
|
-
const sink = (append) => ((chunk, enc, cb) => {
|
|
24
|
-
append(typeof chunk === "string" ? chunk : String(chunk));
|
|
25
|
-
const done = typeof enc === "function" ? enc : cb;
|
|
26
|
-
if (typeof done === "function") done();
|
|
27
|
-
return true;
|
|
28
|
-
});
|
|
29
|
-
process.stdout.write = sink((s) => {
|
|
30
|
-
out += s;
|
|
31
|
-
});
|
|
32
|
-
process.stderr.write = sink((s) => {
|
|
33
|
-
errText += s;
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
stdout: () => out,
|
|
37
|
-
stderr: () => errText,
|
|
38
|
-
restore: () => {
|
|
39
|
-
process.stdout.write = realOut;
|
|
40
|
-
process.stderr.write = realErr;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
async function serveOne(req, runFn) {
|
|
45
|
-
const cwdBefore = process.cwd();
|
|
46
|
-
const restoreEnv = swapEnv(req.env ?? { ...process.env });
|
|
47
|
-
const cap = captureOutput();
|
|
48
|
-
let status;
|
|
49
|
-
try {
|
|
50
|
-
if (req.cwd !== void 0) process.chdir(req.cwd);
|
|
51
|
-
process.exitCode = void 0;
|
|
52
|
-
await runFn([process.execPath, "token-goat", ...req.argv]);
|
|
53
|
-
status = typeof process.exitCode === "number" ? process.exitCode : 0;
|
|
54
|
-
} catch (e) {
|
|
55
|
-
cap.restore();
|
|
56
|
-
process.stderr.write("");
|
|
57
|
-
status = 1;
|
|
58
|
-
const captured = { out: cap.stdout(), err: cap.stderr() + String(e instanceof Error ? e.stack ?? e.message : e) + "\n" };
|
|
59
|
-
restoreEnv();
|
|
60
|
-
process.exitCode = void 0;
|
|
61
|
-
try {
|
|
62
|
-
process.chdir(cwdBefore);
|
|
63
|
-
} catch {
|
|
64
|
-
}
|
|
65
|
-
clearModuleCaches();
|
|
66
|
-
return { id: req.id, status, stdout: captured.out, stderr: captured.err };
|
|
67
|
-
}
|
|
68
|
-
cap.restore();
|
|
69
|
-
const stdout = cap.stdout();
|
|
70
|
-
const stderr = cap.stderr();
|
|
71
|
-
restoreEnv();
|
|
72
|
-
process.exitCode = void 0;
|
|
73
|
-
try {
|
|
74
|
-
process.chdir(cwdBefore);
|
|
75
|
-
} catch {
|
|
76
|
-
}
|
|
77
|
-
clearModuleCaches();
|
|
78
|
-
return { id: req.id, status, stdout, stderr };
|
|
79
|
-
}
|
|
80
|
-
function serveBatch(token, runFn) {
|
|
81
|
-
let buffered = "";
|
|
82
|
-
let chain = Promise.resolve();
|
|
83
|
-
process.stdin.setEncoding("utf8");
|
|
84
|
-
process.stdin.on("data", (chunk) => {
|
|
85
|
-
buffered += chunk;
|
|
86
|
-
for (; ; ) {
|
|
87
|
-
const nl = buffered.indexOf("\n");
|
|
88
|
-
if (nl === -1) break;
|
|
89
|
-
const line = buffered.slice(0, nl);
|
|
90
|
-
buffered = buffered.slice(nl + 1);
|
|
91
|
-
if (line.trim() === "") continue;
|
|
92
|
-
const req = JSON.parse(line);
|
|
93
|
-
chain = chain.then(async () => {
|
|
94
|
-
const res = await serveOne(req, runFn);
|
|
95
|
-
process.stdout.write(`${token} ${JSON.stringify(res)}
|
|
96
|
-
`);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
process.stdin.on("end", () => {
|
|
101
|
-
void chain.then(() => {
|
|
102
|
-
process.exitCode = 0;
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
export {
|
|
107
|
-
serveBatch,
|
|
108
|
-
serveOne
|
|
109
|
-
};
|