@storybook/cli 8.0.5 → 8.0.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.
package/dist/generate.js CHANGED
@@ -595,7 +595,7 @@ ${import_chalk34.default.cyan("npx storybook doctor")}`;logger23.info(),foundIss
595
595
  ${availableFixes}
596
596
  `)},doAutomigrate=async options=>{let packageManager=import_core_common22.JsPackageManagerFactory.getPackageManager({force:options.packageManager}),[packageJson,storybookVersion]=await Promise.all([packageManager.retrievePackageJson(),(0,import_core_common22.getCoercedStorybookVersion)(packageManager)]),{configDir:inferredConfigDir,mainConfig:mainConfigPath}=(0,import_core_common22.getStorybookInfo)(packageJson,options.configDir),configDir=options.configDir||inferredConfigDir||".storybook";if(!storybookVersion)throw new Error("Could not determine Storybook version");if(!mainConfigPath)throw new Error("Could not determine main config path");await automigrate({...options,packageManager,storybookVersion,beforeVersion:storybookVersion,mainConfigPath,configDir,isUpgrade:!1,isLatest:!1})&&await doctor({configDir,packageManager:options.packageManager})},automigrate=async({fixId,fixes:inputFixes,dryRun,yes,packageManager,list,configDir,mainConfigPath,storybookVersion,beforeVersion,renderer:rendererPackage,skipInstall,hideMigrationSummary=!1,isUpgrade,isLatest})=>{if(list)return logAvailableMigrations(),null;let selectedFixes=inputFixes||allFixes.filter(fix=>!(fix.id===upgradeStorybookRelatedDependencies.id&&isLatest===!1&&fixId!==upgradeStorybookRelatedDependencies.id)),fixes=fixId?selectedFixes.filter(f=>f.id===fixId):selectedFixes;if(fixId&&fixes.length===0)return logger24.info(`\u{1F4ED} No migrations found for ${import_chalk35.default.magenta(fixId)}.`),logAvailableMigrations(),null;augmentLogsToFile2(),logger24.info("\u{1F50E} checking possible migrations..");let{fixResults,fixSummary,preCheckFailure}=await runFixes({fixes,packageManager,rendererPackage,skipInstall,configDir,mainConfigPath,storybookVersion,beforeVersion,isUpgrade:!!isUpgrade,dryRun,yes});if(Object.values(fixResults).some(r=>r==="failed"||r==="check_failed")?await(0,import_fs_extra9.move)(TEMP_LOG_FILE_PATH2,(0,import_path17.join)(process.cwd(),LOG_FILE_NAME2),{overwrite:!0}):await(0,import_fs_extra9.remove)(TEMP_LOG_FILE_PATH2),!hideMigrationSummary){let installationMetadata=await packageManager.findInstallations(["@storybook/*","storybook"]);logger24.info(),logger24.info(getMigrationSummary({fixResults,fixSummary,logFile:LOG_FILE_PATH2,installationMetadata})),logger24.info()}return cleanup2(),{fixResults,preCheckFailure}};async function runFixes({fixes,dryRun,yes,rendererPackage,skipInstall,configDir,packageManager,mainConfigPath,storybookVersion,beforeVersion,isUpgrade}){let fixResults={},fixSummary={succeeded:[],failed:{},manual:[],skipped:[]};for(let i=0;i<fixes.length;i+=1){let f=fixes[i],result;try{let{mainConfig,previewConfigPath}=await getStorybookData({configDir,packageManager});(isUpgrade&&import_semver18.default.satisfies(beforeVersion,f.versionRange[0],{includePrerelease:!0})&&import_semver18.default.satisfies(storybookVersion,f.versionRange[1],{includePrerelease:!0})||!isUpgrade)&&(result=await f.check({packageManager,configDir,rendererPackage,mainConfig,storybookVersion,previewConfigPath,mainConfigPath}))}catch(error){logger24.info(`\u26A0\uFE0F failed to check fix ${import_chalk35.default.bold(f.id)}`),error instanceof Error&&(logger24.error(`
597
597
  ${error.stack}`),fixSummary.failed[f.id]=error.message),fixResults[f.id]="check_failed"}if(result){let promptType=typeof f.promptType=="function"?await f.promptType(result):f.promptType??"auto";logger24.info(`
598
- \u{1F50E} found a '${import_chalk35.default.cyan(f.id)}' migration:`);let message=f.prompt(result),getTitle=()=>{switch(promptType){case"auto":return"Automigration detected";case"manual":return"Manual migration detected";case"notification":return"Migration notification"}};logger24.info(boxen(message,{borderStyle:"round",padding:1,borderColor:"#F1618C",title:getTitle()}));let runAnswer;try{if(dryRun)runAnswer={fix:!1};else if(yes)runAnswer={fix:!0},promptType==="manual"&&(fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id));else if(promptType==="manual"){fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id),logger24.info();let{shouldContinue}=await(0,import_prompts11.default)({type:"toggle",name:"shouldContinue",message:"Select continue once you have made the required changes, or quit to exit the migration process",initial:!0,active:"continue",inactive:"quit"},{onCancel:()=>{throw new Error}});if(!shouldContinue){fixResults[f.id]="manual_skipped";break}}else promptType==="auto"?runAnswer=await(0,import_prompts11.default)({type:"confirm",name:"fix",message:`Do you want to run the '${import_chalk35.default.cyan(f.id)}' migration on your project?`,initial:f.promptDefaultValue??!0},{onCancel:()=>{throw new Error}}):promptType==="notification"&&(runAnswer=await(0,import_prompts11.default)({type:"confirm",name:"fix",message:"Do you want to continue?",initial:!0},{onCancel:()=>{throw new Error}}))}catch{break}if(promptType==="auto")if((0,import_tiny_invariant5.default)(runAnswer,"runAnswer must be defined if not promptOnly"),runAnswer.fix)try{(0,import_tiny_invariant5.default)(typeof f.run=="function","run method should be available in fix."),(0,import_tiny_invariant5.default)(mainConfigPath,"Main config path should be defined to run migration."),await f.run({result,packageManager,dryRun,mainConfigPath,skipInstall}),logger24.info(`\u2705 ran ${import_chalk35.default.cyan(f.id)} migration`),fixResults[f.id]="succeeded",fixSummary.succeeded.push(f.id)}catch(error){fixResults[f.id]="failed",fixSummary.failed[f.id]=error instanceof Error?error.message:"Failed to run migration",logger24.info(`\u274C error when running ${import_chalk35.default.cyan(f.id)} migration`),logger24.info(error),logger24.info()}else fixResults[f.id]="skipped",fixSummary.skipped.push(f.id)}else fixResults[f.id]=fixResults[f.id]||"unnecessary"}return{fixResults,fixSummary}}var logger25=console;async function migrate(migration,{glob:glob3,dryRun,list,rename,parser}){if(list)(0,import_codemod3.listCodemods)().forEach(key=>logger25.log(key));else if(migration){if(migration==="mdx-to-csf"&&!dryRun){let packageManager=import_core_common23.JsPackageManagerFactory.getPackageManager(),[packageJson,storybookVersion]=await Promise.all([packageManager.retrievePackageJson(),(0,import_core_common23.getCoercedStorybookVersion)(packageManager)]),{configDir:inferredConfigDir,mainConfig:mainConfigPath}=(0,import_core_common23.getStorybookInfo)(packageJson),configDir=inferredConfigDir||".storybook";if(!storybookVersion)throw new Error("Could not determine Storybook version");if(!mainConfigPath)throw new Error("Could not determine main config path");await runFixes({fixes:[mdxToCSF],configDir,mainConfigPath,packageManager,storybookVersion,beforeVersion:storybookVersion,isUpgrade:!1}),await addStorybookBlocksPackage()}await(0,import_codemod3.runCodemod)(migration,{glob:glob3,dryRun,logger:logger25,rename,parser})}else throw new Error("Migrate: please specify a migration name or --list")}async function addStorybookBlocksPackage(){let packageManager=import_core_common23.JsPackageManagerFactory.getPackageManager(),packageJson=await packageManager.retrievePackageJson(),versionToInstall=getStorybookVersionSpecifier(await packageManager.retrievePackageJson());logger25.info('\u2705 Adding "@storybook/blocks" package'),await packageManager.addDependencies({installAsDevDependencies:!0,packageJson},[`@storybook/blocks@${versionToInstall}`])}var import_cross_spawn=require("cross-spawn"),import_telemetry3=require("@storybook/telemetry"),import_semver21=__toESM(require("semver")),import_node_logger6=require("@storybook/node-logger"),import_core_server2=require("@storybook/core-server"),import_server_errors4=require("@storybook/core-events/server-errors"),import_chalk40=__toESM(require("chalk")),import_ts_dedent44=__toESM(require("ts-dedent"));var import_core_common24=require("@storybook/core-common");var import_node_logger5=require("@storybook/node-logger"),import_chalk39=__toESM(require("chalk"));var excludesFalse=x=>x!==!1,blockers=()=>[Promise.resolve().then(()=>(init_block_storystorev6(),block_storystorev6_exports)),Promise.resolve().then(()=>(init_block_dependencies_versions(),block_dependencies_versions_exports)),Promise.resolve().then(()=>(init_block_node_version(),block_node_version_exports))],segmentDivider2=`
598
+ \u{1F50E} found a '${import_chalk35.default.cyan(f.id)}' migration:`);let message=f.prompt(result),getTitle=()=>{switch(promptType){case"auto":return"Automigration detected";case"manual":return"Manual migration detected";case"notification":return"Migration notification"}};logger24.info(boxen(message,{borderStyle:"round",padding:1,borderColor:"#F1618C",title:getTitle()}));let runAnswer;try{if(dryRun)runAnswer={fix:!1};else if(yes)runAnswer={fix:!0},promptType==="manual"&&(fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id));else if(promptType==="manual"){fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id),logger24.info();let{shouldContinue}=await(0,import_prompts11.default)({type:"toggle",name:"shouldContinue",message:"Select continue once you have made the required changes, or quit to exit the migration process",initial:!0,active:"continue",inactive:"quit"},{onCancel:()=>{throw new Error}});if(!shouldContinue){fixResults[f.id]="manual_skipped";break}}else promptType==="auto"?runAnswer=await(0,import_prompts11.default)({type:"confirm",name:"fix",message:`Do you want to run the '${import_chalk35.default.cyan(f.id)}' migration on your project?`,initial:f.promptDefaultValue??!0},{onCancel:()=>{throw new Error}}):promptType==="notification"&&(runAnswer=await(0,import_prompts11.default)({type:"confirm",name:"fix",message:"Do you want to continue?",initial:!0},{onCancel:()=>{throw new Error}}))}catch{break}if(promptType==="auto")if((0,import_tiny_invariant5.default)(runAnswer,"runAnswer must be defined if not promptOnly"),runAnswer.fix)try{(0,import_tiny_invariant5.default)(typeof f.run=="function","run method should be available in fix."),(0,import_tiny_invariant5.default)(mainConfigPath,"Main config path should be defined to run migration."),await f.run({result,packageManager,dryRun,mainConfigPath,skipInstall}),logger24.info(`\u2705 ran ${import_chalk35.default.cyan(f.id)} migration`),fixResults[f.id]="succeeded",fixSummary.succeeded.push(f.id)}catch(error){fixResults[f.id]="failed",fixSummary.failed[f.id]=error instanceof Error?error.message:"Failed to run migration",logger24.info(`\u274C error when running ${import_chalk35.default.cyan(f.id)} migration`),logger24.info(error),logger24.info()}else fixResults[f.id]="skipped",fixSummary.skipped.push(f.id)}else fixResults[f.id]=fixResults[f.id]||"unnecessary"}return{fixResults,fixSummary}}var logger25=console;async function migrate(migration,{glob:glob3,dryRun,list,rename,parser,configDir:userSpecifiedConfigDir}){if(list)(0,import_codemod3.listCodemods)().forEach(key=>logger25.log(key));else if(migration){if(migration==="mdx-to-csf"&&!dryRun){let packageManager=import_core_common23.JsPackageManagerFactory.getPackageManager(),[packageJson,storybookVersion]=await Promise.all([packageManager.retrievePackageJson(),(0,import_core_common23.getCoercedStorybookVersion)(packageManager)]),{configDir:inferredConfigDir,mainConfig:mainConfigPath}=(0,import_core_common23.getStorybookInfo)(packageJson,userSpecifiedConfigDir),configDir=userSpecifiedConfigDir||inferredConfigDir||".storybook";if(!storybookVersion)throw new Error("Could not determine Storybook version");if(!mainConfigPath)throw new Error("Could not determine main config path");await runFixes({fixes:[mdxToCSF],configDir,mainConfigPath,packageManager,storybookVersion,beforeVersion:storybookVersion,isUpgrade:!1}),await addStorybookBlocksPackage()}await(0,import_codemod3.runCodemod)(migration,{glob:glob3,dryRun,logger:logger25,rename,parser})}else throw new Error("Migrate: please specify a migration name or --list")}async function addStorybookBlocksPackage(){let packageManager=import_core_common23.JsPackageManagerFactory.getPackageManager(),packageJson=await packageManager.retrievePackageJson(),versionToInstall=getStorybookVersionSpecifier(await packageManager.retrievePackageJson());logger25.info('\u2705 Adding "@storybook/blocks" package'),await packageManager.addDependencies({installAsDevDependencies:!0,packageJson},[`@storybook/blocks@${versionToInstall}`])}var import_cross_spawn=require("cross-spawn"),import_telemetry3=require("@storybook/telemetry"),import_semver21=__toESM(require("semver")),import_node_logger6=require("@storybook/node-logger"),import_core_server2=require("@storybook/core-server"),import_server_errors4=require("@storybook/core-events/server-errors"),import_chalk40=__toESM(require("chalk")),import_ts_dedent44=__toESM(require("ts-dedent"));var import_core_common24=require("@storybook/core-common");var import_node_logger5=require("@storybook/node-logger"),import_chalk39=__toESM(require("chalk"));var excludesFalse=x=>x!==!1,blockers=()=>[Promise.resolve().then(()=>(init_block_storystorev6(),block_storystorev6_exports)),Promise.resolve().then(()=>(init_block_dependencies_versions(),block_dependencies_versions_exports)),Promise.resolve().then(()=>(init_block_node_version(),block_node_version_exports))],segmentDivider2=`
599
599
 
600
600
  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
601
601
 
@@ -661,7 +661,7 @@ ${error.stack}`),fixSummary.failed[f.id]=error.message),fixResults[f.id]="check_
661
661
  Broken build, fix the error above.
