@shell-shock/core 0.17.6 → 0.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -29
  3. package/dist/api.cjs +1 -95
  4. package/dist/api.d.cts +52 -4
  5. package/dist/api.d.cts.map +1 -1
  6. package/dist/api.d.mts +52 -4
  7. package/dist/api.d.mts.map +1 -1
  8. package/dist/api.mjs +1 -92
  9. package/dist/api.mjs.map +1 -1
  10. package/dist/components/command-validation-logic.cjs +1 -292
  11. package/dist/components/command-validation-logic.mjs +1 -289
  12. package/dist/components/command-validation-logic.mjs.map +1 -1
  13. package/dist/components/docs.cjs +1 -265
  14. package/dist/components/docs.d.cts.map +1 -1
  15. package/dist/components/docs.d.mts.map +1 -1
  16. package/dist/components/docs.mjs +1 -256
  17. package/dist/components/docs.mjs.map +1 -1
  18. package/dist/components/exec-builtin.cjs +13 -429
  19. package/dist/components/exec-builtin.mjs +13 -425
  20. package/dist/components/exec-builtin.mjs.map +1 -1
  21. package/dist/components/helpers.cjs +1 -120
  22. package/dist/components/helpers.mjs +1 -112
  23. package/dist/components/helpers.mjs.map +1 -1
  24. package/dist/components/index.cjs +1 -58
  25. package/dist/components/index.mjs +1 -10
  26. package/dist/components/options-parser-logic.cjs +5 -960
  27. package/dist/components/options-parser-logic.d.cts +1 -1
  28. package/dist/components/options-parser-logic.mjs +5 -945
  29. package/dist/components/options-parser-logic.mjs.map +1 -1
  30. package/dist/components/state-builtin.cjs +8 -629
  31. package/dist/components/state-builtin.d.cts.map +1 -1
  32. package/dist/components/state-builtin.d.mts.map +1 -1
  33. package/dist/components/state-builtin.mjs +8 -622
  34. package/dist/components/state-builtin.mjs.map +1 -1
  35. package/dist/components/usage.cjs +1 -117
  36. package/dist/components/usage.mjs +1 -114
  37. package/dist/components/usage.mjs.map +1 -1
  38. package/dist/components/utils-builtin.cjs +33 -838
  39. package/dist/components/utils-builtin.d.cts.map +1 -1
  40. package/dist/components/utils-builtin.d.mts.map +1 -1
  41. package/dist/components/utils-builtin.mjs +33 -828
  42. package/dist/components/utils-builtin.mjs.map +1 -1
  43. package/dist/config.cjs +1 -31
  44. package/dist/config.mjs +1 -29
  45. package/dist/config.mjs.map +1 -1
  46. package/dist/contexts/command.cjs +1 -26
  47. package/dist/contexts/command.mjs +1 -23
  48. package/dist/contexts/command.mjs.map +1 -1
  49. package/dist/contexts/index.cjs +1 -9
  50. package/dist/contexts/index.mjs +1 -4
  51. package/dist/contexts/options.cjs +1 -63
  52. package/dist/contexts/options.mjs +1 -58
  53. package/dist/contexts/options.mjs.map +1 -1
  54. package/dist/helpers/automd.cjs +1 -71
  55. package/dist/helpers/automd.mjs +1 -70
  56. package/dist/helpers/automd.mjs.map +1 -1
  57. package/dist/helpers/docs-helpers.cjs +1 -23
  58. package/dist/helpers/docs-helpers.mjs +1 -22
  59. package/dist/helpers/docs-helpers.mjs.map +1 -1
  60. package/dist/helpers/paths.cjs +1 -137
  61. package/dist/helpers/paths.mjs +1 -133
  62. package/dist/helpers/paths.mjs.map +1 -1
  63. package/dist/helpers/persistence.cjs +1 -113
  64. package/dist/helpers/persistence.mjs +1 -110
  65. package/dist/helpers/persistence.mjs.map +1 -1
  66. package/dist/helpers/update-package-json.cjs +1 -59
  67. package/dist/helpers/update-package-json.mjs +1 -57
  68. package/dist/helpers/update-package-json.mjs.map +1 -1
  69. package/dist/helpers/utilities.cjs +1 -95
  70. package/dist/helpers/utilities.mjs +1 -93
  71. package/dist/helpers/utilities.mjs.map +1 -1
  72. package/dist/helpers/validations.cjs +1 -71
  73. package/dist/helpers/validations.mjs +1 -71
  74. package/dist/helpers/validations.mjs.map +1 -1
  75. package/dist/index.cjs +1 -52
  76. package/dist/index.d.cts +1 -1
  77. package/dist/index.d.mts +1 -1
  78. package/dist/index.mjs +1 -7
  79. package/dist/plugin-utils/compute-bin.cjs +1 -50
  80. package/dist/plugin-utils/compute-bin.mjs +1 -49
  81. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  82. package/dist/plugin-utils/context-helpers.cjs +1 -231
  83. package/dist/plugin-utils/context-helpers.mjs +1 -221
  84. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  85. package/dist/plugin-utils/deepkit.cjs +1 -71
  86. package/dist/plugin-utils/deepkit.mjs +1 -69
  87. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  88. package/dist/plugin-utils/description-helpers.cjs +2 -111
  89. package/dist/plugin-utils/description-helpers.mjs +2 -107
  90. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  91. package/dist/plugin-utils/get-command-tree.cjs +1 -117
  92. package/dist/plugin-utils/get-command-tree.mjs +1 -114
  93. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  94. package/dist/plugin-utils/index.cjs +1 -39
  95. package/dist/plugin-utils/index.mjs +1 -10
  96. package/dist/plugin-utils/reflect.cjs +1 -52
  97. package/dist/plugin-utils/reflect.mjs +1 -52
  98. package/dist/plugin-utils/reflect.mjs.map +1 -1
  99. package/dist/plugin-utils/traverse-command-tree.cjs +1 -64
  100. package/dist/plugin-utils/traverse-command-tree.mjs +1 -62
  101. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  102. package/dist/plugin-utils/type-checks.cjs +1 -93
  103. package/dist/plugin-utils/type-checks.mjs +1 -88
  104. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  105. package/dist/plugin.cjs +4 -429
  106. package/dist/plugin.d.cts.map +1 -1
  107. package/dist/plugin.d.mts.map +1 -1
  108. package/dist/plugin.mjs +4 -423
  109. package/dist/plugin.mjs.map +1 -1
  110. package/dist/resolver/deepkit.cjs +1 -135
  111. package/dist/resolver/deepkit.mjs +1 -134
  112. package/dist/resolver/deepkit.mjs.map +1 -1
  113. package/dist/resolver/helpers.cjs +1 -173
  114. package/dist/resolver/helpers.mjs +1 -168
  115. package/dist/resolver/helpers.mjs.map +1 -1
  116. package/dist/resolver/module.cjs +1 -145
  117. package/dist/resolver/module.mjs +1 -144
  118. package/dist/resolver/module.mjs.map +1 -1
  119. package/dist/resolver/resolve.cjs +1 -222
  120. package/dist/resolver/resolve.mjs +1 -221
  121. package/dist/resolver/resolve.mjs.map +1 -1
  122. package/dist/types/command.cjs +1 -441
  123. package/dist/types/command.mjs +1 -405
  124. package/dist/types/command.mjs.map +1 -1
  125. package/dist/types/config.cjs +1 -144
  126. package/dist/types/config.d.cts +3 -2
  127. package/dist/types/config.d.cts.map +1 -1
  128. package/dist/types/config.d.mts +3 -2
  129. package/dist/types/config.d.mts.map +1 -1
  130. package/dist/types/config.mjs +1 -138
  131. package/dist/types/config.mjs.map +1 -1
  132. package/dist/types/context.cjs +1 -37
  133. package/dist/types/context.d.cts +3 -2
  134. package/dist/types/context.d.cts.map +1 -1
  135. package/dist/types/context.d.mts +3 -2
  136. package/dist/types/context.d.mts.map +1 -1
  137. package/dist/types/context.mjs +1 -34
  138. package/dist/types/context.mjs.map +1 -1
  139. package/dist/types/env.cjs +1 -52
  140. package/dist/types/env.mjs +1 -50
  141. package/dist/types/env.mjs.map +1 -1
  142. package/dist/types/index.cjs +1 -49
  143. package/dist/types/index.mjs +1 -6
  144. package/dist/types/options.cjs +1 -12
  145. package/dist/types/options.mjs +1 -10
  146. package/package.json +23 -23
