@shell-shock/preset-script 0.6.61 → 0.6.63

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 (39) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -29
  3. package/dist/components/bin-entry.cjs +3 -149
  4. package/dist/components/bin-entry.d.cts.map +1 -1
  5. package/dist/components/bin-entry.d.mts.map +1 -1
  6. package/dist/components/bin-entry.mjs +3 -144
  7. package/dist/components/bin-entry.mjs.map +1 -1
  8. package/dist/components/command-entry.cjs +3 -203
  9. package/dist/components/command-entry.mjs +3 -197
  10. package/dist/components/command-entry.mjs.map +1 -1
  11. package/dist/components/command-router.cjs +2 -161
  12. package/dist/components/command-router.mjs +2 -156
  13. package/dist/components/command-router.mjs.map +1 -1
  14. package/dist/components/exit-function-declaration.cjs +6 -114
  15. package/dist/components/exit-function-declaration.mjs +6 -111
  16. package/dist/components/exit-function-declaration.mjs.map +1 -1
  17. package/dist/components/index.cjs +1 -18
  18. package/dist/components/index.mjs +1 -7
  19. package/dist/components/virtual-command-entry.cjs +1 -154
  20. package/dist/components/virtual-command-entry.mjs +1 -149
  21. package/dist/components/virtual-command-entry.mjs.map +1 -1
  22. package/dist/helpers/get-global-options.cjs +1 -76
  23. package/dist/helpers/get-global-options.mjs +1 -73
  24. package/dist/helpers/get-global-options.mjs.map +1 -1
  25. package/dist/index.cjs +1 -127
  26. package/dist/index.d.cts.map +1 -1
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.mjs +1 -120
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/types/index.mjs +1 -1
  31. package/dist/types/plugin.mjs +1 -1
  32. package/package.json +15 -19
  33. package/dist/components/bin-entry.cjs.map +0 -1
  34. package/dist/components/command-entry.cjs.map +0 -1
  35. package/dist/components/command-router.cjs.map +0 -1
  36. package/dist/components/exit-function-declaration.cjs.map +0 -1
  37. package/dist/components/virtual-command-entry.cjs.map +0 -1
  38. package/dist/helpers/get-global-options.cjs.map +0 -1
  39. package/dist/index.cjs.map +0 -1
@@ -1,76 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _shell_shock_core = require("@shell-shock/core");
4
-
5
- //#region src/helpers/get-global-options.ts
6
- /**
7
- * Get the default command options.
8
- *
9
- * @returns The default command options.
10
- */
11
- function getGlobalOptions() {
12
- return [
13
- {
14
- name: "help",
15
- title: "Help",
16
- description: "Show help information.",
17
- env: false,
18
- alias: ["h", "?"],
19
- kind: _shell_shock_core.CommandParameterKinds.boolean,
20
- optional: true,
21
- default: false,
22
- variadic: false,
23
- skipAddingNegative: true
24
- },
25
- {
26
- name: "version",
27
- title: "Version",
28
- description: "Show the version of the application.",
29
- env: false,
30
- alias: ["v"],
31
- kind: _shell_shock_core.CommandParameterKinds.boolean,
32
- optional: true,
33
- default: false,
34
- variadic: false,
35
- skipAddingNegative: true
36
- },
37
- {
38
- name: "verbose",
39
- title: "Verbose",
40
- description: "Enable verbose output.",
41
- env: "VERBOSE",
42
- alias: ["V"],
43
- kind: _shell_shock_core.CommandParameterKinds.boolean,
44
- optional: true,
45
- default: false,
46
- variadic: false,
47
- skipAddingNegative: true
48
- },
49
- {
50
- name: "color",
51
- title: "Color",
52
- description: "Enable colored terminal output.",
53
- env: "COLOR",
54
- alias: ["colors"],
55
- kind: _shell_shock_core.CommandParameterKinds.boolean,
56
- optional: true,
57
- variadic: false,
58
- skipAddingNegative: false
59
- },
60
- {
61
- name: "no-banner",
62
- title: "Hide Banner",
63
- description: "Do not display the application banner displayed while running the CLI - will be set to true if running in a CI pipeline.",
64
- env: "NO_BANNER",
65
- alias: ["hide-banner"],
66
- kind: _shell_shock_core.CommandParameterKinds.boolean,
67
- optional: true,
68
- variadic: false,
69
- default: false
70
- }
71
- ];
72
- }
73
-
74
- //#endregion
75
- exports.getGlobalOptions = getGlobalOptions;
76
- //# sourceMappingURL=get-global-options.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@shell-shock/core`);function t(){return[{name:`help`,title:`Help`,description:`Show help information.`,env:!1,alias:[`h`,`?`],kind:e.CommandParameterKinds.boolean,optional:!0,default:!1,variadic:!1,skipAddingNegative:!0},{name:`version`,title:`Version`,description:`Show the version of the application.`,env:!1,alias:[`v`],kind:e.CommandParameterKinds.boolean,optional:!0,default:!1,variadic:!1,skipAddingNegative:!0},{name:`verbose`,title:`Verbose`,description:`Enable verbose output.`,env:`VERBOSE`,alias:[`V`],kind:e.CommandParameterKinds.boolean,optional:!0,default:!1,variadic:!1,skipAddingNegative:!0},{name:`color`,title:`Color`,description:`Enable colored terminal output.`,env:`COLOR`,alias:[`colors`],kind:e.CommandParameterKinds.boolean,optional:!0,variadic:!1,skipAddingNegative:!1},{name:`no-banner`,title:`Hide Banner`,description:`Do not display the application banner displayed while running the CLI - will be set to true if running in a CI pipeline.`,env:`NO_BANNER`,alias:[`hide-banner`],kind:e.CommandParameterKinds.boolean,optional:!0,variadic:!1,default:!1}]}exports.getGlobalOptions=t;
@@ -1,74 +1,2 @@
1
- import { CommandParameterKinds } from "@shell-shock/core";
2
-
3
- //#region src/helpers/get-global-options.ts
4
- /**
5
- * Get the default command options.
6
- *
7
- * @returns The default command options.
8
- */
9
- function getGlobalOptions() {
10
- return [
11
- {
12
- name: "help",
13
- title: "Help",
14
- description: "Show help information.",
15
- env: false,
16
- alias: ["h", "?"],
17
- kind: CommandParameterKinds.boolean,
18
- optional: true,
19
- default: false,
20
- variadic: false,
21
- skipAddingNegative: true
22
- },
23
- {
24
- name: "version",
25
- title: "Version",
26
- description: "Show the version of the application.",
27
- env: false,
28
- alias: ["v"],
29
- kind: CommandParameterKinds.boolean,
30
- optional: true,
31
- default: false,
32
- variadic: false,
33
- skipAddingNegative: true
34
- },
35
- {
36
- name: "verbose",
37
- title: "Verbose",
38
- description: "Enable verbose output.",
39
- env: "VERBOSE",
40
- alias: ["V"],
41
- kind: CommandParameterKinds.boolean,
42
- optional: true,
43
- default: false,
44
- variadic: false,
45
- skipAddingNegative: true
46
- },
47
- {
48
- name: "color",
49
- title: "Color",
50
- description: "Enable colored terminal output.",
51
- env: "COLOR",
52
- alias: ["colors"],
53
- kind: CommandParameterKinds.boolean,
54
- optional: true,
55
- variadic: false,
56
- skipAddingNegative: false
57
- },
58
- {
59
- name: "no-banner",
60
- title: "Hide Banner",
61
- description: "Do not display the application banner displayed while running the CLI - will be set to true if running in a CI pipeline.",
62
- env: "NO_BANNER",
63
- alias: ["hide-banner"],
64
- kind: CommandParameterKinds.boolean,
65
- optional: true,
66
- variadic: false,
67
- default: false
68
- }
69
- ];
70
- }
71
-
72
- //#endregion
73
- export { getGlobalOptions };
1
+ import{CommandParameterKinds as e}from"@shell-shock/core";function t(){return[{name:`help`,title:`Help`,description:`Show help information.`,env:!1,alias:[`h`,`?`],kind:e.boolean,optional:!0,default:!1,variadic:!1,skipAddingNegative:!0},{name:`version`,title:`Version`,description:`Show the version of the application.`,env:!1,alias:[`v`],kind:e.boolean,optional:!0,default:!1,variadic:!1,skipAddingNegative:!0},{name:`verbose`,title:`Verbose`,description:`Enable verbose output.`,env:`VERBOSE`,alias:[`V`],kind:e.boolean,optional:!0,default:!1,variadic:!1,skipAddingNegative:!0},{name:`color`,title:`Color`,description:`Enable colored terminal output.`,env:`COLOR`,alias:[`colors`],kind:e.boolean,optional:!0,variadic:!1,skipAddingNegative:!1},{name:`no-banner`,title:`Hide Banner`,description:`Do not display the application banner displayed while running the CLI - will be set to true if running in a CI pipeline.`,env:`NO_BANNER`,alias:[`hide-banner`],kind:e.boolean,optional:!0,variadic:!1,default:!1}]}export{t as getGlobalOptions};
74
2
  //# sourceMappingURL=get-global-options.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-global-options.mjs","names":[],"sources":["../../src/helpers/get-global-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandOption } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\n\n/**\n * Get the default command options.\n *\n * @returns The default command options.\n */\nexport function getGlobalOptions(): CommandOption[] {\n return [\n {\n name: \"help\",\n title: \"Help\",\n description: \"Show help information.\",\n env: false,\n alias: [\"h\", \"?\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n default: false,\n variadic: false,\n skipAddingNegative: true\n },\n {\n name: \"version\",\n title: \"Version\",\n description: \"Show the version of the application.\",\n env: false,\n alias: [\"v\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n default: false,\n variadic: false,\n skipAddingNegative: true\n },\n {\n name: \"verbose\",\n title: \"Verbose\",\n description: \"Enable verbose output.\",\n env: \"VERBOSE\",\n alias: [\"V\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n default: false,\n variadic: false,\n skipAddingNegative: true\n },\n {\n name: \"color\",\n title: \"Color\",\n description: \"Enable colored terminal output.\",\n env: \"COLOR\",\n alias: [\"colors\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n variadic: false,\n skipAddingNegative: false\n },\n {\n name: \"no-banner\",\n title: \"Hide Banner\",\n description:\n \"Do not display the application banner displayed while running the CLI - will be set to true if running in a CI pipeline.\",\n env: \"NO_BANNER\",\n alias: [\"hide-banner\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n variadic: false,\n default: false\n }\n ];\n}\n"],"mappings":";;;;;;;;AA0BA,SAAgB,mBAAoC;AAClD,QAAO;EACL;GACE,MAAM;GACN,OAAO;GACP,aAAa;GACb,KAAK;GACL,OAAO,CAAC,KAAK,IAAI;GACjB,MAAM,sBAAsB;GAC5B,UAAU;GACV,SAAS;GACT,UAAU;GACV,oBAAoB;GACrB;EACD;GACE,MAAM;GACN,OAAO;GACP,aAAa;GACb,KAAK;GACL,OAAO,CAAC,IAAI;GACZ,MAAM,sBAAsB;GAC5B,UAAU;GACV,SAAS;GACT,UAAU;GACV,oBAAoB;GACrB;EACD;GACE,MAAM;GACN,OAAO;GACP,aAAa;GACb,KAAK;GACL,OAAO,CAAC,IAAI;GACZ,MAAM,sBAAsB;GAC5B,UAAU;GACV,SAAS;GACT,UAAU;GACV,oBAAoB;GACrB;EACD;GACE,MAAM;GACN,OAAO;GACP,aAAa;GACb,KAAK;GACL,OAAO,CAAC,SAAS;GACjB,MAAM,sBAAsB;GAC5B,UAAU;GACV,UAAU;GACV,oBAAoB;GACrB;EACD;GACE,MAAM;GACN,OAAO;GACP,aACE;GACF,KAAK;GACL,OAAO,CAAC,cAAc;GACtB,MAAM,sBAAsB;GAC5B,UAAU;GACV,UAAU;GACV,SAAS;GACV;EACF"}
1
+ {"version":3,"file":"get-global-options.mjs","names":[],"sources":["../../src/helpers/get-global-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandOption } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\n\n/**\n * Get the default command options.\n *\n * @returns The default command options.\n */\nexport function getGlobalOptions(): CommandOption[] {\n return [\n {\n name: \"help\",\n title: \"Help\",\n description: \"Show help information.\",\n env: false,\n alias: [\"h\", \"?\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n default: false,\n variadic: false,\n skipAddingNegative: true\n },\n {\n name: \"version\",\n title: \"Version\",\n description: \"Show the version of the application.\",\n env: false,\n alias: [\"v\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n default: false,\n variadic: false,\n skipAddingNegative: true\n },\n {\n name: \"verbose\",\n title: \"Verbose\",\n description: \"Enable verbose output.\",\n env: \"VERBOSE\",\n alias: [\"V\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n default: false,\n variadic: false,\n skipAddingNegative: true\n },\n {\n name: \"color\",\n title: \"Color\",\n description: \"Enable colored terminal output.\",\n env: \"COLOR\",\n alias: [\"colors\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n variadic: false,\n skipAddingNegative: false\n },\n {\n name: \"no-banner\",\n title: \"Hide Banner\",\n description:\n \"Do not display the application banner displayed while running the CLI - will be set to true if running in a CI pipeline.\",\n env: \"NO_BANNER\",\n alias: [\"hide-banner\"],\n kind: CommandParameterKinds.boolean,\n optional: true,\n variadic: false,\n default: false\n }\n ];\n}\n"],"mappings":"0DAyBA,SAAE,GAAA,CACF,MAAO,CAAA,CACL,KAAO,OACL,MAAA,OACA,YAAa,yBACb,IAAE,GACF,MAAE,CAAA,IAAW,IAAG,CAChB,KAAM,EAAM,QACZ,SAAU,GACV,QAAQ,GACR,SAAU,GACV,mBAAgB,GACjB,CAAE,CACD,KAAE,UACF,MAAC,UACD,YAAA,uCACA,IAAE,GACF,MAAO,CAAC,IAAE,CACV,KAAE,EAAuB,QACzB,SAAO,GACP,QAAS,GACT,SAAQ,GACR,mBAAgB,GACjB,CAAE,CACD,KAAE,UACF,MAAE,UACF,YAAC,yBACD,IAAA,UACA,MAAO,CAAC,IAAC,CACT,KAAE,EAAgB,QAClB,SAAE,GACF,QAAQ,GACR,SAAU,GACV,mBAAQ,GACT,CAAE,CACD,KAAE,QACF,MAAE,QACF,YAAE,kCACF,IAAC,QACD,MAAA,CAAA,SAAA,CACA,KAAM,EAAS,QACf,SAAU,GACV,SAAE,GACF,mBAAc,GACf,CAAE,CACD,KAAM,YACN,MAAE,cACF,YAAY,2HACZ,IAAE,YACF,MAAC,CAAA,cAAA,CACD,KAAA,EAAA,QACA,SAAS,GACT,SAAU,GACV,QAAE,GACH,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,127 +1 @@
1
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_components_bin_entry = require('./components/bin-entry.cjs');
4
- const require_components_command_router = require('./components/command-router.cjs');
5
- const require_components_virtual_command_entry = require('./components/virtual-command-entry.cjs');
6
- const require_components_command_entry = require('./components/command-entry.cjs');
7
- const require_helpers_get_global_options = require('./helpers/get-global-options.cjs');
8
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
9
- let _alloy_js_core = require("@alloy-js/core");
10
- let _alloy_js_typescript = require("@alloy-js/typescript");
11
- let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
12
- let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
13
- let _shell_shock_plugin_banner = require("@shell-shock/plugin-banner");
14
- _shell_shock_plugin_banner = require_runtime.__toESM(_shell_shock_plugin_banner);
15
- let _shell_shock_plugin_console = require("@shell-shock/plugin-console");
16
- _shell_shock_plugin_console = require_runtime.__toESM(_shell_shock_plugin_console);
17
- let _shell_shock_plugin_help = require("@shell-shock/plugin-help");
18
- _shell_shock_plugin_help = require_runtime.__toESM(_shell_shock_plugin_help);
19
-
20
- //#region src/index.tsx
21
- /**
22
- * The Shell Shock base plugin.
23
- */
24
- const plugin = (options = {}) => {
25
- return [
26
- ...(0, _shell_shock_plugin_console.default)(options),
27
- ...(0, _shell_shock_plugin_help.default)(options),
28
- ...(0, _shell_shock_plugin_banner.default)(options.banner),
29
- {
30
- name: "shell-shock:script-preset",
31
- config() {
32
- this.debug("Providing default configuration for the Shell Shock `script` preset.");
33
- return {
34
- globalOptions: require_helpers_get_global_options.getGlobalOptions,
35
- isCaseSensitive: false,
36
- ...options
37
- };
38
- }
39
- },
40
- {
41
- name: "shell-shock:script-preset:generate-entrypoint",
42
- prepare: {
43
- order: "post",
44
- async handler() {
45
- const _self$ = this;
46
- this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
47
- return (0, _powerlines_plugin_alloy_render.render)(this, [(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_bin_entry.BinEntry, {
48
- builtinImports: {
49
- console: [
50
- "divider",
51
- "stripAnsi",
52
- "writeLine",
53
- "splitText",
54
- "help"
55
- ],
56
- utils: ["isMinimal"],
57
- state: [
58
- "useArgs",
59
- "hasFlag",
60
- "isHelp"
61
- ]
62
- },
63
- get children() {
64
- return [
65
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
66
- get when() {
67
- return Object.keys(_self$.commands).length > 0;
68
- },
69
- get children() {
70
- return [
71
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
72
- "const": true,
73
- name: "args",
74
- type: "string[]",
75
- initializer: _alloy_js_core.code`useArgs();`
76
- }),
77
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
78
- (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
79
- segments: [],
80
- get commands() {
81
- return _self$.commands ?? {};
82
- }
83
- }),
84
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
85
- ];
86
- }
87
- }),
88
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
89
- _alloy_js_core.code`await showBanner();`,
90
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
91
- _alloy_js_core.code`return showHelp();`
92
- ];
93
- }
94
- }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
95
- get when() {
96
- return Object.values(_self$.commands).length > 0;
97
- },
98
- get children() {
99
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
100
- get each() {
101
- return Object.values(_self$.commands);
102
- },
103
- doubleHardline: true,
104
- children: (child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
105
- get when() {
106
- return child.isVirtual;
107
- },
108
- get fallback() {
109
- return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_entry.CommandEntry, { command: child });
110
- },
111
- get children() {
112
- return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_virtual_command_entry.VirtualCommandEntry, { command: child });
113
- }
114
- })
115
- });
116
- }
117
- })]);
118
- }
119
- }
120
- }
121
- ];
122
- };
123
-
124
- //#endregion
125
- exports.default = plugin;
126
- exports.plugin = plugin;
127
- //# sourceMappingURL=index.cjs.map
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./components/bin-entry.cjs`),n=require(`./components/command-router.cjs`),r=require(`./components/virtual-command-entry.cjs`),i=require(`./components/command-entry.cjs`),a=require(`./helpers/get-global-options.cjs`);let o=require(`@alloy-js/core/jsx-runtime`),s=require(`@alloy-js/core`),c=require(`@alloy-js/typescript`),l=require(`@powerlines/plugin-alloy/core/components`),u=require(`@powerlines/plugin-alloy/render`),d=require(`@shell-shock/plugin-banner`);d=e.__toESM(d);let f=require(`@shell-shock/plugin-console`);f=e.__toESM(f);let p=require(`@shell-shock/plugin-help`);p=e.__toESM(p);const m=(e={})=>[...(0,f.default)(e),...(0,p.default)(e),...(0,d.default)(e.banner),{name:`shell-shock:script-preset`,config(){return this.debug("Providing default configuration for the Shell Shock `script` preset."),{globalOptions:a.getGlobalOptions,isCaseSensitive:!1,...e}},prepare:{order:`post`,async handler(){let e=this;return this.debug("Rendering entrypoint modules for the Shell Shock `script` preset."),(0,u.render)(this,[(0,o.createComponent)(t.BinEntry,{builtinImports:{console:[`divider`,`stripAnsi`,`writeLine`,`splitText`,`help`],utils:[`isMinimal`],state:[`useArgs`,`hasFlag`,`isHelp`]},get children(){return[(0,o.createComponent)(s.Show,{get when(){return Object.keys(e.commands).length>0},get children(){return[(0,o.createComponent)(c.VarDeclaration,{const:!0,name:`args`,type:`string[]`,initializer:s.code`useArgs();`}),(0,o.createIntrinsic)(`hbr`,{}),(0,o.createComponent)(n.CommandRouter,{segments:[],get commands(){return e.commands??{}}}),(0,o.createIntrinsic)(`hbr`,{})]}}),(0,o.createComponent)(l.Spacing,{}),s.code`await showBanner();`,(0,o.createComponent)(l.Spacing,{}),s.code`return showHelp();`]}}),(0,o.createComponent)(s.Show,{get when(){return Object.values(e.commands).length>0},get children(){return(0,o.createComponent)(s.For,{get each(){return Object.values(e.commands)},doubleHardline:!0,children:e=>(0,o.createComponent)(s.Show,{get when(){return e.isVirtual},get fallback(){return(0,o.createComponent)(i.CommandEntry,{command:e})},get children(){return(0,o.createComponent)(r.VirtualCommandEntry,{command:e})}})})}})])}}}];exports.default=m,exports.plugin=m;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAoCA;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KA4EJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAqCA;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KACR,MAAA,CAAO,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAoCA;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KA4EJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAqCA;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.mjs CHANGED
@@ -1,121 +1,2 @@
1
- import { BinEntry } from "./components/bin-entry.mjs";
2
- import { CommandRouter } from "./components/command-router.mjs";
3
- import { VirtualCommandEntry } from "./components/virtual-command-entry.mjs";
4
- import { CommandEntry } from "./components/command-entry.mjs";
5
- import { getGlobalOptions } from "./helpers/get-global-options.mjs";
6
- import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
7
- import { For, Show, code } from "@alloy-js/core";
8
- import { VarDeclaration } from "@alloy-js/typescript";
9
- import { Spacing } from "@powerlines/plugin-alloy/core/components";
10
- import { render } from "@powerlines/plugin-alloy/render";
11
- import banner from "@shell-shock/plugin-banner";
12
- import console from "@shell-shock/plugin-console";
13
- import help from "@shell-shock/plugin-help";
14
-
15
- //#region src/index.tsx
16
- /**
17
- * The Shell Shock base plugin.
18
- */
19
- const plugin = (options = {}) => {
20
- return [
21
- ...console(options),
22
- ...help(options),
23
- ...banner(options.banner),
24
- {
25
- name: "shell-shock:script-preset",
26
- config() {
27
- this.debug("Providing default configuration for the Shell Shock `script` preset.");
28
- return {
29
- globalOptions: getGlobalOptions,
30
- isCaseSensitive: false,
31
- ...options
32
- };
33
- }
34
- },
35
- {
36
- name: "shell-shock:script-preset:generate-entrypoint",
37
- prepare: {
38
- order: "post",
39
- async handler() {
40
- const _self$ = this;
41
- this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
42
- return render(this, [createComponent(BinEntry, {
43
- builtinImports: {
44
- console: [
45
- "divider",
46
- "stripAnsi",
47
- "writeLine",
48
- "splitText",
49
- "help"
50
- ],
51
- utils: ["isMinimal"],
52
- state: [
53
- "useArgs",
54
- "hasFlag",
55
- "isHelp"
56
- ]
57
- },
58
- get children() {
59
- return [
60
- createComponent(Show, {
61
- get when() {
62
- return Object.keys(_self$.commands).length > 0;
63
- },
64
- get children() {
65
- return [
66
- createComponent(VarDeclaration, {
67
- "const": true,
68
- name: "args",
69
- type: "string[]",
70
- initializer: code`useArgs();`
71
- }),
72
- createIntrinsic("hbr", {}),
73
- createComponent(CommandRouter, {
74
- segments: [],
75
- get commands() {
76
- return _self$.commands ?? {};
77
- }
78
- }),
79
- createIntrinsic("hbr", {})
80
- ];
81
- }
82
- }),
83
- createComponent(Spacing, {}),
84
- code`await showBanner();`,
85
- createComponent(Spacing, {}),
86
- code`return showHelp();`
87
- ];
88
- }
89
- }), createComponent(Show, {
90
- get when() {
91
- return Object.values(_self$.commands).length > 0;
92
- },
93
- get children() {
94
- return createComponent(For, {
95
- get each() {
96
- return Object.values(_self$.commands);
97
- },
98
- doubleHardline: true,
99
- children: (child) => createComponent(Show, {
100
- get when() {
101
- return child.isVirtual;
102
- },
103
- get fallback() {
104
- return createComponent(CommandEntry, { command: child });
105
- },
106
- get children() {
107
- return createComponent(VirtualCommandEntry, { command: child });
108
- }
109
- })
110
- });
111
- }
112
- })]);
113
- }
114
- }
115
- }
116
- ];
117
- };
118
-
119
- //#endregion
120
- export { plugin as default, plugin };
1
+ import{BinEntry as e}from"./components/bin-entry.mjs";import{CommandRouter as t}from"./components/command-router.mjs";import{VirtualCommandEntry as n}from"./components/virtual-command-entry.mjs";import{CommandEntry as r}from"./components/command-entry.mjs";import{getGlobalOptions as i}from"./helpers/get-global-options.mjs";import{createComponent as a,createIntrinsic as o}from"@alloy-js/core/jsx-runtime";import{For as s,Show as c,code as l}from"@alloy-js/core";import{VarDeclaration as u}from"@alloy-js/typescript";import{Spacing as d}from"@powerlines/plugin-alloy/core/components";import{render as f}from"@powerlines/plugin-alloy/render";import p from"@shell-shock/plugin-banner";import m from"@shell-shock/plugin-console";import h from"@shell-shock/plugin-help";const g=(g={})=>[...m(g),...h(g),...p(g.banner),{name:`shell-shock:script-preset`,config(){return this.debug("Providing default configuration for the Shell Shock `script` preset."),{globalOptions:i,isCaseSensitive:!1,...g}},prepare:{order:`post`,async handler(){let i=this;return this.debug("Rendering entrypoint modules for the Shell Shock `script` preset."),f(this,[a(e,{builtinImports:{console:[`divider`,`stripAnsi`,`writeLine`,`splitText`,`help`],utils:[`isMinimal`],state:[`useArgs`,`hasFlag`,`isHelp`]},get children(){return[a(c,{get when(){return Object.keys(i.commands).length>0},get children(){return[a(u,{const:!0,name:`args`,type:`string[]`,initializer:l`useArgs();`}),o(`hbr`,{}),a(t,{segments:[],get commands(){return i.commands??{}}}),o(`hbr`,{})]}}),a(d,{}),l`await showBanner();`,a(d,{}),l`return showHelp();`]}}),a(c,{get when(){return Object.values(i.commands).length>0},get children(){return a(s,{get each(){return Object.values(i.commands)},doubleHardline:!0,children:e=>a(c,{get when(){return e.isVirtual},get fallback(){return a(r,{command:e})},get children(){return a(n,{command:e})}})})}})])}}}];export{g as default,g as plugin};
121
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport banner from \"@shell-shock/plugin-banner\";\nimport console from \"@shell-shock/plugin-console\";\nimport help from \"@shell-shock/plugin-help\";\nimport type { Plugin } from \"powerlines\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getGlobalOptions } from \"./helpers/get-global-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n ...console<TContext>(options),\n ...help<TContext>(options),\n ...banner<TContext>(options.banner),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n globalOptions: getGlobalOptions,\n isCaseSensitive: false,\n ...options\n };\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"help\"\n ],\n utils: [\"isMinimal\"],\n state: [\"useArgs\", \"hasFlag\", \"isHelp\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`useArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <Spacing />\n {code`await showBanner();`}\n <Spacing />\n {code`return showHelp();`}\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n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AAW;;QAEnC,gBAAU;QACV,WAAK,UAAc,gBAAc,MAAU;SACzC,IAAG,OAAK;AACN,iBAAI,MAAA;;SAEN,IAAC,WAAW;AACX,iBAAQ,gBAAC,cAAA,EACT,SAAY,OACb,CAAA;;SAEA,IAAI,WAAO;AACT,iBAAO,gBAAG,qBAAA,EACR,SAAC,OACF,CAAC;;SAEL,CAAC;QACH,CAAC;;MAEL,CAAC,CAAC,CAAC;;IAEP;GACF;EAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport banner from \"@shell-shock/plugin-banner\";\nimport console from \"@shell-shock/plugin-console\";\nimport help from \"@shell-shock/plugin-help\";\nimport type { Plugin } from \"powerlines\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getGlobalOptions } from \"./helpers/get-global-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n): Plugin<TContext>[] => {\n return [\n ...console<TContext>(options),\n ...help<TContext>(options),\n ...banner<TContext>(options.banner),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n globalOptions: getGlobalOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"help\"\n ],\n utils: [\"isMinimal\"],\n state: [\"useArgs\", \"hasFlag\", \"isHelp\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`useArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <Spacing />\n {code`await showBanner();`}\n <Spacing />\n {code`return showHelp();`}\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For\n each={Object.values(\n this.commands as Record<string, CommandTree>\n )}\n doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ];\n};\n\nexport default plugin;\n"],"mappings":"+vBAkCA,MAAE,GAAA,EAAA,EAAA,GACK,CAAA,GAAM,EAAM,EAAK,CAAM,GAAA,EAAA,EAAA,CAAA,GAAA,EAAA,EAAA,OAAA,CAAA,CAC5B,KAAA,4BACF,QAAa,CAEZ,OADC,KAAS,MAAA,uEAA8B,CACxC,CACC,cAAS,EACR,gBAAsB,GACjB,GAAC,EACF,EAEH,QAAS,CACT,MAAA,OACE,MAAM,SAAO,CACb,IAAQ,EAAC,KAEP,OADA,KAAK,MAAK,oEAAA,CACP,EAAU,KAAO,CAAC,EAAkB,EAAU,CAChD,eAAA,gEAED,MAAO,CAAA,YAAA,CACL,MAAA,CAAA,UAAe,UAAgB,SAAA,CAC/B,CACA,IAAG,UAAA,CACJ,MAAA,CAAA,EAAA,EAAA,CACF,IAAA,MAAA,CACQ,OAAA,OAAA,KAAA,EAAA,SAAA,CAAA,OAAA,GAED,IAAA,UAAU,CACT,MAAK,CAAA,EAAA,EAAA,CACP,MAAU,GACZ,KAAA,uBAEM,YAAM,CAAA,aACP,CAAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACH,SAAA,EAAA,CACE,IAAA,UAAA,CACC,OAAA,EAAgB,UAAA,EAAA,EAEf,CAAC,CAAE,EAAS,MAAA,EAAA,CAAA,CAAA,EAEhB,CAAC,CAAE,EAAe,EAAA,EAAA,CAAA,CAAA,CAAA,sBAAA,EAAA,EAAA,EAAA,CAAA,CAAA,CAAA,qBAAA,EAEtB,CAAC,CAAE,EAAa,EAAA,CACf,IAAI,MAAK,CACP,OAAM,OAAQ,OAAC,EAAW,SAAA,CAAA,OAAA,GAE5B,IAAI,UAAI,CACN,OAAK,EAAkB,EAAK,CAC1B,IAAI,MAAC,CACH,OAAI,OAAA,OAAA,EAAA,SAAA,EAEN,eAAY,GACZ,SAAM,GAAa,EAAgB,EAAA,CACjC,IAAG,MAAA,CACD,OAAM,EAAA,WAER,IAAG,UAAK,CACN,OAAI,EAAA,EAAA,CACL,QAAS,EACT,CAAA,EAED,IAAC,UAAY,CACb,OAAQ,EAAA,EAAA,CACJ,QAAM,EACT,CAAA,EAEF,CAAC,CACH,CAAC,EAEL,CAAC,CAAC,CAAC,EAEP,CACF,CAAC"}
@@ -1 +1 @@
1
- export { };
1
+ export{};
@@ -1 +1 @@
1
- export { };
1
+ export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/preset-script",
3
- "version": "0.6.61",
3
+ "version": "0.6.63",
4
4
  "private": false,
5
5
  "description": "A Shell Shock preset that generates a fully-featured script application.",
6
6
  "keywords": [
@@ -195,25 +195,21 @@
195
195
  "dependencies": {
196
196
  "@alloy-js/core": "0.23.0-dev.8",
197
197
  "@alloy-js/typescript": "0.23.0-dev.4",
198
- "@powerlines/deepkit": "^0.8.2",
199
- "@powerlines/plugin-alloy": "^0.26.18",
200
- "@powerlines/plugin-plugin": "^0.12.350",
201
- "@shell-shock/core": "^0.17.6",
202
- "@shell-shock/plugin-banner": "^0.1.33",
203
- "@shell-shock/plugin-help": "^0.2.24",
204
- "@shell-shock/plugin-console": "^0.2.10",
205
- "@shell-shock/plugin-theme": "^0.4.19",
206
- "@stryke/helpers": "^0.10.8",
207
- "@stryke/path": "^0.27.4",
208
- "@stryke/string-format": "^0.17.9",
198
+ "@powerlines/deepkit": "^0.8.49",
199
+ "@powerlines/plugin-alloy": "^0.26.67",
200
+ "@powerlines/plugin-plugin": "^0.12.399",
201
+ "@shell-shock/core": "^0.17.8",
202
+ "@shell-shock/plugin-banner": "^0.1.35",
203
+ "@shell-shock/plugin-console": "^0.2.12",
204
+ "@shell-shock/plugin-help": "^0.2.26",
205
+ "@shell-shock/plugin-theme": "^0.4.21",
206
+ "@stryke/helpers": "^0.10.11",
207
+ "@stryke/path": "^0.28.1",
208
+ "@stryke/string-format": "^0.17.12",
209
209
  "defu": "^6.1.7",
210
- "powerlines": "^0.42.40"
211
- },
212
- "devDependencies": {
213
- "@babel/core": "^7.29.0",
214
- "@powerlines/plugin-alloy": "^0.26.18",
215
- "@types/node": "^25.6.0"
210
+ "powerlines": "^0.44.12"
216
211
  },
212
+ "devDependencies": { "@babel/core": "8.0.0-rc.3", "@types/node": "^25.6.0" },
217
213
  "publishConfig": { "access": "public" },
218
- "gitHead": "592aee8162fccb2d8547f6cf31b820aca3ae13ec"
214
+ "gitHead": "832c19e668deb4d29b5e0219a7708d111790f607"
219
215
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin-entry.cjs","names":[],"sources":["../../src/components/bin-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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\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 TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { ExitFunctionDeclaration } from \"./exit-function-declaration\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <Spacing />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n const startDate = new Date();\n try {\n process.on(\"exit\", () => exit({\n startDate,\n skipProcessExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n await withGlobal(async () => {\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n });\n\n exit({ startDate });\n } catch (err) {\n exit({ startDate, exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\n \"verbose\",\n \"table\",\n \"writeLine\",\n \"borderColors\",\n \"textColors\",\n \"stripAnsi\",\n \"error\",\n \"warn\"\n ],\n utils: [\"isUnicodeSupported\", \"findSuggestions\"],\n state: [\"withGlobal\", \"useGlobal\", \"hasFlag\"],\n help: [\"showHelp\"],\n banner: [\"showBanner\"]\n })}>\n <ExitFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(prefix)}>\n {prefix}\n <Spacing />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`}>\n <TSDocRemarks>\n {`This file serves as the main entry point for the binary executable of the ${getAppTitle(\n context,\n true\n )} 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.`}\n </TSDocRemarks>\n <TSDocReturns>\n {`Returns a promise that resolves to either a successful result or an error object.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n async\n returnType=\"any | { error: string | Error }\"\n name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${\n context?.packageJson.version\n ? `\"${context?.packageJson.version}\"`\n : \"0.0.1\"\n });\n return; `}\n </IfStatement>\n <Spacing />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAE,iBAAA;AACA,QAAM;kDAAoB,0DAAO,EAAI,CAAC;EAAA,mBAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8E9C,MAAO,EACL,QACC,S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A;MACN,OAAC;MACD,YAAY;MACZ,MAAI;MACJ,IAAI,WAAA;AACF,cAAG;wDAAuB,kCAAa;SACtC,WAAY,mBAAA;SACX,IAAE,WAAU;AACV,iBAAO,mBAAA,eAAA,SAAA,YAAA,UAAA,IAAA,SAAA,YAAA,QAAA,KAAA,QAAA;;;SAGV,CAAC;wDAAY,0DAAA,EAAA,CAAA;QAAA;wDAAA,OAAA,EAAA,CAAA;QAAA;;MAEjB,CAAC;qDAAgB,OAAQ,EAAK,CAAA;qDAAqB,OAAA,EAAA,CAAU;qDAAoB,OAAO,EAAC,CAAA;qDAAA,qBAAA;MACxF,IAAI,OAAA;AACF,cAAK,QAAA,QAAA;;MAEP,IAAE,WAAA;AACA,8DAAyB,gBAAgB,EAAE,CAAA;;MAE7C,UAAG;MACJ,CAAC;qDAAkB,OAAK,EAAA,CAAA;KAAA;;GAE5B,CAAC,CAAC;EACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-entry.cjs","names":[],"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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\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 type { CommandTree } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport { IsDebug } from \"@shell-shock/core/components/helpers\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code` return withCommand(\"${command.path}\", [${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? camelCase(getDynamicPathSegmentName(segment))\n : `\"${segment}\"`\n )\n .join(\", \")}], [${\n Object.keys(command.options).length > 0 ? `options` : \"\"\n }${\n command.args.length > 0\n ? `${\n Object.keys(command.options).length > 0 ? \", \" : \"\"\n }${command.args.map(arg => camelCase(arg.name)).join(\", \")}`\n : \"\"\n }], handle${pascalCase(command.name)}); `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n banner?: Children;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, banner, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(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: \"useArgs()\" }]}>\n <CommandParserLogic\n command={command}\n appSpecificEnvPrefix={context.config.appSpecificEnvPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n {code`writeLine(\"\");`}\n <IfStatement condition={<IsDebug />}>\n {code`writeLine(textColors.body.tertiary(\"Debug mode is enabled. Additional debug information may be logged to the console.\"));\n writeLine(\"\");\n debug(\\`Command path: ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\" / \")} \\\\n\\\\nOptions: \\\\n${Object.values(command.options)\n .map(\n option =>\n ` - ${kebabCase(option.name)}: \\${options.${camelCase(\n option.name\n )} === undefined ? \"\" : JSON.stringify(options.${camelCase(\n option.name\n )})}`\n )\n .join(\"\\\\n\")}${\n command.args.length > 0\n ? ` \\\\n\\\\nArguments: \\\\n${command.args\n .map(\n arg =>\n ` - ${kebabCase(arg.name)}: \\${${camelCase(\n arg.name\n )} === undefined ? \"\" : JSON.stringify(${camelCase(\n arg.name\n )})}`\n )\n .join(\"\\\\n\")}`\n : \"\"\n }\\`); `}\n </IfStatement>\n <Spacing />\n {children}\n <Spacing />\n <IfStatement condition={code`options.help`}>\n {code`return showHelp(); `}\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.segments\n .filter(segment => !isDynamicPathSegment(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.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"debug\", \"warn\", \"error\", \"writeLine\", \"textColors\"],\n utils: [\"isMinimal\", \"isUnicodeSupported\"],\n state: [\n \"useGlobal\",\n \"GlobalOptions\",\n \"useGlobalOptions\",\n \"useArgs\",\n \"hasFlag\",\n \"withCommand\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner(); `}>\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\\`The following validation failures were found while processing the user provided input, and must be corrected before the \\${italic(\"${\n command.title\n }\")} command can be executed: \\\\n\\\\n\\${failures.map(failure => \" - \" + failure).join(\"\\\\n\")}\\`);\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\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":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAO,kBAAA,OAEL;CACA,MAAA,EACA,YACI;AACN,QAAS,4CAAY,mBAAM,wBAAkB,QAAA,KAAA,MAAA,QAAA,SAAA,KAAA,qEAAA,QAAA,iHAAA,QAAA,CAAA,GAAA,IAAA,QAAA,GAAA,CAAA,KAAA,KAAA,CAAA,MAAA,OAAA,KAAA,QAAA,QAAA,CAAA,SAAA,IAAA,YAAA,KAAA,QAAA,KAAA,SAAA,IAAA,GAAA,OAAA,KAAA,QAAA,QAAA,CAAA,SAAA,IAAA,OAAA,KAAA,QAAA,KAAA,KAAA,wDAAA,IAAA,KAAA,CAAA,CAAA,KAAA,KAAA,KAAA,GAAA,6DAAA,QAAA,KAAA,CAAA,KAAA,kDAAA,OAAA,EAAA,CAAA,CAAA;;;;;AAW7C,SAAU,0BAAiB,OAAA;SAEzB,SACE,QACA,aACE;CACJ,MAAM,6EAA8B;AACpC,QAAO;kDAAe,+EAAiC,EAC5C,SACV,CAAC;kDAAI,0DAAA,EAAA,CAAA;kDAAA,4DAAA;GACJ,IAAI,UAAU;AACZ,WAAE,OAAY,QAAQ,MAAA,kDAAoB,QAAG,CAAA,GAAS,QAAG,SAAA,KAAA,qEAAA,QAAA,GAAA,wHAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA;;GAE3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ACzC,CAAC;;EAEJ,IAAE,WAAA;AACH,UAAA;oDAAA,0DAAA,EAAA,CAAA;oDAAA,+EAAA,EACH;;;KAEiB;KACf,QAAc,mBAAA;KACR,IAAI,WAAA;AACV,aAAA,iDAAA,8EAAA,EACS,SACX,CAAA,kDAAA,kCAAA;;OAEE,IAAA,WAAA;AACY,eAAO,mBAAA,8IAAiC,QAAA,MAAA;;;OAG5C,CAAA,CAAA;;KAEH,CAAC;IAAA;;EAEL,CAAC,CAAA,kDAAS,oBAAA;EACT,IAAE,OAAQ;AACR,UAAG,OAAO,OAAW,QAAC,SAAA;;EAExB,WAAS,0DAAE,qBAAA;GACX,IAAA,OAAA;AACD,WAAA,MAAA;;GAEC,IAAA,WAAgB;AACd,2DAAY,cAAA,EACV,SAAU,OACV,CAAA;;GAEJ,IAAA,WAAA;AACD,2DAAA,8DAAA,EACK,SAAA,OACD,CAAA;;GAEF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-router.cjs","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":";;;;;;;;;;;;;AA8BA,SAAc,qBAAqB;CACnC,MAAQ,8DAAqB;AAC7B,QAAO;kDAAO,qBAAoB;;AAE5B,WAAC,CAAA,QAAS;;;AAGd,2DAAO,gGAAA;KACJ,IAAA,OAAA;AACE,aAAU,2DAAoB,QAAA,KAAA;;KAE7B,IAAE,aAAe;AACf,aAAA,KAAY,QAAI,SAAA,QAAA,YAAA,0DAAA,QAAA,CAAA,CAAA,QAAA,SAAA,QAAA,YAAA,0DAAA,QAAA,CAAA,CAAA,SAAA;;KAElB,YAAM;KACP,CAAC;;GAEL,CAAC;kDAAQ,OAAA,EAAA,CAAA;6CAAA,mBAAA,kEAAA,QAAA,KAAA,CAAA,SAAA;EAAA;;;;;AAWZ,SAAY,cAAQ,OAAA;CAClB,MAAA,EACA,UACF,oBAEE;CACA,MAAK,2CAAwB,KAAA,SAAA,UAAA,GAAA;AAC7B,wDAAA,qBAAA;EACF,IAAO,OAAQ;AACb,UAAQ,YAAU,OAAU,KAAO,SAAQ,CAAA,SAAA;;EAE3C,IAAM,WAAQ;;;KAER,OAAC;KACJ,MAAS;KACP,MAAA;KACC,aAAA,mBAAA;KACD,CAAC;oDAAa,0DAAA,EAAA,CAAA;oDAAA,qBAAA;KACb,IAAI,OAAE;AACN,aAAA,YAAqB,OAAC,KAAA,SAAA,CAAA,SAAA;;KAEvB,IAAA,WAAS;AACT,aAAU,iDAAmB,kCAAM;OACjC,IAAA,YAAA;AACC,eA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