662
662
  You may need to refresh the browser.
663
663
  `),import_node_logger8.logger.line()}var dev=async cliOptions=>{process.env.NODE_ENV=process.env.NODE_ENV||"development";let readUpResult2=(0,import_read_pkg_up.sync)({cwd:__dirname});(0,import_tiny_invariant7.default)(readUpResult2,"Failed to find the closest package.json file.");let options={...cliOptions,configDir:cliOptions.configDir||"./.storybook",configType:"DEVELOPMENT",ignorePreview:!!cliOptions.previewUrl&&!cliOptions.forceBuildPreview,cache:import_core_common27.cache,packageJson:(0,import_read_pkg_up.sync)({cwd:__dirname})?.packageJson};await(0,import_core_server3.withTelemetry)("dev",{cliOptions,presetOptions:options,printError},()=>(0,import_core_server3.buildDevStandalone)(options))};var import_read_pkg_up2=require("read-pkg-up"),import_core_server4=require("@storybook/core-server"),import_core_common28=require("@storybook/core-common"),import_tiny_invariant8=__toESM(require("tiny-invariant")),build=async cliOptions=>{let readUpResult2=(0,import_read_pkg_up2.sync)({cwd:__dirname});(0,import_tiny_invariant8.default)(readUpResult2,"Failed to find the closest package.json file.");let options={...cliOptions,configDir:cliOptions.configDir||"./.storybook",outputDir:cliOptions.outputDir||"./storybook-static",ignorePreview:!!cliOptions.previewUrl&&!cliOptions.forceBuildPreview,configType:"PRODUCTION",cache:import_core_common28.cache,packageJson:readUpResult2.packageJson};await(0,import_core_server4.withTelemetry)("build",{cliOptions,presetOptions:options},()=>(0,import_core_server4.buildStaticStandalone)(options))};(0,import_telemetry4.addToGlobalContext)("cliVersion",import_core_common29.versions.storybook);var readUpResult=(0,import_read_pkg_up3.sync)({cwd:__dirname});(0,import_tiny_invariant9.default)(readUpResult,"Failed to find the closest package.json file.");var pkg=readUpResult.packageJson,consoleLogger=console,command=name=>import_commander.default.command(name).option("--disable-telemetry","Disable sending telemetry data",process.env.STORYBOOK_DISABLE_TELEMETRY&&process.env.STORYBOOK_DISABLE_TELEMETRY!=="false").option("--debug","Get more logs in debug mode",!1).option("--enable-crash-reports","Enable sending crash reports to telemetry data");command("init").description("Initialize Storybook into your project.").option("-f --force","Force add Storybook").option("-s --skip-install","Skip installing deps").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing deps").option("--use-pnp","Enable pnp mode for Yarn 2+").option("-p --parser <babel | babylon | flow | ts | tsx>","jscodeshift parser").option("-t --type <type>","Add Storybook for a specific project type").option("-y --yes","Answer yes to all prompts").option("-b --builder <webpack5 | vite>","Builder library").option("-l --linkable","Prepare installation for link (contributor helper)").action(options=>{initiate(options,pkg).catch(()=>process.exit(1))});command("add <addon>").description("Add an addon to your Storybook").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing dependencies").option("-s --skip-postinstall","Skip package specific postinstall config modifications").action((addonName,options)=>add(addonName,options));command("remove <addon>").description("Remove an addon from your Storybook").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing dependencies").action((addonName,options)=>(0,import_core_server5.withTelemetry)("remove",{cliOptions:options},async()=>{await(0,import_core_common29.removeAddon)(addonName,options),options.disableTelemetry||await(0,import_telemetry4.telemetry)("remove",{addon:addonName,source:"cli"})}));command("upgrade").description(`Upgrade your Storybook packages to v${import_core_common29.versions.storybook}`).option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing dependencies").option("-y --yes","Skip prompting the user").option("-f --force","force the upgrade, skipping autoblockers").option("-n --dry-run","Only check for upgrades, do not install").option("-s --skip-check","Skip postinstall version and automigration checks").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").action(async options=>upgrade(options).catch(()=>process.exit(1)));command("info").description("Prints debugging information about the local environment").action(async()=>{consoleLogger.log(import_chalk43.default.bold(`
