@maizzle/framework 6.0.0-9 → 6.0.0-rc.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.
- package/bin/maizzle.mjs +10 -0
- package/dist/build.d.mts +19 -0
- package/dist/build.d.mts.map +1 -0
- package/dist/build.mjs +121 -0
- package/dist/build.mjs.map +1 -0
- package/dist/components/Button.vue +141 -0
- package/dist/components/Divider.vue +105 -0
- package/dist/components/NoWidows.vue +123 -0
- package/dist/components/NotOutlook.vue +17 -0
- package/dist/components/Outlook.vue +74 -0
- package/dist/components/Spacer.vue +36 -0
- package/dist/components/Vml.vue +89 -0
- package/dist/components/WithUrl.vue +190 -0
- package/dist/components/utils.d.mts +5 -0
- package/dist/components/utils.d.mts.map +1 -0
- package/dist/components/utils.mjs +9 -0
- package/dist/components/utils.mjs.map +1 -0
- package/dist/components/utils.ts +6 -0
- package/dist/composables/defineConfig.d.mts +14 -0
- package/dist/composables/defineConfig.d.mts.map +1 -0
- package/dist/composables/defineConfig.mjs +34 -0
- package/dist/composables/defineConfig.mjs.map +1 -0
- package/dist/composables/renderContext.d.mts +19 -0
- package/dist/composables/renderContext.d.mts.map +1 -0
- package/dist/composables/renderContext.mjs +6 -0
- package/dist/composables/renderContext.mjs.map +1 -0
- package/dist/composables/useConfig.d.mts +9 -0
- package/dist/composables/useConfig.d.mts.map +1 -0
- package/dist/composables/useConfig.mjs +13 -0
- package/dist/composables/useConfig.mjs.map +1 -0
- package/dist/composables/useDoctype.d.mts +13 -0
- package/dist/composables/useDoctype.d.mts.map +1 -0
- package/dist/composables/useDoctype.mjs +20 -0
- package/dist/composables/useDoctype.mjs.map +1 -0
- package/dist/composables/useEvent.d.mts +17 -0
- package/dist/composables/useEvent.d.mts.map +1 -0
- package/dist/composables/useEvent.mjs +25 -0
- package/dist/composables/useEvent.mjs.map +1 -0
- package/dist/composables/usePlaintext.d.mts +19 -0
- package/dist/composables/usePlaintext.d.mts.map +1 -0
- package/dist/composables/usePlaintext.mjs +22 -0
- package/dist/composables/usePlaintext.mjs.map +1 -0
- package/dist/config/defaults.d.mts +6 -0
- package/dist/config/defaults.d.mts.map +1 -0
- package/dist/config/defaults.mjs +28 -0
- package/dist/config/defaults.mjs.map +1 -0
- package/dist/config/index.d.mts +15 -0
- package/dist/config/index.d.mts.map +1 -0
- package/dist/config/index.mjs +47 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/events/index.d.mts +91 -0
- package/dist/events/index.d.mts.map +1 -0
- package/dist/events/index.mjs +110 -0
- package/dist/events/index.mjs.map +1 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +29 -0
- package/dist/plaintext.d.mts +5 -0
- package/dist/plaintext.d.mts.map +1 -0
- package/dist/plaintext.mjs +15 -0
- package/dist/plaintext.mjs.map +1 -0
- package/dist/plugin.d.mts +17 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +41 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/plugins/postcss/mergeMediaQueries.d.mts +18 -0
- package/dist/plugins/postcss/mergeMediaQueries.d.mts.map +1 -0
- package/dist/plugins/postcss/mergeMediaQueries.mjs +22 -0
- package/dist/plugins/postcss/mergeMediaQueries.mjs.map +1 -0
- package/dist/plugins/postcss/pruneVars.d.mts +8 -0
- package/dist/plugins/postcss/pruneVars.d.mts.map +1 -0
- package/dist/plugins/postcss/pruneVars.mjs +49 -0
- package/dist/plugins/postcss/pruneVars.mjs.map +1 -0
- package/dist/plugins/postcss/removeDeclarations.d.mts +12 -0
- package/dist/plugins/postcss/removeDeclarations.d.mts.map +1 -0
- package/dist/plugins/postcss/removeDeclarations.mjs +45 -0
- package/dist/plugins/postcss/removeDeclarations.mjs.map +1 -0
- package/dist/plugins/postcss/tailwindCleanup.d.mts +18 -0
- package/dist/plugins/postcss/tailwindCleanup.d.mts.map +1 -0
- package/dist/plugins/postcss/tailwindCleanup.mjs +35 -0
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +1 -0
- package/dist/render/createRenderer.d.mts +34 -0
- package/dist/render/createRenderer.d.mts.map +1 -0
- package/dist/render/createRenderer.mjs +149 -0
- package/dist/render/createRenderer.mjs.map +1 -0
- package/dist/render/index.d.mts +26 -0
- package/dist/render/index.d.mts.map +1 -0
- package/dist/render/index.mjs +40 -0
- package/dist/render/index.mjs.map +1 -0
- package/dist/serve.d.mts +25 -0
- package/dist/serve.d.mts.map +1 -0
- package/dist/serve.mjs +402 -0
- package/dist/serve.mjs.map +1 -0
- package/dist/server/compatibility.d.mts +6 -0
- package/dist/server/compatibility.d.mts.map +1 -0
- package/dist/server/compatibility.mjs +83 -0
- package/dist/server/compatibility.mjs.map +1 -0
- package/dist/server/linter.d.mts +6 -0
- package/dist/server/linter.d.mts.map +1 -0
- package/dist/server/linter.mjs +200 -0
- package/dist/server/linter.mjs.map +1 -0
- package/dist/server/ui/App.vue +360 -0
- package/dist/server/ui/components/ui/button/Button.vue +31 -0
- package/dist/server/ui/components/ui/button/index.ts +38 -0
- package/dist/server/ui/components/ui/command/Command.vue +87 -0
- package/dist/server/ui/components/ui/command/CommandDialog.vue +31 -0
- package/dist/server/ui/components/ui/command/CommandEmpty.vue +27 -0
- package/dist/server/ui/components/ui/command/CommandGroup.vue +45 -0
- package/dist/server/ui/components/ui/command/CommandInput.vue +39 -0
- package/dist/server/ui/components/ui/command/CommandItem.vue +76 -0
- package/dist/server/ui/components/ui/command/CommandList.vue +25 -0
- package/dist/server/ui/components/ui/command/CommandSeparator.vue +21 -0
- package/dist/server/ui/components/ui/command/CommandShortcut.vue +17 -0
- package/dist/server/ui/components/ui/command/index.ts +25 -0
- package/dist/server/ui/components/ui/dialog/Dialog.vue +19 -0
- package/dist/server/ui/components/ui/dialog/DialogClose.vue +15 -0
- package/dist/server/ui/components/ui/dialog/DialogContent.vue +53 -0
- package/dist/server/ui/components/ui/dialog/DialogDescription.vue +23 -0
- package/dist/server/ui/components/ui/dialog/DialogFooter.vue +27 -0
- package/dist/server/ui/components/ui/dialog/DialogHeader.vue +17 -0
- package/dist/server/ui/components/ui/dialog/DialogOverlay.vue +21 -0
- package/dist/server/ui/components/ui/dialog/DialogScrollContent.vue +59 -0
- package/dist/server/ui/components/ui/dialog/DialogTitle.vue +23 -0
- package/dist/server/ui/components/ui/dialog/DialogTrigger.vue +15 -0
- package/dist/server/ui/components/ui/dialog/index.ts +10 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +39 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuContent.vue +39 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuGroup.vue +15 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuItem.vue +31 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuLabel.vue +23 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +40 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSeparator.vue +23 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuShortcut.vue +17 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSub.vue +18 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubContent.vue +27 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +31 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/dist/server/ui/components/ui/dropdown-menu/index.ts +16 -0
- package/dist/server/ui/components/ui/empty/Empty.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyContent.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyDescription.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyHeader.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyMedia.vue +21 -0
- package/dist/server/ui/components/ui/empty/EmptyTitle.vue +17 -0
- package/dist/server/ui/components/ui/empty/index.ts +26 -0
- package/dist/server/ui/components/ui/input/Input.vue +33 -0
- package/dist/server/ui/components/ui/input/index.ts +1 -0
- package/dist/server/ui/components/ui/kbd/Kbd.vue +20 -0
- package/dist/server/ui/components/ui/kbd/KbdGroup.vue +17 -0
- package/dist/server/ui/components/ui/kbd/index.ts +2 -0
- package/dist/server/ui/components/ui/resizable/ResizableHandle.vue +30 -0
- package/dist/server/ui/components/ui/resizable/ResizablePanel.vue +21 -0
- package/dist/server/ui/components/ui/resizable/ResizablePanelGroup.vue +25 -0
- package/dist/server/ui/components/ui/resizable/index.ts +3 -0
- package/dist/server/ui/components/ui/scroll-area/ScrollArea.vue +33 -0
- package/dist/server/ui/components/ui/scroll-area/ScrollBar.vue +32 -0
- package/dist/server/ui/components/ui/scroll-area/index.ts +2 -0
- package/dist/server/ui/components/ui/separator/Separator.vue +29 -0
- package/dist/server/ui/components/ui/separator/index.ts +1 -0
- package/dist/server/ui/components/ui/sheet/Sheet.vue +19 -0
- package/dist/server/ui/components/ui/sheet/SheetClose.vue +15 -0
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +62 -0
- package/dist/server/ui/components/ui/sheet/SheetDescription.vue +21 -0
- package/dist/server/ui/components/ui/sheet/SheetFooter.vue +16 -0
- package/dist/server/ui/components/ui/sheet/SheetHeader.vue +15 -0
- package/dist/server/ui/components/ui/sheet/SheetOverlay.vue +21 -0
- package/dist/server/ui/components/ui/sheet/SheetTitle.vue +21 -0
- package/dist/server/ui/components/ui/sheet/SheetTrigger.vue +15 -0
- package/dist/server/ui/components/ui/sheet/index.ts +8 -0
- package/dist/server/ui/components/ui/sidebar/Sidebar.vue +96 -0
- package/dist/server/ui/components/ui/sidebar/SidebarContent.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarFooter.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroup.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroupAction.vue +27 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroupContent.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroupLabel.vue +25 -0
- package/dist/server/ui/components/ui/sidebar/SidebarHeader.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarInput.vue +31 -0
- package/dist/server/ui/components/ui/sidebar/SidebarInset.vue +21 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenu.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuAction.vue +35 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuBadge.vue +26 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuButton.vue +48 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuButtonChild.vue +36 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuItem.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSkeleton.vue +35 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSub.vue +22 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSubButton.vue +36 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSubItem.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarProvider.vue +82 -0
- package/dist/server/ui/components/ui/sidebar/SidebarRail.vue +33 -0
- package/dist/server/ui/components/ui/sidebar/SidebarSeparator.vue +19 -0
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +28 -0
- package/dist/server/ui/components/ui/sidebar/index.ts +60 -0
- package/dist/server/ui/components/ui/sidebar/utils.ts +19 -0
- package/dist/server/ui/components/ui/skeleton/Skeleton.vue +17 -0
- package/dist/server/ui/components/ui/skeleton/index.ts +1 -0
- package/dist/server/ui/components/ui/tabs/Tabs.vue +24 -0
- package/dist/server/ui/components/ui/tabs/TabsContent.vue +21 -0
- package/dist/server/ui/components/ui/tabs/TabsList.vue +24 -0
- package/dist/server/ui/components/ui/tabs/TabsTrigger.vue +26 -0
- package/dist/server/ui/components/ui/tabs/index.ts +4 -0
- package/dist/server/ui/components/ui/toggle/Toggle.vue +35 -0
- package/dist/server/ui/components/ui/toggle/index.ts +28 -0
- package/dist/server/ui/components/ui/toggle-group/ToggleGroup.vue +49 -0
- package/dist/server/ui/components/ui/toggle-group/ToggleGroupItem.vue +46 -0
- package/dist/server/ui/components/ui/toggle-group/index.ts +2 -0
- package/dist/server/ui/components/ui/tooltip/Tooltip.vue +19 -0
- package/dist/server/ui/components/ui/tooltip/TooltipContent.vue +34 -0
- package/dist/server/ui/components/ui/tooltip/TooltipProvider.vue +14 -0
- package/dist/server/ui/components/ui/tooltip/TooltipTrigger.vue +15 -0
- package/dist/server/ui/components/ui/tooltip/index.ts +4 -0
- package/dist/server/ui/favicon.svg +1 -0
- package/dist/server/ui/index.html +13 -0
- package/dist/server/ui/lib/utils.ts +7 -0
- package/dist/server/ui/logo-gradient.svg +1 -0
- package/dist/server/ui/logo.svg +1 -0
- package/dist/server/ui/main.css +129 -0
- package/dist/server/ui/main.ts +16 -0
- package/dist/server/ui/mark-gradient.svg +1 -0
- package/dist/server/ui/mark.svg +1 -0
- package/dist/server/ui/pages/Home.vue +39 -0
- package/dist/server/ui/pages/Preview.vue +609 -0
- package/dist/server/ui/stripes.svg +174 -0
- package/dist/transformers/addAttributes.d.mts +32 -0
- package/dist/transformers/addAttributes.d.mts.map +1 -0
- package/dist/transformers/addAttributes.mjs +101 -0
- package/dist/transformers/addAttributes.mjs.map +1 -0
- package/dist/transformers/attributeToStyle.d.mts +25 -0
- package/dist/transformers/attributeToStyle.d.mts.map +1 -0
- package/dist/transformers/attributeToStyle.mjs +80 -0
- package/dist/transformers/attributeToStyle.mjs.map +1 -0
- package/dist/transformers/base.d.mts +8 -0
- package/dist/transformers/base.d.mts.map +1 -0
- package/dist/transformers/base.mjs +160 -0
- package/dist/transformers/base.mjs.map +1 -0
- package/dist/transformers/entities.d.mts +8 -0
- package/dist/transformers/entities.d.mts.map +1 -0
- package/dist/transformers/entities.mjs +38 -0
- package/dist/transformers/entities.mjs.map +1 -0
- package/dist/transformers/format.d.mts +15 -0
- package/dist/transformers/format.d.mts.map +1 -0
- package/dist/transformers/format.mjs +26 -0
- package/dist/transformers/format.mjs.map +1 -0
- package/dist/transformers/index.d.mts +35 -0
- package/dist/transformers/index.d.mts.map +1 -0
- package/dist/transformers/index.mjs +73 -0
- package/dist/transformers/index.mjs.map +1 -0
- package/dist/transformers/inlineCSS.d.mts +30 -0
- package/dist/transformers/inlineCSS.d.mts.map +1 -0
- package/dist/transformers/inlineCSS.mjs +79 -0
- package/dist/transformers/inlineCSS.mjs.map +1 -0
- package/dist/transformers/inlineLink.d.mts +14 -0
- package/dist/transformers/inlineLink.d.mts.map +1 -0
- package/dist/transformers/inlineLink.mjs +76 -0
- package/dist/transformers/inlineLink.mjs.map +1 -0
- package/dist/transformers/minify.d.mts +17 -0
- package/dist/transformers/minify.d.mts.map +1 -0
- package/dist/transformers/minify.mjs +24 -0
- package/dist/transformers/minify.mjs.map +1 -0
- package/dist/transformers/purgeCSS.d.mts +23 -0
- package/dist/transformers/purgeCSS.d.mts.map +1 -0
- package/dist/transformers/purgeCSS.mjs +66 -0
- package/dist/transformers/purgeCSS.mjs.map +1 -0
- package/dist/transformers/removeAttributes.d.mts +31 -0
- package/dist/transformers/removeAttributes.d.mts.map +1 -0
- package/dist/transformers/removeAttributes.mjs +63 -0
- package/dist/transformers/removeAttributes.mjs.map +1 -0
- package/dist/transformers/replaceStrings.d.mts +16 -0
- package/dist/transformers/replaceStrings.d.mts.map +1 -0
- package/dist/transformers/replaceStrings.mjs +19 -0
- package/dist/transformers/replaceStrings.mjs.map +1 -0
- package/dist/transformers/safeClassNames.d.mts +22 -0
- package/dist/transformers/safeClassNames.d.mts.map +1 -0
- package/dist/transformers/safeClassNames.mjs +103 -0
- package/dist/transformers/safeClassNames.mjs.map +1 -0
- package/dist/transformers/shorthandCSS.d.mts +24 -0
- package/dist/transformers/shorthandCSS.d.mts.map +1 -0
- package/dist/transformers/shorthandCSS.mjs +48 -0
- package/dist/transformers/shorthandCSS.mjs.map +1 -0
- package/dist/transformers/tailwindcss.d.mts +20 -0
- package/dist/transformers/tailwindcss.d.mts.map +1 -0
- package/dist/transformers/tailwindcss.mjs +136 -0
- package/dist/transformers/tailwindcss.mjs.map +1 -0
- package/dist/transformers/urlQuery.d.mts +24 -0
- package/dist/transformers/urlQuery.d.mts.map +1 -0
- package/dist/transformers/urlQuery.mjs +65 -0
- package/dist/transformers/urlQuery.mjs.map +1 -0
- package/dist/types/config.d.mts +129 -0
- package/dist/types/config.d.mts.map +1 -0
- package/dist/types/config.mjs +1 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/dist/utils/ast/index.d.mts +4 -0
- package/dist/utils/ast/index.mjs +5 -0
- package/dist/utils/ast/parser.d.mts +7 -0
- package/dist/utils/ast/parser.d.mts.map +1 -0
- package/dist/utils/ast/parser.mjs +15 -0
- package/dist/utils/ast/parser.mjs.map +1 -0
- package/dist/utils/ast/serializer.d.mts +7 -0
- package/dist/utils/ast/serializer.d.mts.map +1 -0
- package/dist/utils/ast/serializer.mjs +13 -0
- package/dist/utils/ast/serializer.mjs.map +1 -0
- package/dist/utils/ast/walker.d.mts +7 -0
- package/dist/utils/ast/walker.d.mts.map +1 -0
- package/dist/utils/ast/walker.mjs +12 -0
- package/dist/utils/ast/walker.mjs.map +1 -0
- package/dist/utils/url.d.mts +8 -0
- package/dist/utils/url.d.mts.map +1 -0
- package/dist/utils/url.mjs +32 -0
- package/dist/utils/url.mjs.map +1 -0
- package/node_modules/@clack/core/CHANGELOG.md +257 -0
- package/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/@clack/core/README.md +22 -0
- package/node_modules/@clack/core/dist/index.cjs +15 -0
- package/node_modules/@clack/core/dist/index.cjs.map +1 -0
- package/node_modules/@clack/core/dist/index.d.cts +211 -0
- package/node_modules/@clack/core/dist/index.d.mts +211 -0
- package/node_modules/@clack/core/dist/index.d.ts +211 -0
- package/node_modules/@clack/core/dist/index.mjs +15 -0
- package/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/node_modules/@clack/core/package.json +62 -0
- package/node_modules/@clack/prompts/CHANGELOG.md +412 -0
- package/node_modules/@clack/prompts/LICENSE +9 -0
- package/node_modules/@clack/prompts/README.md +207 -0
- package/node_modules/@clack/prompts/dist/index.cjs +87 -0
- package/node_modules/@clack/prompts/dist/index.cjs.map +1 -0
- package/node_modules/@clack/prompts/dist/index.d.cts +165 -0
- package/node_modules/@clack/prompts/dist/index.d.mts +165 -0
- package/node_modules/@clack/prompts/dist/index.d.ts +165 -0
- package/node_modules/@clack/prompts/dist/index.mjs +87 -0
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
- package/node_modules/@clack/prompts/package.json +61 -0
- package/node_modules/@maizzle/cli/LICENSE +21 -0
- package/node_modules/@maizzle/cli/README.md +58 -0
- package/node_modules/@maizzle/cli/dist/commands/make/component.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/component.mjs +31 -0
- package/node_modules/@maizzle/cli/dist/commands/make/config.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/config.mjs +21 -0
- package/node_modules/@maizzle/cli/dist/commands/make/layout.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/layout.mjs +31 -0
- package/node_modules/@maizzle/cli/dist/commands/make/scaffold.d.mts +5 -0
- package/node_modules/@maizzle/cli/dist/commands/make/scaffold.mjs +28 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/component.vue +9 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/config.ts +9 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/layout.vue +39 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/template.vue +8 -0
- package/node_modules/@maizzle/cli/dist/commands/make/template.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/template.mjs +31 -0
- package/node_modules/@maizzle/cli/dist/index.d.mts +8 -0
- package/node_modules/@maizzle/cli/dist/index.mjs +42 -0
- package/node_modules/@maizzle/cli/package.json +59 -0
- package/node_modules/citty/LICENSE +36 -0
- package/node_modules/citty/README.md +134 -0
- package/node_modules/citty/dist/index.cjs +475 -0
- package/node_modules/citty/dist/index.d.cts +80 -0
- package/node_modules/citty/dist/index.d.mts +80 -0
- package/node_modules/citty/dist/index.d.ts +80 -0
- package/node_modules/citty/dist/index.mjs +463 -0
- package/node_modules/citty/package.json +49 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1149 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2662 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +709 -0
- package/node_modules/commander/lib/option.js +367 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +82 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +1045 -0
- package/node_modules/consola/LICENSE +47 -0
- package/node_modules/consola/README.md +352 -0
- package/node_modules/consola/basic.d.ts +1 -0
- package/node_modules/consola/browser.d.ts +1 -0
- package/node_modules/consola/core.d.ts +1 -0
- package/node_modules/consola/dist/basic.cjs +32 -0
- package/node_modules/consola/dist/basic.d.cts +23 -0
- package/node_modules/consola/dist/basic.d.mts +21 -0
- package/node_modules/consola/dist/basic.d.ts +23 -0
- package/node_modules/consola/dist/basic.mjs +24 -0
- package/node_modules/consola/dist/browser.cjs +84 -0
- package/node_modules/consola/dist/browser.d.cts +23 -0
- package/node_modules/consola/dist/browser.d.mts +21 -0
- package/node_modules/consola/dist/browser.d.ts +23 -0
- package/node_modules/consola/dist/browser.mjs +76 -0
- package/node_modules/consola/dist/chunks/prompt.cjs +288 -0
- package/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/node_modules/consola/dist/core.cjs +517 -0
- package/node_modules/consola/dist/core.d.cts +459 -0
- package/node_modules/consola/dist/core.d.mts +459 -0
- package/node_modules/consola/dist/core.d.ts +459 -0
- package/node_modules/consola/dist/core.mjs +512 -0
- package/node_modules/consola/dist/index.cjs +663 -0
- package/node_modules/consola/dist/index.d.cts +24 -0
- package/node_modules/consola/dist/index.d.mts +22 -0
- package/node_modules/consola/dist/index.d.ts +24 -0
- package/node_modules/consola/dist/index.mjs +651 -0
- package/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +75 -0
- package/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +312 -0
- package/node_modules/consola/dist/utils.cjs +64 -0
- package/node_modules/consola/dist/utils.d.cts +286 -0
- package/node_modules/consola/dist/utils.d.mts +286 -0
- package/node_modules/consola/dist/utils.d.ts +286 -0
- package/node_modules/consola/dist/utils.mjs +54 -0
- package/node_modules/consola/lib/index.cjs +10 -0
- package/node_modules/consola/package.json +136 -0
- package/node_modules/consola/utils.d.ts +1 -0
- package/node_modules/create-maizzle/README.md +86 -0
- package/node_modules/create-maizzle/bin/create-maizzle.mjs +4 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/CHANGELOG.md +340 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/README.md +22 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.d.mts +349 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs +11 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/package.json +60 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/CHANGELOG.md +576 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/LICENSE +9 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/README.md +270 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.d.mts +391 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs +137 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/package.json +65 -0
- package/node_modules/create-maizzle/package.json +47 -0
- package/node_modules/create-maizzle/src/index.js +242 -0
- package/node_modules/defu/LICENSE +21 -0
- package/node_modules/defu/README.md +171 -0
- package/node_modules/defu/dist/defu.cjs +77 -0
- package/node_modules/defu/dist/defu.d.cts +31 -0
- package/node_modules/defu/dist/defu.d.mts +29 -0
- package/node_modules/defu/dist/defu.d.ts +31 -0
- package/node_modules/defu/dist/defu.mjs +69 -0
- package/node_modules/defu/lib/defu.cjs +10 -0
- package/node_modules/defu/lib/defu.d.cts +12 -0
- package/node_modules/defu/package.json +48 -0
- package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/index.js +171 -0
- package/node_modules/fast-string-truncated-width/dist/types.d.ts +22 -0
- package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
- package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
- package/node_modules/fast-string-truncated-width/license +21 -0
- package/node_modules/fast-string-truncated-width/package.json +35 -0
- package/node_modules/fast-string-truncated-width/readme.md +60 -0
- package/node_modules/fast-string-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-width/dist/index.js +14 -0
- package/node_modules/fast-string-width/license +21 -0
- package/node_modules/fast-string-width/package.json +34 -0
- package/node_modules/fast-string-width/readme.md +45 -0
- package/node_modules/fast-wrap-ansi/LICENSE +23 -0
- package/node_modules/fast-wrap-ansi/README.md +26 -0
- package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
- package/node_modules/fast-wrap-ansi/lib/main.js +216 -0
- package/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
- package/node_modules/fast-wrap-ansi/package.json +51 -0
- package/node_modules/giget/LICENSE +184 -0
- package/node_modules/giget/README.md +248 -0
- package/node_modules/giget/dist/cli.mjs +112 -0
- package/node_modules/giget/dist/index.d.mts +49 -0
- package/node_modules/giget/dist/index.mjs +22 -0
- package/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +468 -0
- package/node_modules/giget/package.json +62 -0
- package/node_modules/node-fetch-native/LICENSE +114 -0
- package/node_modules/node-fetch-native/README.md +225 -0
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +2 -0
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +2 -0
- package/node_modules/node-fetch-native/dist/index.cjs +1 -0
- package/node_modules/node-fetch-native/dist/index.mjs +1 -0
- package/node_modules/node-fetch-native/dist/native.cjs +1 -0
- package/node_modules/node-fetch-native/dist/native.mjs +1 -0
- package/node_modules/node-fetch-native/dist/node.cjs +19 -0
- package/node_modules/node-fetch-native/dist/node.mjs +19 -0
- package/node_modules/node-fetch-native/dist/polyfill.cjs +1 -0
- package/node_modules/node-fetch-native/dist/polyfill.mjs +1 -0
- package/node_modules/node-fetch-native/dist/proxy-stub.cjs +1 -0
- package/node_modules/node-fetch-native/dist/proxy-stub.mjs +1 -0
- package/node_modules/node-fetch-native/dist/proxy.cjs +58 -0
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +1 -0
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +1 -0
- package/node_modules/node-fetch-native/index.d.ts +1 -0
- 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 +11 -0
- package/node_modules/node-fetch-native/lib/index.d.cts +10 -0
- package/node_modules/node-fetch-native/lib/index.d.mts +10 -0
- package/node_modules/node-fetch-native/lib/index.d.ts +10 -0
- package/node_modules/node-fetch-native/lib/native.cjs +11 -0
- package/node_modules/node-fetch-native/lib/polyfill.d.cts +1 -0
- package/node_modules/node-fetch-native/lib/polyfill.d.mts +1 -0
- package/node_modules/node-fetch-native/lib/polyfill.d.ts +1 -0
- package/node_modules/node-fetch-native/lib/proxy.d.ts +32 -0
- package/node_modules/node-fetch-native/node.d.ts +1 -0
- package/node_modules/node-fetch-native/package.json +138 -0
- package/node_modules/node-fetch-native/polyfill.d.ts +1 -0
- package/node_modules/node-fetch-native/proxy.d.ts +1 -0
- package/node_modules/nypm/LICENSE +21 -0
- package/node_modules/nypm/README.md +152 -0
- package/node_modules/nypm/dist/cli.d.mts +1 -0
- package/node_modules/nypm/dist/cli.mjs +460 -0
- package/node_modules/nypm/dist/index.d.mts +209 -0
- package/node_modules/nypm/dist/index.mjs +423 -0
- package/node_modules/nypm/node_modules/citty/LICENSE +21 -0
- package/node_modules/nypm/node_modules/citty/README.md +231 -0
- package/node_modules/nypm/node_modules/citty/dist/THIRD-PARTY-LICENSES.md +33 -0
- package/node_modules/nypm/node_modules/citty/dist/_chunks/libs/scule.mjs +70 -0
- package/node_modules/nypm/node_modules/citty/dist/index.d.mts +112 -0
- package/node_modules/nypm/node_modules/citty/dist/index.mjs +425 -0
- package/node_modules/nypm/node_modules/citty/package.json +42 -0
- package/node_modules/nypm/package.json +54 -0
- package/node_modules/pathe/LICENSE +70 -0
- package/node_modules/pathe/README.md +73 -0
- package/node_modules/pathe/dist/index.cjs +39 -0
- package/node_modules/pathe/dist/index.d.cts +47 -0
- package/node_modules/pathe/dist/index.d.mts +47 -0
- package/node_modules/pathe/dist/index.d.ts +47 -0
- package/node_modules/pathe/dist/index.mjs +19 -0
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/node_modules/pathe/dist/utils.cjs +82 -0
- package/node_modules/pathe/dist/utils.d.cts +32 -0
- package/node_modules/pathe/dist/utils.d.mts +32 -0
- package/node_modules/pathe/dist/utils.d.ts +32 -0
- package/node_modules/pathe/dist/utils.mjs +77 -0
- package/node_modules/pathe/package.json +61 -0
- package/node_modules/pathe/utils.d.ts +1 -0
- package/node_modules/picocolors/LICENSE +15 -0
- package/node_modules/picocolors/README.md +21 -0
- package/node_modules/picocolors/package.json +25 -0
- package/node_modules/picocolors/picocolors.browser.js +4 -0
- package/node_modules/picocolors/picocolors.d.ts +5 -0
- package/node_modules/picocolors/picocolors.js +75 -0
- package/node_modules/picocolors/types.d.ts +51 -0
- package/node_modules/sisteransi/license +21 -0
- package/node_modules/sisteransi/package.json +34 -0
- package/node_modules/sisteransi/readme.md +113 -0
- package/node_modules/sisteransi/src/index.js +58 -0
- package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/node_modules/tinyexec/LICENSE +21 -0
- package/node_modules/tinyexec/README.md +269 -0
- package/node_modules/tinyexec/dist/LICENSES.txt +83 -0
- package/node_modules/tinyexec/dist/main.d.mts +71 -0
- package/node_modules/tinyexec/dist/main.mjs +642 -0
- package/node_modules/tinyexec/package.json +62 -0
- package/package.json +74 -73
- package/CHANGELOG.md +0 -770
- package/bin/maizzle +0 -5
- package/src/commands/build.js +0 -348
- package/src/commands/serve.js +0 -3
- package/src/generators/plaintext.js +0 -222
- package/src/generators/render.js +0 -129
- package/src/index.js +0 -49
- package/src/posthtml/defaultComponentsConfig.js +0 -19
- package/src/posthtml/defaultConfig.js +0 -14
- package/src/posthtml/index.js +0 -102
- package/src/posthtml/plugins/combineMediaQueries.js +0 -42
- package/src/posthtml/plugins/envAttributes.js +0 -32
- package/src/posthtml/plugins/envTags.js +0 -33
- package/src/posthtml/plugins/expandLinkTag.js +0 -59
- package/src/posthtml/plugins/postcss/compileCss.js +0 -125
- package/src/posthtml/plugins/removeRawStyleAttributes.js +0 -30
- package/src/server/client.js +0 -182
- package/src/server/index.js +0 -464
- package/src/server/routes/hmr.js +0 -26
- package/src/server/routes/index.js +0 -77
- package/src/server/views/404.html +0 -59
- package/src/server/views/error.html +0 -83
- package/src/server/views/index.html +0 -172
- package/src/server/websockets.js +0 -27
- package/src/transformers/addAttributes.js +0 -29
- package/src/transformers/attributeToStyle.js +0 -90
- package/src/transformers/baseUrl.js +0 -154
- package/src/transformers/core.js +0 -32
- package/src/transformers/filters/defaultFilters.js +0 -146
- package/src/transformers/filters/index.js +0 -18
- package/src/transformers/index.js +0 -259
- package/src/transformers/inline.js +0 -306
- package/src/transformers/markdown.js +0 -26
- package/src/transformers/minify.js +0 -27
- package/src/transformers/posthtmlMso.js +0 -14
- package/src/transformers/prettify.js +0 -29
- package/src/transformers/preventWidows.js +0 -37
- package/src/transformers/purge.js +0 -56
- package/src/transformers/removeAttributes.js +0 -55
- package/src/transformers/replaceStrings.js +0 -37
- package/src/transformers/safeClassNames.js +0 -29
- package/src/transformers/shorthandCss.js +0 -20
- package/src/transformers/sixHex.js +0 -30
- package/src/transformers/template.js +0 -26
- package/src/transformers/urlParameters.js +0 -20
- package/src/transformers/useAttributeSizes.js +0 -63
- package/src/utils/getConfigByFilePath.js +0 -143
- package/src/utils/node.js +0 -68
- package/src/utils/string.js +0 -186
- package/types/build.d.ts +0 -166
- package/types/config.d.ts +0 -638
- package/types/css/combineMediaQueries.d.ts +0 -90
- package/types/css/inline.d.ts +0 -218
- package/types/css/purge.d.ts +0 -125
- package/types/events.d.ts +0 -153
- package/types/index.d.ts +0 -232
- package/types/markdown.d.ts +0 -33
- package/types/minify.d.ts +0 -138
- package/types/plaintext.d.ts +0 -56
- package/types/posthtml.d.ts +0 -162
- package/types/render.d.ts +0 -13
- package/types/urlParameters.d.ts +0 -40
- package/types/widowWords.d.ts +0 -38
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const consola = require('consola');
|
|
4
|
+
const utils = require('consola/utils');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
7
|
+
|
|
8
|
+
const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
|
|
9
|
+
|
|
10
|
+
function toArray(val) {
|
|
11
|
+
if (Array.isArray(val)) {
|
|
12
|
+
return val;
|
|
13
|
+
}
|
|
14
|
+
return val === void 0 ? [] : [val];
|
|
15
|
+
}
|
|
16
|
+
function formatLineColumns(lines, linePrefix = "") {
|
|
17
|
+
const maxLengh = [];
|
|
18
|
+
for (const line of lines) {
|
|
19
|
+
for (const [i, element] of line.entries()) {
|
|
20
|
+
maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return lines.map(
|
|
24
|
+
(l) => l.map(
|
|
25
|
+
(c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])
|
|
26
|
+
).join(" ")
|
|
27
|
+
).join("\n");
|
|
28
|
+
}
|
|
29
|
+
function resolveValue(input) {
|
|
30
|
+
return typeof input === "function" ? input() : input;
|
|
31
|
+
}
|
|
32
|
+
class CLIError extends Error {
|
|
33
|
+
constructor(message, code) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.code = code;
|
|
36
|
+
this.name = "CLIError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const NUMBER_CHAR_RE = /\d/;
|
|
41
|
+
const STR_SPLITTERS = ["-", "_", "/", "."];
|
|
42
|
+
function isUppercase(char = "") {
|
|
43
|
+
if (NUMBER_CHAR_RE.test(char)) {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
return char !== char.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
function splitByCase(str, separators) {
|
|
49
|
+
const splitters = separators ?? STR_SPLITTERS;
|
|
50
|
+
const parts = [];
|
|
51
|
+
if (!str || typeof str !== "string") {
|
|
52
|
+
return parts;
|
|
53
|
+
}
|
|
54
|
+
let buff = "";
|
|
55
|
+
let previousUpper;
|
|
56
|
+
let previousSplitter;
|
|
57
|
+
for (const char of str) {
|
|
58
|
+
const isSplitter = splitters.includes(char);
|
|
59
|
+
if (isSplitter === true) {
|
|
60
|
+
parts.push(buff);
|
|
61
|
+
buff = "";
|
|
62
|
+
previousUpper = void 0;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const isUpper = isUppercase(char);
|
|
66
|
+
if (previousSplitter === false) {
|
|
67
|
+
if (previousUpper === false && isUpper === true) {
|
|
68
|
+
parts.push(buff);
|
|
69
|
+
buff = char;
|
|
70
|
+
previousUpper = isUpper;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
74
|
+
const lastChar = buff.at(-1);
|
|
75
|
+
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
76
|
+
buff = lastChar + char;
|
|
77
|
+
previousUpper = isUpper;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
buff += char;
|
|
82
|
+
previousUpper = isUpper;
|
|
83
|
+
previousSplitter = isSplitter;
|
|
84
|
+
}
|
|
85
|
+
parts.push(buff);
|
|
86
|
+
return parts;
|
|
87
|
+
}
|
|
88
|
+
function upperFirst(str) {
|
|
89
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
90
|
+
}
|
|
91
|
+
function lowerFirst(str) {
|
|
92
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
93
|
+
}
|
|
94
|
+
function pascalCase(str, opts) {
|
|
95
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
96
|
+
}
|
|
97
|
+
function camelCase(str, opts) {
|
|
98
|
+
return lowerFirst(pascalCase(str || "", opts));
|
|
99
|
+
}
|
|
100
|
+
function kebabCase(str, joiner) {
|
|
101
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function toArr(any) {
|
|
105
|
+
return any == void 0 ? [] : Array.isArray(any) ? any : [any];
|
|
106
|
+
}
|
|
107
|
+
function toVal(out, key, val, opts) {
|
|
108
|
+
let x;
|
|
109
|
+
const old = out[key];
|
|
110
|
+
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;
|
|
111
|
+
out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
112
|
+
}
|
|
113
|
+
function parseRawArgs(args = [], opts = {}) {
|
|
114
|
+
let k;
|
|
115
|
+
let arr;
|
|
116
|
+
let arg;
|
|
117
|
+
let name;
|
|
118
|
+
let val;
|
|
119
|
+
const out = { _: [] };
|
|
120
|
+
let i = 0;
|
|
121
|
+
let j = 0;
|
|
122
|
+
let idx = 0;
|
|
123
|
+
const len = args.length;
|
|
124
|
+
const alibi = opts.alias !== void 0;
|
|
125
|
+
const strict = opts.unknown !== void 0;
|
|
126
|
+
const defaults = opts.default !== void 0;
|
|
127
|
+
opts.alias = opts.alias || {};
|
|
128
|
+
opts.string = toArr(opts.string);
|
|
129
|
+
opts.boolean = toArr(opts.boolean);
|
|
130
|
+
if (alibi) {
|
|
131
|
+
for (k in opts.alias) {
|
|
132
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
133
|
+
for (i = 0; i < arr.length; i++) {
|
|
134
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (i = opts.boolean.length; i-- > 0; ) {
|
|
139
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
140
|
+
for (j = arr.length; j-- > 0; ) {
|
|
141
|
+
opts.boolean.push(arr[j]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (i = opts.string.length; i-- > 0; ) {
|
|
145
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
146
|
+
for (j = arr.length; j-- > 0; ) {
|
|
147
|
+
opts.string.push(arr[j]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (defaults) {
|
|
151
|
+
for (k in opts.default) {
|
|
152
|
+
name = typeof opts.default[k];
|
|
153
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
154
|
+
if (opts[name] !== void 0) {
|
|
155
|
+
opts[name].push(k);
|
|
156
|
+
for (i = 0; i < arr.length; i++) {
|
|
157
|
+
opts[name].push(arr[i]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
163
|
+
for (i = 0; i < len; i++) {
|
|
164
|
+
arg = args[i];
|
|
165
|
+
if (arg === "--") {
|
|
166
|
+
out._ = out._.concat(args.slice(++i));
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
for (j = 0; j < arg.length; j++) {
|
|
170
|
+
if (arg.charCodeAt(j) !== 45) {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (j === 0) {
|
|
175
|
+
out._.push(arg);
|
|
176
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
177
|
+
name = arg.slice(Math.max(0, j + 3));
|
|
178
|
+
if (strict && !~keys.indexOf(name)) {
|
|
179
|
+
return opts.unknown(arg);
|
|
180
|
+
}
|
|
181
|
+
out[name] = false;
|
|
182
|
+
} else {
|
|
183
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
184
|
+
if (arg.charCodeAt(idx) === 61) {
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
name = arg.substring(j, idx);
|
|
189
|
+
val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
|
|
190
|
+
arr = j === 2 ? [name] : name;
|
|
191
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
192
|
+
name = arr[idx];
|
|
193
|
+
if (strict && !~keys.indexOf(name)) {
|
|
194
|
+
return opts.unknown("-".repeat(j) + name);
|
|
195
|
+
}
|
|
196
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (defaults) {
|
|
201
|
+
for (k in opts.default) {
|
|
202
|
+
if (out[k] === void 0) {
|
|
203
|
+
out[k] = opts.default[k];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (alibi) {
|
|
208
|
+
for (k in out) {
|
|
209
|
+
arr = opts.alias[k] || [];
|
|
210
|
+
while (arr.length > 0) {
|
|
211
|
+
out[arr.shift()] = out[k];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return out;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function parseArgs(rawArgs, argsDef) {
|
|
219
|
+
const parseOptions = {
|
|
220
|
+
boolean: [],
|
|
221
|
+
string: [],
|
|
222
|
+
mixed: [],
|
|
223
|
+
alias: {},
|
|
224
|
+
default: {}
|
|
225
|
+
};
|
|
226
|
+
const args = resolveArgs(argsDef);
|
|
227
|
+
for (const arg of args) {
|
|
228
|
+
if (arg.type === "positional") {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (arg.type === "string") {
|
|
232
|
+
parseOptions.string.push(arg.name);
|
|
233
|
+
} else if (arg.type === "boolean") {
|
|
234
|
+
parseOptions.boolean.push(arg.name);
|
|
235
|
+
}
|
|
236
|
+
if (arg.default !== void 0) {
|
|
237
|
+
parseOptions.default[arg.name] = arg.default;
|
|
238
|
+
}
|
|
239
|
+
if (arg.alias) {
|
|
240
|
+
parseOptions.alias[arg.name] = arg.alias;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const parsed = parseRawArgs(rawArgs, parseOptions);
|
|
244
|
+
const [...positionalArguments] = parsed._;
|
|
245
|
+
const parsedArgsProxy = new Proxy(parsed, {
|
|
246
|
+
get(target, prop) {
|
|
247
|
+
return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
for (const [, arg] of args.entries()) {
|
|
251
|
+
if (arg.type === "positional") {
|
|
252
|
+
const nextPositionalArgument = positionalArguments.shift();
|
|
253
|
+
if (nextPositionalArgument !== void 0) {
|
|
254
|
+
parsedArgsProxy[arg.name] = nextPositionalArgument;
|
|
255
|
+
} else if (arg.default === void 0 && arg.required !== false) {
|
|
256
|
+
throw new CLIError(
|
|
257
|
+
`Missing required positional argument: ${arg.name.toUpperCase()}`,
|
|
258
|
+
"EARG"
|
|
259
|
+
);
|
|
260
|
+
} else {
|
|
261
|
+
parsedArgsProxy[arg.name] = arg.default;
|
|
262
|
+
}
|
|
263
|
+
} else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
|
|
264
|
+
throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return parsedArgsProxy;
|
|
268
|
+
}
|
|
269
|
+
function resolveArgs(argsDef) {
|
|
270
|
+
const args = [];
|
|
271
|
+
for (const [name, argDef] of Object.entries(argsDef || {})) {
|
|
272
|
+
args.push({
|
|
273
|
+
...argDef,
|
|
274
|
+
name,
|
|
275
|
+
alias: toArray(argDef.alias)
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return args;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function defineCommand(def) {
|
|
282
|
+
return def;
|
|
283
|
+
}
|
|
284
|
+
async function runCommand(cmd, opts) {
|
|
285
|
+
const cmdArgs = await resolveValue(cmd.args || {});
|
|
286
|
+
const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
|
|
287
|
+
const context = {
|
|
288
|
+
rawArgs: opts.rawArgs,
|
|
289
|
+
args: parsedArgs,
|
|
290
|
+
data: opts.data,
|
|
291
|
+
cmd
|
|
292
|
+
};
|
|
293
|
+
if (typeof cmd.setup === "function") {
|
|
294
|
+
await cmd.setup(context);
|
|
295
|
+
}
|
|
296
|
+
let result;
|
|
297
|
+
try {
|
|
298
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
299
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
300
|
+
const subCommandArgIndex = opts.rawArgs.findIndex(
|
|
301
|
+
(arg) => !arg.startsWith("-")
|
|
302
|
+
);
|
|
303
|
+
const subCommandName = opts.rawArgs[subCommandArgIndex];
|
|
304
|
+
if (subCommandName) {
|
|
305
|
+
if (!subCommands[subCommandName]) {
|
|
306
|
+
throw new CLIError(
|
|
307
|
+
`Unknown command \`${subCommandName}\``,
|
|
308
|
+
"E_UNKNOWN_COMMAND"
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
312
|
+
if (subCommand) {
|
|
313
|
+
await runCommand(subCommand, {
|
|
314
|
+
rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1)
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
} else if (!cmd.run) {
|
|
318
|
+
throw new CLIError(`No command specified.`, "E_NO_COMMAND");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (typeof cmd.run === "function") {
|
|
322
|
+
result = await cmd.run(context);
|
|
323
|
+
}
|
|
324
|
+
} finally {
|
|
325
|
+
if (typeof cmd.cleanup === "function") {
|
|
326
|
+
await cmd.cleanup(context);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return { result };
|
|
330
|
+
}
|
|
331
|
+
async function resolveSubCommand(cmd, rawArgs, parent) {
|
|
332
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
333
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
334
|
+
const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
335
|
+
const subCommandName = rawArgs[subCommandArgIndex];
|
|
336
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
337
|
+
if (subCommand) {
|
|
338
|
+
return resolveSubCommand(
|
|
339
|
+
subCommand,
|
|
340
|
+
rawArgs.slice(subCommandArgIndex + 1),
|
|
341
|
+
cmd
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return [cmd, parent];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async function showUsage(cmd, parent) {
|
|
349
|
+
try {
|
|
350
|
+
consola__default.log(await renderUsage(cmd, parent) + "\n");
|
|
351
|
+
} catch (error) {
|
|
352
|
+
consola__default.error(error);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async function renderUsage(cmd, parent) {
|
|
356
|
+
const cmdMeta = await resolveValue(cmd.meta || {});
|
|
357
|
+
const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
|
|
358
|
+
const parentMeta = await resolveValue(parent?.meta || {});
|
|
359
|
+
const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
|
|
360
|
+
const argLines = [];
|
|
361
|
+
const posLines = [];
|
|
362
|
+
const commandsLines = [];
|
|
363
|
+
const usageLine = [];
|
|
364
|
+
for (const arg of cmdArgs) {
|
|
365
|
+
if (arg.type === "positional") {
|
|
366
|
+
const name = arg.name.toUpperCase();
|
|
367
|
+
const isRequired = arg.required !== false && arg.default === void 0;
|
|
368
|
+
const defaultHint = arg.default ? `="${arg.default}"` : "";
|
|
369
|
+
posLines.push([
|
|
370
|
+
"`" + name + defaultHint + "`",
|
|
371
|
+
arg.description || "",
|
|
372
|
+
arg.valueHint ? `<${arg.valueHint}>` : ""
|
|
373
|
+
]);
|
|
374
|
+
usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
|
|
375
|
+
} else {
|
|
376
|
+
const isRequired = arg.required === true && arg.default === void 0;
|
|
377
|
+
const argStr = (arg.type === "boolean" && arg.default === true ? [
|
|
378
|
+
...(arg.alias || []).map((a) => `--no-${a}`),
|
|
379
|
+
`--no-${arg.name}`
|
|
380
|
+
].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(
|
|
381
|
+
", "
|
|
382
|
+
)) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
|
|
383
|
+
argLines.push([
|
|
384
|
+
"`" + argStr + (isRequired ? " (required)" : "") + "`",
|
|
385
|
+
arg.description || ""
|
|
386
|
+
]);
|
|
387
|
+
if (isRequired) {
|
|
388
|
+
usageLine.push(argStr);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (cmd.subCommands) {
|
|
393
|
+
const commandNames = [];
|
|
394
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
395
|
+
for (const [name, sub] of Object.entries(subCommands)) {
|
|
396
|
+
const subCmd = await resolveValue(sub);
|
|
397
|
+
const meta = await resolveValue(subCmd?.meta);
|
|
398
|
+
commandsLines.push([`\`${name}\``, meta?.description || ""]);
|
|
399
|
+
commandNames.push(name);
|
|
400
|
+
}
|
|
401
|
+
usageLine.push(commandNames.join("|"));
|
|
402
|
+
}
|
|
403
|
+
const usageLines = [];
|
|
404
|
+
const version = cmdMeta.version || parentMeta.version;
|
|
405
|
+
usageLines.push(
|
|
406
|
+
utils.colors.gray(
|
|
407
|
+
`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`
|
|
408
|
+
),
|
|
409
|
+
""
|
|
410
|
+
);
|
|
411
|
+
const hasOptions = argLines.length > 0 || posLines.length > 0;
|
|
412
|
+
usageLines.push(
|
|
413
|
+
`${utils.colors.underline(utils.colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``,
|
|
414
|
+
""
|
|
415
|
+
);
|
|
416
|
+
if (posLines.length > 0) {
|
|
417
|
+
usageLines.push(utils.colors.underline(utils.colors.bold("ARGUMENTS")), "");
|
|
418
|
+
usageLines.push(formatLineColumns(posLines, " "));
|
|
419
|
+
usageLines.push("");
|
|
420
|
+
}
|
|
421
|
+
if (argLines.length > 0) {
|
|
422
|
+
usageLines.push(utils.colors.underline(utils.colors.bold("OPTIONS")), "");
|
|
423
|
+
usageLines.push(formatLineColumns(argLines, " "));
|
|
424
|
+
usageLines.push("");
|
|
425
|
+
}
|
|
426
|
+
if (commandsLines.length > 0) {
|
|
427
|
+
usageLines.push(utils.colors.underline(utils.colors.bold("COMMANDS")), "");
|
|
428
|
+
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
429
|
+
usageLines.push(
|
|
430
|
+
"",
|
|
431
|
+
`Use \`${commandName} <command> --help\` for more information about a command.`
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
return usageLines.filter((l) => typeof l === "string").join("\n");
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
async function runMain(cmd, opts = {}) {
|
|
438
|
+
const rawArgs = opts.rawArgs || process.argv.slice(2);
|
|
439
|
+
const showUsage$1 = opts.showUsage || showUsage;
|
|
440
|
+
try {
|
|
441
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
442
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
443
|
+
process.exit(0);
|
|
444
|
+
} else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
|
|
445
|
+
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
446
|
+
if (!meta?.version) {
|
|
447
|
+
throw new CLIError("No version specified", "E_NO_VERSION");
|
|
448
|
+
}
|
|
449
|
+
consola__default.log(meta.version);
|
|
450
|
+
} else {
|
|
451
|
+
await runCommand(cmd, { rawArgs });
|
|
452
|
+
}
|
|
453
|
+
} catch (error) {
|
|
454
|
+
const isCLIError = error instanceof CLIError;
|
|
455
|
+
if (!isCLIError) {
|
|
456
|
+
consola__default.error(error, "\n");
|
|
457
|
+
}
|
|
458
|
+
if (isCLIError) {
|
|
459
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
460
|
+
}
|
|
461
|
+
consola__default.error(error.message);
|
|
462
|
+
process.exit(1);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function createMain(cmd) {
|
|
466
|
+
return (opts = {}) => runMain(cmd, opts);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
exports.createMain = createMain;
|
|
470
|
+
exports.defineCommand = defineCommand;
|
|
471
|
+
exports.parseArgs = parseArgs;
|
|
472
|
+
exports.renderUsage = renderUsage;
|
|
473
|
+
exports.runCommand = runCommand;
|
|
474
|
+
exports.runMain = runMain;
|
|
475
|
+
exports.showUsage = showUsage;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
type ArgType = "boolean" | "string" | "positional" | undefined;
|
|
2
|
+
type _ArgDef<T extends ArgType, VT extends boolean | string> = {
|
|
3
|
+
type?: T;
|
|
4
|
+
description?: string;
|
|
5
|
+
valueHint?: string;
|
|
6
|
+
alias?: string | string[];
|
|
7
|
+
default?: VT;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BooleanArgDef = _ArgDef<"boolean", boolean>;
|
|
11
|
+
type StringArgDef = _ArgDef<"string", string>;
|
|
12
|
+
type PositionalArgDef = Omit<_ArgDef<"positional", string>, "alias">;
|
|
13
|
+
type ArgDef = BooleanArgDef | StringArgDef | PositionalArgDef;
|
|
14
|
+
type ArgsDef = Record<string, ArgDef>;
|
|
15
|
+
type Arg = ArgDef & {
|
|
16
|
+
name: string;
|
|
17
|
+
alias: string[];
|
|
18
|
+
};
|
|
19
|
+
type ParsedArgs<T extends ArgsDef = ArgsDef> = {
|
|
20
|
+
_: string[];
|
|
21
|
+
} & Record<{
|
|
22
|
+
[K in keyof T]: T[K] extends {
|
|
23
|
+
type: "positional";
|
|
24
|
+
} ? K : never;
|
|
25
|
+
}[keyof T], string> & Record<{
|
|
26
|
+
[K in keyof T]: T[K] extends {
|
|
27
|
+
type: "string";
|
|
28
|
+
} ? K : never;
|
|
29
|
+
}[keyof T], string> & Record<{
|
|
30
|
+
[K in keyof T]: T[K] extends {
|
|
31
|
+
type: "boolean";
|
|
32
|
+
} ? K : never;
|
|
33
|
+
}[keyof T], boolean> & Record<string, string | boolean | string[]>;
|
|
34
|
+
interface CommandMeta {
|
|
35
|
+
name?: string;
|
|
36
|
+
version?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
type SubCommandsDef = Record<string, Resolvable<CommandDef<any>>>;
|
|
40
|
+
type CommandDef<T extends ArgsDef = ArgsDef> = {
|
|
41
|
+
meta?: Resolvable<CommandMeta>;
|
|
42
|
+
args?: Resolvable<T>;
|
|
43
|
+
subCommands?: Resolvable<SubCommandsDef>;
|
|
44
|
+
setup?: (context: CommandContext<T>) => any | Promise<any>;
|
|
45
|
+
cleanup?: (context: CommandContext<T>) => any | Promise<any>;
|
|
46
|
+
run?: (context: CommandContext<T>) => any | Promise<any>;
|
|
47
|
+
};
|
|
48
|
+
type CommandContext<T extends ArgsDef = ArgsDef> = {
|
|
49
|
+
rawArgs: string[];
|
|
50
|
+
args: ParsedArgs<T>;
|
|
51
|
+
cmd: CommandDef<T>;
|
|
52
|
+
subCommand?: CommandDef<T>;
|
|
53
|
+
data?: any;
|
|
54
|
+
};
|
|
55
|
+
type Awaitable<T> = () => T | Promise<T>;
|
|
56
|
+
type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
57
|
+
|
|
58
|
+
declare function defineCommand<T extends ArgsDef = ArgsDef>(def: CommandDef<T>): CommandDef<T>;
|
|
59
|
+
interface RunCommandOptions {
|
|
60
|
+
rawArgs: string[];
|
|
61
|
+
data?: any;
|
|
62
|
+
showUsage?: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare function runCommand<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, opts: RunCommandOptions): Promise<{
|
|
65
|
+
result: unknown;
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
declare function showUsage<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void>;
|
|
69
|
+
declare function renderUsage<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string>;
|
|
70
|
+
|
|
71
|
+
interface RunMainOptions {
|
|
72
|
+
rawArgs?: string[];
|
|
73
|
+
showUsage?: typeof showUsage;
|
|
74
|
+
}
|
|
75
|
+
declare function runMain<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, opts?: RunMainOptions): Promise<void>;
|
|
76
|
+
declare function createMain<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>): (opts?: RunMainOptions) => Promise<void>;
|
|
77
|
+
|
|
78
|
+
declare function parseArgs<T extends ArgsDef = ArgsDef>(rawArgs: string[], argsDef: ArgsDef): ParsedArgs<T>;
|
|
79
|
+
|
|
80
|
+
export { type Arg, type ArgDef, type ArgType, type ArgsDef, type Awaitable, type BooleanArgDef, type CommandContext, type CommandDef, type CommandMeta, type ParsedArgs, type PositionalArgDef, type Resolvable, type RunCommandOptions, type RunMainOptions, type StringArgDef, type SubCommandsDef, type _ArgDef, createMain, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
type ArgType = "boolean" | "string" | "positional" | undefined;
|
|
2
|
+
type _ArgDef<T extends ArgType, VT extends boolean | string> = {
|
|
3
|
+
type?: T;
|
|
4
|
+
description?: string;
|
|
5
|
+
valueHint?: string;
|
|
6
|
+
alias?: string | string[];
|
|
7
|
+
default?: VT;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BooleanArgDef = _ArgDef<"boolean", boolean>;
|
|
11
|
+
type StringArgDef = _ArgDef<"string", string>;
|
|
12
|
+
type PositionalArgDef = Omit<_ArgDef<"positional", string>, "alias">;
|
|
13
|
+
type ArgDef = BooleanArgDef | StringArgDef | PositionalArgDef;
|
|
14
|
+
type ArgsDef = Record<string, ArgDef>;
|
|
15
|
+
type Arg = ArgDef & {
|
|
16
|
+
name: string;
|
|
17
|
+
alias: string[];
|
|
18
|
+
};
|
|
19
|
+
type ParsedArgs<T extends ArgsDef = ArgsDef> = {
|
|
20
|
+
_: string[];
|
|
21
|
+
} & Record<{
|
|
22
|
+
[K in keyof T]: T[K] extends {
|
|
23
|
+
type: "positional";
|
|
24
|
+
} ? K : never;
|
|
25
|
+
}[keyof T], string> & Record<{
|
|
26
|
+
[K in keyof T]: T[K] extends {
|
|
27
|
+
type: "string";
|
|
28
|
+
} ? K : never;
|
|
29
|
+
}[keyof T], string> & Record<{
|
|
30
|
+
[K in keyof T]: T[K] extends {
|
|
31
|
+
type: "boolean";
|
|
32
|
+
} ? K : never;
|
|
33
|
+
}[keyof T], boolean> & Record<string, string | boolean | string[]>;
|
|
34
|
+
interface CommandMeta {
|
|
35
|
+
name?: string;
|
|
36
|
+
version?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
type SubCommandsDef = Record<string, Resolvable<CommandDef<any>>>;
|
|
40
|
+
type CommandDef<T extends ArgsDef = ArgsDef> = {
|
|
41
|
+
meta?: Resolvable<CommandMeta>;
|
|
42
|
+
args?: Resolvable<T>;
|
|
43
|
+
subCommands?: Resolvable<SubCommandsDef>;
|
|
44
|
+
setup?: (context: CommandContext<T>) => any | Promise<any>;
|
|
45
|
+
cleanup?: (context: CommandContext<T>) => any | Promise<any>;
|
|
46
|
+
run?: (context: CommandContext<T>) => any | Promise<any>;
|
|
47
|
+
};
|
|
48
|
+
type CommandContext<T extends ArgsDef = ArgsDef> = {
|
|
49
|
+
rawArgs: string[];
|
|
50
|
+
args: ParsedArgs<T>;
|
|
51
|
+
cmd: CommandDef<T>;
|
|
52
|
+
subCommand?: CommandDef<T>;
|
|
53
|
+
data?: any;
|
|
54
|
+
};
|
|
55
|
+
type Awaitable<T> = () => T | Promise<T>;
|
|
56
|
+
type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
57
|
+
|
|
58
|
+
declare function defineCommand<T extends ArgsDef = ArgsDef>(def: CommandDef<T>): CommandDef<T>;
|
|
59
|
+
interface RunCommandOptions {
|
|
60
|
+
rawArgs: string[];
|
|
61
|
+
data?: any;
|
|
62
|
+
showUsage?: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare function runCommand<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, opts: RunCommandOptions): Promise<{
|
|
65
|
+
result: unknown;
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
declare function showUsage<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void>;
|
|
69
|
+
declare function renderUsage<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string>;
|
|
70
|
+
|
|
71
|
+
interface RunMainOptions {
|
|
72
|
+
rawArgs?: string[];
|
|
73
|
+
showUsage?: typeof showUsage;
|
|
74
|
+
}
|
|
75
|
+
declare function runMain<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, opts?: RunMainOptions): Promise<void>;
|
|
76
|
+
declare function createMain<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>): (opts?: RunMainOptions) => Promise<void>;
|
|
77
|
+
|
|
78
|
+
declare function parseArgs<T extends ArgsDef = ArgsDef>(rawArgs: string[], argsDef: ArgsDef): ParsedArgs<T>;
|
|
79
|
+
|
|
80
|
+
export { type Arg, type ArgDef, type ArgType, type ArgsDef, type Awaitable, type BooleanArgDef, type CommandContext, type CommandDef, type CommandMeta, type ParsedArgs, type PositionalArgDef, type Resolvable, type RunCommandOptions, type RunMainOptions, type StringArgDef, type SubCommandsDef, type _ArgDef, createMain, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };
|