@shell-shock/plugin-help 0.2.26 → 0.2.29

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 (34) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/components/display.cjs +276 -18
  3. package/dist/components/display.d.cts +6 -7
  4. package/dist/components/display.d.cts.map +1 -1
  5. package/dist/components/display.d.mts +6 -7
  6. package/dist/components/display.d.mts.map +1 -1
  7. package/dist/components/display.mjs +270 -18
  8. package/dist/components/display.mjs.map +1 -1
  9. package/dist/components/help-builtin.cjs +99 -1
  10. package/dist/components/help-builtin.d.cts +1 -2
  11. package/dist/components/help-builtin.d.cts.map +1 -1
  12. package/dist/components/help-builtin.d.mts +2 -3
  13. package/dist/components/help-builtin.d.mts.map +1 -1
  14. package/dist/components/help-builtin.mjs +96 -1
  15. package/dist/components/help-builtin.mjs.map +1 -1
  16. package/dist/components/help-command.cjs +151 -1
  17. package/dist/components/help-command.d.cts +3 -5
  18. package/dist/components/help-command.d.cts.map +1 -1
  19. package/dist/components/help-command.d.mts +3 -5
  20. package/dist/components/help-command.d.mts.map +1 -1
  21. package/dist/components/help-command.mjs +149 -1
  22. package/dist/components/help-command.mjs.map +1 -1
  23. package/dist/components/index.cjs +14 -1
  24. package/dist/components/index.mjs +5 -1
  25. package/dist/index.cjs +97 -1
  26. package/dist/index.d.cts +1 -1
  27. package/dist/index.d.mts +1 -1
  28. package/dist/index.d.mts.map +1 -1
  29. package/dist/index.mjs +91 -1
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/types/index.mjs +1 -1
  32. package/dist/types/plugin.d.mts.map +1 -1
  33. package/dist/types/plugin.mjs +1 -1
  34. package/package.json +18 -18
