@shell-shock/preset-script 0.1.1 → 0.1.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 (134) hide show
  1. package/README.md +1 -1
  2. package/dist/components/args-parser-logic.cjs +678 -0
  3. package/dist/components/args-parser-logic.cjs.map +1 -0
  4. package/dist/components/args-parser-logic.d.cts +45 -0
  5. package/dist/components/args-parser-logic.d.cts.map +1 -0
  6. package/dist/components/args-parser-logic.d.mts +45 -0
  7. package/dist/components/args-parser-logic.d.mts.map +1 -0
  8. package/dist/components/args-parser-logic.mjs +672 -0
  9. package/dist/components/args-parser-logic.mjs.map +1 -0
  10. package/dist/components/bin-entry.cjs +179 -0
  11. package/dist/components/bin-entry.cjs.map +1 -0
  12. package/dist/components/{entry/bin.d.cts → bin-entry.d.cts} +9 -3
  13. package/dist/components/bin-entry.d.cts.map +1 -0
  14. package/dist/components/{entry/bin.d.mts → bin-entry.d.mts} +9 -3
  15. package/dist/components/bin-entry.d.mts.map +1 -0
  16. package/dist/components/bin-entry.mjs +176 -0
  17. package/dist/components/bin-entry.mjs.map +1 -0
  18. package/dist/components/command-entry.cjs +162 -0
  19. package/dist/components/command-entry.cjs.map +1 -0
  20. package/dist/components/command-entry.d.cts +24 -0
  21. package/dist/components/command-entry.d.cts.map +1 -0
  22. package/dist/components/command-entry.d.mts +24 -0
  23. package/dist/components/command-entry.d.mts.map +1 -0
  24. package/dist/components/command-entry.mjs +158 -0
  25. package/dist/components/command-entry.mjs.map +1 -0
  26. package/dist/components/command-router.cjs +104 -74
  27. package/dist/components/command-router.cjs.map +1 -1
  28. package/dist/components/command-router.d.cts +13 -4
  29. package/dist/components/command-router.d.cts.map +1 -0
  30. package/dist/components/command-router.d.mts +13 -4
  31. package/dist/components/command-router.d.mts.map +1 -0
  32. package/dist/components/command-router.mjs +103 -73
  33. package/dist/components/command-router.mjs.map +1 -1
  34. package/dist/components/console-builtin.cjs +2083 -0
  35. package/dist/components/console-builtin.cjs.map +1 -0
  36. package/dist/components/console-builtin.d.cts +56 -0
  37. package/dist/components/console-builtin.d.cts.map +1 -0
  38. package/dist/components/console-builtin.d.mts +56 -0
  39. package/dist/components/console-builtin.d.mts.map +1 -0
  40. package/dist/components/console-builtin.mjs +2074 -0
  41. package/dist/components/console-builtin.mjs.map +1 -0
  42. package/dist/components/help.cjs +130 -0
  43. package/dist/components/help.cjs.map +1 -0
  44. package/dist/components/help.d.cts +57 -0
  45. package/dist/components/help.d.cts.map +1 -0
  46. package/dist/components/help.d.mts +57 -0
  47. package/dist/components/help.d.mts.map +1 -0
  48. package/dist/components/help.mjs +126 -0
  49. package/dist/components/help.mjs.map +1 -0
  50. package/dist/components/index.cjs +39 -15
  51. package/dist/components/index.d.cts +9 -7
  52. package/dist/components/index.d.mts +9 -7
  53. package/dist/components/index.mjs +8 -6
  54. package/dist/components/utils-builtin.cjs +612 -0
  55. package/dist/components/utils-builtin.cjs.map +1 -0
  56. package/dist/components/utils-builtin.d.cts +32 -0
  57. package/dist/components/utils-builtin.d.cts.map +1 -0
  58. package/dist/components/utils-builtin.d.mts +32 -0
  59. package/dist/components/utils-builtin.d.mts.map +1 -0
  60. package/dist/components/utils-builtin.mjs +605 -0
  61. package/dist/components/utils-builtin.mjs.map +1 -0
  62. package/dist/components/virtual-command-entry.cjs +133 -0
  63. package/dist/components/virtual-command-entry.cjs.map +1 -0
  64. package/dist/components/virtual-command-entry.d.cts +21 -0
  65. package/dist/components/virtual-command-entry.d.cts.map +1 -0
  66. package/dist/components/virtual-command-entry.d.mts +21 -0
  67. package/dist/components/virtual-command-entry.d.mts.map +1 -0
  68. package/dist/components/virtual-command-entry.mjs +130 -0
  69. package/dist/components/virtual-command-entry.mjs.map +1 -0
  70. package/dist/contexts/index.cjs +4 -0
  71. package/dist/contexts/index.d.cts +2 -0
  72. package/dist/contexts/index.d.mts +2 -0
  73. package/dist/contexts/index.mjs +3 -0
  74. package/dist/contexts/theme.d.cts +20 -0
  75. package/dist/contexts/theme.d.cts.map +1 -0
  76. package/dist/contexts/theme.d.mts +20 -0
  77. package/dist/contexts/theme.d.mts.map +1 -0
  78. package/dist/helpers/ansi-utils.cjs +28 -4
  79. package/dist/helpers/ansi-utils.cjs.map +1 -1
  80. package/dist/helpers/ansi-utils.d.cts +68 -0
  81. package/dist/helpers/ansi-utils.d.cts.map +1 -0
  82. package/dist/helpers/ansi-utils.d.mts +68 -0
  83. package/dist/helpers/ansi-utils.d.mts.map +1 -0
  84. package/dist/helpers/ansi-utils.mjs +28 -4
  85. package/dist/helpers/ansi-utils.mjs.map +1 -1
  86. package/dist/helpers/get-default-options.cjs +6 -13
  87. package/dist/helpers/get-default-options.cjs.map +1 -1
  88. package/dist/helpers/get-default-options.mjs +6 -13
  89. package/dist/helpers/get-default-options.mjs.map +1 -1
  90. package/dist/index.cjs +114 -29
  91. package/dist/index.cjs.map +1 -1
  92. package/dist/index.d.cts.map +1 -0
  93. package/dist/index.d.mts.map +1 -0
  94. package/dist/index.mjs +115 -28
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/types/plugin.d.cts +1 -6
  97. package/dist/types/plugin.d.cts.map +1 -0
  98. package/dist/types/plugin.d.mts +1 -6
  99. package/dist/types/plugin.d.mts.map +1 -0
  100. package/package.json +163 -71
  101. package/dist/components/builtin/console.cjs +0 -1232
  102. package/dist/components/builtin/console.cjs.map +0 -1
  103. package/dist/components/builtin/console.d.cts +0 -37
  104. package/dist/components/builtin/console.d.mts +0 -37
  105. package/dist/components/builtin/console.mjs +0 -1225
  106. package/dist/components/builtin/console.mjs.map +0 -1
  107. package/dist/components/builtin/index.cjs +0 -9
  108. package/dist/components/builtin/index.d.cts +0 -2
  109. package/dist/components/builtin/index.d.mts +0 -2
  110. package/dist/components/builtin/index.mjs +0 -3
  111. package/dist/components/entry/bin.cjs +0 -92
  112. package/dist/components/entry/bin.cjs.map +0 -1
  113. package/dist/components/entry/bin.mjs +0 -91
  114. package/dist/components/entry/bin.mjs.map +0 -1
  115. package/dist/components/entry/command.cjs +0 -54
  116. package/dist/components/entry/command.cjs.map +0 -1
  117. package/dist/components/entry/command.d.cts +0 -15
  118. package/dist/components/entry/command.d.mts +0 -15
  119. package/dist/components/entry/command.mjs +0 -53
  120. package/dist/components/entry/command.mjs.map +0 -1
  121. package/dist/components/entry/index.cjs +0 -3
  122. package/dist/components/entry/index.d.cts +0 -2
  123. package/dist/components/entry/index.d.mts +0 -2
  124. package/dist/components/entry/index.mjs +0 -3
  125. package/dist/components/shutdown.cjs +0 -93
  126. package/dist/components/shutdown.cjs.map +0 -1
  127. package/dist/components/shutdown.d.cts +0 -14
  128. package/dist/components/shutdown.d.mts +0 -14
  129. package/dist/components/shutdown.mjs +0 -91
  130. package/dist/components/shutdown.mjs.map +0 -1
  131. package/dist/contexts/command.cjs +0 -21
  132. package/dist/contexts/command.cjs.map +0 -1
  133. package/dist/contexts/command.mjs +0 -19
  134. package/dist/contexts/command.mjs.map +0 -1
