Init: RoggioApp Architecture, Prisma Schema, API MVP
This commit is contained in:
+269
@@ -0,0 +1,269 @@
|
||||
import { parseArgs as e } from "node:util";
|
||||
const t = /\d/, n = [
|
||||
`-`,
|
||||
`_`,
|
||||
`/`,
|
||||
`.`
|
||||
];
|
||||
function r(e = ``) {
|
||||
if (!t.test(e)) return e !== e.toLowerCase();
|
||||
}
|
||||
function i(e, t) {
|
||||
let i = t ?? n, a = [];
|
||||
if (!e || typeof e != `string`) return a;
|
||||
let o = ``, s, c;
|
||||
for (let t of e) {
|
||||
let e = i.includes(t);
|
||||
if (e === !0) {
|
||||
a.push(o), o = ``, s = void 0;
|
||||
continue;
|
||||
}
|
||||
let n = r(t);
|
||||
if (c === !1) {
|
||||
if (s === !1 && n === !0) {
|
||||
a.push(o), o = t, s = n;
|
||||
continue;
|
||||
}
|
||||
if (s === !0 && n === !1 && o.length > 1) {
|
||||
let e = o.at(-1);
|
||||
a.push(o.slice(0, Math.max(0, o.length - 1))), o = e + t, s = n;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
o += t, s = n, c = e;
|
||||
}
|
||||
return a.push(o), a;
|
||||
}
|
||||
function a(e) {
|
||||
return e ? e[0].toUpperCase() + e.slice(1) : ``;
|
||||
}
|
||||
function o(e) {
|
||||
return e ? e[0].toLowerCase() + e.slice(1) : ``;
|
||||
}
|
||||
function s(e, t) {
|
||||
return e ? (Array.isArray(e) ? e : i(e)).map((e) => a(t?.normalize ? e.toLowerCase() : e)).join(``) : ``;
|
||||
}
|
||||
function c(e, t) {
|
||||
return o(s(e || ``, t));
|
||||
}
|
||||
function l(e, t) {
|
||||
return e ? (Array.isArray(e) ? e : i(e)).map((e) => e.toLowerCase()).join(t ?? `-`) : ``;
|
||||
}
|
||||
function u(e) {
|
||||
return Array.isArray(e) ? e : e === void 0 ? [] : [e];
|
||||
}
|
||||
function d(e, t = ``) {
|
||||
let n = [];
|
||||
for (let t of e) for (let [e, r] of t.entries()) n[e] = Math.max(n[e] || 0, r.length);
|
||||
return e.map((e) => e.map((e, r) => t + e[r === 0 ? `padStart` : `padEnd`](n[r])).join(` `)).join(`
|
||||
`);
|
||||
}
|
||||
function f(e) {
|
||||
return typeof e == `function` ? e() : e;
|
||||
}
|
||||
var p = class extends Error {
|
||||
code;
|
||||
constructor(e, t) {
|
||||
super(e), this.name = `CLIError`, this.code = t;
|
||||
}
|
||||
};
|
||||
function m(t = [], n = {}) {
|
||||
let r = new Set(n.boolean || []), i = new Set(n.string || []), a = n.alias || {}, o = n.default || {}, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
||||
for (let [e, t] of Object.entries(a)) {
|
||||
let n = t;
|
||||
for (let t of n) s.set(e, t), c.has(t) || c.set(t, []), c.get(t).push(e), s.set(t, e), c.has(e) || c.set(e, []), c.get(e).push(t);
|
||||
}
|
||||
let l = {};
|
||||
function u(e) {
|
||||
if (r.has(e)) return `boolean`;
|
||||
let t = c.get(e) || [];
|
||||
for (let e of t) if (r.has(e)) return `boolean`;
|
||||
return `string`;
|
||||
}
|
||||
let d = new Set([
|
||||
...r,
|
||||
...i,
|
||||
...Object.keys(a),
|
||||
...Object.values(a).flat(),
|
||||
...Object.keys(o)
|
||||
]);
|
||||
for (let e of d) l[e] || (l[e] = {
|
||||
type: u(e),
|
||||
default: o[e]
|
||||
});
|
||||
for (let [e, t] of s.entries()) e.length === 1 && l[t] && !l[t].short && (l[t].short = e);
|
||||
let f = [], p = {};
|
||||
for (let e = 0; e < t.length; e++) {
|
||||
let n = t[e];
|
||||
if (n === `--`) {
|
||||
f.push(...t.slice(e));
|
||||
break;
|
||||
}
|
||||
if (n.startsWith(`--no-`)) {
|
||||
let e = n.slice(5);
|
||||
p[e] = !0;
|
||||
continue;
|
||||
}
|
||||
f.push(n);
|
||||
}
|
||||
let m;
|
||||
try {
|
||||
m = e({
|
||||
args: f,
|
||||
options: Object.keys(l).length > 0 ? l : void 0,
|
||||
allowPositionals: !0,
|
||||
strict: !1
|
||||
});
|
||||
} catch {
|
||||
m = {
|
||||
values: {},
|
||||
positionals: f
|
||||
};
|
||||
}
|
||||
let h = { _: [] };
|
||||
h._ = m.positionals;
|
||||
for (let [e, t] of Object.entries(m.values)) h[e] = t;
|
||||
for (let [e] of Object.entries(p)) {
|
||||
h[e] = !1;
|
||||
let t = s.get(e);
|
||||
t && (h[t] = !1);
|
||||
let n = c.get(e);
|
||||
if (n) for (let e of n) h[e] = !1;
|
||||
}
|
||||
for (let [e, t] of s.entries()) h[e] !== void 0 && h[t] === void 0 && (h[t] = h[e]), h[t] !== void 0 && h[e] === void 0 && (h[e] = h[t]);
|
||||
return h;
|
||||
}
|
||||
const h = (() => {
|
||||
let e = globalThis.process?.env ?? {};
|
||||
return e.NO_COLOR === `1` || e.TERM === `dumb` || e.TEST || e.CI;
|
||||
})(), g = (e, t = 39) => (n) => h ? n : `\u001B[${e}m${n}\u001B[${t}m`, _ = g(1, 22), v = g(36), y = g(90), b = g(4, 24);
|
||||
function x(e, t) {
|
||||
let n = {
|
||||
boolean: [],
|
||||
string: [],
|
||||
alias: {},
|
||||
default: {}
|
||||
}, r = S(t);
|
||||
for (let e of r) {
|
||||
if (e.type === `positional`) continue;
|
||||
e.type === `string` || e.type === `enum` ? n.string.push(e.name) : e.type === `boolean` && n.boolean.push(e.name), e.default !== void 0 && (n.default[e.name] = e.default), e.alias && (n.alias[e.name] = e.alias);
|
||||
let t = c(e.name), r = l(e.name);
|
||||
if (t !== e.name || r !== e.name) {
|
||||
let i = u(n.alias[e.name] || []);
|
||||
t !== e.name && !i.includes(t) && i.push(t), r !== e.name && !i.includes(r) && i.push(r), i.length > 0 && (n.alias[e.name] = i);
|
||||
}
|
||||
}
|
||||
let i = m(e, n), [ ...a] = i._, o = new Proxy(i, { get(e, t) {
|
||||
return e[t] ?? e[c(t)] ?? e[l(t)];
|
||||
} });
|
||||
for (let [, e] of r.entries()) if (e.type === `positional`) {
|
||||
let t = a.shift();
|
||||
if (t !== void 0) o[e.name] = t;
|
||||
else if (e.default === void 0 && e.required !== !1) throw new p(`Missing required positional argument: ${e.name.toUpperCase()}`, `EARG`);
|
||||
else o[e.name] = e.default;
|
||||
} else if (e.type === `enum`) {
|
||||
let t = o[e.name], n = e.options || [];
|
||||
if (t !== void 0 && n.length > 0 && !n.includes(t)) throw new p(`Invalid value for argument: ${v(`--${e.name}`)} (${v(t)}). Expected one of: ${n.map((e) => v(e)).join(`, `)}.`, `EARG`);
|
||||
} else if (e.required && o[e.name] === void 0) throw new p(`Missing required argument: --${e.name}`, `EARG`);
|
||||
return o;
|
||||
}
|
||||
function S(e) {
|
||||
let t = [];
|
||||
for (let [n, r] of Object.entries(e || {})) t.push({
|
||||
...r,
|
||||
name: n,
|
||||
alias: u(r.alias)
|
||||
});
|
||||
return t;
|
||||
}
|
||||
function C(e) {
|
||||
return e;
|
||||
}
|
||||
async function w(e, t) {
|
||||
let n = await f(e.args || {}), r = x(t.rawArgs, n), i = {
|
||||
rawArgs: t.rawArgs,
|
||||
args: r,
|
||||
data: t.data,
|
||||
cmd: e
|
||||
};
|
||||
typeof e.setup == `function` && await e.setup(i);
|
||||
let a;
|
||||
try {
|
||||
let n = await f(e.subCommands);
|
||||
if (n && Object.keys(n).length > 0) {
|
||||
let r = t.rawArgs.findIndex((e) => !e.startsWith(`-`)), i = t.rawArgs[r];
|
||||
if (i) {
|
||||
if (!n[i]) throw new p(`Unknown command ${v(i)}`, `E_UNKNOWN_COMMAND`);
|
||||
let e = await f(n[i]);
|
||||
e && await w(e, { rawArgs: t.rawArgs.slice(r + 1) });
|
||||
} else if (!e.run) throw new p(`No command specified.`, `E_NO_COMMAND`);
|
||||
}
|
||||
typeof e.run == `function` && (a = await e.run(i));
|
||||
} finally {
|
||||
typeof e.cleanup == `function` && await e.cleanup(i);
|
||||
}
|
||||
return { result: a };
|
||||
}
|
||||
async function T(e, t, n) {
|
||||
let r = await f(e.subCommands);
|
||||
if (r && Object.keys(r).length > 0) {
|
||||
let n = t.findIndex((e) => !e.startsWith(`-`)), i = t[n], a = await f(r[i]);
|
||||
if (a) return T(a, t.slice(n + 1), e);
|
||||
}
|
||||
return [e, n];
|
||||
}
|
||||
async function E(e, t) {
|
||||
try {
|
||||
console.log(await O(e, t) + `
|
||||
`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
const D = /^no[-A-Z]/;
|
||||
async function O(e, t) {
|
||||
let n = await f(e.meta || {}), r = S(await f(e.args || {})), i = await f(t?.meta || {}), a = `${i.name ? `${i.name} ` : ``}` + (n.name || process.argv[1]), o = [], s = [], c = [], l = [];
|
||||
for (let e of r) if (e.type === `positional`) {
|
||||
let t = e.name.toUpperCase(), n = e.required !== !1 && e.default === void 0, r = e.default ? `="${e.default}"` : ``;
|
||||
s.push([
|
||||
v(t + r),
|
||||
e.description || ``,
|
||||
e.valueHint ? `<${e.valueHint}>` : ``
|
||||
]), l.push(n ? `<${t}>` : `[${t}]`);
|
||||
} else {
|
||||
let t = e.required === !0 && e.default === void 0, n = [...(e.alias || []).map((e) => `-${e}`), `--${e.name}`].join(`, `) + (e.type === `string` && (e.valueHint || e.default) ? `=${e.valueHint ? `<${e.valueHint}>` : `"${e.default || ``}"`}` : ``) + (e.type === `enum` && e.options ? `=<${e.options.join(`|`)}>` : ``);
|
||||
if (o.push([v(n + (t ? ` (required)` : ``)), e.description || ``]), e.type === `boolean` && (e.default === !0 || e.negativeDescription) && !D.test(e.name)) {
|
||||
let n = [...(e.alias || []).map((e) => `--no-${e}`), `--no-${e.name}`].join(`, `);
|
||||
o.push([v(n + (t ? ` (required)` : ``)), e.negativeDescription || ``]);
|
||||
}
|
||||
t && l.push(n);
|
||||
}
|
||||
if (e.subCommands) {
|
||||
let t = [], n = await f(e.subCommands);
|
||||
for (let [e, r] of Object.entries(n)) {
|
||||
let n = await f((await f(r))?.meta);
|
||||
n?.hidden || (c.push([v(e), n?.description || ``]), t.push(e));
|
||||
}
|
||||
l.push(t.join(`|`));
|
||||
}
|
||||
let u = [], p = n.version || i.version;
|
||||
u.push(y(`${n.description} (${a + (p ? ` v${p}` : ``)})`), ``);
|
||||
let m = o.length > 0 || s.length > 0;
|
||||
return u.push(`${b(_(`USAGE`))} ${v(`${a}${m ? ` [OPTIONS]` : ``} ${l.join(` `)}`)}`, ``), s.length > 0 && (u.push(b(_(`ARGUMENTS`)), ``), u.push(d(s, ` `)), u.push(``)), o.length > 0 && (u.push(b(_(`OPTIONS`)), ``), u.push(d(o, ` `)), u.push(``)), c.length > 0 && (u.push(b(_(`COMMANDS`)), ``), u.push(d(c, ` `)), u.push(``, `Use ${v(`${a} <command> --help`)} for more information about a command.`)), u.filter((e) => typeof e == `string`).join(`
|
||||
`);
|
||||
}
|
||||
async function k(e, t = {}) {
|
||||
let n = t.rawArgs || process.argv.slice(2), r = t.showUsage || E;
|
||||
try {
|
||||
if (n.includes(`--help`) || n.includes(`-h`)) await r(...await T(e, n)), process.exit(0);
|
||||
else if (n.length === 1 && n[0] === `--version`) {
|
||||
let t = typeof e.meta == `function` ? await e.meta() : await e.meta;
|
||||
if (!t?.version) throw new p(`No version specified`, `E_NO_VERSION`);
|
||||
console.log(t.version);
|
||||
} else await w(e, { rawArgs: n });
|
||||
} catch (t) {
|
||||
t instanceof p ? (await r(...await T(e, n)), console.error(t.message)) : console.error(t, `
|
||||
`), process.exit(1);
|
||||
}
|
||||
}
|
||||
export { k as n, C as t };
|
||||
+1
@@ -0,0 +1 @@
|
||||
type e=`npm`|`yarn`|`pnpm`|`bun`|`deno`;type t={name:e;command:string;version?:string;buildMeta?:string;majorVersion?:string;lockFile?:string|string[];files?:string[];};type n={cwd?:string;env?:Record<string,string>;silent?:boolean;packageManager?:t|e;installPeerDependencies?:boolean;dev?:boolean;workspace?:boolean|string;global?:boolean;corepack?:boolean;dry?:boolean;};type r={exec?:{command:string;args:string[];};};declare function i(e?:Pick<n,`cwd`|`silent`|`packageManager`|`dry`|`corepack`>&{frozenLockFile?:boolean;ignoreWorkspace?:boolean;}): Promise<r>;export{i as t};
|
||||
+669
@@ -0,0 +1,669 @@
|
||||
import { t as e } from "../rolldown-runtime.mjs";
|
||||
import { createRequire as t } from "node:module";
|
||||
import { existsSync as n } from "node:fs";
|
||||
import { readFile as r } from "node:fs/promises";
|
||||
import { PassThrough as i } from "node:stream";
|
||||
import { spawn as a } from "node:child_process";
|
||||
import { delimiter as o, dirname as s, normalize as c, resolve as l } from "node:path";
|
||||
import { cwd as u } from "node:process";
|
||||
import d from "node:readline";
|
||||
const f = /^[A-Za-z]:\//;
|
||||
function p(e = ``) {
|
||||
return e && e.replace(/\\/g, `/`).replace(f, (e) => e.toUpperCase());
|
||||
}
|
||||
const ee = /^[/\\]{2}/, te = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, m = /^[A-Za-z]:$/, h = /^\/([A-Za-z]:)?$/, g = function(e) {
|
||||
if (e.length === 0) return `.`;
|
||||
e = p(e);
|
||||
let t = e.match(ee), n = x(e), r = e[e.length - 1] === `/`;
|
||||
return e = b(e, !n), e.length === 0 ? n ? `/` : r ? `./` : `.` : (r && (e += `/`), m.test(e) && (e += `/`), t ? n ? `//${e}` : `//./${e}` : n && !x(e) ? `/${e}` : e);
|
||||
}, _ = function(...e) {
|
||||
let t = ``;
|
||||
for (let n of e) if (n) if (t.length > 0) {
|
||||
let e = t[t.length - 1] === `/`, r = n[0] === `/`;
|
||||
e && r ? t += n.slice(1) : t += e || r ? n : `/${n}`;
|
||||
} else t += n;
|
||||
return g(t);
|
||||
};
|
||||
function v() {
|
||||
return typeof process < `u` && typeof process.cwd == `function` ? process.cwd().replace(/\\/g, `/`) : `/`;
|
||||
}
|
||||
const y = function(...e) {
|
||||
e = e.map((e) => p(e));
|
||||
let t = ``, n = !1;
|
||||
for (let r = e.length - 1; r >= -1 && !n; r--) {
|
||||
let i = r >= 0 ? e[r] : v();
|
||||
!i || i.length === 0 || (t = `${i}/${t}`, n = x(i));
|
||||
}
|
||||
return t = b(t, !n), n && !x(t) ? `/${t}` : t.length > 0 ? t : `.`;
|
||||
};
|
||||
function b(e, t) {
|
||||
let n = ``, r = 0, i = -1, a = 0, o = null;
|
||||
for (let s = 0; s <= e.length; ++s) {
|
||||
if (s < e.length) o = e[s];
|
||||
else if (o === `/`) break;
|
||||
else o = `/`;
|
||||
if (o === `/`) {
|
||||
if (!(i === s - 1 || a === 1)) if (a === 2) {
|
||||
if (n.length < 2 || r !== 2 || n[n.length - 1] !== `.` || n[n.length - 2] !== `.`) {
|
||||
if (n.length > 2) {
|
||||
let e = n.lastIndexOf(`/`);
|
||||
e === -1 ? (n = ``, r = 0) : (n = n.slice(0, e), r = n.length - 1 - n.lastIndexOf(`/`)), i = s, a = 0;
|
||||
continue;
|
||||
} else if (n.length > 0) {
|
||||
n = ``, r = 0, i = s, a = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
t && (n += n.length > 0 ? `/..` : `..`, r = 2);
|
||||
} else n.length > 0 ? n += `/${e.slice(i + 1, s)}` : n = e.slice(i + 1, s), r = s - i - 1;
|
||||
i = s, a = 0;
|
||||
} else o === `.` && a !== -1 ? ++a : a = -1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
const x = function(e) {
|
||||
return te.test(e);
|
||||
}, S = function(e, t) {
|
||||
let n = y(e).replace(h, `$1`).split(`/`), r = y(t).replace(h, `$1`).split(`/`);
|
||||
if (r[0][1] === `:` && n[0][1] === `:` && n[0] !== r[0]) return r.join(`/`);
|
||||
let i = [...n];
|
||||
for (let e of i) {
|
||||
if (r[0] !== e) break;
|
||||
n.shift(), r.shift();
|
||||
}
|
||||
return [...n.map(() => `..`), ...r].join(`/`);
|
||||
}, C = function(e) {
|
||||
let t = p(e).replace(/\/$/, ``).split(`/`).slice(0, -1);
|
||||
return t.length === 1 && m.test(t[0]) && (t[0] += `/`), t.join(`/`) || (x(e) ? `/` : `.`);
|
||||
}, ne = function(e, t) {
|
||||
let n = p(e).split(`/`), r = ``;
|
||||
for (let e = n.length - 1; e >= 0; e--) {
|
||||
let t = n[e];
|
||||
if (t) {
|
||||
r = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return t && r.endsWith(t) ? r.slice(0, -t.length) : r;
|
||||
};
|
||||
globalThis.process?.platform;
|
||||
var w = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), T = t(import.meta.url);
|
||||
const re = /^path$/i, E = {
|
||||
key: `PATH`,
|
||||
value: ``
|
||||
};
|
||||
function D(e) {
|
||||
for (let t in e) {
|
||||
if (!Object.prototype.hasOwnProperty.call(e, t) || !re.test(t)) continue;
|
||||
let n = e[t];
|
||||
return n ? {
|
||||
key: t,
|
||||
value: n
|
||||
} : E;
|
||||
}
|
||||
return E;
|
||||
}
|
||||
function O(e, t) {
|
||||
let n = t.value.split(o), r = [], i = e, a;
|
||||
do
|
||||
r.push(l(i, `node_modules`, `.bin`)), a = i, i = s(i);
|
||||
while (i !== a);
|
||||
let c = r.concat(n).join(o);
|
||||
return {
|
||||
key: t.key,
|
||||
value: c
|
||||
};
|
||||
}
|
||||
function k(e, t) {
|
||||
let n = {
|
||||
...process.env,
|
||||
...t
|
||||
}, r = O(e, D(n));
|
||||
return n[r.key] = r.value, n;
|
||||
}
|
||||
const A = (e) => {
|
||||
let t = e.length, n = new i(), r = () => {
|
||||
--t === 0 && n.emit(`end`);
|
||||
};
|
||||
for (let t of e) t.pipe(n, { end: !1 }), t.on(`end`, r);
|
||||
return n;
|
||||
};
|
||||
var j = w(((e, t) => {
|
||||
t.exports = a, a.sync = o;
|
||||
var n = T(`fs`);
|
||||
function r(e, t) {
|
||||
var n = t.pathExt === void 0 ? process.env.PATHEXT : t.pathExt;
|
||||
if (!n || (n = n.split(`;`), n.indexOf(``) !== -1)) return !0;
|
||||
for (var r = 0; r < n.length; r++) {
|
||||
var i = n[r].toLowerCase();
|
||||
if (i && e.substr(-i.length).toLowerCase() === i) return !0;
|
||||
}
|
||||
return !1;
|
||||
}
|
||||
function i(e, t, n) {
|
||||
return !e.isSymbolicLink() && !e.isFile() ? !1 : r(t, n);
|
||||
}
|
||||
function a(e, t, r) {
|
||||
n.stat(e, function(n, a) {
|
||||
r(n, n ? !1 : i(a, e, t));
|
||||
});
|
||||
}
|
||||
function o(e, t) {
|
||||
return i(n.statSync(e), e, t);
|
||||
}
|
||||
})), M = w(((e, t) => {
|
||||
t.exports = r, r.sync = i;
|
||||
var n = T(`fs`);
|
||||
function r(e, t, r) {
|
||||
n.stat(e, function(e, n) {
|
||||
r(e, e ? !1 : a(n, t));
|
||||
});
|
||||
}
|
||||
function i(e, t) {
|
||||
return a(n.statSync(e), t);
|
||||
}
|
||||
function a(e, t) {
|
||||
return e.isFile() && o(e, t);
|
||||
}
|
||||
function o(e, t) {
|
||||
var n = e.mode, r = e.uid, i = e.gid, a = t.uid === void 0 ? process.getuid && process.getuid() : t.uid, o = t.gid === void 0 ? process.getgid && process.getgid() : t.gid, s = 64, c = 8, l = 1, u = s | c;
|
||||
return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
|
||||
}
|
||||
})), N = w(((e, t) => {
|
||||
T(`fs`);
|
||||
var n = process.platform === `win32` || global.TESTING_WINDOWS ? j() : M();
|
||||
t.exports = r, r.sync = i;
|
||||
function r(e, t, i) {
|
||||
if (typeof t == `function` && (i = t, t = {}), !i) {
|
||||
if (typeof Promise != `function`) throw TypeError(`callback not provided`);
|
||||
return new Promise(function(n, i) {
|
||||
r(e, t || {}, function(e, t) {
|
||||
e ? i(e) : n(t);
|
||||
});
|
||||
});
|
||||
}
|
||||
n(e, t || {}, function(e, n) {
|
||||
e && (e.code === `EACCES` || t && t.ignoreErrors) && (e = null, n = !1), i(e, n);
|
||||
});
|
||||
}
|
||||
function i(e, t) {
|
||||
try {
|
||||
return n.sync(e, t || {});
|
||||
} catch (e) {
|
||||
if (t && t.ignoreErrors || e.code === `EACCES`) return !1;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
})), P = w(((e, t) => {
|
||||
let n = process.platform === `win32` || process.env.OSTYPE === `cygwin` || process.env.OSTYPE === `msys`, r = T(`path`), i = n ? `;` : `:`, a = N(), o = (e) => Object.assign(Error(`not found: ${e}`), { code: `ENOENT` }), s = (e, t) => {
|
||||
let r = t.colon || i, a = e.match(/\//) || n && e.match(/\\/) ? [``] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || ``).split(r)], o = n ? t.pathExt || process.env.PATHEXT || `.EXE;.CMD;.BAT;.COM` : ``, s = n ? o.split(r) : [``];
|
||||
return n && e.indexOf(`.`) !== -1 && s[0] !== `` && s.unshift(``), {
|
||||
pathEnv: a,
|
||||
pathExt: s,
|
||||
pathExtExe: o
|
||||
};
|
||||
}, c = (e, t, n) => {
|
||||
typeof t == `function` && (n = t, t = {}), t ||= {};
|
||||
let { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t), u = [], d = (n) => new Promise((a, s) => {
|
||||
if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
|
||||
let c = i[n], l = /^".*"$/.test(c) ? c.slice(1, -1) : c, d = r.join(l, e);
|
||||
a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
|
||||
}), f = (e, n, r) => new Promise((i, o) => {
|
||||
if (r === c.length) return i(d(n + 1));
|
||||
let s = c[r];
|
||||
a(e + s, { pathExt: l }, (a, o) => {
|
||||
if (!a && o) if (t.all) u.push(e + s);
|
||||
else return i(e + s);
|
||||
return i(f(e, n, r + 1));
|
||||
});
|
||||
});
|
||||
return n ? d(0).then((e) => n(null, e), n) : d(0);
|
||||
};
|
||||
t.exports = c, c.sync = (e, t) => {
|
||||
t ||= {};
|
||||
let { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t), l = [];
|
||||
for (let o = 0; o < n.length; o++) {
|
||||
let s = n[o], u = /^".*"$/.test(s) ? s.slice(1, -1) : s, d = r.join(u, e), f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
|
||||
for (let e = 0; e < i.length; e++) {
|
||||
let n = f + i[e];
|
||||
try {
|
||||
if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
|
||||
else return n;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
if (t.all && l.length) return l;
|
||||
if (t.nothrow) return null;
|
||||
throw o(e);
|
||||
};
|
||||
})), F = w(((e, t) => {
|
||||
let n = (e = {}) => {
|
||||
let t = e.env || process.env;
|
||||
return (e.platform || process.platform) === `win32` ? Object.keys(t).reverse().find((e) => e.toUpperCase() === `PATH`) || `Path` : `PATH`;
|
||||
};
|
||||
t.exports = n, t.exports.default = n;
|
||||
})), I = w(((e, t) => {
|
||||
let n = T(`path`), r = P(), i = F();
|
||||
function a(e, t) {
|
||||
let a = e.options.env || process.env, o = process.cwd(), s = e.options.cwd != null, c = s && process.chdir !== void 0 && !process.chdir.disabled;
|
||||
if (c) try {
|
||||
process.chdir(e.options.cwd);
|
||||
} catch {}
|
||||
let l;
|
||||
try {
|
||||
l = r.sync(e.command, {
|
||||
path: a[i({ env: a })],
|
||||
pathExt: t ? n.delimiter : void 0
|
||||
});
|
||||
} catch {} finally {
|
||||
c && process.chdir(o);
|
||||
}
|
||||
return l &&= n.resolve(s ? e.options.cwd : ``, l), l;
|
||||
}
|
||||
function o(e) {
|
||||
return a(e) || a(e, !0);
|
||||
}
|
||||
t.exports = o;
|
||||
})), L = w(((e, t) => {
|
||||
let n = /([()\][%!^"`<>&|;, *?])/g;
|
||||
function r(e) {
|
||||
return e = e.replace(n, `^$1`), e;
|
||||
}
|
||||
function i(e, t) {
|
||||
return e = `${e}`, e = e.replace(/(?=(\\+?)?)\1"/g, `$1$1\\"`), e = e.replace(/(?=(\\+?)?)\1$/, `$1$1`), e = `"${e}"`, e = e.replace(n, `^$1`), t && (e = e.replace(n, `^$1`)), e;
|
||||
}
|
||||
t.exports.command = r, t.exports.argument = i;
|
||||
})), R = w(((e, t) => {
|
||||
t.exports = /^#!(.*)/;
|
||||
})), z = w(((e, t) => {
|
||||
let n = R();
|
||||
t.exports = (e = ``) => {
|
||||
let t = e.match(n);
|
||||
if (!t) return null;
|
||||
let [r, i] = t[0].replace(/#! ?/, ``).split(` `), a = r.split(`/`).pop();
|
||||
return a === `env` ? i : i ? `${a} ${i}` : a;
|
||||
};
|
||||
})), B = w(((e, t) => {
|
||||
let n = T(`fs`), r = z();
|
||||
function i(e) {
|
||||
let t = Buffer.alloc(150), i;
|
||||
try {
|
||||
i = n.openSync(e, `r`), n.readSync(i, t, 0, 150, 0), n.closeSync(i);
|
||||
} catch {}
|
||||
return r(t.toString());
|
||||
}
|
||||
t.exports = i;
|
||||
})), V = w(((e, t) => {
|
||||
let n = T(`path`), r = I(), i = L(), a = B(), o = process.platform === `win32`, s = /\.(?:com|exe)$/i, c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
||||
function l(e) {
|
||||
e.file = r(e);
|
||||
let t = e.file && a(e.file);
|
||||
return t ? (e.args.unshift(e.file), e.command = t, r(e)) : e.file;
|
||||
}
|
||||
function u(e) {
|
||||
if (!o) return e;
|
||||
let t = l(e), r = !s.test(t);
|
||||
if (e.options.forceShell || r) {
|
||||
let r = c.test(t);
|
||||
e.command = n.normalize(e.command), e.command = i.command(e.command), e.args = e.args.map((e) => i.argument(e, r)), e.args = [
|
||||
`/d`,
|
||||
`/s`,
|
||||
`/c`,
|
||||
`"${[e.command].concat(e.args).join(` `)}"`
|
||||
], e.command = process.env.comspec || `cmd.exe`, e.options.windowsVerbatimArguments = !0;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
function d(e, t, n) {
|
||||
t && !Array.isArray(t) && (n = t, t = null), t = t ? t.slice(0) : [], n = Object.assign({}, n);
|
||||
let r = {
|
||||
command: e,
|
||||
args: t,
|
||||
options: n,
|
||||
file: void 0,
|
||||
original: {
|
||||
command: e,
|
||||
args: t
|
||||
}
|
||||
};
|
||||
return n.shell ? r : u(r);
|
||||
}
|
||||
t.exports = d;
|
||||
})), ie = w(((e, t) => {
|
||||
let n = process.platform === `win32`;
|
||||
function r(e, t) {
|
||||
return Object.assign(Error(`${t} ${e.command} ENOENT`), {
|
||||
code: `ENOENT`,
|
||||
errno: `ENOENT`,
|
||||
syscall: `${t} ${e.command}`,
|
||||
path: e.command,
|
||||
spawnargs: e.args
|
||||
});
|
||||
}
|
||||
function i(e, t) {
|
||||
if (!n) return;
|
||||
let r = e.emit;
|
||||
e.emit = function(n, i) {
|
||||
if (n === `exit`) {
|
||||
let n = a(i, t);
|
||||
if (n) return r.call(e, `error`, n);
|
||||
}
|
||||
return r.apply(e, arguments);
|
||||
};
|
||||
}
|
||||
function a(e, t) {
|
||||
return n && e === 1 && !t.file ? r(t.original, `spawn`) : null;
|
||||
}
|
||||
function o(e, t) {
|
||||
return n && e === 1 && !t.file ? r(t.original, `spawnSync`) : null;
|
||||
}
|
||||
t.exports = {
|
||||
hookChildProcess: i,
|
||||
verifyENOENT: a,
|
||||
verifyENOENTSync: o,
|
||||
notFoundError: r
|
||||
};
|
||||
})), H = w(((e, t) => {
|
||||
let n = T(`child_process`), r = V(), i = ie();
|
||||
function a(e, t, a) {
|
||||
let o = r(e, t, a), s = n.spawn(o.command, o.args, o.options);
|
||||
return i.hookChildProcess(s, o), s;
|
||||
}
|
||||
function o(e, t, a) {
|
||||
let o = r(e, t, a), s = n.spawnSync(o.command, o.args, o.options);
|
||||
return s.error = s.error || i.verifyENOENTSync(s.status, o), s;
|
||||
}
|
||||
t.exports = a, t.exports.spawn = a, t.exports.sync = o, t.exports._parse = r, t.exports._enoent = i;
|
||||
}))(), U = class extends Error {
|
||||
result;
|
||||
output;
|
||||
get exitCode() {
|
||||
if (this.result.exitCode !== null) return this.result.exitCode;
|
||||
}
|
||||
constructor(e, t) {
|
||||
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = t;
|
||||
}
|
||||
};
|
||||
const W = {
|
||||
timeout: void 0,
|
||||
persist: !1
|
||||
}, G = { windowsHide: !0 };
|
||||
function K(e, t) {
|
||||
return {
|
||||
command: c(e),
|
||||
args: t ?? []
|
||||
};
|
||||
}
|
||||
function q(e) {
|
||||
let t = new AbortController();
|
||||
for (let n of e) {
|
||||
if (n.aborted) return t.abort(), n;
|
||||
n.addEventListener(`abort`, () => {
|
||||
t.abort(n.reason);
|
||||
}, { signal: t.signal });
|
||||
}
|
||||
return t.signal;
|
||||
}
|
||||
async function J(e) {
|
||||
let t = ``;
|
||||
for await (let n of e) t += n.toString();
|
||||
return t;
|
||||
}
|
||||
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, t, n) {
|
||||
this._options = {
|
||||
...W,
|
||||
...n
|
||||
}, this._command = e, this._args = t ?? [], this._processClosed = new Promise((e) => {
|
||||
this._resolveClose = e;
|
||||
});
|
||||
}
|
||||
kill(e) {
|
||||
return this._process?.kill(e) === !0;
|
||||
}
|
||||
get aborted() {
|
||||
return this._aborted;
|
||||
}
|
||||
get killed() {
|
||||
return this._process?.killed === !0;
|
||||
}
|
||||
pipe(e, t, n) {
|
||||
return ae(e, t, {
|
||||
...n,
|
||||
stdin: this
|
||||
});
|
||||
}
|
||||
async *[Symbol.asyncIterator]() {
|
||||
let e = this._process;
|
||||
if (!e) return;
|
||||
let t = [];
|
||||
this._streamErr && t.push(this._streamErr), this._streamOut && t.push(this._streamOut);
|
||||
let n = A(t), r = d.createInterface({ input: n });
|
||||
for await (let e of r) yield e.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 U(this);
|
||||
}
|
||||
async _waitForOutput() {
|
||||
let e = this._process;
|
||||
if (!e) throw Error(`No process was started`);
|
||||
let [t, n] = await Promise.all([this._streamOut ? J(this._streamOut) : ``, this._streamErr ? J(this._streamErr) : ``]);
|
||||
if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError) throw this._thrownError;
|
||||
let r = {
|
||||
stderr: n,
|
||||
stdout: t,
|
||||
exitCode: this.exitCode
|
||||
};
|
||||
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new U(this, r);
|
||||
return r;
|
||||
}
|
||||
then(e, t) {
|
||||
return this._waitForOutput().then(e, t);
|
||||
}
|
||||
_streamOut;
|
||||
_streamErr;
|
||||
spawn() {
|
||||
let e = u(), t = this._options, n = {
|
||||
...G,
|
||||
...t.nodeOptions
|
||||
}, r = [];
|
||||
this._resetState(), t.timeout !== void 0 && r.push(AbortSignal.timeout(t.timeout)), t.signal !== void 0 && r.push(t.signal), t.persist === !0 && (n.detached = !0), r.length > 0 && (n.signal = q(r)), n.env = k(e, n.env);
|
||||
let { command: i, args: o } = K(this._command, this._args), s = (0, H._parse)(i, o, n), c = a(s.command, s.args, s.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), t.stdin !== void 0 && c.stdin && t.stdin.process) {
|
||||
let { stdout: e } = t.stdin.process;
|
||||
e && e.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();
|
||||
};
|
||||
};
|
||||
const X = (e, t, n) => {
|
||||
let r = new Y(e, t, n);
|
||||
return r.spawn(), r;
|
||||
}, ae = X;
|
||||
var oe = e({
|
||||
detectPackageManager: () => $,
|
||||
installDependencies: () => fe,
|
||||
packageManagers: () => Q
|
||||
});
|
||||
async function se(e, t, n = {}) {
|
||||
let r = g(e).split(`/`);
|
||||
for (; r.length > 0;) {
|
||||
let e = await t(r.join(`/`) || `/`);
|
||||
if (e || !n.includeParentDirs) return e;
|
||||
r.pop();
|
||||
}
|
||||
}
|
||||
function ce(e) {
|
||||
let t;
|
||||
return () => (t === void 0 && (t = e().then((e) => (t = e, t))), t);
|
||||
}
|
||||
const Z = ce(async () => {
|
||||
if (globalThis.process?.versions?.webcontainer) return !1;
|
||||
try {
|
||||
let { exitCode: e } = await X(`corepack`, [`--version`]);
|
||||
return e === 0;
|
||||
} catch {
|
||||
return !1;
|
||||
}
|
||||
});
|
||||
async function le(e, t, n = {}) {
|
||||
let r = e !== `npm` && e !== `bun` && e !== `deno` && n.corepack !== !1 && await Z() ? [`corepack`, [e, ...t]] : [e, t], { exitCode: i, stdout: a, stderr: o } = await X(r[0], r[1], { nodeOptions: {
|
||||
cwd: y(n.cwd || process.cwd()),
|
||||
env: n.env,
|
||||
stdio: n.silent ? `pipe` : `inherit`
|
||||
} });
|
||||
if (i !== 0) throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent ? [
|
||||
``,
|
||||
a,
|
||||
o
|
||||
].join(`
|
||||
`) : ``}`);
|
||||
}
|
||||
async function ue(e = {}) {
|
||||
let t = e.cwd || process.cwd(), n = {
|
||||
...process.env,
|
||||
...e.env
|
||||
}, r = (typeof e.packageManager == `string` ? Q.find((t) => t.name === e.packageManager) : e.packageManager) || await $(e.cwd || process.cwd());
|
||||
if (!r) throw Error(`No package manager auto-detected.`);
|
||||
return {
|
||||
cwd: t,
|
||||
env: n,
|
||||
silent: e.silent ?? !1,
|
||||
packageManager: r,
|
||||
dev: e.dev ?? !1,
|
||||
workspace: e.workspace,
|
||||
global: e.global ?? !1,
|
||||
dry: e.dry ?? !1,
|
||||
corepack: e.corepack ?? !0
|
||||
};
|
||||
}
|
||||
function de(e) {
|
||||
let [t, n] = (e || ``).split(`@`), [r, i] = n?.split(`+`) || [];
|
||||
if (t && t !== `-` && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t)) return {
|
||||
name: t,
|
||||
version: r,
|
||||
buildMeta: i
|
||||
};
|
||||
let a = (t || ``).replace(/\W+/g, ``);
|
||||
return {
|
||||
name: a,
|
||||
version: r,
|
||||
buildMeta: i,
|
||||
warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]
|
||||
};
|
||||
}
|
||||
const Q = [
|
||||
{
|
||||
name: `npm`,
|
||||
command: `npm`,
|
||||
lockFile: `package-lock.json`
|
||||
},
|
||||
{
|
||||
name: `pnpm`,
|
||||
command: `pnpm`,
|
||||
lockFile: `pnpm-lock.yaml`,
|
||||
files: [`pnpm-workspace.yaml`]
|
||||
},
|
||||
{
|
||||
name: `bun`,
|
||||
command: `bun`,
|
||||
lockFile: [`bun.lockb`, `bun.lock`]
|
||||
},
|
||||
{
|
||||
name: `yarn`,
|
||||
command: `yarn`,
|
||||
lockFile: `yarn.lock`,
|
||||
files: [`.yarnrc.yml`]
|
||||
},
|
||||
{
|
||||
name: `deno`,
|
||||
command: `deno`,
|
||||
lockFile: `deno.lock`,
|
||||
files: [`deno.json`]
|
||||
}
|
||||
];
|
||||
async function $(e, t = {}) {
|
||||
let i = await se(y(e || `.`), async (e) => {
|
||||
if (!t.ignorePackageJSON) {
|
||||
let t = _(e, `package.json`);
|
||||
if (n(t)) {
|
||||
let e = JSON.parse(await r(t, `utf8`));
|
||||
if (e?.packageManager) {
|
||||
let { name: t, version: n = `0.0.0`, buildMeta: r, warnings: i } = de(e.packageManager);
|
||||
if (t) {
|
||||
let e = n.split(`.`)[0], a = Q.find((n) => n.name === t && n.majorVersion === e) || Q.find((e) => e.name === t);
|
||||
return {
|
||||
name: t,
|
||||
command: t,
|
||||
version: n,
|
||||
majorVersion: e,
|
||||
buildMeta: r,
|
||||
warnings: i,
|
||||
files: a?.files,
|
||||
lockFile: a?.lockFile
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n(_(e, `deno.json`))) return Q.find((e) => e.name === `deno`);
|
||||
}
|
||||
if (!t.ignoreLockFile) {
|
||||
for (let t of Q) if ([t.lockFile, t.files].flat().filter(Boolean).some((t) => n(y(e, t)))) return { ...t };
|
||||
}
|
||||
}, { includeParentDirs: t.includeParentDirs ?? !0 });
|
||||
if (!i && !t.ignoreArgv) {
|
||||
let e = process.argv[1];
|
||||
if (e) {
|
||||
for (let t of Q) if (RegExp(`[/\\\\]\\.?${t.command}`).test(e)) return t;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
async function fe(e = {}) {
|
||||
let t = await ue(e), n = e.frozenLockFile ? {
|
||||
npm: [`ci`],
|
||||
yarn: [`install`, `--immutable`],
|
||||
bun: [`install`, `--frozen-lockfile`],
|
||||
pnpm: [`install`, `--frozen-lockfile`],
|
||||
deno: [`install`, `--frozen`]
|
||||
}[t.packageManager.name] : [`install`];
|
||||
return e.ignoreWorkspace && t.packageManager.name === `pnpm` && n.push(`--ignore-workspace`), t.dry || await le(t.packageManager.command, n, {
|
||||
cwd: t.cwd,
|
||||
silent: t.silent,
|
||||
corepack: t.corepack
|
||||
}), { exec: {
|
||||
command: t.packageManager.command,
|
||||
args: n
|
||||
} };
|
||||
}
|
||||
export { y as a, S as i, ne as n, C as r, oe as t };
|
||||
+2931
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user