storybook 9.1.0-alpha.5 → 9.1.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/assets/browser/favicon-wrapper.svg +46 -0
  2. package/assets/browser/favicon.svg +1 -1
  3. package/dist/bin/index.cjs +62 -69
  4. package/dist/bin/index.js +43 -50
  5. package/dist/cli/bin/index.cjs +932 -932
  6. package/dist/cli/bin/index.js +635 -634
  7. package/dist/cli/index.cjs +14965 -14973
  8. package/dist/cli/index.d.ts +713 -15
  9. package/dist/cli/index.js +13488 -13495
  10. package/dist/common/index.cjs +13169 -13067
  11. package/dist/common/index.d.ts +348 -73
  12. package/dist/common/index.js +24024 -23919
  13. package/dist/components/index.cjs +1462 -1448
  14. package/dist/components/index.d.ts +3 -1
  15. package/dist/components/index.js +412 -397
  16. package/dist/core-server/index.cjs +6649 -6588
  17. package/dist/core-server/index.d.ts +14 -2
  18. package/dist/core-server/index.js +6053 -5993
  19. package/dist/core-server/presets/common-manager.js +3438 -3353
  20. package/dist/core-server/presets/common-preset.cjs +2370 -2374
  21. package/dist/core-server/presets/common-preset.js +1881 -1881
  22. package/dist/csf/index.cjs +2536 -736
  23. package/dist/csf/index.d.ts +251 -9
  24. package/dist/csf/index.js +2558 -749
  25. package/dist/csf-tools/index.cjs +226 -224
  26. package/dist/csf-tools/index.js +116 -112
  27. package/dist/instrumenter/index.cjs +1150 -1099
  28. package/dist/instrumenter/index.d.ts +1 -0
  29. package/dist/instrumenter/index.js +1261 -1214
  30. package/dist/manager/globals-runtime.js +21317 -23959
  31. package/dist/manager/runtime.js +3713 -3534
  32. package/dist/manager-api/index.cjs +74 -74
  33. package/dist/manager-api/index.d.ts +8 -531
  34. package/dist/manager-api/index.js +142 -142
  35. package/dist/node-logger/index.cjs +8520 -994
  36. package/dist/node-logger/index.d.ts +395 -2
  37. package/dist/node-logger/index.js +8535 -995
  38. package/dist/preview/runtime.js +13337 -16032
  39. package/dist/preview-api/index.cjs +273 -271
  40. package/dist/preview-api/index.d.ts +4 -1
  41. package/dist/preview-api/index.js +14 -12
  42. package/dist/server-errors.cjs +201 -242
  43. package/dist/server-errors.d.ts +1 -12
  44. package/dist/server-errors.js +182 -223
  45. package/dist/telemetry/index.cjs +1314 -1313
  46. package/dist/telemetry/index.d.ts +3 -2
  47. package/dist/telemetry/index.js +1195 -1192
  48. package/dist/test/index.cjs +9136 -9815
  49. package/dist/test/index.js +8339 -9025
  50. package/dist/types/index.d.ts +15 -15
  51. package/package.json +6 -188
  52. package/dist/actions/preview.cjs +0 -159
  53. package/dist/actions/preview.d.ts +0 -45
  54. package/dist/actions/preview.js +0 -149
  55. package/dist/backgrounds/index.cjs +0 -16
  56. package/dist/backgrounds/index.d.ts +0 -2
  57. package/dist/backgrounds/index.js +0 -0
  58. package/dist/backgrounds/preview.cjs +0 -143
  59. package/dist/backgrounds/preview.d.ts +0 -53
  60. package/dist/backgrounds/preview.js +0 -127
  61. package/dist/component-testing/index.cjs +0 -23
  62. package/dist/component-testing/index.d.ts +0 -3
  63. package/dist/component-testing/index.js +0 -5
  64. package/dist/component-testing/preview.cjs +0 -40
  65. package/dist/component-testing/preview.d.ts +0 -5
  66. package/dist/component-testing/preview.js +0 -25
  67. package/dist/controls/preview.cjs +0 -26
  68. package/dist/controls/preview.d.ts +0 -43
  69. package/dist/controls/preview.js +0 -9
  70. package/dist/highlight/preview.cjs +0 -590
  71. package/dist/highlight/preview.d.ts +0 -20
  72. package/dist/highlight/preview.js +0 -575
  73. package/dist/measure/index.cjs +0 -16
  74. package/dist/measure/index.d.ts +0 -2
  75. package/dist/measure/index.js +0 -0
  76. package/dist/measure/preview.cjs +0 -466
  77. package/dist/measure/preview.d.ts +0 -25
  78. package/dist/measure/preview.js +0 -450
  79. package/dist/outline/index.cjs +0 -16
  80. package/dist/outline/index.d.ts +0 -2
  81. package/dist/outline/index.js +0 -0
  82. package/dist/outline/preview.cjs +0 -518
  83. package/dist/outline/preview.d.ts +0 -25
  84. package/dist/outline/preview.js +0 -486
  85. package/dist/test/preview.cjs +0 -73
  86. package/dist/test/preview.d.ts +0 -17
  87. package/dist/test/preview.js +0 -66
  88. package/dist/viewport/preview.cjs +0 -35
  89. package/dist/viewport/preview.d.ts +0 -62
  90. package/dist/viewport/preview.js +0 -19
