storybook 9.0.11 → 9.0.13
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/index.cjs +43 -43
- package/dist/bin/index.js +43 -43
- package/dist/cli/bin/index.cjs +629 -629
- package/dist/cli/bin/index.js +202 -201
- package/dist/cli/index.cjs +13788 -13797
- package/dist/cli/index.d.ts +712 -15
- package/dist/cli/index.js +12364 -12372
- package/dist/common/index.cjs +10997 -10888
- package/dist/common/index.d.ts +348 -66
- package/dist/common/index.js +24318 -24206
- package/dist/components/index.cjs +632 -628
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +390 -386
- package/dist/core-server/index.cjs +4840 -4793
- package/dist/core-server/index.d.ts +10 -1
- package/dist/core-server/index.js +5748 -5701
- package/dist/core-server/presets/common-manager.js +257 -243
- package/dist/core-server/presets/common-preset.cjs +1048 -1046
- package/dist/core-server/presets/common-preset.js +2054 -2049
- package/dist/csf-tools/index.cjs +226 -224
- package/dist/csf-tools/index.js +116 -112
- package/dist/manager/globals-runtime.js +3286 -3282
- package/dist/manager-api/index.cjs +73 -73
- package/dist/manager-api/index.js +140 -140
- package/dist/node-logger/index.cjs +8520 -994
- package/dist/node-logger/index.d.ts +395 -2
- package/dist/node-logger/index.js +8535 -995
- package/dist/server-errors.cjs +201 -242
- package/dist/server-errors.d.ts +1 -12
- package/dist/server-errors.js +182 -223
- package/dist/telemetry/index.cjs +1224 -1223
- package/dist/telemetry/index.d.ts +3 -2
- package/dist/telemetry/index.js +1069 -1066
- package/dist/types/index.d.ts +3 -3
- package/package.json +2 -1
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { PackageJsonWithMaybeDeps, JsPackageManager as JsPackageManager$1,
|
|
2
|
-
import { SupportedFrameworks, SupportedRenderers } from 'storybook/internal/types';
|
|
1
|
+
import { PackageJsonWithMaybeDeps, JsPackageManager as JsPackageManager$1, PackageJson } from 'storybook/internal/common';
|
|
2
|
+
import { SupportedFrameworks, SupportedRenderers, PackageJson as PackageJson$1 } from 'storybook/internal/types';
|
|
3
3
|
import * as semver from 'semver';
|
|
4
|
+
import { Buffer } from 'node:buffer';
|
|
5
|
+
import { ChildProcess } from 'node:child_process';
|
|
6
|
+
import { Readable, Writable, Stream } from 'node:stream';
|
|
4
7
|
|
|
5
8
|
/** A list of all frameworks that are supported, but use a package outside the storybook monorepo */
|
|
6
9
|
type ExternalFramework = {
|
|
@@ -118,10 +121,10 @@ declare const writeFileAsJson: (jsonPath: string, content: unknown) => boolean;
|
|
|
118
121
|
* ]);
|
|
119
122
|
* ```
|
|
120
123
|
*
|
|
121
|
-
* @param
|
|
122
|
-
* @returns
|
|
124
|
+
* @param packageJson The current package.json so we can inspect its contents
|
|
125
|
+
* @returns Contains the packages and versions that need to be installed
|
|
123
126
|
*/
|
|
124
|
-
declare function getBabelDependencies(packageManager: JsPackageManager$1
|
|
127
|
+
declare function getBabelDependencies(packageManager: JsPackageManager$1): Promise<string[]>;
|
|
125
128
|
declare function addToDevDependenciesIfNotPresent(packageJson: PackageJson, name: string, packageVersion: string): void;
|
|
126
129
|
declare function copyTemplate(templateRoot: string, destination?: string): void;
|
|
127
130
|
type CopyTemplateFilesOptions = {
|
|
@@ -141,10 +144,9 @@ declare function getVersionSafe(packageManager: JsPackageManager$1, packageName:
|
|
|
141
144
|
declare const cliStoriesTargetPath: () => Promise<"./src/stories" | "./stories">;
|
|
142
145
|
declare function copyTemplateFiles({ packageManager, templateLocation, language, destination, commonAssetsDir, features, }: CopyTemplateFilesOptions): Promise<void>;
|
|
143
146
|
declare function adjustTemplate(templatePath: string, templateData: Record<string, any>): Promise<void>;
|
|
144
|
-
declare function getStorybookVersionSpecifier(packageJson: PackageJsonWithDepsAndDevDeps): string | undefined;
|
|
145
147
|
declare function isNxProject(): Promise<string | undefined>;
|
|
146
148
|
declare function coerceSemver(version: string): semver.SemVer;
|
|
147
|
-
declare function hasStorybookDependencies(packageManager: JsPackageManager$1):
|
|
149
|
+
declare function hasStorybookDependencies(packageManager: JsPackageManager$1): boolean;
|
|
148
150
|
|
|
149
151
|
declare const ANGULAR_JSON_PATH = "angular.json";
|
|
150
152
|
declare const compoDocPreviewPrefix: string;
|
|
@@ -187,16 +189,711 @@ declare class AngularJSON {
|
|
|
187
189
|
|
|
188
190
|
declare function getRendererDir(packageManager: JsPackageManager$1, renderer: SupportedFrameworks | SupportedRenderers): Promise<string>;
|
|
189
191
|
|
|
190
|
-
type
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
type StdioOption =
|
|
193
|
+
| 'pipe'
|
|
194
|
+
| 'overlapped'
|
|
195
|
+
| 'ipc'
|
|
196
|
+
| 'ignore'
|
|
197
|
+
| 'inherit'
|
|
198
|
+
| Stream
|
|
199
|
+
| number
|
|
200
|
+
| undefined;
|
|
201
|
+
|
|
202
|
+
type EncodingOption =
|
|
203
|
+
| 'utf8'
|
|
204
|
+
// eslint-disable-next-line unicorn/text-encoding-identifier-case
|
|
205
|
+
| 'utf-8'
|
|
206
|
+
| 'utf16le'
|
|
207
|
+
| 'utf-16le'
|
|
208
|
+
| 'ucs2'
|
|
209
|
+
| 'ucs-2'
|
|
210
|
+
| 'latin1'
|
|
211
|
+
| 'binary'
|
|
212
|
+
| 'ascii'
|
|
213
|
+
| 'hex'
|
|
214
|
+
| 'base64'
|
|
215
|
+
| 'base64url'
|
|
216
|
+
| 'buffer'
|
|
217
|
+
| null
|
|
218
|
+
| undefined;
|
|
219
|
+
type DefaultEncodingOption = 'utf8';
|
|
220
|
+
|
|
221
|
+
type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
|
|
222
|
+
/**
|
|
223
|
+
Kill the spawned process when the parent process exits unless either:
|
|
224
|
+
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
|
|
225
|
+
- the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
|
|
226
|
+
|
|
227
|
+
@default true
|
|
228
|
+
*/
|
|
229
|
+
readonly cleanup?: boolean;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
Prefer locally installed binaries when looking for a binary to execute.
|
|
233
|
+
|
|
234
|
+
If you `$ npm install foo`, you can then `execa('foo')`.
|
|
235
|
+
|
|
236
|
+
@default `true` with `$`, `false` otherwise
|
|
237
|
+
*/
|
|
238
|
+
readonly preferLocal?: boolean;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
Preferred path to find locally installed binaries in (use with `preferLocal`).
|
|
242
|
+
|
|
243
|
+
@default process.cwd()
|
|
244
|
+
*/
|
|
245
|
+
readonly localDir?: string | URL;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
Path to the Node.js executable to use in child processes.
|
|
249
|
+
|
|
250
|
+
This can be either an absolute path or a path relative to the `cwd` option.
|
|
251
|
+
|
|
252
|
+
Requires `preferLocal` to be `true`.
|
|
253
|
+
|
|
254
|
+
For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
|
|
255
|
+
|
|
256
|
+
@default process.execPath
|
|
257
|
+
*/
|
|
258
|
+
readonly execPath?: string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.
|
|
262
|
+
|
|
263
|
+
If the spawned process fails, `error.stdout`, `error.stderr`, and `error.all` will contain the buffered data.
|
|
264
|
+
|
|
265
|
+
@default true
|
|
266
|
+
*/
|
|
267
|
+
readonly buffer?: boolean;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
271
|
+
|
|
272
|
+
@default `inherit` with `$`, `pipe` otherwise
|
|
273
|
+
*/
|
|
274
|
+
readonly stdin?: StdioOption;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
278
|
+
|
|
279
|
+
@default 'pipe'
|
|
280
|
+
*/
|
|
281
|
+
readonly stdout?: StdioOption;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
285
|
+
|
|
286
|
+
@default 'pipe'
|
|
287
|
+
*/
|
|
288
|
+
readonly stderr?: StdioOption;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
Setting this to `false` resolves the promise with the error instead of rejecting it.
|
|
292
|
+
|
|
293
|
+
@default true
|
|
294
|
+
*/
|
|
295
|
+
readonly reject?: boolean;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
Add an `.all` property on the promise and the resolved value. The property contains the output of the process with `stdout` and `stderr` interleaved.
|
|
299
|
+
|
|
300
|
+
@default false
|
|
301
|
+
*/
|
|
302
|
+
readonly all?: boolean;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
|
|
306
|
+
|
|
307
|
+
@default true
|
|
308
|
+
*/
|
|
309
|
+
readonly stripFinalNewline?: boolean;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
|
313
|
+
|
|
314
|
+
@default true
|
|
315
|
+
*/
|
|
316
|
+
readonly extendEnv?: boolean;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
Current working directory of the child process.
|
|
320
|
+
|
|
321
|
+
@default process.cwd()
|
|
322
|
+
*/
|
|
323
|
+
readonly cwd?: string | URL;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
|
|
327
|
+
|
|
328
|
+
@default process.env
|
|
329
|
+
*/
|
|
330
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
|
|
334
|
+
*/
|
|
335
|
+
readonly argv0?: string;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
|
|
339
|
+
|
|
340
|
+
@default 'pipe'
|
|
341
|
+
*/
|
|
342
|
+
readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:
|
|
346
|
+
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
|
|
347
|
+
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
|
|
348
|
+
|
|
349
|
+
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
|
|
350
|
+
|
|
351
|
+
@default 'json'
|
|
352
|
+
*/
|
|
353
|
+
readonly serialization?: 'json' | 'advanced';
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
|
|
357
|
+
|
|
358
|
+
@default false
|
|
359
|
+
*/
|
|
360
|
+
readonly detached?: boolean;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
Sets the user identity of the process.
|
|
364
|
+
*/
|
|
365
|
+
readonly uid?: number;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
Sets the group identity of the process.
|
|
369
|
+
*/
|
|
370
|
+
readonly gid?: number;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
|
374
|
+
|
|
375
|
+
We recommend against using this option since it is:
|
|
376
|
+
- not cross-platform, encouraging shell-specific syntax.
|
|
377
|
+
- slower, because of the additional shell interpretation.
|
|
378
|
+
- unsafe, potentially allowing command injection.
|
|
379
|
+
|
|
380
|
+
@default false
|
|
381
|
+
*/
|
|
382
|
+
readonly shell?: boolean | string;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
|
|
386
|
+
|
|
387
|
+
@default 'utf8'
|
|
388
|
+
*/
|
|
389
|
+
readonly encoding?: EncodingType;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.
|
|
393
|
+
|
|
394
|
+
@default 0
|
|
395
|
+
*/
|
|
396
|
+
readonly timeout?: number;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 100 MB.
|
|
400
|
+
|
|
401
|
+
@default 100_000_000
|
|
402
|
+
*/
|
|
403
|
+
readonly maxBuffer?: number;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
Signal value to be used when the spawned process will be killed.
|
|
407
|
+
|
|
408
|
+
@default 'SIGTERM'
|
|
409
|
+
*/
|
|
410
|
+
readonly killSignal?: string | number;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
414
|
+
|
|
415
|
+
When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `true`.
|
|
416
|
+
|
|
417
|
+
@example
|
|
418
|
+
```
|
|
419
|
+
import {execa} from 'execa';
|
|
420
|
+
|
|
421
|
+
const abortController = new AbortController();
|
|
422
|
+
const subprocess = execa('node', [], {signal: abortController.signal});
|
|
423
|
+
|
|
424
|
+
setTimeout(() => {
|
|
425
|
+
abortController.abort();
|
|
426
|
+
}, 1000);
|
|
427
|
+
|
|
428
|
+
try {
|
|
429
|
+
await subprocess;
|
|
430
|
+
} catch (error) {
|
|
431
|
+
console.log(subprocess.killed); // true
|
|
432
|
+
console.log(error.isCanceled); // true
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
*/
|
|
436
|
+
readonly signal?: AbortSignal;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
|
440
|
+
|
|
441
|
+
@default false
|
|
442
|
+
*/
|
|
443
|
+
readonly windowsVerbatimArguments?: boolean;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.
|
|
447
|
+
|
|
448
|
+
@default true
|
|
449
|
+
*/
|
|
450
|
+
readonly windowsHide?: boolean;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
Print each command on `stderr` before executing it.
|
|
454
|
+
|
|
455
|
+
This can also be enabled by setting the `NODE_DEBUG=execa` environment variable in the current process.
|
|
456
|
+
|
|
457
|
+
@default false
|
|
458
|
+
*/
|
|
459
|
+
readonly verbose?: boolean;
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
type StdoutStderrAll = string | Buffer | undefined;
|
|
463
|
+
|
|
464
|
+
type ExecaReturnBase<StdoutStderrType extends StdoutStderrAll> = {
|
|
465
|
+
/**
|
|
466
|
+
The file and arguments that were run, for logging purposes.
|
|
467
|
+
|
|
468
|
+
This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
469
|
+
*/
|
|
470
|
+
command: string;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
Same as `command` but escaped.
|
|
474
|
+
|
|
475
|
+
This is meant to be copy and pasted into a shell, for debugging purposes.
|
|
476
|
+
Since the escaping is fairly basic, this should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
477
|
+
*/
|
|
478
|
+
escapedCommand: string;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
The numeric exit code of the process that was run.
|
|
482
|
+
*/
|
|
483
|
+
exitCode: number;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
The output of the process on stdout.
|
|
487
|
+
*/
|
|
488
|
+
stdout: StdoutStderrType;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
The output of the process on stderr.
|
|
492
|
+
*/
|
|
493
|
+
stderr: StdoutStderrType;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
Whether the process failed to run.
|
|
497
|
+
*/
|
|
498
|
+
failed: boolean;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
Whether the process timed out.
|
|
502
|
+
*/
|
|
503
|
+
timedOut: boolean;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
Whether the process was killed.
|
|
507
|
+
*/
|
|
508
|
+
killed: boolean;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
|
512
|
+
|
|
513
|
+
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
|
514
|
+
*/
|
|
515
|
+
signal?: string;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
|
519
|
+
|
|
520
|
+
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.
|
|
521
|
+
*/
|
|
522
|
+
signalDescription?: string;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
The `cwd` of the command if provided in the command options. Otherwise it is `process.cwd()`.
|
|
526
|
+
*/
|
|
527
|
+
cwd: string;
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
type ExecaSyncReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
531
|
+
} & ExecaReturnBase<StdoutStderrType>;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
|
|
535
|
+
|
|
536
|
+
The child process fails when:
|
|
537
|
+
- its exit code is not `0`
|
|
538
|
+
- it was killed with a signal
|
|
539
|
+
- timing out
|
|
540
|
+
- being canceled
|
|
541
|
+
- there's not enough memory or there are already too many child processes
|
|
542
|
+
*/
|
|
543
|
+
type ExecaReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
544
|
+
/**
|
|
545
|
+
The output of the process with `stdout` and `stderr` interleaved.
|
|
546
|
+
|
|
547
|
+
This is `undefined` if either:
|
|
548
|
+
- the `all` option is `false` (default value)
|
|
549
|
+
- `execaSync()` was used
|
|
550
|
+
*/
|
|
551
|
+
all?: StdoutStderrType;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
Whether the process was canceled.
|
|
555
|
+
|
|
556
|
+
You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.
|
|
557
|
+
*/
|
|
558
|
+
isCanceled: boolean;
|
|
559
|
+
} & ExecaSyncReturnValue<StdoutStderrType>;
|
|
560
|
+
|
|
561
|
+
type ExecaSyncError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
562
|
+
/**
|
|
563
|
+
Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.
|
|
564
|
+
|
|
565
|
+
The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.
|
|
566
|
+
*/
|
|
567
|
+
message: string;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
This is the same as the `message` property except it does not include the child process stdout/stderr.
|
|
571
|
+
*/
|
|
572
|
+
shortMessage: string;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
Original error message. This is the same as the `message` property except it includes neither the child process stdout/stderr nor some additional information added by Execa.
|
|
576
|
+
|
|
577
|
+
This is `undefined` unless the child process exited due to an `error` event or a timeout.
|
|
578
|
+
*/
|
|
579
|
+
originalMessage?: string;
|
|
580
|
+
} & Error & ExecaReturnBase<StdoutStderrType>;
|
|
581
|
+
|
|
582
|
+
type ExecaError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
583
|
+
/**
|
|
584
|
+
The output of the process with `stdout` and `stderr` interleaved.
|
|
585
|
+
|
|
586
|
+
This is `undefined` if either:
|
|
587
|
+
- the `all` option is `false` (default value)
|
|
588
|
+
- `execaSync()` was used
|
|
589
|
+
*/
|
|
590
|
+
all?: StdoutStderrType;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
Whether the process was canceled.
|
|
594
|
+
*/
|
|
595
|
+
isCanceled: boolean;
|
|
596
|
+
} & ExecaSyncError<StdoutStderrType>;
|
|
597
|
+
|
|
598
|
+
type KillOptions = {
|
|
599
|
+
/**
|
|
600
|
+
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
|
|
601
|
+
|
|
602
|
+
Can be disabled with `false`.
|
|
603
|
+
|
|
604
|
+
@default 5000
|
|
605
|
+
*/
|
|
606
|
+
forceKillAfterTimeout?: number | false;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
type ExecaChildPromise<StdoutStderrType extends StdoutStderrAll> = {
|
|
610
|
+
/**
|
|
611
|
+
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
|
|
612
|
+
|
|
613
|
+
This is `undefined` if either:
|
|
614
|
+
- the `all` option is `false` (the default value)
|
|
615
|
+
- both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
|
|
616
|
+
*/
|
|
617
|
+
all?: Readable;
|
|
618
|
+
|
|
619
|
+
catch<ResultType = never>(
|
|
620
|
+
onRejected?: (reason: ExecaError<StdoutStderrType>) => ResultType | PromiseLike<ResultType>
|
|
621
|
+
): Promise<ExecaReturnValue<StdoutStderrType> | ResultType>;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal), except if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`. Note that this graceful termination does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events) (`SIGKILL` and `SIGTERM` has the same effect of force-killing the process immediately.) If you want to achieve graceful termination on Windows, you have to use other means, such as [`taskkill`](https://github.com/sindresorhus/taskkill).
|
|
625
|
+
*/
|
|
626
|
+
kill(signal?: string, options?: KillOptions): void;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This used to be preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`. But now this is deprecated and you should either use `.kill()` or the `signal` option when creating the child process.
|
|
630
|
+
*/
|
|
631
|
+
cancel(): void;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process's `stdout` to `target`, which can be:
|
|
635
|
+
- Another `execa()` return value
|
|
636
|
+
- A writable stream
|
|
637
|
+
- A file path string
|
|
638
|
+
|
|
639
|
+
If the `target` is another `execa()` return value, it is returned. Otherwise, the original `execa()` return value is returned. This allows chaining `pipeStdout()` then `await`ing the final result.
|
|
640
|
+
|
|
641
|
+
The `stdout` option] must be kept as `pipe`, its default value.
|
|
642
|
+
*/
|
|
643
|
+
pipeStdout?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
644
|
+
pipeStdout?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
Like `pipeStdout()` but piping the child process's `stderr` instead.
|
|
648
|
+
|
|
649
|
+
The `stderr` option must be kept as `pipe`, its default value.
|
|
650
|
+
*/
|
|
651
|
+
pipeStderr?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
652
|
+
pipeStderr?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
Combines both `pipeStdout()` and `pipeStderr()`.
|
|
656
|
+
|
|
657
|
+
Either the `stdout` option or the `stderr` option must be kept as `pipe`, their default value. Also, the `all` option must be set to `true`.
|
|
658
|
+
*/
|
|
659
|
+
pipeAll?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
660
|
+
pipeAll?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
type ExecaChildProcess<StdoutStderrType extends StdoutStderrAll = string> = ChildProcess &
|
|
664
|
+
ExecaChildPromise<StdoutStderrType> &
|
|
665
|
+
Promise<ExecaReturnValue<StdoutStderrType>>;
|
|
666
|
+
|
|
667
|
+
type PackageJsonWithDepsAndDevDeps = PackageJson$1 & Required<Pick<PackageJson$1, 'dependencies' | 'devDependencies'>>;
|
|
668
|
+
|
|
669
|
+
type PackageMetadata = {
|
|
670
|
+
version: string;
|
|
671
|
+
location?: string;
|
|
672
|
+
reasons?: string[];
|
|
673
|
+
};
|
|
674
|
+
type InstallationMetadata = {
|
|
675
|
+
dependencies: Record<string, PackageMetadata[]>;
|
|
676
|
+
duplicatedDependencies: Record<string, string[]>;
|
|
677
|
+
infoCommand: string;
|
|
678
|
+
dedupeCommand: string;
|
|
193
679
|
};
|
|
194
680
|
|
|
195
|
-
type
|
|
681
|
+
type PackageManagerName = 'npm' | 'yarn1' | 'yarn2' | 'pnpm' | 'bun';
|
|
682
|
+
interface JsPackageManagerOptions {
|
|
683
|
+
cwd?: string;
|
|
684
|
+
configDir?: string;
|
|
685
|
+
storiesPaths?: string[];
|
|
686
|
+
}
|
|
687
|
+
type PackageJsonInfo = {
|
|
688
|
+
packageJsonPath: string;
|
|
689
|
+
operationDir: string;
|
|
690
|
+
packageJson: PackageJsonWithDepsAndDevDeps;
|
|
691
|
+
};
|
|
692
|
+
declare abstract class JsPackageManager {
|
|
693
|
+
#private;
|
|
694
|
+
abstract readonly type: PackageManagerName;
|
|
695
|
+
/** The path to the primary package.json file (contains the `storybook` dependency). */
|
|
696
|
+
readonly primaryPackageJson: PackageJsonInfo;
|
|
697
|
+
/** The paths to all package.json files in the project root. */
|
|
698
|
+
packageJsonPaths: string[];
|
|
699
|
+
/**
|
|
700
|
+
* The path to the Storybook instance directory. This is used to find the primary package.json
|
|
701
|
+
* file in a repository.
|
|
702
|
+
*/
|
|
703
|
+
readonly instanceDir: string;
|
|
704
|
+
/** The current working directory. */
|
|
705
|
+
protected readonly cwd: string;
|
|
706
|
+
/** Cache for latest version results to avoid repeated network calls. */
|
|
707
|
+
static readonly latestVersionCache: Map<string, string | null>;
|
|
708
|
+
/** Cache for installed version results to avoid repeated file system calls. */
|
|
709
|
+
static readonly installedVersionCache: Map<string, string | null>;
|
|
710
|
+
constructor(options?: JsPackageManagerOptions);
|
|
711
|
+
/** Runs arbitrary package scripts. */
|
|
712
|
+
abstract getRunCommand(command: string): string;
|
|
713
|
+
/**
|
|
714
|
+
* Run a command from a local or remote. Fetches a package from the registry without installing it
|
|
715
|
+
* as a dependency, hotloads it, and runs whatever default command binary it exposes.
|
|
716
|
+
*/
|
|
717
|
+
abstract getRemoteRunCommand(pkg: string, args: string[], specifier?: string): string;
|
|
718
|
+
/** Get the package.json file for a given module. */
|
|
719
|
+
abstract getModulePackageJSON(packageName: string): PackageJson$1 | null;
|
|
720
|
+
isStorybookInMonorepo(): boolean;
|
|
721
|
+
installDependencies(options?: {
|
|
722
|
+
force?: boolean;
|
|
723
|
+
}): Promise<void>;
|
|
724
|
+
dedupeDependencies(options?: {
|
|
725
|
+
force?: boolean;
|
|
726
|
+
}): Promise<void>;
|
|
727
|
+
/** Read the `package.json` file available in the provided directory */
|
|
728
|
+
static getPackageJson(packageJsonPath: string): PackageJsonWithDepsAndDevDeps;
|
|
729
|
+
writePackageJson(packageJson: PackageJson$1, directory?: string): void;
|
|
730
|
+
getAllDependencies(): Record<string, string>;
|
|
731
|
+
isDependencyInstalled(dependency: string): boolean;
|
|
732
|
+
/**
|
|
733
|
+
* Add dependencies to a project using `yarn add` or `npm install`.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
*
|
|
737
|
+
* ```ts
|
|
738
|
+
* addDependencies(options, [
|
|
739
|
+
* `@storybook/react@${storybookVersion}`,
|
|
740
|
+
* `@storybook/addon-links@${linksVersion}`,
|
|
741
|
+
* ]);
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies`
|
|
745
|
+
* which we use to determine how we install packages.
|
|
746
|
+
* @param {Array} dependencies Contains a list of packages to add.
|
|
747
|
+
*/
|
|
748
|
+
addDependencies(options: {
|
|
749
|
+
skipInstall: true;
|
|
750
|
+
type: 'dependencies' | 'devDependencies' | 'peerDependencies';
|
|
751
|
+
writeOutputToFile?: boolean;
|
|
752
|
+
packageJsonInfo?: PackageJsonInfo;
|
|
753
|
+
} | {
|
|
754
|
+
skipInstall?: false;
|
|
755
|
+
type: 'dependencies' | 'devDependencies';
|
|
756
|
+
writeOutputToFile?: boolean;
|
|
757
|
+
packageJsonInfo?: PackageJsonInfo;
|
|
758
|
+
}, dependencies: string[]): Promise<void | ExecaChildProcess>;
|
|
759
|
+
/**
|
|
760
|
+
* Removing dependencies from the package.json file, which is found first starting from the
|
|
761
|
+
* instance root. The method does not run a package manager install like `npm install`.
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
*
|
|
765
|
+
* ```ts
|
|
766
|
+
* removeDependencies([`@storybook/react`]);
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* @param dependencies Contains a list of packages to remove.
|
|
770
|
+
*/
|
|
771
|
+
removeDependencies(dependencies: string[]): Promise<void>;
|
|
772
|
+
/**
|
|
773
|
+
* Return an array of strings matching following format: `<package_name>@<package_latest_version>`
|
|
774
|
+
*
|
|
775
|
+
* For packages in the storybook monorepo, when the latest version is equal to the version of the
|
|
776
|
+
* current CLI the version is not added to the string.
|
|
777
|
+
*
|
|
778
|
+
* When a package is in the monorepo, and the version is not equal to the CLI version, the version
|
|
779
|
+
* is taken from the versions.ts file and added to the string.
|
|
780
|
+
*
|
|
781
|
+
* @param packages
|
|
782
|
+
*/
|
|
783
|
+
getVersionedPackages(packages: string[]): Promise<string[]>;
|
|
784
|
+
/**
|
|
785
|
+
* Return an array of string standing for the latest version of the input packages. To be able to
|
|
786
|
+
* identify which version goes with which package the order of the input array is keep.
|
|
787
|
+
*
|
|
788
|
+
* @param packageNames
|
|
789
|
+
*/
|
|
790
|
+
getVersions(...packageNames: string[]): Promise<string[]>;
|
|
791
|
+
/**
|
|
792
|
+
* Return the latest version of the input package available on npmjs registry. If constraint are
|
|
793
|
+
* provided it return the latest version matching the constraints.
|
|
794
|
+
*
|
|
795
|
+
* For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file
|
|
796
|
+
* directly
|
|
797
|
+
*
|
|
798
|
+
* @param packageName The name of the package
|
|
799
|
+
* @param constraint A valid semver constraint, example: '1.x || >=2.5.0 || 5.0.0 - 7.2.3'
|
|
800
|
+
*/
|
|
801
|
+
getVersion(packageName: string, constraint?: string): Promise<string>;
|
|
802
|
+
/**
|
|
803
|
+
* Get the latest version of the package available on npmjs.com. If constraint is set then it
|
|
804
|
+
* returns a version satisfying it, otherwise the latest version available is returned.
|
|
805
|
+
*
|
|
806
|
+
* @param packageName Name of the package
|
|
807
|
+
* @param constraint Version range to use to constraint the returned version
|
|
808
|
+
*/
|
|
809
|
+
latestVersion(packageName: string, constraint?: string): Promise<string | null>;
|
|
810
|
+
/**
|
|
811
|
+
* Clear the latest version cache. Useful for testing or when you want to refresh version
|
|
812
|
+
* information.
|
|
813
|
+
*
|
|
814
|
+
* @param packageName Optional package name to clear only specific entries. If not provided,
|
|
815
|
+
* clears all cache.
|
|
816
|
+
*/
|
|
817
|
+
static clearLatestVersionCache(packageName?: string): void;
|
|
818
|
+
/**
|
|
819
|
+
* Clear the installed version cache for a specific package or all packages.
|
|
820
|
+
*
|
|
821
|
+
* @param packageName Optional package name to clear from cache. If not provided, clears all.
|
|
822
|
+
*/
|
|
823
|
+
clearInstalledVersionCache(packageName?: string): void;
|
|
824
|
+
/**
|
|
825
|
+
* Clear both the latest version cache and installed version cache. This should be called after
|
|
826
|
+
* any operation that modifies dependencies.
|
|
827
|
+
*/
|
|
828
|
+
clearAllVersionCaches(): void;
|
|
829
|
+
addStorybookCommandInScripts(options?: {
|
|
830
|
+
port: number;
|
|
831
|
+
preCommand?: string;
|
|
832
|
+
}): void;
|
|
833
|
+
addScripts(scripts: Record<string, string>): void;
|
|
834
|
+
addPackageResolutions(versions: Record<string, string>): void;
|
|
835
|
+
protected abstract runInstall(options?: {
|
|
836
|
+
force?: boolean;
|
|
837
|
+
}): ExecaChildProcess;
|
|
838
|
+
protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean, writeOutputToFile?: boolean): ExecaChildProcess;
|
|
839
|
+
protected abstract getResolutions(packageJson: PackageJson$1, versions: Record<string, string>): Record<string, any>;
|
|
840
|
+
/**
|
|
841
|
+
* Get the latest or all versions of the input package available on npmjs.com
|
|
842
|
+
*
|
|
843
|
+
* @param packageName Name of the package
|
|
844
|
+
* @param fetchAllVersions Should return
|
|
845
|
+
*/
|
|
846
|
+
protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
|
|
847
|
+
abstract getRegistryURL(): Promise<string | undefined>;
|
|
848
|
+
abstract runInternalCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
|
|
849
|
+
abstract runPackageCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
|
|
850
|
+
abstract runPackageCommandSync(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): string;
|
|
851
|
+
abstract findInstallations(pattern?: string[]): Promise<InstallationMetadata | undefined>;
|
|
852
|
+
abstract findInstallations(pattern?: string[], options?: {
|
|
853
|
+
depth: number;
|
|
854
|
+
}): Promise<InstallationMetadata | undefined>;
|
|
855
|
+
abstract parseErrorFromLogs(logs?: string): string;
|
|
856
|
+
executeCommandSync({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
|
|
857
|
+
command: string;
|
|
858
|
+
args: string[];
|
|
859
|
+
cwd?: string;
|
|
860
|
+
ignoreError?: boolean;
|
|
861
|
+
}): string;
|
|
862
|
+
/**
|
|
863
|
+
* Execute a command asynchronously and return the execa process. This allows you to hook into
|
|
864
|
+
* stdout/stderr streams and monitor the process.
|
|
865
|
+
*
|
|
866
|
+
* @example Const process = packageManager.executeCommand({ command: 'npm', args: ['install'] });
|
|
867
|
+
* process.stdout?.on('data', (data) => console.log(data.toString())); const result = await
|
|
868
|
+
* process;
|
|
869
|
+
*/
|
|
870
|
+
executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
|
|
871
|
+
command: string;
|
|
872
|
+
args: string[];
|
|
873
|
+
cwd?: string;
|
|
874
|
+
ignoreError?: boolean;
|
|
875
|
+
}): ExecaChildProcess;
|
|
876
|
+
/** Returns the installed (within node_modules or pnp zip) version of a specified package */
|
|
877
|
+
getInstalledVersion(packageName: string): Promise<string | null>;
|
|
878
|
+
isPackageInstalled(packageName: string): Promise<boolean>;
|
|
879
|
+
/**
|
|
880
|
+
* Searches for a dependency/devDependency in all package.json files and returns the version of
|
|
881
|
+
* the dependency.
|
|
882
|
+
*/
|
|
883
|
+
getDependencyVersion(dependency: string): string | null;
|
|
884
|
+
static hasStorybookDependency(packageJsonPath: string): boolean;
|
|
885
|
+
static hasAnyStorybookDependency(packageJsonPath: string): boolean;
|
|
886
|
+
/** List all package.json files starting from the given directory and stopping at the project root. */
|
|
887
|
+
static listAllPackageJsonPaths(instanceDir: string, storiesPaths?: string[]): string[];
|
|
888
|
+
static getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
type NpmOptions = Parameters<JsPackageManager['addDependencies']>[0];
|
|
892
|
+
|
|
196
893
|
declare const SUPPORTED_ESLINT_EXTENSIONS: string[];
|
|
197
|
-
declare const findEslintFile: () => Promise<string | undefined>;
|
|
894
|
+
declare const findEslintFile: (instanceDir: string) => Promise<string | undefined>;
|
|
198
895
|
declare const configureFlatConfig: (code: string) => Promise<string>;
|
|
199
|
-
declare function extractEslintInfo(packageManager: JsPackageManager): Promise<{
|
|
896
|
+
declare function extractEslintInfo(packageManager: JsPackageManager$1): Promise<{
|
|
200
897
|
hasEslint: boolean;
|
|
201
898
|
isStorybookPluginInstalled: boolean;
|
|
202
899
|
eslintConfigFile: string | undefined;
|
|
@@ -206,7 +903,7 @@ declare function extractEslintInfo(packageManager: JsPackageManager): Promise<{
|
|
|
206
903
|
declare const normalizeExtends: (existingExtends: any) => string[];
|
|
207
904
|
declare function configureEslintPlugin({ eslintConfigFile, packageManager, isFlatConfig, }: {
|
|
208
905
|
eslintConfigFile: string | undefined;
|
|
209
|
-
packageManager: JsPackageManager;
|
|
906
|
+
packageManager: JsPackageManager$1;
|
|
210
907
|
isFlatConfig: boolean;
|
|
211
908
|
}): Promise<void>;
|
|
212
909
|
declare const suggestESLintPlugin: () => Promise<boolean>;
|
|
@@ -1184,4 +1881,4 @@ declare class Settings {
|
|
|
1184
1881
|
save(): Promise<void>;
|
|
1185
1882
|
}
|
|
1186
1883
|
|
|
1187
|
-
export { ANGULAR_JSON_PATH, AngularJSON, type Builder, CommunityBuilder, CoreBuilder, CoreWebpackCompilers, type ExternalFramework, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, SUPPORTED_RENDERERS, Settings, SupportedLanguage, type TemplateConfiguration, type TemplateMatcher, _clearGlobalSettings, addToDevDependenciesIfNotPresent, adjustTemplate, builderNameToCoreBuilder, cliStoriesTargetPath, coerceSemver, compilerNameToCoreCompiler, compoDocPreviewPrefix, configureEslintPlugin, configureFlatConfig, copyTemplate, copyTemplateFiles, detect, detectBuilder, detectFrameworkPreset, detectLanguage, detectPnp, externalFrameworks, extractEslintInfo, findEslintFile, frameworkToDefaultBuilder, getBabelDependencies, getRendererDir,
|
|
1884
|
+
export { ANGULAR_JSON_PATH, AngularJSON, type Builder, CommunityBuilder, CoreBuilder, CoreWebpackCompilers, type ExternalFramework, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, SUPPORTED_RENDERERS, Settings, SupportedLanguage, type TemplateConfiguration, type TemplateMatcher, _clearGlobalSettings, addToDevDependenciesIfNotPresent, adjustTemplate, builderNameToCoreBuilder, cliStoriesTargetPath, coerceSemver, compilerNameToCoreCompiler, compoDocPreviewPrefix, configureEslintPlugin, configureFlatConfig, copyTemplate, copyTemplateFiles, detect, detectBuilder, detectFrameworkPreset, detectLanguage, detectPnp, externalFrameworks, extractEslintInfo, findEslintFile, frameworkToDefaultBuilder, getBabelDependencies, getRendererDir, getVersionSafe, globalSettings, hasStorybookDependencies, installableProjectTypes, isNxProject, isStorybookInstantiated, normalizeExtends, promptForCompoDocs, readFileAsJson, suggestESLintPlugin, supportedTemplates, unsupportedTemplate, writeFileAsJson };
|