@@ -1 +1 @@
1
- {"version":3,"file":"help-builtin.mjs","names":[],"sources":["../../src/components/help-builtin.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 { Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TSDoc, TSDocRemarks } from \"@powerlines/plugin-alloy/typescript\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport {\n getAppTitle,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport defu from \"defu\";\nimport type { HelpPluginContext } from \"../types\";\nimport { CommandHelpDisplay, VirtualCommandHelpDisplay } from \"./display\";\n\nexport interface HelpBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {\n /**\n * The command to generate the `help` function declaration for.\n */\n command: CommandTree;\n}\n\n/**\n * A built-in help module for Shell Shock.\n */\nexport function HelpBuiltin(props: HelpBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <BuiltinFile\n id={joinPaths(\n \"help\",\n ...command.segments.filter(segment => !isDynamicPathSegment(segment))\n )}\n description={\n command.path\n ? `A collection of utility functions that assist in displaying help information for the ${\n command.title\n } command.`\n : `A collection of utility functions that assist in displaying help information for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`\n }\n {...rest}\n builtinImports={defu(rest.builtinImports ?? {}, {\n utils: [\"isUnicodeSupported\"],\n console: [\n \"splitText\",\n \"writeLine\",\n \"inlineCode\",\n \"textColors\",\n \"inverse\",\n \"bold\",\n \"help\",\n \"table\",\n \"link\"\n ]\n })}>\n <TSDoc\n heading={`Utility functions for displaying help information for the ${\n command.path\n ? `${command.title} command`\n : `${getAppTitle(context, true)} application`\n }.`}>\n <TSDocRemarks>\n {`This module contains utility functions that assist in displaying help information for the ${\n command.path\n ? `${command.title} command`\n : `${getAppTitle(context, true)} application`\n }. The main function exported by this module is the \\`showHelp\\` function, which can be used to display help information for the specified command or application. This function can be called from within the command's handler or from any other part of the application where help information needs to be displayed.`}\n </TSDocRemarks>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"showHelp\"\n doc={`Display help information for the ${\n command.path\n ? `${command.title} command`\n : `${getAppTitle(context, true)} application`\n }.`}>\n <Show\n when={!command.isVirtual}\n fallback={\n <VirtualCommandHelpDisplay\n options={Object.values(command.options)}\n commands={command.children ?? {}}\n />\n }>\n <CommandHelpDisplay command={command} />\n </Show>\n </FunctionDeclaration>\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":"gvBAgCA,SAAc,EAAA,EAAoB,CAClC,GAAQ,CAAC,CAAA,UAET,YACE,GAAA,EAAgB,EAAA,CAAA,UAAA,WAAA,CAAA,CACV,EAAE,GAAW,CACnB,OAAA,EAAA,EAAA,EAAA,CACE,IAAA,IAAA,CACC,OAAI,EAAW,OAAS,GAAK,EAAM,SAAS,OAAA,GAAe,CAAA,EAAA,EAAA,CAAA,CAAA,EAE9D,IAAA,aAAoB,CACtB,OAAA,MAAA,CAAA,CAAA,EAAA,KAAA,EAAA,CAAA,wFAAA,EAAA,MAAA,WAAA,wFAAA,EAAA,EAAA,GAAA,CAAA,uCAEE,CAAA,EAAA,CACE,IAAC,gBAAoB,CACvB,OAAA,EAAA,EAAA,gBAAA,EAAA,CAAA,CACK,MAAQ,CAAC,qBAAmB,CAC3B,QAAG,CAAO,YAAa,YAAS,aAAkB,aAAA,UAAA,OAAA,OAAA,QAAA,OAAA,CACrD,CAAA,EAED,IAAA,UAAA,CACF,MAAM,CAAA,EAAwB,EAAA,eAEvB,MAAA,6DAAA,EAAA,KAAA,GAAA,EAAA,MAAA,UAAA,GAAA,EAAA,EAAA,GAAA,CAAA,cAAA,IAED,IAAE,UAAS,CACV,OAAK,EAAA,EAAA,CACH,IAAA,UAAgB,CACpB,MAAA,6FAAA,EAAA,KAAA,GAAA,EAAA,MAAA,UAAA,GAAA,EAAA,EAAA,GAAA,CAAA,cAAA,0TAEC,CAAA,EAED,CAAC,CAAE,EAAY,EAAA,CACd,OAAM,GACN,KAAM,WACN,IAAI,KAAE,CACJ,MAAI,oCAAA,EAAA,KAAA,GAAA,EAAA,MAAA,UAAA,GAAA,EAAA,EAAA,GAAA,CAAA,cAAA,IAER,IAAA,UAAA,CACI,OAAI,EAAA,EAAA,CACR,IAAA,MAAgB,CACR,MAAG,CAAA,EAAA,WAEN,IAAA,UAAU,CACV,OAAU,EAAA,EAAA,CACV,IAAA,SAAW,CACX,OAAW,OAAA,OAAA,EAAA,QAAA,EAEN,IAAA,UAAA,CACA,OAAA,EAAA,UAAA,EAAA,EAED,CAAA,EAEN,IAAA,UAAA,CACF,OAAA,EAAA,EAAA,CACkB,UACf,CAAA,EAEC,CAAC,EAEL,CAAC,CAAC,EAAY,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACb,IAAI,MAAK,CACP,MAAE,EAAQ,GAEF,WACX,CAAC,CAAC,EAEN,CAAC,CAAC"}
1
+ {"version":3,"file":"help-builtin.mjs","names":[],"sources":[],"mappings":""}
@@ -1 +1,151 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@alloy-js/core`),n=require(`@powerlines/plugin-alloy/core/components`),r=require(`@powerlines/plugin-alloy/core/contexts/context`),i=require(`@alloy-js/typescript`),a=require(`@powerlines/plugin-alloy/typescript`),o=require(`@stryke/path`),s=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),c=require(`@stryke/string-format/pascal-case`);function l(){let c=(0,r.usePowerlines)();return(0,e.createComponent)(a.TypescriptFile,{get path(){return(0,o.joinPaths)(c.entryPath,`help`,`command.ts`)},get children(){return[t.code` // Temporary placeholder file to ensure the help command's entry file is generated. The actual content of this file will be rendered in the \`prepare\` step of this plugin, after the command list has been fully resolved. `,(0,e.createComponent)(n.Spacing,{}),(0,e.createComponent)(s.TSDoc,{heading:`Display command usage details and other useful information to the user.`,get children(){return(0,e.createComponent)(s.TSDocParam,{name:`segments`,children:`The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`})}}),(0,e.createComponent)(i.FunctionDeclaration,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`segments`,type:`string[]`,default:`[]`}]})]}})}function u(n){let l=(0,r.usePowerlines)(),u=(0,t.computed)(()=>n.segments?n.segments.reduce((e,t)=>(e[(0,o.joinPaths)(`help`,...t)]=[{name:`showHelp`,alias:`showHelp${t.map(e=>(0,c.pascalCase)(e.replace(/-/g,``))).join(``)}`}],e),{}):{}),d=n.segments??[];return(0,e.createComponent)(a.TypescriptFile,{get path(){return(0,o.joinPaths)(l.entryPath,`help`,`command.ts`)},imports:{"node:os":`os`,"node:fs/promises":[`readFile`,`writeFile`]},get builtinImports(){return{...u.value,help:[`showHelp`],console:[`splitText`,`writeLine`,`inlineCode`,`textColors`,`inverse`,`bold`,`help`,`table`,`link`]}},get children(){return[(0,e.createComponent)(s.TSDoc,{heading:`Display command usage details and other useful information to the user.`,get children(){return(0,e.createComponent)(s.TSDocParam,{name:`segments`,children:`The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`})}}),(0,e.createComponent)(i.FunctionDeclaration,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`segments`,type:`string[]`,default:`[]`}],get children(){return(0,e.createComponent)(t.Show,{get when(){return d.length>0},fallback:t.code`showHelp(); `,get children(){return[(0,e.createComponent)(t.For,{each:d,doubleHardline:!0,children:(n,r)=>(0,e.createComponent)(t.Show,{when:r>0,get fallback(){return(0,e.createComponent)(i.IfStatement,{get condition(){return t.code`segments.join("/").toLowerCase() === "${n.join(`/`).toLowerCase()}"`},get children(){return t.code` showHelp${n.map(e=>(0,c.pascalCase)(e)).join(``)}(); `}})},get children(){return(0,e.createComponent)(i.ElseIfClause,{get condition(){return t.code`segments.join("/").toLowerCase() === "${n.join(`/`).toLowerCase()}"`},get children(){return t.code` showHelp${n.map(e=>(0,c.pascalCase)(e)).join(``)}(); `}})}})}),(0,e.createComponent)(i.ElseClause,{children:t.code`showHelp(); `})]}})}})]}})}exports.HelpCommand=u,exports.TemporaryHelpCommand=l;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
+ let _alloy_js_core = require("@alloy-js/core");
4
+ let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
5
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
6
+ let _alloy_js_typescript = require("@alloy-js/typescript");
7
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
8
+ let _stryke_path = require("@stryke/path");
9
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
10
+ let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
11
+
12
+ //#region src/components/help-command.tsx
13
+ /**
14
+ * A temporary placeholder component for the help command. The actual content of this component will be rendered in the `prepare` step of the help plugin, after the command list has been fully resolved. This is necessary to ensure that the help command's entry file is generated, and to avoid any issues with missing files or circular dependencies during the rendering process.
15
+ */
16
+ function TemporaryHelpCommand() {
17
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
18
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
19
+ get path() {
20
+ return (0, _stryke_path.joinPaths)(context.entryPath, "help", "command.ts");
21
+ },
22
+ get children() {
23
+ return [
24
+ _alloy_js_core.code` // Temporary placeholder file to ensure the help command's entry file is generated. The actual content of this file will be rendered in the \`prepare\` step of this plugin, after the command list has been fully resolved. `,
25
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
26
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
27
+ heading: "Display command usage details and other useful information to the user.",
28
+ get children() {
29
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
30
+ name: "segments",
31
+ children: `The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`
32
+ });
33
+ }
34
+ }),
35
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
36
+ "export": true,
37
+ "default": true,
38
+ async: true,
39
+ name: "handler",
40
+ parameters: [{
41
+ name: "segments",
42
+ type: "string[]",
43
+ default: "[]"
44
+ }]
45
+ })
46
+ ];
47
+ }
48
+ });
49
+ }
50
+ /**
51
+ * The Help command's handler wrapper for the Shell Shock project.
52
+ */
53
+ function HelpCommand(props) {
54
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
55
+ const helpImports = (0, _alloy_js_core.computed)(() => props.commands ? props.commands.reduce((ret, segments) => {
56
+ ret[(0, _stryke_path.joinPaths)("help", ...segments)] = [{
57
+ name: "showHelp",
58
+ alias: `showHelp${segments.map((segment) => (0, _stryke_string_format_pascal_case.pascalCase)(segment.replace(/-/g, ""))).join("")}`
59
+ }];
60
+ return ret;
61
+ }, {}) : {});
62
+ const commandSegmentsList = props.commands ?? [];
63
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
64
+ get path() {
65
+ return (0, _stryke_path.joinPaths)(context.entryPath, "help", "command.ts");
66
+ },
67
+ imports: {
68
+ "node:os": "os",
69
+ "node:fs/promises": ["readFile", "writeFile"]
70
+ },
71
+ get builtinImports() {
72
+ return {
73
+ ...helpImports.value,
74
+ help: ["showHelp"],
75
+ console: [
76
+ "splitText",
77
+ "writeLine",
78
+ "inlineCode",
79
+ "textColors",
80
+ "inverse",
81
+ "bold",
82
+ "help",
83
+ "table",
84
+ "link"
85
+ ]
86
+ };
87
+ },
88
+ get children() {
89
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
90
+ heading: "Display command usage details and other useful information to the user.",
91
+ get children() {
92
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
93
+ name: "segments",
94
+ children: `The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`
95
+ });
96
+ }
97
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
98
+ "export": true,
99
+ "default": true,
100
+ async: true,
101
+ name: "handler",
102
+ parameters: [{
103
+ name: "segments",
104
+ type: "string[]",
105
+ default: "[]"
106
+ }],
107
+ get children() {
108
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
109
+ get when() {
110
+ return commandSegmentsList.length > 0;
111
+ },
112
+ fallback: _alloy_js_core.code`showHelp(); `,
113
+ get children() {
114
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
115
+ each: commandSegmentsList,
116
+ doubleHardline: true,
117
+ children: (segments, index) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
118
+ when: index > 0,
119
+ get fallback() {
120
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
121
+ get condition() {
122
+ return _alloy_js_core.code`segments.join("/").toLowerCase() === "${segments.join("/").toLowerCase()}"`;
123
+ },
124
+ get children() {
125
+ return _alloy_js_core.code` showHelp${segments.map((segment) => (0, _stryke_string_format_pascal_case.pascalCase)(segment)).join("")}(); `;
126
+ }
127
+ });
128
+ },
129
+ get children() {
130
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
131
+ get condition() {
132
+ return _alloy_js_core.code`segments.join("/").toLowerCase() === "${segments.join("/").toLowerCase()}"`;
133
+ },
134
+ get children() {
135
+ return _alloy_js_core.code` showHelp${segments.map((segment) => (0, _stryke_string_format_pascal_case.pascalCase)(segment)).join("")}(); `;
136
+ }
137
+ });
138
+ }
139
+ })
140
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { children: _alloy_js_core.code`showHelp(); ` })];
141
+ }
142
+ });
143
+ }
144
+ })];
145
+ }
146
+ });
147
+ }
148
+
149
+ //#endregion
150
+ exports.HelpCommand = HelpCommand;
151
+ exports.TemporaryHelpCommand = TemporaryHelpCommand;
@@ -1,17 +1,15 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
1
  //#region src/components/help-command.d.ts
