storybook 9.0.11 → 9.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/bin/index.cjs +43 -43
  2. package/dist/bin/index.js +43 -43
  3. package/dist/cli/bin/index.cjs +629 -629
  4. package/dist/cli/bin/index.js +202 -201
  5. package/dist/cli/index.cjs +13788 -13797
  6. package/dist/cli/index.d.ts +712 -15
  7. package/dist/cli/index.js +12364 -12372
  8. package/dist/common/index.cjs +10997 -10888
  9. package/dist/common/index.d.ts +348 -66
  10. package/dist/common/index.js +24318 -24206
  11. package/dist/components/index.cjs +632 -628
  12. package/dist/components/index.d.ts +2 -1
  13. package/dist/components/index.js +390 -386
  14. package/dist/core-server/index.cjs +4840 -4793
  15. package/dist/core-server/index.d.ts +10 -1
  16. package/dist/core-server/index.js +5748 -5701
  17. package/dist/core-server/presets/common-manager.js +257 -243
  18. package/dist/core-server/presets/common-preset.cjs +1048 -1046
  19. package/dist/core-server/presets/common-preset.js +2054 -2049
  20. package/dist/csf-tools/index.cjs +226 -224
  21. package/dist/csf-tools/index.js +116 -112
  22. package/dist/manager/globals-runtime.js +3286 -3282
  23. package/dist/manager-api/index.cjs +73 -73
  24. package/dist/manager-api/index.js +140 -140
  25. package/dist/node-logger/index.cjs +8520 -994
  26. package/dist/node-logger/index.d.ts +395 -2
  27. package/dist/node-logger/index.js +8535 -995
  28. package/dist/server-errors.cjs +201 -242
  29. package/dist/server-errors.d.ts +1 -12
  30. package/dist/server-errors.js +182 -223
  31. package/dist/telemetry/index.cjs +1224 -1223
  32. package/dist/telemetry/index.d.ts +3 -2
  33. package/dist/telemetry/index.js +1069 -1066
  34. package/dist/types/index.d.ts +3 -3
  35. package/package.json +2 -1
@@ -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 { 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: {
@@ -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
- abstract initPackageJson(): Promise<void>;
476
- abstract getRunStorybookCommand(): string;
477
- abstract getRunCommand(command: string): string;
478
- abstract getRemoteRunCommand(): string;
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
- * Detect whether Storybook gets initialized in a mono-repository/workspace environment The cwd
486
- * doesn't have to be the root of the monorepo, it can be a subdirectory
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
- isStorybookInMonorepo(): boolean;
491
- /** Install dependencies listed in `package.json` */
492
- installDependencies(): Promise<void>;
493
- packageJsonPath(): string;
494
- readPackageJson(): Promise<PackageJson>;
495
- 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;
496
708
  /**
497
- * Read the `package.json` file available in the directory the command was call from If there is
498
- * 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.
499
711
  */
500
- retrievePackageJson(): Promise<PackageJsonWithDepsAndDevDeps>;
501
- 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;
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
- installAsDevDependencies?: boolean;
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: true;
526
- packageJson: PackageJson;
527
- }), dependencies: string[]): Promise<void>;
749
+ skipInstall?: false;
750
+ type: 'dependencies' | 'devDependencies';
751
+ writeOutputToFile?: boolean;
752
+ packageJsonInfo?: PackageJsonInfo;
753
+ }, dependencies: string[]): Promise<void | ExecaChildProcess>;
528
754
  /**
529
- * 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`.
530
757
  *
531
758
  * @example
532
759
  *
533
760
  * ```ts
534
- * removeDependencies(options, [`@storybook/react`]);
761
+ * removeDependencies([`@storybook/react`]);
535
762
  * ```
536
763
  *
537
- * @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies`
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(options: {
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
- }): Promise<void>;
587
- addScripts(scripts: Record<string, string>): Promise<void>;
588
- addPackageResolutions(versions: Record<string, string>): Promise<void>;
589
- protected abstract runInstall(): Promise<void>;
590
- protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean, writeOutputToFile?: boolean): Promise<void>;
591
- 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;
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 runPackageCommand(command: string, args: string[], cwd?: string, stdio?: string): Promise<string>;
602
- 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;
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
- /** Returns the installed (within node_modules or pnp zip) version of a specified package */
615
- 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
+ */
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
- }): 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;
622
884
  }
623
885
 
624
886
  declare class JsPackageManagerFactory {
625
- 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, }?: {
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: (packageJson: PackageJson, configDir?: string) => {
1067
+ declare const getConfigInfo: (configDir?: string) => {
789
1068
  configDir: string;
790
- mainConfig: string | null;
791
- previewConfig: string | null;
792
- managerConfig: string | null;
1069
+ mainConfigPath: string | null;
1070
+ previewConfigPath: string | null;
1071
+ managerConfigPath: string | null;
793
1072
  };
794
- declare const getStorybookInfo: (packageJson: PackageJson, configDir?: string) => CoreCommon_StorybookInfo;
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 };