@maizzle/framework 6.0.0-rc.1 → 6.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/maizzle.mjs +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +32 -0
- package/dist/build.mjs +6 -3
- package/dist/build.mjs.map +1 -1
- package/dist/components/Body.vue +111 -0
- package/dist/components/Button.vue +68 -14
- package/dist/components/CodeBlock.vue +68 -0
- package/dist/components/CodeInline.vue +49 -0
- package/dist/components/Column.vue +78 -0
- package/dist/components/Container.vue +53 -0
- package/dist/components/Divider.vue +28 -0
- package/dist/components/Head.vue +30 -0
- package/dist/components/Heading.vue +28 -0
- package/dist/components/Html.vue +104 -0
- package/dist/components/Img.vue +70 -0
- package/dist/components/Layout.vue +93 -0
- package/dist/components/Link.vue +26 -0
- package/dist/components/Markdown.vue +89 -0
- package/dist/components/Outlook.vue +36 -0
- package/dist/components/Overlap.vue +84 -0
- package/dist/components/Preheader.vue +20 -0
- package/dist/components/Row.vue +91 -0
- package/dist/components/Section.vue +83 -0
- package/dist/components/Spacer.vue +50 -7
- package/dist/components/Text.vue +29 -0
- package/dist/components/Vml.vue +165 -13
- package/dist/composables/renderContext.d.mts +5 -0
- package/dist/composables/renderContext.d.mts.map +1 -1
- package/dist/composables/renderContext.mjs.map +1 -1
- package/dist/composables/usePreheader.d.mts +24 -0
- package/dist/composables/usePreheader.d.mts.map +1 -0
- package/dist/composables/usePreheader.mjs +29 -0
- package/dist/composables/usePreheader.mjs.map +1 -0
- package/dist/config/defaults.mjs +1 -3
- package/dist/config/defaults.mjs.map +1 -1
- package/dist/config/index.mjs +7 -0
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/dist/node_modules/picomatch/index.mjs +13 -0
- package/dist/node_modules/picomatch/index.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/constants.mjs +174 -0
- package/dist/node_modules/picomatch/lib/constants.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/parse.mjs +1067 -0
- package/dist/node_modules/picomatch/lib/parse.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/picomatch.mjs +304 -0
- package/dist/node_modules/picomatch/lib/picomatch.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/scan.mjs +296 -0
- package/dist/node_modules/picomatch/lib/scan.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/utils.mjs +53 -0
- package/dist/node_modules/picomatch/lib/utils.mjs.map +1 -0
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +24 -7
- package/dist/plugin.mjs.map +1 -1
- package/dist/plugins/postcss/resolveProps.d.mts +8 -0
- package/dist/plugins/postcss/resolveProps.d.mts.map +1 -0
- package/dist/plugins/postcss/resolveProps.mjs +144 -0
- package/dist/plugins/postcss/resolveProps.mjs.map +1 -0
- package/dist/plugins/postcss/tailwindCleanup.d.mts.map +1 -1
- package/dist/plugins/postcss/tailwindCleanup.mjs +46 -13
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +1 -1
- package/dist/render/createRenderer.d.mts +8 -3
- package/dist/render/createRenderer.d.mts.map +1 -1
- package/dist/render/createRenderer.mjs +146 -10
- package/dist/render/createRenderer.mjs.map +1 -1
- package/dist/render/index.mjs +6 -3
- package/dist/render/index.mjs.map +1 -1
- package/dist/serve.d.mts.map +1 -1
- package/dist/serve.mjs +157 -63
- package/dist/serve.mjs.map +1 -1
- package/dist/server/compatibility.d.mts +1 -2
- package/dist/server/compatibility.d.mts.map +1 -1
- package/dist/server/compatibility.mjs +30 -16
- package/dist/server/compatibility.mjs.map +1 -1
- package/dist/server/email.d.mts +17 -0
- package/dist/server/email.d.mts.map +1 -0
- package/dist/server/email.mjs +41 -0
- package/dist/server/email.mjs.map +1 -0
- package/dist/server/linter.d.mts +1 -2
- package/dist/server/linter.d.mts.map +1 -1
- package/dist/server/linter.mjs +60 -71
- package/dist/server/linter.mjs.map +1 -1
- package/dist/server/ui/App.vue +206 -70
- package/dist/server/ui/components/ui/checkbox/Checkbox.vue +35 -0
- package/dist/server/ui/components/ui/checkbox/index.ts +1 -0
- package/dist/server/ui/components/ui/command/CommandDialog.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandInput.vue +19 -1
- package/dist/server/ui/components/ui/command/CommandItem.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandList.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandShortcut.vue +1 -1
- package/dist/server/ui/components/ui/dialog/DialogOverlay.vue +9 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/dist/server/ui/components/ui/scroll-area/ScrollBar.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetOverlay.vue +9 -1
- package/dist/server/ui/components/ui/sidebar/Sidebar.vue +8 -1
- package/dist/server/ui/components/ui/sidebar/SidebarProvider.vue +1 -1
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +5 -4
- package/dist/server/ui/components/ui/tags-input/TagsInput.vue +26 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +17 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItem.vue +19 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +22 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItemText.vue +17 -0
- package/dist/server/ui/components/ui/tags-input/index.ts +5 -0
- package/dist/server/ui/components/ui/toggle/index.ts +3 -3
- package/dist/server/ui/components/ui/toggle-group/ToggleGroup.vue +1 -1
- package/dist/server/ui/components/ui/toggle-group/ToggleGroupItem.vue +2 -2
- package/dist/server/ui/main.css +20 -20
- package/dist/server/ui/pages/Home.vue +12 -5
- package/dist/server/ui/pages/Preview.vue +506 -216
- package/dist/transformers/entities.d.mts.map +1 -1
- package/dist/transformers/entities.mjs +3 -0
- package/dist/transformers/entities.mjs.map +1 -1
- package/dist/transformers/filters/defaults.d.mts +6 -0
- package/dist/transformers/filters/defaults.d.mts.map +1 -0
- package/dist/transformers/filters/defaults.mjs +78 -0
- package/dist/transformers/filters/defaults.mjs.map +1 -0
- package/dist/transformers/filters/index.d.mts +22 -0
- package/dist/transformers/filters/index.d.mts.map +1 -0
- package/dist/transformers/filters/index.mjs +67 -0
- package/dist/transformers/filters/index.mjs.map +1 -0
- package/dist/transformers/index.d.mts +11 -9
- package/dist/transformers/index.d.mts.map +1 -1
- package/dist/transformers/index.mjs +19 -11
- package/dist/transformers/index.mjs.map +1 -1
- package/dist/transformers/inlineCSS.d.mts +1 -14
- package/dist/transformers/inlineCSS.d.mts.map +1 -1
- package/dist/transformers/inlineCSS.mjs +32 -36
- package/dist/transformers/inlineCSS.mjs.map +1 -1
- package/dist/transformers/purgeCSS.d.mts.map +1 -1
- package/dist/transformers/purgeCSS.mjs +67 -1
- package/dist/transformers/purgeCSS.mjs.map +1 -1
- package/dist/transformers/sixHex.d.mts +16 -0
- package/dist/transformers/sixHex.d.mts.map +1 -0
- package/dist/transformers/sixHex.mjs +30 -0
- package/dist/transformers/sixHex.mjs.map +1 -0
- package/dist/transformers/tailwindcss.d.mts +6 -2
- package/dist/transformers/tailwindcss.d.mts.map +1 -1
- package/dist/transformers/tailwindcss.mjs +54 -30
- package/dist/transformers/tailwindcss.mjs.map +1 -1
- package/dist/types/config.d.mts +436 -23
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/utils/ast/serializer.d.mts +3 -2
- package/dist/utils/ast/serializer.d.mts.map +1 -1
- package/dist/utils/ast/serializer.mjs +24 -0
- package/dist/utils/ast/serializer.mjs.map +1 -1
- package/dist/utils/detect.d.mts +5 -0
- package/dist/utils/detect.d.mts.map +1 -0
- package/dist/utils/detect.mjs +11 -0
- package/dist/utils/detect.mjs.map +1 -0
- package/node_modules/@clack/core/CHANGELOG.md +87 -4
- package/node_modules/@clack/core/README.md +1 -1
- package/node_modules/@clack/core/dist/index.d.mts +186 -48
- package/node_modules/@clack/core/dist/index.mjs +10 -14
- package/node_modules/@clack/core/dist/index.mjs.map +1 -1
- package/node_modules/@clack/core/package.json +7 -9
- package/node_modules/@clack/prompts/CHANGELOG.md +171 -7
- package/node_modules/@clack/prompts/README.md +66 -3
- package/node_modules/@clack/prompts/dist/index.d.mts +302 -76
- package/node_modules/@clack/prompts/dist/index.mjs +134 -84
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
- package/node_modules/@clack/prompts/package.json +14 -10
- package/node_modules/citty/LICENSE +0 -15
- package/node_modules/citty/README.md +166 -69
- package/node_modules/citty/dist/index.d.mts +88 -56
- package/node_modules/citty/dist/index.mjs +399 -437
- package/node_modules/citty/package.json +28 -35
- package/node_modules/giget/README.md +59 -11
- package/node_modules/giget/dist/THIRD-PARTY-LICENSES.md +205 -0
- package/node_modules/giget/dist/_chunks/giget.mjs +508 -0
- package/node_modules/giget/dist/_chunks/libs/citty.mjs +269 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.d.mts +1 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.mjs +669 -0
- package/node_modules/giget/dist/_chunks/libs/tar.mjs +2931 -0
- package/node_modules/giget/dist/_chunks/rolldown-runtime.mjs +14 -0
- package/node_modules/giget/dist/cli.d.mts +1 -0
- package/node_modules/giget/dist/cli.mjs +89 -111
- package/node_modules/giget/dist/index.d.mts +46 -35
- package/node_modules/giget/dist/index.mjs +2 -22
- package/node_modules/giget/package.json +32 -45
- package/node_modules/maizzle/README.md +140 -0
- package/node_modules/maizzle/bin/maizzle.mjs +5 -0
- package/node_modules/maizzle/dist/commands/new.d.mts +7 -0
- package/node_modules/maizzle/dist/commands/new.mjs +253 -0
- package/node_modules/{@maizzle/cli → maizzle}/dist/index.d.mts +1 -1
- package/node_modules/maizzle/dist/index.mjs +44 -0
- package/node_modules/{commander → maizzle/node_modules/commander}/Readme.md +94 -67
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/argument.js +5 -4
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/command.js +154 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/help.js +77 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/option.js +16 -3
- package/node_modules/{commander → maizzle/node_modules/commander}/package-support.json +4 -1
- package/node_modules/{commander → maizzle/node_modules/commander}/package.json +8 -8
- package/node_modules/{commander → maizzle/node_modules/commander}/typings/index.d.ts +71 -3
- package/node_modules/{@maizzle/cli → maizzle}/package.json +14 -12
- package/node_modules/tinyexec/README.md +49 -3
- package/node_modules/tinyexec/dist/main.d.mts +25 -14
- package/node_modules/tinyexec/dist/main.mjs +148 -100
- package/node_modules/tinyexec/package.json +9 -8
- package/package.json +17 -13
- package/dist/server/ui/components/ui/resizable/ResizableHandle.vue +0 -30
- package/dist/server/ui/components/ui/resizable/ResizablePanel.vue +0 -21
- package/dist/server/ui/components/ui/resizable/ResizablePanelGroup.vue +0 -25
- package/dist/server/ui/components/ui/resizable/index.ts +0 -3
- package/node_modules/@clack/core/dist/index.cjs +0 -15
- package/node_modules/@clack/core/dist/index.cjs.map +0 -1
- package/node_modules/@clack/core/dist/index.d.cts +0 -211
- package/node_modules/@clack/core/dist/index.d.ts +0 -211
- package/node_modules/@clack/prompts/dist/index.cjs +0 -87
- package/node_modules/@clack/prompts/dist/index.cjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.d.cts +0 -165
- package/node_modules/@clack/prompts/dist/index.d.ts +0 -165
- package/node_modules/@maizzle/cli/README.md +0 -58
- package/node_modules/@maizzle/cli/dist/index.mjs +0 -42
- package/node_modules/citty/dist/index.cjs +0 -475
- package/node_modules/citty/dist/index.d.cts +0 -80
- package/node_modules/citty/dist/index.d.ts +0 -80
- package/node_modules/consola/LICENSE +0 -47
- package/node_modules/consola/README.md +0 -352
- package/node_modules/consola/basic.d.ts +0 -1
- package/node_modules/consola/browser.d.ts +0 -1
- package/node_modules/consola/core.d.ts +0 -1
- package/node_modules/consola/dist/basic.cjs +0 -32
- package/node_modules/consola/dist/basic.d.cts +0 -23
- package/node_modules/consola/dist/basic.d.mts +0 -21
- package/node_modules/consola/dist/basic.d.ts +0 -23
- package/node_modules/consola/dist/basic.mjs +0 -24
- package/node_modules/consola/dist/browser.cjs +0 -84
- package/node_modules/consola/dist/browser.d.cts +0 -23
- package/node_modules/consola/dist/browser.d.mts +0 -21
- package/node_modules/consola/dist/browser.d.ts +0 -23
- package/node_modules/consola/dist/browser.mjs +0 -76
- package/node_modules/consola/dist/chunks/prompt.cjs +0 -288
- package/node_modules/consola/dist/chunks/prompt.mjs +0 -280
- package/node_modules/consola/dist/core.cjs +0 -517
- package/node_modules/consola/dist/core.d.cts +0 -459
- package/node_modules/consola/dist/core.d.mts +0 -459
- package/node_modules/consola/dist/core.d.ts +0 -459
- package/node_modules/consola/dist/core.mjs +0 -512
- package/node_modules/consola/dist/index.cjs +0 -663
- package/node_modules/consola/dist/index.d.cts +0 -24
- package/node_modules/consola/dist/index.d.mts +0 -22
- package/node_modules/consola/dist/index.d.ts +0 -24
- package/node_modules/consola/dist/index.mjs +0 -651
- package/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +0 -75
- package/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +0 -72
- package/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +0 -288
- package/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +0 -312
- package/node_modules/consola/dist/utils.cjs +0 -64
- package/node_modules/consola/dist/utils.d.cts +0 -286
- package/node_modules/consola/dist/utils.d.mts +0 -286
- package/node_modules/consola/dist/utils.d.ts +0 -286
- package/node_modules/consola/dist/utils.mjs +0 -54
- package/node_modules/consola/lib/index.cjs +0 -10
- package/node_modules/consola/package.json +0 -136
- package/node_modules/consola/utils.d.ts +0 -1
- package/node_modules/create-maizzle/README.md +0 -86
- package/node_modules/create-maizzle/bin/create-maizzle.mjs +0 -4
- package/node_modules/create-maizzle/node_modules/@clack/core/CHANGELOG.md +0 -340
- package/node_modules/create-maizzle/node_modules/@clack/core/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/core/README.md +0 -22
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.d.mts +0 -349
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs +0 -11
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/core/package.json +0 -60
- package/node_modules/create-maizzle/node_modules/@clack/prompts/CHANGELOG.md +0 -576
- package/node_modules/create-maizzle/node_modules/@clack/prompts/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/prompts/README.md +0 -270
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.d.mts +0 -391
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs +0 -137
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/prompts/package.json +0 -65
- package/node_modules/create-maizzle/package.json +0 -47
- package/node_modules/create-maizzle/src/index.js +0 -242
- package/node_modules/defu/LICENSE +0 -21
- package/node_modules/defu/README.md +0 -171
- package/node_modules/defu/dist/defu.cjs +0 -77
- package/node_modules/defu/dist/defu.d.cts +0 -31
- package/node_modules/defu/dist/defu.d.mts +0 -29
- package/node_modules/defu/dist/defu.d.ts +0 -31
- package/node_modules/defu/dist/defu.mjs +0 -69
- package/node_modules/defu/lib/defu.cjs +0 -10
- package/node_modules/defu/lib/defu.d.cts +0 -12
- package/node_modules/defu/package.json +0 -48
- package/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -468
- package/node_modules/node-fetch-native/LICENSE +0 -114
- package/node_modules/node-fetch-native/README.md +0 -225
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -2
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -2
- package/node_modules/node-fetch-native/dist/index.cjs +0 -1
- package/node_modules/node-fetch-native/dist/index.mjs +0 -1
- package/node_modules/node-fetch-native/dist/native.cjs +0 -1
- package/node_modules/node-fetch-native/dist/native.mjs +0 -1
- package/node_modules/node-fetch-native/dist/node.cjs +0 -19
- package/node_modules/node-fetch-native/dist/node.mjs +0 -19
- package/node_modules/node-fetch-native/dist/polyfill.cjs +0 -1
- package/node_modules/node-fetch-native/dist/polyfill.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.cjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy.cjs +0 -58
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +0 -1
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -1
- package/node_modules/node-fetch-native/index.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/empty.cjs +0 -0
- package/node_modules/node-fetch-native/lib/empty.mjs +0 -0
- package/node_modules/node-fetch-native/lib/index.cjs +0 -11
- package/node_modules/node-fetch-native/lib/index.d.cts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.mts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.ts +0 -10
- package/node_modules/node-fetch-native/lib/native.cjs +0 -11
- package/node_modules/node-fetch-native/lib/polyfill.d.cts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.mts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/proxy.d.ts +0 -32
- package/node_modules/node-fetch-native/node.d.ts +0 -1
- package/node_modules/node-fetch-native/package.json +0 -138
- package/node_modules/node-fetch-native/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/proxy.d.ts +0 -1
- package/node_modules/nypm/node_modules/citty/LICENSE +0 -21
- package/node_modules/nypm/node_modules/citty/README.md +0 -231
- package/node_modules/nypm/node_modules/citty/dist/index.d.mts +0 -112
- package/node_modules/nypm/node_modules/citty/dist/index.mjs +0 -425
- package/node_modules/nypm/node_modules/citty/package.json +0 -42
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/THIRD-PARTY-LICENSES.md +0 -0
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/_chunks/libs/scule.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/LICENSE +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/component.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/config.ts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/layout.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/template.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/LICENSE +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/esm.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/index.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/error.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/suggestSimilar.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/typings/esm.d.mts +0 -0
|
@@ -1,463 +1,425 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { n as kebabCase, r as snakeCase, t as camelCase } from "./_chunks/libs/scule.mjs";
|
|
2
|
+
import { parseArgs as parseArgs$1 } from "node:util";
|
|
3
|
+
//#region src/_utils.ts
|
|
4
4
|
function toArray(val) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return val === void 0 ? [] : [val];
|
|
5
|
+
if (Array.isArray(val)) return val;
|
|
6
|
+
return val === void 0 ? [] : [val];
|
|
9
7
|
}
|
|
10
8
|
function formatLineColumns(lines, linePrefix = "") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return lines.map(
|
|
18
|
-
(l) => l.map(
|
|
19
|
-
(c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])
|
|
20
|
-
).join(" ")
|
|
21
|
-
).join("\n");
|
|
9
|
+
const maxLength = [];
|
|
10
|
+
for (const line of lines) for (const [i, element] of line.entries()) maxLength[i] = Math.max(maxLength[i] || 0, element.length);
|
|
11
|
+
return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLength[i])).join(" ")).join("\n");
|
|
22
12
|
}
|
|
23
13
|
function resolveValue(input) {
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
class CLIError extends Error {
|
|
27
|
-
constructor(message, code) {
|
|
28
|
-
super(message);
|
|
29
|
-
this.code = code;
|
|
30
|
-
this.name = "CLIError";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const NUMBER_CHAR_RE = /\d/;
|
|
35
|
-
const STR_SPLITTERS = ["-", "_", "/", "."];
|
|
36
|
-
function isUppercase(char = "") {
|
|
37
|
-
if (NUMBER_CHAR_RE.test(char)) {
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
return char !== char.toLowerCase();
|
|
41
|
-
}
|
|
42
|
-
function splitByCase(str, separators) {
|
|
43
|
-
const splitters = separators ?? STR_SPLITTERS;
|
|
44
|
-
const parts = [];
|
|
45
|
-
if (!str || typeof str !== "string") {
|
|
46
|
-
return parts;
|
|
47
|
-
}
|
|
48
|
-
let buff = "";
|
|
49
|
-
let previousUpper;
|
|
50
|
-
let previousSplitter;
|
|
51
|
-
for (const char of str) {
|
|
52
|
-
const isSplitter = splitters.includes(char);
|
|
53
|
-
if (isSplitter === true) {
|
|
54
|
-
parts.push(buff);
|
|
55
|
-
buff = "";
|
|
56
|
-
previousUpper = void 0;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const isUpper = isUppercase(char);
|
|
60
|
-
if (previousSplitter === false) {
|
|
61
|
-
if (previousUpper === false && isUpper === true) {
|
|
62
|
-
parts.push(buff);
|
|
63
|
-
buff = char;
|
|
64
|
-
previousUpper = isUpper;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
68
|
-
const lastChar = buff.at(-1);
|
|
69
|
-
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
70
|
-
buff = lastChar + char;
|
|
71
|
-
previousUpper = isUpper;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
buff += char;
|
|
76
|
-
previousUpper = isUpper;
|
|
77
|
-
previousSplitter = isSplitter;
|
|
78
|
-
}
|
|
79
|
-
parts.push(buff);
|
|
80
|
-
return parts;
|
|
81
|
-
}
|
|
82
|
-
function upperFirst(str) {
|
|
83
|
-
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
84
|
-
}
|
|
85
|
-
function lowerFirst(str) {
|
|
86
|
-
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
87
|
-
}
|
|
88
|
-
function pascalCase(str, opts) {
|
|
89
|
-
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
90
|
-
}
|
|
91
|
-
function camelCase(str, opts) {
|
|
92
|
-
return lowerFirst(pascalCase(str || "", opts));
|
|
93
|
-
}
|
|
94
|
-
function kebabCase(str, joiner) {
|
|
95
|
-
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function toArr(any) {
|
|
99
|
-
return any == void 0 ? [] : Array.isArray(any) ? any : [any];
|
|
100
|
-
}
|
|
101
|
-
function toVal(out, key, val, opts) {
|
|
102
|
-
let x;
|
|
103
|
-
const old = out[key];
|
|
104
|
-
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;
|
|
105
|
-
out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
14
|
+
return typeof input === "function" ? input() : input;
|
|
106
15
|
}
|
|
16
|
+
var CLIError = class extends Error {
|
|
17
|
+
code;
|
|
18
|
+
constructor(message, code) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "CLIError";
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/_parser.ts
|
|
107
26
|
function parseRawArgs(args = [], opts = {}) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
if (alibi) {
|
|
202
|
-
for (k in out) {
|
|
203
|
-
arr = opts.alias[k] || [];
|
|
204
|
-
while (arr.length > 0) {
|
|
205
|
-
out[arr.shift()] = out[k];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return out;
|
|
27
|
+
const booleans = new Set(opts.boolean || []);
|
|
28
|
+
const strings = new Set(opts.string || []);
|
|
29
|
+
const aliasMap = opts.alias || {};
|
|
30
|
+
const defaults = opts.default || {};
|
|
31
|
+
const aliasToMain = /* @__PURE__ */ new Map();
|
|
32
|
+
const mainToAliases = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const [key, value] of Object.entries(aliasMap)) {
|
|
34
|
+
const targets = value;
|
|
35
|
+
for (const target of targets) {
|
|
36
|
+
aliasToMain.set(key, target);
|
|
37
|
+
if (!mainToAliases.has(target)) mainToAliases.set(target, []);
|
|
38
|
+
mainToAliases.get(target).push(key);
|
|
39
|
+
aliasToMain.set(target, key);
|
|
40
|
+
if (!mainToAliases.has(key)) mainToAliases.set(key, []);
|
|
41
|
+
mainToAliases.get(key).push(target);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const options = {};
|
|
45
|
+
function getType(name) {
|
|
46
|
+
if (booleans.has(name)) return "boolean";
|
|
47
|
+
const aliases = mainToAliases.get(name) || [];
|
|
48
|
+
for (const alias of aliases) if (booleans.has(alias)) return "boolean";
|
|
49
|
+
return "string";
|
|
50
|
+
}
|
|
51
|
+
function isStringType(name) {
|
|
52
|
+
if (strings.has(name)) return true;
|
|
53
|
+
const aliases = mainToAliases.get(name) || [];
|
|
54
|
+
for (const alias of aliases) if (strings.has(alias)) return true;
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const allOptions = new Set([
|
|
58
|
+
...booleans,
|
|
59
|
+
...strings,
|
|
60
|
+
...Object.keys(aliasMap),
|
|
61
|
+
...Object.values(aliasMap).flat(),
|
|
62
|
+
...Object.keys(defaults)
|
|
63
|
+
]);
|
|
64
|
+
for (const name of allOptions) if (!options[name]) options[name] = {
|
|
65
|
+
type: getType(name),
|
|
66
|
+
default: defaults[name]
|
|
67
|
+
};
|
|
68
|
+
for (const [alias, main] of aliasToMain.entries()) if (alias.length === 1 && options[main] && !options[main].short) options[main].short = alias;
|
|
69
|
+
const processedArgs = [];
|
|
70
|
+
const negatedFlags = {};
|
|
71
|
+
for (let i = 0; i < args.length; i++) {
|
|
72
|
+
const arg = args[i];
|
|
73
|
+
if (arg === "--") {
|
|
74
|
+
processedArgs.push(...args.slice(i));
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (arg.startsWith("--no-")) {
|
|
78
|
+
const flagName = arg.slice(5);
|
|
79
|
+
negatedFlags[flagName] = true;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
processedArgs.push(arg);
|
|
83
|
+
}
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = parseArgs$1({
|
|
87
|
+
args: processedArgs,
|
|
88
|
+
options: Object.keys(options).length > 0 ? options : void 0,
|
|
89
|
+
allowPositionals: true,
|
|
90
|
+
strict: false
|
|
91
|
+
});
|
|
92
|
+
} catch {
|
|
93
|
+
parsed = {
|
|
94
|
+
values: {},
|
|
95
|
+
positionals: processedArgs
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const out = { _: [] };
|
|
99
|
+
out._ = parsed.positionals;
|
|
100
|
+
for (const [key, value] of Object.entries(parsed.values)) {
|
|
101
|
+
let coerced = value;
|
|
102
|
+
if (getType(key) === "boolean" && typeof value === "string") coerced = value !== "false";
|
|
103
|
+
else if (isStringType(key) && typeof value === "boolean") coerced = "";
|
|
104
|
+
out[key] = coerced;
|
|
105
|
+
}
|
|
106
|
+
for (const [name] of Object.entries(negatedFlags)) {
|
|
107
|
+
out[name] = false;
|
|
108
|
+
const mainName = aliasToMain.get(name);
|
|
109
|
+
if (mainName) out[mainName] = false;
|
|
110
|
+
const aliases = mainToAliases.get(name);
|
|
111
|
+
if (aliases) for (const alias of aliases) out[alias] = false;
|
|
112
|
+
}
|
|
113
|
+
for (const [alias, main] of aliasToMain.entries()) {
|
|
114
|
+
if (out[alias] !== void 0 && out[main] === void 0) out[main] = out[alias];
|
|
115
|
+
if (out[main] !== void 0 && out[alias] === void 0) out[alias] = out[main];
|
|
116
|
+
if (out[alias] !== out[main] && defaults[main] === out[main]) out[main] = out[alias];
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
210
119
|
}
|
|
211
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/_color.ts
|
|
122
|
+
const noColor = /* @__PURE__ */ (() => {
|
|
123
|
+
const env = globalThis.process?.env ?? {};
|
|
124
|
+
return env.NO_COLOR === "1" || env.TERM === "dumb" || env.TEST || env.CI;
|
|
125
|
+
})();
|
|
126
|
+
const _c = (c, r = 39) => (t) => noColor ? t : `\u001B[${c}m${t}\u001B[${r}m`;
|
|
127
|
+
const bold = /* @__PURE__ */ _c(1, 22);
|
|
128
|
+
const cyan = /* @__PURE__ */ _c(36);
|
|
129
|
+
const gray = /* @__PURE__ */ _c(90);
|
|
130
|
+
const underline = /* @__PURE__ */ _c(4, 24);
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/args.ts
|
|
212
133
|
function parseArgs(rawArgs, argsDef) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
`Missing required positional argument: ${arg.name.toUpperCase()}`,
|
|
252
|
-
"EARG"
|
|
253
|
-
);
|
|
254
|
-
} else {
|
|
255
|
-
parsedArgsProxy[arg.name] = arg.default;
|
|
256
|
-
}
|
|
257
|
-
} else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
|
|
258
|
-
throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return parsedArgsProxy;
|
|
134
|
+
const parseOptions = {
|
|
135
|
+
boolean: [],
|
|
136
|
+
string: [],
|
|
137
|
+
alias: {},
|
|
138
|
+
default: {}
|
|
139
|
+
};
|
|
140
|
+
const args = resolveArgs(argsDef);
|
|
141
|
+
for (const arg of args) {
|
|
142
|
+
if (arg.type === "positional") continue;
|
|
143
|
+
if (arg.type === "string" || arg.type === "enum") parseOptions.string.push(arg.name);
|
|
144
|
+
else if (arg.type === "boolean") parseOptions.boolean.push(arg.name);
|
|
145
|
+
if (arg.default !== void 0) parseOptions.default[arg.name] = arg.default;
|
|
146
|
+
if (arg.alias) parseOptions.alias[arg.name] = arg.alias;
|
|
147
|
+
const camelName = camelCase(arg.name);
|
|
148
|
+
const kebabName = kebabCase(arg.name);
|
|
149
|
+
if (camelName !== arg.name || kebabName !== arg.name) {
|
|
150
|
+
const existingAliases = toArray(parseOptions.alias[arg.name] || []);
|
|
151
|
+
if (camelName !== arg.name && !existingAliases.includes(camelName)) existingAliases.push(camelName);
|
|
152
|
+
if (kebabName !== arg.name && !existingAliases.includes(kebabName)) existingAliases.push(kebabName);
|
|
153
|
+
if (existingAliases.length > 0) parseOptions.alias[arg.name] = existingAliases;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const parsed = parseRawArgs(rawArgs, parseOptions);
|
|
157
|
+
const [ ...positionalArguments] = parsed._;
|
|
158
|
+
const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
|
|
159
|
+
return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
|
|
160
|
+
} });
|
|
161
|
+
for (const [, arg] of args.entries()) if (arg.type === "positional") {
|
|
162
|
+
const nextPositionalArgument = positionalArguments.shift();
|
|
163
|
+
if (nextPositionalArgument !== void 0) parsedArgsProxy[arg.name] = nextPositionalArgument;
|
|
164
|
+
else if (arg.default === void 0 && arg.required !== false) throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
|
|
165
|
+
else parsedArgsProxy[arg.name] = arg.default;
|
|
166
|
+
} else if (arg.type === "enum") {
|
|
167
|
+
const argument = parsedArgsProxy[arg.name];
|
|
168
|
+
const options = arg.options || [];
|
|
169
|
+
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");
|
|
170
|
+
} else if (arg.required && parsedArgsProxy[arg.name] === void 0) throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
|
|
171
|
+
return parsedArgsProxy;
|
|
262
172
|
}
|
|
263
173
|
function resolveArgs(argsDef) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
return args;
|
|
174
|
+
const args = [];
|
|
175
|
+
for (const [name, argDef] of Object.entries(argsDef || {})) args.push({
|
|
176
|
+
...argDef,
|
|
177
|
+
name,
|
|
178
|
+
alias: toArray(argDef.alias)
|
|
179
|
+
});
|
|
180
|
+
return args;
|
|
273
181
|
}
|
|
274
|
-
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/plugin.ts
|
|
184
|
+
function defineCittyPlugin(plugin) {
|
|
185
|
+
return plugin;
|
|
186
|
+
}
|
|
187
|
+
async function resolvePlugins(plugins) {
|
|
188
|
+
return Promise.all(plugins.map((p) => resolveValue(p)));
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/command.ts
|
|
275
192
|
function defineCommand(def) {
|
|
276
|
-
|
|
193
|
+
return def;
|
|
277
194
|
}
|
|
278
195
|
async function runCommand(cmd, opts) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
196
|
+
const cmdArgs = await resolveValue(cmd.args || {});
|
|
197
|
+
const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
|
|
198
|
+
const context = {
|
|
199
|
+
rawArgs: opts.rawArgs,
|
|
200
|
+
args: parsedArgs,
|
|
201
|
+
data: opts.data,
|
|
202
|
+
cmd
|
|
203
|
+
};
|
|
204
|
+
const plugins = await resolvePlugins(cmd.plugins ?? []);
|
|
205
|
+
let result;
|
|
206
|
+
let runError;
|
|
207
|
+
try {
|
|
208
|
+
for (const plugin of plugins) await plugin.setup?.(context);
|
|
209
|
+
if (typeof cmd.setup === "function") await cmd.setup(context);
|
|
210
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
211
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
212
|
+
const subCommandArgIndex = findSubCommandIndex(opts.rawArgs, cmdArgs);
|
|
213
|
+
const explicitName = opts.rawArgs[subCommandArgIndex];
|
|
214
|
+
if (explicitName) {
|
|
215
|
+
const subCommand = await _findSubCommand(subCommands, explicitName);
|
|
216
|
+
if (!subCommand) throw new CLIError(`Unknown command ${cyan(explicitName)}`, "E_UNKNOWN_COMMAND");
|
|
217
|
+
await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
|
|
218
|
+
} else {
|
|
219
|
+
const defaultSubCommand = await resolveValue(cmd.default);
|
|
220
|
+
if (defaultSubCommand) {
|
|
221
|
+
if (cmd.run) throw new CLIError(`Cannot specify both 'run' and 'default' on the same command.`, "E_DEFAULT_CONFLICT");
|
|
222
|
+
const subCommand = await _findSubCommand(subCommands, defaultSubCommand);
|
|
223
|
+
if (!subCommand) throw new CLIError(`Default sub command ${cyan(defaultSubCommand)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
|
|
224
|
+
await runCommand(subCommand, { rawArgs: opts.rawArgs });
|
|
225
|
+
} else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (typeof cmd.run === "function") result = await cmd.run(context);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
runError = error;
|
|
231
|
+
}
|
|
232
|
+
const cleanupErrors = [];
|
|
233
|
+
if (typeof cmd.cleanup === "function") try {
|
|
234
|
+
await cmd.cleanup(context);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
cleanupErrors.push(error);
|
|
237
|
+
}
|
|
238
|
+
for (const plugin of [...plugins].reverse()) try {
|
|
239
|
+
await plugin.cleanup?.(context);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
cleanupErrors.push(error);
|
|
242
|
+
}
|
|
243
|
+
if (runError) throw runError;
|
|
244
|
+
if (cleanupErrors.length === 1) throw cleanupErrors[0];
|
|
245
|
+
if (cleanupErrors.length > 1) throw new Error("Multiple cleanup errors", { cause: cleanupErrors });
|
|
246
|
+
return { result };
|
|
324
247
|
}
|
|
325
248
|
async function resolveSubCommand(cmd, rawArgs, parent) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
249
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
250
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
251
|
+
const subCommandArgIndex = findSubCommandIndex(rawArgs, await resolveValue(cmd.args || {}));
|
|
252
|
+
const subCommandName = rawArgs[subCommandArgIndex];
|
|
253
|
+
const subCommand = await _findSubCommand(subCommands, subCommandName);
|
|
254
|
+
if (subCommand) return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
|
|
255
|
+
}
|
|
256
|
+
return [cmd, parent];
|
|
257
|
+
}
|
|
258
|
+
async function _findSubCommand(subCommands, name) {
|
|
259
|
+
if (name in subCommands) return resolveValue(subCommands[name]);
|
|
260
|
+
for (const sub of Object.values(subCommands)) {
|
|
261
|
+
const resolved = await resolveValue(sub);
|
|
262
|
+
const meta = await resolveValue(resolved?.meta);
|
|
263
|
+
if (meta?.alias) {
|
|
264
|
+
if (toArray(meta.alias).includes(name)) return resolved;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function findSubCommandIndex(rawArgs, argsDef) {
|
|
269
|
+
for (let i = 0; i < rawArgs.length; i++) {
|
|
270
|
+
const arg = rawArgs[i];
|
|
271
|
+
if (arg === "--") return -1;
|
|
272
|
+
if (arg.startsWith("-")) {
|
|
273
|
+
if (!arg.includes("=") && _isValueFlag(arg, argsDef)) i++;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
return i;
|
|
277
|
+
}
|
|
278
|
+
return -1;
|
|
279
|
+
}
|
|
280
|
+
function _isValueFlag(flag, argsDef) {
|
|
281
|
+
const name = flag.replace(/^-{1,2}/, "");
|
|
282
|
+
const normalized = camelCase(name);
|
|
283
|
+
for (const [key, def] of Object.entries(argsDef)) {
|
|
284
|
+
if (def.type !== "string" && def.type !== "enum") continue;
|
|
285
|
+
if (normalized === camelCase(key)) return true;
|
|
286
|
+
if ((Array.isArray(def.alias) ? def.alias : def.alias ? [def.alias] : []).includes(name)) return true;
|
|
287
|
+
}
|
|
288
|
+
return false;
|
|
340
289
|
}
|
|
341
|
-
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/usage.ts
|
|
342
292
|
async function showUsage(cmd, parent) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
293
|
+
try {
|
|
294
|
+
console.log(await renderUsage(cmd, parent) + "\n");
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.error(error);
|
|
297
|
+
}
|
|
348
298
|
}
|
|
299
|
+
const negativePrefixRe = /^no[-A-Z]/;
|
|
349
300
|
async function renderUsage(cmd, parent) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
usageLines.push(formatLineColumns(posLines, " "));
|
|
413
|
-
usageLines.push("");
|
|
414
|
-
}
|
|
415
|
-
if (argLines.length > 0) {
|
|
416
|
-
usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
|
|
417
|
-
usageLines.push(formatLineColumns(argLines, " "));
|
|
418
|
-
usageLines.push("");
|
|
419
|
-
}
|
|
420
|
-
if (commandsLines.length > 0) {
|
|
421
|
-
usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
|
|
422
|
-
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
423
|
-
usageLines.push(
|
|
424
|
-
"",
|
|
425
|
-
`Use \`${commandName} <command> --help\` for more information about a command.`
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
return usageLines.filter((l) => typeof l === "string").join("\n");
|
|
301
|
+
const cmdMeta = await resolveValue(cmd.meta || {});
|
|
302
|
+
const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
|
|
303
|
+
const parentMeta = await resolveValue(parent?.meta || {});
|
|
304
|
+
const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
|
|
305
|
+
const argLines = [];
|
|
306
|
+
const posLines = [];
|
|
307
|
+
const commandsLines = [];
|
|
308
|
+
const usageLine = [];
|
|
309
|
+
for (const arg of cmdArgs) if (arg.type === "positional") {
|
|
310
|
+
const name = arg.name.toUpperCase();
|
|
311
|
+
const isRequired = arg.required !== false && arg.default === void 0;
|
|
312
|
+
posLines.push([cyan(name + renderValueHint(arg)), renderDescription(arg, isRequired)]);
|
|
313
|
+
usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
|
|
314
|
+
} else {
|
|
315
|
+
const isRequired = arg.required === true && arg.default === void 0;
|
|
316
|
+
const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + renderValueHint(arg);
|
|
317
|
+
argLines.push([cyan(argStr), renderDescription(arg, isRequired)]);
|
|
318
|
+
/**
|
|
319
|
+
* print negative boolean arg variant usage when
|
|
320
|
+
* - enabled by default or has `negativeDescription`
|
|
321
|
+
* - not prefixed with `no-` or `no[A-Z]`
|
|
322
|
+
*/
|
|
323
|
+
if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
|
|
324
|
+
const negativeArgStr = [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ");
|
|
325
|
+
argLines.push([cyan(negativeArgStr), [arg.negativeDescription, isRequired ? gray("(Required)") : ""].filter(Boolean).join(" ")]);
|
|
326
|
+
}
|
|
327
|
+
if (isRequired) usageLine.push(`--${arg.name}` + renderValueHint(arg));
|
|
328
|
+
}
|
|
329
|
+
if (cmd.subCommands) {
|
|
330
|
+
const commandNames = [];
|
|
331
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
332
|
+
for (const [name, sub] of Object.entries(subCommands)) {
|
|
333
|
+
const meta = await resolveValue((await resolveValue(sub))?.meta);
|
|
334
|
+
if (meta?.hidden) continue;
|
|
335
|
+
const aliases = toArray(meta?.alias);
|
|
336
|
+
const label = [name, ...aliases].join(", ");
|
|
337
|
+
commandsLines.push([cyan(label), meta?.description || ""]);
|
|
338
|
+
commandNames.push(name, ...aliases);
|
|
339
|
+
}
|
|
340
|
+
usageLine.push(commandNames.join("|"));
|
|
341
|
+
}
|
|
342
|
+
const usageLines = [];
|
|
343
|
+
const version = cmdMeta.version || parentMeta.version;
|
|
344
|
+
usageLines.push(gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
|
|
345
|
+
const hasOptions = argLines.length > 0 || posLines.length > 0;
|
|
346
|
+
usageLines.push(`${underline(bold("USAGE"))} ${cyan(`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}`)}`, "");
|
|
347
|
+
if (posLines.length > 0) {
|
|
348
|
+
usageLines.push(underline(bold("ARGUMENTS")), "");
|
|
349
|
+
usageLines.push(formatLineColumns(posLines, " "));
|
|
350
|
+
usageLines.push("");
|
|
351
|
+
}
|
|
352
|
+
if (argLines.length > 0) {
|
|
353
|
+
usageLines.push(underline(bold("OPTIONS")), "");
|
|
354
|
+
usageLines.push(formatLineColumns(argLines, " "));
|
|
355
|
+
usageLines.push("");
|
|
356
|
+
}
|
|
357
|
+
if (commandsLines.length > 0) {
|
|
358
|
+
usageLines.push(underline(bold("COMMANDS")), "");
|
|
359
|
+
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
360
|
+
usageLines.push("", `Use ${cyan(`${commandName} <command> --help`)} for more information about a command.`);
|
|
361
|
+
}
|
|
362
|
+
return usageLines.filter((l) => typeof l === "string").join("\n");
|
|
429
363
|
}
|
|
430
|
-
|
|
364
|
+
function renderValueHint(arg) {
|
|
365
|
+
const valueHint = arg.valueHint ? `=<${arg.valueHint}>` : "";
|
|
366
|
+
const fallbackValueHint = valueHint || `=<${snakeCase(arg.name)}>`;
|
|
367
|
+
if (!arg.type || arg.type === "positional" || arg.type === "boolean") return valueHint;
|
|
368
|
+
if (arg.type === "enum" && arg.options?.length) return `=<${arg.options.join("|")}>`;
|
|
369
|
+
return fallbackValueHint;
|
|
370
|
+
}
|
|
371
|
+
function renderDescription(arg, required) {
|
|
372
|
+
const requiredHint = required ? gray("(Required)") : "";
|
|
373
|
+
const defaultHint = arg.default === void 0 ? "" : gray(`(Default: ${arg.default})`);
|
|
374
|
+
return [
|
|
375
|
+
arg.description,
|
|
376
|
+
requiredHint,
|
|
377
|
+
defaultHint
|
|
378
|
+
].filter(Boolean).join(" ");
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/main.ts
|
|
431
382
|
async function runMain(cmd, opts = {}) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
if (isCLIError) {
|
|
453
|
-
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
454
|
-
}
|
|
455
|
-
consola.error(error.message);
|
|
456
|
-
process.exit(1);
|
|
457
|
-
}
|
|
383
|
+
const rawArgs = opts.rawArgs || process.argv.slice(2);
|
|
384
|
+
const showUsage$1 = opts.showUsage || showUsage;
|
|
385
|
+
try {
|
|
386
|
+
const builtinFlags = await _resolveBuiltinFlags(cmd);
|
|
387
|
+
if (builtinFlags.help.length > 0 && rawArgs.some((arg) => builtinFlags.help.includes(arg))) {
|
|
388
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
389
|
+
process.exit(0);
|
|
390
|
+
} else if (rawArgs.length === 1 && builtinFlags.version.includes(rawArgs[0])) {
|
|
391
|
+
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
392
|
+
if (!meta?.version) throw new CLIError("No version specified", "E_NO_VERSION");
|
|
393
|
+
console.log(meta.version);
|
|
394
|
+
} else await runCommand(cmd, { rawArgs });
|
|
395
|
+
} catch (error) {
|
|
396
|
+
if (error instanceof CLIError) {
|
|
397
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
398
|
+
console.error(error.message);
|
|
399
|
+
} else console.error(error, "\n");
|
|
400
|
+
process.exit(1);
|
|
401
|
+
}
|
|
458
402
|
}
|
|
459
403
|
function createMain(cmd) {
|
|
460
|
-
|
|
404
|
+
return (opts = {}) => runMain(cmd, opts);
|
|
405
|
+
}
|
|
406
|
+
async function _resolveBuiltinFlags(cmd) {
|
|
407
|
+
const argsDef = await resolveValue(cmd.args || {});
|
|
408
|
+
const userNames = /* @__PURE__ */ new Set();
|
|
409
|
+
const userAliases = /* @__PURE__ */ new Set();
|
|
410
|
+
for (const [name, def] of Object.entries(argsDef)) {
|
|
411
|
+
userNames.add(name);
|
|
412
|
+
for (const alias of toArray(def.alias)) userAliases.add(alias);
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
help: _getBuiltinFlags("help", "h", userNames, userAliases),
|
|
416
|
+
version: _getBuiltinFlags("version", "v", userNames, userAliases)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function _getBuiltinFlags(long, short, userNames, userAliases) {
|
|
420
|
+
if (userNames.has(long) || userAliases.has(long)) return [];
|
|
421
|
+
if (userNames.has(short) || userAliases.has(short)) return [`--${long}`];
|
|
422
|
+
return [`--${long}`, `-${short}`];
|
|
461
423
|
}
|
|
462
|
-
|
|
463
|
-
export { createMain, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };
|
|
424
|
+
//#endregion
|
|
425
|
+
export { createMain, defineCittyPlugin, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };
|