@shell-shock/core 0.17.8 → 0.17.10

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 (141) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/api.cjs +148 -1
  3. package/dist/api.d.cts +6 -6
  4. package/dist/api.d.cts.map +1 -1
  5. package/dist/api.d.mts +6 -6
  6. package/dist/api.d.mts.map +1 -1
  7. package/dist/api.mjs +145 -1
  8. package/dist/api.mjs.map +1 -1
  9. package/dist/components/command-validation-logic.cjs +292 -1
  10. package/dist/components/command-validation-logic.mjs +289 -1
  11. package/dist/components/command-validation-logic.mjs.map +1 -1
  12. package/dist/components/docs.cjs +265 -1
  13. package/dist/components/docs.mjs +256 -1
  14. package/dist/components/docs.mjs.map +1 -1
  15. package/dist/components/exec-builtin.cjs +429 -13
  16. package/dist/components/exec-builtin.mjs +425 -13
  17. package/dist/components/exec-builtin.mjs.map +1 -1
  18. package/dist/components/helpers.cjs +120 -1
  19. package/dist/components/helpers.mjs +112 -1
  20. package/dist/components/helpers.mjs.map +1 -1
  21. package/dist/components/index.cjs +58 -1
  22. package/dist/components/index.mjs +10 -1
  23. package/dist/components/options-parser-logic.cjs +960 -5
  24. package/dist/components/options-parser-logic.d.cts +1 -1
  25. package/dist/components/options-parser-logic.mjs +945 -5
  26. package/dist/components/options-parser-logic.mjs.map +1 -1
  27. package/dist/components/state-builtin.cjs +629 -8
  28. package/dist/components/state-builtin.mjs +622 -8
  29. package/dist/components/state-builtin.mjs.map +1 -1
  30. package/dist/components/usage.cjs +117 -1
  31. package/dist/components/usage.mjs +114 -1
  32. package/dist/components/usage.mjs.map +1 -1
  33. package/dist/components/utils-builtin.cjs +838 -33
  34. package/dist/components/utils-builtin.mjs +828 -33
  35. package/dist/components/utils-builtin.mjs.map +1 -1
  36. package/dist/config.cjs +31 -1
  37. package/dist/config.mjs +29 -1
  38. package/dist/config.mjs.map +1 -1
  39. package/dist/contexts/command.cjs +26 -1
  40. package/dist/contexts/command.mjs +23 -1
  41. package/dist/contexts/command.mjs.map +1 -1
  42. package/dist/contexts/index.cjs +9 -1
  43. package/dist/contexts/index.mjs +4 -1
  44. package/dist/contexts/options.cjs +63 -1
  45. package/dist/contexts/options.mjs +58 -1
  46. package/dist/contexts/options.mjs.map +1 -1
  47. package/dist/helpers/automd.cjs +71 -1
  48. package/dist/helpers/automd.mjs +70 -1
  49. package/dist/helpers/automd.mjs.map +1 -1
  50. package/dist/helpers/docs-helpers.cjs +23 -1
  51. package/dist/helpers/docs-helpers.mjs +22 -1
  52. package/dist/helpers/docs-helpers.mjs.map +1 -1
  53. package/dist/helpers/paths.cjs +137 -1
  54. package/dist/helpers/paths.mjs +133 -1
  55. package/dist/helpers/paths.mjs.map +1 -1
  56. package/dist/helpers/persistence.cjs +115 -1
  57. package/dist/helpers/persistence.mjs +112 -1
  58. package/dist/helpers/persistence.mjs.map +1 -1
  59. package/dist/helpers/update-package-json.cjs +65 -1
  60. package/dist/helpers/update-package-json.mjs +63 -1
  61. package/dist/helpers/update-package-json.mjs.map +1 -1
  62. package/dist/helpers/utilities.cjs +95 -1
  63. package/dist/helpers/utilities.mjs +93 -1
  64. package/dist/helpers/utilities.mjs.map +1 -1
  65. package/dist/helpers/validations.cjs +71 -1
  66. package/dist/helpers/validations.mjs +71 -1
  67. package/dist/helpers/validations.mjs.map +1 -1
  68. package/dist/index.cjs +53 -1
  69. package/dist/index.d.cts +3 -3
  70. package/dist/index.d.mts +3 -3
  71. package/dist/index.mjs +7 -1
  72. package/dist/plugin-utils/compute-bin.cjs +50 -1
  73. package/dist/plugin-utils/compute-bin.mjs +49 -1
  74. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  75. package/dist/plugin-utils/context-helpers.cjs +231 -1
  76. package/dist/plugin-utils/context-helpers.mjs +221 -1
  77. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  78. package/dist/plugin-utils/deepkit.cjs +71 -1
  79. package/dist/plugin-utils/deepkit.mjs +69 -1
  80. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  81. package/dist/plugin-utils/description-helpers.cjs +111 -2
  82. package/dist/plugin-utils/description-helpers.mjs +107 -2
  83. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  84. package/dist/plugin-utils/get-command-tree.cjs +117 -1
  85. package/dist/plugin-utils/get-command-tree.mjs +114 -1
  86. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  87. package/dist/plugin-utils/index.cjs +39 -1
  88. package/dist/plugin-utils/index.mjs +10 -1
  89. package/dist/plugin-utils/reflect.cjs +52 -1
  90. package/dist/plugin-utils/reflect.mjs +52 -1
  91. package/dist/plugin-utils/reflect.mjs.map +1 -1
  92. package/dist/plugin-utils/traverse-command-tree.cjs +64 -1
  93. package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
  94. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  95. package/dist/plugin-utils/type-checks.cjs +93 -1
  96. package/dist/plugin-utils/type-checks.mjs +88 -1
  97. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  98. package/dist/plugin.cjs +471 -4
  99. package/dist/plugin.d.cts.map +1 -1
  100. package/dist/plugin.d.mts.map +1 -1
  101. package/dist/plugin.mjs +465 -4
  102. package/dist/plugin.mjs.map +1 -1
  103. package/dist/resolver/deepkit.cjs +135 -1
  104. package/dist/resolver/deepkit.mjs +134 -1
  105. package/dist/resolver/deepkit.mjs.map +1 -1
  106. package/dist/resolver/helpers.cjs +173 -1
  107. package/dist/resolver/helpers.mjs +168 -1
  108. package/dist/resolver/helpers.mjs.map +1 -1
  109. package/dist/resolver/module.cjs +145 -1
  110. package/dist/resolver/module.mjs +144 -1
  111. package/dist/resolver/module.mjs.map +1 -1
  112. package/dist/resolver/resolve.cjs +222 -1
  113. package/dist/resolver/resolve.mjs +221 -1
  114. package/dist/resolver/resolve.mjs.map +1 -1
  115. package/dist/types/command.cjs +441 -1
  116. package/dist/types/command.d.cts +1 -1
  117. package/dist/types/command.d.mts +2 -2
  118. package/dist/types/command.mjs +405 -1
  119. package/dist/types/command.mjs.map +1 -1
  120. package/dist/types/config.cjs +134 -1
  121. package/dist/types/config.d.cts +10 -8
  122. package/dist/types/config.d.cts.map +1 -1
  123. package/dist/types/config.d.mts +10 -8
  124. package/dist/types/config.d.mts.map +1 -1
  125. package/dist/types/config.mjs +127 -1
  126. package/dist/types/config.mjs.map +1 -1
  127. package/dist/types/context.cjs +37 -1
  128. package/dist/types/context.mjs +34 -1
  129. package/dist/types/context.mjs.map +1 -1
  130. package/dist/types/env.cjs +52 -1
  131. package/dist/types/env.d.cts +1 -1
  132. package/dist/types/env.d.mts +1 -1
  133. package/dist/types/env.mjs +50 -1
  134. package/dist/types/env.mjs.map +1 -1
  135. package/dist/types/index.cjs +50 -1
  136. package/dist/types/index.d.cts +2 -2
  137. package/dist/types/index.d.mts +2 -2
  138. package/dist/types/index.mjs +6 -1
  139. package/dist/types/options.cjs +12 -1
  140. package/dist/types/options.mjs +10 -1
  141. package/package.json +22 -21