664
- Storybook Environment Info:`));let activePackageManager=(await import_core_common29.JsPackageManagerFactory.getPackageManager()).type.replace(/\d/,""),output=await import_envinfo.default.run({System:["OS","CPU","Shell"],Binaries:["Node","Yarn","npm","pnpm"],Browsers:["Chrome","Edge","Firefox","Safari"],npmPackages:"{@storybook/*,*storybook*,sb,chromatic}",npmGlobalPackages:"{@storybook/*,*storybook*,sb,chromatic}"}),activePackageManagerLine=output.match(new RegExp(`${activePackageManager}:.*`,"i"));consoleLogger.log(output.replace(activePackageManagerLine,import_chalk43.default.bold(`${activePackageManagerLine} <----- active`)))});command("migrate [migration]").description("Run a Storybook codemod migration on your source files").option("-l --list","List available migrations").option("-g --glob <glob>","Glob for files upon which to apply the migration","**/*.js").option("-p --parser <babel | babylon | flow | ts | tsx>","jscodeshift parser").option("-n --dry-run","Dry run: verify the migration exists and show the files to which it will be applied").option("-r --rename <from-to>",'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"').action((migration,{configDir,glob:glob3,dryRun,list,rename,parser})=>{migrate(migration,{configDir,glob:glob3,dryRun,list,rename,parser,logger:consoleLogger}).catch(err=>{import_node_logger9.logger.error(err),process.exit(1)})});command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>","Define an output directory").option("--no-init","Whether to download a template without an initialized Storybook",!1).action((filterValue,options)=>sandbox({filterValue,...options},pkg).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)}));command("link <repo-url-or-directory>").description("Pull down a repro from a URL (or a local directory), link it, and run storybook").option("--local","Link a local directory already in your file system").option("--no-start","Start the storybook",!0).action((target,{local,start})=>link({target,local,start}).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)}));command("automigrate [fixId]").description("Check storybook for incompatibilities or migrations and apply fixes").option("-y --yes","Skip prompting the user").option("-n --dry-run","Only check for fixes, do not actually run them").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-l --list","List available migrations").option("-c, --config-dir <dir-name>","Directory of Storybook configurations to migrate").option("-s --skip-install","Skip installing deps").option("--renderer <renderer-pkg-name>","The renderer package for the framework Storybook is using.").action(async(fixId,options)=>{await doAutomigrate({fixId,...options}).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)})});command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-c, --config-dir <dir-name>","Directory of Storybook configuration").action(async options=>{await doctor(options).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)})});command("dev").option("-p, --port <number>","Port to run Storybook",str=>parseInt(str,10)).option("-h, --host <string>","Host to run Storybook").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("--https","Serve Storybook over HTTPS. Note: You must provide your own certificate information.").option("--ssl-ca <ca>","Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",import_core_common29.parseList).option("--ssl-cert <cert>","Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>","Provide an SSL key. (Required with --https)").option("--smoke-test","Exit after successful start").option("--ci","CI mode (skip interactive prompts, don't open browser)").option("--no-open","Do not open Storybook automatically in the browser").option("--loglevel <level>","Control level of logging during build").option("--quiet","Suppress verbose build output").option("--no-version-updates","Suppress update check",!0).option("--debug-webpack","Display final webpack configurations for debugging purposes").option("--webpack-stats-json [directory]","Write Webpack stats JSON to disk (synonym for `--stats-json`)").option("--stats-json [directory]","Write stats JSON to disk").option("--preview-url <string>","Disables the default storybook preview and lets your use your own").option("--force-build-preview","Build the preview iframe even if you are using --preview-url").option("--docs","Build a documentation-only site using addon-docs").option("--exact-port","Exit early if the desired port is not available").option("--initial-path [path]","URL path to be appended when visiting Storybook for the first time").action(async options=>{import_node_logger9.logger.setLevel(import_commander.default.loglevel),consoleLogger.log(import_chalk43.default.bold(`${pkg.name} v${pkg.version}`)+import_chalk43.default.reset(`
664
+ Storybook Environment Info:`));let activePackageManager=(await import_core_common29.JsPackageManagerFactory.getPackageManager()).type.replace(/\d/,""),output=await import_envinfo.default.run({System:["OS","CPU","Shell"],Binaries:["Node","Yarn","npm","pnpm"],Browsers:["Chrome","Edge","Firefox","Safari"],npmPackages:"{@storybook/*,*storybook*,sb,chromatic}",npmGlobalPackages:"{@storybook/*,*storybook*,sb,chromatic}"}),activePackageManagerLine=output.match(new RegExp(`${activePackageManager}:.*`,"i"));consoleLogger.log(output.replace(activePackageManagerLine,import_chalk43.default.bold(`${activePackageManagerLine} <----- active`)))});command("migrate [migration]").description("Run a Storybook codemod migration on your source files").option("-l --list","List available migrations").option("-g --glob <glob>","Glob for files upon which to apply the migration","**/*.js").option("-p --parser <babel | babylon | flow | ts | tsx>","jscodeshift parser").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("-n --dry-run","Dry run: verify the migration exists and show the files to which it will be applied").option("-r --rename <from-to>",'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"').action((migration,{configDir,glob:glob3,dryRun,list,rename,parser})=>{migrate(migration,{configDir,glob:glob3,dryRun,list,rename,parser}).catch(err=>{import_node_logger9.logger.error(err),process.exit(1)})});command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>","Define an output directory").option("--no-init","Whether to download a template without an initialized Storybook",!1).action((filterValue,options)=>sandbox({filterValue,...options},pkg).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)}));command("link <repo-url-or-directory>").description("Pull down a repro from a URL (or a local directory), link it, and run storybook").option("--local","Link a local directory already in your file system").option("--no-start","Start the storybook",!0).action((target,{local,start})=>link({target,local,start}).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)}));command("automigrate [fixId]").description("Check storybook for incompatibilities or migrations and apply fixes").option("-y --yes","Skip prompting the user").option("-n --dry-run","Only check for fixes, do not actually run them").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-l --list","List available migrations").option("-c, --config-dir <dir-name>","Directory of Storybook configurations to migrate").option("-s --skip-install","Skip installing deps").option("--renderer <renderer-pkg-name>","The renderer package for the framework Storybook is using.").action(async(fixId,options)=>{await doAutomigrate({fixId,...options}).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)})});command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-c, --config-dir <dir-name>","Directory of Storybook configuration").action(async options=>{await doctor(options).catch(e=>{import_node_logger9.logger.error(e),process.exit(1)})});command("dev").option("-p, --port <number>","Port to run Storybook",str=>parseInt(str,10)).option("-h, --host <string>","Host to run Storybook").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("--https","Serve Storybook over HTTPS. Note: You must provide your own certificate information.").option("--ssl-ca <ca>","Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",import_core_common29.parseList).option("--ssl-cert <cert>","Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>","Provide an SSL key. (Required with --https)").option("--smoke-test","Exit after successful start").option("--ci","CI mode (skip interactive prompts, don't open browser)").option("--no-open","Do not open Storybook automatically in the browser").option("--loglevel <level>","Control level of logging during build").option("--quiet","Suppress verbose build output").option("--no-version-updates","Suppress update check",!0).option("--debug-webpack","Display final webpack configurations for debugging purposes").option("--webpack-stats-json [directory]","Write Webpack stats JSON to disk (synonym for `--stats-json`)").option("--stats-json [directory]","Write stats JSON to disk").option("--preview-url <string>","Disables the default storybook preview and lets your use your own").option("--force-build-preview","Build the preview iframe even if you are using --preview-url").option("--docs","Build a documentation-only site using addon-docs").option("--exact-port","Exit early if the desired port is not available").option("--initial-path [path]","URL path to be appended when visiting Storybook for the first time").action(async options=>{import_node_logger9.logger.setLevel(import_commander.default.loglevel),consoleLogger.log(import_chalk43.default.bold(`${pkg.name} v${pkg.version}`)+import_chalk43.default.reset(`
665
665
  `)),(0,import_core_common29.getEnvConfig)(options,{port:"SBCONFIG_PORT",host:"SBCONFIG_HOSTNAME",staticDir:"SBCONFIG_STATIC_DIR",configDir:"SBCONFIG_CONFIG_DIR",ci:"CI"}),parseInt(`${options.port}`,10)&&(options.port=parseInt(`${options.port}`,10)),await dev({...options,packageJson:pkg}).catch(()=>process.exit(1))});command("build").option("-o, --output-dir <dir-name>","Directory where to store built files").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("--quiet","Suppress verbose build output").option("--loglevel <level>","Control level of logging during build").option("--debug-webpack","Display final webpack configurations for debugging purposes").option("--webpack-stats-json [directory]","Write Webpack stats JSON to disk (synonym for `--stats-json`)").option("--stats-json [directory]","Write stats JSON to disk").option("--preview-url <string>","Disables the default storybook preview and lets your use your own").option("--force-build-preview","Build the preview iframe even if you are using --preview-url").option("--docs","Build a documentation-only site using addon-docs").option("--test","Build stories optimized for testing purposes.").action(async options=>{process.env.NODE_ENV=process.env.NODE_ENV||"production",import_node_logger9.logger.setLevel(import_commander.default.loglevel),consoleLogger.log(import_chalk43.default.bold(`${pkg.name} v${pkg.version}
666
666
  `)),(0,import_core_common29.getEnvConfig)(options,{staticDir:"SBCONFIG_STATIC_DIR",outputDir:"SBCONFIG_OUTPUT_DIR",configDir:"SBCONFIG_CONFIG_DIR"}),await build({...options,packageJson:pkg,test:!!options.test||process.env.SB_TESTBUILD==="true"}).catch(()=>process.exit(1))});import_commander.default.on("command:*",([invalidCmd])=>{consoleLogger.error(` Invalid command: %s.
667
667
  See --help for a list of available commands.`,invalidCmd);let suggestion=import_commander.default.commands.map(cmd=>cmd._name).find(cmd=>(0,import_leven.default)(cmd,invalidCmd)<3);suggestion&&consoleLogger.info(`
package/dist/generate.mjs CHANGED
@@ -590,7 +590,7 @@ ${chalk15.cyan("npx storybook doctor")}`;logger23.info(),foundIssues?(logger23.i
590
590
  ${availableFixes}
591
591
  `);},doAutomigrate=async options=>{let packageManager=JsPackageManagerFactory.getPackageManager({force:options.packageManager}),[packageJson,storybookVersion]=await Promise.all([packageManager.retrievePackageJson(),getCoercedStorybookVersion(packageManager)]),{configDir:inferredConfigDir,mainConfig:mainConfigPath}=getStorybookInfo(packageJson,options.configDir),configDir=options.configDir||inferredConfigDir||".storybook";if(!storybookVersion)throw new Error("Could not determine Storybook version");if(!mainConfigPath)throw new Error("Could not determine main config path");await automigrate({...options,packageManager,storybookVersion,beforeVersion:storybookVersion,mainConfigPath,configDir,isUpgrade:!1,isLatest:!1})&&await doctor({configDir,packageManager:options.packageManager});},automigrate=async({fixId,fixes:inputFixes,dryRun,yes,packageManager,list,configDir,mainConfigPath,storybookVersion,beforeVersion,renderer:rendererPackage,skipInstall,hideMigrationSummary=!1,isUpgrade,isLatest})=>{if(list)return logAvailableMigrations(),null;let selectedFixes=inputFixes||allFixes.filter(fix=>!(fix.id===upgradeStorybookRelatedDependencies.id&&isLatest===!1&&fixId!==upgradeStorybookRelatedDependencies.id)),fixes=fixId?selectedFixes.filter(f=>f.id===fixId):selectedFixes;if(fixId&&fixes.length===0)return logger24.info(`\u{1F4ED} No migrations found for ${chalk15.magenta(fixId)}.`),logAvailableMigrations(),null;augmentLogsToFile2(),logger24.info("\u{1F50E} checking possible migrations..");let{fixResults,fixSummary,preCheckFailure}=await runFixes({fixes,packageManager,rendererPackage,skipInstall,configDir,mainConfigPath,storybookVersion,beforeVersion,isUpgrade:!!isUpgrade,dryRun,yes});if(Object.values(fixResults).some(r=>r==="failed"||r==="check_failed")?await move(TEMP_LOG_FILE_PATH2,join(process.cwd(),LOG_FILE_NAME2),{overwrite:!0}):await remove(TEMP_LOG_FILE_PATH2),!hideMigrationSummary){let installationMetadata=await packageManager.findInstallations(["@storybook/*","storybook"]);logger24.info(),logger24.info(getMigrationSummary({fixResults,fixSummary,logFile:LOG_FILE_PATH2,installationMetadata})),logger24.info();}return cleanup2(),{fixResults,preCheckFailure}};async function runFixes({fixes,dryRun,yes,rendererPackage,skipInstall,configDir,packageManager,mainConfigPath,storybookVersion,beforeVersion,isUpgrade}){let fixResults={},fixSummary={succeeded:[],failed:{},manual:[],skipped:[]};for(let i=0;i<fixes.length;i+=1){let f=fixes[i],result;try{let{mainConfig,previewConfigPath}=await getStorybookData({configDir,packageManager});(isUpgrade&&semver.satisfies(beforeVersion,f.versionRange[0],{includePrerelease:!0})&&semver.satisfies(storybookVersion,f.versionRange[1],{includePrerelease:!0})||!isUpgrade)&&(result=await f.check({packageManager,configDir,rendererPackage,mainConfig,storybookVersion,previewConfigPath,mainConfigPath}));}catch(error){logger24.info(`\u26A0\uFE0F failed to check fix ${chalk15.bold(f.id)}`),error instanceof Error&&(logger24.error(`
592
592
  ${error.stack}`),fixSummary.failed[f.id]=error.message),fixResults[f.id]="check_failed";}if(result){let promptType=typeof f.promptType=="function"?await f.promptType(result):f.promptType??"auto";logger24.info(`
593
- \u{1F50E} found a '${chalk15.cyan(f.id)}' migration:`);let message=f.prompt(result),getTitle=()=>{switch(promptType){case"auto":return "Automigration detected";case"manual":return "Manual migration detected";case"notification":return "Migration notification"}};logger24.info(boxen(message,{borderStyle:"round",padding:1,borderColor:"#F1618C",title:getTitle()}));let runAnswer;try{if(dryRun)runAnswer={fix:!1};else if(yes)runAnswer={fix:!0},promptType==="manual"&&(fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id));else if(promptType==="manual"){fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id),logger24.info();let{shouldContinue}=await prompts5({type:"toggle",name:"shouldContinue",message:"Select continue once you have made the required changes, or quit to exit the migration process",initial:!0,active:"continue",inactive:"quit"},{onCancel:()=>{throw new Error}});if(!shouldContinue){fixResults[f.id]="manual_skipped";break}}else promptType==="auto"?runAnswer=await prompts5({type:"confirm",name:"fix",message:`Do you want to run the '${chalk15.cyan(f.id)}' migration on your project?`,initial:f.promptDefaultValue??!0},{onCancel:()=>{throw new Error}}):promptType==="notification"&&(runAnswer=await prompts5({type:"confirm",name:"fix",message:"Do you want to continue?",initial:!0},{onCancel:()=>{throw new Error}}));}catch{break}if(promptType==="auto")if(invariant5(runAnswer,"runAnswer must be defined if not promptOnly"),runAnswer.fix)try{invariant5(typeof f.run=="function","run method should be available in fix."),invariant5(mainConfigPath,"Main config path should be defined to run migration."),await f.run({result,packageManager,dryRun,mainConfigPath,skipInstall}),logger24.info(`\u2705 ran ${chalk15.cyan(f.id)} migration`),fixResults[f.id]="succeeded",fixSummary.succeeded.push(f.id);}catch(error){fixResults[f.id]="failed",fixSummary.failed[f.id]=error instanceof Error?error.message:"Failed to run migration",logger24.info(`\u274C error when running ${chalk15.cyan(f.id)} migration`),logger24.info(error),logger24.info();}else fixResults[f.id]="skipped",fixSummary.skipped.push(f.id);}else fixResults[f.id]=fixResults[f.id]||"unnecessary";}return {fixResults,fixSummary}}var logger25=console;async function migrate(migration,{glob:glob3,dryRun,list,rename,parser}){if(list)listCodemods().forEach(key=>logger25.log(key));else if(migration){if(migration==="mdx-to-csf"&&!dryRun){let packageManager=JsPackageManagerFactory.getPackageManager(),[packageJson,storybookVersion]=await Promise.all([packageManager.retrievePackageJson(),getCoercedStorybookVersion(packageManager)]),{configDir:inferredConfigDir,mainConfig:mainConfigPath}=getStorybookInfo(packageJson),configDir=inferredConfigDir||".storybook";if(!storybookVersion)throw new Error("Could not determine Storybook version");if(!mainConfigPath)throw new Error("Could not determine main config path");await runFixes({fixes:[mdxToCSF],configDir,mainConfigPath,packageManager,storybookVersion,beforeVersion:storybookVersion,isUpgrade:!1}),await addStorybookBlocksPackage();}await runCodemod(migration,{glob:glob3,dryRun,logger:logger25,rename,parser});}else throw new Error("Migrate: please specify a migration name or --list")}async function addStorybookBlocksPackage(){let packageManager=JsPackageManagerFactory.getPackageManager(),packageJson=await packageManager.retrievePackageJson(),versionToInstall=getStorybookVersionSpecifier(await packageManager.retrievePackageJson());logger25.info('\u2705 Adding "@storybook/blocks" package'),await packageManager.addDependencies({installAsDevDependencies:!0,packageJson},[`@storybook/blocks@${versionToInstall}`]);}var excludesFalse=x=>x!==!1,blockers=()=>[import('./block-storystorev6-C2BHRNHL.mjs'),import('./block-dependencies-versions-VDCGN5AR.mjs'),import('./block-node-version-DKYGVJZQ.mjs')],segmentDivider2=`
593
+ \u{1F50E} found a '${chalk15.cyan(f.id)}' migration:`);let message=f.prompt(result),getTitle=()=>{switch(promptType){case"auto":return "Automigration detected";case"manual":return "Manual migration detected";case"notification":return "Migration notification"}};logger24.info(boxen(message,{borderStyle:"round",padding:1,borderColor:"#F1618C",title:getTitle()}));let runAnswer;try{if(dryRun)runAnswer={fix:!1};else if(yes)runAnswer={fix:!0},promptType==="manual"&&(fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id));else if(promptType==="manual"){fixResults[f.id]="manual_succeeded",fixSummary.manual.push(f.id),logger24.info();let{shouldContinue}=await prompts5({type:"toggle",name:"shouldContinue",message:"Select continue once you have made the required changes, or quit to exit the migration process",initial:!0,active:"continue",inactive:"quit"},{onCancel:()=>{throw new Error}});if(!shouldContinue){fixResults[f.id]="manual_skipped";break}}else promptType==="auto"?runAnswer=await prompts5({type:"confirm",name:"fix",message:`Do you want to run the '${chalk15.cyan(f.id)}' migration on your project?`,initial:f.promptDefaultValue??!0},{onCancel:()=>{throw new Error}}):promptType==="notification"&&(runAnswer=await prompts5({type:"confirm",name:"fix",message:"Do you want to continue?",initial:!0},{onCancel:()=>{throw new Error}}));}catch{break}if(promptType==="auto")if(invariant5(runAnswer,"runAnswer must be defined if not promptOnly"),runAnswer.fix)try{invariant5(typeof f.run=="function","run method should be available in fix."),invariant5(mainConfigPath,"Main config path should be defined to run migration."),await f.run({result,packageManager,dryRun,mainConfigPath,skipInstall}),logger24.info(`\u2705 ran ${chalk15.cyan(f.id)} migration`),fixResults[f.id]="succeeded",fixSummary.succeeded.push(f.id);}catch(error){fixResults[f.id]="failed",fixSummary.failed[f.id]=error instanceof Error?error.message:"Failed to run migration",logger24.info(`\u274C error when running ${chalk15.cyan(f.id)} migration`),logger24.info(error),logger24.info();}else fixResults[f.id]="skipped",fixSummary.skipped.push(f.id);}else fixResults[f.id]=fixResults[f.id]||"unnecessary";}return {fixResults,fixSummary}}var logger25=console;async function migrate(migration,{glob:glob3,dryRun,list,rename,parser,configDir:userSpecifiedConfigDir}){if(list)listCodemods().forEach(key=>logger25.log(key));else if(migration){if(migration==="mdx-to-csf"&&!dryRun){let packageManager=JsPackageManagerFactory.getPackageManager(),[packageJson,storybookVersion]=await Promise.all([packageManager.retrievePackageJson(),getCoercedStorybookVersion(packageManager)]),{configDir:inferredConfigDir,mainConfig:mainConfigPath}=getStorybookInfo(packageJson,userSpecifiedConfigDir),configDir=userSpecifiedConfigDir||inferredConfigDir||".storybook";if(!storybookVersion)throw new Error("Could not determine Storybook version");if(!mainConfigPath)throw new Error("Could not determine main config path");await runFixes({fixes:[mdxToCSF],configDir,mainConfigPath,packageManager,storybookVersion,beforeVersion:storybookVersion,isUpgrade:!1}),await addStorybookBlocksPackage();}await runCodemod(migration,{glob:glob3,dryRun,logger:logger25,rename,parser});}else throw new Error("Migrate: please specify a migration name or --list")}async function addStorybookBlocksPackage(){let packageManager=JsPackageManagerFactory.getPackageManager(),packageJson=await packageManager.retrievePackageJson(),versionToInstall=getStorybookVersionSpecifier(await packageManager.retrievePackageJson());logger25.info('\u2705 Adding "@storybook/blocks" package'),await packageManager.addDependencies({installAsDevDependencies:!0,packageJson},[`@storybook/blocks@${versionToInstall}`]);}var excludesFalse=x=>x!==!1,blockers=()=>[import('./block-storystorev6-C2BHRNHL.mjs'),import('./block-dependencies-versions-VDCGN5AR.mjs'),import('./block-node-version-DKYGVJZQ.mjs')],segmentDivider2=`
594
594
 
595
595
  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
596
596
 
@@ -656,7 +656,7 @@ ${error.stack}`),fixSummary.failed[f.id]=error.message),fixResults[f.id]="check_
656
656
  Broken build, fix the error above.