@@ -2,24 +2,19 @@ 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 { Stream } from 'node:stream';
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: {
9
11
  '@storybook/addon-a11y': string;
10
- '@storybook/addon-actions': string;
11
- '@storybook/addon-backgrounds': string;
12
- '@storybook/addon-controls': string;
13
12
  '@storybook/addon-docs': string;
14
13
  '@storybook/addon-jest': string;
15
14
  '@storybook/addon-links': string;
16
- '@storybook/addon-measure': string;
17
15
  '@storybook/addon-onboarding': string;
18
- '@storybook/addon-outline': string;
19
16
  'storybook-addon-pseudo-states': string;
20
17
  '@storybook/addon-themes': string;
21
- '@storybook/addon-toolbars': string;
22
- '@storybook/addon-viewport': string;
23
18
  '@storybook/addon-vitest': string;
24
19
  '@storybook/builder-vite': string;
25
20
  '@storybook/builder-webpack5': string;
@@ -446,6 +441,211 @@ type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption>
446
441
  readonly verbose?: boolean;
447
442
  };
448
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
+
449
649
  type PackageJsonWithDepsAndDevDeps = PackageJson & Required<Pick<PackageJson, 'dependencies' | 'devDependencies'>>;
450
650
  type PackageJsonWithMaybeDeps = Partial<Pick<PackageJson, 'dependencies' | 'devDependencies' | 'peerDependencies' | 'files'>>;
451
651
 
@@ -476,36 +676,54 @@ declare const COMMON_ENV_VARS: {
476
676
  declare function getPackageDetails(pkg: string): [string, string?];
477
677
  interface JsPackageManagerOptions {
478
678
  cwd?: string;
679
+ configDir?: string;
680
+ storiesPaths?: string[];
479
681
  }
682
+ type PackageJsonInfo = {
683
+ packageJsonPath: string;
684
+ operationDir: string;
685
+ packageJson: PackageJsonWithDepsAndDevDeps;
686
+ };
480
687
  declare abstract class JsPackageManager {
688
+ #private;
481
689
  abstract readonly type: PackageManagerName;
482
- abstract initPackageJson(): Promise<void>;
483
- abstract getRunStorybookCommand(): string;
484
- abstract getRunCommand(command: string): string;
485
- abstract getRemoteRunCommand(): string;
486
- readonly cwd?: string;
487
- abstract getPackageJSON(packageName: string, basePath?: string): Promise<PackageJson | null>;
488
- /** Get the INSTALLED version of a package from the package.json file */
489
- getPackageVersion(packageName: string, basePath?: string | undefined): Promise<string | null>;
490
- 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[];
491
694
  /**
492
- * Detect whether Storybook gets initialized in a mono-repository/workspace environment The cwd
493
- * doesn't have to be the root of the monorepo, it can be a subdirectory
494
- *
495
- * @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.
496
697
  */
497
- isStorybookInMonorepo(): boolean;
498
- /** Install dependencies listed in `package.json` */
499
- installDependencies(): Promise<void>;
500
- packageJsonPath(): string;
501
- readPackageJson(): Promise<PackageJson>;
502
- writePackageJson(packageJson: PackageJson): Promise<void>;
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;
503
708
  /**
504
- * Read the `package.json` file available in the directory the command was call from If there is
505
- * no `package.json` it will create one.
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.
506
711
  */
507
- retrievePackageJson(): Promise<PackageJsonWithDepsAndDevDeps>;
508
- getAllDependencies(): Promise<Partial<Record<string, string>>>;
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;
509
727
  /**
510
728
  * Add dependencies to a project using `yarn add` or `npm install`.
511
729
  *
@@ -523,32 +741,29 @@ declare abstract class JsPackageManager {
523
741
  * @param {Array} dependencies Contains a list of packages to add.
524
742
  */
525
743
  addDependencies(options: {
526
- installAsDevDependencies?: boolean;
744
+ skipInstall: true;
745
+ type: 'dependencies' | 'devDependencies' | 'peerDependencies';
527
746
  writeOutputToFile?: boolean;
528
- } & ({
529
- skipInstall?: false;
530
- packageJson?: PackageJson;
747
+ packageJsonInfo?: PackageJsonInfo;
531
748
  } | {
532
- skipInstall: true;
533
- packageJson: PackageJson;
534
- }), dependencies: string[]): Promise<void>;
749
+ skipInstall?: false;
750
+ type: 'dependencies' | 'devDependencies';
751
+ writeOutputToFile?: boolean;
752
+ packageJsonInfo?: PackageJsonInfo;
753
+ }, dependencies: string[]): Promise<void | ExecaChildProcess>;
535
754
  /**
536
- * Remove dependencies from a project using `yarn remove` or `npm uninstall`.
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`.
537
757
  *
538
758
  * @example
539
759
  *
540
760
  * ```ts
541
- * removeDependencies(options, [`@storybook/react`]);
761
+ * removeDependencies([`@storybook/react`]);
542
762
  * ```
543
763
  *
544
- * @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies`
545
- * which we use to determine how we install packages.
546
- * @param {Array} dependencies Contains a list of packages to remove.
764
+ * @param dependencies Contains a list of packages to remove.
547
765
  */
