@shell-shock/preset-script 0.3.3 → 0.4.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 (60) hide show
  1. package/README.md +1 -1
  2. package/dist/components/banner-function-declaration.cjs +53 -20
  3. package/dist/components/banner-function-declaration.cjs.map +1 -1
  4. package/dist/components/banner-function-declaration.d.cts +20 -4
  5. package/dist/components/banner-function-declaration.d.cts.map +1 -1
  6. package/dist/components/banner-function-declaration.d.mts +20 -4
  7. package/dist/components/banner-function-declaration.d.mts.map +1 -1
  8. package/dist/components/banner-function-declaration.mjs +54 -22
  9. package/dist/components/banner-function-declaration.mjs.map +1 -1
  10. package/dist/components/bin-entry.cjs +12 -2
  11. package/dist/components/bin-entry.cjs.map +1 -1
  12. package/dist/components/bin-entry.d.cts.map +1 -1
  13. package/dist/components/bin-entry.d.mts.map +1 -1
  14. package/dist/components/bin-entry.mjs +12 -2
  15. package/dist/components/bin-entry.mjs.map +1 -1
  16. package/dist/components/command-entry.cjs +22 -16
  17. package/dist/components/command-entry.cjs.map +1 -1
  18. package/dist/components/command-entry.d.cts +10 -8
  19. package/dist/components/command-entry.d.cts.map +1 -1
  20. package/dist/components/command-entry.d.mts +9 -7
  21. package/dist/components/command-entry.d.mts.map +1 -1
  22. package/dist/components/command-entry.mjs +25 -19
  23. package/dist/components/command-entry.mjs.map +1 -1
  24. package/dist/components/command-router.cjs +2 -2
  25. package/dist/components/command-router.cjs.map +1 -1
  26. package/dist/components/command-router.mjs +3 -3
  27. package/dist/components/command-router.mjs.map +1 -1
  28. package/dist/components/help.cjs +70 -13
  29. package/dist/components/help.cjs.map +1 -1
  30. package/dist/components/help.d.cts +36 -10
  31. package/dist/components/help.d.cts.map +1 -1
  32. package/dist/components/help.d.mts +36 -10
  33. package/dist/components/help.d.mts.map +1 -1
  34. package/dist/components/help.mjs +68 -12
  35. package/dist/components/help.mjs.map +1 -1
  36. package/dist/components/index.cjs +4 -2
  37. package/dist/components/index.d.cts +5 -5
  38. package/dist/components/index.d.mts +5 -5
  39. package/dist/components/index.mjs +3 -3
  40. package/dist/components/utils-builtin.cjs +8 -1
  41. package/dist/components/utils-builtin.cjs.map +1 -1
  42. package/dist/components/utils-builtin.d.cts.map +1 -1
  43. package/dist/components/utils-builtin.d.mts.map +1 -1
  44. package/dist/components/utils-builtin.mjs +8 -1
  45. package/dist/components/utils-builtin.mjs.map +1 -1
  46. package/dist/components/virtual-command-entry.cjs +32 -12
  47. package/dist/components/virtual-command-entry.cjs.map +1 -1
  48. package/dist/components/virtual-command-entry.d.cts +9 -7
  49. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  50. package/dist/components/virtual-command-entry.d.mts +8 -6
  51. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  52. package/dist/components/virtual-command-entry.mjs +34 -14
  53. package/dist/components/virtual-command-entry.mjs.map +1 -1
  54. package/dist/index.cjs +6 -1
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts.map +1 -1
  57. package/dist/index.d.mts.map +1 -1
  58. package/dist/index.mjs +7 -2
  59. package/dist/index.mjs.map +1 -1
  60. package/package.json +7 -7
