@maizzle/framework 6.0.0-8 → 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 -74
- package/CHANGELOG.md +0 -764
- 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 -129
- 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,423 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { join, normalize, resolve } from "pathe";
|
|
6
|
+
import { x } from "tinyexec";
|
|
7
|
+
import { join as join$1 } from "node:path";
|
|
8
|
+
async function findup(cwd, match, options = {}) {
|
|
9
|
+
const segments = normalize(cwd).split("/");
|
|
10
|
+
while (segments.length > 0) {
|
|
11
|
+
const result = await match(segments.join("/") || "/");
|
|
12
|
+
if (result || !options.includeParentDirs) return result;
|
|
13
|
+
segments.pop();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function readPackageJSON(cwd) {
|
|
17
|
+
return findup(cwd, (p) => {
|
|
18
|
+
const pkgPath = join$1(p, "package.json");
|
|
19
|
+
if (existsSync(pkgPath)) return readFile(pkgPath, "utf8").then((data) => JSON.parse(data));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function cached(fn) {
|
|
23
|
+
let v;
|
|
24
|
+
return () => {
|
|
25
|
+
if (v === void 0) v = fn().then((r) => {
|
|
26
|
+
v = r;
|
|
27
|
+
return v;
|
|
28
|
+
});
|
|
29
|
+
return v;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const hasCorepack = cached(async () => {
|
|
33
|
+
if (globalThis.process?.versions?.webcontainer) return false;
|
|
34
|
+
try {
|
|
35
|
+
const { exitCode } = await x("corepack", ["--version"]);
|
|
36
|
+
return exitCode === 0;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
async function executeCommand(command, args, options = {}) {
|
|
42
|
+
const xArgs = command !== "npm" && command !== "bun" && command !== "deno" && options.corepack !== false && await hasCorepack() ? ["corepack", [command, ...args]] : [command, args];
|
|
43
|
+
const { exitCode, stdout, stderr } = await x(xArgs[0], xArgs[1], { nodeOptions: {
|
|
44
|
+
cwd: resolve(options.cwd || process.cwd()),
|
|
45
|
+
env: options.env,
|
|
46
|
+
stdio: options.silent ? "pipe" : "inherit"
|
|
47
|
+
} });
|
|
48
|
+
if (exitCode !== 0) throw new Error(`\`${xArgs.flat().join(" ")}\` failed.${options.silent ? [
|
|
49
|
+
"",
|
|
50
|
+
stdout,
|
|
51
|
+
stderr
|
|
52
|
+
].join("\n") : ""}`);
|
|
53
|
+
}
|
|
54
|
+
const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
|
|
55
|
+
async function resolveOperationOptions(options = {}) {
|
|
56
|
+
const cwd = options.cwd || process.cwd();
|
|
57
|
+
const env = {
|
|
58
|
+
...process.env,
|
|
59
|
+
...options.env
|
|
60
|
+
};
|
|
61
|
+
const packageManager = (typeof options.packageManager === "string" ? packageManagers.find((pm) => pm.name === options.packageManager) : options.packageManager) || await detectPackageManager(options.cwd || process.cwd());
|
|
62
|
+
if (!packageManager) throw new Error(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG);
|
|
63
|
+
return {
|
|
64
|
+
cwd,
|
|
65
|
+
env,
|
|
66
|
+
silent: options.silent ?? false,
|
|
67
|
+
packageManager,
|
|
68
|
+
dev: options.dev ?? false,
|
|
69
|
+
workspace: options.workspace,
|
|
70
|
+
global: options.global ?? false,
|
|
71
|
+
dry: options.dry ?? false,
|
|
72
|
+
corepack: options.corepack ?? true
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function getWorkspaceArgs(options) {
|
|
76
|
+
if (!options.workspace) return [];
|
|
77
|
+
const workspacePkg = typeof options.workspace === "string" && options.workspace !== "" ? options.workspace : void 0;
|
|
78
|
+
if (options.packageManager.name === "pnpm") return workspacePkg ? ["--filter", workspacePkg] : ["--workspace-root"];
|
|
79
|
+
if (options.packageManager.name === "npm") return workspacePkg ? ["-w", workspacePkg] : ["--workspaces"];
|
|
80
|
+
if (options.packageManager.name === "yarn") if (!options.packageManager.majorVersion || options.packageManager.majorVersion === "1") return workspacePkg ? ["--cwd", workspacePkg] : ["-W"];
|
|
81
|
+
else return workspacePkg ? ["workspace", workspacePkg] : [];
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
function getWorkspaceArgs2(options) {
|
|
85
|
+
if (!options.workspace) return [];
|
|
86
|
+
const workspacePkg = typeof options.workspace === "string" && options.workspace !== "" ? options.workspace : void 0;
|
|
87
|
+
if (options.packageManager === "pnpm") return workspacePkg ? ["--filter", workspacePkg] : ["--workspace-root"];
|
|
88
|
+
if (options.packageManager === "npm") return workspacePkg ? ["-w", workspacePkg] : ["--workspaces"];
|
|
89
|
+
if (options.packageManager === "yarn") if (options.yarnBerry) return workspacePkg ? ["workspace", workspacePkg] : [];
|
|
90
|
+
else return workspacePkg ? ["--cwd", workspacePkg] : ["-W"];
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
function fmtCommand(args) {
|
|
94
|
+
return args.filter(Boolean).map((arg, i) => i > 0 && arg.includes(" ") ? `"${arg}"` : arg).join(" ");
|
|
95
|
+
}
|
|
96
|
+
function doesDependencyExist(name, options) {
|
|
97
|
+
const require = createRequire(options.cwd.endsWith("/") ? options.cwd : options.cwd + "/");
|
|
98
|
+
try {
|
|
99
|
+
return require.resolve(name).startsWith(options.cwd);
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function parsePackageManagerField(packageManager) {
|
|
105
|
+
const [name, _version] = (packageManager || "").split("@");
|
|
106
|
+
const [version, buildMeta] = _version?.split("+") || [];
|
|
107
|
+
if (name && name !== "-" && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name)) return {
|
|
108
|
+
name,
|
|
109
|
+
version,
|
|
110
|
+
buildMeta
|
|
111
|
+
};
|
|
112
|
+
const sanitized = (name || "").replace(/\W+/g, "");
|
|
113
|
+
return {
|
|
114
|
+
name: sanitized,
|
|
115
|
+
version,
|
|
116
|
+
buildMeta,
|
|
117
|
+
warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${name}\` to \`${sanitized}\``]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const packageManagers = [
|
|
121
|
+
{
|
|
122
|
+
name: "npm",
|
|
123
|
+
command: "npm",
|
|
124
|
+
lockFile: "package-lock.json"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "pnpm",
|
|
128
|
+
command: "pnpm",
|
|
129
|
+
lockFile: "pnpm-lock.yaml",
|
|
130
|
+
files: ["pnpm-workspace.yaml"]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "bun",
|
|
134
|
+
command: "bun",
|
|
135
|
+
lockFile: ["bun.lockb", "bun.lock"]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "yarn",
|
|
139
|
+
command: "yarn",
|
|
140
|
+
lockFile: "yarn.lock",
|
|
141
|
+
files: [".yarnrc.yml"]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "deno",
|
|
145
|
+
command: "deno",
|
|
146
|
+
lockFile: "deno.lock",
|
|
147
|
+
files: ["deno.json"]
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
async function detectPackageManager(cwd, options = {}) {
|
|
151
|
+
const detected = await findup(resolve(cwd || "."), async (path) => {
|
|
152
|
+
if (!options.ignorePackageJSON) {
|
|
153
|
+
const packageJSONPath = join(path, "package.json");
|
|
154
|
+
if (existsSync(packageJSONPath)) {
|
|
155
|
+
const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
|
|
156
|
+
if (packageJSON?.packageManager) {
|
|
157
|
+
const { name, version = "0.0.0", buildMeta, warnings } = parsePackageManagerField(packageJSON.packageManager);
|
|
158
|
+
if (name) {
|
|
159
|
+
const majorVersion = version.split(".")[0];
|
|
160
|
+
const packageManager = packageManagers.find((pm) => pm.name === name && pm.majorVersion === majorVersion) || packageManagers.find((pm) => pm.name === name);
|
|
161
|
+
return {
|
|
162
|
+
name,
|
|
163
|
+
command: name,
|
|
164
|
+
version,
|
|
165
|
+
majorVersion,
|
|
166
|
+
buildMeta,
|
|
167
|
+
warnings,
|
|
168
|
+
files: packageManager?.files,
|
|
169
|
+
lockFile: packageManager?.lockFile
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (existsSync(join(path, "deno.json"))) return packageManagers.find((pm) => pm.name === "deno");
|
|
175
|
+
}
|
|
176
|
+
if (!options.ignoreLockFile) {
|
|
177
|
+
for (const packageManager of packageManagers) if ([packageManager.lockFile, packageManager.files].flat().filter(Boolean).some((file) => existsSync(resolve(path, file)))) return { ...packageManager };
|
|
178
|
+
}
|
|
179
|
+
}, { includeParentDirs: options.includeParentDirs ?? true });
|
|
180
|
+
if (!detected && !options.ignoreArgv) {
|
|
181
|
+
const scriptArg = process.argv[1];
|
|
182
|
+
if (scriptArg) {
|
|
183
|
+
for (const packageManager of packageManagers) if (new RegExp(`[/\\\\]\\.?${packageManager.command}`).test(scriptArg)) return packageManager;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return detected;
|
|
187
|
+
}
|
|
188
|
+
function installDependenciesCommand(packageManager, options = {}) {
|
|
189
|
+
const installCmd = options.short ? "i" : "install";
|
|
190
|
+
const pmToFrozenLockfileInstallCommand = {
|
|
191
|
+
npm: ["ci"],
|
|
192
|
+
yarn: [installCmd, "--immutable"],
|
|
193
|
+
bun: [installCmd, "--frozen-lockfile"],
|
|
194
|
+
pnpm: [installCmd, "--frozen-lockfile"],
|
|
195
|
+
deno: [installCmd, "--frozen"]
|
|
196
|
+
};
|
|
197
|
+
return fmtCommand([packageManager, ...options.frozenLockFile ? pmToFrozenLockfileInstallCommand[packageManager] : [installCmd]]);
|
|
198
|
+
}
|
|
199
|
+
function addDependencyCommand(packageManager, name, options = {}) {
|
|
200
|
+
const names = Array.isArray(name) ? name : [name];
|
|
201
|
+
if (packageManager === "deno") {
|
|
202
|
+
for (let i = 0; i < names.length; i++) if (!/^(npm|jsr|file):.+$/.test(names[i])) names[i] = `npm:${names[i]}`;
|
|
203
|
+
}
|
|
204
|
+
return fmtCommand([packageManager, ...(packageManager === "yarn" ? [
|
|
205
|
+
...getWorkspaceArgs2({
|
|
206
|
+
packageManager,
|
|
207
|
+
...options
|
|
208
|
+
}),
|
|
209
|
+
options.global && !options.yarnBerry ? "global" : "",
|
|
210
|
+
"add",
|
|
211
|
+
options.dev ? options.short ? "-D" : "--dev" : "",
|
|
212
|
+
...names
|
|
213
|
+
] : [
|
|
214
|
+
packageManager === "npm" ? options.short ? "i" : "install" : "add",
|
|
215
|
+
...getWorkspaceArgs2({
|
|
216
|
+
packageManager,
|
|
217
|
+
...options
|
|
218
|
+
}),
|
|
219
|
+
options.dev ? options.short ? "-D" : "--dev" : "",
|
|
220
|
+
options.global ? "-g" : "",
|
|
221
|
+
...names
|
|
222
|
+
]).filter(Boolean)]);
|
|
223
|
+
}
|
|
224
|
+
function runScriptCommand(packageManager, name, options = {}) {
|
|
225
|
+
return fmtCommand([packageManager, ...[
|
|
226
|
+
packageManager === "deno" ? "task" : "run",
|
|
227
|
+
name,
|
|
228
|
+
...options.args || []
|
|
229
|
+
]]);
|
|
230
|
+
}
|
|
231
|
+
function dlxCommand(packageManager, name, options = {}) {
|
|
232
|
+
const command = {
|
|
233
|
+
npm: options.short ? "npx" : "npm exec",
|
|
234
|
+
yarn: "yarn dlx",
|
|
235
|
+
pnpm: options.short ? "pnpx" : "pnpm dlx",
|
|
236
|
+
bun: options.short ? "bunx" : "bun x",
|
|
237
|
+
deno: "deno run -A"
|
|
238
|
+
}[packageManager];
|
|
239
|
+
let packages = options.packages || [];
|
|
240
|
+
if (packageManager === "deno") {
|
|
241
|
+
if (!name.startsWith("npm:")) name = `npm:${name}`;
|
|
242
|
+
packages = packages.map((pkg) => pkg.startsWith("npm:") ? pkg : `npm:${pkg}`);
|
|
243
|
+
}
|
|
244
|
+
const packageArgs = [];
|
|
245
|
+
if (packages.length > 0 && packageManager !== "deno") {
|
|
246
|
+
const packageFlag = options.short && /^npm|yarn$/.test(packageManager) ? "-p" : "--package";
|
|
247
|
+
for (const pkg of packages) packageArgs.push(`${packageFlag}=${pkg}`);
|
|
248
|
+
}
|
|
249
|
+
const argSep = packageManager === "npm" && !options.short ? "--" : "";
|
|
250
|
+
return fmtCommand([
|
|
251
|
+
command,
|
|
252
|
+
...packageArgs,
|
|
253
|
+
name,
|
|
254
|
+
argSep,
|
|
255
|
+
...options.args || []
|
|
256
|
+
]);
|
|
257
|
+
}
|
|
258
|
+
async function installDependencies(options = {}) {
|
|
259
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
260
|
+
const commandArgs = options.frozenLockFile ? {
|
|
261
|
+
npm: ["ci"],
|
|
262
|
+
yarn: ["install", "--immutable"],
|
|
263
|
+
bun: ["install", "--frozen-lockfile"],
|
|
264
|
+
pnpm: ["install", "--frozen-lockfile"],
|
|
265
|
+
deno: ["install", "--frozen"]
|
|
266
|
+
}[resolvedOptions.packageManager.name] : ["install"];
|
|
267
|
+
if (options.ignoreWorkspace && resolvedOptions.packageManager.name === "pnpm") commandArgs.push("--ignore-workspace");
|
|
268
|
+
if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, commandArgs, {
|
|
269
|
+
cwd: resolvedOptions.cwd,
|
|
270
|
+
silent: resolvedOptions.silent,
|
|
271
|
+
corepack: resolvedOptions.corepack
|
|
272
|
+
});
|
|
273
|
+
return { exec: {
|
|
274
|
+
command: resolvedOptions.packageManager.command,
|
|
275
|
+
args: commandArgs
|
|
276
|
+
} };
|
|
277
|
+
}
|
|
278
|
+
async function addDependency(name, options = {}) {
|
|
279
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
280
|
+
const names = Array.isArray(name) ? name : [name];
|
|
281
|
+
if (resolvedOptions.packageManager.name === "deno") {
|
|
282
|
+
for (let i = 0; i < names.length; i++) if (!/^(npm|jsr|file):.+$/.test(names[i] || "")) names[i] = `npm:${names[i]}`;
|
|
283
|
+
}
|
|
284
|
+
if (names.length === 0) return {};
|
|
285
|
+
const args = (resolvedOptions.packageManager.name === "yarn" ? [
|
|
286
|
+
...getWorkspaceArgs(resolvedOptions),
|
|
287
|
+
resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
|
|
288
|
+
"add",
|
|
289
|
+
resolvedOptions.dev ? "-D" : "",
|
|
290
|
+
...names
|
|
291
|
+
] : [
|
|
292
|
+
resolvedOptions.packageManager.name === "npm" ? "install" : "add",
|
|
293
|
+
...getWorkspaceArgs(resolvedOptions),
|
|
294
|
+
resolvedOptions.dev ? "-D" : "",
|
|
295
|
+
resolvedOptions.global ? "-g" : "",
|
|
296
|
+
...names
|
|
297
|
+
]).filter(Boolean);
|
|
298
|
+
if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, args, {
|
|
299
|
+
cwd: resolvedOptions.cwd,
|
|
300
|
+
silent: resolvedOptions.silent,
|
|
301
|
+
corepack: resolvedOptions.corepack
|
|
302
|
+
});
|
|
303
|
+
if (!resolvedOptions.dry && options.installPeerDependencies) {
|
|
304
|
+
const existingPkg = await readPackageJSON(resolvedOptions.cwd);
|
|
305
|
+
const peerDeps = [];
|
|
306
|
+
const peerDevDeps = [];
|
|
307
|
+
const _require = createRequire(join$1(resolvedOptions.cwd, "/_.js"));
|
|
308
|
+
for (const _name of names) {
|
|
309
|
+
const pkgName = _name.match(/^(.[^@]+)/)?.[0];
|
|
310
|
+
const pkg = await readPackageJSON(_require.resolve(pkgName));
|
|
311
|
+
if (!pkg?.peerDependencies || pkg?.name !== pkgName) continue;
|
|
312
|
+
for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
|
|
313
|
+
if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
|
|
314
|
+
if (existingPkg?.dependencies?.[peerDependency] || existingPkg?.devDependencies?.[peerDependency]) continue;
|
|
315
|
+
(pkg.peerDependenciesMeta?.[peerDependency]?.dev ? peerDevDeps : peerDeps).push(`${peerDependency}@${version}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (peerDeps.length > 0) await addDependency(peerDeps, { ...resolvedOptions });
|
|
319
|
+
if (peerDevDeps.length > 0) await addDevDependency(peerDevDeps, { ...resolvedOptions });
|
|
320
|
+
}
|
|
321
|
+
return { exec: {
|
|
322
|
+
command: resolvedOptions.packageManager.command,
|
|
323
|
+
args
|
|
324
|
+
} };
|
|
325
|
+
}
|
|
326
|
+
async function addDevDependency(name, options = {}) {
|
|
327
|
+
return await addDependency(name, {
|
|
328
|
+
...options,
|
|
329
|
+
dev: true
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
async function removeDependency(name, options = {}) {
|
|
333
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
334
|
+
const names = Array.isArray(name) ? name : [name];
|
|
335
|
+
if (names.length === 0) return {};
|
|
336
|
+
const args = (resolvedOptions.packageManager.name === "yarn" ? [
|
|
337
|
+
resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
|
|
338
|
+
...getWorkspaceArgs(resolvedOptions),
|
|
339
|
+
"remove",
|
|
340
|
+
resolvedOptions.dev ? "-D" : "",
|
|
341
|
+
resolvedOptions.global ? "-g" : "",
|
|
342
|
+
...names
|
|
343
|
+
] : [
|
|
344
|
+
resolvedOptions.packageManager.name === "npm" ? "uninstall" : "remove",
|
|
345
|
+
...getWorkspaceArgs(resolvedOptions),
|
|
346
|
+
resolvedOptions.dev ? "-D" : "",
|
|
347
|
+
resolvedOptions.global ? "-g" : "",
|
|
348
|
+
...names
|
|
349
|
+
]).filter(Boolean);
|
|
350
|
+
if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, args, {
|
|
351
|
+
cwd: resolvedOptions.cwd,
|
|
352
|
+
silent: resolvedOptions.silent,
|
|
353
|
+
corepack: resolvedOptions.corepack
|
|
354
|
+
});
|
|
355
|
+
return { exec: {
|
|
356
|
+
command: resolvedOptions.packageManager.command,
|
|
357
|
+
args
|
|
358
|
+
} };
|
|
359
|
+
}
|
|
360
|
+
async function ensureDependencyInstalled(name, options = {}) {
|
|
361
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
362
|
+
if (doesDependencyExist(name, resolvedOptions)) return true;
|
|
363
|
+
await addDependency(name, resolvedOptions);
|
|
364
|
+
}
|
|
365
|
+
async function dedupeDependencies(options = {}) {
|
|
366
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
367
|
+
const isSupported = !["bun", "deno"].includes(resolvedOptions.packageManager.name);
|
|
368
|
+
if (options.recreateLockfile ?? !isSupported) {
|
|
369
|
+
const lockfiles = Array.isArray(resolvedOptions.packageManager.lockFile) ? resolvedOptions.packageManager.lockFile : [resolvedOptions.packageManager.lockFile];
|
|
370
|
+
for (const lockfile of lockfiles) if (lockfile) fs.rmSync(resolve(resolvedOptions.cwd, lockfile), { force: true });
|
|
371
|
+
return await installDependencies(resolvedOptions);
|
|
372
|
+
}
|
|
373
|
+
if (isSupported) {
|
|
374
|
+
const isyarnv1 = resolvedOptions.packageManager.name === "yarn" && resolvedOptions.packageManager.majorVersion === "1";
|
|
375
|
+
if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, [isyarnv1 ? "install" : "dedupe"], {
|
|
376
|
+
cwd: resolvedOptions.cwd,
|
|
377
|
+
silent: resolvedOptions.silent,
|
|
378
|
+
corepack: resolvedOptions.corepack
|
|
379
|
+
});
|
|
380
|
+
return { exec: {
|
|
381
|
+
command: resolvedOptions.packageManager.command,
|
|
382
|
+
args: [isyarnv1 ? "install" : "dedupe"]
|
|
383
|
+
} };
|
|
384
|
+
}
|
|
385
|
+
throw new Error(`Deduplication is not supported for ${resolvedOptions.packageManager.name}`);
|
|
386
|
+
}
|
|
387
|
+
async function runScript(name, options = {}) {
|
|
388
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
389
|
+
const args = [
|
|
390
|
+
resolvedOptions.packageManager.name === "deno" ? "task" : "run",
|
|
391
|
+
name,
|
|
392
|
+
...options.args || []
|
|
393
|
+
];
|
|
394
|
+
if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, args, {
|
|
395
|
+
cwd: resolvedOptions.cwd,
|
|
396
|
+
env: resolvedOptions.env,
|
|
397
|
+
silent: resolvedOptions.silent,
|
|
398
|
+
corepack: resolvedOptions.corepack
|
|
399
|
+
});
|
|
400
|
+
return { exec: {
|
|
401
|
+
command: resolvedOptions.packageManager.command,
|
|
402
|
+
args
|
|
403
|
+
} };
|
|
404
|
+
}
|
|
405
|
+
async function dlx(name, options = {}) {
|
|
406
|
+
const resolvedOptions = await resolveOperationOptions(options);
|
|
407
|
+
const [command, ...args] = dlxCommand(resolvedOptions.packageManager.name, name, {
|
|
408
|
+
args: options.args,
|
|
409
|
+
short: options.short,
|
|
410
|
+
packages: options.packages
|
|
411
|
+
}).split(" ");
|
|
412
|
+
if (!resolvedOptions.dry) await executeCommand(command, args, {
|
|
413
|
+
cwd: resolvedOptions.cwd,
|
|
414
|
+
env: resolvedOptions.env,
|
|
415
|
+
silent: resolvedOptions.silent,
|
|
416
|
+
corepack: resolvedOptions.corepack
|
|
417
|
+
});
|
|
418
|
+
return { exec: {
|
|
419
|
+
command,
|
|
420
|
+
args
|
|
421
|
+
} };
|
|
422
|
+
}
|
|
423
|
+
export { addDependency, addDependencyCommand, addDevDependency, dedupeDependencies, detectPackageManager, dlx, dlxCommand, ensureDependencyInstalled, installDependencies, installDependenciesCommand, packageManagers, removeDependency, runScript, runScriptCommand };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# 🌆 citty
|
|
2
|
+
|
|
3
|
+
<!-- automd:badges color=yellow bundlephobia -->
|
|
4
|
+
|
|
5
|
+
[](https://npmjs.com/package/citty)
|
|
6
|
+
[](https://npmjs.com/package/citty)
|
|
7
|
+
[](https://bundlephobia.com/package/citty)
|
|
8
|
+
|
|
9
|
+
<!-- /automd -->
|
|
10
|
+
|
|
11
|
+
Elegant CLI Builder
|
|
12
|
+
|
|
13
|
+
- Zero dependency, fast and lightweight (based on native [`util.parseArgs`](https://nodejs.org/api/util.html#utilparseargsconfig))
|
|
14
|
+
- Smart value parsing with typecast and boolean shortcuts
|
|
15
|
+
- Nested sub-commands with lazy and async loading
|
|
16
|
+
- Pluggable and composable API with auto generated usage
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npx nypm add -D citty
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { defineCommand, runMain } from "citty";
|
|
26
|
+
|
|
27
|
+
const main = defineCommand({
|
|
28
|
+
meta: {
|
|
29
|
+
name: "hello",
|
|
30
|
+
version: "1.0.0",
|
|
31
|
+
description: "My Awesome CLI App",
|
|
32
|
+
},
|
|
33
|
+
args: {
|
|
34
|
+
name: {
|
|
35
|
+
type: "positional",
|
|
36
|
+
description: "Your name",
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
friendly: {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
description: "Use friendly greeting",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
setup({ args }) {
|
|
45
|
+
console.log(`now setup ${args.command}`);
|
|
46
|
+
},
|
|
47
|
+
cleanup({ args }) {
|
|
48
|
+
console.log(`now cleanup ${args.command}`);
|
|
49
|
+
},
|
|
50
|
+
run({ args }) {
|
|
51
|
+
console.log(`${args.friendly ? "Hi" : "Greetings"} ${args.name}!`);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
runMain(main);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
node index.mjs john
|
|
60
|
+
# Greetings john!
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Sub Commands
|
|
64
|
+
|
|
65
|
+
Sub commands can be nested recursively. Use lazy imports for large CLIs to avoid loading all commands at once.
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { defineCommand, runMain } from "citty";
|
|
69
|
+
|
|
70
|
+
const sub = defineCommand({
|
|
71
|
+
meta: { name: "sub", description: "Sub command" },
|
|
72
|
+
args: {
|
|
73
|
+
name: { type: "positional", description: "Your name", required: true },
|
|
74
|
+
},
|
|
75
|
+
run({ args }) {
|
|
76
|
+
console.log(`Hello ${args.name}!`);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const main = defineCommand({
|
|
81
|
+
meta: { name: "hello", version: "1.0.0", description: "My Awesome CLI App" },
|
|
82
|
+
subCommands: { sub },
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
runMain(main);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Subcommands support `meta.alias` (e.g., `["i", "add"]`) and `meta.hidden: true` to hide from help output.
|
|
89
|
+
|
|
90
|
+
### Lazy Commands
|
|
91
|
+
|
|
92
|
+
For large CLIs, lazy load sub commands so only the executed command is imported:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
const main = defineCommand({
|
|
96
|
+
meta: { name: "hello", version: "1.0.0", description: "My Awesome CLI App" },
|
|
97
|
+
subCommands: {
|
|
98
|
+
sub: () => import("./sub.mjs").then((m) => m.default),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`meta`, `args`, and `subCommands` all accept `Resolvable<T>` values — a value, Promise, function, or async function — enabling lazy and dynamic resolution.
|
|
104
|
+
|
|
105
|
+
### Hooks
|
|
106
|
+
|
|
107
|
+
Commands support `setup` and `cleanup` functions called before and after `run()`. Only the executed command's hooks run. `cleanup` always runs, even if `run()` throws.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const main = defineCommand({
|
|
111
|
+
meta: { name: "hello", version: "1.0.0", description: "My Awesome CLI App" },
|
|
112
|
+
setup() {
|
|
113
|
+
console.log("Setting up...");
|
|
114
|
+
},
|
|
115
|
+
cleanup() {
|
|
116
|
+
console.log("Cleaning up...");
|
|
117
|
+
},
|
|
118
|
+
run() {
|
|
119
|
+
console.log("Hello World!");
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Plugins
|
|
125
|
+
|
|
126
|
+
Plugins extend commands with reusable `setup` and `cleanup` hooks:
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
import { defineCommand, defineCittyPlugin, runMain } from "citty";
|
|
130
|
+
|
|
131
|
+
const logger = defineCittyPlugin({
|
|
132
|
+
name: "logger",
|
|
133
|
+
setup({ args }) {
|
|
134
|
+
console.log("Logger setup, args:", args);
|
|
135
|
+
},
|
|
136
|
+
cleanup() {
|
|
137
|
+
console.log("Logger cleanup");
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const main = defineCommand({
|
|
142
|
+
meta: { name: "hello", description: "My CLI App" },
|
|
143
|
+
plugins: [logger],
|
|
144
|
+
run() {
|
|
145
|
+
console.log("Hello!");
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
runMain(main);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Plugin `setup` hooks run before the command's `setup` (in order), `cleanup` hooks run after (in reverse). Plugins can be async or factory functions.
|
|
153
|
+
|
|
154
|
+
## Arguments
|
|
155
|
+
|
|
156
|
+
### Argument Types
|
|
157
|
+
|
|
158
|
+
| Type | Description | Example |
|
|
159
|
+
| ------------ | ---------------------------------------- | --------------------------- |
|
|
160
|
+
| `positional` | Unnamed positional args | `cli <name>` |
|
|
161
|
+
| `string` | Named string options | `--name value` |
|
|
162
|
+
| `boolean` | Boolean flags, supports `--no-` negation | `--verbose` |
|
|
163
|
+
| `enum` | Constrained to `options` array | `--level=info\|warn\|error` |
|
|
164
|
+
|
|
165
|
+
### Common Options
|
|
166
|
+
|
|
167
|
+
| Option | Description |
|
|
168
|
+
| ------------- | ------------------------------------------------------------- |
|
|
169
|
+
| `description` | Help text shown in usage output |
|
|
170
|
+
| `required` | Whether the argument is required |
|
|
171
|
+
| `default` | Default value when not provided |
|
|
172
|
+
| `alias` | Short aliases (e.g., `["f"]`). Not for `positional` |
|
|
173
|
+
| `valueHint` | Display hint in help (e.g., `"host"` renders `--name=<host>`) |
|
|
174
|
+
|
|
175
|
+
### Example
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
const main = defineCommand({
|
|
179
|
+
args: {
|
|
180
|
+
name: { type: "positional", description: "Your name", required: true },
|
|
181
|
+
friendly: { type: "boolean", description: "Use friendly greeting", alias: ["f"] },
|
|
182
|
+
greeting: { type: "string", description: "Custom greeting", default: "Hello" },
|
|
183
|
+
level: {
|
|
184
|
+
type: "enum",
|
|
185
|
+
description: "Log level",
|
|
186
|
+
options: ["debug", "info", "warn", "error"],
|
|
187
|
+
default: "info",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
run({ args }) {
|
|
191
|
+
console.log(`${args.greeting} ${args.name}! (level: ${args.level})`);
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Boolean Negation
|
|
197
|
+
|
|
198
|
+
Boolean args support `--no-` prefix. The negative variant appears in help when `default: true` or `negativeDescription` is set.
|
|
199
|
+
|
|
200
|
+
### Case-Agnostic Access
|
|
201
|
+
|
|
202
|
+
Kebab-case args can be accessed as camelCase: `args["output-dir"]` and `args.outputDir` both work.
|
|
203
|
+
|
|
204
|
+
## Built-in Flags
|
|
205
|
+
|
|
206
|
+
`--help` / `-h` and `--version` / `-v` are handled automatically. Disabled if your command defines args with the same names or aliases.
|
|
207
|
+
|
|
208
|
+
## API
|
|
209
|
+
|
|
210
|
+
| Function | Description |
|
|
211
|
+
| ----------------------------- | -------------------------------------------------------------------------- |
|
|
212
|
+
| `defineCommand(def)` | Type helper for defining commands |
|
|
213
|
+
| `runMain(cmd, opts?)` | Run a command with usage support and graceful error handling |
|
|
214
|
+
| `createMain(cmd)` | Create a wrapper that calls `runMain` when invoked |
|
|
215
|
+
| `runCommand(cmd, opts)` | Parse args and run command/sub-commands; access `result` from return value |
|
|
216
|
+
| `parseArgs(rawArgs, argsDef)` | Parse input arguments and apply defaults |
|
|
217
|
+
| `renderUsage(cmd, parent?)` | Render command usage to a string |
|
|
218
|
+
| `showUsage(cmd, parent?)` | Render usage and print to console |
|
|
219
|
+
| `defineCittyPlugin(def)` | Type helper for defining plugins |
|
|
220
|
+
|
|
221
|
+
## Development
|
|
222
|
+
|
|
223
|
+
- Clone this repository
|
|
224
|
+
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
|
|
225
|
+
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
|
|
226
|
+
- Install dependencies using `pnpm install`
|
|
227
|
+
- Run interactive tests using `pnpm dev`
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
Made with 💛 Published under [MIT License](./LICENSE).
|