@maizzle/framework 6.0.0-rc.1 → 6.0.0-rc.2
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/bin/maizzle.mjs +1 -1
- package/dist/build.mjs +2 -1
- package/dist/build.mjs.map +1 -1
- package/dist/config/index.mjs +7 -0
- package/dist/config/index.mjs.map +1 -1
- package/dist/render/createRenderer.d.mts +2 -0
- package/dist/render/createRenderer.d.mts.map +1 -1
- package/dist/render/createRenderer.mjs +7 -2
- package/dist/render/createRenderer.mjs.map +1 -1
- package/dist/render/index.mjs +2 -1
- package/dist/render/index.mjs.map +1 -1
- package/dist/serve.mjs +2 -1
- package/dist/serve.mjs.map +1 -1
- package/dist/types/config.d.mts +3 -0
- package/dist/types/config.d.mts.map +1 -1
- package/node_modules/@clack/core/CHANGELOG.md +87 -4
- package/node_modules/@clack/core/README.md +1 -1
- package/node_modules/@clack/core/dist/index.d.mts +186 -48
- package/node_modules/@clack/core/dist/index.mjs +10 -14
- package/node_modules/@clack/core/dist/index.mjs.map +1 -1
- package/node_modules/@clack/core/package.json +7 -9
- package/node_modules/@clack/prompts/CHANGELOG.md +171 -7
- package/node_modules/@clack/prompts/README.md +66 -3
- package/node_modules/@clack/prompts/dist/index.d.mts +302 -76
- package/node_modules/@clack/prompts/dist/index.mjs +134 -84
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
- package/node_modules/@clack/prompts/package.json +14 -10
- package/node_modules/citty/LICENSE +0 -15
- package/node_modules/citty/README.md +166 -69
- package/node_modules/citty/dist/index.d.mts +88 -56
- package/node_modules/citty/dist/index.mjs +399 -437
- package/node_modules/citty/package.json +28 -35
- package/node_modules/giget/README.md +59 -11
- package/node_modules/giget/dist/THIRD-PARTY-LICENSES.md +205 -0
- package/node_modules/giget/dist/_chunks/giget.mjs +508 -0
- package/node_modules/giget/dist/_chunks/libs/citty.mjs +269 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.d.mts +1 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.mjs +669 -0
- package/node_modules/giget/dist/_chunks/libs/tar.mjs +2931 -0
- package/node_modules/giget/dist/_chunks/rolldown-runtime.mjs +14 -0
- package/node_modules/giget/dist/cli.d.mts +1 -0
- package/node_modules/giget/dist/cli.mjs +89 -111
- package/node_modules/giget/dist/index.d.mts +46 -35
- package/node_modules/giget/dist/index.mjs +2 -22
- package/node_modules/giget/package.json +32 -45
- package/node_modules/maizzle/README.md +140 -0
- package/node_modules/maizzle/bin/maizzle.mjs +5 -0
- package/node_modules/maizzle/dist/commands/new.d.mts +7 -0
- package/node_modules/maizzle/dist/commands/new.mjs +278 -0
- package/node_modules/{@maizzle/cli → maizzle}/dist/index.d.mts +1 -1
- package/node_modules/maizzle/dist/index.mjs +44 -0
- package/node_modules/{commander → maizzle/node_modules/commander}/Readme.md +94 -67
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/argument.js +5 -4
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/command.js +154 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/help.js +77 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/option.js +16 -3
- package/node_modules/{commander → maizzle/node_modules/commander}/package-support.json +4 -1
- package/node_modules/{commander → maizzle/node_modules/commander}/package.json +8 -8
- package/node_modules/{commander → maizzle/node_modules/commander}/typings/index.d.ts +71 -3
- package/node_modules/{@maizzle/cli → maizzle}/package.json +13 -11
- package/node_modules/tinyexec/README.md +49 -3
- package/node_modules/tinyexec/dist/main.d.mts +25 -14
- package/node_modules/tinyexec/dist/main.mjs +148 -100
- package/node_modules/tinyexec/package.json +9 -8
- package/package.json +3 -3
- package/node_modules/@clack/core/dist/index.cjs +0 -15
- package/node_modules/@clack/core/dist/index.cjs.map +0 -1
- package/node_modules/@clack/core/dist/index.d.cts +0 -211
- package/node_modules/@clack/core/dist/index.d.ts +0 -211
- package/node_modules/@clack/prompts/dist/index.cjs +0 -87
- package/node_modules/@clack/prompts/dist/index.cjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.d.cts +0 -165
- package/node_modules/@clack/prompts/dist/index.d.ts +0 -165
- package/node_modules/@maizzle/cli/README.md +0 -58
- package/node_modules/@maizzle/cli/dist/index.mjs +0 -42
- package/node_modules/citty/dist/index.cjs +0 -475
- package/node_modules/citty/dist/index.d.cts +0 -80
- package/node_modules/citty/dist/index.d.ts +0 -80
- package/node_modules/consola/LICENSE +0 -47
- package/node_modules/consola/README.md +0 -352
- package/node_modules/consola/basic.d.ts +0 -1
- package/node_modules/consola/browser.d.ts +0 -1
- package/node_modules/consola/core.d.ts +0 -1
- package/node_modules/consola/dist/basic.cjs +0 -32
- package/node_modules/consola/dist/basic.d.cts +0 -23
- package/node_modules/consola/dist/basic.d.mts +0 -21
- package/node_modules/consola/dist/basic.d.ts +0 -23
- package/node_modules/consola/dist/basic.mjs +0 -24
- package/node_modules/consola/dist/browser.cjs +0 -84
- package/node_modules/consola/dist/browser.d.cts +0 -23
- package/node_modules/consola/dist/browser.d.mts +0 -21
- package/node_modules/consola/dist/browser.d.ts +0 -23
- package/node_modules/consola/dist/browser.mjs +0 -76
- package/node_modules/consola/dist/chunks/prompt.cjs +0 -288
- package/node_modules/consola/dist/chunks/prompt.mjs +0 -280
- package/node_modules/consola/dist/core.cjs +0 -517
- package/node_modules/consola/dist/core.d.cts +0 -459
- package/node_modules/consola/dist/core.d.mts +0 -459
- package/node_modules/consola/dist/core.d.ts +0 -459
- package/node_modules/consola/dist/core.mjs +0 -512
- package/node_modules/consola/dist/index.cjs +0 -663
- package/node_modules/consola/dist/index.d.cts +0 -24
- package/node_modules/consola/dist/index.d.mts +0 -22
- package/node_modules/consola/dist/index.d.ts +0 -24
- package/node_modules/consola/dist/index.mjs +0 -651
- package/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +0 -75
- package/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +0 -72
- package/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +0 -288
- package/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +0 -312
- package/node_modules/consola/dist/utils.cjs +0 -64
- package/node_modules/consola/dist/utils.d.cts +0 -286
- package/node_modules/consola/dist/utils.d.mts +0 -286
- package/node_modules/consola/dist/utils.d.ts +0 -286
- package/node_modules/consola/dist/utils.mjs +0 -54
- package/node_modules/consola/lib/index.cjs +0 -10
- package/node_modules/consola/package.json +0 -136
- package/node_modules/consola/utils.d.ts +0 -1
- package/node_modules/create-maizzle/README.md +0 -86
- package/node_modules/create-maizzle/bin/create-maizzle.mjs +0 -4
- package/node_modules/create-maizzle/node_modules/@clack/core/CHANGELOG.md +0 -340
- package/node_modules/create-maizzle/node_modules/@clack/core/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/core/README.md +0 -22
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.d.mts +0 -349
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs +0 -11
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/core/package.json +0 -60
- package/node_modules/create-maizzle/node_modules/@clack/prompts/CHANGELOG.md +0 -576
- package/node_modules/create-maizzle/node_modules/@clack/prompts/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/prompts/README.md +0 -270
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.d.mts +0 -391
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs +0 -137
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/prompts/package.json +0 -65
- package/node_modules/create-maizzle/package.json +0 -47
- package/node_modules/create-maizzle/src/index.js +0 -242
- package/node_modules/defu/LICENSE +0 -21
- package/node_modules/defu/README.md +0 -171
- package/node_modules/defu/dist/defu.cjs +0 -77
- package/node_modules/defu/dist/defu.d.cts +0 -31
- package/node_modules/defu/dist/defu.d.mts +0 -29
- package/node_modules/defu/dist/defu.d.ts +0 -31
- package/node_modules/defu/dist/defu.mjs +0 -69
- package/node_modules/defu/lib/defu.cjs +0 -10
- package/node_modules/defu/lib/defu.d.cts +0 -12
- package/node_modules/defu/package.json +0 -48
- package/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -468
- package/node_modules/node-fetch-native/LICENSE +0 -114
- package/node_modules/node-fetch-native/README.md +0 -225
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -2
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -2
- package/node_modules/node-fetch-native/dist/index.cjs +0 -1
- package/node_modules/node-fetch-native/dist/index.mjs +0 -1
- package/node_modules/node-fetch-native/dist/native.cjs +0 -1
- package/node_modules/node-fetch-native/dist/native.mjs +0 -1
- package/node_modules/node-fetch-native/dist/node.cjs +0 -19
- package/node_modules/node-fetch-native/dist/node.mjs +0 -19
- package/node_modules/node-fetch-native/dist/polyfill.cjs +0 -1
- package/node_modules/node-fetch-native/dist/polyfill.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.cjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy.cjs +0 -58
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +0 -1
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -1
- package/node_modules/node-fetch-native/index.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/empty.cjs +0 -0
- package/node_modules/node-fetch-native/lib/empty.mjs +0 -0
- package/node_modules/node-fetch-native/lib/index.cjs +0 -11
- package/node_modules/node-fetch-native/lib/index.d.cts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.mts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.ts +0 -10
- package/node_modules/node-fetch-native/lib/native.cjs +0 -11
- package/node_modules/node-fetch-native/lib/polyfill.d.cts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.mts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/proxy.d.ts +0 -32
- package/node_modules/node-fetch-native/node.d.ts +0 -1
- package/node_modules/node-fetch-native/package.json +0 -138
- package/node_modules/node-fetch-native/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/proxy.d.ts +0 -1
- package/node_modules/nypm/node_modules/citty/LICENSE +0 -21
- package/node_modules/nypm/node_modules/citty/README.md +0 -231
- package/node_modules/nypm/node_modules/citty/dist/index.d.mts +0 -112
- package/node_modules/nypm/node_modules/citty/dist/index.mjs +0 -425
- package/node_modules/nypm/node_modules/citty/package.json +0 -42
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/THIRD-PARTY-LICENSES.md +0 -0
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/_chunks/libs/scule.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/LICENSE +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/component.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/config.ts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/layout.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/template.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/LICENSE +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/esm.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/index.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/error.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/suggestSimilar.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/typings/esm.d.mts +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { parseArgs as e } from "node:util";
|
|
2
|
+
const t = /\d/, n = [
|
|
3
|
+
`-`,
|
|
4
|
+
`_`,
|
|
5
|
+
`/`,
|
|
6
|
+
`.`
|
|
7
|
+
];
|
|
8
|
+
function r(e = ``) {
|
|
9
|
+
if (!t.test(e)) return e !== e.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function i(e, t) {
|
|
12
|
+
let i = t ?? n, a = [];
|
|
13
|
+
if (!e || typeof e != `string`) return a;
|
|
14
|
+
let o = ``, s, c;
|
|
15
|
+
for (let t of e) {
|
|
16
|
+
let e = i.includes(t);
|
|
17
|
+
if (e === !0) {
|
|
18
|
+
a.push(o), o = ``, s = void 0;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
let n = r(t);
|
|
22
|
+
if (c === !1) {
|
|
23
|
+
if (s === !1 && n === !0) {
|
|
24
|
+
a.push(o), o = t, s = n;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (s === !0 && n === !1 && o.length > 1) {
|
|
28
|
+
let e = o.at(-1);
|
|
29
|
+
a.push(o.slice(0, Math.max(0, o.length - 1))), o = e + t, s = n;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
o += t, s = n, c = e;
|
|
34
|
+
}
|
|
35
|
+
return a.push(o), a;
|
|
36
|
+
}
|
|
37
|
+
function a(e) {
|
|
38
|
+
return e ? e[0].toUpperCase() + e.slice(1) : ``;
|
|
39
|
+
}
|
|
40
|
+
function o(e) {
|
|
41
|
+
return e ? e[0].toLowerCase() + e.slice(1) : ``;
|
|
42
|
+
}
|
|
43
|
+
function s(e, t) {
|
|
44
|
+
return e ? (Array.isArray(e) ? e : i(e)).map((e) => a(t?.normalize ? e.toLowerCase() : e)).join(``) : ``;
|
|
45
|
+
}
|
|
46
|
+
function c(e, t) {
|
|
47
|
+
return o(s(e || ``, t));
|
|
48
|
+
}
|
|
49
|
+
function l(e, t) {
|
|
50
|
+
return e ? (Array.isArray(e) ? e : i(e)).map((e) => e.toLowerCase()).join(t ?? `-`) : ``;
|
|
51
|
+
}
|
|
52
|
+
function u(e) {
|
|
53
|
+
return Array.isArray(e) ? e : e === void 0 ? [] : [e];
|
|
54
|
+
}
|
|
55
|
+
function d(e, t = ``) {
|
|
56
|
+
let n = [];
|
|
57
|
+
for (let t of e) for (let [e, r] of t.entries()) n[e] = Math.max(n[e] || 0, r.length);
|
|
58
|
+
return e.map((e) => e.map((e, r) => t + e[r === 0 ? `padStart` : `padEnd`](n[r])).join(` `)).join(`
|
|
59
|
+
`);
|
|
60
|
+
}
|
|
61
|
+
function f(e) {
|
|
62
|
+
return typeof e == `function` ? e() : e;
|
|
63
|
+
}
|
|
64
|
+
var p = class extends Error {
|
|
65
|
+
code;
|
|
66
|
+
constructor(e, t) {
|
|
67
|
+
super(e), this.name = `CLIError`, this.code = t;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function m(t = [], n = {}) {
|
|
71
|
+
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();
|
|
72
|
+
for (let [e, t] of Object.entries(a)) {
|
|
73
|
+
let n = t;
|
|
74
|
+
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);
|
|
75
|
+
}
|
|
76
|
+
let l = {};
|
|
77
|
+
function u(e) {
|
|
78
|
+
if (r.has(e)) return `boolean`;
|
|
79
|
+
let t = c.get(e) || [];
|
|
80
|
+
for (let e of t) if (r.has(e)) return `boolean`;
|
|
81
|
+
return `string`;
|
|
82
|
+
}
|
|
83
|
+
let d = new Set([
|
|
84
|
+
...r,
|
|
85
|
+
...i,
|
|
86
|
+
...Object.keys(a),
|
|
87
|
+
...Object.values(a).flat(),
|
|
88
|
+
...Object.keys(o)
|
|
89
|
+
]);
|
|
90
|
+
for (let e of d) l[e] || (l[e] = {
|
|
91
|
+
type: u(e),
|
|
92
|
+
default: o[e]
|
|
93
|
+
});
|
|
94
|
+
for (let [e, t] of s.entries()) e.length === 1 && l[t] && !l[t].short && (l[t].short = e);
|
|
95
|
+
let f = [], p = {};
|
|
96
|
+
for (let e = 0; e < t.length; e++) {
|
|
97
|
+
let n = t[e];
|
|
98
|
+
if (n === `--`) {
|
|
99
|
+
f.push(...t.slice(e));
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
if (n.startsWith(`--no-`)) {
|
|
103
|
+
let e = n.slice(5);
|
|
104
|
+
p[e] = !0;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
f.push(n);
|
|
108
|
+
}
|
|
109
|
+
let m;
|
|
110
|
+
try {
|
|
111
|
+
m = e({
|
|
112
|
+
args: f,
|
|
113
|
+
options: Object.keys(l).length > 0 ? l : void 0,
|
|
114
|
+
allowPositionals: !0,
|
|
115
|
+
strict: !1
|
|
116
|
+
});
|
|
117
|
+
} catch {
|
|
118
|
+
m = {
|
|
119
|
+
values: {},
|
|
120
|
+
positionals: f
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
let h = { _: [] };
|
|
124
|
+
h._ = m.positionals;
|
|
125
|
+
for (let [e, t] of Object.entries(m.values)) h[e] = t;
|
|
126
|
+
for (let [e] of Object.entries(p)) {
|
|
127
|
+
h[e] = !1;
|
|
128
|
+
let t = s.get(e);
|
|
129
|
+
t && (h[t] = !1);
|
|
130
|
+
let n = c.get(e);
|
|
131
|
+
if (n) for (let e of n) h[e] = !1;
|
|
132
|
+
}
|
|
133
|
+
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]);
|
|
134
|
+
return h;
|
|
135
|
+
}
|
|
136
|
+
const h = (() => {
|
|
137
|
+
let e = globalThis.process?.env ?? {};
|
|
138
|
+
return e.NO_COLOR === `1` || e.TERM === `dumb` || e.TEST || e.CI;
|
|
139
|
+
})(), 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);
|
|
140
|
+
function x(e, t) {
|
|
141
|
+
let n = {
|
|
142
|
+
boolean: [],
|
|
143
|
+
string: [],
|
|
144
|
+
alias: {},
|
|
145
|
+
default: {}
|
|
146
|
+
}, r = S(t);
|
|
147
|
+
for (let e of r) {
|
|
148
|
+
if (e.type === `positional`) continue;
|
|
149
|
+
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);
|
|
150
|
+
let t = c(e.name), r = l(e.name);
|
|
151
|
+
if (t !== e.name || r !== e.name) {
|
|
152
|
+
let i = u(n.alias[e.name] || []);
|
|
153
|
+
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);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
let i = m(e, n), [ ...a] = i._, o = new Proxy(i, { get(e, t) {
|
|
157
|
+
return e[t] ?? e[c(t)] ?? e[l(t)];
|
|
158
|
+
} });
|
|
159
|
+
for (let [, e] of r.entries()) if (e.type === `positional`) {
|
|
160
|
+
let t = a.shift();
|
|
161
|
+
if (t !== void 0) o[e.name] = t;
|
|
162
|
+
else if (e.default === void 0 && e.required !== !1) throw new p(`Missing required positional argument: ${e.name.toUpperCase()}`, `EARG`);
|
|
163
|
+
else o[e.name] = e.default;
|
|
164
|
+
} else if (e.type === `enum`) {
|
|
165
|
+
let t = o[e.name], n = e.options || [];
|
|
166
|
+
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`);
|
|
167
|
+
} else if (e.required && o[e.name] === void 0) throw new p(`Missing required argument: --${e.name}`, `EARG`);
|
|
168
|
+
return o;
|
|
169
|
+
}
|
|
170
|
+
function S(e) {
|
|
171
|
+
let t = [];
|
|
172
|
+
for (let [n, r] of Object.entries(e || {})) t.push({
|
|
173
|
+
...r,
|
|
174
|
+
name: n,
|
|
175
|
+
alias: u(r.alias)
|
|
176
|
+
});
|
|
177
|
+
return t;
|
|
178
|
+
}
|
|
179
|
+
function C(e) {
|
|
180
|
+
return e;
|
|
181
|
+
}
|
|
182
|
+
async function w(e, t) {
|
|
183
|
+
let n = await f(e.args || {}), r = x(t.rawArgs, n), i = {
|
|
184
|
+
rawArgs: t.rawArgs,
|
|
185
|
+
args: r,
|
|
186
|
+
data: t.data,
|
|
187
|
+
cmd: e
|
|
188
|
+
};
|
|
189
|
+
typeof e.setup == `function` && await e.setup(i);
|
|
190
|
+
let a;
|
|
191
|
+
try {
|
|
192
|
+
let n = await f(e.subCommands);
|
|
193
|
+
if (n && Object.keys(n).length > 0) {
|
|
194
|
+
let r = t.rawArgs.findIndex((e) => !e.startsWith(`-`)), i = t.rawArgs[r];
|
|
195
|
+
if (i) {
|
|
196
|
+
if (!n[i]) throw new p(`Unknown command ${v(i)}`, `E_UNKNOWN_COMMAND`);
|
|
197
|
+
let e = await f(n[i]);
|
|
198
|
+
e && await w(e, { rawArgs: t.rawArgs.slice(r + 1) });
|
|
199
|
+
} else if (!e.run) throw new p(`No command specified.`, `E_NO_COMMAND`);
|
|
200
|
+
}
|
|
201
|
+
typeof e.run == `function` && (a = await e.run(i));
|
|
202
|
+
} finally {
|
|
203
|
+
typeof e.cleanup == `function` && await e.cleanup(i);
|
|
204
|
+
}
|
|
205
|
+
return { result: a };
|
|
206
|
+
}
|
|
207
|
+
async function T(e, t, n) {
|
|
208
|
+
let r = await f(e.subCommands);
|
|
209
|
+
if (r && Object.keys(r).length > 0) {
|
|
210
|
+
let n = t.findIndex((e) => !e.startsWith(`-`)), i = t[n], a = await f(r[i]);
|
|
211
|
+
if (a) return T(a, t.slice(n + 1), e);
|
|
212
|
+
}
|
|
213
|
+
return [e, n];
|
|
214
|
+
}
|
|
215
|
+
async function E(e, t) {
|
|
216
|
+
try {
|
|
217
|
+
console.log(await O(e, t) + `
|
|
218
|
+
`);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
console.error(e);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const D = /^no[-A-Z]/;
|
|
224
|
+
async function O(e, t) {
|
|
225
|
+
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 = [];
|
|
226
|
+
for (let e of r) if (e.type === `positional`) {
|
|
227
|
+
let t = e.name.toUpperCase(), n = e.required !== !1 && e.default === void 0, r = e.default ? `="${e.default}"` : ``;
|
|
228
|
+
s.push([
|
|
229
|
+
v(t + r),
|
|
230
|
+
e.description || ``,
|
|
231
|
+
e.valueHint ? `<${e.valueHint}>` : ``
|
|
232
|
+
]), l.push(n ? `<${t}>` : `[${t}]`);
|
|
233
|
+
} else {
|
|
234
|
+
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(`|`)}>` : ``);
|
|
235
|
+
if (o.push([v(n + (t ? ` (required)` : ``)), e.description || ``]), e.type === `boolean` && (e.default === !0 || e.negativeDescription) && !D.test(e.name)) {
|
|
236
|
+
let n = [...(e.alias || []).map((e) => `--no-${e}`), `--no-${e.name}`].join(`, `);
|
|
237
|
+
o.push([v(n + (t ? ` (required)` : ``)), e.negativeDescription || ``]);
|
|
238
|
+
}
|
|
239
|
+
t && l.push(n);
|
|
240
|
+
}
|
|
241
|
+
if (e.subCommands) {
|
|
242
|
+
let t = [], n = await f(e.subCommands);
|
|
243
|
+
for (let [e, r] of Object.entries(n)) {
|
|
244
|
+
let n = await f((await f(r))?.meta);
|
|
245
|
+
n?.hidden || (c.push([v(e), n?.description || ``]), t.push(e));
|
|
246
|
+
}
|
|
247
|
+
l.push(t.join(`|`));
|
|
248
|
+
}
|
|
249
|
+
let u = [], p = n.version || i.version;
|
|
250
|
+
u.push(y(`${n.description} (${a + (p ? ` v${p}` : ``)})`), ``);
|
|
251
|
+
let m = o.length > 0 || s.length > 0;
|
|
252
|
+
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(`
|
|
253
|
+
`);
|
|
254
|
+
}
|
|
255
|
+
async function k(e, t = {}) {
|
|
256
|
+
let n = t.rawArgs || process.argv.slice(2), r = t.showUsage || E;
|
|
257
|
+
try {
|
|
258
|
+
if (n.includes(`--help`) || n.includes(`-h`)) await r(...await T(e, n)), process.exit(0);
|
|
259
|
+
else if (n.length === 1 && n[0] === `--version`) {
|
|
260
|
+
let t = typeof e.meta == `function` ? await e.meta() : await e.meta;
|
|
261
|
+
if (!t?.version) throw new p(`No version specified`, `E_NO_VERSION`);
|
|
262
|
+
console.log(t.version);
|
|
263
|
+
} else await w(e, { rawArgs: n });
|
|
264
|
+
} catch (t) {
|
|
265
|
+
t instanceof p ? (await r(...await T(e, n)), console.error(t.message)) : console.error(t, `
|
|
266
|
+
`), process.exit(1);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
export { k as n, C as t };
|
|
@@ -0,0 +1 @@
|
|
|
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};
|