@@ -0,0 +1,162 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_components_args_parser_logic = require('./args-parser-logic.cjs');
3
+ const require_components_help = require('./help.cjs');
4
+ const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
5
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
6
+ let __alloy_js_core = require("@alloy-js/core");
7
+ let __alloy_js_typescript = require("@alloy-js/typescript");
8
+ let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
9
+ let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
10
+ let __powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
11
+ let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
12
+ let __stryke_path_replace = require("@stryke/path/replace");
13
+ let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
14
+ let defu = require("defu");
15
+ defu = require_rolldown_runtime.__toESM(defu);
16
+ let __stryke_path_find = require("@stryke/path/find");
17
+ let __stryke_path_join = require("@stryke/path/join");
18
+ let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
19
+ let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
20
+
21
+ //#region src/components/command-entry.tsx
22
+ function CommandInvocation(props) {
23
+ const { command } = props;
24
+ return [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`return Promise.resolve(handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(options${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment)).map((segment) => (0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getVariableCommandPathName)(segment))).join(", ")}` : ""}${command.params.length > 0 ? `, ${command.params.map((param) => (0, __stryke_string_format_camel_case.camelCase)(param.name)).join(", ")}` : ""}));`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
25
+ }
26
+ /**
27
+ * A component that generates the `handler` function declaration for a command.
28
+ */
29
+ function CommandHandlerDeclaration(props) {
30
+ const { command } = props;
31
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
32
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
33
+ get heading() {
34
+ return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment) ? `[${(0, __stryke_string_format_constant_case.constantCase)((0, __shell_shock_core_plugin_utils_context_helpers.getVariableCommandPathName)(segment))}]` : segment).join(" ")}) command.`;
35
+ },
36
+ get children() {
37
+ return [
38
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { get children() {
39
+ return `${command.description.replace(/\.+$/, "")}.`;
40
+ } }),
41
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
42
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocTitle, { get children() {
43
+ return command.title;
44
+ } }),
45
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
46
+ name: "args",
47
+ children: `The command-line arguments passed to the command.`
48
+ })
49
+ ];
50
+ }
51
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
52
+ "export": true,
53
+ async: true,
54
+ name: "handler",
55
+ parameters: [{
56
+ name: "args",
57
+ type: "string[]",
58
+ default: "getArgs()"
59
+ }],
60
+ get children() {
61
+ return [
62
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_args_parser_logic.VariablePathsParserLogic, { get path() {
63
+ return command.path;
64
+ } }),
65
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
66
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
67
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_args_parser_logic.OptionsParserLogic, { command }),
68
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
69
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
70
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_args_parser_logic.ParamsParserLogic, { get params() {
71
+ return command.params;
72
+ } }),
73
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
74
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
75
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
76
+ condition: __alloy_js_core.code`options.help`,
77
+ get children() {
78
+ return [
79
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
80
+ writeLine("");
81
+ writeLine(colors.text.heading.primary("${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context)} - ${command.title}"));
82
+ writeLine("");
83
+ writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
84
+ writeLine("");`),
85
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
86
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.Help, { command })
87
+ ];
88
+ }
89
+ }),
90
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { get children() {
91
+ return [(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}), (0, __alloy_js_core_jsx_runtime.createComponent)(CommandInvocation, { command })];
92
+ } })
93
+ ];
94
+ }
95
+ })];
96
+ }
97
+ /**
98
+ * The command entry point for the Shell Shock project.
99
+ */
100
+ function CommandEntry(props) {
101
+ const { command, imports, builtinImports, ...rest } = props;
102
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
103
+ const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment)).join("/"), "index.ts"));
104
+ const commandSourcePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_replace.replaceExtension)((0, __stryke_path_find.relativePath)((0, __stryke_path_join.joinPaths)(context.entryPath, (0, __stryke_path_find.findFilePath)(filePath.value)), command.entry.input?.file || command.entry.file)));
105
+ const typeDefinition = (0, __alloy_js_core.computed)(() => ({
106
+ ...command.entry,
107
+ output: command.id
108
+ }));
109
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_entry_file.EntryFile, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
110
+ get path() {
111
+ return filePath.value;
112
+ },
113
+ get typeDefinition() {
114
+ return typeDefinition.value;
115
+ },
116
+ get imports() {
117
+ return (0, defu.default)(imports ?? {}, { [commandSourcePath.value]: `handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}` });
118
+ },
119
+ get builtinImports() {
120
+ return (0, defu.default)(builtinImports ?? {}, {
121
+ env: ["env"],
122
+ console: [
123
+ "warn",
124
+ "error",
125
+ "table",
126
+ "colors",
127
+ "writeLine"
128
+ ],
129
+ utils: ["getArgs"]
130
+ });
131
+ },
132
+ get children() {
133
+ return [
134
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_args_parser_logic.OptionsInterfaceDeclaration, { command }),
135
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
136
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
137
+ (0, __alloy_js_core_jsx_runtime.createComponent)(CommandHandlerDeclaration, { command })
138
+ ];
139
+ }
140
+ })), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
141
+ get each() {
142
+ return Object.values(command.children);
143
+ },
144
+ children: (child) => (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
145
+ get when() {
146
+ return child.isVirtual;
147
+ },
148
+ get fallback() {
149
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(CommandEntry, { command: child });
150
+ },
151
+ get children() {
152
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_virtual_command_entry.VirtualCommandEntry, { command: child });
153
+ }
154
+ })
155
+ })];
156
+ }
157
+
158
+ //#endregion
159
+ exports.CommandEntry = CommandEntry;
160
+ exports.CommandHandlerDeclaration = CommandHandlerDeclaration;
161
+ exports.CommandInvocation = CommandInvocation;
162
+ //# sourceMappingURL=command-entry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","getAppBin","getAppTitle","getVariableCommandPathName","isVariableCommandPath","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","OptionsInterfaceDeclaration","OptionsParserLogic","ParamsParserLogic","VariablePathsParserLogic","Help","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","params","param","_$createIntrinsic","CommandHandlerDeclaration","context","_$createComponent","heading","title","children","description","replace","async","parameters","type","default","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n getAppBin,\n getAppTitle,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n ParamsParserLogic,\n VariablePathsParserLogic\n} from \"./args-parser-logic\";\nimport { Help } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment => isVariableCommandPath(segment))\n .length > 0\n ? `, ${command.path.segments\n .filter(segment => isVariableCommandPath(segment))\n .map(segment => camelCase(getVariableCommandPathName(segment)))\n .join(\", \")}`\n : \"\"\n }${\n command.params.length > 0\n ? `, ${command.params.map(param => camelCase(param.name)).join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `[${constantCase(getVariableCommandPathName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <VariablePathsParserLogic path={command.path} />\n <hbr />\n <hbr />\n <OptionsParserLogic command={command} />\n <hbr />\n <hbr />\n <ParamsParserLogic params={command.params} />\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(\n /\\.+$/,\n \"\"\n )}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isVariableCommandPath(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\"],\n console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\"]\n })}>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualComm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KAE/C,CACF,CAAC;CACD,MAAMC,sDAAiC;EACrC,GAAGrC,QAAQkC;EACXI,QAAQtC,QAAQuC;EACjB,EAAE;AAEH,QAAA,kDAEKhE,kHACKsD,MAAI;EAAA,IACR1B,OAAI;AAAA,UAAE2B,SAASG;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCN,UAAO;AAAA,4BAAOA,WAAW,EAAE,EAAE,GAC1BI,kBAAkBE,QAAQ,4DAAoBjC,QAAQE,KAAK,IAC7D,CAAC;;EAAA,IACF0B,iBAAc;AAAA,4BAAOA,kBAAkB,EAAE,EAAE;IACzCa,KAAK,CAAC,MAAM;IACZC,SAAS;KAAC;KAAQ;KAAS;KAAS;KAAU;KAAY;IAC1DC,OAAO,CAAC,UAAS;IAClB,CAAC;;EAAA,IAAAzB,WAAA;AAAA,UAAA;qDACD1B,kEAA2B,EAAUQ,SAAO,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAG5Ca,2BAAyB,EAAUb,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,mDAE5C/B,qBAAG;EAAA,IAAC2E,OAAI;AAAA,UAAEC,OAAOC,OAAO9C,QAAQkB,SAAS;;EAAAA,WACvC6B,2DACE7E,sBAAI;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,4DAAGxB,cAAY,EAAC1B,SAAS+C,OAAK,CAAA;;GAAA,IAAA7B,WAAA;AAAA,4DACrCrB,8DAAmB,EAACG,SAAS+C,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -0,0 +1,24 @@
1
+ import * as _alloy_js_core11 from "@alloy-js/core";
2
+ import { CommandTree } from "@shell-shock/core/types/command";
3
+ import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
4
+
5
+ //#region src/components/command-entry.d.ts
6
+ declare function CommandInvocation(props: {
7
+ command: CommandTree;
8
+ }): _alloy_js_core11.Children;
9
+ /**
10
+ * A component that generates the `handler` function declaration for a command.
11
+ */
12
+ declare function CommandHandlerDeclaration(props: {
13
+ command: CommandTree;
14
+ }): _alloy_js_core11.Children;
15
+ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
+ command: CommandTree;
17
+ }
18
+ /**
19
+ * The command entry point for the Shell Shock project.
20
+ */
21
+ declare function CommandEntry(props: CommandEntryProps): _alloy_js_core11.Children;
22
+ //#endregion
23
+ export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
24
+ //# sourceMappingURL=command-entry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AA0BA;AA4DA;AACE,iBA7Dc,yBAAA,CA6Dd,KAAA,EAAA;EAGS,OAAA,EAhEiD,WAgEjD;CAJgC,CAAA,EA5D4B,gBAAA,CAAE,QA4D9B;AAAI,UAA9B,iBAAA,SAA0B,IAAI,CAC7C,cAD6C,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAU/B,OAAA,EANL,WAMiB;;;;;iBAAZ,YAAA,QAAoB,oBAAiB,gBAAA,CAAA"}
@@ -0,0 +1,24 @@
1
+ import * as _alloy_js_core11 from "@alloy-js/core";
2
+ import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
3
+ import { CommandTree } from "@shell-shock/core/types/command";
4
+
5
+ //#region src/components/command-entry.d.ts
6
+ declare function CommandInvocation(props: {
7
+ command: CommandTree;
8
+ }): _alloy_js_core11.Children;
9
+ /**
10
+ * A component that generates the `handler` function declaration for a command.
11
+ */
12
+ declare function CommandHandlerDeclaration(props: {
13
+ command: CommandTree;
14
+ }): _alloy_js_core11.Children;
15
+ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
+ command: CommandTree;
17
+ }
18
+ /**
19
+ * The command entry point for the Shell Shock project.
20
+ */
21
+ declare function CommandEntry(props: CommandEntryProps): _alloy_js_core11.Children;
22
+ //#endregion
23
+ export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
24
+ //# sourceMappingURL=command-entry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AA0BA;AA4DA;AACE,iBA7Dc,yBAAA,CA6Dd,KAAA,EAAA;EAGS,OAAA,EAhEiD,WAgEjD;CAJgC,CAAA,EA5D4B,gBAAA,CAAE,QA4D9B;AAAI,UAA9B,iBAAA,SAA0B,IAAI,CAC7C,cAD6C,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAU/B,OAAA,EANL,WAMiB;;;;;iBAAZ,YAAA,QAAoB,oBAAiB,gBAAA,CAAA"}
@@ -0,0 +1,158 @@
1
+ import { OptionsInterfaceDeclaration, OptionsParserLogic, ParamsParserLogic, VariablePathsParserLogic } from "./args-parser-logic.mjs";
2
+ import { Help } from "./help.mjs";
3
+ import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
4
+ import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
5
+ import { For, Show, code, computed } from "@alloy-js/core";
6
+ import { ElseClause, FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
7
+ import { getAppBin, getAppTitle, getVariableCommandPathName, isVariableCommandPath } from "@shell-shock/core/plugin-utils/context-helpers";
8
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
9
+ import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
10
+ import { TSDoc, TSDocParam, TSDocRemarks, TSDocTitle } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
11
+ import { replaceExtension } from "@stryke/path/replace";
12
+ import { pascalCase } from "@stryke/string-format/pascal-case";
13
+ import defu from "defu";
14
+ import { findFilePath, relativePath } from "@stryke/path/find";
15
+ import { joinPaths } from "@stryke/path/join";
16
+ import { camelCase } from "@stryke/string-format/camel-case";
17
+ import { constantCase } from "@stryke/string-format/constant-case";
18
+
19
+ //#region src/components/command-entry.tsx
20
+ function CommandInvocation(props) {
21
+ const { command } = props;
22
+ return [memo(() => code`return Promise.resolve(handle${pascalCase(command.name)}(options${command.path.segments.filter((segment) => isVariableCommandPath(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => isVariableCommandPath(segment)).map((segment) => camelCase(getVariableCommandPathName(segment))).join(", ")}` : ""}${command.params.length > 0 ? `, ${command.params.map((param) => camelCase(param.name)).join(", ")}` : ""}));`), createIntrinsic("hbr", {})];
23
+ }
24
+ /**
25
+ * A component that generates the `handler` function declaration for a command.
26
+ */
27
+ function CommandHandlerDeclaration(props) {
28
+ const { command } = props;
29
+ const context = usePowerlines();
30
+ return [createComponent(TSDoc, {
31
+ get heading() {
32
+ return `The ${command.title} (${getAppBin(context)} ${command.path.segments.map((segment) => isVariableCommandPath(segment) ? `[${constantCase(getVariableCommandPathName(segment))}]` : segment).join(" ")}) command.`;
33
+ },
34
+ get children() {
35
+ return [
36
+ createComponent(TSDocRemarks, { get children() {
37
+ return `${command.description.replace(/\.+$/, "")}.`;
38
+ } }),
39
+ createIntrinsic("hbr", {}),
40
+ createComponent(TSDocTitle, { get children() {
41
+ return command.title;
42
+ } }),
43
+ createComponent(TSDocParam, {
44
+ name: "args",
45
+ children: `The command-line arguments passed to the command.`
46
+ })
47
+ ];
48
+ }
49
+ }), createComponent(FunctionDeclaration, {
50
+ "export": true,
51
+ async: true,
52
+ name: "handler",
53
+ parameters: [{
54
+ name: "args",
55
+ type: "string[]",
56
+ default: "getArgs()"
57
+ }],
58
+ get children() {
59
+ return [
60
+ createComponent(VariablePathsParserLogic, { get path() {
61
+ return command.path;
62
+ } }),
63
+ createIntrinsic("hbr", {}),
64
+ createIntrinsic("hbr", {}),
65
+ createComponent(OptionsParserLogic, { command }),
66
+ createIntrinsic("hbr", {}),
67
+ createIntrinsic("hbr", {}),
68
+ createComponent(ParamsParserLogic, { get params() {
69
+ return command.params;
70
+ } }),
71
+ createIntrinsic("hbr", {}),
72
+ createIntrinsic("hbr", {}),
73
+ createComponent(IfStatement, {
74
+ condition: code`options.help`,
75
+ get children() {
76
+ return [
77
+ memo(() => code`
78
+ writeLine("");
79
+ writeLine(colors.text.heading.primary("${getAppTitle(context)} - ${command.title}"));
80
+ writeLine("");
81
+ writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
82
+ writeLine("");`),
83
+ createIntrinsic("hbr", {}),
84
+ createComponent(Help, { command })
85
+ ];
86
+ }
87
+ }),
88
+ createComponent(ElseClause, { get children() {
89
+ return [createIntrinsic("hbr", {}), createComponent(CommandInvocation, { command })];
90
+ } })
91
+ ];
92
+ }
93
+ })];
94
+ }
95
+ /**
96
+ * The command entry point for the Shell Shock project.
97
+ */
98
+ function CommandEntry(props) {
99
+ const { command, imports, builtinImports, ...rest } = props;
100
+ const context = usePowerlines();
101
+ const filePath = computed(() => joinPaths(command.path.segments.filter((segment) => !isVariableCommandPath(segment)).join("/"), "index.ts"));
102
+ const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
103
+ const typeDefinition = computed(() => ({
104
+ ...command.entry,
105
+ output: command.id
106
+ }));
107
+ return [createComponent(EntryFile, mergeProps(rest, {
108
+ get path() {
109
+ return filePath.value;
110
+ },
111
+ get typeDefinition() {
112
+ return typeDefinition.value;
113
+ },
114
+ get imports() {
115
+ return defu(imports ?? {}, { [commandSourcePath.value]: `handle${pascalCase(command.name)}` });
116
+ },
117
+ get builtinImports() {
118
+ return defu(builtinImports ?? {}, {
119
+ env: ["env"],
120
+ console: [
121
+ "warn",
122
+ "error",
123
+ "table",
124
+ "colors",
125
+ "writeLine"
126
+ ],
127
+ utils: ["getArgs"]
128
+ });
129
+ },
130
+ get children() {
131
+ return [
132
+ createComponent(OptionsInterfaceDeclaration, { command }),
133
+ createIntrinsic("hbr", {}),
134
+ createIntrinsic("hbr", {}),
135
+ createComponent(CommandHandlerDeclaration, { command })
136
+ ];
137
+ }
138
+ })), createComponent(For, {
139
+ get each() {
140
+ return Object.values(command.children);
141
+ },
142
+ children: (child) => createComponent(Show, {
143
+ get when() {
144
+ return child.isVirtual;
145
+ },
146
+ get fallback() {
147
+ return createComponent(CommandEntry, { command: child });
148
+ },
149
+ get children() {
150
+ return createComponent(VirtualCommandEntry, { command: child });
151
+ }
152
+ })
153
+ })];
154
+ }
155
+
156
+ //#endregion
157
+ export { CommandEntry, CommandHandlerDeclaration, CommandInvocation };
158
+ //# sourceMappingURL=command-entry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","getAppBin","getAppTitle","getVariableCommandPathName","isVariableCommandPath","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","OptionsInterfaceDeclaration","OptionsParserLogic","ParamsParserLogic","VariablePathsParserLogic","Help","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","params","param","_$createIntrinsic","CommandHandlerDeclaration","context","_$createComponent","heading","title","children","description","replace","async","parameters","type","default","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n getAppBin,\n getAppTitle,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n ParamsParserLogic,\n VariablePathsParserLogic\n} from \"./args-parser-logic\";\nimport { Help } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment => isVariableCommandPath(segment))\n .length > 0\n ? `, ${command.path.segments\n .filter(segment => isVariableCommandPath(segment))\n .map(segment => camelCase(getVariableCommandPathName(segment)))\n .join(\", \")}`\n : \"\"\n }${\n command.params.length > 0\n ? `, ${command.params.map(param => camelCase(param.name)).join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `[${constantCase(getVariableCommandPathName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <VariablePathsParserLogic path={command.path} />\n <hbr />\n <hbr />\n <OptionsParserLogic command={command} />\n <hbr />\n <hbr />\n <ParamsParserLogic params={command.params} />\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(\n /\\.+$/,\n \"\"\n )}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isVariableCommandPath(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\"],\n console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\"]\n })}>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyDA,SAAgB+B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,CAAAE,WAEKlC,IAAI,gCAAgCuB,WAAWU,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,YAAWvB,sBAAsBuB,QAAQ,CAAC,CACpEC,SAAS,IACR,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,YAAWvB,sBAAsBuB,QAAQ,CAAC,CACjDE,KAAIF,YAAWlB,UAAUN,2BAA2BwB,QAAQ,CAAC,CAAC,CAC9DG,KAAK,KAAK,KACb,KAEJT,QAAQU,OAAOH,SAAS,IACpB,KAAKP,QAAQU,OAAOF,KAAIG,UAASvB,UAAUuB,MAAMT,KAAK,CAAC,CAACO,KAAK,KAAK,KAClE,GAAE,KACH,EAAA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AAAA,UAAEpC,KAAKoC,WAAW,EAAE,EAAE,GAC1BI,kBAAkBE,QAAQ,SAAS3C,WAAWU,QAAQE,KAAK,IAC7D,CAAC;;EAAA,IACF0B,iBAAc;AAAA,UAAErC,KAAKqC,kBAAkB,EAAE,EAAE;IACzCa,KAAK,CAAC,MAAM;IACZC,SAAS;KAAC;KAAQ;KAAS;KAAS;KAAU;KAAY;IAC1DC,OAAO,CAAC,UAAS;IAClB,CAAC;;EAAA,IAAAzB,WAAA;AAAA,UAAA;IAAAH,gBACDvB,6BAA2B,EAAUQ,SAAO,CAAA;IAAAY,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAG,gBAG5CF,2BAAyB,EAAUb,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAe,gBAE5C9C,KAAG;EAAA,IAAC2E,OAAI;AAAA,UAAEC,OAAOC,OAAO9C,QAAQkB,SAAS;;EAAAA,WACvC6B,UAAKhC,gBACH7C,MAAI;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,WAAAnC,gBAAGW,cAAY,EAAC1B,SAAS+C,OAAK,CAAA;;GAAA,IAAA7B,WAAA;AAAA,WAAAH,gBACrClB,qBAAmB,EAACG,SAAS+C,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -1,100 +1,130 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_command = require('../contexts/command.cjs');
3
2
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
3
  let __alloy_js_core = require("@alloy-js/core");
5
4
  let __alloy_js_typescript = require("@alloy-js/typescript");
6
- let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
7
- let __powerlines_plugin_alloy_typescript_components_dynamic_import_statement = require("@powerlines/plugin-alloy/typescript/components/dynamic-import-statement");
5
+ let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
8
6
  let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
7
+ let __powerlines_plugin_alloy_typescript_components_dynamic_import_statement = require("@powerlines/plugin-alloy/typescript/components/dynamic-import-statement");
8
+ let __shell_shock_core_contexts_command = require("@shell-shock/core/contexts/command");
9
9
 
10
10
  //#region src/components/command-router.tsx
11
11
  function CommandRouterRoute() {
12
- const command = require_command.useCommand();
13
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
14
- get when() {
15
- return !command.isVirtual;
16
- },
17
- get fallback() {
18
- return __alloy_js_core.code`return handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(args);`;
19
- },
20
- get children() {
21
- return [
22
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_dynamic_import_statement.DynamicImportStatement, {
12
+ const command = (0, __shell_shock_core_contexts_command.useCommand)();
13
+ return [
14
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
15
+ get when() {
16
+ return !command.isVirtual;
17
+ },
18
+ get children() {
19
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_dynamic_import_statement.DynamicImportStatement, {
23
20
  get name() {
24
21
  return `handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}`;
25
22
  },
26
23
  get importPath() {
27
- return `./${command.entry.output}`;
24
+ return `./${command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment))[command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment)).length - 1]}`;
28
25
  },
29
26
  exportName: "handler"
30
- }),
31
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
32
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`return handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(args);`)
33
- ];
34
- }
35
- });
36
- }
37
- function CommandRouter() {
38
- const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
39
- const command = require_command.useCommand();
40
- const index = (0, __alloy_js_core.computed)(() => 2 + (command?.path.length ?? 0));
41
- return [
42
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
43
- "let": true,
44
- name: "command",
45
- type: "string",
46
- initializer: __alloy_js_core.code`"";`
47
- }),
48
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
49
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
50
- get condition() {
51
- return __alloy_js_core.code`args.length > ${index.value} && args[${index.value}]`;
52
- },
53
- get children() {
54
- return __alloy_js_core.code`command = args[${index.value}];`;
27
+ });
55
28
  }
56
29
  }),
