@storybook/cli 9.0.16 → 9.0.17

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.
@@ -77,7 +77,7 @@ ${project.error.stack||project.error.message}`).join(`
77
77
  ${errorMessage}
78
78
  Please fix the errors and run the upgrade command again.`)}let selectedProjects=await handleMultipleProjects(validProjects,errorProjects,detectedConfigDirs,options.yes);return selectedProjects?{allProjects:validProjects,selectedProjects}:void 0}catch(error){throw error instanceof import_common2.HandledError||import_node_logger3.logger.error("Failed to get projects"),error}},findFilesUp=(matchers,cwd)=>{let matchingFiles=[];return findUpMultipleSync(directory=>{matchingFiles.push(...globbySync(matchers,{gitignore:!0,cwd:directory}))},{cwd,stopAt:(0,import_common3.getProjectRoot)()}),matchingFiles},getStoriesPathsFromConfig=async({stories,configDir,workingDir})=>{if(stories.length===0)return[];let normalizedStories=(0,import_common2.normalizeStories)(stories,{configDir,workingDir});return(await import_core_server.StoryIndexGenerator.findMatchingFilesForSpecifiers(normalizedStories,workingDir,!0)).flatMap(([specifier,cache])=>import_core_server.StoryIndexGenerator.storyFileNames(new Map([[specifier,cache]])))}}});var import_node_path6,import_common4,import_common5,import_csf_tools,import_node_logger4,import_picocolors2,import_ts_dedent4,getFrameworkPackageName,getStorybookData,updateMainConfig,init_mainConfigFile=__esm({"src/automigrate/helpers/mainConfigFile.ts"(){"use strict";import_node_path6=require("path"),import_common4=require("storybook/internal/common"),import_common5=require("storybook/internal/common"),import_csf_tools=require("storybook/internal/csf-tools"),import_node_logger4=require("storybook/internal/node-logger"),import_picocolors2=__toESM(require_picocolors(),1),import_ts_dedent4=require("ts-dedent");init_util();getFrameworkPackageName=mainConfig=>{let packageNameOrPath=typeof mainConfig?.framework=="string"?mainConfig.framework:mainConfig?.framework?.name;return packageNameOrPath?(0,import_common4.extractProperFrameworkName)(packageNameOrPath):null},getStorybookData=async({configDir:userDefinedConfigDir,cwd,packageManagerName,cache=!1})=>{import_node_logger4.logger.debug("Getting Storybook info...");let{mainConfigPath,version:storybookVersionSpecifier,configDir:configDirFromScript,previewConfigPath}=(0,import_common4.getStorybookInfo)(userDefinedConfigDir),configDir=userDefinedConfigDir||configDirFromScript||".storybook";import_node_logger4.logger.debug("Loading main config...");let mainConfig;try{mainConfig=await(0,import_common4.loadMainConfig)({configDir,noCache:!cache,cwd})}catch(err){throw new Error(import_ts_dedent4.dedent`Unable to find or evaluate ${import_picocolors2.default.blue(mainConfigPath)}: ${String(err)}`)}let workingDir=(0,import_node_path6.isAbsolute)(configDir)?(0,import_node_path6.dirname)(configDir):(0,import_node_path6.dirname)((0,import_node_path6.join)(cwd??process.cwd(),configDir));import_node_logger4.logger.debug("Getting stories paths...");let storiesPaths=await getStoriesPathsFromConfig({stories:mainConfig.stories,configDir,workingDir});import_node_logger4.logger.debug("Getting package manager...");let packageManager=import_common4.JsPackageManagerFactory.getPackageManager({force:packageManagerName,configDir,storiesPaths});import_node_logger4.logger.debug("Getting Storybook version...");let storybookVersion=await(0,import_common5.getCoercedStorybookVersion)(packageManager);return{configDir,mainConfig,storybookVersionSpecifier,storybookVersion,mainConfigPath,previewConfigPath,packageManager,storiesPaths}},updateMainConfig=async({mainConfigPath,dryRun},callback)=>{try{let main=await(0,import_csf_tools.readConfig)(mainConfigPath);await callback(main),dryRun||await(0,import_csf_tools.writeConfig)(main)}catch(e){import_node_logger4.logger.log(`\u274C The migration failed to update your ${import_picocolors2.default.blue(mainConfigPath)} on your behalf because of the following error:
79
79
  ${e}
