nitro 2.2.28 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +11 -259
  3. package/dist/_chunks/app.mjs +19797 -0
  4. package/dist/_chunks/build.mjs +84 -0
  5. package/dist/_chunks/build2.mjs +318 -0
  6. package/dist/_chunks/build3.mjs +6452 -0
  7. package/dist/_chunks/detect-acorn.mjs +503 -0
  8. package/dist/_chunks/index.mjs +22242 -0
  9. package/dist/_chunks/index2.mjs +297 -0
  10. package/dist/_chunks/index3.mjs +1058 -0
  11. package/dist/_chunks/index4.mjs +1206 -0
  12. package/dist/_chunks/info.mjs +11157 -0
  13. package/dist/_chunks/json5.mjs +68 -0
  14. package/dist/_chunks/jsonc.mjs +51 -0
  15. package/dist/_chunks/pathe.M-eThtNZ.mjs +204 -0
  16. package/dist/_chunks/plugin.mjs +960 -0
  17. package/dist/_chunks/server.mjs +254 -0
  18. package/dist/_chunks/snapshot.mjs +284 -0
  19. package/dist/_chunks/toml.mjs +259 -0
  20. package/dist/_chunks/yaml.mjs +86 -0
  21. package/dist/cli/build.mjs +54 -0
  22. package/dist/cli/common.mjs +13 -0
  23. package/dist/cli/dev.mjs +95 -0
  24. package/dist/cli/index.d.mts +1 -0
  25. package/dist/cli/index.mjs +477 -0
  26. package/dist/cli/index2.mjs +17 -0
  27. package/dist/cli/list.mjs +34 -0
  28. package/dist/cli/prepare.mjs +24 -0
  29. package/dist/cli/run.mjs +60 -0
  30. package/dist/index.d.mts +52 -0
  31. package/dist/index.mjs +55 -0
  32. package/dist/node_modules/@poppinss/colors/build/index.js +169 -0
  33. package/dist/node_modules/@poppinss/colors/package.json +116 -0
  34. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  35. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  36. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +717 -0
  37. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  38. package/dist/node_modules/@poppinss/exception/build/index.js +63 -0
  39. package/dist/node_modules/@poppinss/exception/package.json +106 -0
  40. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1313 -0
  41. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  42. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  43. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  44. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  45. package/dist/node_modules/@speed-highlight/core/package.json +90 -0
  46. package/dist/node_modules/cookie/dist/index.js +239 -0
  47. package/dist/node_modules/cookie/package.json +42 -0
  48. package/dist/node_modules/croner/dist/croner.js +1 -0
  49. package/dist/node_modules/croner/package.json +63 -0
  50. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  51. package/dist/node_modules/defu/package.json +43 -0
  52. package/dist/node_modules/destr/dist/index.mjs +72 -0
  53. package/dist/node_modules/destr/package.json +47 -0
  54. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  55. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  56. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  57. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  58. package/dist/node_modules/get-port-please/package.json +39 -0
  59. package/dist/node_modules/hookable/dist/index.mjs +290 -0
  60. package/dist/node_modules/hookable/package.json +49 -0
  61. package/dist/node_modules/kleur/index.js +110 -0
  62. package/dist/node_modules/kleur/index.mjs +110 -0
  63. package/dist/node_modules/kleur/package.json +51 -0
  64. package/dist/node_modules/klona/dist/index.mjs +81 -0
  65. package/dist/node_modules/klona/full/index.mjs +53 -0
  66. package/dist/node_modules/klona/package.json +74 -0
  67. package/dist/node_modules/scule/dist/index.mjs +80 -0
  68. package/dist/node_modules/scule/package.json +43 -0
  69. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  70. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  71. package/dist/node_modules/source-map/lib/base64.js +19 -0
  72. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  73. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  74. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  75. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  76. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  77. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  78. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  79. package/dist/node_modules/source-map/lib/url.js +13 -0
  80. package/dist/node_modules/source-map/lib/util.js +444 -0
  81. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  82. package/dist/node_modules/source-map/package.json +79 -0
  83. package/dist/node_modules/source-map/source-map.js +10 -0
  84. package/dist/node_modules/std-env/dist/index.mjs +1 -0
  85. package/dist/node_modules/std-env/package.json +46 -0
  86. package/dist/node_modules/supports-color/index.js +202 -0
  87. package/dist/node_modules/supports-color/package.json +64 -0
  88. package/dist/node_modules/ufo/dist/index.mjs +638 -0
  89. package/dist/node_modules/ufo/package.json +47 -0
  90. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  91. package/dist/node_modules/unctx/package.json +67 -0
  92. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +42 -0
  93. package/dist/node_modules/youch/build/chunk-4XB2BYKC.js +85 -0
  94. package/dist/node_modules/youch/build/chunk-4YEN7HVQ.js +61 -0
  95. package/dist/node_modules/youch/build/chunk-EUJBVOYB.js +83 -0
  96. package/dist/node_modules/youch/build/chunk-HFSXRSKS.js +85 -0
  97. package/dist/node_modules/youch/build/chunk-JAN2TFI2.js +222 -0
  98. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +6 -0
  99. package/dist/node_modules/youch/build/chunk-PINJDICN.js +72 -0
  100. package/dist/node_modules/youch/build/chunk-PUHGL6HA.js +41 -0
  101. package/dist/node_modules/youch/build/chunk-VE4LENUR.js +45 -0
  102. package/dist/node_modules/youch/build/index.js +352 -0
  103. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  104. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  105. package/dist/node_modules/youch/build/public/error_info/style.css +144 -0
  106. package/dist/node_modules/youch/build/public/error_stack/script.js +74 -0
  107. package/dist/node_modules/youch/build/public/error_stack/style.css +220 -0
  108. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  109. package/dist/node_modules/youch/build/public/header/script.js +16 -0
  110. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  111. package/dist/node_modules/youch/build/public/layout/script.js +20 -0
  112. package/dist/node_modules/youch/build/public/layout/style.css +431 -0
  113. package/dist/node_modules/youch/package.json +133 -0
  114. package/dist/node_modules/youch-core/build/index.js +316 -0
  115. package/dist/node_modules/youch-core/package.json +124 -0
  116. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  117. package/dist/presets/_nitro/runtime/nitro-dev.mjs +62 -0
  118. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +3 -0
  119. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +18 -0
  120. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  121. package/dist/presets/_nitro/runtime/service-worker.mjs +21 -0
  122. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  123. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +13 -0
  124. package/dist/presets/aws-lambda/runtime/_utils.d.mts +18 -0
  125. package/dist/presets/aws-lambda/runtime/_utils.mjs +102 -0
  126. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +3 -0
  127. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +33 -0
  128. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +3 -0
  129. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
  130. package/dist/presets/azure/runtime/_utils.d.mts +2 -0
  131. package/dist/presets/azure/runtime/_utils.mjs +50 -0
  132. package/dist/presets/azure/runtime/azure-swa.d.mts +5 -0
  133. package/dist/presets/azure/runtime/azure-swa.mjs +28 -0
  134. package/dist/presets/bun/runtime/bun.d.mts +1 -0
  135. package/dist/presets/bun/runtime/bun.mjs +27 -0
  136. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +13 -0
  137. package/dist/presets/cloudflare/runtime/_module-handler.mjs +93 -0
  138. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +19 -0
  139. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +74 -0
  140. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +9 -0
  141. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +20 -0
  142. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +20 -0
  143. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +47 -0
  144. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +3 -0
  145. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -0
  146. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
  147. package/dist/presets/deno/runtime/deno-deploy.mjs +17 -0
  148. package/dist/presets/deno/runtime/deno-server.d.mts +6 -0
  149. package/dist/presets/deno/runtime/deno-server.mjs +59 -0
  150. package/dist/presets/netlify/runtime/netlify-edge.d.mts +3 -0
  151. package/dist/presets/netlify/runtime/netlify-edge.mjs +17 -0
  152. package/dist/presets/netlify/runtime/netlify.d.mts +3 -0
  153. package/dist/presets/netlify/runtime/netlify.mjs +24 -0
  154. package/dist/presets/node/runtime/node-cluster.d.mts +1 -0
  155. package/dist/presets/node/runtime/node-cluster.mjs +58 -0
  156. package/dist/presets/node/runtime/node-middleware.d.mts +4 -0
  157. package/dist/presets/node/runtime/node-middleware.mjs +14 -0
  158. package/dist/presets/node/runtime/node-server.d.mts +3 -0
  159. package/dist/presets/node/runtime/node-server.mjs +44 -0
  160. package/dist/presets/standard/runtime/server.d.mts +5 -0
  161. package/dist/presets/standard/runtime/server.mjs +6 -0
  162. package/dist/presets/stormkit/runtime/stormkit.d.mts +21 -0
  163. package/dist/presets/stormkit/runtime/stormkit.mjs +28 -0
  164. package/dist/presets/vercel/runtime/vercel.d.mts +8 -0
  165. package/dist/presets/vercel/runtime/vercel.mjs +17 -0
  166. package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -0
  167. package/dist/presets/winterjs/runtime/winterjs.mjs +87 -0
  168. package/dist/presets/zeabur/runtime/zeabur.d.mts +3 -0
  169. package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
  170. package/dist/presets.mjs +2460 -0
  171. package/dist/runtime/index.d.mts +11 -0
  172. package/dist/runtime/index.mjs +17 -0
  173. package/dist/runtime/internal/app.d.mts +2 -0
  174. package/dist/runtime/internal/app.mjs +153 -0
  175. package/dist/runtime/internal/cache.d.mts +7 -0
  176. package/dist/runtime/internal/cache.mjs +236 -0
  177. package/dist/runtime/internal/context.d.mts +12 -0
  178. package/dist/runtime/internal/context.mjs +17 -0
  179. package/dist/runtime/internal/database.d.mts +2 -0
  180. package/dist/runtime/internal/database.mjs +14 -0
  181. package/dist/runtime/internal/debug.d.mts +2 -0
  182. package/dist/runtime/internal/debug.mjs +5 -0
  183. package/dist/runtime/internal/empty.d.mts +0 -0
  184. package/dist/runtime/internal/empty.mjs +0 -0
  185. package/dist/runtime/internal/error/dev.d.mts +9 -0
  186. package/dist/runtime/internal/error/dev.mjs +122 -0
  187. package/dist/runtime/internal/error/prod.d.mts +8 -0
  188. package/dist/runtime/internal/error/prod.mjs +62 -0
  189. package/dist/runtime/internal/error/utils.d.mts +8 -0
  190. package/dist/runtime/internal/error/utils.mjs +3 -0
  191. package/dist/runtime/internal/index.d.mts +3 -0
  192. package/dist/runtime/internal/index.mjs +3 -0
  193. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +16 -0
  194. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +213 -0
  195. package/dist/runtime/internal/meta.d.mts +2 -0
  196. package/dist/runtime/internal/meta.mjs +3 -0
  197. package/dist/runtime/internal/plugin.d.mts +3 -0
  198. package/dist/runtime/internal/plugin.mjs +4 -0
  199. package/dist/runtime/internal/renderer.d.mts +3 -0
  200. package/dist/runtime/internal/renderer.mjs +36 -0
  201. package/dist/runtime/internal/route-rules.d.mts +8 -0
  202. package/dist/runtime/internal/route-rules.mjs +62 -0
  203. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  204. package/dist/runtime/internal/routes/dev-tasks.mjs +23 -0
  205. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  206. package/dist/runtime/internal/routes/openapi.mjs +100 -0
  207. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  208. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  209. package/dist/runtime/internal/routes/renderer-template.dev.mjs +21 -0
  210. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  211. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  212. package/dist/runtime/internal/routes/scalar.mjs +194 -0
  213. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  214. package/dist/runtime/internal/routes/swagger.mjs +44 -0
  215. package/dist/runtime/internal/runtime-config.d.mts +9 -0
  216. package/dist/runtime/internal/runtime-config.mjs +49 -0
  217. package/dist/runtime/internal/shutdown.d.mts +9 -0
  218. package/dist/runtime/internal/shutdown.mjs +34 -0
  219. package/dist/runtime/internal/static.d.mts +3 -0
  220. package/dist/runtime/internal/static.mjs +77 -0
  221. package/dist/runtime/internal/storage.d.mts +2 -0
  222. package/dist/runtime/internal/storage.mjs +6 -0
  223. package/dist/runtime/internal/task.d.mts +17 -0
  224. package/dist/runtime/internal/task.mjs +73 -0
  225. package/dist/runtime/internal/utils.d.mts +1 -0
  226. package/dist/runtime/internal/utils.mjs +15 -0
  227. package/dist/runtime/internal/vite/dev-entry.d.mts +1 -0
  228. package/dist/runtime/internal/vite/dev-entry.mjs +6 -0
  229. package/dist/runtime/internal/vite/dev-worker.d.mts +1 -0
  230. package/dist/runtime/internal/vite/dev-worker.mjs +362 -0
  231. package/dist/runtime/internal/vite/prod-setup.d.mts +4 -0
  232. package/dist/runtime/internal/vite/prod-setup.mjs +55 -0
  233. package/dist/runtime/internal/vite/ssr-renderer.d.mts +4 -0
  234. package/dist/runtime/internal/vite/ssr-renderer.mjs +4 -0
  235. package/dist/types/index.d.mts +2810 -0
  236. package/dist/types/index.mjs +1 -0
  237. package/dist/vite.d.mts +59 -0
  238. package/dist/vite.mjs +68 -0
  239. package/lib/config.d.mts +9 -0
  240. package/lib/config.mjs +5 -0
  241. package/lib/deps/h3.d.mts +1 -0
  242. package/lib/deps/h3.mjs +1 -0
  243. package/lib/deps/ofetch.mjs +1 -0
  244. package/lib/deps/ofetch.mts +1 -0
  245. package/lib/meta.d.mts +5 -0
  246. package/lib/meta.mjs +21 -0
  247. package/lib/runtime-meta.d.mts +5 -0
  248. package/lib/runtime-meta.mjs +38 -0
  249. package/package.json +170 -38
  250. package/.editorconfig +0 -12
  251. package/.eslintrc.js +0 -34
  252. package/.travis.yml +0 -7
  253. package/Dockerfile +0 -12
  254. package/Makefile +0 -37
  255. package/bin/nitro +0 -55
  256. package/lib/auto-require.js +0 -44
  257. package/lib/class-file.js +0 -105
  258. package/lib/class-files.js +0 -212
  259. package/lib/color.js +0 -89
  260. package/lib/cwd.js +0 -27
  261. package/lib/dir-expand.js +0 -80
  262. package/lib/dir.js +0 -130
  263. package/lib/file.js +0 -80
  264. package/lib/join-paths.js +0 -60
  265. package/lib/livereload/livereload.js +0 -55
  266. package/lib/livereload.js +0 -86
  267. package/lib/nitro.js +0 -161
  268. package/lib/package.js +0 -211
  269. package/lib/presets/autoprefixer.js +0 -11
  270. package/lib/presets/babel.js +0 -33
  271. package/lib/presets/browserify.js +0 -106
  272. package/lib/presets/coffee-script.js +0 -29
  273. package/lib/presets/cssnano.js +0 -11
  274. package/lib/presets/eslint.js +0 -67
  275. package/lib/presets/jshint.js +0 -51
  276. package/lib/presets/less.js +0 -45
  277. package/lib/presets/log.js +0 -11
  278. package/lib/presets/ng-annotate.js +0 -34
  279. package/lib/presets/noop.js +0 -7
  280. package/lib/presets/postcss/auto-postcss.js +0 -46
  281. package/lib/presets/postcss/autoprefixer-options.js +0 -9
  282. package/lib/presets/postcss.js +0 -40
  283. package/lib/presets/rollup.js +0 -56
  284. package/lib/presets/sass.js +0 -64
  285. package/lib/presets/sitemap.js +0 -101
  286. package/lib/presets/sitemap.xml +0 -12
  287. package/lib/presets/svg-symbols.js +0 -22
  288. package/lib/presets/svgo.js +0 -21
  289. package/lib/presets/uglify.js +0 -72
  290. package/lib/presets/webpack.js +0 -66
  291. package/lib/processors.js +0 -84
  292. package/lib/promisify.js +0 -16
  293. package/lib/server.js +0 -224
  294. package/lib/tasks.js +0 -114
  295. package/lib/watch.js +0 -81
  296. package/test.js +0 -59
  297. package/tests/cwd-tests.js +0 -25
  298. package/tests/dir-tests.js +0 -80
  299. package/tests/dummy/dummy.coffee +0 -7
  300. package/tests/dummy/dummy.js +0 -8
  301. package/tests/dummy/dummy.less +0 -6
  302. package/tests/dummy/dummy.sass +0 -5
  303. package/tests/file-tests.js +0 -17
  304. package/tests/join-paths-tests.js +0 -86
  305. package/tests/tasks-tests.js +0 -65
  306. package/wercker.yml +0 -25
