@shell-shock/preset-cli 0.9.12 → 0.9.13
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/dist/_virtual/_rolldown/runtime.mjs +1 -4
- package/dist/components/banner-builtin.cjs +3 -3
- package/dist/components/banner-builtin.mjs +3 -3
- package/dist/components/banner-builtin.mjs.map +1 -1
- package/dist/components/command-entry.cjs +1 -0
- package/dist/components/command-entry.mjs +1 -0
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +1 -0
- package/dist/components/virtual-command-entry.mjs +1 -0
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/packages/plugin-changelog/dist/components/changelog-command.cjs +2 -2
- package/dist/packages/plugin-changelog/dist/components/changelog-command.mjs +1 -1
- package/dist/packages/unified/dist/html-DzncQodH.cjs +156 -0
- package/dist/packages/unified/dist/html-DzncQodH.mjs +157 -0
- package/dist/packages/unified/dist/html-DzncQodH.mjs.map +1 -0
- package/dist/packages/unified/dist/markdown/index.cjs +1 -1
- package/dist/packages/unified/dist/markdown/index.mjs +1 -1
- package/dist/packages/unified/dist/{markdown-OuY_JOk0.cjs → markdown-BiaU4FQg.cjs} +3 -3
- package/dist/packages/unified/dist/{markdown-OuY_JOk0.mjs → markdown-BiaU4FQg.mjs} +4 -4
- package/dist/packages/unified/dist/{markdown-OuY_JOk0.mjs.map → markdown-BiaU4FQg.mjs.map} +1 -1
- package/package.json +11 -15
- package/dist/node_modules/.pnpm/chalk-string@4.0.0/node_modules/chalk-string/build/src/args.cjs +0 -36
- package/dist/node_modules/.pnpm/chalk-string@4.0.0/node_modules/chalk-string/build/src/args.mjs +0 -36
- package/dist/node_modules/.pnpm/chalk-string@4.0.0/node_modules/chalk-string/build/src/args.mjs.map +0 -1
- package/dist/node_modules/.pnpm/chalk-string@4.0.0/node_modules/chalk-string/build/src/main.cjs +0 -32
- package/dist/node_modules/.pnpm/chalk-string@4.0.0/node_modules/chalk-string/build/src/main.mjs +0 -33
- package/dist/node_modules/.pnpm/chalk-string@4.0.0/node_modules/chalk-string/build/src/main.mjs.map +0 -1
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.cjs +0 -133
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.mjs +0 -134
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.cjs +0 -32
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.mjs +0 -31
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.mjs.map +0 -1
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.cjs +0 -169
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.mjs +0 -167
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.cjs +0 -98
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.mjs +0 -95
- package/dist/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/colors-option@6.1.2/node_modules/colors-option/build/src/main.cjs +0 -23
- package/dist/node_modules/.pnpm/colors-option@6.1.2/node_modules/colors-option/build/src/main.mjs +0 -23
- package/dist/node_modules/.pnpm/colors-option@6.1.2/node_modules/colors-option/build/src/main.mjs.map +0 -1
- package/dist/node_modules/.pnpm/colors-option@6.1.2/node_modules/colors-option/build/src/options.cjs +0 -36
- package/dist/node_modules/.pnpm/colors-option@6.1.2/node_modules/colors-option/build/src/options.mjs +0 -36
- package/dist/node_modules/.pnpm/colors-option@6.1.2/node_modules/colors-option/build/src/options.mjs.map +0 -1
- package/dist/node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.cjs +0 -10
- package/dist/node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.mjs +0 -10
- package/dist/node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.mjs.map +0 -1
- package/dist/packages/unified/dist/html-Di3_LwV3.cjs +0 -337
- package/dist/packages/unified/dist/html-Di3_LwV3.mjs +0 -338
- package/dist/packages/unified/dist/html-Di3_LwV3.mjs.map +0 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
1
|
//#region \0rolldown/runtime.js
|
|
4
2
|
var __create = Object.create;
|
|
5
3
|
var __defProp = Object.defineProperty;
|
|
@@ -39,7 +37,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
37
|
value: mod,
|
|
40
38
|
enumerable: true
|
|
41
39
|
}) : target, mod));
|
|
42
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
43
40
|
|
|
44
41
|
//#endregion
|
|
45
|
-
export { __commonJSMin, __exportAll,
|
|
42
|
+
export { __commonJSMin, __exportAll, __toESM };
|
|
@@ -54,12 +54,12 @@ function BannerFunctionBodyDeclaration(props) {
|
|
|
54
54
|
insertNewlineAfterDescription: true,
|
|
55
55
|
get children() {
|
|
56
56
|
return _alloy_js_core.code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
|
|
57
|
-
const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(
|
|
57
|
+
const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${totalPadding.value}, 20) ? "${title.value}" : \`\\n\${titleLines.join("\\n")}\\n\`;
|
|
58
58
|
|
|
59
59
|
splitText(title,
|
|
60
|
-
Math.max(
|
|
60
|
+
Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)
|
|
61
61
|
).forEach((line) => {
|
|
62
|
-
writeLine(borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((
|
|
62
|
+
writeLine(borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
63
63
|
}); `;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
@@ -52,12 +52,12 @@ function BannerFunctionBodyDeclaration(props) {
|
|
|
52
52
|
insertNewlineAfterDescription: true,
|
|
53
53
|
get children() {
|
|
54
54
|
return code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
|
|
55
|
-
const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(
|
|
55
|
+
const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${totalPadding.value}, 20) ? "${title.value}" : \`\\n\${titleLines.join("\\n")}\\n\`;
|
|
56
56
|
|
|
57
57
|
splitText(title,
|
|
58
|
-
Math.max(
|
|
58
|
+
Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)
|
|
59
59
|
).forEach((line) => {
|
|
60
|
-
writeLine(borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((
|
|
60
|
+
writeLine(borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
61
61
|
}); `;
|
|
62
62
|
}
|
|
63
63
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.mjs","names":[],"sources":["../../src/components/banner-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { BannerBuiltin as BaseBannerBuiltin } from \"@shell-shock/plugin-banner/components/banner-builtin\";\nimport type { BannerFunctionBodyDeclarationProps } from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport {\n BannerFunctionDeclarationWrapper,\n BannerFunctionBodyDeclaration as BaseBannerFunctionBodyDeclaration\n} from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionBodyDeclaration(\n props: Omit<\n BannerFunctionBodyDeclarationProps,\n \"header\" | \"description\" | \"footer\"\n >\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) +\n (theme.borderStyles.banner.outline[variant]?.right.length ?? 0)\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <BaseBannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(
|
|
1
|
+
{"version":3,"file":"banner-builtin.mjs","names":[],"sources":["../../src/components/banner-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { BannerBuiltin as BaseBannerBuiltin } from \"@shell-shock/plugin-banner/components/banner-builtin\";\nimport type { BannerFunctionBodyDeclarationProps } from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport {\n BannerFunctionDeclarationWrapper,\n BannerFunctionBodyDeclaration as BaseBannerFunctionBodyDeclaration\n} from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionBodyDeclaration(\n props: Omit<\n BannerFunctionBodyDeclarationProps,\n \"header\" | \"description\" | \"footer\"\n >\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) +\n (theme.borderStyles.banner.outline[variant]?.right.length ?? 0)\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <BaseBannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${\n totalPadding.value\n }, 20) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`;\n\n splitText(title,\n Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)\n ).forEach((line) => {\n writeLine(borderColors.banner.outline.${variant}(\"${\n theme.borderStyles.banner.outline[variant].left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n theme.borderStyles.banner.outline[variant].right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n </BaseBannerFunctionBodyDeclaration>\n );\n}\n\nexport type BannerBuiltinProps = Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> & {\n /**\n * The command to generate the `banner` function declaration for.\n */\n command: CommandTree;\n};\n\n/**\n * A built-in banner module for Shell Shock.\n */\nexport function BannerBuiltin(props: BannerBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n\n return (\n <BaseBannerBuiltin {...rest} command={command}>\n <BannerFunctionDeclarationWrapper command={command}>\n <BannerFunctionBodyDeclaration command={command} />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BannerFunctionDeclarationWrapper>\n </BaseBannerBuiltin>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,SAAe,8BAAyB,OAAoD;CAC1F,MAAA,EACF,gBAAgB,OACd,UAAW,WACT,YACC;CACH,MAAA,QAAA,UAAA;CACA,MAAA,UAAA,eAAA;CACA,MAAM,SAAE,eAAsB,GAAC,MAAQ,OAAG,OAAU,OAAQ,YAAS,YAAA,QAAA,CAAA,IAAA,QAAA,YAAA,WAAA,UAAA;;CAErE,MAAM,QAAQ,eAAU,YAAA,SAAA,KAAA,CAAA,QAAA,IAAA,QAAA,YAAA,WAAA,WAAA,GAAA,CAAA;CACxB,MAAM,cAAU,eAAc,SAAA,eAAmB,kBAAA,QAAA,CAAA;;EAEjD,MAAM,SAAS,OAAQ,YAAA,SAAA,KAAA,EAAA;GACnB,MAAE;GACF,OAAG;GACH,YAAU;GACV,eAAC;GACJ,YAAA;GACD,UAAc;GACd,oBAAwB;GACtB,KAAA;GACC,CAAC;AACF,MAAG,CAAA,OACH,QAAA,CAAA,GAAA,YAAA,SAAA,KAAA,CAAA,yBAAA;AAEF,SAAM,OAAA;GACJ;CACF,MAAC,gBAAA,eAAA,KAAA,IAAA,MAAA,QAAA,KAAA,EAAA,GAAA,KAAA,MAAA,aAAA,OAAA,QAAA,UAAA,KAAA,UAAA,MAAA,MAAA,aAAA,OAAA,QAAA,UAAA,MAAA,UAAA,GAAA;;AAED,QAAM,gBAAa,iCAAe;EAChC,IAAA,SAAa;AACX,UAAO,OAAK;;EAEd,IAAE,cAAa;AACb,UAAA,YAAgB;;EAElB,IAAE,SAAU;AACV,UAAA,OAAA;;EAEA;EACW;EACJ;EACT,+BAAA;;AAEA,UAAO,IAAM,uBAAM,WAAA,MAAA,KAAA,SAAA,KAAA,UAAA,KAAA,MAAA,CAAA,CAAA,CAAA,KAAA,KAAA,CAAA;yHACnB,aAAA,MAAA,WAAA,MAAA,MAAA;;;+CAGI,aAAA,MAAA;;gDAEwC,QAAQ,IAAA,MAAU,aAAG,OAAA,QAAA,SAAA,KAAA,6FAAA,cAAA,MAAA,8CAAA,QAAA,iGAAA,cAAA,MAAA,6CAAA,QAAA,IAAA,MAAA,aAAA,OAAA,QAAA,SAAA,MAAA,2BAAA,cAAA;;;EAGnE,CAAA;;;;;AAYF,SAAM,cAAA,OAA6B;CACjC,MAAK,CAAA,EACH,SACA,YACC,QAAO,WAAY,OAAO,CAAC,WAAW,WAAW,CAAC;AACrD,QAAM,gBAAa,iBAAA,WAAA,MAAA;EACR;;AAEP,UAAA,gBAAe,kCAAA;IACJ;IACT,IAAA,WAAe;AACf,YAAS;MAAC,gBAAa,+BAA4B,EAC3C,SACL,CAAC;MAAE,gBAAgB,SAAS,EAAA,CAAK;MAAE,gBAAkB,MAAA;OACtD,IAAA,OAAa;AACT,eAAO,QAAQ,SAAA;;OAEP;OACZ,CAAA;MAAA;;IAEH,CAAC;;EAEL,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n \"useGlobal\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\",\n { name: \"GlobalOptions\", type: true }\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp() && (${Object.values(\n command.options ?? {}\n )\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\\`The following validation failures were found while processing the user provided input, and must be corrected before the \\${italic(\"${command.title}\")} command can be executed: \\\\n\\\\n\\${failures.map(failure => \" - \" + failure).join(\"\\\\n\")}\\`);\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;CA8CA,MAAO,EACL,SACC,SACD,gBACA,GAAA,SACF;;CAEE,MAAA,WAAA,eAAA,UAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CACA,MAAK,oBAAoB,eAAc,iBAAa,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA;CACpD,MAAA,iBAAA,gBAAA;EACF,GAAO,QAAQ;EACb,QAAQ,QAAS;;AAEjB,QAAM,CAAA,gBAAU,WAAc,WAAmB,MAAA;EACjD,IAAM,OAAA;AACJ,UAAS,SAAA;;EAET,IAAI,iBAAiB;AAC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AC;;EAEN,CAAC,CAAC,EAAE,gBAAiB,KAAI;EACxB,IAAI,OAAO;AACT,UAAO,OAAO,OAAA,QAAA,SAAA;;EAEhB,WAAU,UAAK,gBAAA,MAAA;GACb,IAAI,OAAK;AACP,WAAO,MAAI;;GAEb,IAAI,WAAS;AACX,WAAO,gBAAkB,cAAa,EACpC,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAW;AACb,WAAO,gBAAkB,qBAAS,EAChC,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\",\n { name: \"GlobalOptions\", type: true }\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp() && (${Object.values(\n command.options ?? {}\n )\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\\`The following validation failures were found while processing the user provided input, and must be corrected before the \\${italic(\"${command.title}\")} command can be executed: \\\\n\\\\n\\${failures.map(failure => \" - \" + failure).join(\"\\\\n\")}\\`);\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;CA8CA,MAAO,EACL,SACC,SACD,gBACA,GAAA,SACF;;CAEE,MAAA,WAAA,eAAA,UAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CACA,MAAK,oBAAoB,eAAc,iBAAa,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA;CACpD,MAAA,iBAAA,gBAAA;EACF,GAAO,QAAQ;EACb,QAAQ,QAAS;;AAEjB,QAAM,CAAA,gBAAU,WAAc,WAAmB,MAAA;EACjD,IAAM,OAAA;AACJ,UAAS,SAAA;;EAET,IAAI,iBAAiB;AACnB,UAAO,eAAK;;EAEd,IAAA,UAAA;AACD,UAAA,KAAA,WAAA,EAAA,EAAA,GACK,kBAAmB,MAAC,WAAa,IAAA,GAAA,kBAAA,QAAA,KAAA,kBAAA,UAAA,SAAA,WAAA,QAAA,KAAA,IACrC,CAAA;;EAEA,IAAI,iBAAiB;AACnB,UAAE,KAAQ,kBAAoB,EAAC,EAAA;IAC/B,KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACF,SAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACD,OAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACK,OAAA;KAAA;KAAiB;KAAgB;KAAA;KAAA;KAAA;KAAA;MAClC,MAAQ;MACL,MAAE;MACP;KAAA;;;;;;;;;;KAEI,UAAA,QAAA,GAAA,QAAA,SAAA,QAAA,YAA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iB,cAAA;gBACtB,IAAI,YAAU;AACZ,wBAAI,IAAA,GAAU,UAAO,IAAM,KAAA,CAAA;;gBAEhC,IAAI,WAAA;AACH,wBAAW,IAAG;;qEAE2B,IAAC,SAAA,sBAAA,SAAA,aAAA,GAAA,6BAAA,IAAA,KAAA;gCACtC,IAAI,cAAS,kBAAA,uBAAA,IAAA,YAAA,CAAA;kCACX,GAAG;;;;;;;kCAOH,IAAI,SAAO,sBAAA,SAAA;;;0CAGR,GAAA;;;;;;;;;8BASP,UAAU,IAAC,KAAQ,CAAC,gEAAsB,IAAA,SAAA,sBAAA,SAAA,iBAAA,GAAA;;;gBAG3C,CAAC;;cAEL,CAAC,CAAC;;YAEN,CAAC,CAAC;WACJ,CAAC;UAAE,IAAI;UAAI,gBAAA,SAAA,EAAA,CAAA;UAAA,gBAAA,wBAAA,EACD,SACV,CAAC;UAAE,gBAAkB,aAAS;WAC7B,WAAU,IAAA;WACV,IAAI,WAAI;;;;WAIT,CAAC;UAAC;;QAEN,CAAC;;MAEL,CAAC,CAAC;;IAEN,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAkB,KAAC;EACtB,IAAI,OAAO;AACT,UAAO,OAAO,OAAM,QAAA,SAAA;;EAEtB,WAAU,UAAG,gBAAA,MAAA;GACX,IAAI,OAAM;AACR,WAAO,MAAA;;GAET,IAAI,WAAW;AACb,WAAO,gBAAI,cAAA,EACT,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAW;AACb,WAAO,gBAAiB,qBAAS,EAC/B,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, For, Show } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport { VirtualCommandHandlerDeclaration } from \"@shell-shock/preset-script/components/virtual-command-entry\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\n \"warn\",\n \"error\",\n \"info\",\n \"help\",\n \"table\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"stripAnsi\"\n ],\n utils: [\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"isInteractive\",\n \"findSuggestions\",\n \"sleep\"\n ],\n state: [\n \"useGlobal\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\",\n { name: \"GlobalOptions\", type: true }\n ],\n prompts: [\"text\", \"numeric\", \"toggle\", \"select\", \"isCancel\"],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <VirtualCommandHandlerDeclaration command={command}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,SAAE,oBAAA,OAAA;CACA,MAAK,EACL,SACF,SACE,4BAEA;CACA,MAAM,UAAU,eAAc;CAC9B,MAAE,WAAS,eAAA,UAAA,QAAA,WAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;AACX,QAAI,CAAA,gBAAiB,gBAAA,WAAA,MAAA;EACnB,IAAE,OAAQ;AACR,UAAG,SAAO;;EAEZ,IAAG,UAAQ;AACX,UAAA,KAAA,WAAA,EAAA,EAAA,OAAA,QAAA,QAAA,SAAA,CAAA,QAAA,GAAA,WAAA,MAAA,UAAA,CAAA,QAAA,KAAA,CAAA,MAAA,WAAA;AACD,QAAA,KAAA,MAAA,UAAA,CAAA;;KAEM,OAAA,SAAA,WAAA,KAAA;KACJ,CAAA;AACE,WAAA;MACE,EAAE,CAAK,CAAA;;EAEZ,IAAI,iBAAa;AACf,UAAI,KAAQ,kBAAK,EAAA,EAAA;IACf,KAAE,CAAA,iBAAe,UAAgB;IACjC,SAAK;KAAA;KAAW;KAAW;KAAM;KAAS;KAAA;KAAA;KAAA;KAAA;KAAA;IAC1C,OAAK;KAAA;KAAc;KAAiB;KAAA;KAAA;KAAA;IACpC,OAAM;KAAA;KAAe;KAAU;KAAA;KAAA;KAAA;MAC7B,MAAM;MACN,MAAK;;;IAEP,SAAM;KAAA;KAAU;KAAA;KAAA;KAAA;KAAA;KACf,UAAS,QAAG,GAAA,QAAA,SAAqB,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,WAAA;KACjC,UAAA,UAAA,GAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,aAAA;IACF,CAAC;;EAEJ,IAAI,WAAW;AACb,UAAO,CAAA,gBAAK,SAAA,EAAA,CAAA,EAAA,gBAAA,kCAAA;IACL;IACL,IAAI,WAAM;AACR,YAAO,gBAAC,eAAA;MACN,IAAC,WAAM;AACN,cAAA,QAAU;;MAEX,IAAC,WAAW;AACX,cAAA,QAAS;;MAEZ,CAAA;;IAEH,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAM,KAAgB;EACzB,IAAI,OAAK;AACP,UAAK,OAAA,OAAA,QAAA,SAAA;;EAEP,WAAS,UAAU,gBAAA,MAAA;GACjB,IAAI,OAAG;AACL,WAAK,
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, For, Show } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport { VirtualCommandHandlerDeclaration } from \"@shell-shock/preset-script/components/virtual-command-entry\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\n \"warn\",\n \"error\",\n \"info\",\n \"help\",\n \"table\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"stripAnsi\"\n ],\n utils: [\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"isInteractive\",\n \"findSuggestions\",\n \"sleep\"\n ],\n state: [\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\",\n { name: \"GlobalOptions\", type: true }\n ],\n prompts: [\"text\", \"numeric\", \"toggle\", \"select\", \"isCancel\"],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <VirtualCommandHandlerDeclaration command={command}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,SAAE,oBAAA,OAAA;CACA,MAAK,EACL,SACF,SACE,4BAEA;CACA,MAAM,UAAU,eAAc;CAC9B,MAAE,WAAS,eAAA,UAAA,QAAA,WAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;AACX,QA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AAA,MAAA;GACjB,IAAI,OAAG;AACL,WAAK,MAAA;;GAEP,IAAI,WAAW;AACb,WAAK,gBAAO,cAAA,EACV,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAU;AACZ,WAAK,gBAAK,qBAAA,EACR,SAAK,OACN,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_markdown_BiaU4FQg = require('../../../unified/dist/markdown-BiaU4FQg.cjs');
|
|
3
3
|
require('../../../unified/dist/markdown/index.cjs');
|
|
4
4
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
5
|
let _alloy_js_core = require("@alloy-js/core");
|
|
@@ -21,7 +21,7 @@ function ChangelogCommand() {
|
|
|
21
21
|
const result = (0, _alloy_js_core.createResource)(async () => {
|
|
22
22
|
const content = await context.fs.read(context.config.changelog.file);
|
|
23
23
|
if (!content) return null;
|
|
24
|
-
return
|
|
24
|
+
return require_markdown_BiaU4FQg.h(content);
|
|
25
25
|
});
|
|
26
26
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
27
27
|
get path() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h } from "../../../unified/dist/markdown-
|
|
1
|
+
import { h } from "../../../unified/dist/markdown-BiaU4FQg.mjs";
|
|
2
2
|
import "../../../unified/dist/markdown/index.mjs";
|
|
3
3
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
4
|
import { Show, code, createResource } from "@alloy-js/core";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_index = require('../../../node_modules/.pnpm/parse5@8.0.0/node_modules/parse5/dist/index.cjs');
|
|
3
|
+
const require_he$1 = require('../../../node_modules/.pnpm/he@1.2.0/node_modules/he/he.cjs');
|
|
4
|
+
const require_index$1 = require('../../../node_modules/.pnpm/normalize-html-whitespace@1.0.0/node_modules/normalize-html-whitespace/index.cjs');
|
|
5
|
+
require('../../../node_modules/.pnpm/wrap-ansi@10.0.0/node_modules/wrap-ansi/index.cjs');
|
|
6
|
+
|
|
7
|
+
//#region ../unified/dist/html-DzncQodH.mjs
|
|
8
|
+
var import_he = /* @__PURE__ */ require_runtime.__toESM(require_he$1.default, 1);
|
|
9
|
+
var import_normalize_html_whitespace = /* @__PURE__ */ require_runtime.__toESM(require_index$1.default, 1);
|
|
10
|
+
const r = (e) => ({
|
|
11
|
+
pre: !1,
|
|
12
|
+
lineWidth: 120,
|
|
13
|
+
fontAttrs: !0,
|
|
14
|
+
depth: 0,
|
|
15
|
+
asciiMode: !1,
|
|
16
|
+
...e
|
|
17
|
+
}), i = (e, t) => e == null && t == null ? null : e == null ? t : t == null ? e : t.value == null ? {
|
|
18
|
+
pre: e.pre,
|
|
19
|
+
value: e.value,
|
|
20
|
+
post: e.post == null ? t.pre == null ? t.post == null ? `` : t.post : t.pre : e.post
|
|
21
|
+
} : e.value == null ? {
|
|
22
|
+
pre: e.pre == null ? e.post == null ? t.pre == null ? `` : t.pre : e.post : e.pre,
|
|
23
|
+
value: t.value,
|
|
24
|
+
post: t.post
|
|
25
|
+
} : e.post == null ? t.pre == null ? {
|
|
26
|
+
pre: e.pre,
|
|
27
|
+
value: `${e.value}${t.value}`,
|
|
28
|
+
post: t.post
|
|
29
|
+
} : {
|
|
30
|
+
pre: e.pre,
|
|
31
|
+
value: `${e.value}${t.pre}${t.value}`,
|
|
32
|
+
post: t.post
|
|
33
|
+
} : {
|
|
34
|
+
pre: e.pre,
|
|
35
|
+
value: `${e.value}${e.post}${t.value}`,
|
|
36
|
+
post: t.post
|
|
37
|
+
}, a = /* @__PURE__ */ new WeakMap(), o = (e, t, n = null) => {
|
|
38
|
+
if (!e || typeof e != `object` || !t || typeof t != `string`) return n;
|
|
39
|
+
let r = a.get(e);
|
|
40
|
+
if (r) {
|
|
41
|
+
let e = r.get(t);
|
|
42
|
+
if (e !== void 0) return e ?? n;
|
|
43
|
+
}
|
|
44
|
+
if (!e.attrs || !Array.isArray(e.attrs) || e.attrs.length === 0) return r || (r = /* @__PURE__ */ new Map(), a.set(e, r)), r.set(t, null), n;
|
|
45
|
+
let i = e.attrs.find((e) => e && typeof e == `object` && e.name === t);
|
|
46
|
+
if (r || (r = /* @__PURE__ */ new Map(), a.set(e, r)), !i || i.value === void 0) return r.set(t, null), n;
|
|
47
|
+
let o = i.value;
|
|
48
|
+
return r.set(t, o), o;
|
|
49
|
+
}, s = import_he.default.decode, c = import_normalize_html_whitespace.default, l = (e, t) => {
|
|
50
|
+
let n = String(e.value ?? ``);
|
|
51
|
+
if (t.pre) return {
|
|
52
|
+
pre: null,
|
|
53
|
+
value: s(n),
|
|
54
|
+
post: null,
|
|
55
|
+
type: `inline`,
|
|
56
|
+
nodeName: `#text`
|
|
57
|
+
};
|
|
58
|
+
let r = [...(c(n) || ``).replaceAll(`
|
|
59
|
+
`, ` `)], i = [` `, `
|
|
60
|
+
`].includes(r[0] ?? ``) ? r.shift() ?? null : null, a = [` `, `
|
|
61
|
+
`].includes(r.at(-1) ?? ``) ? r.pop() ?? null : null;
|
|
62
|
+
return {
|
|
63
|
+
pre: i,
|
|
64
|
+
value: r.length > 0 ? `${s(r.join(``))}` : null,
|
|
65
|
+
post: a,
|
|
66
|
+
type: `inline`,
|
|
67
|
+
nodeName: `#text`
|
|
68
|
+
};
|
|
69
|
+
}, u = (e) => (t, n) => {
|
|
70
|
+
let r = e ?? ((e) => e ?? null), a = p.span;
|
|
71
|
+
if (!t || !t.childNodes) return null;
|
|
72
|
+
let o = t.childNodes.reduce((e, r) => {
|
|
73
|
+
let o = v(r, n, a);
|
|
74
|
+
return o ? {
|
|
75
|
+
...i(e, o),
|
|
76
|
+
type: `inline`,
|
|
77
|
+
nodeName: t.nodeName
|
|
78
|
+
} : e;
|
|
79
|
+
}, null);
|
|
80
|
+
return {
|
|
81
|
+
pre: o?.pre ? r(o.pre, t, n) : null,
|
|
82
|
+
value: r(o?.value, t, n),
|
|
83
|
+
post: o?.post ? r(o.post, t, n) : null,
|
|
84
|
+
type: `inline`,
|
|
85
|
+
nodeName: t.nodeName
|
|
86
|
+
};
|
|
87
|
+
}, d = u((e, t, n) => {
|
|
88
|
+
let r = o(t, `href`, null), i = o(t, `title`, null), a = !r || [
|
|
89
|
+
`file://`,
|
|
90
|
+
`http://`,
|
|
91
|
+
`https://`,
|
|
92
|
+
`mailto:`,
|
|
93
|
+
`ftp://`,
|
|
94
|
+
`ftps://`,
|
|
95
|
+
`sftp://`,
|
|
96
|
+
`ssh://`,
|
|
97
|
+
`dav://`,
|
|
98
|
+
`tel:`,
|
|
99
|
+
`git://`
|
|
100
|
+
].some((e) => r.startsWith(e)) ? r : null;
|
|
101
|
+
return a ? `link("${a}", ${i ? `"${i}", ` : ``}${a && (a.startsWith(`http://`) || a.startsWith(`https://`)) ? `true` : `false`})` : i ? `"${i}"` : ``;
|
|
102
|
+
}), f = u((e, t) => {
|
|
103
|
+
let n = o(t, `title`, null);
|
|
104
|
+
return e ? n ? `${e} (${n})` : e : ``;
|
|
105
|
+
});
|
|
106
|
+
var p = {
|
|
107
|
+
"#text": l,
|
|
108
|
+
a: d,
|
|
109
|
+
abbr: f
|
|
110
|
+
};
|
|
111
|
+
const m = process.env.CACHE_RENDER !== `false`, h = /* @__PURE__ */ new WeakMap(), g = (e, t) => {
|
|
112
|
+
if (!m || !e || typeof e != `object`) return;
|
|
113
|
+
let n = h.get(e);
|
|
114
|
+
if (n) return n.get(JSON.stringify({
|
|
115
|
+
lineWidth: t.lineWidth,
|
|
116
|
+
pre: t.pre,
|
|
117
|
+
listDepth: t.listDepth,
|
|
118
|
+
listType: t.listType,
|
|
119
|
+
depth: t.depth
|
|
120
|
+
}));
|
|
121
|
+
}, _ = (e, t, n) => {
|
|
122
|
+
if (!m || !e || typeof e != `object`) return;
|
|
123
|
+
let r = h.get(e);
|
|
124
|
+
if (r || (r = /* @__PURE__ */ new Map(), h.set(e, r)), r.set(JSON.stringify({
|
|
125
|
+
lineWidth: t.lineWidth,
|
|
126
|
+
pre: t.pre,
|
|
127
|
+
listDepth: t.listDepth,
|
|
128
|
+
listType: t.listType,
|
|
129
|
+
depth: t.depth
|
|
130
|
+
}), n), r.size > 10) {
|
|
131
|
+
let e = r.keys().next().value;
|
|
132
|
+
r.delete(e);
|
|
133
|
+
}
|
|
134
|
+
}, v = (e, t, n = p.div) => {
|
|
135
|
+
if (!e) return null;
|
|
136
|
+
let r = t.depth === void 0 ? 0 : t.depth;
|
|
137
|
+
if (r >= 100) return null;
|
|
138
|
+
let i = {
|
|
139
|
+
...t,
|
|
140
|
+
depth: r + 1
|
|
141
|
+
}, a = g(e, i);
|
|
142
|
+
if (a !== void 0) return a;
|
|
143
|
+
let o = null;
|
|
144
|
+
try {
|
|
145
|
+
o = (p[e.nodeName || `#text`] || n)(e, i), _(e, i, o);
|
|
146
|
+
} catch {
|
|
147
|
+
o = null;
|
|
148
|
+
}
|
|
149
|
+
return o;
|
|
150
|
+
};
|
|
151
|
+
function y(t, n) {
|
|
152
|
+
return `${(v(require_index.parse(t, { sourceCodeLocationInfo: !0 }), r(n)) || { value: `` }).value}\n`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
exports.y = y;
|