@shell-shock/preset-script 0.1.2 → 0.2.1

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.
Files changed (46) hide show
  1. package/README.md +2 -2
  2. package/dist/components/bin-entry.cjs +15 -6
  3. package/dist/components/bin-entry.cjs.map +1 -1
  4. package/dist/components/bin-entry.d.cts +3 -3
  5. package/dist/components/bin-entry.d.cts.map +1 -1
  6. package/dist/components/bin-entry.d.mts +3 -3
  7. package/dist/components/bin-entry.d.mts.map +1 -1
  8. package/dist/components/bin-entry.mjs +15 -6
  9. package/dist/components/bin-entry.mjs.map +1 -1
  10. package/dist/components/command-router.cjs +61 -38
  11. package/dist/components/command-router.cjs.map +1 -1
  12. package/dist/components/command-router.d.cts.map +1 -1
  13. package/dist/components/command-router.d.mts.map +1 -1
  14. package/dist/components/command-router.mjs +61 -38
  15. package/dist/components/command-router.mjs.map +1 -1
  16. package/dist/components/console-builtin.cjs +74 -51
  17. package/dist/components/console-builtin.cjs.map +1 -1
  18. package/dist/components/console-builtin.d.cts.map +1 -1
  19. package/dist/components/console-builtin.d.mts.map +1 -1
  20. package/dist/components/console-builtin.mjs +74 -51
  21. package/dist/components/console-builtin.mjs.map +1 -1
  22. package/dist/components/help.cjs +33 -21
  23. package/dist/components/help.cjs.map +1 -1
  24. package/dist/components/help.d.cts +16 -8
  25. package/dist/components/help.d.cts.map +1 -1
  26. package/dist/components/help.d.mts +19 -11
  27. package/dist/components/help.d.mts.map +1 -1
  28. package/dist/components/help.mjs +34 -22
  29. package/dist/components/help.mjs.map +1 -1
  30. package/dist/components/index.cjs +1 -1
  31. package/dist/components/index.d.cts +3 -3
  32. package/dist/components/index.d.mts +3 -3
  33. package/dist/components/index.mjs +2 -2
  34. package/dist/components/utils-builtin.d.mts +7 -7
  35. package/dist/components/virtual-command-entry.cjs +8 -1
  36. package/dist/components/virtual-command-entry.cjs.map +1 -1
  37. package/dist/components/virtual-command-entry.mjs +8 -1
  38. package/dist/components/virtual-command-entry.mjs.map +1 -1
  39. package/dist/index.cjs +94 -71
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts.map +1 -1
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +95 -72
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/types/plugin.d.cts.map +1 -1
  46. package/package.json +10 -10
@@ -86,7 +86,14 @@ function VirtualCommandEntry(props) {
86
86
  return filePath.value;
87
87
  },
