@shell-shock/core 0.8.9 → 0.8.10

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,5 +1,5 @@
1
1
  import { CommandTree } from "../types/command.mjs";
2
- import * as _alloy_js_core0 from "@alloy-js/core";
2
+ import * as _alloy_js_core9 from "@alloy-js/core";
3
3
  import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
4
4
 
5
5
  //#region src/components/docs.d.ts
@@ -12,7 +12,7 @@ interface CommandOptionsDocsProps {
12
12
  /**
13
13
  * Generates the options markdown documentation for a command.
14
14
  */
15
- declare function CommandOptionsDocs(props: CommandOptionsDocsProps): _alloy_js_core0.Children;
15
+ declare function CommandOptionsDocs(props: CommandOptionsDocsProps): _alloy_js_core9.Children;
16
16
  interface CommandDocsUsageExampleProps {
17
17
  /**
18
18
  * The package manager to generate the usage example for.
@@ -31,7 +31,7 @@ interface CommandDocsUsageExampleProps {
31
31
  /**
32
32
  * Generates the markdown documentation for a command.
33
33
  */
34
- declare function CommandDocsUsageExample(props: CommandDocsUsageExampleProps): _alloy_js_core0.Children;
34
+ declare function CommandDocsUsageExample(props: CommandDocsUsageExampleProps): _alloy_js_core9.Children;
35
35
  interface CommandDocsProps {
36
36
  /**
37
37
  * The heading level offset to apply to the generated documentation.
@@ -56,7 +56,7 @@ interface CommandDocsProps {
56
56
  /**
57
57
  * Generates the markdown documentation for a command.
58
58
  */
59
- declare function CommandDocs(props: CommandDocsProps): _alloy_js_core0.Children;
59
+ declare function CommandDocs(props: CommandDocsProps): _alloy_js_core9.Children;
60
60
  interface CommandDocsFileProps extends Partial<MarkdownFileProps> {
61
61
  /**
62
62
  * The heading level offset to apply to the generated documentation.
@@ -75,7 +75,7 @@ interface CommandDocsFileProps extends Partial<MarkdownFileProps> {
75
75
  /**
76
76
  * Generates the markdown documentation file for a command.
77
77
  */
78
- declare function CommandDocsFile(props: CommandDocsFileProps): _alloy_js_core0.Children;
78
+ declare function CommandDocsFile(props: CommandDocsFileProps): _alloy_js_core9.Children;
79
79
  //#endregion
80
80
  export { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps };
81
81
  //# sourceMappingURL=docs.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import { CommandOption, CommandTree } from "../types/command.mjs";
2
- import * as _alloy_js_core4 from "@alloy-js/core";
2
+ import * as _alloy_js_core1 from "@alloy-js/core";
3
3
 
4
4
  //#region src/components/options-parser-logic.d.ts
5
5
  interface DynamicSegmentsParserLogicProps {
@@ -12,7 +12,7 @@ interface DynamicSegmentsParserLogicProps {
12
12
  */
13
13
  isCaseSensitive: boolean;
14
14
  }
15
- declare function DynamicSegmentsParserLogic(props: DynamicSegmentsParserLogicProps): _alloy_js_core4.Children;
15
+ declare function DynamicSegmentsParserLogic(props: DynamicSegmentsParserLogicProps): _alloy_js_core1.Children;
16
16
  interface ArgumentsParserLogicProps {
17
17
  /**
18
18
  * The command to generate the positional parameters parser logic for.
@@ -27,7 +27,7 @@ interface ArgumentsParserLogicProps {
27
27
  */
28
28
  isCaseSensitive: boolean;
29
29
  }
30
- declare function ArgumentsParserLogic(props: ArgumentsParserLogicProps): _alloy_js_core4.Children;
30
+ declare function ArgumentsParserLogic(props: ArgumentsParserLogicProps): _alloy_js_core1.Children;
31
31
  /**
32
32
  * The command option interface property.
33
33
  */
@@ -35,7 +35,7 @@ declare function OptionsMember({
35
35
  option
36
36
  }: {
37
37
  option: CommandOption;
38
- }): _alloy_js_core4.Children;
38
+ }): _alloy_js_core1.Children;
39
39
  interface OptionsMemberParserLogicProps {
40
40
  /**
41
41
  * The option name to generate the parser logic for.
@@ -55,7 +55,7 @@ interface OptionsMemberParserLogicProps {
55
55
  /**
56
56
  * The command option property parser logic.
57
57
  */
58
- declare function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps): _alloy_js_core4.Children;
58
+ declare function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps): _alloy_js_core1.Children;
59
59
  interface OptionsMemberParserConditionProps {
60
60
  /**
61
61
  * The option name to generate the parser logic for.
@@ -72,10 +72,10 @@ interface OptionsMemberParserConditionProps {
72
72
  */
73
73
  isCaseSensitive: boolean;
74
74
  }
75
- declare function OptionsMemberParserCondition(props: OptionsMemberParserConditionProps): _alloy_js_core4.Children;
75
+ declare function OptionsMemberParserCondition(props: OptionsMemberParserConditionProps): _alloy_js_core1.Children;
76
76
  declare function OptionsInterfaceDeclaration(props: {
77
77
  command: CommandTree;
78
- }): _alloy_js_core4.Children;
78
+ }): _alloy_js_core1.Children;
79
79
  interface OptionsParserLogicProps {
80
80
  /**
81
81
  * The command to generate the options parser logic for.
@@ -95,7 +95,7 @@ interface OptionsParserLogicProps {
95
95
  /**
96
96
  * The command options parser logic.
97
97
  */
98
- declare function OptionsParserLogic(props: OptionsParserLogicProps): _alloy_js_core4.Children;
98
+ declare function OptionsParserLogic(props: OptionsParserLogicProps): _alloy_js_core1.Children;
99
99
  interface CommandParserLogicProps {
100
100
  /**
101
101
  * The command to generate the parser logic for.
@@ -115,7 +115,7 @@ interface CommandParserLogicProps {
115
115
  /**
116
116
  * The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.
117
117
  */
118
- declare function CommandParserLogic(props: CommandParserLogicProps): _alloy_js_core4.Children;
118
+ declare function CommandParserLogic(props: CommandParserLogicProps): _alloy_js_core1.Children;
119
119
  //#endregion
120
120
  export { ArgumentsParserLogic, ArgumentsParserLogicProps, CommandParserLogic, CommandParserLogicProps, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps };
121
121
  //# sourceMappingURL=options-parser-logic.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import { CommandTree } from "../types/command.cjs";
2
- import * as _alloy_js_core0 from "@alloy-js/core";
2
+ import * as _alloy_js_core7 from "@alloy-js/core";
3
3
 
4
4
  //#region src/components/usage.d.ts
5
5
  interface UsageProps {
@@ -22,7 +22,7 @@ interface UsageProps {
22
22
  /**
23
23
  * A component that generates the usage display for a command.
24
24
  */
25
- declare function Usage(props: UsageProps): _alloy_js_core0.Children;
25
+ declare function Usage(props: UsageProps): _alloy_js_core7.Children;
26
26
  //#endregion
27
27
  export { Usage, UsageProps };
28
28
  //# sourceMappingURL=usage.d.cts.map
@@ -1,5 +1,5 @@
1
1
  import { CommandTree } from "../types/command.mjs";
2
- import * as _alloy_js_core12 from "@alloy-js/core";
2
+ import * as _alloy_js_core0 from "@alloy-js/core";
3
3
 
4
4
  //#region src/components/usage.d.ts
5
5
  interface UsageProps {
@@ -22,7 +22,7 @@ interface UsageProps {
22
22
  /**
23
23
  * A component that generates the usage display for a command.
24
24
  */
25
- declare function Usage(props: UsageProps): _alloy_js_core12.Children;
25
+ declare function Usage(props: UsageProps): _alloy_js_core0.Children;
26
26
  //#endregion
27
27
  export { Usage, UsageProps };
28
28
  //# sourceMappingURL=usage.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.mts","names":[],"sources":["../../src/components/usage.tsx"],"sourcesContent":[],"mappings":";;;;UA2BiB,UAAA;;;AAAjB;EAuBgB,OAAA,EAnBL,WAmBkB;;;;;;;;;;;;;;;;iBAAb,KAAA,QAAa,aAAU,gBAAA,CAAA"}
1
+ {"version":3,"file":"usage.d.mts","names":[],"sources":["../../src/components/usage.tsx"],"sourcesContent":[],"mappings":";;;;UA2BiB,UAAA;;;AAAjB;EAuBgB,OAAA,EAnBL,WAmBkB;;;;;;;;;;;;;;;;iBAAb,KAAA,QAAa,aAAU,eAAA,CAAA"}
@@ -29,7 +29,7 @@ let powerlines_lib_utilities_resolve = require("powerlines/lib/utilities/resolve
29
29
  * @returns The resolved description for the command option.
30
30
  */
31
31
  function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
32
- return `A${optional && !defaultValue ? "n optional" : ""} command line ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "flag" : "option"} that allows the user to ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "indicator" : `${kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
32
+ return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "flag" : "option"} that allows the user to ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "indicator" : `${kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
33
33
  }
34
34
  /**
35
35
  * Resolves the description for a command argument based on its reflection.
@@ -164,7 +164,7 @@ async function reflectCommandTree(context, command, parent) {
164
164
  const type = (0, __powerlines_deepkit_vendor_type.reflect)(resolved);
165
165
  if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.function) throw new Error(`The command entry file "${command.entry.input.file}" does not export a valid function.`);
166
166
  tree.reflection = new __powerlines_deepkit_vendor_type.ReflectionFunction(type);
167
- tree.description ??= command.description || type.description || `The ${tree.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command line interface.`;
167
+ tree.description ??= command.description || type.description || `The ${tree.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
168
168
  const parameters = tree.reflection.getParameters();
169
169
  if (parameters.length > 0 && parameters[0]) {
170
170
  if (parameters[0].type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral || parameters[0].type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.class) {
@@ -180,7 +180,7 @@ async function reflectCommandTree(context, command, parent) {
180
180
  }
181
181
  });
182
182
  }
183
- } else tree.description ??= `A collection of available ${tree.title.replace(/(?:c|C)ommands?$/, "").trim() || (0, __stryke_string_format_title_case.titleCase)(tree.name)} commands that are included in the ${require_plugin_utils_context_helpers.getAppTitle(context)} command line application.`;
183
+ } else tree.description ??= `A collection of available ${tree.title.replace(/(?:c|C)ommands?$/, "").trim() || (0, __stryke_string_format_title_case.titleCase)(tree.name)} commands that are included in the ${require_plugin_utils_context_helpers.getAppTitle(context)} command-line application.`;
184
184
  if (context.env) {
185
185
  if ((0, __stryke_type_checks_is_set_object.isSetObject)(tree.options)) Object.values(tree.options).filter((option) => option.env !== false).forEach((option) => {
186
186
  context.env.types.env.addProperty({
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-command.cjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionFunction","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getDefaultOptions","resolveCommandOptionDescription","name","kind","optional","variadic","title","defaultValue","boolean","trim","number","resolveCommandArgumentDescription","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandDynamicPathSegments","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","type","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","string","Error","extractCommandArgument","array","getName","argument","getAlias","parameter","reflectCommandTree","parent","isVirtual","replace","tree","icon","options","arguments","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","getParameters","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","slice","arg","forEach","index","found","findIndex","segments","some","segment","Object","values","types","addProperty","undefined","visibility","public","tags","domain","inputs","every","value"],"sources":["../../src/helpers/resolve-command.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption,\n StringCommandArgument,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command line ${\n kind === ReflectionKind.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getNameAsString(),\n reflection.getKind(),\n reflection.isOptional(),\n reflection.isArray(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: type.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray(),\n reflection\n } as CommandOption;\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind = (\n type as TypeArray\n ).type.kind as ReflectionKind.string | ReflectionKind.number;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command positional argument information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command positional argument information.\n */\nexport function extractCommandArgument(\n command: CommandInput,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n\n if (\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName(),\n alias: reflection.getAlias(),\n kind: type.kind,\n title: titleCase(reflection.getName()),\n description:\n reflection.parameter.description ||\n resolveCommandArgumentDescription(\n reflection.getName(),\n type.kind === ReflectionKind.array ? type.type.kind : type.kind,\n reflection.isOptional(),\n type.kind === ReflectionKind.array,\n titleCase(reflection.getName()),\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getName()),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n reflection\n } as CommandArgument;\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandArgument | NumberCommandArgument).variadic =\n true;\n (argument as StringCommandArgument | NumberCommandArgument).kind =\n type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return argument;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const tree = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n arguments: [],\n parent: parent ?? null,\n children: {},\n reflection: null\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n tree.icon = metadata.icon;\n }\n\n const type = reflect(resolved);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.reflection = new ReflectionFunction(type);\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command line interface.`;\n\n const parameters = tree.reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n } else {\n throw new Error(\n `The first parameter of the command handler function in \"${\n command.entry.input.file\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n tree.arguments = parameters\n .slice(1)\n .map(arg => extractCommandArgument(command, arg));\n\n // Ensure unique argument names by appending an index suffix to duplicates\n tree.arguments.forEach((argument, index) => {\n const found = tree.arguments.findIndex(\n arg => arg.name === argument.name\n );\n if (\n (found !== -1 && found !== index) ||\n tree.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n tree.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n tree.arguments.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title.replace(/(?:c|C)ommands?$/, \"\").trim() || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.reflection?.getType() ??\n ((option as StringCommandOption | NumberCommandOption).variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }),\n default: option.default,\n tags: {\n ...option.reflection?.getTags(),\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n tree.arguments\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: arg.reflection.getType(),\n default: arg.default,\n tags: {\n ...arg.reflection.getTags(),\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.segments\n .slice(0, command.segments.length)\n .every((value, index) => value === command.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgByB,gCACdC,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,gBACtDJ,SAASvB,gDAAe4B,UAAU,SAAS,SAAQ,2BAEnDL,SAASvB,gDAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,qDAAcP,KAAK,CAAA,GAClCC,SAASvB,gDAAe4B,UACpB,cACA,GAAGL,SAASvB,gDAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;;;;;;;;;;;;AAeV,SAAgBM,kCACdT,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,KACLH,YAAY,CAACG,eAAe,cAAc,GAAE,oCAE5C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,QAAQ,CAAC,CAC7D7D,WACDG,QAAQwD,SAAS9E,QAAOgF,YAAW,CAACnG,0DAAqBmG,QAAQ,CAAC,CAC/D7D,SACD,KACJmC,QAAMwB,SACHN,MAAM,GAAGlD,QAAQwD,SAAS3D,OAAO,CACjCwE,OAAOC,OAAOjB,UAAUiB,UAAUtE,QAAQwD,SAASH,OAC1D,CAAC,CACC1B,MAAKI,SAASC,MAAMrE,QAAQ,MAAM4D,mBAAmBjD,SAAS0D,OAAOL,KAAK;AAG5E,QAAOA"}
1
+ {"version":3,"file":"resolve-command.cjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionFunction","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getDefaultOptions","resolveCommandOptionDescription","name","kind","optional","variadic","title","defaultValue","boolean","trim","number","resolveCommandArgumentDescription","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandDynamicPathSegments","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","type","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","string","Error","extractCommandArgument","array","getName","argument","getAlias","parameter","reflectCommandTree","parent","isVirtual","replace","tree","icon","options","arguments","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","getParameters","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","slice","arg","forEach","index","found","findIndex","segments","some","segment","Object","values","types","addProperty","undefined","visibility","public","tags","domain","inputs","every","value"],"sources":["../../src/helpers/resolve-command.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption,\n StringCommandArgument,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === ReflectionKind.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getNameAsString(),\n reflection.getKind(),\n reflection.isOptional(),\n reflection.isArray(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: type.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray(),\n reflection\n } as CommandOption;\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind = (\n type as TypeArray\n ).type.kind as ReflectionKind.string | ReflectionKind.number;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command positional argument information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command positional argument information.\n */\nexport function extractCommandArgument(\n command: CommandInput,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n\n if (\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName(),\n alias: reflection.getAlias(),\n kind: type.kind,\n title: titleCase(reflection.getName()),\n description:\n reflection.parameter.description ||\n resolveCommandArgumentDescription(\n reflection.getName(),\n type.kind === ReflectionKind.array ? type.type.kind : type.kind,\n reflection.isOptional(),\n type.kind === ReflectionKind.array,\n titleCase(reflection.getName()),\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getName()),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n reflection\n } as CommandArgument;\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandArgument | NumberCommandArgument).variadic =\n true;\n (argument as StringCommandArgument | NumberCommandArgument).kind =\n type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return argument;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const tree = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n arguments: [],\n parent: parent ?? null,\n children: {},\n reflection: null\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n tree.icon = metadata.icon;\n }\n\n const type = reflect(resolved);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.reflection = new ReflectionFunction(type);\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n\n const parameters = tree.reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n } else {\n throw new Error(\n `The first parameter of the command handler function in \"${\n command.entry.input.file\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n tree.arguments = parameters\n .slice(1)\n .map(arg => extractCommandArgument(command, arg));\n\n // Ensure unique argument names by appending an index suffix to duplicates\n tree.arguments.forEach((argument, index) => {\n const found = tree.arguments.findIndex(\n arg => arg.name === argument.name\n );\n if (\n (found !== -1 && found !== index) ||\n tree.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n tree.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n tree.arguments.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title.replace(/(?:c|C)ommands?$/, \"\").trim() || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command-line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.reflection?.getType() ??\n ((option as StringCommandOption | NumberCommandOption).variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }),\n default: option.default,\n tags: {\n ...option.reflection?.getTags(),\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n tree.arguments\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: arg.reflection.getType(),\n default: arg.default,\n tags: {\n ...arg.reflection.getTags(),\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.segments\n .slice(0, command.segments.length)\n .every((value, index) => value === command.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgByB,gCACdC,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,gBACtDJ,SAASvB,gDAAe4B,UAAU,SAAS,SAAQ,2BAEnDL,SAASvB,gDAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,qDAAcP,KAAK,CAAA,GAClCC,SAASvB,gDAAe4B,UACpB,cACA,GAAGL,SAASvB,gDAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;;;;;;;;;;;;AAeV,SAAgBM,kCACdT,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,KACLH,YAAY,CAACG,eAAe,cAAc,GAAE,oCAE5CJ,SAASvB,gDAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,qDAAcP,KAAK,CAAA,GAClCC,SAASvB,gDAAe4B,UACpB,cACA,GAAGL,SAASvB,gDAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;AAIV,SAAgBO,iBAAiBC,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OAC1D,CAAC,CACC1B,MAAKI,SAASC,MAAMrE,QAAQ,MAAM4D,mBAAmBjD,SAAS0D,OAAOL,KAAK;AAG5E,QAAOA"}
@@ -28,7 +28,7 @@ import { resolveModule } from "powerlines/lib/utilities/resolve";
28
28
  * @returns The resolved description for the command option.
29
29
  */
30
30
  function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
31
- return `A${optional && !defaultValue ? "n optional" : ""} command line ${kind === ReflectionKind.boolean ? "flag" : "option"} that allows the user to ${kind === ReflectionKind.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || titleCase(name)} ${kind === ReflectionKind.boolean ? "indicator" : `${kind === ReflectionKind.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
31
+ return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === ReflectionKind.boolean ? "flag" : "option"} that allows the user to ${kind === ReflectionKind.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || titleCase(name)} ${kind === ReflectionKind.boolean ? "indicator" : `${kind === ReflectionKind.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
32
32
  }
33
33
  /**
34
34
  * Resolves the description for a command argument based on its reflection.
@@ -163,7 +163,7 @@ async function reflectCommandTree(context, command, parent) {
163
163
  const type = reflect(resolved);
164
164
  if (type.kind !== ReflectionKind.function) throw new Error(`The command entry file "${command.entry.input.file}" does not export a valid function.`);
165
165
  tree.reflection = new ReflectionFunction(type);
166
- tree.description ??= command.description || type.description || `The ${tree.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command line interface.`;
166
+ tree.description ??= command.description || type.description || `The ${tree.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
167
167
  const parameters = tree.reflection.getParameters();
168
168
  if (parameters.length > 0 && parameters[0]) {
169
169
  if (parameters[0].type.kind === ReflectionKind.objectLiteral || parameters[0].type.kind === ReflectionKind.class) {
@@ -179,7 +179,7 @@ async function reflectCommandTree(context, command, parent) {
179
179
  }
180
180
  });
181
181
  }
182
- } else tree.description ??= `A collection of available ${tree.title.replace(/(?:c|C)ommands?$/, "").trim() || titleCase(tree.name)} commands that are included in the ${getAppTitle(context)} command line application.`;
182
+ } else tree.description ??= `A collection of available ${tree.title.replace(/(?:c|C)ommands?$/, "").trim() || titleCase(tree.name)} commands that are included in the ${getAppTitle(context)} command-line application.`;
183
183
  if (context.env) {
184
184
  if (isSetObject(tree.options)) Object.values(tree.options).filter((option) => option.env !== false).forEach((option) => {
185
185
  context.env.types.env.addProperty({
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-command.mjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionFunction","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getDefaultOptions","resolveCommandOptionDescription","name","kind","optional","variadic","title","defaultValue","boolean","trim","number","resolveCommandArgumentDescription","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandDynamicPathSegments","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","type","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","string","Error","extractCommandArgument","array","getName","argument","getAlias","parameter","reflectCommandTree","parent","isVirtual","replace","tree","icon","options","arguments","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","getParameters","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","slice","arg","forEach","index","found","findIndex","segments","some","segment","Object","values","types","addProperty","undefined","visibility","public","tags","domain","inputs","every","value"],"sources":["../../src/helpers/resolve-command.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption,\n StringCommandArgument,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command line ${\n kind === ReflectionKind.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getNameAsString(),\n reflection.getKind(),\n reflection.isOptional(),\n reflection.isArray(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: type.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray(),\n reflection\n } as CommandOption;\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind = (\n type as TypeArray\n ).type.kind as ReflectionKind.string | ReflectionKind.number;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command positional argument information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command positional argument information.\n */\nexport function extractCommandArgument(\n command: CommandInput,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n\n if (\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName(),\n alias: reflection.getAlias(),\n kind: type.kind,\n title: titleCase(reflection.getName()),\n description:\n reflection.parameter.description ||\n resolveCommandArgumentDescription(\n reflection.getName(),\n type.kind === ReflectionKind.array ? type.type.kind : type.kind,\n reflection.isOptional(),\n type.kind === ReflectionKind.array,\n titleCase(reflection.getName()),\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getName()),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n reflection\n } as CommandArgument;\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandArgument | NumberCommandArgument).variadic =\n true;\n (argument as StringCommandArgument | NumberCommandArgument).kind =\n type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return argument;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const tree = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n arguments: [],\n parent: parent ?? null,\n children: {},\n reflection: null\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n tree.icon = metadata.icon;\n }\n\n const type = reflect(resolved);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.reflection = new ReflectionFunction(type);\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command line interface.`;\n\n const parameters = tree.reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n } else {\n throw new Error(\n `The first parameter of the command handler function in \"${\n command.entry.input.file\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n tree.arguments = parameters\n .slice(1)\n .map(arg => extractCommandArgument(command, arg));\n\n // Ensure unique argument names by appending an index suffix to duplicates\n tree.arguments.forEach((argument, index) => {\n const found = tree.arguments.findIndex(\n arg => arg.name === argument.name\n );\n if (\n (found !== -1 && found !== index) ||\n tree.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n tree.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n tree.arguments.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title.replace(/(?:c|C)ommands?$/, \"\").trim() || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.reflection?.getType() ??\n ((option as StringCommandOption | NumberCommandOption).variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }),\n default: option.default,\n tags: {\n ...option.reflection?.getTags(),\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n tree.arguments\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: arg.reflection.getType(),\n default: arg.default,\n tags: {\n ...arg.reflection.getTags(),\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.segments\n .slice(0, command.segments.length)\n .every((value, index) => value === command.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgByB,gCACdC,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,gBACtDJ,SAASvB,eAAe4B,UAAU,SAAS,SAAQ,2BAEnDL,SAASvB,eAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,IAAIjB,UAAUU,KAAK,CAAA,GAClCC,SAASvB,eAAe4B,UACpB,cACA,GAAGL,SAASvB,eAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;;;;;;;;;;;;AAeV,SAAgBM,kCACdT,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,KACLH,YAAY,CAACG,eAAe,cAAc,GAAE,oCAE5CJ,SAASvB,eAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,IAAIjB,UAAUU,KAAK,CAAA,GAClCC,SAASvB,eAAe4B,UACpB,cACA,GAAGL,SAASvB,eAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KAC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MAAK,MAAMnC,SAAS1D,QAAQ8F,OAAO1F,QACjCsD,YACEA,QAAMwB,SAAS9E,QAAOgF,YAAW,CAACnG,qBAAqBmG,QAAQ,CAAC,CAC7D7D,WACDG,QAAQwD,SAAS9E,QAAOgF,YAAW,CAACnG,qBAAqBmG,QAAQ,CAAC,CAC/D7D,SACD,KACJmC,QAAMwB,SACHN,MAAM,GAAGlD,QAAQwD,SAAS3D,OAAO,CACjCwE,OAAOC,OAAOjB,UAAUiB,UAAUtE,QAAQwD,SAASH,OAC1D,CAAC,CACC1B,MAAKI,SAASC,MAAMrE,QAAQ,MAAM4D,mBAAmBjD,SAAS0D,OAAOL,KAAK;AAG5E,QAAOA"}
1
+ {"version":3,"file":"resolve-command.mjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionFunction","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getDefaultOptions","resolveCommandOptionDescription","name","kind","optional","variadic","title","defaultValue","boolean","trim","number","resolveCommandArgumentDescription","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandDynamicPathSegments","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","type","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","string","Error","extractCommandArgument","array","getName","argument","getAlias","parameter","reflectCommandTree","parent","isVirtual","replace","tree","icon","options","arguments","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","getParameters","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","slice","arg","forEach","index","found","findIndex","segments","some","segment","Object","values","types","addProperty","undefined","visibility","public","tags","domain","inputs","every","value"],"sources":["../../src/helpers/resolve-command.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption,\n StringCommandArgument,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === ReflectionKind.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: ReflectionKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getNameAsString(),\n reflection.getKind(),\n reflection.isOptional(),\n reflection.isArray(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: type.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray(),\n reflection\n } as CommandOption;\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind = (\n type as TypeArray\n ).type.kind as ReflectionKind.string | ReflectionKind.number;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command positional argument information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command positional argument information.\n */\nexport function extractCommandArgument(\n command: CommandInput,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n\n if (\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName(),\n alias: reflection.getAlias(),\n kind: type.kind,\n title: titleCase(reflection.getName()),\n description:\n reflection.parameter.description ||\n resolveCommandArgumentDescription(\n reflection.getName(),\n type.kind === ReflectionKind.array ? type.type.kind : type.kind,\n reflection.isOptional(),\n type.kind === ReflectionKind.array,\n titleCase(reflection.getName()),\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getName()),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n reflection\n } as CommandArgument;\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandArgument | NumberCommandArgument).variadic =\n true;\n (argument as StringCommandArgument | NumberCommandArgument).kind =\n type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return argument;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const tree = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n arguments: [],\n parent: parent ?? null,\n children: {},\n reflection: null\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n tree.icon = metadata.icon;\n }\n\n const type = reflect(resolved);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.reflection = new ReflectionFunction(type);\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n\n const parameters = tree.reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n } else {\n throw new Error(\n `The first parameter of the command handler function in \"${\n command.entry.input.file\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n tree.arguments = parameters\n .slice(1)\n .map(arg => extractCommandArgument(command, arg));\n\n // Ensure unique argument names by appending an index suffix to duplicates\n tree.arguments.forEach((argument, index) => {\n const found = tree.arguments.findIndex(\n arg => arg.name === argument.name\n );\n if (\n (found !== -1 && found !== index) ||\n tree.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n tree.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n tree.arguments.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title.replace(/(?:c|C)ommands?$/, \"\").trim() || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command-line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.reflection?.getType() ??\n ((option as StringCommandOption | NumberCommandOption).variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }),\n default: option.default,\n tags: {\n ...option.reflection?.getTags(),\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n tree.arguments\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: arg.reflection.getType(),\n default: arg.default,\n tags: {\n ...arg.reflection.getTags(),\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.segments\n .slice(0, command.segments.length)\n .every((value, index) => value === command.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgByB,gCACdC,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,gBACtDJ,SAASvB,eAAe4B,UAAU,SAAS,SAAQ,2BAEnDL,SAASvB,eAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,IAAIjB,UAAUU,KAAK,CAAA,GAClCC,SAASvB,eAAe4B,UACpB,cACA,GAAGL,SAASvB,eAAe8B,SAAS,YAAY,SAAQ,QACtDL,WAAW,MAAM,KACjB;;;;;;;;;;;;;AAeV,SAAgBM,kCACdT,MACAC,MACAC,WAAW,OACXC,WAAW,OACXC,OACAC,cACQ;AACR,QAAO,KACLH,YAAY,CAACG,eAAe,cAAc,GAAE,oCAE5CJ,SAASvB,eAAe4B,UACpB,YACAH,WACE,mBACA,mBAAkB,GACtBC,OAAOG,MAAM,IAAIjB,UAAUU,KAAK,CAAA,GAClCC,SAASvB,eAA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,KAAIkB,UAAStD,aAAasD,MAAM,CAAC;IACpC6D,QAAQ;IACV;GACD,CACH,CAAC;;AAGL,MAAK,MAAMnC,SAAS1D,QAAQ8F,OAAO1F,QACjCsD,YACEA,QAAMwB,SAAS9E,QAAOgF,YAAW,CAACnG,qBAAqBmG,QAAQ,CAAC,CAC7D7D,WACDG,QAAQwD,SAAS9E,QAAOgF,YAAW,CAACnG,qBAAqBmG,QAAQ,CAAC,CAC/D7D,SACD,KACJmC,QAAMwB,SACHN,MAAM,GAAGlD,QAAQwD,SAAS3D,OAAO,CACjCwE,OAAOC,OAAOjB,UAAUiB,UAAUtE,QAAQwD,SAASH,OAC1D,CAAC,CACC1B,MAAKI,SAASC,MAAMrE,QAAQ,MAAM4D,mBAAmBjD,SAAS0D,OAAOL,KAAK;AAG5E,QAAOA"}
@@ -33,10 +33,12 @@ function getAppName(context) {
33
33
  * Retrieves the application title from the context and configuration.
34
34
  *
35
35
  * @param context - The build context containing workspace and package information.
36
+ * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.
36
37
  * @returns The application title in title-case format.
37
38
  */
38
- function getAppTitle(context) {
39
- return context.config.title || (0, __stryke_string_format_title_case.titleCase)(context.config.name || getAppName(context));
39
+ function getAppTitle(context, replaceCLI = false) {
40
+ const title = context.config.title || (0, __stryke_string_format_title_case.titleCase)(context.config.name || getAppName(context));
41
+ return replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title;
40
42
  }
41
43
  /**
42
44
  * Retrieves the application description from the context and configuration.
@@ -45,7 +47,7 @@ function getAppTitle(context) {
45
47
  * @returns The application description.
46
48
  */
47
49
  function getAppDescription(context) {
48
- return context.config.description || context.packageJson?.description || `The ${getAppTitle(context)} command-line interface application.`;
50
+ return context.config.description || context.packageJson?.description || `The ${getAppTitle(context, true)} command-line interface application.`;
49
51
  }
50
52
  /**
51
53
  * Retrieves the primary binary name for the application.
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","title","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return (\n context.config.title ||\n titleCase(context.config.name || getAppName(context))\n );\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yD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isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","replaceCLI","title","replace","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title;\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE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AW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
@@ -22,9 +22,10 @@ declare function getAppName(context: UnresolvedContext | Context): string;
22
22
  * Retrieves the application title from the context and configuration.
23
23
  *
24
24
  * @param context - The build context containing workspace and package information.
25
+ * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.
25
26
  * @returns The application title in title-case format.
26
27
  */
27
- declare function getAppTitle(context: UnresolvedContext | Context): string;
28
+ declare function getAppTitle(context: UnresolvedContext | Context, replaceCLI?: boolean): string;
28
29
  /**
29
30
  * Retrieves the application description from the context and configuration.
30
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBA3IgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAazC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
1
+ {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAsBgB,iBAnEA,cAAA,CAoEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBArJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAqBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
@@ -22,9 +22,10 @@ declare function getAppName(context: UnresolvedContext | Context): string;
22
22
  * Retrieves the application title from the context and configuration.
23
23
  *
24
24
  * @param context - The build context containing workspace and package information.
25
+ * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.
25
26
  * @returns The application title in title-case format.
26
27
  */
27
- declare function getAppTitle(context: UnresolvedContext | Context): string;
28
+ declare function getAppTitle(context: UnresolvedContext | Context, replaceCLI?: boolean): string;
28
29
  /**
29
30
  * Retrieves the application description from the context and configuration.
30
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBA3IgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAazC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
1
+ {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAsBgB,iBAnEA,cAAA,CAoEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBArJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAqBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
@@ -32,10 +32,12 @@ function getAppName(context) {
32
32
  * Retrieves the application title from the context and configuration.
33
33
  *
34
34
  * @param context - The build context containing workspace and package information.
35
+ * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.
35
36
  * @returns The application title in title-case format.
36
37
  */
37
- function getAppTitle(context) {
38
- return context.config.title || titleCase(context.config.name || getAppName(context));
38
+ function getAppTitle(context, replaceCLI = false) {
39
+ const title = context.config.title || titleCase(context.config.name || getAppName(context));
40
+ return replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title;
39
41
  }
40
42
  /**
41
43
  * Retrieves the application description from the context and configuration.
@@ -44,7 +46,7 @@ function getAppTitle(context) {
44
46
  * @returns The application description.
45
47
  */
46
48
  function getAppDescription(context) {
47
- return context.config.description || context.packageJson?.description || `The ${getAppTitle(context)} command-line interface application.`;
49
+ return context.config.description || context.packageJson?.description || `The ${getAppTitle(context, true)} command-line interface application.`;
48
50
  }
49
51
  /**
50
52
  * Retrieves the primary binary name for the application.
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","title","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return (\n context.config.title ||\n titleCase(context.config.name || getAppName(context))\n );\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QACEA,QAAQC,OAAOQ,SACfxB,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAUzD,SAAgBU,kBACdV,SACQ;AACR,QACEA,QAAQC,OAAOU,eACfX,QAAQM,aAAaK,eACrB,OAAOH,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBY,UAAUZ,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCU,OAAOC,KAAKd,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;AAepC,SAAgBe,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;AAcnD,SAAgBC,0BAA0BH,MAAsB;AAC9D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBC,mBAAmBL,MAAuB;AACxD,QAAQA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI,IAAKF,KAAKC,WAAW,IAAI;;;;;;;;;;;;;;AAe7E,SAAgBK,wBAAwBN,MAAsB;AAC5D,QAAOA,KACJI,WAAW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
1
+ {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","replaceCLI","title","replace","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title;\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC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WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
package/dist/plugin.cjs CHANGED
@@ -145,13 +145,13 @@ const plugin = (options = {}) => {
145
145
  async handler() {
146
146
  if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
147
147
  else {
148
- this.debug(`Shell Shock will create an application with the following commands: \n${this.inputs.filter((cmd) => !cmd.isVirtual).map((command) => ` - ${command.id}: ${(0, __stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
148
+ this.debug(`Shell Shock will create an application with the following commands: \n${this.inputs.filter((cmd) => !cmd.isVirtual).map((command) => ` - ${command.id}: ${(0, __stryke_path_is_parent_path.isParentPath)(command.entry.file, this.commandsPath) ? (0, __stryke_path_replace.replacePath)(command.entry.file, this.commandsPath) : (0, __stryke_path_file_path_fns.relativePath)(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
149
149
  this.debug("Finding and adding virtual command inputs for each command previously found.");
150
150
  this.inputs = this.inputs.reduce((ret, command) => {
151
151
  let depth = 0;
152
152
  let parentPath = (0, __stryke_path_resolve_parent_path.resolveParentPath)((0, __stryke_path_file_path_fns.findFilePath)(command.entry.file));
153
- while (parentPath !== this.commandsPath) {
154
- if (depth++ > MAX_DEPTH) throw new Error(`Maximum command virtual parent depth of ${MAX_DEPTH} exceeded while processing command: ${command.name}`);
153
+ if ((0, __stryke_path_is_parent_path.isParentPath)(parentPath, this.commandsPath)) while (parentPath !== this.commandsPath) {
154
+ if (depth++ > MAX_DEPTH) throw new Error(`Unable to process virtual commands for ${command.name} \n\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`);
155
155
  if (!ret.some((existing) => (0, __stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
156
156
  const file = (0, __stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
157
157
  const id = require_resolve_command.resolveCommandId(this, file);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","segments","alias","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM6C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;2CACG;4CACC;2CACD;EACR;GACEC,MAAM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OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,2DACEzJ,iCAAI;MAAA,IAAC0J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,+DACzBnI,yCAAe,EAACwF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
1
+ {"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","segments","alias","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM8C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;2CACG;4CACC;2CACD;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,oDAAwB,KAAK;IAEnC,MAAMkB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMV,gDAAW,KAAK;KACtBiB,OAAOhB,iDAAY,KAAK;KACxBiB,aAAanB,uDAAkB,KAAK;KACpCoB,kEAAwBnB,gDAAW,KAAK,CAAC;KACzCoB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBR,QAAQ;MACNS,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,CAAC,KAAKd,OAAOc,SACZC,MAAMC,QAAQ,KAAKhB,OAAOc,MAAM,IAC/B,KAAKd,OAAOc,MAAMG,WAAW,IAC3B,yCACY,KAAKjB,OAAOkB,YAAY,UAAU,0CAClC,KAAKlB,OAAOkB,YAAY,WAAW,CAC9C,GACDC;KACNC,OAAO;MACLP,KAAK;MACLQ,UAAU;MACVC,cAAc;MACdC,UAAU;MACVC,YAAY,CAAC,sBAAqB;MACnC;KACDC,MAAM;KACNC,WAAW;KAEf,CAAC;AACD,QAAI,CAACxB,OAAOO,IAAIC,OAAOiB,SAASzB,OAAOM,UAAU,CAC/CN,QAAOO,IAAIC,OAAOkB,KAAK1B,OAAOM,UAAU;AAG1C,WAAON;;GAET2B,gBAAgB;IACdC,OAAO;IACP,MAAMC,UAAU;AACd,UAAK9B,MAAM,+CAA+C;AAE1D,UAAKD,OAAOgC,2DAAmB,KAAKC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C;;GAGN;EACD;GACEvC,MAAM;GACN8B,iBAAiB;AACf,SAAK7B,OAAO/C,WAAW,EAAE;AACzB,SAAK+C,OAAO/C,OAAOkJ,aAAa;KAC9B,GAAI,KAAKnG,OAAO/C,OAAOkJ,cAAc,EAAE;KACvC7H,UAAUA,wBAAS,KAAI;KACxB;;GAEH,MAAM8H,OAAO;AACX,SAAKnG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBmB,KAAIO,UAASlE,qDAAe,MAAMkE,MAAMrB,SAAS,CAAC,CAClDY,OAAOC,QAAyB;AAEnC,wDACE,uDACCtG,gCAAG;KAAA,IAACwJ,OAAI;AAAA,aAAEnE,OAAOC,OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,2DACE1J,iCAAI;MAAA,IAAC2J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,+DACzBnI,yCAAe,EAACwF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAgFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA4djC,MA5diC,CA4d1B,QA5d0B,CAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAgFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA6djC,MA7diC,CA6d1B,QA7d0B,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAgFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA4djC,MA5diC,CA4d1B,QA5d0B,CAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAgFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA6djC,MA7diC,CA6d1B,QA7d0B,CAAA,EAAA"}
package/dist/plugin.mjs CHANGED
@@ -18,7 +18,7 @@ import tsdown from "@powerlines/plugin-tsdown";
18
18
  import { toArray } from "@stryke/convert/to-array";
19
19
  import { chmodX } from "@stryke/fs/chmod-x";
20
20
  import { appendPath } from "@stryke/path/append";
21
- import { findFilePath } from "@stryke/path/file-path-fns";
21
+ import { findFilePath, relativePath } from "@stryke/path/file-path-fns";
22
22
  import { isParentPath } from "@stryke/path/is-parent-path";
23
23
  import { joinPaths } from "@stryke/path/join-paths";
24
24
  import { replacePath } from "@stryke/path/replace";
@@ -139,13 +139,13 @@ const plugin = (options = {}) => {
139
139
  async handler() {
140
140
  if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
141
141
  else {
142
- this.debug(`Shell Shock will create an application with the following commands: \n${this.inputs.filter((cmd) => !cmd.isVirtual).map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
142
+ this.debug(`Shell Shock will create an application with the following commands: \n${this.inputs.filter((cmd) => !cmd.isVirtual).map((command) => ` - ${command.id}: ${isParentPath(command.entry.file, this.commandsPath) ? replacePath(command.entry.file, this.commandsPath) : relativePath(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
143
143
  this.debug("Finding and adding virtual command inputs for each command previously found.");
144
144
  this.inputs = this.inputs.reduce((ret, command) => {
145
145
  let depth = 0;
146
146
  let parentPath = resolveParentPath(findFilePath(command.entry.file));
147
- while (parentPath !== this.commandsPath) {
148
- if (depth++ > MAX_DEPTH) throw new Error(`Maximum command virtual parent depth of ${MAX_DEPTH} exceeded while processing command: ${command.name}`);
147
+ if (isParentPath(parentPath, this.commandsPath)) while (parentPath !== this.commandsPath) {
148
+ if (depth++ > MAX_DEPTH) throw new Error(`Unable to process virtual commands for ${command.name} \n\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`);
149
149
  if (!ret.some((existing) => findFilePath(existing.entry.file) === parentPath)) {
150
150
  const file = joinPaths(parentPath, "command.ts");
151
151
  const id = resolveCommandId(this, file);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","segments","alias","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM6C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACLzC,QAAQ;EACRF,SAAS;EACTD,QAAQ;EACR;GACE6C,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,wBAAwB,KAAK;IAEnC,MAAMkB,SAAS/B,KACb,EACEgC,QAAQ,EACNC,WAAWzC,UAAU,KAAKqC,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMV,WAAW,KAAK;KACtBiB,OAAOhB,YAAY,KAAK;KACxBiB,aAAanB,kBAAkB,KAAK;KACpCoB,WAAWzC,aAAasB,WAAW,KAAK,CAAC;KACzCoB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBR,QAAQ;MACNS,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,CAAC,KAAKd,OAAOc,SACZC,MAAMC,QAAQ,KAAKhB,OAAOc,MAAM,IAC/B,KAAKd,OAAOc,MAAMG,WAAW,IAC3B,CACEtD,UAAU,KAAKqC,OAAOkB,YAAY,UAAU,EAC5CvD,UAAU,KAAKqC,OAAOkB,YAAY,WAAW,CAC9C,GACDC;KACNC,OAAO;MACLP,KAAK;MACLQ,UAAU;MACVC,cAAc;MACdC,UAAU;MACVC,YAAY,CAAC,sBAAqB;MACnC;KACDC,MAAM;KACNC,WAAW;KAEf,CAAC;AACD,QAAI,CAACxB,OAAOO,IAAIC,OAAOiB,SAASzB,OAAOM,UAA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OAAOK,YAEhB,CAAC;AAED,SAAI,KAAKqE,GAAGC,WAAWrC,KAAK,EAAE;AAC5B,WAAKrC,MACH,6EAA6EqC,OAC9E;AAED,YAAM/E,OAAO+E,KAAK;WAElB,MAAKwB,KACH,uDAAuDxB,KAAI,4GAC5D;MAGP,CAAC;;GAGN;EACD;GACEvC,MAAM;GACN8B,iBAAiB;AACf,SAAK7B,OAAO9C,WAAW,EAAE;AACzB,SAAK8C,OAAO9C,OAAOiJ,aAAa;KAC9B,GAAI,KAAKnG,OAAO9C,OAAOiJ,cAAc,EAAE;KACvC7H,UAAUA,SAAS,KAAI;KACxB;;GAEH,MAAM8H,OAAO;AACX,SAAKnG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBmB,KAAIO,UAASlE,eAAe,MAAMkE,MAAMrB,SAAS,CAAC,CAClDY,OAAOC,QAAyB;AAEnC,WAAOnG,OACL,MAAIoJ,gBACHtJ,KAAG;KAAA,IAACuJ,OAAI;AAAA,aAAEnE,OAAOC,OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,UAAKJ,gBACHrJ,MAAI;MAAA,IAAC0J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,cAAAH,gBACzBhI,iBAAe,EAACwF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
1
+ {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","segments","alias","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM8C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACL1C,QAAQ;EACRF,SAAS;EACTD,QAAQ;EACR;GACE8C,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,wBAAwB,KAAK;IAEnC,MAAMkB,SAAS/B,KACb,EACEgC,QAAQ,EACNC,WAAWzC,UAAU,KAAKqC,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMV,WAAW,KAAK;KACtBiB,OAAOhB,YAAY,KAAK;KACxBiB,aAAanB,kBAAkB,KAAK;KACpCoB,WAAWzC,aAAasB,WAAW,KAAK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AEnC,WAAOpG,OACL,MAAIqJ,gBACHvJ,KAAG;KAAA,IAACwJ,OAAI;AAAA,aAAEnE,OAAOC,OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,UAAKJ,gBACHtJ,MAAI;MAAA,IAAC2J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,cAAAH,gBACzBhI,iBAAe,EAACwF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
@@ -160,6 +160,9 @@ interface CommandBase {
160
160
  icon?: string;
161
161
  /**
162
162
  * Whether the command is virtual.
163
+ *
164
+ * @remarks
165
+ * Virtual commands are considered forks in the command tree and are not directly executable. They are used to group related subcommands together without having an actual command handler or entry point.
163
166
  */
164
167
  isVirtual: boolean;
165
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.cts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":";;;;;UA4BiB,oBAAA;;AAAjB;AA+BA;EAeiB,IAAA,EAAA,MAAA;EAeA;AAmBjB;AAOA;EAOiB,IAAA,EAtFT,cAsFS;EAeL;;;EAGR,KAAA,EAAA,MAAA;EAAoB;AAExB;AAOA;EAOiB,WAAA,EAAA,MAAA;EAOL;;;EAGR,KAAA,EAAA,MAAA,EAAA;EAAsB;AAE1B;AAuCA;EAWY,GAAA,EAAA,MAAA,GAAW,KAAA;EAAG;;;EAoBb,QAAA,EAAA,OAAA;;AAQc,UA3LV,sBAAA,SAA+B,oBA2LrB,CAAA;EAAf;;;EAOA,IAAA,EA9LJ,cAAA,CAAe,MA8LY;EAEvB;AAEZ;;EAAoC,OAAA,CAAA,EAAA,MAAA;EAOV;;;EAYC,QAAA,EAAA,OAAA;;AAIZ,UA9ME,sBAAA,SAA+B,oBA8MjC,CAAA;EAAe;AAG9B;AA+BA;QA5OQ,cAAA,CAAe;;;;;;;;;;UAWN,uBAAA,SAAgC;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;;EAYC,QAAA,EAAA,OAAA;;AAIZ,UA1NE,sBAAA,SAA+B,oBA0NjC,CAAA;EAAe;AAG9B;AA+BA;QAxPQ,cAAA,CAAe;;;;;;;;;;UAWN,uBAAA,SAAgC;;;;QAIzC,cAAA,CAAe;;;;;;;;;;;;;;UAeN,mBAAA,SAA4B;;;;eAI9B;;UAGE,mBAAA,SAA4B;;;;eAI9B;;UAGE,oBAAA,SAA6B;;;;eAI/B;;;;;;;;;;KAWH,aAAA,GACR,sBACA,sBACA;UAEa,qBAAA,SAA8B;;;;cAIjC;;UAGG,qBAAA,SAA8B;;;;cAIjC;;UAGG,sBAAA,SAA+B;;;;cAIlC;;KAGF,eAAA,GACR,wBACA,wBACA;UAEa,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkDA,YAAA,SAAqB;;;;;;;;SAS7B;;KAGG,WAAA,GAAc;;;;;;;;;;;;;;;;WAgBf,eAAe;;;;aAIb;;;;iBAII;;;;YAIL,eAAe;;;;cAIb;;KAGF,uBAAA,GAA0B,KAAK;KAE/B,yBAAA,GAA4B,KAAK;KAEjC,qBAAA,GAAwB,KAClC;;;;WAMS,eAAe;;;;aAIb;;;;;;;;YAQD,eAAe;;;;eAIZ;;UAGE,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BA,aAAA;aACJ;YACD"}
@@ -160,6 +160,9 @@ interface CommandBase {
160
160
  icon?: string;
161
161
  /**
162
162
  * Whether the command is virtual.
163
+ *
164
+ * @remarks
165
+ * Virtual commands are considered forks in the command tree and are not directly executable. They are used to group related subcommands together without having an actual command handler or entry point.
163
166
  */
164
167
  isVirtual: boolean;
165
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.mts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":";;;;;UA4BiB,oBAAA;;AAAjB;AA+BA;EAeiB,IAAA,EAAA,MAAA;EAeA;AAmBjB;AAOA;EAOiB,IAAA,EAtFT,cAsF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e;;;;aAIb;;;;;;;;YAQD,eAAe;;;;eAIZ;;UAGE,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BA,aAAA;aACJ;YACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/core",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "type": "module",
5
5
  "description": "A package containing the core Shell Shock functionality used to build and manage a command-line application.",
6
6
  "repository": {
@@ -364,13 +364,13 @@
364
364
  "@alloy-js/core": "0.23.0-dev.8",
365
365
  "@alloy-js/markdown": "0.23.0-dev.1",
366
366
  "@alloy-js/typescript": "0.23.0-dev.4",
367
- "@powerlines/deepkit": "^0.6.63",
368
- "@powerlines/plugin-alloy": "^0.23.13",
369
- "@powerlines/plugin-automd": "^0.1.283",
370
- "@powerlines/plugin-deepkit": "^0.11.162",
371
- "@powerlines/plugin-nodejs": "^0.1.197",
372
- "@powerlines/plugin-plugin": "^0.12.234",
373
- "@powerlines/plugin-tsdown": "^0.1.236",
367
+ "@powerlines/deepkit": "^0.6.65",
368
+ "@powerlines/plugin-alloy": "^0.23.15",
369
+ "@powerlines/plugin-automd": "^0.1.285",
370
+ "@powerlines/plugin-deepkit": "^0.11.164",
371
+ "@powerlines/plugin-nodejs": "^0.1.199",
372
+ "@powerlines/plugin-plugin": "^0.12.236",
373
+ "@powerlines/plugin-tsdown": "^0.1.238",
374
374
  "@stryke/cli": "^0.13.15",
375
375
  "@stryke/convert": "^0.6.40",
376
376
  "@stryke/fs": "^0.33.43",
@@ -381,11 +381,11 @@
381
381
  "@stryke/type-checks": "^0.5.25",
382
382
  "@stryke/types": "^0.10.39",
383
383
  "automd": "^0.4.3",
384
- "defu": "^6.1.4",
385
- "powerlines": "^0.38.50",
384
+ "defu": "6.1.4",
385
+ "powerlines": "^0.38.52",
386
386
  "rolldown": "1.0.0-beta.52"
387
387
  },
388
388
  "devDependencies": { "@types/node": "^22.19.11", "typescript": "^5.9.3" },
389
389
  "publishConfig": { "access": "public" },
390
- "gitHead": "305a2a23562d3ddd3f1c04bc770de72a30cf0fcb"
390
+ "gitHead": "ba4e6ba921fb77de5be8950f02ea798752b61450"
391
391
  }