@maizzle/framework 6.0.0-rc.1 → 6.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/maizzle.mjs +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +32 -0
- package/dist/build.mjs +6 -3
- package/dist/build.mjs.map +1 -1
- package/dist/components/Body.vue +111 -0
- package/dist/components/Button.vue +68 -14
- package/dist/components/CodeBlock.vue +68 -0
- package/dist/components/CodeInline.vue +49 -0
- package/dist/components/Column.vue +78 -0
- package/dist/components/Container.vue +53 -0
- package/dist/components/Divider.vue +28 -0
- package/dist/components/Head.vue +30 -0
- package/dist/components/Heading.vue +28 -0
- package/dist/components/Html.vue +104 -0
- package/dist/components/Img.vue +70 -0
- package/dist/components/Layout.vue +93 -0
- package/dist/components/Link.vue +26 -0
- package/dist/components/Markdown.vue +89 -0
- package/dist/components/Outlook.vue +36 -0
- package/dist/components/Overlap.vue +84 -0
- package/dist/components/Preheader.vue +20 -0
- package/dist/components/Row.vue +91 -0
- package/dist/components/Section.vue +83 -0
- package/dist/components/Spacer.vue +50 -7
- package/dist/components/Text.vue +29 -0
- package/dist/components/Vml.vue +165 -13
- package/dist/composables/renderContext.d.mts +5 -0
- package/dist/composables/renderContext.d.mts.map +1 -1
- package/dist/composables/renderContext.mjs.map +1 -1
- package/dist/composables/usePreheader.d.mts +24 -0
- package/dist/composables/usePreheader.d.mts.map +1 -0
- package/dist/composables/usePreheader.mjs +29 -0
- package/dist/composables/usePreheader.mjs.map +1 -0
- package/dist/config/defaults.mjs +1 -3
- package/dist/config/defaults.mjs.map +1 -1
- package/dist/config/index.mjs +7 -0
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/dist/node_modules/picomatch/index.mjs +13 -0
- package/dist/node_modules/picomatch/index.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/constants.mjs +174 -0
- package/dist/node_modules/picomatch/lib/constants.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/parse.mjs +1067 -0
- package/dist/node_modules/picomatch/lib/parse.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/picomatch.mjs +304 -0
- package/dist/node_modules/picomatch/lib/picomatch.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/scan.mjs +296 -0
- package/dist/node_modules/picomatch/lib/scan.mjs.map +1 -0
- package/dist/node_modules/picomatch/lib/utils.mjs +53 -0
- package/dist/node_modules/picomatch/lib/utils.mjs.map +1 -0
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +24 -7
- package/dist/plugin.mjs.map +1 -1
- package/dist/plugins/postcss/resolveProps.d.mts +8 -0
- package/dist/plugins/postcss/resolveProps.d.mts.map +1 -0
- package/dist/plugins/postcss/resolveProps.mjs +144 -0
- package/dist/plugins/postcss/resolveProps.mjs.map +1 -0
- package/dist/plugins/postcss/tailwindCleanup.d.mts.map +1 -1
- package/dist/plugins/postcss/tailwindCleanup.mjs +46 -13
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +1 -1
- package/dist/render/createRenderer.d.mts +8 -3
- package/dist/render/createRenderer.d.mts.map +1 -1
- package/dist/render/createRenderer.mjs +146 -10
- package/dist/render/createRenderer.mjs.map +1 -1
- package/dist/render/index.mjs +6 -3
- package/dist/render/index.mjs.map +1 -1
- package/dist/serve.d.mts.map +1 -1
- package/dist/serve.mjs +157 -63
- package/dist/serve.mjs.map +1 -1
- package/dist/server/compatibility.d.mts +1 -2
- package/dist/server/compatibility.d.mts.map +1 -1
- package/dist/server/compatibility.mjs +30 -16
- package/dist/server/compatibility.mjs.map +1 -1
- package/dist/server/email.d.mts +17 -0
- package/dist/server/email.d.mts.map +1 -0
- package/dist/server/email.mjs +41 -0
- package/dist/server/email.mjs.map +1 -0
- package/dist/server/linter.d.mts +1 -2
- package/dist/server/linter.d.mts.map +1 -1
- package/dist/server/linter.mjs +60 -71
- package/dist/server/linter.mjs.map +1 -1
- package/dist/server/ui/App.vue +206 -70
- package/dist/server/ui/components/ui/checkbox/Checkbox.vue +35 -0
- package/dist/server/ui/components/ui/checkbox/index.ts +1 -0
- package/dist/server/ui/components/ui/command/CommandDialog.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandInput.vue +19 -1
- package/dist/server/ui/components/ui/command/CommandItem.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandList.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandShortcut.vue +1 -1
- package/dist/server/ui/components/ui/dialog/DialogOverlay.vue +9 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/dist/server/ui/components/ui/scroll-area/ScrollBar.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetOverlay.vue +9 -1
- package/dist/server/ui/components/ui/sidebar/Sidebar.vue +8 -1
- package/dist/server/ui/components/ui/sidebar/SidebarProvider.vue +1 -1
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +5 -4
- package/dist/server/ui/components/ui/tags-input/TagsInput.vue +26 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +17 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItem.vue +19 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +22 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItemText.vue +17 -0
- package/dist/server/ui/components/ui/tags-input/index.ts +5 -0
- package/dist/server/ui/components/ui/toggle/index.ts +3 -3
- package/dist/server/ui/components/ui/toggle-group/ToggleGroup.vue +1 -1
- package/dist/server/ui/components/ui/toggle-group/ToggleGroupItem.vue +2 -2
- package/dist/server/ui/main.css +20 -20
- package/dist/server/ui/pages/Home.vue +12 -5
- package/dist/server/ui/pages/Preview.vue +506 -216
- package/dist/transformers/entities.d.mts.map +1 -1
- package/dist/transformers/entities.mjs +3 -0
- package/dist/transformers/entities.mjs.map +1 -1
- package/dist/transformers/filters/defaults.d.mts +6 -0
- package/dist/transformers/filters/defaults.d.mts.map +1 -0
- package/dist/transformers/filters/defaults.mjs +78 -0
- package/dist/transformers/filters/defaults.mjs.map +1 -0
- package/dist/transformers/filters/index.d.mts +22 -0
- package/dist/transformers/filters/index.d.mts.map +1 -0
- package/dist/transformers/filters/index.mjs +67 -0
- package/dist/transformers/filters/index.mjs.map +1 -0
- package/dist/transformers/index.d.mts +11 -9
- package/dist/transformers/index.d.mts.map +1 -1
- package/dist/transformers/index.mjs +19 -11
- package/dist/transformers/index.mjs.map +1 -1
- package/dist/transformers/inlineCSS.d.mts +1 -14
- package/dist/transformers/inlineCSS.d.mts.map +1 -1
- package/dist/transformers/inlineCSS.mjs +32 -36
- package/dist/transformers/inlineCSS.mjs.map +1 -1
- package/dist/transformers/purgeCSS.d.mts.map +1 -1
- package/dist/transformers/purgeCSS.mjs +67 -1
- package/dist/transformers/purgeCSS.mjs.map +1 -1
- package/dist/transformers/sixHex.d.mts +16 -0
- package/dist/transformers/sixHex.d.mts.map +1 -0
- package/dist/transformers/sixHex.mjs +30 -0
- package/dist/transformers/sixHex.mjs.map +1 -0
- package/dist/transformers/tailwindcss.d.mts +6 -2
- package/dist/transformers/tailwindcss.d.mts.map +1 -1
- package/dist/transformers/tailwindcss.mjs +54 -30
- package/dist/transformers/tailwindcss.mjs.map +1 -1
- package/dist/types/config.d.mts +436 -23
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/utils/ast/serializer.d.mts +3 -2
- package/dist/utils/ast/serializer.d.mts.map +1 -1
- package/dist/utils/ast/serializer.mjs +24 -0
- package/dist/utils/ast/serializer.mjs.map +1 -1
- package/dist/utils/detect.d.mts +5 -0
- package/dist/utils/detect.d.mts.map +1 -0
- package/dist/utils/detect.mjs +11 -0
- package/dist/utils/detect.mjs.map +1 -0
- package/node_modules/@clack/core/CHANGELOG.md +87 -4
- package/node_modules/@clack/core/README.md +1 -1
- package/node_modules/@clack/core/dist/index.d.mts +186 -48
- package/node_modules/@clack/core/dist/index.mjs +10 -14
- package/node_modules/@clack/core/dist/index.mjs.map +1 -1
- package/node_modules/@clack/core/package.json +7 -9
- package/node_modules/@clack/prompts/CHANGELOG.md +171 -7
- package/node_modules/@clack/prompts/README.md +66 -3
- package/node_modules/@clack/prompts/dist/index.d.mts +302 -76
- package/node_modules/@clack/prompts/dist/index.mjs +134 -84
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
- package/node_modules/@clack/prompts/package.json +14 -10
- package/node_modules/citty/LICENSE +0 -15
- package/node_modules/citty/README.md +166 -69
- package/node_modules/citty/dist/index.d.mts +88 -56
- package/node_modules/citty/dist/index.mjs +399 -437
- package/node_modules/citty/package.json +28 -35
- package/node_modules/giget/README.md +59 -11
- package/node_modules/giget/dist/THIRD-PARTY-LICENSES.md +205 -0
- package/node_modules/giget/dist/_chunks/giget.mjs +508 -0
- package/node_modules/giget/dist/_chunks/libs/citty.mjs +269 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.d.mts +1 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.mjs +669 -0
- package/node_modules/giget/dist/_chunks/libs/tar.mjs +2931 -0
- package/node_modules/giget/dist/_chunks/rolldown-runtime.mjs +14 -0
- package/node_modules/giget/dist/cli.d.mts +1 -0
- package/node_modules/giget/dist/cli.mjs +89 -111
- package/node_modules/giget/dist/index.d.mts +46 -35
- package/node_modules/giget/dist/index.mjs +2 -22
- package/node_modules/giget/package.json +32 -45
- package/node_modules/maizzle/README.md +140 -0
- package/node_modules/maizzle/bin/maizzle.mjs +5 -0
- package/node_modules/maizzle/dist/commands/new.d.mts +7 -0
- package/node_modules/maizzle/dist/commands/new.mjs +253 -0
- package/node_modules/{@maizzle/cli → maizzle}/dist/index.d.mts +1 -1
- package/node_modules/maizzle/dist/index.mjs +44 -0
- package/node_modules/{commander → maizzle/node_modules/commander}/Readme.md +94 -67
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/argument.js +5 -4
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/command.js +154 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/help.js +77 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/option.js +16 -3
- package/node_modules/{commander → maizzle/node_modules/commander}/package-support.json +4 -1
- package/node_modules/{commander → maizzle/node_modules/commander}/package.json +8 -8
- package/node_modules/{commander → maizzle/node_modules/commander}/typings/index.d.ts +71 -3
- package/node_modules/{@maizzle/cli → maizzle}/package.json +14 -12
- package/node_modules/tinyexec/README.md +49 -3
- package/node_modules/tinyexec/dist/main.d.mts +25 -14
- package/node_modules/tinyexec/dist/main.mjs +148 -100
- package/node_modules/tinyexec/package.json +9 -8
- package/package.json +17 -13
- package/dist/server/ui/components/ui/resizable/ResizableHandle.vue +0 -30
- package/dist/server/ui/components/ui/resizable/ResizablePanel.vue +0 -21
- package/dist/server/ui/components/ui/resizable/ResizablePanelGroup.vue +0 -25
- package/dist/server/ui/components/ui/resizable/index.ts +0 -3
- package/node_modules/@clack/core/dist/index.cjs +0 -15
- package/node_modules/@clack/core/dist/index.cjs.map +0 -1
- package/node_modules/@clack/core/dist/index.d.cts +0 -211
- package/node_modules/@clack/core/dist/index.d.ts +0 -211
- package/node_modules/@clack/prompts/dist/index.cjs +0 -87
- package/node_modules/@clack/prompts/dist/index.cjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.d.cts +0 -165
- package/node_modules/@clack/prompts/dist/index.d.ts +0 -165
- package/node_modules/@maizzle/cli/README.md +0 -58
- package/node_modules/@maizzle/cli/dist/index.mjs +0 -42
- package/node_modules/citty/dist/index.cjs +0 -475
- package/node_modules/citty/dist/index.d.cts +0 -80
- package/node_modules/citty/dist/index.d.ts +0 -80
- package/node_modules/consola/LICENSE +0 -47
- package/node_modules/consola/README.md +0 -352
- package/node_modules/consola/basic.d.ts +0 -1
- package/node_modules/consola/browser.d.ts +0 -1
- package/node_modules/consola/core.d.ts +0 -1
- package/node_modules/consola/dist/basic.cjs +0 -32
- package/node_modules/consola/dist/basic.d.cts +0 -23
- package/node_modules/consola/dist/basic.d.mts +0 -21
- package/node_modules/consola/dist/basic.d.ts +0 -23
- package/node_modules/consola/dist/basic.mjs +0 -24
- package/node_modules/consola/dist/browser.cjs +0 -84
- package/node_modules/consola/dist/browser.d.cts +0 -23
- package/node_modules/consola/dist/browser.d.mts +0 -21
- package/node_modules/consola/dist/browser.d.ts +0 -23
- package/node_modules/consola/dist/browser.mjs +0 -76
- package/node_modules/consola/dist/chunks/prompt.cjs +0 -288
- package/node_modules/consola/dist/chunks/prompt.mjs +0 -280
- package/node_modules/consola/dist/core.cjs +0 -517
- package/node_modules/consola/dist/core.d.cts +0 -459
- package/node_modules/consola/dist/core.d.mts +0 -459
- package/node_modules/consola/dist/core.d.ts +0 -459
- package/node_modules/consola/dist/core.mjs +0 -512
- package/node_modules/consola/dist/index.cjs +0 -663
- package/node_modules/consola/dist/index.d.cts +0 -24
- package/node_modules/consola/dist/index.d.mts +0 -22
- package/node_modules/consola/dist/index.d.ts +0 -24
- package/node_modules/consola/dist/index.mjs +0 -651
- package/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +0 -75
- package/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +0 -72
- package/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +0 -288
- package/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +0 -312
- package/node_modules/consola/dist/utils.cjs +0 -64
- package/node_modules/consola/dist/utils.d.cts +0 -286
- package/node_modules/consola/dist/utils.d.mts +0 -286
- package/node_modules/consola/dist/utils.d.ts +0 -286
- package/node_modules/consola/dist/utils.mjs +0 -54
- package/node_modules/consola/lib/index.cjs +0 -10
- package/node_modules/consola/package.json +0 -136
- package/node_modules/consola/utils.d.ts +0 -1
- package/node_modules/create-maizzle/README.md +0 -86
- package/node_modules/create-maizzle/bin/create-maizzle.mjs +0 -4
- package/node_modules/create-maizzle/node_modules/@clack/core/CHANGELOG.md +0 -340
- package/node_modules/create-maizzle/node_modules/@clack/core/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/core/README.md +0 -22
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.d.mts +0 -349
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs +0 -11
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/core/package.json +0 -60
- package/node_modules/create-maizzle/node_modules/@clack/prompts/CHANGELOG.md +0 -576
- package/node_modules/create-maizzle/node_modules/@clack/prompts/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/prompts/README.md +0 -270
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.d.mts +0 -391
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs +0 -137
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/prompts/package.json +0 -65
- package/node_modules/create-maizzle/package.json +0 -47
- package/node_modules/create-maizzle/src/index.js +0 -242
- package/node_modules/defu/LICENSE +0 -21
- package/node_modules/defu/README.md +0 -171
- package/node_modules/defu/dist/defu.cjs +0 -77
- package/node_modules/defu/dist/defu.d.cts +0 -31
- package/node_modules/defu/dist/defu.d.mts +0 -29
- package/node_modules/defu/dist/defu.d.ts +0 -31
- package/node_modules/defu/dist/defu.mjs +0 -69
- package/node_modules/defu/lib/defu.cjs +0 -10
- package/node_modules/defu/lib/defu.d.cts +0 -12
- package/node_modules/defu/package.json +0 -48
- package/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -468
- package/node_modules/node-fetch-native/LICENSE +0 -114
- package/node_modules/node-fetch-native/README.md +0 -225
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -2
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -2
- package/node_modules/node-fetch-native/dist/index.cjs +0 -1
- package/node_modules/node-fetch-native/dist/index.mjs +0 -1
- package/node_modules/node-fetch-native/dist/native.cjs +0 -1
- package/node_modules/node-fetch-native/dist/native.mjs +0 -1
- package/node_modules/node-fetch-native/dist/node.cjs +0 -19
- package/node_modules/node-fetch-native/dist/node.mjs +0 -19
- package/node_modules/node-fetch-native/dist/polyfill.cjs +0 -1
- package/node_modules/node-fetch-native/dist/polyfill.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.cjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy.cjs +0 -58
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +0 -1
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -1
- package/node_modules/node-fetch-native/index.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/empty.cjs +0 -0
- package/node_modules/node-fetch-native/lib/empty.mjs +0 -0
- package/node_modules/node-fetch-native/lib/index.cjs +0 -11
- package/node_modules/node-fetch-native/lib/index.d.cts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.mts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.ts +0 -10
- package/node_modules/node-fetch-native/lib/native.cjs +0 -11
- package/node_modules/node-fetch-native/lib/polyfill.d.cts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.mts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/proxy.d.ts +0 -32
- package/node_modules/node-fetch-native/node.d.ts +0 -1
- package/node_modules/node-fetch-native/package.json +0 -138
- package/node_modules/node-fetch-native/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/proxy.d.ts +0 -1
- package/node_modules/nypm/node_modules/citty/LICENSE +0 -21
- package/node_modules/nypm/node_modules/citty/README.md +0 -231
- package/node_modules/nypm/node_modules/citty/dist/index.d.mts +0 -112
- package/node_modules/nypm/node_modules/citty/dist/index.mjs +0 -425
- package/node_modules/nypm/node_modules/citty/package.json +0 -42
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/THIRD-PARTY-LICENSES.md +0 -0
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/_chunks/libs/scule.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/LICENSE +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/component.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/config.ts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/layout.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/template.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/LICENSE +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/esm.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/index.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/error.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/suggestSimilar.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/typings/esm.d.mts +0 -0
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { a as resolve$1, i as relative, n as basename$1, r as dirname$1 } from "./libs/nypm.mjs";
|
|
2
|
+
import { createWriteStream, existsSync, readdirSync, renameSync } from "node:fs";
|
|
3
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { PassThrough, Readable, pipeline } from "node:stream";
|
|
5
|
+
import { pipeline as pipeline$1 } from "node:stream/promises";
|
|
6
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
7
|
+
import { homedir, tmpdir } from "node:os";
|
|
8
|
+
import { promisify } from "node:util";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
//#region src/_utils.ts
|
|
11
|
+
async function download(url, filePath, options = {}) {
|
|
12
|
+
const infoPath = filePath + ".json";
|
|
13
|
+
const info = JSON.parse(await readFile(infoPath, "utf8").catch(() => "{}"));
|
|
14
|
+
const etag = (await sendFetch(url, {
|
|
15
|
+
method: "HEAD",
|
|
16
|
+
headers: options.headers
|
|
17
|
+
}).catch(() => void 0))?.headers.get("etag");
|
|
18
|
+
if (info.etag === etag && existsSync(filePath)) return;
|
|
19
|
+
if (typeof etag === "string") info.etag = etag;
|
|
20
|
+
const response = await sendFetch(url, { headers: options.headers });
|
|
21
|
+
if (response.status >= 400) throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
|
|
22
|
+
const stream = createWriteStream(filePath);
|
|
23
|
+
await promisify(pipeline)(response.body, stream);
|
|
24
|
+
await writeFile(infoPath, JSON.stringify(info), "utf8");
|
|
25
|
+
}
|
|
26
|
+
const inputRegex = /^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/;
|
|
27
|
+
const expandedInputRegex = /^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;
|
|
28
|
+
function parseGitURI(input, options) {
|
|
29
|
+
const useExpanded = options?.expandRepo || input.includes("::");
|
|
30
|
+
const m = input.match(useExpanded ? expandedInputRegex : inputRegex)?.groups || {};
|
|
31
|
+
const subdir = useExpanded ? m.subdir ? "/" + m.subdir : "/" : m.subdir || "/";
|
|
32
|
+
return {
|
|
33
|
+
repo: m.repo || "",
|
|
34
|
+
subdir,
|
|
35
|
+
ref: m.ref ? m.ref.slice(1) : "main"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function debug(...args) {
|
|
39
|
+
if (process.env.DEBUG) console.debug("[giget]", ...args);
|
|
40
|
+
}
|
|
41
|
+
async function sendFetch(url, options = {}) {
|
|
42
|
+
if (options.headers?.["sec-fetch-mode"]) options.mode = options.headers["sec-fetch-mode"];
|
|
43
|
+
const res = await fetch(url, {
|
|
44
|
+
...options,
|
|
45
|
+
headers: normalizeHeaders(options.headers)
|
|
46
|
+
}).catch((error) => {
|
|
47
|
+
throw new Error(`Failed to download ${url}: ${error}`, { cause: error });
|
|
48
|
+
});
|
|
49
|
+
if (options.validateStatus && res.status >= 400) throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`);
|
|
50
|
+
return res;
|
|
51
|
+
}
|
|
52
|
+
function cacheDirectory() {
|
|
53
|
+
const cacheDir = process.env.XDG_CACHE_HOME ? resolve$1(process.env.XDG_CACHE_HOME, "giget") : resolve$1(homedir(), ".cache/giget");
|
|
54
|
+
if (process.platform === "win32") {
|
|
55
|
+
const windowsCacheDir = resolve$1(tmpdir(), "giget");
|
|
56
|
+
if (!existsSync(windowsCacheDir) && existsSync(cacheDir)) try {
|
|
57
|
+
renameSync(cacheDir, windowsCacheDir);
|
|
58
|
+
} catch {}
|
|
59
|
+
return windowsCacheDir;
|
|
60
|
+
}
|
|
61
|
+
return cacheDir;
|
|
62
|
+
}
|
|
63
|
+
function normalizeHeaders(headers = {}) {
|
|
64
|
+
const normalized = {};
|
|
65
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
66
|
+
if (!value) continue;
|
|
67
|
+
normalized[key.toLowerCase()] = value;
|
|
68
|
+
}
|
|
69
|
+
return normalized;
|
|
70
|
+
}
|
|
71
|
+
function currentShell() {
|
|
72
|
+
if (process.env.SHELL) return process.env.SHELL;
|
|
73
|
+
if (process.platform === "win32") return "cmd.exe";
|
|
74
|
+
return "/bin/bash";
|
|
75
|
+
}
|
|
76
|
+
function startShell(cwd) {
|
|
77
|
+
cwd = resolve$1(cwd);
|
|
78
|
+
const shell = currentShell();
|
|
79
|
+
console.info(`(experimental) Opening shell in ${relative(process.cwd(), cwd)}...`);
|
|
80
|
+
spawnSync(shell, [], {
|
|
81
|
+
cwd,
|
|
82
|
+
shell: true,
|
|
83
|
+
stdio: "inherit"
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/git.ts
|
|
88
|
+
const git = (input, options) => {
|
|
89
|
+
const parsed = parseGitCloneURI(input);
|
|
90
|
+
return {
|
|
91
|
+
name: parsed.name,
|
|
92
|
+
version: parsed.subdir ? `${parsed.version || "default"}-${parsed.subdir.replaceAll("/", "-")}` : parsed.version,
|
|
93
|
+
tar: ({ auth } = {}) => _cloneAndTar(parsed, auth ?? options.auth)
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
function parseGitCloneURI(input, opts = {}) {
|
|
97
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
98
|
+
let uri = input.replace(/#.*$/, "");
|
|
99
|
+
let pathSubdir;
|
|
100
|
+
if (/^[./]/.test(input)) uri = resolve$1(cwd, uri);
|
|
101
|
+
else if (/^https?:\/\//.test(uri)) {
|
|
102
|
+
const httpMatch = /^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(uri);
|
|
103
|
+
if (httpMatch) {
|
|
104
|
+
const [, origin, repo, rest] = httpMatch;
|
|
105
|
+
uri = `${origin}/${repo}`;
|
|
106
|
+
if (rest) pathSubdir = rest;
|
|
107
|
+
}
|
|
108
|
+
} else if (uri.includes("@")) {
|
|
109
|
+
const sshMatch = /^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(uri);
|
|
110
|
+
if (sshMatch) {
|
|
111
|
+
const [, repoUri, rest] = sshMatch;
|
|
112
|
+
uri = repoUri;
|
|
113
|
+
if (rest) pathSubdir = rest;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
const hostMap = {
|
|
117
|
+
"github:": "https://github.com/",
|
|
118
|
+
"gh:": "https://github.com/",
|
|
119
|
+
"gitlab:": "https://gitlab.com/",
|
|
120
|
+
"bitbucket:": "https://bitbucket.org/",
|
|
121
|
+
"sourcehut:": "https://git.sr.ht/~"
|
|
122
|
+
};
|
|
123
|
+
const host = /^(.+?:)/.exec(uri)?.at(1);
|
|
124
|
+
if (host && hostMap[host]) uri = uri.replace(host, hostMap[host]);
|
|
125
|
+
else if (!host) uri = `${(process.env.GIGET_GIT_HOST || "https://github.com/").replace(/\/$/, "")}/${uri}`;
|
|
126
|
+
const httpMatch = /^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(uri);
|
|
127
|
+
if (httpMatch) {
|
|
128
|
+
const [, repoUri, rest] = httpMatch;
|
|
129
|
+
uri = repoUri;
|
|
130
|
+
if (rest) pathSubdir = rest;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const name = uri.replace(/^https?:\/\//, "").replace(/^.+@/, "").replace(/(\.git)?(#.*)?$/, "").replace(/^\W+/, "").replaceAll(/[:/]/g, "-");
|
|
134
|
+
const [version, hashSubdir] = /#(.+)$/.exec(input)?.at(1)?.split(":") ?? [];
|
|
135
|
+
const resolvedVersion = version || void 0;
|
|
136
|
+
const subdir = hashSubdir || pathSubdir;
|
|
137
|
+
return {
|
|
138
|
+
uri,
|
|
139
|
+
name,
|
|
140
|
+
...resolvedVersion && { version: resolvedVersion },
|
|
141
|
+
...subdir && { subdir }
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function _cloneAndTar(parsed, token) {
|
|
145
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "giget-git-"));
|
|
146
|
+
if (token && /[\r\n]/.test(token)) throw new Error("Auth token must not contain newline characters");
|
|
147
|
+
const execEnv = {
|
|
148
|
+
...process.env,
|
|
149
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
150
|
+
};
|
|
151
|
+
if (token) {
|
|
152
|
+
execEnv.GIT_CONFIG_COUNT = "1";
|
|
153
|
+
execEnv.GIT_CONFIG_KEY_0 = "http.extraHeader";
|
|
154
|
+
execEnv.GIT_CONFIG_VALUE_0 = `Authorization: Bearer ${token}`;
|
|
155
|
+
}
|
|
156
|
+
const execOpts = {
|
|
157
|
+
env: execEnv,
|
|
158
|
+
timeout: 6e4
|
|
159
|
+
};
|
|
160
|
+
const status = _createStatus();
|
|
161
|
+
const gitExec = (args) => _gitSpawn(args, execOpts, status);
|
|
162
|
+
const gitExecIn = (args) => _gitSpawn(args, {
|
|
163
|
+
...execOpts,
|
|
164
|
+
cwd: tmpDir
|
|
165
|
+
}, status);
|
|
166
|
+
try {
|
|
167
|
+
const cloneArgs = [
|
|
168
|
+
"clone",
|
|
169
|
+
"--progress",
|
|
170
|
+
"--depth",
|
|
171
|
+
"1"
|
|
172
|
+
];
|
|
173
|
+
if (parsed.subdir) cloneArgs.push("--filter=blob:none", "--sparse", "--no-checkout");
|
|
174
|
+
if (parsed.version) cloneArgs.push("--branch", parsed.version);
|
|
175
|
+
cloneArgs.push("--", parsed.uri, tmpDir);
|
|
176
|
+
try {
|
|
177
|
+
status.update("Cloning...");
|
|
178
|
+
await gitExec(cloneArgs);
|
|
179
|
+
status.update("Cloned.");
|
|
180
|
+
} catch (cloneError) {
|
|
181
|
+
if (!parsed.version) throw cloneError;
|
|
182
|
+
debug("Shallow clone failed, falling back to full clone:", cloneError);
|
|
183
|
+
status.update("Shallow clone failed, cloning...");
|
|
184
|
+
await rm(tmpDir, {
|
|
185
|
+
recursive: true,
|
|
186
|
+
force: true
|
|
187
|
+
});
|
|
188
|
+
await mkdir(tmpDir, { recursive: true });
|
|
189
|
+
await gitExecIn(["init"]);
|
|
190
|
+
await gitExecIn([
|
|
191
|
+
"remote",
|
|
192
|
+
"add",
|
|
193
|
+
"origin",
|
|
194
|
+
parsed.uri
|
|
195
|
+
]);
|
|
196
|
+
await gitExecIn(["fetch", "origin"]);
|
|
197
|
+
await gitExecIn(["checkout", parsed.version]);
|
|
198
|
+
status.update("Fetched.");
|
|
199
|
+
}
|
|
200
|
+
if (parsed.subdir) {
|
|
201
|
+
status.update(`Sparse checkout ${parsed.subdir}...`);
|
|
202
|
+
await gitExecIn([
|
|
203
|
+
"sparse-checkout",
|
|
204
|
+
"set",
|
|
205
|
+
parsed.subdir
|
|
206
|
+
]);
|
|
207
|
+
await gitExecIn(["checkout"]);
|
|
208
|
+
}
|
|
209
|
+
status.update("Packing...");
|
|
210
|
+
const tarDir = parsed.subdir ? join(tmpDir, parsed.subdir) : tmpDir;
|
|
211
|
+
const { create } = await import("./libs/tar.mjs").then((n) => n.t);
|
|
212
|
+
status.done();
|
|
213
|
+
const stream = create({
|
|
214
|
+
gzip: true,
|
|
215
|
+
cwd: tarDir,
|
|
216
|
+
filter: (path) => !path.startsWith(".git/") && path !== ".git" && !path.startsWith("./.git/") && path !== "./.git"
|
|
217
|
+
}, ["."]).pipe(new PassThrough());
|
|
218
|
+
let cleaned = false;
|
|
219
|
+
const cleanup = () => {
|
|
220
|
+
if (cleaned) return;
|
|
221
|
+
cleaned = true;
|
|
222
|
+
rm(tmpDir, {
|
|
223
|
+
recursive: true,
|
|
224
|
+
force: true
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
stream.on("end", cleanup);
|
|
228
|
+
stream.on("error", cleanup);
|
|
229
|
+
stream.on("close", cleanup);
|
|
230
|
+
return stream;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
status.done();
|
|
233
|
+
await rm(tmpDir, {
|
|
234
|
+
recursive: true,
|
|
235
|
+
force: true
|
|
236
|
+
});
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const _spinnerFrames = [
|
|
241
|
+
"⠋",
|
|
242
|
+
"⠙",
|
|
243
|
+
"⠹",
|
|
244
|
+
"⠸",
|
|
245
|
+
"⠼",
|
|
246
|
+
"⠴",
|
|
247
|
+
"⠦",
|
|
248
|
+
"⠧",
|
|
249
|
+
"⠇",
|
|
250
|
+
"⠏"
|
|
251
|
+
];
|
|
252
|
+
function _gitSpawn(args, opts, status) {
|
|
253
|
+
return new Promise((resolve, reject) => {
|
|
254
|
+
const proc = spawn("git", args, {
|
|
255
|
+
...opts,
|
|
256
|
+
stdio: [
|
|
257
|
+
"ignore",
|
|
258
|
+
"pipe",
|
|
259
|
+
"pipe"
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
proc.stdout.resume();
|
|
263
|
+
let lastLine = "";
|
|
264
|
+
proc.stderr?.on("data", (chunk) => {
|
|
265
|
+
const str = chunk.toString();
|
|
266
|
+
for (const line of str.split(/[\r\n]/)) {
|
|
267
|
+
const clean = line.trim();
|
|
268
|
+
if (clean) lastLine = clean;
|
|
269
|
+
}
|
|
270
|
+
if (status) status.update(lastLine);
|
|
271
|
+
});
|
|
272
|
+
proc.on("close", (code) => {
|
|
273
|
+
if (code === 0) resolve(lastLine);
|
|
274
|
+
else reject(/* @__PURE__ */ new Error(`git ${args[0]} exited with code ${code}. Is git installed?`));
|
|
275
|
+
});
|
|
276
|
+
proc.on("error", (err) => {
|
|
277
|
+
if (err.code === "ENOENT") reject(/* @__PURE__ */ new Error("git is not installed or not found in PATH"));
|
|
278
|
+
else reject(err);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function _createStatus() {
|
|
283
|
+
if (!process.stderr.isTTY) return {
|
|
284
|
+
update(_text) {},
|
|
285
|
+
done() {}
|
|
286
|
+
};
|
|
287
|
+
let msg = "";
|
|
288
|
+
let frame = 0;
|
|
289
|
+
const render = () => {
|
|
290
|
+
const spinner = _spinnerFrames[frame % _spinnerFrames.length];
|
|
291
|
+
frame++;
|
|
292
|
+
process.stderr.write(`\x1B[2K\r\x1B[2m${spinner} ${msg}\x1B[0m`);
|
|
293
|
+
};
|
|
294
|
+
const interval = setInterval(render, 80);
|
|
295
|
+
return {
|
|
296
|
+
update(text) {
|
|
297
|
+
msg = text;
|
|
298
|
+
render();
|
|
299
|
+
},
|
|
300
|
+
done() {
|
|
301
|
+
clearInterval(interval);
|
|
302
|
+
process.stderr.write("\x1B[2K\r");
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/providers.ts
|
|
308
|
+
const http = async (input, options) => {
|
|
309
|
+
if (input.endsWith(".json")) return await _httpJSON(input, options);
|
|
310
|
+
const url = new URL(input);
|
|
311
|
+
let name = basename$1(url.pathname);
|
|
312
|
+
try {
|
|
313
|
+
const head = await sendFetch(url.href, {
|
|
314
|
+
method: "HEAD",
|
|
315
|
+
validateStatus: true,
|
|
316
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 }
|
|
317
|
+
});
|
|
318
|
+
if ((head.headers.get("content-type") || "").includes("application/json")) return await _httpJSON(input, options);
|
|
319
|
+
const filename = head.headers.get("content-disposition")?.match(/filename="?(.+)"?/)?.[1];
|
|
320
|
+
if (filename) name = filename.split(".")[0];
|
|
321
|
+
} catch (error) {
|
|
322
|
+
debug(`Failed to fetch HEAD for ${url.href}:`, error);
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
name: `${name}-${url.href.slice(0, 8)}`,
|
|
326
|
+
version: "",
|
|
327
|
+
subdir: "",
|
|
328
|
+
tar: url.href,
|
|
329
|
+
defaultDir: name,
|
|
330
|
+
headers: { Authorization: options.auth ? `Bearer ${options.auth}` : void 0 }
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
const _httpJSON = async (input, options) => {
|
|
334
|
+
const info = await (await sendFetch(input, {
|
|
335
|
+
validateStatus: true,
|
|
336
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 }
|
|
337
|
+
})).json();
|
|
338
|
+
if (!info.tar || !info.name) throw new Error(`Invalid template info from ${input}. name or tar fields are missing!`);
|
|
339
|
+
return info;
|
|
340
|
+
};
|
|
341
|
+
const github = (input, options) => {
|
|
342
|
+
const parsed = parseGitURI(input);
|
|
343
|
+
const githubAPIURL = process.env.GIGET_GITHUB_URL || "https://api.github.com";
|
|
344
|
+
return {
|
|
345
|
+
name: parsed.repo.replace("/", "-"),
|
|
346
|
+
version: parsed.ref,
|
|
347
|
+
subdir: parsed.subdir,
|
|
348
|
+
headers: {
|
|
349
|
+
Authorization: options.auth ? `Bearer ${options.auth}` : void 0,
|
|
350
|
+
Accept: "application/vnd.github+json",
|
|
351
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
352
|
+
},
|
|
353
|
+
url: `${githubAPIURL.replace("api.github.com", "github.com")}/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
354
|
+
tar: `${githubAPIURL}/repos/${parsed.repo}/tarball/${parsed.ref}`
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
const gitlab = (input, options) => {
|
|
358
|
+
const parsed = parseGitURI(input, { expandRepo: true });
|
|
359
|
+
const gitlab = process.env.GIGET_GITLAB_URL || "https://gitlab.com";
|
|
360
|
+
return {
|
|
361
|
+
name: parsed.repo.replace("/", "-"),
|
|
362
|
+
version: parsed.ref,
|
|
363
|
+
subdir: parsed.subdir,
|
|
364
|
+
headers: {
|
|
365
|
+
authorization: options.auth ? `Bearer ${options.auth}` : void 0,
|
|
366
|
+
"sec-fetch-mode": "same-origin"
|
|
367
|
+
},
|
|
368
|
+
url: `${gitlab}/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
369
|
+
tar: `${gitlab}/${parsed.repo}/-/archive/${parsed.ref}.tar.gz`
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
const bitbucket = (input, options) => {
|
|
373
|
+
const parsed = parseGitURI(input);
|
|
374
|
+
return {
|
|
375
|
+
name: parsed.repo.replace("/", "-"),
|
|
376
|
+
version: parsed.ref,
|
|
377
|
+
subdir: parsed.subdir,
|
|
378
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 },
|
|
379
|
+
url: `https://bitbucket.com/${parsed.repo}/src/${parsed.ref}${parsed.subdir}`,
|
|
380
|
+
tar: `https://bitbucket.org/${parsed.repo}/get/${parsed.ref}.tar.gz`
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
const sourcehut = (input, options) => {
|
|
384
|
+
const parsed = parseGitURI(input);
|
|
385
|
+
return {
|
|
386
|
+
name: parsed.repo.replace("/", "-"),
|
|
387
|
+
version: parsed.ref,
|
|
388
|
+
subdir: parsed.subdir,
|
|
389
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 },
|
|
390
|
+
url: `https://git.sr.ht/~${parsed.repo}/tree/${parsed.ref}/item${parsed.subdir}`,
|
|
391
|
+
tar: `https://git.sr.ht/~${parsed.repo}/archive/${parsed.ref}.tar.gz`
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
const providers = {
|
|
395
|
+
http,
|
|
396
|
+
https: http,
|
|
397
|
+
git,
|
|
398
|
+
github,
|
|
399
|
+
gh: github,
|
|
400
|
+
gitlab,
|
|
401
|
+
bitbucket,
|
|
402
|
+
sourcehut
|
|
403
|
+
};
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/registry.ts
|
|
406
|
+
const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/unjs/giget/main/templates";
|
|
407
|
+
const registryProvider = (registryEndpoint = DEFAULT_REGISTRY, options = {}) => {
|
|
408
|
+
return (async (input) => {
|
|
409
|
+
const start = Date.now();
|
|
410
|
+
const registryURL = `${registryEndpoint}/${input}.json`;
|
|
411
|
+
const result = await sendFetch(registryURL, { headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 } });
|
|
412
|
+
if (result.status >= 400) throw new Error(`Failed to download ${input} template info from ${registryURL}: ${result.status} ${result.statusText}`);
|
|
413
|
+
const info = await result.json();
|
|
414
|
+
if (!info.tar || !info.name) throw new Error(`Invalid template info from ${registryURL}. name or tar fields are missing!`);
|
|
415
|
+
debug(`Fetched ${input} template info from ${registryURL} in ${Date.now() - start}ms`);
|
|
416
|
+
return info;
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/giget.ts
|
|
421
|
+
const sourceProtoRe = /^([\w+-.]+):/;
|
|
422
|
+
async function downloadTemplate(input, options = {}) {
|
|
423
|
+
options.registry = process.env.GIGET_REGISTRY ?? options.registry;
|
|
424
|
+
options.auth = process.env.GIGET_AUTH ?? options.auth;
|
|
425
|
+
const registry = options.registry === false ? void 0 : registryProvider(options.registry, { auth: options.auth });
|
|
426
|
+
let providerName = options.provider || (registry ? "registry" : "github");
|
|
427
|
+
let source = input;
|
|
428
|
+
const sourceProviderMatch = input.match(sourceProtoRe);
|
|
429
|
+
if (sourceProviderMatch) {
|
|
430
|
+
providerName = sourceProviderMatch[1];
|
|
431
|
+
source = input.slice(sourceProviderMatch[0].length);
|
|
432
|
+
if (providerName === "http" || providerName === "https") source = input;
|
|
433
|
+
}
|
|
434
|
+
if (providerName.endsWith("+git")) {
|
|
435
|
+
source = `${providerName.slice(0, -4)}:${source}`;
|
|
436
|
+
providerName = "git";
|
|
437
|
+
}
|
|
438
|
+
const provider = options.providers?.[providerName] || providers[providerName] || registry;
|
|
439
|
+
if (!provider) throw new Error(`Unsupported provider: ${providerName}`);
|
|
440
|
+
const template = await Promise.resolve().then(() => provider(source, { auth: options.auth })).catch((error) => {
|
|
441
|
+
throw new Error(`Failed to download template from ${providerName}: ${error.message}`);
|
|
442
|
+
});
|
|
443
|
+
if (!template) throw new Error(`Failed to resolve template from ${providerName}`);
|
|
444
|
+
template.name = (template.name || "template").replace(/[^\da-z-]/gi, "-");
|
|
445
|
+
template.defaultDir = (template.defaultDir || template.name).replace(/[^\da-z-]/gi, "-");
|
|
446
|
+
const tarPath = resolve$1(resolve$1(cacheDirectory(), providerName, template.name), (template.version || template.name) + ".tar.gz");
|
|
447
|
+
if (options.preferOffline && existsSync(tarPath)) options.offline = true;
|
|
448
|
+
if (!options.offline) {
|
|
449
|
+
await mkdir(dirname$1(tarPath), { recursive: true });
|
|
450
|
+
const s = Date.now();
|
|
451
|
+
if (typeof template.tar === "function") {
|
|
452
|
+
const tarFn = template.tar;
|
|
453
|
+
await (async () => {
|
|
454
|
+
const stream = await tarFn({ auth: options.auth });
|
|
455
|
+
await pipeline$1(stream instanceof Readable ? stream : Readable.fromWeb(stream), createWriteStream(tarPath));
|
|
456
|
+
})().catch((error) => {
|
|
457
|
+
if (!existsSync(tarPath)) throw error;
|
|
458
|
+
debug("Download error. Using cached version:", error);
|
|
459
|
+
options.offline = true;
|
|
460
|
+
});
|
|
461
|
+
} else await download(template.tar, tarPath, { headers: {
|
|
462
|
+
Authorization: options.auth ? `Bearer ${options.auth}` : void 0,
|
|
463
|
+
...normalizeHeaders(template.headers)
|
|
464
|
+
} }).catch((error) => {
|
|
465
|
+
if (!existsSync(tarPath)) throw error;
|
|
466
|
+
debug("Download error. Using cached version:", error);
|
|
467
|
+
options.offline = true;
|
|
468
|
+
});
|
|
469
|
+
debug(`Downloaded to ${tarPath} in ${Date.now() - s}ms`);
|
|
470
|
+
}
|
|
471
|
+
if (!existsSync(tarPath)) throw new Error(`Tarball not found: ${tarPath} (offline: ${options.offline})`);
|
|
472
|
+
const extractPath = resolve$1(resolve$1(options.cwd || "."), options.dir || template.defaultDir);
|
|
473
|
+
if (options.forceClean) await rm(extractPath, {
|
|
474
|
+
recursive: true,
|
|
475
|
+
force: true
|
|
476
|
+
});
|
|
477
|
+
if (!options.force && existsSync(extractPath) && readdirSync(extractPath).length > 0) throw new Error(`Destination ${extractPath} already exists.`);
|
|
478
|
+
await mkdir(extractPath, { recursive: true });
|
|
479
|
+
const s = Date.now();
|
|
480
|
+
const subdir = template.subdir?.replace(/^\//, "") || "";
|
|
481
|
+
const { extract } = await import("./libs/tar.mjs").then((n) => n.t);
|
|
482
|
+
await extract({
|
|
483
|
+
file: tarPath,
|
|
484
|
+
cwd: extractPath,
|
|
485
|
+
onReadEntry(entry) {
|
|
486
|
+
entry.path = entry.path.split("/").splice(1).join("/");
|
|
487
|
+
if (subdir) if (entry.path.startsWith(subdir + "/")) entry.path = entry.path.slice(subdir.length);
|
|
488
|
+
else entry.path = "";
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
debug(`Extracted to ${extractPath} in ${Date.now() - s}ms`);
|
|
492
|
+
if (options.install) {
|
|
493
|
+
debug("Installing dependencies...");
|
|
494
|
+
const { installDependencies } = await import("./libs/nypm.mjs").then((n) => n.t);
|
|
495
|
+
await installDependencies({
|
|
496
|
+
cwd: extractPath,
|
|
497
|
+
silent: options.silent,
|
|
498
|
+
...typeof options.install === "object" ? options.install : {}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
...template,
|
|
503
|
+
source,
|
|
504
|
+
dir: extractPath
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
export { registryProvider as n, startShell as r, downloadTemplate as t };
|