548
- removeDependencies(options: {
549
- skipInstall?: boolean;
550
- packageJson?: PackageJson;
551
- }, dependencies: string[]): Promise<void>;
766
+ removeDependencies(dependencies: string[]): Promise<void>;
552
767
  /**
553
768
  * Return an array of strings matching following format: `<package_name>@<package_latest_version>`
554
769
  *
@@ -586,16 +801,36 @@ declare abstract class JsPackageManager {
586
801
  * @param packageName Name of the package
587
802
  * @param constraint Version range to use to constraint the returned version
588
803
  */
589
- 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;
590
824
  addStorybookCommandInScripts(options?: {
591
825
  port: number;
592
826
  preCommand?: string;
593
- }): Promise<void>;
594
- addScripts(scripts: Record<string, string>): Promise<void>;
595
- addPackageResolutions(versions: Record<string, string>): Promise<void>;
596
- protected abstract runInstall(): Promise<void>;
597
- protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean, writeOutputToFile?: boolean): Promise<void>;
598
- protected abstract runRemoveDeps(dependencies: string[]): Promise<void>;
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;
599
834
  protected abstract getResolutions(packageJson: PackageJson, versions: Record<string, string>): Record<string, any>;
600
835
  /**
601
836
  * Get the latest or all versions of the input package available on npmjs.com
@@ -605,8 +840,9 @@ declare abstract class JsPackageManager {
605
840
  */
606
841
  protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
607
842
  abstract getRegistryURL(): Promise<string | undefined>;
608
- abstract runPackageCommand(command: string, args: string[], cwd?: string, stdio?: string): Promise<string>;
609
- abstract runPackageCommandSync(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe'): string;
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;
610
846
  abstract findInstallations(pattern?: string[]): Promise<InstallationMetadata | undefined>;
611
847
  abstract findInstallations(pattern?: string[], options?: {
612
848
  depth: number;
@@ -618,19 +854,55 @@ declare abstract class JsPackageManager {
618
854
  cwd?: string;
619
855
  ignoreError?: boolean;
620
856
  }): string;
621
- /** Returns the installed (within node_modules or pnp zip) version of a specified package */
622
- getInstalledVersion(packageName: string): Promise<string | null>;
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
+ */
623
865
  executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
624
866
  command: string;
625
867
  args: string[];
626
868
  cwd?: string;
627
869
  ignoreError?: boolean;
628
- }): Promise<string>;
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;
629
884
  }
630
885
 
