@shell-shock/core 0.12.2 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
  2. package/dist/_virtual/_rolldown/runtime.mjs +3 -0
  3. package/dist/api.cjs +3 -2
  4. package/dist/api.cjs.map +1 -1
  5. package/dist/api.d.cts +0 -1
  6. package/dist/api.d.cts.map +1 -1
  7. package/dist/api.d.mts +0 -1
  8. package/dist/api.d.mts.map +1 -1
  9. package/dist/api.mjs +1 -1
  10. package/dist/api.mjs.map +1 -1
  11. package/dist/components/command-validation-logic.cjs +54 -53
  12. package/dist/components/command-validation-logic.cjs.map +1 -1
  13. package/dist/components/command-validation-logic.d.cts +2 -3
  14. package/dist/components/command-validation-logic.d.cts.map +1 -1
  15. package/dist/components/command-validation-logic.d.mts +2 -3
  16. package/dist/components/command-validation-logic.d.mts.map +1 -1
  17. package/dist/components/command-validation-logic.mjs +1 -1
  18. package/dist/components/command-validation-logic.mjs.map +1 -1
  19. package/dist/components/docs.cjs +45 -44
  20. package/dist/components/docs.cjs.map +1 -1
  21. package/dist/components/docs.d.cts +5 -5
  22. package/dist/components/docs.d.cts.map +1 -1
  23. package/dist/components/docs.d.mts +5 -5
  24. package/dist/components/docs.d.mts.map +1 -1
  25. package/dist/components/docs.mjs.map +1 -1
  26. package/dist/components/helpers.cjs +16 -15
  27. package/dist/components/helpers.cjs.map +1 -1
  28. package/dist/components/helpers.d.cts +7 -8
  29. package/dist/components/helpers.d.cts.map +1 -1
  30. package/dist/components/helpers.d.mts +7 -8
  31. package/dist/components/helpers.d.mts.map +1 -1
  32. package/dist/components/helpers.mjs.map +1 -1
  33. package/dist/components/index.cjs +1 -0
  34. package/dist/components/options-parser-logic.cjs +187 -186
  35. package/dist/components/options-parser-logic.cjs.map +1 -1
  36. package/dist/components/options-parser-logic.d.cts +9 -9
  37. package/dist/components/options-parser-logic.d.cts.map +1 -1
  38. package/dist/components/options-parser-logic.d.mts +9 -9
  39. package/dist/components/options-parser-logic.d.mts.map +1 -1
  40. package/dist/components/options-parser-logic.mjs.map +1 -1
  41. package/dist/components/usage.cjs +21 -20
  42. package/dist/components/usage.cjs.map +1 -1
  43. package/dist/components/usage.d.cts +2 -2
  44. package/dist/components/usage.d.cts.map +1 -1
  45. package/dist/components/usage.d.mts.map +1 -1
  46. package/dist/components/usage.mjs.map +1 -1
  47. package/dist/components/utils-builtin.cjs +128 -127
  48. package/dist/components/utils-builtin.cjs.map +1 -1
  49. package/dist/components/utils-builtin.d.cts.map +1 -1
  50. package/dist/components/utils-builtin.d.mts.map +1 -1
  51. package/dist/components/utils-builtin.mjs +4 -4
  52. package/dist/components/utils-builtin.mjs.map +1 -1
  53. package/dist/config.cjs +1 -0
  54. package/dist/config.cjs.map +1 -1
  55. package/dist/config.d.cts +0 -1
  56. package/dist/config.d.cts.map +1 -1
  57. package/dist/config.d.mts +0 -1
  58. package/dist/config.d.mts.map +1 -1
  59. package/dist/config.mjs.map +1 -1
  60. package/dist/contexts/command.cjs +5 -4
  61. package/dist/contexts/command.cjs.map +1 -1
  62. package/dist/contexts/command.d.cts +0 -1
  63. package/dist/contexts/command.d.cts.map +1 -1
  64. package/dist/contexts/command.d.mts +0 -1
  65. package/dist/contexts/command.d.mts.map +1 -1
  66. package/dist/contexts/index.cjs +1 -0
  67. package/dist/contexts/options.cjs +12 -11
  68. package/dist/contexts/options.cjs.map +1 -1
  69. package/dist/contexts/options.d.cts +0 -1
  70. package/dist/contexts/options.d.cts.map +1 -1
  71. package/dist/contexts/options.d.mts +0 -1
  72. package/dist/contexts/options.d.mts.map +1 -1
  73. package/dist/contexts/options.mjs +3 -3
  74. package/dist/contexts/options.mjs.map +1 -1
  75. package/dist/helpers/automd.cjs +16 -16
  76. package/dist/helpers/automd.cjs.map +1 -1
  77. package/dist/helpers/automd.mjs.map +1 -1
  78. package/dist/helpers/docs-helpers.cjs +3 -3
  79. package/dist/helpers/docs-helpers.cjs.map +1 -1
  80. package/dist/helpers/docs-helpers.mjs.map +1 -1
  81. package/dist/helpers/paths.cjs +26 -26
  82. package/dist/helpers/paths.cjs.map +1 -1
  83. package/dist/helpers/paths.mjs +1 -1
  84. package/dist/helpers/paths.mjs.map +1 -1
  85. package/dist/helpers/persistence.cjs +3 -3
  86. package/dist/helpers/persistence.cjs.map +1 -1
  87. package/dist/helpers/persistence.mjs.map +1 -1
  88. package/dist/helpers/update-package-json.cjs +16 -16
  89. package/dist/helpers/update-package-json.cjs.map +1 -1
  90. package/dist/helpers/update-package-json.mjs.map +1 -1
  91. package/dist/helpers/utilities.cjs +9 -9
  92. package/dist/helpers/utilities.cjs.map +1 -1
  93. package/dist/helpers/utilities.mjs.map +1 -1
  94. package/dist/helpers/validations.cjs.map +1 -1
  95. package/dist/helpers/validations.mjs.map +1 -1
  96. package/dist/index.cjs +1 -1
  97. package/dist/index.d.cts +0 -1
  98. package/dist/index.d.mts +0 -1
  99. package/dist/plugin-utils/context-helpers.cjs +10 -10
  100. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  101. package/dist/plugin-utils/context-helpers.d.cts +0 -3
  102. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  103. package/dist/plugin-utils/context-helpers.d.mts +0 -3
  104. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  105. package/dist/plugin-utils/context-helpers.mjs +1 -1
  106. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  107. package/dist/plugin-utils/deepkit.cjs +18 -18
  108. package/dist/plugin-utils/deepkit.cjs.map +1 -1
  109. package/dist/plugin-utils/deepkit.d.cts +0 -1
  110. package/dist/plugin-utils/deepkit.d.cts.map +1 -1
  111. package/dist/plugin-utils/deepkit.d.mts +0 -1
  112. package/dist/plugin-utils/deepkit.d.mts.map +1 -1
  113. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  114. package/dist/plugin-utils/description-helpers.cjs.map +1 -1
  115. package/dist/plugin-utils/description-helpers.d.cts.map +1 -1
  116. package/dist/plugin-utils/description-helpers.d.mts.map +1 -1
  117. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  118. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  119. package/dist/plugin-utils/get-command-tree.d.cts +0 -1
  120. package/dist/plugin-utils/get-command-tree.d.cts.map +1 -1
  121. package/dist/plugin-utils/get-command-tree.d.mts +0 -1
  122. package/dist/plugin-utils/get-command-tree.d.mts.map +1 -1
  123. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  124. package/dist/plugin-utils/index.cjs +1 -0
  125. package/dist/plugin-utils/reflect.cjs.map +1 -1
  126. package/dist/plugin-utils/reflect.d.cts +0 -1
  127. package/dist/plugin-utils/reflect.d.cts.map +1 -1
  128. package/dist/plugin-utils/reflect.d.mts +0 -1
  129. package/dist/plugin-utils/reflect.d.mts.map +1 -1
  130. package/dist/plugin-utils/reflect.mjs.map +1 -1
  131. package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -1
  132. package/dist/plugin-utils/traverse-command-tree.d.cts +0 -1
  133. package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -1
  134. package/dist/plugin-utils/traverse-command-tree.d.mts +0 -1
  135. package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -1
  136. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  137. package/dist/plugin-utils/type-checks.cjs +7 -7
  138. package/dist/plugin-utils/type-checks.cjs.map +1 -1
  139. package/dist/plugin-utils/type-checks.d.cts +0 -1
  140. package/dist/plugin-utils/type-checks.d.cts.map +1 -1
  141. package/dist/plugin-utils/type-checks.d.mts +0 -1
  142. package/dist/plugin-utils/type-checks.d.mts.map +1 -1
  143. package/dist/plugin-utils/type-checks.mjs +1 -1
  144. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  145. package/dist/plugin.cjs +68 -75
  146. package/dist/plugin.cjs.map +1 -1
  147. package/dist/plugin.d.cts +0 -1
  148. package/dist/plugin.d.cts.map +1 -1
  149. package/dist/plugin.d.mts +0 -1
  150. package/dist/plugin.d.mts.map +1 -1
  151. package/dist/plugin.mjs +23 -30
  152. package/dist/plugin.mjs.map +1 -1
  153. package/dist/resolver/deepkit.cjs +29 -29
  154. package/dist/resolver/deepkit.cjs.map +1 -1
  155. package/dist/resolver/deepkit.mjs.map +1 -1
  156. package/dist/resolver/helpers.cjs +17 -17
  157. package/dist/resolver/helpers.cjs.map +1 -1
  158. package/dist/resolver/helpers.mjs.map +1 -1
  159. package/dist/resolver/module.cjs +29 -29
  160. package/dist/resolver/module.cjs.map +1 -1
  161. package/dist/resolver/module.mjs +1 -1
  162. package/dist/resolver/module.mjs.map +1 -1
  163. package/dist/resolver/resolve.cjs +17 -17
  164. package/dist/resolver/resolve.cjs.map +1 -1
  165. package/dist/resolver/resolve.mjs +3 -3
  166. package/dist/resolver/resolve.mjs.map +1 -1
  167. package/dist/types/command.cjs +1 -0
  168. package/dist/types/command.cjs.map +1 -1
  169. package/dist/types/command.d.cts.map +1 -1
  170. package/dist/types/command.d.mts.map +1 -1
  171. package/dist/types/command.mjs.map +1 -1
  172. package/dist/types/config.cjs +1 -0
  173. package/dist/types/config.cjs.map +1 -1
  174. package/dist/types/config.d.cts.map +1 -1
  175. package/dist/types/config.d.mts.map +1 -1
  176. package/dist/types/config.mjs.map +1 -1
  177. package/dist/types/context.cjs +1 -0
  178. package/dist/types/context.cjs.map +1 -1
  179. package/dist/types/context.d.cts.map +1 -1
  180. package/dist/types/context.d.mts.map +1 -1
  181. package/dist/types/env.cjs +1 -0
  182. package/dist/types/env.d.cts.map +1 -1
  183. package/dist/types/env.d.mts.map +1 -1
  184. package/dist/types/index.cjs +1 -0
  185. package/dist/types/options.cjs +1 -0
  186. package/dist/types/options.d.cts.map +1 -1
  187. package/dist/types/options.d.mts.map +1 -1
  188. package/dist/types/runtime.cjs +1 -0
  189. package/dist/types/runtime.d.cts.map +1 -1
  190. package/dist/types/runtime.d.mts.map +1 -1
  191. package/package.json +23 -23
