@shell-shock/core 0.15.1 → 0.16.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.
Files changed (103) hide show
  1. package/dist/api.cjs +10 -7
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.d.cts +1 -1
  4. package/dist/api.d.cts.map +1 -1
  5. package/dist/api.d.mts +1 -1
  6. package/dist/api.d.mts.map +1 -1
  7. package/dist/api.mjs +11 -8
  8. package/dist/api.mjs.map +1 -1
  9. package/dist/components/helpers.cjs +1 -1
  10. package/dist/components/helpers.cjs.map +1 -1
  11. package/dist/components/helpers.mjs +1 -1
  12. package/dist/components/helpers.mjs.map +1 -1
  13. package/dist/components/index.cjs +8 -4
  14. package/dist/components/index.d.cts +4 -2
  15. package/dist/components/index.d.mts +4 -2
  16. package/dist/components/index.mjs +4 -2
  17. package/dist/components/options-parser-logic.cjs +68 -48
  18. package/dist/components/options-parser-logic.cjs.map +1 -1
  19. package/dist/components/options-parser-logic.d.cts.map +1 -1
  20. package/dist/components/options-parser-logic.d.mts.map +1 -1
  21. package/dist/components/options-parser-logic.mjs +68 -48
  22. package/dist/components/options-parser-logic.mjs.map +1 -1
  23. package/dist/components/spawn-builtin.cjs +656 -0
  24. package/dist/components/spawn-builtin.cjs.map +1 -0
  25. package/dist/components/spawn-builtin.d.cts +12 -0
  26. package/dist/components/spawn-builtin.d.cts.map +1 -0
  27. package/dist/components/spawn-builtin.d.mts +12 -0
  28. package/dist/components/spawn-builtin.d.mts.map +1 -0
  29. package/dist/components/spawn-builtin.mjs +653 -0
  30. package/dist/components/spawn-builtin.mjs.map +1 -0
  31. package/dist/components/state-builtin.cjs +545 -0
  32. package/dist/components/state-builtin.cjs.map +1 -0
  33. package/dist/components/state-builtin.d.cts +18 -0
  34. package/dist/components/state-builtin.d.cts.map +1 -0
  35. package/dist/components/state-builtin.d.mts +18 -0
  36. package/dist/components/state-builtin.d.mts.map +1 -0
  37. package/dist/components/state-builtin.mjs +539 -0
  38. package/dist/components/state-builtin.mjs.map +1 -0
  39. package/dist/components/utils-builtin.cjs +15 -509
  40. package/dist/components/utils-builtin.cjs.map +1 -1
  41. package/dist/components/utils-builtin.d.cts +1 -10
  42. package/dist/components/utils-builtin.d.cts.map +1 -1
  43. package/dist/components/utils-builtin.d.mts +1 -10
  44. package/dist/components/utils-builtin.d.mts.map +1 -1
  45. package/dist/components/utils-builtin.mjs +17 -508
  46. package/dist/components/utils-builtin.mjs.map +1 -1
  47. package/dist/config.cjs.map +1 -1
  48. package/dist/config.mjs.map +1 -1
  49. package/dist/contexts/options.cjs +9 -9
  50. package/dist/contexts/options.cjs.map +1 -1
  51. package/dist/contexts/options.d.cts +2 -2
  52. package/dist/contexts/options.d.cts.map +1 -1
  53. package/dist/contexts/options.d.mts +2 -2
  54. package/dist/contexts/options.d.mts.map +1 -1
  55. package/dist/contexts/options.mjs +9 -9
  56. package/dist/contexts/options.mjs.map +1 -1
  57. package/dist/index.cjs +2 -10
  58. package/dist/index.d.cts +1 -2
  59. package/dist/index.d.mts +1 -2
  60. package/dist/index.mjs +1 -7
  61. package/dist/plugin.cjs +17 -32
  62. package/dist/plugin.cjs.map +1 -1
  63. package/dist/plugin.d.cts +1 -1
  64. package/dist/plugin.d.cts.map +1 -1
  65. package/dist/plugin.d.mts +1 -1
  66. package/dist/plugin.d.mts.map +1 -1
  67. package/dist/plugin.mjs +16 -30
  68. package/dist/plugin.mjs.map +1 -1
  69. package/dist/resolver/resolve.cjs +1 -1
  70. package/dist/resolver/resolve.cjs.map +1 -1
  71. package/dist/resolver/resolve.mjs +1 -1
  72. package/dist/resolver/resolve.mjs.map +1 -1
  73. package/dist/types/config.cjs +3 -1
  74. package/dist/types/config.cjs.map +1 -1
  75. package/dist/types/config.d.cts +1 -1
  76. package/dist/types/config.d.cts.map +1 -1
  77. package/dist/types/config.d.mts +1 -1
  78. package/dist/types/config.d.mts.map +1 -1
  79. package/dist/types/config.mjs +3 -1
  80. package/dist/types/config.mjs.map +1 -1
  81. package/dist/types/env.cjs +2 -1
  82. package/dist/types/env.cjs.map +1 -1
  83. package/dist/types/env.d.cts +15 -0
  84. package/dist/types/env.d.cts.map +1 -1
  85. package/dist/types/env.d.mts +15 -0
  86. package/dist/types/env.d.mts.map +1 -1
  87. package/dist/types/env.mjs +2 -1
  88. package/dist/types/env.mjs.map +1 -1
  89. package/dist/types/index.cjs +0 -2
  90. package/dist/types/index.d.cts +1 -2
  91. package/dist/types/index.d.mts +1 -2
  92. package/dist/types/index.mjs +1 -2
  93. package/package.json +49 -35
  94. package/dist/index.cjs.map +0 -1
  95. package/dist/index.mjs.map +0 -1
  96. package/dist/types/runtime.cjs +0 -13
  97. package/dist/types/runtime.cjs.map +0 -1
  98. package/dist/types/runtime.d.cts +0 -14
  99. package/dist/types/runtime.d.cts.map +0 -1
  100. package/dist/types/runtime.d.mts +0 -14
  101. package/dist/types/runtime.d.mts.map +0 -1
  102. package/dist/types/runtime.mjs +0 -11
  103. package/dist/types/runtime.mjs.map +0 -1