@@ -1,231 +1 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
3
- let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
4
- let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
5
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
6
-
7
- //#region src/plugin-utils/context-helpers.ts
8
- function __assignType(fn, args) {
9
- fn.__type = args;
10
- return fn;
11
- }
12
- /**
13
- * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.
14
- *
15
- * @param aliases - An array of argument aliases to sort.
16
- * @returns A new array of sorted aliases.
17
- */
18
- function sortArgAliases(aliases) {
19
- if (aliases.length === 0) return [];
20
- const result = aliases.filter(__assignType((alias) => alias.length === 1, [
21
- "alias",
22
- "",
23
- "P\"2!\"/\""
24
- ]));
25
- result.push(...aliases.filter(__assignType((alias) => alias.length > 1, [
26
- "alias",
27
- "",
28
- "P\"2!\"/\""
29
- ])));
30
- return result.sort(__assignType((a, b) => a.localeCompare(b), [
31
- "a",
32
- "b",
33
- "",
34
- "P\"2!\"2\"\"/#"
35
- ]));
36
- }
37
- sortArgAliases.__type = [
38
- "aliases",
39
- "sortArgAliases",
40
- "Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.",
41
- "P&F2!&F/\"?#"
42
- ];
43
- /**
44
- * Retrieves the application name from the context and configuration.
45
- *
46
- * @param context - The build context containing workspace and package information.
47
- * @returns The application name in kebab-case format.
48
- * @throws An error if no valid application name is found.
49
- */
50
- function getAppName(context) {
51
- const result = context.config.name || ((0, _stryke_type_checks_is_set_string.isSetString)(context.config.bin) || Array.isArray(context.config.bin) && context.config.bin.length > 0 && (0, _stryke_type_checks_is_set_string.isSetString)(context.config.bin[0]) ? (0, _stryke_type_checks_is_set_string.isSetString)(context.config.bin) ? context.config.bin : context.config.bin[0] : context.packageJson?.name);
52
- if (!(0, _stryke_type_checks_is_set_string.isSetString)(result)) throw new Error("No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.");
53
- return (0, _stryke_string_format_kebab_case.kebabCase)(result);
54
- }
55
- getAppName.__type = [
56
- "UnresolvedContext",
57
- "Context",
58
- "context",
59
- "getAppName",
60
- "Retrieves the application name from the context and configuration.",
61
- "PP\"w!\"w\"J2#&/$?%"
62
- ];
63
- /**
64
- * Retrieves the application title from the context and configuration.
65
- *
66
- * @param context - The build context containing workspace and package information.
67
- * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.
68
- * @returns The application title in title-case format.
69
- */
70
- function getAppTitle(context, replaceCLI = false) {
71
- const title = context.config.title || (0, _stryke_string_format_title_case.titleCase)(context.config.name || getAppName(context));
72
- return (replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title).trim();
73
- }
74
- getAppTitle.__type = [
75
- "UnresolvedContext",
76
- "Context",
77
- "context",
78
- "replaceCLI",
79
- "getAppTitle",
80
- "Retrieves the application title from the context and configuration.",
81
- "PP\"w!\"w\"J2#\"2$&/%?&"
82
- ];
83
- /**
84
- * Retrieves the application description from the context and configuration.
85
- *
86
- * @param context - The build context containing workspace and package information.
87
- * @returns The application description.
88
- */
89
- function getAppDescription(context) {
90
- return context.config.description || context.packageJson?.description || `The ${getAppTitle(context, true)} command-line interface application.`;
91
- }
92
- getAppDescription.__type = [
93
- "UnresolvedContext",
94
- "Context",
95
- "context",
96
- "getAppDescription",
97
- "Retrieves the application description from the context and configuration.",
98
- "PP\"w!\"w\"J2#&/$?%"
99
- ];
100
- /**
101
- * Retrieves the primary binary name for the application.
102
- *
103
- * @param context - The build context containing workspace and package information.
104
- * @returns The primary binary name as a string.
105
- */
106
- function getAppBin(context) {
107
- return (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.bin) ? Object.keys(context.config.bin)[0] : (0, _stryke_string_format_kebab_case.kebabCase)(getAppName(context));
108
- }
109
- getAppBin.__type = [
110
- "Context",
111
- "context",
112
- "getAppBin",
113
- "Retrieves the primary binary name for the application.",
114
- "P\"w!2\"&/#?$"
115
- ];
116
- /**
117
- * Determines if a given command path segment is variable (enclosed in square brackets).
118
- *
119
- * @example
120
- * ```typescript
121
- * isDynamicPathSegment("[user]"); // true
122
- * isDynamicPathSegment("user"); // false
123
- * ```
124
- *
125
- * @param path - The command path segment to check.
126
- * @returns True if the path is variable, false otherwise.
127
- */
128
- function isDynamicPathSegment(path) {
129
- return path.startsWith("[") && path.endsWith("]");
130
- }
131
- isDynamicPathSegment.__type = [
132
- "path",
133
- "isDynamicPathSegment",
134
- "Determines if a given command path segment is variable (enclosed in square brackets).",
135
- "P&2!)/\"?#"
136
- ];
137
- /**
138
- * Extracts the variable name from a command path segment by removing enclosing square brackets.
139
- *
140
- * @example
141
- * ```typescript
142
- * getDynamicPathSegmentName("[user]"); // "user"
143
- * ```
144
- *
145
- * @param path - The command path segment.
146
- * @returns The variable name without square brackets.
147
- */
148
- function getDynamicPathSegmentName(path) {
149
- return path.replaceAll(/^\[+/g, "").replaceAll(/\]+$/g, "");
150
- }
151
- getDynamicPathSegmentName.__type = [
152
- "path",
153
- "getDynamicPathSegmentName",
154
- "Extracts the variable name from a command path segment by removing enclosing square brackets.",
155
- "P&2!&/\"?#"
156
- ];
157
- /**
158
- * Determines if a given command path segment is a path segment group (enclosed in parentheses).
159
- *
160
- * @example
161
- * ```typescript
162
- * isPathSegmentGroup("(user)"); // true
163
- * isPathSegmentGroup("[user]"); // false
164
- * isPathSegmentGroup("user"); // false
165
- * ```
166
- *
167
- * @param path - The command path segment to check.
168
- * @returns True if the path is a path segment group, false otherwise.
169
- */
170
- function isPathSegmentGroup(path) {
171
- return path.startsWith("(") && path.endsWith(")") || path.startsWith("_");
172
- }
173
- isPathSegmentGroup.__type = [
174
- "path",
175
- "isPathSegmentGroup",
176
- "Determines if a given command path segment is a path segment group (enclosed in parentheses).",
177
- "P&2!)/\"?#"
178
- ];
179
- /**
180
- * Extracts the group name from a command path segment by removing enclosing parentheses.
181
- *
182
- * @example
183
- * ```typescript
184
- * getPathSegmentGroupName("(admin)"); // "admin"
185
- * getPathSegmentGroupName("((group))"); // "group"
186
- * ```
187
- *
188
- * @param path - The command path segment.
189
- * @returns The group name without parentheses.
190
- */
191
- function getPathSegmentGroupName(path) {
192
- return path.replaceAll(/^\(+/g, "").replaceAll(/\)+$/g, "").replaceAll(/^_+/g, "");
193
- }
194
- getPathSegmentGroupName.__type = [
195
- "path",
196
- "getPathSegmentGroupName",
197
- "Extracts the group name from a command path segment by removing enclosing parentheses.",
198
- "P&2!&/\"?#"
199
- ];
200
- /**
201
- * Extracts the variable name from a command path segment by removing enclosing square brackets.
202
- *
203
- * @example
204
- * ```typescript
205
- * getDynamicPathSegmentName("[user]"); // "user"
206
- * ```
207
- *
208
- * @param path - The command path segment.
209
- * @returns The variable name without square brackets.
210
- */
211
- function getPathSegmentName(path) {
212
- return getPathSegmentGroupName(getDynamicPathSegmentName(path));
213
- }
214
- getPathSegmentName.__type = [
215
- "path",
216
- "getPathSegmentName",
217
- "Extracts the variable name from a command path segment by removing enclosing square brackets.",
218
- "P&2!&/\"?#"
219
- ];
220
-
221
- //#endregion
222
- exports.getAppBin = getAppBin;
223
- exports.getAppDescription = getAppDescription;
224
- exports.getAppName = getAppName;
225
- exports.getAppTitle = getAppTitle;
226
- exports.getDynamicPathSegmentName = getDynamicPathSegmentName;
227
- exports.getPathSegmentGroupName = getPathSegmentGroupName;
228
- exports.getPathSegmentName = getPathSegmentName;
229
- exports.isDynamicPathSegment = isDynamicPathSegment;
230
- exports.isPathSegmentGroup = isPathSegmentGroup;
231
- exports.sortArgAliases = sortArgAliases;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@stryke/string-format/kebab-case`),t=require(`@stryke/type-checks/is-set-string`),n=require(`@stryke/string-format/title-case`),r=require(`@stryke/type-checks/is-set-object`);function i(e,t){return e.__type=t,e}function a(e){if(e.length===0)return[];let t=e.filter(i(e=>e.length===1,[`alias`,``,`P"2!"/"`]));return t.push(...e.filter(i(e=>e.length>1,[`alias`,``,`P"2!"/"`]))),t.sort(i((e,t)=>e.localeCompare(t),[`a`,`b`,``,`P"2!"2""/#`]))}a.__type=[`aliases`,`sortArgAliases`,`Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.`,`P&F2!&F/"?#`];function o(n){let r=n.config.name||((0,t.isSetString)(n.config.bin)||Array.isArray(n.config.bin)&&n.config.bin.length>0&&(0,t.isSetString)(n.config.bin[0])?(0,t.isSetString)(n.config.bin)?n.config.bin:n.config.bin[0]:n.packageJson?.name);if(!(0,t.isSetString)(r))throw Error(`No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.`);return(0,e.kebabCase)(r)}o.__type=[`UnresolvedContext`,`Context`,`context`,`getAppName`,`Retrieves the application name from the context and configuration.`,`PP"w!"w"J2#&/$?%`];function s(e,t=!1){let r=e.config.title||(0,n.titleCase)(e.config.name||o(e));return(t?r.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi,``):r).trim()}s.__type=[`UnresolvedContext`,`Context`,`context`,`replaceCLI`,`getAppTitle`,`Retrieves the application title from the context and configuration.`,`PP"w!"w"J2#"2$&/%?&`];function c(e){return e.config.description||e.packageJson?.description||`The ${s(e,!0)} command-line interface application.`}c.__type=[`UnresolvedContext`,`Context`,`context`,`getAppDescription`,`Retrieves the application description from the context and configuration.`,`PP"w!"w"J2#&/$?%`];function l(t){return(0,r.isSetObject)(t.config.bin)?Object.keys(t.config.bin)[0]:(0,e.kebabCase)(o(t))}l.__type=[`Context`,`context`,`getAppBin`,`Retrieves the primary binary name for the application.`,`P"w!2"&/#?$`];function u(e){return e.startsWith(`[`)&&e.endsWith(`]`)}u.__type=[`path`,`isDynamicPathSegment`,`Determines if a given command path segment is variable (enclosed in square brackets).`,`P&2!)/"?#`];function d(e){return e.replaceAll(/^\[+/g,``).replaceAll(/\]+$/g,``)}d.__type=[`path`,`getDynamicPathSegmentName`,`Extracts the variable name from a command path segment by removing enclosing square brackets.`,`P&2!&/"?#`];function f(e){return e.startsWith(`(`)&&e.endsWith(`)`)||e.startsWith(`_`)}f.__type=[`path`,`isPathSegmentGroup`,`Determines if a given command path segment is a path segment group (enclosed in parentheses).`,`P&2!)/"?#`];function p(e){return e.replaceAll(/^\(+/g,``).replaceAll(/\)+$/g,``).replaceAll(/^_+/g,``)}p.__type=[`path`,`getPathSegmentGroupName`,`Extracts the group name from a command path segment by removing enclosing parentheses.`,`P&2!&/"?#`];function m(e){return p(d(e))}m.__type=[`path`,`getPathSegmentName`,`Extracts the variable name from a command path segment by removing enclosing square brackets.`,`P&2!&/"?#`],exports.getAppBin=l,exports.getAppDescription=c,exports.getAppName=o,exports.getAppTitle=s,exports.getDynamicPathSegmentName=d,exports.getPathSegmentGroupName=p,exports.getPathSegmentName=m,exports.isDynamicPathSegment=u,exports.isPathSegmentGroup=f,exports.sortArgAliases=a;
@@ -1,222 +1,2 @@
1
- import { kebabCase } from "@stryke/string-format/kebab-case";
2
- import { isSetString } from "@stryke/type-checks/is-set-string";
3
- import { titleCase } from "@stryke/string-format/title-case";
4
- import { isSetObject } from "@stryke/type-checks/is-set-object";
5
-
6
- //#region src/plugin-utils/context-helpers.ts
7
- function __assignType(fn, args) {
8
- fn.__type = args;
9
- return fn;
10
- }
11
- /**
12
- * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.
13
- *
14
- * @param aliases - An array of argument aliases to sort.
15
- * @returns A new array of sorted aliases.
16
- */
17
- function sortArgAliases(aliases) {
18
- if (aliases.length === 0) return [];
19
- const result = aliases.filter(__assignType((alias) => alias.length === 1, [
20
- "alias",
21
- "",
22
- "P\"2!\"/\""
23
- ]));
24
- result.push(...aliases.filter(__assignType((alias) => alias.length > 1, [
25
- "alias",
26
- "",
27
- "P\"2!\"/\""
28
- ])));
29
- return result.sort(__assignType((a, b) => a.localeCompare(b), [
30
- "a",
31
- "b",
32
- "",
33
- "P\"2!\"2\"\"/#"
34
- ]));
35
- }
36
- sortArgAliases.__type = [
37
- "aliases",
38
- "sortArgAliases",
39
- "Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.",
40
- "P&F2!&F/\"?#"
41
- ];
42
- /**
43
- * Retrieves the application name from the context and configuration.
44
- *
45
- * @param context - The build context containing workspace and package information.
46
- * @returns The application name in kebab-case format.
47
- * @throws An error if no valid application name is found.
48
- */
49
- function getAppName(context) {
50
- const result = context.config.name || (isSetString(context.config.bin) || Array.isArray(context.config.bin) && context.config.bin.length > 0 && isSetString(context.config.bin[0]) ? isSetString(context.config.bin) ? context.config.bin : context.config.bin[0] : context.packageJson?.name);
51
- if (!isSetString(result)) throw new Error("No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.");
52
- return kebabCase(result);
53
- }
54
- getAppName.__type = [
55
- "UnresolvedContext",
56
- "Context",
57
- "context",
58
- "getAppName",
59
- "Retrieves the application name from the context and configuration.",
60
- "PP\"w!\"w\"J2#&/$?%"
61
- ];
62
- /**
63
- * Retrieves the application title from the context and configuration.
64
- *
65
- * @param context - The build context containing workspace and package information.
66
- * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.
67
- * @returns The application title in title-case format.
68
- */
69
- function getAppTitle(context, replaceCLI = false) {
70
- const title = context.config.title || titleCase(context.config.name || getAppName(context));
71
- return (replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title).trim();
72
- }
73
- getAppTitle.__type = [
74
- "UnresolvedContext",
75
- "Context",
76
- "context",
77
- "replaceCLI",
78
- "getAppTitle",
79
- "Retrieves the application title from the context and configuration.",
80
- "PP\"w!\"w\"J2#\"2$&/%?&"
81
- ];
82
- /**
83
- * Retrieves the application description from the context and configuration.
84
- *
85
- * @param context - The build context containing workspace and package information.
86
- * @returns The application description.
87
- */
88
- function getAppDescription(context) {
89
- return context.config.description || context.packageJson?.description || `The ${getAppTitle(context, true)} command-line interface application.`;
90
- }
91
- getAppDescription.__type = [
92
- "UnresolvedContext",
93
- "Context",
94
- "context",
95
- "getAppDescription",
96
- "Retrieves the application description from the context and configuration.",
97
- "PP\"w!\"w\"J2#&/$?%"
98
- ];
99
- /**
100
- * Retrieves the primary binary name for the application.
101
- *
102
- * @param context - The build context containing workspace and package information.
103
- * @returns The primary binary name as a string.
104
- */
105
- function getAppBin(context) {
106
- return isSetObject(context.config.bin) ? Object.keys(context.config.bin)[0] : kebabCase(getAppName(context));
107
- }
108
- getAppBin.__type = [
109
- "Context",
110
- "context",
111
- "getAppBin",
112
- "Retrieves the primary binary name for the application.",
113
- "P\"w!2\"&/#?$"
114
- ];
115
- /**
116
- * Determines if a given command path segment is variable (enclosed in square brackets).
117
- *
118
- * @example
119
- * ```typescript
120
- * isDynamicPathSegment("[user]"); // true
121
- * isDynamicPathSegment("user"); // false
122
- * ```
123
- *
124
- * @param path - The command path segment to check.
125
- * @returns True if the path is variable, false otherwise.
126
- */
127
- function isDynamicPathSegment(path) {
128
- return path.startsWith("[") && path.endsWith("]");
129
- }
130
- isDynamicPathSegment.__type = [
131
- "path",
132
- "isDynamicPathSegment",
133
- "Determines if a given command path segment is variable (enclosed in square brackets).",
134
- "P&2!)/\"?#"
135
- ];
136
- /**
137
- * Extracts the variable name from a command path segment by removing enclosing square brackets.
138
- *
139
- * @example
140
- * ```typescript
141
- * getDynamicPathSegmentName("[user]"); // "user"
142
- * ```
143
- *
144
- * @param path - The command path segment.
145
- * @returns The variable name without square brackets.
146
- */
147
- function getDynamicPathSegmentName(path) {
148
- return path.replaceAll(/^\[+/g, "").replaceAll(/\]+$/g, "");
149
- }
150
- getDynamicPathSegmentName.__type = [
151
- "path",
152
- "getDynamicPathSegmentName",
153
- "Extracts the variable name from a command path segment by removing enclosing square brackets.",
154
- "P&2!&/\"?#"
155
- ];
156
- /**
157
- * Determines if a given command path segment is a path segment group (enclosed in parentheses).
158
- *
159
- * @example
160
- * ```typescript
161
- * isPathSegmentGroup("(user)"); // true
162
- * isPathSegmentGroup("[user]"); // false
163
- * isPathSegmentGroup("user"); // false
164
- * ```
165
- *
166
- * @param path - The command path segment to check.
167
- * @returns True if the path is a path segment group, false otherwise.
168
- */
169
- function isPathSegmentGroup(path) {
170
- return path.startsWith("(") && path.endsWith(")") || path.startsWith("_");
171
- }
172
- isPathSegmentGroup.__type = [
173
- "path",
174
- "isPathSegmentGroup",
175
- "Determines if a given command path segment is a path segment group (enclosed in parentheses).",
176
- "P&2!)/\"?#"
177
- ];
178
- /**
179
- * Extracts the group name from a command path segment by removing enclosing parentheses.
180
- *
181
- * @example
182
- * ```typescript
183
- * getPathSegmentGroupName("(admin)"); // "admin"
184
- * getPathSegmentGroupName("((group))"); // "group"
185
- * ```
186
- *
187
- * @param path - The command path segment.
188
- * @returns The group name without parentheses.
189
- */
190
- function getPathSegmentGroupName(path) {
191
- return path.replaceAll(/^\(+/g, "").replaceAll(/\)+$/g, "").replaceAll(/^_+/g, "");
192
- }
193
- getPathSegmentGroupName.__type = [
194
- "path",
195
- "getPathSegmentGroupName",
196
- "Extracts the group name from a command path segment by removing enclosing parentheses.",
197
- "P&2!&/\"?#"
198
- ];
199
- /**
200
- * Extracts the variable name from a command path segment by removing enclosing square brackets.
201
- *
202
- * @example
203
- * ```typescript
204
- * getDynamicPathSegmentName("[user]"); // "user"
205
- * ```
206
- *
207
- * @param path - The command path segment.
208
- * @returns The variable name without square brackets.
209
- */
210
- function getPathSegmentName(path) {
211
- return getPathSegmentGroupName(getDynamicPathSegmentName(path));
212
- }
213
- getPathSegmentName.__type = [
214
- "path",
215
- "getPathSegmentName",
216
- "Extracts the variable name from a command path segment by removing enclosing square brackets.",
217
- "P&2!&/\"?#"
218
- ];
219
-
220
- //#endregion
221
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases };
1
+ import{kebabCase as e}from"@stryke/string-format/kebab-case";import{isSetString as t}from"@stryke/type-checks/is-set-string";import{titleCase as n}from"@stryke/string-format/title-case";import{isSetObject as r}from"@stryke/type-checks/is-set-object";function i(e,t){return e.__type=t,e}function a(e){if(e.length===0)return[];let t=e.filter(i(e=>e.length===1,[`alias`,``,`P"2!"/"`]));return t.push(...e.filter(i(e=>e.length>1,[`alias`,``,`P"2!"/"`]))),t.sort(i((e,t)=>e.localeCompare(t),[`a`,`b`,``,`P"2!"2""/#`]))}a.__type=[`aliases`,`sortArgAliases`,`Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.`,`P&F2!&F/"?#`];function o(n){let r=n.config.name||(t(n.config.bin)||Array.isArray(n.config.bin)&&n.config.bin.length>0&&t(n.config.bin[0])?t(n.config.bin)?n.config.bin:n.config.bin[0]:n.packageJson?.name);if(!t(r))throw Error(`No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.`);return e(r)}o.__type=[`UnresolvedContext`,`Context`,`context`,`getAppName`,`Retrieves the application name from the context and configuration.`,`PP"w!"w"J2#&/$?%`];function s(e,t=!1){let r=e.config.title||n(e.config.name||o(e));return(t?r.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi,``):r).trim()}s.__type=[`UnresolvedContext`,`Context`,`context`,`replaceCLI`,`getAppTitle`,`Retrieves the application title from the context and configuration.`,`PP"w!"w"J2#"2$&/%?&`];function c(e){return e.config.description||e.packageJson?.description||`The ${s(e,!0)} command-line interface application.`}c.__type=[`UnresolvedContext`,`Context`,`context`,`getAppDescription`,`Retrieves the application description from the context and configuration.`,`PP"w!"w"J2#&/$?%`];function l(t){return r(t.config.bin)?Object.keys(t.config.bin)[0]:e(o(t))}l.__type=[`Context`,`context`,`getAppBin`,`Retrieves the primary binary name for the application.`,`P"w!2"&/#?$`];function u(e){return e.startsWith(`[`)&&e.endsWith(`]`)}u.__type=[`path`,`isDynamicPathSegment`,`Determines if a given command path segment is variable (enclosed in square brackets).`,`P&2!)/"?#`];function d(e){return e.replaceAll(/^\[+/g,``).replaceAll(/\]+$/g,``)}d.__type=[`path`,`getDynamicPathSegmentName`,`Extracts the variable name from a command path segment by removing enclosing square brackets.`,`P&2!&/"?#`];function f(e){return e.startsWith(`(`)&&e.endsWith(`)`)||e.startsWith(`_`)}f.__type=[`path`,`isPathSegmentGroup`,`Determines if a given command path segment is a path segment group (enclosed in parentheses).`,`P&2!)/"?#`];function p(e){return e.replaceAll(/^\(+/g,``).replaceAll(/\)+$/g,``).replaceAll(/^_+/g,``)}p.__type=[`path`,`getPathSegmentGroupName`,`Extracts the group name from a command path segment by removing enclosing parentheses.`,`P&2!&/"?#`];function m(e){return p(d(e))}m.__type=[`path`,`getPathSegmentName`,`Extracts the variable name from a command path segment by removing enclosing square brackets.`,`P&2!&/"?#`];export{l as getAppBin,c as getAppDescription,o as getAppName,s as getAppTitle,d as getDynamicPathSegmentName,p as getPathSegmentGroupName,m as getPathSegmentName,u as isDynamicPathSegment,f as isPathSegmentGroup,a as sortArgAliases};
222
2
  //# sourceMappingURL=context-helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.mjs","names":[],"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":";;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA6BX,SAAc,eAAc,SAAA;AACxB,KAAA,QAAS,WAAA,EACX,QAAA,EAAA;CAEA,MAAM,SAAS,QAAQ,OAAO,cAAe,UAAS,MAAI,WAAA,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;AAC1D,QAAO,KAAO,GAAC,QAAQ,OAAO,cAAe,UAAS,MAAG,SAAA,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;;;;;;;AAG3D,eAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,SAAE,WAAA,SAAA;CACF,MAAO,SAAS,QAAW,OAAO,SAC1B,YAAO,QAAA,OAAA,IAAA,IACH,MAAO,QAAM,QAAA,OAAA,IAAA,IACT,QAAQ,OAAO,IAAI,SAAG,KAC3B,YAAgB,QAAO,OAAM,IAAA,GAAA,GAC1B,YAAW,QAAS,OAAG,IAAA,GACnB,QAAQ,OAAO,MACzB,QAAY,OAAQ,IAAO,KACzB,QAAQ,aAAO;AACrB,KAAI,CAAC,YAAS,OAAU,CACpB,OAAA,IAAQ,MAAA,qIAAkB;AAE9B,QAAM,UAAS,OAAA;;AAEnB,WAAK,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQL,SAAC,YAAA,SAAA,aAAA,OAAA;CACG,MAAM,QAAQ,QAAM,OAAM,SAC1B,UAAM,QAAa,OAAU,QAAQ,WAAK,QAAc,CAAA;AACxD,SAAQ,aACV,MAAA,QAAA,gFAAA,GAAA,GACK,OAAS,MAAA;;AAEhB,YAAY,SAAG;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOf,SAAI,kBAAA,SAAA;AACA,QAAI,QAAM,OAAO,eACb,QAAM,aAAY,eAClB,OAAG,YAAA,SAAA,KAAA,CAAA;;AAEX,kBAAQ,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOR,SAAU,UAAc,SAAM;AAC1B,QAAO,YAAK,QAAY,OAAA,IAAW,GACrC,OAAA,KAAA,QAAA,OAAA,IAAA,CAAA,KACK,UAAS,WAAA,QAAiB,CAAA;;AAEjC,UAAU,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;AAaV,SAAE,qBAAA,MAAA;AACF,QAAO,KAAS,WAAU,IAAA,IAAS,KAAA,SAAU,IAAO;;AAEpD,qBAAkB,SAAQ;CAAA;CAAa;CAAC;CAAA;CAAA;;;;;;;;;;;;AAYxC,SAAC,0BAAA,MAAA;AACG,QAAM,KAAM,WAAK,SAAa,GAAA,CAAA,WAAgB,SAAA,GAAA;;AAElD,0BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;;AAcF,SAAgB,mBAAc,MAAQ;AACpC,QAAA,KAAA,WAAA,IAAA,IAAA,KAAA,SAAA,IAAA,IAAA,KAAA,WAAA,IAAA;;AAEF,mBAAc,SAAc;CAAC;CAAQ;CAAsB;CAAE;CAAA;;;;;;;;;;;;;AAa7D,SAAgB,wBAAkB,MAAW;AACzC,QAAO,KACT,WAAA,SAAA,GAAA,CACK,WAAS,SAAA,GAAA,CACP,WAAM,QAAa,GAAG;;;;;;;;;;;;;;;;;;;AAc/B,SAAE,mBAAA,MAAA;AACF,QAAO,wBAAS,0BAA6C,KAAC,CAAA;;AAE9D,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"context-helpers.mjs","names":[],"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":"0PAAA,SAAS,EAAa,EAAI,EAAM,CAE9B,kBAAO,EA6BT,SAAc,EAAc,EAAA,CAC1B,GAAE,EAAS,SAAA,EACX,MAAA,EAAA,CAEA,IAAM,EAAS,EAAQ,OAAO,EAAS,GAAa,EAAM,SAAA,EAAA,CAAA,QAAA,GAAA,UAAA,CAAA,CAAA,QAC1D,EAAO,KAAK,GAAG,EAAQ,OAAO,EAAS,GAAa,EAAK,OAAA,EAAA,CAAA,QAAA,GAAA,UAAA,CAAA,CAAA,CAAA,gEAG3D,EAAA,OAAA,CAAA,UAAA,iBAAA,qJAAA,cAAA,CAQA,SAAE,EAAA,EAAA,CACF,IAAO,EAAS,EAAA,OAAW,OAAS,EAAiB,EAAG,OAAU,IAAM,EAAC,MAAA,QAAA,EAAA,OAAA,IAAA,EAAA,EAAA,OAAA,IAAA,OAAA,GAAA,EAAA,EAAA,OAAA,IAAA,GAAA,CAAA,EAAA,EAAA,OAAA,IAAA,CAAA,EAAA,OAAA,IAAA,EAAA,OAAA,IAAA,GAAA,EAAA,aAAA,MACvE,GAAA,CAAK,EAAQ,EAAA,CACX,MAAQ,MAAO,qIAAM,CAEvB,OAAG,EAAc,EAAO,CAE1B,EAAM,OAAY,CAAA,oBAAsB,UAAA,UAAA,aAAA,qEAAA,mBAAA,CAQxC,SAAK,EAAA,EAAA,EAAA,GAAA,CACH,IAAA,EAAA,EAAA,OAAA,OAAA,EAAA,EAAA,OAAA,MAAA,EAAA,EAAA,CAAA,iHAGF,EAAA,OAAA,CAAA,oBAAA,UAAA,UAAA,aAAA,cAAA,sEAAA,sBAAA,CAOA,SAAgB,EAAkB,EAAS,CACzC,OAAA,EAAA,OAAA,aAAA,EAAA,aAAA,aAAA,OAAA,EAAA,EAAA,GAAA,CAAA,sCAEF,EAAW,OAAA,CAAiB,oBAAU,UAAA,UAAA,oBAAA,4EAAA,mBAAA,CAOtC,SAAS,EAAA,EAAA,CACP,OAAE,EAAA,EAAA,OAAA,IAAA,CAAA,OAAA,KAAA,EAAA,OAAA,IAAA,CAAA,GAAA,EAAA,EAAA,EAAA,CAAA,CAEJ,EAAU,OAAQ,CAAA,UAAa,UAAQ,YAAW,yDAAsC,cAAA,CAaxF,SAAgB,EAAiB,EAAA,CAC/B,OAAO,EAAE,WAAA,IAAkB,EAAE,EAAA,SAAA,IAAA,CAE/B,EAAS,OAAA,CAAA,OAAA,uBAAA,wFAAA,YAAA,CAYT,SAAE,EAAA,EAAA,CACF,OAAO,EAAA,WAAkB,QAAS,GAAC,CAAA,WAAU,QAAO,GAAA,CAEpD,EAA0B,OAAO,CAAG,OAAI,4BAAA,gGAAA,YAAA,CAcxC,SAAgB,EAAgB,EAAS,CACvC,OAAA,EAAA,WAAA,IAAA,EAAA,EAAA,SAAA,IAAA,EAAA,EAAA,WAAA,IAAA,CAEF,EAAc,OAAc,CAAC,OAAQ,qBAAc,gGAAA,YAAA,CAanD,SAAE,EAAA,EAAA,CACF,OAAO,EAAA,WAAS,QAAA,GAAA,CAAA,WAAgC,QAAS,GAAA,CAAA,WAAO,OAAA,GAAA,CAEhE,EAAA,OAAA,CAAA,OAAA,0BAAA,yFAAA,YAAA,CAYA,SAAgB,EAAkB,EAAO,CACvC,OAAE,EAA6B,EAA0B,EAAC,CAAA,CAE5D,EAAgB,OAAA,CAAA,OAAmB,qBAAuB,gGAAA,YAAA"}
