@shell-shock/core 0.17.7 → 0.17.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/api.cjs +81 -28
  2. package/dist/api.d.cts +51 -3
  3. package/dist/api.d.cts.map +1 -1
  4. package/dist/api.d.mts +51 -3
  5. package/dist/api.d.mts.map +1 -1
  6. package/dist/api.mjs +79 -26
  7. package/dist/api.mjs.map +1 -1
  8. package/dist/components/docs.cjs +1 -1
  9. package/dist/components/docs.d.cts.map +1 -1
  10. package/dist/components/docs.d.mts.map +1 -1
  11. package/dist/components/docs.mjs +1 -1
  12. package/dist/components/docs.mjs.map +1 -1
  13. package/dist/components/exec-builtin.cjs +1 -1
  14. package/dist/components/exec-builtin.mjs +1 -1
  15. package/dist/components/state-builtin.cjs +2 -2
  16. package/dist/components/state-builtin.d.cts.map +1 -1
  17. package/dist/components/state-builtin.d.mts.map +1 -1
  18. package/dist/components/state-builtin.mjs +2 -2
  19. package/dist/components/state-builtin.mjs.map +1 -1
  20. package/dist/components/utils-builtin.cjs +1 -1
  21. package/dist/components/utils-builtin.d.cts.map +1 -1
  22. package/dist/components/utils-builtin.d.mts.map +1 -1
  23. package/dist/components/utils-builtin.mjs +1 -1
  24. package/dist/components/utils-builtin.mjs.map +1 -1
  25. package/dist/contexts/options.cjs +1 -1
  26. package/dist/contexts/options.mjs +1 -1
  27. package/dist/contexts/options.mjs.map +1 -1
  28. package/dist/helpers/docs-helpers.mjs.map +1 -1
  29. package/dist/helpers/paths.cjs +7 -7
  30. package/dist/helpers/paths.mjs +7 -7
  31. package/dist/helpers/paths.mjs.map +1 -1
  32. package/dist/helpers/persistence.cjs +2 -0
  33. package/dist/helpers/persistence.mjs +2 -0
  34. package/dist/helpers/persistence.mjs.map +1 -1
  35. package/dist/helpers/update-package-json.cjs +30 -24
  36. package/dist/helpers/update-package-json.mjs +30 -24
  37. package/dist/helpers/update-package-json.mjs.map +1 -1
  38. package/dist/helpers/utilities.mjs.map +1 -1
  39. package/dist/helpers/validations.mjs.map +1 -1
  40. package/dist/index.cjs +1 -0
  41. package/dist/index.d.cts +2 -2
  42. package/dist/index.d.mts +2 -2
  43. package/dist/index.mjs +2 -2
  44. package/dist/plugin-utils/compute-bin.cjs +1 -1
  45. package/dist/plugin-utils/compute-bin.mjs +1 -1
  46. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  47. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  48. package/dist/plugin-utils/deepkit.cjs +1 -1
  49. package/dist/plugin-utils/deepkit.mjs +1 -1
  50. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  51. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  52. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  53. package/dist/plugin-utils/reflect.cjs +2 -2
  54. package/dist/plugin-utils/reflect.mjs +2 -2
  55. package/dist/plugin-utils/reflect.mjs.map +1 -1
  56. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  57. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  58. package/dist/plugin.cjs +49 -7
  59. package/dist/plugin.d.cts.map +1 -1
  60. package/dist/plugin.d.mts.map +1 -1
  61. package/dist/plugin.mjs +49 -7
  62. package/dist/plugin.mjs.map +1 -1
  63. package/dist/resolver/deepkit.cjs +1 -1
  64. package/dist/resolver/deepkit.mjs +1 -1
  65. package/dist/resolver/deepkit.mjs.map +1 -1
  66. package/dist/resolver/helpers.mjs.map +1 -1
  67. package/dist/resolver/module.cjs +1 -1
  68. package/dist/resolver/module.mjs +1 -1
  69. package/dist/resolver/module.mjs.map +1 -1
  70. package/dist/resolver/resolve.cjs +1 -1
  71. package/dist/resolver/resolve.mjs +1 -1
  72. package/dist/resolver/resolve.mjs.map +1 -1
  73. package/dist/types/command.d.cts +1 -1
  74. package/dist/types/command.d.mts +2 -2
  75. package/dist/types/command.mjs.map +1 -1
  76. package/dist/types/config.cjs +20 -30
  77. package/dist/types/config.d.cts +13 -10
  78. package/dist/types/config.d.cts.map +1 -1
  79. package/dist/types/config.d.mts +13 -10
  80. package/dist/types/config.d.mts.map +1 -1
  81. package/dist/types/config.mjs +20 -31
  82. package/dist/types/config.mjs.map +1 -1
  83. package/dist/types/context.cjs +2 -2
  84. package/dist/types/context.d.cts +3 -2
  85. package/dist/types/context.d.cts.map +1 -1
  86. package/dist/types/context.d.mts +3 -2
  87. package/dist/types/context.d.mts.map +1 -1
  88. package/dist/types/context.mjs +2 -2
  89. package/dist/types/context.mjs.map +1 -1
  90. package/dist/types/env.d.cts +1 -1
  91. package/dist/types/env.d.mts +1 -1
  92. package/dist/types/env.mjs.map +1 -1
  93. package/dist/types/index.cjs +1 -0
  94. package/dist/types/index.d.cts +2 -2
  95. package/dist/types/index.d.mts +2 -2
  96. package/dist/types/index.mjs +2 -2
  97. package/package.json +25 -24
@@ -1,4 +1,5 @@
1
1
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let _powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
2
3
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
3
4
 
4
5
  //#region src/helpers/persistence.ts
@@ -93,6 +94,7 @@ readCommandsPersistence.__type = [
93
94
  */
94
95
  async function writeCommandsPersistence(context) {
95
96
  const filePath = getCommandsPersistencePath(context);
97
+ await (0, _powerlines_plugin_env_helpers.writeEnvTypeReflection)(context, context.env.types.env, "env");
96
98
  await context.fs.write(filePath, JSON.stringify(Object.fromEntries(Object.entries(context.commands).map(__assignType(([name, command]) => [name, serialize(command)], [
97
99
  "param0",
98
100
  "",
@@ -1,3 +1,4 @@
1
+ import { writeEnvTypeReflection } from "@powerlines/plugin-env/helpers";
1
2
  import { joinPaths } from "@stryke/path/join-paths";
2
3
 
3
4
  //#region src/helpers/persistence.ts
@@ -92,6 +93,7 @@ readCommandsPersistence.__type = [
92
93
  */
93
94
  async function writeCommandsPersistence(context) {
94
95
  const filePath = getCommandsPersistencePath(context);
96
+ await writeEnvTypeReflection(context, context.env.types.env, "env");
95
97
  await context.fs.write(filePath, JSON.stringify(Object.fromEntries(Object.entries(context.commands).map(__assignType(([name, command]) => [name, serialize(command)], [
96
98
  "param0",
97
99
  "",
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, SerializedCommandTree } from \"../types\";\nimport type { Context } from \"../types/context\";\n\nfunction serialize(command: CommandTree): SerializedCommandTree {\n return {\n ...command,\n parent: command.parent?.name ? command.parent.name : null,\n children: Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n serialize(child)\n ])\n )\n };\n}\n\nfunction deserialize(\n command: SerializedCommandTree,\n parent: CommandTree | null = null\n): CommandTree {\n const result: CommandTree = {\n ...command,\n parent: parent ?? null,\n children: {}\n };\n\n result.children = Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n deserialize(child, result)\n ])\n );\n\n return result;\n}\n\n/**\n * Gets the file path for persisting CLI command reflections.\n *\n * @param context - The Shell Shock context.\n * @returns The file path for persisting CLI command reflections.\n */\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\n/**\n * Reads the persisted CLI command reflections from the file system and populates the context's commands.\n *\n * @param context - The Shell Shock context.\n * @throws Will throw an error if the reflections file is empty or cannot be read.\n */\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = Object.fromEntries(\n Object.entries(\n (JSON.parse(reflections) ?? {}) as Record<string, SerializedCommandTree>\n ).map(([name, command]) => [name, deserialize(command)])\n );\n}\n\n/**\n * Writes the current CLI command reflections from the context to the file system for persistence.\n *\n * @param context - The Shell Shock context.\n * @returns A promise that resolves when the reflections have been successfully written to the file system.\n * @throws Will throw an error if there is an issue writing the reflections to the file system.\n */\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n Object.fromEntries(\n Object.entries(context.commands).map(([name, command]) => [\n name,\n serialize(command)\n ])\n ),\n null,\n context.config.mode === \"production\" ? 0 : 2\n )\n );\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAoBX,SAAS,UAAU,SAAS;AAC1B,QAAO;EACF,GAAA;EACH,QAAQ,QAAQ,QAAY,OAAG,QAAQ,OAAW,OAAO;EACzD,UAAU,OAAO,YAAW,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CACpB,MACA,UAAA,MAAA,CACJ,EAAA;GAAA;GAAU;GAAK;GAAA,CAAA,CAAA,CAAA;EAClB;;AAEL,UAAG,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACH,SAAA,YAAA,SAAA,SAAA,MAAA;;EAEQ,GAAC;EACP,QAAS,UAAA;EACH,UAAE,EAAA;EACP;AACD,QAAM,WAAQ,OAAa,YAAC,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CACvB,MACH,YAAgB,OAAM,OAAA,CACtB,EAAA;EAAA;EAAW;EAAA;EAAA,CAAA,CAAA,CAAA;AACZ,QAAA;;AAEH,YAAS,SAAW;CAAA;CAAkB;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;;;;;;;AAOtC,SAAe,2BAAA,SAAA;AACf,QAAA,UAAA,QAAA,UAAA,eAAA,gBAAA;;AAEA,2BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,eAAmB,wBAAmB,SAAe;CACrD,MAAA,cAAA,MAAA,QAAA,GAAA,KAAA,2BAAA,QAAA,CAAA;yCAEE,OAAA,IAAA,MAAA,+BAAA,2BAAA,QAAA,CAAA,WAAA;AAED,SAAA,WAAA,OAAA,YAAA,OAAA,QAAA,KAAA,MAAA,YAAA,IAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,CAAA,MAAA,YAAA,QAAA,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;AAED,wBAAwB,SAAS;CAAC;CAAI;CAAiB;CAA0B;CAAA;CAAA;;;;;;;;AAQjF,eAAmB,yBAAkB,SAAA;CACjC,MAAC,WAAA,2BAAA,QAAA;AACH,OAAA,QAAA,GAAA,MAAA,UAAA,KAAA,UAAA,OAAA,YAAA,OAAA,QAAA,QAAA,SAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,OAEA,UAAgB,QAAG,CACjB,EAAA;EAAA;EAAc;EAAA;EAAA,CAAA,CAAA,CAAA,EAAA,MAAA,QAAA,OAAA,SAAA,eAAA,IAAA,EAAA,CAAA;;AAElB,yBAAyB,SAAO;CAAA;CAAM;CAAmB;CAAE;CAAA;CAAA"}
1
+ {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { writeEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, SerializedCommandTree } from \"../types\";\nimport type { Context } from \"../types/context\";\n\nfunction serialize(command: CommandTree): SerializedCommandTree {\n return {\n ...command,\n parent: command.parent?.name ? command.parent.name : null,\n children: Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n serialize(child)\n ])\n )\n };\n}\n\nfunction deserialize(\n command: SerializedCommandTree,\n parent: CommandTree | null = null\n): CommandTree {\n const result: CommandTree = {\n ...command,\n parent: parent ?? null,\n children: {}\n };\n\n result.children = Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n deserialize(child, result)\n ])\n );\n\n return result;\n}\n\n/**\n * Gets the file path for persisting CLI command reflections.\n *\n * @param context - The Shell Shock context.\n * @returns The file path for persisting CLI command reflections.\n */\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\n/**\n * Reads the persisted CLI command reflections from the file system and populates the context's commands.\n *\n * @param context - The Shell Shock context.\n * @throws Will throw an error if the reflections file is empty or cannot be read.\n */\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = Object.fromEntries(\n Object.entries(\n (JSON.parse(reflections) ?? {}) as Record<string, SerializedCommandTree>\n ).map(([name, command]) => [name, deserialize(command)])\n );\n}\n\n/**\n * Writes the current CLI command reflections from the context to the file system for persistence.\n *\n * @param context - The Shell Shock context.\n * @returns A promise that resolves when the reflections have been successfully written to the file system.\n * @throws Will throw an error if there is an issue writing the reflections to the file system.\n */\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n // Also update the environment type reflections whenever we write the command reflections, to ensure they stay in sync.\n await writeEnvTypeReflection(context, context.env.types.env, \"env\");\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n Object.fromEntries(\n Object.entries(context.commands).map(([name, command]) => [\n name,\n serialize(command)\n ])\n ),\n null,\n context.config.mode === \"production\" ? 0 : 2\n )\n );\n}\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;AAqBT,SAAS,UAAU,SAAS;AAC1B,QAAO;EACL,GAAG;EACH,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,OAAO,OAAO;EACrD,UAAU,OAAO,YAAW,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CAAA,MAAA,UAAA,MAAA,CAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA,CAAA;EAC7B;;AAEH,UAAQ,SAAU;CAAA;CAAK;CAAA;CAAA;CAAA;CAAA;AACvB,SAAO,YAAA,SAAA,SAAA,MAAA;CACL,MAAE,SAAA;EACD,GAAA;EACH,QAAA,UAAA;;EAEA;AACE,QAAO,WAAE,OAAA,YAAqB,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CAAA,MAAA,YAAA,OAAA,OAAA,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;AAC9B,QAAO;;AAET,YAAQ,SAAQ;CAAA;CAAc;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;;;;;;;AAO9B,SAAW,2BAAgC,SAAM;AAC/C,QAAI,UAAI,QAAA,UAAA,eAAA,gBAAA;;AAEV,2BAAK,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOL,eAAsB,wBAAmB,SAAQ;CAChD,MAAA,cAAA,MAAA,QAAA,GAAA,KAAA,2BAAA,QAAA,CAAA;AACC,KAAE,CAAA,eAAgB,CAAG,YAAY,OAC/B,OAAA,IAAQ,MAAQ,+BAAyB,2BAAmB,QAAA,CAAA,WAAA;AAEhE,SAAO,WAAS,OAAA,YAAA,OAA2B,QAAS,KAAQ,MAAE,YAAO,IAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,CAAA,MAAA,YAAA,QAAA,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;AAErE,wBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,eAAsB,yBAAwB,SAAS;CACrD,MAAM,WAAW,2BAAwB,QAAA;AAEzC,OAAC,uBAAA,SAAA,QAAA,IAAA,MAAA,KAAA,MAAA;AACD,OAAK,QAAA,GAAY,MAAI,UAAY,KAAA,UAAQ,OAAA,YAAA,OAAA,QAAA,QAAA,SAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,CAAA,MAAA,UAAA,QAAA,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EAAA,MAAA,QAAA,OAAA,SAAA,eAAA,IAAA,EAAA,CAAA;;AAE3C,yBAAmB,SAAe;CAAC;CAAE;CAAA;CAA6C;CAAA;CAAA"}
@@ -21,34 +21,40 @@ formatBinaryPath.__type = [
21
21
  "PP&&F-J2!&/\""
22
22
  ];
23
23
  async function updatePackageJsonBinary(context) {
24
- const packageJsonPath = (0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root, "package.json");
25
- if (context.config.bin && Array.isArray(context.config.bin) && context.config.bin.length > 0) {
26
- context.packageJson.bin = Object.fromEntries((0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(context.config.bin)).map(__assignType((bin) => [bin, formatBinaryPath(context.config.output.format)], [
27
- "bin",
28
- "",
29
- "P\"2!\"/\""
30
- ])));
31
- await context.fs.write(packageJsonPath, _stryke_json_storm_json.StormJSON.stringify(context.packageJson));
32
- } else {
33
- if (Array.isArray(context.config.output.format) && context.config.output.format.length > 1) {
34
- context.packageJson.bin = { [(0, _stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))]: formatBinaryPath((0, _stryke_convert_to_array.toArray)(context.config.output.format)[0]) };
35
- context.packageJson.bin = (0, _stryke_convert_to_array.toArray)(context.config.output.format).reduce(__assignType((ret, format) => {
36
- ret[`${(0, _stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))}-${format}`] = formatBinaryPath(format);
37
- return ret;
38
- }, [
39
- "ret",
40
- "format",
24
+ const packageJsonPath = (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root, "package.json");
25
+ if (!context.packageJson) {
26
+ const packageJson = await context.fs.read(packageJsonPath);
27
+ if (packageJson) context.packageJson ??= JSON.parse(packageJson);
28
+ }
29
+ if (context.packageJson) {
30
+ if (context.config.bin && Array.isArray(context.config.bin) && context.config.bin.length > 0) {
31
+ context.packageJson.bin = Object.fromEntries((0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(context.config.bin)).map(__assignType((bin) => [bin, formatBinaryPath(context.config.output.format)], [
32
+ "bin",
41
33
  "",
42
- "P\"2!\"2\"\"/#"
43
- ]), context.packageJson.bin);
44
- } else context.packageJson.bin = { [(0, _stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))]: formatBinaryPath(context.config.output.format) };
45
- await context.fs.write(packageJsonPath, _stryke_json_storm_json.StormJSON.stringify(context.packageJson));
34
+ "P\"2!\"/\""
35
+ ])));
36
+ await context.fs.write(packageJsonPath, _stryke_json_storm_json.StormJSON.stringify(context.packageJson));
37
+ } else {
38
+ if (Array.isArray(context.config.output.format) && context.config.output.format.length > 1) {
39
+ context.packageJson.bin = { [(0, _stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))]: formatBinaryPath((0, _stryke_convert_to_array.toArray)(context.config.output.format)[0]) };
40
+ context.packageJson.bin = (0, _stryke_convert_to_array.toArray)(context.config.output.format).reduce(__assignType((ret, format) => {
41
+ ret[`${(0, _stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))}-${format}`] = formatBinaryPath(format);
42
+ return ret;
43
+ }, [
44
+ "ret",
45
+ "format",
46
+ "",
47
+ "P\"2!\"2\"\"/#"
48
+ ]), context.packageJson.bin);
49
+ } else context.packageJson.bin = { [(0, _stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))]: formatBinaryPath(context.config.output.format) };
50
+ await context.fs.write(packageJsonPath, _stryke_json_storm_json.StormJSON.stringify(context.packageJson));
51
+ }
52
+ if (!(0, _stryke_type_checks_is_set_object.isSetObject)(context.packageJson.bin)) throw new Error("Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.");
53
+ context.config.bin = context.packageJson.bin;
46
54
  }
47
- if (!(0, _stryke_type_checks_is_set_object.isSetObject)(context.packageJson.bin)) throw new Error("Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.");
48
- context.config.bin = Object.keys(context.packageJson.bin);
49
55
  }
50
56
  updatePackageJsonBinary.__type = [
51
- "UnresolvedContext",
57
+ "Context",
52
58
  "context",
53
59
  "updatePackageJsonBinary",
54
60
  "P\"w!2\"$`/#"
@@ -20,34 +20,40 @@ formatBinaryPath.__type = [
20
20
  "PP&&F-J2!&/\""
21
21
  ];
22
22
  async function updatePackageJsonBinary(context) {
23
- const packageJsonPath = joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "package.json");
24
- if (context.config.bin && Array.isArray(context.config.bin) && context.config.bin.length > 0) {
25
- context.packageJson.bin = Object.fromEntries(getUnique(toArray(context.config.bin)).map(__assignType((bin) => [bin, formatBinaryPath(context.config.output.format)], [
26
- "bin",
27
- "",
28
- "P\"2!\"/\""
29
- ])));
30
- await context.fs.write(packageJsonPath, StormJSON.stringify(context.packageJson));
31
- } else {
32
- if (Array.isArray(context.config.output.format) && context.config.output.format.length > 1) {
33
- context.packageJson.bin = { [kebabCase(getAppName(context))]: formatBinaryPath(toArray(context.config.output.format)[0]) };
34
- context.packageJson.bin = toArray(context.config.output.format).reduce(__assignType((ret, format) => {
35
- ret[`${kebabCase(getAppName(context))}-${format}`] = formatBinaryPath(format);
36
- return ret;
37
- }, [
38
- "ret",
39
- "format",
23
+ const packageJsonPath = joinPaths(context.config.cwd, context.config.root, "package.json");
24
+ if (!context.packageJson) {
25
+ const packageJson = await context.fs.read(packageJsonPath);
26
+ if (packageJson) context.packageJson ??= JSON.parse(packageJson);
27
+ }
28
+ if (context.packageJson) {
29
+ if (context.config.bin && Array.isArray(context.config.bin) && context.config.bin.length > 0) {
30
+ context.packageJson.bin = Object.fromEntries(getUnique(toArray(context.config.bin)).map(__assignType((bin) => [bin, formatBinaryPath(context.config.output.format)], [
31
+ "bin",
40
32
  "",
41
- "P\"2!\"2\"\"/#"
42
- ]), context.packageJson.bin);
43
- } else context.packageJson.bin = { [kebabCase(getAppName(context))]: formatBinaryPath(context.config.output.format) };
44
- await context.fs.write(packageJsonPath, StormJSON.stringify(context.packageJson));
33
+ "P\"2!\"/\""
34
+ ])));
35
+ await context.fs.write(packageJsonPath, StormJSON.stringify(context.packageJson));
36
+ } else {
37
+ if (Array.isArray(context.config.output.format) && context.config.output.format.length > 1) {
38
+ context.packageJson.bin = { [kebabCase(getAppName(context))]: formatBinaryPath(toArray(context.config.output.format)[0]) };
39
+ context.packageJson.bin = toArray(context.config.output.format).reduce(__assignType((ret, format) => {
40
+ ret[`${kebabCase(getAppName(context))}-${format}`] = formatBinaryPath(format);
41
+ return ret;
42
+ }, [
43
+ "ret",
44
+ "format",
45
+ "",
46
+ "P\"2!\"2\"\"/#"
47
+ ]), context.packageJson.bin);
48
+ } else context.packageJson.bin = { [kebabCase(getAppName(context))]: formatBinaryPath(context.config.output.format) };
49
+ await context.fs.write(packageJsonPath, StormJSON.stringify(context.packageJson));
50
+ }
51
+ if (!isSetObject(context.packageJson.bin)) throw new Error("Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.");
52
+ context.config.bin = context.packageJson.bin;
45
53
  }
46
- if (!isSetObject(context.packageJson.bin)) throw new Error("Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.");
47
- context.config.bin = Object.keys(context.packageJson.bin);
48
54
  }
49
55
  updatePackageJsonBinary.__type = [
50
- "UnresolvedContext",
56
+ "Context",
51
57
  "context",
52
58
  "updatePackageJsonBinary",
53
59
  "P\"w!2\"$`/#"
@@ -1 +1 @@
1
- {"version":3,"file":"update-package-json.mjs","names":[],"sources":["../../src/helpers/update-package-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getAppName } from \"../plugin-utils/context-helpers\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function formatBinaryPath(\n format: string | string[] | undefined\n): string {\n return `./dist/bin.${\n format === \"cjs\" || (Array.isArray(format) && format.includes(\"cjs\"))\n ? \"cjs\"\n : \"mjs\"\n }`;\n}\n\nexport async function updatePackageJsonBinary(\n context: UnresolvedContext\n): Promise<void> {\n const packageJsonPath = joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"package.json\"\n );\n if (\n context.config.bin &&\n Array.isArray(context.config.bin) &&\n context.config.bin.length > 0\n ) {\n context.packageJson.bin = Object.fromEntries(\n getUnique(toArray(context.config.bin)).map(bin => [\n bin,\n formatBinaryPath(context.config.output.format)\n ])\n );\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n } else {\n if (\n Array.isArray(context.config.output.format) &&\n context.config.output.format.length > 1\n ) {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n toArray(context.config.output.format)[0]\n )\n };\n context.packageJson.bin = toArray(context.config.output.format).reduce(\n (ret, format) => {\n ret[`${kebabCase(getAppName(context))}-${format}`] =\n formatBinaryPath(format);\n\n return ret;\n },\n context.packageJson.bin\n );\n } else {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n context.config.output.format\n )\n };\n }\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n }\n\n if (!isSetObject(context.packageJson.bin)) {\n throw new Error(\n \"Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.\"\n );\n }\n\n context.config.bin = Object.keys(context.packageJson.bin);\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA0BX,SAAgB,iBAAc,QAAA;AAC3B,QAAO,cAAA,WAAA,SAAA,MAAA,QAAA,OAAA,IAAA,OAAA,SAAA,MAAA,GACA,QACA;;AAEV,iBAAY,SAAA;CAAA;CAAA;CAAA;CAAA;AACZ,eAAI,wBAAA,SAAA;CACJ,MAAA,kBAAA,UAAA,QAAA,gBAAA,eAAA,QAAA,OAAA,MAAA,eAAA;2BAEO,MAAM,QAAS,QAAA,OAAA,IAAA,IACpB,QAAS,OAAA,IAAA,SAAA,GAAA;AACR,UAAa,YAAC,MAAA,OAAA,YAAA,UAAA,QAAA,QAAA,OAAA,IAAA,CAAA,CAAA,IAAA,cAAA,QAAA,CACT,KACI,iBAAgB,QAAA,OAAa,OAAA,OAAA,CACrC,EAAO;GAAC;GAAO;GAAI;GAAA,CAAA,CAAA,CAAA;AAClB,QAAQ,QAAI,GAAA,MAAA,iBAAA,UAAA,UAAA,QAAA,YAAA,CAAA;QAEZ;AACD,MAAQ,MAAM,QAAM,QAAA,OAAA,OAAA,OAAA,IACd,QAAQ,OAAQ,OAAO,OAAM,SAAA,GAAA;AAC3B,WAAO,YAAa,MAAA,GAC5B,UAAA,WAAA,QAAA,CAAA,GAAA,iBAAA,QAAA,QAAA,OAAA,OAAA,OAAA,CAAA,GAAA,EACQ;AACN,WAAU,YAAgB,MAAM,QAAO,QAAS,OAAE,OAAA,OAAA,CAAA,OAAA,cAAA,KAAA,WAAA;AAC7C,QAAA,GAAA,UAAA,WAAA,QAAA,CAAA,CAAA,GAAA,YACH,iBAAyB,OAAO;AACjC,WAAA;MACF;IAAA;IAAA;IAAA;IAAA;IAAA,CAAA,EAAA,QAAA,YAAA,IAAA;QAGC,SAAA,YAAe,MAAA,GACL,UAAU,WAAQ,QAAW,CAAA,GAAA,iBAAA,QAAA,OAAA,OAAA,OAAA,EACxC;AAEE,QAAA,QAAA,GAAA,MAAA,iBAAA,UAAA,UAAA,QAAA,YAAA,CAAA;;AAEH,KAAE,CAAA,YAAe,QAAO,YAAa,IAAG,CACtC,OAAA,IAAA,MAAA,0KAAA;AAEF,SAAK,OAAU,MAAA,OAAW,KAAO,QAAK,YAAA,IAAgB;;AAE1D,wBAAQ,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"update-package-json.mjs","names":[],"sources":["../../src/helpers/update-package-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getAppName } from \"../plugin-utils/context-helpers\";\nimport type { Context } from \"../types/context\";\n\nexport function formatBinaryPath(\n format: string | string[] | undefined\n): string {\n return `./dist/bin.${\n format === \"cjs\" || (Array.isArray(format) && format.includes(\"cjs\"))\n ? \"cjs\"\n : \"mjs\"\n }`;\n}\n\nexport async function updatePackageJsonBinary(context: Context): Promise<void> {\n const packageJsonPath = joinPaths(\n context.config.cwd,\n context.config.root,\n \"package.json\"\n );\n\n if (!context.packageJson) {\n const packageJson = await context.fs.read(packageJsonPath);\n if (packageJson) {\n context.packageJson ??= JSON.parse(packageJson);\n }\n }\n\n if (context.packageJson) {\n if (\n context.config.bin &&\n Array.isArray(context.config.bin) &&\n context.config.bin.length > 0\n ) {\n context.packageJson.bin = Object.fromEntries(\n getUnique(toArray(context.config.bin)).map(bin => [\n bin,\n formatBinaryPath(context.config.output.format)\n ])\n );\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n } else {\n if (\n Array.isArray(context.config.output.format) &&\n context.config.output.format.length > 1\n ) {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n toArray(context.config.output.format)[0]\n )\n };\n context.packageJson.bin = toArray(context.config.output.format).reduce(\n (ret, format) => {\n ret[`${kebabCase(getAppName(context))}-${format}`] =\n formatBinaryPath(format);\n\n return ret;\n },\n context.packageJson.bin\n );\n } else {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n context.config.output.format\n )\n };\n }\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n }\n\n if (!isSetObject(context.packageJson.bin)) {\n throw new Error(\n \"Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.\"\n );\n }\n\n context.config.bin = context.packageJson.bin;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;AA0BT,SAAgB,iBAAc,QAAA;AAC5B,QAAO,cAAC,WAAA,SAAA,MAAA,QAAA,OAAA,IAAA,OAAA,SAAA,MAAA,GAAA,QAAA;;AAEV,iBAAgB,SAAS;CAAA;CAAM;CAA0B;CAAe;AACxE,eAAY,wBAAA,SAAA;CACV,MAAM,kBAAI,UAAA,QAAA,OAAA,KAAA,QAAA,OAAA,MAAA,eAAA;AACV,KAAE,CAAA,QAAA,aAAA;EACJ,MAAA,cAAA,MAAA,QAAA,GAAA,KAAA,gBAAA;kBAEM,SAAO,gBAAS,KAAA,MAAA,YAA+B;;AAGnD,KAAE,QAAQ,aAAW;AACnB,MAAC,QAAQ,OAAI,OAAA,MAAA,QAAA,QAAA,OAAA,IAAA,IAAA,QAAA,OAAA,IAAA,SAAA,GAAA;AACd,WAAA,YAAA,MAAA,OAAA,YAAA,UAAA,QAAA,QAAA,OAAA,IAAA,CAAA,CAAA,IAAA,cAAA,QAAA,CAAA,KAAA,iBAAA,QAAA,OAAA,OAAA,OAAA,CAAA,EAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA,CAAA;;SAEI;AACH,OAAM,MAAA,QAAc,QAAM,OAAQ,OAAQ,OAAA,IAAA,QAAgB,OAAA,OAAA,OAAA,SAAA,GAAA;AACtD,YAAA,YAAa,MAAA,GACf,UAAQ,WAAgB,QAAU,CAAC,GAAA,iBAAY,QAAA,QAAA,OAAA,OAAA,OAAA,CAAA,GAAA,EACjD;AACF,YAAA,YAAA,MAAA,QAAA,QAAA,OAAA,OAAA,OAAA,CAAA,OAAA,cAAA,KAAA,WAAA;;AAEI,YAAQ;OACP;KAAA;KAAA;KAAA;KAAA;KAAA,CAAA,EAAA,QAAA,YAAA,IAAA;SAED,SAAM,YAAgB,MAAM,GAC5B,UAAe,WAAW,QAAE,CAAA,GAAA,iBAAA,QAAA,OAAA,OAAA,OAAA,EAC5B;AAEA,SAAE,QAAU,GAAA,MAAQ,iBAAoB,UAAU,UAAE,QAAA,YAAA,CAAA;;AAEtD,MAAI,CAAC,YAAC,QAAiB,YAAc,IAAC,CACpC,OAAG,IAAA,MAAA,0KAAA;;;;AAKT,wBAAkB,SAAU;CAAA;CAAQ;CAAW;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.mjs","names":[],"sources":["../../src/helpers/utilities.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 { TreeItem } from \"@stryke/cli/utils/tree\";\nimport { formatTree } from \"@stryke/cli/utils/tree\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport type { CommandBase, CommandOption, CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\n\nfunction innerFormatCommandTree(command: CommandTree): TreeItem {\n return {\n name: `${command.name}${command.isVirtual ? \" (virtual)\" : \"\"}`,\n children: Object.values(command.children ?? {}).map(innerFormatCommandTree)\n };\n}\n\nexport function formatCommandTree(context: Context): string {\n return formatTree({\n name: context.config.name,\n children: Object.values(context.commands ?? {}).map(innerFormatCommandTree)\n });\n}\n\n/**\n * Retrieves the global command options based on the context configuration.\n *\n * @param context - The build context.\n * @param command - The command for which to retrieve global options.\n * @returns A record of global command options.\n */\nexport function getGlobalOptions(\n context: Context,\n command: CommandBase\n): Record<string, CommandOption> {\n let options!: Record<string, CommandOption>;\n if (Array.isArray(context.config.globalOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.globalOptions,\n (item: CommandOption) => item.name\n ).map(option => [option.name, option])\n );\n } else if (isFunction(context.config.globalOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.globalOptions(context, command),\n (item: CommandOption) => item.name\n ).map(option => [option.name, option])\n );\n } else {\n options = {};\n }\n\n return Object.fromEntries(\n Object.entries(options).map(([key, value]) => [\n key,\n { ...value, env: value.env ?? constantCase(key) }\n ])\n );\n}\n"],"mappings":";;;;;;AAAA,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;;AAE5D,IAAG,SAAS;;;AAOhB,SAAS,uBAAuB,SAAG;AAClC,QAAU;EACV,MAAa,GAAG,QAAQ,OAAO,QAAQ,YAAA,eAA2B;EAC3D,UAAU,OAAO,OAAO,QAAG,YAAiB,EAAC,CAAA,CAAA,IAAA,uBAAA;;;;;;;;;AAIrD,SAAgB,kBAAkB,SAAS;;EAEpC,MAAO,QAAQ,OAAO;EACrB,UAAC,OAAa,OAAO,QAAW,YAAW,EAAA,CAAA,CAAA,IAAA,uBAAA;EACnD,CAAM;;AAEN,kBAAS,SAAkB;CAAC;CAAQ;CAAc;CAAU;CAAA;;;;;;;;AAQ5D,SAAG,iBAAA,SAAA,SAAA;CACH,IAAA;iDAEO,WAAS,OAAA,YAAkB,YAAS,QAAU,OAAO,eAAA,cAAA,SAAA,KAAA,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,IAAA,cAAA,WAAA,CAAA,OAAA,MAAA,OAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;UAElD,WAAc,QAAK,OAAA,cAAA,CACzB,WAAU,OAAO,YAAe,YAAa,QAAO,OAAA,cAAsB,SAAA,QAAA,EAAA,cAAA,SAAA,KAAA,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,IAAA,cAAA,WAAA,CAAA,OAAA,MAAA,OAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;AAK3E,QAAA,OAAc,YAAO,OAAQ,QAAa,QAAQ,CAAA,IAAA,cAAQ,CAAA,KAAa,WAAA,CACzE,KACG;EAAM,GAAA;EAAU,KAAI,MAAM,OAAO,aAAA,IAAA;EAAA,CACjC,EAAA;EAAA;EAAc;EAAE;EAAY,CAAA,CAAA,CAAG;;AAEnC,iBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"utilities.mjs","names":[],"sources":["../../src/helpers/utilities.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 { TreeItem } from \"@stryke/cli/utils/tree\";\nimport { formatTree } from \"@stryke/cli/utils/tree\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport type { CommandBase, CommandOption, CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\n\nfunction innerFormatCommandTree(command: CommandTree): TreeItem {\n return {\n name: `${command.name}${command.isVirtual ? \" (virtual)\" : \"\"}`,\n children: Object.values(command.children ?? {}).map(innerFormatCommandTree)\n };\n}\n\nexport function formatCommandTree(context: Context): string {\n return formatTree({\n name: context.config.name,\n children: Object.values(context.commands ?? {}).map(innerFormatCommandTree)\n });\n}\n\n/**\n * Retrieves the global command options based on the context configuration.\n *\n * @param context - The build context.\n * @param command - The command for which to retrieve global options.\n * @returns A record of global command options.\n */\nexport function getGlobalOptions(\n context: Context,\n command: CommandBase\n): Record<string, CommandOption> {\n let options!: Record<string, CommandOption>;\n if (Array.isArray(context.config.globalOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.globalOptions,\n (item: CommandOption) => item.name\n ).map(option => [option.name, option])\n );\n } else if (isFunction(context.config.globalOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.globalOptions(context, command),\n (item: CommandOption) => item.name\n ).map(option => [option.name, option])\n );\n } else {\n options = {};\n }\n\n return Object.fromEntries(\n Object.entries(options).map(([key, value]) => [\n key,\n { ...value, env: value.env ?? constantCase(key) }\n ])\n );\n}\n"],"mappings":";;;;;;AAAA,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;;AAE9D,IAAG,SAAS;;;AAOd,SAAS,uBAAuB,SAAG;AAClC,QAAA;EACA,MAAA,GAAA,QAAoB,OAAM,QAAQ,YAAK,eAAkB;EACzD,UAAa,OAAO,OAAM,QAAQ,YAAa,EAAC,CAAA,CAAG,IAAC,uBAAA;;;;;;;;;AAIrD,SAAgB,kBAAkB,SAAS;;EAE3C,MAAO,QAAO,OAAW;EACzB,UAAS,OAAY,OAAO,QAAQ,YAAU,EAAI,CAAC,CAAA,IAAA,uBAAA;EACnD,CAAA;;AAEA,kBAAS,SAAkB;CAAC;CAAQ;CAAc;CAAU;CAAA;;;;;;;;AAQ5D,SAAG,iBAAA,SAAA,SAAA;CACH,IAAA;iDAEA,WAAO,OAAS,YAAiB,YAAU,QAAU,OAAO,eAAA,cAAA,SAAA,KAAA,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,IAAA,cAAA,WAAA,CAAA,OAAA,MAAA,OAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;UACnD,WAAW,QAAA,OAAA,cAAA,CAChB,WAAM,OAAQ,YAAW,YAAA,QAAA,OAAA,cAAA,SAAA,QAAA,EAAA,cAAA,SAAA,KAAA,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,IAAA,cAAA,WAAA,CAAA,OAAA,MAAA,OAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;KAEzB,WAAA,EAAA;;EAGF,GAAA;EACC,KAAA,MAAU,OAAI,aAAe,IAAO;EACtC,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;AAED,iBAAiB,SAAO;CAAA;CAAY;CAAS;CAAgB;OAAO;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validations.mjs","names":[],"sources":["../../src/helpers/validations.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 { CommandTree } from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface ValidationFailure {\n code: string;\n details: string;\n}\n\nexport function validateArguments(command: CommandTree): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n let sequential = false;\n for (const argument of command.args ?? []) {\n if (\n (argument.kind === CommandParameterKinds.string ||\n argument.kind === CommandParameterKinds.number) &&\n argument.variadic\n ) {\n if (!sequential) {\n sequential = true;\n } else {\n failures.push({\n code: \"SEQUENTIAL_VARIADIC_ARGUMENTS\",\n details: `Sequential variadic arguments are not allowed - since the argument preceding ${argument.name} is variadic, it must not also be variadic.`\n });\n }\n } else {\n sequential = false;\n }\n }\n\n return failures;\n}\n\nexport function validateOptions(command: CommandTree): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n const optionNames = new Set<string>();\n for (const option of Object.values(command.options ?? {})) {\n if (optionNames.has(option.name)) {\n failures.push({\n code: \"DUPLICATE_OPTION_NAME\",\n details: `Duplicate option name \"${option.name}\" found in command.`\n });\n }\n optionNames.add(option.name);\n\n for (const alias of option.alias) {\n if (optionNames.has(alias)) {\n failures.push({\n code: \"DUPLICATE_OPTION_ALIAS\",\n details: `Duplicate option name \"${alias}\" (an alias of \"${\n option.name\n }\") found in command.`\n });\n }\n optionNames.add(alias);\n }\n }\n\n return failures;\n}\n\nexport function validateCommand(command: CommandTree): ValidationFailure[] {\n const results: ValidationFailure[] = [];\n\n let failures = validateOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateArguments(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n return results;\n}\n"],"mappings":";;;AAkBA,MAAM,uBAAsB;CAAA;CAAS;CAAM;CAAA;CAAA;;CAG3C,MAAO,WAAU,EAAA;CACf,IAAM,aAAM;AACZ,MAAO,MAAE,YAAM,QAAA,QAAA,EAAA,CACjB,MAAA,SAAA,SAAA,sBAAA,6DAEO,SAAS,SACR,KAAQ,CAAC;KAIV,UAAA,KAAA;EACa,MAAK;EACR,SAAS,gFAA+B,SAAA,KAAA;EAC1C,CAAA;KAIH,cAAC;AAGT,QAAM;;AAEV,kBAAM,SAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;AACN,SAAW,gBAAA,SAAA;CACP,MAAE,WAAa,EAAA;CACf,MAAA,eAAA,IAAA,IAAA,CAAA,CAAA,IAAA,CAAA,kBAAA,IAAA,KAAA;AACF,MAAA,MAAA,UAAA,OAAA,OAAA,QAAA,WAAA,EAAA,CAAA,EAAA;mCAEO,UAAQ,KAAA;GACjB,MAAA;;GAEO,CAAA;;AAGC,OAAA,MAAW,SAAO,OAAI,OAAS;AAC3B,OAAC,YAAU,IAAO,MAAO,CAC7B,UAAgB,KAAM;IACV,MAAA;IACL,SAAA,0BAAsB,MAAA,kBAAA,OAAA,KAAA;IACpB,CAAC;AAEd,eAAA,IAAA,MAAA;;;AAGA,QAAK;;AAET,gBAAgB,SAAM;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;AACtB,SAAgB,gBAAC,SAAuB;CACpC,MAAM,UAAU,EAAA;CAChB,IAAI,WAAW,gBAAA,QAAA;AACf,KAAI,SAAM,SAAS,EACf,SAAE,KAAA,GAAA,SAAA;AAEN,YAAE,kBAAsB,QAAA;AACxB,KAAA,SAAA,SAAA,EACF,SAAA,KAAA,GAAA,SAAA;AAEA,QAAO"}
1
+ {"version":3,"file":"validations.mjs","names":[],"sources":["../../src/helpers/validations.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 { CommandTree } from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface ValidationFailure {\n code: string;\n details: string;\n}\n\nexport function validateArguments(command: CommandTree): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n let sequential = false;\n for (const argument of command.args ?? []) {\n if (\n (argument.kind === CommandParameterKinds.string ||\n argument.kind === CommandParameterKinds.number) &&\n argument.variadic\n ) {\n if (!sequential) {\n sequential = true;\n } else {\n failures.push({\n code: \"SEQUENTIAL_VARIADIC_ARGUMENTS\",\n details: `Sequential variadic arguments are not allowed - since the argument preceding ${argument.name} is variadic, it must not also be variadic.`\n });\n }\n } else {\n sequential = false;\n }\n }\n\n return failures;\n}\n\nexport function validateOptions(command: CommandTree): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n const optionNames = new Set<string>();\n for (const option of Object.values(command.options ?? {})) {\n if (optionNames.has(option.name)) {\n failures.push({\n code: \"DUPLICATE_OPTION_NAME\",\n details: `Duplicate option name \"${option.name}\" found in command.`\n });\n }\n optionNames.add(option.name);\n\n for (const alias of option.alias) {\n if (optionNames.has(alias)) {\n failures.push({\n code: \"DUPLICATE_OPTION_ALIAS\",\n details: `Duplicate option name \"${alias}\" (an alias of \"${\n option.name\n }\") found in command.`\n });\n }\n optionNames.add(alias);\n }\n }\n\n return failures;\n}\n\nexport function validateCommand(command: CommandTree): ValidationFailure[] {\n const results: ValidationFailure[] = [];\n\n let failures = validateOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateArguments(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n return results;\n}\n"],"mappings":";;;AAkBA,MAAM,uBAAsB;CAAA;CAAS;CAAM;CAAA;CAAA;;CAG3C,MAAO,WAAU,EAAA;CACf,IAAI,aAAQ;AACZ,MAAA,MAAS,YAAM,QAAA,QAAA,EAAA,CACjB,MAAA,SAAA,SAAA,sBAAA,UAAA,SAAA,SAAA,sBAAA,WAAA,SAAA,0BAEO,cAAS;;EAGV,MAAU;EACT,SAAM,gFAAgC,SAAA,KAAA;EACtC,CAAA;KAGD,cAAS;AAGb,QAAM;;AAER,kBAAiB,SAAK;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;AACtB,SAAgB,gBAAC,SAAA;CACf,MAAM,WAAW,EAAC;CAClB,MAAM,eAAE,IAAA,IAAA,CAAA,CAAA,IAAA,CAAA,kBAAA,IAAA,KAAA;AACR,MAAI,MAAA,UAAA,OAAA,OAAA,QAAA,WAAA,EAAA,CAAA,EAAA;AACF,MAAE,YAAK,IAAA,OAAA,KAAA,CACL,UAAA,KAAa;GACf,MAAA;GACF,SAAA,0BAAA,OAAA,KAAA;;AAGF,cAAA,IAAA,OAAA,KAAA;;AAEM,OAAC,YAAS,IAAA,MAAgB,CACxB,UAAS,KAAC;;IAEV,SAAW,0BAAoB,MAAA,kBAAA,OAAA,KAAA;IAChC,CAAA;AAED,eAAS,IAAK,MAAA;;;AAGlB,QAAM;;AAER,gBAAgB,SAAI;CAAM;CAAM;OAAA;CAAA;CAAA;CAAA;;CAE9B,MAAM,UAAO,EAAK;CAClB,IAAI,WAAI,gBAAuB,QAAC;AAChC,KAAI,SAAE,SAAc,EAClB,SAAM,KAAO,GAAA,SAAA;AAEf,YAAU,kBAAO,QAAA;AACjB,KAAI,SAAQ,SAAS,EACnB,SAAM,KAAA,GAAA,SAAA;AAER,QAAI;;AAEN,gBAAE,SAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA"}
package/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ exports.__ΩCommandParameterKind = require_types_command.__ΩCommandParameterKin
32
32
  exports.__ΩCommandParameterType = require_types_command.__ΩCommandParameterType;
33
33
  exports.__ΩCommandTree = require_types_command.__ΩCommandTree;
34
34
  exports.__ΩContext = require_types_context.__ΩContext;
35
+ exports.__ΩEngineOptions = require_types_config.__ΩEngineOptions;
35
36
  exports.__ΩNumberCommandParameter = require_types_command.__ΩNumberCommandParameter;
36
37
  exports.__ΩNumberCommandParameterConfig = require_types_command.__ΩNumberCommandParameterConfig;
37
38
  exports.__ΩOptions = require_types_config.__ΩOptions;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsCommandParameterConfig, BaseBooleanCommandParameter, BaseCommandParameter, BaseNumberCommandParameter, BaseSingleCommandParameter, BaseStringCommandParameter, BaseVariadicCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, NumberCommandParameter, NumberCommandParameterConfig, SerializedCommandTree, SingleBooleanCommandParameter, SingleNumberCommandParameter, SingleStringCommandParameter, StringCommandParameter, StringCommandParameterConfig, VariadicBooleanCommandParameter, VariadicNumberCommandParameter, VariadicStringCommandParameter } from "./types/command.cjs";
2
2
  import { Context, UnresolvedContext } from "./types/context.cjs";
3
- import { Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig } from "./types/config.cjs";
3
+ import { EngineOptions, Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig } from "./types/config.cjs";
4
4
  import { ShellShockAPI, createShellShock } from "./api.cjs";
5
5
  import { BaseCommandOptions } from "./types/options.cjs";
6
- export { AsCommandParameterConfig, BaseBooleanCommandParameter, BaseCommandOptions, BaseCommandParameter, BaseNumberCommandParameter, BaseSingleCommandParameter, BaseStringCommandParameter, BaseVariadicCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ReferenceOptions, ResolvedConfig, SerializedCommandTree, ShellShockAPI, SingleBooleanCommandParameter, SingleNumberCommandParameter, SingleStringCommandParameter, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, VariadicBooleanCommandParameter, VariadicNumberCommandParameter, VariadicStringCommandParameter, createShellShock };
6
+ export { AsCommandParameterConfig, BaseBooleanCommandParameter, BaseCommandOptions, BaseCommandParameter, BaseNumberCommandParameter, BaseSingleCommandParameter, BaseStringCommandParameter, BaseVariadicCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, EngineOptions, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ReferenceOptions, ResolvedConfig, SerializedCommandTree, ShellShockAPI, SingleBooleanCommandParameter, SingleNumberCommandParameter, SingleStringCommandParameter, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, VariadicBooleanCommandParameter, VariadicNumberCommandParameter, VariadicStringCommandParameter, createShellShock };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsCommandParameterConfig, BaseBooleanCommandParameter, BaseCommandParameter, BaseNumberCommandParameter, BaseSingleCommandParameter, BaseStringCommandParameter, BaseVariadicCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, NumberCommandParameter, NumberCommandParameterConfig, SerializedCommandTree, SingleBooleanCommandParameter, SingleNumberCommandParameter, SingleStringCommandParameter, StringCommandParameter, StringCommandParameterConfig, VariadicBooleanCommandParameter, VariadicNumberCommandParameter, VariadicStringCommandParameter } from "./types/command.mjs";
2
2
  import { Context, UnresolvedContext } from "./types/context.mjs";
3
- import { Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig } from "./types/config.mjs";
3
+ import { EngineOptions, Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig } from "./types/config.mjs";
4
4
  import { ShellShockAPI, createShellShock } from "./api.mjs";
5
5
  import { BaseCommandOptions } from "./types/options.mjs";
6
- export { AsCommandParameterConfig, BaseBooleanCommandParameter, BaseCommandOptions, BaseCommandParameter, BaseNumberCommandParameter, BaseSingleCommandParameter, BaseStringCommandParameter, BaseVariadicCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ReferenceOptions, ResolvedConfig, SerializedCommandTree, ShellShockAPI, SingleBooleanCommandParameter, SingleNumberCommandParameter, SingleStringCommandParameter, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, VariadicBooleanCommandParameter, VariadicNumberCommandParameter, VariadicStringCommandParameter, createShellShock };
6
+ export { AsCommandParameterConfig, BaseBooleanCommandParameter, BaseCommandOptions, BaseCommandParameter, BaseNumberCommandParameter, BaseSingleCommandParameter, BaseStringCommandParameter, BaseVariadicCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, EngineOptions, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ReferenceOptions, ResolvedConfig, SerializedCommandTree, ShellShockAPI, SingleBooleanCommandParameter, SingleNumberCommandParameter, SingleStringCommandParameter, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, VariadicBooleanCommandParameter, VariadicNumberCommandParameter, VariadicStringCommandParameter, createShellShock };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CommandParameterKinds, __ΩAsCommandParameterConfig, __ΩBaseBooleanCommandParameter, __ΩBaseCommandParameter, __ΩBaseNumberCommandParameter, __ΩBaseSingleCommandParameter, __ΩBaseStringCommandParameter, __ΩBaseVariadicCommandParameter, __ΩBooleanCommandOption, __ΩBooleanCommandParameter, __ΩBooleanCommandParameterConfig, __ΩCommandArgument, __ΩCommandArgumentConfig, __ΩCommandBase, __ΩCommandConfig, __ΩCommandMetadata, __ΩCommandModule, __ΩCommandOption, __ΩCommandOptionConfig, __ΩCommandParameter, __ΩCommandParameterConfig, __ΩCommandParameterKind, __ΩCommandParameterType, __ΩCommandTree, __ΩNumberCommandParameter, __ΩNumberCommandParameterConfig, __ΩSerializedCommandTree, __ΩSingleBooleanCommandParameter, __ΩSingleNumberCommandParameter, __ΩSingleStringCommandParameter, __ΩStringCommandParameter, __ΩStringCommandParameterConfig, __ΩVariadicBooleanCommandParameter, __ΩVariadicNumberCommandParameter, __ΩVariadicStringCommandParameter } from "./types/command.mjs";
2
- import { __ΩOptions, __ΩOutputConfig, __ΩReferenceOptions, __ΩResolvedConfig, __ΩUserConfig } from "./types/config.mjs";
2
+ import { __ΩEngineOptions, __ΩOptions, __ΩOutputConfig, __ΩReferenceOptions, __ΩResolvedConfig, __ΩUserConfig } from "./types/config.mjs";
3
3
  import { __ΩContext, __ΩUnresolvedContext } from "./types/context.mjs";
4
4
  import { __ΩBaseCommandOptions } from "./types/options.mjs";
5
5
  import { ShellShockAPI, createShellShock } from "./api.mjs";
6
6
 
7
- export { CommandParameterKinds, ShellShockAPI, __ΩAsCommandParameterConfig, __ΩBaseBooleanCommandParameter, __ΩBaseCommandOptions, __ΩBaseCommandParameter, __ΩBaseNumberCommandParameter, __ΩBaseSingleCommandParameter, __ΩBaseStringCommandParameter, __ΩBaseVariadicCommandParameter, __ΩBooleanCommandOption, __ΩBooleanCommandParameter, __ΩBooleanCommandParameterConfig, __ΩCommandArgument, __ΩCommandArgumentConfig, __ΩCommandBase, __ΩCommandConfig, __ΩCommandMetadata, __ΩCommandModule, __ΩCommandOption, __ΩCommandOptionConfig, __ΩCommandParameter, __ΩCommandParameterConfig, __ΩCommandParameterKind, __ΩCommandParameterType, __ΩCommandTree, __ΩContext, __ΩNumberCommandParameter, __ΩNumberCommandParameterConfig, __ΩOptions, __ΩOutputConfig, __ΩReferenceOptions, __ΩResolvedConfig, __ΩSerializedCommandTree, __ΩSingleBooleanCommandParameter, __ΩSingleNumberCommandParameter, __ΩSingleStringCommandParameter, __ΩStringCommandParameter, __ΩStringCommandParameterConfig, __ΩUnresolvedContext, __ΩUserConfig, __ΩVariadicBooleanCommandParameter, __ΩVariadicNumberCommandParameter, __ΩVariadicStringCommandParameter, createShellShock };
7
+ export { CommandParameterKinds, ShellShockAPI, __ΩAsCommandParameterConfig, __ΩBaseBooleanCommandParameter, __ΩBaseCommandOptions, __ΩBaseCommandParameter, __ΩBaseNumberCommandParameter, __ΩBaseSingleCommandParameter, __ΩBaseStringCommandParameter, __ΩBaseVariadicCommandParameter, __ΩBooleanCommandOption, __ΩBooleanCommandParameter, __ΩBooleanCommandParameterConfig, __ΩCommandArgument, __ΩCommandArgumentConfig, __ΩCommandBase, __ΩCommandConfig, __ΩCommandMetadata, __ΩCommandModule, __ΩCommandOption, __ΩCommandOptionConfig, __ΩCommandParameter, __ΩCommandParameterConfig, __ΩCommandParameterKind, __ΩCommandParameterType, __ΩCommandTree, __ΩContext, __ΩEngineOptions, __ΩNumberCommandParameter, __ΩNumberCommandParameterConfig, __ΩOptions, __ΩOutputConfig, __ΩReferenceOptions, __ΩResolvedConfig, __ΩSerializedCommandTree, __ΩSingleBooleanCommandParameter, __ΩSingleNumberCommandParameter, __ΩSingleStringCommandParameter, __ΩStringCommandParameter, __ΩStringCommandParameterConfig, __ΩUnresolvedContext, __ΩUserConfig, __ΩVariadicBooleanCommandParameter, __ΩVariadicNumberCommandParameter, __ΩVariadicStringCommandParameter, createShellShock };
@@ -26,7 +26,7 @@ function computeBin(context) {
26
26
  alias: [],
27
27
  tags: [],
28
28
  source: "file",
29
- options: Object.fromEntries(context.options.map(__assignType((option) => [option.name, option], [
29
+ options: Object.fromEntries(context.globalOptions.map(__assignType((option) => [option.name, option], [
30
30
  "option",
31
31
  "",
32
32
  "P\"2!\"/\""
@@ -25,7 +25,7 @@ function computeBin(context) {
25
25
  alias: [],
26
26
  tags: [],
27
27
  source: "file",
28
- options: Object.fromEntries(context.options.map(__assignType((option) => [option.name, option], [
28
+ options: Object.fromEntries(context.globalOptions.map(__assignType((option) => [option.name, option], [
29
29
  "option",
30
30
  "",
31
31
  "P\"2!\"/\""
@@ -1 +1 @@
1
- {"version":3,"file":"compute-bin.mjs","names":[],"sources":["../../src/plugin-utils/compute-bin.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 { computed } from \"@alloy-js/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, Context } from \"../types\";\nimport { getAppDescription, getAppName, getAppTitle } from \"./context-helpers\";\n\n/**\n * Compute the command tree for the CLI application, starting from the root bin command. This will be used to determine which commands are available in the CLI application and their respective details.\n *\n * @param context - The plugin context containing the necessary information to compute the command tree.\n * @returns The computed command tree for the CLI application, starting from the root bin command. This will include all commands discovered in the project and their respective details, organized in a hierarchical structure based on their segments and paths.\n */\nexport function computeBin(context: Context): CommandTree {\n const bin = computed(() => ({\n id: \"\",\n name: getAppName(context),\n title: getAppTitle(context),\n description: getAppDescription(context),\n isVirtual: true,\n path: null,\n segments: [],\n alias: [],\n tags: [],\n source: \"file\",\n options: Object.fromEntries(\n context.options.map(option => [option.name, option])\n ),\n args: [],\n entry: {\n file: joinPaths(context.entryPath, \"bin.ts\")\n },\n parent: null,\n children: context.commands\n }));\n\n return bin.value;\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA4BX,SAAc,WAAa,SAAG;AAoB1B,QAnBM,gBAAA;EACF,IAAE;EACN,MAAO,WAAY,QAAQ;EAC3B,OAAW,YAAE,QAAkB;EAC/B,aAAe,kBAAA,QAAA;EACX,WAAM;EACV,MAAU;EACV,UAAS,EAAA;EACL,OAAI,EAAA;EACR,MAAS,EAAA;EACT,QAAS;EACP,SAAQ,OAAQ,YAAc,QAAQ,QAAM,IAAM,cAAC,WAAA,CAAA,OAAA,MAAA,OAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA,CAAA;EACpD,MAAA,EAAA;EACG,OAAI,EACD,MAAA,UAAA,QAAA,WAAA,SAAA,EACL;EACD,QAAA;EACD,UAAY,QAAA;EACZ,EAAA,CACC;;AAEL,WAAS,SAAS;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"compute-bin.mjs","names":[],"sources":["../../src/plugin-utils/compute-bin.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 { computed } from \"@alloy-js/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, Context } from \"../types\";\nimport { getAppDescription, getAppName, getAppTitle } from \"./context-helpers\";\n\n/**\n * Compute the command tree for the CLI application, starting from the root bin command. This will be used to determine which commands are available in the CLI application and their respective details.\n *\n * @param context - The plugin context containing the necessary information to compute the command tree.\n * @returns The computed command tree for the CLI application, starting from the root bin command. This will include all commands discovered in the project and their respective details, organized in a hierarchical structure based on their segments and paths.\n */\nexport function computeBin(context: Context): CommandTree {\n const bin = computed(() => ({\n id: \"\",\n name: getAppName(context),\n title: getAppTitle(context),\n description: getAppDescription(context),\n isVirtual: true,\n path: null,\n segments: [],\n alias: [],\n tags: [],\n source: \"file\",\n options: Object.fromEntries(\n context.globalOptions.map(option => [option.name, option])\n ),\n args: [],\n entry: {\n file: joinPaths(context.entryPath, \"bin.ts\")\n },\n parent: null,\n children: context.commands\n }));\n\n return bin.value;\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;;;;;;;AA4BT,SAAc,WAAa,SAAG;AAoB5B,QAnBQ,gBAAA;EACN,IAAI;EACJ,MAAM,WAAC,QAAY;EACnB,OAAA,YAAa,QAAA;EACb,aAAW,kBAAI,QAAA;EACf,WAAU;EACV,MAAA;EACA,UAAS,EAAA;EACT,OAAO,EAAC;EACR,MAAM,EAAE;EACR,QAAQ;EACR,SAAS,OAAC,YAAkB,QAAQ,cAAc,IAAE,cAAO,WAAA,CAAA,OAAA,MAAA,OAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA,CAAA;EAC3D,MAAC,EAAA;EACD,OAAO,EACP,MAAO,UAAA,QAAA,WAAA,SAAA,EACN;EACD,QAAC;EACD,UAAQ,QAAI;EACb,EACE,CAAA;;AAEL,WAAS,SAAS;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return (\n replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title\n ).trim();\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA6BX,SAAc,eAAc,SAAA;AACxB,KAAA,QAAS,WAAA,EACX,QAAA,EAAA;CAEA,MAAM,SAAS,QAAQ,OAAO,cAAe,UAAS,MAAI,WAAA,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;AAC1D,QAAO,KAAO,GAAC,QAAQ,OAAO,cAAe,UAAS,MAAG,SAAA,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;;;;;;;AAG3D,eAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,SAAE,WAAA,SAAA;CACF,MAAO,SAAS,QAAW,OAAO,SAC1B,YAAO,QAAA,OAAA,IAAA,IACH,MAAO,QAAM,QAAA,OAAA,IAAA,IACT,QAAQ,OAAO,IAAI,SAAG,KAC3B,YAAgB,QAAO,OAAM,IAAA,GAAA,GAC1B,YAAW,QAAS,OAAG,IAAA,GACnB,QAAQ,OAAO,MACzB,QAAY,OAAQ,IAAO,KACzB,QAAQ,aAAO;AACrB,KAAI,CAAC,YAAS,OAAU,CACpB,OAAA,IAAQ,MAAA,qIAAkB;AAE9B,QAAM,UAAS,OAAA;;AAEnB,WAAK,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQL,SAAC,YAAA,SAAA,aAAA,OAAA;CACG,MAAM,QAAQ,QAAM,OAAM,SAC1B,UAAM,QAAa,OAAU,QAAQ,WAAK,QAAc,CAAA;AACxD,SAAQ,aACV,MAAA,QAAA,gFAAA,GAAA,GACK,OAAS,MAAA;;AAEhB,YAAY,SAAG;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOf,SAAI,kBAAA,SAAA;AACA,QAAI,QAAM,OAAO,eACb,QAAM,aAAY,eAClB,OAAG,YAAA,SAAA,KAAA,CAAA;;AAEX,kBAAQ,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOR,SAAU,UAAc,SAAM;AAC1B,QAAO,YAAK,QAAY,OAAA,IAAW,GACrC,OAAA,KAAA,QAAA,OAAA,IAAA,CAAA,KACK,UAAS,WAAA,QAAiB,CAAA;;AAEjC,UAAU,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;AAaV,SAAE,qBAAA,MAAA;AACF,QAAO,KAAS,WAAU,IAAA,IAAS,KAAA,SAAU,IAAO;;AAEpD,qBAAkB,SAAQ;CAAA;CAAa;CAAC;CAAA;CAAA;;;;;;;;;;;;AAYxC,SAAC,0BAAA,MAAA;AACG,QAAM,KAAM,WAAK,SAAa,GAAA,CAAA,WAAgB,SAAA,GAAA;;AAElD,0BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;;AAcF,SAAgB,mBAAc,MAAQ;AACpC,QAAA,KAAA,WAAA,IAAA,IAAA,KAAA,SAAA,IAAA,IAAA,KAAA,WAAA,IAAA;;AAEF,mBAAc,SAAc;CAAC;CAAQ;CAAsB;CAAE;CAAA;;;;;;;;;;;;;AAa7D,SAAgB,wBAAkB,MAAW;AACzC,QAAO,KACT,WAAA,SAAA,GAAA,CACK,WAAS,SAAA,GAAA,CACP,WAAM,QAAa,GAAG;;;;;;;;;;;;;;;;;;;AAc/B,SAAE,mBAAA,MAAA;AACF,QAAO,wBAAS,0BAA6C,KAAC,CAAA;;AAE9D,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return (\n replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title\n ).trim();\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;;;;;;;AA6BT,SAAc,eAAc,SAAA;AAC1B,KAAE,QAAS,WAAA,EACX,QAAA,EAAA;CAEA,MAAM,SAAS,QAAQ,OAAO,cAAS,UAAa,MAAM,WAAA,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;AAC1D,QAAO,KAAK,GAAG,QAAQ,OAAO,cAAS,UAAa,MAAK,SAAA,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;;;;;;;AAG3D,eAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,SAAE,WAAA,SAAA;CACF,MAAO,SAAS,QAAA,OAAW,SAAS,YAAiB,QAAG,OAAU,IAAM,IAAC,MAAA,QAAA,QAAA,OAAA,IAAA,IAAA,QAAA,OAAA,IAAA,SAAA,KAAA,YAAA,QAAA,OAAA,IAAA,GAAA,GAAA,YAAA,QAAA,OAAA,IAAA,GAAA,QAAA,OAAA,MAAA,QAAA,OAAA,IAAA,KAAA,QAAA,aAAA;AACvE,KAAA,CAAK,YAAQ,OAAA,CACX,OAAA,IAAQ,MAAO,qIAAM;AAEvB,QAAG,UAAc,OAAO;;AAE1B,WAAM,SAAY;CAAA;CAAsB;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQxC,SAAK,YAAA,SAAA,aAAA,OAAA;CACH,MAAA,QAAA,QAAA,OAAA,SAAA,UAAA,QAAA,OAAA,QAAA,WAAA,QAAA,CAAA;;;AAGF,YAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOA,SAAgB,kBAAkB,SAAS;AACzC,QAAA,QAAA,OAAA,eAAA,QAAA,aAAA,eAAA,OAAA,YAAA,SAAA,KAAA,CAAA;;AAEF,kBAAW,SAAA;CAAiB;CAAU;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOtC,SAAS,UAAA,SAAA;AACP,QAAE,YAAA,QAAA,OAAA,IAAA,GAAA,OAAA,KAAA,QAAA,OAAA,IAAA,CAAA,KAAA,UAAA,WAAA,QAAA,CAAA;;AAEJ,UAAU,SAAQ;CAAA;CAAa;CAAQ;CAAW;CAAsC;CAAA;;;;;;;;;;;;;AAaxF,SAAgB,qBAAiB,MAAA;AAC/B,QAAO,KAAE,WAAA,IAAkB,IAAE,KAAA,SAAA,IAAA;;AAE/B,qBAAS,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYT,SAAE,0BAAA,MAAA;AACF,QAAO,KAAA,WAAkB,SAAS,GAAC,CAAA,WAAU,SAAO,GAAA;;AAEpD,0BAA0B,SAAO;CAAG;CAAI;CAAA;CAAA;CAAA;;;;;;;;;;;;;;AAcxC,SAAgB,mBAAgB,MAAS;AACvC,QAAA,KAAA,WAAA,IAAA,IAAA,KAAA,SAAA,IAAA,IAAA,KAAA,WAAA,IAAA;;AAEF,mBAAc,SAAc;CAAC;CAAQ;CAAc;CAAA;CAAA;;;;;;;;;;;;;AAanD,SAAE,wBAAA,MAAA;AACF,QAAO,KAAA,WAAS,SAAA,GAAA,CAAA,WAAgC,SAAS,GAAA,CAAA,WAAO,QAAA,GAAA;;AAEhE,wBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYA,SAAgB,mBAAkB,MAAO;AACvC,QAAE,wBAA6B,0BAA0B,KAAC,CAAA;;AAE5D,mBAAgB,SAAA;CAAA;CAAmB;CAAuB;CAAA;CAAA"}
@@ -1,8 +1,8 @@
1
1
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  const require_types_command = require('../types/command.cjs');
3
3
  const require_type_checks = require('./type-checks.cjs');
4
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
4
  let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
5
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
6
6
 
7
7
  //#region src/plugin-utils/deepkit.ts
8
8
  /**
@@ -1,7 +1,7 @@
1
1
  import { CommandParameterKinds } from "../types/command.mjs";
2
2
  import { isCommandParameterKind } from "./type-checks.mjs";
3
- import { isSetObject } from "@stryke/type-checks/is-set-object";
4
3
  import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
4
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
5
5
 
6
6
  //#region src/plugin-utils/deepkit.ts
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/plugin-utils/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 { Type } from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n BaseCommandParameter,\n CommandParameterKind,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { isCommandParameterKind } from \"./type-checks\";\n\n/**\n * Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the reflection kind from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link ReflectionKind}.\n */\nexport function extractReflectionKind(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): ReflectionKind {\n if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.string) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.string)\n ) {\n return checkVariadic && (command as StringCommandParameter).variadic\n ? ReflectionKind.array\n : ReflectionKind.string;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.number) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.number)\n ) {\n return checkVariadic && (command as any).variadic\n ? ReflectionKind.array\n : ReflectionKind.number;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.boolean) ||\n (isSetObject(command) && command.kind === CommandParameterKinds.boolean)\n ) {\n return ReflectionKind.boolean;\n } else {\n return ReflectionKind.string;\n }\n}\n\n/**\n * Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the type from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link Type}.\n */\nexport function extractType(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): Type {\n const reflectionKind = extractReflectionKind(command, checkVariadic);\n if (reflectionKind === ReflectionKind.string) {\n return { kind: ReflectionKind.string };\n } else if (reflectionKind === ReflectionKind.number) {\n return { kind: ReflectionKind.number };\n } else if (reflectionKind === ReflectionKind.boolean) {\n return { kind: ReflectionKind.boolean };\n } else if (reflectionKind === ReflectionKind.array) {\n if (isCommandParameterKind(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n kind: command\n } as BaseCommandParameter,\n false\n )\n };\n } else if (isSetObject(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n ...command,\n kind: command.kind\n } as BaseCommandParameter,\n false\n )\n };\n } else {\n return {\n kind: ReflectionKind.array,\n type: { kind: ReflectionKind.string }\n };\n }\n } else {\n return { kind: ReflectionKind.string };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BE,KAAA,uBAAA,QAAA,IACC,YAAiB,sBAAsB,UACzC,YAAA,QAAA,IACS,QAAU,SAAI,sBAA0B,OAC9C,QAAM,iBAAgB,QAAW,WACzB,eAAgB,QAC1B,eAAA;UAES,uBAAuB,QAAA,IAChC,YAAgB,sBAAA,UACf,YAAe,QAAA,IACb,QAAA,SAAA,sBAAA,OACA,QAAA,iBAAuB,QAAU,WACxB,eAAI,QACb,eAAuB;UAExB,uBAAA,QAAA,IACA,YAAO,sBAA6B,WAChC,YAAA,QAAe,IAAA,QAAA,SAAA,sBAAA,QACf,QAAA,eAAqB;KAGvB,QAAS,eAAG;;AAGlB,sBAAI,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQJ,SAAI,YAAA,SAAA,gBAAA,MAAA;CACA,MAAM,iBAAgB,sBAAO,SAAA,cAAA;AAC7B,KAAI,mBAAC,eAAA,OACL,QAAO,EAAA,MAAA,eAAqB,QAAA;UAEhC,mBAAA,eAAA;UAGa,mBAAmB,eAAS,QACxC,QAAA,EAAA,MAAA,eAAA,SAAA;UAES,mBAAgB,eAAqB,MAC3C,KAAQ,uBAAqB,QAAK,CACpC,QAAA;EACc,MAAA,eAAW;EAChB,MAAA,YAAuB,EAChB,MAAA,SACV,EAAA,MAAA;EACA;UAES,YAAE,QAAe,CACtB,QAAC;EACA,MAAM,eAAe;EACrB,MAAA,YAAmB;GACb,GAAA;GACN,MAAA,QAAmB;GACxB,EAAA,MAAA;EACK;KAGH,QAAA;EACM,MAAE,eAAA;EACH,MAAA,EAAA,MAAA,eAAoB,QAAA;EACzB;KAIJ,QAAO,EAAA,MAAA,eAAA,QAAA;;AAGb,YAAU,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/plugin-utils/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 { Type } from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n BaseCommandParameter,\n CommandParameterKind,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { isCommandParameterKind } from \"./type-checks\";\n\n/**\n * Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the reflection kind from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link ReflectionKind}.\n */\nexport function extractReflectionKind(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): ReflectionKind {\n if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.string) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.string)\n ) {\n return checkVariadic && (command as StringCommandParameter).variadic\n ? ReflectionKind.array\n : ReflectionKind.string;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.number) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.number)\n ) {\n return checkVariadic && (command as any).variadic\n ? ReflectionKind.array\n : ReflectionKind.number;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.boolean) ||\n (isSetObject(command) && command.kind === CommandParameterKinds.boolean)\n ) {\n return ReflectionKind.boolean;\n } else {\n return ReflectionKind.string;\n }\n}\n\n/**\n * Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the type from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link Type}.\n */\nexport function extractType(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): Type {\n const reflectionKind = extractReflectionKind(command, checkVariadic);\n if (reflectionKind === ReflectionKind.string) {\n return { kind: ReflectionKind.string };\n } else if (reflectionKind === ReflectionKind.number) {\n return { kind: ReflectionKind.number };\n } else if (reflectionKind === ReflectionKind.boolean) {\n return { kind: ReflectionKind.boolean };\n } else if (reflectionKind === ReflectionKind.array) {\n if (isCommandParameterKind(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n kind: command\n } as BaseCommandParameter,\n false\n )\n };\n } else if (isSetObject(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n ...command,\n kind: command.kind\n } as BaseCommandParameter,\n false\n )\n };\n } else {\n return {\n kind: ReflectionKind.array,\n type: { kind: ReflectionKind.string }\n };\n }\n } else {\n return { kind: ReflectionKind.string };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BE,KAAA,uBAAA,QAAA,IAAA,YAAA,sBAAA,UAAA,YAAA,QAAA,IAAA,QAAA,SAAA,sBAAA,OACC,QAAQ,iBAAU,QAAe,WAAU,eAAK,QAAA,eAAgC;UAClF,uBAAA,QAAA,IAAA,YAAA,sBAAA,UAAA,YAAA,QAAA,IAAA,QAAA,SAAA,sBAAA,OACG,QAAM,iBAAc,QAAQ,WAAa,eAAgB,QAAI,eAAoB;UAC3E,uBAA0B,QAAO,IAAI,YAAS,sBAAmB,WAAA,YAAA,QAAA,IAAA,QAAA,SAAA,sBAAA,QACvE,QAAO,eAAe;KAE1B,QAAO,eAAS;;AAGhB,sBAAkB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQlB,SAAQ,YAAe,SAAA,gBAAA,MAAA;CACrB,MAAM,iBAAe,sBAAM,SAAA,cAAA;AAC3B,KAAE,mBAAQ,eAAA,OACR,QAAC,EACC,MAAA,eAAY,QACb;UACE,mBAAW,eAA6B,OAC3C,QAAA,EACA,MAAO,eAAgB,QACtB;UACG,mBAAqB,eAAA,QACzB,QAAO,EACN,MAAA,eAAsB,SACtB;UACA,mBAAwB,eAAiB,MAC1C,KAAA,uBAAA,QAAA,CACA,QAAO;EACH,MAAC,eAAA;EACL,MAAO,YAAe,EACxB,MAAA,SACF,EAAA,MAAA;;UAEE,YAAA,QAAA,CACC,QAAU;EACZ,MAAA,eAAA;EACG,MAAM,YAAc;GACd,GAAA;GACN,MAAY,QAAA;GACd,EAAA,MAAA;EACK;KAEL,QAAA;EACM,MAAA,eAAA;EACA,MAAA,EACF,MAAA,eAAmB,QACrB;EACA;KAGA,QAAO,EACP,MAAQ,eAAe,QACvB;;AAGJ,YAAY,SAAE;CAAA;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"description-helpers.mjs","names":[],"sources":["../../src/plugin-utils/description-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport interface FormatDescriptionOptions {\n /**\n * If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.\n *\n * @defaultValue false\n */\n replaceNewlines?: boolean;\n\n /**\n * If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.\n *\n * @defaultValue false\n */\n collapseWhitespace?: boolean;\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionWhitespace(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n let formattedDescription = description.trim();\n if (options.replaceNewlines) {\n formattedDescription = formattedDescription.replace(/\\s*\\n\\s*/g, \" \");\n }\n if (options.collapseWhitespace) {\n formattedDescription = formattedDescription.replace(/\\s{2,}/g, \" \");\n }\n\n return formattedDescription.trim();\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionEscapes(description: string): string {\n return description\n .replaceAll(\"'\", \"\\\\'\")\n .replaceAll('\"', '\\\\\"')\n .replaceAll(\"`\", \"\\\\`\")\n .replace(/\\$\\{/g, \"\\\\${\");\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nexport function formatDescription(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n return formatDescriptionEscapes(\n formatDescriptionWhitespace(description, options)\n );\n}\n\nexport interface FormatShortDescriptionOptions extends FormatDescriptionOptions {\n /**\n * The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.\n *\n * @defaultValue 62\n */\n length?: number;\n}\n\n/**\n * Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.\n *\n * @param description - The full description string.\n * @param options - Options for formatting the short description, including the maximum length.\n * @returns The extracted short description.\n */\nexport function formatShortDescription(\n description: string,\n options: FormatShortDescriptionOptions = {}\n): string {\n const length = options.length ?? 62;\n const formattedDescription = formatDescriptionWhitespace(\n description,\n options\n );\n\n const firstSentenceMatch =\n formattedDescription.indexOf(\"\\n\") < length - 3 ||\n formattedDescription.search(/[.!?\\n]\\s*\\S/) > length - 3\n ? formattedDescription\n .match(/^.*[.!?\\n]\\s?\\S/)?.[0]\n ?.trim()\n ?.slice(0, -1)\n ?.trim()\n : undefined;\n\n let result = (firstSentenceMatch || formattedDescription).trim();\n if (result.trim().length > length) {\n result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;\n }\n\n return formatDescriptionEscapes(result);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,SAAG,4BAAA,aAAA,UAAA,EAAA,EAAA;CACC,IAAE,uBAAa,YAAA,MAAA;AACf,KAAA,QAAA,gBACF,wBAA4B,qBAAA,QAAA,aAAA,IAAA;gCAG5B,wBAAA,qBAAA,QAAA,WAAA,IAAA;AAED,QAAA,qBAAA,MAAA;;AAED,4BAAsB,SAAc;CAAA;OAAiB;CAAgC;QAAqB,EAAE;CAAC;CAAa;CAAA;CAAA;;;;;;;;;;AAU1H,SAAM,yBAAyB,aAAA;AAC3B,QAAA,YACF,WAAA,KAAA,MAAA,CACI,WAAQ,MAAA,OAAA,CACV,WAAA,KAAqB,MAAE,CACzB,QAAA,SAAA,OAAA;;AAEF,yBAAS,SAAyB;CAAC;CAAC;CAAA;CAAA;CAAA;;;;;;;;;;AAUpC,SAAgB,kBAAU,aAAkB,UAAA,EAAA,EAAA;AAC1C,QAAA,yBAAA,4BAAA,aAAA,QAAA,CAAA;;AAEF,kBAAS,SAAA;CAAA;OAAA;CAAA;QAAA,EAAA;CAAA;CAAA;CAAA;CAAA;AACT,MAAK,mCAAqB;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAS1B,SAAI,uBAAA,aAAA,UAAA,EAAA,EAAA;CACD,MAAO,SAAQ,QAAI,UAAc;CACnC,MAAA,uBAAA,4BAAA,aAAA,QAAA;CASG,IAAA,WARwB,qBAAuB,QAAA,KAAA,GAAA,SAAA,KAC/C,qBAAsB,OAAA,eAAkB,GAAA,SAAA,IAC1C,qBACK,MAAS,kBAAiB,GAAA,IACnB,MAAC,EACJ,MAAA,GAAA,GAAA,EACD,MAAA,GACD,WACuB,sBAAoB,MAAA;AACjD,KAAA,OAAA,MAAA,CAAA,SAAA,OACH,UAAA,GAAA,OAAA,UAAA,GAAA,KAAA,IAAA,GAAA,SAAA,EAAA,CAAA,CAAA,MAAA,CAAA;AAEA,QAAO,yBAAU,OAAA;;AAEjB,uBAAuB,SAAQ;CAAA;OAAsB;CAAgC;QAAmB,EAAA;CAAA;CAAS;CAAA;CAAA"}
1
+ {"version":3,"file":"description-helpers.mjs","names":[],"sources":["../../src/plugin-utils/description-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport interface FormatDescriptionOptions {\n /**\n * If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.\n *\n * @defaultValue false\n */\n replaceNewlines?: boolean;\n\n /**\n * If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.\n *\n * @defaultValue false\n */\n collapseWhitespace?: boolean;\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionWhitespace(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n let formattedDescription = description.trim();\n if (options.replaceNewlines) {\n formattedDescription = formattedDescription.replace(/\\s*\\n\\s*/g, \" \");\n }\n if (options.collapseWhitespace) {\n formattedDescription = formattedDescription.replace(/\\s{2,}/g, \" \");\n }\n\n return formattedDescription.trim();\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionEscapes(description: string): string {\n return description\n .replaceAll(\"'\", \"\\\\'\")\n .replaceAll('\"', '\\\\\"')\n .replaceAll(\"`\", \"\\\\`\")\n .replace(/\\$\\{/g, \"\\\\${\");\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nexport function formatDescription(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n return formatDescriptionEscapes(\n formatDescriptionWhitespace(description, options)\n );\n}\n\nexport interface FormatShortDescriptionOptions extends FormatDescriptionOptions {\n /**\n * The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.\n *\n * @defaultValue 62\n */\n length?: number;\n}\n\n/**\n * Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.\n *\n * @param description - The full description string.\n * @param options - Options for formatting the short description, including the maximum length.\n * @returns The extracted short description.\n */\nexport function formatShortDescription(\n description: string,\n options: FormatShortDescriptionOptions = {}\n): string {\n const length = options.length ?? 62;\n const formattedDescription = formatDescriptionWhitespace(\n description,\n options\n );\n\n const firstSentenceMatch =\n formattedDescription.indexOf(\"\\n\") < length - 3 ||\n formattedDescription.search(/[.!?\\n]\\s*\\S/) > length - 3\n ? formattedDescription\n .match(/^.*[.!?\\n]\\s?\\S/)?.[0]\n ?.trim()\n ?.slice(0, -1)\n ?.trim()\n : undefined;\n\n let result = (firstSentenceMatch || formattedDescription).trim();\n if (result.trim().length > length) {\n result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;\n }\n\n return formatDescriptionEscapes(result);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,SAAG,4BAAA,aAAA,UAAA,EAAA,EAAA;CACD,IAAI,uBAAa,YAAA,MAAA;AACjB,KAAE,QAAA,gBACF,wBAAqB,qBAAO,QAAA,aAAA,IAAA;gCAG5B,wBAAA,qBAAA,QAAA,WAAA,IAAA;AAED,QAAA,qBAAA,MAAA;;AAED,4BAAsB,SAAc;CAAA;OAAiB;CAAgC;QAAqB,EAAE;CAAC;CAAa;CAAA;CAAA;;;;;;;;;;AAU1H,SAAM,yBAAyB,aAAA;AAC7B,QAAE,YAAA,WAAuB,KAAA,MAAA,CAAA,WAA4B,MAAK,OAAM,CAAC,WAAM,KAAA,MAAA,CAAA,QAAA,SAAA,OAAA;;AAEzE,yBAAc,SAAoB;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;AAUlC,SAAI,kBAAA,aAAA,UAAA,EAAA,EAAA;AACF,QAAM,yBAAuB,4BAA8B,aAAS,QAAU,CAAI;;AAEpF,kBAAU,SAAiB;CAAC;OAAiB;CAAM;QAAA,EAAA;CAAA;CAAA;CAAA;CAAA;AACnD,MAAI,mCAAkC;OAAM;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;CAU1C,MAAA,SAAA,QAAA,UAAA;CACA,MAAC,uBAA4B,4BAAyB,aAAU,QAAc;CAE9E,IAAE,WADH,qBAAA,QAAA,KAAA,GAAA,SAAA,KAAA,qBAAA,OAAA,eAAA,GAAA,SAAA,IAAA,qBAAA,MAAA,kBAAA,GAAA,IAAA,MAAA,EAAA,MAAA,GAAA,GAAA,EAAA,MAAA,GAAA,WACG,sBAAA,MAAA;AACF,KAAC,OAAQ,MAAO,CAAA,SAAI,OACrB,UAAA,GAAA,OAAA,UAAA,GAAA,KAAA,IAAA,GAAA,SAAA,EAAA,CAAA,CAAA,MAAA,CAAA;AAEC,QAAE,yBAAsB,OAAY;;AAEtC,uBAAgB,SAAA;CAAiB;OAAA;CAAA;QAAA,EAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-command-tree.mjs","names":[],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isDynamicPathSegment } from \"./context-helpers\";\nimport { traverseCommands } from \"./traverse-command-tree\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isDynamicPathSegment(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n\n/**\n * Retrieves a list of all command trees defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command trees in the context.\n */\nexport async function getCommandList(context: Context): Promise<CommandTree[]> {\n const commandList: CommandTree[] = [];\n await traverseCommands(context, commandTree => {\n commandList.push(commandTree);\n });\n\n return commandList;\n}\n\n/**\n * Retrieves a list of all command paths defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command paths in the context.\n */\nexport async function getCommandPaths(context: Context): Promise<string[]> {\n const commandPaths: string[] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandPaths.push(commandTree.path);\n }\n });\n\n return commandPaths;\n}\n\n/**\n * Retrieves a list of all command segments defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command segments in the context.\n */\nexport async function getCommandSegments(\n context: Context\n): Promise<string[][]> {\n const commandSegments: string[][] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandSegments.push(commandTree.segments);\n }\n });\n\n return commandSegments;\n}\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;AAYV,KAAK,KAAO,WAAW;;AAIxB,KAAO,KAAM,SAAC,GAAW;EAClB,MAAO,WAAU,KACf,MAAA,EAAA,CACA,OAAA,cAAwB,YAAW,CAAC,qBAAa,QAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;iCAExD,KAAA,aAAA,YACa,OAAQ,UAAS,eAAc,KAAI,YAAa,UAAA,QAAA,CAC9D,eAAA,YAAA,SAAA,YAAA;MAGe,QAAO;;AAIrB,QAAS;;AAEX,eAAW,SAAa;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOzB,eAAc,eAAA,SAAA;CACV,MAAG,cAAiB,EAAE;AACtB,OAAK,iBAAiB,SAAU,cAAA,gBAAA;AAC5B,cAAC,KAAA,YAAA;IACF;EAAC;EAAa;EAAA;EAAU,CAAA,CAAA;AAC3B,QAAI;;AAER,eAAQ,SAAc;CAAA;CAAY;CAAS;CAAgB;CAAA;CAAA;CAAA;;;;;;;AAO3D,eAAoB,gBAAA,SAAA;CACpB,MAAA,eAAA,EAAA;;AAEE,MAAA,YAAA,KACU,cAAW,KAAI,YAAc,KAAA;IAErC;EAAA;EAAmB;EAAC;EAAa,CAAC,CAAA;AAClC,QAAO;;AAEX,gBAAa,SAAS;CAAA;CAAe;CAAS;CAAkB;CAAe;CAAA;;;;;;;AAO/E,eAAA,mBAAA,SAAA;;AAEE,OAAA,iBAAA,SAAA,cAAA,gBAAA;AACC,MAAS,YAAW,KACtB,iBAAA,KAAA,YAAA,SAAA;IAEG;EAAA;EAAkB;EAAK;EAAS,CAAE,CAAC;AACrC,QAAA;;AAEF,mBAAQ,SAAoB;CAAC;CAAM;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"get-command-tree.mjs","names":[],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isDynamicPathSegment } from \"./context-helpers\";\nimport { traverseCommands } from \"./traverse-command-tree\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isDynamicPathSegment(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n\n/**\n * Retrieves a list of all command trees defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command trees in the context.\n */\nexport async function getCommandList(context: Context): Promise<CommandTree[]> {\n const commandList: CommandTree[] = [];\n await traverseCommands(context, commandTree => {\n commandList.push(commandTree);\n });\n\n return commandList;\n}\n\n/**\n * Retrieves a list of all command paths defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command paths in the context.\n */\nexport async function getCommandPaths(context: Context): Promise<string[]> {\n const commandPaths: string[] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandPaths.push(commandTree.path);\n }\n });\n\n return commandPaths;\n}\n\n/**\n * Retrieves a list of all command segments defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command segments in the context.\n */\nexport async function getCommandSegments(\n context: Context\n): Promise<string[][]> {\n const commandSegments: string[][] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandSegments.push(commandTree.segments);\n }\n });\n\n return commandSegments;\n}\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;;;;;;;;;AAYR,KAAK,KAAA,WAAQ;;AAId,KAAM,KAAK,SAAG,GAAA;EACd,MAAO,WAAc,KAAG,MAAQ,EAAC,CAAA,OAAM,cAAQ,YAAA,CAAA,qBAAA,QAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;AAC/C,OAAS,MAAA,WAAA,SACH,KAAG,aAAA,YAA0B,OAAC,UAAgB,eAAM,KAAA,YAAA,UAAA,QAAA;MAGvD,QAAY;;AAIb,QAAE;;AAEJ,eAAe,SAAC;CAAA;CAAc;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;CAQ5B,MAAI,cAAa,EAAA;AACjB,OAAI,iBAAiB,SAAA,cAAA,gBAAA;AACnB,cAAM,KAAW,YAAA;IAChB;EAAC;EAAQ;EAAA;EAAA,CAAA,CAAA;AACZ,QAAK;;AAEP,eAAS,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOT,eAAM,gBAAA,SAAA;CACJ,MAAE,eAAA,EAAA;AACF,OAAA,iBAAA,SAAA,cAAA,gBAAA;uBAEA,cAAO,KAAW,YAAA,KAAA;;;;;;AAGlB,QAAA;;AAEF,gBAAC,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOD,eAAqB,mBAAY,SAAA;CAC/B,MAAE,kBAAA,EAAA;;AAEF,MAAM,YAAY,KACpB,iBAAA,KAAA,YAAA,SAAA;IAEE;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;AACA,QAAC;;AAEH,mBAAmB,SAAK;CAAK;CAAS;CAAW;CAAuB;CAAA;CAAA"}
@@ -13,7 +13,7 @@ function __assignType(fn, args) {
13
13
  */
14
14
  function sortOptions(options) {
15
15
  if (!options || options.length === 0) return [];
16
- return options.filter(__assignType((arg) => arg.kind !== require_types_command.CommandParameterKinds.boolean || !arg.isNegativeOf, [
16
+ return options.filter(__assignType((arg) => arg.kind !== require_types_command.CommandParameterKinds.boolean || arg.variadic || !arg.isNegativeOf, [
17
17
  "arg",
18
18
  "",
19
19
  "P\"2!\"/\""
@@ -25,7 +25,7 @@ function sortOptions(options) {
25
25
  ])).reduce(__assignType((ret, arg) => {
26
26
  ret.push(arg);
27
27
  if (arg.kind === require_types_command.CommandParameterKinds.boolean) {
28
- const negativeArg = options.find(__assignType((a) => a.kind === require_types_command.CommandParameterKinds.boolean && a.isNegativeOf === arg.name, [
28
+ const negativeArg = options.find(__assignType((a) => a.kind === require_types_command.CommandParameterKinds.boolean && !a.variadic && a.isNegativeOf === arg.name, [
29
29
  "a",
30
30
  "",
31
31
  "P\"2!\"/\""