@shell-shock/core 0.1.1 → 0.2.1
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/README.md +221 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/api.cjs +45 -1
- package/dist/api.d.cts +7 -0
- package/dist/api.d.mts +7 -0
- package/dist/api.mjs +44 -1
- package/dist/components/index.cjs +7 -0
- package/dist/components/index.d.cts +2 -0
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.mjs +3 -0
- package/dist/components/utils-builtin.cjs +453 -0
- package/dist/components/utils-builtin.d.cts +27 -0
- package/dist/components/utils-builtin.d.mts +27 -0
- package/dist/components/utils-builtin.mjs +447 -0
- package/dist/config.cjs +17 -1
- package/dist/config.mjs +16 -1
- package/dist/helpers/persistence.cjs +49 -0
- package/dist/helpers/persistence.mjs +46 -0
- package/dist/helpers/resolve-command.cjs +92 -1
- package/dist/helpers/resolve-command.mjs +88 -1
- package/dist/helpers/update-package-json.cjs +28 -1
- package/dist/helpers/update-package-json.mjs +27 -1
- package/dist/helpers/utilities.cjs +41 -0
- package/dist/helpers/utilities.mjs +38 -0
- package/dist/index.cjs +24 -1
- package/dist/index.d.cts +16 -2
- package/dist/index.d.mts +15 -2
- package/dist/index.mjs +19 -1
- package/dist/plugin-utils/get-command-tree.cjs +22 -0
- package/dist/plugin-utils/get-command-tree.d.cts +15 -0
- package/dist/plugin-utils/get-command-tree.d.mts +15 -0
- package/dist/plugin-utils/get-command-tree.mjs +21 -0
- package/dist/plugin-utils/index.cjs +3 -0
- package/dist/plugin-utils/index.d.cts +2 -0
- package/dist/plugin-utils/index.d.mts +2 -0
- package/dist/plugin-utils/index.mjs +3 -0
- package/dist/powerlines.cjs +172 -2
- package/dist/powerlines.d.cts +2 -2
- package/dist/powerlines.d.mts +2 -2
- package/dist/powerlines.mjs +168 -2
- package/dist/types/command.d.cts +63 -0
- package/dist/types/command.d.mts +63 -0
- package/dist/types/command.mjs +1 -0
- package/dist/types/config.d.cts +9 -26
- package/dist/types/config.d.mts +9 -26
- package/dist/types/config.mjs +1 -1
- package/dist/types/context.cjs +0 -0
- package/dist/types/context.d.cts +26 -0
- package/dist/types/context.d.mts +26 -0
- package/dist/types/context.mjs +1 -0
- package/dist/types/index.d.cts +4 -2
- package/dist/types/index.d.mts +4 -2
- package/dist/types/index.mjs +1 -1
- package/dist/types/options.cjs +0 -0
- package/dist/types/options.d.cts +7 -0
- package/dist/types/options.d.mts +7 -0
- package/dist/types/options.mjs +1 -0
- package/package.json +76 -13
- package/dist/types/build.d.cts +0 -66
- package/dist/types/build.d.mts +0 -66
- package/dist/types/build.mjs +0 -1
- /package/dist/types/{build.cjs → command.cjs} +0 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let defu = require("defu");
|
|
3
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
4
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
6
|
+
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
7
|
+
let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
8
|
+
let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
9
|
+
|
|
10
|
+
//#region src/components/utils-builtin.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Generates utilities for detecting terminal color support.
|
|
13
|
+
*/
|
|
14
|
+
function EnvSupportUtilities() {
|
|
15
|
+
return [
|
|
16
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
17
|
+
"export": true,
|
|
18
|
+
"const": true,
|
|
19
|
+
name: "isTTY",
|
|
20
|
+
doc: "Detect if stdout.TTY is available",
|
|
21
|
+
initializer: __alloy_js_core.code`Boolean(process.stdout && process.stdout.isTTY);`
|
|
22
|
+
}),
|
|
23
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
24
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
25
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
26
|
+
"export": true,
|
|
27
|
+
"const": true,
|
|
28
|
+
name: "isMinimal",
|
|
29
|
+
doc: "Detect if the current environment is minimal (CI, non-TTY, etc.)",
|
|
30
|
+
initializer: __alloy_js_core.code` env.MINIMAL || isCI || isTest || !isTTY; `
|
|
31
|
+
}),
|
|
32
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
33
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
34
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
35
|
+
"export": true,
|
|
36
|
+
"const": true,
|
|
37
|
+
name: "isInteractive",
|
|
38
|
+
doc: "Detect if the current environment is interactive",
|
|
39
|
+
initializer: __alloy_js_core.code` !isMinimal && process.stdin?.isTTY && env.TERM !== "dumb"; `
|
|
40
|
+
})
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generates utilities for detecting terminal color support.
|
|
45
|
+
*/
|
|
46
|
+
function ColorSupportUtilities() {
|
|
47
|
+
return [
|
|
48
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
49
|
+
"export": true,
|
|
50
|
+
name: "GetColorSupportLevelOptions",
|
|
51
|
+
doc: "Options for the getColorSupportLevel function",
|
|
52
|
+
get children() {
|
|
53
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
54
|
+
name: "ignoreFlags",
|
|
55
|
+
type: "boolean",
|
|
56
|
+
doc: "Indicates if the function should skip checking command-line flags for color support"
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
61
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
62
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
63
|
+
heading: "Checks if a specific flag is present in the command line arguments.",
|
|
64
|
+
get children() {
|
|
65
|
+
return [
|
|
66
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
|
|
67
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
68
|
+
name: "flag",
|
|
69
|
+
children: "The flag to check for, e.g., \"color\", \"no-color\"."
|
|
70
|
+
}),
|
|
71
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
72
|
+
name: "argv",
|
|
73
|
+
children: "The command line arguments to check against. Defaults to global Deno args or process args."
|
|
74
|
+
}),
|
|
75
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "True if the flag is present, false otherwise." })
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
80
|
+
"export": true,
|
|
81
|
+
name: "getColorSupportLevel",
|
|
82
|
+
parameters: [{
|
|
83
|
+
name: "stream",
|
|
84
|
+
type: "NodeJS.WriteStream & { fd: 1 | 2; }"
|
|
85
|
+
}, {
|
|
86
|
+
name: "options",
|
|
87
|
+
type: "GetColorSupportLevelOptions",
|
|
88
|
+
default: "{}"
|
|
89
|
+
}],
|
|
90
|
+
children: __alloy_js_core.code`const { ignoreFlags = false } = options;
|
|
91
|
+
|
|
92
|
+
let forceColor: number | undefined;
|
|
93
|
+
if (env.FORCE_COLOR !== undefined) {
|
|
94
|
+
forceColor = !env.FORCE_COLOR
|
|
95
|
+
? 0
|
|
96
|
+
: typeof env.FORCE_COLOR === "boolean"
|
|
97
|
+
? 1
|
|
98
|
+
: typeof env.FORCE_COLOR === "number" &&
|
|
99
|
+
[0, 1, 2, 3].includes(Math.min(env.FORCE_COLOR as number, 3))
|
|
100
|
+
? Math.min(env.FORCE_COLOR as number, 3)
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (ignoreFlags !== true && forceColor === undefined) {
|
|
105
|
+
forceColor = hasFlag("no-color") ||
|
|
106
|
+
hasFlag("no-colors") ||
|
|
107
|
+
hasFlag("color=false") ||
|
|
108
|
+
hasFlag("color=never")
|
|
109
|
+
? 0
|
|
110
|
+
: hasFlag("color") ||
|
|
111
|
+
hasFlag("colors") ||
|
|
112
|
+
hasFlag("color=true") ||
|
|
113
|
+
hasFlag("color=always")
|
|
114
|
+
? 1
|
|
115
|
+
: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (forceColor === 0) {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (ignoreFlags !== true) {
|
|
123
|
+
if (hasFlag("color=16m") ||
|
|
124
|
+
hasFlag("color=full") ||
|
|
125
|
+
hasFlag("color=truecolor")) {
|
|
126
|
+
return 3;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (hasFlag("color=256")) {
|
|
130
|
+
return 2;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const level = Boolean(env.TF_BUILD) || Boolean(env.AGENT_NAME)
|
|
135
|
+
? 1
|
|
136
|
+
: stream &&
|
|
137
|
+
!(isTTY || (stream && stream.isTTY)) &&
|
|
138
|
+
forceColor === undefined
|
|
139
|
+
? 0
|
|
140
|
+
: env.TERM === "dumb"
|
|
141
|
+
? forceColor || 0
|
|
142
|
+
: isWindows
|
|
143
|
+
? Number(os.release().split(".")[0]) >= 10 &&
|
|
144
|
+
Number(os.release().split(".")[2]) >= 10_586
|
|
145
|
+
? Number(os.release().split(".")[2]) >= 14_931
|
|
146
|
+
? 3
|
|
147
|
+
: 2
|
|
148
|
+
: 1
|
|
149
|
+
: isCI
|
|
150
|
+
? Boolean(env.GITHUB_ACTIONS) ||
|
|
151
|
+
Boolean(env.GITEA_ACTIONS) ||
|
|
152
|
+
Boolean(env.CIRCLECI)
|
|
153
|
+
? 3
|
|
154
|
+
: Boolean(env.TRAVIS) ||
|
|
155
|
+
Boolean(env.APPVEYOR) ||
|
|
156
|
+
Boolean(env.GITLAB_CI) ||
|
|
157
|
+
Boolean(env.BUILDKITE) ||
|
|
158
|
+
Boolean(env.DRONE) ||
|
|
159
|
+
env.CI_NAME === "codeship"
|
|
160
|
+
? 1
|
|
161
|
+
: forceColor || 0
|
|
162
|
+
: Boolean(env.TEAMCITY_VERSION)
|
|
163
|
+
? /^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(String(env.TEAMCITY_VERSION) || "")
|
|
164
|
+
? 1
|
|
165
|
+
: 0
|
|
166
|
+
: String(env.COLORTERM) === "truecolor" ||
|
|
167
|
+
env.TERM === "xterm-kitty"
|
|
168
|
+
? 3
|
|
169
|
+
: Boolean(env.TERM_PROGRAM)
|
|
170
|
+
? env.TERM_PROGRAM === "iTerm.app"
|
|
171
|
+
? Number.parseInt(
|
|
172
|
+
(env.TERM_PROGRAM_VERSION || "").split(".")[0] as string,
|
|
173
|
+
10
|
|
174
|
+
) >= 3
|
|
175
|
+
? 3
|
|
176
|
+
: 2
|
|
177
|
+
: env.TERM_PROGRAM === "Apple_Terminal"
|
|
178
|
+
? 2
|
|
179
|
+
: 0
|
|
180
|
+
: /-256(?:color)?$/i.test(env.TERM || "")
|
|
181
|
+
? 2
|
|
182
|
+
: /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
183
|
+
env.TERM || ""
|
|
184
|
+
)
|
|
185
|
+
? 1
|
|
186
|
+
: Boolean(env.COLORTERM);
|
|
187
|
+
|
|
188
|
+
return typeof level === "boolean" || level === 0
|
|
189
|
+
? false
|
|
190
|
+
: {
|
|
191
|
+
level,
|
|
192
|
+
hasBasic: true,
|
|
193
|
+
has256: level >= 2,
|
|
194
|
+
has16m: level >= 3,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
`
|
|
198
|
+
}),
|
|
199
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
200
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
201
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
202
|
+
"export": true,
|
|
203
|
+
"const": true,
|
|
204
|
+
name: "colorSupportLevels",
|
|
205
|
+
doc: "Detect the terminal color support level in the current environment",
|
|
206
|
+
initializer: __alloy_js_core.code` {
|
|
207
|
+
stdout: getColorSupportLevel(process.stdout),
|
|
208
|
+
stderr: getColorSupportLevel(process.stderr),
|
|
209
|
+
}; `
|
|
210
|
+
}),
|
|
211
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
212
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
213
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
214
|
+
"export": true,
|
|
215
|
+
"const": true,
|
|
216
|
+
name: "isColorSupported",
|
|
217
|
+
doc: "Detect if terminal color is supported in the current environment",
|
|
218
|
+
initializer: __alloy_js_core.code` Boolean(colorSupportLevels.stdout); `
|
|
219
|
+
}),
|
|
220
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
221
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
222
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
223
|
+
"export": true,
|
|
224
|
+
"const": true,
|
|
225
|
+
name: "isUnicodeSupported",
|
|
226
|
+
doc: "Detect if Unicode characters are supported in the current environment",
|
|
227
|
+
initializer: __alloy_js_core.code` !isWindows
|
|
228
|
+
? env.TERM !== "linux"
|
|
229
|
+
: Boolean(env.WT_SESSION) ||
|
|
230
|
+
Boolean(env.TERMINUS_SUBLIME) ||
|
|
231
|
+
env.ConEmuTask === "{cmd::Cmder}" ||
|
|
232
|
+
env.TERM_PROGRAM === "Terminus-Sublime" ||
|
|
233
|
+
env.TERM_PROGRAM === "vscode" ||
|
|
234
|
+
env.TERM === "xterm-256color" ||
|
|
235
|
+
env.TERM === "alacritty" ||
|
|
236
|
+
env.TERM === "rxvt-unicode" ||
|
|
237
|
+
env.TERM === "rxvt-unicode-256color" ||
|
|
238
|
+
env.TERMINAL_EMULATOR === "JetBrains-JediTerm"; `
|
|
239
|
+
})
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Generates utilities for detecting terminal color support.
|
|
244
|
+
*/
|
|
245
|
+
function HyperlinkSupportUtilities() {
|
|
246
|
+
return [
|
|
247
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
248
|
+
name: "parseVersion",
|
|
249
|
+
parameters: [{
|
|
250
|
+
name: "version",
|
|
251
|
+
type: "string",
|
|
252
|
+
default: "\"\""
|
|
253
|
+
}],
|
|
254
|
+
children: __alloy_js_core.code`if (/^\d{3,4}$/.test(version)) {
|
|
255
|
+
const match = /(\d{1,2})(\d{2})/.exec(version) ?? [];
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
major: 0,
|
|
259
|
+
minor: Number.parseInt(match[1]!, 10),
|
|
260
|
+
patch: Number.parseInt(match[2]!, 10)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const versionParts = (version ?? "")
|
|
265
|
+
.split(".")
|
|
266
|
+
.map(n => Number.parseInt(n, 10));
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
major: versionParts[0],
|
|
270
|
+
minor: versionParts[1],
|
|
271
|
+
patch: versionParts[2]
|
|
272
|
+
}; `
|
|
273
|
+
}),
|
|
274
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
275
|
+
heading: "Check if the current environment/terminal supports hyperlinks in the terminal.",
|
|
276
|
+
get children() {
|
|
277
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "True if the current environment/terminal supports hyperlinks." });
|
|
278
|
+
}
|
|
279
|
+
}),
|
|
280
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
281
|
+
"export": true,
|
|
282
|
+
name: "isHyperlinkSupported",
|
|
283
|
+
returnType: "boolean",
|
|
284
|
+
children: __alloy_js_core.code`if (Boolean(env.FORCE_HYPERLINK)) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (Boolean(env.NETLIFY)) {
|
|
289
|
+
return true;
|
|
290
|
+
} else if (isColorSupported || isTTY) {
|
|
291
|
+
return false;
|
|
292
|
+
} else if (Boolean(env.WT_SESSION)) {
|
|
293
|
+
return true;
|
|
294
|
+
} else if (isWindows || isMinimal || Boolean(env.TEAMCITY_VERSION)) {
|
|
295
|
+
return false;
|
|
296
|
+
} else if (Boolean(env.TERM_PROGRAM)) {
|
|
297
|
+
const version = parseVersion(env.TERM_PROGRAM_VERSION);
|
|
298
|
+
|
|
299
|
+
switch (String(env.TERM_PROGRAM)) {
|
|
300
|
+
case "iTerm.app": {
|
|
301
|
+
if (version.major === 3) {
|
|
302
|
+
return version.minor !== undefined && version.minor >= 1;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return version.major !== undefined && version.major > 3;
|
|
306
|
+
}
|
|
307
|
+
case "WezTerm": {
|
|
308
|
+
return version.major !== undefined && version.major >= 20_200_620;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
case "vscode": {
|
|
312
|
+
if (Boolean(env.CURSOR_TRACE_ID)) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
version.minor !== undefined &&
|
|
318
|
+
version.major !== undefined &&
|
|
319
|
+
(version.major > 1 || (version.major === 1 && version.minor >= 72))
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
case "ghostty": {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (Boolean(env.VTE_VERSION)) {
|
|
330
|
+
if (env.VTE_VERSION === "0.50.0") {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const version = parseVersion(env.VTE_VERSION);
|
|
335
|
+
return (
|
|
336
|
+
(version.major !== undefined && version.major > 0) ||
|
|
337
|
+
(version.minor !== undefined && version.minor >= 50)
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (String(env.TERM) === "alacritty") {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return false; `
|
|
346
|
+
})
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Generates utilities for detecting terminal color support.
|
|
351
|
+
*/
|
|
352
|
+
function ArgsUtilities() {
|
|
353
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
354
|
+
heading: "Checks if a specific flag is present in the command line arguments.",
|
|
355
|
+
get children() {
|
|
356
|
+
return [
|
|
357
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
|
|
358
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
359
|
+
name: "flag",
|
|
360
|
+
children: "The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\"."
|
|
361
|
+
}),
|
|
362
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
363
|
+
name: "argv",
|
|
364
|
+
children: "The command line arguments to check against. Defaults to global Deno args or process args."
|
|
365
|
+
}),
|
|
366
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "True if the flag is present, false otherwise." })
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
370
|
+
"export": true,
|
|
371
|
+
name: "hasFlag",
|
|
372
|
+
parameters: [{
|
|
373
|
+
name: "flag",
|
|
374
|
+
type: "string | string[]"
|
|
375
|
+
}, {
|
|
376
|
+
name: "argv",
|
|
377
|
+
type: "string[]",
|
|
378
|
+
optional: true,
|
|
379
|
+
default: "globalThis.Deno ? globalThis.Deno.args : process.argv"
|
|
380
|
+
}],
|
|
381
|
+
get children() {
|
|
382
|
+
return [
|
|
383
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
384
|
+
"const": true,
|
|
385
|
+
name: "position",
|
|
386
|
+
type: "number",
|
|
387
|
+
initializer: __alloy_js_core.code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {
|
|
388
|
+
const pos = argv.findIndex(arg => (f.startsWith("-") ? "" : (f.length === 1 ? "-" : "--") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? "-" : "--") + f + "=")?.toLowerCase());
|
|
389
|
+
return pos !== -1 ? pos : ret;
|
|
390
|
+
}, -1);`
|
|
391
|
+
}),
|
|
392
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
393
|
+
__alloy_js_core.code`return position !== -1 && argv.indexOf("--") === -1 || position < argv.indexOf("--");`
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
})];
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* A built-in utilities module for Shell Shock.
|
|
400
|
+
*/
|
|
401
|
+
function UtilsBuiltin(props) {
|
|
402
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
403
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, __alloy_js_core_jsx_runtime.mergeProps)({
|
|
404
|
+
id: "utils",
|
|
405
|
+
description: "A collection of helper utilities that ease command-line application development."
|
|
406
|
+
}, rest, {
|
|
407
|
+
get imports() {
|
|
408
|
+
return (0, defu.default)(rest.imports ?? {}, {
|
|
409
|
+
"node:os": ["os"],
|
|
410
|
+
"node:process": ["process"]
|
|
411
|
+
});
|
|
412
|
+
},
|
|
413
|
+
get builtinImports() {
|
|
414
|
+
return (0, defu.default)(rest.builtinImports ?? {}, { env: [
|
|
415
|
+
"env",
|
|
416
|
+
"isCI",
|
|
417
|
+
"isTest",
|
|
418
|
+
"isWindows"
|
|
419
|
+
] });
|
|
420
|
+
},
|
|
421
|
+
get children() {
|
|
422
|
+
return [
|
|
423
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
424
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
425
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(ArgsUtilities, {}),
|
|
426
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
427
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
428
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(EnvSupportUtilities, {}),
|
|
429
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
430
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
431
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(HyperlinkSupportUtilities, {}),
|
|
432
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
433
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
434
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(ColorSupportUtilities, {}),
|
|
435
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
436
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
437
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
438
|
+
get when() {
|
|
439
|
+
return Boolean(children);
|
|
440
|
+
},
|
|
441
|
+
children
|
|
442
|
+
})
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
exports.ArgsUtilities = ArgsUtilities;
|
|
450
|
+
exports.ColorSupportUtilities = ColorSupportUtilities;
|
|
451
|
+
exports.EnvSupportUtilities = EnvSupportUtilities;
|
|
452
|
+
exports.HyperlinkSupportUtilities = HyperlinkSupportUtilities;
|
|
453
|
+
exports.UtilsBuiltin = UtilsBuiltin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
|
+
|
|
4
|
+
//#region src/components/utils-builtin.d.ts
|
|
5
|
+
interface UtilsBuiltinProps extends Omit<BuiltinFileProps, "id" | "description"> {}
|
|
6
|
+
/**
|
|
7
|
+
* Generates utilities for detecting terminal color support.
|
|
8
|
+
*/
|
|
9
|
+
declare function EnvSupportUtilities(): _alloy_js_core0.Children;
|
|
10
|
+
/**
|
|
11
|
+
* Generates utilities for detecting terminal color support.
|
|
12
|
+
*/
|
|
13
|
+
declare function ColorSupportUtilities(): _alloy_js_core0.Children;
|
|
14
|
+
/**
|
|
15
|
+
* Generates utilities for detecting terminal color support.
|
|
16
|
+
*/
|
|
17
|
+
declare function HyperlinkSupportUtilities(): _alloy_js_core0.Children;
|
|
18
|
+
/**
|
|
19
|
+
* Generates utilities for detecting terminal color support.
|
|
20
|
+
*/
|
|
21
|
+
declare function ArgsUtilities(): _alloy_js_core0.Children;
|
|
22
|
+
/**
|
|
23
|
+
* A built-in utilities module for Shell Shock.
|
|
24
|
+
*/
|
|
25
|
+
declare function UtilsBuiltin(props: UtilsBuiltinProps): _alloy_js_core0.Children;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
|
+
|
|
4
|
+
//#region src/components/utils-builtin.d.ts
|
|
5
|
+
interface UtilsBuiltinProps extends Omit<BuiltinFileProps, "id" | "description"> {}
|
|
6
|
+
/**
|
|
7
|
+
* Generates utilities for detecting terminal color support.
|
|
8
|
+
*/
|
|
9
|
+
declare function EnvSupportUtilities(): _alloy_js_core0.Children;
|
|
10
|
+
/**
|
|
11
|
+
* Generates utilities for detecting terminal color support.
|
|
12
|
+
*/
|
|
13
|
+
declare function ColorSupportUtilities(): _alloy_js_core0.Children;
|
|
14
|
+
/**
|
|
15
|
+
* Generates utilities for detecting terminal color support.
|
|
16
|
+
*/
|
|
17
|
+
declare function HyperlinkSupportUtilities(): _alloy_js_core0.Children;
|
|
18
|
+
/**
|
|
19
|
+
* Generates utilities for detecting terminal color support.
|
|
20
|
+
*/
|
|
21
|
+
declare function ArgsUtilities(): _alloy_js_core0.Children;
|
|
22
|
+
/**
|
|
23
|
+
* A built-in utilities module for Shell Shock.
|
|
24
|
+
*/
|
|
25
|
+
declare function UtilsBuiltin(props: UtilsBuiltinProps): _alloy_js_core0.Children;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps };
|