nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.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.
Files changed (246) hide show
  1. package/README.md +2 -0
  2. package/dist/_build/common.mjs +24924 -52
  3. package/dist/_build/rolldown.mjs +29 -63
  4. package/dist/_build/rollup.mjs +22 -110
  5. package/dist/_build/vite.build.mjs +3 -43
  6. package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
  7. package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
  8. package/dist/_chunks/nitro2.mjs +101 -0
  9. package/dist/_chunks/utils.mjs +254 -0
  10. package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
  11. package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
  12. package/dist/_libs/citty.mjs +140 -110
  13. package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
  14. package/dist/_libs/compatx.d.mts +47 -0
  15. package/dist/_libs/confbox.mjs +388 -799
  16. package/dist/_libs/esbuild.d.mts +20 -0
  17. package/dist/_libs/estree-walker.mjs +1 -144
  18. package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
  19. package/dist/_libs/httpxy.d.mts +79 -0
  20. package/dist/_libs/httpxy.mjs +6 -1
  21. package/dist/_libs/magic-string.d.mts +220 -0
  22. package/dist/_libs/mlly.d.mts +57 -0
  23. package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
  24. package/dist/_libs/pkg-types.d.mts +23 -0
  25. package/dist/_libs/plugin-alias.mjs +4 -2
  26. package/dist/_libs/plugin-inject.mjs +5 -5
  27. package/dist/_libs/plugin-json.mjs +2 -2
  28. package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
  29. package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
  30. package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
  31. package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
  32. package/dist/_libs/remapping.mjs +1 -1
  33. package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
  34. package/dist/_libs/rou3.d.mts +43 -0
  35. package/dist/_libs/rou3.mjs +9 -6
  36. package/dist/_libs/std-env.d.mts +4 -0
  37. package/dist/_libs/tsconfck.mjs +3 -3
  38. package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
  39. package/dist/_libs/unplugin+unimport.d.mts +426 -0
  40. package/dist/_libs/unwasm.d.mts +29 -0
  41. package/dist/_presets.mjs +130 -80
  42. package/dist/builder.d.mts +4 -4
  43. package/dist/builder.mjs +6 -30
  44. package/dist/cli/_chunks/build.mjs +1 -1
  45. package/dist/cli/_chunks/dev.mjs +5 -11
  46. package/dist/cli/_chunks/list.mjs +1 -1
  47. package/dist/cli/_chunks/prepare.mjs +1 -1
  48. package/dist/cli/_chunks/run.mjs +1 -1
  49. package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
  50. package/dist/node_modules/@poppinss/colors/package.json +20 -18
  51. package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
  52. package/dist/node_modules/@poppinss/exception/package.json +19 -16
  53. package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
  54. package/dist/node_modules/@sindresorhus/is/package.json +1 -1
  55. package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
  56. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
  57. package/dist/node_modules/@speed-highlight/core/package.json +2 -2
  58. package/dist/node_modules/hookable/dist/index.mjs +5 -6
  59. package/dist/node_modules/hookable/package.json +13 -13
  60. package/dist/node_modules/ufo/dist/index.mjs +16 -9
  61. package/dist/node_modules/ufo/package.json +15 -14
  62. package/dist/node_modules/unctx/package.json +16 -16
  63. package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
  64. package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
  65. package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
  66. package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
  67. package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
  68. package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
  69. package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
  70. package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
  71. package/dist/node_modules/youch/build/index.js +8 -9
  72. package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
  73. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  74. package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
  75. package/dist/node_modules/youch/package.json +1 -1
  76. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
  77. package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
  78. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
  79. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
  80. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
  81. package/dist/presets/_nitro/runtime/service-worker.mjs +2 -2
  82. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
  83. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
  84. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  85. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
  86. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
  87. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
  88. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
  89. package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
  90. package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
  91. package/dist/presets/bun/runtime/bun.d.mts +1 -1
  92. package/dist/presets/bun/runtime/bun.mjs +7 -8
  93. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
  94. package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
  95. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
  96. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
  97. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
  98. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
  99. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
  100. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
  101. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
  102. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
  103. package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
  104. package/dist/presets/deno/runtime/deno-server.mjs +5 -6
  105. package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
  106. package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
  107. package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
  108. package/dist/presets/netlify/runtime/netlify.mjs +3 -1
  109. package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
  110. package/dist/presets/node/runtime/node-cluster.mjs +5 -6
  111. package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
  112. package/dist/presets/node/runtime/node-middleware.mjs +4 -5
  113. package/dist/presets/node/runtime/node-server.d.mts +1 -1
  114. package/dist/presets/node/runtime/node-server.mjs +5 -6
  115. package/dist/presets/standard/runtime/server.d.mts +1 -1
  116. package/dist/presets/standard/runtime/server.mjs +1 -1
  117. package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
  118. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
  119. package/dist/presets/vercel/runtime/isr.d.mts +2 -0
  120. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  121. package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
  122. package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
  123. package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
  124. package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
  125. package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
  126. package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
  127. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  128. package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
  129. package/dist/runtime/app.d.mts +1 -1
  130. package/dist/runtime/app.mjs +1 -1
  131. package/dist/runtime/internal/app.d.mts +7 -3
  132. package/dist/runtime/internal/app.mjs +29 -22
  133. package/dist/runtime/internal/database.mjs +1 -1
  134. package/dist/runtime/internal/error/dev.d.mts +0 -1
  135. package/dist/runtime/internal/error/dev.mjs +1 -1
  136. package/dist/runtime/internal/route-rules.d.mts +0 -4
  137. package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
  138. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  139. package/dist/runtime/internal/routes/openapi.mjs +3 -3
  140. package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
  141. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  142. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  143. package/dist/runtime/internal/routes/scalar.mjs +4 -4
  144. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  145. package/dist/runtime/internal/routes/swagger.mjs +3 -3
  146. package/dist/runtime/internal/runtime-config.mjs +8 -8
  147. package/dist/runtime/internal/static.mjs +1 -1
  148. package/dist/runtime/internal/storage.mjs +1 -1
  149. package/dist/runtime/internal/task.mjs +1 -1
  150. package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
  151. package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
  152. package/dist/runtime/meta.d.mts +1 -1
  153. package/dist/runtime/meta.mjs +1 -1
  154. package/dist/runtime/nitro.d.mts +0 -3
  155. package/dist/runtime/nitro.mjs +1 -1
  156. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  157. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  158. package/dist/runtime/virtual/database.d.mts +8 -0
  159. package/dist/runtime/virtual/database.mjs +2 -0
  160. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  161. package/dist/runtime/virtual/error-handler.mjs +9 -0
  162. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  163. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  164. package/dist/runtime/virtual/plugins.d.mts +3 -0
  165. package/dist/runtime/virtual/plugins.mjs +2 -0
  166. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  167. package/dist/runtime/virtual/polyfills.mjs +2 -0
  168. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  169. package/dist/runtime/virtual/public-assets.mjs +8 -0
  170. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  171. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  172. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  173. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  174. package/dist/runtime/virtual/routing.d.mts +8 -0
  175. package/dist/runtime/virtual/routing.mjs +11 -0
  176. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  177. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  178. package/dist/runtime/virtual/server-assets.d.mts +6 -0
  179. package/dist/runtime/virtual/server-assets.mjs +12 -0
  180. package/dist/runtime/virtual/storage.d.mts +3 -0
  181. package/dist/runtime/virtual/storage.mjs +5 -0
  182. package/dist/runtime/virtual/tasks.d.mts +10 -0
  183. package/dist/runtime/virtual/tasks.mjs +3 -0
  184. package/dist/types/index.d.mts +292 -371
  185. package/dist/types/index.mjs +10 -0
  186. package/dist/vite.d.mts +7 -12
  187. package/dist/vite.mjs +734 -41
  188. package/lib/vite.types.d.mts +26 -0
  189. package/lib/vite.types.mjs +2 -0
  190. package/package.json +82 -53
  191. package/dist/_build/common2.mjs +0 -772
  192. package/dist/_build/vite.plugin.mjs +0 -768
  193. package/dist/_chunks/ANM1K1bE.mjs +0 -304
  194. package/dist/_chunks/BX9-zVkM.mjs +0 -59
  195. package/dist/_chunks/C7CbzoI1.mjs +0 -39
  196. package/dist/_libs/acorn.mjs +0 -5034
  197. package/dist/_libs/c12.mjs +0 -2858
  198. package/dist/_libs/commondir.mjs +0 -22
  199. package/dist/_libs/deepmerge.mjs +0 -86
  200. package/dist/_libs/dot-prop.mjs +0 -138
  201. package/dist/_libs/duplexer.mjs +0 -71
  202. package/dist/_libs/etag.mjs +0 -80
  203. package/dist/_libs/fdir.mjs +0 -514
  204. package/dist/_libs/function-bind.mjs +0 -63
  205. package/dist/_libs/giget.mjs +0 -19289
  206. package/dist/_libs/gzip-size.mjs +0 -21
  207. package/dist/_libs/hasown.mjs +0 -14
  208. package/dist/_libs/is-core-module.mjs +0 -220
  209. package/dist/_libs/is-module.mjs +0 -13
  210. package/dist/_libs/is-reference.mjs +0 -32
  211. package/dist/_libs/js-tokens.mjs +0 -382
  212. package/dist/_libs/knitwork.mjs +0 -124
  213. package/dist/_libs/local-pkg.mjs +0 -1686
  214. package/dist/_libs/magic-string.mjs +0 -939
  215. package/dist/_libs/mime.mjs +0 -1391
  216. package/dist/_libs/node-fetch-native.mjs +0 -173
  217. package/dist/_libs/path-parse.mjs +0 -47
  218. package/dist/_libs/pathe.mjs +0 -41
  219. package/dist/_libs/picomatch.mjs +0 -1673
  220. package/dist/_libs/plugin-replace.mjs +0 -104
  221. package/dist/_libs/pretty-bytes.mjs +0 -116
  222. package/dist/_libs/std-env.mjs +0 -158
  223. package/dist/_libs/strip-literal.mjs +0 -51
  224. package/dist/_libs/tinyglobby.mjs +0 -292
  225. package/dist/_libs/untyped.mjs +0 -271
  226. package/dist/_libs/unwasm.mjs +0 -5836
  227. package/dist/cli/_chunks/detect-acorn.mjs +0 -12
  228. package/dist/cli/_chunks/dist.mjs +0 -3
  229. package/dist/cli/_chunks/dist2.mjs +0 -3
  230. package/dist/cli/_chunks/dist3.mjs +0 -3
  231. package/dist/cli/_chunks/dist4.mjs +0 -4
  232. package/dist/cli/_chunks/dist5.mjs +0 -4
  233. package/dist/cli/_chunks/esm.mjs +0 -3
  234. package/dist/cli/_chunks/json5.mjs +0 -4
  235. package/dist/cli/_chunks/jsonc.mjs +0 -4
  236. package/dist/cli/_chunks/multipart-parser.mjs +0 -6
  237. package/dist/cli/_chunks/toml.mjs +0 -4
  238. package/dist/cli/_chunks/yaml.mjs +0 -4
  239. package/dist/node_modules/kleur/index.js +0 -110
  240. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
  241. package/lib/deps/ofetch.mjs +0 -1
  242. package/lib/deps/ofetch.mts +0 -1
  243. /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
  244. /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
  245. /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
  246. /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
