@shell-shock/core 0.8.13 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/api.cjs +34 -0
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.mjs +34 -0
  4. package/dist/api.mjs.map +1 -1
  5. package/dist/components/docs.d.cts +5 -5
  6. package/dist/components/docs.d.cts.map +1 -1
  7. package/dist/components/docs.d.mts +5 -5
  8. package/dist/components/helpers.d.cts +6 -6
  9. package/dist/components/helpers.d.mts +6 -6
  10. package/dist/components/index.cjs +1 -0
  11. package/dist/components/index.d.cts +2 -2
  12. package/dist/components/index.d.mts +2 -2
  13. package/dist/components/index.mjs +2 -2
  14. package/dist/components/options-parser-logic.d.cts +9 -9
  15. package/dist/components/options-parser-logic.d.mts +9 -9
  16. package/dist/components/usage.d.cts +2 -2
  17. package/dist/components/usage.d.cts.map +1 -1
  18. package/dist/components/usage.d.mts +2 -2
  19. package/dist/components/utils-builtin.cjs +341 -0
  20. package/dist/components/utils-builtin.cjs.map +1 -1
  21. package/dist/components/utils-builtin.d.cts +12 -8
  22. package/dist/components/utils-builtin.d.cts.map +1 -1
  23. package/dist/components/utils-builtin.d.mts +12 -8
  24. package/dist/components/utils-builtin.d.mts.map +1 -1
  25. package/dist/components/utils-builtin.mjs +342 -2
  26. package/dist/components/utils-builtin.mjs.map +1 -1
  27. package/dist/config.cjs +12 -0
  28. package/dist/config.cjs.map +1 -1
  29. package/dist/config.mjs +12 -0
  30. package/dist/config.mjs.map +1 -1
  31. package/dist/contexts/command.cjs +3 -2
  32. package/dist/contexts/command.cjs.map +1 -1
  33. package/dist/contexts/command.mjs +3 -2
  34. package/dist/contexts/command.mjs.map +1 -1
  35. package/dist/contexts/options.cjs +20 -4
  36. package/dist/contexts/options.cjs.map +1 -1
  37. package/dist/contexts/options.mjs +20 -4
  38. package/dist/contexts/options.mjs.map +1 -1
  39. package/dist/helpers/docs-helpers.cjs +6 -0
  40. package/dist/helpers/docs-helpers.cjs.map +1 -1
  41. package/dist/helpers/docs-helpers.mjs +6 -0
  42. package/dist/helpers/docs-helpers.mjs.map +1 -1
  43. package/dist/helpers/persistence.cjs +92 -11
  44. package/dist/helpers/persistence.cjs.map +1 -1
  45. package/dist/helpers/persistence.mjs +92 -11
  46. package/dist/helpers/persistence.mjs.map +1 -1
  47. package/dist/helpers/resolve-command.cjs +200 -18
  48. package/dist/helpers/resolve-command.cjs.map +1 -1
  49. package/dist/helpers/resolve-command.mjs +201 -19
  50. package/dist/helpers/resolve-command.mjs.map +1 -1
  51. package/dist/helpers/update-package-json.cjs +27 -3
  52. package/dist/helpers/update-package-json.cjs.map +1 -1
  53. package/dist/helpers/update-package-json.mjs +27 -3
  54. package/dist/helpers/update-package-json.mjs.map +1 -1
  55. package/dist/helpers/utilities.cjs +58 -4
  56. package/dist/helpers/utilities.cjs.map +1 -1
  57. package/dist/helpers/utilities.mjs +58 -4
  58. package/dist/helpers/utilities.mjs.map +1 -1
  59. package/dist/helpers/validations.cjs +28 -1
  60. package/dist/helpers/validations.cjs.map +1 -1
  61. package/dist/helpers/validations.mjs +28 -1
  62. package/dist/helpers/validations.mjs.map +1 -1
  63. package/dist/index.cjs +33 -0
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +2 -2
  66. package/dist/index.d.mts +2 -2
  67. package/dist/index.mjs +6 -1
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/plugin-utils/context-helpers.cjs +78 -3
  70. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  71. package/dist/plugin-utils/context-helpers.mjs +78 -3
  72. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  73. package/dist/plugin-utils/get-command-tree.cjs +17 -1
  74. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  75. package/dist/plugin-utils/get-command-tree.mjs +17 -1
  76. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  77. package/dist/plugin-utils/reflect.cjs +31 -3
  78. package/dist/plugin-utils/reflect.cjs.map +1 -1
  79. package/dist/plugin-utils/reflect.mjs +31 -3
  80. package/dist/plugin-utils/reflect.mjs.map +1 -1
  81. package/dist/plugin-utils/traverse-command-tree.cjs +34 -4
  82. package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -1
  83. package/dist/plugin-utils/traverse-command-tree.mjs +34 -4
  84. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  85. package/dist/plugin.cjs +5 -1
  86. package/dist/plugin.cjs.map +1 -1
  87. package/dist/plugin.d.cts.map +1 -1
  88. package/dist/plugin.d.mts.map +1 -1
  89. package/dist/plugin.mjs +5 -1
  90. package/dist/plugin.mjs.map +1 -1
  91. package/dist/types/command.cjs +241 -0
  92. package/dist/types/command.cjs.map +1 -0
  93. package/dist/types/command.mjs +221 -1
  94. package/dist/types/command.mjs.map +1 -0
  95. package/dist/types/config.cjs +114 -0
  96. package/dist/types/config.cjs.map +1 -0
  97. package/dist/types/config.d.cts +11 -10
  98. package/dist/types/config.d.cts.map +1 -1
  99. package/dist/types/config.d.mts +11 -10
  100. package/dist/types/config.d.mts.map +1 -1
  101. package/dist/types/config.mjs +110 -1
  102. package/dist/types/config.mjs.map +1 -0
  103. package/dist/types/context.cjs +33 -0
  104. package/dist/types/context.cjs.map +1 -0
  105. package/dist/types/context.mjs +31 -1
  106. package/dist/types/context.mjs.map +1 -0
  107. package/dist/types/env.cjs +12 -0
  108. package/dist/types/env.cjs.map +1 -0
  109. package/dist/types/env.d.cts +17 -0
  110. package/dist/types/env.d.cts.map +1 -0
  111. package/dist/types/env.d.mts +17 -0
  112. package/dist/types/env.d.mts.map +1 -0
  113. package/dist/types/env.mjs +11 -0
  114. package/dist/types/env.mjs.map +1 -0
  115. package/dist/types/index.cjs +34 -0
  116. package/dist/types/index.d.cts +2 -2
  117. package/dist/types/index.d.mts +2 -2
  118. package/dist/types/index.mjs +7 -1
  119. package/dist/types/options.cjs +12 -0
  120. package/dist/types/options.cjs.map +1 -0
  121. package/dist/types/options.mjs +11 -1
  122. package/dist/types/options.mjs.map +1 -0
  123. package/dist/types/runtime.cjs +12 -0
  124. package/dist/types/runtime.cjs.map +1 -0
  125. package/dist/types/runtime.mjs +11 -1
  126. package/dist/types/runtime.mjs.map +1 -0
  127. package/package.json +25 -11
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.mjs","names":["deserializeType","ReflectionFunction","ReflectionKind","resolveClassType","serializeType","omit","joinPaths","getCommandsPersistencePath","context","dataPath","serializedCommandTree","commands","serialize","node","parent","serializedNode","options","Object","entries","reduce","ret","key","option","arguments","map","arg","children","reflection","type","undefined","child","id","result","deserializeCommandTree","serializedCommands","deserialize","kind","function","Error","optionsReflection","getParameters","length","optionsType","objectLiteral","deserializedNode","getProperty","name","i","getParameterOrUndefined","readCommandsPersistence","reflections","fs","read","JSON","parse","writeCommandsPersistence","filePath","write","stringify","config","mode"],"sources":["../../src/helpers/persistence.ts"],"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 { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport {\n deserializeType,\n ReflectionFunction,\n ReflectionKind,\n resolveClassType,\n serializeType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandTree,\n SerializedCommandOption,\n SerializedCommandTree\n} from \"../types\";\nimport type { Context } from \"../types/context\";\n\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\nexport function serializedCommandTree(\n commands: Record<string, CommandTree>\n): Record<string, SerializedCommandTree> {\n const serialize = (\n node: CommandTree,\n parent: string | null = null\n ): SerializedCommandTree => {\n const serializedNode: SerializedCommandTree = {\n ...node,\n options: Object.entries(node.options).reduce(\n (ret, [key, option]) => {\n ret[key] = {\n ...omit(option, [\"reflection\"])\n };\n return ret;\n },\n {} as Record<string, SerializedCommandOption>\n ),\n arguments: node.arguments.map(arg => ({\n ...omit(arg, [\"reflection\"])\n })),\n parent,\n children: {},\n reflection: node.reflection\n ? serializeType(node.reflection.type)\n : undefined\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n serializedNode.children[key] = serialize(child, node.id);\n }\n\n return serializedNode;\n };\n\n const result: Record<string, SerializedCommandTree> = {};\n for (const [key, child] of Object.entries(commands)) {\n result[key] = serialize(child, null);\n }\n\n return result;\n}\n\nexport function deserializeCommandTree(\n serializedCommands: Record<string, SerializedCommandTree>\n): Record<string, CommandTree> {\n const deserialize = (\n node: SerializedCommandTree,\n parent: CommandTree | null = null\n ): CommandTree => {\n const type = deserializeType(node.reflection);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `Failed to deserialize persisted data - invalid command handler reflection type for command ${node.id}`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n let optionsReflection: ReflectionClass<any> | undefined;\n if (\n reflection.getParameters().length > 0 &&\n reflection.getParameters()[0]\n ) {\n const optionsType = reflection.getParameters()[0]!.type;\n if (optionsType.kind === ReflectionKind.objectLiteral) {\n optionsReflection = resolveClassType(optionsType);\n }\n }\n\n const deserializedNode: CommandTree = {\n ...node,\n options: optionsReflection\n ? Object.entries(node.options).reduce(\n (ret, [key, option]) => {\n ret[key] = {\n ...option,\n reflection: optionsReflection.getProperty(option.name)\n } as CommandOption;\n return ret;\n },\n {} as Record<string, CommandOption>\n )\n : {},\n arguments: node.arguments.map((arg, i) => ({\n ...arg,\n reflection:\n reflection.getParameters().length > i + 1\n ? reflection.getParameters()[i + 1]\n : reflection.getParameterOrUndefined(arg.name)\n })) as CommandArgument[],\n parent,\n children: {},\n reflection\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n deserializedNode.children[key] = deserialize(child, deserializedNode);\n }\n\n return deserializedNode;\n };\n\n const result: Record<string, CommandTree> = {};\n for (const [key, child] of Object.entries(serializedCommands)) {\n result[key] = deserialize(child, null);\n }\n\n return result;\n}\n\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = deserializeCommandTree(JSON.parse(reflections));\n}\n\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n serializedCommandTree(context.commands),\n null,\n context.config.mode === \"development\" ? 2 : 0\n )\n );\n}\n"],"mappings":";;;;;AAqCA,SAAgBO,2BAA2BC,SAA0B;AACnE,QAAOF,UAAUE,QAAQC,UAAU,eAAe,gBAAgB;;AAGpE,SAAgBC,sBACdC,UACuC;CACvC,MAAMC,aACJC,MACAC,SAAwB,SACE;EAC1B,MAAMC,iBAAwC;GAC5C,GAAGF;GACHG,SAASC,OAAOC,QAAQL,KAAKG,QAAQ,CAACG,QACnCC,KAAK,CAACC,KAAKC,YAAY;AACtBF,QAAIC,OAAO,EACT,GAAGhB,KAAKiB,QAAQ,CAAC,aAAa,CAAA,EAC/B;AACD,WAAOF;MAET,EACF,CAAC;GACDG,WAAWV,KAAKU,UAAUC,KAAIC,SAAQ,EACpC,GAAGpB,KAAKoB,KAAK,CAAC,aAAa,CAAA,EAC5B,EAAE;GACHX;GACAY,UAAU,EAAE;GACZC,YAAYd,KAAKc,aACbvB,cAAcS,KAAKc,WAAWC,KAAK,GACnCC;GACL;AAED,OAAK,MAAM,C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,MAAM,CAACN,KAAKS,UAAUb,OAAOC,QAAQL,KAAKa,YAAY,EAAE,CAAC,CAC5DkB,kBAAiBlB,SAASL,OAAOc,YAAYL,OAAOc,iBAAiB;AAGvE,SAAOA;;CAGT,MAAMZ,SAAsC,EAAE;AAC9C,MAAK,MAAM,CAACX,KAAKS,UAAUb,OAAOC,QAAQgB,mBAAmB,CAC3DF,QAAOX,OAAOc,YAAYL,OAAO,KAAK;AAGxC,QAAOE;;AAGT,eAAsBiB,wBAAwBzC,SAAkB;CAC9D,MAAM0C,cAAc,MAAM1C,QAAQ2C,GAAGC,KACnC7C,2BAA2BC,QAC7B,CAAC;AACD,KAAI,CAAC0C,eAAe,CAACA,YAAYT,OAC/B,OAAM,IAAIH,MACR,+BAA+B/B,2BAA2BC,QAAQ,CAAA,WACnE;AAGHA,SAAQG,WAAWsB,uBAAuBoB,KAAKC,MAAMJ,YAAY,CAAC;;AAGpE,eAAsBK,yBAAyB/C,SAAkB;CAC/D,MAAMgD,WAAWjD,2BAA2BC,QAAQ;AAEpD,OAAMA,QAAQ2C,GAAGM,MACfD,UACAH,KAAKK,UACHhD,sBAAsBF,QAAQG,SAAS,EACvC,MACAH,QAAQmD,OAAOC,SAAS,gBAAgB,IAAI,EAEhD,CAAC"}
1
+ {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"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 { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport {\n deserializeType,\n ReflectionFunction,\n ReflectionKind,\n resolveClassType,\n serializeType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandTree,\n SerializedCommandOption,\n SerializedCommandTree\n} from \"../types\";\nimport type { Context } from \"../types/context\";\n\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\nexport function serializedCommandTree(\n commands: Record<string, CommandTree>\n): Record<string, SerializedCommandTree> {\n const serialize = (\n node: CommandTree,\n parent: string | null = null\n ): SerializedCommandTree => {\n const serializedNode: SerializedCommandTree = {\n ...node,\n options: Object.entries(node.options).reduce(\n (ret, [key, option]) => {\n ret[key] = {\n ...omit(option, [\"reflection\"])\n };\n return ret;\n },\n {} as Record<string, SerializedCommandOption>\n ),\n arguments: node.arguments.map(arg => ({\n ...omit(arg, [\"reflection\"])\n })),\n parent,\n children: {},\n reflection: node.reflection\n ? serializeType(node.reflection.type)\n : undefined\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n serializedNode.children[key] = serialize(child, node.id);\n }\n\n return serializedNode;\n };\n\n const result: Record<string, SerializedCommandTree> = {};\n for (const [key, child] of Object.entries(commands)) {\n result[key] = serialize(child, null);\n }\n\n return result;\n}\n\nexport function deserializeCommandTree(\n serializedCommands: Record<string, SerializedCommandTree>\n): Record<string, CommandTree> {\n const deserialize = (\n node: SerializedCommandTree,\n parent: CommandTree | null = null\n ): CommandTree => {\n const type = deserializeType(node.reflection);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `Failed to deserialize persisted data - invalid command handler reflection type for command ${node.id}`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n let optionsReflection: ReflectionClass<any> | undefined;\n if (\n reflection.getParameters().length > 0 &&\n reflection.getParameters()[0]\n ) {\n const optionsType = reflection.getParameters()[0]!.type;\n if (optionsType.kind === ReflectionKind.objectLiteral) {\n optionsReflection = resolveClassType(optionsType);\n }\n }\n\n const deserializedNode: CommandTree = {\n ...node,\n options: optionsReflection\n ? Object.entries(node.options).reduce(\n (ret, [key, option]) => {\n ret[key] = {\n ...option,\n reflection: optionsReflection.getProperty(option.name)\n } as CommandOption;\n return ret;\n },\n {} as Record<string, CommandOption>\n )\n : {},\n arguments: node.arguments.map((arg, i) => ({\n ...arg,\n reflection:\n reflection.getParameters().length > i + 1\n ? reflection.getParameters()[i + 1]\n : reflection.getParameterOrUndefined(arg.name)\n })) as CommandArgument[],\n parent,\n children: {},\n reflection\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n deserializedNode.children[key] = deserialize(child, deserializedNode);\n }\n\n return deserializedNode;\n };\n\n const result: Record<string, CommandTree> = {};\n for (const [key, child] of Object.entries(serializedCommands)) {\n result[key] = deserialize(child, null);\n }\n\n return result;\n}\n\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = deserializeCommandTree(JSON.parse(reflections));\n}\n\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n serializedCommandTree(context.commands),\n null,\n context.config.mode === \"development\" ? 2 : 0\n )\n );\n}\n"],"mappings":";;;;;AAAA,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;;AAE5D,IAAG,SAAS;;;;AAOZ,QAAO,UAAU,QAAQ,UAAU,eAAY,gBAAA;;AAEnD,2BAA2B,SAAS;CAAC;CAAW;CAAW;CAAkB;CAAA;AAC7E,SAAgB,sBAAsB,UAAU;;EAExC,MAAM,iBAAiB;;GAEnB,SAAS,OAAO,QAAQ,KAAK,QAAQ,CAAC,OAAO,cAAa,KAAA,CAAA,KAAA,YAAA;iBAElD,GAAG,KAAK,QA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AAA,KAAA;KACX;AACH,WAAA;MACb;IAAA;IAAA;IAAA;IAAA;IAAA,CAAA,EAAA,EAAA,CAAA;GAEO,WAAW,KAAK,UAAU,IAAI,cAAc,KAAK,OAAO;IACpD,GAAG;IACf,YAAA,WAAA,eAAA,CAAA,SAAA,IAAA,wCAEkB,WAAG,wBAAA,IAAA,KAAA;IACtB,GAAA;IAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;;GAES,UAAU,EAAE;GACZ;GACH;AACP,OAAA,MAAA,CAAA,KAAA,UAAA,OAAA,QAAA,KAAA,YAAA,EAAA,CAAA;AAGF,SAAA;;;;;;;;;;CAEI,MAAM,SAAS,EAAE;AACjB,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,mBAAY,CAClD,QAAO,OAAO,YAAS,OAAA,KAAA;AAE3B,QAAO;;AAEX,uBAAoB,SAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;AACpB,eAAsB,wBAAwB,SAAG;CAC7C,MAAM,cAAc,MAAM,QAAQ,GAAG,KAAK,2BAAC,QAAA,CAAA;AAC3C,KAAI,CAAC,eAAY,CAAA,YAAA,OACb,OAAM,IAAI,MAAM,+BAA+B,2BAA2B,QAAQ,CAAA,WAAY;AAElG,SAAA,WAAA,uBAAA,KAAA,MAAA,YAAA,CAAA;;AAEJ,wBAAwB,SAAS;CAAC;CAAW;CAAM;CAAA;CAAA;;CAE/C,MAAM,WAAW,2BAA2B,QAAQ;AACpD,OAAG,QAAA,GAAA,MAAA,UAAA,KAAA,UAAA,sBAAA,QAAA,SAAA,EAAA,MAAA,QAAA,OAAA,SAAA,gBAAA,IAAA,EAAA,CAAA;;AAEP,yBAAyB,SAAS;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -17,6 +17,10 @@ let __stryke_path_normalize = require("@stryke/path/normalize");
17
17
  let powerlines_lib_utilities_resolve = require("powerlines/lib/utilities/resolve");
