@shell-shock/core 0.17.8 → 0.17.10

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 (141) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/api.cjs +148 -1
  3. package/dist/api.d.cts +6 -6
  4. package/dist/api.d.cts.map +1 -1
  5. package/dist/api.d.mts +6 -6
  6. package/dist/api.d.mts.map +1 -1
  7. package/dist/api.mjs +145 -1
  8. package/dist/api.mjs.map +1 -1
  9. package/dist/components/command-validation-logic.cjs +292 -1
  10. package/dist/components/command-validation-logic.mjs +289 -1
  11. package/dist/components/command-validation-logic.mjs.map +1 -1
  12. package/dist/components/docs.cjs +265 -1
  13. package/dist/components/docs.mjs +256 -1
  14. package/dist/components/docs.mjs.map +1 -1
  15. package/dist/components/exec-builtin.cjs +429 -13
  16. package/dist/components/exec-builtin.mjs +425 -13
  17. package/dist/components/exec-builtin.mjs.map +1 -1
  18. package/dist/components/helpers.cjs +120 -1
  19. package/dist/components/helpers.mjs +112 -1
  20. package/dist/components/helpers.mjs.map +1 -1
  21. package/dist/components/index.cjs +58 -1
  22. package/dist/components/index.mjs +10 -1
  23. package/dist/components/options-parser-logic.cjs +960 -5
  24. package/dist/components/options-parser-logic.d.cts +1 -1
  25. package/dist/components/options-parser-logic.mjs +945 -5
  26. package/dist/components/options-parser-logic.mjs.map +1 -1
  27. package/dist/components/state-builtin.cjs +629 -8
  28. package/dist/components/state-builtin.mjs +622 -8
  29. package/dist/components/state-builtin.mjs.map +1 -1
  30. package/dist/components/usage.cjs +117 -1
  31. package/dist/components/usage.mjs +114 -1
  32. package/dist/components/usage.mjs.map +1 -1
  33. package/dist/components/utils-builtin.cjs +838 -33
  34. package/dist/components/utils-builtin.mjs +828 -33
  35. package/dist/components/utils-builtin.mjs.map +1 -1
  36. package/dist/config.cjs +31 -1
  37. package/dist/config.mjs +29 -1
  38. package/dist/config.mjs.map +1 -1
  39. package/dist/contexts/command.cjs +26 -1
  40. package/dist/contexts/command.mjs +23 -1
  41. package/dist/contexts/command.mjs.map +1 -1
  42. package/dist/contexts/index.cjs +9 -1
  43. package/dist/contexts/index.mjs +4 -1
  44. package/dist/contexts/options.cjs +63 -1
  45. package/dist/contexts/options.mjs +58 -1
  46. package/dist/contexts/options.mjs.map +1 -1
  47. package/dist/helpers/automd.cjs +71 -1
  48. package/dist/helpers/automd.mjs +70 -1
  49. package/dist/helpers/automd.mjs.map +1 -1
  50. package/dist/helpers/docs-helpers.cjs +23 -1
  51. package/dist/helpers/docs-helpers.mjs +22 -1
  52. package/dist/helpers/docs-helpers.mjs.map +1 -1
  53. package/dist/helpers/paths.cjs +137 -1
  54. package/dist/helpers/paths.mjs +133 -1
  55. package/dist/helpers/paths.mjs.map +1 -1
  56. package/dist/helpers/persistence.cjs +115 -1
  57. package/dist/helpers/persistence.mjs +112 -1
  58. package/dist/helpers/persistence.mjs.map +1 -1
  59. package/dist/helpers/update-package-json.cjs +65 -1
  60. package/dist/helpers/update-package-json.mjs +63 -1
  61. package/dist/helpers/update-package-json.mjs.map +1 -1
  62. package/dist/helpers/utilities.cjs +95 -1
  63. package/dist/helpers/utilities.mjs +93 -1
  64. package/dist/helpers/utilities.mjs.map +1 -1
  65. package/dist/helpers/validations.cjs +71 -1
  66. package/dist/helpers/validations.mjs +71 -1
  67. package/dist/helpers/validations.mjs.map +1 -1
  68. package/dist/index.cjs +53 -1
  69. package/dist/index.d.cts +3 -3
  70. package/dist/index.d.mts +3 -3
  71. package/dist/index.mjs +7 -1
  72. package/dist/plugin-utils/compute-bin.cjs +50 -1
  73. package/dist/plugin-utils/compute-bin.mjs +49 -1
  74. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  75. package/dist/plugin-utils/context-helpers.cjs +231 -1
  76. package/dist/plugin-utils/context-helpers.mjs +221 -1
  77. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  78. package/dist/plugin-utils/deepkit.cjs +71 -1
  79. package/dist/plugin-utils/deepkit.mjs +69 -1
  80. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  81. package/dist/plugin-utils/description-helpers.cjs +111 -2
  82. package/dist/plugin-utils/description-helpers.mjs +107 -2
  83. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  84. package/dist/plugin-utils/get-command-tree.cjs +117 -1
  85. package/dist/plugin-utils/get-command-tree.mjs +114 -1
  86. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  87. package/dist/plugin-utils/index.cjs +39 -1
  88. package/dist/plugin-utils/index.mjs +10 -1
  89. package/dist/plugin-utils/reflect.cjs +52 -1
  90. package/dist/plugin-utils/reflect.mjs +52 -1
  91. package/dist/plugin-utils/reflect.mjs.map +1 -1
  92. package/dist/plugin-utils/traverse-command-tree.cjs +64 -1
  93. package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
  94. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  95. package/dist/plugin-utils/type-checks.cjs +93 -1
  96. package/dist/plugin-utils/type-checks.mjs +88 -1
  97. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  98. package/dist/plugin.cjs +471 -4
  99. package/dist/plugin.d.cts.map +1 -1
  100. package/dist/plugin.d.mts.map +1 -1
  101. package/dist/plugin.mjs +465 -4
  102. package/dist/plugin.mjs.map +1 -1
  103. package/dist/resolver/deepkit.cjs +135 -1
  104. package/dist/resolver/deepkit.mjs +134 -1
  105. package/dist/resolver/deepkit.mjs.map +1 -1
  106. package/dist/resolver/helpers.cjs +173 -1
  107. package/dist/resolver/helpers.mjs +168 -1
  108. package/dist/resolver/helpers.mjs.map +1 -1
  109. package/dist/resolver/module.cjs +145 -1
  110. package/dist/resolver/module.mjs +144 -1
  111. package/dist/resolver/module.mjs.map +1 -1
  112. package/dist/resolver/resolve.cjs +222 -1
  113. package/dist/resolver/resolve.mjs +221 -1
  114. package/dist/resolver/resolve.mjs.map +1 -1
  115. package/dist/types/command.cjs +441 -1
  116. package/dist/types/command.d.cts +1 -1
  117. package/dist/types/command.d.mts +2 -2
  118. package/dist/types/command.mjs +405 -1
  119. package/dist/types/command.mjs.map +1 -1
  120. package/dist/types/config.cjs +134 -1
  121. package/dist/types/config.d.cts +10 -8
  122. package/dist/types/config.d.cts.map +1 -1
  123. package/dist/types/config.d.mts +10 -8
  124. package/dist/types/config.d.mts.map +1 -1
  125. package/dist/types/config.mjs +127 -1
  126. package/dist/types/config.mjs.map +1 -1
  127. package/dist/types/context.cjs +37 -1
  128. package/dist/types/context.mjs +34 -1
  129. package/dist/types/context.mjs.map +1 -1
  130. package/dist/types/env.cjs +52 -1
  131. package/dist/types/env.d.cts +1 -1
  132. package/dist/types/env.d.mts +1 -1
  133. package/dist/types/env.mjs +50 -1
  134. package/dist/types/env.mjs.map +1 -1
  135. package/dist/types/index.cjs +50 -1
  136. package/dist/types/index.d.cts +2 -2
  137. package/dist/types/index.d.mts +2 -2
  138. package/dist/types/index.mjs +6 -1
  139. package/dist/types/options.cjs +12 -1
  140. package/dist/types/options.mjs +10 -1
  141. package/package.json +22 -21