80
- `),import_node_logger4.logger.log(`\u26A0\uFE0F Storybook automigrations are based on AST parsing and it's possible that your ${import_picocolors2.default.blue(mainConfigPath)} file contains a non-standard format (e.g. your export is not an object) or that there was an error when parsing dynamic values (e.g. "require" calls, or usage of environment variables). When your main config is non-standard, automigrations are unfortunately not possible. Please follow the instructions given previously and follow the documentation to make the updates manually.`)}}}});var require_windows=__commonJS({"../../node_modules/isexe/windows.js"(exports2,module2){"use strict";module2.exports=isexe;isexe.sync=sync;var fs7=require("fs");function checkPathExt(path7,options){var pathext=options.pathExt!==void 0?options.pathExt:process.env.PATHEXT;if(!pathext||(pathext=pathext.split(";"),pathext.indexOf("")!==-1))return!0;for(var i=0;i<pathext.length;i++){var p=pathext[i].toLowerCase();if(p&&path7.substr(-p.length).toLowerCase()===p)return!0}return!1}function checkStat(stat,path7,options){return!stat.isSymbolicLink()&&!stat.isFile()?!1:checkPathExt(path7,options)}function isexe(path7,options,cb){fs7.stat(path7,function(er,stat){cb(er,er?!1:checkStat(stat,path7,options))})}function sync(path7,options){return checkStat(fs7.statSync(path7),path7,options)}}});var require_mode=__commonJS({"../../node_modules/isexe/mode.js"(exports2,module2){"use strict";module2.exports=isexe;isexe.sync=sync;var fs7=require("fs");function isexe(path7,options,cb){fs7.stat(path7,function(er,stat){cb(er,er?!1:checkStat(stat,options))})}function sync(path7,options){return checkStat(fs7.statSync(path7),options)}function checkStat(stat,options){return stat.isFile()&&checkMode(stat,options)}function checkMode(stat,options){var mod=stat.mode,uid=stat.uid,gid=stat.gid,myUid=options.uid!==void 0?options.uid:process.getuid&&process.getuid(),myGid=options.gid!==void 0?options.gid:process.getgid&&process.getgid(),u=parseInt("100",8),g=parseInt("010",8),o=parseInt("001",8),ug=u|g,ret=mod&o||mod&g&&gid===myGid||mod&u&&uid===myUid||mod&ug&&myUid===0;return ret}}});var require_isexe=__commonJS({"../../node_modules/isexe/index.js"(exports2,module2){"use strict";var fs7=require("fs"),core;process.platform==="win32"||global.TESTING_WINDOWS?core=require_windows():core=require_mode();module2.exports=isexe;isexe.sync=sync;function isexe(path7,options,cb){if(typeof options=="function"&&(cb=options,options={}),!cb){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(resolve,reject){isexe(path7,options||{},function(er,is){er?reject(er):resolve(is)})})}core(path7,options||{},function(er,is){er&&(er.code==="EACCES"||options&&options.ignoreErrors)&&(er=null,is=!1),cb(er,is)})}function sync(path7,options){try{return core.sync(path7,options||{})}catch(er){if(options&&options.ignoreErrors||er.code==="EACCES")return!1;throw er}}}});var require_which=__commonJS({"../../node_modules/which/which.js"(exports2,module2){"use strict";var isWindows=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",path7=require("path"),COLON=isWindows?";":":",isexe=require_isexe(),getNotFoundError=cmd=>Object.assign(new Error(`not found: ${cmd}`),{code:"ENOENT"}),getPathInfo=(cmd,opt)=>{let colon=opt.colon||COLON,pathEnv=cmd.match(/\//)||isWindows&&cmd.match(/\\/)?[""]:[...isWindows?[process.cwd()]:[],...(opt.path||process.env.PATH||"").split(colon)],pathExtExe=isWindows?opt.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",pathExt=isWindows?pathExtExe.split(colon):[""];return isWindows&&cmd.indexOf(".")!==-1&&pathExt[0]!==""&&pathExt.unshift(""),{pathEnv,pathExt,pathExtExe}},which=(cmd,opt,cb)=>{typeof opt=="function"&&(cb=opt,opt={}),opt||(opt={});let{pathEnv,pathExt,pathExtExe}=getPathInfo(cmd,opt),found=[],step=i=>new Promise((resolve,reject)=>{if(i===pathEnv.length)return opt.all&&found.length?resolve(found):reject(getNotFoundError(cmd));let ppRaw=pathEnv[i],pathPart=/^".*"$/.test(ppRaw)?ppRaw.slice(1,-1):ppRaw,pCmd=path7.join(pathPart,cmd),p=!pathPart&&/^\.[\\\/]/.test(cmd)?cmd.slice(0,2)+pCmd:pCmd;resolve(subStep(p,i,0))}),subStep=(p,i,ii)=>new Promise((resolve,reject)=>{if(ii===pathExt.length)return resolve(step(i+1));let ext=pathExt[ii];isexe(p+ext,{pathExt:pathExtExe},(er,is)=>{if(!er&&is)if(opt.all)found.push(p+ext);else return resolve(p+ext);return resolve(subStep(p,i,ii+1))})});return cb?step(0).then(res=>cb(null,res),cb):step(0)},whichSync=(cmd,opt)=>{opt=opt||{};let{pathEnv,pathExt,pathExtExe}=getPathInfo(cmd,opt),found=[];for(let i=0;i<pathEnv.length;i++){let ppRaw=pathEnv[i],pathPart=/^".*"$/.test(ppRaw)?ppRaw.slice(1,-1):ppRaw,pCmd=path7.join(pathPart,cmd),p=!pathPart&&/^\.[\\\/]/.test(cmd)?cmd.slice(0,2)+pCmd:pCmd;for(let j=0;j<pathExt.length;j++){let cur=p+pathExt[j];try{if(isexe.sync(cur,{pathExt:pathExtExe}))if(opt.all)found.push(cur);else return cur}catch{}}}if(opt.all&&found.length)return found;if(opt.nothrow)return null;throw getNotFoundError(cmd)};module2.exports=which;which.sync=whichSync}});var require_path_key=__commonJS({"../../node_modules/path-key/index.js"(exports2,module2){"use strict";var pathKey=(options={})=>{let environment=options.env||process.env;return(options.platform||process.platform)!=="win32"?"PATH":Object.keys(environment).reverse().find(key=>key.toUpperCase()==="PATH")||"Path"};module2.exports=pathKey;module2.exports.default=pathKey}});var require_resolveCommand=__commonJS({"../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2,module2){"use strict";var path7=require("path"),which=require_which(),getPathKey=require_path_key();function resolveCommandAttempt(parsed,withoutPathExt){let env=parsed.options.env||process.env,cwd=process.cwd(),hasCustomCwd=parsed.options.cwd!=null,shouldSwitchCwd=hasCustomCwd&&process.chdir!==void 0&&!process.chdir.disabled;if(shouldSwitchCwd)try{process.chdir(parsed.options.cwd)}catch{}let resolved;try{resolved=which.sync(parsed.command,{path:env[getPathKey({env})],pathExt:withoutPathExt?path7.delimiter:void 0})}catch{}finally{shouldSwitchCwd&&process.chdir(cwd)}return resolved&&(resolved=path7.resolve(hasCustomCwd?parsed.options.cwd:"",resolved)),resolved}function resolveCommand(parsed){return resolveCommandAttempt(parsed)||resolveCommandAttempt(parsed,!0)}module2.exports=resolveCommand}});var require_escape=__commonJS({"../../node_modules/cross-spawn/lib/util/escape.js"(exports2,module2){"use strict";var metaCharsRegExp=/([()\][%!^"`<>&|;, *?])/g;function escapeCommand(arg){return arg=arg.replace(metaCharsRegExp,"^$1"),arg}function escapeArgument(arg,doubleEscapeMetaChars){return arg=`${arg}`,arg=arg.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),arg=arg.replace(/(?=(\\+?)?)\1$/,"$1$1"),arg=`"${arg}"`,arg=arg.replace(metaCharsRegExp,"^$1"),doubleEscapeMetaChars&&(arg=arg.replace(metaCharsRegExp,"^$1")),arg}module2.exports.command=escapeCommand;module2.exports.argument=escapeArgument}});var require_shebang_regex=__commonJS({"../../node_modules/shebang-regex/index.js"(exports2,module2){"use strict";module2.exports=/^#!(.*)/}});var require_shebang_command=__commonJS({"../../node_modules/shebang-command/index.js"(exports2,module2){"use strict";var shebangRegex=require_shebang_regex();module2.exports=(string="")=>{let match=string.match(shebangRegex);if(!match)return null;let[path7,argument]=match[0].replace(/#! ?/,"").split(" "),binary=path7.split("/").pop();return binary==="env"?argument:argument?`${binary} ${argument}`:binary}}});var require_readShebang=__commonJS({"../../node_modules/cross-spawn/lib/util/readShebang.js"(exports2,module2){"use strict";var fs7=require("fs"),shebangCommand=require_shebang_command();function readShebang(command2){let buffer=Buffer.alloc(150),fd;try{fd=fs7.openSync(command2,"r"),fs7.readSync(fd,buffer,0,150,0),fs7.closeSync(fd)}catch{}return shebangCommand(buffer.toString())}module2.exports=readShebang}});var require_parse4=__commonJS({"../../node_modules/cross-spawn/lib/parse.js"(exports2,module2){"use strict";var path7=require("path"),resolveCommand=require_resolveCommand(),escape=require_escape(),readShebang=require_readShebang(),isWin=process.platform==="win32",isExecutableRegExp=/\.(?:com|exe)$/i,isCmdShimRegExp=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function detectShebang(parsed){parsed.file=resolveCommand(parsed);let shebang=parsed.file&&readShebang(parsed.file);return shebang?(parsed.args.unshift(parsed.file),parsed.command=shebang,resolveCommand(parsed)):parsed.file}function parseNonShell(parsed){if(!isWin)return parsed;let commandFile=detectShebang(parsed),needsShell=!isExecutableRegExp.test(commandFile);if(parsed.options.forceShell||needsShell){let needsDoubleEscapeMetaChars=isCmdShimRegExp.test(commandFile);parsed.command=path7.normalize(parsed.command),parsed.command=escape.command(parsed.command),parsed.args=parsed.args.map(arg=>escape.argument(arg,needsDoubleEscapeMetaChars));let shellCommand=[parsed.command].concat(parsed.args).join(" ");parsed.args=["/d","/s","/c",`"${shellCommand}"`],parsed.command=process.env.comspec||"cmd.exe",parsed.options.windowsVerbatimArguments=!0}return parsed}function parse2(command2,args,options){args&&!Array.isArray(args)&&(options=args,args=null),args=args?args.slice(0):[],options=Object.assign({},options);let parsed={command:command2,args,options,file:void 0,original:{command:command2,args}};return options.shell?parsed:parseNonShell(parsed)}module2.exports=parse2}});var require_enoent=__commonJS({"../../node_modules/cross-spawn/lib/enoent.js"(exports2,module2){"use strict";var isWin=process.platform==="win32";function notFoundError(original,syscall){return Object.assign(new Error(`${syscall} ${original.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${syscall} ${original.command}`,path:original.command,spawnargs:original.args})}function hookChildProcess(cp,parsed){if(!isWin)return;let originalEmit=cp.emit;cp.emit=function(name,arg1){if(name==="exit"){let err=verifyENOENT(arg1,parsed);if(err)return originalEmit.call(cp,"error",err)}return originalEmit.apply(cp,arguments)}}function verifyENOENT(status,parsed){return isWin&&status===1&&!parsed.file?notFoundError(parsed.original,"spawn"):null}function verifyENOENTSync(status,parsed){return isWin&&status===1&&!parsed.file?notFoundError(parsed.original,"spawnSync"):null}module2.exports={hookChildProcess,verifyENOENT,verifyENOENTSync,notFoundError}}});var require_cross_spawn=__commonJS({"../../node_modules/cross-spawn/index.js"(exports2,module2){"use strict";var cp=require("child_process"),parse2=require_parse4(),enoent=require_enoent();function spawn(command2,args,options){let parsed=parse2(command2,args,options),spawned=cp.spawn(parsed.command,parsed.args,parsed.options);return enoent.hookChildProcess(spawned,parsed),spawned}function spawnSync3(command2,args,options){let parsed=parse2(command2,args,options),result=cp.spawnSync(parsed.command,parsed.args,parsed.options);return result.error=result.error||enoent.verifyENOENTSync(result.status,parsed),result}module2.exports=spawn;module2.exports.spawn=spawn;module2.exports.sync=spawnSync3;module2.exports._parse=parse2;module2.exports._enoent=enoent}});var import_cli3=require("storybook/internal/cli"),import_common25=require("storybook/internal/common"),import_core_server3=require("storybook/internal/core-server"),import_node_logger24=require("storybook/internal/node-logger"),import_telemetry2=require("storybook/internal/telemetry"),import_commander=require("commander"),import_envinfo=__toESM(require_envinfo(),1);var array=[],characterCodeCache=[];function leven(first,second){if(first===second)return 0;let swap=first;first.length>second.length&&(first=second,second=swap);let firstLength=first.length,secondLength=second.length;for(;firstLength>0&&first.charCodeAt(~-firstLength)===second.charCodeAt(~-secondLength);)firstLength--,secondLength--;let start=0;for(;start<firstLength&&first.charCodeAt(start)===second.charCodeAt(start);)start++;if(firstLength-=start,secondLength-=start,firstLength===0)return secondLength;let bCharacterCode,result,temporary,temporary2,index=0,index2=0;for(;index<firstLength;)characterCodeCache[index]=first.charCodeAt(start+index),array[index]=++index;for(;index2<secondLength;)for(bCharacterCode=second.charCodeAt(start+index2),temporary=index2++,result=index2,index=0;index<firstLength;index++)temporary2=bCharacterCode===characterCodeCache[index]?temporary:temporary+1,temporary=array[index],result=array[index]=temporary>result?temporary2>result?result+1:temporary2:temporary2>temporary?temporary+1:temporary2;return result}var import_picocolors19=__toESM(require_picocolors(),1);var version="9.0.16";var import_node_path7=require("path"),import_common6=require("storybook/internal/common"),import_csf_tools2=require("storybook/internal/csf-tools"),import_node_logger5=require("storybook/internal/node-logger"),import_semver6=__toESM(require_semver2(),1),import_ts_dedent5=require("ts-dedent");var import_babel=require("storybook/internal/babel"),defaultRequireWrapperName="getAbsolutePath";function doesVariableOrFunctionDeclarationExist(node,name){return import_babel.types.isVariableDeclaration(node)&&node.declarations.length===1&&import_babel.types.isVariableDeclarator(node.declarations[0])&&import_babel.types.isIdentifier(node.declarations[0].id)&&node.declarations[0].id?.name===name||import_babel.types.isFunctionDeclaration(node)&&import_babel.types.isIdentifier(node.id)&&node.id.name===name}function getReferenceToRequireWrapper(config,value){return import_babel.types.callExpression(import_babel.types.identifier(getRequireWrapperName(config)??defaultRequireWrapperName),[import_babel.types.stringLiteral(value)])}function getRequireWrapperName(config){let declarationName=config.getBodyDeclarations().flatMap(node=>doesVariableOrFunctionDeclarationExist(node,"wrapForPnp")?["wrapForPnp"]:doesVariableOrFunctionDeclarationExist(node,defaultRequireWrapperName)?[defaultRequireWrapperName]:[]);return declarationName.length?declarationName[0]:null}function isRequireWrapperNecessary(node,cb=()=>{}){if(import_babel.types.isStringLiteral(node))return cb(node),!0;if(import_babel.types.isObjectExpression(node)){let nameProperty=node.properties.find(property=>import_babel.types.isObjectProperty(property)&&import_babel.types.isIdentifier(property.key)&&property.key.name==="name");if(nameProperty&&import_babel.types.isStringLiteral(nameProperty.value))return cb(nameProperty),!0}return import_babel.types.isArrayExpression(node)&&node.elements.some(element=>element&&isRequireWrapperNecessary(element))?(cb(node),!0):!1}function getFieldsForRequireWrapper(config){let frameworkNode=config.getFieldNode(["framework"]),builderNode=config.getFieldNode(["core","builder"]),rendererNode=config.getFieldNode(["core","renderer"]),addons=config.getFieldNode(["addons"]);return[...frameworkNode?[frameworkNode]:[],...builderNode?[builderNode]:[],...rendererNode?[rendererNode]:[],...addons&&import_babel.types.isArrayExpression(addons)?[addons]:[]]}function getRequireWrapperAsCallExpression(isConfigTypescript){let functionDeclaration={...import_babel.types.functionDeclaration(import_babel.types.identifier(defaultRequireWrapperName),[{...import_babel.types.identifier("value"),...isConfigTypescript?{typeAnnotation:import_babel.types.tsTypeAnnotation(import_babel.types.tSStringKeyword())}:{}}],import_babel.types.blockStatement([import_babel.types.returnStatement(import_babel.types.callExpression(import_babel.types.identifier("dirname"),[import_babel.types.callExpression(import_babel.types.memberExpression(import_babel.types.identifier("require"),import_babel.types.identifier("resolve")),[import_babel.types.callExpression(import_babel.types.identifier("join"),[import_babel.types.identifier("value"),import_babel.types.stringLiteral("package.json")])])]))])),...isConfigTypescript?{returnType:import_babel.types.tSTypeAnnotation(import_babel.types.tsAnyKeyword())}:{}};return import_babel.types.addComment(functionDeclaration,"leading",`*
80
+ `),import_node_logger4.logger.log(`\u26A0\uFE0F Storybook automigrations are based on AST parsing and it's possible that your ${import_picocolors2.default.blue(mainConfigPath)} file contains a non-standard format (e.g. your export is not an object) or that there was an error when parsing dynamic values (e.g. "require" calls, or usage of environment variables). When your main config is non-standard, automigrations are unfortunately not possible. Please follow the instructions given previously and follow the documentation to make the updates manually.`)}}}});var require_windows=__commonJS({"../../node_modules/isexe/windows.js"(exports2,module2){"use strict";module2.exports=isexe;isexe.sync=sync;var fs7=require("fs");function checkPathExt(path7,options){var pathext=options.pathExt!==void 0?options.pathExt:process.env.PATHEXT;if(!pathext||(pathext=pathext.split(";"),pathext.indexOf("")!==-1))return!0;for(var i=0;i<pathext.length;i++){var p=pathext[i].toLowerCase();if(p&&path7.substr(-p.length).toLowerCase()===p)return!0}return!1}function checkStat(stat,path7,options){return!stat.isSymbolicLink()&&!stat.isFile()?!1:checkPathExt(path7,options)}function isexe(path7,options,cb){fs7.stat(path7,function(er,stat){cb(er,er?!1:checkStat(stat,path7,options))})}function sync(path7,options){return checkStat(fs7.statSync(path7),path7,options)}}});var require_mode=__commonJS({"../../node_modules/isexe/mode.js"(exports2,module2){"use strict";module2.exports=isexe;isexe.sync=sync;var fs7=require("fs");function isexe(path7,options,cb){fs7.stat(path7,function(er,stat){cb(er,er?!1:checkStat(stat,options))})}function sync(path7,options){return checkStat(fs7.statSync(path7),options)}function checkStat(stat,options){return stat.isFile()&&checkMode(stat,options)}function checkMode(stat,options){var mod=stat.mode,uid=stat.uid,gid=stat.gid,myUid=options.uid!==void 0?options.uid:process.getuid&&process.getuid(),myGid=options.gid!==void 0?options.gid:process.getgid&&process.getgid(),u=parseInt("100",8),g=parseInt("010",8),o=parseInt("001",8),ug=u|g,ret=mod&o||mod&g&&gid===myGid||mod&u&&uid===myUid||mod&ug&&myUid===0;return ret}}});var require_isexe=__commonJS({"../../node_modules/isexe/index.js"(exports2,module2){"use strict";var fs7=require("fs"),core;process.platform==="win32"||global.TESTING_WINDOWS?core=require_windows():core=require_mode();module2.exports=isexe;isexe.sync=sync;function isexe(path7,options,cb){if(typeof options=="function"&&(cb=options,options={}),!cb){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(resolve,reject){isexe(path7,options||{},function(er,is){er?reject(er):resolve(is)})})}core(path7,options||{},function(er,is){er&&(er.code==="EACCES"||options&&options.ignoreErrors)&&(er=null,is=!1),cb(er,is)})}function sync(path7,options){try{return core.sync(path7,options||{})}catch(er){if(options&&options.ignoreErrors||er.code==="EACCES")return!1;throw er}}}});var require_which=__commonJS({"../../node_modules/which/which.js"(exports2,module2){"use strict";var isWindows=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",path7=require("path"),COLON=isWindows?";":":",isexe=require_isexe(),getNotFoundError=cmd=>Object.assign(new Error(`not found: ${cmd}`),{code:"ENOENT"}),getPathInfo=(cmd,opt)=>{let colon=opt.colon||COLON,pathEnv=cmd.match(/\//)||isWindows&&cmd.match(/\\/)?[""]:[...isWindows?[process.cwd()]:[],...(opt.path||process.env.PATH||"").split(colon)],pathExtExe=isWindows?opt.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",pathExt=isWindows?pathExtExe.split(colon):[""];return isWindows&&cmd.indexOf(".")!==-1&&pathExt[0]!==""&&pathExt.unshift(""),{pathEnv,pathExt,pathExtExe}},which=(cmd,opt,cb)=>{typeof opt=="function"&&(cb=opt,opt={}),opt||(opt={});let{pathEnv,pathExt,pathExtExe}=getPathInfo(cmd,opt),found=[],step=i=>new Promise((resolve,reject)=>{if(i===pathEnv.length)return opt.all&&found.length?resolve(found):reject(getNotFoundError(cmd));let ppRaw=pathEnv[i],pathPart=/^".*"$/.test(ppRaw)?ppRaw.slice(1,-1):ppRaw,pCmd=path7.join(pathPart,cmd),p=!pathPart&&/^\.[\\\/]/.test(cmd)?cmd.slice(0,2)+pCmd:pCmd;resolve(subStep(p,i,0))}),subStep=(p,i,ii)=>new Promise((resolve,reject)=>{if(ii===pathExt.length)return resolve(step(i+1));let ext=pathExt[ii];isexe(p+ext,{pathExt:pathExtExe},(er,is)=>{if(!er&&is)if(opt.all)found.push(p+ext);else return resolve(p+ext);return resolve(subStep(p,i,ii+1))})});return cb?step(0).then(res=>cb(null,res),cb):step(0)},whichSync=(cmd,opt)=>{opt=opt||{};let{pathEnv,pathExt,pathExtExe}=getPathInfo(cmd,opt),found=[];for(let i=0;i<pathEnv.length;i++){let ppRaw=pathEnv[i],pathPart=/^".*"$/.test(ppRaw)?ppRaw.slice(1,-1):ppRaw,pCmd=path7.join(pathPart,cmd),p=!pathPart&&/^\.[\\\/]/.test(cmd)?cmd.slice(0,2)+pCmd:pCmd;for(let j=0;j<pathExt.length;j++){let cur=p+pathExt[j];try{if(isexe.sync(cur,{pathExt:pathExtExe}))if(opt.all)found.push(cur);else return cur}catch{}}}if(opt.all&&found.length)return found;if(opt.nothrow)return null;throw getNotFoundError(cmd)};module2.exports=which;which.sync=whichSync}});var require_path_key=__commonJS({"../../node_modules/path-key/index.js"(exports2,module2){"use strict";var pathKey=(options={})=>{let environment=options.env||process.env;return(options.platform||process.platform)!=="win32"?"PATH":Object.keys(environment).reverse().find(key=>key.toUpperCase()==="PATH")||"Path"};module2.exports=pathKey;module2.exports.default=pathKey}});var require_resolveCommand=__commonJS({"../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2,module2){"use strict";var path7=require("path"),which=require_which(),getPathKey=require_path_key();function resolveCommandAttempt(parsed,withoutPathExt){let env=parsed.options.env||process.env,cwd=process.cwd(),hasCustomCwd=parsed.options.cwd!=null,shouldSwitchCwd=hasCustomCwd&&process.chdir!==void 0&&!process.chdir.disabled;if(shouldSwitchCwd)try{process.chdir(parsed.options.cwd)}catch{}let resolved;try{resolved=which.sync(parsed.command,{path:env[getPathKey({env})],pathExt:withoutPathExt?path7.delimiter:void 0})}catch{}finally{shouldSwitchCwd&&process.chdir(cwd)}return resolved&&(resolved=path7.resolve(hasCustomCwd?parsed.options.cwd:"",resolved)),resolved}function resolveCommand(parsed){return resolveCommandAttempt(parsed)||resolveCommandAttempt(parsed,!0)}module2.exports=resolveCommand}});var require_escape=__commonJS({"../../node_modules/cross-spawn/lib/util/escape.js"(exports2,module2){"use strict";var metaCharsRegExp=/([()\][%!^"`<>&|;, *?])/g;function escapeCommand(arg){return arg=arg.replace(metaCharsRegExp,"^$1"),arg}function escapeArgument(arg,doubleEscapeMetaChars){return arg=`${arg}`,arg=arg.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),arg=arg.replace(/(?=(\\+?)?)\1$/,"$1$1"),arg=`"${arg}"`,arg=arg.replace(metaCharsRegExp,"^$1"),doubleEscapeMetaChars&&(arg=arg.replace(metaCharsRegExp,"^$1")),arg}module2.exports.command=escapeCommand;module2.exports.argument=escapeArgument}});var require_shebang_regex=__commonJS({"../../node_modules/shebang-regex/index.js"(exports2,module2){"use strict";module2.exports=/^#!(.*)/}});var require_shebang_command=__commonJS({"../../node_modules/shebang-command/index.js"(exports2,module2){"use strict";var shebangRegex=require_shebang_regex();module2.exports=(string="")=>{let match=string.match(shebangRegex);if(!match)return null;let[path7,argument]=match[0].replace(/#! ?/,"").split(" "),binary=path7.split("/").pop();return binary==="env"?argument:argument?`${binary} ${argument}`:binary}}});var require_readShebang=__commonJS({"../../node_modules/cross-spawn/lib/util/readShebang.js"(exports2,module2){"use strict";var fs7=require("fs"),shebangCommand=require_shebang_command();function readShebang(command2){let buffer=Buffer.alloc(150),fd;try{fd=fs7.openSync(command2,"r"),fs7.readSync(fd,buffer,0,150,0),fs7.closeSync(fd)}catch{}return shebangCommand(buffer.toString())}module2.exports=readShebang}});var require_parse4=__commonJS({"../../node_modules/cross-spawn/lib/parse.js"(exports2,module2){"use strict";var path7=require("path"),resolveCommand=require_resolveCommand(),escape=require_escape(),readShebang=require_readShebang(),isWin=process.platform==="win32",isExecutableRegExp=/\.(?:com|exe)$/i,isCmdShimRegExp=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function detectShebang(parsed){parsed.file=resolveCommand(parsed);let shebang=parsed.file&&readShebang(parsed.file);return shebang?(parsed.args.unshift(parsed.file),parsed.command=shebang,resolveCommand(parsed)):parsed.file}function parseNonShell(parsed){if(!isWin)return parsed;let commandFile=detectShebang(parsed),needsShell=!isExecutableRegExp.test(commandFile);if(parsed.options.forceShell||needsShell){let needsDoubleEscapeMetaChars=isCmdShimRegExp.test(commandFile);parsed.command=path7.normalize(parsed.command),parsed.command=escape.command(parsed.command),parsed.args=parsed.args.map(arg=>escape.argument(arg,needsDoubleEscapeMetaChars));let shellCommand=[parsed.command].concat(parsed.args).join(" ");parsed.args=["/d","/s","/c",`"${shellCommand}"`],parsed.command=process.env.comspec||"cmd.exe",parsed.options.windowsVerbatimArguments=!0}return parsed}function parse2(command2,args,options){args&&!Array.isArray(args)&&(options=args,args=null),args=args?args.slice(0):[],options=Object.assign({},options);let parsed={command:command2,args,options,file:void 0,original:{command:command2,args}};return options.shell?parsed:parseNonShell(parsed)}module2.exports=parse2}});var require_enoent=__commonJS({"../../node_modules/cross-spawn/lib/enoent.js"(exports2,module2){"use strict";var isWin=process.platform==="win32";function notFoundError(original,syscall){return Object.assign(new Error(`${syscall} ${original.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${syscall} ${original.command}`,path:original.command,spawnargs:original.args})}function hookChildProcess(cp,parsed){if(!isWin)return;let originalEmit=cp.emit;cp.emit=function(name,arg1){if(name==="exit"){let err=verifyENOENT(arg1,parsed);if(err)return originalEmit.call(cp,"error",err)}return originalEmit.apply(cp,arguments)}}function verifyENOENT(status,parsed){return isWin&&status===1&&!parsed.file?notFoundError(parsed.original,"spawn"):null}function verifyENOENTSync(status,parsed){return isWin&&status===1&&!parsed.file?notFoundError(parsed.original,"spawnSync"):null}module2.exports={hookChildProcess,verifyENOENT,verifyENOENTSync,notFoundError}}});var require_cross_spawn=__commonJS({"../../node_modules/cross-spawn/index.js"(exports2,module2){"use strict";var cp=require("child_process"),parse2=require_parse4(),enoent=require_enoent();function spawn(command2,args,options){let parsed=parse2(command2,args,options),spawned=cp.spawn(parsed.command,parsed.args,parsed.options);return enoent.hookChildProcess(spawned,parsed),spawned}function spawnSync3(command2,args,options){let parsed=parse2(command2,args,options),result=cp.spawnSync(parsed.command,parsed.args,parsed.options);return result.error=result.error||enoent.verifyENOENTSync(result.status,parsed),result}module2.exports=spawn;module2.exports.spawn=spawn;module2.exports.sync=spawnSync3;module2.exports._parse=parse2;module2.exports._enoent=enoent}});var import_cli3=require("storybook/internal/cli"),import_common25=require("storybook/internal/common"),import_core_server3=require("storybook/internal/core-server"),import_node_logger24=require("storybook/internal/node-logger"),import_telemetry2=require("storybook/internal/telemetry"),import_commander=require("commander"),import_envinfo=__toESM(require_envinfo(),1);var array=[],characterCodeCache=[];function leven(first,second){if(first===second)return 0;let swap=first;first.length>second.length&&(first=second,second=swap);let firstLength=first.length,secondLength=second.length;for(;firstLength>0&&first.charCodeAt(~-firstLength)===second.charCodeAt(~-secondLength);)firstLength--,secondLength--;let start=0;for(;start<firstLength&&first.charCodeAt(start)===second.charCodeAt(start);)start++;if(firstLength-=start,secondLength-=start,firstLength===0)return secondLength;let bCharacterCode,result,temporary,temporary2,index=0,index2=0;for(;index<firstLength;)characterCodeCache[index]=first.charCodeAt(start+index),array[index]=++index;for(;index2<secondLength;)for(bCharacterCode=second.charCodeAt(start+index2),temporary=index2++,result=index2,index=0;index<firstLength;index++)temporary2=bCharacterCode===characterCodeCache[index]?temporary:temporary+1,temporary=array[index],result=array[index]=temporary>result?temporary2>result?result+1:temporary2:temporary2>temporary?temporary+1:temporary2;return result}var import_picocolors19=__toESM(require_picocolors(),1);var version="9.0.17";var import_node_path7=require("path"),import_common6=require("storybook/internal/common"),import_csf_tools2=require("storybook/internal/csf-tools"),import_node_logger5=require("storybook/internal/node-logger"),import_semver6=__toESM(require_semver2(),1),import_ts_dedent5=require("ts-dedent");var import_babel=require("storybook/internal/babel"),defaultRequireWrapperName="getAbsolutePath";function doesVariableOrFunctionDeclarationExist(node,name){return import_babel.types.isVariableDeclaration(node)&&node.declarations.length===1&&import_babel.types.isVariableDeclarator(node.declarations[0])&&import_babel.types.isIdentifier(node.declarations[0].id)&&node.declarations[0].id?.name===name||import_babel.types.isFunctionDeclaration(node)&&import_babel.types.isIdentifier(node.id)&&node.id.name===name}function getReferenceToRequireWrapper(config,value){return import_babel.types.callExpression(import_babel.types.identifier(getRequireWrapperName(config)??defaultRequireWrapperName),[import_babel.types.stringLiteral(value)])}function getRequireWrapperName(config){let declarationName=config.getBodyDeclarations().flatMap(node=>doesVariableOrFunctionDeclarationExist(node,"wrapForPnp")?["wrapForPnp"]:doesVariableOrFunctionDeclarationExist(node,defaultRequireWrapperName)?[defaultRequireWrapperName]:[]);return declarationName.length?declarationName[0]:null}function isRequireWrapperNecessary(node,cb=()=>{}){if(import_babel.types.isStringLiteral(node))return cb(node),!0;if(import_babel.types.isObjectExpression(node)){let nameProperty=node.properties.find(property=>import_babel.types.isObjectProperty(property)&&import_babel.types.isIdentifier(property.key)&&property.key.name==="name");if(nameProperty&&import_babel.types.isStringLiteral(nameProperty.value))return cb(nameProperty),!0}return import_babel.types.isArrayExpression(node)&&node.elements.some(element=>element&&isRequireWrapperNecessary(element))?(cb(node),!0):!1}function getFieldsForRequireWrapper(config){let frameworkNode=config.getFieldNode(["framework"]),builderNode=config.getFieldNode(["core","builder"]),rendererNode=config.getFieldNode(["core","renderer"]),addons=config.getFieldNode(["addons"]);return[...frameworkNode?[frameworkNode]:[],...builderNode?[builderNode]:[],...rendererNode?[rendererNode]:[],...addons&&import_babel.types.isArrayExpression(addons)?[addons]:[]]}function getRequireWrapperAsCallExpression(isConfigTypescript){let functionDeclaration={...import_babel.types.functionDeclaration(import_babel.types.identifier(defaultRequireWrapperName),[{...import_babel.types.identifier("value"),...isConfigTypescript?{typeAnnotation:import_babel.types.tsTypeAnnotation(import_babel.types.tSStringKeyword())}:{}}],import_babel.types.blockStatement([import_babel.types.returnStatement(import_babel.types.callExpression(import_babel.types.identifier("dirname"),[import_babel.types.callExpression(import_babel.types.memberExpression(import_babel.types.identifier("require"),import_babel.types.identifier("resolve")),[import_babel.types.callExpression(import_babel.types.identifier("join"),[import_babel.types.identifier("value"),import_babel.types.stringLiteral("package.json")])])]))])),...isConfigTypescript?{returnType:import_babel.types.tSTypeAnnotation(import_babel.types.tsAnyKeyword())}:{}};return import_babel.types.addComment(functionDeclaration,"leading",`*
81
81
  * This function is used to resolve the absolute path of a package.
