@shell-shock/core 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/components/docs.cjs +4 -4
  2. package/dist/components/docs.cjs.map +1 -1
  3. package/dist/components/docs.d.cts +5 -5
  4. package/dist/components/docs.d.cts.map +1 -1
  5. package/dist/components/docs.d.mts +5 -5
  6. package/dist/components/docs.d.mts.map +1 -1
  7. package/dist/components/helpers.cjs +9 -0
  8. package/dist/components/helpers.cjs.map +1 -1
  9. package/dist/components/helpers.d.cts +15 -7
  10. package/dist/components/helpers.d.cts.map +1 -1
  11. package/dist/components/helpers.d.mts +15 -7
  12. package/dist/components/helpers.d.mts.map +1 -1
  13. package/dist/components/helpers.mjs +9 -1
  14. package/dist/components/helpers.mjs.map +1 -1
  15. package/dist/components/index.cjs +1 -0
  16. package/dist/components/index.d.cts +2 -2
  17. package/dist/components/index.d.mts +2 -2
  18. package/dist/components/index.mjs +2 -2
  19. package/dist/components/options-parser-logic.cjs +167 -87
  20. package/dist/components/options-parser-logic.cjs.map +1 -1
  21. package/dist/components/options-parser-logic.d.cts +15 -15
  22. package/dist/components/options-parser-logic.d.cts.map +1 -1
  23. package/dist/components/options-parser-logic.d.mts +15 -15
  24. package/dist/components/options-parser-logic.d.mts.map +1 -1
  25. package/dist/components/options-parser-logic.mjs +163 -83
  26. package/dist/components/options-parser-logic.mjs.map +1 -1
  27. package/dist/components/usage.cjs +5 -5
  28. package/dist/components/usage.cjs.map +1 -1
  29. package/dist/components/usage.d.cts +2 -2
  30. package/dist/components/usage.d.cts.map +1 -1
  31. package/dist/components/usage.d.mts +2 -2
  32. package/dist/components/usage.mjs +4 -4
  33. package/dist/components/usage.mjs.map +1 -1
  34. package/dist/components/utils-builtin.cjs +2 -2
  35. package/dist/components/utils-builtin.cjs.map +1 -1
  36. package/dist/components/utils-builtin.d.cts +9 -9
  37. package/dist/components/utils-builtin.d.cts.map +1 -1
  38. package/dist/components/utils-builtin.d.mts +9 -9
  39. package/dist/components/utils-builtin.d.mts.map +1 -1
  40. package/dist/components/utils-builtin.mjs +5 -5
  41. package/dist/components/utils-builtin.mjs.map +1 -1
  42. package/dist/contexts/options.cjs +2 -2
  43. package/dist/contexts/options.cjs.map +1 -1
  44. package/dist/contexts/options.d.cts +1 -1
  45. package/dist/contexts/options.d.cts.map +1 -1
  46. package/dist/contexts/options.d.mts +1 -1
  47. package/dist/contexts/options.d.mts.map +1 -1
  48. package/dist/contexts/options.mjs +4 -4
  49. package/dist/contexts/options.mjs.map +1 -1
  50. package/dist/helpers/automd.cjs +2 -2
  51. package/dist/helpers/automd.cjs.map +1 -1
  52. package/dist/helpers/automd.mjs.map +1 -1
  53. package/dist/helpers/paths.cjs +125 -0
  54. package/dist/helpers/paths.cjs.map +1 -0
  55. package/dist/helpers/paths.mjs +121 -0
  56. package/dist/helpers/paths.mjs.map +1 -0
  57. package/dist/helpers/persistence.cjs +68 -116
  58. package/dist/helpers/persistence.cjs.map +1 -1
  59. package/dist/helpers/persistence.mjs +68 -116
  60. package/dist/helpers/persistence.mjs.map +1 -1
  61. package/dist/helpers/update-package-json.cjs +4 -4
  62. package/dist/helpers/update-package-json.cjs.map +1 -1
  63. package/dist/helpers/utilities.cjs +1 -1
  64. package/dist/helpers/utilities.mjs +1 -1
  65. package/dist/helpers/validations.cjs +2 -3
  66. package/dist/helpers/validations.cjs.map +1 -1
  67. package/dist/helpers/validations.mjs +2 -2
  68. package/dist/helpers/validations.mjs.map +1 -1
  69. package/dist/index.cjs +14 -11
  70. package/dist/index.d.cts +2 -2
  71. package/dist/index.d.mts +2 -2
  72. package/dist/index.mjs +3 -3
  73. package/dist/plugin-utils/deepkit.cjs +72 -0
  74. package/dist/plugin-utils/deepkit.cjs.map +1 -0
  75. package/dist/plugin-utils/deepkit.d.cts +24 -0
  76. package/dist/plugin-utils/deepkit.d.cts.map +1 -0
  77. package/dist/plugin-utils/deepkit.d.mts +24 -0
  78. package/dist/plugin-utils/deepkit.d.mts.map +1 -0
  79. package/dist/plugin-utils/deepkit.mjs +70 -0
  80. package/dist/plugin-utils/deepkit.mjs.map +1 -0
  81. package/dist/plugin-utils/description-helpers.cjs +105 -0
  82. package/dist/plugin-utils/description-helpers.cjs.map +1 -0
  83. package/dist/plugin-utils/description-helpers.d.cts +44 -0
  84. package/dist/plugin-utils/description-helpers.d.cts.map +1 -0
  85. package/dist/plugin-utils/description-helpers.d.mts +44 -0
  86. package/dist/plugin-utils/description-helpers.d.mts.map +1 -0
  87. package/dist/plugin-utils/description-helpers.mjs +101 -0
  88. package/dist/plugin-utils/description-helpers.mjs.map +1 -0
  89. package/dist/plugin-utils/get-command-tree.cjs +2 -2
  90. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  91. package/dist/plugin-utils/index.cjs +32 -18
  92. package/dist/plugin-utils/index.d.cts +4 -1
  93. package/dist/plugin-utils/index.d.mts +4 -1
  94. package/dist/plugin-utils/index.mjs +4 -1
  95. package/dist/plugin-utils/reflect.cjs +4 -5
  96. package/dist/plugin-utils/reflect.cjs.map +1 -1
  97. package/dist/plugin-utils/reflect.mjs +4 -4
  98. package/dist/plugin-utils/reflect.mjs.map +1 -1
  99. package/dist/plugin-utils/type-checks.cjs +89 -0
  100. package/dist/plugin-utils/type-checks.cjs.map +1 -0
  101. package/dist/plugin-utils/type-checks.d.cts +42 -0
  102. package/dist/plugin-utils/type-checks.d.cts.map +1 -0
  103. package/dist/plugin-utils/type-checks.d.mts +42 -0
  104. package/dist/plugin-utils/type-checks.d.mts.map +1 -0
  105. package/dist/plugin-utils/type-checks.mjs +84 -0
  106. package/dist/plugin-utils/type-checks.mjs.map +1 -0
  107. package/dist/plugin.cjs +31 -29
  108. package/dist/plugin.cjs.map +1 -1
  109. package/dist/plugin.d.cts.map +1 -1
  110. package/dist/plugin.d.mts.map +1 -1
  111. package/dist/plugin.mjs +15 -13
  112. package/dist/plugin.mjs.map +1 -1
  113. package/dist/resolver/deepkit.cjs +132 -0
  114. package/dist/resolver/deepkit.cjs.map +1 -0
  115. package/dist/resolver/deepkit.mjs +131 -0
  116. package/dist/resolver/deepkit.mjs.map +1 -0
  117. package/dist/resolver/helpers.cjs +167 -0
  118. package/dist/resolver/helpers.cjs.map +1 -0
  119. package/dist/resolver/helpers.mjs +162 -0
  120. package/dist/resolver/helpers.mjs.map +1 -0
  121. package/dist/resolver/module.cjs +144 -0
  122. package/dist/resolver/module.cjs.map +1 -0
  123. package/dist/resolver/module.mjs +143 -0
  124. package/dist/resolver/module.mjs.map +1 -0
  125. package/dist/resolver/resolve.cjs +209 -0
  126. package/dist/resolver/resolve.cjs.map +1 -0
  127. package/dist/resolver/resolve.mjs +208 -0
  128. package/dist/resolver/resolve.mjs.map +1 -0
  129. package/dist/types/command.cjs +127 -104
  130. package/dist/types/command.cjs.map +1 -1
  131. package/dist/types/command.d.cts +39 -78
  132. package/dist/types/command.d.cts.map +1 -1
  133. package/dist/types/command.d.mts +39 -78
  134. package/dist/types/command.d.mts.map +1 -1
  135. package/dist/types/command.mjs +115 -95
  136. package/dist/types/command.mjs.map +1 -1
  137. package/dist/types/config.cjs +5 -3
  138. package/dist/types/config.cjs.map +1 -1
  139. package/dist/types/config.d.cts +7 -3
  140. package/dist/types/config.d.cts.map +1 -1
  141. package/dist/types/config.d.mts +7 -3
  142. package/dist/types/config.d.mts.map +1 -1
  143. package/dist/types/config.mjs +5 -3
  144. package/dist/types/config.mjs.map +1 -1
  145. package/dist/types/context.cjs +1 -1
  146. package/dist/types/context.cjs.map +1 -1
  147. package/dist/types/context.d.cts +2 -2
  148. package/dist/types/context.d.cts.map +1 -1
  149. package/dist/types/context.d.mts +2 -2
  150. package/dist/types/context.d.mts.map +1 -1
  151. package/dist/types/context.mjs +1 -1
  152. package/dist/types/context.mjs.map +1 -1
  153. package/dist/types/index.cjs +13 -10
  154. package/dist/types/index.d.cts +2 -2
  155. package/dist/types/index.d.mts +2 -2
  156. package/dist/types/index.mjs +2 -2
  157. package/package.json +24 -75
  158. package/dist/helpers/resolve-command.cjs +0 -430
  159. package/dist/helpers/resolve-command.cjs.map +0 -1
  160. package/dist/helpers/resolve-command.mjs +0 -425
  161. package/dist/helpers/resolve-command.mjs.map +0 -1
