storybook 9.1.0-alpha.5 → 9.1.0-alpha.6

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 (39) hide show
  1. package/dist/bin/index.cjs +62 -69
  2. package/dist/bin/index.js +43 -50
  3. package/dist/cli/bin/index.cjs +604 -604
  4. package/dist/cli/bin/index.js +151 -150
  5. package/dist/cli/index.cjs +13787 -13796
  6. package/dist/cli/index.d.ts +706 -15
  7. package/dist/cli/index.js +12363 -12371
  8. package/dist/common/index.cjs +13481 -13382
  9. package/dist/common/index.d.ts +341 -72
  10. package/dist/common/index.js +24018 -23916
  11. package/dist/components/index.cjs +5 -3
  12. package/dist/components/index.d.ts +2 -1
  13. package/dist/components/index.js +5 -3
  14. package/dist/controls/preview.cjs +14 -14
  15. package/dist/controls/preview.d.ts +1 -1
  16. package/dist/controls/preview.js +2 -2
  17. package/dist/core-server/index.cjs +4838 -4791
  18. package/dist/core-server/index.d.ts +10 -1
  19. package/dist/core-server/index.js +5746 -5699
  20. package/dist/core-server/presets/common-manager.js +46 -32
  21. package/dist/core-server/presets/common-preset.cjs +1047 -1045
  22. package/dist/core-server/presets/common-preset.js +2053 -2048
  23. package/dist/csf/index.d.ts +2 -1
  24. package/dist/csf-tools/index.cjs +226 -224
  25. package/dist/csf-tools/index.js +116 -112
  26. package/dist/manager/globals-runtime.js +6 -4
  27. package/dist/manager-api/index.cjs +73 -73
  28. package/dist/manager-api/index.js +140 -140
  29. package/dist/node-logger/index.cjs +8520 -994
  30. package/dist/node-logger/index.d.ts +395 -2
  31. package/dist/node-logger/index.js +8535 -995
  32. package/dist/server-errors.cjs +201 -242
  33. package/dist/server-errors.d.ts +1 -12
  34. package/dist/server-errors.js +182 -223
  35. package/dist/telemetry/index.cjs +1326 -1325
  36. package/dist/telemetry/index.d.ts +3 -2
  37. package/dist/telemetry/index.js +1217 -1214
  38. package/dist/types/index.d.ts +3 -3
  39. package/package.json +18 -9
@@ -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,50 @@ 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>;
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[];
694
+ /**
695
+ * The path to the Storybook instance directory. This is used to find the primary package.json
696
+ * file in a repository.
697
+ */
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>;
490
705
  constructor(options?: JsPackageManagerOptions);
706
+ /** Runs arbitrary package scripts. */
707
+ abstract getRunCommand(command: string): string;
491
708
  /**
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
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.
496
711
  */
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;
497
715
  isStorybookInMonorepo(): boolean;
498
- /** Install dependencies listed in `package.json` */
499
716
  installDependencies(): Promise<void>;
500
- packageJsonPath(): string;
501
- readPackageJson(): Promise<PackageJson>;
502
- writePackageJson(packageJson: PackageJson): Promise<void>;
503
- /**
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.
506
- */
507
- retrievePackageJson(): Promise<PackageJsonWithDepsAndDevDeps>;
508
- getAllDependencies(): Promise<Partial<Record<string, string>>>;
717
+ dedupeDependencies(): Promise<void>;
718
+ /** Read the `package.json` file available in the provided directory */
719
+ static getPackageJson(packageJsonPath: string): PackageJsonWithDepsAndDevDeps;
720
+ writePackageJson(packageJson: PackageJson, directory?: string): void;
721
+ getAllDependencies(): Record<string, string>;
722
+ isDependencyInstalled(dependency: string): boolean;
509
723
  /**
510
724
  * Add dependencies to a project using `yarn add` or `npm install`.
511
725
  *
@@ -523,32 +737,29 @@ declare abstract class JsPackageManager {
523
737
  * @param {Array} dependencies Contains a list of packages to add.
524
738
  */
525
739
  addDependencies(options: {
526
- installAsDevDependencies?: boolean;
740
+ skipInstall: true;
741
+ type: 'dependencies' | 'devDependencies' | 'peerDependencies';
527
742
  writeOutputToFile?: boolean;
528
- } & ({
529
- skipInstall?: false;
530
- packageJson?: PackageJson;
743
+ packageJsonInfo?: PackageJsonInfo;
531
744
  } | {
532
- skipInstall: true;
533
- packageJson: PackageJson;
534
- }), dependencies: string[]): Promise<void>;
745
+ skipInstall?: false;
746
+ type: 'dependencies' | 'devDependencies';
747
+ writeOutputToFile?: boolean;
748
+ packageJsonInfo?: PackageJsonInfo;
749
+ }, dependencies: string[]): Promise<void | ExecaChildProcess>;
535
750
  /**
536
- * Remove dependencies from a project using `yarn remove` or `npm uninstall`.
751
+ * Removing dependencies from the package.json file, which is found first starting from the
752
+ * instance root. The method does not run a package manager install like `npm install`.
537
753
  *
538
754
  * @example
539
755
  *
540
756
  * ```ts
541
- * removeDependencies(options, [`@storybook/react`]);
757
+ * removeDependencies([`@storybook/react`]);
542
758
  * ```
543
759
  *
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.
760
+ * @param dependencies Contains a list of packages to remove.
547
761
  */
