New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

create-storybook

Package Overview
Dependencies
Maintainers
0
Versions
286
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-storybook - npm Package Compare versions

Comparing version 0.0.0-pr-30197-sha-a3d613d5 to 0.0.0-pr-30202-sha-35656f03

dist/chunk-I6NEWYLK.js

37

dist/bin/index.js

@@ -1,8 +0,31 @@

import { initiate } from '../chunk-BXPKU4GR.js';
import { versions } from 'storybook/internal/common';
import { addToGlobalContext } from 'storybook/internal/telemetry';
import { program } from 'commander';
import { findPackageSync } from 'fd-package-json';
import invariant from 'tiny-invariant';
import ESM_COMPAT_Module from 'node:module';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { __commonJS, __require, __toESM, initiate } from '../chunk-I6NEWYLK.js';
import { addToGlobalContext } from '@storybook/core/telemetry';
addToGlobalContext("cliVersion",versions.storybook);var pkg=findPackageSync(__dirname);invariant(pkg,"Failed to find the closest package.json file.");program.name("Initialize Storybook into your project.").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").option("-f --force","Force add Storybook").option("-s --skip-install","Skip installing deps").option("--package-manager <npm|pnpm|yarn1|yarn2|bun>","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)").option("--dev","Launch the development server after completing initialization. Enabled by default",process.env.CI!=="true"&&process.env.IN_STORYBOOK_SANDBOX!=="true").option("--no-dev","Complete the initialization of Storybook without launching the Storybook development server").action(options=>{initiate(options).catch(()=>process.exit(1));}).version(String(pkg.version)).parse(process.argv);
const __filename = fileURLToPath(import.meta.url);
dirname(__filename);
ESM_COMPAT_Module.createRequire(import.meta.url);
var require_error=__commonJS({"../../node_modules/commander/lib/error.js"(exports){var CommanderError2=class extends Error{constructor(exitCode,code,message){super(message),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=code,this.exitCode=exitCode,this.nestedError=void 0;}},InvalidArgumentError2=class extends CommanderError2{constructor(message){super(1,"commander.invalidArgument",message),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name;}};exports.CommanderError=CommanderError2;exports.InvalidArgumentError=InvalidArgumentError2;}});var require_argument=__commonJS({"../../node_modules/commander/lib/argument.js"(exports){var{InvalidArgumentError:InvalidArgumentError2}=require_error(),Argument2=class{constructor(name,description){switch(this.description=description||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,name[0]){case"<":this.required=!0,this._name=name.slice(1,-1);break;case"[":this.required=!1,this._name=name.slice(1,-1);break;default:this.required=!0,this._name=name;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3));}name(){return this._name}_concatValue(value,previous){return previous===this.defaultValue||!Array.isArray(previous)?[value]:previous.concat(value)}default(value,description){return this.defaultValue=value,this.defaultValueDescription=description,this}argParser(fn){return this.parseArg=fn,this}choices(values){return this.argChoices=values.slice(),this.parseArg=(arg,previous)=>{if(!this.argChoices.includes(arg))throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(arg,previous):arg},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function humanReadableArgName(arg){let nameOutput=arg.name()+(arg.variadic===!0?"...":"");return arg.required?"<"+nameOutput+">":"["+nameOutput+"]"}exports.Argument=Argument2;exports.humanReadableArgName=humanReadableArgName;}});var require_help=__commonJS({"../../node_modules/commander/lib/help.js"(exports){var{humanReadableArgName}=require_argument(),Help2=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1;}visibleCommands(cmd){let visibleCommands=cmd.commands.filter(cmd2=>!cmd2._hidden),helpCommand=cmd._getHelpCommand();return helpCommand&&!helpCommand._hidden&&visibleCommands.push(helpCommand),this.sortSubcommands&&visibleCommands.sort((a,b)=>a.name().localeCompare(b.name())),visibleCommands}compareOptions(a,b){let getSortKey=option=>option.short?option.short.replace(/^-/,""):option.long.replace(/^--/,"");return getSortKey(a).localeCompare(getSortKey(b))}visibleOptions(cmd){let visibleOptions=cmd.options.filter(option=>!option.hidden),helpOption=cmd._getHelpOption();if(helpOption&&!helpOption.hidden){let removeShort=helpOption.short&&cmd._findOption(helpOption.short),removeLong=helpOption.long&&cmd._findOption(helpOption.long);!removeShort&&!removeLong?visibleOptions.push(helpOption):helpOption.long&&!removeLong?visibleOptions.push(cmd.createOption(helpOption.long,helpOption.description)):helpOption.short&&!removeShort&&visibleOptions.push(cmd.createOption(helpOption.short,helpOption.description));}return this.sortOptions&&visibleOptions.sort(this.compareOptions),visibleOptions}visibleGlobalOptions(cmd){if(!this.showGlobalOptions)return [];let globalOptions=[];for(let ancestorCmd=cmd.parent;ancestorCmd;ancestorCmd=ancestorCmd.parent){let visibleOptions=ancestorCmd.options.filter(option=>!option.hidden);globalOptions.push(...visibleOptions);}return this.sortOptions&&globalOptions.sort(this.compareOptions),globalOptions}visibleArguments(cmd){return cmd._argsDescription&&cmd.registeredArguments.forEach(argument=>{argument.description=argument.description||cmd._argsDescription[argument.name()]||"";}),cmd.registeredArguments.find(argument=>argument.description)?cmd.registeredArguments:[]}subcommandTerm(cmd){let args=cmd.registeredArguments.map(arg=>humanReadableArgName(arg)).join(" ");return cmd._name+(cmd._aliases[0]?"|"+cmd._aliases[0]:"")+(cmd.options.length?" [options]":"")+(args?" "+args:"")}optionTerm(option){return option.flags}argumentTerm(argument){return argument.name()}longestSubcommandTermLength(cmd,helper){return helper.visibleCommands(cmd).reduce((max,command)=>Math.max(max,helper.subcommandTerm(command).length),0)}longestOptionTermLength(cmd,helper){return helper.visibleOptions(cmd).reduce((max,option)=>Math.max(max,helper.optionTerm(option).length),0)}longestGlobalOptionTermLength(cmd,helper){return helper.visibleGlobalOptions(cmd).reduce((max,option)=>Math.max(max,helper.optionTerm(option).length),0)}longestArgumentTermLength(cmd,helper){return helper.visibleArguments(cmd).reduce((max,argument)=>Math.max(max,helper.argumentTerm(argument).length),0)}commandUsage(cmd){let cmdName=cmd._name;cmd._aliases[0]&&(cmdName=cmdName+"|"+cmd._aliases[0]);let ancestorCmdNames="";for(let ancestorCmd=cmd.parent;ancestorCmd;ancestorCmd=ancestorCmd.parent)ancestorCmdNames=ancestorCmd.name()+" "+ancestorCmdNames;return ancestorCmdNames+cmdName+" "+cmd.usage()}commandDescription(cmd){return cmd.description()}subcommandDescription(cmd){return cmd.summary()||cmd.description()}optionDescription(option){let extraInfo=[];return option.argChoices&&extraInfo.push(`choices: ${option.argChoices.map(choice=>JSON.stringify(choice)).join(", ")}`),option.defaultValue!==void 0&&(option.required||option.optional||option.isBoolean()&&typeof option.defaultValue=="boolean")&&extraInfo.push(`default: ${option.defaultValueDescription||JSON.stringify(option.defaultValue)}`),option.presetArg!==void 0&&option.optional&&extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`),option.envVar!==void 0&&extraInfo.push(`env: ${option.envVar}`),extraInfo.length>0?`${option.description} (${extraInfo.join(", ")})`:option.description}argumentDescription(argument){let extraInfo=[];if(argument.argChoices&&extraInfo.push(`choices: ${argument.argChoices.map(choice=>JSON.stringify(choice)).join(", ")}`),argument.defaultValue!==void 0&&extraInfo.push(`default: ${argument.defaultValueDescription||JSON.stringify(argument.defaultValue)}`),extraInfo.length>0){let extraDescripton=`(${extraInfo.join(", ")})`;return argument.description?`${argument.description} ${extraDescripton}`:extraDescripton}return argument.description}formatHelp(cmd,helper){let termWidth=helper.padWidth(cmd,helper),helpWidth=helper.helpWidth||80,itemIndentWidth=2,itemSeparatorWidth=2;function formatItem(term,description){if(description){let fullText=`${term.padEnd(termWidth+itemSeparatorWidth)}${description}`;return helper.wrap(fullText,helpWidth-itemIndentWidth,termWidth+itemSeparatorWidth)}return term}function formatList(textArray){return textArray.join(`
`).replace(/^/gm," ".repeat(itemIndentWidth))}let output=[`Usage: ${helper.commandUsage(cmd)}`,""],commandDescription=helper.commandDescription(cmd);commandDescription.length>0&&(output=output.concat([helper.wrap(commandDescription,helpWidth,0),""]));let argumentList=helper.visibleArguments(cmd).map(argument=>formatItem(helper.argumentTerm(argument),helper.argumentDescription(argument)));argumentList.length>0&&(output=output.concat(["Arguments:",formatList(argumentList),""]));let optionList=helper.visibleOptions(cmd).map(option=>formatItem(helper.optionTerm(option),helper.optionDescription(option)));if(optionList.length>0&&(output=output.concat(["Options:",formatList(optionList),""])),this.showGlobalOptions){let globalOptionList=helper.visibleGlobalOptions(cmd).map(option=>formatItem(helper.optionTerm(option),helper.optionDescription(option)));globalOptionList.length>0&&(output=output.concat(["Global Options:",formatList(globalOptionList),""]));}let commandList=helper.visibleCommands(cmd).map(cmd2=>formatItem(helper.subcommandTerm(cmd2),helper.subcommandDescription(cmd2)));return commandList.length>0&&(output=output.concat(["Commands:",formatList(commandList),""])),output.join(`
`)}padWidth(cmd,helper){return Math.max(helper.longestOptionTermLength(cmd,helper),helper.longestGlobalOptionTermLength(cmd,helper),helper.longestSubcommandTermLength(cmd,helper),helper.longestArgumentTermLength(cmd,helper))}wrap(str,width,indent,minColumnWidth=40){let indents=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",manualIndent=new RegExp(`[\\n][${indents}]+`);if(str.match(manualIndent))return str;let columnWidth=width-indent;if(columnWidth<minColumnWidth)return str;let leadingStr=str.slice(0,indent),columnText=str.slice(indent).replace(`\r
`,`
`),indentString=" ".repeat(indent),breaks="\\s\u200B",regex=new RegExp(`
|.{1,${columnWidth-1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,"g"),lines=columnText.match(regex)||[];return leadingStr+lines.map((line,i)=>line===`
`?"":(i>0?indentString:"")+line.trimEnd()).join(`
`)}};exports.Help=Help2;}});var require_option=__commonJS({"../../node_modules/commander/lib/option.js"(exports){var{InvalidArgumentError:InvalidArgumentError2}=require_error(),Option2=class{constructor(flags,description){this.flags=flags,this.description=description||"",this.required=flags.includes("<"),this.optional=flags.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(flags),this.mandatory=!1;let optionFlags=splitOptionFlags(flags);this.short=optionFlags.shortFlag,this.long=optionFlags.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0;}default(value,description){return this.defaultValue=value,this.defaultValueDescription=description,this}preset(arg){return this.presetArg=arg,this}conflicts(names){return this.conflictsWith=this.conflictsWith.concat(names),this}implies(impliedOptionValues){let newImplied=impliedOptionValues;return typeof impliedOptionValues=="string"&&(newImplied={[impliedOptionValues]:!0}),this.implied=Object.assign(this.implied||{},newImplied),this}env(name){return this.envVar=name,this}argParser(fn){return this.parseArg=fn,this}makeOptionMandatory(mandatory=!0){return this.mandatory=!!mandatory,this}hideHelp(hide=!0){return this.hidden=!!hide,this}_concatValue(value,previous){return previous===this.defaultValue||!Array.isArray(previous)?[value]:previous.concat(value)}choices(values){return this.argChoices=values.slice(),this.parseArg=(arg,previous)=>{if(!this.argChoices.includes(arg))throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(arg,previous):arg},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(arg){return this.short===arg||this.long===arg}isBoolean(){return !this.required&&!this.optional&&!this.negate}},DualOptions=class{constructor(options){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,options.forEach(option=>{option.negate?this.negativeOptions.set(option.attributeName(),option):this.positiveOptions.set(option.attributeName(),option);}),this.negativeOptions.forEach((value,key)=>{this.positiveOptions.has(key)&&this.dualOptions.add(key);});}valueFromOption(value,option){let optionKey=option.attributeName();if(!this.dualOptions.has(optionKey))return !0;let preset=this.negativeOptions.get(optionKey).presetArg,negativeValue=preset!==void 0?preset:!1;return option.negate===(negativeValue===value)}};function camelcase(str){return str.split("-").reduce((str2,word)=>str2+word[0].toUpperCase()+word.slice(1))}function splitOptionFlags(flags){let shortFlag,longFlag,flagParts=flags.split(/[ |,]+/);return flagParts.length>1&&!/^[[<]/.test(flagParts[1])&&(shortFlag=flagParts.shift()),longFlag=flagParts.shift(),!shortFlag&&/^-[^-]$/.test(longFlag)&&(shortFlag=longFlag,longFlag=void 0),{shortFlag,longFlag}}exports.Option=Option2;exports.DualOptions=DualOptions;}});var require_suggestSimilar=__commonJS({"../../node_modules/commander/lib/suggestSimilar.js"(exports){function editDistance(a,b){if(Math.abs(a.length-b.length)>3)return Math.max(a.length,b.length);let d=[];for(let i=0;i<=a.length;i++)d[i]=[i];for(let j=0;j<=b.length;j++)d[0][j]=j;for(let j=1;j<=b.length;j++)for(let i=1;i<=a.length;i++){let cost=1;a[i-1]===b[j-1]?cost=0:cost=1,d[i][j]=Math.min(d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+cost),i>1&&j>1&&a[i-1]===b[j-2]&&a[i-2]===b[j-1]&&(d[i][j]=Math.min(d[i][j],d[i-2][j-2]+1));}return d[a.length][b.length]}function suggestSimilar(word,candidates){if(!candidates||candidates.length===0)return "";candidates=Array.from(new Set(candidates));let searchingOptions=word.startsWith("--");searchingOptions&&(word=word.slice(2),candidates=candidates.map(candidate=>candidate.slice(2)));let similar=[],bestDistance=3,minSimilarity=.4;return candidates.forEach(candidate=>{if(candidate.length<=1)return;let distance=editDistance(word,candidate),length=Math.max(word.length,candidate.length);(length-distance)/length>minSimilarity&&(distance<bestDistance?(bestDistance=distance,similar=[candidate]):distance===bestDistance&&similar.push(candidate));}),similar.sort((a,b)=>a.localeCompare(b)),searchingOptions&&(similar=similar.map(candidate=>`--${candidate}`)),similar.length>1?`
(Did you mean one of ${similar.join(", ")}?)`:similar.length===1?`
(Did you mean ${similar[0]}?)`:""}exports.suggestSimilar=suggestSimilar;}});var require_command=__commonJS({"../../node_modules/commander/lib/command.js"(exports){var EventEmitter=__require("node:events").EventEmitter,childProcess=__require("node:child_process"),path=__require("node:path"),fs=__require("node:fs"),process2=__require("node:process"),{Argument:Argument2,humanReadableArgName}=require_argument(),{CommanderError:CommanderError2}=require_error(),{Help:Help2}=require_help(),{Option:Option2,DualOptions}=require_option(),{suggestSimilar}=require_suggestSimilar(),Command2=class _Command extends EventEmitter{constructor(name){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=name||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:str=>process2.stdout.write(str),writeErr:str=>process2.stderr.write(str),getOutHelpWidth:()=>process2.stdout.isTTY?process2.stdout.columns:void 0,getErrHelpWidth:()=>process2.stderr.isTTY?process2.stderr.columns:void 0,outputError:(str,write)=>write(str)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={};}copyInheritedSettings(sourceCommand){return this._outputConfiguration=sourceCommand._outputConfiguration,this._helpOption=sourceCommand._helpOption,this._helpCommand=sourceCommand._helpCommand,this._helpConfiguration=sourceCommand._helpConfiguration,this._exitCallback=sourceCommand._exitCallback,this._storeOptionsAsProperties=sourceCommand._storeOptionsAsProperties,this._combineFlagAndOptionalValue=sourceCommand._combineFlagAndOptionalValue,this._allowExcessArguments=sourceCommand._allowExcessArguments,this._enablePositionalOptions=sourceCommand._enablePositionalOptions,this._showHelpAfterError=sourceCommand._showHelpAfterError,this._showSuggestionAfterError=sourceCommand._showSuggestionAfterError,this}_getCommandAndAncestors(){let result=[];for(let command=this;command;command=command.parent)result.push(command);return result}command(nameAndArgs,actionOptsOrExecDesc,execOpts){let desc=actionOptsOrExecDesc,opts=execOpts;typeof desc=="object"&&desc!==null&&(opts=desc,desc=null),opts=opts||{};let[,name,args]=nameAndArgs.match(/([^ ]+) *(.*)/),cmd=this.createCommand(name);return desc&&(cmd.description(desc),cmd._executableHandler=!0),opts.isDefault&&(this._defaultCommandName=cmd._name),cmd._hidden=!!(opts.noHelp||opts.hidden),cmd._executableFile=opts.executableFile||null,args&&cmd.arguments(args),this._registerCommand(cmd),cmd.parent=this,cmd.copyInheritedSettings(this),desc?this:cmd}createCommand(name){return new _Command(name)}createHelp(){return Object.assign(new Help2,this.configureHelp())}configureHelp(configuration){return configuration===void 0?this._helpConfiguration:(this._helpConfiguration=configuration,this)}configureOutput(configuration){return configuration===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,configuration),this)}showHelpAfterError(displayHelp=!0){return typeof displayHelp!="string"&&(displayHelp=!!displayHelp),this._showHelpAfterError=displayHelp,this}showSuggestionAfterError(displaySuggestion=!0){return this._showSuggestionAfterError=!!displaySuggestion,this}addCommand(cmd,opts){if(!cmd._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return opts=opts||{},opts.isDefault&&(this._defaultCommandName=cmd._name),(opts.noHelp||opts.hidden)&&(cmd._hidden=!0),this._registerCommand(cmd),cmd.parent=this,cmd._checkForBrokenPassThrough(),this}createArgument(name,description){return new Argument2(name,description)}argument(name,description,fn,defaultValue){let argument=this.createArgument(name,description);return typeof fn=="function"?argument.default(defaultValue).argParser(fn):argument.default(fn),this.addArgument(argument),this}arguments(names){return names.trim().split(/ +/).forEach(detail=>{this.argument(detail);}),this}addArgument(argument){let previousArgument=this.registeredArguments.slice(-1)[0];if(previousArgument&&previousArgument.variadic)throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);if(argument.required&&argument.defaultValue!==void 0&&argument.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);return this.registeredArguments.push(argument),this}helpCommand(enableOrNameAndArgs,description){if(typeof enableOrNameAndArgs=="boolean")return this._addImplicitHelpCommand=enableOrNameAndArgs,this;enableOrNameAndArgs=enableOrNameAndArgs??"help [command]";let[,helpName,helpArgs]=enableOrNameAndArgs.match(/([^ ]+) *(.*)/),helpDescription=description??"display help for command",helpCommand=this.createCommand(helpName);return helpCommand.helpOption(!1),helpArgs&&helpCommand.arguments(helpArgs),helpDescription&&helpCommand.description(helpDescription),this._addImplicitHelpCommand=!0,this._helpCommand=helpCommand,this}addHelpCommand(helpCommand,deprecatedDescription){return typeof helpCommand!="object"?(this.helpCommand(helpCommand,deprecatedDescription),this):(this._addImplicitHelpCommand=!0,this._helpCommand=helpCommand,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(event,listener){let allowedValues=["preSubcommand","preAction","postAction"];if(!allowedValues.includes(event))throw new Error(`Unexpected value for event passed to hook : '${event}'.
Expecting one of '${allowedValues.join("', '")}'`);return this._lifeCycleHooks[event]?this._lifeCycleHooks[event].push(listener):this._lifeCycleHooks[event]=[listener],this}exitOverride(fn){return fn?this._exitCallback=fn:this._exitCallback=err=>{if(err.code!=="commander.executeSubCommandAsync")throw err},this}_exit(exitCode,code,message){this._exitCallback&&this._exitCallback(new CommanderError2(exitCode,code,message)),process2.exit(exitCode);}action(fn){let listener=args=>{let expectedArgsCount=this.registeredArguments.length,actionArgs=args.slice(0,expectedArgsCount);return this._storeOptionsAsProperties?actionArgs[expectedArgsCount]=this:actionArgs[expectedArgsCount]=this.opts(),actionArgs.push(this),fn.apply(this,actionArgs)};return this._actionHandler=listener,this}createOption(flags,description){return new Option2(flags,description)}_callParseArg(target,value,previous,invalidArgumentMessage){try{return target.parseArg(value,previous)}catch(err){if(err.code==="commander.invalidArgument"){let message=`${invalidArgumentMessage} ${err.message}`;this.error(message,{exitCode:err.exitCode,code:err.code});}throw err}}_registerOption(option){let matchingOption=option.short&&this._findOption(option.short)||option.long&&this._findOption(option.long);if(matchingOption){let matchingFlag=option.long&&this._findOption(option.long)?option.long:option.short;throw new Error(`Cannot add option '${option.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
- already used by option '${matchingOption.flags}'`)}this.options.push(option);}_registerCommand(command){let knownBy=cmd=>[cmd.name()].concat(cmd.aliases()),alreadyUsed=knownBy(command).find(name=>this._findCommand(name));if(alreadyUsed){let existingCmd=knownBy(this._findCommand(alreadyUsed)).join("|"),newCmd=knownBy(command).join("|");throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`)}this.commands.push(command);}addOption(option){this._registerOption(option);let oname=option.name(),name=option.attributeName();if(option.negate){let positiveLongFlag=option.long.replace(/^--no-/,"--");this._findOption(positiveLongFlag)||this.setOptionValueWithSource(name,option.defaultValue===void 0?!0:option.defaultValue,"default");}else option.defaultValue!==void 0&&this.setOptionValueWithSource(name,option.defaultValue,"default");let handleOptionValue=(val,invalidValueMessage,valueSource)=>{val==null&&option.presetArg!==void 0&&(val=option.presetArg);let oldValue=this.getOptionValue(name);val!==null&&option.parseArg?val=this._callParseArg(option,val,oldValue,invalidValueMessage):val!==null&&option.variadic&&(val=option._concatValue(val,oldValue)),val==null&&(option.negate?val=!1:option.isBoolean()||option.optional?val=!0:val=""),this.setOptionValueWithSource(name,val,valueSource);};return this.on("option:"+oname,val=>{let invalidValueMessage=`error: option '${option.flags}' argument '${val}' is invalid.`;handleOptionValue(val,invalidValueMessage,"cli");}),option.envVar&&this.on("optionEnv:"+oname,val=>{let invalidValueMessage=`error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;handleOptionValue(val,invalidValueMessage,"env");}),this}_optionEx(config,flags,description,fn,defaultValue){if(typeof flags=="object"&&flags instanceof Option2)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let option=this.createOption(flags,description);if(option.makeOptionMandatory(!!config.mandatory),typeof fn=="function")option.default(defaultValue).argParser(fn);else if(fn instanceof RegExp){let regex=fn;fn=(val,def)=>{let m=regex.exec(val);return m?m[0]:def},option.default(defaultValue).argParser(fn);}else option.default(fn);return this.addOption(option)}option(flags,description,parseArg,defaultValue){return this._optionEx({},flags,description,parseArg,defaultValue)}requiredOption(flags,description,parseArg,defaultValue){return this._optionEx({mandatory:!0},flags,description,parseArg,defaultValue)}combineFlagAndOptionalValue(combine=!0){return this._combineFlagAndOptionalValue=!!combine,this}allowUnknownOption(allowUnknown=!0){return this._allowUnknownOption=!!allowUnknown,this}allowExcessArguments(allowExcess=!0){return this._allowExcessArguments=!!allowExcess,this}enablePositionalOptions(positional=!0){return this._enablePositionalOptions=!!positional,this}passThroughOptions(passThrough=!0){return this._passThroughOptions=!!passThrough,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(storeAsProperties=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!storeAsProperties,this}getOptionValue(key){return this._storeOptionsAsProperties?this[key]:this._optionValues[key]}setOptionValue(key,value){return this.setOptionValueWithSource(key,value,void 0)}setOptionValueWithSource(key,value,source){return this._storeOptionsAsProperties?this[key]=value:this._optionValues[key]=value,this._optionValueSources[key]=source,this}getOptionValueSource(key){return this._optionValueSources[key]}getOptionValueSourceWithGlobals(key){let source;return this._getCommandAndAncestors().forEach(cmd=>{cmd.getOptionValueSource(key)!==void 0&&(source=cmd.getOptionValueSource(key));}),source}_prepareUserArgs(argv,parseOptions){if(argv!==void 0&&!Array.isArray(argv))throw new Error("first parameter to parse must be array or undefined");if(parseOptions=parseOptions||{},argv===void 0&&parseOptions.from===void 0){process2.versions?.electron&&(parseOptions.from="electron");let execArgv=process2.execArgv??[];(execArgv.includes("-e")||execArgv.includes("--eval")||execArgv.includes("-p")||execArgv.includes("--print"))&&(parseOptions.from="eval");}argv===void 0&&(argv=process2.argv),this.rawArgs=argv.slice();let userArgs;switch(parseOptions.from){case void 0:case"node":this._scriptPath=argv[1],userArgs=argv.slice(2);break;case"electron":process2.defaultApp?(this._scriptPath=argv[1],userArgs=argv.slice(2)):userArgs=argv.slice(1);break;case"user":userArgs=argv.slice(0);break;case"eval":userArgs=argv.slice(1);break;default:throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`)}return !this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",userArgs}parse(argv,parseOptions){let userArgs=this._prepareUserArgs(argv,parseOptions);return this._parseCommand([],userArgs),this}async parseAsync(argv,parseOptions){let userArgs=this._prepareUserArgs(argv,parseOptions);return await this._parseCommand([],userArgs),this}_executeSubCommand(subcommand,args){args=args.slice();let launchWithNode=!1,sourceExt=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(baseDir,baseName){let localBin=path.resolve(baseDir,baseName);if(fs.existsSync(localBin))return localBin;if(sourceExt.includes(path.extname(baseName)))return;let foundExt=sourceExt.find(ext=>fs.existsSync(`${localBin}${ext}`));if(foundExt)return `${localBin}${foundExt}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let executableFile=subcommand._executableFile||`${this._name}-${subcommand._name}`,executableDir=this._executableDir||"";if(this._scriptPath){let resolvedScriptPath;try{resolvedScriptPath=fs.realpathSync(this._scriptPath);}catch{resolvedScriptPath=this._scriptPath;}executableDir=path.resolve(path.dirname(resolvedScriptPath),executableDir);}if(executableDir){let localFile=findFile(executableDir,executableFile);if(!localFile&&!subcommand._executableFile&&this._scriptPath){let legacyName=path.basename(this._scriptPath,path.extname(this._scriptPath));legacyName!==this._name&&(localFile=findFile(executableDir,`${legacyName}-${subcommand._name}`));}executableFile=localFile||executableFile;}launchWithNode=sourceExt.includes(path.extname(executableFile));let proc;process2.platform!=="win32"?launchWithNode?(args.unshift(executableFile),args=incrementNodeInspectorPort(process2.execArgv).concat(args),proc=childProcess.spawn(process2.argv[0],args,{stdio:"inherit"})):proc=childProcess.spawn(executableFile,args,{stdio:"inherit"}):(args.unshift(executableFile),args=incrementNodeInspectorPort(process2.execArgv).concat(args),proc=childProcess.spawn(process2.execPath,args,{stdio:"inherit"})),proc.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(signal=>{process2.on(signal,()=>{proc.killed===!1&&proc.exitCode===null&&proc.kill(signal);});});let exitCallback=this._exitCallback;proc.on("close",code=>{code=code??1,exitCallback?exitCallback(new CommanderError2(code,"commander.executeSubCommandAsync","(close)")):process2.exit(code);}),proc.on("error",err=>{if(err.code==="ENOENT"){let executableDirMessage=executableDir?`searched for local subcommand relative to directory '${executableDir}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",executableMissing=`'${executableFile}' does not exist
- if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- ${executableDirMessage}`;throw new Error(executableMissing)}else if(err.code==="EACCES")throw new Error(`'${executableFile}' not executable`);if(!exitCallback)process2.exit(1);else {let wrappedError=new CommanderError2(1,"commander.executeSubCommandAsync","(error)");wrappedError.nestedError=err,exitCallback(wrappedError);}}),this.runningCommand=proc;}_dispatchSubcommand(commandName,operands,unknown){let subCommand=this._findCommand(commandName);subCommand||this.help({error:!0});let promiseChain;return promiseChain=this._chainOrCallSubCommandHook(promiseChain,subCommand,"preSubcommand"),promiseChain=this._chainOrCall(promiseChain,()=>{if(subCommand._executableHandler)this._executeSubCommand(subCommand,operands.concat(unknown));else return subCommand._parseCommand(operands,unknown)}),promiseChain}_dispatchHelpCommand(subcommandName){subcommandName||this.help();let subCommand=this._findCommand(subcommandName);return subCommand&&!subCommand._executableHandler&&subCommand.help(),this._dispatchSubcommand(subcommandName,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((arg,i)=>{arg.required&&this.args[i]==null&&this.missingArgument(arg.name());}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args);}_processArguments(){let myParseArg=(argument,value,previous)=>{let parsedValue=value;if(value!==null&&argument.parseArg){let invalidValueMessage=`error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;parsedValue=this._callParseArg(argument,value,previous,invalidValueMessage);}return parsedValue};this._checkNumberOfArguments();let processedArgs=[];this.registeredArguments.forEach((declaredArg,index)=>{let value=declaredArg.defaultValue;declaredArg.variadic?index<this.args.length?(value=this.args.slice(index),declaredArg.parseArg&&(value=value.reduce((processed,v)=>myParseArg(declaredArg,v,processed),declaredArg.defaultValue))):value===void 0&&(value=[]):index<this.args.length&&(value=this.args[index],declaredArg.parseArg&&(value=myParseArg(declaredArg,value,declaredArg.defaultValue))),processedArgs[index]=value;}),this.processedArgs=processedArgs;}_chainOrCall(promise,fn){return promise&&promise.then&&typeof promise.then=="function"?promise.then(()=>fn()):fn()}_chainOrCallHooks(promise,event){let result=promise,hooks=[];return this._getCommandAndAncestors().reverse().filter(cmd=>cmd._lifeCycleHooks[event]!==void 0).forEach(hookedCommand=>{hookedCommand._lifeCycleHooks[event].forEach(callback=>{hooks.push({hookedCommand,callback});});}),event==="postAction"&&hooks.reverse(),hooks.forEach(hookDetail=>{result=this._chainOrCall(result,()=>hookDetail.callback(hookDetail.hookedCommand,this));}),result}_chainOrCallSubCommandHook(promise,subCommand,event){let result=promise;return this._lifeCycleHooks[event]!==void 0&&this._lifeCycleHooks[event].forEach(hook=>{result=this._chainOrCall(result,()=>hook(this,subCommand));}),result}_parseCommand(operands,unknown){let parsed=this.parseOptions(unknown);if(this._parseOptionsEnv(),this._parseOptionsImplied(),operands=operands.concat(parsed.operands),unknown=parsed.unknown,this.args=operands.concat(unknown),operands&&this._findCommand(operands[0]))return this._dispatchSubcommand(operands[0],operands.slice(1),unknown);if(this._getHelpCommand()&&operands[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(operands[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(unknown),this._dispatchSubcommand(this._defaultCommandName,operands,unknown);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(parsed.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let checkForUnknownOptions=()=>{parsed.unknown.length>0&&this.unknownOption(parsed.unknown[0]);},commandEvent=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions(),this._processArguments();let promiseChain;return promiseChain=this._chainOrCallHooks(promiseChain,"preAction"),promiseChain=this._chainOrCall(promiseChain,()=>this._actionHandler(this.processedArgs)),this.parent&&(promiseChain=this._chainOrCall(promiseChain,()=>{this.parent.emit(commandEvent,operands,unknown);})),promiseChain=this._chainOrCallHooks(promiseChain,"postAction"),promiseChain}if(this.parent&&this.parent.listenerCount(commandEvent))checkForUnknownOptions(),this._processArguments(),this.parent.emit(commandEvent,operands,unknown);else if(operands.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",operands,unknown);this.listenerCount("command:*")?this.emit("command:*",operands,unknown):this.commands.length?this.unknownCommand():(checkForUnknownOptions(),this._processArguments());}else this.commands.length?(checkForUnknownOptions(),this.help({error:!0})):(checkForUnknownOptions(),this._processArguments());}_findCommand(name){if(name)return this.commands.find(cmd=>cmd._name===name||cmd._aliases.includes(name))}_findOption(arg){return this.options.find(option=>option.is(arg))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(cmd=>{cmd.options.forEach(anOption=>{anOption.mandatory&&cmd.getOptionValue(anOption.attributeName())===void 0&&cmd.missingMandatoryOptionValue(anOption);});});}_checkForConflictingLocalOptions(){let definedNonDefaultOptions=this.options.filter(option=>{let optionKey=option.attributeName();return this.getOptionValue(optionKey)===void 0?!1:this.getOptionValueSource(optionKey)!=="default"});definedNonDefaultOptions.filter(option=>option.conflictsWith.length>0).forEach(option=>{let conflictingAndDefined=definedNonDefaultOptions.find(defined=>option.conflictsWith.includes(defined.attributeName()));conflictingAndDefined&&this._conflictingOption(option,conflictingAndDefined);});}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(cmd=>{cmd._checkForConflictingLocalOptions();});}parseOptions(argv){let operands=[],unknown=[],dest=operands,args=argv.slice();function maybeOption(arg){return arg.length>1&&arg[0]==="-"}let activeVariadicOption=null;for(;args.length;){let arg=args.shift();if(arg==="--"){dest===unknown&&dest.push(arg),dest.push(...args);break}if(activeVariadicOption&&!maybeOption(arg)){this.emit(`option:${activeVariadicOption.name()}`,arg);continue}if(activeVariadicOption=null,maybeOption(arg)){let option=this._findOption(arg);if(option){if(option.required){let value=args.shift();value===void 0&&this.optionMissingArgument(option),this.emit(`option:${option.name()}`,value);}else if(option.optional){let value=null;args.length>0&&!maybeOption(args[0])&&(value=args.shift()),this.emit(`option:${option.name()}`,value);}else this.emit(`option:${option.name()}`);activeVariadicOption=option.variadic?option:null;continue}}if(arg.length>2&&arg[0]==="-"&&arg[1]!=="-"){let option=this._findOption(`-${arg[1]}`);if(option){option.required||option.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${option.name()}`,arg.slice(2)):(this.emit(`option:${option.name()}`),args.unshift(`-${arg.slice(2)}`));continue}}if(/^--[^=]+=/.test(arg)){let index=arg.indexOf("="),option=this._findOption(arg.slice(0,index));if(option&&(option.required||option.optional)){this.emit(`option:${option.name()}`,arg.slice(index+1));continue}}if(maybeOption(arg)&&(dest=unknown),(this._enablePositionalOptions||this._passThroughOptions)&&operands.length===0&&unknown.length===0){if(this._findCommand(arg)){operands.push(arg),args.length>0&&unknown.push(...args);break}else if(this._getHelpCommand()&&arg===this._getHelpCommand().name()){operands.push(arg),args.length>0&&operands.push(...args);break}else if(this._defaultCommandName){unknown.push(arg),args.length>0&&unknown.push(...args);break}}if(this._passThroughOptions){dest.push(arg),args.length>0&&dest.push(...args);break}dest.push(arg);}return {operands,unknown}}opts(){if(this._storeOptionsAsProperties){let result={},len=this.options.length;for(let i=0;i<len;i++){let key=this.options[i].attributeName();result[key]=key===this._versionOptionName?this._version:this[key];}return result}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((combinedOptions,cmd)=>Object.assign(combinedOptions,cmd.opts()),{})}error(message,errorOptions){this._outputConfiguration.outputError(`${message}
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
`),this.outputHelp({error:!0}));let config=errorOptions||{},exitCode=config.exitCode||1,code=config.code||"commander.error";this._exit(exitCode,code,message);}_parseOptionsEnv(){this.options.forEach(option=>{if(option.envVar&&option.envVar in process2.env){let optionKey=option.attributeName();(this.getOptionValue(optionKey)===void 0||["default","config","env"].includes(this.getOptionValueSource(optionKey)))&&(option.required||option.optional?this.emit(`optionEnv:${option.name()}`,process2.env[option.envVar]):this.emit(`optionEnv:${option.name()}`));}});}_parseOptionsImplied(){let dualHelper=new DualOptions(this.options),hasCustomOptionValue=optionKey=>this.getOptionValue(optionKey)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(optionKey));this.options.filter(option=>option.implied!==void 0&&hasCustomOptionValue(option.attributeName())&&dualHelper.valueFromOption(this.getOptionValue(option.attributeName()),option)).forEach(option=>{Object.keys(option.implied).filter(impliedKey=>!hasCustomOptionValue(impliedKey)).forEach(impliedKey=>{this.setOptionValueWithSource(impliedKey,option.implied[impliedKey],"implied");});});}missingArgument(name){let message=`error: missing required argument '${name}'`;this.error(message,{code:"commander.missingArgument"});}optionMissingArgument(option){let message=`error: option '${option.flags}' argument missing`;this.error(message,{code:"commander.optionMissingArgument"});}missingMandatoryOptionValue(option){let message=`error: required option '${option.flags}' not specified`;this.error(message,{code:"commander.missingMandatoryOptionValue"});}_conflictingOption(option,conflictingOption){let findBestOptionFromValue=option2=>{let optionKey=option2.attributeName(),optionValue=this.getOptionValue(optionKey),negativeOption=this.options.find(target=>target.negate&&optionKey===target.attributeName()),positiveOption=this.options.find(target=>!target.negate&&optionKey===target.attributeName());return negativeOption&&(negativeOption.presetArg===void 0&&optionValue===!1||negativeOption.presetArg!==void 0&&optionValue===negativeOption.presetArg)?negativeOption:positiveOption||option2},getErrorMessage=option2=>{let bestOption=findBestOptionFromValue(option2),optionKey=bestOption.attributeName();return this.getOptionValueSource(optionKey)==="env"?`environment variable '${bestOption.envVar}'`:`option '${bestOption.flags}'`},message=`error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;this.error(message,{code:"commander.conflictingOption"});}unknownOption(flag){if(this._allowUnknownOption)return;let suggestion="";if(flag.startsWith("--")&&this._showSuggestionAfterError){let candidateFlags=[],command=this;do{let moreFlags=command.createHelp().visibleOptions(command).filter(option=>option.long).map(option=>option.long);candidateFlags=candidateFlags.concat(moreFlags),command=command.parent;}while(command&&!command._enablePositionalOptions);suggestion=suggestSimilar(flag,candidateFlags);}let message=`error: unknown option '${flag}'${suggestion}`;this.error(message,{code:"commander.unknownOption"});}_excessArguments(receivedArgs){if(this._allowExcessArguments)return;let expected=this.registeredArguments.length,s=expected===1?"":"s",message=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;this.error(message,{code:"commander.excessArguments"});}unknownCommand(){let unknownName=this.args[0],suggestion="";if(this._showSuggestionAfterError){let candidateNames=[];this.createHelp().visibleCommands(this).forEach(command=>{candidateNames.push(command.name()),command.alias()&&candidateNames.push(command.alias());}),suggestion=suggestSimilar(unknownName,candidateNames);}let message=`error: unknown command '${unknownName}'${suggestion}`;this.error(message,{code:"commander.unknownCommand"});}version(str,flags,description){if(str===void 0)return this._version;this._version=str,flags=flags||"-V, --version",description=description||"output the version number";let versionOption=this.createOption(flags,description);return this._versionOptionName=versionOption.attributeName(),this._registerOption(versionOption),this.on("option:"+versionOption.name(),()=>{this._outputConfiguration.writeOut(`${str}
`),this._exit(0,"commander.version",str);}),this}description(str,argsDescription){return str===void 0&&argsDescription===void 0?this._description:(this._description=str,argsDescription&&(this._argsDescription=argsDescription),this)}summary(str){return str===void 0?this._summary:(this._summary=str,this)}alias(alias){if(alias===void 0)return this._aliases[0];let command=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(command=this.commands[this.commands.length-1]),alias===command._name)throw new Error("Command alias can't be the same as its name");let matchingCommand=this.parent?._findCommand(alias);if(matchingCommand){let existingCmd=[matchingCommand.name()].concat(matchingCommand.aliases()).join("|");throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`)}return command._aliases.push(alias),this}aliases(aliases){return aliases===void 0?this._aliases:(aliases.forEach(alias=>this.alias(alias)),this)}usage(str){if(str===void 0){if(this._usage)return this._usage;let args=this.registeredArguments.map(arg=>humanReadableArgName(arg));return [].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?args:[]).join(" ")}return this._usage=str,this}name(str){return str===void 0?this._name:(this._name=str,this)}nameFromFilename(filename){return this._name=path.basename(filename,path.extname(filename)),this}executableDir(path2){return path2===void 0?this._executableDir:(this._executableDir=path2,this)}helpInformation(contextOptions){let helper=this.createHelp();return helper.helpWidth===void 0&&(helper.helpWidth=contextOptions&&contextOptions.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),helper.formatHelp(this,helper)}_getHelpContext(contextOptions){contextOptions=contextOptions||{};let context={error:!!contextOptions.error},write;return context.error?write=arg=>this._outputConfiguration.writeErr(arg):write=arg=>this._outputConfiguration.writeOut(arg),context.write=contextOptions.write||write,context.command=this,context}outputHelp(contextOptions){let deprecatedCallback;typeof contextOptions=="function"&&(deprecatedCallback=contextOptions,contextOptions=void 0);let context=this._getHelpContext(contextOptions);this._getCommandAndAncestors().reverse().forEach(command=>command.emit("beforeAllHelp",context)),this.emit("beforeHelp",context);let helpInformation=this.helpInformation(context);if(deprecatedCallback&&(helpInformation=deprecatedCallback(helpInformation),typeof helpInformation!="string"&&!Buffer.isBuffer(helpInformation)))throw new Error("outputHelp callback must return a string or a Buffer");context.write(helpInformation),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",context),this._getCommandAndAncestors().forEach(command=>command.emit("afterAllHelp",context));}helpOption(flags,description){return typeof flags=="boolean"?(flags?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(flags=flags??"-h, --help",description=description??"display help for command",this._helpOption=this.createOption(flags,description),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(option){return this._helpOption=option,this}help(contextOptions){this.outputHelp(contextOptions);let exitCode=process2.exitCode||0;exitCode===0&&contextOptions&&typeof contextOptions!="function"&&contextOptions.error&&(exitCode=1),this._exit(exitCode,"commander.help","(outputHelp)");}addHelpText(position,text){let allowedValues=["beforeAll","before","after","afterAll"];if(!allowedValues.includes(position))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${allowedValues.join("', '")}'`);let helpEvent=`${position}Help`;return this.on(helpEvent,context=>{let helpStr;typeof text=="function"?helpStr=text({error:context.error,command:context.command}):helpStr=text,helpStr&&context.write(`${helpStr}
`);}),this}_outputHelpIfRequested(args){let helpOption=this._getHelpOption();helpOption&&args.find(arg=>helpOption.is(arg))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"));}};function incrementNodeInspectorPort(args){return args.map(arg=>{if(!arg.startsWith("--inspect"))return arg;let debugOption,debugHost="127.0.0.1",debugPort="9229",match;return (match=arg.match(/^(--inspect(-brk)?)$/))!==null?debugOption=match[1]:(match=arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(debugOption=match[1],/^\d+$/.test(match[3])?debugPort=match[3]:debugHost=match[3]):(match=arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(debugOption=match[1],debugHost=match[3],debugPort=match[4]),debugOption&&debugPort!=="0"?`${debugOption}=${debugHost}:${parseInt(debugPort)+1}`:arg})}exports.Command=Command2;}});var require_commander=__commonJS({"../../node_modules/commander/index.js"(exports){var{Argument:Argument2}=require_argument(),{Command:Command2}=require_command(),{CommanderError:CommanderError2,InvalidArgumentError:InvalidArgumentError2}=require_error(),{Help:Help2}=require_help(),{Option:Option2}=require_option();exports.program=new Command2;exports.createCommand=name=>new Command2(name);exports.createOption=(flags,description)=>new Option2(flags,description);exports.createArgument=(name,description)=>new Argument2(name,description);exports.Command=Command2;exports.Option=Option2;exports.Argument=Argument2;exports.Help=Help2;exports.CommanderError=CommanderError2;exports.InvalidArgumentError=InvalidArgumentError2;exports.InvalidOptionArgumentError=InvalidArgumentError2;}});var import_index=__toESM(require_commander(),1),{program,createCommand,createArgument,createOption,CommanderError,InvalidArgumentError,InvalidOptionArgumentError,Command,Argument,Option,Help}=import_index.default;var version="0.0.0-pr-30202-sha-35656f03";var IS_NON_CI=process.env.CI!=="true",IS_NON_STORYBOOK_SANDBOX=process.env.IN_STORYBOOK_SANDBOX!=="true";addToGlobalContext("cliVersion",version);var createStorybookProgram=program.name("Initialize Storybook into your project.").option("--disable-telemetry","Disable sending telemetry data",process.env.STORYBOOK_DISABLE_TELEMETRY&&process.env.STORYBOOK_DISABLE_TELEMETRY!=="false").option("--intents <...list>","What features of storybook are you interested in?").option("--debug","Get more logs in debug mode").option("--enable-crash-reports","Enable sending crash reports to telemetry data").option("-f --force","Force add Storybook").option("-s --skip-install","Skip installing deps").option("--package-manager <npm|pnpm|yarn1|yarn2|bun>","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)").option("--dev","Launch the development server after completing initialization. Enabled by default").option("--no-dev","Complete the initialization of Storybook without launching the Storybook development server");createStorybookProgram.action(async options=>{options.debug=options.debug??!1,options.dev=options.dev??(IS_NON_CI&&IS_NON_STORYBOOK_SANDBOX),await initiate(options).catch(()=>process.exit(1));}).version(String(version)).parse(process.argv);

5

dist/index.d.ts

@@ -1,3 +0,3 @@

import { ProjectType, Builder } from 'storybook/internal/cli';
import { PackageManagerName, JsPackageManager } from 'storybook/internal/common';
import { ProjectType, Builder } from '@storybook/core/cli';
import { PackageManagerName, JsPackageManager } from '@storybook/core/common';

@@ -7,2 +7,3 @@ type CommandOptions = {

usePnp?: boolean;
intents: string[];
type?: ProjectType;

@@ -9,0 +10,0 @@ force?: any;

@@ -1,1 +0,8 @@

export { doInitiate as initiate } from './chunk-BXPKU4GR.js';
import ESM_COMPAT_Module from 'node:module';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
export { doInitiate as initiate } from './chunk-I6NEWYLK.js';
const __filename = fileURLToPath(import.meta.url);
dirname(__filename);
ESM_COMPAT_Module.createRequire(import.meta.url);
{
"name": "create-storybook",
"version": "0.0.0-pr-30197-sha-a3d613d5",
"version": "0.0.0-pr-30202-sha-35656f03",
"description": "Initialize Storybook into your project",

@@ -24,10 +24,5 @@ "homepage": "https://github.com/storybookjs/storybook/tree/next/code/lib/create-storybook",

"types": "./dist/index.d.ts",
"node": "./dist/index.cjs",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"import": "./dist/index.js"
},
"./bin/index.cjs": {
"node": "./bin/index.cjs",
"require": "./bin/index.cjs"
},
"./bin/index.cjs": "./bin/index.cjs",
"./package.json": "./package.json"

@@ -59,22 +54,26 @@ },

"dependencies": {
"@storybook/core": "0.0.0-pr-30202-sha-35656f03"
},
"devDependencies": {
"@types/prompts": "^2.0.9",
"@types/semver": "^7.3.4",
"@types/util-deprecate": "^1.0.0",
"boxen": "^7.1.1",
"commander": "^12.1.0",
"es-toolkit": "^1.22.0",
"execa": "^5.0.0",
"fast-glob": "^3.3.3",
"fd-package-json": "^1.2.0",
"find-up": "^5.0.0",
"find-up": "^7.0.0",
"ora": "^5.4.1",
"prettier": "^3.1.1",
"picocolors": "^1.1.0",
"prompts": "^2.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"semver": "^7.3.7",
"storybook": "0.0.0-pr-30197-sha-a3d613d5",
"tiny-invariant": "^1.3.1",
"ts-dedent": "^2.0.0"
"ts-dedent": "^2.0.0",
"typescript": "^5.7.3",
"zod": "^3.24.1"
},
"devDependencies": {
"@types/prompts": "^2.0.9",
"@types/util-deprecate": "^1.0.0",
"boxen": "^7.1.1",
"picocolors": "^1.1.0",
"typescript": "^5.3.2"
},
"publishConfig": {

@@ -88,5 +87,7 @@ "access": "public"

],
"platform": "node"
"formats": [
"node-esm"
]
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc