@shell-shock/core 0.17.7 → 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 (97) hide show
  1. package/dist/api.cjs +81 -28
  2. package/dist/api.d.cts +51 -3
  3. package/dist/api.d.cts.map +1 -1
  4. package/dist/api.d.mts +51 -3
  5. package/dist/api.d.mts.map +1 -1
  6. package/dist/api.mjs +79 -26
  7. package/dist/api.mjs.map +1 -1
  8. package/dist/components/docs.cjs +1 -1
  9. package/dist/components/docs.d.cts.map +1 -1
  10. package/dist/components/docs.d.mts.map +1 -1
  11. package/dist/components/docs.mjs +1 -1
  12. package/dist/components/docs.mjs.map +1 -1
  13. package/dist/components/exec-builtin.cjs +1 -1
  14. package/dist/components/exec-builtin.mjs +1 -1
  15. package/dist/components/state-builtin.cjs +2 -2
  16. package/dist/components/state-builtin.d.cts.map +1 -1
  17. package/dist/components/state-builtin.d.mts.map +1 -1
  18. package/dist/components/state-builtin.mjs +2 -2
  19. package/dist/components/state-builtin.mjs.map +1 -1
  20. package/dist/components/utils-builtin.cjs +1 -1
  21. package/dist/components/utils-builtin.d.cts.map +1 -1
  22. package/dist/components/utils-builtin.d.mts.map +1 -1
  23. package/dist/components/utils-builtin.mjs +1 -1
  24. package/dist/components/utils-builtin.mjs.map +1 -1
  25. package/dist/contexts/options.cjs +1 -1
  26. package/dist/contexts/options.mjs +1 -1
  27. package/dist/contexts/options.mjs.map +1 -1
  28. package/dist/helpers/docs-helpers.mjs.map +1 -1
  29. package/dist/helpers/paths.cjs +7 -7
  30. package/dist/helpers/paths.mjs +7 -7
  31. package/dist/helpers/paths.mjs.map +1 -1
  32. package/dist/helpers/persistence.cjs +2 -0
  33. package/dist/helpers/persistence.mjs +2 -0
  34. package/dist/helpers/persistence.mjs.map +1 -1
  35. package/dist/helpers/update-package-json.cjs +30 -24
  36. package/dist/helpers/update-package-json.mjs +30 -24
  37. package/dist/helpers/update-package-json.mjs.map +1 -1
  38. package/dist/helpers/utilities.mjs.map +1 -1
  39. package/dist/helpers/validations.mjs.map +1 -1
  40. package/dist/index.cjs +1 -0
  41. package/dist/index.d.cts +2 -2
  42. package/dist/index.d.mts +2 -2
  43. package/dist/index.mjs +2 -2
  44. package/dist/plugin-utils/compute-bin.cjs +1 -1
  45. package/dist/plugin-utils/compute-bin.mjs +1 -1
  46. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  47. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  48. package/dist/plugin-utils/deepkit.cjs +1 -1
  49. package/dist/plugin-utils/deepkit.mjs +1 -1
  50. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  51. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  52. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  53. package/dist/plugin-utils/reflect.cjs +2 -2
  54. package/dist/plugin-utils/reflect.mjs +2 -2
  55. package/dist/plugin-utils/reflect.mjs.map +1 -1
  56. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  57. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  58. package/dist/plugin.cjs +49 -7
  59. package/dist/plugin.d.cts.map +1 -1
  60. package/dist/plugin.d.mts.map +1 -1
  61. package/dist/plugin.mjs +49 -7
  62. package/dist/plugin.mjs.map +1 -1
  63. package/dist/resolver/deepkit.cjs +1 -1
  64. package/dist/resolver/deepkit.mjs +1 -1
  65. package/dist/resolver/deepkit.mjs.map +1 -1
  66. package/dist/resolver/helpers.mjs.map +1 -1
  67. package/dist/resolver/module.cjs +1 -1
  68. package/dist/resolver/module.mjs +1 -1
  69. package/dist/resolver/module.mjs.map +1 -1
  70. package/dist/resolver/resolve.cjs +1 -1
  71. package/dist/resolver/resolve.mjs +1 -1
  72. package/dist/resolver/resolve.mjs.map +1 -1
  73. package/dist/types/command.d.cts +1 -1
  74. package/dist/types/command.d.mts +2 -2
  75. package/dist/types/command.mjs.map +1 -1
  76. package/dist/types/config.cjs +20 -30
  77. package/dist/types/config.d.cts +13 -10
  78. package/dist/types/config.d.cts.map +1 -1
  79. package/dist/types/config.d.mts +13 -10
  80. package/dist/types/config.d.mts.map +1 -1
  81. package/dist/types/config.mjs +20 -31
  82. package/dist/types/config.mjs.map +1 -1
  83. package/dist/types/context.cjs +2 -2
  84. package/dist/types/context.d.cts +3 -2
  85. package/dist/types/context.d.cts.map +1 -1
  86. package/dist/types/context.d.mts +3 -2
  87. package/dist/types/context.d.mts.map +1 -1
  88. package/dist/types/context.mjs +2 -2
  89. package/dist/types/context.mjs.map +1 -1
  90. package/dist/types/env.d.cts +1 -1
  91. package/dist/types/env.d.mts +1 -1
  92. package/dist/types/env.mjs.map +1 -1
  93. package/dist/types/index.cjs +1 -0
  94. package/dist/types/index.d.cts +2 -2
  95. package/dist/types/index.d.mts +2 -2
  96. package/dist/types/index.mjs +2 -2
  97. package/package.json +25 -24