@@ -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 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,SAAI,KAAKH,QAAQL,UAAU,CACzB;MAAEA,MAAM;MAAWS,OAAO,4DAAoBT,KAAK;MAAI,CACxD;AAED,YAAOQ;OACN,EAA2B,CAClC,CAAC;;GAAA,IACD3B,iBAAc;AAAA,6BAAOA,kBAAkB,EAAE,EAAE;KACzC6B,SAAS;MAAC;MAAS;MAAW;MAAQ;KACtCC,OAAO,CAAC,WAAW,OAAM;KAC1B,CAAC;;GAAA,IAAA5B,WAAA;AAAA,WAAA;sDACDpB,sBAAI;MAAA,IAACiD,OAAI;AAAA,cAAEC,QAAQlC,OAAO;;MAAA,IAAAI,WAAA;AAAA,cAAA;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 const startDate = new Date();\n\n process.on(\"exit\", () => exit({\n startDate,\n skipExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\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({ startDate });\n } catch (err) {\n exit({ startDate, 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDAiEJ,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,MA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A,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 +1 @@
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
+ {"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AA4EiB,iBA5ED,cAAA,CAAA,CA4Ee,EA5ED,QA4EC;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;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
+ {"version":3,"file":"bin-entry.d.mts","names":[],"sources":["../../src/components/bin-entry.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AA4EiB,iBA5ED,cAAA,CAAA,CA4Ee,EA5ED,QA4EC;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"}
@@ -22,17 +22,22 @@ function RunApplication() {
22
22
  code`// Run the application main logic inside an asynchronous IIFE
23
23
  (async () => {
24
24
  try {
25
+ const startDate = new Date();
26
+
25
27
  process.on("exit", () => exit({
28
+ startDate,
26
29
  skipExit: true,
27
30
  isSynchronous: true,
28
31
  signal: 0
29
32
  }));
30
33
  process.on("beforeExit", () => exit({
34
+ startDate,
31
35
  signal: 0
32
36
  }));
33
37
  process.on("message", message => {
34
38
  if (message === 'shutdown') {
35
39
  exit({
40
+ startDate,
36
41
  isSynchronous: true,
37
42
  signal: -128
38
43
  });
@@ -40,26 +45,31 @@ function RunApplication() {
40
45
  });
41
46
 
42
47
  process.once("SIGTERM", () => exit({
48
+ startDate,
43
49
  signal: 15
44
50
  }));
45
51
  process.once("SIGINT", () => exit({
52
+ startDate,
46
53
  signal: 2
47
54
  }));
48
55
  process.once("SIGUSR2", () => {
49
56
  verbose("The application was terminated by the user");
50
57
  return exit({
58
+ startDate,
51
59
  signal: 12
52
60
  });
53
61
  });
54
62
  process.once("SIGQUIT", () => {
55
63
  verbose("The application was terminated by the user");
56
64
  return exit({
65
+ startDate,
57
66
  signal: 12
58
67
  });
59
68
  });
60
69
 
61
70
  for (const type of ["unhandledRejection", "uncaughtException"]) {
62
71
  process.on(type, err => exit({
72
+ startDate,
63
73
  exception: err || new Error(\`An \${type === "unhandledRejection" ? "unhandled promise rejection" : "uncaught exception"} occurred during processing - the application is shutting down.\`)
64
74
  }));
65
75
  }
@@ -69,9 +79,9 @@ function RunApplication() {
69
79
  error(result.error);
70
80
  }
71
81
 
72
- exit();
82
+ exit({ startDate });
73
83
  } catch (err) {
74
- exit({ exception: err as Error });
84
+ exit({ startDate, exception: err as Error });
75
85
  }
76
86
  })();
77
87
  `,
@@ -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 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,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Q,gBACD5B,MAAI;MAAA,IAACiD,OAAI;AAAA,cAAEC,QAAQlC,OAAO;;MAAA,IAAAI,WAAA;AAAA,cAAA;QACxBJ;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 const startDate = new Date();\n\n process.on(\"exit\", () => exit({\n startDate,\n skipExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\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({ startDate });\n } catch (err) {\n exit({ startDate, 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEJgB,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,aA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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,4 +1,5 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
2
3
  const require_components_help = require('./help.cjs');
3
4
  const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
4
5
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
@@ -21,17 +22,17 @@ let __stryke_string_format_constant_case = require("@stryke/string-format/consta
21
22
  //#region src/components/command-entry.tsx
22
23
  function CommandInvocation(props) {
23
24
  const { command } = props;
24
- return [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`return Promise.resolve(handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(options${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isPositionalCommandOption)(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isPositionalCommandOption)(segment)).map((segment) => (0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getPositionalCommandOptionName)(segment))).join(", ")}` : ""}));`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
25
+ return [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`return Promise.resolve(handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(options${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).map((segment) => (0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))).join(", ")}` : ""}));`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
25
26
  }
26
27
  /**
27
28
  * A component that generates the `handler` function declaration for a command.
28
29
  */
29
30
  function CommandHandlerDeclaration(props) {
30
- const { command } = props;
31
+ const { command, children } = props;
31
32
  const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
32
33
  return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
33
34
  get heading() {
34
- return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isPositionalCommandOption)(segment) ? `[${(0, __stryke_string_format_constant_case.constantCase)((0, __shell_shock_core_plugin_utils_context_helpers.getPositionalCommandOptionName)(segment))}]` : segment).join(" ")}) command.`;
35
+ return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment) ? `[${(0, __stryke_string_format_constant_case.constantCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))}]` : segment).join(" ")}) command.`;
35
36
  },
