@netlify/agent-runner-cli 1.58.5 → 1.58.7-alpha
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/bin-local.js +32 -32
- package/dist/bin.js +36 -36
- package/dist/index.d.ts +254 -2
- package/dist/index.js +41 -41
- package/package.json +12 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,259 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as os from 'os';
|
|
2
|
+
import { FdGenericOption as FdGenericOption$1 } from './arguments/specific.js';
|
|
3
|
+
import * as execa from 'execa';
|
|
4
|
+
import { Options, ResultPromise } from 'execa';
|
|
5
|
+
import { FromOption } from './fd-options.js';
|
|
6
|
+
import { Readable, Writable } from 'node:stream';
|
|
7
|
+
import { TransformStream, ReadableStream, WritableStream } from 'node:stream/web';
|
|
8
|
+
import { Unless, And, Not, Or, AndUnless } from '../utils.js';
|
|
9
|
+
import { GeneratorTransform, GeneratorTransformFull, DuplexTransform, WebTransform } from '../transform/normalize.js';
|
|
10
|
+
import * as stream from 'stream';
|
|
2
11
|
|
|
12
|
+
type VerboseOption = FdGenericOption$1<
|
|
13
|
+
| 'none'
|
|
14
|
+
| 'short'
|
|
15
|
+
| 'full'
|
|
16
|
+
| VerboseFunction
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
type VerboseFunction = (verboseLine: string, verboseObject: MinimalVerboseObject) => string | void;
|
|
20
|
+
|
|
21
|
+
type GenericVerboseObject = {
|
|
22
|
+
/**
|
|
23
|
+
Event type. This can be:
|
|
24
|
+
- `'command'`: subprocess start
|
|
25
|
+
- `'output'`: `stdout`/`stderr` output
|
|
26
|
+
- `'ipc'`: IPC output
|
|
27
|
+
- `'error'`: subprocess failure
|
|
28
|
+
- `'duration'`: subprocess success or failure
|
|
29
|
+
*/
|
|
30
|
+
type: 'command' | 'output' | 'ipc' | 'error' | 'duration';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
Depending on `verboseObject.type`, this is:
|
|
34
|
+
- `'command'`: the `result.escapedCommand`
|
|
35
|
+
- `'output'`: one line from `result.stdout` or `result.stderr`
|
|
36
|
+
- `'ipc'`: one IPC message from `result.ipcOutput`
|
|
37
|
+
- `'error'`: the `error.shortMessage`
|
|
38
|
+
- `'duration'`: the `result.durationMs`
|
|
39
|
+
*/
|
|
40
|
+
message: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
The file and arguments that were run. This is the same as `result.escapedCommand`.
|
|
44
|
+
*/
|
|
45
|
+
escapedCommand: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
Serial number identifying the subprocess within the current process. It is incremented from `'0'`.
|
|
49
|
+
|
|
50
|
+
This is helpful when multiple subprocesses are running at the same time.
|
|
51
|
+
|
|
52
|
+
This is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.
|
|
53
|
+
*/
|
|
54
|
+
commandId: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
Event date/time.
|
|
58
|
+
*/
|
|
59
|
+
timestamp: Date;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
Whether another subprocess is piped into this subprocess. This is `false` when `result.pipedFrom` is empty.
|
|
63
|
+
*/
|
|
64
|
+
piped: boolean;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type MinimalVerboseObject = GenericVerboseObject & {
|
|
68
|
+
// We cannot use the `CommonOptions` type because it would make this type recursive
|
|
69
|
+
options: object;
|
|
70
|
+
result?: never;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Options which can be fd-specific like `{verbose: {stdout: 'none', stderr: 'full'}}`
|
|
74
|
+
type FdGenericOption<OptionType> = OptionType | GenericOptionObject<OptionType>;
|
|
75
|
+
|
|
76
|
+
type GenericOptionObject<OptionType> = {
|
|
77
|
+
readonly [FdName in GenericFromOption]?: OptionType
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type GenericFromOption = FromOption | 'ipc';
|
|
81
|
+
|
|
82
|
+
type DefaultEncodingOption = 'utf8';
|
|
83
|
+
type TextEncodingOption =
|
|
84
|
+
| DefaultEncodingOption
|
|
85
|
+
| 'utf16le';
|
|
86
|
+
|
|
87
|
+
type BufferEncodingOption = 'buffer';
|
|
88
|
+
type BinaryEncodingOption =
|
|
89
|
+
| BufferEncodingOption
|
|
90
|
+
| 'hex'
|
|
91
|
+
| 'base64'
|
|
92
|
+
| 'base64url'
|
|
93
|
+
| 'latin1'
|
|
94
|
+
| 'ascii';
|
|
95
|
+
|
|
96
|
+
// `options.encoding`
|
|
97
|
+
type EncodingOption =
|
|
98
|
+
| TextEncodingOption
|
|
99
|
+
| BinaryEncodingOption
|
|
100
|
+
| undefined;
|
|
101
|
+
|
|
102
|
+
// `options.stdio` when it is not an array
|
|
103
|
+
type SimpleStdioOption<
|
|
104
|
+
IsSync extends boolean,
|
|
105
|
+
IsExtra extends boolean,
|
|
106
|
+
IsArray extends boolean,
|
|
107
|
+
> =
|
|
108
|
+
| undefined
|
|
109
|
+
| 'pipe'
|
|
110
|
+
| Unless<And<And<Not<IsSync>, IsArray>, IsExtra>, 'inherit'>
|
|
111
|
+
| Unless<IsArray, 'ignore'>
|
|
112
|
+
| Unless<IsSync, 'overlapped'>;
|
|
113
|
+
|
|
114
|
+
// Values available in both `options.stdin|stdio` and `options.stdout|stderr|stdio`
|
|
115
|
+
type CommonStdioOption<
|
|
116
|
+
IsSync extends boolean,
|
|
117
|
+
IsExtra extends boolean,
|
|
118
|
+
IsArray extends boolean,
|
|
119
|
+
> =
|
|
120
|
+
| SimpleStdioOption<IsSync, IsExtra, IsArray>
|
|
121
|
+
| URL
|
|
122
|
+
| {readonly file: string; readonly append?: boolean}
|
|
123
|
+
| GeneratorTransform<IsSync>
|
|
124
|
+
| GeneratorTransformFull<IsSync>
|
|
125
|
+
| Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9>
|
|
126
|
+
| Unless<Or<IsSync, IsArray>, 'ipc'>
|
|
127
|
+
| Unless<IsSync, DuplexTransform | WebTransform | TransformStream>;
|
|
128
|
+
|
|
129
|
+
// Synchronous iterables excluding strings, Uint8Arrays and Arrays
|
|
130
|
+
type IterableObject<IsArray extends boolean> = Iterable<unknown>
|
|
131
|
+
& object
|
|
132
|
+
& {readonly BYTES_PER_ELEMENT?: never}
|
|
133
|
+
& AndUnless<IsArray, {readonly lastIndexOf?: never}>;
|
|
134
|
+
|
|
135
|
+
// `process.stdin|stdout|stderr` are `Duplex` with a `fd` property.
|
|
136
|
+
// This ensures they can only be passed to `stdin`/`stdout`/`stderr`, based on their direction.
|
|
137
|
+
type ProcessStdinFd = {readonly fd?: 0};
|
|
138
|
+
type ProcessStdoutStderrFd = {readonly fd?: 1 | 2};
|
|
139
|
+
|
|
140
|
+
// Values available only in `options.stdin|stdio`
|
|
141
|
+
type InputStdioOption<
|
|
142
|
+
IsSync extends boolean = boolean,
|
|
143
|
+
IsExtra extends boolean = boolean,
|
|
144
|
+
IsArray extends boolean = boolean,
|
|
145
|
+
> =
|
|
146
|
+
| 0
|
|
147
|
+
| Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsArray>>
|
|
148
|
+
| Unless<And<IsSync, IsArray>, Readable & ProcessStdinFd>
|
|
149
|
+
| Unless<IsSync, (AsyncIterable<unknown> & ProcessStdinFd) | ReadableStream>;
|
|
150
|
+
|
|
151
|
+
// Values available only in `options.stdout|stderr|stdio`
|
|
152
|
+
type OutputStdioOption<
|
|
153
|
+
IsSync extends boolean,
|
|
154
|
+
IsArray extends boolean,
|
|
155
|
+
> =
|
|
156
|
+
| 1
|
|
157
|
+
| 2
|
|
158
|
+
| Unless<And<IsSync, IsArray>, Writable & ProcessStdoutStderrFd>
|
|
159
|
+
| Unless<IsSync, WritableStream>;
|
|
160
|
+
|
|
161
|
+
// `options.stdin` array items
|
|
162
|
+
type StdinSingleOption<
|
|
163
|
+
IsSync extends boolean,
|
|
164
|
+
IsExtra extends boolean,
|
|
165
|
+
IsArray extends boolean,
|
|
166
|
+
> =
|
|
167
|
+
| CommonStdioOption<IsSync, IsExtra, IsArray>
|
|
168
|
+
| InputStdioOption<IsSync, IsExtra, IsArray>;
|
|
169
|
+
|
|
170
|
+
// `options.stdin`
|
|
171
|
+
type StdinOptionCommon<
|
|
172
|
+
IsSync extends boolean = boolean,
|
|
173
|
+
IsExtra extends boolean = boolean,
|
|
174
|
+
> =
|
|
175
|
+
| StdinSingleOption<IsSync, IsExtra, false>
|
|
176
|
+
| ReadonlyArray<StdinSingleOption<IsSync, IsExtra, true>>;
|
|
177
|
+
|
|
178
|
+
// `options.stdout|stderr` array items
|
|
179
|
+
type StdoutStderrSingleOption<
|
|
180
|
+
IsSync extends boolean,
|
|
181
|
+
IsExtra extends boolean,
|
|
182
|
+
IsArray extends boolean,
|
|
183
|
+
> =
|
|
184
|
+
| CommonStdioOption<IsSync, IsExtra, IsArray>
|
|
185
|
+
| OutputStdioOption<IsSync, IsArray>;
|
|
186
|
+
|
|
187
|
+
// `options.stdout|stderr`
|
|
188
|
+
type StdoutStderrOptionCommon<
|
|
189
|
+
IsSync extends boolean = boolean,
|
|
190
|
+
IsExtra extends boolean = boolean,
|
|
191
|
+
> =
|
|
192
|
+
| StdoutStderrSingleOption<IsSync, IsExtra, false>
|
|
193
|
+
| ReadonlyArray<StdoutStderrSingleOption<IsSync, IsExtra, true>>;
|
|
194
|
+
|
|
195
|
+
// `options.stdio[3+]`
|
|
196
|
+
type StdioExtraOptionCommon<IsSync extends boolean> =
|
|
197
|
+
| StdinOptionCommon<IsSync, true>
|
|
198
|
+
| StdoutStderrOptionCommon<IsSync, true>;
|
|
199
|
+
|
|
200
|
+
// `options.stdio` when it is an array
|
|
201
|
+
type StdioOptionsArray<IsSync extends boolean = boolean> = readonly [
|
|
202
|
+
StdinOptionCommon<IsSync, false>,
|
|
203
|
+
StdoutStderrOptionCommon<IsSync, false>,
|
|
204
|
+
StdoutStderrOptionCommon<IsSync, false>,
|
|
205
|
+
...ReadonlyArray<StdioExtraOptionCommon<IsSync>>,
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
// `options.stdio`
|
|
209
|
+
type StdioOptionsProperty<IsSync extends boolean = boolean> =
|
|
210
|
+
| SimpleStdioOption<IsSync, false, false>
|
|
211
|
+
| StdioOptionsArray<IsSync>;
|
|
212
|
+
|
|
213
|
+
interface IdleTimeoutOptions {
|
|
214
|
+
idleTimeout?: number;
|
|
215
|
+
}
|
|
3
216
|
/** Run a command, with arguments being an array */
|
|
4
|
-
declare const run: (file: string, args?: string[] | object, options?: Options) =>
|
|
217
|
+
declare const run: (file: string, args?: string[] | object, options?: Options & IdleTimeoutOptions) => ResultPromise<{
|
|
218
|
+
preferLocal?: boolean;
|
|
219
|
+
localDir?: string | URL;
|
|
220
|
+
node?: boolean;
|
|
221
|
+
nodeOptions?: readonly string[];
|
|
222
|
+
nodePath?: string | URL;
|
|
223
|
+
shell?: boolean | string | URL;
|
|
224
|
+
cwd?: string | URL;
|
|
225
|
+
env?: Readonly<Partial<Record<string, string>>>;
|
|
226
|
+
extendEnv?: boolean;
|
|
227
|
+
input?: string | Uint8Array | stream.Readable;
|
|
228
|
+
inputFile?: string | URL;
|
|
229
|
+
stdin?: StdinOptionCommon<false>;
|
|
230
|
+
stdout?: StdoutStderrOptionCommon<false>;
|
|
231
|
+
stderr?: StdoutStderrOptionCommon<false>;
|
|
232
|
+
stdio?: StdioOptionsProperty<false>;
|
|
233
|
+
all?: boolean;
|
|
234
|
+
encoding?: EncodingOption;
|
|
235
|
+
lines?: FdGenericOption<boolean>;
|
|
236
|
+
stripFinalNewline?: FdGenericOption<boolean>;
|
|
237
|
+
maxBuffer?: FdGenericOption<number>;
|
|
238
|
+
buffer?: FdGenericOption<boolean>;
|
|
239
|
+
ipc?: boolean | undefined;
|
|
240
|
+
serialization?: "json" | "advanced" | undefined;
|
|
241
|
+
ipcInput?: execa.Message | undefined;
|
|
242
|
+
verbose?: VerboseOption;
|
|
243
|
+
reject?: boolean;
|
|
244
|
+
timeout?: number;
|
|
245
|
+
cancelSignal?: AbortSignal | undefined;
|
|
246
|
+
gracefulCancel?: boolean | undefined;
|
|
247
|
+
forceKillAfterDelay?: number | boolean | undefined;
|
|
248
|
+
killSignal?: keyof os.SignalConstants | number;
|
|
249
|
+
detached?: boolean | undefined;
|
|
250
|
+
cleanup?: boolean | undefined;
|
|
251
|
+
uid?: number;
|
|
252
|
+
gid?: number;
|
|
253
|
+
argv0?: string;
|
|
254
|
+
windowsHide?: boolean;
|
|
255
|
+
windowsVerbatimArguments?: boolean;
|
|
256
|
+
}>;
|
|
5
257
|
|
|
6
258
|
interface RunnerConfig {
|
|
7
259
|
id: string;
|