18
18
 
19
19
  //#region src/helpers/resolve-command.ts
20
+ function __assignType(fn, args) {
21
+ fn.__type = args;
22
+ return fn;
23
+ }
20
24
  /**
21
25
  * Resolves the description for a command option based on its reflection.
22
26
  *
@@ -31,6 +35,17 @@ let powerlines_lib_utilities_resolve = require("powerlines/lib/utilities/resolve
31
35
  function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
32
36
  return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "flag" : "option"} that allows the user to ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "indicator" : `${kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
33
37
  }
38
+ resolveCommandOptionDescription.__type = [
39
+ "name",
40
+ () => __powerlines_deepkit_vendor_type.__ΩReflectionKind,
41
+ "kind",
42
+ "optional",
43
+ "variadic",
44
+ "title",
45
+ "defaultValue",
46
+ "resolveCommandOptionDescription",
47
+ "P&2!n\"2#\"2$\"2%&2&8\"2'8&/("
48
+ ];
34
49
  /**
35
50
  * Resolves the description for a command argument based on its reflection.
36
51
  *
@@ -45,9 +60,31 @@ function resolveCommandOptionDescription(name, kind, optional = false, variadic
45
60
  function resolveCommandArgumentDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
46
61
  return `An${optional && !defaultValue ? " optional" : ""} argument that allows the user to ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "indicator" : `${kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
47
62
  }
63
+ resolveCommandArgumentDescription.__type = [
64
+ "name",
65
+ () => __powerlines_deepkit_vendor_type.__ΩReflectionKind,
66
+ "kind",
67
+ "optional",
68
+ "variadic",
69
+ "title",
70
+ "defaultValue",
71
+ "resolveCommandArgumentDescription",
72
+ "P&2!n\"2#\"2$\"2%&2&8\"2'8&/("
73
+ ];
48
74
  function resolveCommandId(context, file) {
49
- return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter((p) => Boolean(p) && !require_plugin_utils_context_helpers.isDynamicPathSegment(p)).join("/").replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").replaceAll("/", "-");
75
+ return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter(__assignType((p) => Boolean(p) && !require_plugin_utils_context_helpers.isDynamicPathSegment(p), [
76
+ "p",
77
+ "",
78
+ "P\"2!\"/\""
79
+ ])).join("/").replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").replaceAll("/", "-");
50
80
  }
81
+ resolveCommandId.__type = [
82
+ "Context",
83
+ "context",
84
+ "file",
85
+ "resolveCommandId",
86
+ "P\"w!2\"&2#&/$"
87
+ ];
51
88
  /**
52
89
  * Finds the command name from the given file path.
53
90
  *
@@ -63,15 +100,59 @@ function resolveCommandName(file) {
63
100
  }
64
101
  return name;
65
102
  }
103
+ resolveCommandName.__type = [
104
+ "file",
105
+ "resolveCommandName",
106
+ "P&2!\"/\""
107
+ ];
66
108
  function resolveCommandPath(context, file) {
67
- return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").split("/").filter((path) => path && !require_plugin_utils_context_helpers.isPathSegmentGroup(path)).join("/");
109
+ return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").split("/").filter(__assignType((path) => path && !require_plugin_utils_context_helpers.isPathSegmentGroup(path), [
110
+ "path",
111
+ "",
112
+ "P\"2!\"/\""
113
+ ])).join("/");
114
+ }
115
+ resolveCommandPath.__type = [
116
+ "Context",
117
+ "context",
118
+ "file",
119
+ "resolveCommandPath",
120
+ "P\"w!2\"&2#&/$"
121
+ ];
122
+ function resolveCommandDynamicPathSegments(context, file) {
123
+ return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter(__assignType((path) => Boolean(path) && require_plugin_utils_context_helpers.isDynamicPathSegment(path), [
124
+ "path",
125
+ "",
126
+ "P\"2!\"/\""
127
+ ])).map(__assignType((path) => require_plugin_utils_context_helpers.getDynamicPathSegmentName(path), [
128
+ "path",
129
+ "",
130
+ "P\"2!\"/\""
131
+ ]));
68
132
  }
133
+ resolveCommandDynamicPathSegments.__type = [
134
+ "Context",
135
+ "context",
136
+ "file",
137
+ "resolveCommandDynamicPathSegments",
138
+ "P\"w!2\"&2#&F/$"
139
+ ];
69
140
  function findCommandsRoot(context) {
70
141
  if ((0, __stryke_type_checks_is_set_string.isSetString)(context.config.entry)) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.entry), context.config.projectRoot), context.workspaceConfig.workspaceRoot);
71
142
  else if ((0, __stryke_type_checks_is_set_object.isSetObject)(context.config.entry) && "file" in context.config.entry) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.entry.file), context.config.projectRoot), context.workspaceConfig.workspaceRoot);
72
- else if (Array.isArray(context.config.entry) && context.config.entry.length > 0) return (0, __stryke_path_common.commonPath)(context.config.entry.map((entry) => (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(entry) ? entry : entry.file), context.config.projectRoot), context.workspaceConfig.workspaceRoot)));
143
+ else if (Array.isArray(context.config.entry) && context.config.entry.length > 0) return (0, __stryke_path_common.commonPath)(context.config.entry.map(__assignType((entry) => (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(entry) ? entry : entry.file), context.config.projectRoot), context.workspaceConfig.workspaceRoot), [
144
+ "entry",
145
+ "",
146
+ "P\"2!\"/\""
147
+ ])));
73
148
  return (0, __stryke_path_append.appendPath)(context.config.sourceRoot || context.config.projectRoot, context.workspaceConfig.workspaceRoot);
74
149
  }
150
+ findCommandsRoot.__type = [
151
+ "Context",
152
+ "context",
153
+ "findCommandsRoot",
154
+ "P\"w!2\"&/#"
155
+ ];
75
156
  /**
76
157
  * Extracts command parameter information from a type parameter reflection.
77
158
  *
@@ -100,6 +181,15 @@ function extractCommandOption(command, reflection) {
100
181
  else if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for option "${reflection.getNameAsString()}" in command "${command.name}". Only string, number, boolean, string[] and number[] are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
101
182
  return option;
102
183
  }
184
+ extractCommandOption.__type = [
185
+ "CommandInput",
186
+ "command",
187
+ "ReflectionProperty",
188
+ "reflection",
189
+ "CommandOption",
190
+ "extractCommandOption",
191
+ "P\"w!2\"\"w#2$\"w%/&"
192
+ ];
103
193
  /**
104
194
  * Extracts command positional argument information from a type parameter reflection.
105
195
  *
@@ -128,6 +218,15 @@ function extractCommandArgument(command, reflection) {
128
218
  else if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${command.name}". Only string, number, boolean, string[] and number[] are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
129
219
  return argument;
130
220
  }
221
+ extractCommandArgument.__type = [
222
+ "CommandInput",
223
+ "command",
224
+ "ReflectionParameter",
225
+ "reflection",
226
+ "CommandArgument",
227
+ "extractCommandArgument",
228
+ "P\"w!2\"\"w#2$\"w%/&"
229
+ ];
131
230
  /**
132
231
  * Reflects the command tree for a given command input.
133
232
  *
@@ -152,10 +251,10 @@ async function reflectCommandTree(context, command, parent) {
152
251
  if (!command.isVirtual) {
153
252
  if (!command.entry.input?.file || !context.fs.existsSync(command.entry.input.file)) throw new Error(`${!command.entry.input?.file ? "Missing" : "Non-existent"} command entry file for "${command.name}"`);
154
253
  context.debug(`Adding reflection for user-defined command: ${command.id} (file: ${command.entry.input.file})`);
155
- const resolved = await (0, powerlines_lib_utilities_resolve.resolveModule)(context, command.entry.input, { plugins: [(0, __powerlines_deepkit_esbuild_plugin.esbuildPlugin)(context, {
254
+ const resolved = await (powerlines_lib_utilities_resolve.resolveModule.Ω = [["CommandModule", "\"w!"]], (0, powerlines_lib_utilities_resolve.resolveModule)(context, command.entry.input, { plugins: [(0, __powerlines_deepkit_esbuild_plugin.esbuildPlugin)(context, {
156
255
  reflection: "default",
157
256
  reflectionLevel: "verbose"
158
- })] });
257
+ })] }));
159
258
  const metadata = resolved.metadata ?? {};
160
259
  if ((0, __stryke_type_checks_is_set_string.isSetString)(metadata.title)) tree.title = metadata.title;
161
260
  if ((0, __stryke_type_checks_is_set_string.isSetString)(metadata.description)) tree.description = metadata.description;
@@ -171,18 +270,47 @@ async function reflectCommandTree(context, command, parent) {
171
270
  const optionsReflection = __powerlines_deepkit_vendor_type.ReflectionClass.from(parameters[0].type);
172
271
  for (const propertyReflection of optionsReflection.getProperties()) tree.options[propertyReflection.getNameAsString()] = extractCommandOption(command, propertyReflection);
173
272
  } else throw new Error(`The first parameter of the command handler function in "${command.entry.input.file}" must be an object literal or class type representing the command options.`);
174
- tree.arguments = parameters.slice(1).map((arg) => extractCommandArgument(command, arg));
175
- tree.arguments.forEach((argument, index) => {
176
- const found = tree.arguments.findIndex((arg) => arg.name === argument.name);
177
- if (found !== -1 && found !== index || tree.segments.some((segment) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment) && require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment) === argument.name)) {
178
- argument.name += `_${tree.segments.filter((segment) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment) && require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === argument.name).length + tree.arguments.filter((arg) => arg.name.replace(/_\d+$/, "") === argument.name).length}`;
273
+ tree.arguments = parameters.slice(1).map(__assignType((arg) => extractCommandArgument(command, arg), [
274
+ "arg",
275
+ "",
276
+ "P\"2!\"/\""
277
+ ]));
278
+ tree.arguments.forEach(__assignType((argument, index) => {
279
+ const found = tree.arguments.findIndex(__assignType((arg) => arg.name === argument.name, [
280
+ "arg",
281
+ "",
282
+ "P\"2!\"/\""
283
+ ]));
284
+ if (found !== -1 && found !== index || tree.segments.some(__assignType((segment) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment) && require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment) === argument.name, [
285
+ "segment",
286
+ "",
287
+ "P\"2!\"/\""
288
+ ]))) {
289
+ argument.name += `_${tree.segments.filter(__assignType((segment) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment) && require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === argument.name, [
290
+ "segment",
291
+ "",
292
+ "P\"2!\"/\""
293
+ ])).length + tree.arguments.filter(__assignType((arg) => arg.name.replace(/_\d+$/, "") === argument.name, [
294
+ "arg",
295
+ "",
296
+ "P\"2!\"/\""
297
+ ])).length}`;
179
298
  argument.env = (0, __stryke_string_format_constant_case.constantCase)(argument.name);
180
299
  }
181
- });
300
+ }, [
301
+ "argument",
302
+ "index",
303
+ "",
304
+ "P\"2!\"2\"\"/#"
305
+ ]));
182
306
  }
183
307
  } else tree.description ??= `A collection of available ${tree.title.replace(/(?:c|C)ommands?$/, "").trim() || (0, __stryke_string_format_title_case.titleCase)(tree.name)} commands that are included in the ${require_plugin_utils_context_helpers.getAppTitle(context)} command-line application.`;
184
308
  if (context.env) {
185
- if ((0, __stryke_type_checks_is_set_object.isSetObject)(tree.options)) Object.values(tree.options).filter((option) => option.env !== false).forEach((option) => {
309
+ if ((0, __stryke_type_checks_is_set_object.isSetObject)(tree.options)) Object.values(tree.options).filter(__assignType((option) => option.env !== false, [
310
+ "option",
311
+ "",
312
+ "P\"2!\"/\""
313
+ ])).forEach(__assignType((option) => {
186
314
  context.env.types.env.addProperty({
187
315
  name: option.env,
188
316
  optional: option.optional ? true : void 0,
@@ -196,12 +324,28 @@ async function reflectCommandTree(context, command, parent) {
196
324
  tags: {
197
325
  ...option.reflection?.getTags(),
198
326
  title: option.title,
199
- alias: option.alias.filter((alias) => alias.length > 1).map((alias) => (0, __stryke_string_format_constant_case.constantCase)(alias)),
327
+ alias: option.alias.filter(__assignType((alias) => alias.length > 1, [
328
+ "alias",
329
+ "",
330
+ "P\"2!\"/\""
331
+ ])).map(__assignType((alias) => (0, __stryke_string_format_constant_case.constantCase)(alias), [
332
+ "alias",
333
+ "",
334
+ "P\"2!\"/\""
335
+ ])),
200
336
  domain: "cli"
201
337
  }
202
338
  });
203
- });
204
- tree.arguments.filter((arg) => arg.env !== false).forEach((arg) => context.env.types.env.addProperty({
339
+ }, [
340
+ "option",
341
+ "",
342
+ "P\"2!\"/\""
343
+ ]));
344
+ tree.arguments.filter(__assignType((arg) => arg.env !== false, [
345
+ "arg",
346
+ "",
347
+ "P\"2!\"/\""
348
+ ])).forEach(__assignType((arg) => context.env.types.env.addProperty({
205
349
  name: arg.env,
206
350
  optional: arg.optional ? true : void 0,
207
351
  description: arg.description,
@@ -210,14 +354,52 @@ async function reflectCommandTree(context, command, parent) {
210
354
  default: arg.default,
211
355
  tags: {
212
356
  ...arg.reflection.getTags(),
213
- alias: arg.alias.filter((alias) => alias.length > 1).map((alias) => (0, __stryke_string_format_constant_case.constantCase)(alias)),
357
+ alias: arg.alias.filter(__assignType((alias) => alias.length > 1, [
358
+ "alias",
359
+ "",
360
+ "P\"2!\"/\""
361
+ ])).map(__assignType((alias) => (0, __stryke_string_format_constant_case.constantCase)(alias), [
362
+ "alias",
363
+ "",
364
+ "P\"2!\"/\""
365
+ ])),
214
366
  domain: "cli"
215
367
  }
216
- }));
368
+ }), [
369
+ "arg",
370
+ "",
371
+ "P\"2!\"/\""
372
+ ]));
217
373
  }
218
- for (const input of context.inputs.filter((input$1) => input$1.segments.filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment)).length === command.segments.filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment)).length + 1 && input$1.segments.slice(0, command.segments.length).every((value, index) => value === command.segments[index]))) tree.children[input.name] = await reflectCommandTree(context, input, tree);
374
+ for (const input of context.inputs.filter(__assignType((input$1) => input$1.segments.filter(__assignType((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment), [
375
+ "segment",
376
+ "",
377
+ "P\"2!\"/\""
378
+ ])).length === command.segments.filter(__assignType((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment), [
379
+ "segment",
380
+ "",
381
+ "P\"2!\"/\""
382
+ ])).length + 1 && input$1.segments.slice(0, command.segments.length).every(__assignType((value, index) => value === command.segments[index], [
383
+ "value",
384
+ "index",
385
+ "",
386
+ "P\"2!\"2\"\"/#"
387
+ ])), [
388
+ "input",
389
+ "",
390
+ "P\"2!\"/\""
391
+ ]))) tree.children[input.name] = await reflectCommandTree(context, input, tree);
219
392
  return tree;
220
393
  }
394
+ reflectCommandTree.__type = [
395
+ "context",
396
+ "CommandInput",
397
+ "command",
398
+ "CommandTree",
399
+ "parent",
400
+ "reflectCommandTree",
401
+ "P\"2!\"w\"2#\"w$2%8\"w$`/&"
402
+ ];
221
403
 
222
404
  //#endregion
223
405
  exports.findCommandsRoot = findCommandsRoot;
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-command.cjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionFunction","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getDefaultOptions","resolveCommandOptionDescription","name","kind","optional","variadic","title","defaultValue","boolean","trim","number","resolveCommandArgumentDescription","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandDynamicPathSegments","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","type","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","string","Error","extractCommandArgument","array","getName","argument","getAlias","parameter","reflectCommandTree","parent","isVirtual","replace","tree","icon","options","arguments","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","getParameters","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","slice","arg","forEach","index","found","findIndex","segments","some","segment","Object","values","types","addProperty","undefined","visibility","public","tags","domain","inputs","every","value"],"sources":["../../src/helpers/resolve-command.ts"],"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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption,\n StringCommandArgument,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === ReflectionKind.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getNameAsString(),\n reflection.getKind(),\n reflection.isOptional(),\n reflection.isArray(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: type.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray(),\n reflection\n } as CommandOption;\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind = (\n type as TypeArray\n ).type.kind as ReflectionKind.string | ReflectionKind.number;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command positional argument information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command positional argument information.\n */\nexport function extractCommandArgument(\n command: CommandInput,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n\n if (\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName(),\n alias: reflection.getAlias(),\n kind: type.kind,\n title: titleCase(reflection.getName()),\n description:\n reflection.parameter.description ||\n resolveCommandArgumentDescription(\n reflection.getName(),\n type.kind === ReflectionKind.array ? type.type.kind : type.kind,\n reflection.isOptional(),\n type.kind === ReflectionKind.array,\n titleCase(reflection.getName()),\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getName()),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n reflection\n } as CommandArgument;\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandArgument | NumberCommandArgument).variadic =\n true;\n (argument as StringCommandArgument | NumberCommandArgument).kind =\n type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return argument;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const tree = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n arguments: [],\n parent: parent ?? null,\n children: {},\n reflection: null\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n tree.icon = metadata.icon;\n }\n\n const type = reflect(resolved);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.reflection = new ReflectionFunction(type);\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n\n const parameters = tree.reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n } else {\n throw new Error(\n `The first parameter of the command handler function in \"${\n command.entry.input.file\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n tree.arguments = parameters\n .slice(1)\n .map(arg => extractCommandArgument(command, arg));\n\n // Ensure unique argument names by appending an index suffix to duplicates\n tree.arguments.forEach((argument, index) => {\n const found = tree.arguments.findIndex(\n arg => arg.name === argument.name\n );\n if (\n (found !== -1 && found !== index) ||\n tree.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n tree.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n tree.arguments.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title.replace(/(?:c|C)ommands?$/, \"\").trim() || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command-line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.reflection?.getType() ??\n ((option as StringCommandOption | NumberCommandOption).variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }),\n default: option.default,\n tags: {\n ...option.reflection?.getTags(),\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n tree.arguments\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: arg.reflection.getType(),\n default: arg.default,\n tags: {\n ...arg.reflection.getTags(),\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.segments\n .slice(0, command.segments.length)\n .every((value, index) => value === command.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgByB,gCACdC,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,gBACtDJ,SAASvB,gDAAe4B,UAAU,SAAS,SAAQ,2BAEnDL,SAASvB,gDAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,qDAAcP,KAAK,CAAA,GAClCC,SAASvB,gDAAe4B,UACpB,cACA,GAAGL,SAASvB,gDAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;;;;;;;;;;;;AAeV,SAAgBM,kCACdT,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,KACLH,YAAY,CAACG,eAAe,cAAc,GAAE,oCAE5CJ,SAASvB,gDAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,qDAAcP,KAAK,CAAA,GAClCC,SAASvB,gDAAe4B,UACpB,cACA,GAAGL,SAASvB,gDAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;AAIV,SAAgBO,iBAAiBC,SAAkBC,MAAsB;AACvE,6FAAgCA,KAAK,EAAED,QAAQE,aAAa,CACzDC,MAAM,IAAI,CACVC,QAAOC,MAAKC,QAAQD,EAAE,IAAI,CAACpB,0DAAqBoB,EAAE,CAAC,CACnDE,KAAK,IAAI,CACTC,WAAW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,KAAK,IAAI;;;;;;;;A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AAS;KAC/BxC,OAAOqC,OAAOrC;KACduC,OAAOF,OAAOE,MACX5B,QAAO4B,UAASA,MAAMT,SAAS,EAAE,CACjCT,KAAIkB,iEAAsBA,MAAM,CAAC;KACpC6D,QAAQ;KACV;IACD,CAAC;IACF;AAGNxC,OAAKG,UACFpD,QAAOyE,QAAOA,IAAItC,QAAQ,MAAM,CAChCuC,SAAQD,QACP7E,QAAQuC,IAAIgD,MAAMhD,IAAIiD,YAAY;GAChCnG,MAAMwF,IAAItC;GACVhD,UAAUsF,IAAItF,WAAW,OAAOkG;GAChCvD,aAAa2C,IAAI3C;GACjBwD,YAAY1H,sDAAqB2H;GACjC/D,MAAMiD,IAAIlD,WAAWE,SAAS;GAC9BW,SAASqC,IAAIrC;GACboD,MAAM;IACJ,GAAGf,IAAIlD,WAAWM,SAAS;IAC3BD,OAAO6C,IAAI7C,MACR5B,QAAO4B,UAASA,MAAMT,SAAS,EAAE,CACjCT,KAAIkB,iEAAsBA,MAAM,CAAC;IACpC6D,QAAQ;IACV;GACD,CACH,CAAC;;AAGL,MAAK,MAAMnC,SAAS1D,QAAQ8F,OAAO1F,QACjCsD,YACEA,QAAMwB,SAAS9E,QAAOgF,YAAW,CAACnG,0DAAqBmG,QAAQ,CAAC,CAC7D7D,WACDG,QAAQwD,SAAS9E,QAAOgF,YAAW,CAACnG,0DAAqBmG,QAAQ,CAAC,CAC/D7D,SACD,KACJmC,QAAMwB,SACHN,MAAM,GAAGlD,QAAQwD,SAAS3D,OAAO,CACjCwE,OAAOC,OAAOjB,UAAUiB,UAAUtE,QAAQwD,SAASH,OAC1D,CAAC,CACC1B,MAAKI,SAASC,MAAMrE,QAAQ,MAAM4D,mBAAmBjD,SAAS0D,OAAOL,KAAK;AAG5E,QAAOA"}
1
+ {"version":3,"file":"resolve-command.cjs","names":[],"sources":["../../src/helpers/resolve-command.ts"],"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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption,\n StringCommandArgument,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === ReflectionKind.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getNameAsString(),\n reflection.getKind(),\n reflection.isOptional(),\n reflection.isArray(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: type.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray(),\n reflection\n } as CommandOption;\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind = (\n type as TypeArray\n ).type.kind as ReflectionKind.string | ReflectionKind.number;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command positional argument information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command positional argument information.\n */\nexport function extractCommandArgument(\n command: CommandInput,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n\n if (\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName(),\n alias: reflection.getAlias(),\n kind: type.kind,\n title: titleCase(reflection.getName()),\n description:\n reflection.parameter.description ||\n resolveCommandArgumentDescription(\n reflection.getName(),\n type.kind === ReflectionKind.array ? type.type.kind : type.kind,\n reflection.isOptional(),\n type.kind === ReflectionKind.array,\n titleCase(reflection.getName()),\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getName()),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n reflection\n } as CommandArgument;\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandArgument | NumberCommandArgument).variadic =\n true;\n (argument as StringCommandArgument | NumberCommandArgument).kind =\n type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return argument;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const tree = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n arguments: [],\n parent: parent ?? null,\n children: {},\n reflection: null\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n tree.icon = metadata.icon;\n }\n\n const type = reflect(resolved);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.reflection = new ReflectionFunction(type);\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n\n const parameters = tree.reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n } else {\n throw new Error(\n `The first parameter of the command handler function in \"${\n command.entry.input.file\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n tree.arguments = parameters\n .slice(1)\n .map(arg => extractCommandArgument(command, arg));\n\n // Ensure unique argument names by appending an index suffix to duplicates\n tree.arguments.forEach((argument, index) => {\n const found = tree.arguments.findIndex(\n arg => arg.name === argument.name\n );\n if (\n (found !== -1 && found !== index) ||\n tree.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n tree.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n tree.arguments.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title.replace(/(?:c|C)ommands?$/, \"\").trim() || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command-line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.reflection?.getType() ??\n ((option as StringCommandOption | NumberCommandOption).variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }),\n default: option.default,\n tags: {\n ...option.reflection?.getTags(),\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n tree.arguments\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: arg.reflection.getType(),\n default: arg.default,\n tags: {\n ...arg.reflection.getTags(),\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.segments\n .slice(0, command.segments.length)\n .every((value, index) => value === command.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;;;;AA8CX,SAAY,gCAAA,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACR,QAAO,IAAI,YAAE,CAAA,eAAA,eAAA,GAAA,gBAAA,SAAA,gDAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,gDAAA,UACP,YACA,WACI,mBACD,mBAAA,GAAA,OAAA,MAAA,qDAAA,KAAA,CAAA,GAAA,SAAA,gDAAA,UACH,cACA,GAAG,SAAQ,gDAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAErB,gCAAoB,SAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYpB,SAAgB,kCAAkC,MAAM,MAAC,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACrD,QAAO,KAAK,YAAY,CAAC,eAAe,cAAc,GAAE,oCAAY,SAAA,gDAAA,UAC9D,YACR,WACY,mBACA,mBAAA,GAAA,OAAA,MAAA,qDAAA,KAAA,CAAA,GAAA,SAAA,gDAAA,UACJ,cACA,GAAG,SAAK,gDAAA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