@@ -1,4 +1,82 @@
1
- import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";import{ReflectionKind as n}from"@powerlines/deepkit/vendor/type";import r from"defu";import{Show as i,code as a,splitProps as o}from"@alloy-js/core";import{Spacing as s}from"@powerlines/plugin-alloy/core/components/spacing";import{FunctionDeclaration as c,InterfaceDeclaration as l,InterfaceMember as u,VarDeclaration as d}from"@alloy-js/typescript";import{BuiltinFile as f}from"@powerlines/plugin-alloy/typescript/components/builtin-file";import{TSDoc as p,TSDocDefaultValue as m,TSDocParam as h,TSDocReturns as g}from"@powerlines/plugin-alloy/typescript/components/tsdoc";const _=[`T`,`K`,()=>v,()=>y,`Omit`,`b!b"e!!e!!ge!"o$#o##w%y`],v=[`T`,`K`,`Pick`,`l+e#!e"!fRb!b"Pde""N#!w#y`],y=[`T`,`U`,`Exclude`,`l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y`],b=[()=>_,`id`,`description`,`ExecBuiltinProps`,`P!P.".#Jo!#Mw$y`];function x(_){let[{children:v},y]=o(_,[`children`]);return e(f,t({id:`exec`,description:`A module to handle command execution in a Shell Shock application.`},y,{get imports(){return r(y.imports??{},{"node:path":[`basename`,`extname`,`dirname`,`join`],"node:fs":[`existsSync`],"node:child_process":[{name:`spawn`,alias:`_spawn`},`execFileSync`],"node:stream":[{name:`Stream`,default:!0,type:!0}]})},get builtinImports(){return r(y.builtinImports??{},{env:[`isWindows`,`env`]})},get children(){return[e(c,{name:`resolveCommandEnv`,parameters:[{name:`params`,type:`{ argv: string[]; env?: NodeJS.ProcessEnv; }`}],returnType:`NodeJS.ProcessEnv`,children:a`const argv = params.argv;
1
+ import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
3
+ import defu$1 from "defu";
4
+ import { Show, code, splitProps } from "@alloy-js/core";
5
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
+ import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
7
+ import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
8
+ import { TSDoc, TSDocDefaultValue, TSDocParam, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
9
+
10
+ //#region src/components/exec-builtin.tsx
11
+ const __ΩOmit = [
12
+ "T",
13
+ "K",
14
+ () => __ΩPick,
15
+ () => __ΩExclude,
16
+ "Omit",
17
+ "b!b\"e!!e!!ge!\"o$#o##w%y"
18
+ ];
19
+ const __ΩPick = [
20
+ "T",
21
+ "K",
22
+ "Pick",
23
+ "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
24
+ ];
25
+ const __ΩExclude = [
26
+ "T",
27
+ "U",
28
+ "Exclude",
29
+ "l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
30
+ ];
31
+ const __ΩExecBuiltinProps = [
32
+ () => __ΩOmit,
33
+ "id",
34
+ "description",
35
+ "ExecBuiltinProps",
36
+ "P!P.\".#Jo!#Mw$y"
37
+ ];
38
+ /**
39
+ * A built-in module for handling command execution in Shell Shock.
40
+ */
41
+ function ExecBuiltin(props) {
42
+ const [{ children }, rest] = splitProps(props, ["children"]);
43
+ return createComponent(BuiltinFile, mergeProps({
44
+ id: "exec",
45
+ description: "A module to handle command execution in a Shell Shock application."
46
+ }, rest, {
47
+ get imports() {
48
+ return defu$1(rest.imports ?? {}, {
49
+ "node:path": [
50
+ "basename",
51
+ "extname",
52
+ "dirname",
53
+ "join"
54
+ ],
55
+ "node:fs": ["existsSync"],
56
+ "node:child_process": [{
57
+ name: "spawn",
58
+ alias: "_spawn"
59
+ }, "execFileSync"],
60
+ "node:stream": [{
61
+ name: "Stream",
62
+ default: true,
63
+ type: true
64
+ }]
65
+ });
66
+ },
67
+ get builtinImports() {
68
+ return defu$1(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
69
+ },
70
+ get children() {
71
+ return [
72
+ createComponent(FunctionDeclaration, {
73
+ name: "resolveCommandEnv",
74
+ parameters: [{
75
+ name: "params",
76
+ type: "{ argv: string[]; env?: NodeJS.ProcessEnv; }"
77
+ }],
78
+ returnType: "NodeJS.ProcessEnv",
79
+ children: code`const argv = params.argv;
2
80
  const shouldSuppressNpmFund = (() => {
3
81
  const cmd = basename(argv[0] ?? "");
4
82
  if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
@@ -24,12 +102,32 @@ import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";imp
24
102
  result.NPM_CONFIG_FUND ??= "false";
25
103
  result.npm_config_fund ??= "false";
26
104
  }
27
- return result; `}),e(s,{}),e(c,{name:`isWindowsBatchCommand`,parameters:[{name:`resolvedCommand`,type:`string`}],returnType:`boolean`,children:a`if (!isWindows) {
105
+ return result; `
106
+ }),
107
+ createComponent(Spacing, {}),
108
+ createComponent(FunctionDeclaration, {
109
+ name: "isWindowsBatchCommand",
110
+ parameters: [{
111
+ name: "resolvedCommand",
112
+ type: "string"
113
+ }],
114
+ returnType: "boolean",
115
+ children: code`if (!isWindows) {
28
116
  return false;
29
117
  }
30
118
  const ext = extname(resolvedCommand).toLowerCase();
31
119
 
32
- return ext === ".cmd" || ext === ".bat"; `}),e(s,{}),e(c,{name:`escapeForCmdExe`,parameters:[{name:`arg`,type:`string`}],returnType:`string`,children:a`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
120
+ return ext === ".cmd" || ext === ".bat"; `
121
+ }),
122
+ createComponent(Spacing, {}),
123
+ createComponent(FunctionDeclaration, {
124
+ name: "escapeForCmdExe",
125
+ parameters: [{
126
+ name: "arg",
127
+ type: "string"
128
+ }],
129
+ returnType: "string",
130
+ children: code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
33
131
  throw new Error(
34
132
  \`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
35
133
  "Pass an explicit shell-wrapper argv at the call site instead."
@@ -38,9 +136,33 @@ import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";imp
38
136
  if (!arg.includes(" ") && !arg.includes('"')) {
39
137
  return arg;
40
138
  }
41
- return \`"\${arg.replace(/"/g, '""')}"\`; `}),e(s,{}),e(c,{name:`buildCmdExeCommandLine`,parameters:[{name:`resolvedCommand`,type:`string`},{name:`args`,type:`string[]`}],returnType:`string`,children:a`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
139
+ return \`"\${arg.replace(/"/g, '""')}"\`; `
140
+ }),
141
+ createComponent(Spacing, {}),
142
+ createComponent(FunctionDeclaration, {
143
+ name: "buildCmdExeCommandLine",
144
+ parameters: [{
145
+ name: "resolvedCommand",
146
+ type: "string"
147
+ }, {
148
+ name: "args",
149
+ type: "string[]"
150
+ }],
151
+ returnType: "string",
152
+ children: code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
42
153
  " "
43
- ); `}),e(s,{}),e(c,{name:`resolveNpmArgvForWindows`,doc:`On Windows, Node 18.20.2+ (CVE-2024-27980) rejects spawning .cmd/.bat directly without shell, causing EINVAL. Resolve npm/npx to node + cli script so we spawn node.exe instead of npm.cmd.`,parameters:[{name:`argv`,type:`string[]`}],returnType:`string[] | null`,children:a`if (!isWindows || argv.length === 0) {
154
+ ); `
155
+ }),
156
+ createComponent(Spacing, {}),
157
+ createComponent(FunctionDeclaration, {
158
+ name: "resolveNpmArgvForWindows",
159
+ doc: "On Windows, Node 18.20.2+ (CVE-2024-27980) rejects spawning .cmd/.bat directly without shell, causing EINVAL. Resolve npm/npx to node + cli script so we spawn node.exe instead of npm.cmd.",
160
+ parameters: [{
161
+ name: "argv",
162
+ type: "string[]"
163
+ }],
164
+ returnType: "string[] | null",
165
+ children: code`if (!isWindows || argv.length === 0) {
44
166
  return null;
45
167
  }
46
168
  const base = basename(argv[0] ?? "")
@@ -60,7 +182,18 @@ import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";imp
60
182
 
61
183
  return [shimmedCommand, ...argv.slice(1)];
62
184
  }
63
- return [process.execPath, cliPath, ...argv.slice(1)]; `}),e(s,{}),e(c,{name:`resolveCommand`,doc:`Resolves a command for Windows compatibility. On Windows, non-.exe commands (like pnpm, yarn) are resolved to .cmd; npm/npx are handled by resolveNpmArgvForWindows to avoid spawn EINVAL (no direct .cmd).`,parameters:[{name:`command`,type:`string`}],returnType:`string`,children:a`if (!isWindows) {
185
+ return [process.execPath, cliPath, ...argv.slice(1)]; `
186
+ }),
187
+ createComponent(Spacing, {}),
188
+ createComponent(FunctionDeclaration, {
189
+ name: "resolveCommand",
190
+ doc: "Resolves a command for Windows compatibility. On Windows, non-.exe commands (like pnpm, yarn) are resolved to .cmd; npm/npx are handled by resolveNpmArgvForWindows to avoid spawn EINVAL (no direct .cmd).",
191
+ parameters: [{
192
+ name: "command",
193
+ type: "string"
194
+ }],
195
+ returnType: "string",
196
+ children: code`if (!isWindows) {
64
197
  return command;
65
198
  }
66
199
  const base = basename(command).toLowerCase();
@@ -70,13 +203,33 @@ import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";imp
70
203
  if (["pnpm", "yarn"].includes(base)) {
71
204
  return \`\${command}.cmd\`;
72
205
  }
73
- return command; `}),e(s,{}),e(c,{name:`resolveCommandStdio`,parameters:[{name:`params`,type:`{ hasInput: boolean; preferInherit: boolean; }`}],returnType:`["pipe" | "inherit" | "ignore", "pipe", "pipe"]`,children:a`const stdin = params.hasInput
206
+ return command; `
207
+ }),
208
+ createComponent(Spacing, {}),
209
+ createComponent(FunctionDeclaration, {
210
+ name: "resolveCommandStdio",
211
+ parameters: [{
212
+ name: "params",
213
+ type: "{ hasInput: boolean; preferInherit: boolean; }"
214
+ }],
215
+ returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
216
+ children: code`const stdin = params.hasInput
74
217
  ? "pipe"
75
218
  : params.preferInherit
76
219
  ? "inherit"
77
220
  : "pipe";
78
221
 
79
- return [stdin, "pipe", "pipe"]; `}),e(s,{}),e(c,{name:`resolveProcessExitCode`,parameters:[{name:`params`,type:`{ explicitCode: number | null | undefined; childExitCode: number | null | undefined; resolvedSignal: NodeJS.Signals | null; usesWindowsExitCodeShim: boolean; timedOut: boolean; noOutputTimedOut: boolean; killIssuedByTimeout: boolean; }`}],returnType:`number | null`,children:a`return (
222
+ return [stdin, "pipe", "pipe"]; `
223
+ }),
224
+ createComponent(Spacing, {}),
225
+ createComponent(FunctionDeclaration, {
226
+ name: "resolveProcessExitCode",
227
+ parameters: [{
228
+ name: "params",
229
+ type: "{ explicitCode: number | null | undefined; childExitCode: number | null | undefined; resolvedSignal: NodeJS.Signals | null; usesWindowsExitCodeShim: boolean; timedOut: boolean; noOutputTimedOut: boolean; killIssuedByTimeout: boolean; }"
230
+ }],
231
+ returnType: "number | null",
232
+ children: code`return (
80
233
  params.explicitCode ??
81
234
  params.childExitCode ??
82
235
  (params.usesWindowsExitCodeShim &&
@@ -86,13 +239,187 @@ import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";imp
86
239
  !params.killIssuedByTimeout
87
240
  ? 0
88
241
  : null)
89
- ); `}),e(s,{}),e(c,{name:`shouldSpawnWithShell`,parameters:[{name:`params`,type:`{ resolvedCommand: string; platform: NodeJS.Platform; }`}],returnType:`boolean`,children:a`// SECURITY: never enable \`shell\` for argv-based execution.
242
+ ); `
243
+ }),
244
+ createComponent(Spacing, {}),
245
+ createComponent(FunctionDeclaration, {
246
+ name: "shouldSpawnWithShell",
247
+ parameters: [{
248
+ name: "params",
249
+ type: "{ resolvedCommand: string; platform: NodeJS.Platform; }"
250
+ }],
251
+ returnType: "boolean",
252
+ children: code`// SECURITY: never enable \`shell\` for argv-based execution.
90
253
  // \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
91
254
  // (like chat prompts passed as CLI args) into command-injection primitives.
92
255
  // If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
93
256
  // and validate/escape at the call site.
94
257
  void params;
95
- return false; `}),e(s,{}),e(p,{heading:`The result of a spawn operation.`}),e(l,{export:!0,name:`SpawnResult`,get children(){return[e(p,{heading:`The PID of the spawned child process, if available.`}),e(u,{name:`pid`,optional:!0,type:`number`}),e(s,{}),e(p,{heading:`The standard output produced by the child process.`}),e(u,{name:`stdout`,type:`string`}),e(s,{}),e(p,{heading:`The standard error produced by the child process.`}),e(u,{name:`stderr`,type:`string`}),e(s,{}),e(p,{heading:`The exit code of the child process, if available.`}),e(u,{name:`code`,type:`number | null`}),e(s,{}),e(p,{heading:`The signal that caused the child process to terminate, if it was killed by a signal.`}),e(u,{name:`signal`,type:`NodeJS.Signals | null`}),e(s,{}),e(p,{heading:`Whether the child process was killed.`}),e(u,{name:`killed`,type:`boolean`}),e(s,{}),e(p,{heading:`The reason for the child process termination.`}),e(u,{name:`termination`,type:a`"exit" | "timeout" | "no-output-timeout" | "signal"`}),e(s,{}),e(p,{heading:`Whether the child process timed out due to no output.`}),e(u,{name:`noOutputTimedOut`,optional:!0,type:`boolean`})]}}),e(s,{}),e(p,{heading:`Options for spawning a child process.`}),e(l,{export:!0,name:`SpawnOptions`,get children(){return[e(p,{heading:"The timeout in milliseconds for the spawn operation. If the process runs longer than this, it will be killed and the spawn promise will reject. This can also be provided as a number directly to the spawn function for convenience. Providing \\`-1\\` will disable the timeout.",get children(){return e(m,{get type(){return n.number},defaultValue:`300000`})}}),e(u,{name:`timeoutMs`,optional:!0,type:`number`}),e(s,{}),e(p,{heading:`The current working directory of the child process.`}),e(u,{name:`cwd`,optional:!0,type:`string`}),e(s,{}),e(p,{heading:`The input to be passed to the child process.`}),e(u,{name:`input`,optional:!0,type:`string`}),e(s,{}),e(p,{heading:`The environment variables for the child process.`}),e(u,{name:`env`,optional:!0,type:`NodeJS.ProcessEnv`}),e(s,{}),e(p,{heading:`Whether to pass arguments to the child process verbatim on Windows.`}),e(u,{name:`windowsVerbatimArguments`,optional:!0,type:`boolean`}),e(s,{}),e(p,{heading:`The timeout in milliseconds for the child process to produce output on stdout or stderr. If the process produces no output for this duration, it will be killed and the spawn promise will reject with a no-output-timeout termination reason.`}),e(u,{name:`noOutputTimeoutMs`,optional:!0,type:`number`})]}}),e(s,{}),e(d,{const:!0,name:`WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS`,initializer:a`250`}),e(s,{}),e(d,{const:!0,name:`WINDOWS_CLOSE_STATE_POLL_MS`,initializer:a`10`}),e(s,{}),e(p,{heading:`Spawns a child process with the given arguments and options, returning a promise that resolves with the result of the spawn operation.`,get children(){return[e(h,{name:`argv`,children:`The command and its arguments to spawn.`}),e(h,{name:`optionsOrTimeoutMs`,children:"The options for spawning the command, or a number representing the timeout in milliseconds. This allows for a convenient shorthand when only a timeout is needed. Providing `-1` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used."}),e(g,{children:`A promise that resolves with the result of the spawn operation, including stdout, stderr, exit code, signal, and termination reason.`})]}}),e(c,{export:!0,async:!0,name:`spawn`,parameters:[{name:`argv`,type:`string[]`},{name:`optionsOrTimeoutMs`,type:`number | SpawnOptions`,default:`300000`}],returnType:`Promise<SpawnResult>`,children:a`const options: SpawnOptions =
258
+ return false; `
259
+ }),
260
+ createComponent(Spacing, {}),
261
+ createComponent(TSDoc, { heading: "The result of a spawn operation." }),
262
+ createComponent(InterfaceDeclaration, {
263
+ "export": true,
264
+ name: "SpawnResult",
265
+ get children() {
266
+ return [
267
+ createComponent(TSDoc, { heading: "The PID of the spawned child process, if available." }),
268
+ createComponent(InterfaceMember, {
269
+ name: "pid",
270
+ optional: true,
271
+ type: "number"
272
+ }),
273
+ createComponent(Spacing, {}),
274
+ createComponent(TSDoc, { heading: "The standard output produced by the child process." }),
275
+ createComponent(InterfaceMember, {
276
+ name: "stdout",
277
+ type: "string"
278
+ }),
279
+ createComponent(Spacing, {}),
280
+ createComponent(TSDoc, { heading: "The standard error produced by the child process." }),
281
+ createComponent(InterfaceMember, {
282
+ name: "stderr",
283
+ type: "string"
284
+ }),
285
+ createComponent(Spacing, {}),
286
+ createComponent(TSDoc, { heading: "The exit code of the child process, if available." }),
287
+ createComponent(InterfaceMember, {
288
+ name: "code",
289
+ type: "number | null"
290
+ }),
291
+ createComponent(Spacing, {}),
292
+ createComponent(TSDoc, { heading: "The signal that caused the child process to terminate, if it was killed by a signal." }),
293
+ createComponent(InterfaceMember, {
294
+ name: "signal",
295
+ type: "NodeJS.Signals | null"
296
+ }),
297
+ createComponent(Spacing, {}),
298
+ createComponent(TSDoc, { heading: "Whether the child process was killed." }),
299
+ createComponent(InterfaceMember, {
300
+ name: "killed",
301
+ type: "boolean"
302
+ }),
303
+ createComponent(Spacing, {}),
304
+ createComponent(TSDoc, { heading: "The reason for the child process termination." }),
305
+ createComponent(InterfaceMember, {
306
+ name: "termination",
307
+ type: code`"exit" | "timeout" | "no-output-timeout" | "signal"`
308
+ }),
309
+ createComponent(Spacing, {}),
310
+ createComponent(TSDoc, { heading: "Whether the child process timed out due to no output." }),
311
+ createComponent(InterfaceMember, {
312
+ name: "noOutputTimedOut",
313
+ optional: true,
314
+ type: "boolean"
315
+ })
316
+ ];
317
+ }
318
+ }),
319
+ createComponent(Spacing, {}),
320
+ createComponent(TSDoc, { heading: "Options for spawning a child process." }),
321
+ createComponent(InterfaceDeclaration, {
322
+ "export": true,
323
+ name: "SpawnOptions",
324
+ get children() {
325
+ return [
326
+ createComponent(TSDoc, {
327
+ heading: "The timeout in milliseconds for the spawn operation. If the process runs longer than this, it will be killed and the spawn promise will reject. This can also be provided as a number directly to the spawn function for convenience. Providing \\`-1\\` will disable the timeout.",
328
+ get children() {
329
+ return createComponent(TSDocDefaultValue, {
330
+ get type() {
331
+ return ReflectionKind.number;
332
+ },
333
+ defaultValue: "300000"
334
+ });
335
+ }
336
+ }),
337
+ createComponent(InterfaceMember, {
338
+ name: "timeoutMs",
339
+ optional: true,
340
+ type: "number"
341
+ }),
342
+ createComponent(Spacing, {}),
343
+ createComponent(TSDoc, { heading: "The current working directory of the child process." }),
344
+ createComponent(InterfaceMember, {
345
+ name: "cwd",
346
+ optional: true,
347
+ type: "string"
348
+ }),
349
+ createComponent(Spacing, {}),
350
+ createComponent(TSDoc, { heading: "The input to be passed to the child process." }),
351
+ createComponent(InterfaceMember, {
352
+ name: "input",
353
+ optional: true,
354
+ type: "string"
355
+ }),
356
+ createComponent(Spacing, {}),
357
+ createComponent(TSDoc, { heading: "The environment variables for the child process." }),
358
+ createComponent(InterfaceMember, {
359
+ name: "env",
360
+ optional: true,
361
+ type: "NodeJS.ProcessEnv"
362
+ }),
363
+ createComponent(Spacing, {}),
364
+ createComponent(TSDoc, { heading: "Whether to pass arguments to the child process verbatim on Windows." }),
365
+ createComponent(InterfaceMember, {
366
+ name: "windowsVerbatimArguments",
367
+ optional: true,
368
+ type: "boolean"
369
+ }),
370
+ createComponent(Spacing, {}),
371
+ createComponent(TSDoc, { heading: "The timeout in milliseconds for the child process to produce output on stdout or stderr. If the process produces no output for this duration, it will be killed and the spawn promise will reject with a no-output-timeout termination reason." }),
372
+ createComponent(InterfaceMember, {
373
+ name: "noOutputTimeoutMs",
374
+ optional: true,
375
+ type: "number"
376
+ })
377
+ ];
378
+ }
379
+ }),
380
+ createComponent(Spacing, {}),
381
+ createComponent(VarDeclaration, {
382
+ "const": true,
383
+ name: "WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS",
384
+ initializer: code`250`
385
+ }),
386
+ createComponent(Spacing, {}),
387
+ createComponent(VarDeclaration, {
388
+ "const": true,
389
+ name: "WINDOWS_CLOSE_STATE_POLL_MS",
390
+ initializer: code`10`
391
+ }),
392
+ createComponent(Spacing, {}),
393
+ createComponent(TSDoc, {
394
+ heading: "Spawns a child process with the given arguments and options, returning a promise that resolves with the result of the spawn operation.",
395
+ get children() {
396
+ return [
397
+ createComponent(TSDocParam, {
398
+ name: "argv",
399
+ children: "The command and its arguments to spawn."
400
+ }),
401
+ createComponent(TSDocParam, {
402
+ name: "optionsOrTimeoutMs",
403
+ children: `The options for spawning the command, or a number representing the timeout in milliseconds. This allows for a convenient shorthand when only a timeout is needed. Providing \`-1\` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used.`
404
+ }),
405
+ createComponent(TSDocReturns, { children: "A promise that resolves with the result of the spawn operation, including stdout, stderr, exit code, signal, and termination reason." })
406
+ ];
407
+ }
408
+ }),
409
+ createComponent(FunctionDeclaration, {
410
+ "export": true,
411
+ async: true,
412
+ name: "spawn",
413
+ parameters: [{
414
+ name: "argv",
415
+ type: "string[]"
416
+ }, {
417
+ name: "optionsOrTimeoutMs",
418
+ type: "number | SpawnOptions",
419
+ default: "300000"
420
+ }],
421
+ returnType: "Promise<SpawnResult>",
422
+ children: code`const options: SpawnOptions =
96
423
  typeof optionsOrTimeoutMs === "number"
97
424
  ? { timeoutMs: optionsOrTimeoutMs }
98
425
  : optionsOrTimeoutMs;
@@ -315,19 +642,104 @@ return new Promise((resolve, reject) => {
315
642
  };
316
643
  waitForExitState();
317
644
  });
318
- });`}),e(s,{}),e(p,{heading:`A helper function that executes a command and returns its stdout.`,get children(){return[e(h,{name:`argv`,children:"The command and its arguments to spawn. This is passed directly to the spawn function. Remember that on Windows, commands like `npm` or `pnpm` will be resolved to their .cmd shims, so you can just pass `npm` without worrying about the extension."}),e(h,{name:`optionsOrTimeoutMs`,children:"The options for spawning the command, or a number representing the timeout in milliseconds. This is passed directly to the spawn function. Providing `-1` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used."}),e(g,{children:`A promise that resolves with the result of the spawn operation if the command exits with code 0, or rejects with an error if the command exits with a non-zero code or if there is a problem spawning the process.`})]}}),e(c,{export:!0,async:!0,name:`exec`,parameters:[{name:`argv`,type:`string[]`},{name:`optionsOrTimeoutMs`,type:`number | SpawnOptions`,default:`300000`}],returnType:`Promise<string>`,children:a`const spawnResult = await spawn(argv, optionsOrTimeoutMs);
645
+ });`
646
+ }),
647
+ createComponent(Spacing, {}),
648
+ createComponent(TSDoc, {
649
+ heading: "A helper function that executes a command and returns its stdout.",
650
+ get children() {
651
+ return [
652
+ createComponent(TSDocParam, {
653
+ name: "argv",
654
+ children: `The command and its arguments to spawn. This is passed directly to the spawn function. Remember that on Windows, commands like \`npm\` or \`pnpm\` will be resolved to their .cmd shims, so you can just pass \`npm\` without worrying about the extension.`
655
+ }),
656
+ createComponent(TSDocParam, {
657
+ name: "optionsOrTimeoutMs",
658
+ children: `The options for spawning the command, or a number representing the timeout in milliseconds. This is passed directly to the spawn function. Providing \`-1\` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used.`
659
+ }),
660
+ createComponent(TSDocReturns, { children: "A promise that resolves with the result of the spawn operation if the command exits with code 0, or rejects with an error if the command exits with a non-zero code or if there is a problem spawning the process." })
661
+ ];
662
+ }
663
+ }),
664
+ createComponent(FunctionDeclaration, {
665
+ "export": true,
666
+ async: true,
667
+ name: "exec",
668
+ parameters: [{
669
+ name: "argv",
670
+ type: "string[]"
671
+ }, {
672
+ name: "optionsOrTimeoutMs",
673
+ type: "number | SpawnOptions",
674
+ default: "300000"
675
+ }],
676
+ returnType: "Promise<string>",
677
+ children: code`const spawnResult = await spawn(argv, optionsOrTimeoutMs);
319
678
  if (spawnResult.code !== 0) {
320
679
  throw Object.assign(new Error(
321
680
  \`Command "\${argv.join(" ")}" exited with code \${spawnResult.code} and signal \${spawnResult.signal}\`
322
681
  ), spawnResult);
323
682
  }
324
683
 
325
- return spawnResult.stdout.trim(); `}),e(s,{}),e(p,{heading:"A helper function that executes a command synchronously and returns its stdout. This is a thin wrapper around \\`child_process.execFileSync\\` with some added Windows compatibility handling.",get children(){return[e(h,{name:`argv`,children:"The command and its arguments to spawn. This is passed directly to `execFileSync` after Windows-specific resolution. Remember that on Windows, commands like `npm` or `pnpm` will be resolved to their .cmd shims, so you can just pass `npm` without worrying about the extension."}),e(h,{name:`options`,children:"The options for spawning the command. This is passed directly to `execFileSync` after some processing. The timeout option is supported, but note that it will throw an error if the process runs longer than the specified timeout. If no options are provided, a default timeout of 5 minutes will be used."}),e(g,{children:`The standard output produced by the command if it exits with code 0. If the command exits with a non-zero code or if there is a problem spawning the process, an error will be thrown.`})]}}),e(c,{export:!0,name:`execSync`,parameters:[{name:`argv`,type:`string[]`},{name:`options`,type:`SpawnOptions`,default:`{}`}],returnType:`string`,children:a`return execFileSync(argv.length > 0 ? argv[0] : "", argv.slice(1), {
684
+ return spawnResult.stdout.trim(); `
685
+ }),
686
+ createComponent(Spacing, {}),
687
+ createComponent(TSDoc, {
688
+ heading: "A helper function that executes a command synchronously and returns its stdout. This is a thin wrapper around \\`child_process.execFileSync\\` with some added Windows compatibility handling.",
689
+ get children() {
690
+ return [
691
+ createComponent(TSDocParam, {
692
+ name: "argv",
693
+ children: `The command and its arguments to spawn. This is passed directly to \`execFileSync\` after Windows-specific resolution. Remember that on Windows, commands like \`npm\` or \`pnpm\` will be resolved to their .cmd shims, so you can just pass \`npm\` without worrying about the extension.`
694
+ }),
695
+ createComponent(TSDocParam, {
696
+ name: "options",
697
+ children: `The options for spawning the command. This is passed directly to \`execFileSync\` after some processing. The timeout option is supported, but note that it will throw an error if the process runs longer than the specified timeout. If no options are provided, a default timeout of 5 minutes will be used.`
698
+ }),
699
+ createComponent(TSDocReturns, { children: "The standard output produced by the command if it exits with code 0. If the command exits with a non-zero code or if there is a problem spawning the process, an error will be thrown." })
700
+ ];
701
+ }
702
+ }),
703
+ createComponent(FunctionDeclaration, {
704
+ "export": true,
705
+ name: "execSync",
706
+ parameters: [{
707
+ name: "argv",
708
+ type: "string[]"
709
+ }, {
710
+ name: "options",
711
+ type: "SpawnOptions",
712
+ default: "{}"
713
+ }],
714
+ returnType: "string",
715
+ children: code`return execFileSync(argv.length > 0 ? argv[0] : "", argv.slice(1), {
326
716
  encoding: "utf8",
327
717
  stdio: ["ignore", "pipe", "ignore"],
328
718
  timeout: options.timeoutMs ?? 300000,
329
719
  env: resolveCommandEnv({ argv, env: options.env }),
330
720
  cwd: options.cwd || process.cwd(),
331
721
  windowsHide: true
332
- }).trim(); `}),e(s,{}),e(i,{get when(){return!!v},children:v})]}}))}x.__type=[()=>b,`props`,`ExecBuiltin`,`A built-in module for handling command execution in Shell Shock.`,`Pn!2""/#?$`];export{x as ExecBuiltin,b as __ΩExecBuiltinProps};
722
+ }).trim(); `
723
+ }),
724
+ createComponent(Spacing, {}),
725
+ createComponent(Show, {
726
+ get when() {
727
+ return Boolean(children);
728
+ },
729
+ children
730
+ })
731
+ ];
732
+ }
733
+ }));
734
+ }
735
+ ExecBuiltin.__type = [
736
+ () => __ΩExecBuiltinProps,
737
+ "props",
738
+ "ExecBuiltin",
739
+ "A built-in module for handling command execution in Shell Shock.",
740
+ "Pn!2\"\"/#?$"
741
+ ];
742
+
743
+ //#endregion
744
+ export { ExecBuiltin, __ΩExecBuiltinProps };
333
745
  //# sourceMappingURL=exec-builtin.mjs.map