4
2
  /**
5
3
  * A temporary placeholder component for the help command. The actual content of this component will be rendered in the `prepare` step of the help plugin, after the command list has been fully resolved. This is necessary to ensure that the help command's entry file is generated, and to avoid any issues with missing files or circular dependencies during the rendering process.
6
4
  */
7
- declare function TemporaryHelpCommand(): _$_alloy_js_core0.Children;
5
+ declare function TemporaryHelpCommand(): import("@alloy-js/core").Children;
8
6
  interface HelpCommandsProps {
9
- segments: string[][];
7
+ commands: string[][];
10
8
  }
11
9
  /**
12
10
  * The Help command's handler wrapper for the Shell Shock project.
13
11
  */
14
- declare function HelpCommand(props: HelpCommandsProps): _$_alloy_js_core0.Children;
12
+ declare function HelpCommand(props: HelpCommandsProps): import("@alloy-js/core").Children;
15
13
  //#endregion
16
14
  export { HelpCommand, HelpCommandsProps, TemporaryHelpCommand };
17
15
  //# sourceMappingURL=help-command.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help-command.d.cts","names":[],"sources":["../../src/components/help-command.tsx"],"mappings":";;;;;;iBAuCgB,oBAAA,CAAA,GAAoB,iBAAA,CAAA,QAAA;AAAA,UAwBnB,iBAAA;EACf,QAAA;AAAA;;AADF;;iBAOgB,WAAA,CAAY,KAAA,EAAO,iBAAA,GAAiB,iBAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"help-command.d.cts","names":[],"sources":["../../src/components/help-command.tsx"],"mappings":";;AAuCA;;iBAAgB,oBAAA,6BAAoB,QAAA;AAAA,UAwBnB,iBAAA;EACf,QAAQ;AAAA;;;;iBAMM,WAAA,CAAY,KAAA,EAAO,iBAAiB,4BAAA,QAAA"}
@@ -1,17 +1,15 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
1
  //#region src/components/help-command.d.ts
