@shell-shock/preset-script 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/components/bin-entry.cjs +0 -1
  3. package/dist/components/bin-entry.cjs.map +1 -1
  4. package/dist/components/bin-entry.d.cts.map +1 -1
  5. package/dist/components/bin-entry.d.mts.map +1 -1
  6. package/dist/components/bin-entry.mjs +0 -1
  7. package/dist/components/bin-entry.mjs.map +1 -1
  8. package/dist/components/command-entry.d.mts +4 -4
  9. package/dist/components/command-entry.d.mts.map +1 -1
  10. package/dist/components/command-router.cjs +2 -2
  11. package/dist/components/command-router.cjs.map +1 -1
  12. package/dist/components/command-router.mjs +2 -2
  13. package/dist/components/command-router.mjs.map +1 -1
  14. package/dist/components/console-builtin.cjs +246 -34
  15. package/dist/components/console-builtin.cjs.map +1 -1
  16. package/dist/components/console-builtin.d.cts +12 -2
  17. package/dist/components/console-builtin.d.cts.map +1 -1
  18. package/dist/components/console-builtin.d.mts +12 -2
  19. package/dist/components/console-builtin.d.mts.map +1 -1
  20. package/dist/components/console-builtin.mjs +247 -36
  21. package/dist/components/console-builtin.mjs.map +1 -1
  22. package/dist/components/help.cjs +4 -4
  23. package/dist/components/help.cjs.map +1 -1
  24. package/dist/components/help.mjs +4 -4
  25. package/dist/components/help.mjs.map +1 -1
  26. package/dist/components/index.cjs +1 -0
  27. package/dist/components/index.d.cts +2 -2
  28. package/dist/components/index.d.mts +2 -2
  29. package/dist/components/index.mjs +2 -2
  30. package/dist/components/utils-builtin.cjs +18 -16
  31. package/dist/components/utils-builtin.cjs.map +1 -1
  32. package/dist/components/utils-builtin.d.cts.map +1 -1
  33. package/dist/components/utils-builtin.d.mts +7 -7
  34. package/dist/components/utils-builtin.d.mts.map +1 -1
  35. package/dist/components/utils-builtin.mjs +18 -16
  36. package/dist/components/utils-builtin.mjs.map +1 -1
  37. package/dist/helpers/ansi-utils.cjs +74 -10
  38. package/dist/helpers/ansi-utils.cjs.map +1 -1
  39. package/dist/helpers/ansi-utils.mjs +74 -10
  40. package/dist/helpers/ansi-utils.mjs.map +1 -1
  41. package/dist/helpers/get-default-options.cjs +20 -0
  42. package/dist/helpers/get-default-options.cjs.map +1 -1
  43. package/dist/helpers/get-default-options.mjs +20 -0
  44. package/dist/helpers/get-default-options.mjs.map +1 -1
  45. package/dist/index.cjs +10 -8
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts.map +1 -1
  48. package/dist/index.d.mts.map +1 -1
  49. package/dist/index.mjs +11 -9
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/types/plugin.d.mts.map +1 -1
  52. package/package.json +10 -10
package/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the ⚡<b>Shell Shock</b> monorepo. The Shell Shock pack
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-0.1.2-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-0.2.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
@@ -73,7 +73,6 @@ function RunApplication() {
73
73
 
74
74
  exit();
75
75
  } catch (err) {
76
- verbose("An exception occurred during processing");
77
76
  exit({ exception: err as Error });
78
77
  }
79
78
  })();
