storybook 9.0.11 → 9.0.12
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 +5 -3
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +5 -3
- package/dist/core-server/index.cjs +4838 -4791
- package/dist/core-server/index.d.ts +10 -1
- package/dist/core-server/index.js +5746 -5699
- package/dist/core-server/presets/common-manager.js +257 -243
- package/dist/core-server/presets/common-preset.cjs +1047 -1045
- package/dist/core-server/presets/common-preset.js +2053 -2048
- package/dist/csf-tools/index.cjs +226 -224
- package/dist/csf-tools/index.js +116 -112
- package/dist/manager/globals-runtime.js +6 -4
- 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/common/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import * as storybook_internal_types from 'storybook/internal/types';
|
|
|
2
2
|
import { PresetConfig, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CLIOptions, LoadOptions, BuilderOptions, StorybookConfigRaw, LoadedPreset, Presets, PackageJson, CoreCommon_AddonInfo, SupportedFrameworks, SupportedRenderers, Options as Options$1, CoreCommon_StorybookInfo, Ref, StorybookConfig, StoriesEntry, NormalizedStoriesSpecifier } from 'storybook/internal/types';
|
|
3
3
|
export { PackageJson } from 'storybook/internal/types';
|
|
4
4
|
import { WriteStream } from 'node:fs';
|
|
5
|
-
import {
|
|
5
|
+
import { Buffer } from 'node:buffer';
|
|
6
|
+
import { ChildProcess } from 'node:child_process';
|
|
7
|
+
import { Readable, Writable, Stream } from 'node:stream';
|
|
6
8
|
import { ConfigFile } from 'storybook/internal/csf-tools';
|
|
7
9
|
|
|
8
10
|
declare const _default: {
|
|
@@ -439,6 +441,211 @@ type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption>
|
|
|
439
441
|
readonly verbose?: boolean;
|
|
440
442
|
};
|
|
441
443
|
|
|
444
|
+
type StdoutStderrAll = string | Buffer | undefined;
|
|
445
|
+
|
|
446
|
+
type ExecaReturnBase<StdoutStderrType extends StdoutStderrAll> = {
|
|
447
|
+
/**
|
|
448
|
+
The file and arguments that were run, for logging purposes.
|
|
449
|
+
|
|
450
|
+
This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
451
|
+
*/
|
|
452
|
+
command: string;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
Same as `command` but escaped.
|
|
456
|
+
|
|
457
|
+
This is meant to be copy and pasted into a shell, for debugging purposes.
|
|
458
|
+
Since the escaping is fairly basic, this should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
459
|
+
*/
|
|
460
|
+
escapedCommand: string;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
The numeric exit code of the process that was run.
|
|
464
|
+
*/
|
|
465
|
+
exitCode: number;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
The output of the process on stdout.
|
|
469
|
+
*/
|
|
470
|
+
stdout: StdoutStderrType;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
The output of the process on stderr.
|
|
474
|
+
*/
|
|
475
|
+
stderr: StdoutStderrType;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
Whether the process failed to run.
|
|
479
|
+
*/
|
|
480
|
+
failed: boolean;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
Whether the process timed out.
|
|
484
|
+
*/
|
|
485
|
+
timedOut: boolean;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
Whether the process was killed.
|
|
489
|
+
*/
|
|
490
|
+
killed: boolean;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
|
494
|
+
|
|
495
|
+
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
|
496
|
+
*/
|
|
497
|
+
signal?: string;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
|
501
|
+
|
|
502
|
+
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.
|
|
503
|
+
*/
|
|
504
|
+
signalDescription?: string;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
The `cwd` of the command if provided in the command options. Otherwise it is `process.cwd()`.
|
|
508
|
+
*/
|
|
509
|
+
cwd: string;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
type ExecaSyncReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
513
|
+
} & ExecaReturnBase<StdoutStderrType>;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
|
|
517
|
+
|
|
518
|
+
The child process fails when:
|
|
519
|
+
- its exit code is not `0`
|
|
520
|
+
- it was killed with a signal
|
|
521
|
+
- timing out
|
|
522
|
+
- being canceled
|
|
523
|
+
- there's not enough memory or there are already too many child processes
|
|
524
|
+
*/
|
|
525
|
+
type ExecaReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
526
|
+
/**
|
|
527
|
+
The output of the process with `stdout` and `stderr` interleaved.
|
|
528
|
+
|
|
529
|
+
This is `undefined` if either:
|
|
530
|
+
- the `all` option is `false` (default value)
|
|
531
|
+
- `execaSync()` was used
|
|
532
|
+
*/
|
|
533
|
+
all?: StdoutStderrType;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
Whether the process was canceled.
|
|
537
|
+
|
|
538
|
+
You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.
|
|
539
|
+
*/
|
|
540
|
+
isCanceled: boolean;
|
|
541
|
+
} & ExecaSyncReturnValue<StdoutStderrType>;
|
|
542
|
+
|
|
543
|
+
type ExecaSyncError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
544
|
+
/**
|
|
545
|
+
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.
|
|
546
|
+
|
|
547
|
+
The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.
|
|
548
|
+
*/
|
|
549
|
+
message: string;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
This is the same as the `message` property except it does not include the child process stdout/stderr.
|
|
553
|
+
*/
|
|
554
|
+
shortMessage: string;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
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.
|
|
558
|
+
|
|
559
|
+
This is `undefined` unless the child process exited due to an `error` event or a timeout.
|
|
560
|
+
*/
|
|
561
|
+
originalMessage?: string;
|
|
562
|
+
} & Error & ExecaReturnBase<StdoutStderrType>;
|
|
563
|
+
|
|
564
|
+
type ExecaError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
565
|
+
/**
|
|
566
|
+
The output of the process with `stdout` and `stderr` interleaved.
|
|
567
|
+
|
|
568
|
+
This is `undefined` if either:
|
|
569
|
+
- the `all` option is `false` (default value)
|
|
570
|
+
- `execaSync()` was used
|
|
571
|
+
*/
|
|
572
|
+
all?: StdoutStderrType;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
Whether the process was canceled.
|
|
576
|
+
*/
|
|
577
|
+
isCanceled: boolean;
|
|
578
|
+
} & ExecaSyncError<StdoutStderrType>;
|
|
579
|
+
|
|
580
|
+
type KillOptions = {
|
|
581
|
+
/**
|
|
582
|
+
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
|
|
583
|
+
|
|
584
|
+
Can be disabled with `false`.
|
|
585
|
+
|
|
586
|
+
@default 5000
|
|
587
|
+
*/
|
|
588
|
+
forceKillAfterTimeout?: number | false;
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
type ExecaChildPromise<StdoutStderrType extends StdoutStderrAll> = {
|
|
592
|
+
/**
|
|
593
|
+
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).
|
|
594
|
+
|
|
595
|
+
This is `undefined` if either:
|
|
596
|
+
- the `all` option is `false` (the default value)
|
|
597
|
+
- 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)
|
|
598
|
+
*/
|
|
599
|
+
all?: Readable;
|
|
600
|
+
|
|
601
|
+
catch<ResultType = never>(
|
|
602
|
+
onRejected?: (reason: ExecaError<StdoutStderrType>) => ResultType | PromiseLike<ResultType>
|
|
603
|
+
): Promise<ExecaReturnValue<StdoutStderrType> | ResultType>;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
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).
|
|
607
|
+
*/
|
|
608
|
+
kill(signal?: string, options?: KillOptions): void;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
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.
|
|
612
|
+
*/
|
|
613
|
+
cancel(): void;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process's `stdout` to `target`, which can be:
|
|
617
|
+
- Another `execa()` return value
|
|
618
|
+
- A writable stream
|
|
619
|
+
- A file path string
|
|
620
|
+
|
|
621
|
+
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.
|
|
622
|
+
|
|
623
|
+
The `stdout` option] must be kept as `pipe`, its default value.
|
|
624
|
+
*/
|
|
625
|
+
pipeStdout?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
626
|
+
pipeStdout?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
Like `pipeStdout()` but piping the child process's `stderr` instead.
|
|
630
|
+
|
|
631
|
+
The `stderr` option must be kept as `pipe`, its default value.
|
|
632
|
+
*/
|
|
633
|
+
pipeStderr?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
634
|
+
pipeStderr?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
Combines both `pipeStdout()` and `pipeStderr()`.
|
|
638
|
+
|
|
639
|
+
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`.
|
|
640
|
+
*/
|
|
641
|
+
pipeAll?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
642
|
+
pipeAll?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
type ExecaChildProcess<StdoutStderrType extends StdoutStderrAll = string> = ChildProcess &
|
|
646
|
+
ExecaChildPromise<StdoutStderrType> &
|
|
647
|
+
Promise<ExecaReturnValue<StdoutStderrType>>;
|
|
648
|
+
|
|
442
649
|
type PackageJsonWithDepsAndDevDeps = PackageJson & Required<Pick<PackageJson, 'dependencies' | 'devDependencies'>>;
|
|
443
650
|
type PackageJsonWithMaybeDeps = Partial<Pick<PackageJson, 'dependencies' | 'devDependencies' | 'peerDependencies' | 'files'>>;
|
|
444
651
|
|
|
@@ -469,36 +676,54 @@ declare const COMMON_ENV_VARS: {
|
|
|
469
676
|
declare function getPackageDetails(pkg: string): [string, string?];
|
|
470
677
|
interface JsPackageManagerOptions {
|
|
471
678
|
cwd?: string;
|
|
679
|
+
configDir?: string;
|
|
680
|
+
storiesPaths?: string[];
|
|
472
681
|
}
|
|
682
|
+
type PackageJsonInfo = {
|
|
683
|
+
packageJsonPath: string;
|
|
684
|
+
operationDir: string;
|
|
685
|
+
packageJson: PackageJsonWithDepsAndDevDeps;
|
|
686
|
+
};
|
|
473
687
|
declare abstract class JsPackageManager {
|
|
688
|
+
#private;
|
|
474
689
|
abstract readonly type: PackageManagerName;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
readonly cwd?: string;
|
|
480
|
-
abstract getPackageJSON(packageName: string, basePath?: string): Promise<PackageJson | null>;
|
|
481
|
-
/** Get the INSTALLED version of a package from the package.json file */
|
|
482
|
-
getPackageVersion(packageName: string, basePath?: string | undefined): Promise<string | null>;
|
|
483
|
-
constructor(options?: JsPackageManagerOptions);
|
|
690
|
+
/** The path to the primary package.json file (contains the `storybook` dependency). */
|
|
691
|
+
readonly primaryPackageJson: PackageJsonInfo;
|
|
692
|
+
/** The paths to all package.json files in the project root. */
|
|
693
|
+
packageJsonPaths: string[];
|
|
484
694
|
/**
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
* @returns `true`, if Storybook is initialized inside a mono-repository/workspace
|
|
695
|
+
* The path to the Storybook instance directory. This is used to find the primary package.json
|
|
696
|
+
* file in a repository.
|
|
489
697
|
*/
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
698
|
+
readonly instanceDir: string;
|
|
699
|
+
/** The current working directory. */
|
|
700
|
+
protected readonly cwd: string;
|
|
701
|
+
/** Cache for latest version results to avoid repeated network calls. */
|
|
702
|
+
static readonly latestVersionCache: Map<string, string | null>;
|
|
703
|
+
/** Cache for installed version results to avoid repeated file system calls. */
|
|
704
|
+
static readonly installedVersionCache: Map<string, string | null>;
|
|
705
|
+
constructor(options?: JsPackageManagerOptions);
|
|
706
|
+
/** Runs arbitrary package scripts. */
|
|
707
|
+
abstract getRunCommand(command: string): string;
|
|
496
708
|
/**
|
|
497
|
-
*
|
|
498
|
-
*
|
|
709
|
+
* Run a command from a local or remote. Fetches a package from the registry without installing it
|
|
710
|
+
* as a dependency, hotloads it, and runs whatever default command binary it exposes.
|
|
499
711
|
*/
|
|
500
|
-
|
|
501
|
-
|
|
712
|
+
abstract getRemoteRunCommand(pkg: string, args: string[], specifier?: string): string;
|
|
713
|
+
/** Get the package.json file for a given module. */
|
|
714
|
+
abstract getModulePackageJSON(packageName: string): PackageJson | null;
|
|
715
|
+
isStorybookInMonorepo(): boolean;
|
|
716
|
+
installDependencies(options?: {
|
|
717
|
+
force?: boolean;
|
|
718
|
+
}): Promise<void>;
|
|
719
|
+
dedupeDependencies(options?: {
|
|
720
|
+
force?: boolean;
|
|
721
|
+
}): Promise<void>;
|
|
722
|
+
/** Read the `package.json` file available in the provided directory */
|
|
723
|
+
static getPackageJson(packageJsonPath: string): PackageJsonWithDepsAndDevDeps;
|
|
724
|
+
writePackageJson(packageJson: PackageJson, directory?: string): void;
|
|
725
|
+
getAllDependencies(): Record<string, string>;
|
|
726
|
+
isDependencyInstalled(dependency: string): boolean;
|
|
502
727
|
/**
|
|
503
728
|
* Add dependencies to a project using `yarn add` or `npm install`.
|
|
504
729
|
*
|
|
@@ -516,32 +741,29 @@ declare abstract class JsPackageManager {
|
|
|
516
741
|
* @param {Array} dependencies Contains a list of packages to add.
|
|
517
742
|
*/
|
|
518
743
|
addDependencies(options: {
|
|
519
|
-
|
|
744
|
+
skipInstall: true;
|
|
745
|
+
type: 'dependencies' | 'devDependencies' | 'peerDependencies';
|
|
520
746
|
writeOutputToFile?: boolean;
|
|
521
|
-
|
|
522
|
-
skipInstall?: false;
|
|
523
|
-
packageJson?: PackageJson;
|
|
747
|
+
packageJsonInfo?: PackageJsonInfo;
|
|
524
748
|
} | {
|
|
525
|
-
skipInstall
|
|
526
|
-
|
|
527
|
-
|
|
749
|
+
skipInstall?: false;
|
|
750
|
+
type: 'dependencies' | 'devDependencies';
|
|
751
|
+
writeOutputToFile?: boolean;
|
|
752
|
+
packageJsonInfo?: PackageJsonInfo;
|
|
753
|
+
}, dependencies: string[]): Promise<void | ExecaChildProcess>;
|
|
528
754
|
/**
|
|
529
|
-
*
|
|
755
|
+
* Removing dependencies from the package.json file, which is found first starting from the
|
|
756
|
+
* instance root. The method does not run a package manager install like `npm install`.
|
|
530
757
|
*
|
|
531
758
|
* @example
|
|
532
759
|
*
|
|
533
760
|
* ```ts
|
|
534
|
-
* removeDependencies(
|
|
761
|
+
* removeDependencies([`@storybook/react`]);
|
|
535
762
|
* ```
|
|
536
763
|
*
|
|
537
|
-
* @param
|
|
538
|
-
* which we use to determine how we install packages.
|
|
539
|
-
* @param {Array} dependencies Contains a list of packages to remove.
|
|
764
|
+
* @param dependencies Contains a list of packages to remove.
|
|
540
765
|
*/
|
|
541
|
-
removeDependencies(
|
|
542
|
-
skipInstall?: boolean;
|
|
543
|
-
packageJson?: PackageJson;
|
|
544
|
-
}, dependencies: string[]): Promise<void>;
|
|
766
|
+
removeDependencies(dependencies: string[]): Promise<void>;
|
|
545
767
|
/**
|
|
546
768
|
* Return an array of strings matching following format: `<package_name>@<package_latest_version>`
|
|
547
769
|
*
|
|
@@ -579,16 +801,36 @@ declare abstract class JsPackageManager {
|
|
|
579
801
|
* @param packageName Name of the package
|
|
580
802
|
* @param constraint Version range to use to constraint the returned version
|
|
581
803
|
*/
|
|
582
|
-
latestVersion(packageName: string, constraint?: string): Promise<string>;
|
|
804
|
+
latestVersion(packageName: string, constraint?: string): Promise<string | null>;
|
|
805
|
+
/**
|
|
806
|
+
* Clear the latest version cache. Useful for testing or when you want to refresh version
|
|
807
|
+
* information.
|
|
808
|
+
*
|
|
809
|
+
* @param packageName Optional package name to clear only specific entries. If not provided,
|
|
810
|
+
* clears all cache.
|
|
811
|
+
*/
|
|
812
|
+
static clearLatestVersionCache(packageName?: string): void;
|
|
813
|
+
/**
|
|
814
|
+
* Clear the installed version cache for a specific package or all packages.
|
|
815
|
+
*
|
|
816
|
+
* @param packageName Optional package name to clear from cache. If not provided, clears all.
|
|
817
|
+
*/
|
|
818
|
+
clearInstalledVersionCache(packageName?: string): void;
|
|
819
|
+
/**
|
|
820
|
+
* Clear both the latest version cache and installed version cache. This should be called after
|
|
821
|
+
* any operation that modifies dependencies.
|
|
822
|
+
*/
|
|
823
|
+
clearAllVersionCaches(): void;
|
|
583
824
|
addStorybookCommandInScripts(options?: {
|
|
584
825
|
port: number;
|
|
585
826
|
preCommand?: string;
|
|
586
|
-
}):
|
|
587
|
-
addScripts(scripts: Record<string, string>):
|
|
588
|
-
addPackageResolutions(versions: Record<string, string>):
|
|
589
|
-
protected abstract runInstall(
|
|
590
|
-
|
|
591
|
-
|
|
827
|
+
}): void;
|
|
828
|
+
addScripts(scripts: Record<string, string>): void;
|
|
829
|
+
addPackageResolutions(versions: Record<string, string>): void;
|
|
830
|
+
protected abstract runInstall(options?: {
|
|
831
|
+
force?: boolean;
|
|
832
|
+
}): ExecaChildProcess;
|
|
833
|
+
protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean, writeOutputToFile?: boolean): ExecaChildProcess;
|
|
592
834
|
protected abstract getResolutions(packageJson: PackageJson, versions: Record<string, string>): Record<string, any>;
|
|
593
835
|
/**
|
|
594
836
|
* Get the latest or all versions of the input package available on npmjs.com
|
|
@@ -598,8 +840,9 @@ declare abstract class JsPackageManager {
|
|
|
598
840
|
*/
|
|
599
841
|
protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
|
|
600
842
|
abstract getRegistryURL(): Promise<string | undefined>;
|
|
601
|
-
abstract
|
|
602
|
-
abstract
|
|
843
|
+
abstract runInternalCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
|
|
844
|
+
abstract runPackageCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
|
|
845
|
+
abstract runPackageCommandSync(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): string;
|
|
603
846
|
abstract findInstallations(pattern?: string[]): Promise<InstallationMetadata | undefined>;
|
|
604
847
|
abstract findInstallations(pattern?: string[], options?: {
|
|
605
848
|
depth: number;
|
|
@@ -611,19 +854,55 @@ declare abstract class JsPackageManager {
|
|
|
611
854
|
cwd?: string;
|
|
612
855
|
ignoreError?: boolean;
|
|
613
856
|
}): string;
|
|
614
|
-
/**
|
|
615
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Execute a command asynchronously and return the execa process. This allows you to hook into
|
|
859
|
+
* stdout/stderr streams and monitor the process.
|
|
860
|
+
*
|
|
861
|
+
* @example Const process = packageManager.executeCommand({ command: 'npm', args: ['install'] });
|
|
862
|
+
* process.stdout?.on('data', (data) => console.log(data.toString())); const result = await
|
|
863
|
+
* process;
|
|
864
|
+
*/
|
|
616
865
|
executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
|
|
617
866
|
command: string;
|
|
618
867
|
args: string[];
|
|
619
868
|
cwd?: string;
|
|
620
869
|
ignoreError?: boolean;
|
|
621
|
-
}):
|
|
870
|
+
}): ExecaChildProcess;
|
|
871
|
+
/** Returns the installed (within node_modules or pnp zip) version of a specified package */
|
|
872
|
+
getInstalledVersion(packageName: string): Promise<string | null>;
|
|
873
|
+
isPackageInstalled(packageName: string): Promise<boolean>;
|
|
874
|
+
/**
|
|
875
|
+
* Searches for a dependency/devDependency in all package.json files and returns the version of
|
|
876
|
+
* the dependency.
|
|
877
|
+
*/
|
|
878
|
+
getDependencyVersion(dependency: string): string | null;
|
|
879
|
+
static hasStorybookDependency(packageJsonPath: string): boolean;
|
|
880
|
+
static hasAnyStorybookDependency(packageJsonPath: string): boolean;
|
|
881
|
+
/** List all package.json files starting from the given directory and stopping at the project root. */
|
|
882
|
+
static listAllPackageJsonPaths(instanceDir: string, storiesPaths?: string[]): string[];
|
|
883
|
+
static getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo;
|
|
622
884
|
}
|
|
623
885
|
|
|
624
886
|
declare class JsPackageManagerFactory {
|
|
625
|
-
|
|
887
|
+
/** Cache for package manager instances */
|
|
888
|
+
private static cache;
|
|
889
|
+
/** Generate a cache key based on the parameters */
|
|
890
|
+
private static getCacheKey;
|
|
891
|
+
/** Clear the package manager cache */
|
|
892
|
+
static clearCache(): void;
|
|
893
|
+
/**
|
|
894
|
+
* Determine which package manager type to use based on lockfiles, commands, and environment
|
|
895
|
+
*
|
|
896
|
+
* @param cwd - Current working directory
|
|
897
|
+
* @returns Package manager type as string: 'npm', 'pnpm', 'bun', 'yarn1', or 'yarn2'
|
|
898
|
+
* @throws Error if no usable package manager is found
|
|
899
|
+
*/
|
|
900
|
+
static getPackageManagerType(cwd?: string): PackageManagerName;
|
|
901
|
+
static getPackageManager({ force, configDir, storiesPaths, ignoreCache, }?: {
|
|
626
902
|
force?: PackageManagerName;
|
|
903
|
+
configDir?: string;
|
|
904
|
+
storiesPaths?: string[];
|
|
905
|
+
ignoreCache?: boolean;
|
|
627
906
|
}, cwd?: string): JsPackageManager;
|
|
628
907
|
/** Look up map of package manager proxies by name */
|
|
629
908
|
private static PROXY_MAP;
|
|
@@ -785,13 +1064,13 @@ declare const rendererPackages: Record<string, string>;
|
|
|
785
1064
|
declare const frameworkPackages: Record<string, SupportedFrameworks>;
|
|
786
1065
|
declare const builderPackages: string[];
|
|
787
1066
|
declare const findConfigFile: (prefix: string, configDir: string) => string | null;
|
|
788
|
-
declare const getConfigInfo: (
|
|
1067
|
+
declare const getConfigInfo: (configDir?: string) => {
|
|
789
1068
|
configDir: string;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1069
|
+
mainConfigPath: string | null;
|
|
1070
|
+
previewConfigPath: string | null;
|
|
1071
|
+
managerConfigPath: string | null;
|
|
793
1072
|
};
|
|
794
|
-
declare const getStorybookInfo: (
|
|
1073
|
+
declare const getStorybookInfo: (configDir?: string) => CoreCommon_StorybookInfo;
|
|
795
1074
|
|
|
796
1075
|
declare const getAutoRefs: (options: Options$1) => Promise<Record<string, Ref>>;
|
|
797
1076
|
declare function getRefs(options: Options$1): Promise<Record<string, Ref>>;
|
|
@@ -829,9 +1108,10 @@ declare function loadCustomPresets({ configDir }: {
|
|
|
829
1108
|
configDir: string;
|
|
830
1109
|
}): PresetConfig[];
|
|
831
1110
|
|
|
832
|
-
declare function loadMainConfig({ configDir, noCache, }: {
|
|
1111
|
+
declare function loadMainConfig({ configDir, noCache, cwd, }: {
|
|
833
1112
|
configDir: string;
|
|
834
1113
|
noCache?: boolean;
|
|
1114
|
+
cwd?: string;
|
|
835
1115
|
}): Promise<StorybookConfig>;
|
|
836
1116
|
|
|
837
1117
|
declare function loadManagerOrAddonsFile({ configDir }: {
|
|
@@ -862,12 +1142,18 @@ interface NormalizeOptions {
|
|
|
862
1142
|
declare const normalizeStories: (entries: StoriesEntry[], options: NormalizeOptions) => NormalizedStoriesSpecifier[];
|
|
863
1143
|
|
|
864
1144
|
declare const getProjectRoot: () => string;
|
|
1145
|
+
declare const invalidateProjectRootCache: () => void;
|
|
865
1146
|
declare const nodePathsToArray: (nodePath: string) => string[];
|
|
866
1147
|
/** Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` */
|
|
867
1148
|
declare function normalizeStoryPath(filename: string): string;
|
|
868
1149
|
|
|
869
1150
|
declare function readTemplate(filename: string): Promise<string>;
|
|
870
1151
|
|
|
1152
|
+
type RemoveAddonOptions = {
|
|
1153
|
+
packageManager: JsPackageManager;
|
|
1154
|
+
configDir?: string;
|
|
1155
|
+
skipInstall?: boolean;
|
|
1156
|
+
};
|
|
871
1157
|
/**
|
|
872
1158
|
* Remove the given addon package and remove it from main.js
|
|
873
1159
|
*
|
|
@@ -877,11 +1163,7 @@ declare function readTemplate(filename: string): Promise<string>;
|
|
|
877
1163
|
* sb remove @storybook/addon-links
|
|
878
1164
|
* ```
|
|
879
1165
|
*/
|
|
880
|
-
declare function removeAddon(addon: string, options
|
|
881
|
-
packageManager?: PackageManagerName;
|
|
882
|
-
cwd?: string;
|
|
883
|
-
configDir?: string;
|
|
884
|
-
}): Promise<void>;
|
|
1166
|
+
declare function removeAddon(addon: string, options: RemoveAddonOptions): Promise<void>;
|
|
885
1167
|
|
|
886
1168
|
/**
|
|
887
1169
|
* Get the path of the file or directory with input name inside the Storybook cache directory:
|
|
@@ -901,7 +1183,7 @@ declare function getPreviewHeadTemplate(configDirPath: string, interpolations?:
|
|
|
901
1183
|
|
|
902
1184
|
declare function validateFrameworkName(frameworkName: string | undefined): asserts frameworkName is string;
|
|
903
1185
|
|
|
904
|
-
declare function validateConfigurationFiles(configDir: string): Promise<void>;
|
|
1186
|
+
declare function validateConfigurationFiles(configDir: string, cwd?: string): Promise<void>;
|
|
905
1187
|
|
|
906
1188
|
/** Mimicking the satisfies operator until we can upgrade to TS4.9 */
|
|
907
1189
|
declare function satisfies<A>(): <T extends A>(x: T) => T;
|
|
@@ -967,4 +1249,4 @@ declare const transformImportFiles: (files: string[], renamedImports: Record<str
|
|
|
967
1249
|
error: Error;
|
|
968
1250
|
}[]>;
|
|
969
1251
|
|
|
970
|
-
export { COMMON_ENV_VARS, DEFAULT_FILES_PATTERN, type FileOptions, FileSystemCache, HandledError, type InstallationMetadata, JsPackageManager, JsPackageManagerFactory, type PackageJsonWithDepsAndDevDeps, type PackageJsonWithMaybeDeps, type PackageManagerName, type PackageMetadata, boost, builderPackages, cache, checkAddonOrder, codeLog, commandLog, commonGlobOptions, createFileSystemCache, createLogStream, extractProperFrameworkName, extractProperRendererNameFromFramework, filterPresetsConfig, findConfigFile, formatFileContent, frameworkPackages, frameworkToRenderer, getAddonNames, getAutoRefs, getBuilderOptions, getChars, getCoercedStorybookVersion, getConfigInfo, getDirectoryFromWorkingDir, getEnvConfig, getFrameworkName, getInterpretedFile, getInterpretedFileWithExt, getPackageDetails, getPresets, getPreviewBodyTemplate, getPreviewHeadTemplate, getProjectRoot, getRefs, getRendererName, getStoryId, getStoryTitle, getStorybookConfiguration, getStorybookInfo, getSyncedStorybookAddons, globToRegexp, interopRequireDefault, interpolate, isCorePackage, isPreservingSymlinks, isSatelliteAddon, loadAllPresets, loadCustomPresets, loadEnvs, loadMainConfig, loadManagerOrAddonsFile, loadPreset, loadPreviewOrConfigFile, logConfig, nodePathsToArray, normalizeStories, normalizeStoriesEntry, normalizeStoryPath, paddedLog, parseList, posix, readTemplate, removeAddon, rendererPackages, resolveAddonName, resolvePathInStorybookCache, satisfies, scanAndTransformFiles, serverRequire, serverResolve, stringifyEnvs, stringifyProcessEnvs, stripAbsNodeModulesPath, syncStorybookAddons, temporaryDirectory, temporaryFile, transformImportFiles, validateConfigurationFiles, validateFrameworkName, _default as versions };
|
|
1252
|
+
export { COMMON_ENV_VARS, DEFAULT_FILES_PATTERN, type FileOptions, FileSystemCache, HandledError, type InstallationMetadata, JsPackageManager, JsPackageManagerFactory, type PackageJsonInfo, type PackageJsonWithDepsAndDevDeps, type PackageJsonWithMaybeDeps, type PackageManagerName, type PackageMetadata, type RemoveAddonOptions, boost, builderPackages, cache, checkAddonOrder, codeLog, commandLog, commonGlobOptions, createFileSystemCache, createLogStream, extractProperFrameworkName, extractProperRendererNameFromFramework, filterPresetsConfig, findConfigFile, formatFileContent, frameworkPackages, frameworkToRenderer, getAddonNames, getAutoRefs, getBuilderOptions, getChars, getCoercedStorybookVersion, getConfigInfo, getDirectoryFromWorkingDir, getEnvConfig, getFrameworkName, getInterpretedFile, getInterpretedFileWithExt, getPackageDetails, getPresets, getPreviewBodyTemplate, getPreviewHeadTemplate, getProjectRoot, getRefs, getRendererName, getStoryId, getStoryTitle, getStorybookConfiguration, getStorybookInfo, getSyncedStorybookAddons, globToRegexp, interopRequireDefault, interpolate, invalidateProjectRootCache, isCorePackage, isPreservingSymlinks, isSatelliteAddon, loadAllPresets, loadCustomPresets, loadEnvs, loadMainConfig, loadManagerOrAddonsFile, loadPreset, loadPreviewOrConfigFile, logConfig, nodePathsToArray, normalizeStories, normalizeStoriesEntry, normalizeStoryPath, paddedLog, parseList, posix, readTemplate, removeAddon, rendererPackages, resolveAddonName, resolvePathInStorybookCache, satisfies, scanAndTransformFiles, serverRequire, serverResolve, stringifyEnvs, stringifyProcessEnvs, stripAbsNodeModulesPath, syncStorybookAddons, temporaryDirectory, temporaryFile, transformImportFiles, validateConfigurationFiles, validateFrameworkName, _default as versions };
|