4
2
  /**
5
3
  * A temporary placeholder component for the help command. The actual content of this component will be rendered in the `prepare` step of the help plugin, after the command list has been fully resolved. This is necessary to ensure that the help command's entry file is generated, and to avoid any issues with missing files or circular dependencies during the rendering process.
6
4
  */
7
- declare function TemporaryHelpCommand(): _$_alloy_js_core0.Children;
5
+ declare function TemporaryHelpCommand(): import("@alloy-js/core").Children;
8
6
  interface HelpCommandsProps {
9
- segments: string[][];
7
+ commands: string[][];
10
8
  }
11
9
  /**
12
10
  * The Help command's handler wrapper for the Shell Shock project.
13
11
  */
14
- declare function HelpCommand(props: HelpCommandsProps): _$_alloy_js_core0.Children;
12
+ declare function HelpCommand(props: HelpCommandsProps): import("@alloy-js/core").Children;
15
13
  //#endregion
16
14
  export { HelpCommand, HelpCommandsProps, TemporaryHelpCommand };
17
15
  //# sourceMappingURL=help-command.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help-command.d.mts","names":[],"sources":["../../src/components/help-command.tsx"],"mappings":";;;;;;iBAuCgB,oBAAA,CAAA,GAAoB,iBAAA,CAAA,QAAA;AAAA,UAwBnB,iBAAA;EACf,QAAA;AAAA;;AADF;;iBAOgB,WAAA,CAAY,KAAA,EAAO,iBAAA,GAAiB,iBAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"help-command.d.mts","names":[],"sources":["../../src/components/help-command.tsx"],"mappings":""}