657
657
  You may need to refresh the browser.
658
658
  `),logger.line();}var dev=async cliOptions=>{process.env.NODE_ENV=process.env.NODE_ENV||"development";let readUpResult2=sync$1({cwd:__dirname});invariant5(readUpResult2,"Failed to find the closest package.json file.");let options={...cliOptions,configDir:cliOptions.configDir||"./.storybook",configType:"DEVELOPMENT",ignorePreview:!!cliOptions.previewUrl&&!cliOptions.forceBuildPreview,cache,packageJson:sync$1({cwd:__dirname})?.packageJson};await withTelemetry("dev",{cliOptions,presetOptions:options,printError},()=>buildDevStandalone(options));};var build=async cliOptions=>{let readUpResult2=sync$1({cwd:__dirname});invariant5(readUpResult2,"Failed to find the closest package.json file.");let options={...cliOptions,configDir:cliOptions.configDir||"./.storybook",outputDir:cliOptions.outputDir||"./storybook-static",ignorePreview:!!cliOptions.previewUrl&&!cliOptions.forceBuildPreview,configType:"PRODUCTION",cache:cache,packageJson:readUpResult2.packageJson};await withTelemetry("build",{cliOptions,presetOptions:options},()=>buildStaticStandalone(options));};addToGlobalContext("cliVersion",versions.storybook);var readUpResult=sync$1({cwd:__dirname});invariant5(readUpResult,"Failed to find the closest package.json file.");var pkg=readUpResult.packageJson,consoleLogger=console,command=name=>program.command(name).option("--disable-telemetry","Disable sending telemetry data",process.env.STORYBOOK_DISABLE_TELEMETRY&&process.env.STORYBOOK_DISABLE_TELEMETRY!=="false").option("--debug","Get more logs in debug mode",!1).option("--enable-crash-reports","Enable sending crash reports to telemetry data");command("init").description("Initialize Storybook into your project.").option("-f --force","Force add Storybook").option("-s --skip-install","Skip installing deps").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing deps").option("--use-pnp","Enable pnp mode for Yarn 2+").option("-p --parser <babel | babylon | flow | ts | tsx>","jscodeshift parser").option("-t --type <type>","Add Storybook for a specific project type").option("-y --yes","Answer yes to all prompts").option("-b --builder <webpack5 | vite>","Builder library").option("-l --linkable","Prepare installation for link (contributor helper)").action(options=>{initiate(options).catch(()=>process.exit(1));});command("add <addon>").description("Add an addon to your Storybook").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing dependencies").option("-s --skip-postinstall","Skip package specific postinstall config modifications").action((addonName,options)=>add(addonName,options));command("remove <addon>").description("Remove an addon from your Storybook").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing dependencies").action((addonName,options)=>withTelemetry("remove",{cliOptions:options},async()=>{await removeAddon(addonName,options),options.disableTelemetry||await telemetry("remove",{addon:addonName,source:"cli"});}));command("upgrade").description(`Upgrade your Storybook packages to v${versions.storybook}`).option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager for installing dependencies").option("-y --yes","Skip prompting the user").option("-f --force","force the upgrade, skipping autoblockers").option("-n --dry-run","Only check for upgrades, do not install").option("-s --skip-check","Skip postinstall version and automigration checks").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").action(async options=>upgrade(options).catch(()=>process.exit(1)));command("info").description("Prints debugging information about the local environment").action(async()=>{consoleLogger.log(chalk15.bold(`
