@shell-shock/core 0.8.10 → 0.8.11

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.cjs";
2
- import * as _alloy_js_core8 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_core8.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_core8.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_core8.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_core8.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.cts.map
@@ -1,5 +1,5 @@
1
1
  import { CommandTree } from "../types/command.mjs";
2
- import * as _alloy_js_core9 from "@alloy-js/core";
2
+ import * as _alloy_js_core1 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_core9.Children;
15
+ declare function CommandOptionsDocs(props: CommandOptionsDocsProps): _alloy_js_core1.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_core9.Children;
34
+ declare function CommandDocsUsageExample(props: CommandDocsUsageExampleProps): _alloy_js_core1.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_core9.Children;
59
+ declare function CommandDocs(props: CommandDocsProps): _alloy_js_core1.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_core9.Children;
78
+ declare function CommandDocsFile(props: CommandDocsFileProps): _alloy_js_core1.Children;
79
79
  //#endregion
80
80
  export { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps };
81
81
  //# sourceMappingURL=docs.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core12 from "@alloy-js/core";
1
+ import * as _alloy_js_core8 from "@alloy-js/core";
2
2
 
3
3
  //#region src/components/helpers.d.ts
4
4
  interface BooleanInputParserLogicProps {
@@ -7,7 +7,7 @@ interface BooleanInputParserLogicProps {
7
7
  /**
8
8
  * Parses a string input into a boolean value, interpreting common truthy and falsy string representations.
9
9
  */
10
- declare function BooleanInputParserLogic(props: BooleanInputParserLogicProps): _alloy_js_core12.Children;
10
+ declare function BooleanInputParserLogic(props: BooleanInputParserLogicProps): _alloy_js_core8.Children;
11
11
  //#endregion
12
12
  export { BooleanInputParserLogic, BooleanInputParserLogicProps };
13
13
  //# sourceMappingURL=helpers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.cts","names":[],"sources":["../../src/components/helpers.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,4BAAA;;;AAAjB;AAOA;;iBAAgB,uBAAA,QAA+B,+BAA4B,gBAAA,CAAA"}
1
+ {"version":3,"file":"helpers.d.cts","names":[],"sources":["../../src/components/helpers.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,4BAAA;;;AAAjB;AAOA;;iBAAgB,uBAAA,QAA+B,+BAA4B,eAAA,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { CommandOption, CommandTree } from "../types/command.mjs";
2
- import * as _alloy_js_core1 from "@alloy-js/core";
2
+ import * as _alloy_js_core5 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_core1.Children;
15
+ declare function DynamicSegmentsParserLogic(props: DynamicSegmentsParserLogicProps): _alloy_js_core5.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_core1.Children;
30
+ declare function ArgumentsParserLogic(props: ArgumentsParserLogicProps): _alloy_js_core5.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_core1.Children;
38
+ }): _alloy_js_core5.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_core1.Children;
58
+ declare function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps): _alloy_js_core5.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_core1.Children;
75
+ declare function OptionsMemberParserCondition(props: OptionsMemberParserConditionProps): _alloy_js_core5.Children;
76
76
  declare function OptionsInterfaceDeclaration(props: {
77
77
  command: CommandTree;
78
- }): _alloy_js_core1.Children;
78
+ }): _alloy_js_core5.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_core1.Children;
98
+ declare function OptionsParserLogic(props: OptionsParserLogicProps): _alloy_js_core5.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_core1.Children;
118
+ declare function CommandParserLogic(props: CommandParserLogicProps): _alloy_js_core5.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_core7 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_core7.Children;
25
+ declare function Usage(props: UsageProps): _alloy_js_core0.Children;
26
26
  //#endregion
27
27
  export { Usage, UsageProps };
28
28
  //# sourceMappingURL=usage.d.cts.map
@@ -38,7 +38,7 @@ function getAppName(context) {
38
38
  */
39
39
  function getAppTitle(context, replaceCLI = false) {
40
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;
41
+ return (replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title).trim();
42
42
  }
43
43
  /**
44
44
  * Retrieves the application description from the context and configuration.
@@ -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","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 getPathS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AAuB;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.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","replaceCLI","title","replace","trim","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 (\n replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title\n ).trim();\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,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yDAChBU,QAAQC,OAAOE,IAAI,GAAI,uDACrBH,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,qDAAaX,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,yDAAiBhB,OAAO;;;;;;;;;AAU1B,SAAgBiB,YACdR,SACAS,aAAa,OACL;CACR,MAAMC,QACJV,QAAQC,OAAOS,0DACLV,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;AAEvD,SACES,aACIC,MAAMC,QACJ,gFACA,GACD,GACDD,OACJE,MAAM;;;;;;;;AASV,SAAgBC,kBACdb,SACQ;AACR,QACEA,QAAQC,OAAOa,eACfd,QAAQM,aAAaQ,eACr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BA,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;AAwBgB,iBArEA,cAAA,CAsEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBAvJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAuBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAwBgB,iBArEA,cAAA,CAsEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBAvJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAuBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
@@ -37,7 +37,7 @@ function getAppName(context) {
37
37
  */
38
38
  function getAppTitle(context, replaceCLI = false) {
39
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;
40
+ return (replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title).trim();
41
41
  }
42
42
  /**
43
43
  * Retrieves the application description from the context and configuration.
@@ -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","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,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;;;;;;;;;AAU1B,SAAgBiB,YACdR,SACAS,aAAa,OACL;CACR,MAAMC,QACJV,QAAQC,OAAOS,SACfzB,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;AAEvD,QAAOS,aACHC,MAAMC,QACJ,gFACA,GACD,GACDD;;;;;;;;AASN,SAAgBE,kBACdZ,SACQ;AACR,QACEA,QAAQC,OAAOY,eACfb,QAAQM,aAAaO,eACrB,OAAOL,YAAYR,SAAS,KAAK,CAAA;;;;;;;;AAUrC,SAAgBc,UAAUd,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCY,OAAOC,KAAKhB,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;AAepC,SAAgBiB,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","trim","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 (\n replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title\n ).trim();\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,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,G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BAAwBH,0BAA0BH,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/core",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
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.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",
367
+ "@powerlines/deepkit": "^0.6.66",
368
+ "@powerlines/plugin-alloy": "^0.23.16",
369
+ "@powerlines/plugin-automd": "^0.1.286",
370
+ "@powerlines/plugin-deepkit": "^0.11.165",
371
+ "@powerlines/plugin-nodejs": "^0.1.200",
372
+ "@powerlines/plugin-plugin": "^0.12.237",
373
+ "@powerlines/plugin-tsdown": "^0.1.239",
374
374
  "@stryke/cli": "^0.13.15",
375
375
  "@stryke/convert": "^0.6.40",
376
376
  "@stryke/fs": "^0.33.43",
@@ -382,10 +382,10 @@
382
382
  "@stryke/types": "^0.10.39",
383
383
  "automd": "^0.4.3",
384
384
  "defu": "6.1.4",
385
- "powerlines": "^0.38.52",
385
+ "powerlines": "^0.38.53",
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": "ba4e6ba921fb77de5be8950f02ea798752b61450"
390
+ "gitHead": "1137a1ee3be5bb927dc9b15e118f804fd09a24b4"
391
391
  }