@shell-shock/core 0.17.7 → 0.17.8
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/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/api.cjs +1 -95
- package/dist/api.d.cts +52 -4
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +52 -4
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +1 -92
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +1 -292
- package/dist/components/command-validation-logic.mjs +1 -289
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -265
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +1 -256
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +13 -429
- package/dist/components/exec-builtin.mjs +13 -425
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +1 -120
- package/dist/components/helpers.mjs +1 -112
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +1 -58
- package/dist/components/index.mjs +1 -10
- package/dist/components/options-parser-logic.cjs +5 -960
- package/dist/components/options-parser-logic.d.cts +1 -1
- package/dist/components/options-parser-logic.mjs +5 -945
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +8 -629
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts.map +1 -1
- package/dist/components/state-builtin.mjs +8 -622
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +1 -117
- package/dist/components/usage.mjs +1 -114
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +33 -838
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +33 -828
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +1 -31
- package/dist/config.mjs +1 -29
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +1 -26
- package/dist/contexts/command.mjs +1 -23
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/index.cjs +1 -9
- package/dist/contexts/index.mjs +1 -4
- package/dist/contexts/options.cjs +1 -63
- package/dist/contexts/options.mjs +1 -58
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +1 -71
- package/dist/helpers/automd.mjs +1 -70
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -23
- package/dist/helpers/docs-helpers.mjs +1 -22
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +1 -137
- package/dist/helpers/paths.mjs +1 -133
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +1 -113
- package/dist/helpers/persistence.mjs +1 -110
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +1 -59
- package/dist/helpers/update-package-json.mjs +1 -57
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -95
- package/dist/helpers/utilities.mjs +1 -93
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +1 -71
- package/dist/helpers/validations.mjs +1 -71
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +1 -52
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -7
- package/dist/plugin-utils/compute-bin.cjs +1 -50
- package/dist/plugin-utils/compute-bin.mjs +1 -49
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +1 -231
- package/dist/plugin-utils/context-helpers.mjs +1 -221
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +1 -71
- package/dist/plugin-utils/deepkit.mjs +1 -69
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +2 -111
- package/dist/plugin-utils/description-helpers.mjs +2 -107
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +1 -117
- package/dist/plugin-utils/get-command-tree.mjs +1 -114
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +1 -39
- package/dist/plugin-utils/index.mjs +1 -10
- package/dist/plugin-utils/reflect.cjs +1 -52
- package/dist/plugin-utils/reflect.mjs +1 -52
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +1 -64
- package/dist/plugin-utils/traverse-command-tree.mjs +1 -62
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +1 -93
- package/dist/plugin-utils/type-checks.mjs +1 -88
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +4 -429
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +4 -423
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +1 -135
- package/dist/resolver/deepkit.mjs +1 -134
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +1 -173
- package/dist/resolver/helpers.mjs +1 -168
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +1 -145
- package/dist/resolver/module.mjs +1 -144
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +1 -222
- package/dist/resolver/resolve.mjs +1 -221
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +1 -441
- package/dist/types/command.mjs +1 -405
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -144
- package/dist/types/config.d.cts +3 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +3 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -138
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -37
- package/dist/types/context.d.cts +3 -2
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -2
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -34
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.cjs +1 -52
- package/dist/types/env.mjs +1 -50
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +1 -49
- package/dist/types/index.mjs +1 -6
- package/dist/types/options.cjs +1 -12
- package/dist/types/options.mjs +1 -10
- package/package.json +23 -23
|
@@ -1,82 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import defu$1 from "defu";
|
|
3
|
-
import { Show, code, splitProps } from "@alloy-js/core";
|
|
4
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
|
-
import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
6
|
-
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
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;
|
|
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;
|
|
80
2
|
const shouldSuppressNpmFund = (() => {
|
|
81
3
|
const cmd = basename(argv[0] ?? "");
|
|
82
4
|
if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
|
|
@@ -102,32 +24,12 @@ function ExecBuiltin(props) {
|
|
|
102
24
|
result.NPM_CONFIG_FUND ??= "false";
|
|
103
25
|
result.npm_config_fund ??= "false";
|
|
104
26
|
}
|
|
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) {
|
|
27
|
+
return result; `}),e(s,{}),e(c,{name:`isWindowsBatchCommand`,parameters:[{name:`resolvedCommand`,type:`string`}],returnType:`boolean`,children:a`if (!isWindows) {
|
|
116
28
|
return false;
|
|
117
29
|
}
|
|
118
30
|
const ext = extname(resolvedCommand).toLowerCase();
|
|
119
31
|
|
|
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)) {
|
|
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)) {
|
|
131
33
|
throw new Error(
|
|
132
34
|
\`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
|
|
133
35
|
"Pass an explicit shell-wrapper argv at the call site instead."
|
|
@@ -136,33 +38,9 @@ function ExecBuiltin(props) {
|
|
|
136
38
|
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
137
39
|
return arg;
|
|
138
40
|
}
|
|
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(
|
|
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(
|
|
153
42
|
" "
|
|
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) {
|
|
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) {
|
|
166
44
|
return null;
|
|
167
45
|
}
|
|
168
46
|
const base = basename(argv[0] ?? "")
|
|
@@ -182,18 +60,7 @@ function ExecBuiltin(props) {
|
|
|
182
60
|
|
|
183
61
|
return [shimmedCommand, ...argv.slice(1)];
|
|
184
62
|
}
|
|
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) {
|
|
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) {
|
|
197
64
|
return command;
|
|
198
65
|
}
|
|
199
66
|
const base = basename(command).toLowerCase();
|
|
@@ -203,33 +70,13 @@ function ExecBuiltin(props) {
|
|
|
203
70
|
if (["pnpm", "yarn"].includes(base)) {
|
|
204
71
|
return \`\${command}.cmd\`;
|
|
205
72
|
}
|
|
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
|
|
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
|
|
217
74
|
? "pipe"
|
|
218
75
|
: params.preferInherit
|
|
219
76
|
? "inherit"
|
|
220
77
|
: "pipe";
|
|
221
78
|
|
|
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 (
|
|
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 (
|
|
233
80
|
params.explicitCode ??
|
|
234
81
|
params.childExitCode ??
|
|
235
82
|
(params.usesWindowsExitCodeShim &&
|
|
@@ -239,187 +86,13 @@ function ExecBuiltin(props) {
|
|
|
239
86
|
!params.killIssuedByTimeout
|
|
240
87
|
? 0
|
|
241
88
|
: null)
|
|
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.
|
|
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.
|
|
253
90
|
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
254
91
|
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
255
92
|
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
256
93
|
// and validate/escape at the call site.
|
|
257
94
|
void params;
|
|
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 =
|
|
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 =
|
|
423
96
|
typeof optionsOrTimeoutMs === "number"
|
|
424
97
|
? { timeoutMs: optionsOrTimeoutMs }
|
|
425
98
|
: optionsOrTimeoutMs;
|
|
@@ -642,104 +315,19 @@ return new Promise((resolve, reject) => {
|
|
|
642
315
|
};
|
|
643
316
|
waitForExitState();
|
|
644
317
|
});
|
|
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);
|
|
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);
|
|
678
319
|
if (spawnResult.code !== 0) {
|
|
679
320
|
throw Object.assign(new Error(
|
|
680
321
|
\`Command "\${argv.join(" ")}" exited with code \${spawnResult.code} and signal \${spawnResult.signal}\`
|
|
681
322
|
), spawnResult);
|
|
682
323
|
}
|
|
683
324
|
|
|
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), {
|
|
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), {
|
|
716
326
|
encoding: "utf8",
|
|
717
327
|
stdio: ["ignore", "pipe", "ignore"],
|
|
718
328
|
timeout: options.timeoutMs ?? 300000,
|
|
719
329
|
env: resolveCommandEnv({ argv, env: options.env }),
|
|
720
330
|
cwd: options.cwd || process.cwd(),
|
|
721
331
|
windowsHide: true
|
|
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 };
|
|
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};
|
|
745
333
|
//# sourceMappingURL=exec-builtin.mjs.map
|