@shell-shock/core 0.8.13 → 0.9.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 +34 -0
- package/dist/api.cjs.map +1 -1
- package/dist/api.mjs +34 -0
- 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/helpers.d.mts +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/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.d.mts +2 -2
- package/dist/components/utils-builtin.cjs +341 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +12 -8
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +12 -8
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +342 -2
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +12 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +12 -0
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +3 -2
- package/dist/contexts/command.cjs.map +1 -1
- package/dist/contexts/command.mjs +3 -2
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/options.cjs +20 -4
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.mjs +20 -4
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +6 -0
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +6 -0
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +92 -11
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +92 -11
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/resolve-command.cjs +200 -18
- package/dist/helpers/resolve-command.cjs.map +1 -1
- package/dist/helpers/resolve-command.mjs +201 -19
- package/dist/helpers/resolve-command.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +27 -3
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +27 -3
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +58 -4
- package/dist/helpers/utilities.cjs.map +1 -1
- package/dist/helpers/utilities.mjs +58 -4
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +28 -1
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +28 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +78 -3
- package/dist/plugin-utils/context-helpers.cjs.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +78 -3
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +17 -1
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.mjs +17 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/reflect.cjs +31 -3
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.mjs +31 -3
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +34 -4
- package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +34 -4
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin.cjs +5 -1
- 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 +5 -1
- package/dist/plugin.mjs.map +1 -1
- package/dist/types/command.cjs +241 -0
- package/dist/types/command.cjs.map +1 -0
- package/dist/types/command.mjs +221 -1
- package/dist/types/command.mjs.map +1 -0
- package/dist/types/config.cjs +114 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +11 -10
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +11 -10
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +110 -1
- package/dist/types/config.mjs.map +1 -0
- package/dist/types/context.cjs +33 -0
- package/dist/types/context.cjs.map +1 -0
- package/dist/types/context.mjs +31 -1
- package/dist/types/context.mjs.map +1 -0
- package/dist/types/env.cjs +12 -0
- package/dist/types/env.cjs.map +1 -0
- package/dist/types/env.d.cts +17 -0
- package/dist/types/env.d.cts.map +1 -0
- package/dist/types/env.d.mts +17 -0
- package/dist/types/env.d.mts.map +1 -0
- package/dist/types/env.mjs +11 -0
- package/dist/types/env.mjs.map +1 -0
- package/dist/types/index.cjs +34 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +7 -1
- package/dist/types/options.cjs +12 -0
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.mjs +11 -1
- package/dist/types/options.mjs.map +1 -0
- package/dist/types/runtime.cjs +12 -0
- package/dist/types/runtime.cjs.map +1 -0
- package/dist/types/runtime.mjs +11 -1
- package/dist/types/runtime.mjs.map +1 -0
- package/package.json +25 -11
|
@@ -423,6 +423,330 @@ function ArgsUtilities() {
|
|
|
423
423
|
})
|
|
424
424
|
];
|
|
425
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.
|
|
428
|
+
*/
|
|
429
|
+
function SpawnFunctionDeclaration() {
|
|
430
|
+
return [
|
|
431
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
432
|
+
async: true,
|
|
433
|
+
name: "resolveCommand",
|
|
434
|
+
parameters: [
|
|
435
|
+
{
|
|
436
|
+
name: "command",
|
|
437
|
+
type: "string"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: "options",
|
|
441
|
+
type: "Record<string, any>",
|
|
442
|
+
default: "{}"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "pathExt",
|
|
446
|
+
type: "string",
|
|
447
|
+
default: "process.env.PATHEXT || [\".EXE\", \".CMD\", \".BAT\", \".COM\"].join(delimiter)"
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
children: __alloy_js_core.code`const env = options.env || process.env;
|
|
451
|
+
const cwd = process.cwd();
|
|
452
|
+
if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {
|
|
453
|
+
try {
|
|
454
|
+
process.chdir(options.cwd);
|
|
455
|
+
} catch (err) {
|
|
456
|
+
// Do nothing
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
let resolved;
|
|
461
|
+
try {
|
|
462
|
+
let extensions = [""];
|
|
463
|
+
if (isWindows) {
|
|
464
|
+
extensions = pathExt.split(delimiter).flatMap((item) => [item, item.toLowerCase()]);
|
|
465
|
+
if (command.includes(".") && extensions[0] !== "") {
|
|
466
|
+
extensions.unshift("");
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
for (const envPart of (command.match(new RegExp(\`[\${posix.sep}\${sep === posix.sep ? "" : sep}]\`.replace(/(\\\\)/g, "\\\\$1"))))
|
|
471
|
+
? [...(isWindows ? [process.cwd()] : []), ...(process.env.PATH || "").split(delimiter)]
|
|
472
|
+
: [""]
|
|
473
|
+
) {
|
|
474
|
+
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)}\`;
|
|
475
|
+
for (const extension of extensions) {
|
|
476
|
+
if (isWindows) {
|
|
477
|
+
const filePath = part + extension;
|
|
478
|
+
if ((await stat(filePath)).isFile() && extensions.some((ext) => filePath.substring(filePath.length - ext.length).toLowerCase() === ext.toLowerCase())) {
|
|
479
|
+
resolved = filePath;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
const file = await stat(part + extension);
|
|
484
|
+
if (file.isFile() && (file.mode & 0o111) !== 0) {
|
|
485
|
+
resolved = part + extension;
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
} catch (err) {
|
|
492
|
+
// Do nothing
|
|
493
|
+
} finally {
|
|
494
|
+
if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {
|
|
495
|
+
process.chdir(cwd);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
if (resolved) {
|
|
501
|
+
resolved = resolve(
|
|
502
|
+
options.cwd ? options.cwd : "",
|
|
503
|
+
resolved
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return resolved; `
|
|
508
|
+
}),
|
|
509
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
510
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
511
|
+
name: "SpawnBaseOptions",
|
|
512
|
+
doc: "Options for the `spawn` handler function.",
|
|
513
|
+
get children() {
|
|
514
|
+
return [
|
|
515
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
516
|
+
name: "stdout",
|
|
517
|
+
optional: true,
|
|
518
|
+
type: "(data: string) => void",
|
|
519
|
+
doc: "The writable stream to use for prompt output, defaults to process.stdout"
|
|
520
|
+
}),
|
|
521
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
522
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
523
|
+
name: "stderr",
|
|
524
|
+
optional: true,
|
|
525
|
+
type: "(data: string) => void",
|
|
526
|
+
doc: "The writable stream to use for prompt error output, defaults to process.stderr"
|
|
527
|
+
}),
|
|
528
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
529
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
530
|
+
name: "rejectOnError",
|
|
531
|
+
optional: true,
|
|
532
|
+
type: "boolean",
|
|
533
|
+
doc: "Whether to reject the promise on error. Defaults to false."
|
|
534
|
+
}),
|
|
535
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
536
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
537
|
+
name: "file",
|
|
538
|
+
optional: true,
|
|
539
|
+
type: "string",
|
|
540
|
+
doc: "The file to execute."
|
|
541
|
+
}),
|
|
542
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
543
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
544
|
+
name: "shell",
|
|
545
|
+
optional: true,
|
|
546
|
+
type: "boolean | string",
|
|
547
|
+
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."
|
|
548
|
+
}),
|
|
549
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
550
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
551
|
+
name: "forceShell",
|
|
552
|
+
optional: true,
|
|
553
|
+
type: "boolean",
|
|
554
|
+
doc: "If true, forces the command to run inside of a shell, even if the command is a file."
|
|
555
|
+
})
|
|
556
|
+
];
|
|
557
|
+
}
|
|
558
|
+
}),
|
|
559
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
560
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
|
|
561
|
+
"export": true,
|
|
562
|
+
name: "SpawnOptions",
|
|
563
|
+
children: __alloy_js_core.code`SpawnBaseOptions & Parameters<typeof _spawn>[1]`
|
|
564
|
+
}),
|
|
565
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
566
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
567
|
+
heading: "A function to spawn child processes with proper color support and environment variable handling.",
|
|
568
|
+
get children() {
|
|
569
|
+
return [
|
|
570
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
571
|
+
name: "command",
|
|
572
|
+
children: `The command to execute.`
|
|
573
|
+
}),
|
|
574
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
575
|
+
name: "args",
|
|
576
|
+
children: `The command-line arguments to pass to the command. Defaults to an empty array.`
|
|
577
|
+
}),
|
|
578
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
579
|
+
name: "options",
|
|
580
|
+
children: `Additional options for spawning the process, such as the current working directory (\`cwd\`).`
|
|
581
|
+
}),
|
|
582
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The result of the spawned process.` })
|
|
583
|
+
];
|
|
584
|
+
}
|
|
585
|
+
}),
|
|
586
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
587
|
+
"export": true,
|
|
588
|
+
async: true,
|
|
589
|
+
name: "spawn",
|
|
590
|
+
parameters: [
|
|
591
|
+
{
|
|
592
|
+
name: "command",
|
|
593
|
+
type: "string"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: "args",
|
|
597
|
+
type: "string[] | SpawnOptions",
|
|
598
|
+
default: "{} as SpawnOptions"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
name: "options",
|
|
602
|
+
type: "SpawnOptions",
|
|
603
|
+
default: "{} as SpawnOptions"
|
|
604
|
+
}
|
|
605
|
+
],
|
|
606
|
+
children: __alloy_js_core.code`const normalized = {
|
|
607
|
+
command,
|
|
608
|
+
args: [] as string[],
|
|
609
|
+
options: options as SpawnOptions | any,
|
|
610
|
+
file: undefined as string | undefined,
|
|
611
|
+
original: {
|
|
612
|
+
command,
|
|
613
|
+
args,
|
|
614
|
+
},
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
if (args) {
|
|
618
|
+
if (Array.isArray(args)) {
|
|
619
|
+
if (args.length > 0) {
|
|
620
|
+
normalized.args = args.slice(0);
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
normalized.options = { ...args } as SpawnOptions | any;
|
|
624
|
+
normalized.args = [];
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (!normalized.options.shell && isWindows) {
|
|
629
|
+
normalized.file = (await resolveCommand(normalized.command, normalized.options)) || (await resolveCommand(normalized.command, normalized.options, delimiter));
|
|
630
|
+
|
|
631
|
+
let commandFile = normalized.file;
|
|
632
|
+
if (normalized.file) {
|
|
633
|
+
let shebang: string | undefined;
|
|
634
|
+
const buffer = Buffer.alloc(150);
|
|
635
|
+
|
|
636
|
+
try {
|
|
637
|
+
const fd = openSync(normalized.file, "r");
|
|
638
|
+
await read(fd, buffer, 0, 150, 0);
|
|
639
|
+
closeSync(fd);
|
|
640
|
+
} catch (err) {
|
|
641
|
+
// Do nothing
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
const matched = buffer.toString().match(/^#!(.*)/);
|
|
645
|
+
if (matched) {
|
|
646
|
+
const [path, argument] = matched[0].replace(/#! ?/, "").split(" ");
|
|
647
|
+
const binary = path.split("/").pop();
|
|
648
|
+
if (binary === "env") {
|
|
649
|
+
shebang = argument;
|
|
650
|
+
} else {
|
|
651
|
+
shebang = argument ? \`\${binary} \${argument}\` : binary;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (shebang) {
|
|
656
|
+
normalized.args.unshift(normalized.file);
|
|
657
|
+
normalized.command = shebang;
|
|
658
|
+
|
|
659
|
+
commandFile = await resolveCommand(normalized.command, normalized.options);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (commandFile && (normalized.options.forceShell || /\\.(?:com|exe)$/i.test(commandFile))) {
|
|
664
|
+
normalized.command = normalize(normalized.command).replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1");
|
|
665
|
+
|
|
666
|
+
normalized.args = ["/d", "/s", "/c", \`"\${normalized.command} \${normalized.args.map(arg =>
|
|
667
|
+
\`\${arg}\`.replace(/(?=(\\\\+?)?)\\1"/g, "$1$1\\"").replace(/(?=(\\\\+?)?)\\1$/, "$1$1")
|
|
668
|
+
).map(arg =>
|
|
669
|
+
\`"\${arg}"\`.replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1")
|
|
670
|
+
).map(arg =>
|
|
671
|
+
/node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i.test(commandFile) ? arg.replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1") : arg
|
|
672
|
+
).join(" ")}"\`];
|
|
673
|
+
normalized.command = process.env.comspec || "cmd.exe";
|
|
674
|
+
normalized.options.windowsVerbatimArguments = true;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
let stdout = "";
|
|
679
|
+
let stderr = "";
|
|
680
|
+
|
|
681
|
+
const child = _spawn(normalized.command, normalized.args, {
|
|
682
|
+
cwd: process.cwd(),
|
|
683
|
+
env: {
|
|
684
|
+
...process.env,
|
|
685
|
+
FORCE_COLOR: isColorSupported ? "1" : "0",
|
|
686
|
+
},
|
|
687
|
+
...normalized.options,
|
|
688
|
+
}) as ReturnType<typeof _spawn>;
|
|
689
|
+
|
|
690
|
+
if (isWindows) {
|
|
691
|
+
const emit = child.emit;
|
|
692
|
+
child.emit = (eventName: string | symbol, ...eventArgs: any[]) => {
|
|
693
|
+
if (eventName === "exit") {
|
|
694
|
+
let err: Error | null = null;
|
|
695
|
+
if (eventArgs[0] === 1 && !normalized.file) {
|
|
696
|
+
err = Object.assign(new Error(\`spawn \${normalized.original.command} ENOENT\`), {
|
|
697
|
+
code: "ENOENT",
|
|
698
|
+
errno: "ENOENT",
|
|
699
|
+
syscall: \`spawn \${normalized.original.command}\`,
|
|
700
|
+
path: normalized.original.command,
|
|
701
|
+
spawnargs: normalized.original.args,
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
if (err) {
|
|
706
|
+
return emit.call(child, "error", err);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return emit.apply(child, [eventName, ...eventArgs]);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
return new Promise((resolve, reject) => {
|
|
715
|
+
if (normalized.options.stdin !== undefined) {
|
|
716
|
+
child.stdin?.write(normalized.options.stdin);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
child.stdin?.end();
|
|
720
|
+
|
|
721
|
+
child.stdout?.on("data", data => {
|
|
722
|
+
stdout += data;
|
|
723
|
+
if (normalized.options.stdout) {
|
|
724
|
+
normalized.options.stdout(data);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
child.stderr?.on("data", data => {
|
|
729
|
+
stderr += data;
|
|
730
|
+
if (normalized.options.stderr) {
|
|
731
|
+
normalized.options.stderr(data);
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
if (normalized.options.rejectOnError) {
|
|
736
|
+
child.addListener("error", reject);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
child.on("close", code => {
|
|
740
|
+
if (code !== 0 && normalized.options.rejectOnError) {
|
|
741
|
+
reject(stderr);
|
|
742
|
+
} else {
|
|
743
|
+
resolve({ stdout, stderr });
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
}); `
|
|
747
|
+
})
|
|
748
|
+
];
|
|
749
|
+
}
|
|
426
750
|
function ContextUtilities() {
|
|
427
751
|
return __alloy_js_core.code`
|
|
428
752
|
/**
|
|
@@ -518,6 +842,20 @@ function UtilsBuiltin(props) {
|
|
|
518
842
|
return (0, defu.default)(rest.imports ?? {}, {
|
|
519
843
|
"node:os": "os",
|
|
520
844
|
"node:process": "process",
|
|
845
|
+
"node:path": [
|
|
846
|
+
"resolve",
|
|
847
|
+
"delimiter",
|
|
848
|
+
"normalize",
|
|
849
|
+
"join",
|
|
850
|
+
"posix",
|
|
851
|
+
"sep"
|
|
852
|
+
],
|
|
853
|
+
"node:fs": ["openSync", "closeSync"],
|
|
854
|
+
"node:fs/promises": ["stat", "read"],
|
|
855
|
+
"node:child_process": [{
|
|
856
|
+
name: "spawn",
|
|
857
|
+
alias: "_spawn"
|
|
858
|
+
}],
|
|
521
859
|
"node:async_hooks": ["AsyncLocalStorage"]
|
|
522
860
|
});
|
|
523
861
|
},
|
|
@@ -551,6 +889,8 @@ function UtilsBuiltin(props) {
|
|
|
551
889
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
552
890
|
(0, __alloy_js_core_jsx_runtime.createComponent)(ColorSupportUtilities, {}),
|
|
553
891
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
892
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(SpawnFunctionDeclaration, {}),
|
|
893
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
554
894
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
555
895
|
get when() {
|
|
556
896
|
return Boolean(children);
|
|
@@ -568,5 +908,6 @@ exports.ColorSupportUtilities = ColorSupportUtilities;
|
|
|
568
908
|
exports.ContextUtilities = ContextUtilities;
|
|
569
909
|
exports.EnvSupportUtilities = EnvSupportUtilities;
|
|
570
910
|
exports.HyperlinkSupportUtilities = HyperlinkSupportUtilities;
|
|
911
|
+
exports.SpawnFunctionDeclaration = SpawnFunctionDeclaration;
|
|
571
912
|
exports.UtilsBuiltin = UtilsBuiltin;
|
|
572
913
|
//# sourceMappingURL=utils-builtin.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-builtin.cjs","names":["code","Show","splitProps","FunctionDeclaration","InterfaceDeclaration","InterfaceMember","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","ContextUtilities","UtilsBuiltin","props","rest","_$mergeProps","id","description","imports","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 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\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: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 <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,SAAgBgB,sBAAsB;AACpC,QAAA;mDAEKV,sCAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAapB,oBAAI;GAAkD,CAAA;mDAEpEO,2DAAO,EAAA,CAAA;mDACPD,sCAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAapB,oBAAI;GAA4C,CAAA;mDAE9DO,2DAAO,EAAA,CAAA;mDACPD,sCAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAapB,oBAAI;GAAgI,CAAA;EAAA;;;;;AASzJ,SAAgBqB,wBAAwB;AACtC,QAAA;mDAEKjB,4CAAoB;GAAA,UAAA;GAEnBc,MAAI;GACJC,KAAG;GAAA,IAAAG,WAAA;AAAA,4DACFjB,uCAAe;KACda,MAAI;KACJK,MAAI;KACJJ,KAAG;KAAA,CAAA;;GAAA,CAAA;mDAGNZ,2DAAO,EAAA,CAAA;mDACPE,6DAAK;GAACe,SAAO;GAAA,IAAAF,WAAA;AAAA,WAAA;sDACXX,iEAAS,EAAAW,UACP,+DAA6D,CAAA;sDAE/DV,kEAAU;MAACM,MAAI;MAAAI,UACb;MAAmD,CAAA;sDAErDV,kEAAU;MAACM,MAAI;MAAAI,UAEZ;MAA4F,CAAA;sDAG/FR,oEAAY,EAAAQ,UACV,iDAA+C,CAAA;KAAA;;GAAA,CAAA;mDAGnDnB,2CAAmB;GAAA,UAAA;GAElBe,MAAI;GACJO,YAAY,CACV;IAAEP,MAAM;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;;;;;;;;;;;;;;;AAqFb,SAAgBgC,aAAaC,OAA0B;CACrD,MAAM,CAAC,EAAEX,YAAYY,wCAAmBD,OAAO,CAAC,WAAW,CAAC;AAE5D,yDACGzB,sHAAW;EACV4B,IAAE;EACFC,aAAW;EAAA,EACPH,MAAI;EAAA,IACRI,UAAO;AAAA,4BAAOJ,KAAKI,WAAW,EAAE,EAAE;IAChC,WAAW;IACX,gBAAgB;IAChB,oBAAoB,CAAC,oBAAmB;IACzC,CAAC;;EAAA,IACFC,iBAAc;AAAA,4BAAOL,KAAKK,kBAAkB,EAAE,EAAE;IAC9CC,SAAS;KAAC;KAAS;KAAW;KAAY;IAC1CC,KAAK;KAAC;KAAO;KAAQ;KAAU;KAAa;KAAiB;KAAS;IACvE,CAAC;;EAAA,IAAAnB,WAAA;AAAA,UAAA;qDACDf,2DAAO,EAAA,CAAA;qDACPwB,kBAAgB,EAAA,CAAA;qDAChBxB,2DAAO,EAAA,CAAA;qDACPsB,eAAa,EAAA,CAAA;qDACbtB,2DAAO,EAAA,CAAA;qDACPS,qBAAmB,EAAA,CAAA;qDACnBT,2DAAO,EAAA,CAAA;qDACPoB,2BAAyB,EAAA,CAAA;qDACzBpB,2DAAO,EAAA,CAAA;qDACPc,uBAAqB,EAAA,CAAA;qDACrBd,2DAAO,EAAA,CAAA;qDACPN,sBAAI;KAAA,IAACyC,OAAI;AAAA,aAAEC,QAAQrB,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils-builtin.cjs","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 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\"],\n \"node:fs/promises\": [\"stat\", \"read\"],\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;mDAEKV,sCAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,oBAAI;GAAkD,CAAA;mDAEpEQ,2DAAO,EAAA,CAAA;mDACPD,sCAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,oBAAI;GAA4C,CAAA;mDAE9DQ,2DAAO,EAAA,CAAA;mDACPD,sCAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,oBAAI;GAAgI,CAAA;EAAA;;;;;AASzJ,SAAgBsB,wBAAwB;AACtC,QAAA;mDAEKlB,4CAAoB;GAAA,UAAA;GAEnBe,MAAI;GACJC,KAAG;GAAA,IAAAG,WAAA;AAAA,4DACFlB,uCAAe;KACdc,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+B,IAAE;EACFC,aAAW;EAAA,EACPH,MAAI;EAAA,IACRI,UAAO;AAAA,4BAAOJ,KAAKI,WAAW,EAAE,EAAE;IAChC,WAAW;IACX,gBAAgB;IAChB,aAAa;KACX;KACA;KACA;KACA;KACA;KACA;KACD;IACD,WAAW,CAAC,YAAY,YAAY;IACpC,oBAAoB,CAAC,QAAQ,OAAO;IACpC,sBAAsB,CAAC;KAAEvB,MAAM;KAASwB,OAAO;KAAU,CAAC;IAC1D,oBAAoB,CAAC,oBAAmB;IACzC,CAAC;;EAAA,IACFC,iBAAc;AAAA,4BAAON,KAAKM,kBAAkB,EAAE,EAAE;IAC9CC,SAAS;KAAC;KAAS;KAAW;KAAY;IAC1CC,KAAK;KAAC;KAAO;KAAQ;KAAU;KAAa;KAAiB;KAAS;IACvE,CAAC;;EAAA,IAAAvB,WAAA;AAAA,UAAA;qDACDf,2DAAO,EAAA,CAAA;qDACP2B,kBAAgB,EAAA,CAAA;qDAChB3B,2DAAO,EAAA,CAAA;qDACPsB,eAAa,EAAA,CAAA;qDACbtB,2DAAO,EAAA,CAAA;qDACPS,qBAAmB,EAAA,CAAA;qDACnBT,2DAAO,EAAA,CAAA;qDACPoB,2BAAyB,EAAA,CAAA;qDACzBpB,2DAAO,EAAA,CAAA;qDACPc,uBAAqB,EAAA,CAAA;qDACrBd,2DAAO,EAAA,CAAA;qDACPwB,0BAAwB,EAAA,CAAA;qDACxBxB,2DAAO,EAAA,CAAA;qDACPP,sBAAI;KAAA,IAAC8C,OAAI;AAAA,aAAEC,QAAQzB,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core8 from "@alloy-js/core";
|
|
2
2
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
3
|
|
|
4
4
|
//#region src/components/utils-builtin.d.ts
|
|
@@ -6,24 +6,28 @@ interface UtilsBuiltinProps extends Omit<BuiltinFileProps, "id" | "description">
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates utilities for detecting terminal color support.
|
|
8
8
|
*/
|
|
9
|
-
declare function EnvSupportUtilities():
|
|
9
|
+
declare function EnvSupportUtilities(): _alloy_js_core8.Children;
|
|
10
10
|
/**
|
|
11
11
|
* Generates utilities for detecting terminal color support.
|
|
12
12
|
*/
|
|
13
|
-
declare function ColorSupportUtilities():
|
|
13
|
+
declare function ColorSupportUtilities(): _alloy_js_core8.Children;
|
|
14
14
|
/**
|
|
15
15
|
* Generates utilities for detecting terminal color support.
|
|
16
16
|
*/
|
|
17
|
-
declare function HyperlinkSupportUtilities():
|
|
17
|
+
declare function HyperlinkSupportUtilities(): _alloy_js_core8.Children;
|
|
18
18
|
/**
|
|
19
19
|
* Generates utilities for detecting terminal color support.
|
|
20
20
|
*/
|
|
21
|
-
declare function ArgsUtilities():
|
|
22
|
-
|
|
21
|
+
declare function ArgsUtilities(): _alloy_js_core8.Children;
|
|
22
|
+
/**
|
|
23
|
+
* Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.
|
|
24
|
+
*/
|
|
25
|
+
declare function SpawnFunctionDeclaration(): _alloy_js_core8.Children;
|
|
26
|
+
declare function ContextUtilities(): _alloy_js_core8.Children;
|
|
23
27
|
/**
|
|
24
28
|
* A built-in utilities module for Shell Shock.
|
|
25
29
|
*/
|
|
26
|
-
declare function UtilsBuiltin(props: UtilsBuiltinProps):
|
|
30
|
+
declare function UtilsBuiltin(props: UtilsBuiltinProps): _alloy_js_core8.Children;
|
|
27
31
|
//#endregion
|
|
28
|
-
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps };
|
|
32
|
+
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, SpawnFunctionDeclaration, UtilsBuiltin, UtilsBuiltinProps };
|
|
29
33
|
//# sourceMappingURL=utils-builtin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-builtin.d.cts","names":[],"sources":["../../src/components/utils-builtin.tsx"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"utils-builtin.d.cts","names":[],"sources":["../../src/components/utils-builtin.tsx"],"sourcesContent":[],"mappings":";;;;UAuCiB,iBAAA,SAA0B,KACzC;;AADF;AAQA;AAiCgB,iBAjCA,mBAAA,CAAA,CAiCqB,EAjCF,eAAA,CAAA,QAiCE;AAsMrC;AA0GA;AA+EA;AAkTgB,iBAjrBA,qBAAA,CAAA,CAirBgB,EAjrBK,eAAA,CAAA,QAirBL;AAsFhC;;;iBAjkBgB,yBAAA,CAAA,GAAyB,eAAA,CAAA;;;;iBA0GzB,aAAA,CAAA,GAAa,eAAA,CAAA;;;;iBA+Eb,wBAAA,CAAA,GAAwB,eAAA,CAAA;iBAkTxB,gBAAA,CAAA,GAAgB,eAAA,CAAA;;;;iBAsFhB,YAAA,QAAoB,oBAAiB,eAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core8 from "@alloy-js/core";
|
|
2
2
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
3
|
|
|
4
4
|
//#region src/components/utils-builtin.d.ts
|
|
@@ -6,24 +6,28 @@ interface UtilsBuiltinProps extends Omit<BuiltinFileProps, "id" | "description">
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates utilities for detecting terminal color support.
|
|
8
8
|
*/
|
|
9
|
-
declare function EnvSupportUtilities():
|
|
9
|
+
declare function EnvSupportUtilities(): _alloy_js_core8.Children;
|
|
10
10
|
/**
|
|
11
11
|
* Generates utilities for detecting terminal color support.
|
|
12
12
|
*/
|
|
13
|
-
declare function ColorSupportUtilities():
|
|
13
|
+
declare function ColorSupportUtilities(): _alloy_js_core8.Children;
|
|
14
14
|
/**
|
|
15
15
|
* Generates utilities for detecting terminal color support.
|
|
16
16
|
*/
|
|
17
|
-
declare function HyperlinkSupportUtilities():
|
|
17
|
+
declare function HyperlinkSupportUtilities(): _alloy_js_core8.Children;
|
|
18
18
|
/**
|
|
19
19
|
* Generates utilities for detecting terminal color support.
|
|
20
20
|
*/
|
|
21
|
-
declare function ArgsUtilities():
|
|
22
|
-
|
|
21
|
+
declare function ArgsUtilities(): _alloy_js_core8.Children;
|
|
22
|
+
/**
|
|
23
|
+
* Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.
|
|
24
|
+
*/
|
|
25
|
+
declare function SpawnFunctionDeclaration(): _alloy_js_core8.Children;
|
|
26
|
+
declare function ContextUtilities(): _alloy_js_core8.Children;
|
|
23
27
|
/**
|
|
24
28
|
* A built-in utilities module for Shell Shock.
|
|
25
29
|
*/
|
|
26
|
-
declare function UtilsBuiltin(props: UtilsBuiltinProps):
|
|
30
|
+
declare function UtilsBuiltin(props: UtilsBuiltinProps): _alloy_js_core8.Children;
|
|
27
31
|
//#endregion
|
|
28
|
-
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps };
|
|
32
|
+
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, SpawnFunctionDeclaration, UtilsBuiltin, UtilsBuiltinProps };
|
|
29
33
|
//# sourceMappingURL=utils-builtin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-builtin.d.mts","names":[],"sources":["../../src/components/utils-builtin.tsx"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"utils-builtin.d.mts","names":[],"sources":["../../src/components/utils-builtin.tsx"],"sourcesContent":[],"mappings":";;;;UAuCiB,iBAAA,SAA0B,KACzC;;AADF;AAQA;AAiCgB,iBAjCA,mBAAA,CAAA,CAiCqB,EAjCF,eAAA,CAAA,QAiCE;AAsMrC;AA0GA;AA+EA;AAkTgB,iBAjrBA,qBAAA,CAAA,CAirBgB,EAjrBK,eAAA,CAAA,QAirBL;AAsFhC;;;iBAjkBgB,yBAAA,CAAA,GAAyB,eAAA,CAAA;;;;iBA0GzB,aAAA,CAAA,GAAa,eAAA,CAAA;;;;iBA+Eb,wBAAA,CAAA,GAAwB,eAAA,CAAA;iBAkTxB,gBAAA,CAAA,GAAgB,eAAA,CAAA;;;;iBAsFhB,YAAA,QAAoB,oBAAiB,eAAA,CAAA"}
|