@shell-shock/core 0.9.7 → 0.10.0
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.
- package/dist/api.cjs +1 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +1 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/helpers.d.cts +6 -6
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.mts +2 -2
- package/dist/components/utils-builtin.cjs +204 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +13 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +13 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +205 -2
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -1
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/resolve-command.cjs +27 -7
- package/dist/helpers/resolve-command.cjs.map +1 -1
- package/dist/helpers/resolve-command.mjs +26 -6
- package/dist/helpers/resolve-command.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +1 -1
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +1 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/index.cjs +1 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +2 -4
- package/dist/index.mjs.map +1 -1
- package/dist/plugin.cjs +20 -21
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +19 -19
- package/dist/plugin.mjs.map +1 -1
- package/dist/types/command.cjs +12 -3
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts +15 -2
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +15 -2
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +12 -4
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -2
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +2 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +2 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -2
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs.map +1 -1
- package/dist/types/context.d.cts +1 -1
- package/dist/types/context.d.mts +1 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/package.json +22 -16
|
@@ -1,13 +1,214 @@
|
|
|
1
|
-
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import defu$1 from "defu";
|
|
3
3
|
import { Show, code, splitProps } from "@alloy-js/core";
|
|
4
4
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
5
|
import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
6
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/dist/core/contexts/context.mjs";
|
|
6
7
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
7
8
|
import { TSDoc, TSDocInternal, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
8
9
|
|
|
9
10
|
//#region src/components/utils-builtin.tsx
|
|
10
11
|
/**
|
|
12
|
+
* Generates the `findSuggestions` function for suggesting corrections for potentially misspelled options or commands.
|
|
13
|
+
*/
|
|
14
|
+
function FindSuggestionsDeclaration() {
|
|
15
|
+
const context = usePowerlines();
|
|
16
|
+
return [
|
|
17
|
+
createComponent(VarDeclaration, {
|
|
18
|
+
"const": true,
|
|
19
|
+
name: "deburred",
|
|
20
|
+
initializer: code` {
|
|
21
|
+
"\\xc0": "A", "\\xc1": "A", "\\xc2": "A", "\\xc3": "A", "\\xc4": "A", "\\xc5": "A",
|
|
22
|
+
"\\xe0": "a", "\\xe1": "a", "\\xe2": "a", "\\xe3": "a", "\\xe4": "a", "\\xe5": "a",
|
|
23
|
+
"\\xc7": "C", "\\xe7": "c",
|
|
24
|
+
"\\xd0": "D", "\\xf0": "d",
|
|
25
|
+
"\\xc8": "E", "\\xc9": "E", "\\xca": "E", "\\xcb": "E",
|
|
26
|
+
"\\xe8": "e", "\\xe9": "e", "\\xea": "e", "\\xeb": "e",
|
|
27
|
+
"\\xcc": "I", "\\xcd": "I", "\\xce": "I", "\\xcf": "I",
|
|
28
|
+
"\\xec": "i", "\\xed": "i", "\\xee": "i", "\\xef": "i",
|
|
29
|
+
"\\xd1": "N", "\\xf1": "n",
|
|
30
|
+
"\\xd2": "O", "\\xd3": "O", "\\xd4": "O", "\\xd5": "O", "\\xd6": "O", "\\xd8": "O",
|
|
31
|
+
"\\xf2": "o", "\\xf3": "o", "\\xf4": "o", "\\xf5": "o", "\\xf6": "o", "\\xf8": "o",
|
|
32
|
+
"\\xd9": "U", "\\xda": "U", "\\xdb": "U", "\\xdc": "U",
|
|
33
|
+
"\\xf9": "u", "\\xfa": "u", "\\xfb": "u", "\\xfc": "u",
|
|
34
|
+
"\\xdd": "Y", "\\xfd": "y", "\\xff": "y",
|
|
35
|
+
"\\xc6": "Ae", "\\xe6": "ae",
|
|
36
|
+
"\\xde": "Th", "\\xfe": "th",
|
|
37
|
+
"\\xdf": "ss",
|
|
38
|
+
"\\u0100": "A", "\\u0102": "A", "\\u0104": "A",
|
|
39
|
+
"\\u0101": "a", "\\u0103": "a", "\\u0105": "a",
|
|
40
|
+
"\\u0106": "C", "\\u0108": "C", "\\u010a": "C", "\\u010c": "C",
|
|
41
|
+
"\\u0107": "c", "\\u0109": "c", "\\u010b": "c", "\\u010d": "c",
|
|
42
|
+
"\\u010e": "D", "\\u0110": "D", "\\u010f": "d", "\\u0111": "d",
|
|
43
|
+
"\\u0112": "E", "\\u0114": "E", "\\u0116": "E", "\\u0118": "E", "\\u011a": "E",
|
|
44
|
+
"\\u0113": "e", "\\u0115": "e", "\\u0117": "e", "\\u0119": "e", "\\u011b": "e",
|
|
45
|
+
"\\u011c": "G", "\\u011e": "G", "\\u0120": "G", "\\u0122": "G",
|
|
46
|
+
"\\u011d": "g", "\\u011f": "g", "\\u0121": "g", "\\u0123": "g",
|
|
47
|
+
"\\u0124": "H", "\\u0126": "H", "\\u0125": "h", "\\u0127": "h",
|
|
48
|
+
"\\u0128": "I", "\\u012a": "I", "\\u012c": "I", "\\u012e": "I", "\\u0130": "I",
|
|
49
|
+
"\\u0129": "i", "\\u012b": "i", "\\u012d": "i", "\\u012f": "i", "\\u0131": "i",
|
|
50
|
+
"\\u0134": "J", "\\u0135": "j",
|
|
51
|
+
"\\u0136": "K", "\\u0137": "k", "\\u0138": "k",
|
|
52
|
+
"\\u0139": "L", "\\u013b": "L", "\\u013d": "L", "\\u013f": "L", "\\u0141": "L",
|
|
53
|
+
"\\u013a": "l", "\\u013c": "l", "\\u013e": "l", "\\u0140": "l", "\\u0142": "l",
|
|
54
|
+
"\\u0143": "N", "\\u0145": "N", "\\u0147": "N", "\\u014a": "N",
|
|
55
|
+
"\\u0144": "n", "\\u0146": "n", "\\u0148": "n", "\\u014b": "n",
|
|
56
|
+
"\\u014c": "O", "\\u014e": "O", "\\u0150": "O",
|
|
57
|
+
"\\u014d": "o", "\\u014f": "o", "\\u0151": "o",
|
|
58
|
+
"\\u0154": "R", "\\u0156": "R", "\\u0158": "R",
|
|
59
|
+
"\\u0155": "r", "\\u0157": "r", "\\u0159": "r",
|
|
60
|
+
"\\u015a": "S", "\\u015c": "S", "\\u015e": "S", "\\u0160": "S",
|
|
61
|
+
"\\u015b": "s", "\\u015d": "s", "\\u015f": "s", "\\u0161": "s",
|
|
62
|
+
"\\u0162": "T", "\\u0164": "T", "\\u0166": "T",
|
|
63
|
+
"\\u0163": "t", "\\u0165": "t", "\\u0167": "t",
|
|
64
|
+
"\\u0168": "U", "\\u016a": "U", "\\u016c": "U", "\\u016e": "U", "\\u0170": "U", "\\u0172": "U",
|
|
65
|
+
"\\u0169": "u", "\\u016b": "u", "\\u016d": "u", "\\u016f": "u", "\\u0171": "u", "\\u0173": "u",
|
|
66
|
+
"\\u0174": "W", "\\u0175": "w",
|
|
67
|
+
"\\u0176": "Y", "\\u0177": "y", "\\u0178": "Y",
|
|
68
|
+
"\\u0179": "Z", "\\u017b": "Z", "\\u017d": "Z",
|
|
69
|
+
"\\u017a": "z", "\\u017c": "z", "\\u017e": "z",
|
|
70
|
+
"\\u0132": "IJ", "\\u0133": "ij",
|
|
71
|
+
"\\u0152": "Oe", "\\u0153": "oe",
|
|
72
|
+
"\\u0149": "n", "\\u017f": "s"
|
|
73
|
+
} as Record<string, string>; `
|
|
74
|
+
}),
|
|
75
|
+
createComponent(Spacing, {}),
|
|
76
|
+
createComponent(TSDoc, {
|
|
77
|
+
heading: "A utility function that takes an input string and a list of possible matches, and returns a list of suggested matches based on the Levenshtein distance between the input and the possible matches.",
|
|
78
|
+
get children() {
|
|
79
|
+
return [
|
|
80
|
+
createComponent(TSDocRemarks, { children: "This function is intended to be used to suggest corrections for potentially misspelled options or commands." }),
|
|
81
|
+
createIntrinsic("hbr", {}),
|
|
82
|
+
createIntrinsic("hbr", {}),
|
|
83
|
+
createComponent(TSDocInternal, {}),
|
|
84
|
+
createIntrinsic("hbr", {}),
|
|
85
|
+
createIntrinsic("hbr", {}),
|
|
86
|
+
createComponent(TSDocParam, {
|
|
87
|
+
name: "input",
|
|
88
|
+
children: "The input string to check for potential matches."
|
|
89
|
+
}),
|
|
90
|
+
createComponent(TSDocParam, {
|
|
91
|
+
name: "options",
|
|
92
|
+
children: "A list of possible matches to compare against the input."
|
|
93
|
+
}),
|
|
94
|
+
createComponent(TSDocReturns, { children: "A list of suggested matches based on the Levenshtein distance." })
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
createComponent(FunctionDeclaration, {
|
|
99
|
+
"export": true,
|
|
100
|
+
name: "findSuggestions",
|
|
101
|
+
parameters: [{
|
|
102
|
+
name: "input",
|
|
103
|
+
type: "string"
|
|
104
|
+
}, {
|
|
105
|
+
name: "options",
|
|
106
|
+
type: "string[]"
|
|
107
|
+
}],
|
|
108
|
+
returnType: "string[]",
|
|
109
|
+
get children() {
|
|
110
|
+
return [
|
|
111
|
+
createComponent(VarDeclaration, {
|
|
112
|
+
"const": true,
|
|
113
|
+
name: "normalizedInput",
|
|
114
|
+
get initializer() {
|
|
115
|
+
return code`String(input ?? "")${context.config.isCaseSensitive ? "" : ".toLowerCase()"}.trim().replaceAll(/(\\s|_|-|,|\\.)+/gu, " ").replace(/[\\\\xc0-\\\\xd6\\\\xd8-\\\\xf6\\\\xf8-\\\\xff\\\\u0100-\\\\u017f]/g, key => deburred[key]).replace(/[\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe2f\\\\u20d0-\\\\u20ff]/g, ""); `;
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
118
|
+
createComponent(Spacing, {}),
|
|
119
|
+
memo(() => code`
|
|
120
|
+
if (!normalizedInput || options.length === 0) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const threshold = Math.ceil(normalizedInput.length * 0.25) || 1;
|
|
125
|
+
const results: Array<{ option: string; distance: number }> = [];
|
|
126
|
+
|
|
127
|
+
for (const option of options) {
|
|
128
|
+
const normalizedOption = String(option ?? "")${context.config.isCaseSensitive ? "" : ".toLowerCase()"}.trim().replaceAll(/(\\s|_|-|,|\\.)+/gu, " ").replace(/[\\\\xc0-\\\\xd6\\\\xd8-\\\\xf6\\\\xf8-\\\\xff\\\\u0100-\\\\u017f]/g, key => deburred[key]).replace(/[\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe2f\\\\u20d0-\\\\u20ff]/g, "");
|
|
129
|
+
|
|
130
|
+
if (!normalizedOption) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const lenA = normalizedInput.length;
|
|
135
|
+
const lenB = normalizedOption.length;
|
|
136
|
+
|
|
137
|
+
if (Math.abs(lenA - lenB) > threshold) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let distance: number;
|
|
142
|
+
if (lenA === 0) {
|
|
143
|
+
distance = lenB;
|
|
144
|
+
} else if (lenB === 0) {
|
|
145
|
+
distance = lenA;
|
|
146
|
+
} else if (lenA <= 32) {
|
|
147
|
+
const peq: Record<string, number> = {};
|
|
148
|
+
for (let i = 0; i < lenA; i++) {
|
|
149
|
+
const c = normalizedInput[i]!;
|
|
150
|
+
peq[c] = (peq[c] || 0) | (1 << i);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let pv = -1;
|
|
154
|
+
let mv = 0;
|
|
155
|
+
let score = lenA;
|
|
156
|
+
|
|
157
|
+
for (let j = 0; j < lenB; j++) {
|
|
158
|
+
const eq = peq[normalizedOption[j]!] || 0;
|
|
159
|
+
const xv = eq | mv;
|
|
160
|
+
const xh = ((eq & pv) + pv) ^ pv ^ eq;
|
|
161
|
+
let ph = mv | ~(xh | pv);
|
|
162
|
+
let mh = pv & xh;
|
|
163
|
+
|
|
164
|
+
if ((ph >>> (lenA - 1)) & 1) {
|
|
165
|
+
score++;
|
|
166
|
+
}
|
|
167
|
+
if ((mh >>> (lenA - 1)) & 1) {
|
|
168
|
+
score--;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
ph = (ph << 1) | 1;
|
|
172
|
+
mh = mh << 1;
|
|
173
|
+
pv = mh | ~(xv | ph);
|
|
174
|
+
mv = ph & xv;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
distance = score;
|
|
178
|
+
} else {
|
|
179
|
+
const row = new Array(lenB + 1);
|
|
180
|
+
for (let j = 0; j <= lenB; j++) {
|
|
181
|
+
row[j] = j;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
for (let i = 1; i <= lenA; i++) {
|
|
185
|
+
let prev = i;
|
|
186
|
+
for (let j = 1; j <= lenB; j++) {
|
|
187
|
+
const val = normalizedInput[i - 1] === normalizedOption[j - 1]
|
|
188
|
+
? row[j - 1]
|
|
189
|
+
: Math.min(row[j - 1], prev, row[j]) + 1;
|
|
190
|
+
row[j - 1] = prev;
|
|
191
|
+
prev = val;
|
|
192
|
+
}
|
|
193
|
+
row[lenB] = prev;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
distance = row[lenB];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (distance <= threshold) {
|
|
200
|
+
results.push({ option, distance });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return results.sort((a, b) => a.distance - b.distance).map(r => r.option);
|
|
205
|
+
`)
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
11
212
|
* Generates utilities for detecting terminal color support.
|
|
12
213
|
*/
|
|
13
214
|
function EnvSupportUtilities() {
|
|
@@ -894,6 +1095,8 @@ function UtilsBuiltin(props) {
|
|
|
894
1095
|
createComponent(Spacing, {}),
|
|
895
1096
|
createComponent(SpawnFunctionDeclaration, {}),
|
|
896
1097
|
createComponent(Spacing, {}),
|
|
1098
|
+
createComponent(FindSuggestionsDeclaration, {}),
|
|
1099
|
+
createComponent(Spacing, {}),
|
|
897
1100
|
createComponent(Show, {
|
|
898
1101
|
get when() {
|
|
899
1102
|
return Boolean(children);
|
|
@@ -906,5 +1109,5 @@ function UtilsBuiltin(props) {
|
|
|
906
1109
|
}
|
|
907
1110
|
|
|
908
1111
|
//#endregion
|
|
909
|
-
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, SpawnFunctionDeclaration, UtilsBuiltin };
|
|
1112
|
+
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, FindSuggestionsDeclaration, HyperlinkSupportUtilities, SpawnFunctionDeclaration, UtilsBuiltin };
|
|
910
1113
|
//# sourceMappingURL=utils-builtin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","InterfaceDeclaration","InterfaceMember","TypeDeclaration","VarDeclaration","Spacing","BuiltinFile","TSDoc","TSDocInternal","TSDocLink","TSDocParam","TSDocRemarks","TSDocReturns","defu","EnvSupportUtilities","_$createComponent","name","doc","initializer","ColorSupportUtilities","children","type","heading","parameters","default","HyperlinkSupportUtilities","returnType","ArgsUtilities","_$createIntrinsic","SpawnFunctionDeclaration","async","optional","ContextUtilities","UtilsBuiltin","props","rest","_$mergeProps","id","description","imports","alias","builtinImports","console","env","when","Boolean"],"sources":["../../src/components/utils-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n TypeDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocInternal,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface UtilsBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function EnvSupportUtilities() {\n return (\n <>\n <VarDeclaration\n export\n const\n name=\"isTTY\"\n doc=\"Detect if stdout.TTY is available\"\n initializer={code`Boolean(process.stdout && process.stdout.isTTY);`}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isMinimal\"\n doc=\"Detect if the current environment is minimal (CI, non-TTY, etc.)\"\n initializer={code` env.MINIMAL || isCI || isTest || !isTTY; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isInteractive\"\n doc=\"Detect if the current environment is interactive\"\n initializer={code` !isMinimal && process.stdin?.isTTY && env.TERM !== \"dumb\" && !hasFlag([\"no-interactive\", \"non-interactive\", \"no-interact\"]); `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ColorSupportUtilities() {\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"GetColorSupportLevelOptions\"\n doc=\"Options for the getColorSupportLevel function\">\n <InterfaceMember\n name=\"ignoreFlags\"\n type=\"boolean\"\n doc=\"Indicates if the function should skip checking command-line flags for color support\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Checks if a specific flag is present in the command-line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {'The flag to check for, e.g., \"color\", \"no-color\".'}\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command-line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"getColorSupportLevel\"\n parameters={[\n { name: \"stream\", type: \"NodeJS.WriteStream & { fd: 1 | 2; }\" },\n {\n name: \"options\",\n type: \"GetColorSupportLevelOptions\",\n default: \"{ ignoreFlags: false }\"\n }\n ]}>\n {code`const { ignoreFlags } = options;\n\n let forceColor: number | undefined;\n if (env.FORCE_COLOR !== undefined) {\n forceColor = !env.FORCE_COLOR\n ? 0\n : typeof env.FORCE_COLOR === \"boolean\"\n ? 1\n : typeof env.FORCE_COLOR === \"number\" &&\n [0, 1, 2, 3].includes(Math.min(env.FORCE_COLOR as number, 3))\n ? Math.min(env.FORCE_COLOR as number, 3)\n : undefined;\n }\n\n if (ignoreFlags !== true && forceColor === undefined) {\n if (\n hasFlag(\"no-color\") ||\n hasFlag(\"no-colors\") ||\n hasFlag(\"color=false\") ||\n hasFlag(\"color=never\")\n ) {\n return 0;\n }\n\n if (\n hasFlag(\"color=16m\") ||\n hasFlag(\"color=full\") ||\n hasFlag(\"color=truecolor\")\n ) {\n return 3;\n }\n\n if (hasFlag(\"color=256\")) {\n return 2;\n }\n\n if (\n hasFlag(\"color\") ||\n hasFlag(\"colors\") ||\n hasFlag(\"color=true\") ||\n hasFlag(\"color=always\")\n ) {\n forceColor = 1;\n }\n }\n\n const level = Boolean(env.TF_BUILD) || Boolean(env.AGENT_NAME)\n ? 1\n : stream &&\n !(isTTY || (stream && stream.isTTY)) &&\n forceColor === undefined\n ? 0\n : env.TERM === \"dumb\"\n ? forceColor || 0\n : isWindows\n ? Number(os.release().split(\".\")[0]) >= 10 &&\n Number(os.release().split(\".\")[2]) >= 10_586\n ? Number(os.release().split(\".\")[2]) >= 14_931\n ? 3\n : 2\n : 1\n : isCI\n ? Boolean(env.GITHUB_ACTIONS) ||\n Boolean(env.GITEA_ACTIONS) ||\n Boolean(env.CIRCLECI)\n ? 3\n : Boolean(env.TRAVIS) ||\n Boolean(env.APPVEYOR) ||\n Boolean(env.GITLAB_CI) ||\n Boolean(env.BUILDKITE) ||\n Boolean(env.DRONE) ||\n env.CI_NAME === \"codeship\"\n ? 1\n : forceColor || 0\n : Boolean(env.TEAMCITY_VERSION)\n ? /^(?:9\\.0*[1-9]\\d*\\.|\\d{2,}\\.)/.test(String(env.TEAMCITY_VERSION) || \"\")\n ? 1\n : 0\n : String(env.COLORTERM) === \"truecolor\" ||\n env.TERM === \"xterm-kitty\"\n ? 3\n : Boolean(env.TERM_PROGRAM)\n ? env.TERM_PROGRAM === \"iTerm.app\"\n ? Number.parseInt(\n (env.TERM_PROGRAM_VERSION || \"\").split(\".\")[0] as string,\n 10\n ) >= 3\n ? 3\n : 2\n : env.TERM_PROGRAM === \"Apple_Terminal\"\n ? 2\n : 0\n : /-256(?:color)?$/i.test(env.TERM || \"\")\n ? 2\n : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(\n env.TERM || \"\"\n )\n ? 1\n : Boolean(env.COLORTERM);\n\n return typeof level === \"boolean\" || level === 0\n ? false\n : {\n level,\n hasBasic: true,\n has256: level >= 2,\n has16m: level >= 3,\n };\n\n `}\n </FunctionDeclaration>\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"colorSupportLevels\"\n doc=\"Detect the terminal color support level in the current environment\"\n initializer={code` {\n stdout: getColorSupportLevel(process.stdout),\n stderr: getColorSupportLevel(process.stderr),\n }; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isColorSupported\"\n doc=\"Detect if terminal color is supported in the current environment\"\n initializer={code` Boolean(colorSupportLevels.stdout); `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isUnicodeSupported\"\n doc=\"Detect if Unicode characters are supported in the current environment\"\n initializer={code` !isWindows\n ? env.TERM !== \"linux\"\n : Boolean(env.WT_SESSION) ||\n Boolean(env.TERMINUS_SUBLIME) ||\n env.ConEmuTask === \"{cmd::Cmder}\" ||\n env.TERM_PROGRAM === \"Terminus-Sublime\" ||\n env.TERM_PROGRAM === \"vscode\" ||\n env.TERM === \"xterm-256color\" ||\n env.TERM === \"alacritty\" ||\n env.TERM === \"rxvt-unicode\" ||\n env.TERM === \"rxvt-unicode-256color\" ||\n env.TERMINAL_EMULATOR === \"JetBrains-JediTerm\"; `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\n\nexport function HyperlinkSupportUtilities() {\n return (\n <>\n <FunctionDeclaration\n name=\"parseVersion\"\n parameters={[{ name: \"version\", type: \"string\", default: '\"\"' }]}>\n {code`if (/^\\d{3,4}$/.test(version)) {\n const match = /(\\d{1,2})(\\d{2})/.exec(version) ?? [];\n\n return {\n major: 0,\n minor: Number.parseInt(match[1]!, 10),\n patch: Number.parseInt(match[2]!, 10)\n };\n }\n\n const versionParts = (version ?? \"\")\n .split(\".\")\n .map(n => Number.parseInt(n, 10));\n\n return {\n major: versionParts[0],\n minor: versionParts[1],\n patch: versionParts[2]\n }; `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Check if the current environment/terminal supports hyperlinks in the terminal.\">\n <TSDocReturns>\n {\"True if the current environment/terminal supports hyperlinks.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"isHyperlinkSupported\"\n returnType=\"boolean\">\n {code`if (Boolean(env.FORCE_HYPERLINK)) {\n return true;\n }\n\n if (Boolean(env.NETLIFY)) {\n return true;\n } else if (isColorSupported || isTTY) {\n return false;\n } else if (Boolean(env.WT_SESSION)) {\n return true;\n } else if (isWindows || isMinimal || Boolean(env.TEAMCITY_VERSION)) {\n return false;\n } else if (Boolean(env.TERM_PROGRAM)) {\n const version = parseVersion(env.TERM_PROGRAM_VERSION);\n\n switch (String(env.TERM_PROGRAM)) {\n case \"iTerm.app\": {\n if (version.major === 3) {\n return version.minor !== undefined && version.minor >= 1;\n }\n\n return version.major !== undefined && version.major > 3;\n }\n case \"WezTerm\": {\n return version.major !== undefined && version.major >= 20_200_620;\n }\n\n case \"vscode\": {\n if (Boolean(env.CURSOR_TRACE_ID)) {\n return true;\n }\n\n return (\n version.minor !== undefined &&\n version.major !== undefined &&\n (version.major > 1 || (version.major === 1 && version.minor >= 72))\n );\n }\n\n case \"ghostty\": {\n return true;\n }\n }\n }\n\n if (Boolean(env.VTE_VERSION)) {\n if (env.VTE_VERSION === \"0.50.0\") {\n return false;\n }\n\n const version = parseVersion(env.VTE_VERSION);\n return (\n (version.major !== undefined && version.major > 0) ||\n (version.minor !== undefined && version.minor >= 50)\n );\n }\n\n if (String(env.TERM) === \"alacritty\") {\n return true;\n }\n\n return false; `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ArgsUtilities() {\n return (\n <>\n <TSDoc heading=\"Retrieves the command-line arguments from Deno or Node.js environments.\">\n <TSDocRemarks>\n {\n \"This function is only intended for internal use. Please use `useArgs()` instead.\"\n }\n </TSDocRemarks>\n <hbr />\n <hbr />\n <TSDocInternal />\n <hbr />\n <hbr />\n <TSDocReturns>\n {\n \"An array of command-line arguments from Deno or Node.js environments.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"getArgs\" returnType=\"string[]\">\n {code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Checks if a specific flag is present in the command-line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {\n 'The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\".'\n }\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command-line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"hasFlag\"\n parameters={[\n { name: \"flag\", type: \"string | string[]\" },\n {\n name: \"argv\",\n type: \"string[]\",\n default: \"useArgs()\"\n }\n ]}>\n <VarDeclaration\n const\n name=\"position\"\n type=\"number\"\n initializer={code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {\n const pos = argv.findIndex(arg => (f.startsWith(\"-\") ? \"\" : (f.length === 1 ? \"-\" : \"--\") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? \"-\" : \"--\") + f + \"=\"));\n return pos !== -1 ? pos : ret;\n }, -1);`}\n />\n <hbr />\n {code`return position !== -1 && argv.indexOf(\"--\") === -1 || position < argv.indexOf(\"--\");`}\n </FunctionDeclaration>\n <Spacing />\n <VarDeclaration\n export\n name=\"isHelp\"\n type=\"boolean\"\n initializer={code` !isCI && hasFlag([\"help\", \"h\", \"?\"]); `}\n />\n </>\n );\n}\n\n/**\n * Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.\n */\nexport function SpawnFunctionDeclaration() {\n return (\n <>\n <FunctionDeclaration\n async\n name=\"resolveCommand\"\n parameters={[\n {\n name: \"command\",\n type: \"string\"\n },\n {\n name: \"options\",\n type: \"Record<string, any>\",\n default: \"{}\"\n },\n {\n name: \"pathExt\",\n type: \"string\",\n default:\n 'process.env.PATHEXT || [\".EXE\", \".CMD\", \".BAT\", \".COM\"].join(delimiter)'\n }\n ]}>\n {code`const env = options.env || process.env;\n const cwd = process.cwd();\n if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {\n try {\n process.chdir(options.cwd);\n } catch (err) {\n // Do nothing\n }\n }\n\n let resolved;\n try {\n let extensions = [\"\"];\n if (isWindows) {\n extensions = pathExt.split(delimiter).flatMap((item) => [item, item.toLowerCase()]);\n if (command.includes(\".\") && extensions[0] !== \"\") {\n extensions.unshift(\"\");\n }\n }\n\n for (const envPart of (command.match(new RegExp(\\`[\\${posix.sep}\\${sep === posix.sep ? \"\" : sep}]\\`.replace(/(\\\\\\\\)/g, \"\\\\\\\\$1\"))))\n ? [...(isWindows ? [process.cwd()] : []), ...(process.env.PATH || \"\").split(delimiter)]\n : [\"\"]\n ) {\n const part = \\`\\${!(/^\".*\"$/.test(envPart) ? envPart.slice(1, -1) : envPart) && new RegExp(\\`^\\\\.\\${new RegExp(\\`[\\${posix.sep}\\${sep === posix.sep ? \"\" : sep}]\\`.replace(/(\\\\\\\\)/g, \"\\\\\\\\$1\")).source}\\`).test(command) ? command.slice(0, 2) : \"\"}\\${join(/^\".*\"$/.test(envPart) ? envPart.slice(1, -1) : envPart, command)}\\`;\n for (const extension of extensions) {\n if (isWindows) {\n const filePath = part + extension;\n if ((await stat(filePath)).isFile() && extensions.some((ext) => filePath.substring(filePath.length - ext.length).toLowerCase() === ext.toLowerCase())) {\n resolved = filePath;\n break;\n }\n } else {\n const file = await stat(part + extension);\n if (file.isFile() && (file.mode & 0o111) !== 0) {\n resolved = part + extension;\n break;\n }\n }\n }\n }\n } catch (err) {\n // Do nothing\n } finally {\n if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {\n process.chdir(cwd);\n }\n }\n\n\n if (resolved) {\n resolved = resolve(\n options.cwd ? options.cwd : \"\",\n resolved\n );\n }\n\n return resolved; `}\n </FunctionDeclaration>\n <Spacing />\n <InterfaceDeclaration\n name=\"SpawnBaseOptions\"\n doc=\"Options for the `spawn` handler function.\">\n <InterfaceMember\n name=\"stdout\"\n optional\n type=\"(data: string) => void\"\n doc=\"The writable stream to use for prompt output, defaults to process.stdout\"\n />\n <hbr />\n <InterfaceMember\n name=\"stderr\"\n optional\n type=\"(data: string) => void\"\n doc=\"The writable stream to use for prompt error output, defaults to process.stderr\"\n />\n <hbr />\n <InterfaceMember\n name=\"rejectOnError\"\n optional\n type=\"boolean\"\n doc=\"Whether to reject the promise on error. Defaults to false.\"\n />\n <hbr />\n <InterfaceMember\n name=\"file\"\n optional\n type=\"string\"\n doc=\"The file to execute.\"\n />\n <hbr />\n <InterfaceMember\n name=\"shell\"\n optional\n type=\"boolean | string\"\n doc=\"If true, runs command inside of a shell. Uses '/bin/sh' on UNIX, and process.env.ComSpec on Windows. If a string is provided, it specifies the shell to use.\"\n />\n <hbr />\n <InterfaceMember\n name=\"forceShell\"\n optional\n type=\"boolean\"\n doc=\"If true, forces the command to run inside of a shell, even if the command is a file.\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <TypeDeclaration export name=\"SpawnOptions\">\n {code`SpawnBaseOptions & Parameters<typeof _spawn>[1]`}\n </TypeDeclaration>\n <Spacing />\n <TSDoc heading=\"A function to spawn child processes with proper color support and environment variable handling.\">\n <TSDocParam name=\"command\">{`The command to execute.`}</TSDocParam>\n <TSDocParam name=\"args\">\n {`The command-line arguments to pass to the command. Defaults to an empty array.`}\n </TSDocParam>\n <TSDocParam name=\"options\">\n {`Additional options for spawning the process, such as the current working directory (\\`cwd\\`).`}\n </TSDocParam>\n <TSDocReturns>{`The result of the spawned process.`}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"spawn\"\n parameters={[\n { name: \"command\", type: \"string\" },\n {\n name: \"args\",\n type: \"string[] | SpawnOptions\",\n default: \"{} as SpawnOptions\"\n },\n {\n name: \"options\",\n type: \"SpawnOptions\",\n default: \"{} as SpawnOptions\"\n }\n ]}>\n {code`const normalized = {\n command,\n args: [] as string[],\n options: options as SpawnOptions | any,\n file: undefined as string | undefined,\n original: {\n command,\n args,\n },\n };\n\n if (args) {\n if (Array.isArray(args)) {\n if (args.length > 0) {\n normalized.args = args.slice(0);\n }\n } else {\n normalized.options = { ...args } as SpawnOptions | any;\n normalized.args = [];\n }\n }\n\n if (!normalized.options.shell && isWindows) {\n normalized.file = (await resolveCommand(normalized.command, normalized.options)) || (await resolveCommand(normalized.command, normalized.options, delimiter));\n\n let commandFile = normalized.file;\n if (normalized.file) {\n let shebang: string | undefined;\n const buffer = Buffer.alloc(150);\n\n try {\n const fd = openSync(normalized.file, \"r\");\n await promisify(read)(fd, buffer, 0, 150, 0);\n closeSync(fd);\n } catch (err) {\n // Do nothing\n }\n\n const matched = buffer.toString().match(/^#!(.*)/);\n if (matched) {\n const [path, argument] = matched[0].replace(/#! ?/, \"\").split(\" \");\n\t const binary = path.split(\"/\").pop();\n if (binary === \"env\") {\n shebang = argument;\n } else {\n shebang = argument ? \\`\\${binary} \\${argument}\\` : binary;\n }\n }\n\n if (shebang) {\n normalized.args.unshift(normalized.file);\n normalized.command = shebang;\n\n commandFile = await resolveCommand(normalized.command, normalized.options);\n }\n }\n\n if (commandFile && (normalized.options.forceShell || /\\\\.(?:com|exe)$/i.test(commandFile))) {\n normalized.command = normalize(normalized.command).replace(/([()\\\\][%!^\"\\`<>&|;, *?])/g, \"^$1\");\n\n normalized.args = [\"/d\", \"/s\", \"/c\", \\`\"\\${normalized.command} \\${normalized.args.map(arg =>\n \\`\\${arg}\\`.replace(/(?=(\\\\\\\\+?)?)\\\\1\"/g, \"$1$1\\\\\"\").replace(/(?=(\\\\\\\\+?)?)\\\\1$/, \"$1$1\")\n ).map(arg =>\n \\`\"\\${arg}\"\\`.replace(/([()\\\\][%!^\"\\`<>&|;, *?])/g, \"^$1\")\n ).map(arg =>\n /node_modules[\\\\\\\\/].bin[\\\\\\\\/][^\\\\\\\\/]+\\\\.cmd$/i.test(commandFile) ? arg.replace(/([()\\\\][%!^\"\\`<>&|;, *?])/g, \"^$1\") : arg\n ).join(\" \")}\"\\`];\n normalized.command = process.env.comspec || \"cmd.exe\";\n normalized.options.windowsVerbatimArguments = true;\n }\n }\n\n let stdout = \"\";\n let stderr = \"\";\n\n const child = _spawn(normalized.command, normalized.args, {\n cwd: process.cwd(),\n env: {\n ...process.env,\n FORCE_COLOR: isColorSupported ? \"1\" : \"0\",\n },\n ...normalized.options,\n }) as ReturnType<typeof _spawn>;\n\n if (isWindows) {\n const emit = child.emit;\n child.emit = (eventName: string | symbol, ...eventArgs: any[]) => {\n if (eventName === \"exit\") {\n let err: Error | null = null;\n if (eventArgs[0] === 1 && !normalized.file) {\n err = Object.assign(new Error(\\`spawn \\${normalized.original.command} ENOENT\\`), {\n code: \"ENOENT\",\n errno: \"ENOENT\",\n syscall: \\`spawn \\${normalized.original.command}\\`,\n path: normalized.original.command,\n spawnargs: normalized.original.args,\n });\n }\n\n if (err) {\n return emit.call(child, \"error\", err);\n }\n }\n\n return emit.apply(child, [eventName, ...eventArgs]);\n };\n }\n\n return new Promise((resolve, reject) => {\n if (normalized.options.stdin !== undefined) {\n child.stdin?.write(normalized.options.stdin);\n }\n\n child.stdin?.end();\n\n child.stdout?.on(\"data\", data => {\n stdout += data;\n if (normalized.options.stdout) {\n normalized.options.stdout(data);\n }\n });\n\n child.stderr?.on(\"data\", data => {\n stderr += data;\n if (normalized.options.stderr) {\n normalized.options.stderr(data);\n }\n });\n\n if (normalized.options.rejectOnError) {\n child.addListener(\"error\", reject);\n }\n\n child.on(\"close\", code => {\n if (code !== 0 && normalized.options.rejectOnError) {\n reject(stderr);\n } else {\n resolve({ stdout, stderr });\n }\n });\n }); `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport function ContextUtilities() {\n return code`\n /**\n * The global Shell Shock - Application context instance.\n *\n * @internal\n */\n export let internal_appContext = new AsyncLocalStorage<Map<string, any>>();\n\n /**\n * Get the Shell Shock - Application context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Application context for the current application or undefined if the context is not available.\n */\n export function useApp(): Map<string, any> | undefined {\n return internal_appContext.getStore();\n }\n\n /**\n * A utility hook function to get the command line arguments from the application context.\n *\n * @returns An array of command-line arguments from the application context.\n * @throws If the application context is not available.\n */\n export function useArgs(): string[] {\n return useApp()?.get(\"args\") ?? getArgs();\n }\n\n /**\n * The context object for the current command execution, containing the command path and segments.\n */\n export interface CommandContext {\n path: string;\n segments: string[];\n }\n\n /**\n * The global Shell Shock - Command context instance.\n *\n * @internal\n */\n export let internal_commandContext = new AsyncLocalStorage<CommandContext>();\n\n /**\n * Get the Shell Shock - Command context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Command context for the current application.\n * @throws If the Shell Shock - Command context is not available.\n */\n export function useCommand(): CommandContext {\n const result = internal_commandContext.getStore();\n if (!result) {\n throw new Error(\n \\`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\\`\n );\n }\n return result;\n }\n\n /**\n * A utility hook function to get the individual segments of the current command path.\n *\n * @returns An array of command path segments.\n * @throws If the command context is not available.\n */\n export function useSegments(): string[] {\n return useCommand().segments;\n }\n\n /**\n * A utility hook function to get the full command path as a string.\n *\n * @returns The full command path as a string.\n * @throws If the command context is not available.\n */\n export function usePath(): string {\n return useCommand().path;\n }\n `;\n}\n\n/**\n * A built-in utilities module for Shell Shock.\n */\nexport function UtilsBuiltin(props: UtilsBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"utils\"\n description=\"A collection of helper utilities that ease command-line application development.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:os\": \"os\",\n \"node:process\": \"process\",\n \"node:path\": [\n \"resolve\",\n \"delimiter\",\n \"normalize\",\n \"join\",\n \"posix\",\n \"sep\"\n ],\n \"node:fs\": [\"openSync\", \"closeSync\", \"read\"],\n \"node:fs/promises\": [\"stat\"],\n \"node:util\": [\"promisify\"],\n \"node:child_process\": [{ name: \"spawn\", alias: \"_spawn\" }],\n \"node:async_hooks\": [\"AsyncLocalStorage\"]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"writeLine\"],\n env: [\"env\", \"isCI\", \"isTest\", \"isWindows\", \"isDevelopment\", \"isDebug\"]\n })}>\n <Spacing />\n <ContextUtilities />\n <Spacing />\n <ArgsUtilities />\n <Spacing />\n <EnvSupportUtilities />\n <Spacing />\n <HyperlinkSupportUtilities />\n <Spacing />\n <ColorSupportUtilities />\n <Spacing />\n <SpawnFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+CA,SAAgBiB,sBAAsB;AACpC,QAAA;EAAAC,gBAEKX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,IAAI;GAAkD,CAAA;EAAAkB,gBAEpEV,SAAO,EAAA,CAAA;EAAAU,gBACPX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,IAAI;GAA4C,CAAA;EAAAkB,gBAE9DV,SAAO,EAAA,CAAA;EAAAU,gBACPX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,IAAI;GAAgI,CAAA;EAAA;;;;;AASzJ,SAAgBsB,wBAAwB;AACtC,QAAA;EAAAJ,gBAEKd,sBAAoB;GAAA,UAAA;GAEnBe,MAAI;GACJC,KAAG;GAAA,IAAAG,WAAA;AAAA,WAAAL,gBACFb,iBAAe;KACdc,MAAI;KACJK,MAAI;KACJJ,KAAG;KAAA,CAAA;;GAAA,CAAA;EAAAF,gBAGNV,SAAO,EAAA,CAAA;EAAAU,gBACPR,OAAK;GAACe,SAAO;GAAA,IAAAF,WAAA;AAAA,WAAA;KAAAL,gBACXN,WAAS,EAAAW,UACP,+DAA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AA;IAAAU,gBACPjB,MAAI;KAAA,IAAC8C,OAAI;AAAA,aAAEC,QAAQzB,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","InterfaceDeclaration","InterfaceMember","TypeDeclaration","VarDeclaration","Spacing","usePowerlines","BuiltinFile","TSDoc","TSDocInternal","TSDocLink","TSDocParam","TSDocRemarks","TSDocReturns","defu","FindSuggestionsDeclaration","context","_$createComponent","name","initializer","heading","children","_$createIntrinsic","parameters","type","returnType","config","isCaseSensitive","_$memo","EnvSupportUtilities","doc","ColorSupportUtilities","default","HyperlinkSupportUtilities","ArgsUtilities","SpawnFunctionDeclaration","async","optional","ContextUtilities","UtilsBuiltin","props","rest","_$mergeProps","id","description","imports","alias","builtinImports","console","env","when","Boolean"],"sources":["../../src/components/utils-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n TypeDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/dist/core/contexts/context.mjs\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocInternal,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\nimport type { Context } from \"../types/context\";\n\nexport interface UtilsBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * Generates the `findSuggestions` function for suggesting corrections for potentially misspelled options or commands.\n */\nexport function FindSuggestionsDeclaration() {\n const context = usePowerlines<Context>();\n\n return (\n <>\n <VarDeclaration\n const\n name=\"deburred\"\n initializer={code` {\n \"\\\\xc0\": \"A\", \"\\\\xc1\": \"A\", \"\\\\xc2\": \"A\", \"\\\\xc3\": \"A\", \"\\\\xc4\": \"A\", \"\\\\xc5\": \"A\",\n \"\\\\xe0\": \"a\", \"\\\\xe1\": \"a\", \"\\\\xe2\": \"a\", \"\\\\xe3\": \"a\", \"\\\\xe4\": \"a\", \"\\\\xe5\": \"a\",\n \"\\\\xc7\": \"C\", \"\\\\xe7\": \"c\",\n \"\\\\xd0\": \"D\", \"\\\\xf0\": \"d\",\n \"\\\\xc8\": \"E\", \"\\\\xc9\": \"E\", \"\\\\xca\": \"E\", \"\\\\xcb\": \"E\",\n \"\\\\xe8\": \"e\", \"\\\\xe9\": \"e\", \"\\\\xea\": \"e\", \"\\\\xeb\": \"e\",\n \"\\\\xcc\": \"I\", \"\\\\xcd\": \"I\", \"\\\\xce\": \"I\", \"\\\\xcf\": \"I\",\n \"\\\\xec\": \"i\", \"\\\\xed\": \"i\", \"\\\\xee\": \"i\", \"\\\\xef\": \"i\",\n \"\\\\xd1\": \"N\", \"\\\\xf1\": \"n\",\n \"\\\\xd2\": \"O\", \"\\\\xd3\": \"O\", \"\\\\xd4\": \"O\", \"\\\\xd5\": \"O\", \"\\\\xd6\": \"O\", \"\\\\xd8\": \"O\",\n \"\\\\xf2\": \"o\", \"\\\\xf3\": \"o\", \"\\\\xf4\": \"o\", \"\\\\xf5\": \"o\", \"\\\\xf6\": \"o\", \"\\\\xf8\": \"o\",\n \"\\\\xd9\": \"U\", \"\\\\xda\": \"U\", \"\\\\xdb\": \"U\", \"\\\\xdc\": \"U\",\n \"\\\\xf9\": \"u\", \"\\\\xfa\": \"u\", \"\\\\xfb\": \"u\", \"\\\\xfc\": \"u\",\n \"\\\\xdd\": \"Y\", \"\\\\xfd\": \"y\", \"\\\\xff\": \"y\",\n \"\\\\xc6\": \"Ae\", \"\\\\xe6\": \"ae\",\n \"\\\\xde\": \"Th\", \"\\\\xfe\": \"th\",\n \"\\\\xdf\": \"ss\",\n \"\\\\u0100\": \"A\", \"\\\\u0102\": \"A\", \"\\\\u0104\": \"A\",\n \"\\\\u0101\": \"a\", \"\\\\u0103\": \"a\", \"\\\\u0105\": \"a\",\n \"\\\\u0106\": \"C\", \"\\\\u0108\": \"C\", \"\\\\u010a\": \"C\", \"\\\\u010c\": \"C\",\n \"\\\\u0107\": \"c\", \"\\\\u0109\": \"c\", \"\\\\u010b\": \"c\", \"\\\\u010d\": \"c\",\n \"\\\\u010e\": \"D\", \"\\\\u0110\": \"D\", \"\\\\u010f\": \"d\", \"\\\\u0111\": \"d\",\n \"\\\\u0112\": \"E\", \"\\\\u0114\": \"E\", \"\\\\u0116\": \"E\", \"\\\\u0118\": \"E\", \"\\\\u011a\": \"E\",\n \"\\\\u0113\": \"e\", \"\\\\u0115\": \"e\", \"\\\\u0117\": \"e\", \"\\\\u0119\": \"e\", \"\\\\u011b\": \"e\",\n \"\\\\u011c\": \"G\", \"\\\\u011e\": \"G\", \"\\\\u0120\": \"G\", \"\\\\u0122\": \"G\",\n \"\\\\u011d\": \"g\", \"\\\\u011f\": \"g\", \"\\\\u0121\": \"g\", \"\\\\u0123\": \"g\",\n \"\\\\u0124\": \"H\", \"\\\\u0126\": \"H\", \"\\\\u0125\": \"h\", \"\\\\u0127\": \"h\",\n \"\\\\u0128\": \"I\", \"\\\\u012a\": \"I\", \"\\\\u012c\": \"I\", \"\\\\u012e\": \"I\", \"\\\\u0130\": \"I\",\n \"\\\\u0129\": \"i\", \"\\\\u012b\": \"i\", \"\\\\u012d\": \"i\", \"\\\\u012f\": \"i\", \"\\\\u0131\": \"i\",\n \"\\\\u0134\": \"J\", \"\\\\u0135\": \"j\",\n \"\\\\u0136\": \"K\", \"\\\\u0137\": \"k\", \"\\\\u0138\": \"k\",\n \"\\\\u0139\": \"L\", \"\\\\u013b\": \"L\", \"\\\\u013d\": \"L\", \"\\\\u013f\": \"L\", \"\\\\u0141\": \"L\",\n \"\\\\u013a\": \"l\", \"\\\\u013c\": \"l\", \"\\\\u013e\": \"l\", \"\\\\u0140\": \"l\", \"\\\\u0142\": \"l\",\n \"\\\\u0143\": \"N\", \"\\\\u0145\": \"N\", \"\\\\u0147\": \"N\", \"\\\\u014a\": \"N\",\n \"\\\\u0144\": \"n\", \"\\\\u0146\": \"n\", \"\\\\u0148\": \"n\", \"\\\\u014b\": \"n\",\n \"\\\\u014c\": \"O\", \"\\\\u014e\": \"O\", \"\\\\u0150\": \"O\",\n \"\\\\u014d\": \"o\", \"\\\\u014f\": \"o\", \"\\\\u0151\": \"o\",\n \"\\\\u0154\": \"R\", \"\\\\u0156\": \"R\", \"\\\\u0158\": \"R\",\n \"\\\\u0155\": \"r\", \"\\\\u0157\": \"r\", \"\\\\u0159\": \"r\",\n \"\\\\u015a\": \"S\", \"\\\\u015c\": \"S\", \"\\\\u015e\": \"S\", \"\\\\u0160\": \"S\",\n \"\\\\u015b\": \"s\", \"\\\\u015d\": \"s\", \"\\\\u015f\": \"s\", \"\\\\u0161\": \"s\",\n \"\\\\u0162\": \"T\", \"\\\\u0164\": \"T\", \"\\\\u0166\": \"T\",\n \"\\\\u0163\": \"t\", \"\\\\u0165\": \"t\", \"\\\\u0167\": \"t\",\n \"\\\\u0168\": \"U\", \"\\\\u016a\": \"U\", \"\\\\u016c\": \"U\", \"\\\\u016e\": \"U\", \"\\\\u0170\": \"U\", \"\\\\u0172\": \"U\",\n \"\\\\u0169\": \"u\", \"\\\\u016b\": \"u\", \"\\\\u016d\": \"u\", \"\\\\u016f\": \"u\", \"\\\\u0171\": \"u\", \"\\\\u0173\": \"u\",\n \"\\\\u0174\": \"W\", \"\\\\u0175\": \"w\",\n \"\\\\u0176\": \"Y\", \"\\\\u0177\": \"y\", \"\\\\u0178\": \"Y\",\n \"\\\\u0179\": \"Z\", \"\\\\u017b\": \"Z\", \"\\\\u017d\": \"Z\",\n \"\\\\u017a\": \"z\", \"\\\\u017c\": \"z\", \"\\\\u017e\": \"z\",\n \"\\\\u0132\": \"IJ\", \"\\\\u0133\": \"ij\",\n \"\\\\u0152\": \"Oe\", \"\\\\u0153\": \"oe\",\n \"\\\\u0149\": \"n\", \"\\\\u017f\": \"s\"\n } as Record<string, string>; `}\n />\n <Spacing />\n <TSDoc heading=\"A utility function that takes an input string and a list of possible matches, and returns a list of suggested matches based on the Levenshtein distance between the input and the possible matches.\">\n <TSDocRemarks>\n {\n \"This function is intended to be used to suggest corrections for potentially misspelled options or commands.\"\n }\n </TSDocRemarks>\n <hbr />\n <hbr />\n <TSDocInternal />\n <hbr />\n <hbr />\n <TSDocParam name=\"input\">\n {\"The input string to check for potential matches.\"}\n </TSDocParam>\n <TSDocParam name=\"options\">\n {\"A list of possible matches to compare against the input.\"}\n </TSDocParam>\n <TSDocReturns>\n {\"A list of suggested matches based on the Levenshtein distance.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"findSuggestions\"\n parameters={[\n {\n name: \"input\",\n type: \"string\"\n },\n {\n name: \"options\",\n type: \"string[]\"\n }\n ]}\n returnType=\"string[]\">\n <VarDeclaration\n const\n name=\"normalizedInput\"\n initializer={code`String(input ?? \"\")${\n context.config.isCaseSensitive ? \"\" : \".toLowerCase()\"\n }.trim().replaceAll(/(\\\\s|_|-|,|\\\\.)+/gu, \" \").replace(/[\\\\\\\\xc0-\\\\\\\\xd6\\\\\\\\xd8-\\\\\\\\xf6\\\\\\\\xf8-\\\\\\\\xff\\\\\\\\u0100-\\\\\\\\u017f]/g, key => deburred[key]).replace(/[\\\\\\\\u0300-\\\\\\\\u036f\\\\\\\\ufe20-\\\\\\\\ufe2f\\\\\\\\u20d0-\\\\\\\\u20ff]/g, \"\"); `}\n />\n <Spacing />\n {code`\n if (!normalizedInput || options.length === 0) {\n return [];\n }\n\n const threshold = Math.ceil(normalizedInput.length * 0.25) || 1;\n const results: Array<{ option: string; distance: number }> = [];\n\n for (const option of options) {\n const normalizedOption = String(option ?? \"\")${\n context.config.isCaseSensitive ? \"\" : \".toLowerCase()\"\n }.trim().replaceAll(/(\\\\s|_|-|,|\\\\.)+/gu, \" \").replace(/[\\\\\\\\xc0-\\\\\\\\xd6\\\\\\\\xd8-\\\\\\\\xf6\\\\\\\\xf8-\\\\\\\\xff\\\\\\\\u0100-\\\\\\\\u017f]/g, key => deburred[key]).replace(/[\\\\\\\\u0300-\\\\\\\\u036f\\\\\\\\ufe20-\\\\\\\\ufe2f\\\\\\\\u20d0-\\\\\\\\u20ff]/g, \"\");\n\n if (!normalizedOption) {\n continue;\n }\n\n const lenA = normalizedInput.length;\n const lenB = normalizedOption.length;\n\n if (Math.abs(lenA - lenB) > threshold) {\n continue;\n }\n\n let distance: number;\n if (lenA === 0) {\n distance = lenB;\n } else if (lenB === 0) {\n distance = lenA;\n } else if (lenA <= 32) {\n const peq: Record<string, number> = {};\n for (let i = 0; i < lenA; i++) {\n const c = normalizedInput[i]!;\n peq[c] = (peq[c] || 0) | (1 << i);\n }\n\n let pv = -1;\n let mv = 0;\n let score = lenA;\n\n for (let j = 0; j < lenB; j++) {\n const eq = peq[normalizedOption[j]!] || 0;\n const xv = eq | mv;\n const xh = ((eq & pv) + pv) ^ pv ^ eq;\n let ph = mv | ~(xh | pv);\n let mh = pv & xh;\n\n if ((ph >>> (lenA - 1)) & 1) {\n score++;\n }\n if ((mh >>> (lenA - 1)) & 1) {\n score--;\n }\n\n ph = (ph << 1) | 1;\n mh = mh << 1;\n pv = mh | ~(xv | ph);\n mv = ph & xv;\n }\n\n distance = score;\n } else {\n const row = new Array(lenB + 1);\n for (let j = 0; j <= lenB; j++) {\n row[j] = j;\n }\n\n for (let i = 1; i <= lenA; i++) {\n let prev = i;\n for (let j = 1; j <= lenB; j++) {\n const val = normalizedInput[i - 1] === normalizedOption[j - 1]\n ? row[j - 1]\n : Math.min(row[j - 1], prev, row[j]) + 1;\n row[j - 1] = prev;\n prev = val;\n }\n row[lenB] = prev;\n }\n\n distance = row[lenB];\n }\n\n if (distance <= threshold) {\n results.push({ option, distance });\n }\n }\n\n return results.sort((a, b) => a.distance - b.distance).map(r => r.option);\n `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function EnvSupportUtilities() {\n return (\n <>\n <VarDeclaration\n export\n const\n name=\"isTTY\"\n doc=\"Detect if stdout.TTY is available\"\n initializer={code`Boolean(process.stdout && process.stdout.isTTY);`}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isMinimal\"\n doc=\"Detect if the current environment is minimal (CI, non-TTY, etc.)\"\n initializer={code` env.MINIMAL || isCI || isTest || !isTTY; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isInteractive\"\n doc=\"Detect if the current environment is interactive\"\n initializer={code` !isMinimal && process.stdin?.isTTY && env.TERM !== \"dumb\" && !hasFlag([\"no-interactive\", \"non-interactive\", \"no-interact\"]); `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ColorSupportUtilities() {\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"GetColorSupportLevelOptions\"\n doc=\"Options for the getColorSupportLevel function\">\n <InterfaceMember\n name=\"ignoreFlags\"\n type=\"boolean\"\n doc=\"Indicates if the function should skip checking command-line flags for color support\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Checks if a specific flag is present in the command-line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {'The flag to check for, e.g., \"color\", \"no-color\".'}\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command-line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"getColorSupportLevel\"\n parameters={[\n { name: \"stream\", type: \"NodeJS.WriteStream & { fd: 1 | 2; }\" },\n {\n name: \"options\",\n type: \"GetColorSupportLevelOptions\",\n default: \"{ ignoreFlags: false }\"\n }\n ]}>\n {code`const { ignoreFlags } = options;\n\n let forceColor: number | undefined;\n if (env.FORCE_COLOR !== undefined) {\n forceColor = !env.FORCE_COLOR\n ? 0\n : typeof env.FORCE_COLOR === \"boolean\"\n ? 1\n : typeof env.FORCE_COLOR === \"number\" &&\n [0, 1, 2, 3].includes(Math.min(env.FORCE_COLOR as number, 3))\n ? Math.min(env.FORCE_COLOR as number, 3)\n : undefined;\n }\n\n if (ignoreFlags !== true && forceColor === undefined) {\n if (\n hasFlag(\"no-color\") ||\n hasFlag(\"no-colors\") ||\n hasFlag(\"color=false\") ||\n hasFlag(\"color=never\")\n ) {\n return 0;\n }\n\n if (\n hasFlag(\"color=16m\") ||\n hasFlag(\"color=full\") ||\n hasFlag(\"color=truecolor\")\n ) {\n return 3;\n }\n\n if (hasFlag(\"color=256\")) {\n return 2;\n }\n\n if (\n hasFlag(\"color\") ||\n hasFlag(\"colors\") ||\n hasFlag(\"color=true\") ||\n hasFlag(\"color=always\")\n ) {\n forceColor = 1;\n }\n }\n\n const level = Boolean(env.TF_BUILD) || Boolean(env.AGENT_NAME)\n ? 1\n : stream &&\n !(isTTY || (stream && stream.isTTY)) &&\n forceColor === undefined\n ? 0\n : env.TERM === \"dumb\"\n ? forceColor || 0\n : isWindows\n ? Number(os.release().split(\".\")[0]) >= 10 &&\n Number(os.release().split(\".\")[2]) >= 10_586\n ? Number(os.release().split(\".\")[2]) >= 14_931\n ? 3\n : 2\n : 1\n : isCI\n ? Boolean(env.GITHUB_ACTIONS) ||\n Boolean(env.GITEA_ACTIONS) ||\n Boolean(env.CIRCLECI)\n ? 3\n : Boolean(env.TRAVIS) ||\n Boolean(env.APPVEYOR) ||\n Boolean(env.GITLAB_CI) ||\n Boolean(env.BUILDKITE) ||\n Boolean(env.DRONE) ||\n env.CI_NAME === \"codeship\"\n ? 1\n : forceColor || 0\n : Boolean(env.TEAMCITY_VERSION)\n ? /^(?:9\\.0*[1-9]\\d*\\.|\\d{2,}\\.)/.test(String(env.TEAMCITY_VERSION) || \"\")\n ? 1\n : 0\n : String(env.COLORTERM) === \"truecolor\" ||\n env.TERM === \"xterm-kitty\"\n ? 3\n : Boolean(env.TERM_PROGRAM)\n ? env.TERM_PROGRAM === \"iTerm.app\"\n ? Number.parseInt(\n (env.TERM_PROGRAM_VERSION || \"\").split(\".\")[0] as string,\n 10\n ) >= 3\n ? 3\n : 2\n : env.TERM_PROGRAM === \"Apple_Terminal\"\n ? 2\n : 0\n : /-256(?:color)?$/i.test(env.TERM || \"\")\n ? 2\n : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(\n env.TERM || \"\"\n )\n ? 1\n : Boolean(env.COLORTERM);\n\n return typeof level === \"boolean\" || level === 0\n ? false\n : {\n level,\n hasBasic: true,\n has256: level >= 2,\n has16m: level >= 3,\n };\n\n `}\n </FunctionDeclaration>\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"colorSupportLevels\"\n doc=\"Detect the terminal color support level in the current environment\"\n initializer={code` {\n stdout: getColorSupportLevel(process.stdout),\n stderr: getColorSupportLevel(process.stderr),\n }; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isColorSupported\"\n doc=\"Detect if terminal color is supported in the current environment\"\n initializer={code` Boolean(colorSupportLevels.stdout); `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"isUnicodeSupported\"\n doc=\"Detect if Unicode characters are supported in the current environment\"\n initializer={code` !isWindows\n ? env.TERM !== \"linux\"\n : Boolean(env.WT_SESSION) ||\n Boolean(env.TERMINUS_SUBLIME) ||\n env.ConEmuTask === \"{cmd::Cmder}\" ||\n env.TERM_PROGRAM === \"Terminus-Sublime\" ||\n env.TERM_PROGRAM === \"vscode\" ||\n env.TERM === \"xterm-256color\" ||\n env.TERM === \"alacritty\" ||\n env.TERM === \"rxvt-unicode\" ||\n env.TERM === \"rxvt-unicode-256color\" ||\n env.TERMINAL_EMULATOR === \"JetBrains-JediTerm\"; `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\n\nexport function HyperlinkSupportUtilities() {\n return (\n <>\n <FunctionDeclaration\n name=\"parseVersion\"\n parameters={[{ name: \"version\", type: \"string\", default: '\"\"' }]}>\n {code`if (/^\\d{3,4}$/.test(version)) {\n const match = /(\\d{1,2})(\\d{2})/.exec(version) ?? [];\n\n return {\n major: 0,\n minor: Number.parseInt(match[1]!, 10),\n patch: Number.parseInt(match[2]!, 10)\n };\n }\n\n const versionParts = (version ?? \"\")\n .split(\".\")\n .map(n => Number.parseInt(n, 10));\n\n return {\n major: versionParts[0],\n minor: versionParts[1],\n patch: versionParts[2]\n }; `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Check if the current environment/terminal supports hyperlinks in the terminal.\">\n <TSDocReturns>\n {\"True if the current environment/terminal supports hyperlinks.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"isHyperlinkSupported\"\n returnType=\"boolean\">\n {code`if (Boolean(env.FORCE_HYPERLINK)) {\n return true;\n }\n\n if (Boolean(env.NETLIFY)) {\n return true;\n } else if (isColorSupported || isTTY) {\n return false;\n } else if (Boolean(env.WT_SESSION)) {\n return true;\n } else if (isWindows || isMinimal || Boolean(env.TEAMCITY_VERSION)) {\n return false;\n } else if (Boolean(env.TERM_PROGRAM)) {\n const version = parseVersion(env.TERM_PROGRAM_VERSION);\n\n switch (String(env.TERM_PROGRAM)) {\n case \"iTerm.app\": {\n if (version.major === 3) {\n return version.minor !== undefined && version.minor >= 1;\n }\n\n return version.major !== undefined && version.major > 3;\n }\n case \"WezTerm\": {\n return version.major !== undefined && version.major >= 20_200_620;\n }\n\n case \"vscode\": {\n if (Boolean(env.CURSOR_TRACE_ID)) {\n return true;\n }\n\n return (\n version.minor !== undefined &&\n version.major !== undefined &&\n (version.major > 1 || (version.major === 1 && version.minor >= 72))\n );\n }\n\n case \"ghostty\": {\n return true;\n }\n }\n }\n\n if (Boolean(env.VTE_VERSION)) {\n if (env.VTE_VERSION === \"0.50.0\") {\n return false;\n }\n\n const version = parseVersion(env.VTE_VERSION);\n return (\n (version.major !== undefined && version.major > 0) ||\n (version.minor !== undefined && version.minor >= 50)\n );\n }\n\n if (String(env.TERM) === \"alacritty\") {\n return true;\n }\n\n return false; `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ArgsUtilities() {\n return (\n <>\n <TSDoc heading=\"Retrieves the command-line arguments from Deno or Node.js environments.\">\n <TSDocRemarks>\n {\n \"This function is only intended for internal use. Please use `useArgs()` instead.\"\n }\n </TSDocRemarks>\n <hbr />\n <hbr />\n <TSDocInternal />\n <hbr />\n <hbr />\n <TSDocReturns>\n {\n \"An array of command-line arguments from Deno or Node.js environments.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"getArgs\" returnType=\"string[]\">\n {code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Checks if a specific flag is present in the command-line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {\n 'The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\".'\n }\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command-line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"hasFlag\"\n parameters={[\n { name: \"flag\", type: \"string | string[]\" },\n {\n name: \"argv\",\n type: \"string[]\",\n default: \"useArgs()\"\n }\n ]}>\n <VarDeclaration\n const\n name=\"position\"\n type=\"number\"\n initializer={code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {\n const pos = argv.findIndex(arg => (f.startsWith(\"-\") ? \"\" : (f.length === 1 ? \"-\" : \"--\") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? \"-\" : \"--\") + f + \"=\"));\n return pos !== -1 ? pos : ret;\n }, -1);`}\n />\n <hbr />\n {code`return position !== -1 && argv.indexOf(\"--\") === -1 || position < argv.indexOf(\"--\");`}\n </FunctionDeclaration>\n <Spacing />\n <VarDeclaration\n export\n name=\"isHelp\"\n type=\"boolean\"\n initializer={code` !isCI && hasFlag([\"help\", \"h\", \"?\"]); `}\n />\n </>\n );\n}\n\n/**\n * Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.\n */\nexport function SpawnFunctionDeclaration() {\n return (\n <>\n <FunctionDeclaration\n async\n name=\"resolveCommand\"\n parameters={[\n {\n name: \"command\",\n type: \"string\"\n },\n {\n name: \"options\",\n type: \"Record<string, any>\",\n default: \"{}\"\n },\n {\n name: \"pathExt\",\n type: \"string\",\n default:\n 'process.env.PATHEXT || [\".EXE\", \".CMD\", \".BAT\", \".COM\"].join(delimiter)'\n }\n ]}>\n {code`const env = options.env || process.env;\n const cwd = process.cwd();\n if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {\n try {\n process.chdir(options.cwd);\n } catch (err) {\n // Do nothing\n }\n }\n\n let resolved;\n try {\n let extensions = [\"\"];\n if (isWindows) {\n extensions = pathExt.split(delimiter).flatMap((item) => [item, item.toLowerCase()]);\n if (command.includes(\".\") && extensions[0] !== \"\") {\n extensions.unshift(\"\");\n }\n }\n\n for (const envPart of (command.match(new RegExp(\\`[\\${posix.sep}\\${sep === posix.sep ? \"\" : sep}]\\`.replace(/(\\\\\\\\)/g, \"\\\\\\\\$1\"))))\n ? [...(isWindows ? [process.cwd()] : []), ...(process.env.PATH || \"\").split(delimiter)]\n : [\"\"]\n ) {\n const part = \\`\\${!(/^\".*\"$/.test(envPart) ? envPart.slice(1, -1) : envPart) && new RegExp(\\`^\\\\.\\${new RegExp(\\`[\\${posix.sep}\\${sep === posix.sep ? \"\" : sep}]\\`.replace(/(\\\\\\\\)/g, \"\\\\\\\\$1\")).source}\\`).test(command) ? command.slice(0, 2) : \"\"}\\${join(/^\".*\"$/.test(envPart) ? envPart.slice(1, -1) : envPart, command)}\\`;\n for (const extension of extensions) {\n if (isWindows) {\n const filePath = part + extension;\n if ((await stat(filePath)).isFile() && extensions.some((ext) => filePath.substring(filePath.length - ext.length).toLowerCase() === ext.toLowerCase())) {\n resolved = filePath;\n break;\n }\n } else {\n const file = await stat(part + extension);\n if (file.isFile() && (file.mode & 0o111) !== 0) {\n resolved = part + extension;\n break;\n }\n }\n }\n }\n } catch (err) {\n // Do nothing\n } finally {\n if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {\n process.chdir(cwd);\n }\n }\n\n\n if (resolved) {\n resolved = resolve(\n options.cwd ? options.cwd : \"\",\n resolved\n );\n }\n\n return resolved; `}\n </FunctionDeclaration>\n <Spacing />\n <InterfaceDeclaration\n name=\"SpawnBaseOptions\"\n doc=\"Options for the `spawn` handler function.\">\n <InterfaceMember\n name=\"stdout\"\n optional\n type=\"(data: string) => void\"\n doc=\"The writable stream to use for prompt output, defaults to process.stdout\"\n />\n <hbr />\n <InterfaceMember\n name=\"stderr\"\n optional\n type=\"(data: string) => void\"\n doc=\"The writable stream to use for prompt error output, defaults to process.stderr\"\n />\n <hbr />\n <InterfaceMember\n name=\"rejectOnError\"\n optional\n type=\"boolean\"\n doc=\"Whether to reject the promise on error. Defaults to false.\"\n />\n <hbr />\n <InterfaceMember\n name=\"file\"\n optional\n type=\"string\"\n doc=\"The file to execute.\"\n />\n <hbr />\n <InterfaceMember\n name=\"shell\"\n optional\n type=\"boolean | string\"\n doc=\"If true, runs command inside of a shell. Uses '/bin/sh' on UNIX, and process.env.ComSpec on Windows. If a string is provided, it specifies the shell to use.\"\n />\n <hbr />\n <InterfaceMember\n name=\"forceShell\"\n optional\n type=\"boolean\"\n doc=\"If true, forces the command to run inside of a shell, even if the command is a file.\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <TypeDeclaration export name=\"SpawnOptions\">\n {code`SpawnBaseOptions & Parameters<typeof _spawn>[1]`}\n </TypeDeclaration>\n <Spacing />\n <TSDoc heading=\"A function to spawn child processes with proper color support and environment variable handling.\">\n <TSDocParam name=\"command\">{`The command to execute.`}</TSDocParam>\n <TSDocParam name=\"args\">\n {`The command-line arguments to pass to the command. Defaults to an empty array.`}\n </TSDocParam>\n <TSDocParam name=\"options\">\n {`Additional options for spawning the process, such as the current working directory (\\`cwd\\`).`}\n </TSDocParam>\n <TSDocReturns>{`The result of the spawned process.`}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"spawn\"\n parameters={[\n { name: \"command\", type: \"string\" },\n {\n name: \"args\",\n type: \"string[] | SpawnOptions\",\n default: \"{} as SpawnOptions\"\n },\n {\n name: \"options\",\n type: \"SpawnOptions\",\n default: \"{} as SpawnOptions\"\n }\n ]}>\n {code`const normalized = {\n command,\n args: [] as string[],\n options: options as SpawnOptions | any,\n file: undefined as string | undefined,\n original: {\n command,\n args,\n },\n };\n\n if (args) {\n if (Array.isArray(args)) {\n if (args.length > 0) {\n normalized.args = args.slice(0);\n }\n } else {\n normalized.options = { ...args } as SpawnOptions | any;\n normalized.args = [];\n }\n }\n\n if (!normalized.options.shell && isWindows) {\n normalized.file = (await resolveCommand(normalized.command, normalized.options)) || (await resolveCommand(normalized.command, normalized.options, delimiter));\n\n let commandFile = normalized.file;\n if (normalized.file) {\n let shebang: string | undefined;\n const buffer = Buffer.alloc(150);\n\n try {\n const fd = openSync(normalized.file, \"r\");\n await promisify(read)(fd, buffer, 0, 150, 0);\n closeSync(fd);\n } catch (err) {\n // Do nothing\n }\n\n const matched = buffer.toString().match(/^#!(.*)/);\n if (matched) {\n const [path, argument] = matched[0].replace(/#! ?/, \"\").split(\" \");\n\t const binary = path.split(\"/\").pop();\n if (binary === \"env\") {\n shebang = argument;\n } else {\n shebang = argument ? \\`\\${binary} \\${argument}\\` : binary;\n }\n }\n\n if (shebang) {\n normalized.args.unshift(normalized.file);\n normalized.command = shebang;\n\n commandFile = await resolveCommand(normalized.command, normalized.options);\n }\n }\n\n if (commandFile && (normalized.options.forceShell || /\\\\.(?:com|exe)$/i.test(commandFile))) {\n normalized.command = normalize(normalized.command).replace(/([()\\\\][%!^\"\\`<>&|;, *?])/g, \"^$1\");\n\n normalized.args = [\"/d\", \"/s\", \"/c\", \\`\"\\${normalized.command} \\${normalized.args.map(arg =>\n \\`\\${arg}\\`.replace(/(?=(\\\\\\\\+?)?)\\\\1\"/g, \"$1$1\\\\\"\").replace(/(?=(\\\\\\\\+?)?)\\\\1$/, \"$1$1\")\n ).map(arg =>\n \\`\"\\${arg}\"\\`.replace(/([()\\\\][%!^\"\\`<>&|;, *?])/g, \"^$1\")\n ).map(arg =>\n /node_modules[\\\\\\\\/].bin[\\\\\\\\/][^\\\\\\\\/]+\\\\.cmd$/i.test(commandFile) ? arg.replace(/([()\\\\][%!^\"\\`<>&|;, *?])/g, \"^$1\") : arg\n ).join(\" \")}\"\\`];\n normalized.command = process.env.comspec || \"cmd.exe\";\n normalized.options.windowsVerbatimArguments = true;\n }\n }\n\n let stdout = \"\";\n let stderr = \"\";\n\n const child = _spawn(normalized.command, normalized.args, {\n cwd: process.cwd(),\n env: {\n ...process.env,\n FORCE_COLOR: isColorSupported ? \"1\" : \"0\",\n },\n ...normalized.options,\n }) as ReturnType<typeof _spawn>;\n\n if (isWindows) {\n const emit = child.emit;\n child.emit = (eventName: string | symbol, ...eventArgs: any[]) => {\n if (eventName === \"exit\") {\n let err: Error | null = null;\n if (eventArgs[0] === 1 && !normalized.file) {\n err = Object.assign(new Error(\\`spawn \\${normalized.original.command} ENOENT\\`), {\n code: \"ENOENT\",\n errno: \"ENOENT\",\n syscall: \\`spawn \\${normalized.original.command}\\`,\n path: normalized.original.command,\n spawnargs: normalized.original.args,\n });\n }\n\n if (err) {\n return emit.call(child, \"error\", err);\n }\n }\n\n return emit.apply(child, [eventName, ...eventArgs]);\n };\n }\n\n return new Promise((resolve, reject) => {\n if (normalized.options.stdin !== undefined) {\n child.stdin?.write(normalized.options.stdin);\n }\n\n child.stdin?.end();\n\n child.stdout?.on(\"data\", data => {\n stdout += data;\n if (normalized.options.stdout) {\n normalized.options.stdout(data);\n }\n });\n\n child.stderr?.on(\"data\", data => {\n stderr += data;\n if (normalized.options.stderr) {\n normalized.options.stderr(data);\n }\n });\n\n if (normalized.options.rejectOnError) {\n child.addListener(\"error\", reject);\n }\n\n child.on(\"close\", code => {\n if (code !== 0 && normalized.options.rejectOnError) {\n reject(stderr);\n } else {\n resolve({ stdout, stderr });\n }\n });\n }); `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport function ContextUtilities() {\n return code`\n /**\n * The global Shell Shock - Application context instance.\n *\n * @internal\n */\n export let internal_appContext = new AsyncLocalStorage<Map<string, any>>();\n\n /**\n * Get the Shell Shock - Application context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Application context for the current application or undefined if the context is not available.\n */\n export function useApp(): Map<string, any> | undefined {\n return internal_appContext.getStore();\n }\n\n /**\n * A utility hook function to get the command line arguments from the application context.\n *\n * @returns An array of command-line arguments from the application context.\n * @throws If the application context is not available.\n */\n export function useArgs(): string[] {\n return useApp()?.get(\"args\") ?? getArgs();\n }\n\n /**\n * The context object for the current command execution, containing the command path and segments.\n */\n export interface CommandContext {\n path: string;\n segments: string[];\n }\n\n /**\n * The global Shell Shock - Command context instance.\n *\n * @internal\n */\n export let internal_commandContext = new AsyncLocalStorage<CommandContext>();\n\n /**\n * Get the Shell Shock - Command context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Command context for the current application.\n * @throws If the Shell Shock - Command context is not available.\n */\n export function useCommand(): CommandContext {\n const result = internal_commandContext.getStore();\n if (!result) {\n throw new Error(\n \\`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\\`\n );\n }\n return result;\n }\n\n /**\n * A utility hook function to get the individual segments of the current command path.\n *\n * @returns An array of command path segments.\n * @throws If the command context is not available.\n */\n export function useSegments(): string[] {\n return useCommand().segments;\n }\n\n /**\n * A utility hook function to get the full command path as a string.\n *\n * @returns The full command path as a string.\n * @throws If the command context is not available.\n */\n export function usePath(): string {\n return useCommand().path;\n }\n `;\n}\n\n/**\n * A built-in utilities module for Shell Shock.\n */\nexport function UtilsBuiltin(props: UtilsBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"utils\"\n description=\"A collection of helper utilities that ease command-line application development.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:os\": \"os\",\n \"node:process\": \"process\",\n \"node:path\": [\n \"resolve\",\n \"delimiter\",\n \"normalize\",\n \"join\",\n \"posix\",\n \"sep\"\n ],\n \"node:fs\": [\"openSync\", \"closeSync\", \"read\"],\n \"node:fs/promises\": [\"stat\"],\n \"node:util\": [\"promisify\"],\n \"node:child_process\": [{ name: \"spawn\", alias: \"_spawn\" }],\n \"node:async_hooks\": [\"AsyncLocalStorage\"]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"writeLine\"],\n env: [\"env\", \"isCI\", \"isTest\", \"isWindows\", \"isDevelopment\", \"isDebug\"]\n })}>\n <Spacing />\n <ContextUtilities />\n <Spacing />\n <ArgsUtilities />\n <Spacing />\n <EnvSupportUtilities />\n <Spacing />\n <HyperlinkSupportUtilities />\n <Spacing />\n <ColorSupportUtilities />\n <Spacing />\n <SpawnFunctionDeclaration />\n <Spacing />\n <FindSuggestionsDeclaration />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAiDA,SAAgBkB,6BAA6B;CAC3C,MAAMC,UAAUV,eAAwB;AAExC,QAAA;EAAAW,gBAEKb,gBAAc;GAAA,SAAA;GAEbc,MAAI;GACJC,aAAatB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDa,CAAA;EAAAoB,gBAE/BZ,SAAO,EAAA,CAAA;EAAAY,gBACPT,OAAK;GAACY,SAAO;GAAA,IAAAC,WAAA;AAAA,WAAA;KAAAJ,gBACXL,cAAY,EAAAS,UAET,+GAA6G,CAAA;KAAAC,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAL,gBAKhHR,eAAa,EAAA,CAAA;KAAAa,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAL,gBAGbN,YAAU;MAACO,MAAI;MAAAG,UACb;MAAkD,CAAA;KAAAJ,gBAEpDN,YAAU;MAACO,MAAI;MAAAG,UACb;MAA0D,CAAA;KAAAJ,gBAE5DJ,cAAY,EAAAQ,UACV,kEAAgE,CAAA;KAAA;;GAAA,CAAA;EAAAJ,gBAGpEjB,qBAAmB;GAAA,UAAA;GAElBkB,MAAI;GACJK,YAAY,CACV;IACEL,MAAM;IACNM,MAAM;IACP,EACD;IACEN,MAAM;IACNM,MAAM;IACP,CACF;GACDC,YAAU;GAAA,IAAAJ,WAAA;AAAA,WAAA;KAAAJ,gBACTb,gBAAc;MAAA,SAAA;MAEbc,MAAI;MAAA,IACJC,cAAW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AAE,gBAC1BZ,SAAO,EAAA,CAAA;IAAAY,gBACPnB,MAAI;KAAA,IAACoD,OAAI;AAAA,aAAEC,QAAQ9B,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
@@ -9,7 +9,7 @@ let __stryke_path_join = require("@stryke/path/join");
|
|
|
9
9
|
* @returns The output path for the generated documentation.
|
|
10
10
|
*/
|
|
11
11
|
function getDocsOutputPath(context) {
|
|
12
|
-
return (0, __stryke_path_join.joinPaths)(context.config.
|
|
12
|
+
return (0, __stryke_path_join.joinPaths)(context.config.root, "docs", "generated");
|
|
13
13
|
}
|
|
14
14
|
getDocsOutputPath.__type = [
|
|
15
15
|
"Context",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-helpers.cjs","names":[],"sources":["../../src/helpers/docs-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 { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.
|
|
1
|
+
{"version":3,"file":"docs-helpers.cjs","names":[],"sources":["../../src/helpers/docs-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 { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.root, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,kBAAkB,SAAS;AACvC,0CAAiB,QAAQ,OAAO,MAAM,QAAQ,YAAS;;AAE3D,kBAAkB,SAAS;CAAC;CAAW;CAAW;CAAU;CAAA"}
|
|
@@ -8,7 +8,7 @@ import { joinPaths } from "@stryke/path/join";
|
|
|
8
8
|
* @returns The output path for the generated documentation.
|
|
9
9
|
*/
|
|
10
10
|
function getDocsOutputPath(context) {
|
|
11
|
-
return joinPaths(context.config.
|
|
11
|
+
return joinPaths(context.config.root, "docs", "generated");
|
|
12
12
|
}
|
|
13
13
|
getDocsOutputPath.__type = [
|
|
14
14
|
"Context",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-helpers.mjs","names":[],"sources":["../../src/helpers/docs-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 { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.
|
|
1
|
+
{"version":3,"file":"docs-helpers.mjs","names":[],"sources":["../../src/helpers/docs-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 { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.root, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,kBAAkB,SAAS;AACvC,QAAO,UAAU,QAAQ,OAAO,MAAM,QAAQ,YAAS;;AAE3D,kBAAkB,SAAS;CAAC;CAAW;CAAW;CAAU;CAAA"}
|
|
@@ -4,17 +4,20 @@ const require_utilities = require('./utilities.cjs');
|
|
|
4
4
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
5
5
|
let __stryke_path_append = require("@stryke/path/append");
|
|
6
6
|
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
7
8
|
let __stryke_path_replace = require("@stryke/path/replace");
|
|
8
9
|
let __stryke_path_resolve_parent_path = require("@stryke/path/resolve-parent-path");
|
|
9
10
|
let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
10
11
|
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
11
12
|
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
13
|
+
let powerlines_utils = require("powerlines/utils");
|
|
12
14
|
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
13
15
|
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
14
16
|
let __powerlines_deepkit_esbuild_plugin = require("@powerlines/deepkit/esbuild-plugin");
|
|
17
|
+
let __powerlines_plugin_esbuild_helpers_resolve = require("@powerlines/plugin-esbuild/helpers/resolve");
|
|
15
18
|
let __stryke_path_common = require("@stryke/path/common");
|
|
16
19
|
let __stryke_path_normalize = require("@stryke/path/normalize");
|
|
17
|
-
let
|
|
20
|
+
let node_fs = require("node:fs");
|
|
18
21
|
|
|
19
22
|
//#region src/helpers/resolve-command.ts
|
|
20
23
|
function __assignType(fn, args) {
|
|
@@ -138,14 +141,31 @@ resolveCommandDynamicPathSegments.__type = [
|
|
|
138
141
|
"P\"w!2\"&2#&F/$"
|
|
139
142
|
];
|
|
140
143
|
function findCommandsRoot(context) {
|
|
141
|
-
if ((0, __stryke_type_checks_is_set_string.isSetString)(context.config.
|
|
142
|
-
else if ((0,
|
|
143
|
-
else if (Array.isArray(context.config.
|
|
144
|
-
"
|
|
144
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(context.config.input)) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.input), context.config.root), context.workspaceConfig.workspaceRoot);
|
|
145
|
+
else if ((0, powerlines_utils.isTypeDefinition)(context.config.input)) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.input.file), context.config.root), context.workspaceConfig.workspaceRoot);
|
|
146
|
+
else if (Array.isArray(context.config.input) && context.config.input.length > 0) return (0, __stryke_path_common.commonPath)(context.config.input.map(__assignType((input) => (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(input) ? input : input.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
147
|
+
"input",
|
|
145
148
|
"",
|
|
146
149
|
"P\"2!\"/\""
|
|
147
150
|
])));
|
|
148
|
-
return (0,
|
|
151
|
+
else if ((0, __stryke_type_checks_is_set_object.isSetObject)(context.config.input)) return (0, __stryke_path_common.commonPath)(Object.values(context.config.input).map(__assignType((input) => Array.isArray(input) ? (0, __stryke_path_common.commonPath)(input.map(__assignType((i) => (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(i) ? i : i.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
152
|
+
"i",
|
|
153
|
+
"",
|
|
154
|
+
"P\"2!\"/\""
|
|
155
|
+
]))) : (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(input) ? input : input.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
156
|
+
"input",
|
|
157
|
+
"",
|
|
158
|
+
"P\"2!\"/\""
|
|
159
|
+
])));
|
|
160
|
+
let commandsPath = (0, __stryke_path_join_paths.joinPaths)(context.config.root, "src/commands");
|
|
161
|
+
if (!(0, node_fs.existsSync)(commandsPath)) {
|
|
162
|
+
commandsPath = (0, __stryke_path_join_paths.joinPaths)(context.config.root, "commands");
|
|
163
|
+
if (!(0, node_fs.existsSync)(commandsPath)) {
|
|
164
|
+
commandsPath = (0, __stryke_path_join_paths.joinPaths)(context.config.root, "src");
|
|
165
|
+
if (!(0, node_fs.existsSync)(commandsPath)) commandsPath = context.config.root;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return (0, __stryke_path_append.appendPath)(commandsPath, context.workspaceConfig.workspaceRoot);
|
|
149
169
|
}
|
|
150
170
|
findCommandsRoot.__type = [
|
|
151
171
|
"Context",
|
|
@@ -251,7 +271,7 @@ async function reflectCommandTree(context, command, parent) {
|
|
|
251
271
|
if (!command.isVirtual) {
|
|
252
272
|
if (!command.entry.input?.file || !context.fs.existsSync(command.entry.input.file)) throw new Error(`${!command.entry.input?.file ? "Missing" : "Non-existent"} command entry file for "${command.name}"`);
|
|
253
273
|
context.debug(`Adding reflection for user-defined command: ${command.id} (file: ${command.entry.input.file})`);
|
|
254
|
-
const resolved = await (
|
|
274
|
+
const resolved = await (__powerlines_plugin_esbuild_helpers_resolve.resolveModule.Ω = [["CommandModule", "\"w!"]], (0, __powerlines_plugin_esbuild_helpers_resolve.resolveModule)(context, command.entry.input, { plugins: [(0, __powerlines_deepkit_esbuild_plugin.esbuildPlugin)(context, {
|
|
255
275
|
reflection: "default",
|
|
256
276
|
reflectionLevel: "verbose"
|
|
257
277
|
})] }));
|