82
82
  * It is needed in projects that use Yarn PnP or are set up within a monorepo.
83
83
  `),functionDeclaration}function wrapValueWithRequireWrapper(config,node){isRequireWrapperNecessary(node,n=>{if(import_babel.types.isStringLiteral(n)){let wrapperNode=getReferenceToRequireWrapper(config,n.value);Object.keys(n).forEach(k=>{delete n[k]}),Object.keys(wrapperNode).forEach(k=>{n[k]=wrapperNode[k]})}import_babel.types.isObjectProperty(n)&&import_babel.types.isStringLiteral(n.value)&&(n.value=getReferenceToRequireWrapper(config,n.value.value)),import_babel.types.isArrayExpression(n)&&n.elements.forEach(element=>{element&&isRequireWrapperNecessary(element)&&wrapValueWithRequireWrapper(config,element)})})}init_mainConfigFile();var postinstallAddon=async(addonName,options)=>{try{let modulePath=require.resolve(`${addonName}/postinstall`,{paths:[process.cwd()]}),postinstall=require(modulePath);try{console.log(`Running postinstall script for ${addonName}`),await postinstall(options)}catch(e){console.error(`Error running postinstall script for ${addonName}`),console.error(e)}}catch{}};var getVersionSpecifier=addon=>{let groups=/^(@{0,1}[^@]+)(?:@(.+))?$/.exec(addon);return groups?[groups[1],groups[2]]:[addon,void 0]};var checkInstalled=(addonName,main)=>!!main.addons?.find(entry=>(typeof entry=="string"?entry:entry.name)?.endsWith(addonName)),isCoreAddon=addonName=>Object.hasOwn(import_common6.versions,addonName);async function add(addon,{packageManager:pkgMgr,skipPostinstall,configDir:userSpecifiedConfigDir,yes,skipInstall},logger23=console){let[addonName,inputVersion]=getVersionSpecifier(addon),{mainConfig,mainConfigPath,configDir,previewConfigPath,packageManager}=await getStorybookData({configDir:userSpecifiedConfigDir,packageManagerName:pkgMgr});if(typeof configDir>"u")throw new Error(import_ts_dedent5.dedent`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/cli",
3
- "version": "9.0.16",
3
+ "version": "9.0.17",
4
4
  "description": "Storybook CLI",
5
5
  "keywords": [
6
6
  "storybook"
@@ -41,13 +41,13 @@
41
41
  "prep": "jiti ../../../scripts/prepare/bundle.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@storybook/codemod": "9.0.16",
44
+ "@storybook/codemod": "9.0.17",
45
45
  "@types/semver": "^7.3.4",
46
46
  "commander": "^12.1.0",
47
- "create-storybook": "9.0.16",
47
+ "create-storybook": "9.0.17",
48
48
  "giget": "^1.0.0",
49
49
  "jscodeshift": "^0.15.1",
50
- "storybook": "9.0.16",
50
+ "storybook": "9.0.17",
51
51
  "ts-dedent": "^2.0.0"
52
52
  },
53
53
  "devDependencies": {