@shell-shock/core 0.13.0 → 0.13.2

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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/components/utils-builtin.cjs +19 -0
  3. package/dist/components/utils-builtin.cjs.map +1 -1
  4. package/dist/components/utils-builtin.mjs +19 -0
  5. package/dist/components/utils-builtin.mjs.map +1 -1
  6. package/dist/helpers/utilities.cjs +9 -9
  7. package/dist/helpers/utilities.cjs.map +1 -1
  8. package/dist/helpers/utilities.mjs +9 -9
  9. package/dist/helpers/utilities.mjs.map +1 -1
  10. package/dist/index.cjs +1 -0
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.mts +2 -2
  13. package/dist/index.mjs +2 -2
  14. package/dist/plugin.cjs +26 -2
  15. package/dist/plugin.cjs.map +1 -1
  16. package/dist/plugin.d.cts.map +1 -1
  17. package/dist/plugin.d.mts.map +1 -1
  18. package/dist/plugin.mjs +27 -3
  19. package/dist/plugin.mjs.map +1 -1
  20. package/dist/resolver/helpers.cjs +5 -0
  21. package/dist/resolver/helpers.cjs.map +1 -1
  22. package/dist/resolver/helpers.mjs +6 -1
  23. package/dist/resolver/helpers.mjs.map +1 -1
  24. package/dist/resolver/resolve.cjs +1 -1
  25. package/dist/resolver/resolve.cjs.map +1 -1
  26. package/dist/resolver/resolve.mjs +2 -2
  27. package/dist/resolver/resolve.mjs.map +1 -1
  28. package/dist/types/command.cjs +4 -2
  29. package/dist/types/command.cjs.map +1 -1
  30. package/dist/types/command.d.cts +11 -0
  31. package/dist/types/command.d.cts.map +1 -1
  32. package/dist/types/command.d.mts +11 -0
  33. package/dist/types/command.d.mts.map +1 -1
  34. package/dist/types/command.mjs +4 -2
  35. package/dist/types/command.mjs.map +1 -1
  36. package/dist/types/config.cjs +17 -5
  37. package/dist/types/config.cjs.map +1 -1
  38. package/dist/types/config.d.cts +30 -6
  39. package/dist/types/config.d.cts.map +1 -1
  40. package/dist/types/config.d.mts +30 -6
  41. package/dist/types/config.d.mts.map +1 -1
  42. package/dist/types/config.mjs +17 -6
  43. package/dist/types/config.mjs.map +1 -1
  44. package/dist/types/index.cjs +1 -0
  45. package/dist/types/index.d.cts +2 -2
  46. package/dist/types/index.d.mts +2 -2
  47. package/dist/types/index.mjs +2 -2
  48. package/package.json +21 -21
@@ -40,15 +40,15 @@ formatCommandTree.__type = [
40
40
  "P\"w!2\"&/#"
41
41
  ];
42
42
  /**
43
- * Retrieves the default command options based on the context configuration.
43
+ * Retrieves the global command options based on the context configuration.
44
44
  *
45
45
  * @param context - The build context.
46
- * @param command - The command for which to retrieve default options.
47
- * @returns A record of default command options.
46
+ * @param command - The command for which to retrieve global options.
47
+ * @returns A record of global command options.
48
48
  */