@@ -1,2 +1,150 @@
1
- import{createComponent as e}from"@alloy-js/core/jsx-runtime";import{For as t,Show as n,code as r,computed as i}from"@alloy-js/core";import{Spacing as a}from"@powerlines/plugin-alloy/core/components";import{usePowerlines as o}from"@powerlines/plugin-alloy/core/contexts/context";import{ElseClause as s,ElseIfClause as c,FunctionDeclaration as l,IfStatement as u}from"@alloy-js/typescript";import{TypescriptFile as d}from"@powerlines/plugin-alloy/typescript";import{joinPaths as f}from"@stryke/path";import{TSDoc as p,TSDocParam as m}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{pascalCase as h}from"@stryke/string-format/pascal-case";function g(){let t=o();return e(d,{get path(){return f(t.entryPath,`help`,`command.ts`)},get children(){return[r` // Temporary placeholder file to ensure the help command's entry file is generated. The actual content of this file will be rendered in the \`prepare\` step of this plugin, after the command list has been fully resolved. `,e(a,{}),e(p,{heading:`Display command usage details and other useful information to the user.`,get children(){return e(m,{name:`segments`,children:`The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`})}}),e(l,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`segments`,type:`string[]`,default:`[]`}]})]}})}function _(a){let g=o(),_=i(()=>a.segments?a.segments.reduce((e,t)=>(e[f(`help`,...t)]=[{name:`showHelp`,alias:`showHelp${t.map(e=>h(e.replace(/-/g,``))).join(``)}`}],e),{}):{}),v=a.segments??[];return e(d,{get path(){return f(g.entryPath,`help`,`command.ts`)},imports:{"node:os":`os`,"node:fs/promises":[`readFile`,`writeFile`]},get builtinImports(){return{..._.value,help:[`showHelp`],console:[`splitText`,`writeLine`,`inlineCode`,`textColors`,`inverse`,`bold`,`help`,`table`,`link`]}},get children(){return[e(p,{heading:`Display command usage details and other useful information to the user.`,get children(){return e(m,{name:`segments`,children:`The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`})}}),e(l,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`segments`,type:`string[]`,default:`[]`}],get children(){return e(n,{get when(){return v.length>0},fallback:r`showHelp(); `,get children(){return[e(t,{each:v,doubleHardline:!0,children:(t,i)=>e(n,{when:i>0,get fallback(){return e(u,{get condition(){return r`segments.join("/").toLowerCase() === "${t.join(`/`).toLowerCase()}"`},get children(){return r` showHelp${t.map(e=>h(e)).join(``)}(); `}})},get children(){return e(c,{get condition(){return r`segments.join("/").toLowerCase() === "${t.join(`/`).toLowerCase()}"`},get children(){return r` showHelp${t.map(e=>h(e)).join(``)}(); `}})}})}),e(s,{children:r`showHelp(); `})]}})}})]}})}export{_ as HelpCommand,g as TemporaryHelpCommand};
1
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { For, Show, code, computed } from "@alloy-js/core";
3
+ import { Spacing } from "@powerlines/plugin-alloy/core/components";
4
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
5
+ import { ElseClause, ElseIfClause, FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
6
+ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
7
+ import { joinPaths } from "@stryke/path";
8
+ import { TSDoc as TSDoc$1, TSDocParam } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
9
+ import { pascalCase } from "@stryke/string-format/pascal-case";
10
+
11
+ //#region src/components/help-command.tsx
12
+ /**
13
+ * A temporary placeholder component for the help command. The actual content of this component will be rendered in the `prepare` step of the help plugin, after the command list has been fully resolved. This is necessary to ensure that the help command's entry file is generated, and to avoid any issues with missing files or circular dependencies during the rendering process.
14
+ */
15
+ function TemporaryHelpCommand() {
16
+ const context = usePowerlines();
17
+ return createComponent(TypescriptFile, {
18
+ get path() {
19
+ return joinPaths(context.entryPath, "help", "command.ts");
20
+ },
21
+ get children() {
22
+ return [
23
+ code` // Temporary placeholder file to ensure the help command's entry file is generated. The actual content of this file will be rendered in the \`prepare\` step of this plugin, after the command list has been fully resolved. `,
24
+ createComponent(Spacing, {}),
25
+ createComponent(TSDoc$1, {
26
+ heading: "Display command usage details and other useful information to the user.",
27
+ get children() {
28
+ return createComponent(TSDocParam, {
29
+ name: "segments",
30
+ children: `The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`
31
+ });
32
+ }
33
+ }),
34
+ createComponent(FunctionDeclaration, {
35
+ "export": true,
36
+ "default": true,
37
+ async: true,
38
+ name: "handler",
39
+ parameters: [{
40
+ name: "segments",
41
+ type: "string[]",
42
+ default: "[]"
43
+ }]
44
+ })
45
+ ];
46
+ }
47
+ });
48
+ }
49
+ /**
50
+ * The Help command's handler wrapper for the Shell Shock project.
51
+ */
52
+ function HelpCommand(props) {
53
+ const context = usePowerlines();
54
+ const helpImports = computed(() => props.commands ? props.commands.reduce((ret, segments) => {
55
+ ret[joinPaths("help", ...segments)] = [{
56
+ name: "showHelp",
57
+ alias: `showHelp${segments.map((segment) => pascalCase(segment.replace(/-/g, ""))).join("")}`
58
+ }];
59
+ return ret;
60
+ }, {}) : {});
61
+ const commandSegmentsList = props.commands ?? [];
62
+ return createComponent(TypescriptFile, {
63
+ get path() {
64
+ return joinPaths(context.entryPath, "help", "command.ts");
65
+ },
66
+ imports: {
67
+ "node:os": "os",
68
+ "node:fs/promises": ["readFile", "writeFile"]
69
+ },
70
+ get builtinImports() {
71
+ return {
72
+ ...helpImports.value,
73
+ help: ["showHelp"],
74
+ console: [
75
+ "splitText",
76
+ "writeLine",
77
+ "inlineCode",
78
+ "textColors",
79
+ "inverse",
80
+ "bold",
81
+ "help",
82
+ "table",
83
+ "link"
84
+ ]
85
+ };
86
+ },
87
+ get children() {
88
+ return [createComponent(TSDoc$1, {
89
+ heading: "Display command usage details and other useful information to the user.",
90
+ get children() {
91
+ return createComponent(TSDocParam, {
92
+ name: "segments",
93
+ children: `The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`
94
+ });
95
+ }
96
+ }), createComponent(FunctionDeclaration, {
97
+ "export": true,
98
+ "default": true,
99
+ async: true,
100
+ name: "handler",
101
+ parameters: [{
102
+ name: "segments",
103
+ type: "string[]",
104
+ default: "[]"
105
+ }],
106
+ get children() {
107
+ return createComponent(Show, {
108
+ get when() {
109
+ return commandSegmentsList.length > 0;
110
+ },
111
+ fallback: code`showHelp(); `,
112
+ get children() {
113
+ return [createComponent(For, {
114
+ each: commandSegmentsList,
115
+ doubleHardline: true,
116
+ children: (segments, index) => createComponent(Show, {
117
+ when: index > 0,
118
+ get fallback() {
119
+ return createComponent(IfStatement, {
120
+ get condition() {
121
+ return code`segments.join("/").toLowerCase() === "${segments.join("/").toLowerCase()}"`;
122
+ },
123
+ get children() {
124
+ return code` showHelp${segments.map((segment) => pascalCase(segment)).join("")}(); `;
125
+ }
126
+ });
127
+ },
128
+ get children() {
129
+ return createComponent(ElseIfClause, {
130
+ get condition() {
131
+ return code`segments.join("/").toLowerCase() === "${segments.join("/").toLowerCase()}"`;
132
+ },
133
+ get children() {
134
+ return code` showHelp${segments.map((segment) => pascalCase(segment)).join("")}(); `;
135
+ }
136
+ });
137
+ }
138
+ })
139
+ }), createComponent(ElseClause, { children: code`showHelp(); ` })];
140
+ }
141
+ });
142
+ }
143
+ })];
144
+ }
145
+ });
146
+ }
147
+
148
+ //#endregion
149
+ export { HelpCommand, TemporaryHelpCommand };
2
150
  //# sourceMappingURL=help-command.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"help-command.mjs","names":[],"sources":["../../src/components/help-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { joinPaths } from \"@stryke/path\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { HelpPluginContext } from \"../types/plugin\";\n\n/**\n * A temporary placeholder component for the help command. The actual content of this component will be rendered in the `prepare` step of the help plugin, after the command list has been fully resolved. This is necessary to ensure that the help command's entry file is generated, and to avoid any issues with missing files or circular dependencies during the rendering process.\n */\nexport function TemporaryHelpCommand() {\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <TypescriptFile path={joinPaths(context.entryPath, \"help\", \"command.ts\")}>\n {code` // Temporary placeholder file to ensure the help command's entry file is generated. The actual content of this file will be rendered in the \\`prepare\\` step of this plugin, after the command list has been fully resolved. `}\n <Spacing />\n <TSDoc heading=\"Display command usage details and other useful information to the user.\">\n <TSDocParam name=\"segments\">\n {`The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n { name: \"segments\", type: \"string[]\", default: \"[]\" }\n ]}></FunctionDeclaration>\n </TypescriptFile>\n );\n}\n\nexport interface HelpCommandsProps {\n segments: string[][];\n}\n\n/**\n * The Help command's handler wrapper for the Shell Shock project.\n */\nexport function HelpCommand(props: HelpCommandsProps) {\n const context = usePowerlines<HelpPluginContext>();\n\n const helpImports = computed(() =>\n props.segments\n ? props.segments.reduce(\n (ret, segments) => {\n ret[joinPaths(\"help\", ...segments)] = [\n {\n name: \"showHelp\",\n alias: `showHelp${segments\n .map(segment => pascalCase(segment.replace(/-/g, \"\")))\n .join(\"\")}`\n }\n ];\n return ret;\n },\n {} as Record<string, { name: string; alias: string }[]>\n )\n : {}\n );\n\n const commandSegmentsList = props.segments ?? [];\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"help\", \"command.ts\")}\n imports={{\n \"node:os\": \"os\",\n \"node:fs/promises\": [\"readFile\", \"writeFile\"]\n }}\n builtinImports={{\n ...helpImports.value,\n help: [\"showHelp\"],\n console: [\n \"splitText\",\n \"writeLine\",\n \"inlineCode\",\n \"textColors\",\n \"inverse\",\n \"bold\",\n \"help\",\n \"table\",\n \"link\"\n ]\n }}>\n <TSDoc heading=\"Display command usage details and other useful information to the user.\">\n <TSDocParam name=\"segments\">\n {`The command segments for the command to show help for. This is used to determine which command's help information to display. If no segments are provided, general help information about the CLI application will be displayed.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[{ name: \"segments\", type: \"string[]\", default: \"[]\" }]}>\n <Show\n when={commandSegmentsList.length > 0}\n fallback={code`showHelp(); `}>\n <For each={commandSegmentsList} doubleHardline>\n {(segments, index) => (\n <Show\n when={index > 0}\n fallback={\n <IfStatement\n condition={code`segments.join(\"/\").toLowerCase() === \"${segments\n .join(\"/\")\n .toLowerCase()}\"`}>\n {code` showHelp${segments\n .map(segment => pascalCase(segment))\n .join(\"\")}(); `}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`segments.join(\"/\").toLowerCase() === \"${segments\n .join(\"/\")\n .toLowerCase()}\"`}>\n {code` showHelp${segments\n .map(segment => pascalCase(segment))\n .join(\"\")}(); `}\n </ElseIfClause>\n </Show>\n )}\n </For>\n <ElseClause>{code`showHelp(); `}</ElseClause>\n </Show>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":"8oBA8BA,SAAE,GAAA,CACA,IAAM,EAAC,GAAwB,CACjC,OAAS,EAAkB,EAAa,CACxC,IAAQ,MAAC,CACH,OAAO,EAAC,EAAiB,UAAW,OAAO,aAAO,EAEtD,IAAA,UAAA,CACG,MAAA,CAAS,CAAC,iOAAqO,EAAiB,EAAQ,EAAA,CAAA,CAAA,EAAwB,EAAI,CACvS,QAAA,0EACK,IAAA,UAAS,CACR,OAAS,EAAe,EAAA,iBAEvB,SAAA,mOACJ,CAAA,EAEE,CAAA,CAAA,EAAS,EAAA,CACT,OAAM,GACL,QAAW,GACX,MAAO,GACP,KAAE,UACF,WAAK,CAAA,CACN,KAAA,WACC,KAAA,WACA,QAAA,KACA,CAAA,CACD,CAAC,CAAA,EAEL,CAAC,eAMJ,IAAO,EAAU,GAAA,CACf,EAAoB,MAAA,EAAA,SAAA,EAAA,SAAA,QAAA,EAAA,KACtB,EAAA,EAAA,OAAA,GAAA,EAAA,EAAA,CAAA,iBAEE,MAAA,WAAA,EAAA,IAAA,GAAA,EAAA,EAAA,QAAA,KAAA,GAAA,CAAA,CAAA,CAAA,KAAA,GAAA,GACC,CAAG,CACJ,GACF,EAAO,CAAA,CAAA,EAAA,CAAA,CACC,EAAU,EAAc,UAAA,EAAkB,aAEhD,IAAM,MAAA,CACJ,OAAM,EAAA,EAAA,UAAA,OAAA,aAAA,EAEN,QAAO,CACL,UAAU,KACV,mBAAQ,CAAA,WAAA,YAAA,CACT,CACD,IAAI,gBAAgB,CAClB,MAAO,CACL,GAAG,EAAY,MACf,KAAM,CAAA,WAAA,CACN,QAAK,CAAA,YAAA,YAAA,aAAA,aAAA,UAAA,OAAA,OAAA,QAAA,OAAA,CACN,EAEH,IAAI,UAAQ,CACV,MAAE,CAAA,EAAA,EAAA,CACA,QAAC,0EACN,IAAA,UAAA,aAEK,KAAA,uPAEC,CAAA,EAEH,CAAA,CAAI,EAAY,EAA2B,CAC3C,OAAS,GACP,QAAW,GACX,MAAM,GACP,KAAA,UACD,WAAc,CAAC,CACX,KAAC,WACH,KAAQ,WACR,QAAS,KACR,CAAC,CACF,IAAG,UAAU,CACX,OAAC,EAAW,EAAA,CACX,IAAA,MAAW,CACX,OAAQ,EAAA,OAAA,GAER,SAAK,CAAA,eACL,IAAK,UAAC,CACN,MAAI,CAAA,EAAA,EAAA,CACP,KAAA,EACA,eAAA,GACK,UAAS,EAAe,IAAO,EAAkB,EAAO,CAC5D,KAAe,EAAE,EACV,IAAA,UAAiB,CACb,OAAA,EAAA,EAAA,CACP,IAAA,WAAA,CACN,MAAA,EAAA,yCAAA,EAAA,KAAA,IAAA,CAAA,aAAA,CAAA,IAEC,IAAA,UAAA,CACA,MAAA,EAAA,YAAA,EAAA,IAAA,GAAA,EAAA,EAAA,CAAA,CAAA,KAAA,GAAA,CAAA,OAEa,CAAC,EAEN,IAAA,UAAA,CACI,OAAK,EAAc,EAAA,CAClB,IAAA,WAAA,CACG,MAAO,EAAG,yCAAA,EAAA,KAAA,IAAA,CAAA,aAAA,CAAA,IAEZ,IAAA,UAAS,CACP,MAAC,EAAA,YAAA,EAAA,IAAA,GAAA,EAAA,EAAA,CAAA,CAAA,KAAA,GAAA,CAAA,OAEL,CAAA,EAEH,CAAC,CACH,CAAC,CAAE,EAAkB,EAAC,CACrB,SAAU,CAAC,eACZ,CAAC,CAAC,EAEN,CAAC,EAEL,CAAC,CAAC,EAEN,CAAC"}
1
+ {"version":3,"file":"help-command.mjs","names":[],"sources":[],"mappings":""}
@@ -1 +1,14 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./display.cjs`),t=require(`./help-builtin.cjs`),n=require(`./help-command.cjs`);exports.BaseHelpDisplay=e.BaseHelpDisplay,exports.CommandHelpDisplay=e.CommandHelpDisplay,exports.HelpBuiltin=t.HelpBuiltin,exports.HelpCommand=n.HelpCommand,exports.HelpCommandsDisplay=e.HelpCommandsDisplay,exports.HelpOptionsDisplay=e.HelpOptionsDisplay,exports.HelpUsageDisplay=e.HelpUsageDisplay,exports.TemporaryHelpCommand=n.TemporaryHelpCommand,exports.VirtualCommandHelpDisplay=e.VirtualCommandHelpDisplay;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_components_display = require('./display.cjs');
3
+ const require_components_help_builtin = require('./help-builtin.cjs');
4
+ const require_components_help_command = require('./help-command.cjs');
5
+
6
+ exports.BaseHelpDisplay = require_components_display.BaseHelpDisplay;
7
+ exports.CommandHelpDisplay = require_components_display.CommandHelpDisplay;
8
+ exports.HelpBuiltin = require_components_help_builtin.HelpBuiltin;
9
+ exports.HelpCommand = require_components_help_command.HelpCommand;
10
+ exports.HelpCommandsDisplay = require_components_display.HelpCommandsDisplay;
11
+ exports.HelpOptionsDisplay = require_components_display.HelpOptionsDisplay;
12
+ exports.HelpUsageDisplay = require_components_display.HelpUsageDisplay;
13
+ exports.TemporaryHelpCommand = require_components_help_command.TemporaryHelpCommand;
14
+ exports.VirtualCommandHelpDisplay = require_components_display.VirtualCommandHelpDisplay;
@@ -1 +1,5 @@
1
- import{BaseHelpDisplay as e,CommandHelpDisplay as t,HelpCommandsDisplay as n,HelpOptionsDisplay as r,HelpUsageDisplay as i,VirtualCommandHelpDisplay as a}from"./display.mjs";import{HelpBuiltin as o}from"./help-builtin.mjs";import{HelpCommand as s,TemporaryHelpCommand as c}from"./help-command.mjs";export{e as BaseHelpDisplay,t as CommandHelpDisplay,o as HelpBuiltin,s as HelpCommand,n as HelpCommandsDisplay,r as HelpOptionsDisplay,i as HelpUsageDisplay,c as TemporaryHelpCommand,a as VirtualCommandHelpDisplay};
1
+ import { BaseHelpDisplay, CommandHelpDisplay, HelpCommandsDisplay, HelpOptionsDisplay, HelpUsageDisplay, VirtualCommandHelpDisplay } from "./display.mjs";
2
+ import { HelpBuiltin } from "./help-builtin.mjs";
3
+ import { HelpCommand, TemporaryHelpCommand } from "./help-command.mjs";
4
+
5
+ export { BaseHelpDisplay, CommandHelpDisplay, HelpBuiltin, HelpCommand, HelpCommandsDisplay, HelpOptionsDisplay, HelpUsageDisplay, TemporaryHelpCommand, VirtualCommandHelpDisplay };
package/dist/index.cjs CHANGED
@@ -1 +1,97 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./components/help-builtin.cjs`),n=require(`./components/help-command.cjs`);require(`./components/index.cjs`);let r=require(`@alloy-js/core/jsx-runtime`),i=require(`@alloy-js/core`),a=require(`@powerlines/plugin-alloy/core/components`),o=require(`@powerlines/plugin-alloy/render`),s=require(`@shell-shock/core/plugin-utils`),c=require(`@shell-shock/plugin-console`);c=e.__toESM(c);let l=require(`@shell-shock/plugin-theme`);l=e.__toESM(l);let u=require(`@stryke/helpers/get-unique`),d=require(`@stryke/path/join`),f=require(`@stryke/type-checks/is-set-string`),p=require(`defu`);p=e.__toESM(p);const m=(e={})=>[...(0,l.default)(e.theme),...(0,c.default)(e.console),{name:`shell-shock:help`,enforce:`post`,config(){return this.debug("Providing default configuration for the Shell Shock `help` plugin."),{help:(0,p.default)({command:e.command===!1?!1:(0,f.isSetString)(e.command)?{name:e.command}:{name:`help`}},e,{builtins:!0})}},async configResolved(){this.debug(`Adding the Help command to the application context.`),this.config.help.command!==!1&&(this.inputs??=[],this.inputs.some(e=>e.name===this.config.help.command.name)?this.info("The `help` command already exists in the commands list. If you would like the help command to be managed by the `@shell-shock/plugin-help` package, please remove or rename the command."):this.inputs.push({id:this.config.help.command.name,path:this.config.help.command.name,segments:[this.config.help.command.name],title:`Help`,icon:`🛈`,tags:[`Utility`],description:`Display command usage details and other useful information to the user.`,entry:{file:(0,d.joinPaths)(this.entryPath,`help`,`index.ts`),input:{file:(0,d.joinPaths)(this.entryPath,`help`,`command.ts`)}},isVirtual:!1,source:`help-plugin`,...this.config.help.command}),await(0,o.render)(this,(0,r.createComponent)(n.TemporaryHelpCommand,{})))},prepare:{order:`post`,async handler(){let e=this,c=await(0,s.getCommandList)(this);this.debug(`Rendering \`help\` built-ins for each of the ${c.length} command modules.`);let l=(0,i.computed)(()=>(0,u.getUniqueBy)(c.map(e=>e.segments.filter(e=>!(0,s.isDynamicPathSegment)(e)).filter(e=>e.length>0)),e=>e.join(`/`)).filter(e=>e.length>0).sort((e,t)=>e.join(`/`).localeCompare(t.join(`/`))));return(0,o.render)(this,[(0,r.createComponent)(i.Show,{get when(){return e.config.help.builtins!==!1},get children(){return[(0,r.createComponent)(t.HelpBuiltin,{get command(){return(0,s.computeBin)(e)}}),(0,r.createComponent)(a.Spacing,{}),(0,r.createComponent)(i.For,{get each(){return c.sort((e,t)=>e.name.localeCompare(t.name))},doubleHardline:!0,children:e=>(0,r.createComponent)(t.HelpBuiltin,{command:e})}),(0,r.createComponent)(n.HelpCommand,{get segments(){return l.value}})]}})])}}}];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_help_builtin = require('./components/help-builtin.cjs');
4
+ const require_components_help_command = require('./components/help-command.cjs');
5
+ require('./components/index.cjs');
6
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
7
+ let _alloy_js_core = require("@alloy-js/core");
8
+ let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
9
+ let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
10
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
11
+ let _shell_shock_plugin_console = require("@shell-shock/plugin-console");
12
+ _shell_shock_plugin_console = require_runtime.__toESM(_shell_shock_plugin_console);
13
+ let _shell_shock_plugin_theme = require("@shell-shock/plugin-theme");
14
+ _shell_shock_plugin_theme = require_runtime.__toESM(_shell_shock_plugin_theme);
15
+ let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
16
+ let _stryke_path_join = require("@stryke/path/join");
17
+ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
18
+ let defu = require("defu");
19
+ defu = require_runtime.__toESM(defu);
20
+
21
+ //#region src/index.tsx
22
+ /**
23
+ * The Help - Shell Shock plugin to add a help command to the application.
24
+ */
25
+ const plugin = (options = {}) => {
26
+ return [
27
+ ...(0, _shell_shock_plugin_theme.default)(options.theme),
28
+ ...(0, _shell_shock_plugin_console.default)(options.console),
29
+ {
30
+ name: "shell-shock/help",
31
+ enforce: "post",
32
+ config() {
33
+ this.debug("Providing default configuration for the Shell Shock `help` plugin.");
34
+ return { help: (0, defu.default)({ command: options.command === false ? false : (0, _stryke_type_checks_is_set_string.isSetString)(options.command) ? { name: options.command } : { name: "help" } }, options, { builtins: true }) };
35
+ },
36
+ async configResolved() {
37
+ this.debug("Adding the Help command to the application context.");
38
+ if (this.config.help.command !== false) {
39
+ this.inputs ??= [];
40
+ if (this.inputs.some((input) => input.name === this.config.help.command.name)) this.info("The `help` command already exists in the commands list. If you would like the help command to be managed by the `@shell-shock/plugin-help` package, please remove or rename the command.");
41
+ else this.inputs.push({
42
+ id: this.config.help.command.name,
43
+ path: this.config.help.command.name,
44
+ segments: [this.config.help.command.name],
45
+ title: "Help",
46
+ icon: "🛈",
47
+ tags: ["Utility"],
48
+ description: `Display command usage details and other useful information to the user.`,
49
+ entry: {
50
+ file: (0, _stryke_path_join.joinPaths)(this.entryPath, "help", "index.ts"),
51
+ input: { file: (0, _stryke_path_join.joinPaths)(this.entryPath, "help", "command.ts") }
52
+ },
53
+ virtual: false,
54
+ ...this.config.help.command
55
+ });
56
+ await (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_help_command.TemporaryHelpCommand, {}));
57
+ }
58
+ },
59
+ prepare: {
60
+ order: "post",
61
+ async handler() {
62
+ const _self$ = this;
63
+ const commands = await (0, _shell_shock_core_plugin_utils.getCommandList)(this);
64
+ this.debug(`Rendering \`help\` built-ins for each of the ${commands.length} command modules.`);
65
+ const segments = (0, _alloy_js_core.computed)(() => (0, _stryke_helpers_get_unique.getUniqueBy)(commands.map((command) => command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)).filter((segment) => segment.length > 0)), (segments) => segments.join("/")).filter((segments) => segments.length > 0).sort((a, b) => a.join("/").localeCompare(b.join("/"))));
66
+ return (0, _powerlines_plugin_alloy_render.render)(this, [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
67
+ get when() {
68
+ return _self$.config.help.builtins !== false;
69
+ },
70
+ get children() {
71
+ return [
72
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_help_builtin.HelpBuiltin, { get command() {
73
+ return (0, _shell_shock_core_plugin_utils.computeBin)(_self$);
74
+ } }),
75
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
76
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
77
+ get each() {
78
+ return commands.sort((a, b) => a.name.localeCompare(b.name));
79
+ },
80
+ doubleHardline: true,
81
+ children: (command) => (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_help_builtin.HelpBuiltin, { command })
82
+ }),
83
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_help_command.HelpCommand, { get commands() {
84
+ return segments.value;
85
+ } })
86
+ ];
87
+ }
88
+ })]);
89
+ }
90
+ }
91
+ }
92
+ ];
93
+ };
94
+
95
+ //#endregion
96
+ exports.default = plugin;
97
+ exports.plugin = plugin;
package/dist/index.d.cts CHANGED
@@ -7,5 +7,5 @@ import { Plugin } from "powerlines";
7
7
  */
