@storybook/cli 0.0.0-pr-29353-sha-3b7a5f8f → 0.0.0-pr-29241-sha-786ddd72

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.
@@ -51,7 +51,7 @@
51
51
  `}}}});var import_common20=require("storybook/internal/common"),import_core_server2=require("storybook/internal/core-server"),import_node_logger4=require("storybook/internal/node-logger"),import_telemetry2=require("storybook/internal/telemetry"),import_commander=require("commander"),import_envinfo=__toESM(require("envinfo"),1),import_fd_package_json=require("fd-package-json"),import_leven=__toESM(require("leven"),1),import_picocolors43=__toESM(require_picocolors(),1),import_tiny_invariant4=__toESM(require("tiny-invariant"),1);var import_node_path=require("path"),import_common=require("storybook/internal/common"),import_csf_tools=require("storybook/internal/csf-tools"),import_prompts=__toESM(require("prompts"),1),import_semver=__toESM(require("semver"),1),import_ts_dedent=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",`*
52
52
  * This function is used to resolve the absolute path of a package.
53
53
  * It is needed in projects that use Yarn PnP or are set up within a monorepo.
54
- `),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,index,elements)=>{import_babel.types.isStringLiteral(element)&&(elements[index]=getReferenceToRequireWrapper(config,element.value))})})}var postinstallAddon=async(addonName,options)=>{try{let modulePath=require.resolve(`${addonName}/postinstall`,{paths:[process.cwd()]}),postinstall=require(modulePath);console.log({modulePath,postinstall});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]},requireMain=configDir=>{let absoluteConfigDir=(0,import_node_path.isAbsolute)(configDir)?configDir:(0,import_node_path.join)(process.cwd(),configDir),mainFile=(0,import_node_path.join)(absoluteConfigDir,"main");return(0,import_common.serverRequire)(mainFile)??{}},checkInstalled=(addonName,main)=>!!main.addons?.find(entry=>(typeof entry=="string"?entry:entry.name)?.endsWith(addonName)),isCoreAddon=addonName=>Object.hasOwn(import_common.versions,addonName);async function add(addon,{packageManager:pkgMgr,skipPostinstall,configDir:userSpecifiedConfigDir,yes},logger28=console){let[addonName,inputVersion]=getVersionSpecifier(addon),packageManager=import_common.JsPackageManagerFactory.getPackageManager({force:pkgMgr}),packageJson=await packageManager.retrievePackageJson(),{mainConfig,configDir:inferredConfigDir}=(0,import_common.getStorybookInfo)(packageJson,userSpecifiedConfigDir),configDir=userSpecifiedConfigDir||inferredConfigDir||".storybook";if(typeof configDir>"u")throw new Error(import_ts_dedent.dedent`
54
+ `),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,index,elements)=>{import_babel.types.isStringLiteral(element)&&(elements[index]=getReferenceToRequireWrapper(config,element.value))})})}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]},requireMain=configDir=>{let absoluteConfigDir=(0,import_node_path.isAbsolute)(configDir)?configDir:(0,import_node_path.join)(process.cwd(),configDir),mainFile=(0,import_node_path.join)(absoluteConfigDir,"main");return(0,import_common.serverRequire)(mainFile)??{}},checkInstalled=(addonName,main)=>!!main.addons?.find(entry=>(typeof entry=="string"?entry:entry.name)?.endsWith(addonName)),isCoreAddon=addonName=>Object.hasOwn(import_common.versions,addonName);async function add(addon,{packageManager:pkgMgr,skipPostinstall,configDir:userSpecifiedConfigDir,yes},logger28=console){let[addonName,inputVersion]=getVersionSpecifier(addon),packageManager=import_common.JsPackageManagerFactory.getPackageManager({force:pkgMgr}),packageJson=await packageManager.retrievePackageJson(),{mainConfig,configDir:inferredConfigDir}=(0,import_common.getStorybookInfo)(packageJson,userSpecifiedConfigDir),configDir=userSpecifiedConfigDir||inferredConfigDir||".storybook";if(typeof configDir>"u")throw new Error(import_ts_dedent.dedent`
55
55
  Unable to find storybook config directory. Please specify your Storybook config directory with the --config-dir flag.