49
- function getDefaultOptions(context, command) {
49
+ function getGlobalOptions(context, command) {
50
50
  let options;
51
- if (Array.isArray(context.config.defaultOptions)) options = Object.fromEntries((0, _stryke_helpers_get_unique.getUniqueBy)(context.config.defaultOptions, __assignType((item) => item.name, [
51
+ if (Array.isArray(context.config.globalOptions)) options = Object.fromEntries((0, _stryke_helpers_get_unique.getUniqueBy)(context.config.globalOptions, __assignType((item) => item.name, [
52
52
  "CommandOption",
53
53
  "item",
54
54
  "",
@@ -58,7 +58,7 @@ function getDefaultOptions(context, command) {
58
58
  "",
59
59
  "P\"2!\"/\""
60
60
  ])));
61
- else if ((0, _stryke_type_checks_is_function.isFunction)(context.config.defaultOptions)) options = Object.fromEntries((0, _stryke_helpers_get_unique.getUniqueBy)(context.config.defaultOptions(context, command), __assignType((item) => item.name, [
61
+ else if ((0, _stryke_type_checks_is_function.isFunction)(context.config.globalOptions)) options = Object.fromEntries((0, _stryke_helpers_get_unique.getUniqueBy)(context.config.globalOptions(context, command), __assignType((item) => item.name, [
62
62
  "CommandOption",
63
63
  "item",
64
64
  "",
@@ -78,18 +78,18 @@ function getDefaultOptions(context, command) {
78
78
  "P\"2!\"/\""
79
79
  ])));
80
80
  }
81
- getDefaultOptions.__type = [
81
+ getGlobalOptions.__type = [
82
82
  "Context",
83
83
  "context",
84
84
  "CommandBase",
85
85
  "command",
86
86
  () => __ΩRecord,
87
87
  "CommandOption",
88
- "getDefaultOptions",
88
+ "getGlobalOptions",
89
89
  "P\"w!2\"\"w#2$&\"w&o%#/'"
90
90
  ];
91
91
 
92
92
  //#endregion
93
93
  exports.formatCommandTree = formatCommandTree;
94
- exports.getDefaultOptions = getDefaultOptions;
94
+ exports.getGlobalOptions = getGlobalOptions;
95
95
  //# sourceMappingURL=utilities.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.cjs","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 default command options based on the context configuration.\n *\n * @param context - The build context.\n * @param command - The command for which to retrieve default options.\n * @returns A record of default command options.\n */\nexport function getDefaultOptions(\n context: Context,\n command: CommandBase\n): Record<string, CommandOption> {\n let options!: Record<string, CommandOption>;\n if (Array.isArray(context.config.defaultOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.defaultOptions,\n (item: CommandOption) => item.name\n ).map(option => [option.name, option])\n );\n } else if (isFunction(context.config.defaultOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.defaultOptions(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,kBAAA,SAAA,SAAA;CACH,IAAA;kDAEO,WAAS,OAAA,wDAA2B,QAAU,OAAO,gBAAA,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;0DAEpC,QAAK,OAAA,eAAA,CACzB,WAAU,OAAO,wDAA4B,QAAO,OAAA,eAAsB,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,YAAQ,OAAQ,QAAQ,QAAY,CAAC,IAAA,cAAQ,CAAA,KAAa,WAAA,CAC1E,KACG;EAAM,GAAA;EAAU,KAAI,MAAM,6DAAO,IAAA;EAAA,CACjC,EAAA;EAAA;EAAc;EAAE;EAAY,CAAA,CAAA,CAAG;;AAEnC,kBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"utilities.cjs","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,wDAA2B,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;0DAEpC,QAAK,OAAA,cAAA,CACzB,WAAU,OAAO,wDAA4B,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,6DAAO,IAAA;EAAA,CACjC,EAAA;EAAA;EAAc;EAAE;EAAY,CAAA,CAAA,CAAG;;AAEnC,iBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -39,15 +39,15 @@ formatCommandTree.__type = [
39
39
  "P\"w!2\"&/#"
40
40
  ];
41
41
  /**
42
- * Retrieves the default command options based on the context configuration.
42
+ * Retrieves the global command options based on the context configuration.
43
43
  *
44
44
  * @param context - The build context.
45
- * @param command - The command for which to retrieve default options.
46
- * @returns A record of default command options.
45
+ * @param command - The command for which to retrieve global options.
46
+ * @returns A record of global command options.
47
47
  */
48
- function getDefaultOptions(context, command) {
48
+ function getGlobalOptions(context, command) {
49
49
  let options;
50
- if (Array.isArray(context.config.defaultOptions)) options = Object.fromEntries(getUniqueBy(context.config.defaultOptions, __assignType((item) => item.name, [
50
+ if (Array.isArray(context.config.globalOptions)) options = Object.fromEntries(getUniqueBy(context.config.globalOptions, __assignType((item) => item.name, [
51
51
  "CommandOption",
52
52
  "item",
53
53
  "",
@@ -57,7 +57,7 @@ function getDefaultOptions(context, command) {
57
57
  "",
58
58
  "P\"2!\"/\""
59
59
  ])));
60
- else if (isFunction(context.config.defaultOptions)) options = Object.fromEntries(getUniqueBy(context.config.defaultOptions(context, command), __assignType((item) => item.name, [
60
+ else if (isFunction(context.config.globalOptions)) options = Object.fromEntries(getUniqueBy(context.config.globalOptions(context, command), __assignType((item) => item.name, [
61
61
  "CommandOption",
62
62
  "item",
63
63
  "",
@@ -77,17 +77,17 @@ function getDefaultOptions(context, command) {
77
77
  "P\"2!\"/\""
78
78
  ])));
79
79
  }
80
- getDefaultOptions.__type = [
80
+ getGlobalOptions.__type = [
81
81
  "Context",
82
82
  "context",
83
83
  "CommandBase",
84
84
  "command",
85
85
  () => __ΩRecord,
86
86
  "CommandOption",
87
- "getDefaultOptions",
87
+ "getGlobalOptions",
88
88
  "P\"w!2\"\"w#2$&\"w&o%#/'"
89
89
  ];
90
90
 
91
91
  //#endregion
92
- export { formatCommandTree, getDefaultOptions };
92
+ export { formatCommandTree, getGlobalOptions };
93
93
  //# sourceMappingURL=utilities.mjs.map
@@ -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 default command options based on the context configuration.\n *\n * @param context - The build context.\n * @param command - The command for which to retrieve default options.\n * @returns A record of default command options.\n */\nexport function getDefaultOptions(\n context: Context,\n command: CommandBase\n): Record<string, CommandOption> {\n let options!: Record<string, CommandOption>;\n if (Array.isArray(context.config.defaultOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.defaultOptions,\n (item: CommandOption) => item.name\n ).map(option => [option.name, option])\n );\n } else if (isFunction(context.config.defaultOptions)) {\n options = Object.fromEntries(\n getUniqueBy(\n context.config.defaultOptions(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,kBAAA,SAAA,SAAA;CACH,IAAA;kDAEO,WAAS,OAAA,YAAkB,YAAS,QAAU,OAAO,gBAAA,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,eAAA,CACzB,WAAU,OAAO,YAAe,YAAa,QAAO,OAAA,eAAsB,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,YAAQ,OAAQ,QAAQ,QAAY,CAAC,IAAA,cAAQ,CAAA,KAAa,WAAA,CAC1E,KACG;EAAM,GAAA;EAAU,KAAI,MAAM,OAAO,aAAA,IAAA;EAAA,CACjC,EAAA;EAAA;EAAc;EAAE;EAAY,CAAA,CAAA,CAAG;;AAEnC,kBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;OAAA;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;;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"}
package/dist/index.cjs CHANGED
@@ -37,6 +37,7 @@ exports.__ΩNumberCommandParameter = require_types_command.__ΩNumberCommandPara
37
37
  exports.__ΩNumberCommandParameterConfig = require_types_command.__ΩNumberCommandParameterConfig;
38
38
  exports.__ΩOptions = require_types_config.__ΩOptions;
39
39
  exports.__ΩOutputConfig = require_types_config.__ΩOutputConfig;
40
+ exports.__ΩReferenceOptions = require_types_config.__ΩReferenceOptions;
40
41
  exports.__ΩResolvedConfig = require_types_config.__ΩResolvedConfig;
41
42
  exports.__ΩSerializedCommandTree = require_types_command.__ΩSerializedCommandTree;
42
43
  exports.__ΩStringCommandParameter = require_types_command.__ΩStringCommandParameter;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AsCommandParameterConfig, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, NumberCommandParameter, NumberCommandParameterConfig, SerializedCommandTree, StringCommandParameter, StringCommandParameterConfig } from "./types/command.cjs";
2
2
  import { Context, UnresolvedContext } from "./types/context.cjs";
3
- import { Options, OutputConfig, ResolvedConfig, UserConfig } from "./types/config.cjs";
3
+ import { 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
6
  import { CommandContext } from "./types/runtime.cjs";
7
- export { AsCommandParameterConfig, BaseCommandOptions, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandContext, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, createShellShock };
7
+ export { AsCommandParameterConfig, BaseCommandOptions, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandContext, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ReferenceOptions, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, createShellShock };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AsCommandParameterConfig, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, NumberCommandParameter, NumberCommandParameterConfig, SerializedCommandTree, StringCommandParameter, StringCommandParameterConfig } from "./types/command.mjs";
2
2
  import { Context, UnresolvedContext } from "./types/context.mjs";
3
- import { Options, OutputConfig, ResolvedConfig, UserConfig } from "./types/config.mjs";
3
+ import { 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
6
  import { CommandContext } from "./types/runtime.mjs";
7
- export { AsCommandParameterConfig, BaseCommandOptions, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandContext, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, createShellShock };
7
+ export { AsCommandParameterConfig, BaseCommandOptions, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandContext, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, Context, NumberCommandParameter, NumberCommandParameterConfig, Options, OutputConfig, ReferenceOptions, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandParameter, StringCommandParameterConfig, UnresolvedContext, UserConfig, createShellShock };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CommandParameterKinds, __ΩAsCommandParameterConfig, __ΩBaseCommandParameter, __ΩBooleanCommandOption, __ΩBooleanCommandParameter, __ΩBooleanCommandParameterConfig, __ΩCommandArgument, __ΩCommandArgumentConfig, __ΩCommandBase, __ΩCommandConfig, __ΩCommandMetadata, __ΩCommandModule, __ΩCommandOption, __ΩCommandOptionConfig, __ΩCommandParameter, __ΩCommandParameterConfig, __ΩCommandParameterKind, __ΩCommandParameterType, __ΩCommandTree, __ΩNumberCommandParameter, __ΩNumberCommandParameterConfig, __ΩSerializedCommandTree, __ΩStringCommandParameter, __ΩStringCommandParameterConfig } from "./types/command.mjs";
2
- import { __ΩOptions, __ΩOutputConfig, __ΩResolvedConfig, __ΩUserConfig } from "./types/config.mjs";
2
+ import { __Ω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 { __ΩCommandContext } from "./types/runtime.mjs";
@@ -9,5 +9,5 @@ import { ShellShockAPI, createShellShock } from "./api.mjs";
9
9
  var src_default = ShellShockAPI;
10
10
 
11
11
  //#endregion
12
- export { CommandParameterKinds, ShellShockAPI, __ΩAsCommandParameterConfig, __ΩBaseCommandOptions, __ΩBaseCommandParameter, __ΩBooleanCommandOption, __ΩBooleanCommandParameter, __ΩBooleanCommandParameterConfig, __ΩCommandArgument, __ΩCommandArgumentConfig, __ΩCommandBase, __ΩCommandConfig, __ΩCommandContext, __ΩCommandMetadata, __ΩCommandModule, __ΩCommandOption, __ΩCommandOptionConfig, __ΩCommandParameter, __ΩCommandParameterConfig, __ΩCommandParameterKind, __ΩCommandParameterType, __ΩCommandTree, __ΩContext, __ΩNumberCommandParameter, __ΩNumberCommandParameterConfig, __ΩOptions, __ΩOutputConfig, __ΩResolvedConfig, __ΩSerializedCommandTree, __ΩStringCommandParameter, __ΩStringCommandParameterConfig, __ΩUnresolvedContext, __ΩUserConfig, createShellShock, src_default as default };
12
+ export { CommandParameterKinds, ShellShockAPI, __ΩAsCommandParameterConfig, __ΩBaseCommandOptions, __ΩBaseCommandParameter, __ΩBooleanCommandOption, __ΩBooleanCommandParameter, __ΩBooleanCommandParameterConfig, __ΩCommandArgument, __ΩCommandArgumentConfig, __ΩCommandBase, __ΩCommandConfig, __ΩCommandContext, __ΩCommandMetadata, __ΩCommandModule, __ΩCommandOption, __ΩCommandOptionConfig, __ΩCommandParameter, __ΩCommandParameterConfig, __ΩCommandParameterKind, __ΩCommandParameterType, __ΩCommandTree, __ΩContext, __ΩNumberCommandParameter, __ΩNumberCommandParameterConfig, __ΩOptions, __ΩOutputConfig, __ΩReferenceOptions, __ΩResolvedConfig, __ΩSerializedCommandTree, __ΩStringCommandParameter, __ΩStringCommandParameterConfig, __ΩUnresolvedContext, __ΩUserConfig, createShellShock, src_default as default };
13
13
  //# sourceMappingURL=index.mjs.map
package/dist/plugin.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_context_helpers = require('./plugin-utils/context-helpers.cjs');
4
+ const require_types_command = require('./types/command.cjs');
4
5
  const require_components_docs = require('./components/docs.cjs');
5
6
  const require_components_utils_builtin = require('./components/utils-builtin.cjs');
6
7
  const require_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
@@ -53,7 +54,7 @@ const plugin = (options = {}) => {
53
54
  async config() {
54
55
  this.debug("Resolving the Shell Shock configuration.");
55
56
  await require_update_package_json.updatePackageJsonBinary(this);
56
- return (0, defu.defu)({ output: { buildPath: (0, _stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
57
+ return (0, defu.defu)({ output: { path: (0, _stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
57
58
  name: require_context_helpers.getAppName(this),
58
59
  title: require_context_helpers.getAppTitle(this),
59
60
  description: require_context_helpers.getAppDescription(this),
@@ -82,7 +83,7 @@ const plugin = (options = {}) => {
82
83
  if (!this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)) this.config.env.prefix.push(this.config.appSpecificEnvPrefix);
83
84
  this.config.bin = ((0, _stryke_type_checks_is_set_string.isSetString)(this.packageJson.bin) ? { [(0, _stryke_string_format_kebab_case.kebabCase)(this.config.name)]: this.packageJson.bin } : this.packageJson.bin) ?? { [(0, _stryke_string_format_kebab_case.kebabCase)(this.config.name)]: require_update_package_json.formatBinaryPath(this.config.output.format) };
84
85
  this.inputs ??= [];
85
- this.options = Object.values(require_utilities.getDefaultOptions(this, {
86
+ this.options = Object.values(require_utilities.getGlobalOptions(this, {
86
87
  id: null,
87
88
  name: this.config.name,
88
89
  path: null,
@@ -103,6 +104,11 @@ const plugin = (options = {}) => {
103
104
  name: "shell-shock:inputs",
104
105
  async configResolved() {
105
106
  this.debug("Finding command entry point files.");
107
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.reference)) if (this.config.reference.includes("{command}")) this.config.reference = {
108
+ app: this.config.reference.substring(0, this.config.reference.indexOf("{command}")).replace(/\/?$/, "/"),
109
+ commands: this.config.reference
110
+ };
111
+ else this.config.reference = { app: this.config.reference };
106
112
  this.commandsPath = require_paths.findCommandsRoot(this);
107
113
  const inputs = await (0, powerlines_utils.resolveInputs)(this, this.config.input);
108
114
  this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
@@ -139,6 +145,24 @@ const plugin = (options = {}) => {
139
145
  }, this.inputs);
140
146
  this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${(0, _stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}`).join("\n")}`);
141
147
  },
148
+ typegen(code) {
149
+ this.debug("Generating type definitions for the Shell Shock application.");
150
+ return `${code}
151
+
152
+ /**
153
+ * The global options available for every command in the ${require_context_helpers.getAppTitle(this, true)} command-line application.
154
+ */
155
+ export interface GlobalOptions {
156
+ ${this.options.map((option) => `${option.description ? `
157
+ /**
158
+ * ${option.description}${option.default ? `
159
+ *
160
+ * @defaultValue ${option.kind === require_types_command.CommandParameterKinds.string ? `"${option.default}"` : option.default}` : ""}
161
+ */
162
+ ` : ""}${option.name}${option.optional ? "?" : ""}: ${option.kind === require_types_command.CommandParameterKinds.boolean ? "boolean" : `${option.variadic ? "(" : ""}${option.choices ? option.choices.map((choice) => option.kind === require_types_command.CommandParameterKinds.number ? `${choice}` : `"${choice}"`).join(" | ") : option.kind === require_types_command.CommandParameterKinds.number ? "number" : "string"}${option.variadic ? ")[]" : ""}`};${option.alias && option.alias.length > 0 ? option.alias.map((alias) => `${alias}${option.optional ? "?" : ""}: ${option.kind === require_types_command.CommandParameterKinds.boolean ? "boolean" : `${option.variadic ? "(" : ""}${option.choices ? option.choices.map((choice) => option.kind === require_types_command.CommandParameterKinds.number ? `${choice}` : `"${choice}"`).join(" | ") : option.kind === require_types_command.CommandParameterKinds.number ? "number" : "string"}${option.variadic ? ")[]" : ""}`};`).join("\n\n") : ""}`).join("\n\n")}
163
+ }
164
+ `;
165
+ },
142
166
  async prepare() {
143
167
  this.debug("Rendering base built-in modules for the Shell Shock application.");
144
168
  return (0, _powerlines_plugin_alloy_render.render)(this, [(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_utils_builtin.UtilsBuiltin, {})]);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"]\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAE,YAAA;;;;AAKF,MAAE,UAAiB,UAAA,EAAA,KAAA;AACjB,QAAA;iCAAU;2CAAA;0CAAA;EAAA;GACV,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,2CAAoB;AACpB,UAAA,oDAAA,KAAA;AA0BI,0BAzBiB,EACf,QAAC,EACA,kDAAmB,KAAQ,OAAO,MAAM,OAAA,EACxC,EACF,EAAA,SAAO;KACP,MAAO,mCAAU,KAAM;KACvB,OAAO,oCAAU,KAAQ;;KAE1B,UAAY;;KAEhB,iBAAA;KACK,QAAK;MACV,QAAA;MACK,KAAM;MACJ;KACJ,OAAA,CAAA,KAAA,OAAA,SAAA,MAAA,QAAA,KAAA,OAAA,MAAA,IAAA,KAAA,OAAA,MAAA,WAAA,iDAAA,KAAA,OAAA,MAAA,IAAA,OAAA,KAAA,KAAA,OAAA,MAAA,CAAA,WAAA,IAAA,wCAAA,KAAA,OAAA,MAAA,oBAAA,yCAAA,KAAA,OAAA,MAAA,qBAAA,CAAA,GAAA;KACG,SAAC,EACC,UAAE,CAAA,sBAAA,EACR;KACA,QAAQ;MACR,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C;;MAEL,CAAC;KACH,CAAC,CAAC;;GAEN;EAAC"}
1
+ {"version":3,"file":"plugin.cjs","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport { CommandParameterKinds } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n path: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"]\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.commandsPath = findCommandsRoot(this);\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n typegen(code: string) {\n this.debug(\n \"Generating type definitions for the Shell Shock application.\"\n );\n\n return `${code}\n\n/**\n * The global options available for every command in the ${getAppTitle(\n this,\n true\n )} command-line application.\n */\nexport interface GlobalOptions {\n ${this.options\n .map(\n option =>\n `${\n option.description\n ? `\n/**\n * ${option.description}${\n option.default\n ? `\n *\n * @defaultValue ${\n option.kind === CommandParameterKinds.string\n ? `\"${option.default}\"`\n : option.default\n }`\n : \"\"\n }\n */\n`\n : \"\"\n }${option.name}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };${\n option.alias && option.alias.length > 0\n ? option.alias\n .map(\n alias =>\n `${alias}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };`\n )\n .join(\"\\n\\n\")\n : \"\"\n }`\n )\n .join(\"\\n\\n\")}\n}\n`;\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,YAAY;;;;AAKlB,MAAY,UAAA,UAAA,EAAA,KAAA;AACV,QAAA;iCAAW;2CAAA;0CAAA;EAAA;GACX,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,2CAAA;AACI,UAAI,oDAAqB,KAAQ;AA0BjC,0BAzBoB,EAClB,QAAC,EACA,6CAAiB,KAAC,OAAS,MAAQ,OAAA,EACrC,EACA,EAAE,SAAA;KACF,MAAO,mCAAU,KAAM;KACvB,OAAO,oCAAU,KAAQ;;KAE1B,UAAY;;KAEhB,iBAAA;KACK,QAAK;MACV,QAAA;MACK,KAAM;MACJ;KACJ,OAAA,CAAA,KAAA,OAAA,SAAA,MAAA,QAAA,KAAA,OAAA,MAAA,IAAA,KAAA,OAAA,MAAA,WAAA,iDAAA,KAAA,OAAA,MAAA,IAAA,OAAA,KAAA,KAAA,OAAA,MAAA,CAAA,WAAA,IAAA,wCAAA,KAAA,OAAA,MAAA,oBAAA,yCAAA,KAAA,OAAA,MAAA,qBAAA,CAAA,GAAA;KACG,SAAC,EACC,UAAE,CAAA,sBAAA,EAC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OAAA,EAChD,OAAA,GAAS,OAAA,KAyfJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KA0lBJ,MAAA,CAAO,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAiFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KAyfJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KA0lBJ,MAAA,CAAO,QAAA"}
package/dist/plugin.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, isDynamicPathSegment, isPathSegmentGroup } from "./plugin-utils/context-helpers.mjs";
2
+ import { CommandParameterKinds } from "./types/command.mjs";
2
3
  import { CommandDocsFile } from "./components/docs.mjs";
3
4
  import { UtilsBuiltin } from "./components/utils-builtin.mjs";
4
5
  import { traverseCommands } from "./plugin-utils/traverse-command-tree.mjs";
@@ -7,7 +8,7 @@ import { commands } from "./helpers/automd.mjs";
7
8
  import { findCommandsRoot, resolveCommandId, resolveCommandName, resolveCommandPath } from "./helpers/paths.mjs";
8
9
  import { getCommandsPersistencePath, readCommandsPersistence, writeCommandsPersistence } from "./helpers/persistence.mjs";
9
10
  import { formatBinaryPath, updatePackageJsonBinary } from "./helpers/update-package-json.mjs";
10
- import { formatCommandTree, getDefaultOptions } from "./helpers/utilities.mjs";
11
+ import { formatCommandTree, getGlobalOptions } from "./helpers/utilities.mjs";
11
12
  import { validateCommand } from "./helpers/validations.mjs";
12
13
  import { resolve } from "./resolver/resolve.mjs";
13
14
  import { createComponent } from "@alloy-js/core/jsx-runtime";
@@ -48,7 +49,7 @@ const plugin = (options = {}) => {
48
49
  async config() {
49
50
  this.debug("Resolving the Shell Shock configuration.");
50
51
  await updatePackageJsonBinary(this);
51
- return defu({ output: { buildPath: joinPaths(this.config.root, "dist") } }, options, {
52
+ return defu({ output: { path: joinPaths(this.config.root, "dist") } }, options, {
52
53
  name: getAppName(this),
53
54
  title: getAppTitle(this),
54
55
  description: getAppDescription(this),
@@ -77,7 +78,7 @@ const plugin = (options = {}) => {
77
78
  if (!this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)) this.config.env.prefix.push(this.config.appSpecificEnvPrefix);
78
79
  this.config.bin = (isSetString(this.packageJson.bin) ? { [kebabCase(this.config.name)]: this.packageJson.bin } : this.packageJson.bin) ?? { [kebabCase(this.config.name)]: formatBinaryPath(this.config.output.format) };
79
80
  this.inputs ??= [];
80
- this.options = Object.values(getDefaultOptions(this, {
81
+ this.options = Object.values(getGlobalOptions(this, {
81
82
  id: null,
82
83
  name: this.config.name,
83
84
  path: null,
@@ -98,6 +99,11 @@ const plugin = (options = {}) => {
98
99
  name: "shell-shock:inputs",
99
100
  async configResolved() {
100
101
  this.debug("Finding command entry point files.");
102
+ if (isSetString(this.config.reference)) if (this.config.reference.includes("{command}")) this.config.reference = {
103
+ app: this.config.reference.substring(0, this.config.reference.indexOf("{command}")).replace(/\/?$/, "/"),
104
+ commands: this.config.reference
105
+ };
106
+ else this.config.reference = { app: this.config.reference };
101
107
  this.commandsPath = findCommandsRoot(this);
102
108
  const inputs = await resolveInputs(this, this.config.input);
103
109
  this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
@@ -134,6 +140,24 @@ const plugin = (options = {}) => {
134
140
  }, this.inputs);
135
141
  this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}`).join("\n")}`);
136
142
  },
143
+ typegen(code) {
144
+ this.debug("Generating type definitions for the Shell Shock application.");
145
+ return `${code}
146
+
147
+ /**
148
+ * The global options available for every command in the ${getAppTitle(this, true)} command-line application.
149
+ */
150
+ export interface GlobalOptions {
151
+ ${this.options.map((option) => `${option.description ? `
152
+ /**
153
+ * ${option.description}${option.default ? `
154
+ *
155
+ * @defaultValue ${option.kind === CommandParameterKinds.string ? `"${option.default}"` : option.default}` : ""}
156
+ */
157
+ ` : ""}${option.name}${option.optional ? "?" : ""}: ${option.kind === CommandParameterKinds.boolean ? "boolean" : `${option.variadic ? "(" : ""}${option.choices ? option.choices.map((choice) => option.kind === CommandParameterKinds.number ? `${choice}` : `"${choice}"`).join(" | ") : option.kind === CommandParameterKinds.number ? "number" : "string"}${option.variadic ? ")[]" : ""}`};${option.alias && option.alias.length > 0 ? option.alias.map((alias) => `${alias}${option.optional ? "?" : ""}: ${option.kind === CommandParameterKinds.boolean ? "boolean" : `${option.variadic ? "(" : ""}${option.choices ? option.choices.map((choice) => option.kind === CommandParameterKinds.number ? `${choice}` : `"${choice}"`).join(" | ") : option.kind === CommandParameterKinds.number ? "number" : "string"}${option.variadic ? ")[]" : ""}`};`).join("\n\n") : ""}`).join("\n\n")}
158
+ }
159
+ `;
160
+ },
137
161
  async prepare() {
138
162
  this.debug("Rendering base built-in modules for the Shell Shock application.");
139
163
  return render(this, [createComponent(UtilsBuiltin, {})]);