659
- Storybook Environment Info:`));let activePackageManager=(await JsPackageManagerFactory.getPackageManager()).type.replace(/\d/,""),output=await envinfo.run({System:["OS","CPU","Shell"],Binaries:["Node","Yarn","npm","pnpm"],Browsers:["Chrome","Edge","Firefox","Safari"],npmPackages:"{@storybook/*,*storybook*,sb,chromatic}",npmGlobalPackages:"{@storybook/*,*storybook*,sb,chromatic}"}),activePackageManagerLine=output.match(new RegExp(`${activePackageManager}:.*`,"i"));consoleLogger.log(output.replace(activePackageManagerLine,chalk15.bold(`${activePackageManagerLine} <----- active`)));});command("migrate [migration]").description("Run a Storybook codemod migration on your source files").option("-l --list","List available migrations").option("-g --glob <glob>","Glob for files upon which to apply the migration","**/*.js").option("-p --parser <babel | babylon | flow | ts | tsx>","jscodeshift parser").option("-n --dry-run","Dry run: verify the migration exists and show the files to which it will be applied").option("-r --rename <from-to>",'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"').action((migration,{configDir,glob:glob3,dryRun,list,rename,parser})=>{migrate(migration,{configDir,glob:glob3,dryRun,list,rename,parser,logger:consoleLogger}).catch(err=>{logger.error(err),process.exit(1);});});command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>","Define an output directory").option("--no-init","Whether to download a template without an initialized Storybook",!1).action((filterValue,options)=>sandbox({filterValue,...options},pkg).catch(e=>{logger.error(e),process.exit(1);}));command("link <repo-url-or-directory>").description("Pull down a repro from a URL (or a local directory), link it, and run storybook").option("--local","Link a local directory already in your file system").option("--no-start","Start the storybook",!0).action((target,{local,start})=>link({target,local,start}).catch(e=>{logger.error(e),process.exit(1);}));command("automigrate [fixId]").description("Check storybook for incompatibilities or migrations and apply fixes").option("-y --yes","Skip prompting the user").option("-n --dry-run","Only check for fixes, do not actually run them").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-l --list","List available migrations").option("-c, --config-dir <dir-name>","Directory of Storybook configurations to migrate").option("-s --skip-install","Skip installing deps").option("--renderer <renderer-pkg-name>","The renderer package for the framework Storybook is using.").action(async(fixId,options)=>{await doAutomigrate({fixId,...options}).catch(e=>{logger.error(e),process.exit(1);});});command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-c, --config-dir <dir-name>","Directory of Storybook configuration").action(async options=>{await doctor(options).catch(e=>{logger.error(e),process.exit(1);});});command("dev").option("-p, --port <number>","Port to run Storybook",str=>parseInt(str,10)).option("-h, --host <string>","Host to run Storybook").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("--https","Serve Storybook over HTTPS. Note: You must provide your own certificate information.").option("--ssl-ca <ca>","Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",parseList).option("--ssl-cert <cert>","Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>","Provide an SSL key. (Required with --https)").option("--smoke-test","Exit after successful start").option("--ci","CI mode (skip interactive prompts, don't open browser)").option("--no-open","Do not open Storybook automatically in the browser").option("--loglevel <level>","Control level of logging during build").option("--quiet","Suppress verbose build output").option("--no-version-updates","Suppress update check",!0).option("--debug-webpack","Display final webpack configurations for debugging purposes").option("--webpack-stats-json [directory]","Write Webpack stats JSON to disk (synonym for `--stats-json`)").option("--stats-json [directory]","Write stats JSON to disk").option("--preview-url <string>","Disables the default storybook preview and lets your use your own").option("--force-build-preview","Build the preview iframe even if you are using --preview-url").option("--docs","Build a documentation-only site using addon-docs").option("--exact-port","Exit early if the desired port is not available").option("--initial-path [path]","URL path to be appended when visiting Storybook for the first time").action(async options=>{logger.setLevel(program.loglevel),consoleLogger.log(chalk15.bold(`${pkg.name} v${pkg.version}`)+chalk15.reset(`
659
+ Storybook Environment Info:`));let activePackageManager=(await JsPackageManagerFactory.getPackageManager()).type.replace(/\d/,""),output=await envinfo.run({System:["OS","CPU","Shell"],Binaries:["Node","Yarn","npm","pnpm"],Browsers:["Chrome","Edge","Firefox","Safari"],npmPackages:"{@storybook/*,*storybook*,sb,chromatic}",npmGlobalPackages:"{@storybook/*,*storybook*,sb,chromatic}"}),activePackageManagerLine=output.match(new RegExp(`${activePackageManager}:.*`,"i"));consoleLogger.log(output.replace(activePackageManagerLine,chalk15.bold(`${activePackageManagerLine} <----- active`)));});command("migrate [migration]").description("Run a Storybook codemod migration on your source files").option("-l --list","List available migrations").option("-g --glob <glob>","Glob for files upon which to apply the migration","**/*.js").option("-p --parser <babel | babylon | flow | ts | tsx>","jscodeshift parser").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("-n --dry-run","Dry run: verify the migration exists and show the files to which it will be applied").option("-r --rename <from-to>",'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"').action((migration,{configDir,glob:glob3,dryRun,list,rename,parser})=>{migrate(migration,{configDir,glob:glob3,dryRun,list,rename,parser}).catch(err=>{logger.error(err),process.exit(1);});});command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>","Define an output directory").option("--no-init","Whether to download a template without an initialized Storybook",!1).action((filterValue,options)=>sandbox({filterValue,...options},pkg).catch(e=>{logger.error(e),process.exit(1);}));command("link <repo-url-or-directory>").description("Pull down a repro from a URL (or a local directory), link it, and run storybook").option("--local","Link a local directory already in your file system").option("--no-start","Start the storybook",!0).action((target,{local,start})=>link({target,local,start}).catch(e=>{logger.error(e),process.exit(1);}));command("automigrate [fixId]").description("Check storybook for incompatibilities or migrations and apply fixes").option("-y --yes","Skip prompting the user").option("-n --dry-run","Only check for fixes, do not actually run them").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-l --list","List available migrations").option("-c, --config-dir <dir-name>","Directory of Storybook configurations to migrate").option("-s --skip-install","Skip installing deps").option("--renderer <renderer-pkg-name>","The renderer package for the framework Storybook is using.").action(async(fixId,options)=>{await doAutomigrate({fixId,...options}).catch(e=>{logger.error(e),process.exit(1);});});command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").option("--package-manager <npm|pnpm|yarn1|yarn2>","Force package manager").option("-c, --config-dir <dir-name>","Directory of Storybook configuration").action(async options=>{await doctor(options).catch(e=>{logger.error(e),process.exit(1);});});command("dev").option("-p, --port <number>","Port to run Storybook",str=>parseInt(str,10)).option("-h, --host <string>","Host to run Storybook").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("--https","Serve Storybook over HTTPS. Note: You must provide your own certificate information.").option("--ssl-ca <ca>","Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",parseList).option("--ssl-cert <cert>","Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>","Provide an SSL key. (Required with --https)").option("--smoke-test","Exit after successful start").option("--ci","CI mode (skip interactive prompts, don't open browser)").option("--no-open","Do not open Storybook automatically in the browser").option("--loglevel <level>","Control level of logging during build").option("--quiet","Suppress verbose build output").option("--no-version-updates","Suppress update check",!0).option("--debug-webpack","Display final webpack configurations for debugging purposes").option("--webpack-stats-json [directory]","Write Webpack stats JSON to disk (synonym for `--stats-json`)").option("--stats-json [directory]","Write stats JSON to disk").option("--preview-url <string>","Disables the default storybook preview and lets your use your own").option("--force-build-preview","Build the preview iframe even if you are using --preview-url").option("--docs","Build a documentation-only site using addon-docs").option("--exact-port","Exit early if the desired port is not available").option("--initial-path [path]","URL path to be appended when visiting Storybook for the first time").action(async options=>{logger.setLevel(program.loglevel),consoleLogger.log(chalk15.bold(`${pkg.name} v${pkg.version}`)+chalk15.reset(`
660
660
  `)),getEnvConfig(options,{port:"SBCONFIG_PORT",host:"SBCONFIG_HOSTNAME",staticDir:"SBCONFIG_STATIC_DIR",configDir:"SBCONFIG_CONFIG_DIR",ci:"CI"}),parseInt(`${options.port}`,10)&&(options.port=parseInt(`${options.port}`,10)),await dev({...options,packageJson:pkg}).catch(()=>process.exit(1));});command("build").option("-o, --output-dir <dir-name>","Directory where to store built files").option("-c, --config-dir <dir-name>","Directory where to load Storybook configurations from").option("--quiet","Suppress verbose build output").option("--loglevel <level>","Control level of logging during build").option("--debug-webpack","Display final webpack configurations for debugging purposes").option("--webpack-stats-json [directory]","Write Webpack stats JSON to disk (synonym for `--stats-json`)").option("--stats-json [directory]","Write stats JSON to disk").option("--preview-url <string>","Disables the default storybook preview and lets your use your own").option("--force-build-preview","Build the preview iframe even if you are using --preview-url").option("--docs","Build a documentation-only site using addon-docs").option("--test","Build stories optimized for testing purposes.").action(async options=>{process.env.NODE_ENV=process.env.NODE_ENV||"production",logger.setLevel(program.loglevel),consoleLogger.log(chalk15.bold(`${pkg.name} v${pkg.version}
661
661
  `)),getEnvConfig(options,{staticDir:"SBCONFIG_STATIC_DIR",outputDir:"SBCONFIG_OUTPUT_DIR",configDir:"SBCONFIG_CONFIG_DIR"}),await build({...options,packageJson:pkg,test:!!options.test||process.env.SB_TESTBUILD==="true"}).catch(()=>process.exit(1));});program.on("command:*",([invalidCmd])=>{consoleLogger.error(` Invalid command: %s.
662
662
  See --help for a list of available commands.`,invalidCmd);let suggestion=program.commands.map(cmd=>cmd._name).find(cmd=>leven(cmd,invalidCmd)<3);suggestion&&consoleLogger.info(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/cli",
3
- "version": "8.0.5",
3
+ "version": "8.0.6",
4
4
  "description": "Storybook's CLI - install, dev, build, upgrade, and more",
5
5
  "keywords": [
6
6
  "cli",
@@ -59,14 +59,14 @@
59
59
  "@babel/core": "^7.23.0",
60
60
  "@babel/types": "^7.23.0",
61
61
  "@ndelangen/get-tarball": "^3.0.7",
62
- "@storybook/codemod": "8.0.5",
63
- "@storybook/core-common": "8.0.5",
64
- "@storybook/core-events": "8.0.5",
65
- "@storybook/core-server": "8.0.5",
66
- "@storybook/csf-tools": "8.0.5",
67
- "@storybook/node-logger": "8.0.5",
68
- "@storybook/telemetry": "8.0.5",
69
- "@storybook/types": "8.0.5",
62
+ "@storybook/codemod": "8.0.6",
63
+ "@storybook/core-common": "8.0.6",
64
+ "@storybook/core-events": "8.0.6",
65
+ "@storybook/core-server": "8.0.6",
66
+ "@storybook/csf-tools": "8.0.6",
67
+ "@storybook/node-logger": "8.0.6",
68
+ "@storybook/telemetry": "8.0.6",
69
+ "@storybook/types": "8.0.6",
70
70
  "@types/semver": "^7.3.4",
71
71
  "@yarnpkg/fslib": "2.10.3",
72
72
  "@yarnpkg/libzip": "2.3.0",