631
886
  declare class JsPackageManagerFactory {
632
- static getPackageManager({ force }?: {
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, }?: {
633
902
  force?: PackageManagerName;
903
+ configDir?: string;
904
+ storiesPaths?: string[];
905
+ ignoreCache?: boolean;
634
906
  }, cwd?: string): JsPackageManager;
635
907
  /** Look up map of package manager proxies by name */
636
908
  private static PROXY_MAP;
@@ -792,13 +1064,13 @@ declare const rendererPackages: Record<string, string>;
792
1064
  declare const frameworkPackages: Record<string, SupportedFrameworks>;
793
1065
  declare const builderPackages: string[];
794
1066
  declare const findConfigFile: (prefix: string, configDir: string) => string | null;
795
- declare const getConfigInfo: (packageJson: PackageJson, configDir?: string) => {
1067
+ declare const getConfigInfo: (configDir?: string) => {
796
1068
  configDir: string;
797
- mainConfig: string | null;
798
- previewConfig: string | null;
799
- managerConfig: string | null;
1069
+ mainConfigPath: string | null;
1070
+ previewConfigPath: string | null;
1071
+ managerConfigPath: string | null;
800
1072
  };
801
- declare const getStorybookInfo: (packageJson: PackageJson, configDir?: string) => CoreCommon_StorybookInfo;
1073
+ declare const getStorybookInfo: (configDir?: string) => CoreCommon_StorybookInfo;
802
1074
 
803
1075
  declare const getAutoRefs: (options: Options$1) => Promise<Record<string, Ref>>;
804
1076
  declare function getRefs(options: Options$1): Promise<Record<string, Ref>>;
@@ -836,9 +1108,10 @@ declare function loadCustomPresets({ configDir }: {
836
1108
  configDir: string;
837
1109
  }): PresetConfig[];
838
1110
 
839
- declare function loadMainConfig({ configDir, noCache, }: {
1111
+ declare function loadMainConfig({ configDir, noCache, cwd, }: {
840
1112
  configDir: string;
841
1113
  noCache?: boolean;
1114
+ cwd?: string;
842
1115
  }): Promise<StorybookConfig>;
843
1116
 
844
1117
  declare function loadManagerOrAddonsFile({ configDir }: {
@@ -869,12 +1142,18 @@ interface NormalizeOptions {
869
1142
  declare const normalizeStories: (entries: StoriesEntry[], options: NormalizeOptions) => NormalizedStoriesSpecifier[];
870
1143
 
871
1144
  declare const getProjectRoot: () => string;
1145
+ declare const invalidateProjectRootCache: () => void;
872
1146
  declare const nodePathsToArray: (nodePath: string) => string[];
873
1147
  /** Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` */
874
1148
  declare function normalizeStoryPath(filename: string): string;
875
1149
 
876
1150
  declare function readTemplate(filename: string): Promise<string>;
877
1151
 
1152
+ type RemoveAddonOptions = {
1153
+ packageManager: JsPackageManager;
1154
+ configDir?: string;
1155
+ skipInstall?: boolean;
1156
+ };
878
1157
  /**
879
1158
  * Remove the given addon package and remove it from main.js
880
1159
  *
@@ -884,11 +1163,7 @@ declare function readTemplate(filename: string): Promise<string>;
884
1163
  * sb remove @storybook/addon-links
885
1164
  * ```
886
1165
  */
887
- declare function removeAddon(addon: string, options?: {
888
- packageManager?: PackageManagerName;
889
- cwd?: string;
890
- configDir?: string;
891
- }): Promise<void>;
1166
+ declare function removeAddon(addon: string, options: RemoveAddonOptions): Promise<void>;
892
1167
 
893
1168
  /**
894
1169
  * Get the path of the file or directory with input name inside the Storybook cache directory:
@@ -908,7 +1183,7 @@ declare function getPreviewHeadTemplate(configDirPath: string, interpolations?:
908
1183
 
909
1184
  declare function validateFrameworkName(frameworkName: string | undefined): asserts frameworkName is string;
910
1185
 
911
- declare function validateConfigurationFiles(configDir: string): Promise<void>;
1186
+ declare function validateConfigurationFiles(configDir: string, cwd?: string): Promise<void>;
912
1187
 
913
1188
  /** Mimicking the satisfies operator until we can upgrade to TS4.9 */
914
1189
  declare function satisfies<A>(): <T extends A>(x: T) => T;
@@ -974,4 +1249,4 @@ declare const transformImportFiles: (files: string[], renamedImports: Record<str
974
1249
  error: Error;
975
1250
  }[]>;
976
1251
 
977
- 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 };