@@ -1,26 +1,6 @@
1
- import consola$1 from "consola";
2
- import { colors } from "consola/utils";
1
+ import { parseArgs } from "node:util";
3
2
 
4
- //#region node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs
5
- function toArray(val) {
6
- if (Array.isArray(val)) return val;
7
- return val === void 0 ? [] : [val];
8
- }
9
- function formatLineColumns(lines, linePrefix = "") {
10
- const maxLengh = [];
11
- for (const line of lines) for (const [i, element] of line.entries()) maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
12
- return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])).join(" ")).join("\n");
13
- }
14
- function resolveValue(input) {
15
- return typeof input === "function" ? input() : input;
16
- }
17
- var CLIError = class extends Error {
18
- constructor(message, code) {
19
- super(message);
20
- this.code = code;
21
- this.name = "CLIError";
22
- }
23
- };
3
+ //#region node_modules/.pnpm/citty@0.2.0/node_modules/citty/dist/_chunks/libs/scule.mjs
24
4
  const NUMBER_CHAR_RE = /\d/;
25
5
  const STR_SPLITTERS = [
26
6
  "-",
@@ -85,101 +65,136 @@ function camelCase(str, opts) {
85
65
  function kebabCase(str, joiner) {
86
66
  return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
87
67
  }
88
- function toArr(any) {
89
- return any == void 0 ? [] : Array.isArray(any) ? any : [any];
68
+
69
+ //#endregion
70
+ //#region node_modules/.pnpm/citty@0.2.0/node_modules/citty/dist/index.mjs
71
+ function toArray(val) {
72
+ if (Array.isArray(val)) return val;
73
+ return val === void 0 ? [] : [val];
90
74
  }
91
- function toVal(out, key, val, opts) {
92
- let x;
93
- const old = out[key];
94
- const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
95
- out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
75
+ function formatLineColumns(lines, linePrefix = "") {
76
+ const maxLength = [];
77
+ for (const line of lines) for (const [i, element] of line.entries()) maxLength[i] = Math.max(maxLength[i] || 0, element.length);
78
+ return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLength[i])).join(" ")).join("\n");
96
79
  }
97
- function parseRawArgs(args = [], opts = {}) {
98
- let k;
99
- let arr;
100
- let arg;
101
- let name;
102
- let val;
103
- const out = { _: [] };
104
- let i = 0;
105
- let j = 0;
106
- let idx = 0;
107
- const len = args.length;
108
- const alibi = opts.alias !== void 0;
109
- const strict = opts.unknown !== void 0;
110
- const defaults = opts.default !== void 0;
111
- opts.alias = opts.alias || {};
112
- opts.string = toArr(opts.string);
113
- opts.boolean = toArr(opts.boolean);
114
- if (alibi) for (k in opts.alias) {
115
- arr = opts.alias[k] = toArr(opts.alias[k]);
116
- for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
117
- }
118
- for (i = opts.boolean.length; i-- > 0;) {
119
- arr = opts.alias[opts.boolean[i]] || [];
120
- for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
121
- }
122
- for (i = opts.string.length; i-- > 0;) {
123
- arr = opts.alias[opts.string[i]] || [];
124
- for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
80
+ function resolveValue(input) {
81
+ return typeof input === "function" ? input() : input;
82
+ }
83
+ var CLIError = class extends Error {
84
+ code;
85
+ constructor(message, code) {
86
+ super(message);
87
+ this.name = "CLIError";
88
+ this.code = code;
125
89
  }
126
- if (defaults) for (k in opts.default) {
127
- name = typeof opts.default[k];
128
- arr = opts.alias[k] = opts.alias[k] || [];
129
- if (opts[name] !== void 0) {
130
- opts[name].push(k);
131
- for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
90
+ };
91
+ function parseRawArgs(args = [], opts = {}) {
92
+ const booleans = new Set(opts.boolean || []);
93
+ const strings = new Set(opts.string || []);
94
+ const aliasMap = opts.alias || {};
95
+ const defaults = opts.default || {};
96
+ const aliasToMain = /* @__PURE__ */ new Map();
97
+ const mainToAliases = /* @__PURE__ */ new Map();
98
+ for (const [key, value] of Object.entries(aliasMap)) {
99
+ const targets = value;
100
+ for (const target of targets) {
101
+ aliasToMain.set(key, target);
102
+ if (!mainToAliases.has(target)) mainToAliases.set(target, []);
103
+ mainToAliases.get(target).push(key);
104
+ aliasToMain.set(target, key);
105
+ if (!mainToAliases.has(key)) mainToAliases.set(key, []);
106
+ mainToAliases.get(key).push(target);
132
107
  }
133
108
  }
134
- const keys = strict ? Object.keys(opts.alias) : [];
135
- for (i = 0; i < len; i++) {
136
- arg = args[i];
109
+ const options = {};
110
+ function getType(name) {
111
+ if (booleans.has(name)) return "boolean";
112
+ const aliases = mainToAliases.get(name) || [];
113
+ for (const alias of aliases) if (booleans.has(alias)) return "boolean";
114
+ return "string";
115
+ }
116
+ const allOptions = new Set([
117
+ ...booleans,
118
+ ...strings,
119
+ ...Object.keys(aliasMap),
120
+ ...Object.values(aliasMap).flat(),
121
+ ...Object.keys(defaults)
122
+ ]);
123
+ for (const name of allOptions) if (!options[name]) options[name] = {
124
+ type: getType(name),
125
+ default: defaults[name]
126
+ };
127
+ for (const [alias, main] of aliasToMain.entries()) if (alias.length === 1 && options[main] && !options[main].short) options[main].short = alias;
128
+ const processedArgs = [];
129
+ const negatedFlags = {};
130
+ for (let i = 0; i < args.length; i++) {
131
+ const arg = args[i];
137
132
  if (arg === "--") {
138
- out._ = out._.concat(args.slice(++i));
133
+ processedArgs.push(...args.slice(i));
139
134
  break;
140
135
  }
141
- for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
142
- if (j === 0) out._.push(arg);
143
- else if (arg.substring(j, j + 3) === "no-") {
144
- name = arg.slice(Math.max(0, j + 3));
145
- if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
146
- out[name] = false;
147
- } else {
148
- for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
149
- name = arg.substring(j, idx);
150
- val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
151
- arr = j === 2 ? [name] : name;
152
- for (idx = 0; idx < arr.length; idx++) {
153
- name = arr[idx];
154
- if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
155
- toVal(out, name, idx + 1 < arr.length || val, opts);
156
- }
136
+ if (arg.startsWith("--no-")) {
137
+ const flagName = arg.slice(5);
138
+ negatedFlags[flagName] = true;
139
+ continue;
157
140
  }
141
+ processedArgs.push(arg);
158
142
  }
159
- if (defaults) {
160
- for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
143
+ let parsed;
144
+ try {
145
+ parsed = parseArgs({
146
+ args: processedArgs,
147
+ options: Object.keys(options).length > 0 ? options : void 0,
148
+ allowPositionals: true,
149
+ strict: false
150
+ });
151
+ } catch {
152
+ parsed = {
153
+ values: {},
154
+ positionals: processedArgs
155
+ };
161
156
  }
162
- if (alibi) for (k in out) {
163
- arr = opts.alias[k] || [];
164
- while (arr.length > 0) out[arr.shift()] = out[k];
157
+ const out = { _: [] };
158
+ out._ = parsed.positionals;
159
+ for (const [key, value] of Object.entries(parsed.values)) out[key] = value;
160
+ for (const [name] of Object.entries(negatedFlags)) out[name] = false;
161
+ for (const [alias, main] of aliasToMain.entries()) {
162
+ if (out[alias] !== void 0 && out[main] === void 0) out[main] = out[alias];
163
+ if (out[main] !== void 0 && out[alias] === void 0) out[alias] = out[main];
165
164
  }
166
165
  return out;
167
166
  }
168
- function parseArgs(rawArgs, argsDef) {
167
+ const noColor = /* @__PURE__ */ (() => {
168
+ const env = globalThis.process?.env ?? {};
169
+ return env.NO_COLOR === "1" || env.TERM === "dumb" || env.TEST || env.CI;
170
+ })();
171
+ const _c = (c, r = 39) => (t) => noColor ? t : `\u001B[${c}m${t}\u001B[${r}m`;
172
+ const bold = /* @__PURE__ */ _c(1, 22);
173
+ const cyan = /* @__PURE__ */ _c(36);
174
+ const gray = /* @__PURE__ */ _c(90);
175
+ const underline = /* @__PURE__ */ _c(4, 24);
176
+ function parseArgs$1(rawArgs, argsDef) {
169
177
  const parseOptions = {
170
178
  boolean: [],
171
179
  string: [],
172
- mixed: [],
173
180
  alias: {},
174
181
  default: {}
175
182
  };
176
183
  const args = resolveArgs(argsDef);
177
184
  for (const arg of args) {
178
185
  if (arg.type === "positional") continue;
179
- if (arg.type === "string") parseOptions.string.push(arg.name);
186
+ if (arg.type === "string" || arg.type === "enum") parseOptions.string.push(arg.name);
180
187
  else if (arg.type === "boolean") parseOptions.boolean.push(arg.name);
181
188
  if (arg.default !== void 0) parseOptions.default[arg.name] = arg.default;
182
189
  if (arg.alias) parseOptions.alias[arg.name] = arg.alias;
190
+ const camelName = camelCase(arg.name);
191
+ const kebabName = kebabCase(arg.name);
192
+ if (camelName !== arg.name || kebabName !== arg.name) {
193
+ const existingAliases = toArray(parseOptions.alias[arg.name] || []);
194
+ if (camelName !== arg.name && !existingAliases.includes(camelName)) existingAliases.push(camelName);
195
+ if (kebabName !== arg.name && !existingAliases.includes(kebabName)) existingAliases.push(kebabName);
196
+ if (existingAliases.length > 0) parseOptions.alias[arg.name] = existingAliases;
197
+ }
183
198
  }
184
199
  const parsed = parseRawArgs(rawArgs, parseOptions);
185
200
  const [ ...positionalArguments] = parsed._;
@@ -191,6 +206,10 @@ function parseArgs(rawArgs, argsDef) {
191
206
  if (nextPositionalArgument !== void 0) parsedArgsProxy[arg.name] = nextPositionalArgument;
192
207
  else if (arg.default === void 0 && arg.required !== false) throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
193
208
  else parsedArgsProxy[arg.name] = arg.default;
209
+ } else if (arg.type === "enum") {
210
+ const argument = parsedArgsProxy[arg.name];
211
+ const options = arg.options || [];
212
+ if (argument !== void 0 && options.length > 0 && !options.includes(argument)) throw new CLIError(`Invalid value for argument: ${cyan(`--${arg.name}`)} (${cyan(argument)}). Expected one of: ${options.map((o) => cyan(o)).join(", ")}.`, "EARG");
194
213
  } else if (arg.required && parsedArgsProxy[arg.name] === void 0) throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
195
214
  return parsedArgsProxy;
196
215
  }
@@ -208,7 +227,7 @@ function defineCommand(def) {
208
227
  }
209
228
  async function runCommand(cmd, opts) {
210
229
  const cmdArgs = await resolveValue(cmd.args || {});
211
- const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
230
+ const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
212
231
  const context = {
213
232
  rawArgs: opts.rawArgs,
214
233
  args: parsedArgs,
@@ -223,7 +242,7 @@ async function runCommand(cmd, opts) {
223
242
  const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith("-"));
224
243
  const subCommandName = opts.rawArgs[subCommandArgIndex];
225
244
  if (subCommandName) {
226
- if (!subCommands[subCommandName]) throw new CLIError(`Unknown command \`${subCommandName}\``, "E_UNKNOWN_COMMAND");
245
+ if (!subCommands[subCommandName]) throw new CLIError(`Unknown command ${cyan(subCommandName)}`, "E_UNKNOWN_COMMAND");
227
246
  const subCommand = await resolveValue(subCommands[subCommandName]);
228
247
  if (subCommand) await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
229
248
  } else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
@@ -246,11 +265,12 @@ async function resolveSubCommand(cmd, rawArgs, parent) {
246
265
  }
247
266
  async function showUsage(cmd, parent) {
248
267
  try {
249
- consola$1.log(await renderUsage(cmd, parent) + "\n");
268
+ console.log(await renderUsage(cmd, parent) + "\n");
250
269
  } catch (error) {
251
- consola$1.error(error);
270
+ console.error(error);
252
271
  }
253
272
  }
273
+ const negativePrefixRe = /^no[-A-Z]/;
254
274
  async function renderUsage(cmd, parent) {
255
275
  const cmdMeta = await resolveValue(cmd.meta || {});
256
276
  const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
@@ -265,15 +285,24 @@ async function renderUsage(cmd, parent) {
265
285
  const isRequired = arg.required !== false && arg.default === void 0;
266
286
  const defaultHint = arg.default ? `="${arg.default}"` : "";
267
287
  posLines.push([
268
- "`" + name + defaultHint + "`",
288
+ cyan(name + defaultHint),
269
289
  arg.description || "",
270
290
  arg.valueHint ? `<${arg.valueHint}>` : ""
271
291
  ]);
272
292
  usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
273
293
  } else {
274
294
  const isRequired = arg.required === true && arg.default === void 0;
275
- const argStr = (arg.type === "boolean" && arg.default === true ? [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ")) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
276
- argLines.push(["`" + argStr + (isRequired ? " (required)" : "") + "`", arg.description || ""]);
295
+ const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "") + (arg.type === "enum" && arg.options ? `=<${arg.options.join("|")}>` : "");
296
+ argLines.push([cyan(argStr + (isRequired ? " (required)" : "")), arg.description || ""]);
297
+ /**
298
+ * print negative boolean arg variant usage when
299
+ * - enabled by default or has `negativeDescription`
300
+ * - not prefixed with `no-` or `no[A-Z]`
301
+ */
302
+ if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
303
+ const negativeArgStr = [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ");
304
+ argLines.push([cyan(negativeArgStr + (isRequired ? " (required)" : "")), arg.negativeDescription || ""]);
305
+ }
277
306
  if (isRequired) usageLine.push(argStr);
278
307
  }
279
308
  if (cmd.subCommands) {
@@ -281,30 +310,31 @@ async function renderUsage(cmd, parent) {
281
310
  const subCommands = await resolveValue(cmd.subCommands);
282
311
  for (const [name, sub] of Object.entries(subCommands)) {
283
312
  const meta = await resolveValue((await resolveValue(sub))?.meta);
284
- commandsLines.push([`\`${name}\``, meta?.description || ""]);
313
+ if (meta?.hidden) continue;
314
+ commandsLines.push([cyan(name), meta?.description || ""]);
285
315
  commandNames.push(name);
286
316
  }
287
317
  usageLine.push(commandNames.join("|"));
288
318
  }
289
319
  const usageLines = [];
290
320
  const version = cmdMeta.version || parentMeta.version;
291
- usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
321
+ usageLines.push(gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
292
322
  const hasOptions = argLines.length > 0 || posLines.length > 0;
293
- usageLines.push(`${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``, "");
323
+ usageLines.push(`${underline(bold("USAGE"))} ${cyan(`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}`)}`, "");
294
324
  if (posLines.length > 0) {
295
- usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
325
+ usageLines.push(underline(bold("ARGUMENTS")), "");
296
326
  usageLines.push(formatLineColumns(posLines, " "));
297
327
  usageLines.push("");
298
328
  }
299
329
  if (argLines.length > 0) {
300
- usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
330
+ usageLines.push(underline(bold("OPTIONS")), "");
301
331
  usageLines.push(formatLineColumns(argLines, " "));
302
332
  usageLines.push("");
303
333
  }
304
334
  if (commandsLines.length > 0) {
305
- usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
335
+ usageLines.push(underline(bold("COMMANDS")), "");
306
336
  usageLines.push(formatLineColumns(commandsLines, " "));
307
- usageLines.push("", `Use \`${commandName} <command> --help\` for more information about a command.`);
337
+ usageLines.push("", `Use ${cyan(`${commandName} <command> --help`)} for more information about a command.`);
308
338
  }
309
339
  return usageLines.filter((l) => typeof l === "string").join("\n");
310
340
  }
@@ -318,13 +348,13 @@ async function runMain(cmd, opts = {}) {
318
348
  } else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
319
349
  const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
320
350
  if (!meta?.version) throw new CLIError("No version specified", "E_NO_VERSION");
321
- consola$1.log(meta.version);
351
+ console.log(meta.version);
322
352
  } else await runCommand(cmd, { rawArgs });
323
353
  } catch (error) {
324
- const isCLIError = error instanceof CLIError;
325
- if (!isCLIError) consola$1.error(error, "\n");
326
- if (isCLIError) await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
327
- consola$1.error(error.message);
354
+ if (error instanceof CLIError) {
355
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
356
+ console.error(error.message);
357
+ } else console.error(error, "\n");
328
358
  process.exit(1);
329
359
  }
330
360
  }