@shell-shock/preset-script 0.6.63 → 0.6.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,153 @@
1
- import{CommandRouter as e}from"./command-router.mjs";import{CommandEntry as t}from"./command-entry.mjs";import{createComponent as n,createIntrinsic as r,mergeProps as i}from"@alloy-js/core/jsx-runtime";import{For as a,Show as o,code as s,computed as c}from"@alloy-js/core";import{FunctionDeclaration as l}from"@alloy-js/typescript";import{Spacing as u}from"@powerlines/plugin-alloy/core/components";import{usePowerlines as d}from"@powerlines/plugin-alloy/core/contexts/context";import{TSDoc as f,TSDocParam as p,TSDocRemarks as m,TSDocTitle as h}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{getAppBin as g,getDynamicPathSegmentName as _,isDynamicPathSegment as v}from"@shell-shock/core/plugin-utils";import{pascalCase as y}from"@stryke/string-format/pascal-case";import b from"defu";import{joinPaths as x}from"@stryke/path/join";import{constantCase as S}from"@stryke/string-format/constant-case";import{TypescriptFile as C}from"@powerlines/plugin-alloy/typescript/components/typescript-file";function w(e){let{command:t,children:i,banner:a}=e,c=d();return[n(f,{get heading(){return`The ${t.title} (${g(c)} ${t.segments.map(e=>v(e)?`[${S(_(e))}]`:e).join(` `)}) virtual command.`},get children(){return[n(m,{get children(){return`${t.description.replace(/\.+$/,``)}.`}}),r(`hbr`,{}),n(h,{get children(){return t.title}}),n(p,{name:`args`,children:`The command-line arguments passed to the command.`})]}}),n(l,{export:!0,async:!0,name:`handler`,parameters:[{name:`args`,type:`string[]`,default:`useArgs()`}],get children(){return[n(u,{}),i,n(u,{}),n(o,{get when(){return!!a},children:a}),n(u,{}),s`return showHelp(); `]}})]}function T(r){let{command:l,imports:f,builtinImports:p,...m}=r,h=d(),g=c(()=>x(h.entryPath,l.segments.filter(e=>!v(e)).join(`/`),`index.ts`));return[n(C,i(m,{get path(){return g.value},get imports(){return b(f??{},Object.entries(l.children).filter(([,e])=>e.isVirtual).reduce((e,[t,n])=>(e[`./${n.name}`]=[{name:`handler`,alias:`handle${y(t)}`}],e),{}))},get builtinImports(){return b(p??{},{env:[`isDevelopment`,`isDebug`],console:[`warn`,`error`,`writeLine`,`textColors`],utils:[`isMinimal`,`isUnicodeSupported`,`findSuggestions`],state:[{name:`GlobalOptions`,type:!0},`useGlobal`,`useGlobalOptions`,`withCommand`,`useArgs`,`hasFlag`],[x(`help`,...l.segments.filter(e=>!v(e)))]:[`showHelp`],[x(`banner`,...l.segments.filter(e=>!v(e)))]:[`showBanner`]})},get children(){return[n(u,{}),n(w,{command:l,banner:s`await showBanner(); `,get children(){return n(e,{get segments(){return l.segments},get commands(){return l.children}})}})]}})),n(a,{get each(){return Object.values(l.children)},children:e=>n(o,{get when(){return e.isVirtual},get fallback(){return n(t,{command:e})},get children(){return n(T,{command:e})}})})]}export{T as VirtualCommandEntry,w as VirtualCommandHandlerDeclaration};
1
+ import { CommandRouter } from "./command-router.mjs";
2
+ import { CommandEntry } from "./command-entry.mjs";
3
+ import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
4
+ import { For, Show, code, computed } from "@alloy-js/core";
5
+ import { FunctionDeclaration } from "@alloy-js/typescript";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core/components";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { TSDoc, TSDocParam, TSDocRemarks, TSDocTitle } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
9
+ import { getAppBin, getDynamicPathSegmentName, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
10
+ import { pascalCase } from "@stryke/string-format/pascal-case";
11
+ import defu from "defu";
12
+ import { joinPaths } from "@stryke/path/join";
13
+ import { constantCase } from "@stryke/string-format/constant-case";
14
+ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript/components/typescript-file";
15
+
16
+ //#region src/components/virtual-command-entry.tsx
17
+ /**
18
+ * A component that generates the `handler` function declaration for a command.
19
+ */
20
+ function VirtualCommandHandlerDeclaration(props) {
21
+ const { command, children, banner } = props;
22
+ const context = usePowerlines();
23
+ return [createComponent(TSDoc, {
24
+ get heading() {
25
+ return `The ${command.title} (${getAppBin(context)} ${command.segments.map((segment) => isDynamicPathSegment(segment) ? `[${constantCase(getDynamicPathSegmentName(segment))}]` : segment).join(" ")}) virtual command.`;
26
+ },
27
+ get children() {
28
+ return [
29
+ createComponent(TSDocRemarks, { get children() {
30
+ return `${command.description.replace(/\.+$/, "")}.`;
31
+ } }),
32
+ createIntrinsic("hbr", {}),
33
+ createComponent(TSDocTitle, { get children() {
34
+ return command.title;
35
+ } }),
36
+ createComponent(TSDocParam, {
37
+ name: "args",
38
+ children: `The command-line arguments passed to the command.`
39
+ })
40
+ ];
41
+ }
42
+ }), createComponent(FunctionDeclaration, {
43
+ "export": true,
44
+ async: true,
45
+ name: "handler",
46
+ parameters: [{
47
+ name: "args",
48
+ type: "string[]",
49
+ default: "useArgs()"
50
+ }],
51
+ get children() {
52
+ return [
53
+ createComponent(Spacing, {}),
54
+ children,
55
+ createComponent(Spacing, {}),
56
+ createComponent(Show, {
57
+ get when() {
58
+ return Boolean(banner);
59
+ },
60
+ children: banner
61
+ }),
62
+ createComponent(Spacing, {}),
63
+ code`return showHelp(); `
64
+ ];
65
+ }
66
+ })];
67
+ }
68
+ /**
69
+ * The virtual command entry point for the Shell Shock project.
70
+ */
71
+ function VirtualCommandEntry(props) {
72
+ const { command, imports, builtinImports, ...rest } = props;
73
+ const context = usePowerlines();
74
+ const filePath = computed(() => joinPaths(context.entryPath, command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
75
+ return [createComponent(TypescriptFile, mergeProps(rest, {
76
+ get path() {
77
+ return filePath.value;
78
+ },
79
+ get imports() {
80
+ return defu(imports ?? {}, Object.entries(command.children).filter(([, child]) => child.isVirtual).reduce((ret, [name, child]) => {
81
+ ret[`./${child.name}`] = [{
82
+ name: "handler",
83
+ alias: `handle${pascalCase(name)}`
84
+ }];
85
+ return ret;
86
+ }, {}));
87
+ },
88
+ get builtinImports() {
89
+ return defu(builtinImports ?? {}, {
90
+ env: ["isDevelopment", "isDebug"],
91
+ console: [
92
+ "warn",
93
+ "error",
94
+ "writeLine",
95
+ "textColors"
96
+ ],
97
+ utils: [
98
+ "isMinimal",
99
+ "isUnicodeSupported",
100
+ "findSuggestions"
101
+ ],
102
+ state: [
103
+ {
104
+ name: "GlobalOptions",
105
+ type: true
106
+ },
107
+ "useGlobal",
108
+ "useGlobalOptions",
109
+ "withCommand",
110
+ "useArgs",
111
+ "hasFlag"
112
+ ],
113
+ [joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
114
+ [joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"]
115
+ });
116
+ },
117
+ get children() {
118
+ return [createComponent(Spacing, {}), createComponent(VirtualCommandHandlerDeclaration, {
119
+ command,
120
+ banner: code`await showBanner(); `,
121
+ get children() {
122
+ return createComponent(CommandRouter, {
123
+ get segments() {
124
+ return command.segments;
125
+ },
126
+ get commands() {
127
+ return command.children;
128
+ }
129
+ });
130
+ }
131
+ })];
132
+ }
133
+ })), createComponent(For, {
134
+ get each() {
135
+ return Object.values(command.children);
136
+ },
137
+ children: (child) => createComponent(Show, {
138
+ get when() {
139
+ return child.isVirtual;
140
+ },
141
+ get fallback() {
142
+ return createComponent(CommandEntry, { command: child });
143
+ },
144
+ get children() {
145
+ return createComponent(VirtualCommandEntry, { command: child });
146
+ }
147
+ })
148
+ })];
149
+ }
150
+
151
+ //#endregion
152
+ export { VirtualCommandEntry, VirtualCommandHandlerDeclaration };
2
153
  //# sourceMappingURL=virtual-command-entry.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-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 { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\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 {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandHandlerDeclarationProps {\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 VirtualCommandHandlerDeclaration(\n props: VirtualCommandHandlerDeclarationProps\n) {\n const { command, children, banner } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\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(\" \")}) virtual 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 <Spacing />\n {children}\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n {code`return showHelp(); `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\"warn\", \"error\", \"writeLine\", \"textColors\"],\n utils: [\"isMinimal\", \"isUnicodeSupported\", \"findSuggestions\"],\n state: [\n { name: \"GlobalOptions\", type: true },\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\"\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 <VirtualCommandHandlerDeclaration\n command={command}\n banner={code`await showBanner(); `}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\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":"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"}
1
+ {"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-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 { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\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 {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandHandlerDeclarationProps {\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 VirtualCommandHandlerDeclaration(\n props: VirtualCommandHandlerDeclarationProps\n) {\n const { command, children, banner } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\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(\" \")}) virtual 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 <Spacing />\n {children}\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n {code`return showHelp(); `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\"warn\", \"error\", \"writeLine\", \"textColors\"],\n utils: [\"isMinimal\", \"isUnicodeSupported\", \"findSuggestions\"],\n state: [\n { name: \"GlobalOptions\", type: true },\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\"\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 <VirtualCommandHandlerDeclaration\n command={command}\n banner={code`await showBanner(); `}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\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":";;;;;;;;;;;;;;;;;;;AAmCA,SAAE,iCAAA,OAAA;CACA,MAAM,EACR,SACA,UACA,WACM;CACN,MAAO,UAAW,eAAK;AACvB,QAAO,CAAA,gBAAO,OAAqB;EACnC,IAAQ,UAAC;AACH,UAAG,OAAA,QAAgB,MAAQ,IAAA,UAAe,QAAA,CAAA,GAAA,QAAA,SAAA,KAAA,YAAA,qBAAA,QAAA,GAAA,IAAA,aAAA,0BAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA;;EAEhD,IAAO,WAAU;AACf,UAAS;IAAA,gBAAW,cAAA,EACd,IAAG,WAAQ;AACT,YAAG,GAAA,QAAQ,YAAA,QAAA,QAAA,GAAA,CAAA;;;kCAGnB,IAAA,WAAA;AACG,YAAU,QAAK;OAEb,CAAA;IAAA,gBAAS,YAAA;KACR,MAAC;KACP,UAAA;KACK,CAAC;IAAC;;EAEP,CAAA,EAAA,gBAAgB,qBAAc;;EAE9B,OAAO;EACL,MAAC;EACD,YAAG,CAAA;GACD,MAAE;GACF,MAAK;GACL,SAAM;GACP,CAAC;EACF,IAAI,WAAQ;AACV,UAAI;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACF,IAAG,OAAQ;AACV,aAAA,QAAgB,OAAC;;KAElB,UAAC;KACF,CAAC;IAAC,gBAAiB,SAAW,EAAC,CAAA;IAAA,IAAQ;IAAsB;;EAEjE,CAAC,CAAC;;;;;AAKL,SAAgB,oBAAE,OAAA;CAChB,MAAM,EACJ,SACA,SACA,gBACA,GAAG,SACD;CACJ,MAAI,UAAA,eAAA;CACJ,MAAC,WAAA,eAAA,UAAA,QAAA,WAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;AACH,QAAA,CAAA,gBAAA,gBAAA,WAAA,MAAA;;AAEM,UAAC,SAAU;;EAEd,IAAK,UAAI;AACV,UAAA,KAAA,WAAA,EAAA,EAAA,OAAA,QAAA,QAAA,SAAA,CAAA,QAAA,GAAA,WAAA,MAAA,UAAA,CAAA,QAAA,KAAA,CAAA,MAAA,WAAA;AACA,QAAS,KAAA,MAAW,UAAA,CAAA;KACtB,MAAA;;KAEE,CAAA;AACK,WAAQ;MACb,EAAA,CAAA,CAAA;;EAEA,IAAM,iBAAW;;IAEX,KAAA,CAAA,iBAAuB,UAAC;IACxB,SAAS;KAAC;KAAC;KAAa;KAAA;KAAA;IAC5B,OAAS;KAAA;KAAA;KAAA;KAAA;IACP,OAAQ;KAAA;MACR,MAAQ;MACL,MAAO;MACP;KAAA;KAAS;KAAA;KAAA;KAAA;KAAA;KACX,UAAQ,QAAA,GAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,WAAA;KACX,UAAA,UAAA,GAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,aAAA;IACD,CAAA;;EAED,IAAM,WAAC;AACJ,UAAA,CAAA,gBAAA,SAAA,EAAA,CAAA,EAAA,gBAAA,kCAAA;IACE;IACC,QAAQ,IAAA;IACR,IAAI,WAAW;AACf,YAAS,gBAAI,eAAA;MACX,IAAA,WAAa;AACb,cAAO,QAAQ;;MAEb,IAAC,WAAc;AACb,cAAO,QAAQ;;MAElB,CAAC;;IAEL,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAE,KAAA;EACL,IAAI,OAAA;AACF,UAAO,OAAI,OAAA,QAAiB,SAAS;;EAEvC,WAAM,UAAS,gBAAa,MAAA;GAC1B,IAAI,OAAO;AACT,WAAM,MAAO;;GAEf,IAAI,WAAG;AACL,WAAK,gBAAY,cAAA,EACf,SAAG,OACJ,CAAC;;GAEJ,IAAI,WAAU;AACZ,WAAK,gBAAK,qBAAA,EACR,SAAK,OACN,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
@@ -1 +1,75 @@
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
+ 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;
@@ -1,2 +1,74 @@
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};
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 };
2
74
  //# 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":"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"}
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":";;;;;;;;AAyBA,SAAE,mBAAA;AACF,QAAO;EAAA;GACL,MAAO;GACL,OAAA;GACA,aAAa;GACb,KAAE;GACF,OAAE,CAAA,KAAW,IAAG;GAChB,MAAM,sBAAM;GACZ,UAAU;GACV,SAAQ;GACR,UAAU;GACV,oBAAgB;GACjB;EAAE;GACD,MAAE;GACF,OAAC;GACD,aAAA;GACA,KAAE;GACF,OAAO,CAAC,IAAE;GACV,MAAE,sBAAuB;GACzB,UAAO;GACP,SAAS;GACT,UAAQ;GACR,oBAAgB;GACjB;EAAE;GACD,MAAE;GACF,OAAE;GACF,aAAC;GACD,KAAA;GACA,OAAO,CAAC,IAAC;GACT,MAAE,sBAAgB;GAClB,UAAE;GACF,SAAQ;GACR,UAAU;GACV,oBAAQ;GACT;EAAE;GACD,MAAE;GACF,OAAE;GACF,aAAE;GACF,KAAC;GACD,OAAA,CAAA,SAAA;GACA,MAAM,sBAAS;GACf,UAAU;GACV,UAAE;GACF,oBAAc;GACf;EAAE;GACD,MAAM;GACN,OAAE;GACF,aAAY;GACZ,KAAE;GACF,OAAC,CAAA,cAAA;GACD,MAAA,sBAAA;GACA,UAAS;GACT,UAAU;GACV,SAAE;GACH;EAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1,123 @@
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
+ 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
+ prepare: {
40
+ order: "post",
41
+ async handler() {
42
+ const _self$ = this;
43
+ this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
44
+ return (0, _powerlines_plugin_alloy_render.render)(this, [(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_bin_entry.BinEntry, {
45
+ builtinImports: {
46
+ console: [
47
+ "divider",
48
+ "stripAnsi",
49
+ "writeLine",
50
+ "splitText",
51
+ "help"
52
+ ],
53
+ utils: ["isMinimal"],
54
+ state: [
55
+ "useArgs",
56
+ "hasFlag",
57
+ "isHelp"
58
+ ]
59
+ },
60
+ get children() {
61
+ return [
62
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
63
+ get when() {
64
+ return Object.keys(_self$.commands).length > 0;
65
+ },
66
+ get children() {
67
+ return [
68
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
69
+ "const": true,
70
+ name: "args",
71
+ type: "string[]",
72
+ initializer: _alloy_js_core.code`useArgs();`
73
+ }),
74
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
75
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
76
+ segments: [],
77
+ get commands() {
78
+ return _self$.commands ?? {};
79
+ }
80
+ }),
81
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
82
+ ];
83
+ }
84
+ }),
85
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
86
+ _alloy_js_core.code`await showBanner();`,
87
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
88
+ _alloy_js_core.code`return showHelp();`
89
+ ];
90
+ }
91
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
92
+ get when() {
93
+ return Object.values(_self$.commands).length > 0;
94
+ },
95
+ get children() {
96
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
97
+ get each() {
98
+ return Object.values(_self$.commands);
99
+ },
100
+ doubleHardline: true,
101
+ children: (child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
102
+ get when() {
103
+ return child.isVirtual;
104
+ },
105
+ get fallback() {
106
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_entry.CommandEntry, { command: child });
107
+ },
108
+ get children() {
109
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_virtual_command_entry.VirtualCommandEntry, { command: child });
110
+ }
111
+ })
112
+ });
113
+ }
114
+ })]);
115
+ }
116
+ }
117
+ }
118
+ ];
119
+ };
120
+
121
+ //#endregion
122
+ exports.default = plugin;
123
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1,2 +1,118 @@
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};
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
+ prepare: {
35
+ order: "post",
36
+ async handler() {
37
+ const _self$ = this;
38
+ this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
39
+ return render(this, [createComponent(BinEntry, {
40
+ builtinImports: {
41
+ console: [
42
+ "divider",
43
+ "stripAnsi",
44
+ "writeLine",
45
+ "splitText",
46
+ "help"
47
+ ],
48
+ utils: ["isMinimal"],
49
+ state: [
50
+ "useArgs",
51
+ "hasFlag",
52
+ "isHelp"
53
+ ]
54
+ },
55
+ get children() {
56
+ return [
57
+ createComponent(Show, {
58
+ get when() {
59
+ return Object.keys(_self$.commands).length > 0;
60
+ },
61
+ get children() {
62
+ return [
63
+ createComponent(VarDeclaration, {
64
+ "const": true,
65
+ name: "args",
66
+ type: "string[]",
67
+ initializer: code`useArgs();`
68
+ }),
69
+ createIntrinsic("hbr", {}),
70
+ createComponent(CommandRouter, {
71
+ segments: [],
72
+ get commands() {
73
+ return _self$.commands ?? {};
74
+ }
75
+ }),
76
+ createIntrinsic("hbr", {})
77
+ ];
78
+ }
79
+ }),
80
+ createComponent(Spacing, {}),
81
+ code`await showBanner();`,
82
+ createComponent(Spacing, {}),
83
+ code`return showHelp();`
84
+ ];
85
+ }
86
+ }), createComponent(Show, {
87
+ get when() {
88
+ return Object.values(_self$.commands).length > 0;
89
+ },
90
+ get children() {
91
+ return createComponent(For, {
92
+ get each() {
93
+ return Object.values(_self$.commands);
94
+ },
95
+ doubleHardline: true,
96
+ children: (child) => createComponent(Show, {
97
+ get when() {
98
+ return child.isVirtual;
99
+ },
100
+ get fallback() {
101
+ return createComponent(CommandEntry, { command: child });
102
+ },
103
+ get children() {
104
+ return createComponent(VirtualCommandEntry, { command: child });
105
+ }
106
+ })
107
+ });
108
+ }
109
+ })]);
110
+ }
111
+ }
112
+ }
113
+ ];
114
+ };
115
+
116
+ //#endregion
117
+ export { plugin as default, plugin };
2
118
  //# sourceMappingURL=index.mjs.map