package/dist/plugin.mjs CHANGED
@@ -28,9 +28,8 @@ import { camelCase } from "@stryke/string-format/camel-case";
28
28
  import { constantCase } from "@stryke/string-format/constant-case";
29
29
  import { kebabCase } from "@stryke/string-format/kebab-case";
30
30
  import { isObject } from "@stryke/type-checks/is-object";
31
- import { isSetObject } from "@stryke/type-checks/is-set-object";
32
31
  import { isSetString } from "@stryke/type-checks/is-set-string";
33
- import { defu as defu$1 } from "defu";
32
+ import { defu } from "defu";
34
33
  import { tsdown } from "powerlines/tsdown";
35
34
  import { resolveInputs } from "powerlines/utils";
36
35
 
@@ -49,7 +48,7 @@ const plugin = (options = {}) => {
49
48
  async config() {
50
49
  this.debug("Resolving the Shell Shock configuration.");
51
50
  await updatePackageJsonBinary(this);
52
- return defu$1({ output: { buildPath: joinPaths(this.config.root, "dist") } }, options, {
51
+ return defu({ output: { buildPath: joinPaths(this.config.root, "dist") } }, options, {
53
52
  name: getAppName(this),
54
53
  title: getAppTitle(this),
55
54
  description: getAppDescription(this),
@@ -58,12 +57,12 @@ const plugin = (options = {}) => {
58
57
  isCaseSensitive: false,
59
58
  output: {
60
59
  format: "esm",
61
- dts: true
60
+ dts: false
62
61
  },
63
62
  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,
64
63
  resolve: { external: ["@powerlines/deepkit"] },
65
64
  tsdown: {
66
- dts: true,
65
+ dts: false,
67
66
  nodeProtocol: true,
68
67
  unbundle: false
69
68
  }
@@ -91,7 +90,7 @@ const plugin = (options = {}) => {
91
90
  }
92
91
  }
93
92
  },
94
- ...nodejs(defu$1(options ?? {}, { env: {
93
+ ...nodejs(defu(options ?? {}, { env: {
95
94
  types: "@shell-shock/core/types/env#ShellShockEnv",
96
95
  validate: false
97
96
  } })),
@@ -110,7 +109,7 @@ const plugin = (options = {}) => {
110
109
  let segments = resolveCommandPath(this, entry.file).split("/").filter(Boolean);
111
110
  segments = segments.map((segment, index) => {
112
111
  const found = segments.findIndex((existing) => existing === segment);
113
- if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => isDynamicPathSegment(segment$1) && getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
112
+ if (found !== -1 && found !== index) segment += `_${segments.filter((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === segment).length}`;
114
113
  return segment;
115
114
  });
116
115
  ret.push({
@@ -162,7 +161,7 @@ const plugin = (options = {}) => {
162
161
  let segments = resolveCommandPath(this, file).split("/").filter(Boolean);
163
162
  segments = segments.map((segment, index) => {
164
163
  const found = segments.findIndex((existing) => existing === segment);
165
- if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => isDynamicPathSegment(segment$1) && getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
164
+ if (found !== -1 && found !== index) segment += `_${segments.filter((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === segment).length}`;
166
165
  return segment;
167
166
  });
168
167
  ret.push({
@@ -196,7 +195,7 @@ const plugin = (options = {}) => {
196
195
  this.debug(`Skipping command resolution as the meta checksum has not changed.`);
197
196
  await readCommandsPersistence(this);
198
197
  } else {
199
- for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !isDynamicPathSegment(segment) && !isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await resolve({
198
+ for (const input of this.inputs.filter((input) => input.segments.filter((segment) => !isDynamicPathSegment(segment) && !isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await resolve({
200
199
  context: this,
201
200
  command: input
202
201
  });
@@ -234,24 +233,19 @@ const plugin = (options = {}) => {
234
233
  {
235
234
  name: "shell-shock:chmod+x",
236
235
  configResolved() {
237
- this.config.tsdown.outputOptions ??= {};
238
- if (isObject(this.config.tsdown.outputOptions)) this.config.tsdown.outputOptions.banner = (chunk) => {
239
- if (chunk.isEntry && joinPaths(this.entryPath, "bin.ts") === chunk.facadeModuleId) {
240
- this.debug(`Adding hashbang to binary executable output file: ${chunk.fileName}`);
241
- return `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n`;
242
- }
243
- return "";
236
+ this.config.tsdown.hooks ??= {};
237
+ this.config.tsdown.hooks["build:done"] = async (_) => {
238
+ await Promise.all(Object.values(this.config.bin).map(async (bin) => {
239
+ const path = appendPath(bin, joinPaths(this.workspaceConfig.workspaceRoot, this.config.root));
240
+ if (this.fs.existsSync(path)) {
241
+ this.debug(`Adding hashbang to binary executable output file: ${path}`);
242
+ const content = await this.fs.read(path);
243
+ if (content && !content.startsWith("#!")) await this.fs.write(path, `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n\n${content}`);
244
+ this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
245
+ await chmodX(path);
246
+ } else this.warn(`Expected binary output file not found at path: ${path}. Skipping adding hashbang and executable permissions (chmod+x).`);
247
+ }));
244
248
  };
245
- },
246
- async buildEnd() {
247
- if (!isSetObject(this.config.bin)) this.warn(`No binaries were found for the ${this.config.name} application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`);
248
- else await Promise.all(Object.values(this.config.bin).map(async (bin) => {
249
- const path = appendPath(bin, joinPaths(this.workspaceConfig.workspaceRoot, this.config.root));
250
- if (this.fs.existsSync(path)) {
251
- this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
252
- await chmodX(path);
253
- } else this.warn(`Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`);
254
- }));
255
249
  }
256
250
  },
257
251
  {
@@ -265,10 +259,10 @@ const plugin = (options = {}) => {
265
259
  },
266
260
  async docs() {
267
261
  this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
268
- const commands$1 = this.inputs.map((input) => getCommandTree(this, input.segments)).filter(Boolean);
262
+ const commands = this.inputs.map((input) => getCommandTree(this, input.segments)).filter(Boolean);
269
263
  return render(this, createComponent(For, {
270
264
  get each() {
271
- return Object.values(commands$1);
265
+ return Object.values(commands);
272
266
  },
273
267
  doubleHardline: true,
274
268
  children: (child) => createComponent(Show, {
@@ -284,8 +278,7 @@ const plugin = (options = {}) => {
284
278
  }
285
279
  ];
286
280
  };
287
- var plugin_default = plugin;
288
281
 
289
282
  //#endregion
290
- export { plugin_default as default, plugin, plugin as shellShock };
283
+ export { plugin as default, plugin, plugin as shellShock };
291
284
  //# sourceMappingURL=plugin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isObject","isSetObject","isSetString","defu","tsdown","resolveInputs","CommandDocsFile","UtilsBuiltin","commands","findCommandsRoot","resolveCommandId","resolveCommandName","resolveCommandPath","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","resolve","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","root","title","description","platform","projectType","isCaseSensitive","format","dts","input","Array","isArray","length","Object","keys","undefined","external","nodeProtocol","unbundle","configResolved","order","handler","appSpecificEnvPrefix","autoAssignEnv","env","prefix","includes","push","bin","packageJson","inputs","values","id","path","segments","alias","isVirtual","types","validate","commandsPath","reduce","ret","entry","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","context","option","optional","fromEntries","entries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","each","doubleHardline","children","child","when","shellShock"],"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 deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } 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 { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\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, getDefaultOptions } 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) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\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 buildPath: 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 isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\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 },\n tsdown: {\n dts: true,\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 this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(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 }\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.commandsPath = findCommandsRoot(this);\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 isVirtual: false,\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 <UtilsBuiltin />\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 `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\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 ${command.name} \\n\\nPlease ensure ${command.entry.file} 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 isVirtual: true,\n entry: {\n file\n }\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}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\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 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 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.outputOptions ??= {} as any;\n if (isObject(this.config.tsdown.outputOptions)) {\n (\n this.config.tsdown.outputOptions as NonNullable<OutputOptions>\n ).banner = (chunk: RenderedChunk) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${\n chunk.fileName\n }`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n }\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\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\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\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 ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAMgD,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACL5B,QAAQ;EACRlB,SAAS;EACTD,QAAQ;EACR;GACEgD,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMlB,wBAAwB,KAAK;AA0CnC,WAxCed,OACb,EACEkC,QAAQ,EACNC,WAAW5C,UAAU,KAAKwC,OAAOK,MAAM,OAAM,EAC/C,EACD,EACDP,SACA;KACEC,MAAMX,WAAW,KAAK;KACtBkB,OAAOjB,YAAY,KAAK;KACxBkB,a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AO;KAC9C,MAAMK,OAAOjF,WACX4E,KACAxE,UAAU,KAAK4I,gBAAgBC,eAAe,KAAKrG,OAAOK,KAC5D,CAAC;AAED,SAAI,KAAKsE,GAAGC,WAAWvC,KAAK,EAAE;AAC5B,WAAKpC,MACH,6EAA6EoC,OAC9E;AAED,YAAMlF,OAAOkF,KAAK;WAElB,MAAK2B,KACH,uDAAuD3B,KAAI,4GAC5D;MAGP,CAAC;;GAGN;EACD;GACEtC,MAAM;GACNwB,iBAAiB;AACf,SAAKvB,OAAOjD,WAAW,EAAE;AACzB,SAAKiD,OAAOjD,OAAOuJ,aAAa;KAC9B,GAAI,KAAKtG,OAAOjD,OAAOuJ,cAAc,EAAE;KACvChI,UAAUA,SAAS,KAAI;KACxB;;GAEH,MAAMiI,OAAO;AACX,SAAKtG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBoB,KAAIzC,UAASpB,eAAe,MAAMoB,MAAMyB,SAAS,CAAC,CAClDc,OAAOC,QAAyB;AAEnC,WAAOvG,OACL,MAAIiH,gBACHnH,KAAG;KAAA,IAAC4J,OAAI;AAAA,aAAEvF,OAAOkB,OAAO7D,WAAS;;KAAEmI,gBAAc;KAAAC,WAC/CC,UAAK5C,gBACHlH,MAAI;MAAA,IAAC+J,OAAI;AAAA,cAAE,CAACD,MAAMnE;;MAAS,IAAAkE,WAAA;AAAA,cAAA3C,gBACzB3F,iBAAe,EAACyF,SAAS8C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe9G"}
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 deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } 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 { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\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, getDefaultOptions } 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) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\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 buildPath: 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 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 },\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 this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(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 }\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.commandsPath = findCommandsRoot(this);\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 isVirtual: false,\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 <UtilsBuiltin />\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 `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\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 ${command.name} \\n\\nPlease ensure ${command.entry.file} 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 isVirtual: true,\n entry: {\n file\n }\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}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\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 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 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 ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAE,YAAA;;;;AAKF,MAAE,UAAiB,UAAA,EAAA,KAAA;AACjB,QAAA;EAAA,QAAU;EAAA,SAAA;EAAA,QAAA;EAAA;GACV,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,2CAAoB;AACpB,UAAA,wBAAA,KAAA;AA0BI,WAzBW,KAAM,EACf,QAAC,EACA,WAAA,UAAmB,KAAQ,OAAO,MAAM,OAAA,EACxC,EACF,EAAA,SAAO;KACP,MAAO,WAAU,KAAM;KACvB,OAAO,YAAU,KAAQ;;KAE1B,UAAY;;KAEhB,iBAAA;KACK,QAAK;MACV,QAAA;MACK,KAAM;MACJ;KACJ,OAAA,CAAA,KAAA,OAAA,SAAA,MAAA,QAAA,KAAA,OAAA,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;KACG,SAAC,EACC,UAAE,CAAA,sBAAA,EACR;KACA,QAAQ;MACR,KAAA;MACM,cAAc;MAClB,UAAc;MACZ;;;GAIJ,gBAAgB;IACd,OAAI;IACJ,MAAM,UAAQ;AACZ,UAAK,MAAC,+CAA6C;AACnD,UAAI,OAAA,uBAAA,YAAA,KAAA,OAAA,cAAA,GAAA,KAAA,OAAA,gBAAA,aAAA,WAAA,KAAA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@ -1,11 +1,11 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
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
- let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
- let __stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
7
- let __stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
8
- let __stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
4
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
+ let _stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
7
+ let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
8
+ let _stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
9
9
 
10
10
  //#region src/resolver/deepkit.ts
11
11
  function __assignType(fn, args) {
@@ -13,16 +13,16 @@ function __assignType(fn, args) {
13
13
  return fn;
14
14
  }
15
15
  function extractCommandParameterKind(type) {
16
- const isKind = !((0, __stryke_type_checks_is_set_object.isSetObject)(type) && "kind" in type);
16
+ const isKind = !((0, _stryke_type_checks_is_set_object.isSetObject)(type) && "kind" in type);
17
17
  const kind = !isKind ? type.kind : type;
18
- if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.string) return require_types_command.CommandParameterKinds.string;
19
- else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.number || kind === __powerlines_deepkit_vendor_type.ReflectionKind.bigint || !isKind && type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, __stryke_type_checks_is_number.isNumber)(type.literal) || (0, __stryke_type_checks_is_bigint.isBigInt)(type.literal))) return require_types_command.CommandParameterKinds.number;
20
- else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean) return require_types_command.CommandParameterKinds.boolean;
18
+ if (kind === _powerlines_deepkit_vendor_type.ReflectionKind.string) return require_types_command.CommandParameterKinds.string;
19
+ else if (kind === _powerlines_deepkit_vendor_type.ReflectionKind.number || kind === _powerlines_deepkit_vendor_type.ReflectionKind.bigint || !isKind && type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_number.isNumber)(type.literal) || (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal))) return require_types_command.CommandParameterKinds.number;
20
+ else if (kind === _powerlines_deepkit_vendor_type.ReflectionKind.boolean) return require_types_command.CommandParameterKinds.boolean;
21
21
  else return require_types_command.CommandParameterKinds.string;
22
22
  }
23
23
  extractCommandParameterKind.__type = [
24
24
  "Type",
25
- () => __powerlines_deepkit_vendor_type.__ΩReflectionKind,
25
+ () => _powerlines_deepkit_vendor_type.__ΩReflectionKind,
26
26
  "type",
27
27
  "CommandParameterKind",
28
28
  "extractCommandParameterKind",
@@ -41,23 +41,23 @@ function resolveCommandOption(ctx, reflection) {
41
41
  default: reflection.getDefaultValue(),
42
42
  variadic: reflection.isArray()
43
43
  };
44
- if (reflection.isArray()) if (type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) {
44
+ if (reflection.isArray()) if (type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number) {
45
45
  option.variadic = true;
46
46
  option.kind = extractCommandParameterKind(type.type.kind);
47
- } else throw new Error(`Unsupported array type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string[] and number[] are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
48
- else if (type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.union) {
49
- option.kind = type.types.every(__assignType((t) => t.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number || t.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, __stryke_type_checks_is_number.isNumber)(t.literal) || (0, __stryke_type_checks_is_bigint.isBigInt)(t.literal)), [
47
+ } else throw new Error(`Unsupported array type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string[] and number[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
48
+ else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) {
49
+ option.kind = type.types.every(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number || t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_number.isNumber)(t.literal) || (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal)), [
50
50
  "t",
51
51
  "",
52
52
  "P\"2!\"/\""
53
53
  ])) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string;
54
- option.choices = type.types.map(__assignType((t) => t.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, __stryke_type_checks_is_number.isNumber)(t.literal) ? t.literal : (0, __stryke_type_checks_is_bigint.isBigInt)(t.literal) ? Number(t.literal) : (0, __stryke_type_checks_is_regexp.isRegExp)(t.literal) ? t.literal.source : String(t.literal) : null, [
54
+ option.choices = type.types.map(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, _stryke_type_checks_is_number.isNumber)(t.literal) ? t.literal : (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal) ? Number(t.literal) : (0, _stryke_type_checks_is_regexp.isRegExp)(t.literal) ? t.literal.source : String(t.literal) : null, [
55
55
  "t",
56
56
  "",
57
57
  "P\"2!\"/\""
58
58
  ])).filter(Boolean);
59
- } else if (type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal) option.choices = [(0, __stryke_type_checks_is_number.isNumber)(type.literal) ? type.literal : (0, __stryke_type_checks_is_bigint.isBigInt)(type.literal) ? Number(type.literal) : (0, __stryke_type_checks_is_regexp.isRegExp)(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
60
- else if (!existing.kind && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[] and number[] are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
59
+ } else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal) option.choices = [(0, _stryke_type_checks_is_number.isNumber)(type.literal) ? type.literal : (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal) ? Number(type.literal) : (0, _stryke_type_checks_is_regexp.isRegExp)(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
60
+ else if (!existing.kind && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[] and number[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
61
61
  return require_helpers.mergeCommandParameter(existing, option);
62
62
  }
63
63
  resolveCommandOption.__type = [
@@ -72,7 +72,7 @@ resolveCommandOption.__type = [
72
72
  function resolveCommandArgument(ctx, index, reflection) {
73
73
  const type = reflection.getType();
74
74
  const existing = ctx.output.args.length > index ? ctx.output.args[index] : {};
75
- if (!existing.kind && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.number && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.boolean && !(type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array && (type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number))) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string types (or an array of strings) are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
75
+ if (!existing.kind && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.number && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.boolean && !(type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array && (type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number))) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string types (or an array of strings) are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
76
76
  const argument = {
77
77
  name: reflection.getName() || reflection.parameter.name,
78
78
  alias: reflection.getAlias(),
@@ -82,12 +82,12 @@ function resolveCommandArgument(ctx, index, reflection) {
82
82
  optional: reflection.isOptional(),
83
83
  default: reflection.getDefaultValue()
84
84
  };
85
- if (type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array) {
86
- if (type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) {
85
+ if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array) {
86
+ if (type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number) {
87
87
  argument.variadic = true;
88
88
  argument.kind = extractCommandParameterKind(type.type.kind);
89
- } else if (!existing.kind) throw new Error(`Unsupported array type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string[] and number[] are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
90
- } else if (!existing.kind && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[] and number[] are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
89
+ } else if (!existing.kind) throw new Error(`Unsupported array type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string[] and number[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
90
+ } else if (!existing.kind && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[] and number[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
91
91
  return require_helpers.mergeCommandParameter(existing, argument, { name: `arg${index}` });
92
92
  }
93
93
  resolveCommandArgument.__type = [
@@ -101,15 +101,15 @@ resolveCommandArgument.__type = [
101
101
  "P\"w!2\"'2#\"w$2%\"w&/'"
102
102
  ];
103
103
  function resolveFromBytecode(ctx) {
104
- const { input, module: module$1 } = ctx;
105
- const type = (0, __powerlines_deepkit_vendor_type.reflect)(module$1);
106
- if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.function) throw new Error(`The command entry file "${input.command.entry.input?.file || input.command.path}" does not export a valid function.`);
107
- const reflection = new __powerlines_deepkit_vendor_type.ReflectionFunction(type);
104
+ const { input, module } = ctx;
105
+ const type = (0, _powerlines_deepkit_vendor_type.reflect)(module);
106
+ if (type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.function) throw new Error(`The command entry file "${input.command.entry.input?.file || input.command.path}" does not export a valid function.`);
107
+ const reflection = new _powerlines_deepkit_vendor_type.ReflectionFunction(type);
108
108
  ctx.output.description ??= ctx.input.command.description || reflection.getDescription() || type.description;
109
109
  const parameters = reflection.getParameters();
110
110
  if (parameters.length > 0 && parameters[0]) {
111
- if (parameters[0].type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral || parameters[0].type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.class) {
112
- const optionsReflection = __powerlines_deepkit_vendor_type.ReflectionClass.from(parameters[0].type);
111
+ if (parameters[0].type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral || parameters[0].type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class) {
112
+ const optionsReflection = _powerlines_deepkit_vendor_type.ReflectionClass.from(parameters[0].type);
113
113
  for (const propertyReflection of optionsReflection.getProperties()) ctx.output.options[propertyReflection.getNameAsString()] = resolveCommandOption(ctx, propertyReflection);
114
114
  } else if (!ctx.module?.options) throw new Error(`The first parameter of the command handler function in "${ctx.input.command.entry.input?.file || ctx.input.command.path}" must be an object literal or class type representing the command options.`);
115
115
  ctx.output.args = parameters.slice(1).map(__assignType((arg, index) => resolveCommandArgument(ctx, index, arg), [
@@ -1 +1 @@
1
- {"version":3,"file":"deepkit.cjs","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 (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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[] and number[] 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 if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || 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()\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 if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !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 argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return 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 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;CAUP,MAAM,SAAS,sDAAc,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,gDAAe;UAGnB,SAAQ,gDAAA,UACb,SAAS,gDAAG,UACd,CAAA,UACI,KAAA,SAAA,gDAAA,yDACY,KAAK,QAAQ,iDAAK,KAAA,QAAA,EACjC,QAAA,4CAAA;UAEM,SAAI,gDAAA,QACT,QAAO,4CAAK;KAGZ,QAAO,4CAAsB;;AAGrC,4BAA4B,SAAS;CAAC;OAAc;CAAI;CAAA;CAAA;CAAA;CAAA;AACxD,SAAS,qBAAqB,KAAK,YAAY;CAC3C,MAAM,OAAE,WAAA,SAAA;CACR,MAAM,WAAO,IAAA,OAAA,QAAA,WAAA,iBAAA,KACT,EAAG;CACP,MAAM,SAAS;EACX,MAAC,WAAA,iBAAA;EACD,OAAO,WAAS,SAAA,CAAA,S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B;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"deepkit.cjs","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 (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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[] and number[] 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 if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || 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()\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 if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !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 argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return 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 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAW,IAAM,MAAA;;AAEzB,QAAU;;;CAUV,MAAK,SAAQ,qDAAmB,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,+CAAe;UAG9B,SAAmB,+CAAA,UACnB,SAAA,+C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ACH,MAAE,oBAAA,gDAAA,KAAA,WAAA,GAAA,KAAA;AACX,QAAA,MAAgB,sBAAA,kBAAA,eAAA,CACJ,KAAA,OAAW,QAAS,mBAAA,iBAAA,IAChB,qBAAA,KAAA,mBAAA;kCAId,OAAA,IAAA,MAAA,2DAAA,IAAA,MAAA,QAAA,MAAA,OAAA,QAAA,IAAA,MAAA,QAAA,KAAA,6EAAA;AAEG,MAAC,OAAS,OAAA,WACL,MAAK,EAAA,CACL,IAAI,cAAC,KAAe,UAAS,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAG1C,oBAAiB,SAAS;CAAA;CAAuB;CAAA;CAAA;CAAA"}
@@ -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 (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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[] and number[] 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 if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || 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()\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 if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !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 argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return 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 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;CAUP,MAAM,SAAS,EAAE,YAAY,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,eAAe;UAGnB,SAAQ,eAAA,UACb,SAAS,eAAG,UACd,CAAA,UACI,KAAA,SAAA,eAAA,YACG,SAAS,KAAK,QAAQ,IAAI,SAAC,KAAA,QAAA,EACjC,QAAA,sBAAA;UAEM,SAAI,eAAA,QACT,QAAO,sBAAK;KAGZ,QAAO,sBAAsB;;AAGrC,4BAA4B,SAAS;CAAC;OAAc;CAAI;CAAA;CAAA;CAAA;CAAA;AACxD,SAAS,qBAAqB,KAAK,YAAY;CAC3C,MAAM,OAAE,WAAA,SAAA;CACR,MAAM,WAAO,IAAA,OAAA,QAAA,WAAA,iBAAA,KACT,EAAG;CACP,MAAM,SAAS;EACX,MAAC,WAAA,iBAAA;EACD,OAAO,WAAS,SAAA,CAAA,SAAA,EAAA;EAChB,OAAO,WAAQ,SAAA,CAAA,OAAA,MAAA;EACf,aAAS,WAAA,gBAAA;EACT,MAAM,4BAA4B,KAAK;EACvC,UAAU,WAAW,YAAY;EACjC,SAAS,WAAW,iBAAiB;;EAExC;AACD,KAAI,WAAW,SAAS,CACpB,KAAI,KAAK,KAAK,SAAE,eAAA,UACZ,KAAK,KAAK,SAAS,eAAe,QAAQ;AAC1C,SAAO,WACH;AACJ,SAAO,OACP,4BAAA,KAAA,KAAA,KAAA;OAGA,OAAE,IAAA,MAAA,sCAAA,WAAA,iBAAA,CAAA,gBA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BAAuB,SAAM;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAC7B,SAAgB,oBAAoB,KAAK;CACrC,MAAM,EAAC,OAAA,WAAA;CACP,MAAE,OAAA,QAAA,OAAA;AACF,KAAI,KAAK,SAAC,eAAA,SACN,OAAM,IAAI,MAAM,2BAAa,MAAA,QAAA,MAAA,OAAA,QAAA,MAAA,QAAA,KAAA,qCAAA;CAEnC,MAAA,aAAA,IAAA,mBAAA,KAAA;6DAEM,WAAW,gBAAgB,IACnC,KAAA;;AAEI,KAAI,WAAW,SAAS,KAAG,WAAA,IAAA;AACvB,MAAI,WAAU,GAAA,KAAA,SAAA,eAAA,iBACV,WAAG,GAAA,KAAA,SAAA,eAAA,OAAA;GACH,MAAM,oBAAc,gBAAA,KAAA,WAAA,GAAA,KAAA;AACpB,QAAK,MAAE,sBAAA,kBAAA,eAAA,CACH,KAAI,OAAO,QAAQ,mBAAA,iBAAA,IAChB,qBAAA,KAAA,mBAAA;kCAId,OAAA,IAAA,MAAA,2DAAA,IAAA,MAAA,QAAA,MAAA,OAAA,QAAA,IAAA,MAAA,QAAA,KAAA,6EAAA;AAEG,MAAI,OAAO,OAAO,WACb,MAAM,EAAE,CACR,IAAI,cAAc,KAAK,UAAM,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAG1C,oBAAoB,SAAS;CAAC;CAAmB;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 (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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[] and number[] 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 if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || 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()\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 if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !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 argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return 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 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAW,IAAM,MAAA;;AAEzB,QAAU;;;CAUV,MAAK,SAAQ,EAAA,YAAmB,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,eAAe;UAG9B,SAAmB,eAAA,UACnB,SAAA,eAAkB,UACd,CAAA,UACJ,KAAA,SAAA,eAAA,YACO,SAAW,KAAO,QAAQ,IAAI,SAAC,KAAA,QAAA,EACjC,QAAA,sBAAA;UAEL,SAAe,eAAA,QACf,QAAA,sBAAkB;KAGZ,QAAC,sBAA0B;;AAGnC,4BAA2B,SAAO;CAAI;OAAW;CAAO;CAAA;CAAA;CAAA;CAAA;AACxD,SAAS,qBAAqB,KAAA,YAAY;CAC1C,MAAO,OAAK,WAAA,SAAA;CACV,MAAA,WAAe,IAAA,OAAA,QAAA,WA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