8
8
  declare const plugin: <TContext extends HelpPluginContext = HelpPluginContext>(options?: HelpPluginOptions) => Plugin<TContext>[];
9
9
  //#endregion
10
- export { HelpPluginContext, HelpPluginOptions, HelpPluginResolvedConfig, HelpPluginUserConfig, plugin as default, plugin };
10
+ export { type HelpPluginContext, type HelpPluginOptions, type HelpPluginResolvedConfig, type HelpPluginUserConfig, plugin as default, plugin };
11
11
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -7,5 +7,5 @@ import { Plugin } from "powerlines";
7
7
  */
8
8
  declare const plugin: <TContext extends HelpPluginContext = HelpPluginContext>(options?: HelpPluginOptions) => Plugin<TContext>[];
9
9
  //#endregion
10
- export { HelpPluginContext, HelpPluginOptions, HelpPluginResolvedConfig, HelpPluginUserConfig, plugin as default, plugin };
10
+ export { type HelpPluginContext, type HelpPluginOptions, type HelpPluginResolvedConfig, type HelpPluginUserConfig, plugin as default, plugin };
11
11
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AA0CA;cAAa,MAAA,oBAA2B,iBAAA,GAAoB,iBAAA,EAC1D,OAAA,GAAS,iBAAA,KACR,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":""}