Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.

This commit is contained in:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

21
node_modules/tinyexec/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Tinylibs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

256
node_modules/tinyexec/README.md generated vendored Normal file
View File

@@ -0,0 +1,256 @@
# tinyexec 📟
> A minimal package for executing commands
This package was created to provide a minimal way of interacting with child
processes without having to manually deal with streams, piping, etc.
## Installing
```sh
$ npm i -S tinyexec
```
## Usage
A process can be spawned and awaited like so:
```ts
import {x} from 'tinyexec';
const result = await x('ls', ['-l']);
// result.stdout - the stdout as a string
// result.stderr - the stderr as a string
// result.exitCode - the process exit code as a number
```
You may also iterate over the lines of output via an async loop:
```ts
import {x} from 'tinyexec';
const proc = x('ls', ['-l']);
for await (const line of proc) {
// line will be from stderr/stdout in the order you'd see it in a term
}
```
### Options
Options can be passed to have finer control over spawning of the process:
```ts
await x('ls', [], {
timeout: 1000
});
```
The options object can have the following properties:
- `signal` - an `AbortSignal` to allow aborting of the execution
- `timeout` - time in milliseconds at which the process will be forceably killed
- `persist` - if `true`, the process will continue after the host exits
- `stdin` - another `Result` can be used as the input to this process
- `nodeOptions` - any valid options to node's underlying `spawn` function
- `throwOnError` - if true, non-zero exit codes will throw an error
### Piping to another process
You can pipe a process to another via the `pipe` method:
```ts
const proc1 = x('ls', ['-l']);
const proc2 = proc1.pipe('grep', ['.js']);
const result = await proc2;
console.log(result.stdout);
```
`pipe` takes the same options as a regular execution. For example, you can
pass a timeout to the pipe call:
```ts
proc1.pipe('grep', ['.js'], {
timeout: 2000
});
```
### Killing a process
You can kill the process via the `kill` method:
```ts
const proc = x('ls');
proc.kill();
// or with a signal
proc.kill('SIGHUP');
```
### Node modules/binaries
By default, node's available binaries from `node_modules` will be accessible
in your command.
For example, in a repo which has `eslint` installed:
```ts
await x('eslint', ['.']);
```
In this example, `eslint` will come from the locally installed `node_modules`.
### Using an abort signal
An abort signal can be passed to a process in order to abort it at a later
time. This will result in the process being killed and `aborted` being set
to `true`.
```ts
const aborter = new AbortController();
const proc = x('node', ['./foo.mjs'], {
signal: aborter.signal
});
// elsewhere...
aborter.abort();
await proc;
proc.aborted; // true
proc.killed; // true
```
### Using with command strings
If you need to continue supporting commands as strings (e.g. "command arg0 arg1"),
you can use [args-tokenizer](https://github.com/TrySound/args-tokenizer),
a lightweight library for parsing shell command strings into an array.
```ts
import {x} from 'tinyexec';
import {tokenizeArgs} from 'args-tokenizer';
const commandString = 'echo "Hello, World!"';
const [command, ...args] = tokenizeArgs(commandString);
const result = await x(command, args);
result.stdout; // Hello, World!
```
## API
Calling `x(command[, args])` returns an awaitable `Result` which has the
following API methods and properties available:
### `pipe(command[, args[, options]])`
Pipes the current command to another. For example:
```ts
x('ls', ['-l'])
.pipe('grep', ['js']);
```
The parameters are as follows:
- `command` - the command to execute (_without any arguments_)
- `args` - an array of arguments
- `options` - options object
### `process`
The underlying node `ChildProcess`. For example:
```ts
const proc = x('ls');
proc.process; // ChildProcess;
```
### `kill([signal])`
Kills the current process with the specified signal. By default, this will
use the `SIGTERM` signal.
For example:
```ts
const proc = x('ls');
proc.kill();
```
### `pid`
The current process ID. For example:
```ts
const proc = x('ls');
proc.pid; // number
```
### `aborted`
Whether the process has been aborted or not (via the `signal` originally
passed in the options object).
For example:
```ts
const proc = x('ls');
proc.aborted; // bool
```
### `killed`
Whether the process has been killed or not (e.g. via `kill()` or an abort
signal).
For example:
```ts
const proc = x('ls');
proc.killed; // bool
```
### `exitCode`
The exit code received when the process completed execution.
For example:
```ts
const proc = x('ls');
proc.exitCode; // number (e.g. 1)
```
## Comparison with other libraries
`tinyexec` aims to provide a lightweight layer on top of Node's own
`child_process` API.
Some clear benefits compared to other libraries are that `tinyexec` will be much lighter, have a much
smaller footprint and will have a less abstract interface (less "magic"). It
will also have equal security and cross-platform support to popular
alternatives.
There are various features other libraries include which we are unlikely
to ever implement, as they would prevent us from providing a lightweight layer.
For example, if you'd like write scripts rather than individual commands, and
prefer to use templating, we'd definitely recommend
[zx](https://github.com/google/zx). zx is a much higher level library which
does some of the same work `tinyexec` does but behind a template string
interface.
Similarly, libraries like `execa` will provide helpers for various things
like passing files as input to processes. We opt not to support features like
this since many of them are easy to do yourself (using Node's own APIs).

575
node_modules/tinyexec/dist/main.cjs generated vendored Normal file
View File

@@ -0,0 +1,575 @@
"use strict";
var It = Object.create;
var v = Object.defineProperty;
var Lt = Object.getOwnPropertyDescriptor;
var jt = Object.getOwnPropertyNames;
var Ft = Object.getPrototypeOf, zt = Object.prototype.hasOwnProperty;
var l = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports), Ht = (t, e) => {
for (var n in e)
v(t, n, { get: e[n], enumerable: !0 });
}, N = (t, e, n, r) => {
if (e && typeof e == "object" || typeof e == "function")
for (let s of jt(e))
!zt.call(t, s) && s !== n && v(t, s, { get: () => e[s], enumerable: !(r = Lt(e, s)) || r.enumerable });
return t;
};
var q = (t, e, n) => (n = t != null ? It(Ft(t)) : {}, N(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
e || !t || !t.__esModule ? v(n, "default", { value: t, enumerable: !0 }) : n,
t
)), Wt = (t) => N(v({}, "__esModule", { value: !0 }), t);
// node_modules/isexe/windows.js
var K = l((Pe, D) => {
"use strict";
D.exports = W;
W.sync = Xt;
var z = require("fs");
function Bt(t, e) {
var n = e.pathExt !== void 0 ? e.pathExt : process.env.PATHEXT;
if (!n || (n = n.split(";"), n.indexOf("") !== -1))
return !0;
for (var r = 0; r < n.length; r++) {
var s = n[r].toLowerCase();
if (s && t.substr(-s.length).toLowerCase() === s)
return !0;
}
return !1;
}
function H(t, e, n) {
return !t.isSymbolicLink() && !t.isFile() ? !1 : Bt(e, n);
}
function W(t, e, n) {
z.stat(t, function(r, s) {
n(r, r ? !1 : H(s, t, e));
});
}
function Xt(t, e) {
return H(z.statSync(t), t, e);
}
});
// node_modules/isexe/mode.js
var U = l((Oe, G) => {
"use strict";
G.exports = B;
B.sync = Gt;
var M = require("fs");
function B(t, e, n) {
M.stat(t, function(r, s) {
n(r, r ? !1 : X(s, e));
});
}
function Gt(t, e) {
return X(M.statSync(t), e);
}
function X(t, e) {
return t.isFile() && Ut(t, e);
}
function Ut(t, e) {
var n = t.mode, r = t.uid, s = t.gid, o = e.uid !== void 0 ? e.uid : process.getuid && process.getuid(), i = e.gid !== void 0 ? e.gid : process.getgid && process.getgid(), a = parseInt("100", 8), c = parseInt("010", 8), u = parseInt("001", 8), f = a | c, p = n & u || n & c && s === i || n & a && r === o || n & f && o === 0;
return p;
}
});
// node_modules/isexe/index.js
var V = l((ke, Y) => {
"use strict";
var Se = require("fs"), b;
process.platform === "win32" || global.TESTING_WINDOWS ? b = K() : b = U();
Y.exports = C;
C.sync = Yt;
function C(t, e, n) {
if (typeof e == "function" && (n = e, e = {}), !n) {
if (typeof Promise != "function")
throw new TypeError("callback not provided");
return new Promise(function(r, s) {
C(t, e || {}, function(o, i) {
o ? s(o) : r(i);
});
});
}
b(t, e || {}, function(r, s) {
r && (r.code === "EACCES" || e && e.ignoreErrors) && (r = null, s = !1), n(r, s);
});
}
function Yt(t, e) {
try {
return b.sync(t, e || {});
} catch (n) {
if (e && e.ignoreErrors || n.code === "EACCES")
return !1;
throw n;
}
}
});
// node_modules/which/which.js
var rt = l((Te, nt) => {
"use strict";
var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", J = require("path"), Vt = g ? ";" : ":", Q = V(), Z = (t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), tt = (t, e) => {
let n = e.colon || Vt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [
// windows always checks the cwd first
...g ? [process.cwd()] : [],
...(e.path || process.env.PATH || /* istanbul ignore next: very unusual */
"").split(n)
], s = g ? e.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", o = g ? s.split(n) : [""];
return g && t.indexOf(".") !== -1 && o[0] !== "" && o.unshift(""), {
pathEnv: r,
pathExt: o,
pathExtExe: s
};
}, et = (t, e, n) => {
typeof e == "function" && (n = e, e = {}), e || (e = {});
let { pathEnv: r, pathExt: s, pathExtExe: o } = tt(t, e), i = [], a = (u) => new Promise((f, p) => {
if (u === r.length)
return e.all && i.length ? f(i) : p(Z(t));
let d = r[u], x = /^".*"$/.test(d) ? d.slice(1, -1) : d, m = J.join(x, t), _ = !x && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + m : m;
f(c(_, u, 0));
}), c = (u, f, p) => new Promise((d, x) => {
if (p === s.length)
return d(a(f + 1));
let m = s[p];
Q(u + m, { pathExt: o }, (_, qt) => {
if (!_ && qt)
if (e.all)
i.push(u + m);
else
return d(u + m);
return d(c(u, f, p + 1));
});
});
return n ? a(0).then((u) => n(null, u), n) : a(0);
}, Jt = (t, e) => {
e = e || {};
let { pathEnv: n, pathExt: r, pathExtExe: s } = tt(t, e), o = [];
for (let i = 0; i < n.length; i++) {
let a = n[i], c = /^".*"$/.test(a) ? a.slice(1, -1) : a, u = J.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + u : u;
for (let p = 0; p < r.length; p++) {
let d = f + r[p];
try {
if (Q.sync(d, { pathExt: s }))
if (e.all)
o.push(d);
else
return d;
} catch {
}
}
}
if (e.all && o.length)
return o;
if (e.nothrow)
return null;
throw Z(t);
};
nt.exports = et;
et.sync = Jt;
});
// node_modules/path-key/index.js
var ot = l((Ae, P) => {
"use strict";
var st = (t = {}) => {
let e = t.env || process.env;
return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(e).reverse().find((r) => r.toUpperCase() === "PATH") || "Path";
};
P.exports = st;
P.exports.default = st;
});
// node_modules/cross-spawn/lib/util/resolveCommand.js
var at = l((Re, ut) => {
"use strict";
var it = require("path"), Qt = rt(), Zt = ot();
function ct(t, e) {
let n = t.options.env || process.env, r = process.cwd(), s = t.options.cwd != null, o = s && process.chdir !== void 0 && !process.chdir.disabled;
if (o)
try {
process.chdir(t.options.cwd);
} catch {
}
let i;
try {
i = Qt.sync(t.command, {
path: n[Zt({ env: n })],
pathExt: e ? it.delimiter : void 0
});
} catch {
} finally {
o && process.chdir(r);
}
return i && (i = it.resolve(s ? t.options.cwd : "", i)), i;
}
function te(t) {
return ct(t) || ct(t, !0);
}
ut.exports = te;
});
// node_modules/cross-spawn/lib/util/escape.js
var lt = l(($e, S) => {
"use strict";
var O = /([()\][%!^"`<>&|;, *?])/g;
function ee(t) {
return t = t.replace(O, "^$1"), t;
}
function ne(t, e) {
return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(O, "^$1"), e && (t = t.replace(O, "^$1")), t;
}
S.exports.command = ee;
S.exports.argument = ne;
});
// node_modules/shebang-regex/index.js
var dt = l((Ne, pt) => {
"use strict";
pt.exports = /^#!(.*)/;
});
// node_modules/shebang-command/index.js
var ht = l((qe, ft) => {
"use strict";
var re = dt();
ft.exports = (t = "") => {
let e = t.match(re);
if (!e)
return null;
let [n, r] = e[0].replace(/#! ?/, "").split(" "), s = n.split("/").pop();
return s === "env" ? r : r ? `${s} ${r}` : s;
};
});
// node_modules/cross-spawn/lib/util/readShebang.js
var gt = l((Ie, mt) => {
"use strict";
var k = require("fs"), se = ht();
function oe(t) {
let n = Buffer.alloc(150), r;
try {
r = k.openSync(t, "r"), k.readSync(r, n, 0, 150, 0), k.closeSync(r);
} catch {
}
return se(n.toString());
}
mt.exports = oe;
});
// node_modules/cross-spawn/lib/parse.js
var vt = l((Le, xt) => {
"use strict";
var ie = require("path"), Et = at(), wt = lt(), ce = gt(), ue = process.platform === "win32", ae = /\.(?:com|exe)$/i, le = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
function pe(t) {
t.file = Et(t);
let e = t.file && ce(t.file);
return e ? (t.args.unshift(t.file), t.command = e, Et(t)) : t.file;
}
function de(t) {
if (!ue)
return t;
let e = pe(t), n = !ae.test(e);
if (t.options.forceShell || n) {
let r = le.test(e);
t.command = ie.normalize(t.command), t.command = wt.command(t.command), t.args = t.args.map((o) => wt.argument(o, r));
let s = [t.command].concat(t.args).join(" ");
t.args = ["/d", "/s", "/c", `"${s}"`], t.command = process.env.comspec || "cmd.exe", t.options.windowsVerbatimArguments = !0;
}
return t;
}
function fe(t, e, n) {
e && !Array.isArray(e) && (n = e, e = null), e = e ? e.slice(0) : [], n = Object.assign({}, n);
let r = {
command: t,
args: e,
options: n,
file: void 0,
original: {
command: t,
args: e
}
};
return n.shell ? r : de(r);
}
xt.exports = fe;
});
// node_modules/cross-spawn/lib/enoent.js
var _t = l((je, yt) => {
"use strict";
var T = process.platform === "win32";
function A(t, e) {
return Object.assign(new Error(`${e} ${t.command} ENOENT`), {
code: "ENOENT",
errno: "ENOENT",
syscall: `${e} ${t.command}`,
path: t.command,
spawnargs: t.args
});
}
function he(t, e) {
if (!T)
return;
let n = t.emit;
t.emit = function(r, s) {
if (r === "exit") {
let o = bt(s, e, "spawn");
if (o)
return n.call(t, "error", o);
}
return n.apply(t, arguments);
};
}
function bt(t, e) {
return T && t === 1 && !e.file ? A(e.original, "spawn") : null;
}
function me(t, e) {
return T && t === 1 && !e.file ? A(e.original, "spawnSync") : null;
}
yt.exports = {
hookChildProcess: he,
verifyENOENT: bt,
verifyENOENTSync: me,
notFoundError: A
};
});
// node_modules/cross-spawn/index.js
var Ot = l((Fe, E) => {
"use strict";
var Ct = require("child_process"), R = vt(), $ = _t();
function Pt(t, e, n) {
let r = R(t, e, n), s = Ct.spawn(r.command, r.args, r.options);
return $.hookChildProcess(s, r), s;
}
function ge(t, e, n) {
let r = R(t, e, n), s = Ct.spawnSync(r.command, r.args, r.options);
return s.error = s.error || $.verifyENOENTSync(s.status, r), s;
}
E.exports = Pt;
E.exports.spawn = Pt;
E.exports.sync = ge;
E.exports._parse = R;
E.exports._enoent = $;
});
// src/main.ts
var be = {};
Ht(be, {
ExecProcess: () => y,
NonZeroExitError: () => w,
exec: () => Nt,
x: () => $t
});
module.exports = Wt(be);
var St = require("child_process"), kt = require("path"), Tt = require("process");
// src/env.ts
var h = require("path"), Dt = /^path$/i, I = { key: "PATH", value: "" };
function Kt(t) {
for (let e in t) {
if (!Object.prototype.hasOwnProperty.call(t, e) || !Dt.test(e))
continue;
let n = t[e];
return n ? { key: e, value: n } : I;
}
return I;
}
function Mt(t, e) {
let n = e.value.split(h.delimiter), r = t, s;
do
n.push((0, h.resolve)(r, "node_modules", ".bin")), s = r, r = (0, h.dirname)(r);
while (r !== s);
return { key: e.key, value: n.join(h.delimiter) };
}
function L(t, e) {
let n = {
...process.env,
...e
}, r = Mt(t, Kt(n));
return n[r.key] = r.value, n;
}
// src/stream.ts
var j = require("stream");
var F = (t) => {
let e = t.length, n = new j.PassThrough(), r = () => {
--e === 0 && n.emit("end");
};
for (let s of t)
s.pipe(n, { end: !1 }), s.on("end", r);
return n;
};
// src/main.ts
var At = q(require("readline"), 1), Rt = q(Ot(), 1);
// src/non-zero-exit-error.ts
var w = class extends Error {
result;
output;
get exitCode() {
if (this.result.exitCode !== null)
return this.result.exitCode;
}
constructor(e, n) {
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = n;
}
};
// src/main.ts
var Ee = {
timeout: void 0,
persist: !1
}, we = {
windowsHide: !0
};
function xe(t, e) {
return {
command: (0, kt.normalize)(t),
args: e ?? []
};
}
function ve(t) {
let e = new AbortController();
for (let n of t) {
if (n.aborted)
return e.abort(), n;
let r = () => {
e.abort(n.reason);
};
n.addEventListener("abort", r, {
signal: e.signal
});
}
return e.signal;
}
var y = class {
_process;
_aborted = !1;
_options;
_command;
_args;
_resolveClose;
_processClosed;
_thrownError;
get process() {
return this._process;
}
get pid() {
return this._process?.pid;
}
get exitCode() {
if (this._process && this._process.exitCode !== null)
return this._process.exitCode;
}
constructor(e, n, r) {
this._options = {
...Ee,
...r
}, this._command = e, this._args = n ?? [], this._processClosed = new Promise((s) => {
this._resolveClose = s;
});
}
kill(e) {
return this._process?.kill(e) === !0;
}
get aborted() {
return this._aborted;
}
get killed() {
return this._process?.killed === !0;
}
pipe(e, n, r) {
return Nt(e, n, {
...r,
stdin: this
});
}
async *[Symbol.asyncIterator]() {
let e = this._process;
if (!e)
return;
let n = [];
this._streamErr && n.push(this._streamErr), this._streamOut && n.push(this._streamOut);
let r = F(n), s = At.default.createInterface({
input: r
});
for await (let o of s)
yield o.toString();
if (await this._processClosed, e.removeAllListeners(), this._thrownError)
throw this._thrownError;
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
throw new w(this);
}
async _waitForOutput() {
let e = this._process;
if (!e)
throw new Error("No process was started");
let n = "", r = "";
if (this._streamOut)
for await (let o of this._streamOut)
r += o.toString();
if (this._streamErr)
for await (let o of this._streamErr)
n += o.toString();
if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError)
throw this._thrownError;
let s = {
stderr: n,
stdout: r,
exitCode: this.exitCode
};
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
throw new w(this, s);
return s;
}
then(e, n) {
return this._waitForOutput().then(e, n);
}
_streamOut;
_streamErr;
spawn() {
let e = (0, Tt.cwd)(), n = this._options, r = {
...we,
...n.nodeOptions
}, s = [];
this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === !0 && (r.detached = !0), s.length > 0 && (r.signal = ve(s)), r.env = L(e, r.env);
let { command: o, args: i } = xe(this._command, this._args), a = (0, Rt._parse)(o, i, r), c = (0, St.spawn)(
a.command,
a.args,
a.options
);
if (c.stderr && (this._streamErr = c.stderr), c.stdout && (this._streamOut = c.stdout), this._process = c, c.once("error", this._onError), c.once("close", this._onClose), n.stdin !== void 0 && c.stdin && n.stdin.process) {
let { stdout: u } = n.stdin.process;
u && u.pipe(c.stdin);
}
}
_resetState() {
this._aborted = !1, this._processClosed = new Promise((e) => {
this._resolveClose = e;
}), this._thrownError = void 0;
}
_onError = (e) => {
if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
this._aborted = !0;
return;
}
this._thrownError = e;
};
_onClose = () => {
this._resolveClose && this._resolveClose();
};
}, $t = (t, e, n) => {
let r = new y(t, e, n);
return r.spawn(), r;
}, Nt = $t;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ExecProcess,
NonZeroExitError,
exec,
x
});