@@ -1 +1 @@
1
- {"version":3,"file":"command-validation-logic.mjs","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { list } from \"@stryke/string-format/list\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface CommandValidationLogicProps {\n command: CommandTree;\n}\n\n/**\n * A component that generates command validation logic for required options and arguments.\n */\nexport function CommandValidationLogic(props: CommandValidationLogicProps) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration name=\"failures\" type=\"string[]\" initializer={code`[];`} />\n <hbr />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n {code`failures.push(\"Missing required \\\\\"${option.name}\\\\\" option\");`}\n </IfStatement>\n <Show when={option.variadic}>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <Show\n when={option.variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n option.name\n }\\\\\" option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </IfStatement>\n </Show>\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n <Show\n when={!option.variadic}\n fallback={\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n }>\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`![${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`![${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show when={argument.variadic}>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === CommandParameterKinds.number}>\n <Show\n when={(argument as NumberCommandParameter).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n </>\n );\n}\n"],"mappings":"ifAEE,GAAG,OAAS,IA0Bd,MAAE,EAAW,CAAA,cAAA,UAAA,8BAAA,aAAA,eAMb,GAAO,CACL,WACF,cAEE,KAAA,WACE,KAAC,WACH,YAAA,CAAA,MACF,CAAA,CAAM,EAAU,MAAA,EAAA,CAAA,CAAA,EAA8B,EAAA,CAC5C,IAAM,MAAE,sCAGN,eAAC,GACD,IAAG,UAAA,CACD,OAAM,EAAA,GAAA,CAAA,EAAA,EAAA,CACL,IAAI,MAAM,CACR,MAAQ,CAAC,EAAC,UAEX,IAAI,UAAW,CACb,MAAK,CAAA,EAAA,EAAA,CACH,IAAI,WAAW,CACb,MAAI,EAAO,WAAK,EAAY,KAAA,SAAA,IAAA,CAAA,KAAA,EAAA,KAAA,IAAA,IAAA,EAAA,EAAA,KAAA,MAE9B,IAAI,UAAU,CACZ,MAAK,EAAA,sCAAA,EAAA,KAAA,gBAER,CAAC,CAAE,EAAa,EAAA,CACf,IAAG,MAAK,CACN,OAAG,EAAA,UAEL,IAAI,UAAW,CACb,OAAO,EAAe,EAAO,CAC3B,IAAI,WAAQ,CACV,MAAE,EAAS,UAAK,EAAA,KAAA,SAAA,IAAA,CAAA,KAAA,EAAA,KAAA,IAAA,IAAA,EAAA,EAAA,KAAA,GAAA,gBAElB,IAAI,UAAO,CACT,MAAK,EAAM,6DAAU,EAAA,KAAA,sBAExB,CAAC,EAEL,CAAC,CAAC,EAEN,CAAC,CAAE,EAAkB,EAAC,CACrB,IAAI,MAAI,CACN,OAAO,EAAE,OAAA,EAAA,QAEX,IAAI,UAAU,CACZ,OAAO,EAAc,EAAO,CAC1B,IAAI,MAAO,CACT,OAAO,EAAI,UAEb,IAAI,UAAW,CACb,OAAO,EAA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AAI,IAAG,EAAA,EAAA,KAAA,IAEhB,IAAI,UAAQ,CACV,MAAO,EAAI,sCAAa,EAAA,KAAA,6BAE3B,CAAC,CAAE,EAAkB,EAAE,CACtB,IAAI,MAAO,CACT,OAAO,EAAG,UAEZ,IAAI,UAAQ,CACV,OAAO,EAAkB,EAAQ,CAC/B,IAAI,WAAY,CACd,MAAO,EAAC,GAAA,EAAA,EAAA,KAAA,CAAA,gBAEV,IAAI,UAAW,CACb,MAAO,EAAE,6DAAqC,EAAA,KAAA,mCAEjD,CAAC,EAEL,CAAC,CAAC,EAEN,CAAC,CAAE,EAAgB,EAAQ,CAC1B,IAAI,MAAO,CACT,OAAO,EAAS,OAAO,EAAc,QAEvC,IAAI,UAAW,CACb,OAAO,EAAgB,EAAA,CACrB,IAAI,MAAG,CACL,OAAK,EAAA,UAEP,IAAI,UAAM,CACR,OAAO,EAAC,EAAA,CACN,IAAI,WAAQ,CACV,MAAM,EAAA,GAAO,EAAS,EAAA,KAAA,CAAA,mBAAsB,EAAA,EAAA,KAAA,CAAA,IAE9C,IAAI,UAAQ,CACV,MAAI,EAAA,4DAAA,EAAA,KAAA,6BAEP,CAAC,EAEJ,IAAI,UAAW,CACb,OAAO,EAAG,EAAA,CACR,IAAI,WAAM,CACR,MAAI,EAAO,GAAA,EAAA,EAAA,KAAA,CAAA,sCAEb,IAAI,UAAE,CACJ,MAAM,EAAA,2DAAO,EAAA,KAAA,mCAEhB,CAAC,EAEL,CAAC,EAEL,CAAC,CAAC,CAAE,CAAC,WAAY,GAAI,UAAU,CAAA,EAEnC,CAAC,CAAC,CAEL,EAAsB,OAAA,KAAA,EAAA,QAAA,yBAAA,0FAAA,aAAA"}
1
+ {"version":3,"file":"command-validation-logic.mjs","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { list } from \"@stryke/string-format/list\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface CommandValidationLogicProps {\n command: CommandTree;\n}\n\n/**\n * A component that generates command validation logic for required options and arguments.\n */\nexport function CommandValidationLogic(props: CommandValidationLogicProps) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration name=\"failures\" type=\"string[]\" initializer={code`[];`} />\n <hbr />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n {code`failures.push(\"Missing required \\\\\"${option.name}\\\\\" option\");`}\n </IfStatement>\n <Show when={option.variadic}>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <Show\n when={option.variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n option.name\n }\\\\\" option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </IfStatement>\n </Show>\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n <Show\n when={!option.variadic}\n fallback={\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n }>\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`![${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`![${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show when={argument.variadic}>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === CommandParameterKinds.number}>\n <Show\n when={(argument as NumberCommandParameter).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAEE,IAAG,SAAS;;;AA0Bd,MAAE,iCAAW;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;CAMb,MAAO,EACL,YACF;;;GAEE,MAAA;GACE,MAAC;GACH,aAAA,IAAA;GACF,CAAA;EAAM,gBAAU,OAAA,EAAA,CAAA;EAAA,gBAA8B,KAAA;GAC5C,IAAM,OAAE;;;GAGN,gBAAC;GACD,IAAG,WAAA;AACD,WAAM,cAAA,WAAA;KAAA,gBAAA,MAAA;MACL,IAAI,OAAM;AACR,cAAQ,CAAC,OAAC;;MAEX,IAAI,WAAW;AACb,cAAK,CAAA,gBAAA,aAAA;QACH,IAAI,YAAW;AACb,gBAAI,IAAO,WAAK,OAAY,KAAA,SAAA,IAAA,GAAA,KAAA,OAAA,KAAA,MAAA,IAAA,UAAA,OAAA,KAAA;;QAE9B,IAAI,WAAU;AACZ,gBAAK,IAAA,sCAAA,OAAA,KAAA;;QAER,CAAC,EAAE,gBAAa,MAAA;QACf,IAAG,OAAK;AACN,gBAAG,OAAA;;QAEL,IAAI,WAAW;AACb,gBAAO,gB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AAA;;SAEP,CAAC;;OAEJ,IAAI,WAAW;AACb,eAAO,gBAAG,aAAA;SACR,IAAI,YAAM;AACR,iBAAI,IAAO,GAAA,UAAA,SAAA,KAAA,CAAA;;SAEb,IAAI,WAAE;AACJ,iBAAM,IAAA,2DAAO,SAAA,KAAA;;SAEhB,CAAC;;OAEL,CAAC;;KAEL,CAAC,CAAC,EAAE;KAAC;KAAY;KAAI;KAAU,CAAA;;GAEnC,CAAC;EAAC;;AAEL,uBAAsB,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1,265 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../contexts/command.cjs`),t=require(`../helpers/docs-helpers.cjs`),n=require(`../plugin-utils/context-helpers.cjs`),r=require(`../plugin-utils/reflect.cjs`),i=require(`./usage.cjs`);let a=require(`@alloy-js/core/jsx-runtime`),o=require(`defu`),s=require(`@alloy-js/core`),c=require(`@alloy-js/markdown`),l=require(`@powerlines/plugin-alloy/core/components/spacing`),u=require(`@powerlines/plugin-alloy/core/contexts/context`),d=require(`@powerlines/plugin-alloy/markdown/components/markdown-file`),f=require(`@powerlines/plugin-alloy/markdown/components/markdown-table`),p=require(`@stryke/path/join`);const m=[`T`,`Required`,`l+e#!e"!fRb!Pde"!gN##w"y`],h=[`T`,`Partial`,`l+e#!e"!fRb!Pde"!gN#"w"y`];function g(e,t){return e.__type=t,e}const _=[`CommandTree`,`command`,`The command to generate options documentation for.`,`CommandOptionsDocsProps`,`P"w!4"?#Mw$y`];function v(e){let{command:t}=e;return Object.keys(t.options).length===0?s.code`This command does not have any options.`:(0,a.createComponent)(f.MarkdownTable,{get data(){return r.sortOptions(Object.values(t.options)).map(g(e=>({name:e.name.trim(),description:e.description.trim(),defaultValue:e.default?String(e.default)?.includes(`"`)?e.default:`\`${Array.isArray(e.default)?e.default.join(`, `):e.default}\``:``,required:e.optional||e.default?``:`✔`}),[`option`,``,`P"2!"/"`]))}})}v.__type=[()=>_,`props`,`CommandOptionsDocs`,`Generates the options markdown documentation for a command.`,`Pn!2""/#?$`];const y=[`npm`,`yarn`,`pnpm`,`bun`,`packageManager`,`npm`,`The package manager to generate the usage example for.`,`CommandTree`,`command`,`The command to generate the usage example for.`,`CommandDocsUsageExampleProps`,`PP.!.".#.$J4%8>&?'"w(4)?*Mw+y`];function b(e){let{packageManager:t=`npm`,command:r}=e,o=(u.usePowerlines.Ω=[[`Context`,`"w!`]],(0,u.usePowerlines)());return[(0,a.createIntrinsic)(`hbr`,{}),s.code`\`\`\`bash `,(0,a.createIntrinsic)(`hbr`,{}),(0,a.createComponent)(i.Usage,{command:r,get bin(){return n.getAppBin(o)},packageManager:t}),(0,a.createIntrinsic)(`hbr`,{}),s.code`\`\`\``,(0,a.createIntrinsic)(`hbr`,{})]}b.__type=[()=>y,`props`,`CommandDocsUsageExample`,`Generates the markdown documentation for a command.`,`Pn!2""/#?$`];const x=[`levelOffset`,0,`The heading level offset to apply to the generated documentation.`,`CommandTree`,`command`,`The command to generate options documentation for.`,()=>m,()=>y,`packageManager`,`usageExamples`,'`["npm"]`',`Optional usage examples to include in the documentation.`,`CommandDocsProps`,`P'4!8>"?#"w$4%?&n(o'".)fF4*8>+?,Mw-y`];function S(e){let{levelOffset:t=0,command:n,usageExamples:r}=e;return[(0,a.createComponent)(c.Heading,{level:1+t,get children(){return n.title}}),(0,a.createComponent)(l.Spacing,{}),(0,a.memo)(()=>s.code`${n.description}`),(0,a.createComponent)(l.Spacing,{}),(0,a.createComponent)(c.Heading,{level:2+t,children:`Usage`}),(0,a.createComponent)(l.Spacing,{}),(0,a.memo)(()=>s.code`The ${n.name} command can be executed using the following syntax: `),(0,a.createComponent)(l.Spacing,{}),(0,a.createComponent)(s.Show,{get when(){return r&&r.length>0},get fallback(){return(0,a.createComponent)(b,{packageManager:`npm`,command:n})},get children(){return(0,a.createComponent)(s.For,{each:r,hardline:!0,get children(){return g(e=>(0,a.createComponent)(b,{packageManager:e,command:n}),[`packageManager`,``,`P"2!"/"`])}})}}),(0,a.createComponent)(l.Spacing,{}),(0,a.createComponent)(c.Heading,{level:2+t,children:`Options`}),(0,a.createComponent)(l.Spacing,{}),(0,a.memo)(()=>s.code`The following options are available for the ${n.name} command:`),(0,a.createComponent)(l.Spacing,{}),(0,a.createComponent)(v,{command:n}),(0,a.createComponent)(l.Spacing,{})]}S.__type=[()=>x,`props`,`CommandDocs`,`Generates the markdown documentation for a command.`,`Pn!2""/#?$`];const C=[()=>h,`levelOffset`,0,`The heading level offset to apply to the generated documentation.`,`CommandTree`,`command`,`The command to generate documentation for.`,`CommandDocsFileProps`,`P!o!"'4"8>#?$"w%4&?'Mw(y`];function w(n){let{levelOffset:r=0,command:i,frontMatter:c,...l}=n,f=(u.usePowerlines.Ω=[[`Context`,`"w!`]],(0,u.usePowerlines)()),m=(0,s.memo)(()=>[`npm`,`yarn`,`pnpm`,`bun`]);return(0,a.createComponent)(e.CommandContext.Provider,{value:i,get children(){return(0,a.createComponent)(d.MarkdownFile,(0,a.mergeProps)({get path(){return(0,p.joinPaths)(t.getDocsOutputPath(f),`${i.path}.md`)}},l,{get frontMatter(){return(0,o.defu)(c??{},{id:i.id,name:i.name,path:i.path,reference:i.reference,isVirtual:i.isVirtual,title:i.title,description:i.description,tags:i.tags})},get children(){return(0,a.createComponent)(S,{levelOffset:r,command:i,get usageExamples(){return m()}})}}))}})}w.__type=[()=>C,`props`,`CommandDocsFile`,`Generates the markdown documentation file for a command.`,`Pn!2""/#?$`],exports.CommandDocs=S,exports.CommandDocsFile=w,exports.CommandDocsUsageExample=b,exports.CommandOptionsDocs=v,exports.__ΩCommandDocsFileProps=C,exports.__ΩCommandDocsProps=x,exports.__ΩCommandDocsUsageExampleProps=y,exports.__ΩCommandOptionsDocsProps=_;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_contexts_command = require('../contexts/command.cjs');
4
+ const require_docs_helpers = require('../helpers/docs-helpers.cjs');
5
+ const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
6
+ const require_reflect = require('../plugin-utils/reflect.cjs');
7
+ const require_components_usage = require('./usage.cjs');
8
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
9
+ let defu = require("defu");
10
+ let _alloy_js_core = require("@alloy-js/core");
11
+ let _alloy_js_markdown = require("@alloy-js/markdown");
12
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
13
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
14
+ let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
15
+ let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
16
+ let _stryke_path_join = require("@stryke/path/join");
17
+
18
+ //#region src/components/docs.tsx
19
+ const __ΩRequired = [
20
+ "T",
21
+ "Required",
22
+ "l+e#!e\"!fRb!Pde\"!gN##w\"y"
23
+ ];
24
+ const __ΩPartial = [
25
+ "T",
26
+ "Partial",
27
+ "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
28
+ ];
29
+ function __assignType(fn, args) {
30
+ fn.__type = args;
31
+ return fn;
32
+ }
33
+ const __ΩCommandOptionsDocsProps = [
34
+ "CommandTree",
35
+ "command",
36
+ "The command to generate options documentation for.",
37
+ "CommandOptionsDocsProps",
38
+ "P\"w!4\"?#Mw$y"
39
+ ];
40
+ /**
41
+ * Generates the options markdown documentation for a command.
42
+ */
43
+ function CommandOptionsDocs(props) {
44
+ const { command } = props;
45
+ if (Object.keys(command.options).length === 0) return _alloy_js_core.code`This command does not have any options.`;
46
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
47
+ return require_reflect.sortOptions(Object.values(command.options)).map(__assignType((option) => {
48
+ return {
49
+ name: option.name.trim(),
50
+ description: option.description.trim(),
51
+ defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
52
+ required: option.optional || option.default ? "" : "✔"
53
+ };
54
+ }, [
55
+ "option",
56
+ "",
57
+ "P\"2!\"/\""
58
+ ]));
59
+ } });
60
+ }
61
+ CommandOptionsDocs.__type = [
62
+ () => __ΩCommandOptionsDocsProps,
63
+ "props",
64
+ "CommandOptionsDocs",
65
+ "Generates the options markdown documentation for a command.",
66
+ "Pn!2\"\"/#?$"
67
+ ];
68
+ const __ΩCommandDocsUsageExampleProps = [
69
+ "npm",
70
+ "yarn",
71
+ "pnpm",
72
+ "bun",
73
+ "packageManager",
74
+ "npm",
75
+ "The package manager to generate the usage example for.",
76
+ "CommandTree",
77
+ "command",
78
+ "The command to generate the usage example for.",
79
+ "CommandDocsUsageExampleProps",
80
+ "PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
81
+ ];
82
+ /**
83
+ * Generates the markdown documentation for a command.
84
+ */
85
+ function CommandDocsUsageExample(props) {
86
+ const { packageManager = "npm", command } = props;
87
+ const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
88
+ return [
89
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
90
+ _alloy_js_core.code`\`\`\`bash `,
91
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
92
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_usage.Usage, {
93
+ command,
94
+ get bin() {
95
+ return require_context_helpers.getAppBin(context);
96
+ },
97
+ packageManager
98
+ }),
99
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
100
+ _alloy_js_core.code`\`\`\``,
101
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
102
+ ];
103
+ }
104
+ CommandDocsUsageExample.__type = [
105
+ () => __ΩCommandDocsUsageExampleProps,
106
+ "props",
107
+ "CommandDocsUsageExample",
108
+ "Generates the markdown documentation for a command.",
109
+ "Pn!2\"\"/#?$"
110
+ ];
111
+ const __ΩCommandDocsProps = [
112
+ "levelOffset",
113
+ 0,
114
+ "The heading level offset to apply to the generated documentation.",
115
+ "CommandTree",
116
+ "command",
117
+ "The command to generate options documentation for.",
118
+ () => __ΩRequired,
119
+ () => __ΩCommandDocsUsageExampleProps,
120
+ "packageManager",
121
+ "usageExamples",
122
+ "`[\"npm\"]`",
123
+ "Optional usage examples to include in the documentation.",
124
+ "CommandDocsProps",
125
+ "P'4!8>\"?#\"w$4%?&n(o'\".)fF4*8>+?,Mw-y"
126
+ ];
127
+ /**
128
+ * Generates the markdown documentation for a command.
129
+ */
130
+ function CommandDocs(props) {
131
+ const { levelOffset = 0, command, usageExamples } = props;
132
+ return [
133
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
134
+ level: 1 + levelOffset,
135
+ get children() {
136
+ return command.title;
137
+ }
138
+ }),
139
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
140
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`${command.description}`),
141
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
142
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
143
+ level: 2 + levelOffset,
144
+ children: "Usage"
145
+ }),
146
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
147
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The ${command.name} command can be executed using the following syntax: `),
148
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
149
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
150
+ get when() {
151
+ return usageExamples && usageExamples.length > 0;
152
+ },
153
+ get fallback() {
154
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocsUsageExample, {
155
+ packageManager: "npm",
156
+ command
157
+ });
158
+ },
159
+ get children() {
160
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
161
+ each: usageExamples,
162
+ hardline: true,
163
+ get children() {
164
+ return __assignType((packageManager) => (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocsUsageExample, {
165
+ packageManager,
166
+ command
167
+ }), [
168
+ "packageManager",
169
+ "",
170
+ "P\"2!\"/\""
171
+ ]);
172
+ }
173
+ });
174
+ }
175
+ }),
176
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
177
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
178
+ level: 2 + levelOffset,
179
+ children: "Options"
180
+ }),
181
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
182
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The following options are available for the ${command.name} command:`),
183
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
184
+ (0, _alloy_js_core_jsx_runtime.createComponent)(CommandOptionsDocs, { command }),
185
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
186
+ ];
187
+ }
188
+ CommandDocs.__type = [
189
+ () => __ΩCommandDocsProps,
190
+ "props",
191
+ "CommandDocs",
192
+ "Generates the markdown documentation for a command.",
193
+ "Pn!2\"\"/#?$"
194
+ ];
195
+ const __ΩCommandDocsFileProps = [
196
+ () => __ΩPartial,
197
+ "levelOffset",
198
+ 0,
199
+ "The heading level offset to apply to the generated documentation.",
200
+ "CommandTree",
201
+ "command",
202
+ "The command to generate documentation for.",
203
+ "CommandDocsFileProps",
204
+ "P!o!\"'4\"8>#?$\"w%4&?'Mw(y"
205
+ ];
206
+ /**
207
+ * Generates the markdown documentation file for a command.
208
+ */
209
+ function CommandDocsFile(props) {
210
+ const { levelOffset = 0, command, frontMatter, ...rest } = props;
211
+ const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
212
+ const usageExamples = (0, _alloy_js_core.memo)(() => [
213
+ "npm",
214
+ "yarn",
215
+ "pnpm",
216
+ "bun"
217
+ ]);
218
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_contexts_command.CommandContext.Provider, {
219
+ value: command,
220
+ get children() {
221
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_file.MarkdownFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
222
+ return (0, _stryke_path_join.joinPaths)(require_docs_helpers.getDocsOutputPath(context), `${command.path}.md`);
223
+ } }, rest, {
224
+ get frontMatter() {
225
+ return (0, defu.defu)(frontMatter ?? {}, {
226
+ id: command.id,
227
+ name: command.name,
228
+ path: command.path,
229
+ reference: command.reference,
230
+ isVirtual: command.isVirtual,
231
+ title: command.title,
232
+ description: command.description,
233
+ tags: command.tags
234
+ });
235
+ },
236
+ get children() {
237
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocs, {
238
+ levelOffset,
239
+ command,
240
+ get usageExamples() {
241
+ return usageExamples();
242
+ }
243
+ });
244
+ }
245
+ }));
246
+ }
247
+ });
248
+ }
249
+ CommandDocsFile.__type = [
250
+ () => __ΩCommandDocsFileProps,
251
+ "props",
252
+ "CommandDocsFile",
253
+ "Generates the markdown documentation file for a command.",
254
+ "Pn!2\"\"/#?$"
255
+ ];
256
+
257
+ //#endregion
258
+ exports.CommandDocs = CommandDocs;
259
+ exports.CommandDocsFile = CommandDocsFile;
260
+ exports.CommandDocsUsageExample = CommandDocsUsageExample;
261
+ exports.CommandOptionsDocs = CommandOptionsDocs;
262
+ exports.__ΩCommandDocsFileProps = __ΩCommandDocsFileProps;
263
+ exports.__ΩCommandDocsProps = __ΩCommandDocsProps;
264
+ exports.__ΩCommandDocsUsageExampleProps = __ΩCommandDocsUsageExampleProps;
265
+ exports.__ΩCommandOptionsDocsProps = __ΩCommandOptionsDocsProps;
@@ -1,2 +1,257 @@
1
- import{CommandContext as e}from"../contexts/command.mjs";import{getDocsOutputPath as t}from"../helpers/docs-helpers.mjs";import{getAppBin as n}from"../plugin-utils/context-helpers.mjs";import{sortOptions as r}from"../plugin-utils/reflect.mjs";import{Usage as i}from"./usage.mjs";import{createComponent as a,createIntrinsic as o,memo as s,mergeProps as c}from"@alloy-js/core/jsx-runtime";import{defu as l}from"defu";import{For as u,Show as d,code as f,memo as p}from"@alloy-js/core";import{Heading as m}from"@alloy-js/markdown";import{Spacing as h}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as g}from"@powerlines/plugin-alloy/core/contexts/context";import{MarkdownFile as _}from"@powerlines/plugin-alloy/markdown/components/markdown-file";import{MarkdownTable as v}from"@powerlines/plugin-alloy/markdown/components/markdown-table";import{joinPaths as y}from"@stryke/path/join";const b=[`T`,`Required`,`l+e#!e"!fRb!Pde"!gN##w"y`],x=[`T`,`Partial`,`l+e#!e"!fRb!Pde"!gN#"w"y`];function S(e,t){return e.__type=t,e}const C=[`CommandTree`,`command`,`The command to generate options documentation for.`,`CommandOptionsDocsProps`,`P"w!4"?#Mw$y`];function w(e){let{command:t}=e;return Object.keys(t.options).length===0?f`This command does not have any options.`:a(v,{get data(){return r(Object.values(t.options)).map(S(e=>({name:e.name.trim(),description:e.description.trim(),defaultValue:e.default?String(e.default)?.includes(`"`)?e.default:`\`${Array.isArray(e.default)?e.default.join(`, `):e.default}\``:``,required:e.optional||e.default?``:`✔`}),[`option`,``,`P"2!"/"`]))}})}w.__type=[()=>C,`props`,`CommandOptionsDocs`,`Generates the options markdown documentation for a command.`,`Pn!2""/#?$`];const T=[`npm`,`yarn`,`pnpm`,`bun`,`packageManager`,`npm`,`The package manager to generate the usage example for.`,`CommandTree`,`command`,`The command to generate the usage example for.`,`CommandDocsUsageExampleProps`,`PP.!.".#.$J4%8>&?'"w(4)?*Mw+y`];function E(e){let{packageManager:t=`npm`,command:r}=e,s=(g.Ω=[[`Context`,`"w!`]],g());return[o(`hbr`,{}),f`\`\`\`bash `,o(`hbr`,{}),a(i,{command:r,get bin(){return n(s)},packageManager:t}),o(`hbr`,{}),f`\`\`\``,o(`hbr`,{})]}E.__type=[()=>T,`props`,`CommandDocsUsageExample`,`Generates the markdown documentation for a command.`,`Pn!2""/#?$`];const D=[`levelOffset`,0,`The heading level offset to apply to the generated documentation.`,`CommandTree`,`command`,`The command to generate options documentation for.`,()=>b,()=>T,`packageManager`,`usageExamples`,'`["npm"]`',`Optional usage examples to include in the documentation.`,`CommandDocsProps`,`P'4!8>"?#"w$4%?&n(o'".)fF4*8>+?,Mw-y`];function O(e){let{levelOffset:t=0,command:n,usageExamples:r}=e;return[a(m,{level:1+t,get children(){return n.title}}),a(h,{}),s(()=>f`${n.description}`),a(h,{}),a(m,{level:2+t,children:`Usage`}),a(h,{}),s(()=>f`The ${n.name} command can be executed using the following syntax: `),a(h,{}),a(d,{get when(){return r&&r.length>0},get fallback(){return a(E,{packageManager:`npm`,command:n})},get children(){return a(u,{each:r,hardline:!0,get children(){return S(e=>a(E,{packageManager:e,command:n}),[`packageManager`,``,`P"2!"/"`])}})}}),a(h,{}),a(m,{level:2+t,children:`Options`}),a(h,{}),s(()=>f`The following options are available for the ${n.name} command:`),a(h,{}),a(w,{command:n}),a(h,{})]}O.__type=[()=>D,`props`,`CommandDocs`,`Generates the markdown documentation for a command.`,`Pn!2""/#?$`];const k=[()=>x,`levelOffset`,0,`The heading level offset to apply to the generated documentation.`,`CommandTree`,`command`,`The command to generate documentation for.`,`CommandDocsFileProps`,`P!o!"'4"8>#?$"w%4&?'Mw(y`];function A(n){let{levelOffset:r=0,command:i,frontMatter:o,...s}=n,u=(g.Ω=[[`Context`,`"w!`]],g()),d=p(()=>[`npm`,`yarn`,`pnpm`,`bun`]);return a(e.Provider,{value:i,get children(){return a(_,c({get path(){return y(t(u),`${i.path}.md`)}},s,{get frontMatter(){return l(o??{},{id:i.id,name:i.name,path:i.path,reference:i.reference,isVirtual:i.isVirtual,title:i.title,description:i.description,tags:i.tags})},get children(){return a(O,{levelOffset:r,command:i,get usageExamples(){return d()}})}}))}})}A.__type=[()=>k,`props`,`CommandDocsFile`,`Generates the markdown documentation file for a command.`,`Pn!2""/#?$`];export{O as CommandDocs,A as CommandDocsFile,E as CommandDocsUsageExample,w as CommandOptionsDocs,k as __ΩCommandDocsFileProps,D as __ΩCommandDocsProps,T as __ΩCommandDocsUsageExampleProps,C as __ΩCommandOptionsDocsProps};
1
+ import { CommandContext } from "../contexts/command.mjs";
2
+ import { getDocsOutputPath } from "../helpers/docs-helpers.mjs";
3
+ import { getAppBin } from "../plugin-utils/context-helpers.mjs";
4
+ import { sortOptions } from "../plugin-utils/reflect.mjs";
5
+ import { Usage } from "./usage.mjs";
6
+ import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
7
+ import { defu } from "defu";
8
+ import { For, Show, code, memo as memo$1 } from "@alloy-js/core";
9
+ import { Heading } from "@alloy-js/markdown";
10
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
11
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
12
+ import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
13
+ import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
14
+ import { joinPaths } from "@stryke/path/join";
15
+
16
+ //#region src/components/docs.tsx
17
+ const __ΩRequired = [
18
+ "T",
19
+ "Required",
20
+ "l+e#!e\"!fRb!Pde\"!gN##w\"y"
21
+ ];
22
+ const __ΩPartial = [
23
+ "T",
24
+ "Partial",
25
+ "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
26
+ ];
27
+ function __assignType(fn, args) {
28
+ fn.__type = args;
29
+ return fn;
30
+ }
31
+ const __ΩCommandOptionsDocsProps = [
32
+ "CommandTree",
33
+ "command",
34
+ "The command to generate options documentation for.",
35
+ "CommandOptionsDocsProps",
36
+ "P\"w!4\"?#Mw$y"
37
+ ];
38
+ /**
39
+ * Generates the options markdown documentation for a command.
40
+ */
41
+ function CommandOptionsDocs(props) {
42
+ const { command } = props;
43
+ if (Object.keys(command.options).length === 0) return code`This command does not have any options.`;
44
+ return createComponent(MarkdownTable, { get data() {
45
+ return sortOptions(Object.values(command.options)).map(__assignType((option) => {
46
+ return {
47
+ name: option.name.trim(),
48
+ description: option.description.trim(),
49
+ defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
50
+ required: option.optional || option.default ? "" : "✔"
51
+ };
52
+ }, [
53
+ "option",
54
+ "",
55
+ "P\"2!\"/\""
56
+ ]));
57
+ } });
58
+ }
59
+ CommandOptionsDocs.__type = [
60
+ () => __ΩCommandOptionsDocsProps,
61
+ "props",
62
+ "CommandOptionsDocs",
63
+ "Generates the options markdown documentation for a command.",
64
+ "Pn!2\"\"/#?$"
65
+ ];
66
+ const __ΩCommandDocsUsageExampleProps = [
67
+ "npm",
68
+ "yarn",
69
+ "pnpm",
70
+ "bun",
71
+ "packageManager",
72
+ "npm",
73
+ "The package manager to generate the usage example for.",
74
+ "CommandTree",
75
+ "command",
76
+ "The command to generate the usage example for.",
77
+ "CommandDocsUsageExampleProps",
78
+ "PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
79
+ ];
80
+ /**
81
+ * Generates the markdown documentation for a command.
82
+ */
83
+ function CommandDocsUsageExample(props) {
84
+ const { packageManager = "npm", command } = props;
85
+ const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
86
+ return [
87
+ createIntrinsic("hbr", {}),
88
+ code`\`\`\`bash `,
89
+ createIntrinsic("hbr", {}),
90
+ createComponent(Usage, {
91
+ command,
92
+ get bin() {
93
+ return getAppBin(context);
94
+ },
95
+ packageManager
96
+ }),
97
+ createIntrinsic("hbr", {}),
98
+ code`\`\`\``,
99
+ createIntrinsic("hbr", {})
100
+ ];
101
+ }
102
+ CommandDocsUsageExample.__type = [
103
+ () => __ΩCommandDocsUsageExampleProps,
104
+ "props",
105
+ "CommandDocsUsageExample",
106
+ "Generates the markdown documentation for a command.",
107
+ "Pn!2\"\"/#?$"
108
+ ];
109
+ const __ΩCommandDocsProps = [
110
+ "levelOffset",
111
+ 0,
112
+ "The heading level offset to apply to the generated documentation.",
113
+ "CommandTree",
114
+ "command",
115
+ "The command to generate options documentation for.",
116
+ () => __ΩRequired,
117
+ () => __ΩCommandDocsUsageExampleProps,
118
+ "packageManager",
119
+ "usageExamples",
120
+ "`[\"npm\"]`",
121
+ "Optional usage examples to include in the documentation.",
122
+ "CommandDocsProps",
123
+ "P'4!8>\"?#\"w$4%?&n(o'\".)fF4*8>+?,Mw-y"
124
+ ];
125
+ /**
126
+ * Generates the markdown documentation for a command.
127
+ */
128
+ function CommandDocs(props) {
129
+ const { levelOffset = 0, command, usageExamples } = props;
130
+ return [
131
+ createComponent(Heading, {
132
+ level: 1 + levelOffset,
133
+ get children() {
134
+ return command.title;
135
+ }
136
+ }),
137
+ createComponent(Spacing, {}),
138
+ memo(() => code`${command.description}`),
139
+ createComponent(Spacing, {}),
140
+ createComponent(Heading, {
141
+ level: 2 + levelOffset,
142
+ children: "Usage"
143
+ }),
144
+ createComponent(Spacing, {}),
145
+ memo(() => code`The ${command.name} command can be executed using the following syntax: `),
146
+ createComponent(Spacing, {}),
147
+ createComponent(Show, {
148
+ get when() {
149
+ return usageExamples && usageExamples.length > 0;
150
+ },
151
+ get fallback() {
152
+ return createComponent(CommandDocsUsageExample, {
153
+ packageManager: "npm",
154
+ command
155
+ });
156
+ },
157
+ get children() {
158
+ return createComponent(For, {
159
+ each: usageExamples,
160
+ hardline: true,
161
+ get children() {
162
+ return __assignType((packageManager) => createComponent(CommandDocsUsageExample, {
163
+ packageManager,
164
+ command
165
+ }), [
166
+ "packageManager",
167
+ "",
168
+ "P\"2!\"/\""
169
+ ]);
170
+ }
171
+ });
172
+ }
173
+ }),
174
+ createComponent(Spacing, {}),
175
+ createComponent(Heading, {
176
+ level: 2 + levelOffset,
177
+ children: "Options"
178
+ }),
179
+ createComponent(Spacing, {}),
180
+ memo(() => code`The following options are available for the ${command.name} command:`),
181
+ createComponent(Spacing, {}),
182
+ createComponent(CommandOptionsDocs, { command }),
183
+ createComponent(Spacing, {})
184
+ ];
185
+ }
186
+ CommandDocs.__type = [
187
+ () => __ΩCommandDocsProps,
188
+ "props",
189
+ "CommandDocs",
190
+ "Generates the markdown documentation for a command.",
191
+ "Pn!2\"\"/#?$"
192
+ ];
193
+ const __ΩCommandDocsFileProps = [
194
+ () => __ΩPartial,
195
+ "levelOffset",
196
+ 0,
197
+ "The heading level offset to apply to the generated documentation.",
198
+ "CommandTree",
199
+ "command",
200
+ "The command to generate documentation for.",
201
+ "CommandDocsFileProps",
202
+ "P!o!\"'4\"8>#?$\"w%4&?'Mw(y"
203
+ ];
204
+ /**
205
+ * Generates the markdown documentation file for a command.
206
+ */
207
+ function CommandDocsFile(props) {
208
+ const { levelOffset = 0, command, frontMatter, ...rest } = props;
209
+ const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
210
+ const usageExamples = memo$1(() => [
211
+ "npm",
212
+ "yarn",
213
+ "pnpm",
214
+ "bun"
215
+ ]);
216
+ return createComponent(CommandContext.Provider, {
217
+ value: command,
218
+ get children() {
219
+ return createComponent(MarkdownFile, mergeProps({ get path() {
220
+ return joinPaths(getDocsOutputPath(context), `${command.path}.md`);
221
+ } }, rest, {
222
+ get frontMatter() {
223
+ return defu(frontMatter ?? {}, {
224
+ id: command.id,
225
+ name: command.name,
226
+ path: command.path,
227
+ reference: command.reference,
228
+ isVirtual: command.isVirtual,
229
+ title: command.title,
230
+ description: command.description,
231
+ tags: command.tags
232
+ });
233
+ },
234
+ get children() {
235
+ return createComponent(CommandDocs, {
236
+ levelOffset,
237
+ command,
238
+ get usageExamples() {
239
+ return usageExamples();
240
+ }
241
+ });
242
+ }
243
+ }));
244
+ }
245
+ });
246
+ }
247
+ CommandDocsFile.__type = [
248
+ () => __ΩCommandDocsFileProps,
249
+ "props",
250
+ "CommandDocsFile",
251
+ "Generates the markdown documentation file for a command.",
252
+ "Pn!2\"\"/#?$"
253
+ ];
254
+
255
+ //#endregion
256
+ export { CommandDocs, CommandDocsFile, CommandDocsUsageExample, CommandOptionsDocs, __ΩCommandDocsFileProps, __ΩCommandDocsProps, __ΩCommandDocsUsageExampleProps, __ΩCommandOptionsDocsProps };
2
257
  //# sourceMappingURL=docs.mjs.map