@@ -0,0 +1,477 @@
1
+ #!/usr/bin/env node
2
+ import consola from 'consola';
3
+ import { colors } from 'consola/utils';
4
+ import { version } from 'nitro/meta';
5
+
6
+ function toArray(val) {
7
+ if (Array.isArray(val)) {
8
+ return val;
9
+ }
10
+ return val === void 0 ? [] : [val];
11
+ }
12
+ function formatLineColumns(lines, linePrefix = "") {
13
+ const maxLengh = [];
14
+ for (const line of lines) {
15
+ for (const [i, element] of line.entries()) {
16
+ maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
17
+ }
18
+ }
19
+ return lines.map(
20
+ (l) => l.map(
21
+ (c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])
22
+ ).join(" ")
23
+ ).join("\n");
24
+ }
25
+ function resolveValue(input) {
26
+ return typeof input === "function" ? input() : input;
27
+ }
28
+ class CLIError extends Error {
29
+ constructor(message, code) {
30
+ super(message);
31
+ this.code = code;
32
+ this.name = "CLIError";
33
+ }
34
+ }
35
+
36
+ const NUMBER_CHAR_RE = /\d/;
37
+ const STR_SPLITTERS = ["-", "_", "/", "."];
38
+ function isUppercase(char = "") {
39
+ if (NUMBER_CHAR_RE.test(char)) {
40
+ return void 0;
41
+ }
42
+ return char !== char.toLowerCase();
43
+ }
44
+ function splitByCase(str, separators) {
45
+ const splitters = STR_SPLITTERS;
46
+ const parts = [];
47
+ if (!str || typeof str !== "string") {
48
+ return parts;
49
+ }
50
+ let buff = "";
51
+ let previousUpper;
52
+ let previousSplitter;
53
+ for (const char of str) {
54
+ const isSplitter = splitters.includes(char);
55
+ if (isSplitter === true) {
56
+ parts.push(buff);
57
+ buff = "";
58
+ previousUpper = void 0;
59
+ continue;
60
+ }
61
+ const isUpper = isUppercase(char);
62
+ if (previousSplitter === false) {
63
+ if (previousUpper === false && isUpper === true) {
64
+ parts.push(buff);
65
+ buff = char;
66
+ previousUpper = isUpper;
67
+ continue;
68
+ }
69
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
70
+ const lastChar = buff.at(-1);
71
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
72
+ buff = lastChar + char;
73
+ previousUpper = isUpper;
74
+ continue;
75
+ }
76
+ }
77
+ buff += char;
78
+ previousUpper = isUpper;
79
+ previousSplitter = isSplitter;
80
+ }
81
+ parts.push(buff);
82
+ return parts;
83
+ }
84
+ function upperFirst(str) {
85
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
86
+ }
87
+ function lowerFirst(str) {
88
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
89
+ }
90
+ function pascalCase(str, opts) {
91
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(p)).join("") : "";
92
+ }
93
+ function camelCase(str, opts) {
94
+ return lowerFirst(pascalCase(str || ""));
95
+ }
96
+ function kebabCase(str, joiner) {
97
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join("-") : "";
98
+ }
99
+
100
+ function toArr(any) {
101
+ return any == void 0 ? [] : Array.isArray(any) ? any : [any];
102
+ }
103
+ function toVal(out, key, val, opts) {
104
+ let x;
105
+ const old = out[key];
106
+ 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;
107
+ out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
108
+ }
109
+ function parseRawArgs(args = [], opts = {}) {
110
+ let k;
111
+ let arr;
112
+ let arg;
113
+ let name;
114
+ let val;
115
+ const out = { _: [] };
116
+ let i = 0;
117
+ let j = 0;
118
+ let idx = 0;
119
+ const len = args.length;
120
+ const alibi = opts.alias !== void 0;
121
+ const strict = opts.unknown !== void 0;
122
+ const defaults = opts.default !== void 0;
123
+ opts.alias = opts.alias || {};
124
+ opts.string = toArr(opts.string);
125
+ opts.boolean = toArr(opts.boolean);
126
+ if (alibi) {
127
+ for (k in opts.alias) {
128
+ arr = opts.alias[k] = toArr(opts.alias[k]);
129
+ for (i = 0; i < arr.length; i++) {
130
+ (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
131
+ }
132
+ }
133
+ }
134
+ for (i = opts.boolean.length; i-- > 0; ) {
135
+ arr = opts.alias[opts.boolean[i]] || [];
136
+ for (j = arr.length; j-- > 0; ) {
137
+ opts.boolean.push(arr[j]);
138
+ }
139
+ }
140
+ for (i = opts.string.length; i-- > 0; ) {
141
+ arr = opts.alias[opts.string[i]] || [];
142
+ for (j = arr.length; j-- > 0; ) {
143
+ opts.string.push(arr[j]);
144
+ }
145
+ }
146
+ if (defaults) {
147
+ for (k in opts.default) {
148
+ name = typeof opts.default[k];
149
+ arr = opts.alias[k] = opts.alias[k] || [];
150
+ if (opts[name] !== void 0) {
151
+ opts[name].push(k);
152
+ for (i = 0; i < arr.length; i++) {
153
+ opts[name].push(arr[i]);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ const keys = strict ? Object.keys(opts.alias) : [];
159
+ for (i = 0; i < len; i++) {
160
+ arg = args[i];
161
+ if (arg === "--") {
162
+ out._ = out._.concat(args.slice(++i));
163
+ break;
164
+ }
165
+ for (j = 0; j < arg.length; j++) {
166
+ if (arg.charCodeAt(j) !== 45) {
167
+ break;
168
+ }
169
+ }
170
+ if (j === 0) {
171
+ out._.push(arg);
172
+ } else if (arg.substring(j, j + 3) === "no-") {
173
+ name = arg.slice(Math.max(0, j + 3));
174
+ if (strict && !~keys.indexOf(name)) {
175
+ return opts.unknown(arg);
176
+ }
177
+ out[name] = false;
178
+ } else {
179
+ for (idx = j + 1; idx < arg.length; idx++) {
180
+ if (arg.charCodeAt(idx) === 61) {
181
+ break;
182
+ }
183
+ }
184
+ name = arg.substring(j, idx);
185
+ val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
186
+ arr = j === 2 ? [name] : name;
187
+ for (idx = 0; idx < arr.length; idx++) {
188
+ name = arr[idx];
189
+ if (strict && !~keys.indexOf(name)) {
190
+ return opts.unknown("-".repeat(j) + name);
191
+ }
192
+ toVal(out, name, idx + 1 < arr.length || val, opts);
193
+ }
194
+ }
195
+ }
196
+ if (defaults) {
197
+ for (k in opts.default) {
198
+ if (out[k] === void 0) {
199
+ out[k] = opts.default[k];
200
+ }
201
+ }
202
+ }
203
+ if (alibi) {
204
+ for (k in out) {
205
+ arr = opts.alias[k] || [];
206
+ while (arr.length > 0) {
207
+ out[arr.shift()] = out[k];
208
+ }
209
+ }
210
+ }
211
+ return out;
212
+ }
213
+
214
+ function parseArgs(rawArgs, argsDef) {
215
+ const parseOptions = {
216
+ boolean: [],
217
+ string: [],
218
+ mixed: [],
219
+ alias: {},
220
+ default: {}
221
+ };
222
+ const args = resolveArgs(argsDef);
223
+ for (const arg of args) {
224
+ if (arg.type === "positional") {
225
+ continue;
226
+ }
227
+ if (arg.type === "string") {
228
+ parseOptions.string.push(arg.name);
229
+ } else if (arg.type === "boolean") {
230
+ parseOptions.boolean.push(arg.name);
231
+ }
232
+ if (arg.default !== void 0) {
233
+ parseOptions.default[arg.name] = arg.default;
234
+ }
235
+ if (arg.alias) {
236
+ parseOptions.alias[arg.name] = arg.alias;
237
+ }
238
+ }
239
+ const parsed = parseRawArgs(rawArgs, parseOptions);
240
+ const [...positionalArguments] = parsed._;
241
+ const parsedArgsProxy = new Proxy(parsed, {
242
+ get(target, prop) {
243
+ return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
244
+ }
245
+ });
246
+ for (const [, arg] of args.entries()) {
247
+ if (arg.type === "positional") {
248
+ const nextPositionalArgument = positionalArguments.shift();
249
+ if (nextPositionalArgument !== void 0) {
250
+ parsedArgsProxy[arg.name] = nextPositionalArgument;
251
+ } else if (arg.default === void 0 && arg.required !== false) {
252
+ throw new CLIError(
253
+ `Missing required positional argument: ${arg.name.toUpperCase()}`,
254
+ "EARG"
255
+ );
256
+ } else {
257
+ parsedArgsProxy[arg.name] = arg.default;
258
+ }
259
+ } else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
260
+ throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
261
+ }
262
+ }
263
+ return parsedArgsProxy;
264
+ }
265
+ function resolveArgs(argsDef) {
266
+ const args = [];
267
+ for (const [name, argDef] of Object.entries(argsDef || {})) {
268
+ args.push({
269
+ ...argDef,
270
+ name,
271
+ alias: toArray(argDef.alias)
272
+ });
273
+ }
274
+ return args;
275
+ }
276
+
277
+ function defineCommand(def) {
278
+ return def;
279
+ }
280
+ async function runCommand(cmd, opts) {
281
+ const cmdArgs = await resolveValue(cmd.args || {});
282
+ const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
283
+ const context = {
284
+ rawArgs: opts.rawArgs,
285
+ args: parsedArgs,
286
+ data: opts.data,
287
+ cmd
288
+ };
289
+ if (typeof cmd.setup === "function") {
290
+ await cmd.setup(context);
291
+ }
292
+ let result;
293
+ try {
294
+ const subCommands = await resolveValue(cmd.subCommands);
295
+ if (subCommands && Object.keys(subCommands).length > 0) {
296
+ const subCommandArgIndex = opts.rawArgs.findIndex(
297
+ (arg) => !arg.startsWith("-")
298
+ );
299
+ const subCommandName = opts.rawArgs[subCommandArgIndex];
300
+ if (subCommandName) {
301
+ if (!subCommands[subCommandName]) {
302
+ throw new CLIError(
303
+ `Unknown command \`${subCommandName}\``,
304
+ "E_UNKNOWN_COMMAND"
305
+ );
306
+ }
307
+ const subCommand = await resolveValue(subCommands[subCommandName]);
308
+ if (subCommand) {
309
+ await runCommand(subCommand, {
310
+ rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1)
311
+ });
312
+ }
313
+ } else if (!cmd.run) {
314
+ throw new CLIError(`No command specified.`, "E_NO_COMMAND");
315
+ }
316
+ }
317
+ if (typeof cmd.run === "function") {
318
+ result = await cmd.run(context);
319
+ }
320
+ } finally {
321
+ if (typeof cmd.cleanup === "function") {
322
+ await cmd.cleanup(context);
323
+ }
324
+ }
325
+ return { result };
326
+ }
327
+ async function resolveSubCommand(cmd, rawArgs, parent) {
328
+ const subCommands = await resolveValue(cmd.subCommands);
329
+ if (subCommands && Object.keys(subCommands).length > 0) {
330
+ const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
331
+ const subCommandName = rawArgs[subCommandArgIndex];
332
+ const subCommand = await resolveValue(subCommands[subCommandName]);
333
+ if (subCommand) {
334
+ return resolveSubCommand(
335
+ subCommand,
336
+ rawArgs.slice(subCommandArgIndex + 1),
337
+ cmd
338
+ );
339
+ }
340
+ }
341
+ return [cmd, parent];
342
+ }
343
+
344
+ async function showUsage(cmd, parent) {
345
+ try {
346
+ consola.log(await renderUsage(cmd, parent) + "\n");
347
+ } catch (error) {
348
+ consola.error(error);
349
+ }
350
+ }
351
+ async function renderUsage(cmd, parent) {
352
+ const cmdMeta = await resolveValue(cmd.meta || {});
353
+ const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
354
+ const parentMeta = await resolveValue(parent?.meta || {});
355
+ const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
356
+ const argLines = [];
357
+ const posLines = [];
358
+ const commandsLines = [];
359
+ const usageLine = [];
360
+ for (const arg of cmdArgs) {
361
+ if (arg.type === "positional") {
362
+ const name = arg.name.toUpperCase();
363
+ const isRequired = arg.required !== false && arg.default === void 0;
364
+ const defaultHint = arg.default ? `="${arg.default}"` : "";
365
+ posLines.push([
366
+ "`" + name + defaultHint + "`",
367
+ arg.description || "",
368
+ arg.valueHint ? `<${arg.valueHint}>` : ""
369
+ ]);
370
+ usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
371
+ } else {
372
+ const isRequired = arg.required === true && arg.default === void 0;
373
+ const argStr = (arg.type === "boolean" && arg.default === true ? [
374
+ ...(arg.alias || []).map((a) => `--no-${a}`),
375
+ `--no-${arg.name}`
376
+ ].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(
377
+ ", "
378
+ )) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
379
+ argLines.push([
380
+ "`" + argStr + (isRequired ? " (required)" : "") + "`",
381
+ arg.description || ""
382
+ ]);
383
+ if (isRequired) {
384
+ usageLine.push(argStr);
385
+ }
386
+ }
387
+ }
388
+ if (cmd.subCommands) {
389
+ const commandNames = [];
390
+ const subCommands = await resolveValue(cmd.subCommands);
391
+ for (const [name, sub] of Object.entries(subCommands)) {
392
+ const subCmd = await resolveValue(sub);
393
+ const meta = await resolveValue(subCmd?.meta);
394
+ commandsLines.push([`\`${name}\``, meta?.description || ""]);
395
+ commandNames.push(name);
396
+ }
397
+ usageLine.push(commandNames.join("|"));
398
+ }
399
+ const usageLines = [];
400
+ const version = cmdMeta.version || parentMeta.version;
401
+ usageLines.push(
402
+ colors.gray(
403
+ `${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`
404
+ ),
405
+ ""
406
+ );
407
+ const hasOptions = argLines.length > 0 || posLines.length > 0;
408
+ usageLines.push(
409
+ `${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``,
410
+ ""
411
+ );
412
+ if (posLines.length > 0) {
413
+ usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
414
+ usageLines.push(formatLineColumns(posLines, " "));
415
+ usageLines.push("");
416
+ }
417
+ if (argLines.length > 0) {
418
+ usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
419
+ usageLines.push(formatLineColumns(argLines, " "));
420
+ usageLines.push("");
421
+ }
422
+ if (commandsLines.length > 0) {
423
+ usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
424
+ usageLines.push(formatLineColumns(commandsLines, " "));
425
+ usageLines.push(
426
+ "",
427
+ `Use \`${commandName} <command> --help\` for more information about a command.`
428
+ );
429
+ }
430
+ return usageLines.filter((l) => typeof l === "string").join("\n");
431
+ }
432
+
433
+ async function runMain(cmd, opts = {}) {
434
+ const rawArgs = opts.rawArgs || process.argv.slice(2);
435
+ const showUsage$1 = opts.showUsage || showUsage;
436
+ try {
437
+ if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
438
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
439
+ process.exit(0);
440
+ } else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
441
+ const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
442
+ if (!meta?.version) {
443
+ throw new CLIError("No version specified", "E_NO_VERSION");
444
+ }
445
+ consola.log(meta.version);
446
+ } else {
447
+ await runCommand(cmd, { rawArgs });
448
+ }
449
+ } catch (error) {
450
+ const isCLIError = error instanceof CLIError;
451
+ if (!isCLIError) {
452
+ consola.error(error, "\n");
453
+ }
454
+ if (isCLIError) {
455
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
456
+ }
457
+ consola.error(error.message);
458
+ process.exit(1);
459
+ }
460
+ }
461
+
462
+ const main = defineCommand({
463
+ meta: {
464
+ name: "nitro",
465
+ description: "Nitro CLI",
466
+ version: version
467
+ },
468
+ subCommands: {
469
+ dev: () => import('./dev.mjs').then((r) => r.default),
470
+ build: () => import('./build.mjs').then((r) => r.default),
471
+ prepare: () => import('./prepare.mjs').then((r) => r.default),
472
+ task: () => import('./index2.mjs').then((r) => r.default)
473
+ }
474
+ });
475
+ runMain(main);
476
+
477
+ export { defineCommand as d };
@@ -0,0 +1,17 @@
1
+ import { d as defineCommand } from './index.mjs';
2
+ import 'consola';
3
+ import 'consola/utils';
4
+ import 'nitro/meta';
5
+
6
+ const index = defineCommand({
7
+ meta: {
8
+ name: "task",
9
+ description: "Operate in nitro tasks (experimental)"
10
+ },
11
+ subCommands: {
12
+ list: () => import('./list.mjs').then((r) => r.default),
13
+ run: () => import('./run.mjs').then((r) => r.default)
14
+ }
15
+ });
16
+
17
+ export { index as default };
@@ -0,0 +1,34 @@
1
+ import { d as defineCommand } from './index.mjs';
2
+ import { consola } from 'consola';
3
+ import { loadOptions, listTasks } from 'nitro';
4
+ import { r as resolve } from '../_chunks/pathe.M-eThtNZ.mjs';
5
+ import 'consola/utils';
6
+ import 'nitro/meta';
7
+
8
+ const list = defineCommand({
9
+ meta: {
10
+ name: "run",
11
+ description: "List available tasks (experimental)"
12
+ },
13
+ args: {
14
+ dir: {
15
+ type: "string",
16
+ description: "project root directory"
17
+ }
18
+ },
19
+ async run({ args }) {
20
+ const cwd = resolve(args.dir || args.cwd || ".");
21
+ const options = await loadOptions({ rootDir: cwd }).catch(() => void 0);
22
+ const tasks = await listTasks({
23
+ cwd,
24
+ buildDir: options?.buildDir || ".nitro"
25
+ });
26
+ for (const [name, task] of Object.entries(tasks)) {
27
+ consola.log(
28
+ ` - \`${name}\`${task.meta?.description ? ` - ${task.meta.description}` : ""}`
29
+ );
30
+ }
31
+ }
32
+ });
33
+
34
+ export { list as default };
@@ -0,0 +1,24 @@
1
+ import { d as defineCommand } from './index.mjs';
2
+ import { createNitro, writeTypes } from 'nitro';
3
+ import { c as commonArgs } from './common.mjs';
4
+ import { r as resolve } from '../_chunks/pathe.M-eThtNZ.mjs';
5
+ import 'consola';
6
+ import 'consola/utils';
7
+ import 'nitro/meta';
8
+
9
+ const prepare = defineCommand({
10
+ meta: {
11
+ name: "prepare",
12
+ description: "Generate types for the project"
13
+ },
14
+ args: {
15
+ ...commonArgs
16
+ },
17
+ async run({ args }) {
18
+ const rootDir = resolve(args.dir || args._dir || ".");
19
+ const nitro = await createNitro({ rootDir });
20
+ await writeTypes(nitro);
21
+ }
22
+ });
23
+
24
+ export { prepare as default };
@@ -0,0 +1,60 @@
1
+ import { d as defineCommand } from './index.mjs';
2
+ import { consola } from 'consola';
3
+ import destr from 'destr';
4
+ import { loadOptions, runTask } from 'nitro';
5
+ import { r as resolve } from '../_chunks/pathe.M-eThtNZ.mjs';
6
+ import 'consola/utils';
7
+ import 'nitro/meta';
8
+
9
+ const run = defineCommand({
10
+ meta: {
11
+ name: "run",
12
+ description: "Run a runtime task in the currently running dev server (experimental)"
13
+ },
14
+ args: {
15
+ name: {
16
+ type: "positional",
17
+ description: "task name",
18
+ required: true
19
+ },
20
+ dir: {
21
+ type: "string",
22
+ description: "project root directory"
23
+ },
24
+ payload: {
25
+ type: "string",
26
+ description: "payload json to pass to the task"
27
+ }
28
+ },
29
+ async run({ args }) {
30
+ const cwd = resolve(args.dir || args.cwd || ".");
31
+ const options = await loadOptions({ rootDir: cwd }).catch(() => void 0);
32
+ consola.info(`Running task \`${args.name}\`...`);
33
+ let payload = destr(args.payload || "{}");
34
+ if (typeof payload !== "object") {
35
+ consola.error(
36
+ `Invalid payload: \`${args.payload}\` (it should be a valid JSON object)`
37
+ );
38
+ payload = void 0;
39
+ }
40
+ try {
41
+ const { result } = await runTask(
42
+ {
43
+ name: args.name,
44
+ context: {},
45
+ payload
46
+ },
47
+ {
48
+ cwd,
49
+ buildDir: options?.buildDir || ".nitro"
50
+ }
51
+ );
52
+ consola.success("Result:", result);
53
+ } catch (error) {
54
+ consola.error(`Failed to run task \`${args.name}\`: ${error}`);
55
+ process.exit(1);
56
+ }
57
+ }
58
+ });
59
+
60
+ export { run as default };
@@ -0,0 +1,52 @@
1
+ import { NitroConfig, LoadConfigOptions, Nitro, DevRPCHooks, DevMessageListener, NitroOptions, TaskEvent, TaskRunnerOptions } from 'nitro/types';
2
+ import { IncomingMessage, OutgoingMessage } from 'node:http';
3
+ import { Duplex } from 'node:stream';
4
+ import { ServerOptions, Server } from 'srvx';
5
+ import { HTTPHandler } from 'h3';
6
+
7
+ declare function createNitro(config?: NitroConfig, opts?: LoadConfigOptions): Promise<Nitro>;
8
+
9
+ declare function prerender(nitro: Nitro): Promise<void>;
10
+
11
+ declare class NitroDevApp {
12
+ #private;
13
+ nitro: Nitro;
14
+ fetch: (req: Request) => Response | Promise<Response>;
15
+ constructor(nitro: Nitro, catchAllHandler?: HTTPHandler);
16
+ }
17
+
18
+ declare function createDevServer(nitro: Nitro): NitroDevServer;
19
+ declare class NitroDevServer extends NitroDevApp implements DevRPCHooks {
20
+ #private;
21
+ constructor(nitro: Nitro);
22
+ upgrade(req: IncomingMessage, socket: OutgoingMessage<IncomingMessage> | Duplex, head: any): Promise<void>;
23
+ listen(opts?: Partial<Omit<ServerOptions, "fetch">>): Server;
24
+ close(): Promise<void>;
25
+ reload(): void;
26
+ sendMessage(message: unknown): void;
27
+ onMessage(listener: DevMessageListener): void;
28
+ offMessage(listener: DevMessageListener): void;
29
+ }
30
+
31
+ declare function loadOptions(configOverrides?: NitroConfig, opts?: LoadConfigOptions): Promise<NitroOptions>;
32
+
33
+ /** @experimental */
34
+ declare function runTask(taskEvent: TaskEvent, opts?: TaskRunnerOptions): Promise<{
35
+ result: unknown;
36
+ }>;
37
+ /** @experimental */
38
+ declare function listTasks(opts?: TaskRunnerOptions): Promise<Record<string, {
39
+ meta: {
40
+ description: string;
41
+ };
42
+ }>>;
43
+
44
+ declare function build(nitro: Nitro): Promise<void>;
45
+
46
+ declare function copyPublicAssets(nitro: Nitro): Promise<void>;
47
+
48
+ declare function prepare(nitro: Nitro): Promise<void>;
49
+
50
+ declare function writeTypes(nitro: Nitro): Promise<void>;
51
+
52
+ export { build, copyPublicAssets, createDevServer, createNitro, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };