@shell-shock/preset-script 0.6.63 → 0.6.66

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 (41) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/components/bin-entry.cjs +149 -3
  3. package/dist/components/bin-entry.d.cts.map +1 -1
  4. package/dist/components/bin-entry.d.mts.map +1 -1
  5. package/dist/components/bin-entry.mjs +145 -3
  6. package/dist/components/bin-entry.mjs.map +1 -1
  7. package/dist/components/command-entry.cjs +205 -3
  8. package/dist/components/command-entry.d.mts.map +1 -1
  9. package/dist/components/command-entry.mjs +200 -3
  10. package/dist/components/command-entry.mjs.map +1 -1
  11. package/dist/components/command-router.cjs +159 -2
  12. package/dist/components/command-router.d.cts.map +1 -1
  13. package/dist/components/command-router.d.mts.map +1 -1
  14. package/dist/components/command-router.mjs +156 -2
  15. package/dist/components/command-router.mjs.map +1 -1
  16. package/dist/components/exit-function-declaration.cjs +112 -6
  17. package/dist/components/exit-function-declaration.d.cts +1 -3
  18. package/dist/components/exit-function-declaration.d.cts.map +1 -1
  19. package/dist/components/exit-function-declaration.d.mts +1 -3
  20. package/dist/components/exit-function-declaration.d.mts.map +1 -1
  21. package/dist/components/exit-function-declaration.mjs +111 -6
  22. package/dist/components/exit-function-declaration.mjs.map +1 -1
  23. package/dist/components/index.cjs +18 -1
  24. package/dist/components/index.mjs +7 -1
  25. package/dist/components/virtual-command-entry.cjs +156 -1
  26. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  27. package/dist/components/virtual-command-entry.mjs +152 -1
  28. package/dist/components/virtual-command-entry.mjs.map +1 -1
  29. package/dist/helpers/get-global-options.cjs +73 -1
  30. package/dist/helpers/get-global-options.d.cts.map +1 -1
  31. package/dist/helpers/get-global-options.d.mts.map +1 -1
  32. package/dist/helpers/get-global-options.mjs +71 -1
  33. package/dist/helpers/get-global-options.mjs.map +1 -1
  34. package/dist/index.cjs +123 -1
  35. package/dist/index.d.mts.map +1 -1
  36. package/dist/index.mjs +117 -1
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/types/index.mjs +1 -1
  39. package/dist/types/plugin.d.mts.map +1 -1
  40. package/dist/types/plugin.mjs +1 -1
  41. package/package.json +17 -17
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1,4 +1,29 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./exit-function-declaration.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@alloy-js/core`),i=require(`@alloy-js/typescript`),a=require(`@powerlines/plugin-alloy/core/components/spacing`),o=require(`@powerlines/plugin-alloy/core/contexts/context`),s=require(`@powerlines/plugin-alloy/typescript/components/entry-file`),c=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),l=require(`@shell-shock/core/plugin-utils`),u=require(`@stryke/helpers/get-unique`),d=require(`@stryke/path/file-path-fns`),f=require(`@stryke/path/replace`),p=require(`@stryke/string-format/pascal-case`),m=require(`defu`);m=e.__toESM(m);function h(){return[(0,n.createComponent)(a.Spacing,{}),r.code`// Run the application main logic inside an asynchronous IIFE
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_components_exit_function_declaration = require('./exit-function-declaration.cjs');
4
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let _alloy_js_core = require("@alloy-js/core");
6
+ let _alloy_js_typescript = require("@alloy-js/typescript");
7
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
8
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let _powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
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_helpers_get_unique = require("@stryke/helpers/get-unique");
13
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
14
+ let _stryke_path_replace = require("@stryke/path/replace");
15
+ let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
16
+ let defu = require("defu");
17
+ defu = require_runtime.__toESM(defu);
18
+
19
+ //#region src/components/bin-entry.tsx
20
+ /**
21
+ * Runs the application main logic with proper exit handling.
22
+ */
23
+ function RunApplication() {
24
+ return [
25
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
26
+ _alloy_js_core.code`// Run the application main logic inside an asynchronous IIFE
2
27
  (async () => {
3
28
  const startDate = new Date();
4
29
  try {
@@ -64,5 +89,126 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
64
89
  exit({ startDate, exception: err as Error });
65
90
  }
66
91
  })();
67
- `,(0,n.createIntrinsic)(`hbr`,{})]}function g(e){let{prefix:g,postfix:_,builtinImports:v,imports:y,children:b,...x}=e,S=(0,o.usePowerlines)(),C=(0,r.computed)(()=>(0,u.getUnique)(Object.values(S.config.bin)));return(0,n.createComponent)(r.For,{get each(){return C.value},children:e=>(0,n.createComponent)(s.EntryFile,(0,n.mergeProps)(x,{get path(){return(0,d.findFileName)((0,f.replaceExtension)(e))},typeDefinition:{file:e,output:`bin`,input:{file:e}},get imports(){return(0,m.default)(y??{},Object.entries(S.commands).filter(([,e])=>e.isVirtual).reduce((e,[t,n])=>(e[`./${n.name}`]=[{name:`handler`,alias:`handle${(0,p.pascalCase)(t)}`}],e),{}))},get builtinImports(){return(0,m.default)(v??{},{env:[`env`,`isDevelopment`,`isDebug`],console:[`verbose`,`table`,`writeLine`,`borderColors`,`textColors`,`stripAnsi`,`error`,`warn`],utils:[`isUnicodeSupported`,`findSuggestions`],state:[`withGlobal`,`useGlobal`,`hasFlag`],help:[`showHelp`],banner:[`showBanner`]})},get children(){return[(0,n.createComponent)(t.ExitFunctionDeclaration,{}),(0,n.createComponent)(a.Spacing,{}),(0,n.createComponent)(r.Show,{get when(){return!!g},get children(){return[g,(0,n.createComponent)(a.Spacing,{})]}}),(0,n.createComponent)(c.TSDoc,{get heading(){return`Binary entry point for the ${(0,l.getAppTitle)(S,!0)} command-line interface application.`},get children(){return[(0,n.createComponent)(c.TSDocRemarks,{get children(){return`This file serves as the main entry point for the binary executable of the ${(0,l.getAppTitle)(S,!0)} 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.`}}),(0,n.createComponent)(c.TSDocReturns,{children:`Returns a promise that resolves to either a successful result or an error object.`})]}}),(0,n.createComponent)(i.FunctionDeclaration,{async:!0,returnType:`any | { error: string | Error }`,name:`main`,get children(){return[(0,n.createComponent)(i.IfStatement,{condition:r.code`hasFlag(["version", "v"])`,get children(){return r.code`console.log(${S?.packageJson.version?`"${S?.packageJson.version}"`:`0.0.1`});
68
- return; `}}),(0,n.createComponent)(a.Spacing,{}),b,(0,n.createIntrinsic)(`hbr`,{})]}}),(0,n.createIntrinsic)(`hbr`,{}),(0,n.createIntrinsic)(`hbr`,{}),(0,n.createIntrinsic)(`hbr`,{}),(0,n.createComponent)(r.Show,{get when(){return!!_},get fallback(){return(0,n.createComponent)(h,{})},children:_}),(0,n.createIntrinsic)(`hbr`,{})]}}))})}exports.BinEntry=g,exports.RunApplication=h;
92
+ `,
93
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
94
+ ];
95
+ }
96
+ /**
97
+ * The binary entry point for the Shell Shock project.
98
+ */
99
+ function BinEntry(props) {
100
+ const { prefix, postfix, builtinImports, imports, children, ...rest } = props;
101
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
102
+ const bins = (0, _alloy_js_core.computed)(() => (0, _stryke_helpers_get_unique.getUnique)(Object.values(context.config.bin)));
103
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
104
+ get each() {
105
+ return bins.value;
106
+ },
107
+ children: (bin) => (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_entry_file.EntryFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
108
+ get path() {
109
+ return (0, _stryke_path_file_path_fns.findFileName)((0, _stryke_path_replace.replaceExtension)(bin));
110
+ },
111
+ typeDefinition: {
112
+ file: bin,
113
+ output: "bin",
114
+ input: { file: bin }
115
+ },
116
+ get imports() {
117
+ return (0, defu.default)(imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.virtual).reduce((ret, [name, command]) => {
118
+ ret[`./${command.name}`] = [{
119
+ name: "handler",
120
+ alias: `handle${(0, _stryke_string_format_pascal_case.pascalCase)(name)}`
121
+ }];
122
+ return ret;
123
+ }, {}));
124
+ },
125
+ get builtinImports() {
126
+ return (0, defu.default)(builtinImports ?? {}, {
127
+ env: [
128
+ "env",
129
+ "isDevelopment",
130
+ "isDebug"
131
+ ],
132
+ console: [
133
+ "verbose",
134
+ "table",
135
+ "writeLine",
136
+ "borderColors",
137
+ "textColors",
138
+ "stripAnsi",
139
+ "error",
140
+ "warn"
141
+ ],
142
+ utils: ["isUnicodeSupported", "findSuggestions"],
143
+ state: [
144
+ "withGlobal",
145
+ "useGlobal",
146
+ "hasFlag"
147
+ ],
148
+ help: ["showHelp"],
149
+ banner: ["showBanner"]
150
+ });
151
+ },
152
+ get children() {
153
+ return [
154
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_exit_function_declaration.ExitFunctionDeclaration, {}),
155
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
156
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
157
+ get when() {
158
+ return Boolean(prefix);
159
+ },
160
+ get children() {
161
+ return [prefix, (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})];
162
+ }
163
+ }),
164
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
165
+ get heading() {
166
+ return `Binary entry point for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application.`;
167
+ },
168
+ get children() {
169
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { get children() {
170
+ return `This file serves as the main entry point for the binary executable of the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`;
171
+ } }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `Returns a promise that resolves to either a successful result or an error object.` })];
172
+ }
173
+ }),
174
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
175
+ async: true,
176
+ returnType: "any | { error: string | Error }",
177
+ name: "main",
178
+ get children() {
179
+ return [
180
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
181
+ condition: _alloy_js_core.code`hasFlag(["version", "v"])`,
182
+ get children() {
183
+ return _alloy_js_core.code`console.log(${context?.packageJson.version ? `"${context?.packageJson.version}"` : "0.0.1"});
184
+ return; `;
185
+ }
186
+ }),
187
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
188
+ children,
189
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
190
+ ];
191
+ }
192
+ }),
193
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
194
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
195
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
196
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
197
+ get when() {
198
+ return Boolean(postfix);
199
+ },
200
+ get fallback() {
201
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(RunApplication, {});
202
+ },
203
+ children: postfix
204
+ }),
205
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
206
+ ];
207
+ }
208
+ }))
209
+ });
210
+ }
211
+
212
+ //#endregion
213
+ exports.BinEntry = BinEntry;
214
+ exports.RunApplication = RunApplication;
@@ -1 +1 @@
1
- {"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"mappings":";;;;;;AA4CA;iBAAgB,cAAA,CAAA,GAAc,QAAA;AAAA,UA4Eb,aAAA,SAAsB,IAAA,CACrC,cAAA;EAGA,MAAA,GAAS,QAAA;EACT,OAAA,GAAU,QAAA;EACV,QAAA,EAAU,QAAA;AAAA;;;;iBAMI,QAAA,CAAS,KAAA,EAAO,aAAA,GAAa,QAAA"}
1
+ {"version":3,"file":"bin-entry.d.cts","names":[],"sources":["../../src/components/bin-entry.tsx"],"mappings":";;;;;;AA4CA;iBAAgB,cAAA,IAAc,QAAA;AAAA,UA4Eb,aAAA,SAAsB,IAAA,CACrC,cAAA;EAGA,MAAA,GAAS,QAAA;EACT,OAAA,GAAU,QAAA;EACV,QAAA,EAAU,QAAA;AAAA;;;;iBAMI,QAAA,CAAS,KAAA,EAAO,aAAA,GAAa,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"bin-entry.d.mts","names":[],"sources":["../../src/components/bin-entry.tsx"],"mappings":";;;;;;AA4CA;iBAAgB,cAAA,CAAA,GAAc,QAAA;AAAA,UA4Eb,aAAA,SAAsB,IAAA,CACrC,cAAA;EAGA,MAAA,GAAS,QAAA;EACT,OAAA,GAAU,QAAA;EACV,QAAA,EAAU,QAAA;AAAA;;;;iBAMI,QAAA,CAAS,KAAA,EAAO,aAAA,GAAa,QAAA"}
1
+ {"version":3,"file":"bin-entry.d.mts","names":[],"sources":["../../src/components/bin-entry.tsx"],"mappings":""}
@@ -1,4 +1,26 @@
1
- import{ExitFunctionDeclaration as e}from"./exit-function-declaration.mjs";import{createComponent as t,createIntrinsic as n,mergeProps as r}from"@alloy-js/core/jsx-runtime";import{For as i,Show as a,code as o,computed as s}from"@alloy-js/core";import{FunctionDeclaration as c,IfStatement as l}from"@alloy-js/typescript";import{Spacing as u}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as d}from"@powerlines/plugin-alloy/core/contexts/context";import{EntryFile as f}from"@powerlines/plugin-alloy/typescript/components/entry-file";import{TSDoc as p,TSDocRemarks as m,TSDocReturns as h}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{getAppTitle as g}from"@shell-shock/core/plugin-utils";import{getUnique as _}from"@stryke/helpers/get-unique";import{findFileName as v}from"@stryke/path/file-path-fns";import{replaceExtension as y}from"@stryke/path/replace";import{pascalCase as b}from"@stryke/string-format/pascal-case";import x from"defu";function S(){return[t(u,{}),o`// Run the application main logic inside an asynchronous IIFE
1
+ import { ExitFunctionDeclaration } from "./exit-function-declaration.mjs";
2
+ import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
3
+ import { For, Show, code, computed } from "@alloy-js/core";
4
+ import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
5
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
+ import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
8
+ import { TSDoc, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
9
+ import { getAppTitle } from "@shell-shock/core/plugin-utils";
10
+ import { getUnique } from "@stryke/helpers/get-unique";
11
+ import { findFileName } from "@stryke/path/file-path-fns";
12
+ import { replaceExtension } from "@stryke/path/replace";
13
+ import { pascalCase } from "@stryke/string-format/pascal-case";
14
+ import defu from "defu";
15
+
16
+ //#region src/components/bin-entry.tsx
17
+ /**
18
+ * Runs the application main logic with proper exit handling.
19
+ */
20
+ function RunApplication() {
21
+ return [
22
+ createComponent(Spacing, {}),
23
+ code`// Run the application main logic inside an asynchronous IIFE
2
24
  (async () => {
3
25
  const startDate = new Date();
4
26
  try {
@@ -64,6 +86,126 @@ import{ExitFunctionDeclaration as e}from"./exit-function-declaration.mjs";import
64
86
  exit({ startDate, exception: err as Error });
65
87
  }
66
88
  })();
67
- `,n(`hbr`,{})]}function C(C){let{prefix:w,postfix:T,builtinImports:E,imports:D,children:O,...k}=C,A=d(),j=s(()=>_(Object.values(A.config.bin)));return t(i,{get each(){return j.value},children:i=>t(f,r(k,{get path(){return v(y(i))},typeDefinition:{file:i,output:`bin`,input:{file:i}},get imports(){return x(D??{},Object.entries(A.commands).filter(([,e])=>e.isVirtual).reduce((e,[t,n])=>(e[`./${n.name}`]=[{name:`handler`,alias:`handle${b(t)}`}],e),{}))},get builtinImports(){return x(E??{},{env:[`env`,`isDevelopment`,`isDebug`],console:[`verbose`,`table`,`writeLine`,`borderColors`,`textColors`,`stripAnsi`,`error`,`warn`],utils:[`isUnicodeSupported`,`findSuggestions`],state:[`withGlobal`,`useGlobal`,`hasFlag`],help:[`showHelp`],banner:[`showBanner`]})},get children(){return[t(e,{}),t(u,{}),t(a,{get when(){return!!w},get children(){return[w,t(u,{})]}}),t(p,{get heading(){return`Binary entry point for the ${g(A,!0)} command-line interface application.`},get children(){return[t(m,{get children(){return`This file serves as the main entry point for the binary executable of the ${g(A,!0)} 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.`}}),t(h,{children:`Returns a promise that resolves to either a successful result or an error object.`})]}}),t(c,{async:!0,returnType:`any | { error: string | Error }`,name:`main`,get children(){return[t(l,{condition:o`hasFlag(["version", "v"])`,get children(){return o`console.log(${A?.packageJson.version?`"${A?.packageJson.version}"`:`0.0.1`});
68
- return; `}}),t(u,{}),O,n(`hbr`,{})]}}),n(`hbr`,{}),n(`hbr`,{}),n(`hbr`,{}),t(a,{get when(){return!!T},get fallback(){return t(S,{})},children:T}),n(`hbr`,{})]}}))})}export{C as BinEntry,S as RunApplication};
89
+ `,
90
+ createIntrinsic("hbr", {})
91
+ ];
92
+ }
93
+ /**
94
+ * The binary entry point for the Shell Shock project.
95
+ */
96
+ function BinEntry(props) {
97
+ const { prefix, postfix, builtinImports, imports, children, ...rest } = props;
98
+ const context = usePowerlines();
99
+ const bins = computed(() => getUnique(Object.values(context.config.bin)));
100
+ return createComponent(For, {
101
+ get each() {
102
+ return bins.value;
103
+ },
104
+ children: (bin) => createComponent(EntryFile, mergeProps(rest, {
105
+ get path() {
106
+ return findFileName(replaceExtension(bin));
107
+ },
108
+ typeDefinition: {
109
+ file: bin,
110
+ output: "bin",
111
+ input: { file: bin }
112
+ },
113
+ get imports() {
114
+ return defu(imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.virtual).reduce((ret, [name, command]) => {
115
+ ret[`./${command.name}`] = [{
116
+ name: "handler",
117
+ alias: `handle${pascalCase(name)}`
118
+ }];
119
+ return ret;
120
+ }, {}));
121
+ },
122
+ get builtinImports() {
123
+ return defu(builtinImports ?? {}, {
124
+ env: [
125
+ "env",
126
+ "isDevelopment",
127
+ "isDebug"
128
+ ],
129
+ console: [
130
+ "verbose",
131
+ "table",
132
+ "writeLine",
133
+ "borderColors",
134
+ "textColors",
135
+ "stripAnsi",
136
+ "error",
137
+ "warn"
138
+ ],
139
+ utils: ["isUnicodeSupported", "findSuggestions"],
140
+ state: [
141
+ "withGlobal",
142
+ "useGlobal",
143
+ "hasFlag"
144
+ ],
145
+ help: ["showHelp"],
146
+ banner: ["showBanner"]
147
+ });
148
+ },
149
+ get children() {
150
+ return [
151
+ createComponent(ExitFunctionDeclaration, {}),
152
+ createComponent(Spacing, {}),
153
+ createComponent(Show, {
154
+ get when() {
155
+ return Boolean(prefix);
156
+ },
157
+ get children() {
158
+ return [prefix, createComponent(Spacing, {})];
159
+ }
160
+ }),
161
+ createComponent(TSDoc, {
162
+ get heading() {
163
+ return `Binary entry point for the ${getAppTitle(context, true)} command-line interface application.`;
164
+ },
165
+ get children() {
166
+ return [createComponent(TSDocRemarks, { get children() {
167
+ return `This file serves as the main entry point for the binary executable of the ${getAppTitle(context, true)} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`;
168
+ } }), createComponent(TSDocReturns, { children: `Returns a promise that resolves to either a successful result or an error object.` })];
169
+ }
170
+ }),
171
+ createComponent(FunctionDeclaration, {
172
+ async: true,
173
+ returnType: "any | { error: string | Error }",
174
+ name: "main",
175
+ get children() {
176
+ return [
177
+ createComponent(IfStatement, {
178
+ condition: code`hasFlag(["version", "v"])`,
179
+ get children() {
180
+ return code`console.log(${context?.packageJson.version ? `"${context?.packageJson.version}"` : "0.0.1"});
181
+ return; `;
182
+ }
183
+ }),
184
+ createComponent(Spacing, {}),
185
+ children,
186
+ createIntrinsic("hbr", {})
187
+ ];
188
+ }
189
+ }),
190
+ createIntrinsic("hbr", {}),
191
+ createIntrinsic("hbr", {}),
192
+ createIntrinsic("hbr", {}),
193
+ createComponent(Show, {
194
+ get when() {
195
+ return Boolean(postfix);
196
+ },
197
+ get fallback() {
198
+ return createComponent(RunApplication, {});
199
+ },
200
+ children: postfix
201
+ }),
202
+ createIntrinsic("hbr", {})
203
+ ];
204
+ }
205
+ }))
206
+ });
207
+ }
208
+
209
+ //#endregion
210
+ export { BinEntry, RunApplication };
69
211
  //# sourceMappingURL=bin-entry.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bin-entry.mjs","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 type { CommandTree } from \"@shell-shock/core/types/command\";\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<string[]>(() =>\n getUnique(Object.values(context.config.bin))\n );\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 input: {\n file: bin\n }\n }}\n imports={defu(\n imports ?? {},\n Object.entries(context.commands as Record<string, CommandTree>)\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":"y9BAoCA,SAAS,GAAoB,CAC7B,MAAO,CAAA,EAAgB,EAAA,EAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkEd,EAAkB,MAAM,EAAA,CAAI,CAAC,eAMpC,GAAM,CACJ,SACA,UACA,iBACA,UACA,WACA,GAAG,GACD,EACH,EAAA,GAAA,CACH,EAAA,MAAA,EAAA,OAAA,OAAA,EAAA,OAAA,IAAA,CAAA,CAAA,aAEA,IAAO,MAAA,CACL,OAAA,EAAc,OAEd,SAAA,GAAA,EAAA,EAAA,EAAA,EAAA,CACA,IAAQ,MAAC,CACT,OAAU,EAAQ,EAAA,EAAA,CAAA,EAEpB,eAAA,QAEE,OAAA,MACK,MAAO,CACZ,KAAA,EACK,CACA,eAEC,OAAO,EAAG,GAAa,EAAC,CAAA,OAAA,QAAA,EAAsB,SAAA,CAAA,QAAA,EAAA,KAAA,EAAA,UAAA,CAAA,QAAA,EAAA,CAAA,EAAA,MAC9C,EAAM,KAAC,EAAS,QAAa,CAAC,CAClC,KAAU,UACX,MAAA,SAAA,EAAA,EAAA,KAEM,GACA,EAAI,CAAC,CAAC,EAET,IAAG,gBAAA,CACD,OAAM,EAAI,GAAA,EAAA,CAAA,CACR,IAAK,CAAC,MAAA,gBAAa,UAAqB,CACxC,QAAA,CAAA,UAAgB,QAAA,YAAA,eAAA,aAAA,YAAA,QAAA,OAAA,CAChB,MAAO,CAAC,qBAAG,kBAAA,CACX,MAAE,CAAM,aAAO,YAAA,UAAA,CACf,KAAE,CAAK,WAAE,CACT,OAAQ,CAAC,aAAC,CACX,CAAC,EAEJ,IAAI,UAAS,CACX,MAAI,CAAA,EAAa,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACf,IAAE,MAAO,CACP,MAAG,EAAW,GAEhB,IAAI,UAAW,CACb,MAAO,CAAC,EAAO,EAAkB,EAAQ,EAAA,CAAA,CAAA,SAG3C,IAAI,SAAS,CACX,MAAO,8BAAyB,EAAA,EAAA,GAAA,CAAA,uCAElC,IAAA,UAAe,CACb,MAAO,CAAA,EAAO,EAA0B,CACxC,IAAA,UAAS,CACN,MAAQ,6EAAA,EAAA,EAAA,GAAA,CAAA,waAEV,CAAC,CAAC,EAAU,EAAA,CACX,SAAC,oFACF,CAAC,CAAC,EAEN,CAAC,CAAE,EAAS,EAAA,CACX,MAAK,GACL,WAAG,kCACH,KAAE,OACF,IAAE,UAAS,CACT,MAAO,CAAC,EAAU,EAAA,CAClB,UAAU,CAAA,4BACT,IAAA,UAAA,CACF,MAAA,EAAA,eAAyB,GAAA,YAAA,QAAA,IAAA,GAAA,YAAA,QAAA,GAAA,QAAA;yBAGvB,CAAA,CAAA,EAAM,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,MAAA,EAAA,CAAA,CAAA,EAEV,CAAC,CAAE,EAAI,MAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACN,IAAC,MAAA,CACC,MAAO,EAAG,GAEZ,IAAI,UAAA,CACF,OAAG,EAAsB,EAAe,EAAA,CAAA,EAE1C,SAAU,EACX,CAAC,CAAE,EAAW,MAAA,EAAA,CAAA,CAAA,EAElB,CAAC,CAAC,CACJ,CAAC"}
1
+ {"version":3,"file":"bin-entry.mjs","names":[],"sources":[],"mappings":""}
@@ -1,4 +1,206 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./virtual-command-entry.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@alloy-js/core`),i=require(`@alloy-js/typescript`),a=require(`@powerlines/plugin-alloy/core/components/spacing`),o=require(`@powerlines/plugin-alloy/core/contexts/context`),s=require(`@powerlines/plugin-alloy/typescript/components/entry-file`),c=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),l=require(`@shell-shock/core/plugin-utils`),u=require(`@stryke/path/replace`),d=require(`@stryke/string-format/pascal-case`),f=require(`defu`);f=e.__toESM(f);let p=require(`@shell-shock/core/components/helpers`),m=require(`@shell-shock/core/components/command-validation-logic`),h=require(`@shell-shock/core/components/options-parser-logic`),g=require(`@stryke/path/find`),_=require(`@stryke/path/join`),v=require(`@stryke/string-format/camel-case`),y=require(`@stryke/string-format/constant-case`),b=require(`@stryke/string-format/kebab-case`);function x(e){let{command:t}=e;return[(0,n.memo)(()=>r.code` return withCommand("${t.path}", [${t.segments.map(e=>(0,l.isDynamicPathSegment)(e)?(0,v.camelCase)((0,l.getDynamicPathSegmentName)(e)):`"${e}"`).join(`, `)}], [${Object.keys(t.options).length>0?`options`:``}${t.args.length>0?`${Object.keys(t.options).length>0?`, `:``}${t.args.map(e=>(0,v.camelCase)(e.name)).join(`, `)}`:``}], handle${(0,d.pascalCase)(t.name)}); `),(0,n.createIntrinsic)(`hbr`,{})]}function S(e){let{command:t,banner:s,children:u}=e,d=(0,o.usePowerlines)();return[(0,n.createComponent)(h.OptionsInterfaceDeclaration,{command:t}),(0,n.createComponent)(a.Spacing,{}),(0,n.createComponent)(c.TSDoc,{get heading(){return`The ${t.title} (${(0,l.getAppBin)(d)} ${t.segments.map(e=>(0,l.isDynamicPathSegment)(e)?`[${(0,y.constantCase)((0,l.getDynamicPathSegmentName)(e))}]`:e).join(` `)}) command.`},get children(){return[(0,n.createComponent)(c.TSDocRemarks,{get children(){return`${t.description.replace(/\.+$/,``)}.`}}),(0,n.createIntrinsic)(`hbr`,{}),(0,n.createComponent)(c.TSDocTitle,{get children(){return t.title}}),(0,n.createComponent)(c.TSDocParam,{name:`args`,children:`The command-line arguments passed to the command.`})]}}),(0,n.createComponent)(i.FunctionDeclaration,{export:!0,async:!0,name:`handler`,parameters:[{name:`args`,type:`string[]`,default:`useArgs()`}],get children(){return[(0,n.createComponent)(h.CommandParserLogic,{command:t,get appSpecificEnvPrefix(){return d.config.appSpecificEnvPrefix},get isCaseSensitive(){return d.config.isCaseSensitive}}),(0,n.createComponent)(a.Spacing,{}),(0,n.createComponent)(r.Show,{get when(){return!!s},children:s}),(0,n.createComponent)(a.Spacing,{}),r.code`writeLine("");`,(0,n.createComponent)(i.IfStatement,{get condition(){return(0,n.createComponent)(p.IsDebug,{})},get children(){return r.code`writeLine(textColors.body.tertiary("Debug mode is enabled. Additional debug information may be logged to the console."));
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
4
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let _alloy_js_core = require("@alloy-js/core");
6
+ let _alloy_js_typescript = require("@alloy-js/typescript");
7
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
8
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let _powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
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_path_replace = require("@stryke/path/replace");
13
+ let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
14
+ let defu = require("defu");
15
+ defu = require_runtime.__toESM(defu);
16
+ let _shell_shock_core_components_helpers = require("@shell-shock/core/components/helpers");
17
+ let _shell_shock_core_components_command_validation_logic = require("@shell-shock/core/components/command-validation-logic");
18
+ let _shell_shock_core_components_options_parser_logic = require("@shell-shock/core/components/options-parser-logic");
19
+ let _stryke_path_find = require("@stryke/path/find");
20
+ let _stryke_path_join = require("@stryke/path/join");
21
+ let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
22
+ let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
23
+ let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
24
+
25
+ //#region src/components/command-entry.tsx
26
+ function CommandInvocation(props) {
27
+ const { command } = props;
28
+ return [(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code` return withCommand("${command.path}", [${command.segments.map((segment) => (0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? (0, _stryke_string_format_camel_case.camelCase)((0, _shell_shock_core_plugin_utils.getDynamicPathSegmentName)(segment)) : `"${segment}"`).join(", ")}], [${Object.keys(command.options).length > 0 ? `options` : ""}${command.args.length > 0 ? `${Object.keys(command.options).length > 0 ? ", " : ""}${command.args.map((arg) => (0, _stryke_string_format_camel_case.camelCase)(arg.name)).join(", ")}` : ""}], handle${(0, _stryke_string_format_pascal_case.pascalCase)(command.name)}); `), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
29
+ }
30
+ /**
31
+ * A component that generates the `handler` function declaration for a command.
32
+ */
33
+ function CommandHandlerDeclaration(props) {
34
+ const { command, banner, children } = props;
35
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
36
+ return [
37
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_options_parser_logic.OptionsInterfaceDeclaration, { command }),
38
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
40
+ get heading() {
41
+ 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(" ")}) command.`;
42
+ },
43
+ get children() {
44
+ return [
45
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { get children() {
46
+ return `${command.description.replace(/\.+$/, "")}.`;
47
+ } }),
48
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
49
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocTitle, { get children() {
50
+ return command.title;
51
+ } }),
52
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
53
+ name: "args",
54
+ children: `The command-line arguments passed to the command.`
55
+ })
56
+ ];
57
+ }
58
+ }),
59
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
60
+ "export": true,
61
+ async: true,
62
+ name: "handler",
63
+ parameters: [{
64
+ name: "args",
65
+ type: "string[]",
66
+ default: "useArgs()"
67
+ }],
68
+ get children() {
69
+ return [
70
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_options_parser_logic.CommandParserLogic, {
71
+ command,
72
+ get appSpecificEnvPrefix() {
73
+ return context.config.appSpecificEnvPrefix;
74
+ },
75
+ get isCaseSensitive() {
76
+ return context.config.isCaseSensitive;
77
+ }
78
+ }),
79
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
80
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
81
+ get when() {
82
+ return Boolean(banner);
83
+ },
84
+ children: banner
85
+ }),
86
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
87
+ _alloy_js_core.code`writeLine("");`,
88
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
89
+ get condition() {
90
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_helpers.IsDebug, {});
91
+ },
92
+ get children() {
93
+ return _alloy_js_core.code`writeLine(textColors.body.tertiary("Debug mode is enabled. Additional debug information may be logged to the console."));
2
94
  writeLine("");
3
- debug(\`Command path: ${t.segments.map(e=>(0,l.isDynamicPathSegment)(e)?`\${${(0,v.camelCase)((0,l.getDynamicPathSegmentName)(e))}}`:e).join(` / `)} \\n\\nOptions: \\n${Object.values(t.options).map(e=>` - ${(0,b.kebabCase)(e.name)}: \${options.${(0,v.camelCase)(e.name)} === undefined ? "" : JSON.stringify(options.${(0,v.camelCase)(e.name)})}`).join(`\\n`)}${t.args.length>0?` \\n\\nArguments: \\n${t.args.map(e=>` - ${(0,b.kebabCase)(e.name)}: \${${(0,v.camelCase)(e.name)} === undefined ? "" : JSON.stringify(${(0,v.camelCase)(e.name)})}`).join(`\\n`)}`:``}\`); `}}),(0,n.createComponent)(a.Spacing,{}),u,(0,n.createComponent)(a.Spacing,{}),(0,n.createComponent)(i.IfStatement,{condition:r.code`options.help`,children:r.code`return showHelp(); `}),(0,n.createComponent)(i.ElseClause,{get children(){return[(0,n.createIntrinsic)(`hbr`,{}),(0,n.createComponent)(x,{command:t})]}})]}})]}function C(e){let{command:c,imports:p,builtinImports:v,...y}=e,b=(0,o.usePowerlines)(),x=(0,r.computed)(()=>(0,_.joinPaths)(c.segments.filter(e=>!(0,l.isDynamicPathSegment)(e)).join(`/`),`index.ts`)),w=(0,r.computed)(()=>(0,u.replaceExtension)((0,g.relativePath)((0,_.joinPaths)(b.entryPath,(0,g.findFilePath)(x.value)),c.entry.input?.file||c.entry.file))),T=(0,r.computed)(()=>({...c.entry,output:c.id}));return[(0,n.createComponent)(s.EntryFile,(0,n.mergeProps)(y,{get path(){return x.value},get typeDefinition(){return T.value},get imports(){return(0,f.default)(p??{},{[w.value.startsWith(`.`)?w.value:`./${w.value}`]:`handle${(0,d.pascalCase)(c.name)}`})},get builtinImports(){return(0,f.default)(v??{},{env:[`env`,`isDevelopment`,`isDebug`],console:[`debug`,`warn`,`error`,`writeLine`,`textColors`],utils:[`isMinimal`,`isUnicodeSupported`],state:[{name:`GlobalOptions`,type:!0},`useGlobal`,`useGlobalOptions`,`useArgs`,`hasFlag`,`withCommand`],[(0,_.joinPaths)(`help`,...c.segments.filter(e=>!(0,l.isDynamicPathSegment)(e)))]:[`showHelp`],[(0,_.joinPaths)(`banner`,...c.segments.filter(e=>!(0,l.isDynamicPathSegment)(e)))]:[`showBanner`]})},get children(){return[(0,n.createComponent)(a.Spacing,{}),(0,n.createComponent)(h.OptionsInterfaceDeclaration,{command:c}),(0,n.createComponent)(a.Spacing,{}),(0,n.createComponent)(S,{command:c,banner:r.code`await showBanner(); `,get children(){return[(0,n.createComponent)(m.CommandValidationLogic,{command:c}),(0,n.createComponent)(i.IfStatement,{condition:r.code`failures.length > 0`,get children(){return r.code`error(\`The following validation failures were found while processing the user provided input, and must be corrected before the \${italic("${c.title}")} command can be executed: \\n\\n\${failures.map(failure => " - " + failure).join("\\n")}\`);
4
- options.help = true; `}})]}})]}})),(0,n.createComponent)(r.For,{get each(){return Object.values(c.children)},children:e=>(0,n.createComponent)(r.Show,{get when(){return e.isVirtual},get fallback(){return(0,n.createComponent)(C,{command:e})},get children(){return(0,n.createComponent)(t.VirtualCommandEntry,{command:e})}})})]}exports.CommandEntry=C,exports.CommandHandlerDeclaration=S,exports.CommandInvocation=x;
95
+ debug(\`Command path: ${command.segments.map((segment) => (0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? `\${${(0, _stryke_string_format_camel_case.camelCase)((0, _shell_shock_core_plugin_utils.getDynamicPathSegmentName)(segment))}}` : segment).join(" / ")} \\n\\nOptions: \\n${Object.values(command.options).map((option) => ` - ${(0, _stryke_string_format_kebab_case.kebabCase)(option.name)}: \${options.${(0, _stryke_string_format_camel_case.camelCase)(option.name)} === undefined ? "" : JSON.stringify(options.${(0, _stryke_string_format_camel_case.camelCase)(option.name)})}`).join("\\n")}${command.args.length > 0 ? ` \\n\\nArguments: \\n${command.args.map((arg) => ` - ${(0, _stryke_string_format_kebab_case.kebabCase)(arg.name)}: \${${(0, _stryke_string_format_camel_case.camelCase)(arg.name)} === undefined ? "" : JSON.stringify(${(0, _stryke_string_format_camel_case.camelCase)(arg.name)})}`).join("\\n")}` : ""}\`); `;
96
+ }
97
+ }),
98
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
99
+ children,
100
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
101
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
102
+ condition: _alloy_js_core.code`options.help`,
103
+ children: _alloy_js_core.code`return showHelp(); `
104
+ }),
105
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
106
+ return [(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}), (0, _alloy_js_core_jsx_runtime.createComponent)(CommandInvocation, { command })];
107
+ } })
108
+ ];
109
+ }
110
+ })
111
+ ];
112
+ }
113
+ /**
114
+ * The command entry point for the Shell Shock project.
115
+ */
116
+ function CommandEntry(props) {
117
+ const { command, imports, builtinImports, ...rest } = props;
118
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
119
+ const filePath = (0, _alloy_js_core.computed)(() => (0, _stryke_path_join.joinPaths)(command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)).join("/"), "index.ts"));
120
+ const commandSourcePath = (0, _alloy_js_core.computed)(() => (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_find.relativePath)((0, _stryke_path_join.joinPaths)(context.entryPath, (0, _stryke_path_find.findFilePath)(filePath.value)), command.entry.input?.file || command.entry.file)));
121
+ const typeDefinition = (0, _alloy_js_core.computed)(() => ({
122
+ ...command.entry,
123
+ output: command.id
124
+ }));
125
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_entry_file.EntryFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
126
+ get path() {
127
+ return filePath.value;
128
+ },
129
+ get typeDefinition() {
130
+ return typeDefinition.value;
131
+ },
132
+ get imports() {
133
+ return (0, defu.default)(imports ?? {}, { [commandSourcePath.value.startsWith(".") ? commandSourcePath.value : `./${commandSourcePath.value}`]: `handle${(0, _stryke_string_format_pascal_case.pascalCase)(command.name)}` });
134
+ },
135
+ get builtinImports() {
136
+ return (0, defu.default)(builtinImports ?? {}, {
137
+ env: [
138
+ "env",
139
+ "isDevelopment",
140
+ "isDebug"
141
+ ],
142
+ console: [
143
+ "debug",
144
+ "warn",
145
+ "error",
146
+ "writeLine",
147
+ "textColors"
148
+ ],
149
+ utils: ["isMinimal", "isUnicodeSupported"],
150
+ state: [
151
+ {
152
+ name: "GlobalOptions",
153
+ type: true
154
+ },
155
+ "useGlobal",
156
+ "useGlobalOptions",
157
+ "useArgs",
158
+ "hasFlag",
159
+ "withCommand"
160
+ ],
161
+ [(0, _stryke_path_join.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showHelp"],
162
+ [(0, _stryke_path_join.joinPaths)("banner", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showBanner"]
163
+ });
164
+ },
165
+ get children() {
166
+ return [
167
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
168
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_options_parser_logic.OptionsInterfaceDeclaration, { command }),
169
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
170
+ (0, _alloy_js_core_jsx_runtime.createComponent)(CommandHandlerDeclaration, {
171
+ command,
172
+ banner: _alloy_js_core.code`await showBanner(); `,
173
+ get children() {
174
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_command_validation_logic.CommandValidationLogic, { command }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
175
+ condition: _alloy_js_core.code`failures.length > 0`,
176
+ get children() {
177
+ return _alloy_js_core.code`error(\`The following validation failures were found while processing the user provided input, and must be corrected before the \${italic("${command.title}")} command can be executed: \\n\\n\${failures.map(failure => " - " + failure).join("\\n")}\`);
178
+ options.help = true; `;
179
+ }
180
+ })];
181
+ }
182
+ })
183
+ ];
184
+ }
185
+ })), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
186
+ get each() {
187
+ return Object.values(command.children);
188
+ },
189
+ children: (child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
190
+ get when() {
191
+ return child.virtual;
192
+ },
193
+ get fallback() {
194
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(CommandEntry, { command: child });
195
+ },
196
+ get children() {
197
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_virtual_command_entry.VirtualCommandEntry, { command: child });
198
+ }
199
+ })
200
+ })];
201
+ }
202
+
203
+ //#endregion
204
+ exports.CommandEntry = CommandEntry;
205
+ exports.CommandHandlerDeclaration = CommandHandlerDeclaration;
206
+ exports.CommandInvocation = CommandInvocation;
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":";;;;;iBA0DgB,iBAAA,CAAkB,KAAA;EAAS,OAAA,EAAS,WAAA;AAAA,IAAa,QAAA;AAAA,UAyBhD,8BAAA;EACf,OAAA,EAAS,WAAA;EACT,MAAA,GAAS,QAAA;EACT,QAAA,GAAW,QAAA;AAAA;;;;iBAMG,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,QAAA;AAAA,UAqFtB,iBAAA,SAA0B,IAAA,CACzC,cAAA;EAGA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,QAAA"}
1
+ {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":""}