548
- removeDependencies(options: {
549
- skipInstall?: boolean;
550
- packageJson?: PackageJson;
551
- }, dependencies: string[]): Promise<void>;
762
+ removeDependencies(dependencies: string[]): Promise<void>;
552
763
  /**
553
764
  * Return an array of strings matching following format: `<package_name>@<package_latest_version>`
554
765
  *
@@ -586,16 +797,34 @@ declare abstract class JsPackageManager {
586
797
  * @param packageName Name of the package
587
798
  * @param constraint Version range to use to constraint the returned version
588
799
  */
589
- latestVersion(packageName: string, constraint?: string): Promise<string>;
800
+ latestVersion(packageName: string, constraint?: string): Promise<string | null>;
801
+ /**
802
+ * Clear the latest version cache. Useful for testing or when you want to refresh version
803
+ * information.
804
+ *
805
+ * @param packageName Optional package name to clear only specific entries. If not provided,
806
+ * clears all cache.
807
+ */
808
+ static clearLatestVersionCache(packageName?: string): void;
809
+ /**
810
+ * Clear the installed version cache for a specific package or all packages.
811
+ *
812
+ * @param packageName Optional package name to clear from cache. If not provided, clears all.
813
+ */
814
+ clearInstalledVersionCache(packageName?: string): void;
815
+ /**
816
+ * Clear both the latest version cache and installed version cache. This should be called after
817
+ * any operation that modifies dependencies.
818
+ */
819
+ clearAllVersionCaches(): void;
590
820
  addStorybookCommandInScripts(options?: {
591
821
  port: number;
592
822
  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>;
823
+ }): void;
824
+ addScripts(scripts: Record<string, string>): void;
825
+ addPackageResolutions(versions: Record<string, string>): void;
826
+ protected abstract runInstall(): ExecaChildProcess;
827
+ protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean, writeOutputToFile?: boolean): ExecaChildProcess;
599
828
  protected abstract getResolutions(packageJson: PackageJson, versions: Record<string, string>): Record<string, any>;
600
829
  /**
601
830
  * Get the latest or all versions of the input package available on npmjs.com
@@ -605,8 +834,9 @@ declare abstract class JsPackageManager {
605
834
  */
606
835
  protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
607
836
  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;
837
+ abstract runInternalCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
838
+ abstract runPackageCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
839
+ abstract runPackageCommandSync(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): string;
610
840
  abstract findInstallations(pattern?: string[]): Promise<InstallationMetadata | undefined>;
611
841
  abstract findInstallations(pattern?: string[], options?: {
612
842
  depth: number;
@@ -618,19 +848,55 @@ declare abstract class JsPackageManager {
618
848
  cwd?: string;
619
849
  ignoreError?: boolean;
620
850
  }): string;
621
- /** Returns the installed (within node_modules or pnp zip) version of a specified package */
622
- getInstalledVersion(packageName: string): Promise<string | null>;
851
+ /**
852
+ * Execute a command asynchronously and return the execa process. This allows you to hook into
853
+ * stdout/stderr streams and monitor the process.
854
+ *
855
+ * @example Const process = packageManager.executeCommand({ command: 'npm', args: ['install'] });
856
+ * process.stdout?.on('data', (data) => console.log(data.toString())); const result = await
857
+ * process;
858
+ */
623
859
  executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
624
860
  command: string;
625
861
  args: string[];
626
862
  cwd?: string;
627
863
  ignoreError?: boolean;
628
- }): Promise<string>;
864
+ }): ExecaChildProcess;
865
+ /** Returns the installed (within node_modules or pnp zip) version of a specified package */
866
+ getInstalledVersion(packageName: string): Promise<string | null>;
867
+ isPackageInstalled(packageName: string): Promise<boolean>;
868
+ /**
869
+ * Searches for a dependency/devDependency in all package.json files and returns the version of
870
+ * the dependency.
871
+ */
872
+ getDependencyVersion(dependency: string): string | null;
873
+ static hasStorybookDependency(packageJsonPath: string): boolean;
874
+ static hasAnyStorybookDependency(packageJsonPath: string): boolean;
875
+ /** List all package.json files starting from the given directory and stopping at the project root. */
876
+ static listAllPackageJsonPaths(instanceDir: string, storiesPaths?: string[]): string[];
877
+ static getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo;
629
878
  }
630
879
 
