@shell-shock/preset-script 0.6.63 → 0.6.65
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/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/components/bin-entry.cjs +149 -3
- package/dist/components/bin-entry.mjs +145 -3
- package/dist/components/bin-entry.mjs.map +1 -1
- package/dist/components/command-entry.cjs +205 -3
- package/dist/components/command-entry.mjs +200 -3
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +160 -2
- package/dist/components/command-router.mjs +156 -2
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/exit-function-declaration.cjs +113 -6
- package/dist/components/exit-function-declaration.mjs +111 -6
- package/dist/components/exit-function-declaration.mjs.map +1 -1
- package/dist/components/index.cjs +18 -1
- package/dist/components/index.mjs +7 -1
- package/dist/components/virtual-command-entry.cjs +156 -1
- package/dist/components/virtual-command-entry.mjs +152 -1
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-global-options.cjs +75 -1
- package/dist/helpers/get-global-options.mjs +73 -1
- package/dist/helpers/get-global-options.mjs.map +1 -1
- package/dist/index.cjs +123 -1
- package/dist/index.mjs +117 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.mjs","names":[],"sources":["../../src/components/command-router.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.segments.filter(segment => !isDynamicPathSegment(segment))[\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n segments: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands, route } = props;\n\n const index = computed(() => 2 + (segments.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <Spacing />\n </Show>\n <CommandRouterBody\n segments={segments}\n commands={commands}\n route={route}\n />\n </Show>\n );\n}\n\n/**\n * The internal command router body logic component.\n */\nexport function CommandRouterBody(props: CommandRouterProps) {\n const { commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement condition={code`!command.startsWith(\"-\")`}>\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show\n when={Boolean(route)}\n fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command) && !command.startsWith(\"-\")`}>{code`const suggestions = findSuggestions(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `, \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}]).slice(0, 3);\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </IfStatement>\n </Show>\n );\n}\n"],"mappings":"guBA2BA,SAAS,GAAyB,CAClC,IAAQ,EAAC,GAAgB,CACzB,MAAS,CAAA,EAAA,EAAuB,CAChC,IAAO,MAAO,CACR,MAAG,CAAA,EAAa,0BAGhB,OAAC,EAAS,EAAqB,CAC7B,IAAA,MAAU,6BAGb,IAAA,YAAA,CACE,MAAU,KAAE,EAAQ,SAAU,OAAA,GAAA,CAAA,EAAA,EAAA,CAAA,CAAA,EAAA,SAAA,OAAA,GAAA,CAAA,EAAA,EAAA,CAAA,CAAA,OAAA,MAE7B,WAAS,UACV,CAAC,EAEL,CAAC,CAAE,EAAgB,MAAS,EAAA,CAAA,CAAA,MAAkB,CAAC,gBAAA,EAA6B,EAAA,KAAA,CAAA,SAAA,CAAA,CAK/E,SAAS,EAAA,EAAA,CACP,GAAM,CACJ,WACA,WACA,SACD,EACH,EAAA,MAAA,GAAA,EAAA,QAAA,GAAA,aAEA,IAAO,MAAA,CACL,OAAU,GAAQ,OAAA,KAAA,EAAA,CAAA,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":3,"file":"command-router.mjs","names":[],"sources":["../../src/components/command-router.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.segments.filter(segment => !isDynamicPathSegment(segment))[\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n segments: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands, route } = props;\n\n const index = computed(() => 2 + (segments.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <Spacing />\n </Show>\n <CommandRouterBody\n segments={segments}\n commands={commands}\n route={route}\n />\n </Show>\n );\n}\n\n/**\n * The internal command router body logic component.\n */\nexport function CommandRouterBody(props: CommandRouterProps) {\n const { commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement condition={code`!command.startsWith(\"-\")`}>\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show\n when={Boolean(route)}\n fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command) && !command.startsWith(\"-\")`}>{code`const suggestions = findSuggestions(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `, \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}]).slice(0, 3);\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </IfStatement>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAS,qBAAyB;CAClC,MAAQ,UAAC,YAAgB;AACzB,QAAS;EAAA,gBAAA,MAAuB;GAChC,IAAO,OAAO;AACR,WAAG,CAAA,QAAa;;;AAGhB,WAAC,gBAAS,wBAAqB;KAC7B,IAAA,OAAU;;;KAGb,IAAA,aAAA;AACE,aAAU,KAAE,QAAQ,SAAU,QAAA,YAAA,CAAA,qBAAA,QAA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AAA,QAAA,MAAA;;aAEG,IAAE,WAAa;AACnB,qBAAW,gBAAoB,oBAAE,EAAA,CAAA;;aAE7B,UAAA;aACN,CAAA;;WAEH,CAAA;;SAEA,CAAC;;OAEL,CAAC;MACH,CAAC,EAAE,gBAAY,cAAA;MACd,WAAQ,IAAO;MACf,IAAI,WAAQ;AACV,cAAO,IAAG,iDAAW,OAAA,OAAA,YAAA,EAAA,CAAA,CAAA,KAAA,QAAA,IAAA,IAAA,KAAA,IAAA,IAAA,SAAA,EAAA,EAAA,KAAA,UAAA,MAAA,MAAA,GAAA,CAAA,KAAA,GAAA,GAAA,CAAA,KAAA,KAAA,CAAA;;;MAGxB,CAAC,CAAC;;IAEN,CAAC;;EAEL,CAAC"}
|
|
@@ -1,4 +1,95 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
7
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
8
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
9
|
+
let _shell_shock_core_components_helpers = require("@shell-shock/core/components/helpers");
|
|
10
|
+
|
|
11
|
+
//#region src/components/exit-function-declaration.tsx
|
|
12
|
+
/**
|
|
13
|
+
* The `exit` handler function declaration code for the Shell Shock project.
|
|
14
|
+
*/
|
|
15
|
+
function ExitFunctionDeclaration() {
|
|
16
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
17
|
+
return [
|
|
18
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
19
|
+
"export": true,
|
|
20
|
+
name: "ExitOptions",
|
|
21
|
+
doc: "Options for the exit handler function.",
|
|
22
|
+
get children() {
|
|
23
|
+
return [
|
|
24
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
25
|
+
name: "exception",
|
|
26
|
+
optional: true,
|
|
27
|
+
type: "string | Error",
|
|
28
|
+
doc: "An optional exception that caused the exit. This can be a string message or an Error object."
|
|
29
|
+
}),
|
|
30
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
31
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
32
|
+
name: "skipProcessExit",
|
|
33
|
+
optional: true,
|
|
34
|
+
type: "boolean",
|
|
35
|
+
doc: "Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application."
|
|
36
|
+
}),
|
|
37
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
38
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
39
|
+
name: "isSynchronous",
|
|
40
|
+
optional: true,
|
|
41
|
+
type: "boolean",
|
|
42
|
+
doc: "Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed."
|
|
43
|
+
}),
|
|
44
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
45
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
46
|
+
name: "signal",
|
|
47
|
+
optional: true,
|
|
48
|
+
type: "number",
|
|
49
|
+
doc: "The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM)."
|
|
50
|
+
}),
|
|
51
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
52
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
53
|
+
name: "startDate",
|
|
54
|
+
optional: true,
|
|
55
|
+
type: "Date",
|
|
56
|
+
doc: "A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process."
|
|
57
|
+
})
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
62
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
63
|
+
"let": true,
|
|
64
|
+
name: "isExiting",
|
|
65
|
+
type: "boolean",
|
|
66
|
+
initializer: _alloy_js_core.code`false;`
|
|
67
|
+
}),
|
|
68
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
69
|
+
"const": true,
|
|
70
|
+
name: "callbackAsyncQueue",
|
|
71
|
+
type: "Array<[(code: number | string) => Promise<void> | void, number]>",
|
|
72
|
+
initializer: _alloy_js_core.code`[];`
|
|
73
|
+
}),
|
|
74
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
75
|
+
"const": true,
|
|
76
|
+
name: "callbackSyncQueue",
|
|
77
|
+
type: "Array<(code: number | string) => void>",
|
|
78
|
+
initializer: _alloy_js_core.code`[];`
|
|
79
|
+
}),
|
|
80
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
81
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
82
|
+
"export": true,
|
|
83
|
+
async: true,
|
|
84
|
+
name: "exit",
|
|
85
|
+
parameters: [{
|
|
86
|
+
name: "options",
|
|
87
|
+
type: "ExitOptions",
|
|
88
|
+
default: "{}"
|
|
89
|
+
}],
|
|
90
|
+
get children() {
|
|
91
|
+
return [
|
|
92
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
2
93
|
try {
|
|
3
94
|
if (isExiting) {
|
|
4
95
|
return;
|
|
@@ -14,13 +105,21 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
14
105
|
}
|
|
15
106
|
|
|
16
107
|
if (options.exception) {
|
|
17
|
-
error({ message: \`A fatal error occured while running the application - please contact the ${(0,
|
|
108
|
+
error({ message: \`A fatal error occured while running the application - please contact the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} support team\${options.exception && typeof options.exception !== "symbol" ? \`: \\n\\n\${typeof options.exception === "string" ? options.exception : options.exception.message}\` : "."}\`,
|
|
18
109
|
...(options.exception && typeof options.exception === "object" ? { stack: (options.exception as { message: string; stack?: string }).stack } : {})
|
|
19
110
|
});
|
|
20
111
|
}
|
|
21
112
|
|
|
22
|
-
const terminate = (force = false) => { `),
|
|
23
|
-
|
|
113
|
+
const terminate = (force = false) => { `),
|
|
114
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
115
|
+
get condition() {
|
|
116
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_helpers.IsVerbose, {});
|
|
117
|
+
},
|
|
118
|
+
children: _alloy_js_core.code`writeLine("");`
|
|
119
|
+
}),
|
|
120
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
121
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
122
|
+
verbose(\`The ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application exited \${options.exception ? \`early due to an exception\` : "successfully"}\${options.startDate ? \`. Total processing time is \${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \${Date.now() - options.startDate.getTime() > 5000 ? "seconds" : "milliseconds"}\` : ""}...\`);
|
|
24
123
|
if (!options.skipProcessExit) {
|
|
25
124
|
process.nextTick(() => process.exit(exitCode));
|
|
26
125
|
}
|
|
@@ -47,10 +146,18 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
47
146
|
|
|
48
147
|
terminate();
|
|
49
148
|
} catch (err) {
|
|
50
|
-
error(\`The exit process failed to complete\${(err as Error)?.message ? \` - \${(err as Error).message}\` : ""}. Please contact the ${(0,
|
|
149
|
+
error(\`The exit process failed to complete\${(err as Error)?.message ? \` - \${(err as Error).message}\` : ""}. Please contact the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} support team.\`);
|
|
51
150
|
|
|
52
151
|
if (!options.skipProcessExit) {
|
|
53
152
|
process.nextTick(() => process.exit(1));
|
|
54
153
|
}
|
|
55
154
|
}
|
|
56
|
-
`)
|
|
155
|
+
`)
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
exports.ExitFunctionDeclaration = ExitFunctionDeclaration;
|
|
@@ -1,4 +1,93 @@
|
|
|
1
|
-
import{createComponent
|
|
1
|
+
import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
|
+
import { FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
4
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
+
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
7
|
+
import { IsVerbose } from "@shell-shock/core/components/helpers";
|
|
8
|
+
|
|
9
|
+
//#region src/components/exit-function-declaration.tsx
|
|
10
|
+
/**
|
|
11
|
+
* The `exit` handler function declaration code for the Shell Shock project.
|
|
12
|
+
*/
|
|
13
|
+
function ExitFunctionDeclaration() {
|
|
14
|
+
const context = usePowerlines();
|
|
15
|
+
return [
|
|
16
|
+
createComponent(InterfaceDeclaration, {
|
|
17
|
+
"export": true,
|
|
18
|
+
name: "ExitOptions",
|
|
19
|
+
doc: "Options for the exit handler function.",
|
|
20
|
+
get children() {
|
|
21
|
+
return [
|
|
22
|
+
createComponent(InterfaceMember, {
|
|
23
|
+
name: "exception",
|
|
24
|
+
optional: true,
|
|
25
|
+
type: "string | Error",
|
|
26
|
+
doc: "An optional exception that caused the exit. This can be a string message or an Error object."
|
|
27
|
+
}),
|
|
28
|
+
createIntrinsic("hbr", {}),
|
|
29
|
+
createComponent(InterfaceMember, {
|
|
30
|
+
name: "skipProcessExit",
|
|
31
|
+
optional: true,
|
|
32
|
+
type: "boolean",
|
|
33
|
+
doc: "Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application."
|
|
34
|
+
}),
|
|
35
|
+
createIntrinsic("hbr", {}),
|
|
36
|
+
createComponent(InterfaceMember, {
|
|
37
|
+
name: "isSynchronous",
|
|
38
|
+
optional: true,
|
|
39
|
+
type: "boolean",
|
|
40
|
+
doc: "Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed."
|
|
41
|
+
}),
|
|
42
|
+
createIntrinsic("hbr", {}),
|
|
43
|
+
createComponent(InterfaceMember, {
|
|
44
|
+
name: "signal",
|
|
45
|
+
optional: true,
|
|
46
|
+
type: "number",
|
|
47
|
+
doc: "The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM)."
|
|
48
|
+
}),
|
|
49
|
+
createIntrinsic("hbr", {}),
|
|
50
|
+
createComponent(InterfaceMember, {
|
|
51
|
+
name: "startDate",
|
|
52
|
+
optional: true,
|
|
53
|
+
type: "Date",
|
|
54
|
+
doc: "A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process."
|
|
55
|
+
})
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
createComponent(Spacing, {}),
|
|
60
|
+
createComponent(VarDeclaration, {
|
|
61
|
+
"let": true,
|
|
62
|
+
name: "isExiting",
|
|
63
|
+
type: "boolean",
|
|
64
|
+
initializer: code`false;`
|
|
65
|
+
}),
|
|
66
|
+
createComponent(VarDeclaration, {
|
|
67
|
+
"const": true,
|
|
68
|
+
name: "callbackAsyncQueue",
|
|
69
|
+
type: "Array<[(code: number | string) => Promise<void> | void, number]>",
|
|
70
|
+
initializer: code`[];`
|
|
71
|
+
}),
|
|
72
|
+
createComponent(VarDeclaration, {
|
|
73
|
+
"const": true,
|
|
74
|
+
name: "callbackSyncQueue",
|
|
75
|
+
type: "Array<(code: number | string) => void>",
|
|
76
|
+
initializer: code`[];`
|
|
77
|
+
}),
|
|
78
|
+
createComponent(Spacing, {}),
|
|
79
|
+
createComponent(FunctionDeclaration, {
|
|
80
|
+
"export": true,
|
|
81
|
+
async: true,
|
|
82
|
+
name: "exit",
|
|
83
|
+
parameters: [{
|
|
84
|
+
name: "options",
|
|
85
|
+
type: "ExitOptions",
|
|
86
|
+
default: "{}"
|
|
87
|
+
}],
|
|
88
|
+
get children() {
|
|
89
|
+
return [
|
|
90
|
+
memo(() => code`
|
|
2
91
|
try {
|
|
3
92
|
if (isExiting) {
|
|
4
93
|
return;
|
|
@@ -14,13 +103,21 @@ import{createComponent as e,createIntrinsic as t,memo as n}from"@alloy-js/core/j
|
|
|
14
103
|
}
|
|
15
104
|
|
|
16
105
|
if (options.exception) {
|
|
17
|
-
error({ message: \`A fatal error occured while running the application - please contact the ${
|
|
106
|
+
error({ message: \`A fatal error occured while running the application - please contact the ${getAppTitle(context)} support team\${options.exception && typeof options.exception !== "symbol" ? \`: \\n\\n\${typeof options.exception === "string" ? options.exception : options.exception.message}\` : "."}\`,
|
|
18
107
|
...(options.exception && typeof options.exception === "object" ? { stack: (options.exception as { message: string; stack?: string }).stack } : {})
|
|
19
108
|
});
|
|
20
109
|
}
|
|
21
110
|
|
|
22
|
-
const terminate = (force = false) => { `),
|
|
23
|
-
|
|
111
|
+
const terminate = (force = false) => { `),
|
|
112
|
+
createComponent(IfStatement, {
|
|
113
|
+
get condition() {
|
|
114
|
+
return createComponent(IsVerbose, {});
|
|
115
|
+
},
|
|
116
|
+
children: code`writeLine("");`
|
|
117
|
+
}),
|
|
118
|
+
createIntrinsic("hbr", {}),
|
|
119
|
+
memo(() => code`
|
|
120
|
+
verbose(\`The ${getAppTitle(context, true)} application exited \${options.exception ? \`early due to an exception\` : "successfully"}\${options.startDate ? \`. Total processing time is \${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \${Date.now() - options.startDate.getTime() > 5000 ? "seconds" : "milliseconds"}\` : ""}...\`);
|
|
24
121
|
if (!options.skipProcessExit) {
|
|
25
122
|
process.nextTick(() => process.exit(exitCode));
|
|
26
123
|
}
|
|
@@ -47,11 +144,19 @@ import{createComponent as e,createIntrinsic as t,memo as n}from"@alloy-js/core/j
|
|
|
47
144
|
|
|
48
145
|
terminate();
|
|
49
146
|
} catch (err) {
|
|
50
|
-
error(\`The exit process failed to complete\${(err as Error)?.message ? \` - \${(err as Error).message}\` : ""}. Please contact the ${
|
|
147
|
+
error(\`The exit process failed to complete\${(err as Error)?.message ? \` - \${(err as Error).message}\` : ""}. Please contact the ${getAppTitle(context, true)} support team.\`);
|
|
51
148
|
|
|
52
149
|
if (!options.skipProcessExit) {
|
|
53
150
|
process.nextTick(() => process.exit(1));
|
|
54
151
|
}
|
|
55
152
|
}
|
|
56
|
-
`)
|
|
153
|
+
`)
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
export { ExitFunctionDeclaration };
|
|
57
162
|
//# sourceMappingURL=exit-function-declaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-function-declaration.mjs","names":[],"sources":["../../src/components/exit-function-declaration.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 } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { IsVerbose } from \"@shell-shock/core/components/helpers\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * The `exit` handler function declaration code for the Shell Shock project.\n */\nexport function ExitFunctionDeclaration() {\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"ExitOptions\"\n doc=\"Options for the exit handler function.\">\n <InterfaceMember\n name=\"exception\"\n optional\n type=\"string | Error\"\n doc=\"An optional exception that caused the exit. This can be a string message or an Error object.\"\n />\n <hbr />\n <InterfaceMember\n name=\"skipProcessExit\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application.\"\n />\n <hbr />\n <InterfaceMember\n name=\"isSynchronous\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed.\"\n />\n <hbr />\n <InterfaceMember\n name=\"signal\"\n optional\n type=\"number\"\n doc=\"The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM).\"\n />\n <hbr />\n <InterfaceMember\n name=\"startDate\"\n optional\n type=\"Date\"\n doc=\"A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process.\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <VarDeclaration\n let\n name=\"isExiting\"\n type=\"boolean\"\n initializer={code`false;`}\n />\n <VarDeclaration\n const\n name=\"callbackAsyncQueue\"\n type=\"Array<[(code: number | string) => Promise<void> | void, number]>\"\n initializer={code`[];`}\n />\n <VarDeclaration\n const\n name=\"callbackSyncQueue\"\n type=\"Array<(code: number | string) => void>\"\n initializer={code`[];`}\n />\n <Spacing />\n <FunctionDeclaration\n export\n async\n name=\"exit\"\n parameters={[\n {\n name: \"options\",\n type: \"ExitOptions\",\n default: \"{}\"\n }\n ]}>\n {code`\n try {\n if (isExiting) {\n return;\n }\n\n isExiting = true;\n\n let exitCode: number | string = 0;\n if ((options.signal !== undefined && options.signal > 0) || options.exception) {\n exitCode = 128 + (options.signal ?? 1);\n } else if (typeof process.exitCode === \"number\" || typeof process.exitCode === \"string\") {\n exitCode = process.exitCode;\n }\n\n if (options.exception) {\n error({ message: \\`A fatal error occured while running the application - please contact the ${getAppTitle(\n context\n )} support team\\${options.exception && typeof options.exception !== \"symbol\" ? \\`: \\\\n\\\\n\\${typeof options.exception === \"string\" ? options.exception : options.exception.message}\\` : \".\"}\\`,\n ...(options.exception && typeof options.exception === \"object\" ? { stack: (options.exception as { message: string; stack?: string }).stack } : {})\n });\n }\n\n const terminate = (force = false) => { `}\n <IfStatement\n condition={<IsVerbose />}>{code`writeLine(\"\");`}</IfStatement>\n <hbr />\n {code`\n verbose(\\`The ${getAppTitle(\n context,\n true\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}\\${options.startDate ? \\`. Total processing time is \\${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \\${Date.now() - options.startDate.getTime() > 5000 ? \"seconds\" : \"milliseconds\"}\\` : \"\"}...\\`);\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(exitCode));\n }\n };\n\n for (const callbackSync of callbackSyncQueue) {\n callbackSync(exitCode);\n }\n\n if (!options.isSynchronous) {\n const promises = [];\n let forceAfter = 0;\n for (const [callbackAsync, wait] of callbackAsyncQueue) {\n forceAfter = Math.max(forceAfter, wait);\n promises.push(Promise.resolve(callbackAsync(exitCode)));\n }\n\n const asyncTimer = setTimeout(() => {\n terminate(true);\n }, forceAfter);\n await Promise.all(promises);\n clearTimeout(asyncTimer);\n }\n\n terminate();\n } catch (err) {\n error(\\`The exit process failed to complete\\${(err as Error)?.message ? \\` - \\${(err as Error).message}\\` : \"\"}. Please contact the ${getAppTitle(\n context,\n true\n )} support team.\\`);\n\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(1));\n }\n }\n `}\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"exit-function-declaration.mjs","names":[],"sources":["../../src/components/exit-function-declaration.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 } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { IsVerbose } from \"@shell-shock/core/components/helpers\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * The `exit` handler function declaration code for the Shell Shock project.\n */\nexport function ExitFunctionDeclaration() {\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"ExitOptions\"\n doc=\"Options for the exit handler function.\">\n <InterfaceMember\n name=\"exception\"\n optional\n type=\"string | Error\"\n doc=\"An optional exception that caused the exit. This can be a string message or an Error object.\"\n />\n <hbr />\n <InterfaceMember\n name=\"skipProcessExit\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application.\"\n />\n <hbr />\n <InterfaceMember\n name=\"isSynchronous\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed.\"\n />\n <hbr />\n <InterfaceMember\n name=\"signal\"\n optional\n type=\"number\"\n doc=\"The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM).\"\n />\n <hbr />\n <InterfaceMember\n name=\"startDate\"\n optional\n type=\"Date\"\n doc=\"A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process.\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <VarDeclaration\n let\n name=\"isExiting\"\n type=\"boolean\"\n initializer={code`false;`}\n />\n <VarDeclaration\n const\n name=\"callbackAsyncQueue\"\n type=\"Array<[(code: number | string) => Promise<void> | void, number]>\"\n initializer={code`[];`}\n />\n <VarDeclaration\n const\n name=\"callbackSyncQueue\"\n type=\"Array<(code: number | string) => void>\"\n initializer={code`[];`}\n />\n <Spacing />\n <FunctionDeclaration\n export\n async\n name=\"exit\"\n parameters={[\n {\n name: \"options\",\n type: \"ExitOptions\",\n default: \"{}\"\n }\n ]}>\n {code`\n try {\n if (isExiting) {\n return;\n }\n\n isExiting = true;\n\n let exitCode: number | string = 0;\n if ((options.signal !== undefined && options.signal > 0) || options.exception) {\n exitCode = 128 + (options.signal ?? 1);\n } else if (typeof process.exitCode === \"number\" || typeof process.exitCode === \"string\") {\n exitCode = process.exitCode;\n }\n\n if (options.exception) {\n error({ message: \\`A fatal error occured while running the application - please contact the ${getAppTitle(\n context\n )} support team\\${options.exception && typeof options.exception !== \"symbol\" ? \\`: \\\\n\\\\n\\${typeof options.exception === \"string\" ? options.exception : options.exception.message}\\` : \".\"}\\`,\n ...(options.exception && typeof options.exception === \"object\" ? { stack: (options.exception as { message: string; stack?: string }).stack } : {})\n });\n }\n\n const terminate = (force = false) => { `}\n <IfStatement\n condition={<IsVerbose />}>{code`writeLine(\"\");`}</IfStatement>\n <hbr />\n {code`\n verbose(\\`The ${getAppTitle(\n context,\n true\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}\\${options.startDate ? \\`. Total processing time is \\${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \\${Date.now() - options.startDate.getTime() > 5000 ? \"seconds\" : \"milliseconds\"}\\` : \"\"}...\\`);\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(exitCode));\n }\n };\n\n for (const callbackSync of callbackSyncQueue) {\n callbackSync(exitCode);\n }\n\n if (!options.isSynchronous) {\n const promises = [];\n let forceAfter = 0;\n for (const [callbackAsync, wait] of callbackAsyncQueue) {\n forceAfter = Math.max(forceAfter, wait);\n promises.push(Promise.resolve(callbackAsync(exitCode)));\n }\n\n const asyncTimer = setTimeout(() => {\n terminate(true);\n }, forceAfter);\n await Promise.all(promises);\n clearTimeout(asyncTimer);\n }\n\n terminate();\n } catch (err) {\n error(\\`The exit process failed to complete\\${(err as Error)?.message ? \\` - \\${(err as Error).message}\\` : \"\"}. Please contact the ${getAppTitle(\n context,\n true\n )} support team.\\`);\n\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(1));\n }\n }\n `}\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,SAAS,0BAA+B;CACxC,MAAQ,UAAC,eAAqB;AAC9B,QAAO;EAAA,gBAAO,sBAAoC;;GAEhD,MAAA;GACC,KAAK;GACN,IAAA,WAAA;AACI,WAAC;KAAA,gBAAS,iBAA0B;MAClC,MAAA;;MAEA,MAAC;MACJ,KAAA;MACE,CAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA,gBAAA,iBAAA;MACC,MAAA;MACA,UAAM;MACN,MAAK;MACL,KAAC;MACF,CAAC;KAAE,gBAAe,OAAA,EAAA,CAAA;KAAA,gBAAA,iBAAA;MACjB,MAAE;MACF,UAAQ;MACR,MAAM;MACN,KAAC;MACF,CAAC;KAAC,gBAAK,OAAA,EAAA,CAAA;KAAA,gBAAA,iBAAA;MACN,MAAC;MACD,UAAQ;MACR,MAAE;MACF,KAAE;MACH,CAAC;KAAE,gBAAe,OAAQ,EAAI,CAAA;KAAA,gBAAqB,iBAAiB;MACnE,MAAC;MACD,UAAM;MACN,MAAC;MACD,KAAE;MACH,CAAC;KAAC;;GAEN,CAAC;EAAE,gBAAkB,SAAS,EAAA,CAAG;EAAC,gBAAc,gBAAe;GAC9D,OAAK;GACL,MAAK;GACL,MAAK;GACL,aAAY,IAAA;GACb,CAAC;EAAE,gBAAI,gBAAA;GACN,SAAM;GACN,MAAM;GACN,MAAK;GACL,aAAU,IAAA;GACX,CAAC;EAAE,gBAAG,gBAAA;GACL,SAAM;GACN,MAAM;GACN,MAAM;GACN,aAAa,IAAI;GAClB,CAAC;EAAE,gBAAG,SAAA,EAAA,CAAA;EAAA,gBAAA,qBAAA;GACL,UAAI;GACJ,OAAG;GACH,MAAG;GACH,YAAI,CAAA;IACF,MAAM;IACN,MAAM;IACN,SAAE;IACH,CAAC;GACF,IAAG,WAAA;AACD,WAAE;KAAA,WAAA,IAAA;;;;;;;;;;;;;;;;4GAgBY,YAAA,QAAA,CAAA;;;;;qDAKV;KAAA,gBAAA,aAAA;MACF,IAAE,YAAA;AACD,cAAI,gBAAA,WAAA,EAAA,CAAA;;MAEL,UAAQ,IAAA;MACT,CAAC;KAAE,gBAAU,OAAA,EAAA,CAAA;KAAA,WAAA,IAAA;8BACR,YAAA,SAAA,KAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;kJA2B+H,YAAmB,SAAQ,KAAM,CAAC;;;;;;UAMnK;KAAC;;GAER,CAAC;EAAC"}
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_components_exit_function_declaration = require('./exit-function-declaration.cjs');
|
|
3
|
+
const require_components_bin_entry = require('./bin-entry.cjs');
|
|
4
|
+
const require_components_command_router = require('./command-router.cjs');
|
|
5
|
+
const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
|
|
6
|
+
const require_components_command_entry = require('./command-entry.cjs');
|
|
7
|
+
|
|
8
|
+
exports.BinEntry = require_components_bin_entry.BinEntry;
|
|
9
|
+
exports.CommandEntry = require_components_command_entry.CommandEntry;
|
|
10
|
+
exports.CommandHandlerDeclaration = require_components_command_entry.CommandHandlerDeclaration;
|
|
11
|
+
exports.CommandInvocation = require_components_command_entry.CommandInvocation;
|
|
12
|
+
exports.CommandRouter = require_components_command_router.CommandRouter;
|
|
13
|
+
exports.CommandRouterBody = require_components_command_router.CommandRouterBody;
|
|
14
|
+
exports.CommandRouterRoute = require_components_command_router.CommandRouterRoute;
|
|
15
|
+
exports.ExitFunctionDeclaration = require_components_exit_function_declaration.ExitFunctionDeclaration;
|
|
16
|
+
exports.RunApplication = require_components_bin_entry.RunApplication;
|
|
17
|
+
exports.VirtualCommandEntry = require_components_virtual_command_entry.VirtualCommandEntry;
|
|
18
|
+
exports.VirtualCommandHandlerDeclaration = require_components_virtual_command_entry.VirtualCommandHandlerDeclaration;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{ExitFunctionDeclaration
|
|
1
|
+
import { ExitFunctionDeclaration } from "./exit-function-declaration.mjs";
|
|
2
|
+
import { BinEntry, RunApplication } from "./bin-entry.mjs";
|
|
3
|
+
import { CommandRouter, CommandRouterBody, CommandRouterRoute } from "./command-router.mjs";
|
|
4
|
+
import { VirtualCommandEntry, VirtualCommandHandlerDeclaration } from "./virtual-command-entry.mjs";
|
|
5
|
+
import { CommandEntry, CommandHandlerDeclaration, CommandInvocation } from "./command-entry.mjs";
|
|
6
|
+
|
|
7
|
+
export { BinEntry, CommandEntry, CommandHandlerDeclaration, CommandInvocation, CommandRouter, CommandRouterBody, CommandRouterRoute, ExitFunctionDeclaration, RunApplication, VirtualCommandEntry, VirtualCommandHandlerDeclaration };
|
|
@@ -1 +1,156 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_components_command_router = require('./command-router.cjs');
|
|
4
|
+
const require_components_command_entry = require('./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 _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
|
|
9
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
12
|
+
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
13
|
+
let defu = require("defu");
|
|
14
|
+
defu = require_runtime.__toESM(defu);
|
|
15
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
16
|
+
let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
17
|
+
let _powerlines_plugin_alloy_typescript_components_typescript_file = require("@powerlines/plugin-alloy/typescript/components/typescript-file");
|
|
18
|
+
|
|
19
|
+
//#region src/components/virtual-command-entry.tsx
|
|
20
|
+
/**
|
|
21
|
+
* A component that generates the `handler` function declaration for a command.
|
|
22
|
+
*/
|
|
23
|
+
function VirtualCommandHandlerDeclaration(props) {
|
|
24
|
+
const { command, children, banner } = props;
|
|
25
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
26
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
27
|
+
get heading() {
|
|
28
|
+
return `The ${command.title} (${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} ${command.segments.map((segment) => (0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? `[${(0, _stryke_string_format_constant_case.constantCase)((0, _shell_shock_core_plugin_utils.getDynamicPathSegmentName)(segment))}]` : segment).join(" ")}) virtual command.`;
|
|
29
|
+
},
|
|
30
|
+
get children() {
|
|
31
|
+
return [
|
|
32
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { get children() {
|
|
33
|
+
return `${command.description.replace(/\.+$/, "")}.`;
|
|
34
|
+
} }),
|
|
35
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
36
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocTitle, { get children() {
|
|
37
|
+
return command.title;
|
|
38
|
+
} }),
|
|
39
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
40
|
+
name: "args",
|
|
41
|
+
children: `The command-line arguments passed to the command.`
|
|
42
|
+
})
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
46
|
+
"export": true,
|
|
47
|
+
async: true,
|
|
48
|
+
name: "handler",
|
|
49
|
+
parameters: [{
|
|
50
|
+
name: "args",
|
|
51
|
+
type: "string[]",
|
|
52
|
+
default: "useArgs()"
|
|
53
|
+
}],
|
|
54
|
+
get children() {
|
|
55
|
+
return [
|
|
56
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
|
|
57
|
+
children,
|
|
58
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
|
|
59
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
60
|
+
get when() {
|
|
61
|
+
return Boolean(banner);
|
|
62
|
+
},
|
|
63
|
+
children: banner
|
|
64
|
+
}),
|
|
65
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
|
|
66
|
+
_alloy_js_core.code`return showHelp(); `
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
})];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The virtual command entry point for the Shell Shock project.
|
|
73
|
+
*/
|
|
74
|
+
function VirtualCommandEntry(props) {
|
|
75
|
+
const { command, imports, builtinImports, ...rest } = props;
|
|
76
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
77
|
+
const filePath = (0, _alloy_js_core.computed)(() => (0, _stryke_path_join.joinPaths)(context.entryPath, command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)).join("/"), "index.ts"));
|
|
78
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_typescript_file.TypescriptFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
79
|
+
get path() {
|
|
80
|
+
return filePath.value;
|
|
81
|
+
},
|
|
82
|
+
get imports() {
|
|
83
|
+
return (0, defu.default)(imports ?? {}, Object.entries(command.children).filter(([, child]) => child.isVirtual).reduce((ret, [name, child]) => {
|
|
84
|
+
ret[`./${child.name}`] = [{
|
|
85
|
+
name: "handler",
|
|
86
|
+
alias: `handle${(0, _stryke_string_format_pascal_case.pascalCase)(name)}`
|
|
87
|
+
}];
|
|
88
|
+
return ret;
|
|
89
|
+
}, {}));
|
|
90
|
+
},
|
|
91
|
+
get builtinImports() {
|
|
92
|
+
return (0, defu.default)(builtinImports ?? {}, {
|
|
93
|
+
env: ["isDevelopment", "isDebug"],
|
|
94
|
+
console: [
|
|
95
|
+
"warn",
|
|
96
|
+
"error",
|
|
97
|
+
"writeLine",
|
|
98
|
+
"textColors"
|
|
99
|
+
],
|
|
100
|
+
utils: [
|
|
101
|
+
"isMinimal",
|
|
102
|
+
"isUnicodeSupported",
|
|
103
|
+
"findSuggestions"
|
|
104
|
+
],
|
|
105
|
+
state: [
|
|
106
|
+
{
|
|
107
|
+
name: "GlobalOptions",
|
|
108
|
+
type: true
|
|
109
|
+
},
|
|
110
|
+
"useGlobal",
|
|
111
|
+
"useGlobalOptions",
|
|
112
|
+
"withCommand",
|
|
113
|
+
"useArgs",
|
|
114
|
+
"hasFlag"
|
|
115
|
+
],
|
|
116
|
+
[(0, _stryke_path_join.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showHelp"],
|
|
117
|
+
[(0, _stryke_path_join.joinPaths)("banner", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showBanner"]
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
get children() {
|
|
121
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(VirtualCommandHandlerDeclaration, {
|
|
122
|
+
command,
|
|
123
|
+
banner: _alloy_js_core.code`await showBanner(); `,
|
|
124
|
+
get children() {
|
|
125
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
|
|
126
|
+
get segments() {
|
|
127
|
+
return command.segments;
|
|
128
|
+
},
|
|
129
|
+
get commands() {
|
|
130
|
+
return command.children;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
})];
|
|
135
|
+
}
|
|
136
|
+
})), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
137
|
+
get each() {
|
|
138
|
+
return Object.values(command.children);
|
|
139
|
+
},
|
|
140
|
+
children: (child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
141
|
+
get when() {
|
|
142
|
+
return child.isVirtual;
|
|
143
|
+
},
|
|
144
|
+
get fallback() {
|
|
145
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_entry.CommandEntry, { command: child });
|
|
146
|
+
},
|
|
147
|
+
get children() {
|
|
148
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(VirtualCommandEntry, { command: child });
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
})];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
exports.VirtualCommandEntry = VirtualCommandEntry;
|
|
156
|
+
exports.VirtualCommandHandlerDeclaration = VirtualCommandHandlerDeclaration;
|