@@ -1 +1 @@
1
- {"version":3,"file":"bin-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","RunApplication","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","_$createComponent","each","value","_$mergeProps","path","typeDefinition","file","output","didyoumean2","name","default","entries","commands","filter","command","isVirtual","reduce","ret","alias","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"sources":["../../src/components/bin-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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } 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 { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <hbr />\n <hbr />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n try {\n process.on(\"exit\", () => exit({\n skipExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n\n exit();\n } catch (err) {\n verbose(\"An exception occurred during processing\");\n exit({ exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"table\"],\n utils: [\"hasFlag\", \"exit\"]\n })}>\n <Show when={Boolean(prefix)}>\n {prefix}\n <hbr />\n <hbr />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(context)} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${context?.packageJson.version ? `\"${context?.packageJson.version}\"` : \"0.0.1\"});\n return;`}\n </IfStatement>\n <hbr />\n <hbr />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAgBe,iBAAiB;AAC/B,QAAA;mDAAA,OAAA,EAA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QACxBJ;yDAAM,OAAA,EAAA,CAAA;yDAAA,OAAA,EAAA,CAAA;QAAA;;MAAA,CAAA;sDAIRX,6DAAK,EAAA,IACJ8C,UAAO;AAAA,aAAE,+FAA0C7B,QAAQ,CAAA;QAAmB,CAAA;sDAC/ErB,2CAAmB;MAACmD,OAAK;MAACC,YAAU;MAAOhB,MAAI;MAAA,IAAAjB,WAAA;AAAA,cAAA;yDAC7ClB,mCAAW;SAACoD,WAAWzD,oBAAI;SAA2B,IAAAuB,WAAA;AAAA,iBACpDvB,oBAAI,eAAeyB,SAASiC,YAAYC,UAAU,IAAIlC,SAASiC,YAAYC,QAAO,KAAM,QAAO;;;SAC5F,CAAA;yDAAA,OAAA,EAAA,CAAA;yDAAA,OAAA,EAAA,CAAA;QAILpC;yDAAQ,OAAA,EAAA,CAAA;QAAA;;MAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAMVpB,sBAAI;MAAA,IAACiD,OAAI;AAAA,cAAEC,QAAQjC,QAAQ;;MAAA,IAAEwC,WAAQ;AAAA,+DAAG7C,gBAAc,EAAA,CAAA;;MAAAQ,UACpDH;MAAO,CAAA;sDAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA,CAAA;EAIb,CAAA"}
1
+ {"version":3,"file":"bin-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","RunApplication","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","_$createComponent","each","value","_$mergeProps","path","typeDefinition","file","output","didyoumean2","name","default","entries","commands","filter","command","isVirtual","reduce","ret","alias","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"sources":["../../src/components/bin-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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } 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 { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <hbr />\n <hbr />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n try {\n process.on(\"exit\", () => exit({\n skipExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n\n exit();\n } catch (err) {\n exit({ exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"table\"],\n utils: [\"hasFlag\", \"exit\"]\n })}>\n <Show when={Boolean(prefix)}>\n {prefix}\n <hbr />\n <hbr />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(context)} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${context?.packageJson.version ? `\"${context?.packageJson.version}\"` : \"0.0.1\"});\n return;`}\n </IfStatement>\n <hbr />\n <hbr />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAgBe,iBAAiB;AAC/B,QAAA;mDAAA,OAAA,EAAA,CAAA;mDAAA,OAAA,EAAA,CAAA;EAIKf,oBAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDAuDJ,OAAA,EAAA,CAAA;EAAA;;;;;AAkBP,SAAgBiB,SAASC,OAAsB;CAC7C,MAAM,EAAEC,QAAQC,SAASC,gBAAgBC,SAASC,UAAU,GAAGC,SAASN;CAExE,MAAMO,8EAA8C;CACpD,MAAMC,sFAAgCC,OAAOC,OAAOH,QAAQI,OAAOC,IAAI,CAAC,CAAC;AAEzE,yDACG5B,qBAAG;EAAA,IAAC8B,OAAI;AAAA,UAAEN,KAAKO;;EAAKV,WAClBO,yDACEvB,kHACKiB,MAAI;GAAA,IACRW,OAAI;AAAA,qGAAgCL,IAAI,CAAC;;GACzCM,gBAAgB;IACdC,MAAMP;IACNQ,QAAQ;IACT;GAAA,IACDhB,UAAO;AAAA,6BACL,EACEiB,aAAa;KACX;MAAEC,MAAM;MAAcC,SAAS;MAAM;KACrC,EAAED,MAAM,mBAAmB;KAC3B,EAAEA,MAAM,sBAAsB;KAAA,EAEjC,EACDlB,WAAW,EAAE,EACbK,OAAOe,QAAQjB,QAAQkB,SAAS,CAC7BC,QAAQ,GAAGC,aAAaA,QAAQC,UAAU,CAC1CC,QAAQC,KAAK,CAACR,MAAMK,aAAa;AAChCG,SA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"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAmEiB,iBAnED,cAAA,CAAA,CAmEe,EAnED,QAmEC;AAC7B,UADe,aAAA,SAAsB,IACrC,CAAA,cAAA,EAAA,MAAA,GAAA,UAAA,CAAA,CAAA;EAGS,MAAA,CAAA,EAAA,QAAA;EACC,OAAA,CAAA,EAAA,QAAA;EACA,QAAA,EAAA,QAAA;;;AAMZ;;iBAAgB,QAAA,QAAgB,gBAAa"}
1
+ {"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAkEiB,iBAlED,cAAA,CAAA,CAkEe,EAlED,QAkEC;AAC7B,UADe,aAAA,SAAsB,IACrC,CAAA,cAAA,EAAA,MAAA,GAAA,UAAA,CAAA,CAAA;EAGS,MAAA,CAAA,EAAA,QAAA;EACC,OAAA,CAAA,EAAA,QAAA;EACA,QAAA,EAAA,QAAA;;;AAMZ;;iBAAgB,QAAA,QAAgB,gBAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"bin-entry.d.mts","names":[],"sources":["../../src/components/bin-entry.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAmEiB,iBAnED,cAAA,CAAA,CAmEe,EAnED,QAmEC;AAC7B,UADe,aAAA,SAAsB,IACrC,CAAA,cAAA,EAAA,MAAA,GAAA,UAAA,CAAA,CAAA;EAGS,MAAA,CAAA,EAAA,QAAA;EACC,OAAA,CAAA,EAAA,QAAA;EACA,QAAA,EAAA,QAAA;;;AAMZ;;iBAAgB,QAAA,QAAgB,gBAAa"}
1
+ {"version":3,"file":"bin-entry.d.mts","names":[],"sources":["../../src/components/bin-entry.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAkEiB,iBAlED,cAAA,CAAA,CAkEe,EAlED,QAkEC;AAC7B,UADe,aAAA,SAAsB,IACrC,CAAA,cAAA,EAAA,MAAA,GAAA,UAAA,CAAA,CAAA;EAGS,MAAA,CAAA,EAAA,QAAA;EACC,OAAA,CAAA,EAAA,QAAA;EACA,QAAA,EAAA,QAAA;;;AAMZ;;iBAAgB,QAAA,QAAgB,gBAAa"}
@@ -71,7 +71,6 @@ function RunApplication() {
71
71
 
72
72
  exit();
73
73
  } catch (err) {
74
- verbose("An exception occurred during processing");
75
74
  exit({ exception: err as Error });
76
75
  }
77
76
  })();
@@ -1 +1 @@
1
- {"version":3,"file":"bin-entry.mjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","RunApplication","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","_$createComponent","each","value","_$mergeProps","path","typeDefinition","file","output","didyoumean2","name","default","entries","commands","filter","command","isVirtual","reduce","ret","alias","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"sources":["../../src/components/bin-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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } 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 { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <hbr />\n <hbr />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n try {\n process.on(\"exit\", () => exit({\n skipExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n\n exit();\n } catch (err) {\n verbose(\"An exception occurred during processing\");\n exit({ exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"table\"],\n utils: [\"hasFlag\", \"exit\"]\n })}>\n <Show when={Boolean(prefix)}>\n {prefix}\n <hbr />\n <hbr />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(context)} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${context?.packageJson.version ? `\"${context?.packageJson.version}\"` : \"0.0.1\"});\n return;`}\n </IfStatement>\n <hbr />\n <hbr />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,SAAgBe,iBAAiB;AAC/B,QAAA;EAAAC,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAIKhB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;QAAMH,gBAAA,OAAA,EAAA,CAAA;QAAAA,gBAAA,OAAA,EAAA,CAAA;QAAA;;MAAA,CAAA;KAAAe,gBAIRvB,OAAK,EAAA,IACJ8C,UAAO;AAAA,aAAE,8BAA8B7C,YAAYgB,QAAQ,CAAA;QAAmB,CAAA;KAAAM,gBAC/E3B,qBAAmB;MAACmD,OAAK;MAACC,YAAU;MAAOhB,MAAI;MAAA,IAAAjB,WAAA;AAAA,cAAA;QAAAQ,gBAC7C1B,aAAW;SAACoD,WAAWzD,IAAI;SAA2B,IAAAuB,WAAA;AAAA,iBACpDvB,IAAI,eAAeyB,SAASiC,YAAYC,UAAU,IAAIlC,SAASiC,YAAYC,QAAO,KAAM,QAAO;;;SAC5F,CAAA;QAAA3C,gBAAA,OAAA,EAAA,CAAA;QAAAA,gBAAA,OAAA,EAAA,CAAA;QAILO;QAAQP,gBAAA,OAAA,EAAA,CAAA;QAAA;;MAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAe,gBAMV5B,MAAI;MAAA,IAACiD,OAAI;AAAA,cAAEC,QAAQjC,QAAQ;;MAAA,IAAEwC,WAAQ;AAAA,cAAA7B,gBAAGhB,gBAAc,EAAA,CAAA;;MAAAQ,UACpDH;MAAO,CAAA;KAAAJ,gBAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA,CAAA;EAIb,CAAA"}
1
+ {"version":3,"file":"bin-entry.mjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","RunApplication","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","_$createComponent","each","value","_$mergeProps","path","typeDefinition","file","output","didyoumean2","name","default","entries","commands","filter","command","isVirtual","reduce","ret","alias","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"sources":["../../src/components/bin-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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } 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 { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <hbr />\n <hbr />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n try {\n process.on(\"exit\", () => exit({\n skipExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n\n exit();\n } catch (err) {\n exit({ exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"table\"],\n utils: [\"hasFlag\", \"exit\"]\n })}>\n <Show when={Boolean(prefix)}>\n {prefix}\n <hbr />\n <hbr />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(context)} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${context?.packageJson.version ? `\"${context?.packageJson.version}\"` : \"0.0.1\"});\n return;`}\n </IfStatement>\n <hbr />\n <hbr />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,SAAgBe,iBAAiB;AAC/B,QAAA;EAAAC,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAIKhB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDJgB,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AAkBP,SAAgBC,SAASC,OAAsB;CAC7C,MAAM,EAAEC,QAAQC,SAASC,gBAAgBC,SAASC,UAAU,GAAGC,SAASN;CAExE,MAAMO,UAAUnB,eAAoC;CACpD,MAAMoB,OAAOzB,eAAeS,UAAUiB,OAAOC,OAAOH,QAAQI,OAAOC,IAAI,CAAC,CAAC;AAEzE,QAAAC,gBACG7B,KAAG;EAAA,IAAC8B,OAAI;AAAA,UAAEN,KAAKO;;EAAKV,WAClBO,QAAGC,gBACDxB,WAAS2B,WACJV,MAAI;GAAA,IACRW,OAAI;AAAA,WAAExB,aAAaC,iBAAiBkB,IAAI,CAAC;;GACzCM,gBAAgB;IACdC,MAAMP;IACNQ,QAAQ;IACT;GAAA,IACDhB,UAAO;AAAA,WAAER,KACP,EACEyB,aAAa;KACX;MAAEC,MAAM;MAAcC,SAAS;MAAM;KACrC,EAAED,MAAM,mBAAmB;KAC3B,EAA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AA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAe,gBAMV5B,MAAI;MAAA,IAACiD,OAAI;AAAA,cAAEC,QAAQjC,QAAQ;;MAAA,IAAEwC,WAAQ;AAAA,cAAA7B,gBAAGhB,gBAAc,EAAA,CAAA;;MAAAQ,UACpDH;MAAO,CAAA;KAAAJ,gBAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA,CAAA;EAIb,CAAA"}
@@ -1,24 +1,24 @@
1
- import * as _alloy_js_core11 from "@alloy-js/core";
1
+ import * as _alloy_js_core5 from "@alloy-js/core";
2
2
  import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
3
3
  import { CommandTree } from "@shell-shock/core/types/command";
4
4
 
5
5
  //#region src/components/command-entry.d.ts
6
6
  declare function CommandInvocation(props: {
7
7
  command: CommandTree;
8
- }): _alloy_js_core11.Children;
8
+ }): _alloy_js_core5.Children;
9
9
  /**
10
10
  * A component that generates the `handler` function declaration for a command.
11
11
  */
12
12
  declare function CommandHandlerDeclaration(props: {
13
13
  command: CommandTree;
14
- }): _alloy_js_core11.Children;
14
+ }): _alloy_js_core5.Children;
15
15
  interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
16
  command: CommandTree;
17
17
  }
18
18
  /**
19
19
  * The command entry point for the Shell Shock project.
20
20
  */
21
- declare function CommandEntry(props: CommandEntryProps): _alloy_js_core11.Children;
21
+ declare function CommandEntry(props: CommandEntryProps): _alloy_js_core5.Children;
22
22
  //#endregion
23
23
  export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
24
24
  //# sourceMappingURL=command-entry.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AA0BA;AA4DA;AACE,iBA7Dc,yBAAA,CA6Dd,KAAA,EAAA;EAGS,OAAA,EAhEiD,WAgEjD;CAJgC,CAAA,EA5D4B,gBAAA,CAAE,QA4D9B;AAAI,UAA9B,iBAAA,SAA0B,IAAI,CAC7C,cAD6C,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAU/B,OAAA,EANL,WAMiB;;;;;iBAAZ,YAAA,QAAoB,oBAAiB,gBAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;IAAW,eAAA,CAAE;AAAjE;AA0BA;AA4DA;AACE,iBA7Dc,yBAAA,CA6Dd,KAAA,EAAA;EAGS,OAAA,EAhEiD,WAgEjD;CAJgC,CAAA,EA5D4B,eAAA,CAAE,QA4D9B;AAAI,UAA9B,iBAAA,SAA0B,IAAI,CAC7C,cAD6C,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAU/B,OAAA,EANL,WAMiB;;;;;iBAAZ,YAAA,QAAoB,oBAAiB,eAAA,CAAA"}
@@ -110,7 +110,7 @@ function CommandRouter(props) {
110
110
  }
111
111
  }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
112
112
  get each() {
113
- return subcommand.alias;
113
+ return subcommand?.alias ?? [];
114
114
  },
115
115
  doubleHardline: true,
116
116
  children: (alias) => (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
@@ -136,7 +136,7 @@ function CommandRouter(props) {
136
136
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
137
137
  condition: __alloy_js_core.code`Boolean(command)`,
138
138
  get children() {
139
- return __alloy_js_core.code`const suggestions = didYouMean(command, [${Object.values(commands ?? {}).map((cmd) => `"${cmd.name}"${cmd.alias.map((alias) => `", "${alias}"`).join("")}`).join(", ")}], {
139
+ return __alloy_js_core.code`const suggestions = didYouMean(command, [${Object.values(commands ?? {}).map((cmd) => `"${cmd.name}"${(cmd.alias ?? []).map((alias) => `", "${alias}"`).join("")}`).join(", ")}], {
140
140
  caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},
141
141
  returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
142
142
  thresholdType: ThresholdTypeEnums.SIMILARITY,
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.cjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isVariableCommandPath","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","path","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","context","index","Object","keys","type","initializer","condition","value","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","doubleHardline","map","cmd","join","JSON","stringify"],"sources":["../../src/components/command-router.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isVariableCommandPath } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n )[\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n path: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { path, commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const index = computed(() => 2 + (path.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n <For each={subcommand.alias} doubleHardline>\n {alias => (\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? alias\n : alias.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n )}\n </For>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command)`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${cmd.alias.map(alias => `\", \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.75\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;AAiCA,SAAgBa,qBAAqB;CACnC,MAAMC,+DAAsB;AAE5B,QAAA;mDAEKX,sBAAI;GAAA,IAACa,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,4DAC3BV,iGAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,4DAAoBL,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,KAAKC,SAASC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A,aAAGlB,oBAAI,4CAA4CmC,OAAOO,OAC3FX,YAAY,EACd,CAAC,CACEuB,KACCC,QACE,IAAIA,IAAIpC,KAAI,GAAIoC,IAAIH,MAAME,KAAIF,UAAS,OAAOA,MAAK,GAAI,CAACI,KAAK,GAAG,GACnE,CACAA,KAAK,KAAK,CAAA;2BACQC,KAAKC,UAAUzB,QAAQe,OAAOC,gBAAgB,CAAA;;;;;;;KAK4N,CAAA;IAAA;;EAAA,CAAA"}
1
+ {"version":3,"file":"command-router.cjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isVariableCommandPath","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","path","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","context","index","Object","keys","type","initializer","condition","value","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","doubleHardline","map","cmd","join","JSON","stringify"],"sources":["../../src/components/command-router.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isVariableCommandPath } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n )[\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n path: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { path, commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const index = computed(() => 2 + (path.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n <For each={subcommand?.alias ?? []} doubleHardline>\n {alias => (\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? alias\n : alias.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n )}\n </For>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command)`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `\", \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.75\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;AAiCA,SAAgBa,qBAAqB;CACnC,MAAMC,+DAAsB;AAE5B,QAAA;mDAEKX,sBAAI;GAAA,IAACa,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,4DAC3BV,iGAAsB;KAAA,IACrBW,OA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;QAGX,CAAA,CAAA;;MAAA,CAAA;KAGN,CAAA;qDAEF5B,oCAAY;KACXmC,WAAWvC,oBAAI;KAAkB,IAAAkB,WAAA;AAAA,aAAGlB,oBAAI,4CAA4CmC,OAAOO,OAC3FX,YAAY,EACd,CAAC,CACEuB,KACCC,QACE,IAAIA,IAAIpC,KAAI,IAAKoC,IAAIH,SAAS,EAAE,EAAEE,KAAIF,UAAS,OAAOA,MAAK,GAAI,CAACI,KAAK,GAAG,GAC3E,CACAA,KAAK,KAAK,CAAA;2BACQC,KAAKC,UAAUzB,QAAQe,OAAOC,gBAAgB,CAAA;;;;;;;KAK4N,CAAA;IAAA;;EAAA,CAAA"}
@@ -109,7 +109,7 @@ function CommandRouter(props) {
109
109
  }
110
110
  }), createComponent(For, {
111
111
  get each() {
112
- return subcommand.alias;
112
+ return subcommand?.alias ?? [];
113
113
  },
114
114
  doubleHardline: true,
115
115
  children: (alias) => createComponent(ElseIfClause, {
@@ -135,7 +135,7 @@ function CommandRouter(props) {
135
135
  createComponent(ElseIfClause, {
136
136
  condition: code`Boolean(command)`,
137
137
  get children() {
138
- return code`const suggestions = didYouMean(command, [${Object.values(commands ?? {}).map((cmd) => `"${cmd.name}"${cmd.alias.map((alias) => `", "${alias}"`).join("")}`).join(", ")}], {
138
+ return code`const suggestions = didYouMean(command, [${Object.values(commands ?? {}).map((cmd) => `"${cmd.name}"${(cmd.alias ?? []).map((alias) => `", "${alias}"`).join("")}`).join(", ")}], {
139
139
  caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},
140
140
  returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
141
141
  thresholdType: ThresholdTypeEnums.SIMILARITY,
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isVariableCommandPath","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","path","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","context","index","Object","keys","type","initializer","condition","value","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","doubleHardline","map","cmd","join","JSON","stringify"],"sources":["../../src/components/command-router.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isVariableCommandPath } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n )[\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n path: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { path, commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const index = computed(() => 2 + (path.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n <For each={subcommand.alias} doubleHardline>\n {alias => (\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? alias\n : alias.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n )}\n </For>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command)`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${cmd.alias.map(alias => `\", \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.75\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAgBa,qBAAqB;CACnC,MAAMC,UAAUJ,YAAY;AAE5B,QAAA;EAAAK,gBAEKZ,MAAI;GAAA,IAACa,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,WAAAH,gBAC3BP,wBAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,SAASP,WAAWE,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,KAAKC,SAASC,QACpBC,YAAW,CAACb,sBAAsBa,QACpC,CAAC,CACCV,QAAQO,KAAKC,SAASC,QACpBC,YAAW,CAACb,sBAAsBa,QACpC,CAAC,CAACC,SAAS;;KAGfC,YAAU;KAAA,CAAA;;GAAA,CAAA;EAAAC,gBAAA,OAAA,EAAA,CAAA;EAAAC,WAIb5B,IAAI,gBAAgBY,WAAWE,QAAQK,KAAK,CAAA,SAAS;EAAA;;;;;AAc5D,SAAgBU,cAAcC,OAA2B;CACvD,MAAM,EAAET,MAAMU,UAAUC,UAAUF;CAElC,MAAMG,UAAU1B,eAAoC;C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K,CAAA;2BACQC,KAAKC,UAAUzB,QAAQe,OAAOC,gBAAgB,CAAA;;;;;;;KAK4N,CAAA;IAAA;;EAAA,CAAA"}
1
+ {"version":3,"file":"command-router.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isVariableCommandPath","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","path","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","context","index","Object","keys","type","initializer","condition","value","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","doubleHardline","map","cmd","join","JSON","stringify"],"sources":["../../src/components/command-router.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isVariableCommandPath } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n )[\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n path: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { path, commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const index = computed(() => 2 + (path.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n <For each={subcommand?.alias ?? []} doubleHardline>\n {alias => (\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? alias\n : alias.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n )}\n </For>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command)`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `\", \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.75\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAgBa,qBAAqB;CACnC,MAAMC,UAAUJ,YAAY;AAE5B,QAAA;EAAAK,gBAEKZ,MAAI;GAAA,IAACa,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,WAAAH,gBAC3BP,wBAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,SAASP,WAAWE,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,KAAKC,SAASC,QACpBC,YAAW,CAACb,sBAAsBa,QACpC,CAAC,CACCV,QAAQO,KAAKC,SAASC,QACpBC,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