57
30
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
58
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
59
- get each() {
60
- return Object.values(command?.children ?? context?.commands ?? {});
61
- },
62
- children: (subcommand, idx) => (0, __alloy_js_core_jsx_runtime.createComponent)(require_command.CommandContext.Provider, {
63
- value: subcommand,
64
- get children() {
65
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
66
- get when() {
67
- return Boolean(idx);
68
- },
69
- get fallback() {
70
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
71
- get condition() {
72
- return __alloy_js_core.code`command.toLowerCase() === "${subcommand.name.toLowerCase()}"`;
73
- },
74
- get children() {
75
- return (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterRoute, {});
76
- }
77
- });
78
- },
31
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`return handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(args);`)
32
+ ];
33
+ }
34
+ /**
35
+ * The command router component.
36
+ */
37
+ function CommandRouter(props) {
38
+ const { path, commands, route } = props;
39
+ const command = (0, __shell_shock_core_contexts_command.useCommand)();
40
+ const index = (0, __alloy_js_core.computed)(() => 2 + (path.length ?? 0));
41
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
42
+ get when() {
43
+ return commands && Object.keys(commands).length > 0;
44
+ },
45
+ get children() {
46
+ return [
47
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
48
+ "let": true,
49
+ name: "command",
50
+ type: "string",
51
+ initializer: __alloy_js_core.code`"";`
52
+ }),
53
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
54
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
55
+ get condition() {
56
+ return __alloy_js_core.code`args.length > ${index.value} && args[${index.value}]`;
57
+ },
58
+ get children() {
59
+ return __alloy_js_core.code`command = args[${index.value}];`;
60
+ }
61
+ }),
62
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
63
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
64
+ get each() {
65
+ return Object.values(commands ?? {});
66
+ },
67
+ children: (subcommand, idx) => (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_core_contexts_command.CommandContext.Provider, {
68
+ value: subcommand,
79
69
  get children() {
80
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
81
- get condition() {
82
- return __alloy_js_core.code`command.toLowerCase() === "${subcommand.name.toLowerCase()}"`;
70
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
71
+ get when() {
72
+ return subcommand.name !== command?.name;
83
73
  },
84
74
  get children() {
85
- return (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterRoute, {});
75
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
76
+ get when() {
77
+ return Boolean(idx);
78
+ },
79
+ get fallback() {
80
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
81
+ get condition() {
82
+ return __alloy_js_core.code`command.toLowerCase() === "${subcommand.name.toLowerCase()}"`;
83
+ },
84
+ get children() {
85
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
86
+ get when() {
87
+ return Boolean(route);
88
+ },
89
+ get fallback() {
90
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterRoute, {});
91
+ },
92
+ children: route
93
+ });
94
+ }
95
+ });
96
+ },
97
+ get children() {
98
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
99
+ get condition() {
100
+ return __alloy_js_core.code`command.toLowerCase() === "${subcommand.name.toLowerCase()}"`;
101
+ },
102
+ get children() {
103
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
104
+ get when() {
105
+ return Boolean(route);
106
+ },
107
+ get fallback() {
108
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterRoute, {});
109
+ },
110
+ children: route
111
+ });
112
+ }
113
+ });
114
+ }
115
+ });
86
116
  }
87
117
  });
88
118
  }
89
- });
90
- }
91
- })
92
- }),
93
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
94
- condition: __alloy_js_core.code`Boolean(command)`,
95
- children: __alloy_js_core.code`error("Unknown command: " + command);`
96
- })
97
- ];
119
+ })
120
+ }),
121
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
122
+ condition: __alloy_js_core.code`Boolean(command)`,
123
+ children: __alloy_js_core.code`error("Unknown command: " + command);`
124
+ })
125
+ ];
126
+ }
127
+ });
98
128
  }
99
129
 
100
130
  //#endregion