@@ -1,71 +1 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- const require_types_command = require('../types/command.cjs');
3
- const require_type_checks = require('./type-checks.cjs');
4
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
-
7
- //#region src/plugin-utils/deepkit.ts
8
- /**
9
- * Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.
10
- *
11
- * @param command - The command parameter or kind to extract the reflection kind from.
12
- * @param checkVariadic - Whether to check for variadic parameters (arrays).
13
- * @returns The extracted {@link ReflectionKind}.
14
- */
15
- function extractReflectionKind(command, checkVariadic = true) {
16
- if (require_type_checks.isCommandParameterKind(command) && command === require_types_command.CommandParameterKinds.string || (0, _stryke_type_checks_is_set_object.isSetObject)(command) && command.kind === require_types_command.CommandParameterKinds.string) return checkVariadic && command.variadic ? _powerlines_deepkit_vendor_type.ReflectionKind.array : _powerlines_deepkit_vendor_type.ReflectionKind.string;
17
- else if (require_type_checks.isCommandParameterKind(command) && command === require_types_command.CommandParameterKinds.number || (0, _stryke_type_checks_is_set_object.isSetObject)(command) && command.kind === require_types_command.CommandParameterKinds.number) return checkVariadic && command.variadic ? _powerlines_deepkit_vendor_type.ReflectionKind.array : _powerlines_deepkit_vendor_type.ReflectionKind.number;
18
- else if (require_type_checks.isCommandParameterKind(command) && command === require_types_command.CommandParameterKinds.boolean || (0, _stryke_type_checks_is_set_object.isSetObject)(command) && command.kind === require_types_command.CommandParameterKinds.boolean) return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
19
- else return _powerlines_deepkit_vendor_type.ReflectionKind.string;
20
- }
21
- extractReflectionKind.__type = [
22
- "BaseCommandParameter",
23
- "CommandParameterKind",
24
- "command",
25
- "checkVariadic",
26
- "extractReflectionKind",
27
- "Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.",
28
- "PP\"w!\"w\"J2#\"2$!/%?&"
29
- ];
30
- /**
31
- * Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.
32
- *
33
- * @param command - The command parameter or kind to extract the type from.
34
- * @param checkVariadic - Whether to check for variadic parameters (arrays).
35
- * @returns The extracted {@link Type}.
36
- */
37
- function extractType(command, checkVariadic = true) {
38
- const reflectionKind = extractReflectionKind(command, checkVariadic);
39
- if (reflectionKind === _powerlines_deepkit_vendor_type.ReflectionKind.string) return { kind: _powerlines_deepkit_vendor_type.ReflectionKind.string };
40
- else if (reflectionKind === _powerlines_deepkit_vendor_type.ReflectionKind.number) return { kind: _powerlines_deepkit_vendor_type.ReflectionKind.number };
41
- else if (reflectionKind === _powerlines_deepkit_vendor_type.ReflectionKind.boolean) return { kind: _powerlines_deepkit_vendor_type.ReflectionKind.boolean };
42
- else if (reflectionKind === _powerlines_deepkit_vendor_type.ReflectionKind.array) if (require_type_checks.isCommandParameterKind(command)) return {
43
- kind: _powerlines_deepkit_vendor_type.ReflectionKind.array,
44
- type: extractType({ kind: command }, false)
45
- };
46
- else if ((0, _stryke_type_checks_is_set_object.isSetObject)(command)) return {
47
- kind: _powerlines_deepkit_vendor_type.ReflectionKind.array,
48
- type: extractType({
49
- ...command,
50
- kind: command.kind
51
- }, false)
52
- };
53
- else return {
54
- kind: _powerlines_deepkit_vendor_type.ReflectionKind.array,
55
- type: { kind: _powerlines_deepkit_vendor_type.ReflectionKind.string }
56
- };
57
- else return { kind: _powerlines_deepkit_vendor_type.ReflectionKind.string };
58
- }
59
- extractType.__type = [
60
- "BaseCommandParameter",
61
- "CommandParameterKind",
62
- "command",
63
- "checkVariadic",
64
- "extractType",
65
- "Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.",
66
- "PP\"w!\"w\"J2#\"2$!/%?&"
67
- ];
68
-
69
- //#endregion
70
- exports.extractReflectionKind = extractReflectionKind;
71
- exports.extractType = extractType;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../types/command.cjs`),t=require(`./type-checks.cjs`);let n=require(`@powerlines/deepkit/vendor/type`),r=require(`@stryke/type-checks/is-set-object`);function i(i,a=!0){return t.isCommandParameterKind(i)&&i===e.CommandParameterKinds.string||(0,r.isSetObject)(i)&&i.kind===e.CommandParameterKinds.string?a&&i.variadic?n.ReflectionKind.array:n.ReflectionKind.string:t.isCommandParameterKind(i)&&i===e.CommandParameterKinds.number||(0,r.isSetObject)(i)&&i.kind===e.CommandParameterKinds.number?a&&i.variadic?n.ReflectionKind.array:n.ReflectionKind.number:t.isCommandParameterKind(i)&&i===e.CommandParameterKinds.boolean||(0,r.isSetObject)(i)&&i.kind===e.CommandParameterKinds.boolean?n.ReflectionKind.boolean:n.ReflectionKind.string}i.__type=[`BaseCommandParameter`,`CommandParameterKind`,`command`,`checkVariadic`,`extractReflectionKind`,`Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.`,`PP"w!"w"J2#"2$!/%?&`];function a(e,o=!0){let s=i(e,o);return s===n.ReflectionKind.string?{kind:n.ReflectionKind.string}:s===n.ReflectionKind.number?{kind:n.ReflectionKind.number}:s===n.ReflectionKind.boolean?{kind:n.ReflectionKind.boolean}:s===n.ReflectionKind.array?t.isCommandParameterKind(e)?{kind:n.ReflectionKind.array,type:a({kind:e},!1)}:(0,r.isSetObject)(e)?{kind:n.ReflectionKind.array,type:a({...e,kind:e.kind},!1)}:{kind:n.ReflectionKind.array,type:{kind:n.ReflectionKind.string}}:{kind:n.ReflectionKind.string}}a.__type=[`BaseCommandParameter`,`CommandParameterKind`,`command`,`checkVariadic`,`extractType`,`Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.`,`PP"w!"w"J2#"2$!/%?&`],exports.extractReflectionKind=i,exports.extractType=a;