631
880
  declare class JsPackageManagerFactory {
632
- static getPackageManager({ force }?: {
881
+ /** Cache for package manager instances */
882
+ private static cache;
883
+ /** Generate a cache key based on the parameters */
884
+ private static getCacheKey;
885
+ /** Clear the package manager cache */
886
+ static clearCache(): void;
887
+ /**
888
+ * Determine which package manager type to use based on lockfiles, commands, and environment
889
+ *
890
+ * @param cwd - Current working directory
891
+ * @returns Package manager type as string: 'npm', 'pnpm', 'bun', 'yarn1', or 'yarn2'
892
+ * @throws Error if no usable package manager is found
893
+ */
894
+ static getPackageManagerType(cwd?: string): PackageManagerName;
895
+ static getPackageManager({ force, configDir, storiesPaths, ignoreCache, }?: {
633
896
  force?: PackageManagerName;
897
+ configDir?: string;
898
+ storiesPaths?: string[];
899
+ ignoreCache?: boolean;
634
900
  }, cwd?: string): JsPackageManager;
635
901
  /** Look up map of package manager proxies by name */
636
902
  private static PROXY_MAP;
@@ -792,13 +1058,13 @@ declare const rendererPackages: Record<string, string>;
792
1058
  declare const frameworkPackages: Record<string, SupportedFrameworks>;
793
1059
  declare const builderPackages: string[];
794
1060
  declare const findConfigFile: (prefix: string, configDir: string) => string | null;
795
- declare const getConfigInfo: (packageJson: PackageJson, configDir?: string) => {
1061
+ declare const getConfigInfo: (configDir?: string) => {
796
1062
  configDir: string;
797
- mainConfig: string | null;
798
- previewConfig: string | null;
799
- managerConfig: string | null;
1063
+ mainConfigPath: string | null;
1064
+ previewConfigPath: string | null;
1065
+ managerConfigPath: string | null;
800
1066
  };
801
- declare const getStorybookInfo: (packageJson: PackageJson, configDir?: string) => CoreCommon_StorybookInfo;
1067
+ declare const getStorybookInfo: (configDir?: string) => CoreCommon_StorybookInfo;
802
1068
 
803
1069
  declare const getAutoRefs: (options: Options$1) => Promise<Record<string, Ref>>;
804
1070
  declare function getRefs(options: Options$1): Promise<Record<string, Ref>>;
@@ -836,9 +1102,10 @@ declare function loadCustomPresets({ configDir }: {
836
1102
  configDir: string;
837
1103
  }): PresetConfig[];
838
1104
 
839
- declare function loadMainConfig({ configDir, noCache, }: {
1105
+ declare function loadMainConfig({ configDir, noCache, cwd, }: {
840
1106
  configDir: string;
841
1107
  noCache?: boolean;
1108
+ cwd?: string;
842
1109
  }): Promise<StorybookConfig>;
843
1110
 
844
1111
  declare function loadManagerOrAddonsFile({ configDir }: {
@@ -869,12 +1136,18 @@ interface NormalizeOptions {
869
1136
  declare const normalizeStories: (entries: StoriesEntry[], options: NormalizeOptions) => NormalizedStoriesSpecifier[];
870
1137
 
871
1138
  declare const getProjectRoot: () => string;
1139
+ declare const invalidateProjectRootCache: () => void;
872
1140
  declare const nodePathsToArray: (nodePath: string) => string[];
873
1141
  /** Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` */
874
1142
  declare function normalizeStoryPath(filename: string): string;
875
1143
 
876
1144
  declare function readTemplate(filename: string): Promise<string>;
877
1145
 
1146
+ type RemoveAddonOptions = {
1147
+ packageManager: JsPackageManager;
1148
+ configDir?: string;
1149
+ skipInstall?: boolean;
1150
+ };
878
1151
  /**
879
1152
  * Remove the given addon package and remove it from main.js
880
1153
  *
@@ -884,11 +1157,7 @@ declare function readTemplate(filename: string): Promise<string>;
884
1157
  * sb remove @storybook/addon-links
885
1158
  * ```
886
1159
  */
887
- declare function removeAddon(addon: string, options?: {
888
- packageManager?: PackageManagerName;
889
- cwd?: string;
890
- configDir?: string;
891
- }): Promise<void>;
1160
+ declare function removeAddon(addon: string, options: RemoveAddonOptions): Promise<void>;
892
1161
 
893
1162
  /**
894
1163
  * Get the path of the file or directory with input name inside the Storybook cache directory:
@@ -908,7 +1177,7 @@ declare function getPreviewHeadTemplate(configDirPath: string, interpolations?:
908
1177
 
909
1178
  declare function validateFrameworkName(frameworkName: string | undefined): asserts frameworkName is string;
910
1179
 
911
- declare function validateConfigurationFiles(configDir: string): Promise<void>;
1180
+ declare function validateConfigurationFiles(configDir: string, cwd?: string): Promise<void>;
912
1181
 
913
1182
  /** Mimicking the satisfies operator until we can upgrade to TS4.9 */
914
1183
  declare function satisfies<A>(): <T extends A>(x: T) => T;
@@ -974,4 +1243,4 @@ declare const transformImportFiles: (files: string[], renamedImports: Record<str
974
1243
  error: Error;
975
1244
  }[]>;
976
1245
 
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 };
1246
+ 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 };