nitro 3.0.1-alpha.0 → 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.
- package/README.md +2 -0
- package/dist/_build/common.mjs +24940 -0
- package/dist/_build/rolldown.mjs +172 -0
- package/dist/_build/rollup.mjs +201 -0
- package/dist/_build/vite.build.mjs +16 -0
- package/dist/_chunks/dev.mjs +707 -0
- package/dist/_chunks/nitro.mjs +1191 -0
- package/dist/_chunks/nitro2.mjs +101 -0
- package/dist/_chunks/utils.mjs +254 -0
- package/dist/_common.mjs +45 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
- package/dist/_libs/citty.mjs +363 -0
- package/dist/_libs/commondir+is-reference.mjs +1300 -0
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2509 -0
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +187 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +1972 -0
- package/dist/_libs/httpxy.d.mts +79 -0
- package/dist/_libs/httpxy.mjs +415 -0
- package/dist/_libs/klona.mjs +38 -0
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +66 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
- package/dist/_libs/pluginutils.mjs +652 -0
- package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
- package/dist/_libs/readdirp+chokidar.mjs +1611 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/_libs/resolve-uri+gen-mapping.mjs +448 -0
- package/dist/_libs/rou3.d.mts +43 -0
- package/dist/_libs/rou3.mjs +322 -0
- package/dist/_libs/std-env.d.mts +4 -0
- package/dist/_libs/tsconfck.mjs +832 -0
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport+unplugin.mjs +1785 -0
- package/dist/_libs/unplugin+unimport.d.mts +426 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +1802 -0
- package/dist/builder.d.mts +63 -0
- package/dist/builder.mjs +9 -0
- package/dist/cli/_chunks/build.mjs +48 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/dev.mjs +62 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +20 -476
- package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
- package/dist/node_modules/@poppinss/colors/package.json +20 -18
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +1 -1
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
- package/dist/node_modules/@poppinss/exception/package.json +19 -16
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +47 -6
- package/dist/node_modules/@sindresorhus/is/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +2 -2
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +8 -4
- package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
- package/dist/node_modules/cookie-es/package.json +37 -0
- package/dist/node_modules/hookable/dist/index.mjs +244 -268
- package/dist/node_modules/hookable/package.json +29 -26
- package/dist/node_modules/rendu/dist/index.mjs +380 -0
- package/dist/node_modules/rendu/package.json +47 -0
- package/dist/node_modules/ufo/dist/index.mjs +16 -9
- package/dist/node_modules/ufo/package.json +15 -14
- package/dist/node_modules/unctx/package.json +16 -16
- package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-VE4LENUR.js → chunk-CM7DWJNZ.js} +4 -5
- package/dist/node_modules/youch/build/{chunk-JAN2TFI2.js → chunk-EJH674NB.js} +6 -5
- package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
- package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
- package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
- package/dist/node_modules/youch/build/index.js +22 -15
- package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/script.js +20 -22
- package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
- package/dist/node_modules/youch/build/public/header/script.js +0 -2
- package/dist/node_modules/youch/build/public/layout/script.js +0 -8
- package/dist/node_modules/youch/build/public/layout/style.css +4 -0
- package/dist/node_modules/youch/package.json +16 -17
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +2 -1
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +47 -42
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +3 -3
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +11 -15
- package/dist/presets/_nitro/runtime/service-worker.d.mts +2 -1
- package/dist/presets/_nitro/runtime/service-worker.mjs +17 -14
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +2 -1
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +8 -7
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +3 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +2 -3
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -29
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +9 -9
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +3 -3
- package/dist/presets/azure/runtime/azure-swa.mjs +25 -23
- package/dist/presets/bun/runtime/bun.d.mts +3 -1
- package/dist/presets/bun/runtime/bun.mjs +34 -22
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +12 -9
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +84 -90
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +7 -15
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +62 -64
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +2 -8
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +15 -18
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +13 -13
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -43
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -82
- package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
- package/dist/presets/deno/runtime/deno-deploy.d.mts +5 -1
- package/dist/presets/deno/runtime/deno-deploy.mjs +15 -13
- package/dist/presets/deno/runtime/deno-server.d.mts +1 -4
- package/dist/presets/deno/runtime/deno-server.mjs +32 -53
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -2
- package/dist/presets/netlify/runtime/netlify-edge.mjs +18 -14
- package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
- package/dist/presets/netlify/runtime/netlify.mjs +15 -19
- package/dist/presets/node/runtime/node-cluster.d.mts +3 -1
- package/dist/presets/node/runtime/node-cluster.mjs +49 -54
- package/dist/presets/node/runtime/node-middleware.d.mts +3 -4
- package/dist/presets/node/runtime/node-middleware.mjs +9 -9
- package/dist/presets/node/runtime/node-server.d.mts +1 -1
- package/dist/presets/node/runtime/node-server.mjs +36 -34
- package/dist/presets/standard/runtime/server.d.mts +2 -4
- package/dist/presets/standard/runtime/server.mjs +3 -5
- package/dist/presets/stormkit/runtime/stormkit.d.mts +14 -14
- package/dist/presets/stormkit/runtime/stormkit.mjs +22 -22
- package/dist/presets/vercel/runtime/isr.d.mts +2 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.d.mts +3 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
- package/dist/presets/vercel/runtime/vercel.web.d.mts +8 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +25 -0
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -1
- package/dist/presets/winterjs/runtime/winterjs.mjs +74 -70
- package/dist/presets/zeabur/runtime/zeabur.d.mts +2 -2
- package/dist/presets/zeabur/runtime/zeabur.mjs +2 -2
- package/dist/runtime/app.d.mts +1 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/cache.d.mts +1 -0
- package/dist/runtime/cache.mjs +1 -0
- package/dist/runtime/config.d.mts +3 -0
- package/dist/runtime/config.mjs +4 -0
- package/dist/runtime/context.d.mts +1 -0
- package/dist/runtime/context.mjs +1 -0
- package/dist/runtime/database.d.mts +1 -0
- package/dist/runtime/database.mjs +1 -0
- package/dist/runtime/internal/app.d.mts +15 -1
- package/dist/runtime/internal/app.mjs +199 -144
- package/dist/runtime/internal/cache.d.mts +9 -5
- package/dist/runtime/internal/cache.mjs +248 -219
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +9 -11
- package/dist/runtime/internal/error/dev.d.mts +4 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/hooks.d.mts +1 -0
- package/dist/runtime/internal/error/hooks.mjs +9 -0
- package/dist/runtime/internal/error/prod.d.mts +5 -4
- package/dist/runtime/internal/error/prod.mjs +51 -59
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/route-rules.d.mts +4 -8
- package/dist/runtime/internal/route-rules.mjs +54 -52
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +17 -19
- package/dist/runtime/internal/routes/openapi.mjs +82 -88
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +15 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +2 -2
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +44 -39
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +3 -3
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +57 -61
- package/dist/runtime/internal/vite/dev-entry.mjs +11 -2
- package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +54 -57
- package/dist/runtime/internal/vite/ssr-renderer.mjs +3 -1
- package/{lib/runtime-meta.d.mts → dist/runtime/meta.d.mts} +2 -2
- package/dist/runtime/meta.mjs +26 -0
- package/dist/runtime/nitro.d.mts +9 -0
- package/dist/runtime/nitro.mjs +32 -0
- package/dist/runtime/runtime-config.d.mts +1 -0
- package/dist/runtime/runtime-config.mjs +1 -0
- package/dist/runtime/storage.d.mts +1 -0
- package/dist/runtime/storage.mjs +1 -0
- package/dist/runtime/task.d.mts +1 -0
- package/dist/runtime/task.mjs +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +6 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/runtime/vite.d.mts +8 -0
- package/dist/runtime/vite.mjs +9 -0
- package/dist/types/index.d.mts +2561 -2312
- package/dist/types/index.mjs +10 -0
- package/dist/vite.d.mts +44 -51
- package/dist/vite.mjs +737 -68
- package/lib/tsconfig.json +27 -0
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +118 -101
- package/dist/_chunks/app.mjs +0 -19797
- package/dist/_chunks/build.mjs +0 -84
- package/dist/_chunks/build2.mjs +0 -318
- package/dist/_chunks/build3.mjs +0 -6452
- package/dist/_chunks/detect-acorn.mjs +0 -503
- package/dist/_chunks/index.mjs +0 -22242
- package/dist/_chunks/index2.mjs +0 -297
- package/dist/_chunks/index3.mjs +0 -1058
- package/dist/_chunks/index4.mjs +0 -1206
- package/dist/_chunks/info.mjs +0 -11157
- package/dist/_chunks/json5.mjs +0 -68
- package/dist/_chunks/jsonc.mjs +0 -51
- package/dist/_chunks/pathe.M-eThtNZ.mjs +0 -204
- package/dist/_chunks/plugin.mjs +0 -960
- package/dist/_chunks/server.mjs +0 -254
- package/dist/_chunks/snapshot.mjs +0 -284
- package/dist/_chunks/toml.mjs +0 -259
- package/dist/_chunks/yaml.mjs +0 -86
- package/dist/cli/build.mjs +0 -54
- package/dist/cli/common.mjs +0 -13
- package/dist/cli/dev.mjs +0 -95
- package/dist/cli/index2.mjs +0 -17
- package/dist/cli/list.mjs +0 -34
- package/dist/cli/prepare.mjs +0 -24
- package/dist/cli/run.mjs +0 -60
- package/dist/index.d.mts +0 -52
- package/dist/index.mjs +0 -55
- package/dist/node_modules/cookie/dist/index.js +0 -239
- package/dist/node_modules/cookie/package.json +0 -42
- package/dist/node_modules/kleur/index.js +0 -110
- package/dist/node_modules/klona/dist/index.mjs +0 -81
- package/dist/node_modules/klona/full/index.mjs +0 -53
- package/dist/node_modules/klona/package.json +0 -74
- package/dist/node_modules/std-env/dist/index.mjs +0 -1
- package/dist/node_modules/std-env/package.json +0 -46
- package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
- package/dist/presets/vercel/runtime/vercel.d.mts +0 -8
- package/dist/presets/vercel/runtime/vercel.mjs +0 -17
- package/dist/presets.mjs +0 -2460
- package/dist/runtime/index.d.mts +0 -11
- package/dist/runtime/index.mjs +0 -17
- package/dist/runtime/internal/debug.d.mts +0 -2
- package/dist/runtime/internal/debug.mjs +0 -5
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/index.d.mts +0 -3
- package/dist/runtime/internal/index.mjs +0 -3
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +0 -16
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +0 -213
- package/dist/runtime/internal/renderer.d.mts +0 -3
- package/dist/runtime/internal/renderer.mjs +0 -36
- package/dist/runtime/internal/shutdown.d.mts +0 -9
- package/dist/runtime/internal/shutdown.mjs +0 -34
- package/dist/runtime/internal/utils.d.mts +0 -1
- package/dist/runtime/internal/utils.mjs +0 -15
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/prod-setup.mjs +0 -55
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- package/lib/config.d.mts +0 -9
- package/lib/config.mjs +0 -5
- package/lib/deps/ofetch.mjs +0 -1
- package/lib/deps/ofetch.mts +0 -1
- package/lib/meta.d.mts +0 -5
- package/lib/meta.mjs +0 -21
- package/lib/runtime-meta.mjs +0 -38
- /package/dist/runtime/{internal/vite/dev-worker.d.mts → virtual/_runtime_warn.d.mts} +0 -0
- /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
- /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
package/dist/cli/index.mjs
CHANGED
|
@@ -1,477 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 };
|
|
2
|
+
import { n as runMain, t as defineCommand } from "../_libs/citty.mjs";
|
|
3
|
+
import { version } from "nitro/meta";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/index.ts
|
|
6
|
+
runMain(defineCommand({
|
|
7
|
+
meta: {
|
|
8
|
+
name: "nitro",
|
|
9
|
+
description: "Nitro CLI",
|
|
10
|
+
version
|
|
11
|
+
},
|
|
12
|
+
subCommands: {
|
|
13
|
+
dev: () => import("./_chunks/dev.mjs").then((r) => r.default),
|
|
14
|
+
build: () => import("./_chunks/build.mjs").then((r) => r.default),
|
|
15
|
+
prepare: () => import("./_chunks/prepare.mjs").then((r) => r.default),
|
|
16
|
+
task: () => import("./_chunks/task.mjs").then((r) => r.default)
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { };
|