36
37
  get children() {
37
38
  return [
@@ -59,7 +60,7 @@ function CommandHandlerDeclaration(props) {
59
60
  }],
60
61
  get children() {
61
62
  return [
62
- (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_core_components_options_parser_logic.PositionalOptionsParserLogic, {
63
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_core_components_options_parser_logic.DynamicPathSegmentsParserLogic, {
63
64
  get path() {
64
65
  return command.path;
65
66
  },
@@ -80,19 +81,17 @@ function CommandHandlerDeclaration(props) {
80
81
  }),
81
82
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
82
83
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
84
+ __alloy_js_core.code`writeLine("");
85
+ banner();`,
86
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
87
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
88
+ children,
89
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
90
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
83
91
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
84
92
  condition: __alloy_js_core.code`options.help`,
85
93
  get children() {
86
- return [
87
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
88
- writeLine("");
89
- writeLine(colors.text.heading.primary("${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context)} - ${command.title}"));
90
- writeLine("");
91
- writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
92
- writeLine("");`),
93
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
94
- (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.Help, { command })
95
- ];
94
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.CommandHelp, { command });
96
95
  }
97
96
  }),
98
97
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { get children() {
@@ -108,7 +107,7 @@ function CommandHandlerDeclaration(props) {
108
107
  function CommandEntry(props) {
109
108
  const { command, imports, builtinImports, ...rest } = props;
110
109
  const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
111
- const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isPositionalCommandOption)(segment)).join("/"), "index.ts"));
110
+ const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).join("/"), "index.ts"));
112
111
  const commandSourcePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_replace.replaceExtension)((0, __stryke_path_find.relativePath)((0, __stryke_path_join.joinPaths)(context.entryPath, (0, __stryke_path_find.findFilePath)(filePath.value)), command.entry.input?.file || command.entry.file)));
113
112
  const typeDefinition = (0, __alloy_js_core.computed)(() => ({
114
113
  ...command.entry,
@@ -136,11 +135,18 @@ function CommandEntry(props) {
136
135
  "writeLine",
137
136
  "splitText"
138
137
  ],
139
- utils: ["getArgs", "isMinimal"]
138
+ utils: [
139
+ "getArgs",
140
+ "hasFlag",
141
+ "isMinimal"
142
+ ]
140
143
  });
141
144
  },
142
145
  get children() {
143
146
  return [
147
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_banner_function_declaration.BannerFunctionDeclaration, { command }),
148
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
149
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
144
150
  (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_core_components_options_parser_logic.OptionsInterfaceDeclaration, { command }),
145
151
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
146
152
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","OptionsInterfaceDeclaration","OptionsParserLogic","PositionalOptionsParserLogic","getAppBin","getAppTitle","getPositionalCommandOptionName","isPositionalCommandOption","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","Help","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","context","_$createComponent","heading","title","children","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n PositionalOptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getAppTitle,\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { 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 { Help } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).length > 0\n ? `, ${command.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .map(segment =>\n camelCase(getPositionalCommandOptionName(segment))\n )\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) 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 <PositionalOptionsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\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 /\\.+$/,\n \"\"\n )}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"isMinimal\"]\n })}>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,6CAEK/B,oBAAI,mFAA2CgC,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,2FACDA,QAC5B,CAAC,CAACC,SAAS,IACP,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,2FAAqCA,QAAQ,CAAC,CACrDE,KAAIF,iJACsCA,QAAQ,CACnD,CAAC,CACAG,KAAK,KAAK,KACb,GAAE,KACH,mDAAA,OAAA,EAAA,CAAA,CAAA;;;;;AASX,SAAgBE,0BAA0BZ,OAAiC;CACzE,MAAM,EAAEC,YAAYD;CAEpB,MAAMa,8EAA8C;AAEpD,QAAA,kDAEKnC,6DAAK;EAAA,IACJqC,UAAO;AAAA,UAAE,OAAOd,QAAQe,MAAK,mEAC3BH,QACD,CAAA,GAAIZ,QAAQG,KAAKC,SACfI,KAAIF,2FACuBA,QAAQ,GAC9B,+IAAgDA,QAAQ,CAAC,CAAA,KACzDA,QACL,CACAG,KAAK,IAAI,CAAA;;EAAY,IAAAO,WAAA;AAAA,UAAA;qDACvBrC,oEAAY,EAAA,IAAAqC,WAAA;AAAA,YAAE,GAAGhB,QAAQiB,YAAYC,QAAQ,QAAQ,GAAG,CAAA;OAAG,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAE3DtC,kEAAU,EAAA,IAAAoC,WAAA;AAAA,YAAEhB,QAAQe;OAAK,CAAA;qDACzBrC,kEAAU;KAACwB,MAAI;KAAAc,UAAS;KAAmD,CAAA;IAAA;;EAAA,CAAA,mDAE7E3C,2CAAmB;EAAA,UAAA;EAElB8C,OAAK;EACLjB,MAAI;EACJkB,YAAY,CAAC;GAAEl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CAAC;CACD,MAAMC,sDAAiC;EACrC,GAAGtC,QAAQmC;EACXI,QAAQvC,QAAQwC;EACjB,EAAE;AAEH,QAAA,kDAEKhE,kHACKsD,MAAI;EAAA,IACR3B,OAAI;AAAA,UAAE4B,SAASG;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCN,UAAO;AAAA,4BAAOA,WAAW,EAAE,EAAE,GAC1BI,kBAAkBE,QAAQ,4DAAoBlC,QAAQE,KAAK,IAC7D,CAAC;;EAAA,IACF2B,iBAAc;AAAA,4BAAOA,kBAAkB,EAAE,EAAE;IACzCa,KAAK,CAAC,OAAO,OAAO;IACpBC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO,CAAC,WAAW,YAAW;IAC/B,CAAC;;EAAA,IAAA5B,WAAA;AAAA,UAAA;qDACDnC,gFAA2B,EAAUmB,SAAO,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAG5CW,2BAAyB,EAAUX,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,mDAE5C9B,qBAAG;EAAA,IAAC2E,OAAI;AAAA,UAAEC,OAAOC,OAAO/C,QAAQgB,SAAS;;EAAAA,WACvCgC,2DACE7E,sBAAI;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,4DAAGxB,cAAY,EAAC3B,SAASgD,OAAK,CAAA;;GAAA,IAAAhC,WAAA;AAAA,4DACrCnB,8DAAmB,EAACG,SAASgD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","DynamicPathSegmentsParserLogic","OptionsInterfaceDeclaration","OptionsParserLogic","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandHelp","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","children","context","_$createComponent","heading","title","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n DynamicPathSegmentsParserLogic,\n OptionsInterfaceDeclaration,\n OptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { 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 { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandHelp } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment => isDynamicPathSegment(segment))\n .length > 0\n ? `, ${command.path.segments\n .filter(segment => isDynamicPathSegment(segment))\n .map(segment => camelCase(getDynamicPathSegmentName(segment)))\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) 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 <DynamicPathSegmentsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n <CommandHelp command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,6CAEK/B,oBAAI,mFAA2CgC,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,sFAAgCA,QAAQ,CAAC,CACnEC,SAAS,IACR,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,sFAAgCA,QAAQ,CAAC,CAChDE,KAAIF,4IAA+CA,QAAQ,CAAC,CAAC,CAC7DG,KAAK,KAAK,KACb,GAAE,KACH,mDAAA,OAAA,EAAA,CAAA,CAAA;;;;;AAcX,SAAgBE,0BACdZ,OACA;CACA,MAAM,EAAEC,SAASY,aAAab;CAE9B,MAAMc,8EAA8C;AAEpD,QAAA,kDAEKpC,6DAAK;EAAA,IACJsC,UAAO;AAAA,UAAE,OAAOf,QAAQgB,MAAK,mEAC3BH,QACD,CAAA,GAAIb,QAAQG,KAAKC,SACfI,KAAIF,sFACkBA,QAAQ,GACzB,0IAA2CA,QAAQ,CAAC,CAAA,KACpDA,QACL,CACAG,KAAK,IAAI,CAAA;;EAAY,IAAAG,WAAA;AAAA,UAAA;qDACvBjC,oEAAY,EAAA,IAAAiC,WAAA;AAAA,YAAE,GAAGZ,QAAQiB,YAAYC,QAAQ,QAAQ,GAAG,CAAA;OAAG,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAE3DtC,kEAAU,EAAA,IAAAgC,WAAA;AAAA,YAAEZ,QAAQgB;OAAK,CAAA;qDACzBtC,kEAAU;KAACwB,MAAI;KAAAU,UAAS;KAAmD,CAAA;IAAA;;EAAA,CAAA,mDAE7EvC,2CAAmB;EAAA,UAAA;EAElB8C,OAAK;EACLjB,MAAI;EACJkB,YAAY,CAAC;GAAElB,MAAM;GAAQmB,MAA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ACXI,QAAQvC,QAAQwC;EACjB,EAAE;AAEH,QAAA,kDAEKhE,kHACKsD,MAAI;EAAA,IACR3B,OAAI;AAAA,UAAE4B,SAASG;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCN,UAAO;AAAA,4BAAOA,WAAW,EAAE,EAAE,GAC1BI,kBAAkBE,QAAQ,4DAAoBlC,QAAQE,KAAK,IAC7D,CAAC;;EAAA,IACF2B,iBAAc;AAAA,4BAAOA,kBAAkB,EAAE,EAAE;IACzCa,KAAK,CAAC,OAAO,OAAO;IACpBC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO;KAAC;KAAW;KAAW;KAAW;IAC1C,CAAC;;EAAA,IAAAhC,WAAA;AAAA,UAAA;qDACDjB,0EAAyB,EAAUK,SAAO,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAG1ClB,gFAA2B,EAAUkB,SAAO,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAG5CW,2BAAyB,EAAUX,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,mDAE5C9B,qBAAG;EAAA,IAAC2E,OAAI;AAAA,UAAEC,OAAOC,OAAO/C,QAAQY,SAAS;;EAAAA,WACvCoC,2DACE7E,sBAAI;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,4DAAGxB,cAAY,EAAC3B,SAASgD,OAAK,CAAA;;GAAA,IAAApC,WAAA;AAAA,4DACrCf,8DAAmB,EAACG,SAASgD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -1,24 +1,26 @@
1
- import * as _alloy_js_core13 from "@alloy-js/core";
2
- import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
1
+ import { Children } from "@alloy-js/core";
3
2
  import { CommandTree } from "@shell-shock/core/types/command";
3
+ import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
4
4
 
5
5
  //#region src/components/command-entry.d.ts
6
6
  declare function CommandInvocation(props: {
7
7
  command: CommandTree;
8
- }): _alloy_js_core13.Children;
8
+ }): Children;
9
+ interface CommandHandlerDeclarationProps {
10
+ command: CommandTree;
11
+ children?: Children;
12
+ }
9
13
  /**
10
14
  * A component that generates the `handler` function declaration for a command.
11
15
  */
12
- declare function CommandHandlerDeclaration(props: {
13
- command: CommandTree;
14
- }): _alloy_js_core13.Children;
16
+ declare function CommandHandlerDeclaration(props: CommandHandlerDeclarationProps): Children;
15
17
  interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
18
  command: CommandTree;
17
19
  }
18
20
  /**
19
21
  * The command entry point for the Shell Shock project.
20
22
  */
21
- declare function CommandEntry(props: CommandEntryProps): _alloy_js_core13.Children;
23
+ declare function CommandEntry(props: CommandEntryProps): Children;
22
24
  //#endregion
23
- export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
25
+ export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation };
24
26
  //# sourceMappingURL=command-entry.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAwDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AAyBA;AAgEA;AACE,iBAjEc,yBAAA,CAiEd,KAAA,EAAA;EAGS,OAAA,EApEiD,WAoEjD;CAJgC,CAAA,EAhE4B,gBAAA,CAAE,QAgE9B;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.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AAmBC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EA6DC,QAAA,CAAA,EAnEJ,QAmEI;;;;;AAUD,iBAvEA,yBAAA,CAuEqC,KAAA,EAtE5C,8BAsE4C,CAAA,EAtEd,QAsEc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
@@ -1,24 +1,26 @@
1
- import * as _alloy_js_core12 from "@alloy-js/core";
1
+ import { Children } 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_core12.Children;
8
+ }): Children;
9
+ interface CommandHandlerDeclarationProps {
10
+ command: CommandTree;
11
+ children?: Children;
12
+ }
9
13
  /**
10
14
  * A component that generates the `handler` function declaration for a command.
11
15
  */
12
- declare function CommandHandlerDeclaration(props: {
13
- command: CommandTree;
14
- }): _alloy_js_core12.Children;
16
+ declare function CommandHandlerDeclaration(props: CommandHandlerDeclarationProps): Children;
15
17
  interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
18
  command: CommandTree;
17
19
  }