@@ -545,407 +545,6 @@ function HyperlinkSupportUtilities() {
545
545
  ];
546
546
  }
547
547
  /**
548
- * Generates utilities for detecting terminal color support.
549
- */
550
- function ArgsUtilities() {
551
- return [
552
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
553
- heading: "Retrieves the command-line arguments from Deno or Node.js environments.",
554
- get children() {
555
- return [
556
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: "This function is only intended for internal use. Please use `useArgs()` instead." }),
557
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
558
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocInternal, {}),
559
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
560
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "An array of command-line arguments from Deno or Node.js environments." })
561
- ];
562
- }
563
- }),
564
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
565
- "export": true,
566
- name: "getArgs",
567
- returnType: "string[]",
568
- children: _alloy_js_core.code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`
569
- }),
570
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
571
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
572
- heading: "Checks if a specific flag is present in the command-line arguments.",
573
- get children() {
574
- return [
575
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
576
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
577
- name: "flag",
578
- children: "The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\"."
579
- }),
580
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
581
- name: "argv",
582
- children: "The command-line arguments to check against. Defaults to global Deno args or process args."
583
- }),
584
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "True if the flag is present, false otherwise." })
585
- ];
586
- }
587
- }),
588
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
589
- "export": true,
590
- name: "hasFlag",
591
- parameters: [{
592
- name: "flag",
593
- type: "string | string[]"
594
- }, {
595
- name: "argv",
596
- type: "string[]",
597
- default: "useArgs()"
598
- }],
599
- get children() {
600
- return [
601
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
602
- "const": true,
603
- name: "position",
604
- type: "number",
605
- initializer: _alloy_js_core.code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {
606
- const pos = argv.findIndex(arg => (f.startsWith("-") ? "" : (f.length === 1 ? "-" : "--") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? "-" : "--") + f + "="));
607
- return pos !== -1 ? pos : ret;
608
- }, -1);`
609
- }),
610
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
611
- _alloy_js_core.code`return position !== -1 && argv.indexOf("--") === -1 || position < argv.indexOf("--");`
612
- ];
613
- }
614
- }),
615
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
616
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
617
- "export": true,
618
- name: "isHelp",
619
- type: "boolean",
620
- initializer: _alloy_js_core.code` !isCI && hasFlag(["help", "h", "?"]); `
621
- })
622
- ];
623
- }
624
- /**
625
- * Generates the `spawn` function declaration, which is a cross-platform utility for spawning child processes with proper color support and environment variable handling.
626
- */
627
- function SpawnFunctionDeclaration() {
628
- return [
629
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
630
- async: true,
631
- name: "resolveCommand",
632
- parameters: [
633
- {
634
- name: "command",
635
- type: "string"
636
- },
637
- {
638
- name: "options",
639
- type: "Record<string, any>",
640
- default: "{}"
641
- },
642
- {
643
- name: "pathExt",
644
- type: "string",
645
- default: "process.env.PATHEXT || [\".EXE\", \".CMD\", \".BAT\", \".COM\"].join(delimiter)"
646
- }
647
- ],
648
- children: _alloy_js_core.code`const env = options.env || process.env;
649
- const cwd = process.cwd();
650
- if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {
651
- try {
652
- process.chdir(options.cwd);
653
- } catch (err) {
654
- // Do nothing
655
- }
656
- }
657
-
658
- let resolved;
659
- try {
660
- let extensions = [""];
661
- if (isWindows) {
662
- extensions = pathExt.split(delimiter).flatMap((item) => [item, item.toLowerCase()]);
663
- if (command.includes(".") && extensions[0] !== "") {
664
- extensions.unshift("");
665
- }
666
- }
667
-
668
- for (const envPart of (command.match(new RegExp(\`[\${posix.sep}\${sep === posix.sep ? "" : sep}]\`.replace(/(\\\\)/g, "\\\\$1"))))
669
- ? [...(isWindows ? [process.cwd()] : []), ...(process.env.PATH || "").split(delimiter)]
670
- : [""]
671
- ) {
672
- 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)}\`;
673
- for (const extension of extensions) {
674
- if (isWindows) {
675
- const filePath = part + extension;
676
- if ((await stat(filePath)).isFile() && extensions.some((ext) => filePath.substring(filePath.length - ext.length).toLowerCase() === ext.toLowerCase())) {
677
- resolved = filePath;
678
- break;
679
- }
680
- } else {
681
- const file = await stat(part + extension);
682
- if (file.isFile() && (file.mode & 0o111) !== 0) {
683
- resolved = part + extension;
684
- break;
685
- }
686
- }
687
- }
688
- }
689
- } catch (err) {
690
- // Do nothing
691
- } finally {
692
- if (!!options.cwd && process.chdir !== undefined && !(process.chdir as any).disabled) {
693
- process.chdir(cwd);
694
- }
695
- }
696
-
697
-
698
- if (resolved) {
699
- resolved = resolve(
700
- options.cwd ? options.cwd : "",
701
- resolved
702
- );
703
- }
704
-
705
- return resolved; `
706
- }),
707
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
708
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
709
- name: "SpawnBaseOptions",
710
- doc: "Options for the `spawn` handler function.",
711
- get children() {
712
- return [
713
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
714
- name: "stdout",
715
- optional: true,
716
- type: "(data: string) => void",
717
- doc: "The writable stream to use for prompt output, defaults to process.stdout"
718
- }),
719
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
720
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
721
- name: "stderr",
722
- optional: true,
723
- type: "(data: string) => void",
724
- doc: "The writable stream to use for prompt error output, defaults to process.stderr"
725
- }),
726
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
727
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
728
- name: "rejectOnError",
729
- optional: true,
730
- type: "boolean",
731
- doc: "Whether to reject the promise on error. Defaults to false."
732
- }),
733
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
734
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
735
- name: "file",
736
- optional: true,
737
- type: "string",
738
- doc: "The file to execute."
739
- }),
740
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
741
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
742
- name: "shell",
743
- optional: true,
744
- type: "boolean | string",
745
- 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."
746
- }),
747
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
748
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
749
- name: "forceShell",
750
- optional: true,
751
- type: "boolean",
752
- doc: "If true, forces the command to run inside of a shell, even if the command is a file."
753
- })
754
- ];
755
- }
756
- }),
757
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
758
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeDeclaration, {
759
- "export": true,
760
- name: "SpawnOptions",
761
- children: _alloy_js_core.code`SpawnBaseOptions & Parameters<typeof _spawn>[1]`
762
- }),
763
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
764
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
765
- heading: "A function to spawn child processes with proper color support and environment variable handling.",
766
- get children() {
767
- return [
768
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
769
- name: "command",
770
- children: `The command to execute.`
771
- }),
772
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
773
- name: "args",
774
- children: `The command-line arguments to pass to the command. Defaults to an empty array.`
775
- }),
776
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
777
- name: "options",
778
- children: `Additional options for spawning the process, such as the current working directory (\`cwd\`).`
779
- }),
780
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The result of the spawned process.` })
781
- ];
782
- }
783
- }),
784
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
785
- "export": true,
786
- async: true,
787
- name: "spawn",
788
- parameters: [
789
- {
790
- name: "command",
791
- type: "string"
792
- },
793
- {
794
- name: "args",
795
- type: "string[] | SpawnOptions",
796
- default: "{} as SpawnOptions"
797
- },
798
- {
799
- name: "options",
800
- type: "SpawnOptions",
801
- default: "{} as SpawnOptions"
802
- }
803
- ],
804
- children: _alloy_js_core.code`const normalized = {
805
- command,
806
- args: [] as string[],
807
- options: options as SpawnOptions | any,
808
- file: undefined as string | undefined,
809
- original: {
810
- command,
811
- args,
812
- },
813
- };
814
-
815
- if (args) {
816
- if (Array.isArray(args)) {
817
- if (args.length > 0) {
818
- normalized.args = args.slice(0);
819
- }
820
- } else {
821
- normalized.options = { ...args } as SpawnOptions | any;
822
- normalized.args = [];
823
- }
824
- }
825
-
826
- if (!normalized.options.shell && isWindows) {
827
- normalized.file = (await resolveCommand(normalized.command, normalized.options)) || (await resolveCommand(normalized.command, normalized.options, delimiter));
828
-
829
- let commandFile = normalized.file;
830
- if (normalized.file) {
831
- let shebang: string | undefined;
832
- const buffer = Buffer.alloc(150);
833
-
834
- try {
835
- const fd = openSync(normalized.file, "r");
836
- await promisify(read)(fd, buffer, 0, 150, 0);
837
- closeSync(fd);
838
- } catch (err) {
839
- // Do nothing
840
- }
841
-
842
- const matched = buffer.toString().match(/^#!(.*)/);
843
- if (matched) {
844
- const [path, argument] = matched[0].replace(/#! ?/, "").split(" ");
845
- const binary = path.split("/").pop();
846
- if (binary === "env") {
847
- shebang = argument;
848
- } else {
849
- shebang = argument ? \`\${binary} \${argument}\` : binary;
850
- }
851
- }
852
-
853
- if (shebang) {
854
- normalized.args.unshift(normalized.file);
855
- normalized.command = shebang;
856
-
857
- commandFile = await resolveCommand(normalized.command, normalized.options);
858
- }
859
- }
860
-
861
- if (commandFile && (normalized.options.forceShell || /\\.(?:com|exe)$/i.test(commandFile))) {
862
- normalized.command = normalize(normalized.command).replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1");
863
-
864
- normalized.args = ["/d", "/s", "/c", \`"\${normalized.command} \${normalized.args.map(arg =>
865
- \`\${arg}\`.replace(/(?=(\\\\+?)?)\\1"/g, "$1$1\\"").replace(/(?=(\\\\+?)?)\\1$/, "$1$1")
866
- ).map(arg =>
867
- \`"\${arg}"\`.replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1")
868
- ).map(arg =>
869
- /node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i.test(commandFile) ? arg.replace(/([()\\][%!^"\`<>&|;, *?])/g, "^$1") : arg
870
- ).join(" ")}"\`];
871
- normalized.command = process.env.comspec || "cmd.exe";
872
- normalized.options.windowsVerbatimArguments = true;
873
- }
874
- }
875
-
876
- let stdout = "";
877
- let stderr = "";
878
-
879
- const child = _spawn(normalized.command, normalized.args, {
880
- cwd: process.cwd(),
881
- env: {
882
- ...process.env,
883
- FORCE_COLOR: isColorSupported ? "1" : "0",
884
- },
885
- ...normalized.options,
886
- }) as ReturnType<typeof _spawn>;
887
-
888
- if (isWindows) {
889
- const emit = child.emit;
890
- child.emit = (eventName: string | symbol, ...eventArgs: any[]) => {
891
- if (eventName === "exit") {
892
- let err: Error | null = null;
893
- if (eventArgs[0] === 1 && !normalized.file) {
894
- err = Object.assign(new Error(\`spawn \${normalized.original.command} ENOENT\`), {
895
- code: "ENOENT",
896
- errno: "ENOENT",
897
- syscall: \`spawn \${normalized.original.command}\`,
898
- path: normalized.original.command,
899
- spawnargs: normalized.original.args,
900
- });
901
- }
902
-
903
- if (err) {
904
- return emit.call(child, "error", err);
905
- }
906
- }
907
-
908
- return emit.apply(child, [eventName, ...eventArgs]);
909
- };
910
- }
911
-
912
- return new Promise((resolve, reject) => {
913
- if (normalized.options.stdin !== undefined) {
914
- child.stdin?.write(normalized.options.stdin);
915
- }
916
-
917
- child.stdin?.end();
918
-
919
- child.stdout?.on("data", data => {
920
- stdout += data;
921
- if (normalized.options.stdout) {
922
- normalized.options.stdout(data);
923
- }
924
- });
925
-
926
- child.stderr?.on("data", data => {
927
- stderr += data;
928
- if (normalized.options.stderr) {
929
- normalized.options.stderr(data);
930
- }
931
- });
932
-
933
- if (normalized.options.rejectOnError) {
934
- child.addListener("error", reject);
935
- }
936
-
937
- child.on("close", code => {
938
- if (code !== 0 && normalized.options.rejectOnError) {
939
- reject(stderr);
940
- } else {
941
- resolve({ stdout, stderr });
942
- }
943
- });
944
- }); `
945
- })
946
- ];
947
- }
948
- /**
949
548
  * Generates the `resolveModule` function declaration, which is a utility for resolving file paths across different platforms.
950
549
  */
951
550
  function ResolveModuleFunctionDeclaration() {
@@ -1506,7 +1105,7 @@ function ResolveModuleFunctionDeclaration() {
1506
1105
 
1507
1106
  if (!validPackageName) {
1508
1107
  const err = new Error(
1509
- \`Invalid module "\${specifier}" is not a valid package name imported from \${fileURLToPath(base)}\`
1108
+ \`Invalid module \\\`\${specifier}\\\` is not a valid package name imported from \${fileURLToPath(base)}\`
1510
1109
  );
1511
1110
  (err as any).code = "ERR_INVALID_MODULE_SPECIFIER";
1512
1111
  throw err;
@@ -1607,10 +1206,9 @@ function ResolveModuleFunctionDeclaration() {
1607
1206
  return new URL(packageSubpath, packageJsonUrl);
1608
1207
  } while (packageJsonPath.length !== lastPath!.length);
1609
1208
 
1610
- const err = new Error(
1611
- \`Cannot find package '\${packageName}' imported from \${fileURLToPath(base)}\`
1612
- );
1209
+ const err = new Error(\`Cannot find package \\\`\${packageName}\\\`\`);
1613
1210
  (err as any).code = "ERR_MODULE_NOT_FOUND";
1211
+
1614
1212
  throw err;`
1615
1213
  }),
1616
1214
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
@@ -1626,9 +1224,10 @@ function ResolveModuleFunctionDeclaration() {
1626
1224
  returnType: "URL",
1627
1225
  children: _alloy_js_core.code`if (/%2f|%5c/i.test(resolved.pathname)) {
1628
1226
  const err = new Error(
1629
- \`Invalid module "\${resolved.pathname}" must not include encoded "/" or "\\\\" characters imported from \${fileURLToPath(base)}\`
1227
+ \`Invalid module \\\`\${resolved.pathname}\\\` must not include encoded "/" or "\\\\" characters imported from \${fileURLToPath(base)}\`
1630
1228
  );
1631
1229
  (err as any).code = "ERR_INVALID_MODULE_SPECIFIER";
1230
+
1632
1231
  throw err;
1633
1232
  }
1634
1233
 
@@ -1641,7 +1240,7 @@ function ResolveModuleFunctionDeclaration() {
1641
1240
 
1642
1241
  if (stat && stat.isDirectory()) {
1643
1242
  const err = new Error(
1644
- \`Directory import '\${filePath}' is not supported resolving ES modules imported from \${fileURLToPath(base)}\`
1243
+ \`Directory import \\\`\${filePath}\\\` is not supported resolving ES modules imported from \${fileURLToPath(base)}\`
1645
1244
  );
1646
1245
  (err as any).code = "ERR_UNSUPPORTED_DIR_IMPORT";
1647
1246
  throw err;
@@ -1649,7 +1248,7 @@ function ResolveModuleFunctionDeclaration() {
1649
1248
 
1650
1249
  if (!stat || !stat.isFile()) {
1651
1250
  const err = new Error(
1652
- \`Cannot find module '\${filePath}' imported from \${fileURLToPath(base)}\`
1251
+ \`Cannot find module \\\`\${filePath}\\\` imported from \${fileURLToPath(base)}\`
1653
1252
  );
1654
1253
  (err as any).code = "ERR_MODULE_NOT_FOUND";
1655
1254
  throw err;
@@ -1694,7 +1293,7 @@ function ResolveModuleFunctionDeclaration() {
1694
1293
  resolved = new URL(specifier, base);
1695
1294
  } catch (error_: any) {
1696
1295
  const err = new Error(
1697
- \`Failed to resolve module specifier "\${specifier}" from "\${base}": Invalid relative URL or base scheme is not hierarchical.\`
1296
+ \`Failed to resolve module specifier \\\`\${specifier}\\\` from "\${base}": Invalid relative URL or base scheme is not hierarchical.\`
1698
1297
  );
1699
1298
  err.cause = error_;
1700
1299
  throw err;
@@ -1753,7 +1352,7 @@ function ResolveModuleFunctionDeclaration() {
1753
1352
 
1754
1353
  if (!resolved) {
1755
1354
  const err = new Error(
1756
- \`Package import specifier "\${specifier}" is not defined in package imported from \${fileURLToPath(base)}\`
1355
+ \`Package import specifier \\\`\${specifier}\\\` is not defined in package imported from \${fileURLToPath(base)}\`
1757
1356
  );
1758
1357
  (err as any).code = "ERR_PACKAGE_IMPORT_NOT_DEFINED";
1759
1358
  throw err;
@@ -1825,6 +1424,7 @@ function ResolveModuleFunctionDeclaration() {
1825
1424
  }),
1826
1425
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
1827
1426
  async: true,
1427
+ "export": true,
1828
1428
  name: "resolveModule",
1829
1429
  parameters: [{
1830
1430
  name: "specifier",
@@ -1925,9 +1525,10 @@ function ResolveModuleFunctionDeclaration() {
1925
1525
 
1926
1526
  if (!resolved) {
1927
1527
  const err = new Error(
1928
- \`Cannot find module \${specifier} imported from \${base.href}\`
1528
+ \`Cannot find module \\\`\${specifier}\\\`\`
1929
1529
  );
1930
1530
  (err as any).code = "ERR_MODULE_NOT_FOUND";
1531
+
1931
1532
  throw err;
1932
1533
  }
1933
1534
 
@@ -1937,88 +1538,6 @@ function ResolveModuleFunctionDeclaration() {
1937
1538
  })
1938
1539
  ];
1939
1540
  }
1940
- function ContextUtilities() {
1941
- return _alloy_js_core.code`
1942
- /**
1943
- * The global Shell Shock - Application context instance.
1944
- *
1945
- * @internal
1946
- */
1947
- export let internal_appContext = new AsyncLocalStorage<Map<string, any>>();
1948
-
1949
- /**
1950
- * Get the Shell Shock - Application context for the current application.
1951
- *
1952
- * @param options - The options to use when getting the context.
1953
- * @returns The Shell Shock - Application context for the current application or undefined if the context is not available.
1954
- */
1955
- export function useApp(): Map<string, any> | undefined {
1956
- return internal_appContext.getStore();
1957
- }
1958
-
1959
- /**
1960
- * A utility hook function to get the command-line arguments from the application context.
1961
- *
1962
- * @returns An array of command-line arguments from the application context.
1963
- * @throws If the application context is not available.
1964
- */
1965
- export function useArgs(): string[] {
1966
- return useApp()?.get("args") ?? getArgs();
1967
- }
1968
-
1969
- /**
1970
- * The context object for the current command execution, containing the command path and segments.
1971
- */
1972
- export interface CommandContext {
1973
- path: string;
1974
- segments: string[];
1975
- }
1976
-
1977
- /**
1978
- * The global Shell Shock - Command context instance.
1979
- *
1980
- * @internal
1981
- */
1982
- export let internal_commandContext = new AsyncLocalStorage<CommandContext>();
1983
-
1984
- /**
1985
- * Get the Shell Shock - Command context for the current application.
1986
- *
1987
- * @param options - The options to use when getting the context.
1988
- * @returns The Shell Shock - Command context for the current application.
1989
- * @throws If the Shell Shock - Command context is not available.
1990
- */
1991
- export function useCommand(): CommandContext {
1992
- const result = internal_commandContext.getStore();
1993
- if (!result) {
1994
- throw new Error(
1995
- \`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\`
1996
- );
1997
- }
1998
- return result;
1999
- }
2000
-
2001
- /**
2002
- * A utility hook function to get the individual segments of the current command path.
2003
- *
2004
- * @returns An array of command path segments.
2005
- * @throws If the command context is not available.
2006
- */
2007
- export function useSegments(): string[] {
2008
- return useCommand().segments;
2009
- }
2010
-
2011
- /**
2012
- * A utility hook function to get the full command path as a string.
2013
- *
2014
- * @returns The full command path as a string.
2015
- * @throws If the command context is not available.
2016
- */
2017
- export function usePath(): string {
2018
- return useCommand().path;
2019
- }
2020
- `;
2021
- }
2022
1541
  /**
2023
1542
  * A built-in utilities module for Shell Shock.
2024
1543
  */
@@ -2053,12 +1572,7 @@ function UtilsBuiltin(props) {
2053
1572
  "node:fs/promises": ["stat"],
2054
1573
  "node:util": ["promisify"],
2055
1574
  "node:url": ["fileURLToPath", "pathToFileURL"],
2056
- "node:module": ["builtinModules"],
2057
- "node:child_process": [{
2058
- name: "spawn",
2059
- alias: "_spawn"
2060
- }],
2061
- "node:async_hooks": ["AsyncLocalStorage"]
1575
+ "node:module": ["builtinModules"]
2062
1576
  });
2063
1577
  },
2064
1578
  get builtinImports() {
@@ -2075,7 +1589,8 @@ function UtilsBuiltin(props) {
2075
1589
  "isWindows",
2076
1590
  "isDevelopment",
2077
1591
  "isDebug"
2078
- ]
1592
+ ],
1593
+ state: ["hasFlag"]
2079
1594
  });
2080
1595
  },
2081
1596
  get children() {
@@ -2100,18 +1615,12 @@ function UtilsBuiltin(props) {
2100
1615
  children: _alloy_js_core.code`return new Promise((resolve) => setTimeout(resolve, durationMs)); `
2101
1616
  }),
2102
1617
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2103
- (0, _alloy_js_core_jsx_runtime.createComponent)(ContextUtilities, {}),
2104
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2105
- (0, _alloy_js_core_jsx_runtime.createComponent)(ArgsUtilities, {}),
2106
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2107
1618
  (0, _alloy_js_core_jsx_runtime.createComponent)(EnvSupportUtilities, {}),
2108
1619
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2109
1620
  (0, _alloy_js_core_jsx_runtime.createComponent)(HyperlinkSupportUtilities, {}),
2110
1621
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2111
1622
  (0, _alloy_js_core_jsx_runtime.createComponent)(ColorSupportUtilities, {}),
2112
1623
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2113
- (0, _alloy_js_core_jsx_runtime.createComponent)(SpawnFunctionDeclaration, {}),
2114
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2115
1624
  (0, _alloy_js_core_jsx_runtime.createComponent)(ResolveModuleFunctionDeclaration, {}),
2116
1625
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2117
1626
  (0, _alloy_js_core_jsx_runtime.createComponent)(FindSuggestionsDeclaration, {}),
@@ -2128,13 +1637,10 @@ function UtilsBuiltin(props) {
2128
1637
  }
2129
1638
 
2130
1639
  //#endregion
2131
- exports.ArgsUtilities = ArgsUtilities;
2132
1640
  exports.ColorSupportUtilities = ColorSupportUtilities;
2133
- exports.ContextUtilities = ContextUtilities;
2134
1641
  exports.EnvSupportUtilities = EnvSupportUtilities;
2135
1642
  exports.FindSuggestionsDeclaration = FindSuggestionsDeclaration;
2136
1643
  exports.HyperlinkSupportUtilities = HyperlinkSupportUtilities;
2137
1644
  exports.ResolveModuleFunctionDeclaration = ResolveModuleFunctionDeclaration;
2138
- exports.SpawnFunctionDeclaration = SpawnFunctionDeclaration;
2139
1645
  exports.UtilsBuiltin = UtilsBuiltin;
2140
1646
  //# sourceMappingURL=utils-builtin.cjs.map