88
88
  get imports() {
89
- return (0, defu.default)(imports ?? {}, Object.entries(command.children).filter(([, child]) => child.isVirtual).reduce((ret, [name, child]) => {
89
+ return (0, defu.default)({ didyoumean2: [
90
+ {
91
+ name: "didYouMean",
92
+ default: true
93
+ },
94
+ { name: "ReturnTypeEnums" },
95
+ { name: "ThresholdTypeEnums" }
96
+ ] }, imports ?? {}, Object.entries(command.children).filter(([, child]) => child.isVirtual).reduce((ret, [name, child]) => {
90
97
  ret[`./${child.name}`] = [{
91
98
  name: "handler",
92
99
  alias: `handle${(0, __stryke_string_format_pascal_case.pascalCase)(name)}`
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-command-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getAppTitle","getVariableCommandPathName","isVariableCommandPath","joinPaths","constantCase","pascalCase","defu","CommandEntry","CommandRouter","Help","VirtualCommandHandlerDeclaration","props","command","context","_$createComponent","heading","title","path","segments","map","segment","join","children","description","replace","_$createIntrinsic","name","async","parameters","type","default","commands","_$memo","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","value","Object","entries","child","isVirtual","reduce","ret","alias","console","utils","each","values","when","fallback"],"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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\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 {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getAppTitle,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { Help } from \"./help\";\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(props: {\n command: CommandTree;\n}) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `[${constantCase(getVariableCommandPathName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <CommandRouter\n path={command.path.segments}\n commands={command.children}\n />\n <hbr />\n <hbr />\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(/\\.+$/, \"\")}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </FunctionDeclaration>\n </>\n );\n}\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<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.path.segments\n .filter(segment => !isVariableCommandPath(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 console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\"]\n })}>\n <VirtualCommandHandlerDeclaration command={command} />\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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show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getAppTitle","getVariableCommandPathName","isVariableCommandPath","joinPaths","constantCase","pascalCase","defu","CommandEntry","CommandRouter","Help","VirtualCommandHandlerDeclaration","props","command","context","_$createComponent","heading","title","path","segments","map","segment","join","children","description","replace","_$createIntrinsic","name","async","parameters","type","default","commands","_$memo","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","value","didyoumean2","Object","entries","child","isVirtual","reduce","ret","alias","console","utils","each","values","when","fallback"],"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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\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 {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getAppTitle,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { Help } from \"./help\";\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(props: {\n command: CommandTree;\n}) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `[${constantCase(getVariableCommandPathName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <CommandRouter\n path={command.path.segments}\n commands={command.children}\n />\n <hbr />\n <hbr />\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(/\\.+$/, \"\")}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </FunctionDeclaration>\n </>\n );\n}\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<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.path.segments\n .filter(segment => !isVariableCommandPath(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\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 console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\"]\n })}>\n <VirtualCommandHandlerDeclaration command={command} />\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":";;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgBsB,iCAAiCC,OAE9C;CACD,MAAM,EAAEC,YAAYD;CAEpB,MAAME,8EAA8C;AAEpD,QAAA,kDAEKnB,6DAAK;EAAA,IACJqB,UAAO;AAAA,UAAE,OAAOH,QAAQI,MAAK,mEAAeH,QAAQ,CAAA,GAAID,QAAQK,KAAKC,SAClEC,KAAIC,uFACmBA,QAAQ,GAC1B,2IAA4CA,QAAQ,CAAC,CAAA,KACrDA,QACL,CACAC,KAAK,IAAI,CAAA;;EAAoB,IAAAC,WAAA;AAAA,UAAA;qDAC/B1B,oEAAY,EAAA,IAAA0B,WAAA;AAAA,YAAE,GAAGV,QAAQW,YAAYC,QAAQ,QAAQ,GAAG,CAAA;OAAG,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAE3D3B,kEAAU,EAAA,IAAAyB,WAAA;AAAA,YAAEV,QAAQI;OAAK,CAAA;qDACzBrB,k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AAW;AAC9BG,QAAI,KAAKH,MAAMnB,UAAU,CACvB;KAAEA,MAAM;KAAWuB,OAAO,4DAAoBvB,KAAK;KAAI,CACxD;AAED,WAAOsB;MACN,EAA2B,CAClC,CAAC;;EAAA,IACDb,iBAAc;AAAA,4BAAOA,kBAAkB,EAAE,EAAE;IACzCe,SAAS;KAAC;KAAQ;KAAS;KAAS;KAAU;KAAY;IAC1DC,OAAO,CAAC,UAAS;IAClB,CAAC;;EAAA,IAAA7B,WAAA;AAAA,2DACDZ,kCAAgC,EAAUE,SAAO,CAAA;;EAAA,CAAA,CAAA,mDAEnDtB,qBAAG;EAAA,IAAC8D,OAAI;AAAA,UAAET,OAAOU,OAAOzC,QAAQU,SAAS;;EAAAA,WACvCuB,2DACEtD,sBAAI;GAAA,IACH+D,OAAI;AAAA,WAAET,MAAMC;;GAAS,IACrBS,WAAQ;AAAA,4DAAGhD,+CAAY,EAACK,SAASiC,OAAK,CAAA;;GAAA,IAAAvB,WAAA;AAAA,4DACrCW,qBAAmB,EAACrB,SAASiC,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -84,7 +84,14 @@ function VirtualCommandEntry(props) {
84
84
  return filePath.value;
85
85
  },
86
86
  get imports() {
87
- return defu(imports ?? {}, Object.entries(command.children).filter(([, child]) => child.isVirtual).reduce((ret, [name, child]) => {
87
+ return defu({ didyoumean2: [
88
+ {
89
+ name: "didYouMean",
90
+ default: true
91
+ },
92
+ { name: "ReturnTypeEnums" },
93
+ { name: "ThresholdTypeEnums" }
94
+ ] }, imports ?? {}, Object.entries(command.children).filter(([, child]) => child.isVirtual).reduce((ret, [name, child]) => {
88
95
  ret[`./${child.name}`] = [{
89
96
  name: "handler",
90
97
  alias: `handle${pascalCase(name)}`
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-command-entry.mjs","names":["code","computed","For","Show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getAppTitle","getVariableCommandPathName","isVariableCommandPath","joinPaths","constantCase","pascalCase","defu","CommandEntry","CommandRouter","Help","VirtualCommandHandlerDeclaration","props","command","context","_$createComponent","heading","title","path","segments","map","segment","join","children","description","replace","_$createIntrinsic","name","async","parameters","type","default","commands","_$memo","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","value","Object","entries","child","isVirtual","reduce","ret","alias","console","utils","each","values","when","fallback"],"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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\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 {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getAppTitle,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { Help } from \"./help\";\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(props: {\n command: CommandTree;\n}) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `[${constantCase(getVariableCommandPathName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <CommandRouter\n path={command.path.segments}\n commands={command.children}\n />\n <hbr />\n <hbr />\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(/\\.+$/, \"\")}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </FunctionDeclaration>\n </>\n );\n}\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<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.path.segments\n .filter(segment => !isVariableCommandPath(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 console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\"]\n })}>\n <VirtualCommandHandlerDeclaration command={command} />\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":";;;;;;;;;;;;;;;;;;;AAiDA,SAAgBsB,iCAAiCC,OAE9C;CACD,MAAM,EAAEC,YAAYD;CAEpB,MAAME,UAAUpB,eAAoC;AAEpD,QAAA,CAAAqB,gBAEKpB,OAAK;EAAA,IACJqB,UAAO;AAAA,UAAE,OAAOH,QAAQI,MAAK,IAAKjB,UAAUc,QAAQ,CAAA,GAAID,QAAQK,KAAKC,SAClEC,KAAIC,YACHlB,sBAAsBkB,QAAQ,GAC1B,IAAIhB,aAAaH,2BAA2BmB,QAAQ,CAAC,CAAA,KACrDA,QACL,CACAC,KAAK,IAAI,CAAA;;EAAoB,IAAAC,WAAA;AAAA,UAAA;IAAAR,gBAC/BlB,cAAY,EAAA,IAAA0B,WAAA;AAAA,YAAE,GAAGV,QAAQW,YAAYC,QAAQ,QAAQ,GAAG,CAAA;OAAG,CAAA;IAAAC,gBAAA,OAAA,EAAA,CAAA;IAAAX,gBAE3DjB,YAAU,EAAA,IAAAyB,WAAA;AAAA,YAAEV,QAAQI;OAAK,CAAA;IAAAF,gBACzBnB,YAAU;KAAC+B,MAAI;KAAAJ,UAAS;KAAmD,CAAA;IAAA;;EAAA,CAAA,EAAAR,gBAE7EtB,qBAAmB;EAAA,UAAA;EAElBmC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ClC,CAAC;;EAAA,IACDZ,iBAAc;AAAA,UAAE7B,KAAK6B,kBAAkB,EAAE,EAAE;IACzCc,SAAS;KAAC;KAAQ;KAAS;KAAS;KAAU;KAAY;IAC1DC,OAAO,CAAC,UAAS;IAClB,CAAC;;EAAA,IAAA5B,WAAA;AAAA,UAAAR,gBACDJ,kCAAgC,EAAUE,SAAO,CAAA;;EAAA,CAAA,CAAA,EAAAE,gBAEnDxB,KAAG;EAAA,IAAC6D,OAAI;AAAA,UAAET,OAAOU,OAAOxC,QAAQU,SAAS;;EAAAA,WACvCsB,UAAK9B,gBACHvB,MAAI;GAAA,IACH8D,OAAI;AAAA,WAAET,MAAMC;;GAAS,IACrBS,WAAQ;AAAA,WAAAxC,gBAAGP,cAAY,EAACK,SAASgC,OAAK,CAAA;;GAAA,IAAAtB,WAAA;AAAA,WAAAR,gBACrCmB,qBAAmB,EAACrB,SAASgC,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"virtual-command-entry.mjs","names":["code","computed","For","Show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getAppTitle","getVariableCommandPathName","isVariableCommandPath","joinPaths","constantCase","pascalCase","defu","CommandEntry","CommandRouter","Help","VirtualCommandHandlerDeclaration","props","command","context","_$createComponent","heading","title","path","segments","map","segment","join","children","description","replace","_$createIntrinsic","name","async","parameters","type","default","commands","_$memo","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","value","didyoumean2","Object","entries","child","isVirtual","reduce","ret","alias","console","utils","each","values","when","fallback"],"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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\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 {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getAppTitle,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { Help } from \"./help\";\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(props: {\n command: CommandTree;\n}) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `[${constantCase(getVariableCommandPathName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <CommandRouter\n path={command.path.segments}\n commands={command.children}\n />\n <hbr />\n <hbr />\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(/\\.+$/, \"\")}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </FunctionDeclaration>\n </>\n );\n}\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<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.path.segments\n .filter(segment => !isVariableCommandPath(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\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 console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\"]\n })}>\n <VirtualCommandHandlerDeclaration command={command} />\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command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,KAAG;EAAA,IAAC8D,OAAI;AAAA,UAAET,OAAOU,OAAOzC,QAAQU,SAAS;;EAAAA,WACvCuB,UAAK/B,gBACHvB,MAAI;GAAA,IACH+D,OAAI;AAAA,WAAET,MAAMC;;GAAS,IACrBS,WAAQ;AAAA,WAAAzC,gBAAGP,cAAY,EAACK,SAASiC,OAAK,CAAA;;GAAA,IAAAvB,WAAA;AAAA,WAAAR,gBACrCmB,qBAAmB,EAACrB,SAASiC,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
package/dist/index.cjs CHANGED
@@ -12,7 +12,6 @@ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
12
12
  let __alloy_js_core = require("@alloy-js/core");
13
13
  let __alloy_js_typescript = require("@alloy-js/typescript");
14
14
  let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
15
- let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
16
15
  let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
17
16
  let __shell_shock_plugin_theme = require("@shell-shock/plugin-theme");
18
17
  __shell_shock_plugin_theme = require_rolldown_runtime.__toESM(__shell_shock_plugin_theme);
@@ -34,6 +33,9 @@ const plugin = (options = {}) => {
34
33
  ...options
35
34
  };
36
35
  },
36
+ configResolved() {
37
+ this.dependencies.didyoumean2 = "^7.0.4";
38
+ },
37
39
  async prepare() {
38
40
  this.debug("Rendering built-in modules for the Shell Shock `script` preset.");
39
41
  return (0, __powerlines_plugin_alloy_render.render)(this, [(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_utils_builtin.UtilsBuiltin, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_console_builtin.ConsoleBuiltin, {})]);
@@ -46,7 +48,6 @@ const plugin = (options = {}) => {
46
48
  async handler() {
47
49
  const _self$ = this;
48
50
  this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
49
- const commands = this.inputs.map((input) => (0, __shell_shock_core_plugin_utils.getCommandTree)(this, input.path.segments)).filter(Boolean);
50
51
  return (0, __powerlines_plugin_alloy_render.render)(this, [(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_bin_entry.BinEntry, {
51
52
  builtinImports: {
52
53
  console: [
@@ -57,85 +58,107 @@ const plugin = (options = {}) => {
57
58
  utils: ["getArgs"]
58
59
  },
59
60
  get children() {
60
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
61
- get when() {
62
- return (0, __alloy_js_core_jsx_runtime.memo)(() => !!_self$.commands)() && Object.keys(_self$.commands).length > 0;
63
- },
64
- get children() {
65
- return [
66
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
67
- "const": true,
68
- name: "args",
69
- type: "string[]",
70
- initializer: __alloy_js_core.code`getArgs();`
71
- }),
72
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
73
- (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
74
- path: [],
75
- get commands() {
76
- return _self$.commands ?? {};
77
- }
78
- }),
79
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
80
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
81
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
61
+ return [
62
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
63
+ get when() {
64
+ return Object.keys(_self$.commands).length > 0;
65
+ },
66
+ get children() {
67
+ return [
68
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
69
+ "const": true,
70
+ name: "args",
71
+ type: "string[]",
72
+ initializer: __alloy_js_core.code`getArgs();`
73
+ }),
74
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
75
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
76
+ path: [],
77
+ get commands() {
78
+ return _self$.commands ?? {};
79
+ }
80
+ }),
81
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
82
+ ];
83
+ }
84
+ }),
85
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
86
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
82
87
  writeLine("");
83
88
  writeLine(colors.text.heading.primary("${/(?:cli|command-line|command line)\s+(?:application|app)?$/.test((0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(_self$).toLowerCase()) ? (0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(_self$) : `${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(_self$)} Command-Line Application`} v${_self$.packageJson.version}"));
84
89
  writeLine("");
85
90
  writeLine(colors.text.body.primary("${(0, __shell_shock_core_plugin_utils_context_helpers.getAppDescription)(_self$)}"));
86
- writeLine("");
87
- divider({ style: "primary" });
88
- writeLine("");
89
- writeLine("");`),
90
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
91
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
92
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
93
- get each() {
94
- return Object.values(commands);
95
- },
96
- doubleHardline: true,
97
- joiner: __alloy_js_core.code`
98
- writeLine("");
99
- divider({ style: "secondary" });
100
- writeLine("");
101
- writeLine("");
102
- `,
103
- children: (child) => [
104
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
105
- writeLine("");
106
- writeLine(colors.text.heading.secondary("${child.title}"));
91
+ writeLine(""); `),
92
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
93
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
94
+ __alloy_js_core.code`writeLine(colors.text.heading.secondary("GLOBAL OPTIONS:"));`,
95
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
96
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.HelpOptions, { get options() {
97
+ return _self$.options;
98
+ } }),
99
+ __alloy_js_core.code`writeLine(""); `,
100
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
101
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
102
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
103
+ get when() {
104
+ return Object.keys(_self$.commands).length > 0;
105
+ },
106
+ get children() {
107
+ return [
108
+ __alloy_js_core.code`writeLine(colors.text.body.secondary("The following commands are available:"));
109
+ writeLine(""); `,
110
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
111
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
112
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
113
+ get each() {
114
+ return Object.values(_self$.commands);
115
+ },
116
+ doubleHardline: true,
117
+ joiner: __alloy_js_core.code`writeLine(""); `,
118
+ ender: __alloy_js_core.code`writeLine(""); `,
119
+ children: (child) => [
120
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
121
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
107
122
  writeLine("");
108
123
  writeLine(colors.text.body.secondary("${child.description}"));
109
124
  writeLine("");
110
- writeLine("");
111
125
  `),
112
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
113
- (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.Help, {
114
- command: child,
115
- indent: 2
116
- })
117
- ]
118
- })
119
- ];
120
- }
121
- });
126
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
127
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.Help, {
128
+ command: child,
129
+ indent: 2
130
+ }),
131
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
132
+ ]
133
+ })
134
+ ];
135
+ }
136
+ })
137
+ ];
122
138
  }
123
- }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
124
- get each() {
125
- return Object.values(commands);
139
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
140
+ get when() {
141
+ return Object.values(_self$.commands).length > 0;
126
142
  },
127
- doubleHardline: true,
128
- children: (child) => (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
129
- get when() {
130
- return child.isVirtual;
131
- },
132
- get fallback() {
133
- return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_entry.CommandEntry, { command: child });
134
- },
135
- get children() {
136
- return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_virtual_command_entry.VirtualCommandEntry, { command: child });
137
- }
138
- })
143
+ get children() {
144
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
145
+ get each() {
146
+ return Object.values(_self$.commands);
147
+ },
148
+ doubleHardline: true,
149
+ children: (child) => (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
150
+ get when() {
151
+ return child.isVirtual;
152
+ },
153
+ get fallback() {
154
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_entry.CommandEntry, { command: child });
155
+ },
156
+ get children() {
157
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_virtual_command_entry.VirtualCommandEntry, { command: child });
158
+ }
159
+ })
160
+ });
161
+ }
139
162
  })]);
140
163
  }
141
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["code","For","Show","VarDeclaration","render","getCommandTree","getAppDescription","getAppTitle","theme","BinEntry","CommandEntry","CommandRouter","ConsoleBuiltin","Help","UtilsBuiltin","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","prepare","_$createComponent","order","handler","_self$","commands","inputs","map","input","path","segments","filter","Boolean","builtinImports","console","utils","children","when","_$memo","Object","keys","length","type","initializer","_$createIntrinsic","test","toLowerCase","packageJson","version","each","values","doubleHardline","joiner","child","title","description","command","indent","isVirtual","fallback"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getCommandTree } from \"@shell-shock/core/plugin-utils\";\nimport {\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { ConsoleBuiltin } from \"./components/console-builtin\";\nimport { Help } from \"./components/help\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.path.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\"divider\", \"writeLine\", \"colors\"],\n utils: [\"getArgs\"]\n }}>\n <Show\n when={this.commands && Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter path={[]} commands={this.commands ?? {}} />\n <hbr />\n <hbr />\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${\n /(?:cli|command-line|command line)\\s+(?:application|app)?$/.test(\n getAppTitle(this).toLowerCase()\n )\n ? getAppTitle(this)\n : `${getAppTitle(this)} Command-Line Application`\n } v${this.packageJson.version}\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${getAppDescription(\n this\n )}\"));\n writeLine(\"\");\n divider({ style: \"primary\" });\n writeLine(\"\");\n writeLine(\"\");`}\n <hbr />\n <hbr />\n <For\n each={Object.values(commands)}\n doubleHardline\n joiner={code`\n writeLine(\"\");\n divider({ style: \"secondary\" });\n writeLine(\"\");\n writeLine(\"\");\n `}>\n {child => (\n <>\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.secondary(\"${child.title}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n writeLine(\"\");\n `}\n <hbr />\n <Help command={child} indent={2} />\n </>\n )}\n </For>\n </Show>\n </BinEntry>\n <For each={Object.values(commands)} doubleHardline>\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 }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAaiB,UAGXC,UAA+B,EAAE,KAC9B;AACH,QAAO;0CACC,EACJV,OAAOU,QAAQV,OAChB,CAAC;EACF;GACEW,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,uEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEH,MAAMM,UAAU;AACd,SAAKH,MACH,kEACD;AAED,wDACE,MAAI,kDAEDP,+CAAY,EAAA,CAAA,mDACZF,mDAAc,EAAA,CAAA,CAEnB,CAAC;;GAEJ;EACD;GACEO,MAAM;GACNK,SAAS;IACPE,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKP,MACH,oEACD;KAED,MAAMQ,WAAW,KAAKC,OACnBC,KAAIC,8DAAwB,MAAMA,MAAMC,KAAKC,SAAS,CAAC,CACvDC,OAAOC,QAAyB;AAEnC,yDACE,MAAI,kDAED3B,uCAAQ;MACP4B,gBAAgB;OACdC,SAAS;QAAC;QAAW;QAAa;QAAS;OAC3CC,OAAO,CAAC,UAAS;OAClB;MAAA,IAAAC,WAAA;AAAA,+DACAtC,sBAAI;QAAA,IACHuC,OAAI;AAAA,4DAAE,CAAA,CAAAb,OAAKC,SAAQ,EAAA,IAAIc,OAAOC,KAAKhB,OAAKC,SAAS,CAACgB,SAAS;;QAAC,IAAAL,WAAA;AAAA,gBAAA;2DAC3DrC,sCAAc;WAAA,SAAA;WAEbgB,MAAI;WACJ2B,MAAI;WACJC,aAAa/C,oBAAI;WAAY,CAAA;2DAAA,OAAA,EAAA,CAAA;2DAG9BW,iDAAa;WAACsB,MAAM,EAAE;WAAA,IAAEJ,WAAQ;AAAA,mBAAED,OAAKC,YAAY,EAAE;;WAAA,CAAA;2DAAA,OAAA,EAAA,CAAA;2DAAA,OAAA,EAAA,CAAA;sDAGrD7B,oBAAI;;yDAGL,4DAA4DiD,sEAC/CrB,OAAM,CAACsB,aACpB,CAAC,oEACctB,OAAM,GACjB,oEAAcA,OAAM,CAAA,2BAA2B,IAChDA,OAAKuB,YAAYC,QAAO;;6HAE0BxB,OAEtD,CAAA;;;;gCAIc;2DAAA,OAAA,EAAA,CAAA;2DAAA,OAAA,EAAA,CAAA;2DAGZ3B,qBAAG;WAAA,IACFoD,OAAI;AAAA,mBAAEV,OAAOW,OAAOzB,SAAS;;WAC7B0B,gBAAc;WACdC,QAAQxD,oBAAI;;;;;;WAKfwC,WACIiB,UAAK;wDAEDzD,oBAAI;;2DAE8ByD,MAAMC,MAAK;;wDAEdD,MAAME,YAAW;;;kBAGxD;6DAAA,OAAA,EAAA,CAAA;6DAEQ9C,8BAAI;aAAC+C,SAASH;aAAOI,QAAQ;aAAC,CAAA;YAAA;WAElC,CAAA;UAAA;;QAAA,CAAA;;MAAA,CAAA,mDAIN5D,qBAAG;MAAA,IAACoD,OAAI;AAAA,cAAEV,OAAOW,OAAOzB,SAAS;;MAAE0B,gBAAc;MAAAf,WAC/CiB,2DACEvD,sBAAI;OAAA,IACHuC,OAAI;AAAA,eAAEgB,MAAMK;;OAAS,IACrBC,WAAQ;AAAA,gEAAGrD,+CAAY,EAACkD,SAASH,OAAK,CAAA;;OAAA,IAAAjB,WAAA;AAAA,gEACrCzB,8DAAmB,EAAC6C,SAASH,OAAK,CAAA;;OAAA,CAAA;MAEtC,CAAA,CAGP,CAAC;;IAEL;GACD;EACF;;AAGH,kBAAexC"}
1
+ {"version":3,"file":"index.cjs","names":["code","For","Show","VarDeclaration","render","getAppDescription","getAppTitle","theme","BinEntry","CommandEntry","CommandRouter","ConsoleBuiltin","Help","HelpOptions","UtilsBuiltin","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","order","handler","_self$","builtinImports","console","utils","children","when","Object","keys","commands","length","type","initializer","_$createIntrinsic","path","_$memo","test","toLowerCase","packageJson","version","each","values","doubleHardline","joiner","ender","child","title","isVirtual","description","command","indent","fallback"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport {\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { ConsoleBuiltin } from \"./components/console-builtin\";\nimport { Help, HelpOptions } from \"./components/help\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\"divider\", \"writeLine\", \"colors\"],\n utils: [\"getArgs\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter path={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${\n /(?:cli|command-line|command line)\\s+(?:application|app)?$/.test(\n getAppTitle(this).toLowerCase()\n )\n ? getAppTitle(this)\n : `${getAppTitle(this)} Command-Line Application`\n } v${this.packageJson.version}\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${getAppDescription(\n this\n )}\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.text.heading.secondary(\"GLOBAL OPTIONS:\"));`}\n <hbr />\n <HelpOptions options={this.options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(this.commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(this.commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <Help command={child} indent={2} />\n <hbr />\n </>\n )}\n </For>\n </Show>\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAaiB,UAGXC,UAA+B,EAAE,KAC9B;AACH,QAAO;0CACC,EACJX,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,uEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAElC,MAAMC,UAAU;AACd,SAAKN,MACH,kEACD;AAED,wDACE,MAAI,kDAEDP,+CAAY,EAAA,CAAA,mDACZH,mDAAc,EAAA,CAAA,CAEnB,CAAC;;GAEJ;EACD;GACEQ,MAAM;GACNQ,SAAS;IACPE,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKV,MACH,oEACD;AAED,yDACE,MAAI,kDAEDb,uCAAQ;MACPwB,gBAAgB;OACdC,SAAS;QAAC;QAAW;QAAa;QAAS;OAC3CC,OAAO,CAAC,UAAS;OAClB;MAAA,IAAAC,WAAA;AAAA,cAAA;yDACAjC,sBAAI;SAAA,IAACkC,OAAI;AAAA,iBAAEC,OAAOC,KAAKP,OAAKQ,SAAS,CAACC,SAAS;;SAAC,IAAAL,WAAA;AAAA,iBAAA;4DAC9ChC,sCAAc;YAAA,SAAA;YAEbgB,MAAI;YACJsB,MAAI;YACJC,aAAa1C,oBA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QAAA;;MAAA,CAAA,mDAIN1D,sBAAI;MAAA,IAACkC,OAAI;AAAA,cAAEC,OAAOc,OAAOpB,OAAKQ,SAAS,CAACC,SAAS;;MAAC,IAAAL,WAAA;AAAA,+DAChDlC,qBAAG;QAAA,IAACiD,OAAI;AAAA,gBAAEb,OAAOc,OAAOpB,OAAKQ,SAAS;;QAAEa,gBAAc;QAAAjB,WACpDoB,2DACErD,sBAAI;SAAA,IACHkC,OAAI;AAAA,iBAAEmB,MAAME;;SAAS,IACrBI,WAAQ;AAAA,kEAAGpD,+CAAY,EAACkD,SAASJ,OAAK,CAAA;;SAAA,IAAApB,WAAA;AAAA,kEACrCpB,8DAAmB,EAAC4C,SAASJ,OAAK,CAAA;;SAAA,CAAA;QAEtC,CAAA;;MAAA,CAAA,CAIT,CAAC;;IAEL;GACD;EACF;;AAGH,kBAAetC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,GA+HZ,MA/HY,CA+HL,QA/HK,CAAA,EAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,GAmIZ,MAnIY,CAmIL,QAnIK,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,GA+HZ,MA/HY,CA+HL,QA/HK,CAAA,EAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,GAmIZ,MAnIY,CAmIL,QAnIK,CAAA,EAAA"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BinEntry } from "./components/bin-entry.mjs";
2
- import { Help } from "./components/help.mjs";
2
+ import { Help, HelpOptions } from "./components/help.mjs";
3
3
  import { CommandRouter } from "./components/command-router.mjs";
4
4
  import { VirtualCommandEntry } from "./components/virtual-command-entry.mjs";
5
5
  import { CommandEntry } from "./components/command-entry.mjs";
@@ -10,7 +10,6 @@ import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runti
10
10
  import { For, Show, code } from "@alloy-js/core";
11
11
  import { VarDeclaration } from "@alloy-js/typescript";
12
12
  import { render } from "@powerlines/plugin-alloy/render";
13
- import { getCommandTree } from "@shell-shock/core/plugin-utils";
14
13
  import { getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils/context-helpers";
15
14
  import theme from "@shell-shock/plugin-theme";
16
15
 
@@ -31,6 +30,9 @@ const plugin = (options = {}) => {
31
30
  ...options
32
31
  };
33
32
  },
33
+ configResolved() {
34
+ this.dependencies.didyoumean2 = "^7.0.4";
35
+ },
34
36
  async prepare() {
35
37
  this.debug("Rendering built-in modules for the Shell Shock `script` preset.");
36
38
  return render(this, [createComponent(UtilsBuiltin, {}), createComponent(ConsoleBuiltin, {})]);
@@ -43,7 +45,6 @@ const plugin = (options = {}) => {
43
45
  async handler() {
44
46
  const _self$ = this;
45
47
  this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
46
- const commands = this.inputs.map((input) => getCommandTree(this, input.path.segments)).filter(Boolean);
47
48
  return render(this, [createComponent(BinEntry, {
48
49
  builtinImports: {
49
50
  console: [
@@ -54,85 +55,107 @@ const plugin = (options = {}) => {
54
55
  utils: ["getArgs"]
55
56
  },
56
57
  get children() {
57
- return createComponent(Show, {
58
- get when() {
59
- return memo(() => !!_self$.commands)() && Object.keys(_self$.commands).length > 0;
60
- },
61
- get children() {
62
- return [
63
- createComponent(VarDeclaration, {
64
- "const": true,
65
- name: "args",
66
- type: "string[]",
67
- initializer: code`getArgs();`
68
- }),
69
- createIntrinsic("hbr", {}),
70
- createComponent(CommandRouter, {
71
- path: [],
72
- get commands() {
73
- return _self$.commands ?? {};
74
- }
75
- }),
76
- createIntrinsic("hbr", {}),
77
- createIntrinsic("hbr", {}),
78
- memo(() => code`
58
+ return [
59
+ createComponent(Show, {
60
+ get when() {
61
+ return Object.keys(_self$.commands).length > 0;
62
+ },
63
+ get children() {
64
+ return [
65
+ createComponent(VarDeclaration, {
66
+ "const": true,
67
+ name: "args",
68
+ type: "string[]",
69
+ initializer: code`getArgs();`
70
+ }),
71
+ createIntrinsic("hbr", {}),
72
+ createComponent(CommandRouter, {
73
+ path: [],
74
+ get commands() {
75
+ return _self$.commands ?? {};
76
+ }
77
+ }),
78
+ createIntrinsic("hbr", {})
79
+ ];
80
+ }
81
+ }),
82
+ createIntrinsic("hbr", {}),
83
+ memo(() => code`
79
84
  writeLine("");
80
85
  writeLine(colors.text.heading.primary("${/(?:cli|command-line|command line)\s+(?:application|app)?$/.test(getAppTitle(_self$).toLowerCase()) ? getAppTitle(_self$) : `${getAppTitle(_self$)} Command-Line Application`} v${_self$.packageJson.version}"));
81
86
  writeLine("");
82
87
  writeLine(colors.text.body.primary("${getAppDescription(_self$)}"));
83
- writeLine("");
84
- divider({ style: "primary" });
85
- writeLine("");
86
- writeLine("");`),
87
- createIntrinsic("hbr", {}),
88
- createIntrinsic("hbr", {}),
89
- createComponent(For, {
90
- get each() {
91
- return Object.values(commands);
92
- },
93
- doubleHardline: true,
94
- joiner: code`
95
- writeLine("");
96
- divider({ style: "secondary" });
97
- writeLine("");
98
- writeLine("");
99
- `,
100
- children: (child) => [
101
- memo(() => code`
102
- writeLine("");
103
- writeLine(colors.text.heading.secondary("${child.title}"));
88
+ writeLine(""); `),
89
+ createIntrinsic("hbr", {}),
90
+ createIntrinsic("hbr", {}),
91
+ code`writeLine(colors.text.heading.secondary("GLOBAL OPTIONS:"));`,
92
+ createIntrinsic("hbr", {}),
93
+ createComponent(HelpOptions, { get options() {
94
+ return _self$.options;
95
+ } }),
96
+ code`writeLine(""); `,
97
+ createIntrinsic("hbr", {}),
98
+ createIntrinsic("hbr", {}),
99
+ createComponent(Show, {
100
+ get when() {
101
+ return Object.keys(_self$.commands).length > 0;
102
+ },
103
+ get children() {
104
+ return [
105
+ code`writeLine(colors.text.body.secondary("The following commands are available:"));
106
+ writeLine(""); `,
107
+ createIntrinsic("hbr", {}),
108
+ createIntrinsic("hbr", {}),
109
+ createComponent(For, {
110
+ get each() {
111
+ return Object.values(_self$.commands);
112
+ },
113
+ doubleHardline: true,
114
+ joiner: code`writeLine(""); `,
115
+ ender: code`writeLine(""); `,
116
+ children: (child) => [
117
+ memo(() => code`
118
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
104
119
  writeLine("");
105
120
  writeLine(colors.text.body.secondary("${child.description}"));
106
121
  writeLine("");
107
- writeLine("");
108
122
  `),
109
- createIntrinsic("hbr", {}),
110
- createComponent(Help, {
111
- command: child,
112
- indent: 2
113
- })
114
- ]
115
- })
116
- ];
117
- }
118
- });
123
+ createIntrinsic("hbr", {}),
124
+ createComponent(Help, {
125
+ command: child,
126
+ indent: 2
127
+ }),
128
+ createIntrinsic("hbr", {})
129
+ ]
130
+ })
131
+ ];
132
+ }
133
+ })
134
+ ];
119
135
  }
120
- }), createComponent(For, {
121
- get each() {
122
- return Object.values(commands);
136
+ }), createComponent(Show, {
137
+ get when() {
138
+ return Object.values(_self$.commands).length > 0;
123
139
  },
124
- doubleHardline: true,
125
- children: (child) => createComponent(Show, {
126
- get when() {
127
- return child.isVirtual;
128
- },
129
- get fallback() {
130
- return createComponent(CommandEntry, { command: child });
131
- },
132
- get children() {
133
- return createComponent(VirtualCommandEntry, { command: child });
134
- }
135
- })
140
+ get children() {
141
+ return createComponent(For, {
142
+ get each() {
143
+ return Object.values(_self$.commands);
144
+ },
145
+ doubleHardline: true,
146
+ children: (child) => createComponent(Show, {
147
+ get when() {
148
+ return child.isVirtual;
149
+ },
150
+ get fallback() {
151
+ return createComponent(CommandEntry, { command: child });
152
+ },
153
+ get children() {
154
+ return createComponent(VirtualCommandEntry, { command: child });
155
+ }
156
+ })
157
+ });
158
+ }
136
159
  })]);
137
160
  }
138
161
  }