@shell-shock/preset-script 0.6.77 → 0.6.79
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.
- package/dist/command-entry-BlT9_UEL.cjs +367 -0
- package/dist/command-entry-DWSekIys.mjs +339 -0
- package/dist/command-entry-DWSekIys.mjs.map +1 -0
- package/dist/components/bin-entry.cjs +20 -18
- package/dist/components/bin-entry.d.cts +2 -3
- package/dist/components/bin-entry.d.cts.map +1 -1
- package/dist/components/bin-entry.d.mts +2 -3
- package/dist/components/bin-entry.mjs +10 -6
- package/dist/components/command-entry.cjs +4 -204
- package/dist/components/command-entry.d.cts +1 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +1 -2
- package/dist/components/command-entry.mjs +2 -201
- package/dist/components/command-router.cjs +7 -7
- package/dist/components/command-router.d.cts +0 -1
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts +0 -1
- package/dist/components/command-router.mjs +3 -3
- package/dist/components/exit-function-declaration.cjs +11 -11
- package/dist/components/exit-function-declaration.d.cts.map +1 -1
- package/dist/components/exit-function-declaration.mjs +3 -3
- package/dist/components/index.cjs +6 -7
- package/dist/components/index.mjs +1 -2
- package/dist/components/virtual-command-entry.cjs +3 -154
- package/dist/components/virtual-command-entry.d.cts +1 -2
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +1 -2
- package/dist/components/virtual-command-entry.mjs +2 -152
- package/dist/generator.cjs +108 -0
- package/dist/generator.d.cts +10 -0
- package/dist/generator.d.cts.map +1 -0
- package/dist/generator.d.mts +10 -0
- package/dist/generator.d.mts.map +1 -0
- package/dist/generator.mjs +107 -0
- package/dist/generator.mjs.map +1 -0
- package/dist/helpers/get-global-options.cjs +0 -1
- package/dist/helpers/get-global-options.d.cts +0 -1
- package/dist/helpers/get-global-options.d.cts.map +1 -1
- package/dist/helpers/get-global-options.d.mts +0 -1
- package/dist/index.cjs +9 -90
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +11 -89
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/plugin.d.cts +0 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +0 -1
- package/package.json +32 -18
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/components/command-entry.mjs.map +0 -1
- package/dist/components/virtual-command-entry.mjs.map +0 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { CommandRouter } from "./components/command-router.mjs";
|
|
2
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { For, Show, code, computed } from "@alloy-js/core";
|
|
4
|
+
import { ElseClause, FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
|
|
5
|
+
import { Spacing } from "@power-plant/alloy-js/core/components";
|
|
6
|
+
import { Spacing as Spacing$1 } from "@power-plant/alloy-js/core/components/spacing";
|
|
7
|
+
import { TSDoc, TSDocParam, TSDocRemarks, TSDocTitle } from "@power-plant/alloy-js/typescript/components/tsdoc";
|
|
8
|
+
import { EntryFile, usePowerlines } from "@shell-shock/core/contexts/power-plant";
|
|
9
|
+
import { getAppBin, getDynamicPathSegmentName, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
10
|
+
import { replaceExtension } from "@stryke/path/replace";
|
|
11
|
+
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
12
|
+
import { defu } from "defu";
|
|
13
|
+
import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
|
|
14
|
+
import { IsDebug } from "@shell-shock/core/components/helpers";
|
|
15
|
+
import { CommandParserLogic, OptionsInterfaceDeclaration } from "@shell-shock/core/components/options-parser-logic";
|
|
16
|
+
import { findFilePath, relativePath } from "@stryke/path/find";
|
|
17
|
+
import { joinPaths } from "@stryke/path/join";
|
|
18
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
19
|
+
import { constantCase } from "@stryke/string-format/constant-case";
|
|
20
|
+
import { TypescriptFile } from "@power-plant/alloy-js/typescript/components/typescript-file";
|
|
21
|
+
|
|
22
|
+
//#region src/components/virtual-command-entry.tsx
|
|
23
|
+
/**
|
|
24
|
+
* A component that generates the `handler` function declaration for a command.
|
|
25
|
+
*/
|
|
26
|
+
function VirtualCommandHandlerDeclaration(props) {
|
|
27
|
+
const { command, children, banner } = props;
|
|
28
|
+
const context = usePowerlines();
|
|
29
|
+
return [createComponent(TSDoc, {
|
|
30
|
+
get heading() {
|
|
31
|
+
return `The ${command.title} (${getAppBin(context)} ${command.segments.map((segment) => isDynamicPathSegment(segment) ? `[${constantCase(getDynamicPathSegmentName(segment))}]` : segment).join(" ")}) virtual command.`;
|
|
32
|
+
},
|
|
33
|
+
get children() {
|
|
34
|
+
return [
|
|
35
|
+
createComponent(TSDocRemarks, { get children() {
|
|
36
|
+
return `${command.description.replace(/\.+$/, "")}.`;
|
|
37
|
+
} }),
|
|
38
|
+
createIntrinsic("hbr", {}),
|
|
39
|
+
createComponent(TSDocTitle, { get children() {
|
|
40
|
+
return command.title;
|
|
41
|
+
} }),
|
|
42
|
+
createComponent(TSDocParam, {
|
|
43
|
+
name: "args",
|
|
44
|
+
children: `The command-line arguments passed to the command.`
|
|
45
|
+
})
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
}), createComponent(FunctionDeclaration, {
|
|
49
|
+
"export": true,
|
|
50
|
+
async: true,
|
|
51
|
+
name: "handler",
|
|
52
|
+
parameters: [{
|
|
53
|
+
name: "args",
|
|
54
|
+
type: "string[]",
|
|
55
|
+
default: "useArgs()"
|
|
56
|
+
}],
|
|
57
|
+
get children() {
|
|
58
|
+
return [
|
|
59
|
+
createComponent(Spacing, {}),
|
|
60
|
+
children,
|
|
61
|
+
createComponent(Spacing, {}),
|
|
62
|
+
createComponent(Show, {
|
|
63
|
+
get when() {
|
|
64
|
+
return Boolean(banner);
|
|
65
|
+
},
|
|
66
|
+
children: banner
|
|
67
|
+
}),
|
|
68
|
+
createComponent(Spacing, {}),
|
|
69
|
+
code`return showHelp(); `
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
})];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The virtual command entry point for the Shell Shock project.
|
|
76
|
+
*/
|
|
77
|
+
function VirtualCommandEntry(props) {
|
|
78
|
+
const { command, imports, builtinImports, ...rest } = props;
|
|
79
|
+
const context = usePowerlines();
|
|
80
|
+
const filePath = computed(() => joinPaths(context.entryPath, command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
|
|
81
|
+
return [createComponent(TypescriptFile, mergeProps(rest, {
|
|
82
|
+
get path() {
|
|
83
|
+
return filePath.value;
|
|
84
|
+
},
|
|
85
|
+
get imports() {
|
|
86
|
+
return defu(imports ?? {}, Object.entries(command.children).filter(([, child]) => child.virtual).reduce((ret, [name, child]) => {
|
|
87
|
+
ret[`./${child.name}`] = [{
|
|
88
|
+
name: "handler",
|
|
89
|
+
alias: `handle${pascalCase(name)}`
|
|
90
|
+
}];
|
|
91
|
+
return ret;
|
|
92
|
+
}, {}));
|
|
93
|
+
},
|
|
94
|
+
get builtinImports() {
|
|
95
|
+
return defu(builtinImports ?? {}, {
|
|
96
|
+
env: ["isDevelopment", "isDebug"],
|
|
97
|
+
console: [
|
|
98
|
+
"warn",
|
|
99
|
+
"error",
|
|
100
|
+
"writeLine",
|
|
101
|
+
"textColors"
|
|
102
|
+
],
|
|
103
|
+
utils: [
|
|
104
|
+
"isMinimal",
|
|
105
|
+
"isUnicodeSupported",
|
|
106
|
+
"findSuggestions"
|
|
107
|
+
],
|
|
108
|
+
state: [
|
|
109
|
+
{
|
|
110
|
+
name: "GlobalOptions",
|
|
111
|
+
type: true
|
|
112
|
+
},
|
|
113
|
+
"useGlobal",
|
|
114
|
+
"useGlobalOptions",
|
|
115
|
+
"withCommand",
|
|
116
|
+
"useArgs",
|
|
117
|
+
"hasFlag"
|
|
118
|
+
],
|
|
119
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
120
|
+
[joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"]
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
get children() {
|
|
124
|
+
return [createComponent(Spacing, {}), createComponent(VirtualCommandHandlerDeclaration, {
|
|
125
|
+
command,
|
|
126
|
+
banner: code`await showBanner(); `,
|
|
127
|
+
get children() {
|
|
128
|
+
return createComponent(CommandRouter, {
|
|
129
|
+
get segments() {
|
|
130
|
+
return command.segments;
|
|
131
|
+
},
|
|
132
|
+
get commands() {
|
|
133
|
+
return command.children;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
})];
|
|
138
|
+
}
|
|
139
|
+
})), createComponent(For, {
|
|
140
|
+
get each() {
|
|
141
|
+
return Object.values(command.children);
|
|
142
|
+
},
|
|
143
|
+
children: (child) => createComponent(Show, {
|
|
144
|
+
get when() {
|
|
145
|
+
return child.virtual;
|
|
146
|
+
},
|
|
147
|
+
get fallback() {
|
|
148
|
+
return createComponent(CommandEntry, { command: child });
|
|
149
|
+
},
|
|
150
|
+
get children() {
|
|
151
|
+
return createComponent(VirtualCommandEntry, { command: child });
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
})];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/components/command-entry.tsx
|
|
159
|
+
function CommandInvocation(props) {
|
|
160
|
+
const { command } = props;
|
|
161
|
+
return [memo(() => code` return withCommand("${command.path}", [${command.segments.map((segment) => isDynamicPathSegment(segment) ? camelCase(getDynamicPathSegmentName(segment)) : `"${segment}"`).join(", ")}], [${Object.keys(command.options).length > 0 ? `options` : ""}${command.args.length > 0 ? `${Object.keys(command.options).length > 0 ? ", " : ""}${command.args.map((arg) => camelCase(arg.name)).join(", ")}` : ""}], handle${pascalCase(command.name)}); `), createIntrinsic("hbr", {})];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A component that generates the `handler` function declaration for a command.
|
|
165
|
+
*/
|
|
166
|
+
function CommandHandlerDeclaration(props) {
|
|
167
|
+
const { command, banner, children } = props;
|
|
168
|
+
const context = usePowerlines();
|
|
169
|
+
return [
|
|
170
|
+
createComponent(OptionsInterfaceDeclaration, { command }),
|
|
171
|
+
createComponent(Spacing$1, {}),
|
|
172
|
+
createComponent(TSDoc, {
|
|
173
|
+
get heading() {
|
|
174
|
+
return `The ${command.title} (${getAppBin(context)} ${command.segments.map((segment) => isDynamicPathSegment(segment) ? `[${constantCase(getDynamicPathSegmentName(segment))}]` : segment).join(" ")}) command.`;
|
|
175
|
+
},
|
|
176
|
+
get children() {
|
|
177
|
+
return [
|
|
178
|
+
createComponent(TSDocRemarks, { get children() {
|
|
179
|
+
return `${command.description.replace(/\.+$/, "")}.`;
|
|
180
|
+
} }),
|
|
181
|
+
createIntrinsic("hbr", {}),
|
|
182
|
+
createComponent(TSDocTitle, { get children() {
|
|
183
|
+
return command.title;
|
|
184
|
+
} }),
|
|
185
|
+
createComponent(TSDocParam, {
|
|
186
|
+
name: "args",
|
|
187
|
+
children: `The command-line arguments passed to the command.`
|
|
188
|
+
})
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
createComponent(FunctionDeclaration, {
|
|
193
|
+
"export": true,
|
|
194
|
+
async: true,
|
|
195
|
+
name: "handler",
|
|
196
|
+
parameters: [{
|
|
197
|
+
name: "args",
|
|
198
|
+
type: "string[]",
|
|
199
|
+
default: "useArgs()"
|
|
200
|
+
}],
|
|
201
|
+
get children() {
|
|
202
|
+
return [
|
|
203
|
+
createComponent(CommandParserLogic, {
|
|
204
|
+
command,
|
|
205
|
+
get appSpecificEnvPrefix() {
|
|
206
|
+
return context.config.appSpecificEnvPrefix;
|
|
207
|
+
},
|
|
208
|
+
get isCaseSensitive() {
|
|
209
|
+
return context.config.isCaseSensitive;
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
createComponent(Spacing$1, {}),
|
|
213
|
+
createComponent(Show, {
|
|
214
|
+
get when() {
|
|
215
|
+
return Boolean(banner);
|
|
216
|
+
},
|
|
217
|
+
children: banner
|
|
218
|
+
}),
|
|
219
|
+
createComponent(Spacing$1, {}),
|
|
220
|
+
createComponent(IfStatement, {
|
|
221
|
+
condition: code`!isHelp()`,
|
|
222
|
+
get children() {
|
|
223
|
+
return [code`writeLine("");`, createComponent(IfStatement, {
|
|
224
|
+
get condition() {
|
|
225
|
+
return createComponent(IsDebug, {});
|
|
226
|
+
},
|
|
227
|
+
children: code`writeLine(textColors.body.tertiary("Debug mode is enabled. Additional debug information may be logged to the console.")); `
|
|
228
|
+
})];
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
createComponent(Spacing$1, {}),
|
|
232
|
+
children,
|
|
233
|
+
createComponent(Spacing$1, {}),
|
|
234
|
+
createComponent(IfStatement, {
|
|
235
|
+
condition: code`options.help`,
|
|
236
|
+
children: code`return showHelp(); `
|
|
237
|
+
}),
|
|
238
|
+
createComponent(ElseClause, { get children() {
|
|
239
|
+
return [createIntrinsic("hbr", {}), createComponent(CommandInvocation, { command })];
|
|
240
|
+
} })
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The command entry point for the Shell Shock project.
|
|
248
|
+
*/
|
|
249
|
+
function CommandEntry(props) {
|
|
250
|
+
const { command, imports, builtinImports, ...rest } = props;
|
|
251
|
+
const context = usePowerlines();
|
|
252
|
+
const filePath = computed(() => joinPaths(command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
|
|
253
|
+
const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
|
|
254
|
+
const typeDefinition = computed(() => ({
|
|
255
|
+
...command.entry,
|
|
256
|
+
output: command.id
|
|
257
|
+
}));
|
|
258
|
+
return [createComponent(EntryFile, mergeProps(rest, {
|
|
259
|
+
get path() {
|
|
260
|
+
return filePath.value;
|
|
261
|
+
},
|
|
262
|
+
get typeDefinition() {
|
|
263
|
+
return typeDefinition.value;
|
|
264
|
+
},
|
|
265
|
+
get imports() {
|
|
266
|
+
return defu(imports ?? {}, { [commandSourcePath.value.startsWith(".") ? commandSourcePath.value : `./${commandSourcePath.value}`]: `handle${pascalCase(command.name)}` });
|
|
267
|
+
},
|
|
268
|
+
get builtinImports() {
|
|
269
|
+
return defu(builtinImports ?? {}, {
|
|
270
|
+
env: [
|
|
271
|
+
"env",
|
|
272
|
+
"isDevelopment",
|
|
273
|
+
"isDebug"
|
|
274
|
+
],
|
|
275
|
+
console: [
|
|
276
|
+
"debug",
|
|
277
|
+
"warn",
|
|
278
|
+
"error",
|
|
279
|
+
"writeLine",
|
|
280
|
+
"textColors"
|
|
281
|
+
],
|
|
282
|
+
utils: ["isMinimal", "isUnicodeSupported"],
|
|
283
|
+
state: [
|
|
284
|
+
{
|
|
285
|
+
name: "GlobalOptions",
|
|
286
|
+
type: true
|
|
287
|
+
},
|
|
288
|
+
"useGlobal",
|
|
289
|
+
"useGlobalOptions",
|
|
290
|
+
"useArgs",
|
|
291
|
+
"hasFlag",
|
|
292
|
+
"isHelp",
|
|
293
|
+
"withCommand"
|
|
294
|
+
],
|
|
295
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
296
|
+
[joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"]
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
get children() {
|
|
300
|
+
return [
|
|
301
|
+
createComponent(Spacing$1, {}),
|
|
302
|
+
createComponent(OptionsInterfaceDeclaration, { command }),
|
|
303
|
+
createComponent(Spacing$1, {}),
|
|
304
|
+
createComponent(CommandHandlerDeclaration, {
|
|
305
|
+
command,
|
|
306
|
+
banner: code`await showBanner(); `,
|
|
307
|
+
get children() {
|
|
308
|
+
return [createComponent(CommandValidationLogic, { command }), createComponent(IfStatement, {
|
|
309
|
+
condition: code`failures.length > 0`,
|
|
310
|
+
get children() {
|
|
311
|
+
return code`error(\`The following validation failures were found while processing the user provided input, and must be corrected before the \${italic("${command.title}")} command can be executed: \\n\\n\${failures.map(failure => " - " + failure).join("\\n")}\`);
|
|
312
|
+
options.help = true; `;
|
|
313
|
+
}
|
|
314
|
+
})];
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
];
|
|
318
|
+
}
|
|
319
|
+
})), createComponent(For, {
|
|
320
|
+
get each() {
|
|
321
|
+
return Object.values(command.children);
|
|
322
|
+
},
|
|
323
|
+
children: (child) => createComponent(Show, {
|
|
324
|
+
get when() {
|
|
325
|
+
return child.virtual;
|
|
326
|
+
},
|
|
327
|
+
get fallback() {
|
|
328
|
+
return createComponent(CommandEntry, { command: child });
|
|
329
|
+
},
|
|
330
|
+
get children() {
|
|
331
|
+
return createComponent(VirtualCommandEntry, { command: child });
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
})];
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
//#endregion
|
|
338
|
+
export { VirtualCommandHandlerDeclaration as a, VirtualCommandEntry as i, CommandHandlerDeclaration as n, CommandInvocation as r, CommandEntry as t };
|
|
339
|
+
//# sourceMappingURL=command-entry-DWSekIys.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-entry-DWSekIys.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_components_exit_function_declaration = require('./exit-function-declaration.cjs');
|
|
4
3
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
4
|
let _alloy_js_core = require("@alloy-js/core");
|
|
6
5
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
6
|
+
let _power_plant_alloy_js_core_components_spacing = require("@power-plant/alloy-js/core/components/spacing");
|
|
7
|
+
let _power_plant_alloy_js_typescript_components_tsdoc = require("@power-plant/alloy-js/typescript/components/tsdoc");
|
|
8
|
+
let _shell_shock_core_contexts_power_plant = require("@shell-shock/core/contexts/power-plant");
|
|
11
9
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
12
10
|
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
13
11
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
14
12
|
let _stryke_path_replace = require("@stryke/path/replace");
|
|
15
13
|
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
16
14
|
let defu = require("defu");
|
|
17
|
-
defu = require_runtime.__toESM(defu, 1);
|
|
18
15
|
|
|
19
16
|
//#region src/components/bin-entry.tsx
|
|
20
17
|
/**
|
|
@@ -22,7 +19,7 @@ defu = require_runtime.__toESM(defu, 1);
|
|
|
22
19
|
*/
|
|
23
20
|
function RunApplication() {
|
|
24
21
|
return [
|
|
25
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
22
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
26
23
|
_alloy_js_core.code`// Run the application main logic inside an asynchronous IIFE
|
|
27
24
|
(async () => {
|
|
28
25
|
const startDate = new Date();
|
|
@@ -98,13 +95,18 @@ function RunApplication() {
|
|
|
98
95
|
*/
|
|
99
96
|
function BinEntry(props) {
|
|
100
97
|
const { prefix, postfix, builtinImports, imports, children, ...rest } = props;
|
|
101
|
-
const context = (0,
|
|
102
|
-
const bins = (0, _alloy_js_core.computed)(() =>
|
|
98
|
+
const context = (0, _shell_shock_core_contexts_power_plant.usePowerlines)();
|
|
99
|
+
const bins = (0, _alloy_js_core.computed)(() => {
|
|
100
|
+
const binConfig = context.config.bin;
|
|
101
|
+
if (!binConfig) return [];
|
|
102
|
+
const values = Array.isArray(binConfig) ? binConfig : typeof binConfig === "string" ? [binConfig] : Object.values(binConfig);
|
|
103
|
+
return (0, _stryke_helpers_get_unique.getUnique)(values.filter((value) => typeof value === "string"));
|
|
104
|
+
});
|
|
103
105
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
104
106
|
get each() {
|
|
105
107
|
return bins.value;
|
|
106
108
|
},
|
|
107
|
-
children: (bin) => (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
109
|
+
children: (bin) => (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_contexts_power_plant.EntryFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
108
110
|
get path() {
|
|
109
111
|
return (0, _stryke_path_file_path_fns.findFileName)((0, _stryke_path_replace.replaceExtension)(bin));
|
|
110
112
|
},
|
|
@@ -114,7 +116,7 @@ function BinEntry(props) {
|
|
|
114
116
|
input: { file: bin }
|
|
115
117
|
},
|
|
116
118
|
get imports() {
|
|
117
|
-
return (0, defu.
|
|
119
|
+
return (0, defu.defu)(imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.virtual).reduce((ret, [name, command]) => {
|
|
118
120
|
ret[`./${command.name}`] = [{
|
|
119
121
|
name: "handler",
|
|
120
122
|
alias: `handle${(0, _stryke_string_format_pascal_case.pascalCase)(name)}`
|
|
@@ -123,7 +125,7 @@ function BinEntry(props) {
|
|
|
123
125
|
}, {}));
|
|
124
126
|
},
|
|
125
127
|
get builtinImports() {
|
|
126
|
-
return (0, defu.
|
|
128
|
+
return (0, defu.defu)(builtinImports ?? {}, {
|
|
127
129
|
env: [
|
|
128
130
|
"env",
|
|
129
131
|
"isDevelopment",
|
|
@@ -152,23 +154,23 @@ function BinEntry(props) {
|
|
|
152
154
|
get children() {
|
|
153
155
|
return [
|
|
154
156
|
(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_exit_function_declaration.ExitFunctionDeclaration, {}),
|
|
155
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
157
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
156
158
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
157
159
|
get when() {
|
|
158
160
|
return Boolean(prefix);
|
|
159
161
|
},
|
|
160
162
|
get children() {
|
|
161
|
-
return [prefix, (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
163
|
+
return [prefix, (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {})];
|
|
162
164
|
}
|
|
163
165
|
}),
|
|
164
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
166
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDoc, {
|
|
165
167
|
get heading() {
|
|
166
168
|
return `Binary entry point for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application.`;
|
|
167
169
|
},
|
|
168
170
|
get children() {
|
|
169
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
171
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocRemarks, { get children() {
|
|
170
172
|
return `This file serves as the main entry point for the binary executable of the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`;
|
|
171
|
-
} }), (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
173
|
+
} }), (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocReturns, { children: `Returns a promise that resolves to either a successful result or an error object.` })];
|
|
172
174
|
}
|
|
173
175
|
}),
|
|
174
176
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -184,7 +186,7 @@ function BinEntry(props) {
|
|
|
184
186
|
return; `;
|
|
185
187
|
}
|
|
186
188
|
}),
|
|
187
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
189
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
188
190
|
children,
|
|
189
191
|
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
190
192
|
];
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { EntryFileProps } from "@
|
|
3
|
-
|
|
2
|
+
import { EntryFileProps } from "@shell-shock/core/contexts/power-plant";
|
|
4
3
|
//#region src/components/bin-entry.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Runs the application main logic with proper exit handling.
|
|
7
6
|
*/
|
|
8
7
|
declare function RunApplication(): Children;
|
|
9
|
-
interface BinEntryProps extends Omit<EntryFileProps, "path" | "hashbang"> {
|
|
8
|
+
interface BinEntryProps extends Omit<EntryFileProps, "path" | "hashbang" | "prefix" | "postfix"> {
|
|
10
9
|
prefix?: Children;
|
|
11
10
|
postfix?: Children;
|
|
12
11
|
children: Children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"mappings":";;;;;;iBA6CgB,kBAAc;UA4Eb,sBAAsB,KACrC;EAGA,SAAS;EACT,UAAU;EACV,UAAU;;;;;iBAMI,SAAS,OAAO,gBAAa"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { EntryFileProps } from "@
|
|
3
|
-
|
|
2
|
+
import { EntryFileProps } from "@shell-shock/core/contexts/power-plant";
|
|
4
3
|
//#region src/components/bin-entry.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Runs the application main logic with proper exit handling.
|
|
7
6
|
*/
|
|
8
7
|
declare function RunApplication(): Children;
|
|
9
|
-
interface BinEntryProps extends Omit<EntryFileProps, "path" | "hashbang"> {
|
|
8
|
+
interface BinEntryProps extends Omit<EntryFileProps, "path" | "hashbang" | "prefix" | "postfix"> {
|
|
10
9
|
prefix?: Children;
|
|
11
10
|
postfix?: Children;
|
|
12
11
|
children: Children;
|
|
@@ -2,16 +2,15 @@ import { ExitFunctionDeclaration } from "./exit-function-declaration.mjs";
|
|
|
2
2
|
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
3
|
import { For, Show, code, computed } from "@alloy-js/core";
|
|
4
4
|
import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
|
|
5
|
-
import { Spacing } from "@
|
|
6
|
-
import {
|
|
7
|
-
import { EntryFile } from "@
|
|
8
|
-
import { TSDoc, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
5
|
+
import { Spacing } from "@power-plant/alloy-js/core/components/spacing";
|
|
6
|
+
import { TSDoc, TSDocRemarks, TSDocReturns } from "@power-plant/alloy-js/typescript/components/tsdoc";
|
|
7
|
+
import { EntryFile, usePowerlines } from "@shell-shock/core/contexts/power-plant";
|
|
9
8
|
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
10
9
|
import { getUnique } from "@stryke/helpers/get-unique";
|
|
11
10
|
import { findFileName } from "@stryke/path/file-path-fns";
|
|
12
11
|
import { replaceExtension } from "@stryke/path/replace";
|
|
13
12
|
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
14
|
-
import defu from "defu";
|
|
13
|
+
import { defu } from "defu";
|
|
15
14
|
|
|
16
15
|
//#region src/components/bin-entry.tsx
|
|
17
16
|
/**
|
|
@@ -96,7 +95,12 @@ function RunApplication() {
|
|
|
96
95
|
function BinEntry(props) {
|
|
97
96
|
const { prefix, postfix, builtinImports, imports, children, ...rest } = props;
|
|
98
97
|
const context = usePowerlines();
|
|
99
|
-
const bins = computed(() =>
|
|
98
|
+
const bins = computed(() => {
|
|
99
|
+
const binConfig = context.config.bin;
|
|
100
|
+
if (!binConfig) return [];
|
|
101
|
+
const values = Array.isArray(binConfig) ? binConfig : typeof binConfig === "string" ? [binConfig] : Object.values(binConfig);
|
|
102
|
+
return getUnique(values.filter((value) => typeof value === "string"));
|
|
103
|
+
});
|
|
100
104
|
return createComponent(For, {
|
|
101
105
|
get each() {
|
|
102
106
|
return bins.value;
|