@storybook/cli

  • Version 6.2.9
  • Published
  • 485 kB
  • 24 dependencies
  • MIT license

Install

npm i @storybook/cli
yarn add @storybook/cli
pnpm add @storybook/cli

Overview

Storybook's CLI - easiest method of adding storybook to your projects

Index

Functions

function getPackageDetails

getPackageDetails: (pkg: string) => [string, string?];
  • Extract package name and version from input

    Parameter pkg

    A string like @storybook/cli, react or react@^16 A tuple of 2 elements: [packageName, packageVersion]

function readPackageJson

readPackageJson: () => PackageJson | false;

    function writePackageJson

    writePackageJson: (packageJson: PackageJson) => void;

      Classes

      class JsPackageManager

      abstract class JsPackageManager {}

        property type

        abstract readonly type: 'npm' | 'yarn1' | 'yarn2';

          method addDependencies

          addDependencies: (
          options: {
          skipInstall?: boolean;
          installAsDevDependencies?: boolean;
          packageJson?: PackageJson;
          },
          dependencies: string[]
          ) => void;
          • Add dependencies to a project using yarn add or npm install.

            Parameter options

            contains skipInstall, packageJson and installAsDevDependencies which we use to determine how we install packages.

            Parameter dependencies

            contains a list of packages to add.

            Example 1

            addDependencies(options, [ @storybook/react@${storybookVersion}, @storybook/addon-actions@${actionsVersion}, @storybook/addon-links@${linksVersion}, @storybook/addons@${addonsVersion}, ]);

          method addESLintConfig

          addESLintConfig: () => void;

            method addScripts

            addScripts: (scripts: Record<string, string>) => void;

              method addStorybookCommandInScripts

              addStorybookCommandInScripts: (options?: {
              port: number;
              staticFolder?: string;
              preCommand?: string;
              }) => void;

                method executeCommand

                executeCommand: (
                command: string,
                args: string[],
                stdio?: 'pipe' | 'inherit'
                ) => string;

                  method getRunCommand

                  abstract getRunCommand: (command: string) => string;

                    method getRunStorybookCommand

                    abstract getRunStorybookCommand: () => string;

                      method getVersion

                      getVersion: (packageName: string, constraint?: string) => Promise<string>;

                        method getVersionedPackages

                        getVersionedPackages: (...packages: string[]) => Promise<string[]>;
                        • Return an array of strings matching following format: <package_name>@<package_latest_version>

                          Parameter packages

                        method getVersions

                        getVersions: (...packageNames: string[]) => Promise<string[]>;
                        • Return an array of string standing for the latest version of the input packages. To be able to identify which version goes with which package the order of the input array is keep.

                          Parameter packageNames

                        method initPackageJson

                        abstract initPackageJson: () => void;

                          method installDependencies

                          installDependencies: () => void;
                          • Install dependencies listed in package.json

                          method latestVersion

                          latestVersion: (packageName: string, constraint?: string) => Promise<string>;
                          • Get the latest version of the package available on npmjs.com. If constraint is set then it returns a version satisfying it, otherwise the latest version available is returned.

                            Parameter packageName

                            Name of the package

                            Parameter constraint

                            Version range to use to constraint the returned version

                          method retrievePackageJson

                          retrievePackageJson: () => PackageJsonWithDepsAndDevDeps;

                            method runAddDeps

                            protected abstract runAddDeps: (
                            dependencies: string[],
                            installAsDevDependencies: boolean
                            ) => void;

                              method runGetVersions

                              protected abstract runGetVersions: <T extends boolean>(
                              packageName: string,
                              fetchAllVersions: T
                              ) => Promise<T extends true ? string[] : string>;
                              • Get the latest or all versions of the input package available on npmjs.com

                                Parameter packageName

                                Name of the package

                                Parameter fetchAllVersions

                                Should return

                              method runInstall

                              protected abstract runInstall: () => void;

                                class JsPackageManagerFactory

                                class JsPackageManagerFactory {}

                                  method getPackageManager

                                  static getPackageManager: (forceNpmUsage?: boolean) => JsPackageManager;

                                    Type Aliases

                                    type PackageJson

                                    type PackageJson = {
                                    dependencies?: Record<string, string>;
                                    devDependencies?: Record<string, string>;
                                    peerDependencies?: Record<string, string>;
                                    scripts?: Record<string, string>;
                                    eslintConfig?: any;
                                    };

                                      type PackageJsonWithDepsAndDevDeps

                                      type PackageJsonWithDepsAndDevDeps = PackageJson &
                                      Required<Pick<PackageJson, 'dependencies' | 'devDependencies'>>;

                                        Package Files (5)

                                        Dependencies (24)

                                        Dev Dependencies (9)

                                        Peer Dependencies (1)

                                        Badge

                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@storybook/cli.

                                        • Markdown
                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@storybook/cli)
                                        • HTML
                                          <a href="https://www.jsdocs.io/package/@storybook/cli"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>