@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
|
@@ -2,7 +2,7 @@ import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx
|
|
|
2
2
|
import defu$1 from "defu";
|
|
3
3
|
import { Show, code, splitProps } from "@alloy-js/core";
|
|
4
4
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
|
-
import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
5
|
+
import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
6
6
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
7
7
|
import { TSDoc, TSDocInternal, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
8
8
|
|
|
@@ -421,6 +421,330 @@ function ArgsUtilities() {
|
|
|
421
421
|
})
|
|
422
422
|
];
|
|
423
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.
|
|
426
|
+
*/
|
|
427
|
+
function SpawnFunctionDeclaration() {
|
|
428
|
+
return [
|
|
429
|
+
createComponent(FunctionDeclaration, {
|
|
430
|
+
async: true,
|
|
431
|
+
name: "resolveCommand",
|
|
432
|
+
parameters: [
|
|
433
|
+
{
|
|
434
|
+
name: "command",
|
|
435
|
+
type: "string"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: "options",
|
|
439
|
+
type: "Record<string, any>",
|
|
440
|
+
default: "{}"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: "pathExt",
|
|
444
|
+
type: "string",
|
|
445
|
+
default: "process.env.PATHEXT || [\".EXE\", \".CMD\", \".BAT\", \".COM\"].join(delimiter)"
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
children: code`const env = options.env || process.env;
|
|
449
|
+
const cwd = process.cwd();
|
|
450
|
+
if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {
|
|
451
|
+
try {
|
|
452
|
+
process.chdir(options.cwd);
|
|
453
|
+
} catch (err) {
|
|
454
|
+
// Do nothing
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
let resolved;
|
|
459
|
+
try {
|
|
460
|
+
let extensions = [""];
|
|
461
|
+
if (isWindows) {
|
|
462
|
+
extensions = pathExt.split(delimiter).flatMap((item) => [item, item.toLowerCase()]);
|
|
463
|
+
if (command.includes(".") && extensions[0] !== "") {
|
|
464
|
+
extensions.unshift("");
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
for (const envPart of (command.match(new RegExp(\`[\${posix.sep}\${sep === posix.sep ? "" : sep}]\`.replace(/(\\\\)/g, "\\\\$1"))))
|
|
469
|
+
? [...(isWindows ? [process.cwd()] : []), ...(process.env.PATH || "").split(delimiter)]
|
|
470
|
+
: [""]
|
|
471
|
+
) {
|
|
472
|
+
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)}\`;
|
|
473
|
+
for (const extension of extensions) {
|
|
474
|
+
if (isWindows) {
|
|
475
|
+
const filePath = part + extension;
|
|
476
|
+
if ((await stat(filePath)).isFile() && extensions.some((ext) => filePath.substring(filePath.length - ext.length).toLowerCase() === ext.toLowerCase())) {
|
|
477
|
+
resolved = filePath;
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
} else {
|
|
481
|
+
const file = await stat(part + extension);
|
|
482
|
+
if (file.isFile() && (file.mode & 0o111) !== 0) {
|
|
483
|
+
resolved = part + extension;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
} catch (err) {
|
|
490
|
+
// Do nothing
|
|
491
|
+
} finally {
|
|
492
|
+
if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {
|
|
493
|
+
process.chdir(cwd);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
if (resolved) {
|
|
499
|
+
resolved = resolve(
|
|
500
|
+
options.cwd ? options.cwd : "",
|
|
501
|
+
resolved
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return resolved; `
|
|
506
|
+
}),
|
|
507
|
+
createComponent(Spacing, {}),
|
|
508
|
+
createComponent(InterfaceDeclaration, {
|
|
509
|
+
name: "SpawnBaseOptions",
|
|
510
|
+
doc: "Options for the `spawn` handler function.",
|
|
511
|
+
get children() {
|
|
512
|
+
return [
|
|
513
|
+
createComponent(InterfaceMember, {
|
|
514
|
+
name: "stdout",
|
|
515
|
+
optional: true,
|
|
516
|
+
type: "(data: string) => void",
|
|
517
|
+
doc: "The writable stream to use for prompt output, defaults to process.stdout"
|
|
518
|
+
}),
|
|
519
|
+
createIntrinsic("hbr", {}),
|
|
520
|
+
createComponent(InterfaceMember, {
|
|
521
|
+
name: "stderr",
|
|
522
|
+
optional: true,
|
|
523
|
+
type: "(data: string) => void",
|
|
524
|
+
doc: "The writable stream to use for prompt error output, defaults to process.stderr"
|
|
525
|
+
}),
|
|
526
|
+
createIntrinsic("hbr", {}),
|
|
527
|
+
createComponent(InterfaceMember, {
|
|
528
|
+
name: "rejectOnError",
|
|
529
|
+
optional: true,
|
|
530
|
+
type: "boolean",
|
|
531
|
+
doc: "Whether to reject the promise on error. Defaults to false."
|
|
532
|
+
}),
|
|
533
|
+
createIntrinsic("hbr", {}),
|
|
534
|
+
createComponent(InterfaceMember, {
|
|
535
|
+
name: "file",
|
|
536
|
+
optional: true,
|
|
537
|
+
type: "string",
|
|
538
|
+
doc: "The file to execute."
|
|
539
|
+
}),
|
|
540
|
+
createIntrinsic("hbr", {}),
|
|
541
|
+
createComponent(InterfaceMember, {
|
|
542
|
+
name: "shell",
|
|
543
|
+
optional: true,
|
|
544
|
+
type: "boolean | string",
|
|
545
|
+
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."
|
|
546
|
+
}),
|
|
547
|
+
createIntrinsic("hbr", {}),
|
|
548
|
+
createComponent(InterfaceMember, {
|
|
549
|
+
name: "forceShell",
|
|
550
|
+
optional: true,
|
|
551
|
+
type: "boolean",
|
|
552
|
+
doc: "If true, forces the command to run inside of a shell, even if the command is a file."
|
|
553
|
+
})
|
|
554
|
+
];
|
|
555
|
+
}
|
|
556
|
+
}),
|
|
557
|
+
createComponent(Spacing, {}),
|
|
558
|
+
createComponent(TypeDeclaration, {
|
|
559
|
+
"export": true,
|
|
560
|
+
name: "SpawnOptions",
|
|
561
|
+
children: code`SpawnBaseOptions & Parameters<typeof _spawn>[1]`
|
|
562
|
+
}),
|
|
563
|
+
createComponent(Spacing, {}),
|
|
564
|
+
createComponent(TSDoc, {
|
|
565
|
+
heading: "A function to spawn child processes with proper color support and environment variable handling.",
|
|
566
|
+
get children() {
|
|
567
|
+
return [
|
|
568
|
+
createComponent(TSDocParam, {
|
|
569
|
+
name: "command",
|
|
570
|
+
children: `The command to execute.`
|
|
571
|
+
}),
|
|
572
|
+
createComponent(TSDocParam, {
|
|
573
|
+
name: "args",
|
|
574
|
+
children: `The command-line arguments to pass to the command. Defaults to an empty array.`
|
|
575
|
+
}),
|
|
576
|
+
createComponent(TSDocParam, {
|
|
577
|
+
name: "options",
|
|
578
|
+
children: `Additional options for spawning the process, such as the current working directory (\`cwd\`).`
|
|
579
|
+
}),
|
|
580
|
+
createComponent(TSDocReturns, { children: `The result of the spawned process.` })
|
|
581
|
+
];
|
|
582
|
+
}
|
|
583
|
+
}),
|
|
584
|
+
createComponent(FunctionDeclaration, {
|
|
585
|
+
"export": true,
|
|
586
|
+
async: true,
|
|
587
|
+
name: "spawn",
|
|
588
|
+
parameters: [
|
|
589
|
+
{
|
|
590
|
+
name: "command",
|
|
591
|
+
type: "string"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
name: "args",
|
|
595
|
+
type: "string[] | SpawnOptions",
|
|
596
|
+
default: "{} as SpawnOptions"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
name: "options",
|
|
600
|
+
type: "SpawnOptions",
|
|
601
|
+
default: "{} as SpawnOptions"
|
|
602
|
+
}
|
|
603
|
+
],
|
|
604
|
+
children: code`const normalized = {
|
|
605
|
+
command,
|
|
606
|
+
args: [] as string[],
|
|
607
|
+
options: options as SpawnOptions | any,
|
|
608
|
+
file: undefined as string | undefined,
|
|
609
|
+
original: {
|
|
610
|
+
command,
|
|
611
|
+
args,
|
|
612
|
+
},
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
if (args) {
|
|
616
|
+
if (Array.isArray(args)) {
|
|
617
|
+
if (args.length > 0) {
|
|
618
|
+
normalized.args = args.slice(0);
|
|
619
|
+
}
|
|
620
|
+
} else {
|
|
621
|
+
normalized.options = { ...args } as SpawnOptions | any;
|
|
622
|
+
normalized.args = [];
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (!normalized.options.shell && isWindows) {
|
|
627
|
+
normalized.file = (await resolveCommand(normalized.command, normalized.options)) || (await resolveCommand(normalized.command, normalized.options, delimiter));
|
|
628
|
+
|
|
629
|
+
let commandFile = normalized.file;
|
|
630
|
+
if (normalized.file) {
|
|
631
|
+
let shebang: string | undefined;
|
|
632
|
+
const buffer = Buffer.alloc(150);
|
|
633
|
+
|
|
634
|
+
try {
|
|
635
|
+
const fd = openSync(normalized.file, "r");
|
|
636
|
+
await read(fd, buffer, 0, 150, 0);
|
|
637
|
+
closeSync(fd);
|
|
638
|
+
} catch (err) {
|
|
639
|
+
// Do nothing
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const matched = buffer.toString().match(/^#!(.*)/);
|
|
643
|
+
if (matched) {
|
|
644
|
+
const [path, argument] = matched[0].replace(/#! ?/, "").split(" ");
|
|
645
|
+
const binary = path.split("/").pop();
|
|
646
|
+
if (binary === "env") {
|
|
647
|
+
shebang = argument;
|
|
648
|
+
} else {
|
|
649
|
+
shebang = argument ? \`\${binary} \${argument}\` : binary;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (shebang) {
|
|
654
|
+
normalized.args.unshift(normalized.file);
|
|
655
|
+
normalized.command = shebang;
|
|
656
|
+
|
|
657
|
+
commandFile = await resolveCommand(normalized.command, normalized.options);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if (commandFile && (normalized.options.forceShell || /\\.(?:com|exe)$/i.test(commandFile))) {
|
|
662
|
+
normalized.command = normalize(normalized.command).replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1");
|
|
663
|
+
|
|
664
|
+
normalized.args = ["/d", "/s", "/c", \`"\${normalized.command} \${normalized.args.map(arg =>
|
|
665
|
+
\`\${arg}\`.replace(/(?=(\\\\+?)?)\\1"/g, "$1$1\\"").replace(/(?=(\\\\+?)?)\\1$/, "$1$1")
|
|
666
|
+
).map(arg =>
|
|
667
|
+
\`"\${arg}"\`.replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1")
|
|
668
|
+
).map(arg =>
|
|
669
|
+
/node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i.test(commandFile) ? arg.replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1") : arg
|
|
670
|
+
).join(" ")}"\`];
|
|
671
|
+
normalized.command = process.env.comspec || "cmd.exe";
|
|
672
|
+
normalized.options.windowsVerbatimArguments = true;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
let stdout = "";
|
|
677
|
+
let stderr = "";
|
|
678
|
+
|
|
679
|
+
const child = _spawn(normalized.command, normalized.args, {
|
|
680
|
+
cwd: process.cwd(),
|
|
681
|
+
env: {
|
|
682
|
+
...process.env,
|
|
683
|
+
FORCE_COLOR: isColorSupported ? "1" : "0",
|
|
684
|
+
},
|
|
685
|
+
...normalized.options,
|
|
686
|
+
}) as ReturnType<typeof _spawn>;
|
|
687
|
+
|
|
688
|
+
if (isWindows) {
|
|
689
|
+
const emit = child.emit;
|
|
690
|
+
child.emit = (eventName: string | symbol, ...eventArgs: any[]) => {
|
|
691
|
+
if (eventName === "exit") {
|
|
692
|
+
let err: Error | null = null;
|
|
693
|
+
if (eventArgs[0] === 1 && !normalized.file) {
|
|
694
|
+
err = Object.assign(new Error(\`spawn \${normalized.original.command} ENOENT\`), {
|
|
695
|
+
code: "ENOENT",
|
|
696
|
+
errno: "ENOENT",
|
|
697
|
+
syscall: \`spawn \${normalized.original.command}\`,
|
|
698
|
+
path: normalized.original.command,
|
|
699
|
+
spawnargs: normalized.original.args,
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (err) {
|
|
704
|
+
return emit.call(child, "error", err);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return emit.apply(child, [eventName, ...eventArgs]);
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
return new Promise((resolve, reject) => {
|
|
713
|
+
if (normalized.options.stdin !== undefined) {
|
|
714
|
+
child.stdin?.write(normalized.options.stdin);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
child.stdin?.end();
|
|
718
|
+
|
|
719
|
+
child.stdout?.on("data", data => {
|
|
720
|
+
stdout += data;
|
|
721
|
+
if (normalized.options.stdout) {
|
|
722
|
+
normalized.options.stdout(data);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
child.stderr?.on("data", data => {
|
|
727
|
+
stderr += data;
|
|
728
|
+
if (normalized.options.stderr) {
|
|
729
|
+
normalized.options.stderr(data);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
if (normalized.options.rejectOnError) {
|
|
734
|
+
child.addListener("error", reject);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
child.on("close", code => {
|
|
738
|
+
if (code !== 0 && normalized.options.rejectOnError) {
|
|
739
|
+
reject(stderr);
|
|
740
|
+
} else {
|
|
741
|
+
resolve({ stdout, stderr });
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
}); `
|
|
745
|
+
})
|
|
746
|
+
];
|
|
747
|
+
}
|
|
424
748
|
function ContextUtilities() {
|
|
425
749
|
return code`
|
|
426
750
|
/**
|
|
@@ -516,6 +840,20 @@ function UtilsBuiltin(props) {
|
|
|
516
840
|
return defu$1(rest.imports ?? {}, {
|
|
517
841
|
"node:os": "os",
|
|
518
842
|
"node:process": "process",
|
|
843
|
+
"node:path": [
|
|
844
|
+
"resolve",
|
|
845
|
+
"delimiter",
|
|
846
|
+
"normalize",
|
|
847
|
+
"join",
|
|
848
|
+
"posix",
|
|
849
|
+
"sep"
|
|
850
|
+
],
|
|
851
|
+
"node:fs": ["openSync", "closeSync"],
|
|
852
|
+
"node:fs/promises": ["stat", "read"],
|
|
853
|
+
"node:child_process": [{
|
|
854
|
+
name: "spawn",
|
|
855
|
+
alias: "_spawn"
|
|
856
|
+
}],
|
|
519
857
|
"node:async_hooks": ["AsyncLocalStorage"]
|
|
520
858
|
});
|
|
521
859
|
},
|
|
@@ -549,6 +887,8 @@ function UtilsBuiltin(props) {
|
|
|
549
887
|
createComponent(Spacing, {}),
|
|
550
888
|
createComponent(ColorSupportUtilities, {}),
|
|
551
889
|
createComponent(Spacing, {}),
|
|
890
|
+
createComponent(SpawnFunctionDeclaration, {}),
|
|
891
|
+
createComponent(Spacing, {}),
|
|
552
892
|
createComponent(Show, {
|
|
553
893
|
get when() {
|
|
554
894
|
return Boolean(children);
|
|
@@ -561,5 +901,5 @@ function UtilsBuiltin(props) {
|
|
|
561
901
|
}
|
|
562
902
|
|
|
563
903
|
//#endregion
|
|
564
|
-
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, UtilsBuiltin };
|
|
904
|
+
export { ArgsUtilities, ColorSupportUtilities, ContextUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, SpawnFunctionDeclaration, UtilsBuiltin };
|
|
565
905
|
//# sourceMappingURL=utils-builtin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-builtin.mjs","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;EAAAC,gBAEKX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAapB,IAAI;GAAkD,CAAA;EAAAiB,gBAEpEV,SAAO,EAAA,CAAA;EAAAU,gBACPX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAapB,IAAI;GAA4C,CAAA;EAAAiB,gBAE9DV,SAAO,EAAA,CAAA;EAAAU,gBACPX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAapB,IAAI;GAAgI,CAAA;EAAA;;;;;AASzJ,SAAgB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AC;KAAS;KAAW;KAAY;IAC1CC,KAAK;KAAC;KAAO;KAAQ;KAAU;KAAa;KAAiB;KAAS;IACvE,CAAC;;EAAA,IAAAnB,WAAA;AAAA,UAAA;IAAAL,gBACDV,SAAO,EAAA,CAAA;IAAAU,gBACPc,kBAAgB,EAAA,CAAA;IAAAd,gBAChBV,SAAO,EAAA,CAAA;IAAAU,gBACPY,eAAa,EAAA,CAAA;IAAAZ,gBACbV,SAAO,EAAA,CAAA;IAAAU,gBACPD,qBAAmB,EAAA,CAAA;IAAAC,gBACnBV,SAAO,EAAA,CAAA;IAAAU,gBACPU,2BAAyB,EAAA,CAAA;IAAAV,gBACzBV,SAAO,EAAA,CAAA;IAAAU,gBACPI,uBAAqB,EAAA,CAAA;IAAAJ,gBACrBV,SAAO,EAAA,CAAA;IAAAU,gBACPhB,MAAI;KAAA,IAACyC,OAAI;AAAA,aAAEC,QAAQrB,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","InterfaceDeclaration","InterfaceMember","TypeDeclaration","VarDeclaration","Spacing","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;EAAAC,gBAEKX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,IAAI;GAAkD,CAAA;EAAAkB,gBAEpEV,SAAO,EAAA,CAAA;EAAAU,gBACPX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,IAAI;GAA4C,CAAA;EAAAkB,gBAE9DV,SAAO,EAAA,CAAA;EAAAU,gBACPX,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbY,MAAI;GACJC,KAAG;GACHC,aAAarB,IAAI;GAAgI,CAAA;EAAA;;;;;AASzJ,SAAgBsB,wBAAwB;AACtC,QAAA;EAAAJ,gBAEKd,sBAAoB;GAAA,UAAA;GAEnBe,MAAI;GACJC,KAAG;GAAA,IAAAG,WAAA;AAAA,WAAAL,gBACFb,iBAAe;KACdc,MAAI;KACJK,MAAI;KACJJ,KAAG;KAAA,CAAA;;GAAA,CAAA;EAAAF,gBAGNV,SAAO,EAAA,CAAA;EAAAU,gBACPR,OAAK;GAACe,SAAO;GAAA,IAAAF,WAAA;AAAA,WAAA;KAAAL,gBACXN,WAAS,EAAAW,UACP,+DAA6D,CAAA;KAAAL,gBAE/DL,YAAU;MAACM,MAAI;MAAAI,UACb;MAAmD,CAAA;KAAAL,gB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A,CAAA,CAAA"}
|
package/dist/config.cjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/config.ts
|
|
3
|
+
const __ΩPartial = [
|
|
4
|
+
"T",
|
|
5
|
+
"Partial",
|
|
6
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
7
|
+
];
|
|
3
8
|
/**
|
|
4
9
|
* A utility function to define a Shell Shock user configuration.
|
|
5
10
|
*
|
|
@@ -12,6 +17,13 @@
|
|
|
12
17
|
function defineConfig(config) {
|
|
13
18
|
return config;
|
|
14
19
|
}
|
|
20
|
+
defineConfig.__type = [
|
|
21
|
+
() => __ΩPartial,
|
|
22
|
+
"UserConfig",
|
|
23
|
+
"config",
|
|
24
|
+
"defineConfig",
|
|
25
|
+
"P\"w\"o!\"2#\"w\"/$"
|
|
26
|
+
];
|
|
15
27
|
|
|
16
28
|
//#endregion
|
|
17
29
|
exports.defineConfig = defineConfig;
|
package/dist/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":[
|
|
1
|
+
{"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { UserConfig } from \"./types/config\";\n\n/**\n * A utility function to define a Shell Shock user configuration.\n *\n * @remarks\n * This function is used to create a user configuration object for Shell Shock projects. It ensures that the configuration adheres to the expected structure.\n *\n * @param config - A partial user configuration object.\n * @returns A complete user configuration object.\n */\nexport function defineConfig(config: Partial<UserConfig>): UserConfig {\n return config;\n}\n"],"mappings":";;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;;;;AAU/D,SAAgB,aAAa,QAAQ;AACjC,QAAO"}
|
package/dist/config.mjs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/config.ts
|
|
2
|
+
const __ΩPartial = [
|
|
3
|
+
"T",
|
|
4
|
+
"Partial",
|
|
5
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
6
|
+
];
|
|
2
7
|
/**
|
|
3
8
|
* A utility function to define a Shell Shock user configuration.
|
|
4
9
|
*
|
|
@@ -11,6 +16,13 @@
|
|
|
11
16
|
function defineConfig(config) {
|
|
12
17
|
return config;
|
|
13
18
|
}
|
|
19
|
+
defineConfig.__type = [
|
|
20
|
+
() => __ΩPartial,
|
|
21
|
+
"UserConfig",
|
|
22
|
+
"config",
|
|
23
|
+
"defineConfig",
|
|
24
|
+
"P\"w\"o!\"2#\"w\"/$"
|
|
25
|
+
];
|
|
14
26
|
|
|
15
27
|
//#endregion
|
|
16
28
|
export { defineConfig };
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { UserConfig } from \"./types/config\";\n\n/**\n * A utility function to define a Shell Shock user configuration.\n *\n * @remarks\n * This function is used to create a user configuration object for Shell Shock projects. It ensures that the configuration adheres to the expected structure.\n *\n * @param config - A partial user configuration object.\n * @returns A complete user configuration object.\n */\nexport function defineConfig(config: Partial<UserConfig>): UserConfig {\n return config;\n}\n"],"mappings":";AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;;;;AAU/D,SAAgB,aAAa,QAAQ;AACjC,QAAO"}
|
|
@@ -5,15 +5,16 @@ let __alloy_js_core = require("@alloy-js/core");
|
|
|
5
5
|
/**
|
|
6
6
|
* The reflection parameter context used in template rendering.
|
|
7
7
|
*/
|
|
8
|
-
const CommandContext = (0, __alloy_js_core.createNamedContext)("Command");
|
|
8
|
+
const CommandContext = (__alloy_js_core.createNamedContext.Ω = [["CommandTree", "P\"w!-J"]], (0, __alloy_js_core.createNamedContext)("Command"));
|
|
9
9
|
/**
|
|
10
10
|
* Hook to access the Command context.
|
|
11
11
|
*
|
|
12
12
|
* @returns A reactive version of the current reflection.
|
|
13
13
|
*/
|
|
14
14
|
function useCommand() {
|
|
15
|
-
return (0, __alloy_js_core.useContext)(CommandContext);
|
|
15
|
+
return __alloy_js_core.useContext.Ω = [["CommandTree", "P\"w!-J"]], (0, __alloy_js_core.useContext)(CommandContext);
|
|
16
16
|
}
|
|
17
|
+
useCommand.__type = ["useCommand", "P\"/!"];
|
|
17
18
|
|
|
18
19
|
//#endregion
|
|
19
20
|
exports.CommandContext = CommandContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.cjs","names":[
|
|
1
|
+
{"version":3,"file":"command.cjs","names":[],"sources":["../../src/contexts/command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport type { CommandTree } from \"../types/command\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const CommandContext: ComponentContext<CommandTree | undefined> =\n createNamedContext<CommandTree | undefined>(\"Command\");\n\n/**\n * Hook to access the Command context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useCommand() {\n return useContext<CommandTree | undefined>(CommandContext)!;\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BE,QAAA,2BAAA,IAAA,CAAA,CAAA,eAAA,UAAA,CAAA,kCAAA,eAAA;;AAEF,WAAC,SAAA,CAAA,cAAA,QAAA"}
|