70
node_modules/tinyexec/dist/main.d.cts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import { ChildProcess, SpawnOptions } from 'node:child_process';
import { Readable } from 'node:stream';
declare class NonZeroExitError extends Error {
readonly result: Result;
readonly output?: Output;
get exitCode(): number | undefined;
constructor(result: Result, output?: Output);
}
interface Output {
stderr: string;
stdout: string;
exitCode: number | undefined;
}
interface PipeOptions extends Options {
}
type KillSignal = Parameters<ChildProcess['kill']>[0];
interface OutputApi extends AsyncIterable<string> {
pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result;
process: ChildProcess | undefined;
kill(signal?: KillSignal): boolean;
get pid(): number | undefined;
get aborted(): boolean;
get killed(): boolean;
get exitCode(): number | undefined;
}
type Result = PromiseLike<Output> & OutputApi;
interface Options {
signal: AbortSignal;
nodeOptions: SpawnOptions;
timeout: number;
persist: boolean;
stdin: ExecProcess;
throwOnError: boolean;
}
interface TinyExec {
(command: string, args?: string[], options?: Partial<Options>): Result;
}
declare class ExecProcess implements Result {
protected _process?: ChildProcess;
protected _aborted: boolean;
protected _options: Partial<Options>;
protected _command: string;
protected _args: string[];
protected _resolveClose?: () => void;
protected _processClosed: Promise<void>;
protected _thrownError?: Error;
get process(): ChildProcess | undefined;
get pid(): number | undefined;
get exitCode(): number | undefined;
constructor(command: string, args?: string[], options?: Partial<Options>);
kill(signal?: KillSignal): boolean;
get aborted(): boolean;
get killed(): boolean;
pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result;
[Symbol.asyncIterator](): AsyncIterator<string>;
protected _waitForOutput(): Promise<Output>;
then<TResult1 = Output, TResult2 = never>(onfulfilled?: ((value: Output) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
protected _streamOut?: Readable;
protected _streamErr?: Readable;
spawn(): void;
protected _resetState(): void;
protected _onError: (err: Error) => void;
protected _onClose: () => void;
}
declare const x: TinyExec;
declare const exec: TinyExec;
export { ExecProcess, type KillSignal, NonZeroExitError, type Options, type Output, type OutputApi, type PipeOptions, type Result, type TinyExec, exec, x };

70
node_modules/tinyexec/dist/main.d.ts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import { ChildProcess, SpawnOptions } from 'node:child_process';
import { Readable } from 'node:stream';
declare class NonZeroExitError extends Error {
readonly result: Result;
readonly output?: Output;
get exitCode(): number | undefined;
constructor(result: Result, output?: Output);
}
interface Output {
stderr: string;
stdout: string;
exitCode: number | undefined;
}
interface PipeOptions extends Options {
}
type KillSignal = Parameters<ChildProcess['kill']>[0];
interface OutputApi extends AsyncIterable<string> {
pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result;
process: ChildProcess | undefined;
kill(signal?: KillSignal): boolean;
get pid(): number | undefined;
get aborted(): boolean;
get killed(): boolean;
get exitCode(): number | undefined;
}
type Result = PromiseLike<Output> & OutputApi;
interface Options {
signal: AbortSignal;
nodeOptions: SpawnOptions;
timeout: number;
persist: boolean;
stdin: ExecProcess;
throwOnError: boolean;
}
interface TinyExec {
(command: string, args?: string[], options?: Partial<Options>): Result;
}
declare class ExecProcess implements Result {
protected _process?: ChildProcess;
protected _aborted: boolean;
protected _options: Partial<Options>;
protected _command: string;
protected _args: string[];
protected _resolveClose?: () => void;
protected _processClosed: Promise<void>;
protected _thrownError?: Error;
get process(): ChildProcess | undefined;
get pid(): number | undefined;
get exitCode(): number | undefined;
constructor(command: string, args?: string[], options?: Partial<Options>);
kill(signal?: KillSignal): boolean;
get aborted(): boolean;
get killed(): boolean;
pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result;
[Symbol.asyncIterator](): AsyncIterator<string>;
protected _waitForOutput(): Promise<Output>;
then<TResult1 = Output, TResult2 = never>(onfulfilled?: ((value: Output) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
protected _streamOut?: Readable;
protected _streamErr?: Readable;
spawn(): void;
protected _resetState(): void;
protected _onError: (err: Error) => void;
protected _onClose: () => void;
}
declare const x: TinyExec;
declare const exec: TinyExec;
export { ExecProcess, type KillSignal, NonZeroExitError, type Options, type Output, type OutputApi, type PipeOptions, type Result, type TinyExec, exec, x };

578
node_modules/tinyexec/dist/main.js generated vendored Normal file
View File

@@ -0,0 +1,578 @@
import { createRequire as __tinyexec_cr } from "node:module";const require = __tinyexec_cr(import.meta.url);
var St = Object.create;
var $ = Object.defineProperty;
var kt = Object.getOwnPropertyDescriptor;
var Tt = Object.getOwnPropertyNames;
var At = Object.getPrototypeOf, Rt = Object.prototype.hasOwnProperty;
var h = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, {
get: (e, n) => (typeof require < "u" ? require : e)[n]
}) : t)(function(t) {
if (typeof require < "u") return require.apply(this, arguments);
throw Error('Dynamic require of "' + t + '" is not supported');
});
var l = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
var $t = (t, e, n, r) => {
if (e && typeof e == "object" || typeof e == "function")
for (let s of Tt(e))
!Rt.call(t, s) && s !== n && $(t, s, { get: () => e[s], enumerable: !(r = kt(e, s)) || r.enumerable });
return t;
};
var Nt = (t, e, n) => (n = t != null ? St(At(t)) : {}, $t(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
e || !t || !t.__esModule ? $(n, "default", { value: t, enumerable: !0 }) : n,
t
));
// node_modules/isexe/windows.js
var W = l((Se, H) => {
"use strict";
H.exports = z;
z.sync = Wt;
var j = h("fs");
function Ht(t, e) {
var n = e.pathExt !== void 0 ? e.pathExt : process.env.PATHEXT;
if (!n || (n = n.split(";"), n.indexOf("") !== -1))
return !0;
for (var r = 0; r < n.length; r++) {
var s = n[r].toLowerCase();
if (s && t.substr(-s.length).toLowerCase() === s)
return !0;
}
return !1;
}
function F(t, e, n) {
return !t.isSymbolicLink() && !t.isFile() ? !1 : Ht(e, n);
}
function z(t, e, n) {
j.stat(t, function(r, s) {
n(r, r ? !1 : F(s, t, e));
});
}
function Wt(t, e) {
return F(j.statSync(t), t, e);
}
});
// node_modules/isexe/mode.js
var X = l((ke, B) => {
"use strict";
B.exports = K;
K.sync = Dt;
var D = h("fs");
function K(t, e, n) {
D.stat(t, function(r, s) {
n(r, r ? !1 : M(s, e));
});
}
function Dt(t, e) {
return M(D.statSync(t), e);
}
function M(t, e) {
return t.isFile() && Kt(t, e);
}
function Kt(t, e) {
var n = t.mode, r = t.uid, s = t.gid, o = e.uid !== void 0 ? e.uid : process.getuid && process.getuid(), i = e.gid !== void 0 ? e.gid : process.getgid && process.getgid(), a = parseInt("100", 8), c = parseInt("010", 8), u = parseInt("001", 8), f = a | c, p = n & u || n & c && s === i || n & a && r === o || n & f && o === 0;
return p;
}
});
// node_modules/isexe/index.js
var U = l((Ae, G) => {
"use strict";
var Te = h("fs"), v;
process.platform === "win32" || global.TESTING_WINDOWS ? v = W() : v = X();
G.exports = y;
y.sync = Mt;
function y(t, e, n) {
if (typeof e == "function" && (n = e, e = {}), !n) {
if (typeof Promise != "function")
throw new TypeError("callback not provided");
return new Promise(function(r, s) {
y(t, e || {}, function(o, i) {
o ? s(o) : r(i);
});
});
}
v(t, e || {}, function(r, s) {
r && (r.code === "EACCES" || e && e.ignoreErrors) && (r = null, s = !1), n(r, s);
});
}
function Mt(t, e) {
try {
return v.sync(t, e || {});
} catch (n) {
if (e && e.ignoreErrors || n.code === "EACCES")
return !1;
throw n;
}
}
});
// node_modules/which/which.js
var et = l((Re, tt) => {
"use strict";
var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", Y = h("path"), Bt = g ? ";" : ":", V = U(), J = (t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), Q = (t, e) => {
let n = e.colon || Bt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [
// windows always checks the cwd first
...g ? [process.cwd()] : [],
...(e.path || process.env.PATH || /* istanbul ignore next: very unusual */
"").split(n)
], s = g ? e.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", o = g ? s.split(n) : [""];
return g && t.indexOf(".") !== -1 && o[0] !== "" && o.unshift(""), {
pathEnv: r,
pathExt: o,
pathExtExe: s
};
}, Z = (t, e, n) => {
typeof e == "function" && (n = e, e = {}), e || (e = {});
let { pathEnv: r, pathExt: s, pathExtExe: o } = Q(t, e), i = [], a = (u) => new Promise((f, p) => {
if (u === r.length)
return e.all && i.length ? f(i) : p(J(t));
let d = r[u], w = /^".*"$/.test(d) ? d.slice(1, -1) : d, m = Y.join(w, t), b = !w && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + m : m;
f(c(b, u, 0));
}), c = (u, f, p) => new Promise((d, w) => {
if (p === s.length)
return d(a(f + 1));
let m = s[p];
V(u + m, { pathExt: o }, (b, Ot) => {
if (!b && Ot)
if (e.all)
i.push(u + m);
else
return d(u + m);
return d(c(u, f, p + 1));
});
});
return n ? a(0).then((u) => n(null, u), n) : a(0);
}, Xt = (t, e) => {
e = e || {};
let { pathEnv: n, pathExt: r, pathExtExe: s } = Q(t, e), o = [];
for (let i = 0; i < n.length; i++) {
let a = n[i], c = /^".*"$/.test(a) ? a.slice(1, -1) : a, u = Y.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + u : u;
for (let p = 0; p < r.length; p++) {
let d = f + r[p];
try {
if (V.sync(d, { pathExt: s }))
if (e.all)
o.push(d);
else
return d;
} catch {
}
}
}
if (e.all && o.length)
return o;
if (e.nothrow)
return null;
throw J(t);
};
tt.exports = Z;
Z.sync = Xt;
});
// node_modules/path-key/index.js
var rt = l(($e, _) => {
"use strict";
var nt = (t = {}) => {
let e = t.env || process.env;
return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(e).reverse().find((r) => r.toUpperCase() === "PATH") || "Path";
};
_.exports = nt;
_.exports.default = nt;
});
// node_modules/cross-spawn/lib/util/resolveCommand.js
var ct = l((Ne, it) => {
"use strict";
var st = h("path"), Gt = et(), Ut = rt();
function ot(t, e) {
let n = t.options.env || process.env, r = process.cwd(), s = t.options.cwd != null, o = s && process.chdir !== void 0 && !process.chdir.disabled;
if (o)
try {
process.chdir(t.options.cwd);
} catch {
}
let i;
try {
i = Gt.sync(t.command, {
path: n[Ut({ env: n })],
pathExt: e ? st.delimiter : void 0
});
} catch {
} finally {
o && process.chdir(r);
}
return i && (i = st.resolve(s ? t.options.cwd : "", i)), i;
}
function Yt(t) {
return ot(t) || ot(t, !0);
}
it.exports = Yt;
});
// node_modules/cross-spawn/lib/util/escape.js
var ut = l((qe, P) => {
"use strict";
var C = /([()\][%!^"`<>&|;, *?])/g;
function Vt(t) {
return t = t.replace(C, "^$1"), t;
}
function Jt(t, e) {
return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(C, "^$1"), e && (t = t.replace(C, "^$1")), t;
}
P.exports.command = Vt;
P.exports.argument = Jt;
});
// node_modules/shebang-regex/index.js
var lt = l((Ie, at) => {
"use strict";
at.exports = /^#!(.*)/;
});
// node_modules/shebang-command/index.js
var dt = l((Le, pt) => {
"use strict";
var Qt = lt();
pt.exports = (t = "") => {
let e = t.match(Qt);
if (!e)
return null;
let [n, r] = e[0].replace(/#! ?/, "").split(" "), s = n.split("/").pop();
return s === "env" ? r : r ? `${s} ${r}` : s;
};
});
// node_modules/cross-spawn/lib/util/readShebang.js
var ht = l((je, ft) => {
"use strict";
var O = h("fs"), Zt = dt();
function te(t) {
let n = Buffer.alloc(150), r;
try {
r = O.openSync(t, "r"), O.readSync(r, n, 0, 150, 0), O.closeSync(r);
} catch {
}
return Zt(n.toString());
}
ft.exports = te;
});
// node_modules/cross-spawn/lib/parse.js
var wt = l((Fe, Et) => {
"use strict";
var ee = h("path"), mt = ct(), gt = ut(), ne = ht(), re = process.platform === "win32", se = /\.(?:com|exe)$/i, oe = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
function ie(t) {
t.file = mt(t);
let e = t.file && ne(t.file);
return e ? (t.args.unshift(t.file), t.command = e, mt(t)) : t.file;
}
function ce(t) {
if (!re)
return t;
let e = ie(t), n = !se.test(e);
if (t.options.forceShell || n) {
let r = oe.test(e);
t.command = ee.normalize(t.command), t.command = gt.command(t.command), t.args = t.args.map((o) => gt.argument(o, r));
let s = [t.command].concat(t.args).join(" ");
t.args = ["/d", "/s", "/c", `"${s}"`], t.command = process.env.comspec || "cmd.exe", t.options.windowsVerbatimArguments = !0;
}
return t;
}
function ue(t, e, n) {
e && !Array.isArray(e) && (n = e, e = null), e = e ? e.slice(0) : [], n = Object.assign({}, n);
let r = {
command: t,
args: e,
options: n,
file: void 0,
original: {
command: t,
args: e
}
};
return n.shell ? r : ce(r);
}
Et.exports = ue;
});
// node_modules/cross-spawn/lib/enoent.js
var bt = l((ze, vt) => {
"use strict";
var S = process.platform === "win32";
function k(t, e) {
return Object.assign(new Error(`${e} ${t.command} ENOENT`), {
code: "ENOENT",
errno: "ENOENT",
syscall: `${e} ${t.command}`,
path: t.command,
spawnargs: t.args
});
}
function ae(t, e) {
if (!S)
return;
let n = t.emit;
t.emit = function(r, s) {
if (r === "exit") {
let o = xt(s, e, "spawn");
if (o)
return n.call(t, "error", o);
}
return n.apply(t, arguments);
};
}
function xt(t, e) {
return S && t === 1 && !e.file ? k(e.original, "spawn") : null;
}
function le(t, e) {
return S && t === 1 && !e.file ? k(e.original, "spawnSync") : null;
}
vt.exports = {
hookChildProcess: ae,
verifyENOENT: xt,
verifyENOENTSync: le,
notFoundError: k
};
});
// node_modules/cross-spawn/index.js
var Ct = l((He, E) => {
"use strict";
var yt = h("child_process"), T = wt(), A = bt();
function _t(t, e, n) {
let r = T(t, e, n), s = yt.spawn(r.command, r.args, r.options);
return A.hookChildProcess(s, r), s;
}
function pe(t, e, n) {
let r = T(t, e, n), s = yt.spawnSync(r.command, r.args, r.options);
return s.error = s.error || A.verifyENOENTSync(s.status, r), s;
}
E.exports = _t;
E.exports.spawn = _t;
E.exports.sync = pe;
E.exports._parse = T;
E.exports._enoent = A;
});
// src/main.ts
import { spawn as de } from "child_process";
import { normalize as fe } from "path";
import { cwd as he } from "process";
// src/env.ts
import {
delimiter as N,
resolve as qt,
dirname as It
} from "path";
var Lt = /^path$/i, q = { key: "PATH", value: "" };
function jt(t) {
for (let e in t) {
if (!Object.prototype.hasOwnProperty.call(t, e) || !Lt.test(e))
continue;
let n = t[e];
return n ? { key: e, value: n } : q;
}
return q;
}
function Ft(t, e) {
let n = e.value.split(N), r = t, s;
do
n.push(qt(r, "node_modules", ".bin")), s = r, r = It(r);
while (r !== s);
return { key: e.key, value: n.join(N) };
}
function I(t, e) {
let n = {
...process.env,
...e
}, r = Ft(t, jt(n));
return n[r.key] = r.value, n;
}
// src/stream.ts
import { PassThrough as zt } from "stream";
var L = (t) => {
let e = t.length, n = new zt(), r = () => {
--e === 0 && n.emit("end");
};
for (let s of t)
s.pipe(n, { end: !1 }), s.on("end", r);
return n;
};
// src/main.ts
var Pt = Nt(Ct(), 1);
import me from "readline";
// src/non-zero-exit-error.ts
var x = class extends Error {
result;
output;
get exitCode() {
if (this.result.exitCode !== null)
return this.result.exitCode;
}
constructor(e, n) {
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = n;
}
};
// src/main.ts
var ge = {
timeout: void 0,
persist: !1
}, Ee = {
windowsHide: !0
};
function we(t, e) {
return {
command: fe(t),
args: e ?? []
};
}
function xe(t) {
let e = new AbortController();
for (let n of t) {
if (n.aborted)
return e.abort(), n;
let r = () => {
e.abort(n.reason);
};
n.addEventListener("abort", r, {
signal: e.signal
});
}
return e.signal;
}
var R = class {
_process;
_aborted = !1;
_options;
_command;
_args;
_resolveClose;
_processClosed;
_thrownError;
get process() {
return this._process;
}
get pid() {
return this._process?.pid;
}
get exitCode() {
if (this._process && this._process.exitCode !== null)
return this._process.exitCode;
}
constructor(e, n, r) {
this._options = {
...ge,
...r
}, this._command = e, this._args = n ?? [], this._processClosed = new Promise((s) => {
this._resolveClose = s;
});
}
kill(e) {
return this._process?.kill(e) === !0;
}
get aborted() {
return this._aborted;
}
get killed() {
return this._process?.killed === !0;
}
pipe(e, n, r) {
return be(e, n, {
...r,
stdin: this
});
}
async *[Symbol.asyncIterator]() {
let e = this._process;
if (!e)
return;
let n = [];
this._streamErr && n.push(this._streamErr), this._streamOut && n.push(this._streamOut);
let r = L(n), s = me.createInterface({
input: r
});
for await (let o of s)
yield o.toString();
if (await this._processClosed, e.removeAllListeners(), this._thrownError)
throw this._thrownError;
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
throw new x(this);
}
async _waitForOutput() {
let e = this._process;
if (!e)
throw new Error("No process was started");
let n = "", r = "";
if (this._streamOut)
for await (let o of this._streamOut)
r += o.toString();
if (this._streamErr)
for await (let o of this._streamErr)
n += o.toString();
if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError)
throw this._thrownError;
let s = {
stderr: n,
stdout: r,
exitCode: this.exitCode
};
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
throw new x(this, s);
return s;
}
then(e, n) {
return this._waitForOutput().then(e, n);
}
_streamOut;
_streamErr;
spawn() {
let e = he(), n = this._options, r = {
...Ee,
...n.nodeOptions
}, s = [];
this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === !0 && (r.detached = !0), s.length > 0 && (r.signal = xe(s)), r.env = I(e, r.env);
let { command: o, args: i } = we(this._command, this._args), a = (0, Pt._parse)(o, i, r), c = de(
a.command,
a.args,
a.options
);
if (c.stderr && (this._streamErr = c.stderr), c.stdout && (this._streamOut = c.stdout), this._process = c, c.once("error", this._onError), c.once("close", this._onClose), n.stdin !== void 0 && c.stdin && n.stdin.process) {
let { stdout: u } = n.stdin.process;
u && u.pipe(c.stdin);
}
}
_resetState() {
this._aborted = !1, this._processClosed = new Promise((e) => {
this._resolveClose = e;
}), this._thrownError = void 0;
}
_onError = (e) => {
if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
this._aborted = !0;
return;
}
this._thrownError = e;
};
_onClose = () => {
this._resolveClose && this._resolveClose();
};
}, ve = (t, e, n) => {
let r = new R(t, e, n);
return r.spawn(), r;
}, be = ve;
export {
R as ExecProcess,
x as NonZeroExitError,
be as exec,
ve as x
};

66
node_modules/tinyexec/package.json generated vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"name": "tinyexec",
"version": "0.3.2",
"type": "module",
"description": "A minimal library for executing processes in Node",
"main": "./dist/main.js",
"files": [
"dist",
"!dist/node_modules",
"!dist/cjs/test",
"!dist/esm/test"
],
"scripts": {
"build": "npm run build:types && tsup",
"build:types": "tsc",
"dev": "tsup --watch",
"format": "prettier --write src",
"format:check": "prettier --check src",
"lint": "eslint src",
"prepare": "npm run build",
"test": "npm run build && c8 node --test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tinylibs/tinyexec.git"
},
"keywords": [
"execa",
"exec",
"tiny",
"child_process",
"spawn"
],
"author": "James Garbutt (https://github.com/43081j)",
"license": "MIT",
"bugs": {
"url": "https://github.com/tinylibs/tinyexec/issues"
},
"homepage": "https://github.com/tinylibs/tinyexec#readme",
"devDependencies": {
"@eslint/js": "^9.0.0",
"@types/cross-spawn": "^6.0.6",
"@types/node": "^20.12.7",
"c8": "^9.1.0",
"cross-spawn": "^7.0.3",
"eslint-config-google": "^0.14.0",
"prettier": "^3.2.5",
"tsup": "^8.1.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.0"
},
"exports": {
".": {
"import": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
},
"require": {
"types": "./dist/main.d.cts",
"default": "./dist/main.cjs"
}
},
"./package.json": "./package.json"
},
"types": "./dist/main.d.ts"
}