18
20
  /**
19
21
  * The command entry point for the Shell Shock project.
20
22
  */
21
- declare function CommandEntry(props: CommandEntryProps): _alloy_js_core12.Children;
23
+ declare function CommandEntry(props: CommandEntryProps): Children;
22
24
  //#endregion
23
- export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
25
+ export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation };
24
26
  //# 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":";;;;;iBAwDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AAyBA;AAgEA;AACE,iBAjEc,yBAAA,CAiEd,KAAA,EAAA;EAGS,OAAA,EApEiD,WAoEjD;CAJgC,CAAA,EAhE4B,gBAAA,CAAE,QAgE9B;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;AAApD,CAAA,CAAA,EAAiE,QAAjD;AAmBC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EA6DC,QAAA,CAAA,EAnEJ,QAmEI;;;;;AAUD,iBAvEA,yBAAA,CAuEqC,KAAA,EAtE5C,8BAsE4C,CAAA,EAtEd,QAsEc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
@@ -1,16 +1,17 @@
1
- import { Help } from "./help.mjs";
1
+ import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
+ import { CommandHelp } from "./help.mjs";
2
3
  import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
3
4
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
5
  import { For, Show, code, computed } from "@alloy-js/core";
5
6
  import { ElseClause, FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
6
7
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
- import { getAppBin, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption } from "@shell-shock/core/plugin-utils/context-helpers";
8
+ import { getAppBin, getDynamicPathSegmentName, isDynamicPathSegment } from "@shell-shock/core/plugin-utils/context-helpers";
8
9
  import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
9
10
  import { TSDoc, TSDocParam, TSDocRemarks, TSDocTitle } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
11
  import { replaceExtension } from "@stryke/path/replace";
11
12
  import { pascalCase } from "@stryke/string-format/pascal-case";
12
13
  import defu from "defu";
13
- import { OptionsInterfaceDeclaration, OptionsParserLogic, PositionalOptionsParserLogic } from "@shell-shock/core/components/options-parser-logic";
14
+ import { DynamicPathSegmentsParserLogic, OptionsInterfaceDeclaration, OptionsParserLogic } from "@shell-shock/core/components/options-parser-logic";
14
15
  import { findFilePath, relativePath } from "@stryke/path/find";
15
16
  import { joinPaths } from "@stryke/path/join";
16
17
  import { camelCase } from "@stryke/string-format/camel-case";
@@ -19,17 +20,17 @@ import { constantCase } from "@stryke/string-format/constant-case";
19
20
  //#region src/components/command-entry.tsx
20
21
  function CommandInvocation(props) {
21
22
  const { command } = props;
22
- return [memo(() => code`return Promise.resolve(handle${pascalCase(command.name)}(options${command.path.segments.filter((segment) => isPositionalCommandOption(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => isPositionalCommandOption(segment)).map((segment) => camelCase(getPositionalCommandOptionName(segment))).join(", ")}` : ""}));`), createIntrinsic("hbr", {})];
23
+ return [memo(() => code`return Promise.resolve(handle${pascalCase(command.name)}(options${command.path.segments.filter((segment) => isDynamicPathSegment(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => isDynamicPathSegment(segment)).map((segment) => camelCase(getDynamicPathSegmentName(segment))).join(", ")}` : ""}));`), createIntrinsic("hbr", {})];
23
24
  }
24
25
  /**
25
26
  * A component that generates the `handler` function declaration for a command.
26
27
  */
27
28
  function CommandHandlerDeclaration(props) {
28
- const { command } = props;
29
+ const { command, children } = props;
29
30
  const context = usePowerlines();
30
31
  return [createComponent(TSDoc, {
31
32
  get heading() {
32
- return `The ${command.title} (${getAppBin(context)} ${command.path.segments.map((segment) => isPositionalCommandOption(segment) ? `[${constantCase(getPositionalCommandOptionName(segment))}]` : segment).join(" ")}) command.`;
33
+ return `The ${command.title} (${getAppBin(context)} ${command.path.segments.map((segment) => isDynamicPathSegment(segment) ? `[${constantCase(getDynamicPathSegmentName(segment))}]` : segment).join(" ")}) command.`;
33
34
  },
34
35
  get children() {
35
36
  return [
@@ -57,7 +58,7 @@ function CommandHandlerDeclaration(props) {
57
58
  }],
58
59
  get children() {
59
60
  return [
60
- createComponent(PositionalOptionsParserLogic, {
61
+ createComponent(DynamicPathSegmentsParserLogic, {
61
62
  get path() {
62
63
  return command.path;
63
64
  },
@@ -78,19 +79,17 @@ function CommandHandlerDeclaration(props) {
78
79
  }),
79
80
  createIntrinsic("hbr", {}),
80
81
  createIntrinsic("hbr", {}),
82
+ code`writeLine("");
83
+ banner();`,
84
+ createIntrinsic("hbr", {}),
85
+ createIntrinsic("hbr", {}),
86
+ children,
87
+ createIntrinsic("hbr", {}),
88
+ createIntrinsic("hbr", {}),
81
89
  createComponent(IfStatement, {
82
90
  condition: code`options.help`,
83
91
  get children() {
84
- return [
85
- memo(() => code`
86
- writeLine("");
87
- writeLine(colors.text.heading.primary("${getAppTitle(context)} - ${command.title}"));
88
- writeLine("");
89
- writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
90
- writeLine("");`),
91
- createIntrinsic("hbr", {}),
92
- createComponent(Help, { command })
93
- ];
92
+ return createComponent(CommandHelp, { command });
94
93
  }
95
94
  }),
96
95
  createComponent(ElseClause, { get children() {
@@ -106,7 +105,7 @@ function CommandHandlerDeclaration(props) {
106
105
  function CommandEntry(props) {
107
106
  const { command, imports, builtinImports, ...rest } = props;
108
107
  const context = usePowerlines();
109
- const filePath = computed(() => joinPaths(command.path.segments.filter((segment) => !isPositionalCommandOption(segment)).join("/"), "index.ts"));
108
+ const filePath = computed(() => joinPaths(command.path.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
110
109
  const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
111
110
  const typeDefinition = computed(() => ({
112
111
  ...command.entry,
@@ -134,11 +133,18 @@ function CommandEntry(props) {
134
133
  "writeLine",
135
134
  "splitText"
136
135
  ],
137
- utils: ["getArgs", "isMinimal"]
136
+ utils: [
137
+ "getArgs",
138
+ "hasFlag",
139
+ "isMinimal"
140
+ ]
138
141
  });
139
142
  },
140
143
  get children() {
141
144
  return [
145
+ createComponent(BannerFunctionDeclaration, { command }),
146
+ createIntrinsic("hbr", {}),
147
+ createIntrinsic("hbr", {}),
142
148
  createComponent(OptionsInterfaceDeclaration, { command }),
143
149
  createIntrinsic("hbr", {}),
144
150
  createIntrinsic("hbr", {}),
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","OptionsInterfaceDeclaration","OptionsParserLogic","PositionalOptionsParserLogic","getAppBin","getAppTitle","getPositionalCommandOptionName","isPositionalCommandOption","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","Help","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","context","_$createComponent","heading","title","children","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n PositionalOptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getAppTitle,\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { 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 { Help } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).length > 0\n ? `, ${command.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .map(segment =>\n camelCase(getPositionalCommandOptionName(segment))\n )\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) 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 <PositionalOptionsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\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 /\\.+$/,\n \"\"\n )}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"isMinimal\"]\n })}>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,CAAAE,WAEKjC,IAAI,gCAAgC0B,WAAWM,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,YAC3BnB,0BAA0BmB,QAC5B,CAAC,CAACC,SAAS,IACP,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,YAAWnB,0BAA0BmB,QAAQ,CAAC,CACrDE,KAAIF,YACHd,UAAUN,+BAA+BoB,QAAQ,CACnD,CAAC,CACAG,KAAK,KAAK,KACb,GAAE,KACH,EAAAC,gBAAA,OAAA,EAAA,CAAA,CAAA;;;;;AASX,SAAgBC,0BAA0BZ,OAAiC;CACzE,MAAM,EAA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AQE,KAAK,IAC7D,CAAC;;EAAA,IACF2B,iBAAc;AAAA,UAAElC,KAAKkC,kBAAkB,EAAE,EAAE;IACzCa,KAAK,CAAC,OAAO,OAAO;IACpBC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO,CAAC,WAAW,YAAW;IAC/B,CAAC;;EAAA,IAAA5B,WAAA;AAAA,UAAA;IAAAH,gBACDhC,6BAA2B,EAAUmB,SAAO,CAAA;IAAAU,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAG,gBAG5CF,2BAAyB,EAAUX,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAa,gBAE5C3C,KAAG;EAAA,IAAC2E,OAAI;AAAA,UAAEC,OAAOC,OAAO/C,QAAQgB,SAAS;;EAAAA,WACvCgC,UAAKnC,gBACH1C,MAAI;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,WAAAtC,gBAAGc,cAAY,EAAC3B,SAASgD,OAAK,CAAA;;GAAA,IAAAhC,WAAA;AAAA,WAAAH,gBACrChB,qBAAmB,EAACG,SAASgD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","DynamicPathSegmentsParserLogic","OptionsInterfaceDeclaration","OptionsParserLogic","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandHelp","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","children","context","_$createComponent","heading","title","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n DynamicPathSegmentsParserLogic,\n OptionsInterfaceDeclaration,\n OptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { 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 { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandHelp } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment => isDynamicPathSegment(segment))\n .length > 0\n ? `, ${command.path.segments\n .filter(segment => isDynamicPathSegment(segment))\n .map(segment => camelCase(getDynamicPathSegmentName(segment)))\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) 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 <DynamicPathSegmentsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n <CommandHelp command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,CAAAE,WAEKjC,IAAI,gCAAg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