@@ -0,0 +1,167 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
3
+ const require_types_command = require('../types/command.cjs');
4
+ let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
5
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
6
+ let defu = require("defu");
7
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
8
+ let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
9
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
10
+
11
+ //#region src/resolver/helpers.ts
12
+ function __assignType(fn, args) {
13
+ fn.__type = args;
14
+ return fn;
15
+ }
16
+ /**
17
+ * Resolves the description for a command option based on its reflection.
18
+ *
19
+ * @param name - The name of the command option.
20
+ * @param kind - The reflection kind of the command option.
21
+ * @param optional - Whether the command option is optional.
22
+ * @param variadic - Whether the command option is variadic (i.e., an array).
23
+ * @param title - The title of the command option, if any.
24
+ * @param defaultValue - The default value of the command option, if any.
25
+ * @returns The resolved description for the command option.
26
+ */
27
+ function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
28
+ return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === require_types_command.CommandParameterKinds.boolean ? "flag" : "option"} that allows the user to ${kind === require_types_command.CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === require_types_command.CommandParameterKinds.boolean ? "indicator" : `${kind === require_types_command.CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
29
+ }
30
+ resolveCommandOptionDescription.__type = [
31
+ "name",
32
+ "CommandParameterKind",
33
+ "kind",
34
+ "optional",
35
+ "variadic",
36
+ "title",
37
+ "defaultValue",
38
+ "resolveCommandOptionDescription",
39
+ "P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
40
+ ];
41
+ /**
42
+ * Resolves the description for a command argument based on its reflection.
43
+ *
44
+ * @param name - The name of the command argument.
45
+ * @param kind - The reflection kind of the command argument.
46
+ * @param optional - Whether the command argument is optional.
47
+ * @param variadic - Whether the command argument is variadic (i.e., an array).
48
+ * @param title - The title of the command argument, if any.
49
+ * @param defaultValue - The default value of the command argument, if any.
50
+ * @returns The resolved description for the command argument.
51
+ */
52
+ function resolveCommandArgumentDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
53
+ return `An${optional && !defaultValue ? " optional" : ""} argument that allows the user to ${kind === require_types_command.CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === require_types_command.CommandParameterKinds.boolean ? "indicator" : `${kind === require_types_command.CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
54
+ }
55
+ resolveCommandArgumentDescription.__type = [
56
+ "name",
57
+ "CommandParameterKind",
58
+ "kind",
59
+ "optional",
60
+ "variadic",
61
+ "title",
62
+ "defaultValue",
63
+ "resolveCommandArgumentDescription",
64
+ "P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
65
+ ];
66
+ function applyOptionsDefaults(ctx) {
67
+ return Object.fromEntries(Object.entries(ctx.output.options).map(__assignType(([key, option]) => {
68
+ const name = option.name || key;
69
+ const title = option.title || (0, __stryke_string_format_title_case.titleCase)(name);
70
+ return [key, {
71
+ ...option,
72
+ name,
73
+ title,
74
+ description: option.description || resolveCommandOptionDescription(name, option.kind, option.optional, option.kind !== require_types_command.CommandParameterKinds.boolean && option.variadic, title, option.default),
75
+ env: option.env || option.env === false ? option.env : ctx.input.context.config.autoAssignEnv ? (0, __stryke_string_format_constant_case.constantCase)(name) : false
76
+ }];
77
+ }, [
78
+ "param0",
79
+ "",
80
+ "P\"2!\"/\""
81
+ ])));
82
+ }
83
+ applyOptionsDefaults.__type = [
84
+ "ResolverContext",
85
+ "ctx",
86
+ "applyOptionsDefaults",
87
+ "P\"w!2\"\"/#"
88
+ ];
89
+ function applyArgsDefaults(ctx) {
90
+ return ctx.output.args.map(__assignType((arg, i) => {
91
+ const name = arg.name || `arg${i + 1}`;
92
+ const title = arg.title || (0, __stryke_string_format_title_case.titleCase)(name);
93
+ return {
94
+ ...arg,
95
+ name,
96
+ title,
97
+ description: arg.description || resolveCommandArgumentDescription(name, arg.kind, arg.optional, arg.kind !== require_types_command.CommandParameterKinds.boolean && arg.variadic, title, arg.default),
98
+ env: arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? (0, __stryke_string_format_constant_case.constantCase)(name) : false : false
99
+ };
100
+ }, [
101
+ "arg",
102
+ "i",
103
+ "",
104
+ "P\"2!\"2\"\"/#"
105
+ ]));
106
+ }
107
+ applyArgsDefaults.__type = [
108
+ "ResolverContext",
109
+ "ctx",
110
+ "CommandArgument",
111
+ "applyArgsDefaults",
112
+ "P\"w!2\"\"w#F/$"
113
+ ];
114
+ function applyDefaults(ctx) {
115
+ ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
116
+ }
117
+ applyDefaults.__type = [
118
+ "ResolverContext",
119
+ "ctx",
120
+ "applyDefaults",
121
+ "P\"w!2\"\"/#"
122
+ ];
123
+ function resolveVirtualCommand(ctx) {
124
+ ctx.output.title ??= (0, __stryke_string_format_title_case.titleCase)(ctx.input.command.name);
125
+ ctx.output.description ??= `A collection of available ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim() || (0, __stryke_string_format_title_case.titleCase)(ctx.input.command.name)} commands that are included in the ${require_context_helpers.getAppTitle(ctx.input.context)} command-line application.`;
126
+ }
127
+ resolveVirtualCommand.__type = [
128
+ "ResolverContext",
129
+ "ctx",
130
+ "resolveVirtualCommand",
131
+ "P\"w!2\"\"/#"
132
+ ];
133
+ /**
134
+ * Merges two command parameters, giving precedence to string values in the second configuration.
135
+ *
136
+ * @param objA - The first command parameter object.
137
+ * @param objB - The second command parameter object.
138
+ * @returns The merged command parameter object.
139
+ */
140
+ const mergeCommandParameter = (0, defu.createDefu)(__assignType((obj, key, value) => {
141
+ if ((0, __stryke_type_checks_is_string.isString)(obj[key]) && (0, __stryke_type_checks_is_string.isString)(value)) {
142
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(value)) obj[key] = value;
143
+ return true;
144
+ } else if (Array.isArray(obj[key]) && Array.isArray(value)) {
145
+ if (value.length > 0) obj[key] = (0, __stryke_helpers_get_unique.getUniqueBy)(obj[key].concat(value), __assignType((item) => (0, __stryke_type_checks_is_string.isString)(item) ? item : JSON.stringify(item), [
146
+ "item",
147
+ "",
148
+ "P\"2!\"/\""
149
+ ]));
150
+ return true;
151
+ }
152
+ return false;
153
+ }, [
154
+ "obj",
155
+ "key",
156
+ "value",
157
+ "",
158
+ "P\"2!\"2\"\"2#\"/$"
159
+ ]));
160
+
161
+ //#endregion
162
+ exports.applyArgsDefaults = applyArgsDefaults;
163
+ exports.applyDefaults = applyDefaults;
164
+ exports.applyOptionsDefaults = applyOptionsDefaults;
165
+ exports.mergeCommandParameter = mergeCommandParameter;
166
+ exports.resolveVirtualCommand = resolveVirtualCommand;
167
+ //# sourceMappingURL=helpers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs","names":[],"sources":["../../src/resolver/helpers.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 { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type { CommandArgument, CommandParameterKind } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport type { ResolverContext } from \"./types\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === CommandParameterKinds.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function applyOptionsDefaults(ctx: ResolverContext) {\n return Object.fromEntries(\n Object.entries(ctx.output.options).map(([key, option]) => {\n const name = option.name || key;\n const title = option.title || titleCase(name);\n\n return [\n key,\n {\n ...option,\n name,\n title,\n description:\n option.description ||\n resolveCommandOptionDescription(\n name,\n option.kind,\n option.optional,\n option.kind !== CommandParameterKinds.boolean && option.variadic,\n title,\n option.default\n ),\n env:\n option.env || option.env === false\n ? option.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(ctx: ResolverContext): CommandArgument[] {\n return ctx.output.args.map((arg, i) => {\n const name = arg.name || `arg${i + 1}`;\n const title = arg.title || titleCase(name);\n\n return {\n ...arg,\n name,\n title,\n description:\n arg.description ||\n resolveCommandArgumentDescription(\n name,\n arg.kind,\n arg.optional,\n arg.kind !== CommandParameterKinds.boolean && arg.variadic,\n title,\n arg.default\n ),\n env: arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n : false\n };\n });\n}\n\nexport function applyDefaults(ctx: ResolverContext) {\n ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n}\n\nexport function resolveVirtualCommand<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n ctx.output.title ??= titleCase(ctx.input.command.name);\n ctx.output.description ??= `A collection of available ${\n ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim() ||\n titleCase(ctx.input.command.name)\n } commands that are included in the ${getAppTitle(\n ctx.input.context\n )} command-line application.`;\n}\n\n/**\n * Merges two command parameters, giving precedence to string values in the second configuration.\n *\n * @param objA - The first command parameter object.\n * @param objB - The second command parameter object.\n * @returns The merged command parameter object.\n */\nexport const mergeCommandParameter = createDefu((obj, key, value) => {\n if (isString(obj[key]) && isString(value)) {\n if (isSetString(value)) {\n obj[key] = value;\n }\n\n return true;\n } else if (Array.isArray(obj[key]) && Array.isArray(value)) {\n if (value.length > 0) {\n obj[key] = getUniqueBy((obj[key] as unknown[]).concat(value), item =>\n isString(item) ? item : JSON.stringify(item)\n ) as (typeof obj)[typeof key];\n }\n\n return true;\n }\n\n return false;\n});\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;;;;AAsCX,SAAE,gCAAA,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACE,QAAO,IAAI,YAAY,CAAC,eAAe,eAAI,GAAA,gBAAA,SAAA,4CAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,4CAAA,UACrC,YACA,WACI,mBACA,mBAAI,GAAA,OAAA,MAAA,qDAAA,KAAA,CAAA,GAAA,SAAA,4CAAA,UACR,cACA,GAAG,SAAM,4CAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAEnB,gCAAgC,SAAS;CAAC;CAAQ;CAAwB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAY1E,SAAgB,kCAAY,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACxB,QAAK,KAAA,YAAA,CAAA,eAAA,cAAA,GAAA,oCAAA,SAAA,4CAAA,UACJ,YACL,8BAEE,mBAAA,GAAA,OAAA,MAAA,qDAAA,KAA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AA;CAAA;CAAA;CAAA;AACf,SAAgB,cAAK,KAAA;AACjB,KAAI,OAAO,gBAAgB,OAAC,IAAA,OAAA,MAAA,QAAA,oBAAA,GAAA,CAAA,MAAA,CAAA;;AAEhC,cAAc,SAAI;CAAA;CAAA;CAAA;CAAA;CAAA;AAClB,SAAgB,sBAAS,KAAA;AACrB,KAAI,OAAO,2DAAc,IAAA,MAAA,QAAA,KAAA;AACzB,KAAI,OAAO,gBAAgB,6BAA6B,IAAI,OAAO,MAAM,QAAC,oBAAA,GAAA,CAAA,MAAA,qDAC5D,IAAC,MAAA,QAAA,KAAA,CAAA,qCAAA,oCAAA,IAAA,MAAA,QAAA,CAAA;;AAEnB,sBAAa,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQb,MAAO,6CAAA,cAAA,KAAA,KAAA,UAAA;AACH,kDAAC,IAAA,KAAA,iDAAA,MAAA,EAAA;AACF,0DAAA,MAAA,CACH,KAAA,OAAA;AAEQ,SAAO;YAEF,MAAM,QAAQ,IAAI,KAAK,IAAI,MAAE,QAAA,MAAA,EAAA;AAClC,MAAI,MAAM,SAAS;;;;;AAGnB,SAAI;;AAER,QAAO;GACR;CAAC;CAAO;CAAM;CAAA;CAAA;CAAA,CAAA,CAAA"}
@@ -0,0 +1,162 @@
1
+ import { getAppTitle } from "../plugin-utils/context-helpers.mjs";
2
+ import { CommandParameterKinds } from "../types/command.mjs";
3
+ import { constantCase } from "@stryke/string-format/constant-case";
4
+ import { isSetString } from "@stryke/type-checks/is-set-string";
5
+ import { createDefu } from "defu";
6
+ import { titleCase } from "@stryke/string-format/title-case";
7
+ import { getUniqueBy } from "@stryke/helpers/get-unique";
8
+ import { isString } from "@stryke/type-checks/is-string";
9
+
10
+ //#region src/resolver/helpers.ts
11
+ function __assignType(fn, args) {
12
+ fn.__type = args;
13
+ return fn;
14
+ }
15
+ /**
16
+ * Resolves the description for a command option based on its reflection.
17
+ *
18
+ * @param name - The name of the command option.
19
+ * @param kind - The reflection kind of the command option.
20
+ * @param optional - Whether the command option is optional.
21
+ * @param variadic - Whether the command option is variadic (i.e., an array).
22
+ * @param title - The title of the command option, if any.
23
+ * @param defaultValue - The default value of the command option, if any.
24
+ * @returns The resolved description for the command option.
25
+ */
26
+ function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
27
+ return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === CommandParameterKinds.boolean ? "flag" : "option"} that allows the user to ${kind === CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || titleCase(name)} ${kind === CommandParameterKinds.boolean ? "indicator" : `${kind === CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
28
+ }
29
+ resolveCommandOptionDescription.__type = [
30
+ "name",
31
+ "CommandParameterKind",
32
+ "kind",
33
+ "optional",
34
+ "variadic",
35
+ "title",
36
+ "defaultValue",
37
+ "resolveCommandOptionDescription",
38
+ "P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
39
+ ];
40
+ /**
41
+ * Resolves the description for a command argument based on its reflection.
42
+ *
43
+ * @param name - The name of the command argument.
44
+ * @param kind - The reflection kind of the command argument.
45
+ * @param optional - Whether the command argument is optional.
46
+ * @param variadic - Whether the command argument is variadic (i.e., an array).
47
+ * @param title - The title of the command argument, if any.
48
+ * @param defaultValue - The default value of the command argument, if any.
49
+ * @returns The resolved description for the command argument.
50
+ */
51
+ function resolveCommandArgumentDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
52
+ return `An${optional && !defaultValue ? " optional" : ""} argument that allows the user to ${kind === CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || titleCase(name)} ${kind === CommandParameterKinds.boolean ? "indicator" : `${kind === CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
53
+ }
54
+ resolveCommandArgumentDescription.__type = [
55
+ "name",
56
+ "CommandParameterKind",
57
+ "kind",
58
+ "optional",
59
+ "variadic",
60
+ "title",
61
+ "defaultValue",
62
+ "resolveCommandArgumentDescription",
63
+ "P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
64
+ ];
65
+ function applyOptionsDefaults(ctx) {
66
+ return Object.fromEntries(Object.entries(ctx.output.options).map(__assignType(([key, option]) => {
67
+ const name = option.name || key;
68
+ const title = option.title || titleCase(name);
69
+ return [key, {
70
+ ...option,
71
+ name,
72
+ title,
73
+ description: option.description || resolveCommandOptionDescription(name, option.kind, option.optional, option.kind !== CommandParameterKinds.boolean && option.variadic, title, option.default),
74
+ env: option.env || option.env === false ? option.env : ctx.input.context.config.autoAssignEnv ? constantCase(name) : false
75
+ }];
76
+ }, [
77
+ "param0",
78
+ "",
79
+ "P\"2!\"/\""
80
+ ])));
81
+ }
82
+ applyOptionsDefaults.__type = [
83
+ "ResolverContext",
84
+ "ctx",
85
+ "applyOptionsDefaults",
86
+ "P\"w!2\"\"/#"
87
+ ];
88
+ function applyArgsDefaults(ctx) {
89
+ return ctx.output.args.map(__assignType((arg, i) => {
90
+ const name = arg.name || `arg${i + 1}`;
91
+ const title = arg.title || titleCase(name);
92
+ return {
93
+ ...arg,
94
+ name,
95
+ title,
96
+ description: arg.description || resolveCommandArgumentDescription(name, arg.kind, arg.optional, arg.kind !== CommandParameterKinds.boolean && arg.variadic, title, arg.default),
97
+ env: arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? constantCase(name) : false : false
98
+ };
99
+ }, [
100
+ "arg",
101
+ "i",
102
+ "",
103
+ "P\"2!\"2\"\"/#"
104
+ ]));
105
+ }
106
+ applyArgsDefaults.__type = [
107
+ "ResolverContext",
108
+ "ctx",
109
+ "CommandArgument",
110
+ "applyArgsDefaults",
111
+ "P\"w!2\"\"w#F/$"
112
+ ];
113
+ function applyDefaults(ctx) {
114
+ ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
115
+ }
116
+ applyDefaults.__type = [
117
+ "ResolverContext",
118
+ "ctx",
119
+ "applyDefaults",
120
+ "P\"w!2\"\"/#"
121
+ ];
122
+ function resolveVirtualCommand(ctx) {
123
+ ctx.output.title ??= titleCase(ctx.input.command.name);
124
+ ctx.output.description ??= `A collection of available ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim() || titleCase(ctx.input.command.name)} commands that are included in the ${getAppTitle(ctx.input.context)} command-line application.`;
125
+ }
126
+ resolveVirtualCommand.__type = [
127
+ "ResolverContext",
128
+ "ctx",
129
+ "resolveVirtualCommand",
130
+ "P\"w!2\"\"/#"
131
+ ];
132
+ /**
133
+ * Merges two command parameters, giving precedence to string values in the second configuration.
134
+ *
135
+ * @param objA - The first command parameter object.
136
+ * @param objB - The second command parameter object.
137
+ * @returns The merged command parameter object.
138
+ */
139
+ const mergeCommandParameter = createDefu(__assignType((obj, key, value) => {
140
+ if (isString(obj[key]) && isString(value)) {
141
+ if (isSetString(value)) obj[key] = value;
142
+ return true;
143
+ } else if (Array.isArray(obj[key]) && Array.isArray(value)) {
144
+ if (value.length > 0) obj[key] = getUniqueBy(obj[key].concat(value), __assignType((item) => isString(item) ? item : JSON.stringify(item), [
145
+ "item",
146
+ "",
147
+ "P\"2!\"/\""
148
+ ]));
149
+ return true;
150
+ }
151
+ return false;
152
+ }, [
153
+ "obj",
154
+ "key",
155
+ "value",
156
+ "",
157
+ "P\"2!\"2\"\"2#\"/$"
158
+ ]));
159
+
160
+ //#endregion
161
+ export { applyArgsDefaults, applyDefaults, applyOptionsDefaults, mergeCommandParameter, resolveVirtualCommand };
162
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/resolver/helpers.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 { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type { CommandArgument, CommandParameterKind } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport type { ResolverContext } from \"./types\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === CommandParameterKinds.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function applyOptionsDefaults(ctx: ResolverContext) {\n return Object.fromEntries(\n Object.entries(ctx.output.options).map(([key, option]) => {\n const name = option.name || key;\n const title = option.title || titleCase(name);\n\n return [\n key,\n {\n ...option,\n name,\n title,\n description:\n option.description ||\n resolveCommandOptionDescription(\n name,\n option.kind,\n option.optional,\n option.kind !== CommandParameterKinds.boolean && option.variadic,\n title,\n option.default\n ),\n env:\n option.env || option.env === false\n ? option.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(ctx: ResolverContext): CommandArgument[] {\n return ctx.output.args.map((arg, i) => {\n const name = arg.name || `arg${i + 1}`;\n const title = arg.title || titleCase(name);\n\n return {\n ...arg,\n name,\n title,\n description:\n arg.description ||\n resolveCommandArgumentDescription(\n name,\n arg.kind,\n arg.optional,\n arg.kind !== CommandParameterKinds.boolean && arg.variadic,\n title,\n arg.default\n ),\n env: arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n : false\n };\n });\n}\n\nexport function applyDefaults(ctx: ResolverContext) {\n ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n}\n\nexport function resolveVirtualCommand<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n ctx.output.title ??= titleCase(ctx.input.command.name);\n ctx.output.description ??= `A collection of available ${\n ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim() ||\n titleCase(ctx.input.command.name)\n } commands that are included in the ${getAppTitle(\n ctx.input.context\n )} command-line application.`;\n}\n\n/**\n * Merges two command parameters, giving precedence to string values in the second configuration.\n *\n * @param objA - The first command parameter object.\n * @param objB - The second command parameter object.\n * @returns The merged command parameter object.\n */\nexport const mergeCommandParameter = createDefu((obj, key, value) => {\n if (isString(obj[key]) && isString(value)) {\n if (isSetString(value)) {\n obj[key] = value;\n }\n\n return true;\n } else if (Array.isArray(obj[key]) && Array.isArray(value)) {\n if (value.length > 0) {\n obj[key] = getUniqueBy((obj[key] as unknown[]).concat(value), item =>\n isString(item) ? item : JSON.stringify(item)\n ) as (typeof obj)[typeof key];\n }\n\n return true;\n }\n\n return false;\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;;;;AAsCX,SAAE,gCAAA,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACE,QAAO,IAAI,YAAY,CAAC,eAAe,eAAI,GAAA,gBAAA,SAAA,sBAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,sBAAA,UACrC,YACA,WACI,mBACA,mBAAI,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UACR,cACA,GAAG,SAAM,sBAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAEnB,gCAAgC,SAAS;CAAC;CAAQ;CAAwB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAY1E,SAAgB,kCAAY,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACxB,QAAK,KAAA,YAAA,CAAA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Q,OAAO,qCAElC,QACF;GACH;IACD;EAAC;EAAO;EAAI;EAAA;EAAA,CAAA,CAAA;;AAEnB,kBAAe,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACf,SAAgB,cAAK,KAAA;AACjB,KAAI,OAAO,gBAAgB,OAAC,IAAA,OAAA,MAAA,QAAA,oBAAA,GAAA,CAAA,MAAA,CAAA;;AAEhC,cAAc,SAAI;CAAA;CAAA;CAAA;CAAA;CAAA;AAClB,SAAgB,sBAAS,KAAA;AACrB,KAAI,OAAO,UAAU,UAAI,IAAA,MAAA,QAAA,KAAA;AACzB,KAAI,OAAO,gBAAgB,6BAA6B,IAAI,OAAO,MAAM,QAAC,oBAAA,GAAA,CAAA,MAAA,IACtE,UAAU,IAAC,MAAA,QAAA,KAAA,CAAA,qCAAA,YAAA,IAAA,MAAA,QAAA,CAAA;;AAEnB,sBAAa,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQb,MAAO,wBAAA,WAAA,cAAA,KAAA,KAAA,UAAA;AACH,KAAC,SAAA,IAAA,KAAA,IAAA,SAAA,MAAA,EAAA;AACF,MAAA,YAAA,MAAA,CACH,KAAA,OAAA;AAEQ,SAAO;YAEF,MAAM,QAAQ,IAAI,KAAK,IAAI,MAAE,QAAA,MAAA,EAAA;AAClC,MAAI,MAAM,SAAS;;;;;AAGnB,SAAI;;AAER,QAAO;GACR;CAAC;CAAO;CAAM;CAAA;CAAA;CAAA,CAAA,CAAA"}
@@ -0,0 +1,144 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_types_command = require('../types/command.cjs');
3
+ const require_type_checks = require('../plugin-utils/type-checks.cjs');
4
+ require('../plugin-utils/index.cjs');
5
+ let __stryke_convert_to_array = require("@stryke/convert/to-array");
6
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
7
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
8
+ let __stryke_json = require("@stryke/json");
9
+ let __stryke_zod = require("@stryke/zod");
10
+
11
+ //#region src/resolver/module.ts
12
+ const __ΩPartial = [
13
+ "T",
14
+ "Partial",
15
+ "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
16
+ ];
17
+ function __assignType(fn, args) {
18
+ fn.__type = args;
19
+ return fn;
20
+ }
21
+ function resolveCommandOption(name, parent, schema) {
22
+ const result = {
23
+ name,
24
+ kind: (0, __stryke_json.isJsonSchema7ArrayType)(schema) && schema.items ? (0, __stryke_json.isJsonSchema7NumberType)(schema.items) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string : (0, __stryke_json.isJsonSchema7BooleanType)(schema) ? require_types_command.CommandParameterKinds.boolean : (0, __stryke_json.isJsonSchema7NumberType)(schema) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string,
25
+ title: schema.title,
26
+ description: schema.description,
27
+ alias: (0, __stryke_convert_to_array.toArray)(schema.alias || []),
28
+ env: schema.env,
29
+ optional: !parent.required?.includes(name),
30
+ default: schema.default
31
+ };
32
+ if (result.kind === require_types_command.CommandParameterKinds.string || result.kind === require_types_command.CommandParameterKinds.number) {
33
+ result.variadic = (0, __stryke_json.isJsonSchema7ArrayType)(schema);
34
+ if (result.kind === require_types_command.CommandParameterKinds.string) result.format = schema.format;
35
+ if (((0, __stryke_json.isJsonSchema7StringType)(schema) || (0, __stryke_json.isJsonSchema7NumberType)(schema)) && schema.enum) result.choices = schema.enum;
36
+ } else if (result.kind === require_types_command.CommandParameterKinds.boolean) {
37
+ result.skipAddingNegative = schema.skipAddingNegative;
38
+ result.isNegativeOf = schema.isNegativeOf;
39
+ }
40
+ return result;
41
+ }
42
+ resolveCommandOption.__type = [
43
+ "name",
44
+ "parent",
45
+ "schema",
46
+ () => __ΩPartial,
47
+ "CommandOption",
48
+ "resolveCommandOption",
49
+ "P&2!!2\"!2#\"w%o$\"/&"
50
+ ];
51
+ function resolveCommandArgument(schema) {
52
+ const result = {
53
+ name: schema.name,
54
+ kind: (0, __stryke_json.isJsonSchema7ArrayType)(schema) && schema.items ? (0, __stryke_json.isJsonSchema7NumberType)(schema.items) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string : (0, __stryke_json.isJsonSchema7BooleanType)(schema) ? require_types_command.CommandParameterKinds.boolean : (0, __stryke_json.isJsonSchema7NumberType)(schema) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string,
55
+ title: schema.title,
56
+ description: schema.description,
57
+ alias: (0, __stryke_convert_to_array.toArray)(schema.alias || []),
58
+ env: schema.env,
59
+ default: schema.default
60
+ };
61
+ if (result.kind === require_types_command.CommandParameterKinds.string || result.kind === require_types_command.CommandParameterKinds.number) {
62
+ result.variadic = (0, __stryke_json.isJsonSchema7ArrayType)(schema);
63
+ if (result.kind === require_types_command.CommandParameterKinds.string) result.format = schema.format;
64
+ if (((0, __stryke_json.isJsonSchema7StringType)(schema) || (0, __stryke_json.isJsonSchema7NumberType)(schema)) && schema.enum) result.choices = schema.enum;
65
+ }
66
+ return result;
67
+ }
68
+ resolveCommandArgument.__type = [
69
+ "schema",
70
+ () => __ΩPartial,
71
+ "CommandArgument",
72
+ "resolveCommandArgument",
73
+ "P!2!\"w#o\"\"/$"
74
+ ];
75
+ async function resolveFromExports(ctx) {
76
+ validateExports(ctx);
77
+ const metadata = ctx.module?.metadata ?? {};
78
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(metadata.title)) ctx.output.title = metadata.title;
79
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(metadata.description)) ctx.output.description = metadata.description;
80
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(metadata.alias) || Array.isArray(metadata.alias) && metadata.alias.length > 0) ctx.output.alias = (0, __stryke_convert_to_array.toArray)(metadata.alias);
81
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(metadata.icon)) ctx.output.icon = metadata.icon;
82
+ if ((0, __stryke_type_checks_is_set_object.isSetObject)(ctx.module?.options)) if ((0, __stryke_zod.isZod3Type)(ctx.module.options) || (0, __stryke_json.isStandardJsonSchema)(ctx.module.options) || (0, __stryke_json.isJsonSchema7ObjectType)(ctx.module.options)) {
83
+ let jsonSchema;
84
+ if ((0, __stryke_zod.isZod3Type)(ctx.module.options)) jsonSchema = (0, __stryke_zod.extractJsonSchema7)(ctx.module.options);
85
+ else if ((0, __stryke_json.isStandardJsonSchema)(ctx.module.options)) jsonSchema = ctx.module.options["~standard"].jsonSchema.input({ target: "draft-07" });
86
+ else jsonSchema = ctx.module.options;
87
+ if (!(0, __stryke_json.isJsonSchema7ObjectType)(jsonSchema)) throw new TypeError(`Command options for command at path "${ctx.input.command.path}" must be defined as a Zod object schema, a standard JSON Schema object, or a JSON Schema object.`);
88
+ ctx.output.options = Object.fromEntries(Object.entries(jsonSchema.properties).map(__assignType(([name, property]) => [name, resolveCommandOption(name, jsonSchema, property)], [
89
+ "param0",
90
+ "",
91
+ "P\"2!\"/\""
92
+ ])));
93
+ } else if (Object.values(ctx.module.options).every(require_type_checks.isCommandParameterConfig)) ctx.output.options = Object.fromEntries(Object.entries(ctx.module.options).map(__assignType(([name, option]) => [name, {
94
+ name,
95
+ ...option,
96
+ alias: (0, __stryke_convert_to_array.toArray)(option.alias)
97
+ }], [
98
+ "param0",
99
+ "",
100
+ "P\"2!\"/\""
101
+ ])));
102
+ else throw new TypeError(`Command options for command at path "${ctx.input.command.path}" must be defined as a record of valid CommandOption objects, a Zod object schema, or a standard JSON Schema object.`);
103
+ if ((0, __stryke_type_checks_is_set_object.isSetObject)(ctx.module?.args)) if ((0, __stryke_zod.isZod3Type)(ctx.module.args) || (0, __stryke_json.isStandardJsonSchema)(ctx.module.args) || (0, __stryke_json.isJsonSchema7TupleType)(ctx.module.args)) {
104
+ let jsonSchema;
105
+ if ((0, __stryke_zod.isZod3Type)(ctx.module.args)) jsonSchema = (0, __stryke_zod.extractJsonSchema7)(ctx.module.args);
106
+ else if ((0, __stryke_json.isStandardJsonSchema)(ctx.module.args)) jsonSchema = ctx.module.args["~standard"].jsonSchema.input({ target: "draft-07" });
107
+ else jsonSchema = ctx.module.args;
108
+ if (!(0, __stryke_json.isJsonSchema7TupleType)(jsonSchema)) throw new TypeError(`Command arguments for command at path "${ctx.input.command.path}" must be defined as a Zod tuple schema, a standard JSON Schema tuple object, or a JSON Schema tuple object.`);
109
+ ctx.output.args = jsonSchema.items.map(__assignType((item) => resolveCommandArgument(item), [
110
+ "item",
111
+ "",
112
+ "P\"2!\"/\""
113
+ ]));
114
+ } else if (Object.values(ctx.module.args).every(require_type_checks.isCommandParameterConfig)) ctx.output.args = ctx.module.args.map(__assignType((arg) => ({
115
+ ...arg,
116
+ alias: (0, __stryke_convert_to_array.toArray)(arg.alias)
117
+ }), [
118
+ "arg",
119
+ "",
120
+ "P\"2!\"/\""
121
+ ]));
122
+ else throw new TypeError(`Command arguments for command at path "${ctx.input.command.path}" must be defined as a record of valid CommandArgument objects, a Zod tuple schema, or a standard JSON Schema tuple object.`);
123
+ }
124
+ resolveFromExports.__type = [
125
+ "ResolverContext",
126
+ "ctx",
127
+ "resolveFromExports",
128
+ "P\"w!2\"\"/#"
129
+ ];
130
+ function validateExports(ctx) {
131
+ if (!ctx.module) throw new Error(`Command module at path "${ctx.input.command.path}" is undefined or null. Please ensure the module exports a valid command.`);
132
+ else if (!(0, __stryke_type_checks_is_set_object.isSetObject)(ctx.module)) throw new TypeError(`Command module at path "${ctx.input.command.path}" is not an object. Please ensure the module exports a valid command.`);
133
+ else if (!("default" in ctx.module)) throw new Error(`Command module at path "${ctx.input.command.path}" does not appear to be valid. Please ensure the module's default export is a valid command handler function.`);
134
+ }
135
+ validateExports.__type = [
136
+ "ResolverContext",
137
+ "ctx",
138
+ "validateExports",
139
+ "P\"w!2\"\"/#"
140
+ ];
141
+
142
+ //#endregion
143
+ exports.resolveFromExports = resolveFromExports;
144
+ //# sourceMappingURL=module.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.cjs","names":[],"sources":["../../src/resolver/module.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 { toArray } from \"@stryke/convert/to-array\";\nimport type {\n JsonSchema7EnumType,\n JsonSchema7ObjectType,\n JsonSchema7Type\n} from \"@stryke/json\";\nimport {\n isJsonSchema7ArrayType,\n isJsonSchema7BooleanType,\n isJsonSchema7NumberType,\n isJsonSchema7ObjectType,\n isJsonSchema7StringType,\n isJsonSchema7TupleType,\n isStandardJsonSchema\n} from \"@stryke/json\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { extractJsonSchema7, isZod3Type } from \"@stryke/zod\";\nimport { isCommandParameterConfig } from \"../plugin-utils\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterConfig,\n Context,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport type { ResolverContext } from \"./types\";\n\nfunction resolveCommandOption(\n name: string,\n parent: JsonSchema7ObjectType,\n schema: JsonSchema7Type\n): Partial<CommandOption> {\n const result = {\n name,\n kind:\n isJsonSchema7ArrayType(schema) && schema.items\n ? isJsonSchema7NumberType(schema.items)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string\n : isJsonSchema7BooleanType(schema)\n ? CommandParameterKinds.boolean\n : isJsonSchema7NumberType(schema)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string,\n title: schema.title,\n description: schema.description,\n alias: toArray((schema as { alias?: string | string[] }).alias || []),\n env: (schema as { env?: string }).env,\n optional: !parent.required?.includes(name),\n default: schema.default\n } as Partial<CommandOption>;\n if (\n result.kind === CommandParameterKinds.string ||\n result.kind === CommandParameterKinds.number\n ) {\n result.variadic = isJsonSchema7ArrayType(schema);\n if (result.kind === CommandParameterKinds.string) {\n result.format = (\n schema as { format?: StringCommandParameter[\"format\"] }\n ).format;\n }\n\n if (\n (isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) &&\n (schema as JsonSchema7EnumType).enum\n ) {\n result.choices = (schema as JsonSchema7EnumType).enum;\n }\n } else if (result.kind === CommandParameterKinds.boolean) {\n result.skipAddingNegative = (\n schema as { skipAddingNegative?: boolean }\n ).skipAddingNegative;\n result.isNegativeOf = (schema as { isNegativeOf?: string }).isNegativeOf;\n }\n\n return result;\n}\n\nfunction resolveCommandArgument(\n schema: JsonSchema7Type\n): Partial<CommandArgument> {\n const result = {\n name: (schema as { name?: string }).name,\n kind:\n isJsonSchema7ArrayType(schema) && schema.items\n ? isJsonSchema7NumberType(schema.items)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string\n : isJsonSchema7BooleanType(schema)\n ? CommandParameterKinds.boolean\n : isJsonSchema7NumberType(schema)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string,\n title: schema.title,\n description: schema.description,\n alias: toArray((schema as { alias?: string | string[] }).alias || []),\n env: (schema as { env?: string }).env,\n default: schema.default\n } as Partial<CommandArgument>;\n if (\n result.kind === CommandParameterKinds.string ||\n result.kind === CommandParameterKinds.number\n ) {\n result.variadic = isJsonSchema7ArrayType(schema);\n if (result.kind === CommandParameterKinds.string) {\n result.format = (\n schema as { format?: StringCommandParameter[\"format\"] }\n ).format;\n }\n\n if (\n (isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) &&\n (schema as JsonSchema7EnumType).enum\n ) {\n result.choices = (schema as JsonSchema7EnumType).enum;\n }\n }\n\n return result;\n}\n\nexport async function resolveFromExports<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n validateExports(ctx);\n\n const metadata = ctx.module?.metadata ?? {};\n if (isSetString(metadata.title)) {\n ctx.output.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n ctx.output.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n ctx.output.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n ctx.output.icon = metadata.icon;\n }\n\n if (isSetObject(ctx.module?.options)) {\n if (\n isZod3Type(ctx.module.options) ||\n isStandardJsonSchema(ctx.module.options) ||\n isJsonSchema7ObjectType(ctx.module.options)\n ) {\n let jsonSchema: JsonSchema7Type;\n if (isZod3Type(ctx.module.options)) {\n jsonSchema = extractJsonSchema7(ctx.module.options);\n } else if (isStandardJsonSchema(ctx.module.options)) {\n jsonSchema = ctx.module.options[\"~standard\"].jsonSchema.input({\n target: \"draft-07\"\n });\n } else {\n jsonSchema = ctx.module.options as JsonSchema7ObjectType;\n }\n\n if (!isJsonSchema7ObjectType(jsonSchema)) {\n throw new TypeError(\n `Command options for command at path \"${\n ctx.input.command.path\n }\" must be defined as a Zod object schema, a standard JSON Schema object, or a JSON Schema object.`\n );\n }\n\n ctx.output.options = Object.fromEntries(\n Object.entries((jsonSchema as JsonSchema7ObjectType).properties).map(\n ([name, property]) => [\n name,\n resolveCommandOption(name, jsonSchema, property)\n ]\n )\n ) as Record<string, CommandOption>;\n } else if (\n Object.values(ctx.module.options).every(isCommandParameterConfig)\n ) {\n ctx.output.options = Object.fromEntries(\n Object.entries(\n ctx.module.options as Record<string, CommandParameterConfig>\n ).map(([name, option]) => [\n name,\n { name, ...option, alias: toArray(option.alias) }\n ])\n ) as Record<string, CommandOption>;\n } else {\n throw new TypeError(\n `Command options for command at path \"${\n ctx.input.command.path\n }\" must be defined as a record of valid CommandOption objects, a Zod object schema, or a standard JSON Schema object.`\n );\n }\n }\n\n if (isSetObject(ctx.module?.args)) {\n if (\n isZod3Type(ctx.module.args) ||\n isStandardJsonSchema(ctx.module.args) ||\n isJsonSchema7TupleType(ctx.module.args)\n ) {\n let jsonSchema: JsonSchema7Type;\n if (isZod3Type(ctx.module.args)) {\n jsonSchema = extractJsonSchema7(ctx.module.args);\n } else if (isStandardJsonSchema(ctx.module.args)) {\n jsonSchema = ctx.module.args[\"~standard\"].jsonSchema.input({\n target: \"draft-07\"\n });\n } else {\n jsonSchema = ctx.module.args;\n }\n\n if (!isJsonSchema7TupleType(jsonSchema)) {\n throw new TypeError(\n `Command arguments for command at path \"${\n ctx.input.command.path\n }\" must be defined as a Zod tuple schema, a standard JSON Schema tuple object, or a JSON Schema tuple object.`\n );\n }\n\n ctx.output.args = jsonSchema.items.map(item =>\n resolveCommandArgument(item)\n ) as CommandArgument[];\n } else if (Object.values(ctx.module.args).every(isCommandParameterConfig)) {\n ctx.output.args = ctx.module.args.map(arg => ({\n ...arg,\n alias: toArray(arg.alias)\n })) as CommandArgument[];\n } else {\n throw new TypeError(\n `Command arguments for command at path \"${\n ctx.input.command.path\n }\" must be defined as a record of valid CommandArgument objects, a Zod tuple schema, or a standard JSON Schema tuple object.`\n );\n }\n }\n}\n\nfunction validateExports<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n if (!ctx.module) {\n throw new Error(\n `Command module at path \"${\n ctx.input.command.path\n }\" is undefined or null. Please ensure the module exports a valid command.`\n );\n } else if (!isSetObject(ctx.module)) {\n throw new TypeError(\n `Command module at path \"${\n ctx.input.command.path\n }\" is not an object. Please ensure the module exports a valid command.`\n );\n } else if (!(\"default\" in ctx.module)) {\n throw new Error(\n `Command module at path \"${\n ctx.input.command.path\n }\" does not appear to be valid. Please ensure the module's default export is a valid command handler function.`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;AAE3D,IAAG,SAAS;;;AA2BhB,SAAS,qBAAgB,MAAA,QAAA,QAAA;CACrB,MAAM,SAAS;EACX;EACA,gDAAa,OAAA,IAAA,OAA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