@@ -13,7 +13,7 @@ function __assignType(fn, args) {
13
13
  */
14
14
  function sortOptions(options) {
15
15
  if (!options || options.length === 0) return [];
16
- return options.filter(__assignType((arg) => arg.kind !== CommandParameterKinds.boolean || !arg.isNegativeOf, [
16
+ return options.filter(__assignType((arg) => arg.kind !== CommandParameterKinds.boolean || arg.variadic || !arg.isNegativeOf, [
17
17
  "arg",
18
18
  "",
19
19
  "P\"2!\"/\""
@@ -25,7 +25,7 @@ function sortOptions(options) {
25
25
  ])).reduce(__assignType((ret, arg) => {
26
26
  ret.push(arg);
27
27
  if (arg.kind === CommandParameterKinds.boolean) {
28
- const negativeArg = options.find(__assignType((a) => a.kind === CommandParameterKinds.boolean && a.isNegativeOf === arg.name, [
28
+ const negativeArg = options.find(__assignType((a) => a.kind === CommandParameterKinds.boolean && !a.variadic && a.isNegativeOf === arg.name, [
29
29
  "a",
30
30
  "",
31
31
  "P\"2!\"/\""
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/plugin-utils/reflect.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 { CommandOption } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Sort command options alphabetically by name, placing boolean options with negatives appropriately.\n *\n * @param options - The array of command options to sort.\n * @returns A new array of sorted command options.\n */\nexport function sortOptions(options: CommandOption[]): CommandOption[] {\n if (!options || options.length === 0) {\n return [];\n }\n\n return options\n .filter(\n arg => arg.kind !== CommandParameterKinds.boolean || !arg.isNegativeOf\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .reduce((ret, arg) => {\n ret.push(arg);\n\n if (arg.kind === CommandParameterKinds.boolean) {\n // Add the negative argument if it exists\n const negativeArg = options.find(\n a =>\n a.kind === CommandParameterKinds.boolean &&\n a.isNegativeOf === arg.name\n );\n if (negativeArg) {\n ret.push(negativeArg);\n }\n }\n\n return ret;\n }, [] as CommandOption[]);\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AASX,SAAgB,YAAW,SAAQ;AAClC,KAAO,CAAC,WAAW,QAAO,WAAQ;gBAI1B,OAAO,cAAa,QAAO,IAAI,SAAS,sBAAqB,WAAA,CAAA,IAAA,cAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;;;KAE/D,OAAO,cAAgB,KAAK,QAAI;AAC/B,MAAC,KAAA,IAAA;;GAGD,MAAQ,cAAQ,QAAe,KAAG,cAAc,MAAO,EAAC,SAAQ,sBAAe,WACtF,EAAA,iBAAA,IAAA,MAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;AACS,OAAA,YACI,KAAI,KAAM,YAAU;;AAG3B,SAAQ;IACX;EAAA;EAAS;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/plugin-utils/reflect.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 { CommandOption } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Sort command options alphabetically by name, placing boolean options with negatives appropriately.\n *\n * @param options - The array of command options to sort.\n * @returns A new array of sorted command options.\n */\nexport function sortOptions(options: CommandOption[]): CommandOption[] {\n if (!options || options.length === 0) {\n return [];\n }\n\n return options\n .filter(\n arg =>\n arg.kind !== CommandParameterKinds.boolean ||\n arg.variadic ||\n !arg.isNegativeOf\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .reduce((ret, arg) => {\n ret.push(arg);\n\n if (arg.kind === CommandParameterKinds.boolean) {\n // Add the negative argument if it exists\n const negativeArg = options.find(\n a =>\n a.kind === CommandParameterKinds.boolean &&\n !a.variadic &&\n a.isNegativeOf === arg.name\n );\n if (negativeArg) {\n ret.push(negativeArg);\n }\n }\n\n return ret;\n }, [] as CommandOption[]);\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;;;;;;;AAST,SAAgB,YAAW,SAAQ;AAClC,KAAA,CAAA,WAAiB,QAAQ,WAAS;;;;;;;;;;;AAI/B,MAAI,KAAK,IAAI;;GAGX,MAAG,cAAA,QAAwB,KAAM,cAAS,MAAQ,EAAA,SAAA,sBAAA,WAAA,CAAA,EAAA,YAAA,EAAA,iBAAA,IAAA,MAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;mBAEtD,KAAA,KAAA,YAAA;;AAGE,SAAM;IACN;EAAA;EAAS;EAAK;EAAM;EAAU,CAAA,EAAA,EAAQ,CAAA;;AAE1C,YAAO,SAAS;CAAA;CAAqB;CAAa;CAAK;CAAgB;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-command-tree.mjs","names":[],"sources":["../../src/plugin-utils/traverse-command-tree.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 { MaybePromise } from \"@stryke/types/base\";\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Traverses a command tree and applies a visitor function to each node.\n *\n * @param commandTree - The command tree to traverse.\n * @param visitor - The visitor function to apply to each node.\n */\nexport async function traverseCommandTree(\n commandTree: CommandTree,\n visitor: (node: CommandTree) => MaybePromise<void>\n): Promise<void> {\n if (!commandTree.children) {\n return;\n }\n\n await Promise.all(\n Object.values(commandTree.children).map(async childTree => {\n await Promise.resolve(visitor(childTree));\n await traverseCommandTree(childTree, visitor);\n })\n );\n}\n\n/**\n * Traverses all commands in the context and applies a visitor function to each command tree.\n *\n * @param context - The build context containing the command definitions.\n * @param visitor - The visitor function to apply to each command tree.\n */\nexport async function traverseCommands<TContext extends Context>(\n context: TContext,\n visitor: (node: CommandTree) => MaybePromise<void>\n): Promise<void> {\n if (!context.commands) {\n return;\n }\n\n await Promise.all(\n Object.values(context.commands).map(async childTree => {\n await Promise.resolve(visitor(childTree));\n await traverseCommandTree(childTree, visitor);\n })\n );\n}\n"],"mappings":";AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AAQX,eAAsB,oBAAoB,aAAU,SAAS;AAC5D,KAAA,CAAA,YAAoB,SACb;AAEP,OAAK,QAAQ,IAAA,OAAa,OAAS,YAAA,SAAA,CAAA,IAAA,aAAA,OAAA,cAAA;;AAE5B,QAAM,oBAAoB,WAAW,QAAQ;;;;;;;AAGrD,oBAAc,SAAc;CAAA;CAAe;CAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOnD,eAAoB,iBAAY,SAAY,SAAa;AACvD,KAAA,CAAA,QAAA,SACK;AAEL,OAAQ,QAAQ,IAAA,OAAW,OAAK,QAAA,SAAiB,CAAA,IAAA,aAAA,OAAA,cAAA;AAChD,QAAQ,QAAM,QAAA,QAAA,UAAA,CAAA;AACV,QAAA,oBAAsB,WAAA,QAAA;IACzB;EAAA;EAAM;EAAA;EAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"traverse-command-tree.mjs","names":[],"sources":["../../src/plugin-utils/traverse-command-tree.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 { MaybePromise } from \"@stryke/types/base\";\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Traverses a command tree and applies a visitor function to each node.\n *\n * @param commandTree - The command tree to traverse.\n * @param visitor - The visitor function to apply to each node.\n */\nexport async function traverseCommandTree(\n commandTree: CommandTree,\n visitor: (node: CommandTree) => MaybePromise<void>\n): Promise<void> {\n if (!commandTree.children) {\n return;\n }\n\n await Promise.all(\n Object.values(commandTree.children).map(async childTree => {\n await Promise.resolve(visitor(childTree));\n await traverseCommandTree(childTree, visitor);\n })\n );\n}\n\n/**\n * Traverses all commands in the context and applies a visitor function to each command tree.\n *\n * @param context - The build context containing the command definitions.\n * @param visitor - The visitor function to apply to each command tree.\n */\nexport async function traverseCommands<TContext extends Context>(\n context: TContext,\n visitor: (node: CommandTree) => MaybePromise<void>\n): Promise<void> {\n if (!context.commands) {\n return;\n }\n\n await Promise.all(\n Object.values(context.commands).map(async childTree => {\n await Promise.resolve(visitor(childTree));\n await traverseCommandTree(childTree, visitor);\n })\n );\n}\n"],"mappings":";AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;;;;;;;AAQT,eAAsB,oBAAoB,aAAU,SAAS;AAC5D,KAAA,CAAA,YAAkB,SAClB;AAEA,OAAK,QAAQ,IAAA,OAAa,OAAO,YAAE,SAAA,CAAA,IAAA,aAAA,OAAA,cAAA;;AAEhC,QAAM,oBAAoB,WAAW,QAAQ;;;;;;;AAGjD,oBAAc,SAAc;CAAA;CAAe;CAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOnD,eAAoB,iBAAY,SAAY,SAAa;AACvD,KAAA,CAAA,QAAA,SACF;AAEE,OAAA,QAAc,IAAE,OAAA,OAAgB,QAAA,SAAiB,CAAA,IAAA,aAAA,OAAA,cAAA;AAChD,QAAO,QAAO,QAAA,QAAA,UAAA,CAAA;AACb,QAAG,oBAAsB,WAAA,QAAA;IACzB;EAAA;EAAM;EAAA;EAAA,CAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"type-checks.mjs","names":[],"sources":["../../src/plugin-utils/type-checks.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 { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameter,\n CommandParameterConfig,\n CommandParameterKind\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterKind} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.\n */\nexport function isCommandParameterKind(obj: any): obj is CommandParameterKind {\n return (\n isSetString(obj) &&\n [\n CommandParameterKinds.string,\n CommandParameterKinds.number,\n CommandParameterKinds.boolean\n ].includes(obj as CommandParameterKind)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterConfig} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.\n */\nexport function isCommandParameterConfig(\n obj: any\n): obj is CommandParameterConfig {\n return isSetObject(obj) && \"kind\" in obj && isCommandParameterKind(obj.kind);\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameter} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.\n */\nexport function isCommandParameter(obj: any): obj is CommandParameter {\n return (\n isCommandParameterConfig(obj) &&\n \"name\" in obj &&\n isSetString(obj.name) &&\n \"title\" in obj &&\n isSetString(obj.title) &&\n \"description\" in obj &&\n isSetString(obj.description) &&\n \"alias\" in obj &&\n Array.isArray(obj.alias) &&\n \"env\" in obj &&\n (isSetString(obj.env) || obj.env === false) &&\n \"optional\" in obj &&\n isBoolean(obj.optional) &&\n \"variadic\" in obj &&\n isBoolean(obj.variadic)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandOption} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandOption} type, false otherwise.\n */\nexport function isCommandOption(obj: any): obj is CommandOption {\n return (\n isCommandParameterConfig(obj) && isCommandParameter(obj) && \"default\" in obj\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandArgument} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.\n */\nexport function isCommandArgument(obj: any): obj is CommandArgument {\n return isCommandParameterConfig(obj) && isCommandParameter(obj);\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAgB,uBAAS,KAAA;AACzB,QAAS,YAAA,IAAA;EAEP,sBAAA;EACM,sBAA0B;EACjC,sBAAA;EACQ,CAAC,SAAS,IAAC;;AAEpB,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,SAAM,yBAAsB,KAAA;AACxB,QAAE,YAAgB,IAAA,IAAA,UAAA,OAAoB,uBAAA,IAAA,KAAA;;AAE1C,yBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOA,SAAE,mBAAA,KAAA;AACF,QAAO,yBAAS,IAAwB,IACjC,UAAA,OACA,YAAG,IAAA,KAAA,IACF,WAAC,OACT,YAAA,IAAA,MAAA,4BAEE,YAAA,IAAA,YAAA,IACM,WAAS,OAChB,MAAA,QAAA,IAAA,MAAA,IACG,SAAY,QACZ,YAAgB,IAAI,IAAK,IAAI,IAAE,QAAQ,UACzC,cAAA,OACK,UAAS,IAAA,SAAA,IACR,cAAC,OACL,UAAA,IAAA,SAAyB;;AAE7B,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,gBAAE,KAAA;AACd,QAAC,yBAAgC,IAAI,IAAA,mBAAQ,IAAA,IAAA,aAAA;;AAEjD,gBAAc,SAAI;CAAQ;CAAG;CAAA;CAAA;CAAA;;;;;;;AAO7B,SAAgB,kBAAkB,KAAK;AACtC,QAAA,yBAAA,IAAA,IAAA,mBAAA,IAAA;;AAED,kBAAiB,SAAO;CAAA;CAAW;CAAa;CAAoC;CAAA"}
1
+ {"version":3,"file":"type-checks.mjs","names":[],"sources":["../../src/plugin-utils/type-checks.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 { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameter,\n CommandParameterConfig,\n CommandParameterKind\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterKind} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.\n */\nexport function isCommandParameterKind(obj: any): obj is CommandParameterKind {\n return (\n isSetString(obj) &&\n [\n CommandParameterKinds.string,\n CommandParameterKinds.number,\n CommandParameterKinds.boolean\n ].includes(obj as CommandParameterKind)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterConfig} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.\n */\nexport function isCommandParameterConfig(\n obj: any\n): obj is CommandParameterConfig {\n return isSetObject(obj) && \"kind\" in obj && isCommandParameterKind(obj.kind);\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameter} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.\n */\nexport function isCommandParameter(obj: any): obj is CommandParameter {\n return (\n isCommandParameterConfig(obj) &&\n \"name\" in obj &&\n isSetString(obj.name) &&\n \"title\" in obj &&\n isSetString(obj.title) &&\n \"description\" in obj &&\n isSetString(obj.description) &&\n \"alias\" in obj &&\n Array.isArray(obj.alias) &&\n \"env\" in obj &&\n (isSetString(obj.env) || obj.env === false) &&\n \"optional\" in obj &&\n isBoolean(obj.optional) &&\n \"variadic\" in obj &&\n isBoolean(obj.variadic)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandOption} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandOption} type, false otherwise.\n */\nexport function isCommandOption(obj: any): obj is CommandOption {\n return (\n isCommandParameterConfig(obj) && isCommandParameter(obj) && \"default\" in obj\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandArgument} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.\n */\nexport function isCommandArgument(obj: any): obj is CommandArgument {\n return isCommandParameterConfig(obj) && isCommandParameter(obj);\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAgB,uBAAS,KAAA;AACzB,QAAS,YAAA,IAAA,IAAA;EAAqB,sBAAkB;EAAQ,sBAAA;EAAA,sBAAA;EAAA,CAAA,SAAA,IAAA;;AAExD,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,SAAS,yBAAA,KAAA;AACP,QAAE,YAAiB,IAAC,IAAA,UAAA,OAAA,uBAAA,IAAA,KAAA;;AAEtB,yBAAM,SAA4B;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOlC,SAAE,mBAAA,KAAA;AACA,QAAM,yBAA0B,IAAI,IAAC,UAAa,OAAA,YAAA,IAAuB,KAAK,IAAA,WAAA,OAAA,YAAA,IAAA,MAAA,IAAA,iBAAA,OAAA,YAAA,IAAA,YAAA,IAAA,WAAA,OAAA,MAAA,QAAA,IAAA,MAAA,IAAA,SAAA,QAAA,YAAA,IAAA,IAAA,IAAA,IAAA,QAAA,UAAA,cAAA,OAAA,UAAA,IAAA,SAAA,IAAA,cAAA,OAAA,UAAA,IAAA,SAAA;;AAEhF,mBAAmB,SAAS;CAAC;CAAK;CAAA;CAAA;CAAA;;;;;;;AAOlC,SAAA,gBAAA,KAAA;;;AAGA,gBAAgB,SAAS;CAAC;CAAO;CAAmB;CAAsB;CAAA;;;;;;;AAO1E,SAAI,kBAA8B,KAAC;AACjC,QAAO,yBAAU,IAAA,IAAA,mBAAA,IAAA;;AAEnB,kBAAkB,SAAE;CAAA;CAAA;CAAA;CAAA;CAAA"}
package/dist/plugin.cjs CHANGED
@@ -3,8 +3,10 @@ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_context_helpers = require('./plugin-utils/context-helpers.cjs');
4
4
  const require_components_docs = require('./components/docs.cjs');
5
5
  const require_components_exec_builtin = require('./components/exec-builtin.cjs');
6
+ const require_deepkit = require('./plugin-utils/deepkit.cjs');
6
7
  const require_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
7
8
  const require_get_command_tree = require('./plugin-utils/get-command-tree.cjs');
9
+ require('./plugin-utils/index.cjs');
8
10
  const require_components_state_builtin = require('./components/state-builtin.cjs');
9
11
  const require_components_utils_builtin = require('./components/utils-builtin.cjs');
10
12
  const require_automd = require('./helpers/automd.cjs');
@@ -16,9 +18,11 @@ const require_validations = require('./helpers/validations.cjs');
16
18
  const require_resolve = require('./resolver/resolve.cjs');
17
19
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
18
20
  let _alloy_js_core_components = require("@alloy-js/core/components");
21
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
19
22
  let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
20
23
  let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
21
24
  _powerlines_plugin_automd = require_runtime.__toESM(_powerlines_plugin_automd);
25
+ let _powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
22
26
  let _powerlines_plugin_nodejs = require("@powerlines/plugin-nodejs");
23
27
  _powerlines_plugin_nodejs = require_runtime.__toESM(_powerlines_plugin_nodejs);
24
28
  let _powerlines_plugin_tsdown = require("@powerlines/plugin-tsdown");
@@ -56,8 +60,7 @@ const plugin = __assignType((options = {}) => {
56
60
  name: "shell-shock:config",
57
61
  config: __assignType(async function config() {
58
62
  this.debug("Resolving the Shell Shock configuration.");
59
- await require_update_package_json.updatePackageJsonBinary(this);
60
- return (0, defu.defu)({ output: { path: (0, _stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
63
+ return (0, defu.defu)(options, {
61
64
  name: require_context_helpers.getAppName(this),
62
65
  title: require_context_helpers.getAppTitle(this),
63
66
  description: require_context_helpers.getAppDescription(this),
@@ -69,7 +72,7 @@ const plugin = __assignType((options = {}) => {
69
72
  format: "esm",
70
73
  dts: false
71
74
  },
72
- input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || (0, _stryke_type_checks_is_object.isObject)(this.config.input) && Object.keys(this.config.input).length === 0 ? [(0, _stryke_path_join_paths.joinPaths)(this.config.root, "src/**/command.ts"), (0, _stryke_path_join_paths.joinPaths)(this.config.root, "src/**/command.tsx")] : void 0,
75
+ input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || (0, _stryke_type_checks_is_object.isObject)(this.config.input) && Object.keys(this.config.input).length === 0 ? ["src/**/command.ts", "src/**/command.tsx"] : void 0,
73
76
  resolve: {
74
77
  external: ["@powerlines/deepkit"],
75
78
  skipNodeModulesBundle: true
@@ -85,6 +88,7 @@ const plugin = __assignType((options = {}) => {
85
88
  order: "pre",
86
89
  async handler() {
87
90
  this.debug("Shell Shock configuration has been resolved.");
91
+ await require_update_package_json.updatePackageJsonBinary(this);
88
92
  this.config.appSpecificEnvPrefix = (0, _stryke_type_checks_is_set_string.isSetString)(this.config.autoAssignEnv) ? this.config.autoAssignEnv : (0, _stryke_string_format_constant_case.constantCase)(require_context_helpers.getAppName(this));
89
93
  if (!this.config.env.prefix || !Array.isArray(this.config.env.prefix)) this.config.env.prefix = (0, _stryke_convert_to_array.toArray)(this.config.env.prefix);
90
94
  if (!this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)) this.config.env.prefix.push(this.config.appSpecificEnvPrefix);
@@ -99,7 +103,7 @@ const plugin = __assignType((options = {}) => {
99
103
  };
100
104
  else this.config.reference = { app: this.config.reference };
101
105
  this.inputs ??= [];
102
- this.options = Object.values(require_utilities.getGlobalOptions(this, {
106
+ this.globalOptions = Object.values(require_utilities.getGlobalOptions(this, {
103
107
  id: null,
104
108
  name: this.config.name,
105
109
  path: null,
@@ -109,7 +113,7 @@ const plugin = __assignType((options = {}) => {
109
113
  alias: [],
110
114
  isVirtual: false
111
115
  }));
112
- this.options = this.options.map(__assignType((option) => ({
116
+ this.globalOptions = this.globalOptions.map(__assignType((option) => ({
113
117
  ...option,
114
118
  name: (0, _stryke_string_format_camel_case.camelCase)(option.name),
115
119
  alias: option.alias ?? [],
@@ -129,7 +133,6 @@ const plugin = __assignType((options = {}) => {
129
133
  {
130
134
  name: "shell-shock:inputs",
131
135
  async configResolved() {
132
- this.debug("Finding command entry point files.");
133
136
  this.debug(`Checking for commands using input: ${JSON.stringify(this.config.input)}`);
134
137
  this.commandsPath = await require_paths.findCommandsRoot(this);
135
138
  this.debug(`Resolved commands root path: ${this.commandsPath}`);
@@ -286,6 +289,45 @@ const plugin = __assignType((options = {}) => {
286
289
  }
287
290
  }
288
291
  },
292
+ {
293
+ name: "shell-shock:update-env",
294
+ configResolved: {
295
+ order: "post",
296
+ async handler() {
297
+ this.debug("Adding global options to the CLI application's environment variables.");
298
+ for (const option of Object.values(this.globalOptions).filter(__assignType((option) => Boolean(option.env), [
299
+ "option",
300
+ "",
301
+ "P\"2!\"/\""
302
+ ])).filter(__assignType((option) => !this.env.types.env.getPropertyOrUndefined(option.env), [
303
+ "option",
304
+ "",
305
+ "P\"2!\"/\""
306
+ ]))) this.env.types.env.addProperty({
307
+ name: option.env,
308
+ optional: option.optional ? true : void 0,
309
+ description: option.description,
310
+ visibility: _powerlines_deepkit_vendor_type.ReflectionVisibility.public,
311
+ type: require_deepkit.extractType(option),
312
+ default: option.default,
313
+ tags: {
314
+ title: option.title,
315
+ alias: option.alias.filter(__assignType((alias) => alias.length > 1, [
316
+ "alias",
317
+ "",
318
+ "P\"2!\"/\""
319
+ ])).map(__assignType((alias) => (0, _stryke_string_format_constant_case.constantCase)(alias), [
320
+ "alias",
321
+ "",
322
+ "P\"2!\"/\""
323
+ ])),
324
+ domain: "cli"
325
+ }
326
+ });
327
+ await (0, _powerlines_plugin_env_helpers.writeEnvTypeReflection)(this, this.env.types.env, "env");
328
+ }
329
+ }
330
+ },
289
331
  {
290
332
  name: "shell-shock:resolve-commands",
291
333
  prepare: {
@@ -356,7 +398,7 @@ const plugin = __assignType((options = {}) => {
356
398
  this.config.tsdown.hooks ??= {};
357
399
  this.config.tsdown.hooks["build:done"] = __assignType(async (_) => {
358
400
  await Promise.all(Object.values(this.config.bin).map(__assignType(async (bin) => {
359
- const path = (0, _stryke_path_append.appendPath)(bin, (0, _stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.root));
401
+ const path = (0, _stryke_path_append.appendPath)(bin, (0, _stryke_path_join_paths.joinPaths)(this.config.cwd, this.config.root));
360
402
  if (this.fs.existsSync(path)) {
361
403
  this.debug(`Adding hashbang to binary executable output file: ${path}`);
362
404
  const content = await this.fs.read(path);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KACR,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAqFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KACR,MAAA,CAAO,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KACR,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAqFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/plugin.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import { getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, isDynamicPathSegment, isPathSegmentGroup } from "./plugin-utils/context-helpers.mjs";
2
2
  import { CommandDocsFile } from "./components/docs.mjs";
3
3
  import { ExecBuiltin } from "./components/exec-builtin.mjs";
4
+ import { extractType } from "./plugin-utils/deepkit.mjs";
4
5
  import { traverseCommands } from "./plugin-utils/traverse-command-tree.mjs";
5
6
  import { getCommandTree } from "./plugin-utils/get-command-tree.mjs";
7
+ import "./plugin-utils/index.mjs";
6
8
  import { StateBuiltin } from "./components/state-builtin.mjs";
7
9
  import { UtilsBuiltin } from "./components/utils-builtin.mjs";
8
10
  import { commands } from "./helpers/automd.mjs";
@@ -14,8 +16,10 @@ import { validateCommand } from "./helpers/validations.mjs";
14
16
  import { resolve } from "./resolver/resolve.mjs";
15
17
  import { createComponent } from "@alloy-js/core/jsx-runtime";
16
18
  import { For, Show } from "@alloy-js/core/components";
19
+ import { ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
17
20
  import { render } from "@powerlines/plugin-alloy/render";
18
21
  import automd from "@powerlines/plugin-automd";
22
+ import { writeEnvTypeReflection } from "@powerlines/plugin-env/helpers";
19
23
  import nodejs from "@powerlines/plugin-nodejs";
20
24
  import tsdown from "@powerlines/plugin-tsdown";
21
25
  import { toArray } from "@stryke/convert/to-array";
@@ -51,8 +55,7 @@ const plugin = __assignType((options = {}) => {
51
55
  name: "shell-shock:config",
52
56
  config: __assignType(async function config() {
53
57
  this.debug("Resolving the Shell Shock configuration.");
54
- await updatePackageJsonBinary(this);
55
- return defu({ output: { path: joinPaths(this.config.root, "dist") } }, options, {
58
+ return defu(options, {
56
59
  name: getAppName(this),
57
60
  title: getAppTitle(this),
58
61
  description: getAppDescription(this),
@@ -64,7 +67,7 @@ const plugin = __assignType((options = {}) => {
64
67
  format: "esm",
65
68
  dts: false
66
69
  },
67
- input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || isObject(this.config.input) && Object.keys(this.config.input).length === 0 ? [joinPaths(this.config.root, "src/**/command.ts"), joinPaths(this.config.root, "src/**/command.tsx")] : void 0,
70
+ input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || isObject(this.config.input) && Object.keys(this.config.input).length === 0 ? ["src/**/command.ts", "src/**/command.tsx"] : void 0,
68
71
  resolve: {
69
72
  external: ["@powerlines/deepkit"],
70
73
  skipNodeModulesBundle: true
@@ -80,6 +83,7 @@ const plugin = __assignType((options = {}) => {
80
83
  order: "pre",
81
84
  async handler() {
82
85
  this.debug("Shell Shock configuration has been resolved.");
86
+ await updatePackageJsonBinary(this);
83
87
  this.config.appSpecificEnvPrefix = isSetString(this.config.autoAssignEnv) ? this.config.autoAssignEnv : constantCase(getAppName(this));
84
88
  if (!this.config.env.prefix || !Array.isArray(this.config.env.prefix)) this.config.env.prefix = toArray(this.config.env.prefix);
85
89
  if (!this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)) this.config.env.prefix.push(this.config.appSpecificEnvPrefix);
@@ -94,7 +98,7 @@ const plugin = __assignType((options = {}) => {
94
98
  };
95
99
  else this.config.reference = { app: this.config.reference };
96
100
  this.inputs ??= [];
97
- this.options = Object.values(getGlobalOptions(this, {
101
+ this.globalOptions = Object.values(getGlobalOptions(this, {
98
102
  id: null,
99
103
  name: this.config.name,
100
104
  path: null,
@@ -104,7 +108,7 @@ const plugin = __assignType((options = {}) => {
104
108
  alias: [],
105
109
  isVirtual: false
106
110
  }));
107
- this.options = this.options.map(__assignType((option) => ({
111
+ this.globalOptions = this.globalOptions.map(__assignType((option) => ({
108
112
  ...option,
109
113
  name: camelCase(option.name),
110
114
  alias: option.alias ?? [],
@@ -124,7 +128,6 @@ const plugin = __assignType((options = {}) => {
124
128
  {
125
129
  name: "shell-shock:inputs",
126
130
  async configResolved() {
127
- this.debug("Finding command entry point files.");
128
131
  this.debug(`Checking for commands using input: ${JSON.stringify(this.config.input)}`);
129
132
  this.commandsPath = await findCommandsRoot(this);
130
133
  this.debug(`Resolved commands root path: ${this.commandsPath}`);
@@ -281,6 +284,45 @@ const plugin = __assignType((options = {}) => {
281
284
  }
282
285
  }
283
286
  },
287
+ {
288
+ name: "shell-shock:update-env",
289
+ configResolved: {
290
+ order: "post",
291
+ async handler() {
292
+ this.debug("Adding global options to the CLI application's environment variables.");
293
+ for (const option of Object.values(this.globalOptions).filter(__assignType((option) => Boolean(option.env), [
294
+ "option",
295
+ "",
296
+ "P\"2!\"/\""
297
+ ])).filter(__assignType((option) => !this.env.types.env.getPropertyOrUndefined(option.env), [
298
+ "option",
299
+ "",
300
+ "P\"2!\"/\""
301
+ ]))) this.env.types.env.addProperty({
302
+ name: option.env,
303
+ optional: option.optional ? true : void 0,
304
+ description: option.description,
305
+ visibility: ReflectionVisibility.public,
306
+ type: extractType(option),
307
+ default: option.default,
308
+ tags: {
309
+ title: option.title,
310
+ alias: option.alias.filter(__assignType((alias) => alias.length > 1, [
311
+ "alias",
312
+ "",
313
+ "P\"2!\"/\""
314
+ ])).map(__assignType((alias) => constantCase(alias), [
315
+ "alias",
316
+ "",
317
+ "P\"2!\"/\""
318
+ ])),
319
+ domain: "cli"
320
+ }
321
+ });
322
+ await writeEnvTypeReflection(this, this.env.types.env, "env");
323
+ }
324
+ }
325
+ },
284
326
  {
285
327
  name: "shell-shock:resolve-commands",
286
328
  prepare: {
@@ -351,7 +393,7 @@ const plugin = __assignType((options = {}) => {
351
393
  this.config.tsdown.hooks ??= {};
352
394
  this.config.tsdown.hooks["build:done"] = __assignType(async (_) => {
353
395
  await Promise.all(Object.values(this.config.bin).map(__assignType(async (bin) => {
354
- const path = appendPath(bin, joinPaths(this.workspaceConfig.workspaceRoot, this.config.root));
396
+ const path = appendPath(bin, joinPaths(this.config.cwd, this.config.root));
355
397
  if (this.fs.existsSync(path)) {
356
398
  this.debug(`Adding hashbang to binary executable output file: ${path}`);
357
399
  const content = await this.fs.read(path);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { ExecBuiltin } from \"./components/exec-builtin\";\nimport { StateBuiltin } from \"./components/state-builtin\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n): Plugin<TContext>[] => {\n return [\n tsdown<TContext>(),\n automd<TContext>(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n path: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n framework: \"shell-shock\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"],\n skipNodeModulesBundle: true\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else if (this.config.reference.includes(\"{commands}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{commands}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.inputs ??= [];\n this.options = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.debug(\n `Checking for commands using input: ${JSON.stringify(this.config.input)}`\n );\n\n this.commandsPath = await findCommandsRoot(this);\n this.debug(`Resolved commands root path: ${this.commandsPath}`);\n\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: false,\n source: \"file\",\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <StateBuiltin />\n <UtilsBuiltin />\n <ExecBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${\n command.name\n } \\n\\nPlease ensure ${\n command.entry.file\n } is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: true,\n entry: {\n file\n },\n source: \"file\"\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}${command.isVirtual ? \" (virtual)\" : \"\"}: ${\n command.source === \"file\"\n ? replacePath(command.entry.file, this.commandsPath)\n : `added by ${command.source}`\n }`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEE,IAAG,SAAS;;;AAsDd,MAAM,YAAC;;;;AAIP,MAAS,SAAA,cAAmB,UAAkB,EAAC,KAAM;AACrD,QAAS;GAAA,OAAA,IAAA,CAAA,CAAe,WAAW,OAAA,CAAO,EAAC,QAAA;GAAY,OAAA,IAAA,CAAA,CAAA,WAAA,OAAA,CAAA,EAAA,QAAA;EAAA;GACvD,MAAO;GACL,QAAA,aAAiB,eAAA,SAAA;AACjB,SAAA,MAAU,2CAAA;AACV,UAAA,wBAAW,KAAA;AA4BP,WA3BJ,KAAA,EACA,QAAA,EACA,MAAA,UAAA,KAAA,OAAA,MAAA,OAAA,EACO,EACF,EAAE,SAAA;KACD,MAAC,WAAgB,KAAG;KACpB,OAAC,YAAkB,KAAA;KACpB,aAAO,kBAAe,KAAc;KACpC,UAAO;KACP,aAAc;;KAEf,iBAAc;;MAElB,QAAA;MACK,KAAK;MACV;KACK,OAAM,CAAA,KAAQ,OAAE,SAAS,MAAQ,QAAU,KAAA,OAAQ,MAAA,IAAA,KAAA,OAAA,MAAA,WAAA,KAAA,SAAA,KAAA,OAAA,MAAA,IAAA,OAAA,KAAA,KAAA,OAAA,MAAA,CAAA,WAAA,IAAA,CAAA,UAAA,KAAA,OAAA,MAAA,oBAAA,EAAA,UAAA,KAAA,OAAA,MAAA,qBAAA,CAAA,GAAA;KACxD,SAAS;MACD,UAAU,CAAC,sBAAI;MAChB,uBAAA;MACL;KACA,QAAO;MACP,KAAA;MACM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,cAAA,EAAA;;KAEF;MACA,CAAC,kBAAM,QAAA,CAAA;GACV,MAAM,OAAC;AACL,SAAK,MAAE,oEAAc;IACrB,MAAM,WAAC,KAAc,OAAA,IAAA,cAAA,UAAA,eAAA,MAAA,MAAA,SAAA,EAAA;KAAA;KAAA;KAAA;KAAA,CAAA,CAAA,CAAA,OAAA,QAAA;AACrB,WAAO,OAAA,MAAa,gBAAA,KAAA;KAClB,IAAI,OAAA;AACH,aAAA,OAAA,OAAA,SAAA;;KAEJ,gBAAA;KACD,IAAA,WAAA;AACM,aAAG,cAAY,UAAc,gBAAC,MAAA;OAClC,IAAA,OAAgB;AACR,eAAO,CAAA,MAAA;;OAET,IAAE,WAAY;AACd,eAAS,gBAAA,iBAAA,EACN,SAAG,OACL,CAAA;;OAEF,CAAC,EAAA;OAAA;OAAU;OAAA;OAAA,CAAA;;KAEf,CAAC,CAAC;;GAEN;EAAC;GACD;CAAC;CAAW;QAAa,EAAO;CAAG;CAAE;CAAA,CAAA"}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.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 { For, Show } from \"@alloy-js/core/components\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport { writeEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { ExecBuiltin } from \"./components/exec-builtin\";\nimport { StateBuiltin } from \"./components/state-builtin\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport { extractType } from \"./plugin-utils\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n): Plugin<TContext>[] => {\n return [\n tsdown<TContext>(),\n automd<TContext>(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n const result = defu(options, {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n framework: \"shell-shock\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\"src/**/command.ts\", \"src/**/command.tsx\"]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"],\n skipNodeModulesBundle: true\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n });\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n await updatePackageJsonBinary(this);\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else if (this.config.reference.includes(\"{commands}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{commands}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.inputs ??= [];\n this.globalOptions = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n\n this.globalOptions = this.globalOptions.map(option => ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }));\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\n `Checking for commands using input: ${JSON.stringify(this.config.input)}`\n );\n\n this.commandsPath = await findCommandsRoot(this);\n this.debug(`Resolved commands root path: ${this.commandsPath}`);\n\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: false,\n source: \"file\",\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <StateBuiltin />\n <UtilsBuiltin />\n <ExecBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${\n command.name\n } \\n\\nPlease ensure ${\n command.entry.file\n } is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: true,\n entry: {\n file\n },\n source: \"file\"\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}${command.isVirtual ? \" (virtual)\" : \"\"}: ${\n command.source === \"file\"\n ? replacePath(command.entry.file, this.commandsPath)\n : `added by ${command.source}`\n }`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:update-env\",\n configResolved: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Adding global options to the CLI application's environment variables.\"\n );\n\n for (const option of Object.values(this.globalOptions)\n .filter(option => Boolean(option.env))\n .filter(\n option =>\n !this.env.types.env.getPropertyOrUndefined(option.env as string)\n )) {\n this.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: extractType(option),\n default: option.default,\n tags: {\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 await writeEnvTypeReflection(this, this.env.types.env, \"env\");\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {};\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.config.cwd, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEE,IAAG,SAAS;;;AAyDd,MAAE,YAAgB;;;;AAIlB,MAAS,SAAA,cAA0B,UAAQ,EAAA,KAAA;AAC3C,QAAS;GAAA,OAAA,IAAa,CAAC,CAAA,WAAQ,OAAO,CAAA,EAAM,QAAA;GAAA,OAAA,IAAA,CAAA,CAAA,WAAA,OAAA,CAAA,EAAA,QAAA;EAAA;GAC5C,MAAO;GACL,QAAA,aAAiB,eAAA,SAAA;AACjB,SAAA,MAAU,2CAAA;AAwBR,WAvBS,KAAA,SAAA;KACX,MAAA,WAAA,KAAyB;KACzB,OAAA,YAAoB,KAAA;KACpB,aAAA,kBAAA,KAAA;KACM,UAAS;KACT,aAAC;KACD,WAAC;KACD,iBAAiB;KAClB,QAAO;MACP,QAAO;MACP,KAAO;;KAER,OAAS,CAAC,KAAI,OAAA,SAAA,MAAA,QAAA,KAAA,OAAA,MAAA,IAAA,KAA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}
@@ -1,8 +1,8 @@
1
1
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  const require_types_command = require('../types/command.cjs');
3
3
  const require_helpers = require('./helpers.cjs');
4
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
4
  let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
5
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
6
6
  let _stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
7
7
  let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
8
8
  let _stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
@@ -1,7 +1,7 @@
1
1
  import { CommandParameterKinds } from "../types/command.mjs";
2
2
  import { mergeCommandParameter } from "./helpers.mjs";
3
- import { isSetObject } from "@stryke/type-checks/is-set-object";
4
3
  import { ReflectionClass, ReflectionFunction, ReflectionKind, reflect, stringifyType } from "@powerlines/deepkit/vendor/type";
4
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
5
5
  import { isBigInt } from "@stryke/type-checks/is-bigint";
6
6
  import { isNumber } from "@stryke/type-checks/is-number";
7
7
  import { isRegExp } from "@stryke/type-checks/is-regexp";
@@ -1 +1 @@
1
- {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.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 {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\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 ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue() || reflection.parameter.default\n };\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 StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AASX,SAAC,4BAAkC,MAAK;CACvC,MAAS,SAAS,EAAE,YAAY,KAAE,IAAA,UAAiB;;AAEnD,KAAK,SAAQ,eAAa;4CAIpB,SAAK,eAAA,UACV,CAAA,UACA,KAAA,SAAkB,eAAA,YACd,SAAA,KAAA,QAAA,IAAA,SAAA,KAAA,QAAA,EACJ,QAAA,sBAAA;UAEK,SAAA,eAAA,QACL,QAAO,sBAAA;KAGP,QAAA,sBAAc;;AAGhB,4BAA2B,SAAO;CAAI;CAAQ;CAAU;CAAA;CAAA;AACxD,SAAS,qBAAkB,KAAO,YAAY;CAC9C,MAAS,OAAQ,WAAU,SAAO;CAClC,MAAS,WAAa,IAAC,OAAO,QAAW,WAAW,iBAAW,KACxD,EAAA;CACL,MAAA,SAAe;EACf,MAAA,WAAa,iBAAA;EACb,OAAA,WAAoB,SAAA,CAAA,SAAA,EAAA;EACpB,OAAO,WAAA,SAAA,CAAA,OAAA,MAAA;EACP,aAAA,WAAsB,gBAAA;EACtB,MAAA,4BAAA,KAAA;EACM,UAAS,WAAA,YAAA;EACT,SAAC,WAAA,iBAAiC;EAClC,UAAC,WAAA,SAA6B;EACtC;qBAEQ,QAAC,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,SAAC,eAAA,WACX,KAAA,SAAgB,eAAA,UACX,KAAK,SAAE,eAAoB,OAC3B,OAAA,IAAU,MAAC,6CAAA,SAAA,KAAA,gBAAA,IAAA,MAAA,QAAA,KAAA,4FAAA,cAAA,KAAA,CACX,MAAW,CACZ,WAAQ,OAAgB,QAAA,CAAA,GAAA;AAE7B,QAAM,sBAAW,UAAA,UAAA,EACX,MAAE,MAAU,SAChB,CAAA;;AAEJ,uBAAsB,SAAU;CAAC;CAAc;CAAU;CAAW;CAAA;CAAA;CAAA;CAAA;AACpE,SAAgB,oBAAY,KAAU;CAClC,MAAA,EAAQ,OAAE,WAAW;CACrB,MAAA,OAAS,QAAW,OAAA;AACrB,KAAA,KAAA,SAAA,eAAA;CAGC,MAAG,aAAA,IAAA,mBAAA,KAAA;AACH,KAAE,OAAS,gBAAU,IAAA,MAAe,QAAQ,eAC1C,WAAU,gBAAS,IACnB,KAAA;CACF,MAAG,aAAY,WAAA,eAAyB;AACxC,KAAI,WAAI,SAAA,GAAA;EACL,MAAA,aAAY,WAAA,OACX,WAAA,GAAA,KAAA,SAAiC,eAAe,iBAC7C,WAAA,GAAA,KAAA,SAAA,eAAA;AACL,MAAM,YAAS;GACZ,MAAA,oBAA2B,gBAAW,KAAY,WAAS,IAAM,KAAI;AACpE,QAAI,MAAM,sBAAQ,kBAAA,eAAA,CACZ,KAAC,OAAU,QAAQ,mBAAmB,iBAAW,IACvD,qBAAA,KAAA,mBAAA;;AAGF,MAAG,OAAA,QAAgB,aAAY,WAAA,MAAA,EAAA,GAAA,YAAA,IAAA,cAAA,KAAA,UAAA,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGvC,oBAAkB,SAAS;CAAA;CAAsB;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.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 {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\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 ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue() || reflection.parameter.default\n };\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 StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;AAST,SAAC,4BAAkC,MAAK;CACvC,MAAO,SAAS,EAAE,YAAQ,KAAQ,IAAA,UAAc;;AAEhD,KAAK,SAAQ,eAAa;UAEd,SAAS,eAAe,UAAU,SAAS,eAAc,UAAA,CAAA,UAAA,KAAA,SAAA,eAAA,YAAA,SAAA,KAAA,QAAA,IAAA,SAAA,KAAA,QAAA;UAE1D,SAAA,eAAA,QACV,QAAA,sBAAmB;KAEnB,QAAI,sBAAA;;AAGN,4BAAO,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACP,SAAS,qBAAA,KAAA,YAAA;CACP,MAAA,OAAA,WA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