56
56
  `);if(!mainConfig){logger28.error("Unable to find Storybook main.js config");return}let shouldAddToMain=!0;if(checkInstalled(addonName,requireMain(configDir))){let{shouldForceInstall}=await(0,import_prompts.default)({type:"confirm",name:"shouldForceInstall",message:`The Storybook addon "${addonName}" is already present in ${mainConfig}. Do you wish to install it again?`});if(!shouldForceInstall)return;shouldAddToMain=!1}let main=await(0,import_csf_tools.readConfig)(mainConfig);logger28.log(`Verifying ${addonName}`);let storybookVersion=await(0,import_common.getCoercedStorybookVersion)(packageManager),version=inputVersion;!version&&isCoreAddon(addonName)&&storybookVersion&&(version=storybookVersion),version||(version=await packageManager.latestVersion(addonName)),isCoreAddon(addonName)&&version!==storybookVersion&&logger28.warn(`The version of ${addonName} (${version}) you are installing is not the same as the version of Storybook you are using (${storybookVersion}). This may lead to unexpected behavior.`);let addonWithVersion=isValidVersion(version)?`${addonName}@^${version}`:`${addonName}@${version}`;if(logger28.log(`Installing ${addonWithVersion}`),await packageManager.addDependencies({installAsDevDependencies:!0},[addonWithVersion]),shouldAddToMain){if(logger28.log(`Adding '${addon}' to the "addons" field in ${mainConfig}`),main.getFieldNode(["addons"])&&getRequireWrapperName(main)!==null){let addonNode=main.valueToNode(addonName);main.appendNodeToArray(["addons"],addonNode),wrapValueWithRequireWrapper(main,addonNode)}else main.appendValueToArray(["addons"],addonName);await(0,import_csf_tools.writeConfig)(main)}!skipPostinstall&&isCoreAddon(addonName)&&await postinstallAddon(addonName,{packageManager:packageManager.type,configDir,yes})}function isValidVersion(version){return import_semver.default.valid(version)||version.match(/^\d+$/)}var import_node_fs2=require("fs"),import_promises7=require("fs/promises"),import_node_path7=require("path"),import_common15=require("storybook/internal/common");var import_node_process2=__toESM(require("process"),1);function ansiRegex({onlyFirst=!1}={}){let pattern=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(pattern,onlyFirst?void 0:"g")}var regex=ansiRegex();function stripAnsi(string){if(typeof string!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);return string.replace(regex,"")}var import_eastasianwidth=__toESM(require_eastasianwidth(),1),import_emoji_regex=__toESM(require_emoji_regex(),1);function stringWidth(string,options={}){if(typeof string!="string"||string.length===0||(options={ambiguousIsNarrow:!0,...options},string=stripAnsi(string),string.length===0))return 0;string=string.replace((0,import_emoji_regex.default)()," ");let ambiguousCharacterWidth=options.ambiguousIsNarrow?1:2,width=0;for(let character of string){let codePoint=character.codePointAt(0);if(codePoint<=31||codePoint>=127&&codePoint<=159||codePoint>=768&&codePoint<=879)continue;switch(import_eastasianwidth.default.eastAsianWidth(character)){case"F":case"W":width+=2;break;case"A":width+=ambiguousCharacterWidth;break;default:width+=1}}return width}var wrapAnsi16=(offset=0)=>code=>`\x1B[${code+offset}m`,wrapAnsi256=(offset=0)=>code=>`\x1B[${38+offset};5;${code}m`,wrapAnsi16m=(offset=0)=>(red,green,blue)=>`\x1B[${38+offset};2;${red};${green};${blue}m`,styles={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},modifierNames=Object.keys(styles.modifier),foregroundColorNames=Object.keys(styles.color),backgroundColorNames=Object.keys(styles.bgColor),colorNames=[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){let codes=new Map;for(let[groupName,group]of Object.entries(styles)){for(let[styleName,style]of Object.entries(group))styles[styleName]={open:`\x1B[${style[0]}m`,close:`\x1B[${style[1]}m`},group[styleName]=styles[styleName],codes.set(style[0],style[1]);Object.defineProperty(styles,groupName,{value:group,enumerable:!1})}return Object.defineProperty(styles,"codes",{value:codes,enumerable:!1}),styles.color.close="\x1B[39m",styles.bgColor.close="\x1B[49m",styles.color.ansi=wrapAnsi16(),styles.color.ansi256=wrapAnsi256(),styles.color.ansi16m=wrapAnsi16m(),styles.bgColor.ansi=wrapAnsi16(10),styles.bgColor.ansi256=wrapAnsi256(10),styles.bgColor.ansi16m=wrapAnsi16m(10),Object.defineProperties(styles,{rgbToAnsi256:{value(red,green,blue){return red===green&&green===blue?red<8?16:red>248?231:Math.round((red-8)/247*24)+232:16+36*Math.round(red/255*5)+6*Math.round(green/255*5)+Math.round(blue/255*5)},enumerable:!1},hexToRgb:{value(hex){let matches=/[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));if(!matches)return[0,0,0];let[colorString]=matches;colorString.length===3&&(colorString=[...colorString].map(character=>character+character).join(""));let integer=Number.parseInt(colorString,16);return[integer>>16&255,integer>>8&255,integer&255]},enumerable:!1},hexToAnsi256:{value:hex=>styles.rgbToAnsi256(...styles.hexToRgb(hex)),enumerable:!1},ansi256ToAnsi:{value(code){if(code<8)return 30+code;if(code<16)return 90+(code-8);let red,green,blue;if(code>=232)red=((code-232)*10+8)/255,green=red,blue=red;else{code-=16;let remainder=code%36;red=Math.floor(code/36)/5,green=Math.floor(remainder/6)/5,blue=remainder%6/5}let value=Math.max(red,green,blue)*2;if(value===0)return 30;let result=30+(Math.round(blue)<<2|Math.round(green)<<1|Math.round(red));return value===2&&(result+=60),result},enumerable:!1},rgbToAnsi:{value:(red,green,blue)=>styles.ansi256ToAnsi(styles.rgbToAnsi256(red,green,blue)),enumerable:!1},hexToAnsi:{value:hex=>styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),enumerable:!1}}),styles}var ansiStyles=assembleStyles(),ansi_styles_default=ansiStyles;var import_node_process=__toESM(require("process"),1),import_node_os=__toESM(require("os"),1),import_node_tty=__toESM(require("tty"),1);function hasFlag(flag,argv=globalThis.Deno?globalThis.Deno.args:import_node_process.default.argv){let prefix=flag.startsWith("-")?"":flag.length===1?"-":"--",position=argv.indexOf(prefix+flag),terminatorPosition=argv.indexOf("--");return position!==-1&&(terminatorPosition===-1||position<terminatorPosition)}var{env}=import_node_process.default,flagForceColor;hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")?flagForceColor=0:(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always"))&&(flagForceColor=1);function envForceColor(){if("FORCE_COLOR"in env)return env.FORCE_COLOR==="true"?1:env.FORCE_COLOR==="false"?0:env.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(env.FORCE_COLOR,10),3)}function translateLevel(level){return level===0?!1:{level,hasBasic:!0,has256:level>=2,has16m:level>=3}}function _supportsColor(haveStream,{streamIsTTY,sniffFlags=!0}={}){let noFlagForceColor=envForceColor();noFlagForceColor!==void 0&&(flagForceColor=noFlagForceColor);let forceColor=sniffFlags?flagForceColor:noFlagForceColor;if(forceColor===0)return 0;if(sniffFlags){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor"))return 3;if(hasFlag("color=256"))return 2}if("TF_BUILD"in env&&"AGENT_NAME"in env)return 1;if(haveStream&&!streamIsTTY&&forceColor===void 0)return 0;let min=forceColor||0;if(env.TERM==="dumb")return min;if(import_node_process.default.platform==="win32"){let osRelease=import_node_os.default.release().split(".");return Number(osRelease[0])>=10&&Number(osRelease[2])>=10586?Number(osRelease[2])>=14931?3:2:1}if("CI"in env)return"GITHUB_ACTIONS"in env||"GITEA_ACTIONS"in env?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(sign=>sign in env)||env.CI_NAME==="codeship"?1:min;if("TEAMCITY_VERSION"in env)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION)?1:0;if(env.COLORTERM==="truecolor"||env.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in env){let version=Number.parseInt((env.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(env.TERM_PROGRAM){case"iTerm.app":return version>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(env.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)||"COLORTERM"in env?1:min}function createSupportsColor(stream,options={}){let level=_supportsColor(stream,{streamIsTTY:stream&&stream.isTTY,...options});return translateLevel(level)}var supportsColor={stdout:createSupportsColor({isTTY:import_node_tty.default.isatty(1)}),stderr:createSupportsColor({isTTY:import_node_tty.default.isatty(2)})},supports_color_default=supportsColor;function stringReplaceAll(string,substring,replacer){let index=string.indexOf(substring);if(index===-1)return string;let substringLength=substring.length,endIndex=0,returnValue="";do returnValue+=string.slice(endIndex,index)+substring+replacer,endIndex=index+substringLength,index=string.indexOf(substring,endIndex);while(index!==-1);return returnValue+=string.slice(endIndex),returnValue}function stringEncaseCRLFWithFirstIndex(string,prefix,postfix,index){let endIndex=0,returnValue="";do{let gotCR=string[index-1]==="\r";returnValue+=string.slice(endIndex,gotCR?index-1:index)+prefix+(gotCR?`\r
57
57
  `:`
package/dist/bin/index.js CHANGED
@@ -33,7 +33,7 @@ var require_eastasianwidth=__commonJS({"../../node_modules/eastasianwidth/eastas
33
33
  `,pad=opts.pad||" ",widthDiffFn=align!=="right"?halfDiff:fullDiff,returnString=!1;Array.isArray(text)||(returnString=!0,text=String(text).split(split));let width,maxWidth=0;return text=text.map(function(str){return str=String(str),width=stringWidth4(str),maxWidth=Math.max(width,maxWidth),{str,width}}).map(function(obj){return new Array(widthDiffFn(maxWidth,obj.width)+1).join(pad)+obj.str}),returnString?text.join(split):text}ansiAlign2.left=function(text){return ansiAlign2(text,{align:"left"})};ansiAlign2.center=function(text){return ansiAlign2(text,{align:"center"})};ansiAlign2.right=function(text){return ansiAlign2(text,{align:"right"})};module.exports=ansiAlign2;function halfDiff(maxWidth,curWidth){return Math.floor((maxWidth-curWidth)/2)}function fullDiff(maxWidth,curWidth){return maxWidth-curWidth}}});var import_picocolors40=__toESM(require_picocolors(),1);var defaultRequireWrapperName="getAbsolutePath";function doesVariableOrFunctionDeclarationExist(node,name){return types.isVariableDeclaration(node)&&node.declarations.length===1&&types.isVariableDeclarator(node.declarations[0])&&types.isIdentifier(node.declarations[0].id)&&node.declarations[0].id?.name===name||types.isFunctionDeclaration(node)&&types.isIdentifier(node.id)&&node.id.name===name}function getReferenceToRequireWrapper(config,value){return types.callExpression(types.identifier(getRequireWrapperName(config)??defaultRequireWrapperName),[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(types.isStringLiteral(node))return cb(node),!0;if(types.isObjectExpression(node)){let nameProperty=node.properties.find(property=>types.isObjectProperty(property)&&types.isIdentifier(property.key)&&property.key.name==="name");if(nameProperty&&types.isStringLiteral(nameProperty.value))return cb(nameProperty),!0}return 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&&types.isArrayExpression(addons)?[addons]:[]]}function getRequireWrapperAsCallExpression(isConfigTypescript){let functionDeclaration={...types.functionDeclaration(types.identifier(defaultRequireWrapperName),[{...types.identifier("value"),...isConfigTypescript?{typeAnnotation:types.tsTypeAnnotation(types.tSStringKeyword())}:{}}],types.blockStatement([types.returnStatement(types.callExpression(types.identifier("dirname"),[types.callExpression(types.memberExpression(types.identifier("require"),types.identifier("resolve")),[types.callExpression(types.identifier("join"),[types.identifier("value"),types.stringLiteral("package.json")])])]))])),...isConfigTypescript?{returnType:types.tSTypeAnnotation(types.tsAnyKeyword())}:{}};return types.addComment(functionDeclaration,"leading",`*
34
34
  * This function is used to resolve the absolute path of a package.
35
35
  * It is needed in projects that use Yarn PnP or are set up within a monorepo.
36
- `),functionDeclaration}function wrapValueWithRequireWrapper(config,node){isRequireWrapperNecessary(node,n=>{if(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];});}types.isObjectProperty(n)&&types.isStringLiteral(n.value)&&(n.value=getReferenceToRequireWrapper(config,n.value.value)),types.isArrayExpression(n)&&n.elements.forEach((element,index,elements)=>{types.isStringLiteral(element)&&(elements[index]=getReferenceToRequireWrapper(config,element.value));});});}var postinstallAddon=async(addonName,options)=>{try{let modulePath=__require.resolve(`${addonName}/postinstall`,{paths:[process.cwd()]}),postinstall=__require(modulePath);console.log({modulePath,postinstall});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]},requireMain=configDir=>{let absoluteConfigDir=isAbsolute(configDir)?configDir:join(process.cwd(),configDir),mainFile=join(absoluteConfigDir,"main");return serverRequire(mainFile)??{}},checkInstalled=(addonName,main)=>!!main.addons?.find(entry=>(typeof entry=="string"?entry:entry.name)?.endsWith(addonName)),isCoreAddon=addonName=>Object.hasOwn(versions,addonName);async function add(addon,{packageManager:pkgMgr,skipPostinstall,configDir:userSpecifiedConfigDir,yes},logger28=console){let[addonName,inputVersion]=getVersionSpecifier(addon),packageManager=JsPackageManagerFactory.getPackageManager({force:pkgMgr}),packageJson=await packageManager.retrievePackageJson(),{mainConfig,configDir:inferredConfigDir}=getStorybookInfo(packageJson,userSpecifiedConfigDir),configDir=userSpecifiedConfigDir||inferredConfigDir||".storybook";if(typeof configDir>"u")throw new Error(dedent`
36
+ `),functionDeclaration}function wrapValueWithRequireWrapper(config,node){isRequireWrapperNecessary(node,n=>{if(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];});}types.isObjectProperty(n)&&types.isStringLiteral(n.value)&&(n.value=getReferenceToRequireWrapper(config,n.value.value)),types.isArrayExpression(n)&&n.elements.forEach((element,index,elements)=>{types.isStringLiteral(element)&&(elements[index]=getReferenceToRequireWrapper(config,element.value));});});}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]},requireMain=configDir=>{let absoluteConfigDir=isAbsolute(configDir)?configDir:join(process.cwd(),configDir),mainFile=join(absoluteConfigDir,"main");return serverRequire(mainFile)??{}},checkInstalled=(addonName,main)=>!!main.addons?.find(entry=>(typeof entry=="string"?entry:entry.name)?.endsWith(addonName)),isCoreAddon=addonName=>Object.hasOwn(versions,addonName);async function add(addon,{packageManager:pkgMgr,skipPostinstall,configDir:userSpecifiedConfigDir,yes},logger28=console){let[addonName,inputVersion]=getVersionSpecifier(addon),packageManager=JsPackageManagerFactory.getPackageManager({force:pkgMgr}),packageJson=await packageManager.retrievePackageJson(),{mainConfig,configDir:inferredConfigDir}=getStorybookInfo(packageJson,userSpecifiedConfigDir),configDir=userSpecifiedConfigDir||inferredConfigDir||".storybook";if(typeof configDir>"u")throw new Error(dedent`
37
37
  Unable to find storybook config directory. Please specify your Storybook config directory with the --config-dir flag.
38
38
  `);if(!mainConfig){logger28.error("Unable to find Storybook main.js config");return}let shouldAddToMain=!0;if(checkInstalled(addonName,requireMain(configDir))){let{shouldForceInstall}=await prompts6({type:"confirm",name:"shouldForceInstall",message:`The Storybook addon "${addonName}" is already present in ${mainConfig}. Do you wish to install it again?`});if(!shouldForceInstall)return;shouldAddToMain=!1;}let main=await readConfig(mainConfig);logger28.log(`Verifying ${addonName}`);let storybookVersion=await getCoercedStorybookVersion(packageManager),version=inputVersion;!version&&isCoreAddon(addonName)&&storybookVersion&&(version=storybookVersion),version||(version=await packageManager.latestVersion(addonName)),isCoreAddon(addonName)&&version!==storybookVersion&&logger28.warn(`The version of ${addonName} (${version}) you are installing is not the same as the version of Storybook you are using (${storybookVersion}). This may lead to unexpected behavior.`);let addonWithVersion=isValidVersion(version)?`${addonName}@^${version}`:`${addonName}@${version}`;if(logger28.log(`Installing ${addonWithVersion}`),await packageManager.addDependencies({installAsDevDependencies:!0},[addonWithVersion]),shouldAddToMain){if(logger28.log(`Adding '${addon}' to the "addons" field in ${mainConfig}`),main.getFieldNode(["addons"])&&getRequireWrapperName(main)!==null){let addonNode=main.valueToNode(addonName);main.appendNodeToArray(["addons"],addonNode),wrapValueWithRequireWrapper(main,addonNode);}else main.appendValueToArray(["addons"],addonName);await writeConfig(main);}!skipPostinstall&&isCoreAddon(addonName)&&await postinstallAddon(addonName,{packageManager:packageManager.type,configDir,yes});}function isValidVersion(version){return semver.valid(version)||version.match(/^\d+$/)}function ansiRegex({onlyFirst=!1}={}){let pattern=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(pattern,onlyFirst?void 0:"g")}var regex=ansiRegex();function stripAnsi(string){if(typeof string!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);return string.replace(regex,"")}var import_eastasianwidth=__toESM(require_eastasianwidth(),1),import_emoji_regex=__toESM(require_emoji_regex(),1);function stringWidth(string,options={}){if(typeof string!="string"||string.length===0||(options={ambiguousIsNarrow:!0,...options},string=stripAnsi(string),string.length===0))return 0;string=string.replace((0, import_emoji_regex.default)()," ");let ambiguousCharacterWidth=options.ambiguousIsNarrow?1:2,width=0;for(let character of string){let codePoint=character.codePointAt(0);if(codePoint<=31||codePoint>=127&&codePoint<=159||codePoint>=768&&codePoint<=879)continue;switch(import_eastasianwidth.default.eastAsianWidth(character)){case"F":case"W":width+=2;break;case"A":width+=ambiguousCharacterWidth;break;default:width+=1;}}return width}var wrapAnsi16=(offset=0)=>code=>`\x1B[${code+offset}m`,wrapAnsi256=(offset=0)=>code=>`\x1B[${38+offset};5;${code}m`,wrapAnsi16m=(offset=0)=>(red,green,blue)=>`\x1B[${38+offset};2;${red};${green};${blue}m`,styles={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(styles.modifier);var foregroundColorNames=Object.keys(styles.color),backgroundColorNames=Object.keys(styles.bgColor);[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){let codes=new Map;for(let[groupName,group]of Object.entries(styles)){for(let[styleName,style]of Object.entries(group))styles[styleName]={open:`\x1B[${style[0]}m`,close:`\x1B[${style[1]}m`},group[styleName]=styles[styleName],codes.set(style[0],style[1]);Object.defineProperty(styles,groupName,{value:group,enumerable:!1});}return Object.defineProperty(styles,"codes",{value:codes,enumerable:!1}),styles.color.close="\x1B[39m",styles.bgColor.close="\x1B[49m",styles.color.ansi=wrapAnsi16(),styles.color.ansi256=wrapAnsi256(),styles.color.ansi16m=wrapAnsi16m(),styles.bgColor.ansi=wrapAnsi16(10),styles.bgColor.ansi256=wrapAnsi256(10),styles.bgColor.ansi16m=wrapAnsi16m(10),Object.defineProperties(styles,{rgbToAnsi256:{value(red,green,blue){return red===green&&green===blue?red<8?16:red>248?231:Math.round((red-8)/247*24)+232:16+36*Math.round(red/255*5)+6*Math.round(green/255*5)+Math.round(blue/255*5)},enumerable:!1},hexToRgb:{value(hex){let matches=/[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));if(!matches)return [0,0,0];let[colorString]=matches;colorString.length===3&&(colorString=[...colorString].map(character=>character+character).join(""));let integer=Number.parseInt(colorString,16);return [integer>>16&255,integer>>8&255,integer&255]},enumerable:!1},hexToAnsi256:{value:hex=>styles.rgbToAnsi256(...styles.hexToRgb(hex)),enumerable:!1},ansi256ToAnsi:{value(code){if(code<8)return 30+code;if(code<16)return 90+(code-8);let red,green,blue;if(code>=232)red=((code-232)*10+8)/255,green=red,blue=red;else {code-=16;let remainder=code%36;red=Math.floor(code/36)/5,green=Math.floor(remainder/6)/5,blue=remainder%6/5;}let value=Math.max(red,green,blue)*2;if(value===0)return 30;let result=30+(Math.round(blue)<<2|Math.round(green)<<1|Math.round(red));return value===2&&(result+=60),result},enumerable:!1},rgbToAnsi:{value:(red,green,blue)=>styles.ansi256ToAnsi(styles.rgbToAnsi256(red,green,blue)),enumerable:!1},hexToAnsi:{value:hex=>styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),enumerable:!1}}),styles}var ansiStyles=assembleStyles(),ansi_styles_default=ansiStyles;function hasFlag(flag,argv=globalThis.Deno?globalThis.Deno.args:process3.argv){let prefix=flag.startsWith("-")?"":flag.length===1?"-":"--",position=argv.indexOf(prefix+flag),terminatorPosition=argv.indexOf("--");return position!==-1&&(terminatorPosition===-1||position<terminatorPosition)}var{env}=process3,flagForceColor;hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")?flagForceColor=0:(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always"))&&(flagForceColor=1);function envForceColor(){if("FORCE_COLOR"in env)return env.FORCE_COLOR==="true"?1:env.FORCE_COLOR==="false"?0:env.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(env.FORCE_COLOR,10),3)}function translateLevel(level){return level===0?!1:{level,hasBasic:!0,has256:level>=2,has16m:level>=3}}function _supportsColor(haveStream,{streamIsTTY,sniffFlags=!0}={}){let noFlagForceColor=envForceColor();noFlagForceColor!==void 0&&(flagForceColor=noFlagForceColor);let forceColor=sniffFlags?flagForceColor:noFlagForceColor;if(forceColor===0)return 0;if(sniffFlags){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor"))return 3;if(hasFlag("color=256"))return 2}if("TF_BUILD"in env&&"AGENT_NAME"in env)return 1;if(haveStream&&!streamIsTTY&&forceColor===void 0)return 0;let min=forceColor||0;if(env.TERM==="dumb")return min;if(process3.platform==="win32"){let osRelease=os.release().split(".");return Number(osRelease[0])>=10&&Number(osRelease[2])>=10586?Number(osRelease[2])>=14931?3:2:1}if("CI"in env)return "GITHUB_ACTIONS"in env||"GITEA_ACTIONS"in env?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(sign=>sign in env)||env.CI_NAME==="codeship"?1:min;if("TEAMCITY_VERSION"in env)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION)?1:0;if(env.COLORTERM==="truecolor"||env.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in env){let version=Number.parseInt((env.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(env.TERM_PROGRAM){case"iTerm.app":return version>=3?3:2;case"Apple_Terminal":return 2}}return /-256(color)?$/i.test(env.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)||"COLORTERM"in env?1:min}function createSupportsColor(stream,options={}){let level=_supportsColor(stream,{streamIsTTY:stream&&stream.isTTY,...options});return translateLevel(level)}var supportsColor={stdout:createSupportsColor({isTTY:tty.isatty(1)}),stderr:createSupportsColor({isTTY:tty.isatty(2)})},supports_color_default=supportsColor;function stringReplaceAll(string,substring,replacer){let index=string.indexOf(substring);if(index===-1)return string;let substringLength=substring.length,endIndex=0,returnValue="";do returnValue+=string.slice(endIndex,index)+substring+replacer,endIndex=index+substringLength,index=string.indexOf(substring,endIndex);while(index!==-1);return returnValue+=string.slice(endIndex),returnValue}function stringEncaseCRLFWithFirstIndex(string,prefix,postfix,index){let endIndex=0,returnValue="";do{let gotCR=string[index-1]==="\r";returnValue+=string.slice(endIndex,gotCR?index-1:index)+prefix+(gotCR?`\r
39
39
  `:`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/cli",
3
- "version": "0.0.0-pr-29353-sha-3b7a5f8f",
3
+ "version": "0.0.0-pr-29241-sha-786ddd72",
4
4
  "description": "Storybook CLI",
5
5
  "keywords": [
6
6
  "storybook"
@@ -42,10 +42,10 @@
42
42
  "dependencies": {
43
43
  "@babel/core": "^7.24.4",
44
44
  "@babel/types": "^7.24.0",
45
- "@storybook/codemod": "0.0.0-pr-29353-sha-3b7a5f8f",
45
+ "@storybook/codemod": "0.0.0-pr-29241-sha-786ddd72",
46
46
  "@types/semver": "^7.3.4",
47
47
  "commander": "^12.1.0",
48
- "create-storybook": "0.0.0-pr-29353-sha-3b7a5f8f",
48
+ "create-storybook": "0.0.0-pr-29241-sha-786ddd72",
49
49
  "cross-spawn": "^7.0.3",
50
50
  "envinfo": "^7.7.3",
51
51
  "fd-package-json": "^1.2.0",
@@ -57,7 +57,7 @@
57
57
  "leven": "^3.1.0",
58
58
  "prompts": "^2.4.0",
59
59
  "semver": "^7.3.7",
60
- "storybook": "0.0.0-pr-29353-sha-3b7a5f8f",
60
+ "storybook": "0.0.0-pr-29241-sha-786ddd72",
61
61
  "tiny-invariant": "^1.3.1",
62
62
  "ts-dedent": "^2.0.0"
63
63
  },