@visulima/cerebro 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/cli.ts","../../../node_modules/.pnpm/camelcase@8.0.0/node_modules/camelcase/index.js","../src/command/help.ts","../src/default-options.ts","../src/util/command-line-usage/index.ts","../src/util/command-line-usage/section/content-section.ts","../src/util/template-format.ts","../src/util/command-line-usage/section/base-section.ts","../src/util/command-line-usage/section/option-list-section.ts","../src/command/version.ts","../src/constants.ts","../src/empty-toolbox.ts","../src/util/check-node-version.ts","../src/util/command-line-args/get-boolean-values.ts","../src/util/command-line-args/get-parameter-option.ts","../src/util/command-line-args/option-is-boolean.ts","../src/util/command-line-args/map-option-type-label.ts","../src/util/command-line-args/remove-boolean-values.ts","../src/util/command-line-commands.ts","../src/util/levenstein.ts","../src/util/list-missing-arguments.ts","../src/util/merge-arguments.ts","../src/util/parse-raw-command.ts","../src/util/hide-bin.ts","../src/util/register-exception-handler.ts"],"names":["init_esm_shims","process_argv","process_cwd","env","execArgv","execPath","exit","boxen","dim","green","reset","yellow","createPail","UPPERCASE","LOWERCASE","LEADING_CAPITAL","IDENTIFIER","SEPARATORS","LEADING_SEPARATORS","SEPARATORS_AND_IDENTIFIER","NUMBERS_AND_IDENTIFIER","preserveCamelCase","string","toLowerCase","toUpperCase","preserveConsecutiveUppercase","isLastCharLower","isLastCharUpper","isLastLastCharUpper","isLastLastCharPreserved","index","character","input","match","postProcess","pattern","offset","_","identifier","camelCase","options","x","commandLineArgs","defaultOptions","default_options_default","CliTable3","template","templateFormat","string_","template_format_default","os","bold","BaseSection","line","text","base_section_default","defaultTableOptions","ContentSection","section","value","row","cell","content","table","contentObject","content_section_default","OptionListSection","data","definitions","hide","groups","definition","noGroupMatch","groupMatch","reverseNameOrder","isArgument","type","multiple","result","name","array1","array2","item1","option_list_section_default","commandLineUsage","sections","command_line_usage_default","EMPTY_GROUP_KEY","upperFirstChar","printGeneralHelp","logger","runtime","commands","groupOption","filteredCommands","command","groupedCommands","accumulator","group","key","aliases","option","printCommandHelp","usageGroups","alias","HelpCommand","toolbox","commandName","footer","header","help_default","version_default","version","POSITIONALS_KEY","EmptyToolbox","empty_toolbox_default","checkNodeVersion","minNodeVersion","nodeVersion","check_node_version_default","argumentNameRegExp","getParameterOption","argument","regExpResult","nameOrAlias","o","get_parameter_option_default","isBoolean","option_is_boolean_default","convertType","booleanValue","getBooleanValues","arguments_","getBooleanValue","argumentsAndLastOption","argName","argValue","lastOption","get_boolean_values_default","getTypeLabel","typeLabel","mapOptionTypeLabel","map_option_type_label_default","removeBooleanValues","removeBooleanArguments","argumentsAndLastValue","copiedArguments_","remove_boolean_values_default","isShort","isLong","isCombined","isOption","commandLineCommands","argv","error","command_line_commands_default","distance","isSimilar","string1","string2","findAlternatives","array","id","nextId","levenstein_default","listMissingArguments","commandLineConfig","parsedArguments","config","list_missing_arguments_default","mergeArguments","argumentLists","argumentsByName","merge_arguments_default","isElectronApp","isBundledElectronApp","getProcessArgvBinIndex","hideBin","hide_bin_default","COMMAND_DELIMITER","equals","a","b","v","parseRawCommand","commandArray","parse_raw_command_default","registerExceptionHandler","register_exception_handler_default","isCI","lowerFirstChar","Cli","cliName","cwd","packageName","packageVersion","cerebroLevelToPailLevel","commandSection","extension","configKeys","extraOptions","shouldExitProcess","otherExtraOptions","commandNames","alternatives","foundAlternatives","commandArguments","parsedArgs","booleanValues","commandArgs","_all","positionals","groupedDuplicatedOption","object","duplicatedOptions","errorMessages","matchingOption","duplicate","flag","helpCommand","updateAvailable","m","border","missingOptions","errors","unknownOption","first","rest","alternative","conflicts","conflict","c","negatedOption","callback","nonNegatedKey","optionKey","implies","impliedOption","cOption"],"mappings":"wCAAAA,ICAAA,IAAA,OAAS,QAAQC,GAAc,OAAOC,GAAa,OAAAC,EAAK,YAAAC,GAAU,YAAAC,GAAU,QAAAC,MA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AaA,EAAE,UAAY,MAC7F,EAEA,GAAIxB,GAAQ,QAAS,CACjB,IAAMuI,EAAUvI,EAAO,QAEvB,OAAO,QAAQuI,CAAO,EAAE,QAAQ,CAAC,CAACzI,EAAKxC,CAAK,IAAM,CAE9C,GAAI+C,EAAQ,QAAQP,CAAG,IAAM,OAEzBO,EAAQ,QAAQP,CAAG,EAAIxC,MACpB,CACH,IAAMkL,EAAgB9I,EAAQ,SAAS,KAAM+I,GAAYA,EAAQ,OAAS3I,CAAG,GAGzE0I,GAAe,eAAiB,QAAanI,EAAQ,QAAQP,CAAG,IAAM0I,EAAc,gBAEpFnI,EAAQ,QAAQP,CAAG,EAAIxC,EAE/B,CACJ,CAAC,CACL,CACJ,CAAC,CACL,CACJ","sourcesContent":["// TODO: Uncomment this in the next major release\n// import type { CliOptions } from \"./cli\";\n// import { Cli as Cerebro } from \"./cli\";\n\n// eslint-disable-next-line @typescript-eslint/no-namespace,@typescript-eslint/no-unused-vars\ndeclare namespace NodeJS {\n interface ProcessEnvironment {\n CEREBRO_MIN_NODE_VERSION?: string;\n CEREBRO_OUTPUT_LEVEL: VERBOSITY_LEVEL;\n }\n}\n\nexport type { Cli } from \"./@types/cli\";\nexport type { ArgumentDefinition, Command, OptionDefinition } from \"./@types/command\";\nexport type { Extension } from \"./@types/extension\";\nexport type { Toolbox } from \"./@types/toolbox\";\nexport type { CliOptions } from \"./cli\";\n\n/**\n * Any of the output types [[OUTPUT_NORMAL]], [[OUTPUT_RAW]] and [[OUTPUT_PLAIN]].\n */\nexport type OutputType = 1 | 2 | 4;\n\n/**\n * Any of the verbosity types\n * [[VERBOSITY_QUIET]], [[VERBOSITY_NORMAL]], [[VERBOSITY_VERBOSE]] and [[VERBOSITY_DEBUG]].\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;\n\nexport { Cli as default } from \"./cli\";\n// TODO: Uncomment this in the next major release\n// export const createCerebro = (name: string, options: CliOptions): Cerebro => new Cerebro(name, options);\n","import { argv as process_argv, cwd as process_cwd, env, execArgv, execPath, exit } from \"node:process\";\n\nimport { boxen } from \"@visulima/boxen\";\nimport { dim, green, reset, yellow } from \"@visulima/colorize\";\nimport type { ConstructorOptions, Pail } from \"@visulima/pail/server\";\nimport { createPail } from \"@visulima/pail/server\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport camelCase from \"camelcase\";\nimport type { CommandLineOptions } from \"command-line-args\";\nimport commandLineArgs from \"command-line-args\";\n\nimport type {\n Cli as ICli,\n Command as ICommand,\n CommandSection as ICommandSection,\n Extension as IExtension,\n Options as IOptions,\n Toolbox as IToolbox,\n} from \"./@types\";\nimport type { CliRunOptions } from \"./@types/cli\";\nimport type { OptionDefinition, PossibleOptionDefinition } from \"./@types/command\";\nimport HelpCommand from \"./command/help\";\nimport VersionCommand from \"./command/version\";\nimport { POSITIONALS_KEY, VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE } from \"./constants\";\nimport defaultOptions from \"./default-options\";\nimport EmptyToolbox from \"./empty-toolbox\";\nimport type { UpdateNotifierOptions } from \"./update-notifier/has-new-version\";\nimport checkNodeVersion from \"./util/check-node-version\";\nimport getBooleanValues from \"./util/command-line-args/get-boolean-values\";\nimport mapOptionTypeLabel from \"./util/command-line-args/map-option-type-label\";\nimport removeBooleanValues from \"./util/command-line-args/remove-boolean-values\";\nimport commandLineCommands from \"./util/command-line-commands\";\nimport findAlternatives from \"./util/levenstein\";\nimport listMissingArguments from \"./util/list-missing-arguments\";\nimport mergeArguments from \"./util/merge-arguments\";\nimport parseRawCommand from \"./util/parse-raw-command\";\nimport registerExceptionHandler from \"./util/register-exception-handler\";\n\n/** Detect if `CI` environment variable is set */\nconst isCI = \"CI\" in env && (\"GITHUB_ACTIONS\" in env || \"GITLAB_CI\" in env || \"CIRCLECI\" in env);\n\nconst lowerFirstChar = (string_: string): string => string_.charAt(0).toLowerCase() + string_.slice(1);\n\nexport type CliOptions = {\n argv?: string[];\n cwd?: string;\n logger?: ConstructorOptions<string, string>;\n packageName?: string;\n packageVersion?: string;\n};\n\nexport class Cli implements ICli {\n private readonly logger: Pail<never, string>;\n\n private readonly argv: string[];\n\n private readonly cwd: string;\n\n private readonly cliName: string;\n\n private readonly packageVersion: string | undefined;\n\n private readonly packageName: string | undefined;\n\n private readonly extensions: IExtension[] = [];\n\n private readonly commands: Map<string, ICommand>;\n\n private defaultCommand: string;\n\n private updateNotifierOptions: UpdateNotifierOptions | undefined;\n\n private commandSection: ICommandSection;\n\n /**\n * @param cliName The cli cliName.\n * @param options The options for the CLI.\n * - argv This should be in the base case process.argv\n * - cwd The path of main folder.\n * - packageName The packageJson name.\n * - packageVersion The packageJson version.\n */\n public constructor(cliName: string, options: CliOptions = {}) {\n const { argv, cwd, packageName, packageVersion } = {\n argv: process_argv,\n cwd: process_cwd(),\n ...options,\n };\n\n this.argv = parseRawCommand(argv);\n\n // If the \"--quiet\"/\"-q\" flag is ever present, set our global logging\n // to quiet mode. Also set the level on the logger we've already created.\n if (this.argv.includes(\"--quiet\") || this.argv.includes(\"-q\")) {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_QUIET);\n\n // If the \"--verbose\"/\"-v\" flag is ever present, set our global logging\n // to verbose mode. Also set the level on the logger we've already created.\n } else if (this.argv.includes(\"--verbose\") || this.argv.includes(\"-v\")) {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_VERBOSE);\n } else if (this.argv.includes(\"--debug\") || this.argv.includes(\"-vvv\") || \"DEBUG\" in env) {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_DEBUG);\n } else {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_NORMAL);\n }\n\n const cerebroLevelToPailLevel: Record<string, string> = {\n \"32\": \"informational\",\n \"64\": \"trace\",\n \"128\": \"debug\",\n };\n\n this.logger = createPail({\n logLevel: env.CEREBRO_OUTPUT_LEVEL\n ? cerebroLevelToPailLevel[env.CEREBRO_OUTPUT_LEVEL as keyof typeof cerebroLevelToPailLevel] ?? \"informational\"\n : \"informational\",\n ...options.logger,\n });\n\n if (env.CEREBRO_OUTPUT_LEVEL === String(VERBOSITY_QUIET)) {\n this.logger.disable();\n }\n\n checkNodeVersion();\n registerExceptionHandler(this.logger);\n\n this.cliName = cliName;\n this.packageVersion = packageVersion;\n this.packageName = packageName;\n this.cwd = cwd;\n this.defaultCommand = \"help\";\n this.commandSection = {\n header: `${this.cliName}${this.packageVersion ? ` v${this.packageVersion}` : \"\"}`,\n };\n\n this.commands = new Map<string, ICommand>();\n\n this.addCoreExtensions();\n\n this.addCommand(VersionCommand);\n this.addCommand(new HelpCommand(this.commands));\n }\n\n public setCommandSection(commandSection: ICommandSection): this {\n this.commandSection = commandSection;\n\n return this;\n }\n\n public getCommandSection(): ICommandSection {\n return this.commandSection;\n }\n\n /**\n * Set a default command, to display a different command if cli is call without command.\n */\n public setDefaultCommand(commandName: string): this {\n this.defaultCommand = commandName;\n\n return this;\n }\n\n /**\n * Add an arbitrary command to the CLI.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public addCommand<OT = any>(command: ICommand<OT>): this {\n // add the command to the runtime (if it isn't already there)\n\n if (this.commands.has(command.name)) {\n throw new Error(`Ignored command with name \"${command.name}, it was found in the command list.\"`);\n } else {\n command.options?.map((option) => mapOptionTypeLabel<OT>(option));\n\n this.validateDoubleOptions<OT>(command);\n this.addNegatableOption<OT>(command);\n\n command.options?.forEach((option) => {\n // eslint-disable-next-line no-underscore-dangle,no-param-reassign\n option.__camelCaseName__ = camelCase(option.name);\n });\n\n this.commands.set(command.name, command);\n\n if (command.alias !== undefined) {\n let aliases: string[] = command.alias as string[];\n\n if (typeof command.alias === \"string\") {\n aliases = [command.alias];\n }\n\n aliases.forEach((alias) => {\n this.logger.debug(\"adding alias\", alias);\n\n if (this.commands.has(alias)) {\n throw new Error(`Ignoring command alias \"${alias}, command with the same name was found.\"`);\n } else {\n this.commands.set(alias, command);\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Adds an extension so it is available when commands execute. They usually live\n * the given name on the toolbox object passed to commands, but are able\n * to manipulate the toolbox object however they want.\n */\n public addExtension(extension: IExtension): this {\n this.extensions.push(extension);\n\n return this;\n }\n\n /**\n * Enable the update notifier functionality with the given options.\n *\n * @param options - The options for enabling the update notifier.\n * options.alwaysRun - Determines whether the update check should always run. Defaults to false.\n * options.distributionTag - The distribution tag to use for checking updates. Defaults to \"latest\".\n * options.updateCheckInterval - The interval in milliseconds between each update check. Defaults to 24 hours.\n *\n * @example\n * enableUpdateNotifier({\n * alwaysRun: true,\n * debug: false,\n * distributionTag: \"stable\",\n * pkg: {\n * name: \"my-package\",\n * version: \"1.0.0\"\n * },\n * updateCheckInterval: 1000 * 60 * 60\n * });\n */\n public enableUpdateNotifier(options: Partial<Omit<UpdateNotifierOptions, \"debug | pkg\">> = {}): this {\n if (!this.packageName || !this.packageVersion) {\n throw new Error(\"Cannot enable update notifier without package name and version.\");\n }\n\n const configKeys = Object.keys(options);\n\n if (configKeys.length > 0 && !configKeys.includes(\"alwaysRun\") && !configKeys.includes(\"distTag\") && !configKeys.includes(\"updateCheckInterval\")) {\n throw new Error(\"Invalid update notifier options, please check the documentation.\");\n }\n\n this.updateNotifierOptions = {\n alwaysRun: false,\n debug: env.CEREBRO_OUTPUT_LEVEL === String(VERBOSITY_DEBUG),\n distTag: \"latest\",\n pkg: {\n name: this.packageName,\n version: this.packageVersion,\n },\n updateCheckInterval: 1000 * 60 * 60 * 24,\n ...options,\n };\n\n return this;\n }\n\n public getCliName(): string {\n return this.cliName;\n }\n\n public getPackageVersion(): string | undefined {\n return this.packageVersion;\n }\n\n public getPackageName(): string | undefined {\n return this.packageName;\n }\n\n public getCommands(): Map<string, ICommand> {\n return this.commands;\n }\n\n public getCwd(): string {\n return this.cwd;\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public async run(extraOptions: CliRunOptions = {}): Promise<void> {\n const { shouldExitProcess = true, ...otherExtraOptions } = extraOptions;\n\n const commandNames = [...this.commands.keys()];\n\n let parsedArguments: { argv: string[]; command: string | null | undefined };\n\n this.logger.debug(`process.execPath: ${execPath}`);\n this.logger.debug(`process.execArgv: ${execArgv.join(\" \")}`);\n this.logger.debug(`process.argv: ${process_argv.join(\" \")}`);\n\n try {\n parsedArguments = commandLineCommands([null, ...commandNames], this.argv);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // CLI needs a valid command name to do anything. If the given\n // command is invalid, run the generalized help command with default\n // config. This should print the general usage information.\n if (error.name === \"INVALID_COMMAND\" && error.command) {\n let alternatives = \"\";\n\n const foundAlternatives = findAlternatives(error.command, [...this.commands.keys()]);\n\n if (foundAlternatives.length > 0) {\n alternatives = ` Did you mean: \\r\\n - ${foundAlternatives.join(\" \\r\\n- \")}`;\n }\n\n this.logger.error(`\"${error.command}\" is not an available command.${alternatives}`);\n } else {\n this.logger.error(error as object);\n }\n\n return shouldExitProcess ? exit(1) : undefined;\n }\n\n const commandName = parsedArguments.command ?? this.defaultCommand;\n const command = this.commands.get(commandName) as ICommand;\n\n if (typeof command.execute !== \"function\") {\n this.logger.error(`Command \"${command.name}\" has no function to execute.`);\n\n return shouldExitProcess ? exit(1) : undefined;\n }\n\n const commandArguments = parsedArguments.argv;\n\n this.logger.debug(`command '${commandName}' found, parsing command args: ${commandArguments.join(\", \")}`);\n\n // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\n let arguments_ = mergeArguments([...(command.options ?? []), ...defaultOptions]);\n\n arguments_.forEach((argument) => {\n if (argument.multiple && argument.lazyMultiple) {\n throw new Error(`Argument \"${argument.name}\" cannot have both multiple and lazyMultiple options, please choose one.`);\n }\n });\n\n if (command.argument) {\n this.logger.debug(\"command has positional argument, parsing them...\");\n\n arguments_ = [\n {\n defaultOption: true,\n\n description: command.argument?.description,\n group: \"positionals\",\n multiple: true,\n name: POSITIONALS_KEY,\n\n type: command.argument?.type,\n\n typeLabel: command.argument?.typeLabel,\n },\n ...arguments_,\n ];\n }\n\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const parsedArgs = commandLineArgs(arguments_, {\n argv: removeBooleanValues(commandArguments, command.options ?? []),\n camelCase: true,\n partial: true,\n stopAtFirstUnknown: true,\n });\n\n const booleanValues = getBooleanValues(commandArguments, command.options ?? []);\n\n // eslint-disable-next-line unicorn/prevent-abbreviations,no-underscore-dangle\n const commandArgs = { ...parsedArgs, _all: { ...parsedArgs._all, ...booleanValues } } as typeof parsedArgs;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.validateCommandOptions<any>(arguments_, commandArgs, command);\n\n // prepare the execute toolbox\n const toolbox = new EmptyToolbox(command.name, command);\n\n // attach the runtime\n toolbox.runtime = this as ICli;\n\n // allow extensions to attach themselves to the toolbox\n await this.registerExtensions(toolbox as IToolbox);\n\n await this.updateNotifier(toolbox as IToolbox);\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { _all, positionals } = commandArgs;\n\n // eslint-disable-next-line security/detect-object-injection\n if (_all[POSITIONALS_KEY]) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete,security/detect-object-injection\n delete _all[POSITIONALS_KEY];\n }\n\n // eslint-disable-next-line security/detect-object-injection\n toolbox.argument = positionals?.[POSITIONALS_KEY] ?? [];\n toolbox.argv = this.argv;\n toolbox.options = { ..._all, ...otherExtraOptions };\n\n this.mapNegatableOptions(toolbox as IToolbox, command);\n this.mapImpliesOptions(toolbox as IToolbox, command);\n\n this.validateCommandArgsForConflicts(arguments_, toolbox.options as IToolbox[\"options\"], command);\n\n this.logger.debug(\"command options parsed from options:\");\n this.logger.debug(JSON.stringify(toolbox.options, null, 2));\n this.logger.debug(\"command argument parsed from argument:\");\n this.logger.debug(JSON.stringify(toolbox.argument, null, 2));\n\n await this.prepareToolboxResult(commandArgs, toolbox as IToolbox, command);\n\n return shouldExitProcess ? exit(0) : undefined;\n }\n\n // eslint-disable-next-line class-methods-use-this\n private validateDoubleOptions<OT>(command: ICommand): void {\n if (Array.isArray(command.options)) {\n // eslint-disable-next-line unicorn/no-array-reduce\n const groupedDuplicatedOption = command.options.reduce<Record<string, OptionDefinition<OT>[]>>((accumulator, object) => {\n const key = `${object.name}-${object.alias}`;\n\n // eslint-disable-next-line security/detect-object-injection\n if (!accumulator[key]) {\n // eslint-disable-next-line security/detect-object-injection\n accumulator[key] = [];\n }\n\n // eslint-disable-next-line security/detect-object-injection\n (accumulator[key] as OptionDefinition<OT>[]).push(object as OptionDefinition<OT>);\n\n return accumulator;\n }, {});\n const duplicatedOptions = Object.values(groupedDuplicatedOption).filter((object) => object.length > 1);\n\n let errorMessages = \"\";\n\n duplicatedOptions.forEach((options) => {\n const matchingOption = options[0] as OptionDefinition<OT>;\n const duplicate = options[1] as OptionDefinition<OT>;\n\n let flag = \"alias\";\n\n if (matchingOption.name === duplicate.name) {\n flag = \"name\";\n\n if (matchingOption.alias === duplicate.alias) {\n flag += \" and alias\";\n }\n }\n\n errorMessages += `Cannot add option ${flag} \"${JSON.stringify(duplicate)}\" to command \"${\n command.name\n }\" due to conflicting option ${JSON.stringify(matchingOption)}\\n`;\n });\n\n if (errorMessages.length > 0) {\n throw new Error(errorMessages);\n }\n }\n }\n\n /**\n * Adds the core extensions. These provide the basic features\n * available in cerebro.\n */\n private addCoreExtensions() {\n this.addExtension({\n execute: (toolbox: IToolbox) => {\n // eslint-disable-next-line no-param-reassign\n toolbox.logger = this.logger;\n },\n name: \"logger\",\n });\n }\n\n // eslint-disable-next-line unicorn/prevent-abbreviations\n private async prepareToolboxResult(commandArgs: CommandLineOptions, toolbox: IToolbox, command: ICommand) {\n // Help is a special argument for displaying help for the given command.\n // If found, run the help command instead, with the given command name as\n // an option.\n if (commandArgs.global?.help) {\n this.logger.debug(\"'--help' option found, running 'help' for given command...\");\n const helpCommand = this.commands.get(\"help\");\n\n if (!helpCommand) {\n throw new Error(\"Help command not found.\");\n }\n\n await helpCommand.execute(toolbox);\n\n return;\n }\n\n if (commandArgs.global?.version || commandArgs.global?.V) {\n this.logger.debug(\"'--version' option found, running 'version' for given command...\");\n const helpCommand = this.commands.get(\"version\");\n\n if (!helpCommand) {\n throw new Error(\"Version command not found.\");\n }\n\n await helpCommand.execute(toolbox);\n\n return;\n }\n\n await command.execute(toolbox);\n }\n\n private async updateNotifier({ logger }: IToolbox) {\n if (\n (this.updateNotifierOptions && this.updateNotifierOptions.alwaysRun) ||\n (!(env.NO_UPDATE_NOTIFIER || env.NODE_ENV === \"test\" || this.argv.includes(\"--no-update-notifier\") || isCI) && this.updateNotifierOptions)\n ) {\n // @TODO add a stream logger\n logger.raw(\"Checking for updates...\");\n\n const hasNewVersion = await import(\"./update-notifier/has-new-version\").then((m) => m.default);\n\n const updateAvailable = await hasNewVersion(this.updateNotifierOptions);\n\n if (updateAvailable) {\n const template = \"Update available \" + dim(this.packageVersion + \"\") + reset(\" → \") + green(updateAvailable);\n\n this.logger.error(\n boxen(template, {\n borderColor: (border: string) => yellow(border),\n borderStyle: \"round\",\n margin: 1,\n padding: 1,\n textAlignment: \"center\",\n }),\n );\n }\n }\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,unicorn/prevent-abbreviations,class-methods-use-this\n private validateCommandOptions<T>(arguments_: PossibleOptionDefinition<T>[], commandArgs: CommandLineOptions, command: ICommand): void {\n const missingOptions = listMissingArguments(arguments_, commandArgs);\n\n if (missingOptions.length > 0) {\n throw new Error(\n `You called the command \"${command.name}\" without the required options: ${missingOptions.map((argument) => argument.name).join(\", \")}`,\n );\n }\n\n // eslint-disable-next-line no-underscore-dangle\n if (commandArgs._unknown && commandArgs._unknown.length > 0) {\n const errors: string[] = [];\n\n // eslint-disable-next-line no-underscore-dangle\n commandArgs._unknown.forEach((unknownOption) => {\n const isOption = unknownOption.startsWith(\"--\");\n\n let error = `Found unknown ${isOption ? \"option\" : \"argument\"} \"${unknownOption}\"`;\n\n if (isOption) {\n const foundAlternatives = findAlternatives(unknownOption.replace(\"--\", \"\"), [\n ...(command.options ?? []).map((option) => option.name),\n ...defaultOptions.map((option) => option.name),\n ]);\n\n if (foundAlternatives.length > 0) {\n const [first, ...rest] = foundAlternatives.map((alternative) => `--${alternative}`);\n\n error += rest.length > 0 ? `, did you mean ${first} or ${rest.join(\", \")}?` : `, did you mean ${first}?`;\n }\n }\n\n errors.push(error);\n });\n\n if (errors.length > 0) {\n // eslint-disable-next-line unicorn/error-message\n throw new Error(errors.join(\"\\n\"));\n }\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private validateCommandArgsForConflicts<T>(arguments_: PossibleOptionDefinition<T>[], commandArguments: IToolbox[\"options\"], command: ICommand): void {\n const conflicts = arguments_.filter((argument) => argument.conflicts !== undefined);\n\n if (conflicts.length > 0) {\n const conflict = conflicts.find((argument) => {\n if (Array.isArray(argument.conflicts)) {\n // eslint-disable-next-line security/detect-object-injection\n return argument.conflicts.some((c) => commandArguments[c] !== undefined);\n }\n\n return commandArguments[argument.conflicts as string] !== undefined;\n });\n\n if (conflict) {\n throw new Error(\n `You called the command \"${command.name}\" with conflicting options: ${conflict.name} and ${\n typeof conflict.conflicts === \"string\" ? conflict.conflicts : conflict.conflicts?.join(\", \")\n }`,\n );\n }\n }\n }\n\n private addNegatableOption<OT>(command: ICommand): void {\n if (Array.isArray(command.options)) {\n command.options.forEach((option) => {\n if (option.name.startsWith(\"no-\") && !(command.options as OptionDefinition<OT>[]).some((o) => o.name === option.name.replace(\"no-\", \"\"))) {\n if (option.type !== Boolean) {\n this.logger.debug(`Cannot add negated option \"${option.name}\" to command \"${command.name}\" because it is not a boolean.`);\n\n return;\n }\n\n const negatedOption = {\n ...option,\n defaultValue: option.defaultValue === undefined ? true : !option.defaultValue,\n name: `${option.name.replace(\"no-\", \"\")}`,\n } as OptionDefinition<OT>;\n\n (command.options as OptionDefinition<OT>[]).push(negatedOption);\n }\n });\n }\n }\n\n private async registerExtensions(toolbox: IToolbox): Promise<void> {\n const callback = async (extension: IExtension) => {\n if (typeof extension.execute !== \"function\") {\n this.logger.warn(`Skipped ${extension.name} because execute is not a function.`);\n\n return null;\n }\n\n await extension.execute(toolbox as IToolbox);\n\n return null;\n };\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const extension of this.extensions) {\n // eslint-disable-next-line no-await-in-loop\n await callback(extension);\n }\n }\n\n // combining negatable options with their non-negated counterparts\n\n private mapNegatableOptions(toolbox: IToolbox, command: ICommand): void {\n Object.entries(toolbox.options as IToolbox[\"options\"]).forEach(([key, value]) => {\n if (/^no\\w+/.test(key)) {\n const nonNegatedKey: string = lowerFirstChar(key.replace(\"no\", \"\"));\n\n this.logger.debug(`mapping negated option \"${key}\" to \"${nonNegatedKey}\"`);\n\n // eslint-disable-next-line security/detect-object-injection,no-param-reassign\n (toolbox.options as IOptions[\"options\"])[nonNegatedKey] = !value;\n\n command.options?.forEach((option) => {\n if (option.name === nonNegatedKey) {\n // eslint-disable-next-line no-underscore-dangle,no-param-reassign\n option.__negated__ = true;\n }\n });\n }\n });\n }\n\n // Apply any implied option values, if option is undefined or default value.\n // eslint-disable-next-line class-methods-use-this\n private mapImpliesOptions(toolbox: IToolbox, command: ICommand): void {\n Object.keys(toolbox.options as IToolbox[\"options\"]).forEach((optionKey) => {\n const option = command.options?.find(\n // eslint-disable-next-line no-underscore-dangle\n (o) => o.__camelCaseName__ === optionKey && o.__negated__ === undefined && o.implies !== undefined,\n );\n\n if (option?.implies) {\n const implies = option.implies as Record<string, unknown>;\n\n Object.entries(implies).forEach(([key, value]) => {\n // eslint-disable-next-line security/detect-object-injection\n if (toolbox.options[key] === undefined) {\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n toolbox.options[key] = value;\n } else {\n const impliedOption = command.options?.find((cOption) => cOption.name === key);\n\n // eslint-disable-next-line security/detect-object-injection\n if (impliedOption?.defaultValue === undefined || toolbox.options[key] === impliedOption.defaultValue) {\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n toolbox.options[key] = value;\n }\n }\n });\n }\n });\n }\n}\n","const UPPERCASE = /[\\p{Lu}]/u;\nconst LOWERCASE = /[\\p{Ll}]/u;\nconst LEADING_CAPITAL = /^[\\p{Lu}](?![\\p{Lu}])/gu;\nconst IDENTIFIER = /([\\p{Alpha}\\p{N}_]|$)/u;\nconst SEPARATORS = /[_.\\- ]+/;\n\nconst LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);\nconst SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');\nconst NUMBERS_AND_IDENTIFIER = new RegExp('\\\\d+' + IDENTIFIER.source, 'gu');\n\nconst preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase) => {\n\tlet isLastCharLower = false;\n\tlet isLastCharUpper = false;\n\tlet isLastLastCharUpper = false;\n\tlet isLastLastCharPreserved = false;\n\n\tfor (let index = 0; index < string.length; index++) {\n\t\tconst character = string[index];\n\t\tisLastLastCharPreserved = index > 2 ? string[index - 3] === '-' : true;\n\n\t\tif (isLastCharLower && UPPERCASE.test(character)) {\n\t\t\tstring = string.slice(0, index) + '-' + string.slice(index);\n\t\t\tisLastCharLower = false;\n\t\t\tisLastLastCharUpper = isLastCharUpper;\n\t\t\tisLastCharUpper = true;\n\t\t\tindex++;\n\t\t} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase)) {\n\t\t\tstring = string.slice(0, index - 1) + '-' + string.slice(index - 1);\n\t\t\tisLastLastCharUpper = isLastCharUpper;\n\t\t\tisLastCharUpper = false;\n\t\t\tisLastCharLower = true;\n\t\t} else {\n\t\t\tisLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;\n\t\t\tisLastLastCharUpper = isLastCharUpper;\n\t\t\tisLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;\n\t\t}\n\t}\n\n\treturn string;\n};\n\nconst preserveConsecutiveUppercase = (input, toLowerCase) => {\n\tLEADING_CAPITAL.lastIndex = 0;\n\n\treturn input.replaceAll(LEADING_CAPITAL, match => toLowerCase(match));\n};\n\nconst postProcess = (input, toUpperCase) => {\n\tSEPARATORS_AND_IDENTIFIER.lastIndex = 0;\n\tNUMBERS_AND_IDENTIFIER.lastIndex = 0;\n\n\treturn input\n\t\t.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))\n\t\t.replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));\n};\n\nexport default function camelCase(input, options) {\n\tif (!(typeof input === 'string' || Array.isArray(input))) {\n\t\tthrow new TypeError('Expected the input to be `string | string[]`');\n\t}\n\n\toptions = {\n\t\tpascalCase: false,\n\t\tpreserveConsecutiveUppercase: false,\n\t\t...options,\n\t};\n\n\tif (Array.isArray(input)) {\n\t\tinput = input.map(x => x.trim())\n\t\t\t.filter(x => x.length)\n\t\t\t.join('-');\n\t} else {\n\t\tinput = input.trim();\n\t}\n\n\tif (input.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst toLowerCase = options.locale === false\n\t\t? string => string.toLowerCase()\n\t\t: string => string.toLocaleLowerCase(options.locale);\n\n\tconst toUpperCase = options.locale === false\n\t\t? string => string.toUpperCase()\n\t\t: string => string.toLocaleUpperCase(options.locale);\n\n\tif (input.length === 1) {\n\t\tif (SEPARATORS.test(input)) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn options.pascalCase ? toUpperCase(input) : toLowerCase(input);\n\t}\n\n\tconst hasUpperCase = input !== toLowerCase(input);\n\n\tif (hasUpperCase) {\n\t\tinput = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);\n\t}\n\n\tinput = input.replace(LEADING_SEPARATORS, '');\n\tinput = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);\n\n\tif (options.pascalCase) {\n\t\tinput = toUpperCase(input.charAt(0)) + input.slice(1);\n\t}\n\n\treturn postProcess(input, toUpperCase);\n}\n","import type { Pail } from \"@visulima/pail/server\";\n\nimport type { Cli as ICli, Command as ICommand, Toolbox as IToolbox } from \"../@types\";\nimport type { OptionDefinition } from \"../@types/command\";\nimport type { Section } from \"../@types/command-line-usage\";\nimport defaultOptions from \"../default-options\";\nimport commandLineUsage from \"../util/command-line-usage\";\nimport templateFormat from \"../util/template-format\";\n\nconst EMPTY_GROUP_KEY = \"__Other\";\n\nconst upperFirstChar = (string_: string): string => string_.charAt(0).toUpperCase() + string_.slice(1);\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst printGeneralHelp = (logger: Pail<never, string>, runtime: ICli, commands: Map<string, ICommand>, groupOption: string | undefined) => {\n logger.debug(\"no command given, printing general help...\");\n\n let filteredCommands = [...new Set(commands.values())].filter((command) => !command.hidden);\n\n if (groupOption) {\n filteredCommands = filteredCommands.filter((command) => command.group === groupOption);\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n const groupedCommands: Record<string, ICommand[]> = filteredCommands.reduce<Record<string, ICommand[]>>((accumulator, command) => {\n const group = command.group ?? EMPTY_GROUP_KEY;\n\n // eslint-disable-next-line security/detect-object-injection\n if (!accumulator[group]) {\n // eslint-disable-next-line security/detect-object-injection\n accumulator[group] = [];\n }\n\n // eslint-disable-next-line security/detect-object-injection\n (accumulator[group] as ICommand[]).push(command);\n\n return accumulator;\n }, {});\n\n logger.raw(\n commandLineUsage(\n [\n {\n content: `{cyan ${runtime.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,\n header: \"{inverse.cyan Usage }\",\n },\n ...Object.keys(groupedCommands).map((key) => {\n return {\n // eslint-disable-next-line security/detect-object-injection\n content: (groupedCommands[key] as ICommand[]).map((command) => {\n let aliases = \"\";\n\n if (typeof command.alias === \"string\") {\n aliases = command.alias;\n } else if (Array.isArray(command.alias)) {\n aliases = command.alias.join(\", \");\n }\n\n if (aliases !== \"\") {\n aliases = ` [${aliases}]`;\n }\n\n return [`{green ${command.name}} ${aliases}`, command.description ?? \"\"];\n }),\n header:\n key === EMPTY_GROUP_KEY || groupOption\n ? `{inverse.green Available${groupOption ? ` ${upperFirstChar(groupOption)}` : \"\"} Commands }`\n : ` {inverse.green ${upperFirstChar(key)} }`,\n };\n }),\n commands.has(\"help\")\n ? {\n header: \"{inverse.yellow Command Options }\",\n optionList: (commands.get(\"help\") as ICommand).options?.filter((option) => !option.hidden),\n }\n : undefined,\n { header: \"{inverse.yellow Global Options }\", optionList: defaultOptions },\n {\n content: `Run \"{cyan ${runtime.getCliName()}} {green help <command>}\" or \"{cyan ${runtime.getCliName()}} {green <command>} {yellow --help}\" for help with a specific command.`,\n raw: true,\n },\n ].filter(Boolean),\n ),\n );\n};\n\nconst printCommandHelp = (logger: Pail<never, string>, runtime: ICli, commands: Map<string, ICommand>, name: string): void => {\n const command = commands.get(name) as ICommand;\n\n const usageGroups: Section[] = [];\n\n usageGroups.push({\n content: `{cyan ${runtime.getCliName()}} {green ${command.name}}${command.argument ? \" [positional arguments]\" : \"\"}${\n command.options ? \" [options]\" : \"\"\n }`,\n header: \"{inverse.cyan Usage }\",\n });\n\n if (command.description) {\n usageGroups.push({ content: command.description, header: \"{inverse.green Description }\" });\n }\n\n if (command.argument) {\n usageGroups.push({ header: \"Command Positional Arguments\", isArgument: true, optionList: [command.argument] });\n }\n\n if (Array.isArray(command.options) && command.options.length > 0) {\n usageGroups.push({\n header: \"{inverse.yellow Command Options }\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionList: command.options.filter((option) => !option.hidden) as OptionDefinition<any>[],\n });\n }\n\n usageGroups.push({ header: \"{inverse.yellow Global Options }\", optionList: defaultOptions });\n\n if (command.alias !== undefined && command.alias.length > 0) {\n let alias: string[] = command.alias as string[];\n\n if (typeof command.alias === \"string\") {\n alias = [command.alias];\n }\n\n usageGroups.splice(1, 0, {\n content: alias,\n header: \"Alias(es)\",\n });\n }\n\n if (Array.isArray(command.examples) && command.examples.length > 0) {\n usageGroups.push({\n content: command.examples,\n header: \"Examples\",\n });\n }\n\n logger.raw(commandLineUsage(usageGroups));\n};\n\nclass HelpCommand implements ICommand {\n public name = \"help\";\n\n public options = [\n {\n description: \"Display only the specified group\",\n name: \"group\",\n type: String,\n } as OptionDefinition<string>,\n ];\n\n private readonly commands: Map<string, ICommand>;\n\n public constructor(commands: Map<string, ICommand>) {\n this.commands = commands;\n }\n\n public execute(toolbox: IToolbox): void {\n const { commandName, logger, options, runtime } = toolbox;\n\n const { footer, header } = runtime.getCommandSection();\n\n if (header) {\n logger.raw(templateFormat(header as string));\n }\n\n if (commandName === \"help\") {\n printGeneralHelp(logger, runtime, this.commands, options?.group);\n } else {\n printCommandHelp(logger, runtime, this.commands, commandName as string);\n }\n\n if (footer) {\n logger.raw(templateFormat(footer as string));\n }\n }\n}\n\nexport default HelpCommand;\n","import type { PossibleOptionDefinition } from \"./@types/command\";\n\nconst defaultOptions: PossibleOptionDefinition<boolean>[] = [\n {\n description: \"Turn on verbose output\",\n group: \"global\",\n name: \"verbose\",\n type: Boolean,\n },\n {\n description: \"Turn on debugging output\",\n group: \"global\",\n name: \"debug\",\n type: Boolean,\n },\n {\n alias: \"h\",\n description: \"Print out helpful usage information\",\n group: \"global\",\n name: \"help\",\n type: Boolean,\n },\n {\n alias: \"q\",\n description: \"Silence output\",\n group: \"global\",\n name: \"quiet\",\n type: Boolean,\n },\n {\n alias: \"V\",\n description: \"Print version info\",\n group: \"global\",\n name: \"version\",\n type: Boolean,\n },\n {\n description: \"Turn off colored output\",\n group: \"global\",\n name: \"no-color\",\n type: Boolean,\n },\n {\n description: \"Force colored output\",\n group: \"global\",\n name: \"color\",\n type: Boolean,\n },\n];\n\nexport default defaultOptions;\n","import type { Content as IContent, OptionList as IOptionList, Section as ISection } from \"../../@types/command-line-usage\";\nimport ContentSection from \"./section/content-section\";\nimport OptionList from \"./section/option-list-section\";\n\nconst commandLineUsage = (sections: ISection[]): string => {\n const lines = Array.isArray(sections) ? sections : [sections];\n\n if (lines.length === 0) {\n return \"\";\n }\n\n return `\\n${sections\n .map((section) => {\n if ((section as IOptionList).optionList) {\n return new OptionList(section).toString();\n }\n\n return new ContentSection(section as IContent).toString();\n })\n .join(\"\\n\")}`;\n};\n\nexport default commandLineUsage;\n","import type { TableInstanceOptions } from \"cli-table3\";\nimport CliTable3 from \"cli-table3\";\n\nimport type { Content as IContent } from \"../../../@types/command-line-usage\";\nimport templateFormat from \"../../template-format\";\nimport BaseSection from \"./base-section\";\n\nconst defaultTableOptions: Partial<TableInstanceOptions> = {\n chars: {\n bottom: \"\",\n \"bottom-left\": \"\",\n \"bottom-mid\": \"\",\n \"bottom-right\": \"\",\n left: \" \",\n \"left-mid\": \"\",\n mid: \"\",\n \"mid-mid\": \"\",\n middle: \" \",\n right: \"\",\n \"right-mid\": \"\",\n top: \"\",\n \"top-left\": \"\",\n \"top-mid\": \"\",\n \"top-right\": \"\",\n },\n colWidths: [40, 60],\n style: { border: [], compact: true, head: [], \"padding-left\": 2, \"padding-right\": 1 },\n wordWrap: true,\n};\n\n/**\n * A Content section comprises a header and one or more lines of content.\n * @property header The section header, always bold and underlined.\n * @property content Overloaded property, accepting data in one of four formats:\n *\n * 1. A single string (one line of text)\n * 2. An array of strings (multiple lines of text)\n * 3. An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are consistent throughout the array.\n * 4. An object with two properties - `data` and `options`. In this case, the data and options will be passed directly to the underlying [table](https://github.com/cli-table/cli-table3) module for rendering.\n *\n * @property raw - Set to true to avoid indentation and wrapping. Useful for banners.\n * @example\n * Simple string of content. For ansi formatting, use [colorize template literal syntax](https://github.com/visulima/visulima/tree/main/packages/colorize#tagged-template-literals).\n * ```js\n * {\n * header: 'A typical app',\n * content: 'Generates something {rgb(255,200,0).italic very {underline.bgRed important}}.'\n * }\n * ```\n *\n * An array of strings is interpreted as lines, to be joined by the system newline character.\n * ```js\n * {\n * header: 'A typical app',\n * content: [\n * 'First line.',\n * 'Second line.'\n * ],\n * }\n * ```\n *\n * An array of arrays is rendered in table layout.\n * ```js\n * {\n * header: 'A typical app',\n * content: [\n * [ 'First row, first column.', 'First row, second column.', ],\n * [ 'Second row, first column.', 'Second row, second column.', ],\n * ]\n * }\n * ```\n *\n * An object with `data` and `options` properties will be passed directly to the underlying [table](https://github.com/cli-table/cli-table3) module for rendering.\n * ```js\n * {\n * header: 'A typical app',\n * content: {\n * data: [\n * [ 'First row, first column.', 'First row, second column.', ],\n * [ 'Second row, first column.', 'Second row, second column.', ],\n * 'Second row, first column.',\n * ],\n * options: {\n * colWidths: [80],\n * }\n * }\n * }\n * ```\n */\nclass ContentSection extends BaseSection {\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public constructor(section: IContent) {\n super();\n\n if (section.header) {\n this.header(templateFormat(section.header));\n }\n\n if (section.content) {\n /* add content without indentation or wrapping */\n if (section.raw) {\n if (Array.isArray(section.content) && section.content.every((value) => typeof value === \"string\")) {\n section.content.forEach((row) => {\n if (Array.isArray(row)) {\n row.forEach((cell) => this.add(templateFormat(cell)));\n } else {\n this.add(templateFormat(row));\n }\n });\n } else if (typeof section.content === \"string\") {\n this.add(templateFormat(section.content));\n } else {\n throw new TypeError(\"Invalid raw content, must be a string or array of strings.\");\n }\n } else {\n this.add(this.getContentLines(section.content));\n }\n\n this.add(\"\");\n }\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,class-methods-use-this\n private getContentLines(content: IContent[\"content\"]) {\n if (typeof content === \"string\") {\n const table = new CliTable3({\n ...defaultTableOptions,\n colWidths: [80],\n });\n\n table.push([templateFormat(content)]);\n\n return table.toString();\n }\n\n if (\n Array.isArray(content) &&\n // eslint-disable-next-line @typescript-eslint/no-shadow\n content.every((value) => typeof value === \"string\" || (Array.isArray(value) && value.every((value) => typeof value === \"string\")))\n ) {\n const table = new CliTable3({\n ...defaultTableOptions,\n });\n\n content.forEach((row) => {\n if (Array.isArray(row)) {\n table.push(row.map((cell) => templateFormat(cell)));\n } else {\n table.push([templateFormat(row)]);\n }\n });\n\n return table.toString();\n }\n\n if (typeof content === \"object\") {\n const contentObject = content as { data?: string[] | string[][]; options?: TableInstanceOptions };\n\n if (!contentObject.options || !contentObject.data) {\n throw new Error(`Must have an \"options\" or \"data\" property\\n${JSON.stringify(content)}`);\n }\n\n const table = new CliTable3({\n ...defaultTableOptions,\n ...contentObject.options,\n style: { ...defaultTableOptions.style, ...contentObject.options.style },\n });\n\n contentObject.data.forEach((row) => {\n if (Array.isArray(row)) {\n table.push(row.map((cell) => templateFormat(cell)));\n } else {\n table.push([templateFormat(row)]);\n }\n });\n\n return table.toString();\n }\n\n throw new Error(`invalid input - 'content' must be a string, array of strings or a object:\\n\\n${JSON.stringify(content)}`);\n }\n}\n\nexport default ContentSection;\n","// eslint-disable-next-line import/no-named-as-default\nimport template from \"@visulima/colorize/template\";\n\nconst templateFormat = (string_?: string): string => {\n if (string_) {\n return template(Object.assign([], { raw: [string_.replaceAll(\"`\", \"\\\\`\")] }));\n }\n\n return \"\";\n};\n\nexport default templateFormat;\n","import os from \"node:os\";\n\nimport { bold } from \"@visulima/colorize\";\n\nclass BaseSection {\n protected lines: string[];\n\n public constructor() {\n this.lines = [];\n }\n\n public add(line: string): void {\n this.lines.push(line);\n }\n\n public toString(): string {\n return this.lines.join(os.EOL);\n }\n\n public header(text: string): void {\n this.add(bold(text));\n\n this.lines.push(\"\");\n }\n}\n\nexport default BaseSection;\n","import CliTable3 from \"cli-table3\";\n\nimport type { ArgumentDefinition, OptionDefinition as IOptionDefinition } from \"../../../@types/command\";\nimport type { OptionList as IOptionList } from \"../../../@types/command-line-usage\";\nimport templateFormat from \"../../template-format\";\nimport BaseSection from \"./base-section\";\n\nclass OptionListSection extends BaseSection {\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public constructor(data: IOptionList) {\n super();\n\n let definitions = data.optionList ?? [];\n\n const hide = Array.isArray(data.hide) ? data.hide : ([data.hide].filter(Boolean) as string[]);\n const groups = Array.isArray(data.group) ? data.group : ([data.group].filter(Boolean) as string[]);\n\n /* filter out hidden definitions */\n if (hide.length > 0) {\n definitions = definitions.filter((definition) => !hide.includes(definition.name));\n }\n\n if (data.header) {\n this.header(templateFormat(data.header));\n }\n\n if (groups.length > 0) {\n definitions = definitions.filter((definition) => {\n const noGroupMatch = groups.includes(\"_none\") && !definition.group;\n const groupMatch = this.intersect(Array.isArray(definition.group) ? definition.group : [definition.group], groups);\n\n return noGroupMatch || groupMatch ? definition : undefined;\n });\n }\n\n const table = new CliTable3({\n chars: {\n bottom: \"\",\n \"bottom-left\": \"\",\n \"bottom-mid\": \"\",\n \"bottom-right\": \"\",\n left: \" \",\n \"left-mid\": \"\",\n mid: \"\",\n \"mid-mid\": \"\",\n middle: \" \",\n right: \"\",\n \"right-mid\": \"\",\n top: \"\",\n \"top-left\": \"\",\n \"top-mid\": \"\",\n \"top-right\": \"\",\n },\n colWidths: [40, 40],\n style: { \"padding-left\": 2, \"padding-right\": 1 },\n wordWrap: true,\n });\n\n definitions.forEach((definition) =>\n table.push([this.getOptionNames(definition, data.reverseNameOrder ?? false, data.isArgument ?? false), templateFormat(definition.description)]),\n );\n\n this.add(table.toString());\n\n this.lines.push(\"\");\n }\n\n // eslint-disable-next-line class-methods-use-this,sonarjs/cognitive-complexity,@typescript-eslint/no-explicit-any\n private getOptionNames(definition: ArgumentDefinition | IOptionDefinition<any>, reverseNameOrder: boolean, isArgument: boolean): string {\n if (!definition.name) {\n throw new TypeError(\"Invalid option definition, name is required.\");\n }\n\n let type = definition.type ? definition.type.name.toLowerCase() : \"string\";\n\n const multiple = definition.multiple || definition.lazyMultiple ? \"[]\" : \"\";\n\n type = templateFormat(definition.typeLabel ?? `{underline ${type}${multiple}}`);\n\n let result: string;\n\n if (definition.alias) {\n if (definition.name) {\n const name = isArgument ? definition.name : `{yellow --${definition.name}}`;\n\n result = reverseNameOrder\n ? templateFormat(`{bold ${name}}, {bold -${definition.alias}} ${type}`)\n : templateFormat(`{bold -${definition.alias}}, {bold ${name}} ${type}`);\n } else if (reverseNameOrder) {\n result = templateFormat(`{bold -${definition.alias}} ${type}`);\n } else {\n result = templateFormat(`{bold -${definition.alias}} ${type}`);\n }\n } else {\n result = templateFormat(`{bold ${isArgument ? definition.name : `{yellow --${definition.name}}`}} ${type}`);\n }\n\n return result;\n }\n\n // eslint-disable-next-line class-methods-use-this\n private intersect(array1: (string | undefined)[], array2: (string | undefined)[]) {\n return array1.some((item1) => array2.includes(item1));\n }\n}\n\n/**\n * An OptionList section adds a table displaying the supplied option definitions.\n *\n * @property {string} [header] - The section header, always bold and underlined.\n * @property optionList {OptionDefinition[]} - An array of [option definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md) objects. In addition to the regular definition properties, command-line-usage will look for:\n *\n * - `description` - a string describing the option.\n * - `typeLabel` - a string to replace the default type string (e.g. `<string>`). It's often more useful to set a more descriptive type label, like `<ms>`, `<files>`, `<command>` etc.\n * @property {string|string[]} [group] - If specified, only options from this particular group will be printed. [Example](https://github.com/75lb/command-line-usage/blob/master/example/groups.js).\n * @property {string|string[]} [hide] - The names of one of more option definitions to hide from the option list. [Example](https://github.com/75lb/command-line-usage/blob/master/example/hide.js).\n * @property {boolean} [reverseNameOrder] - If true, the option alias will be displayed after the name, i.e. `--verbose, -v` instead of `-v, --verbose`).\n * @property {object} [tableOptions] - An options object suitable for passing into [table-layout](https://github.com/75lb/table-layout#table-). See [here for an example](https://github.com/75lb/command-line-usage/blob/master/example/option-list-options.js).\n *\n * @example\n * {\n * header: 'Options',\n * optionList: [\n * {\n * name: 'help',\n * alias: 'h',\n * description: 'Display this usage guide.'\n * },\n * {\n * name: 'src',\n * description: 'The input files to process',\n * multiple: true,\n * defaultOption: true,\n * typeLabel: '{underline file} ...'\n * },\n * {\n * name: 'timeout',\n * description: 'Timeout value in ms.',\n * alias: 't',\n * typeLabel: '{underline ms}'\n * }\n * ]\n * }\n */\nexport default OptionListSection;\n","import type { Command as ICommand } from \"../@types\";\n\nexport default {\n alias: [\"v\", \"V\"],\n description: \"Output the version number\",\n execute: ({ logger, runtime }) => {\n const version = runtime.getPackageVersion();\n\n if (version === undefined) {\n logger.warn(\"Unknown version\");\n logger.debug(\"The version number was not provided by the cli constructor.\");\n } else {\n logger.info(version);\n }\n },\n name: \"version\",\n options: [],\n usage: [],\n} as ICommand;\n","/**\n * Output with this option will be formatted.\n */\n// eslint-disable-next-line import/no-unused-modules\nexport const OUTPUT_NORMAL = 1;\n\n/**\n * Output with this option will be passed as-is.\n */\n// eslint-disable-next-line import/no-unused-modules\nexport const OUTPUT_RAW = 2;\n\n/**\n * Output with this option will have any formatting stripped away.\n */\n// eslint-disable-next-line import/no-unused-modules\nexport const OUTPUT_PLAIN = 4;\n\n/**\n * Output with this verbosity won't write anything at all.\n */\nexport const VERBOSITY_QUIET = 16;\n\n/**\n * Output with this verbosity will write default content.\n */\nexport const VERBOSITY_NORMAL = 32;\n\n/**\n * Output with this verbosity will be more detailed.\n */\nexport const VERBOSITY_VERBOSE = 64;\n\n/**\n * Output with this verbosity will reveal internals.\n */\nexport const VERBOSITY_DEBUG = 128;\n\nexport const POSITIONALS_KEY = \"positionals\";\n","import type { Toolbox as IToolbox } from \"./@types\";\n\nclass EmptyToolbox implements Partial<IToolbox> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [x: string]: any;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public result: any;\n\n public argv?: IToolbox[\"argv\"];\n\n public options?: IToolbox[\"options\"];\n\n public argument?: IToolbox[\"argument\"];\n\n public command: IToolbox[\"command\"];\n\n public commandName: IToolbox[\"commandName\"];\n\n public runtime?: IToolbox[\"runtime\"];\n\n public logger?: IToolbox[\"logger\"];\n\n public constructor(commandName: IToolbox[\"commandName\"], command: IToolbox[\"command\"]) {\n this.commandName = commandName;\n this.command = command;\n }\n}\n\nexport default EmptyToolbox;\n","/**\n * See https://github.com/visulima/cerebro#supported-nodejs-versions for our\n * version support policy. The CEREBRO_MIN_NODE_VERSION is used for testing only.\n */\nconst checkNodeVersion = (): void => {\n const minNodeVersion = process.env.CEREBRO_MIN_NODE_VERSION ? Number(process.env.CEREBRO_MIN_NODE_VERSION) : 18;\n\n const nodeVersion = process.version.replace(\"v\", \"\");\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const major = Number(/v([^.]+)/.exec(process.version)![1]);\n\n if (major < minNodeVersion) {\n // eslint-disable-next-line no-console\n console.log(\n `cerebro supports a minimum Node version of ${minNodeVersion}. You have ${nodeVersion}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`,\n );\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n};\n\nexport default checkNodeVersion;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\nimport getParameterOption from \"./get-parameter-option\";\nimport isBoolean from \"./option-is-boolean\";\n\ntype PartialAndLastOption<T> = {\n lastName?: string | undefined;\n lastOption?: PossibleOptionDefinition<T> | undefined;\n partial: Partial<T>;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst convertType = <T>(value: any, option: PossibleOptionDefinition<T>): any => {\n if (option.type === undefined) {\n return value;\n }\n\n if (option.type.name === \"Boolean\") {\n if (value === \"true\" || value === \"1\") {\n return option.type(true);\n }\n\n if (value === \"false\" || value === \"0\") {\n return option.type(false);\n }\n }\n\n return option.type(value);\n};\n\nconst booleanValue = new Set([\"1\", \"0\", \"true\", \"false\"]);\n\n/**\n * Gets the values of any boolean arguments that were specified on the command line with a value\n * These arguments were removed by removeBooleanValues\n */\nconst getBooleanValues = <T>(arguments_: string[], options: PossibleOptionDefinition<T>[]): Partial<T> => {\n const getBooleanValue = (argumentsAndLastOption: PartialAndLastOption<T>, argument: string): PartialAndLastOption<T> => {\n const { argName, argValue, option } = getParameterOption<T>(argument, options);\n\n const { lastOption } = argumentsAndLastOption;\n\n if (option && isBoolean(option) && argValue && argName) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-param-reassign\n argumentsAndLastOption.partial[argName as keyof PartialAndLastOption<T>[\"partial\"]] = convertType(argValue, option) as any;\n } else if (argumentsAndLastOption.lastName && lastOption && isBoolean(lastOption) && booleanValue.has(argument)) {\n // eslint-disable-next-line no-param-reassign\n argumentsAndLastOption.partial[argumentsAndLastOption.lastName as keyof PartialAndLastOption<T>[\"partial\"]] = convertType(\n argument,\n lastOption,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n }\n\n return { lastName: argName, lastOption: option, partial: argumentsAndLastOption.partial };\n };\n\n // eslint-disable-next-line unicorn/no-array-callback-reference,unicorn/no-array-reduce\n return arguments_.reduce<PartialAndLastOption<T>>(getBooleanValue, { partial: {} }).partial;\n};\n\nexport default getBooleanValues;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\n\n// eslint-disable-next-line security/detect-unsafe-regex\nconst argumentNameRegExp = /^-{1,2}(\\w+)(=(\\w+))?$/;\n\nconst getParameterOption = <T>(\n argument: string,\n options: PossibleOptionDefinition<T>[],\n): {\n argName?: string;\n argValue?: string;\n option?: PossibleOptionDefinition<T>;\n} => {\n const regExpResult = argumentNameRegExp.exec(argument);\n\n if (regExpResult == null) {\n return {};\n }\n\n const nameOrAlias = regExpResult[1];\n\n const option = options.find((o) => o.name === nameOrAlias || o.alias === nameOrAlias);\n\n if (option !== undefined) {\n return { argName: option.name, argValue: regExpResult[3] as string, option };\n }\n\n return {};\n};\n\nexport default getParameterOption;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\n\nconst isBoolean = <T>(option: PossibleOptionDefinition<T>): boolean => option.type?.name === \"Boolean\";\n\nexport default isBoolean;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\nimport isBoolean from \"./option-is-boolean\";\n\nconst getTypeLabel = <T>(definition: PossibleOptionDefinition<T>) => {\n let typeLabel = definition.type ? definition.type.name.toLowerCase() : \"string\";\n\n const multiple = definition.multiple ?? definition.lazyMultiple ? \"[]\" : \"\";\n\n if (typeLabel) {\n typeLabel = typeLabel === \"boolean\" ? \"\" : `{underline ${typeLabel}${multiple}}`;\n }\n\n return typeLabel;\n};\n\nconst mapOptionTypeLabel = <T>(definition: PossibleOptionDefinition<T>): PossibleOptionDefinition<T> => {\n if (isBoolean(definition)) {\n return definition;\n }\n\n // eslint-disable-next-line no-param-reassign\n definition.typeLabel = definition.typeLabel ?? getTypeLabel<T>(definition);\n\n if (definition.defaultOption) {\n // eslint-disable-next-line no-param-reassign\n definition.typeLabel = `${definition.typeLabel} (D)`;\n }\n\n if (definition.required) {\n // eslint-disable-next-line no-param-reassign\n definition.typeLabel = `${definition.typeLabel} (R)`;\n }\n\n return definition;\n};\n\nexport default mapOptionTypeLabel;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\nimport getParameterOption from \"./get-parameter-option\";\nimport isBoolean from \"./option-is-boolean\";\n\ntype ArgumentsAndLastOption<T> = { args: string[]; lastOption?: PossibleOptionDefinition<T> };\n\nconst booleanValue = new Set([\"1\", \"0\", \"true\", \"false\"]);\n\n/**\n * commandLineArgs throws an error if we pass aa value for a boolean arg as follows:\n * myCommand -a=true --booleanArg=false --otherArg true\n * this function removes these booleans so as to avoid errors from commandLineArgs\n */\n\nconst removeBooleanValues = <T>(arguments_: string[], options: PossibleOptionDefinition<T>[]): string[] => {\n const removeBooleanArguments = (argumentsAndLastValue: ArgumentsAndLastOption<T>, argument: string): ArgumentsAndLastOption<T> => {\n const { argValue, option } = getParameterOption(argument, options);\n\n const { lastOption } = argumentsAndLastValue;\n\n if (lastOption && isBoolean(lastOption) && booleanValue.has(argument)) {\n // eslint-disable-next-line no-underscore-dangle,@typescript-eslint/naming-convention\n const copiedArguments_ = [...argumentsAndLastValue.args];\n\n copiedArguments_.pop();\n\n return { args: copiedArguments_ };\n }\n\n if (option && isBoolean(option) && argValue) {\n return { args: argumentsAndLastValue.args };\n }\n\n return { args: [...argumentsAndLastValue.args, argument], lastOption: option as PossibleOptionDefinition<T> };\n };\n\n // eslint-disable-next-line unicorn/no-array-callback-reference,unicorn/no-array-reduce\n return arguments_.reduce<ArgumentsAndLastOption<T>>(removeBooleanArguments, { args: [] }).args;\n};\n\nexport default removeBooleanValues;\n","/**\n * Copied from\n * The MIT License (MIT)\n * Copyright (c) 2015-21 Lloyd Brookes <75pound@gmail.com>\n */\n\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isShort = new RegExp(/^-([^\\d-])$/);\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isLong = new RegExp(/^--(\\S+)/);\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isCombined = new RegExp(/^-([^\\d-]{2,})$/);\n\nconst isOption = (argument: string) => isShort.test(argument) || isLong.test(argument) || isCombined.test(argument);\n\nconst commandLineCommands = (commands: (string | null)[], argv: string[]): { argv: string[]; command: string | null } => {\n /* the command is the first arg, unless it's an option (e.g. --help) */\n const command = (argv[0] && isOption(argv[0])) || argv.length === 0 ? null : argv.shift() ?? null;\n\n if (!commands.includes(command)) {\n const error: Error & { command?: string | null | undefined } = new Error(`Command not recognised: ${command}`);\n error.command = command;\n error.name = \"INVALID_COMMAND\";\n\n throw error;\n }\n\n return { argv, command };\n};\n\nexport default commandLineCommands;\n","import { distance } from \"fastest-levenshtein\";\n\nconst isSimilar = (string1: string, string2: string) => distance(string1, string2) <= string1.length / 3 || string2.includes(string1);\n\nconst findAlternatives = (string: string, array: string[]): string[] => {\n const id = string.toLowerCase();\n\n return array.filter((nextId) => isSimilar(nextId.toLowerCase(), id));\n};\n\nexport default findAlternatives;\n","import type { CommandLineOptions } from \"command-line-args\";\n\nimport type { PossibleOptionDefinition } from \"../@types/command\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst listMissingArguments = <T = any>(commandLineConfig: PossibleOptionDefinition<T>[], parsedArguments: CommandLineOptions): PossibleOptionDefinition<T>[] =>\n commandLineConfig\n .filter((config) => config.required && parsedArguments[config.name] == null)\n .filter((config) => {\n if (config.type?.name === \"Boolean\") {\n // eslint-disable-next-line no-param-reassign\n parsedArguments[config.name] = false;\n\n return false;\n }\n\n return true;\n });\n\nexport default listMissingArguments;\n","import type { PossibleOptionDefinition } from \"../@types/command\";\n\n/**\n * Performs a simple merge of multiple argument lists. Does not mutate given\n * argument lists or argument.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst mergeArguments = <T = any>(argumentLists: PossibleOptionDefinition<T>[]): PossibleOptionDefinition<T>[] => {\n const argumentsByName = new Map<string, PossibleOptionDefinition<T>>();\n\n argumentLists.forEach((argument) => {\n argumentsByName.set(argument.name, { ...argumentsByName.get(argument.name), ...argument });\n });\n\n return [...argumentsByName.values()];\n};\n\nexport default mergeArguments;\n","import hideBin from \"./hide-bin\";\n\nconst COMMAND_DELIMITER = \" \";\n\n// eslint-disable-next-line security/detect-object-injection\nconst equals = (a: string[], b: string[]) => a.length === b.length && a.every((v, index) => v === b[index]);\n\n/**\n * Parses the raw command into an array of strings.\n *\n * @param commandArray Command string or list of command parts.\n * @returns The command as an array of strings.\n */\nconst parseRawCommand = (commandArray: string[] | string): string[] => {\n // use the command line options if not passed in\n if (typeof commandArray === \"string\") {\n return (commandArray as string).split(COMMAND_DELIMITER);\n }\n\n // remove the first 2 options if it comes from process.argv\n if (equals(commandArray as string[], process.argv)) {\n return hideBin(commandArray as string[]);\n }\n\n return commandArray as string[];\n};\n\nexport default parseRawCommand;\n","interface ElectronProcess extends NodeJS.Process {\n defaultApp?: boolean;\n versions: NodeJS.ProcessVersions & {\n electron: string;\n };\n}\n\n// process.versions.electron is either set by electron, or undefined\n// see https://github.com/electron/electron/blob/master/docs/api/process.md#processversionselectron-readonly\nconst isElectronApp = (): boolean => !!(process as ElectronProcess).versions.electron;\n\n// process.defaultApp is either set by electron in an electron unbundled app, or undefined\n// see https://github.com/electron/electron/blob/master/docs/api/process.md#processdefaultapp-readonly\nconst isBundledElectronApp = (): boolean => isElectronApp() && !(process as ElectronProcess).defaultApp;\n\nconst getProcessArgvBinIndex = (): number => {\n // The binary name is the first command line argument for:\n // - bundled Electron apps: bin argv1 argv2 ... argvn\n if (isBundledElectronApp()) {\n return 0;\n }\n\n // or the second one (default) for:\n // - standard node apps: node bin argv1 argv2 ... argvn\n // - unbundled Electron apps: electron bin argv1 arg2 ... argvn\n return 1;\n};\n\nconst hideBin = (argv: string[]): string[] => argv.slice(getProcessArgvBinIndex() + 1);\n\nexport default hideBin;\n","import type { Pail } from \"@visulima/pail/server\";\n\nconst registerExceptionHandler = (logger: Pail<never, string>): void => {\n // we want to see real exceptions with backtraces and stuff\n process.on(\"uncaughtException\", (error: Partial<Error> | null | undefined) => {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n logger.error(`Uncaught exception: ${error}`);\n\n if (error?.stack) {\n logger.error(error.stack);\n }\n\n process.exit(1);\n });\n\n process.on(\"unhandledRejection\", (error: Partial<Error> | null | undefined) => {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n logger.error(`Promise rejection: ${error}`);\n\n if (error?.stack) {\n logger.error(error.stack);\n }\n\n process.exit(1);\n });\n};\n\nexport default registerExceptionHandler;\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/cli.ts","../../../node_modules/.pnpm/camelcase@8.0.0/node_modules/camelcase/index.js","../src/command/help.ts","../src/default-options.ts","../src/util/command-line-usage/index.ts","../src/util/command-line-usage/section/content-section.ts","../src/util/template-format.ts","../src/util/command-line-usage/section/base-section.ts","../src/util/command-line-usage/section/option-list-section.ts","../src/command/version.ts","../src/constants.ts","../src/empty-toolbox.ts","../src/util/check-node-version.ts","../src/util/command-line-args/get-boolean-values.ts","../src/util/command-line-args/get-parameter-option.ts","../src/util/command-line-args/option-is-boolean.ts","../src/util/command-line-args/map-option-type-label.ts","../src/util/command-line-args/remove-boolean-values.ts","../src/util/command-line-commands.ts","../src/util/levenstein.ts","../src/util/list-missing-arguments.ts","../src/util/merge-arguments.ts","../src/util/parse-raw-command.ts","../src/util/hide-bin.ts","../src/util/register-exception-handler.ts"],"names":["init_esm_shims","process_argv","process_cwd","env","execArgv","execPath","exit","boxen","dim","green","reset","yellow","createPail","UPPERCASE","LOWERCASE","LEADING_CAPITAL","IDENTIFIER","SEPARATORS","LEADING_SEPARATORS","SEPARATORS_AND_IDENTIFIER","NUMBERS_AND_IDENTIFIER","preserveCamelCase","string","toLowerCase","toUpperCase","preserveConsecutiveUppercase","isLastCharLower","isLastCharUpper","isLastLastCharUpper","isLastLastCharPreserved","index","character","input","match","postProcess","pattern","offset","_","identifier","camelCase","options","x","commandLineArgs","defaultOptions","default_options_default","CliTable3","template","templateFormat","string_","template_format_default","os","bold","BaseSection","line","text","base_section_default","defaultTableOptions","ContentSection","section","value","row","cell","content","table","contentObject","content_section_default","OptionListSection","data","definitions","hide","groups","definition","noGroupMatch","groupMatch","reverseNameOrder","isArgument","type","multiple","result","name","array1","array2","item1","option_list_section_default","commandLineUsage","sections","command_line_usage_default","EMPTY_GROUP_KEY","upperFirstChar","printGeneralHelp","logger","runtime","commands","groupOption","filteredCommands","command","groupedCommands","accumulator","group","key","aliases","option","printCommandHelp","usageGroups","alias","HelpCommand","toolbox","commandName","footer","header","help_default","version_default","version","POSITIONALS_KEY","EmptyToolbox","empty_toolbox_default","checkNodeVersion","minNodeVersion","nodeVersion","check_node_version_default","argumentNameRegExp","getParameterOption","argument","regExpResult","nameOrAlias","o","get_parameter_option_default","isBoolean","option_is_boolean_default","convertType","booleanValue","getBooleanValues","arguments_","getBooleanValue","argumentsAndLastOption","argName","argValue","lastOption","get_boolean_values_default","getTypeLabel","typeLabel","mapOptionTypeLabel","map_option_type_label_default","removeBooleanValues","removeBooleanArguments","argumentsAndLastValue","copiedArguments_","remove_boolean_values_default","isShort","isLong","isCombined","isOption","commandLineCommands","argv","error","command_line_commands_default","distance","isSimilar","string1","string2","findAlternatives","array","id","nextId","levenstein_default","listMissingArguments","commandLineConfig","parsedArguments","config","list_missing_arguments_default","mergeArguments","argumentLists","argumentsByName","merge_arguments_default","isElectronApp","isBundledElectronApp","getProcessArgvBinIndex","hideBin","hide_bin_default","COMMAND_DELIMITER","equals","a","b","v","parseRawCommand","commandArray","parse_raw_command_default","registerExceptionHandler","register_exception_handler_default","isCI","lowerFirstChar","Cli","cliName","cwd","packageName","packageVersion","cerebroLevelToPailLevel","commandSection","extension","configKeys","extraOptions","shouldExitProcess","otherExtraOptions","commandNames","alternatives","foundAlternatives","commandArguments","parsedArgs","booleanValues","commandArgs","_all","positionals","groupedDuplicatedOption","object","duplicatedOptions","errorMessages","matchingOption","duplicate","flag","helpCommand","updateAvailable","m","border","missingOptions","errors","unknownOption","first","rest","alternative","conflicts","conflict","c","negatedOption","callback","nonNegatedKey","optionKey","implies","impliedOption","cOption"],"mappings":"wCAAAA,ICAAA,IAAA,OAAS,QAAQC,GAAc,OAAOC,GAAa,OAAAC,EAAK,YAAAC,GAAU,YAAAC,GAAU,QAAAC,MAAY,eAExF,OAAS,SAAAC,OAAa,kBACtB,OAAS,OAAAC,GAAK,SAAAC,GAAO,SAAAC,GAAO,UAAAC,OAAc,qBAE1C,OAAS,cAAAC,OAAkB,wBCL3BZ,IAAA,IAAMa,GAAY,YACZC,GAAY,YACZC,EAAkB,0BAClBC,EAAa,yBACbC,EAAa,WAEbC,GAAqB,IAAI,OAAO,IAAMD,EAAW,MAAM,EACvDE,EAA4B,IAAI,OAAOF,EAAW,OAASD,EAAW,OAAQ,IAAI,EAClFI,EAAyB,IAAI,OAAO,OAASJ,EAAW,OAAQ,IAAI,EAEpEK,GAAoB,CAACC,EAAQC,EAAaC,EAAaC,IAAiC,CAC7F,IAAIC,EAAkB,GAClBC,EAAkB,GAClBC,EAAsB,GACtBC,EAA0B,GAE9B,QAASC,EAAQ,EAAGA,EAAQR,EAAO,OAAQQ,IAAS,CACnD,IAAMC,EAAYT,EAAOQ,CAAK,EAC9BD,EAA0BC,EAAQ,EAAIR,EAAOQ,EAAQ,CAAC,IAAM,IAAM,GAE9DJ,GAAmBb,GAAU,KAAKkB,CAAS,GAC9CT,EAASA,EAAO,MAAM,EAAGQ,CAA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EAAKxC,CAAK,IAAM,CAC7E,GAAI,SAAS,KAAKwC,CAAG,EAAG,CACpB,IAAMuI,EAAwB5C,GAAe3F,EAAI,QAAQ,KAAM,EAAE,CAAC,EAElE,KAAK,OAAO,MAAM,2BAA2BA,CAAG,SAASuI,CAAa,GAAG,EAGxEhI,EAAQ,QAAgCgI,CAAa,EAAI,CAAC/K,EAE3DoC,EAAQ,SAAS,QAASM,GAAW,CAC7BA,EAAO,OAASqI,IAEhBrI,EAAO,YAAc,GAE7B,CAAC,CACL,CACJ,CAAC,CACL,CAIQ,kBAAkBK,EAAmBX,EAAyB,CAClE,OAAO,KAAKW,EAAQ,OAA8B,EAAE,QAASiI,GAAc,CACvE,IAAMtI,EAASN,EAAQ,SAAS,KAE3B8B,GAAMA,EAAE,oBAAsB8G,GAAa9G,EAAE,cAAgB,QAAaA,EAAE,UAAY,MAC7F,EAEA,GAAIxB,GAAQ,QAAS,CACjB,IAAMuI,EAAUvI,EAAO,QAEvB,OAAO,QAAQuI,CAAO,EAAE,QAAQ,CAAC,CAACzI,EAAKxC,CAAK,IAAM,CAE9C,GAAI+C,EAAQ,QAAQP,CAAG,IAAM,OAEzBO,EAAQ,QAAQP,CAAG,EAAIxC,MACpB,CACH,IAAMkL,EAAgB9I,EAAQ,SAAS,KAAM+I,GAAYA,EAAQ,OAAS3I,CAAG,GAGzE0I,GAAe,eAAiB,QAAanI,EAAQ,QAAQP,CAAG,IAAM0I,EAAc,gBAEpFnI,EAAQ,QAAQP,CAAG,EAAIxC,EAE/B,CACJ,CAAC,CACL,CACJ,CAAC,CACL,CACJ","sourcesContent":["// TODO: Uncomment this in the next major release\n// import type { CliOptions } from \"./cli\";\n// import { Cli as Cerebro } from \"./cli\";\n\n// eslint-disable-next-line @typescript-eslint/no-namespace,@typescript-eslint/no-unused-vars\ndeclare namespace NodeJS {\n interface ProcessEnvironment {\n CEREBRO_MIN_NODE_VERSION?: string;\n CEREBRO_OUTPUT_LEVEL: VERBOSITY_LEVEL;\n }\n}\n\nexport type { Cli } from \"./@types/cli\";\nexport type { ArgumentDefinition, Command, OptionDefinition } from \"./@types/command\";\nexport type { Extension } from \"./@types/extension\";\nexport type { Toolbox } from \"./@types/toolbox\";\nexport type { CliOptions } from \"./cli\";\n\n/**\n * Any of the output types [[OUTPUT_NORMAL]], [[OUTPUT_RAW]] and [[OUTPUT_PLAIN]].\n */\nexport type OutputType = 1 | 2 | 4;\n\n/**\n * Any of the verbosity types\n * [[VERBOSITY_QUIET]], [[VERBOSITY_NORMAL]], [[VERBOSITY_VERBOSE]] and [[VERBOSITY_DEBUG]].\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;\n\nexport { Cli as default } from \"./cli\";\n// TODO: Uncomment this in the next major release\n// export const createCerebro = (name: string, options: CliOptions): Cerebro => new Cerebro(name, options);\n","import { argv as process_argv, cwd as process_cwd, env, execArgv, execPath, exit } from \"node:process\";\n\nimport { boxen } from \"@visulima/boxen\";\nimport { dim, green, reset, yellow } from \"@visulima/colorize\";\nimport type { ConstructorOptions, Pail } from \"@visulima/pail/server\";\nimport { createPail } from \"@visulima/pail/server\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport camelCase from \"camelcase\";\nimport type { CommandLineOptions } from \"command-line-args\";\nimport commandLineArgs from \"command-line-args\";\n\nimport type {\n Cli as ICli,\n Command as ICommand,\n CommandSection as ICommandSection,\n Extension as IExtension,\n Options as IOptions,\n Toolbox as IToolbox,\n} from \"./@types\";\nimport type { CliRunOptions } from \"./@types/cli\";\nimport type { OptionDefinition, PossibleOptionDefinition } from \"./@types/command\";\nimport HelpCommand from \"./command/help\";\nimport VersionCommand from \"./command/version\";\nimport { POSITIONALS_KEY, VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE } from \"./constants\";\nimport defaultOptions from \"./default-options\";\nimport EmptyToolbox from \"./empty-toolbox\";\nimport type { UpdateNotifierOptions } from \"./update-notifier/has-new-version\";\nimport checkNodeVersion from \"./util/check-node-version\";\nimport getBooleanValues from \"./util/command-line-args/get-boolean-values\";\nimport mapOptionTypeLabel from \"./util/command-line-args/map-option-type-label\";\nimport removeBooleanValues from \"./util/command-line-args/remove-boolean-values\";\nimport commandLineCommands from \"./util/command-line-commands\";\nimport findAlternatives from \"./util/levenstein\";\nimport listMissingArguments from \"./util/list-missing-arguments\";\nimport mergeArguments from \"./util/merge-arguments\";\nimport parseRawCommand from \"./util/parse-raw-command\";\nimport registerExceptionHandler from \"./util/register-exception-handler\";\n\n/** Detect if `CI` environment variable is set */\nconst isCI = \"CI\" in env && (\"GITHUB_ACTIONS\" in env || \"GITLAB_CI\" in env || \"CIRCLECI\" in env);\n\nconst lowerFirstChar = (string_: string): string => string_.charAt(0).toLowerCase() + string_.slice(1);\n\nexport type CliOptions = {\n argv?: string[];\n cwd?: string;\n logger?: ConstructorOptions<string, string>;\n packageName?: string;\n packageVersion?: string;\n};\n\nexport class Cli implements ICli {\n private readonly logger: Pail<never, string>;\n\n private readonly argv: string[];\n\n private readonly cwd: string;\n\n private readonly cliName: string;\n\n private readonly packageVersion: string | undefined;\n\n private readonly packageName: string | undefined;\n\n private readonly extensions: IExtension[] = [];\n\n private readonly commands: Map<string, ICommand>;\n\n private defaultCommand: string;\n\n private updateNotifierOptions: UpdateNotifierOptions | undefined;\n\n private commandSection: ICommandSection;\n\n /**\n * @param cliName The cli cliName.\n * @param options The options for the CLI.\n * - argv This should be in the base case process.argv\n * - cwd The path of main folder.\n * - packageName The packageJson name.\n * - packageVersion The packageJson version.\n */\n public constructor(cliName: string, options: CliOptions = {}) {\n const { argv, cwd, packageName, packageVersion } = {\n argv: process_argv,\n cwd: process_cwd(),\n ...options,\n };\n\n this.argv = parseRawCommand(argv);\n\n // If the \"--quiet\"/\"-q\" flag is ever present, set our global logging\n // to quiet mode. Also set the level on the logger we've already created.\n if (this.argv.includes(\"--quiet\") || this.argv.includes(\"-q\")) {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_QUIET);\n\n // If the \"--verbose\"/\"-v\" flag is ever present, set our global logging\n // to verbose mode. Also set the level on the logger we've already created.\n } else if (this.argv.includes(\"--verbose\") || this.argv.includes(\"-v\")) {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_VERBOSE);\n } else if (this.argv.includes(\"--debug\") || this.argv.includes(\"-vvv\") || \"DEBUG\" in env) {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_DEBUG);\n } else {\n env.CEREBRO_OUTPUT_LEVEL = String(VERBOSITY_NORMAL);\n }\n\n const cerebroLevelToPailLevel: Record<string, string> = {\n \"32\": \"informational\",\n \"64\": \"trace\",\n \"128\": \"debug\",\n };\n\n this.logger = createPail({\n logLevel: env.CEREBRO_OUTPUT_LEVEL\n ? cerebroLevelToPailLevel[env.CEREBRO_OUTPUT_LEVEL as keyof typeof cerebroLevelToPailLevel] ?? \"informational\"\n : \"informational\",\n ...options.logger,\n });\n\n if (env.CEREBRO_OUTPUT_LEVEL === String(VERBOSITY_QUIET)) {\n this.logger.disable();\n }\n\n checkNodeVersion();\n registerExceptionHandler(this.logger);\n\n this.cliName = cliName;\n this.packageVersion = packageVersion;\n this.packageName = packageName;\n this.cwd = cwd;\n this.defaultCommand = \"help\";\n this.commandSection = {\n header: `${this.cliName}${this.packageVersion ? ` v${this.packageVersion}` : \"\"}`,\n };\n\n this.commands = new Map<string, ICommand>();\n\n this.addCoreExtensions();\n\n this.addCommand(VersionCommand);\n this.addCommand(new HelpCommand(this.commands));\n }\n\n public setCommandSection(commandSection: ICommandSection): this {\n this.commandSection = commandSection;\n\n return this;\n }\n\n public getCommandSection(): ICommandSection {\n return this.commandSection;\n }\n\n /**\n * Set a default command, to display a different command if cli is call without command.\n */\n public setDefaultCommand(commandName: string): this {\n this.defaultCommand = commandName;\n\n return this;\n }\n\n /**\n * Add an arbitrary command to the CLI.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public addCommand<OT = any>(command: ICommand<OT>): this {\n // add the command to the runtime (if it isn't already there)\n\n if (this.commands.has(command.name)) {\n throw new Error(`Ignored command with name \"${command.name}, it was found in the command list.\"`);\n } else {\n command.options?.map((option) => mapOptionTypeLabel<OT>(option));\n\n this.validateDoubleOptions<OT>(command);\n this.addNegatableOption<OT>(command);\n\n command.options?.forEach((option) => {\n // eslint-disable-next-line no-underscore-dangle,no-param-reassign\n option.__camelCaseName__ = camelCase(option.name);\n });\n\n this.commands.set(command.name, command);\n\n if (command.alias !== undefined) {\n let aliases: string[] = command.alias as string[];\n\n if (typeof command.alias === \"string\") {\n aliases = [command.alias];\n }\n\n aliases.forEach((alias) => {\n this.logger.debug(\"adding alias\", alias);\n\n if (this.commands.has(alias)) {\n throw new Error(`Ignoring command alias \"${alias}, command with the same name was found.\"`);\n } else {\n this.commands.set(alias, command);\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Adds an extension so it is available when commands execute. They usually live\n * the given name on the toolbox object passed to commands, but are able\n * to manipulate the toolbox object however they want.\n */\n public addExtension(extension: IExtension): this {\n this.extensions.push(extension);\n\n return this;\n }\n\n /**\n * Enable the update notifier functionality with the given options.\n *\n * @param options - The options for enabling the update notifier.\n * options.alwaysRun - Determines whether the update check should always run. Defaults to false.\n * options.distributionTag - The distribution tag to use for checking updates. Defaults to \"latest\".\n * options.updateCheckInterval - The interval in milliseconds between each update check. Defaults to 24 hours.\n *\n * @example\n * enableUpdateNotifier({\n * alwaysRun: true,\n * debug: false,\n * distributionTag: \"stable\",\n * pkg: {\n * name: \"my-package\",\n * version: \"1.0.0\"\n * },\n * updateCheckInterval: 1000 * 60 * 60\n * });\n */\n public enableUpdateNotifier(options: Partial<Omit<UpdateNotifierOptions, \"debug | pkg\">> = {}): this {\n if (!this.packageName || !this.packageVersion) {\n throw new Error(\"Cannot enable update notifier without package name and version.\");\n }\n\n const configKeys = Object.keys(options);\n\n if (configKeys.length > 0 && !configKeys.includes(\"alwaysRun\") && !configKeys.includes(\"distTag\") && !configKeys.includes(\"updateCheckInterval\")) {\n throw new Error(\"Invalid update notifier options, please check the documentation.\");\n }\n\n this.updateNotifierOptions = {\n alwaysRun: false,\n debug: env.CEREBRO_OUTPUT_LEVEL === String(VERBOSITY_DEBUG),\n distTag: \"latest\",\n pkg: {\n name: this.packageName,\n version: this.packageVersion,\n },\n updateCheckInterval: 1000 * 60 * 60 * 24,\n ...options,\n };\n\n return this;\n }\n\n public getCliName(): string {\n return this.cliName;\n }\n\n public getPackageVersion(): string | undefined {\n return this.packageVersion;\n }\n\n public getPackageName(): string | undefined {\n return this.packageName;\n }\n\n public getCommands(): Map<string, ICommand> {\n return this.commands;\n }\n\n public getCwd(): string {\n return this.cwd;\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public async run(extraOptions: CliRunOptions = {}): Promise<void> {\n const { shouldExitProcess = true, ...otherExtraOptions } = extraOptions;\n\n const commandNames = [...this.commands.keys()];\n\n let parsedArguments: { argv: string[]; command: string | null | undefined };\n\n this.logger.debug(`process.execPath: ${execPath}`);\n this.logger.debug(`process.execArgv: ${execArgv.join(\" \")}`);\n this.logger.debug(`process.argv: ${process_argv.join(\" \")}`);\n\n try {\n parsedArguments = commandLineCommands([null, ...commandNames], this.argv);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // CLI needs a valid command name to do anything. If the given\n // command is invalid, run the generalized help command with default\n // config. This should print the general usage information.\n if (error.name === \"INVALID_COMMAND\" && error.command) {\n let alternatives = \"\";\n\n const foundAlternatives = findAlternatives(error.command, [...this.commands.keys()]);\n\n if (foundAlternatives.length > 0) {\n alternatives = ` Did you mean: \\r\\n - ${foundAlternatives.join(\" \\r\\n- \")}`;\n }\n\n this.logger.error(`\"${error.command}\" is not an available command.${alternatives}`);\n } else {\n this.logger.error(error as Error);\n }\n\n return shouldExitProcess ? exit(1) : undefined;\n }\n\n const commandName = parsedArguments.command ?? this.defaultCommand;\n const command = this.commands.get(commandName) as ICommand;\n\n if (typeof command.execute !== \"function\") {\n this.logger.error(`Command \"${command.name}\" has no function to execute.`);\n\n return shouldExitProcess ? exit(1) : undefined;\n }\n\n const commandArguments = parsedArguments.argv;\n\n this.logger.debug(`command '${commandName}' found, parsing command args: ${commandArguments.join(\", \")}`);\n\n // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\n let arguments_ = mergeArguments([...(command.options ?? []), ...defaultOptions]);\n\n arguments_.forEach((argument) => {\n if (argument.multiple && argument.lazyMultiple) {\n throw new Error(`Argument \"${argument.name}\" cannot have both multiple and lazyMultiple options, please choose one.`);\n }\n });\n\n if (command.argument) {\n this.logger.debug(\"command has positional argument, parsing them...\");\n\n arguments_ = [\n {\n defaultOption: true,\n\n description: command.argument?.description,\n group: \"positionals\",\n multiple: true,\n name: POSITIONALS_KEY,\n\n type: command.argument?.type,\n\n typeLabel: command.argument?.typeLabel,\n },\n ...arguments_,\n ];\n }\n\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const parsedArgs = commandLineArgs(arguments_, {\n argv: removeBooleanValues(commandArguments, command.options ?? []),\n camelCase: true,\n partial: true,\n stopAtFirstUnknown: true,\n });\n\n const booleanValues = getBooleanValues(commandArguments, command.options ?? []);\n\n // eslint-disable-next-line unicorn/prevent-abbreviations,no-underscore-dangle\n const commandArgs = { ...parsedArgs, _all: { ...parsedArgs._all, ...booleanValues } } as typeof parsedArgs;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.validateCommandOptions<any>(arguments_, commandArgs, command);\n\n // prepare the execute toolbox\n const toolbox = new EmptyToolbox(command.name, command);\n\n // attach the runtime\n toolbox.runtime = this as ICli;\n\n // allow extensions to attach themselves to the toolbox\n await this.registerExtensions(toolbox as IToolbox);\n\n await this.updateNotifier(toolbox as IToolbox);\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { _all, positionals } = commandArgs;\n\n // eslint-disable-next-line security/detect-object-injection\n if (_all[POSITIONALS_KEY]) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete,security/detect-object-injection\n delete _all[POSITIONALS_KEY];\n }\n\n // eslint-disable-next-line security/detect-object-injection\n toolbox.argument = positionals?.[POSITIONALS_KEY] ?? [];\n toolbox.argv = this.argv;\n toolbox.options = { ..._all, ...otherExtraOptions };\n\n this.mapNegatableOptions(toolbox as IToolbox, command);\n this.mapImpliesOptions(toolbox as IToolbox, command);\n\n this.validateCommandArgsForConflicts(arguments_, toolbox.options as IToolbox[\"options\"], command);\n\n this.logger.debug(\"command options parsed from options:\");\n this.logger.debug(JSON.stringify(toolbox.options, null, 2));\n this.logger.debug(\"command argument parsed from argument:\");\n this.logger.debug(JSON.stringify(toolbox.argument, null, 2));\n\n await this.prepareToolboxResult(commandArgs, toolbox as IToolbox, command);\n\n return shouldExitProcess ? exit(0) : undefined;\n }\n\n // eslint-disable-next-line class-methods-use-this\n private validateDoubleOptions<OT>(command: ICommand): void {\n if (Array.isArray(command.options)) {\n // eslint-disable-next-line unicorn/no-array-reduce\n const groupedDuplicatedOption = command.options.reduce<Record<string, OptionDefinition<OT>[]>>((accumulator, object) => {\n const key = `${object.name}-${object.alias}`;\n\n // eslint-disable-next-line security/detect-object-injection\n if (!accumulator[key]) {\n // eslint-disable-next-line security/detect-object-injection\n accumulator[key] = [];\n }\n\n // eslint-disable-next-line security/detect-object-injection\n (accumulator[key] as OptionDefinition<OT>[]).push(object as OptionDefinition<OT>);\n\n return accumulator;\n }, {});\n const duplicatedOptions = Object.values(groupedDuplicatedOption).filter((object) => object.length > 1);\n\n let errorMessages = \"\";\n\n duplicatedOptions.forEach((options) => {\n const matchingOption = options[0] as OptionDefinition<OT>;\n const duplicate = options[1] as OptionDefinition<OT>;\n\n let flag = \"alias\";\n\n if (matchingOption.name === duplicate.name) {\n flag = \"name\";\n\n if (matchingOption.alias === duplicate.alias) {\n flag += \" and alias\";\n }\n }\n\n errorMessages += `Cannot add option ${flag} \"${JSON.stringify(duplicate)}\" to command \"${\n command.name\n }\" due to conflicting option ${JSON.stringify(matchingOption)}\\n`;\n });\n\n if (errorMessages.length > 0) {\n throw new Error(errorMessages);\n }\n }\n }\n\n /**\n * Adds the core extensions. These provide the basic features\n * available in cerebro.\n */\n private addCoreExtensions() {\n this.addExtension({\n execute: (toolbox: IToolbox) => {\n // eslint-disable-next-line no-param-reassign\n toolbox.logger = this.logger;\n },\n name: \"logger\",\n });\n }\n\n // eslint-disable-next-line unicorn/prevent-abbreviations\n private async prepareToolboxResult(commandArgs: CommandLineOptions, toolbox: IToolbox, command: ICommand) {\n // Help is a special argument for displaying help for the given command.\n // If found, run the help command instead, with the given command name as\n // an option.\n if (commandArgs.global?.help) {\n this.logger.debug(\"'--help' option found, running 'help' for given command...\");\n const helpCommand = this.commands.get(\"help\");\n\n if (!helpCommand) {\n throw new Error(\"Help command not found.\");\n }\n\n await helpCommand.execute(toolbox);\n\n return;\n }\n\n if (commandArgs.global?.version || commandArgs.global?.V) {\n this.logger.debug(\"'--version' option found, running 'version' for given command...\");\n const helpCommand = this.commands.get(\"version\");\n\n if (!helpCommand) {\n throw new Error(\"Version command not found.\");\n }\n\n await helpCommand.execute(toolbox);\n\n return;\n }\n\n await command.execute(toolbox);\n }\n\n private async updateNotifier({ logger }: IToolbox) {\n if (\n (this.updateNotifierOptions && this.updateNotifierOptions.alwaysRun) ||\n (!(env.NO_UPDATE_NOTIFIER || env.NODE_ENV === \"test\" || this.argv.includes(\"--no-update-notifier\") || isCI) && this.updateNotifierOptions)\n ) {\n // @TODO add a stream logger\n logger.raw(\"Checking for updates...\");\n\n const hasNewVersion = await import(\"./update-notifier/has-new-version\").then((m) => m.default);\n\n const updateAvailable = await hasNewVersion(this.updateNotifierOptions);\n\n if (updateAvailable) {\n const template = \"Update available \" + dim(this.packageVersion + \"\") + reset(\" → \") + green(updateAvailable);\n\n this.logger.error(\n boxen(template, {\n borderColor: (border: string) => yellow(border),\n borderStyle: \"round\",\n margin: 1,\n padding: 1,\n textAlignment: \"center\",\n }),\n );\n }\n }\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,unicorn/prevent-abbreviations,class-methods-use-this\n private validateCommandOptions<T>(arguments_: PossibleOptionDefinition<T>[], commandArgs: CommandLineOptions, command: ICommand): void {\n const missingOptions = listMissingArguments(arguments_, commandArgs);\n\n if (missingOptions.length > 0) {\n throw new Error(\n `You called the command \"${command.name}\" without the required options: ${missingOptions.map((argument) => argument.name).join(\", \")}`,\n );\n }\n\n // eslint-disable-next-line no-underscore-dangle\n if (commandArgs._unknown && commandArgs._unknown.length > 0) {\n const errors: string[] = [];\n\n // eslint-disable-next-line no-underscore-dangle\n commandArgs._unknown.forEach((unknownOption) => {\n const isOption = unknownOption.startsWith(\"--\");\n\n let error = `Found unknown ${isOption ? \"option\" : \"argument\"} \"${unknownOption}\"`;\n\n if (isOption) {\n const foundAlternatives = findAlternatives(unknownOption.replace(\"--\", \"\"), [\n ...(command.options ?? []).map((option) => option.name),\n ...defaultOptions.map((option) => option.name),\n ]);\n\n if (foundAlternatives.length > 0) {\n const [first, ...rest] = foundAlternatives.map((alternative) => `--${alternative}`);\n\n error += rest.length > 0 ? `, did you mean ${first} or ${rest.join(\", \")}?` : `, did you mean ${first}?`;\n }\n }\n\n errors.push(error);\n });\n\n if (errors.length > 0) {\n // eslint-disable-next-line unicorn/error-message\n throw new Error(errors.join(\"\\n\"));\n }\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private validateCommandArgsForConflicts<T>(arguments_: PossibleOptionDefinition<T>[], commandArguments: IToolbox[\"options\"], command: ICommand): void {\n const conflicts = arguments_.filter((argument) => argument.conflicts !== undefined);\n\n if (conflicts.length > 0) {\n const conflict = conflicts.find((argument) => {\n if (Array.isArray(argument.conflicts)) {\n // eslint-disable-next-line security/detect-object-injection\n return argument.conflicts.some((c) => commandArguments[c] !== undefined);\n }\n\n return commandArguments[argument.conflicts as string] !== undefined;\n });\n\n if (conflict) {\n throw new Error(\n `You called the command \"${command.name}\" with conflicting options: ${conflict.name} and ${\n typeof conflict.conflicts === \"string\" ? conflict.conflicts : conflict.conflicts?.join(\", \")\n }`,\n );\n }\n }\n }\n\n private addNegatableOption<OT>(command: ICommand): void {\n if (Array.isArray(command.options)) {\n command.options.forEach((option) => {\n if (option.name.startsWith(\"no-\") && !(command.options as OptionDefinition<OT>[]).some((o) => o.name === option.name.replace(\"no-\", \"\"))) {\n if (option.type !== Boolean) {\n this.logger.debug(`Cannot add negated option \"${option.name}\" to command \"${command.name}\" because it is not a boolean.`);\n\n return;\n }\n\n const negatedOption = {\n ...option,\n defaultValue: option.defaultValue === undefined ? true : !option.defaultValue,\n name: `${option.name.replace(\"no-\", \"\")}`,\n } as OptionDefinition<OT>;\n\n (command.options as OptionDefinition<OT>[]).push(negatedOption);\n }\n });\n }\n }\n\n private async registerExtensions(toolbox: IToolbox): Promise<void> {\n const callback = async (extension: IExtension) => {\n if (typeof extension.execute !== \"function\") {\n this.logger.warn(`Skipped ${extension.name} because execute is not a function.`);\n\n return null;\n }\n\n await extension.execute(toolbox as IToolbox);\n\n return null;\n };\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const extension of this.extensions) {\n // eslint-disable-next-line no-await-in-loop\n await callback(extension);\n }\n }\n\n // combining negatable options with their non-negated counterparts\n\n private mapNegatableOptions(toolbox: IToolbox, command: ICommand): void {\n Object.entries(toolbox.options as IToolbox[\"options\"]).forEach(([key, value]) => {\n if (/^no\\w+/.test(key)) {\n const nonNegatedKey: string = lowerFirstChar(key.replace(\"no\", \"\"));\n\n this.logger.debug(`mapping negated option \"${key}\" to \"${nonNegatedKey}\"`);\n\n // eslint-disable-next-line security/detect-object-injection,no-param-reassign\n (toolbox.options as IOptions[\"options\"])[nonNegatedKey] = !value;\n\n command.options?.forEach((option) => {\n if (option.name === nonNegatedKey) {\n // eslint-disable-next-line no-underscore-dangle,no-param-reassign\n option.__negated__ = true;\n }\n });\n }\n });\n }\n\n // Apply any implied option values, if option is undefined or default value.\n // eslint-disable-next-line class-methods-use-this\n private mapImpliesOptions(toolbox: IToolbox, command: ICommand): void {\n Object.keys(toolbox.options as IToolbox[\"options\"]).forEach((optionKey) => {\n const option = command.options?.find(\n // eslint-disable-next-line no-underscore-dangle\n (o) => o.__camelCaseName__ === optionKey && o.__negated__ === undefined && o.implies !== undefined,\n );\n\n if (option?.implies) {\n const implies = option.implies as Record<string, unknown>;\n\n Object.entries(implies).forEach(([key, value]) => {\n // eslint-disable-next-line security/detect-object-injection\n if (toolbox.options[key] === undefined) {\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n toolbox.options[key] = value;\n } else {\n const impliedOption = command.options?.find((cOption) => cOption.name === key);\n\n // eslint-disable-next-line security/detect-object-injection\n if (impliedOption?.defaultValue === undefined || toolbox.options[key] === impliedOption.defaultValue) {\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n toolbox.options[key] = value;\n }\n }\n });\n }\n });\n }\n}\n","const UPPERCASE = /[\\p{Lu}]/u;\nconst LOWERCASE = /[\\p{Ll}]/u;\nconst LEADING_CAPITAL = /^[\\p{Lu}](?![\\p{Lu}])/gu;\nconst IDENTIFIER = /([\\p{Alpha}\\p{N}_]|$)/u;\nconst SEPARATORS = /[_.\\- ]+/;\n\nconst LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);\nconst SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');\nconst NUMBERS_AND_IDENTIFIER = new RegExp('\\\\d+' + IDENTIFIER.source, 'gu');\n\nconst preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase) => {\n\tlet isLastCharLower = false;\n\tlet isLastCharUpper = false;\n\tlet isLastLastCharUpper = false;\n\tlet isLastLastCharPreserved = false;\n\n\tfor (let index = 0; index < string.length; index++) {\n\t\tconst character = string[index];\n\t\tisLastLastCharPreserved = index > 2 ? string[index - 3] === '-' : true;\n\n\t\tif (isLastCharLower && UPPERCASE.test(character)) {\n\t\t\tstring = string.slice(0, index) + '-' + string.slice(index);\n\t\t\tisLastCharLower = false;\n\t\t\tisLastLastCharUpper = isLastCharUpper;\n\t\t\tisLastCharUpper = true;\n\t\t\tindex++;\n\t\t} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase)) {\n\t\t\tstring = string.slice(0, index - 1) + '-' + string.slice(index - 1);\n\t\t\tisLastLastCharUpper = isLastCharUpper;\n\t\t\tisLastCharUpper = false;\n\t\t\tisLastCharLower = true;\n\t\t} else {\n\t\t\tisLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;\n\t\t\tisLastLastCharUpper = isLastCharUpper;\n\t\t\tisLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;\n\t\t}\n\t}\n\n\treturn string;\n};\n\nconst preserveConsecutiveUppercase = (input, toLowerCase) => {\n\tLEADING_CAPITAL.lastIndex = 0;\n\n\treturn input.replaceAll(LEADING_CAPITAL, match => toLowerCase(match));\n};\n\nconst postProcess = (input, toUpperCase) => {\n\tSEPARATORS_AND_IDENTIFIER.lastIndex = 0;\n\tNUMBERS_AND_IDENTIFIER.lastIndex = 0;\n\n\treturn input\n\t\t.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))\n\t\t.replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));\n};\n\nexport default function camelCase(input, options) {\n\tif (!(typeof input === 'string' || Array.isArray(input))) {\n\t\tthrow new TypeError('Expected the input to be `string | string[]`');\n\t}\n\n\toptions = {\n\t\tpascalCase: false,\n\t\tpreserveConsecutiveUppercase: false,\n\t\t...options,\n\t};\n\n\tif (Array.isArray(input)) {\n\t\tinput = input.map(x => x.trim())\n\t\t\t.filter(x => x.length)\n\t\t\t.join('-');\n\t} else {\n\t\tinput = input.trim();\n\t}\n\n\tif (input.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst toLowerCase = options.locale === false\n\t\t? string => string.toLowerCase()\n\t\t: string => string.toLocaleLowerCase(options.locale);\n\n\tconst toUpperCase = options.locale === false\n\t\t? string => string.toUpperCase()\n\t\t: string => string.toLocaleUpperCase(options.locale);\n\n\tif (input.length === 1) {\n\t\tif (SEPARATORS.test(input)) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn options.pascalCase ? toUpperCase(input) : toLowerCase(input);\n\t}\n\n\tconst hasUpperCase = input !== toLowerCase(input);\n\n\tif (hasUpperCase) {\n\t\tinput = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);\n\t}\n\n\tinput = input.replace(LEADING_SEPARATORS, '');\n\tinput = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);\n\n\tif (options.pascalCase) {\n\t\tinput = toUpperCase(input.charAt(0)) + input.slice(1);\n\t}\n\n\treturn postProcess(input, toUpperCase);\n}\n","import type { Pail } from \"@visulima/pail/server\";\n\nimport type { Cli as ICli, Command as ICommand, Toolbox as IToolbox } from \"../@types\";\nimport type { OptionDefinition } from \"../@types/command\";\nimport type { Section } from \"../@types/command-line-usage\";\nimport defaultOptions from \"../default-options\";\nimport commandLineUsage from \"../util/command-line-usage\";\nimport templateFormat from \"../util/template-format\";\n\nconst EMPTY_GROUP_KEY = \"__Other\";\n\nconst upperFirstChar = (string_: string): string => string_.charAt(0).toUpperCase() + string_.slice(1);\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst printGeneralHelp = (logger: Pail<never, string>, runtime: ICli, commands: Map<string, ICommand>, groupOption: string | undefined) => {\n logger.debug(\"no command given, printing general help...\");\n\n let filteredCommands = [...new Set(commands.values())].filter((command) => !command.hidden);\n\n if (groupOption) {\n filteredCommands = filteredCommands.filter((command) => command.group === groupOption);\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n const groupedCommands: Record<string, ICommand[]> = filteredCommands.reduce<Record<string, ICommand[]>>((accumulator, command) => {\n const group = command.group ?? EMPTY_GROUP_KEY;\n\n // eslint-disable-next-line security/detect-object-injection\n if (!accumulator[group]) {\n // eslint-disable-next-line security/detect-object-injection\n accumulator[group] = [];\n }\n\n // eslint-disable-next-line security/detect-object-injection\n (accumulator[group] as ICommand[]).push(command);\n\n return accumulator;\n }, {});\n\n logger.raw(\n commandLineUsage(\n [\n {\n content: `{cyan ${runtime.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,\n header: \"{inverse.cyan Usage }\",\n },\n ...Object.keys(groupedCommands).map((key) => {\n return {\n // eslint-disable-next-line security/detect-object-injection\n content: (groupedCommands[key] as ICommand[]).map((command) => {\n let aliases = \"\";\n\n if (typeof command.alias === \"string\") {\n aliases = command.alias;\n } else if (Array.isArray(command.alias)) {\n aliases = command.alias.join(\", \");\n }\n\n if (aliases !== \"\") {\n aliases = ` [${aliases}]`;\n }\n\n return [`{green ${command.name}} ${aliases}`, command.description ?? \"\"];\n }),\n header:\n key === EMPTY_GROUP_KEY || groupOption\n ? `{inverse.green Available${groupOption ? ` ${upperFirstChar(groupOption)}` : \"\"} Commands }`\n : ` {inverse.green ${upperFirstChar(key)} }`,\n };\n }),\n commands.has(\"help\")\n ? {\n header: \"{inverse.yellow Command Options }\",\n optionList: (commands.get(\"help\") as ICommand).options?.filter((option) => !option.hidden),\n }\n : undefined,\n { header: \"{inverse.yellow Global Options }\", optionList: defaultOptions },\n {\n content: `Run \"{cyan ${runtime.getCliName()}} {green help <command>}\" or \"{cyan ${runtime.getCliName()}} {green <command>} {yellow --help}\" for help with a specific command.`,\n raw: true,\n },\n ].filter(Boolean),\n ),\n );\n};\n\nconst printCommandHelp = (logger: Pail<never, string>, runtime: ICli, commands: Map<string, ICommand>, name: string): void => {\n const command = commands.get(name) as ICommand;\n\n const usageGroups: Section[] = [];\n\n usageGroups.push({\n content: `{cyan ${runtime.getCliName()}} {green ${command.name}}${command.argument ? \" [positional arguments]\" : \"\"}${\n command.options ? \" [options]\" : \"\"\n }`,\n header: \"{inverse.cyan Usage }\",\n });\n\n if (command.description) {\n usageGroups.push({ content: command.description, header: \"{inverse.green Description }\" });\n }\n\n if (command.argument) {\n usageGroups.push({ header: \"Command Positional Arguments\", isArgument: true, optionList: [command.argument] });\n }\n\n if (Array.isArray(command.options) && command.options.length > 0) {\n usageGroups.push({\n header: \"{inverse.yellow Command Options }\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionList: command.options.filter((option) => !option.hidden) as OptionDefinition<any>[],\n });\n }\n\n usageGroups.push({ header: \"{inverse.yellow Global Options }\", optionList: defaultOptions });\n\n if (command.alias !== undefined && command.alias.length > 0) {\n let alias: string[] = command.alias as string[];\n\n if (typeof command.alias === \"string\") {\n alias = [command.alias];\n }\n\n usageGroups.splice(1, 0, {\n content: alias,\n header: \"Alias(es)\",\n });\n }\n\n if (Array.isArray(command.examples) && command.examples.length > 0) {\n usageGroups.push({\n content: command.examples,\n header: \"Examples\",\n });\n }\n\n logger.raw(commandLineUsage(usageGroups));\n};\n\nclass HelpCommand implements ICommand {\n public name = \"help\";\n\n public options = [\n {\n description: \"Display only the specified group\",\n name: \"group\",\n type: String,\n } as OptionDefinition<string>,\n ];\n\n private readonly commands: Map<string, ICommand>;\n\n public constructor(commands: Map<string, ICommand>) {\n this.commands = commands;\n }\n\n public execute(toolbox: IToolbox): void {\n const { commandName, logger, options, runtime } = toolbox;\n\n const { footer, header } = runtime.getCommandSection();\n\n if (header) {\n logger.raw(templateFormat(header as string));\n }\n\n if (commandName === \"help\") {\n printGeneralHelp(logger, runtime, this.commands, options?.group);\n } else {\n printCommandHelp(logger, runtime, this.commands, commandName as string);\n }\n\n if (footer) {\n logger.raw(templateFormat(footer as string));\n }\n }\n}\n\nexport default HelpCommand;\n","import type { PossibleOptionDefinition } from \"./@types/command\";\n\nconst defaultOptions: PossibleOptionDefinition<boolean>[] = [\n {\n description: \"Turn on verbose output\",\n group: \"global\",\n name: \"verbose\",\n type: Boolean,\n },\n {\n description: \"Turn on debugging output\",\n group: \"global\",\n name: \"debug\",\n type: Boolean,\n },\n {\n alias: \"h\",\n description: \"Print out helpful usage information\",\n group: \"global\",\n name: \"help\",\n type: Boolean,\n },\n {\n alias: \"q\",\n description: \"Silence output\",\n group: \"global\",\n name: \"quiet\",\n type: Boolean,\n },\n {\n alias: \"V\",\n description: \"Print version info\",\n group: \"global\",\n name: \"version\",\n type: Boolean,\n },\n {\n description: \"Turn off colored output\",\n group: \"global\",\n name: \"no-color\",\n type: Boolean,\n },\n {\n description: \"Force colored output\",\n group: \"global\",\n name: \"color\",\n type: Boolean,\n },\n];\n\nexport default defaultOptions;\n","import type { Content as IContent, OptionList as IOptionList, Section as ISection } from \"../../@types/command-line-usage\";\nimport ContentSection from \"./section/content-section\";\nimport OptionList from \"./section/option-list-section\";\n\nconst commandLineUsage = (sections: ISection[]): string => {\n const lines = Array.isArray(sections) ? sections : [sections];\n\n if (lines.length === 0) {\n return \"\";\n }\n\n return `\\n${sections\n .map((section) => {\n if ((section as IOptionList).optionList) {\n return new OptionList(section).toString();\n }\n\n return new ContentSection(section as IContent).toString();\n })\n .join(\"\\n\")}`;\n};\n\nexport default commandLineUsage;\n","import type { TableInstanceOptions } from \"cli-table3\";\nimport CliTable3 from \"cli-table3\";\n\nimport type { Content as IContent } from \"../../../@types/command-line-usage\";\nimport templateFormat from \"../../template-format\";\nimport BaseSection from \"./base-section\";\n\nconst defaultTableOptions: Partial<TableInstanceOptions> = {\n chars: {\n bottom: \"\",\n \"bottom-left\": \"\",\n \"bottom-mid\": \"\",\n \"bottom-right\": \"\",\n left: \" \",\n \"left-mid\": \"\",\n mid: \"\",\n \"mid-mid\": \"\",\n middle: \" \",\n right: \"\",\n \"right-mid\": \"\",\n top: \"\",\n \"top-left\": \"\",\n \"top-mid\": \"\",\n \"top-right\": \"\",\n },\n colWidths: [40, 60],\n style: { border: [], compact: true, head: [], \"padding-left\": 2, \"padding-right\": 1 },\n wordWrap: true,\n};\n\n/**\n * A Content section comprises a header and one or more lines of content.\n * @property header The section header, always bold and underlined.\n * @property content Overloaded property, accepting data in one of four formats:\n *\n * 1. A single string (one line of text)\n * 2. An array of strings (multiple lines of text)\n * 3. An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are consistent throughout the array.\n * 4. An object with two properties - `data` and `options`. In this case, the data and options will be passed directly to the underlying [table](https://github.com/cli-table/cli-table3) module for rendering.\n *\n * @property raw - Set to true to avoid indentation and wrapping. Useful for banners.\n * @example\n * Simple string of content. For ansi formatting, use [colorize template literal syntax](https://github.com/visulima/visulima/tree/main/packages/colorize#tagged-template-literals).\n * ```js\n * {\n * header: 'A typical app',\n * content: 'Generates something {rgb(255,200,0).italic very {underline.bgRed important}}.'\n * }\n * ```\n *\n * An array of strings is interpreted as lines, to be joined by the system newline character.\n * ```js\n * {\n * header: 'A typical app',\n * content: [\n * 'First line.',\n * 'Second line.'\n * ],\n * }\n * ```\n *\n * An array of arrays is rendered in table layout.\n * ```js\n * {\n * header: 'A typical app',\n * content: [\n * [ 'First row, first column.', 'First row, second column.', ],\n * [ 'Second row, first column.', 'Second row, second column.', ],\n * ]\n * }\n * ```\n *\n * An object with `data` and `options` properties will be passed directly to the underlying [table](https://github.com/cli-table/cli-table3) module for rendering.\n * ```js\n * {\n * header: 'A typical app',\n * content: {\n * data: [\n * [ 'First row, first column.', 'First row, second column.', ],\n * [ 'Second row, first column.', 'Second row, second column.', ],\n * 'Second row, first column.',\n * ],\n * options: {\n * colWidths: [80],\n * }\n * }\n * }\n * ```\n */\nclass ContentSection extends BaseSection {\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public constructor(section: IContent) {\n super();\n\n if (section.header) {\n this.header(templateFormat(section.header));\n }\n\n if (section.content) {\n /* add content without indentation or wrapping */\n if (section.raw) {\n if (Array.isArray(section.content) && section.content.every((value) => typeof value === \"string\")) {\n section.content.forEach((row) => {\n if (Array.isArray(row)) {\n row.forEach((cell) => this.add(templateFormat(cell)));\n } else {\n this.add(templateFormat(row));\n }\n });\n } else if (typeof section.content === \"string\") {\n this.add(templateFormat(section.content));\n } else {\n throw new TypeError(\"Invalid raw content, must be a string or array of strings.\");\n }\n } else {\n this.add(this.getContentLines(section.content));\n }\n\n this.add(\"\");\n }\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,class-methods-use-this\n private getContentLines(content: IContent[\"content\"]) {\n if (typeof content === \"string\") {\n const table = new CliTable3({\n ...defaultTableOptions,\n colWidths: [80],\n });\n\n table.push([templateFormat(content)]);\n\n return table.toString();\n }\n\n if (\n Array.isArray(content) &&\n // eslint-disable-next-line @typescript-eslint/no-shadow\n content.every((value) => typeof value === \"string\" || (Array.isArray(value) && value.every((value) => typeof value === \"string\")))\n ) {\n const table = new CliTable3({\n ...defaultTableOptions,\n });\n\n content.forEach((row) => {\n if (Array.isArray(row)) {\n table.push(row.map((cell) => templateFormat(cell)));\n } else {\n table.push([templateFormat(row)]);\n }\n });\n\n return table.toString();\n }\n\n if (typeof content === \"object\") {\n const contentObject = content as { data?: string[] | string[][]; options?: TableInstanceOptions };\n\n if (!contentObject.options || !contentObject.data) {\n throw new Error(`Must have an \"options\" or \"data\" property\\n${JSON.stringify(content)}`);\n }\n\n const table = new CliTable3({\n ...defaultTableOptions,\n ...contentObject.options,\n style: { ...defaultTableOptions.style, ...contentObject.options.style },\n });\n\n contentObject.data.forEach((row) => {\n if (Array.isArray(row)) {\n table.push(row.map((cell) => templateFormat(cell)));\n } else {\n table.push([templateFormat(row)]);\n }\n });\n\n return table.toString();\n }\n\n throw new Error(`invalid input - 'content' must be a string, array of strings or a object:\\n\\n${JSON.stringify(content)}`);\n }\n}\n\nexport default ContentSection;\n","// eslint-disable-next-line import/no-named-as-default\nimport template from \"@visulima/colorize/template\";\n\nconst templateFormat = (string_?: string): string => {\n if (string_) {\n return template(Object.assign([], { raw: [string_.replaceAll(\"`\", \"\\\\`\")] }));\n }\n\n return \"\";\n};\n\nexport default templateFormat;\n","import os from \"node:os\";\n\nimport { bold } from \"@visulima/colorize\";\n\nclass BaseSection {\n protected lines: string[];\n\n public constructor() {\n this.lines = [];\n }\n\n public add(line: string): void {\n this.lines.push(line);\n }\n\n public toString(): string {\n return this.lines.join(os.EOL);\n }\n\n public header(text: string): void {\n this.add(bold(text));\n\n this.lines.push(\"\");\n }\n}\n\nexport default BaseSection;\n","import CliTable3 from \"cli-table3\";\n\nimport type { ArgumentDefinition, OptionDefinition as IOptionDefinition } from \"../../../@types/command\";\nimport type { OptionList as IOptionList } from \"../../../@types/command-line-usage\";\nimport templateFormat from \"../../template-format\";\nimport BaseSection from \"./base-section\";\n\nclass OptionListSection extends BaseSection {\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public constructor(data: IOptionList) {\n super();\n\n let definitions = data.optionList ?? [];\n\n const hide = Array.isArray(data.hide) ? data.hide : ([data.hide].filter(Boolean) as string[]);\n const groups = Array.isArray(data.group) ? data.group : ([data.group].filter(Boolean) as string[]);\n\n /* filter out hidden definitions */\n if (hide.length > 0) {\n definitions = definitions.filter((definition) => !hide.includes(definition.name));\n }\n\n if (data.header) {\n this.header(templateFormat(data.header));\n }\n\n if (groups.length > 0) {\n definitions = definitions.filter((definition) => {\n const noGroupMatch = groups.includes(\"_none\") && !definition.group;\n const groupMatch = this.intersect(Array.isArray(definition.group) ? definition.group : [definition.group], groups);\n\n return noGroupMatch || groupMatch ? definition : undefined;\n });\n }\n\n const table = new CliTable3({\n chars: {\n bottom: \"\",\n \"bottom-left\": \"\",\n \"bottom-mid\": \"\",\n \"bottom-right\": \"\",\n left: \" \",\n \"left-mid\": \"\",\n mid: \"\",\n \"mid-mid\": \"\",\n middle: \" \",\n right: \"\",\n \"right-mid\": \"\",\n top: \"\",\n \"top-left\": \"\",\n \"top-mid\": \"\",\n \"top-right\": \"\",\n },\n colWidths: [40, 40],\n style: { \"padding-left\": 2, \"padding-right\": 1 },\n wordWrap: true,\n });\n\n definitions.forEach((definition) =>\n table.push([this.getOptionNames(definition, data.reverseNameOrder ?? false, data.isArgument ?? false), templateFormat(definition.description)]),\n );\n\n this.add(table.toString());\n\n this.lines.push(\"\");\n }\n\n // eslint-disable-next-line class-methods-use-this,sonarjs/cognitive-complexity,@typescript-eslint/no-explicit-any\n private getOptionNames(definition: ArgumentDefinition | IOptionDefinition<any>, reverseNameOrder: boolean, isArgument: boolean): string {\n if (!definition.name) {\n throw new TypeError(\"Invalid option definition, name is required.\");\n }\n\n let type = definition.type ? definition.type.name.toLowerCase() : \"string\";\n\n const multiple = definition.multiple || definition.lazyMultiple ? \"[]\" : \"\";\n\n type = templateFormat(definition.typeLabel ?? `{underline ${type}${multiple}}`);\n\n let result: string;\n\n if (definition.alias) {\n if (definition.name) {\n const name = isArgument ? definition.name : `{yellow --${definition.name}}`;\n\n result = reverseNameOrder\n ? templateFormat(`{bold ${name}}, {bold -${definition.alias}} ${type}`)\n : templateFormat(`{bold -${definition.alias}}, {bold ${name}} ${type}`);\n } else if (reverseNameOrder) {\n result = templateFormat(`{bold -${definition.alias}} ${type}`);\n } else {\n result = templateFormat(`{bold -${definition.alias}} ${type}`);\n }\n } else {\n result = templateFormat(`{bold ${isArgument ? definition.name : `{yellow --${definition.name}}`}} ${type}`);\n }\n\n return result;\n }\n\n // eslint-disable-next-line class-methods-use-this\n private intersect(array1: (string | undefined)[], array2: (string | undefined)[]) {\n return array1.some((item1) => array2.includes(item1));\n }\n}\n\n/**\n * An OptionList section adds a table displaying the supplied option definitions.\n *\n * @property {string} [header] - The section header, always bold and underlined.\n * @property optionList {OptionDefinition[]} - An array of [option definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md) objects. In addition to the regular definition properties, command-line-usage will look for:\n *\n * - `description` - a string describing the option.\n * - `typeLabel` - a string to replace the default type string (e.g. `<string>`). It's often more useful to set a more descriptive type label, like `<ms>`, `<files>`, `<command>` etc.\n * @property {string|string[]} [group] - If specified, only options from this particular group will be printed. [Example](https://github.com/75lb/command-line-usage/blob/master/example/groups.js).\n * @property {string|string[]} [hide] - The names of one of more option definitions to hide from the option list. [Example](https://github.com/75lb/command-line-usage/blob/master/example/hide.js).\n * @property {boolean} [reverseNameOrder] - If true, the option alias will be displayed after the name, i.e. `--verbose, -v` instead of `-v, --verbose`).\n * @property {object} [tableOptions] - An options object suitable for passing into [table-layout](https://github.com/75lb/table-layout#table-). See [here for an example](https://github.com/75lb/command-line-usage/blob/master/example/option-list-options.js).\n *\n * @example\n * {\n * header: 'Options',\n * optionList: [\n * {\n * name: 'help',\n * alias: 'h',\n * description: 'Display this usage guide.'\n * },\n * {\n * name: 'src',\n * description: 'The input files to process',\n * multiple: true,\n * defaultOption: true,\n * typeLabel: '{underline file} ...'\n * },\n * {\n * name: 'timeout',\n * description: 'Timeout value in ms.',\n * alias: 't',\n * typeLabel: '{underline ms}'\n * }\n * ]\n * }\n */\nexport default OptionListSection;\n","import type { Command as ICommand } from \"../@types\";\n\nexport default {\n alias: [\"v\", \"V\"],\n description: \"Output the version number\",\n execute: ({ logger, runtime }) => {\n const version = runtime.getPackageVersion();\n\n if (version === undefined) {\n logger.warn(\"Unknown version\");\n logger.debug(\"The version number was not provided by the cli constructor.\");\n } else {\n logger.info(version);\n }\n },\n name: \"version\",\n options: [],\n usage: [],\n} as ICommand;\n","/**\n * Output with this option will be formatted.\n */\n// eslint-disable-next-line import/no-unused-modules\nexport const OUTPUT_NORMAL = 1;\n\n/**\n * Output with this option will be passed as-is.\n */\n// eslint-disable-next-line import/no-unused-modules\nexport const OUTPUT_RAW = 2;\n\n/**\n * Output with this option will have any formatting stripped away.\n */\n// eslint-disable-next-line import/no-unused-modules\nexport const OUTPUT_PLAIN = 4;\n\n/**\n * Output with this verbosity won't write anything at all.\n */\nexport const VERBOSITY_QUIET = 16;\n\n/**\n * Output with this verbosity will write default content.\n */\nexport const VERBOSITY_NORMAL = 32;\n\n/**\n * Output with this verbosity will be more detailed.\n */\nexport const VERBOSITY_VERBOSE = 64;\n\n/**\n * Output with this verbosity will reveal internals.\n */\nexport const VERBOSITY_DEBUG = 128;\n\nexport const POSITIONALS_KEY = \"positionals\";\n","import type { Toolbox as IToolbox } from \"./@types\";\n\nclass EmptyToolbox implements Partial<IToolbox> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [x: string]: any;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public result: any;\n\n public argv?: IToolbox[\"argv\"];\n\n public options?: IToolbox[\"options\"];\n\n public argument?: IToolbox[\"argument\"];\n\n public command: IToolbox[\"command\"];\n\n public commandName: IToolbox[\"commandName\"];\n\n public runtime?: IToolbox[\"runtime\"];\n\n public logger?: IToolbox[\"logger\"];\n\n public constructor(commandName: IToolbox[\"commandName\"], command: IToolbox[\"command\"]) {\n this.commandName = commandName;\n this.command = command;\n }\n}\n\nexport default EmptyToolbox;\n","/**\n * See https://github.com/visulima/cerebro#supported-nodejs-versions for our\n * version support policy. The CEREBRO_MIN_NODE_VERSION is used for testing only.\n */\nconst checkNodeVersion = (): void => {\n const minNodeVersion = process.env.CEREBRO_MIN_NODE_VERSION ? Number(process.env.CEREBRO_MIN_NODE_VERSION) : 18;\n\n const nodeVersion = process.version.replace(\"v\", \"\");\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const major = Number(/v([^.]+)/.exec(process.version)![1]);\n\n if (major < minNodeVersion) {\n // eslint-disable-next-line no-console\n console.log(\n `cerebro supports a minimum Node version of ${minNodeVersion}. You have ${nodeVersion}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`,\n );\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n};\n\nexport default checkNodeVersion;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\nimport getParameterOption from \"./get-parameter-option\";\nimport isBoolean from \"./option-is-boolean\";\n\ntype PartialAndLastOption<T> = {\n lastName?: string | undefined;\n lastOption?: PossibleOptionDefinition<T> | undefined;\n partial: Partial<T>;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst convertType = <T>(value: any, option: PossibleOptionDefinition<T>): any => {\n if (option.type === undefined) {\n return value;\n }\n\n if (option.type.name === \"Boolean\") {\n if (value === \"true\" || value === \"1\") {\n return option.type(true);\n }\n\n if (value === \"false\" || value === \"0\") {\n return option.type(false);\n }\n }\n\n return option.type(value);\n};\n\nconst booleanValue = new Set([\"1\", \"0\", \"true\", \"false\"]);\n\n/**\n * Gets the values of any boolean arguments that were specified on the command line with a value\n * These arguments were removed by removeBooleanValues\n */\nconst getBooleanValues = <T>(arguments_: string[], options: PossibleOptionDefinition<T>[]): Partial<T> => {\n const getBooleanValue = (argumentsAndLastOption: PartialAndLastOption<T>, argument: string): PartialAndLastOption<T> => {\n const { argName, argValue, option } = getParameterOption<T>(argument, options);\n\n const { lastOption } = argumentsAndLastOption;\n\n if (option && isBoolean(option) && argValue && argName) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-param-reassign\n argumentsAndLastOption.partial[argName as keyof PartialAndLastOption<T>[\"partial\"]] = convertType(argValue, option) as any;\n } else if (argumentsAndLastOption.lastName && lastOption && isBoolean(lastOption) && booleanValue.has(argument)) {\n // eslint-disable-next-line no-param-reassign\n argumentsAndLastOption.partial[argumentsAndLastOption.lastName as keyof PartialAndLastOption<T>[\"partial\"]] = convertType(\n argument,\n lastOption,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n }\n\n return { lastName: argName, lastOption: option, partial: argumentsAndLastOption.partial };\n };\n\n // eslint-disable-next-line unicorn/no-array-callback-reference,unicorn/no-array-reduce\n return arguments_.reduce<PartialAndLastOption<T>>(getBooleanValue, { partial: {} }).partial;\n};\n\nexport default getBooleanValues;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\n\n// eslint-disable-next-line security/detect-unsafe-regex\nconst argumentNameRegExp = /^-{1,2}(\\w+)(=(\\w+))?$/;\n\nconst getParameterOption = <T>(\n argument: string,\n options: PossibleOptionDefinition<T>[],\n): {\n argName?: string;\n argValue?: string;\n option?: PossibleOptionDefinition<T>;\n} => {\n const regExpResult = argumentNameRegExp.exec(argument);\n\n if (regExpResult == null) {\n return {};\n }\n\n const nameOrAlias = regExpResult[1];\n\n const option = options.find((o) => o.name === nameOrAlias || o.alias === nameOrAlias);\n\n if (option !== undefined) {\n return { argName: option.name, argValue: regExpResult[3] as string, option };\n }\n\n return {};\n};\n\nexport default getParameterOption;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\n\nconst isBoolean = <T>(option: PossibleOptionDefinition<T>): boolean => option.type?.name === \"Boolean\";\n\nexport default isBoolean;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\nimport isBoolean from \"./option-is-boolean\";\n\nconst getTypeLabel = <T>(definition: PossibleOptionDefinition<T>) => {\n let typeLabel = definition.type ? definition.type.name.toLowerCase() : \"string\";\n\n const multiple = definition.multiple ?? definition.lazyMultiple ? \"[]\" : \"\";\n\n if (typeLabel) {\n typeLabel = typeLabel === \"boolean\" ? \"\" : `{underline ${typeLabel}${multiple}}`;\n }\n\n return typeLabel;\n};\n\nconst mapOptionTypeLabel = <T>(definition: PossibleOptionDefinition<T>): PossibleOptionDefinition<T> => {\n if (isBoolean(definition)) {\n return definition;\n }\n\n // eslint-disable-next-line no-param-reassign\n definition.typeLabel = definition.typeLabel ?? getTypeLabel<T>(definition);\n\n if (definition.defaultOption) {\n // eslint-disable-next-line no-param-reassign\n definition.typeLabel = `${definition.typeLabel} (D)`;\n }\n\n if (definition.required) {\n // eslint-disable-next-line no-param-reassign\n definition.typeLabel = `${definition.typeLabel} (R)`;\n }\n\n return definition;\n};\n\nexport default mapOptionTypeLabel;\n","import type { PossibleOptionDefinition } from \"../../@types/command\";\nimport getParameterOption from \"./get-parameter-option\";\nimport isBoolean from \"./option-is-boolean\";\n\ntype ArgumentsAndLastOption<T> = { args: string[]; lastOption?: PossibleOptionDefinition<T> };\n\nconst booleanValue = new Set([\"1\", \"0\", \"true\", \"false\"]);\n\n/**\n * commandLineArgs throws an error if we pass aa value for a boolean arg as follows:\n * myCommand -a=true --booleanArg=false --otherArg true\n * this function removes these booleans so as to avoid errors from commandLineArgs\n */\n\nconst removeBooleanValues = <T>(arguments_: string[], options: PossibleOptionDefinition<T>[]): string[] => {\n const removeBooleanArguments = (argumentsAndLastValue: ArgumentsAndLastOption<T>, argument: string): ArgumentsAndLastOption<T> => {\n const { argValue, option } = getParameterOption(argument, options);\n\n const { lastOption } = argumentsAndLastValue;\n\n if (lastOption && isBoolean(lastOption) && booleanValue.has(argument)) {\n // eslint-disable-next-line no-underscore-dangle,@typescript-eslint/naming-convention\n const copiedArguments_ = [...argumentsAndLastValue.args];\n\n copiedArguments_.pop();\n\n return { args: copiedArguments_ };\n }\n\n if (option && isBoolean(option) && argValue) {\n return { args: argumentsAndLastValue.args };\n }\n\n return { args: [...argumentsAndLastValue.args, argument], lastOption: option as PossibleOptionDefinition<T> };\n };\n\n // eslint-disable-next-line unicorn/no-array-callback-reference,unicorn/no-array-reduce\n return arguments_.reduce<ArgumentsAndLastOption<T>>(removeBooleanArguments, { args: [] }).args;\n};\n\nexport default removeBooleanValues;\n","/**\n * Copied from\n * The MIT License (MIT)\n * Copyright (c) 2015-21 Lloyd Brookes <75pound@gmail.com>\n */\n\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isShort = new RegExp(/^-([^\\d-])$/);\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isLong = new RegExp(/^--(\\S+)/);\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isCombined = new RegExp(/^-([^\\d-]{2,})$/);\n\nconst isOption = (argument: string) => isShort.test(argument) || isLong.test(argument) || isCombined.test(argument);\n\nconst commandLineCommands = (commands: (string | null)[], argv: string[]): { argv: string[]; command: string | null } => {\n /* the command is the first arg, unless it's an option (e.g. --help) */\n const command = (argv[0] && isOption(argv[0])) || argv.length === 0 ? null : argv.shift() ?? null;\n\n if (!commands.includes(command)) {\n const error: Error & { command?: string | null | undefined } = new Error(`Command not recognised: ${command}`);\n error.command = command;\n error.name = \"INVALID_COMMAND\";\n\n throw error;\n }\n\n return { argv, command };\n};\n\nexport default commandLineCommands;\n","import { distance } from \"fastest-levenshtein\";\n\nconst isSimilar = (string1: string, string2: string) => distance(string1, string2) <= string1.length / 3 || string2.includes(string1);\n\nconst findAlternatives = (string: string, array: string[]): string[] => {\n const id = string.toLowerCase();\n\n return array.filter((nextId) => isSimilar(nextId.toLowerCase(), id));\n};\n\nexport default findAlternatives;\n","import type { CommandLineOptions } from \"command-line-args\";\n\nimport type { PossibleOptionDefinition } from \"../@types/command\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst listMissingArguments = <T = any>(commandLineConfig: PossibleOptionDefinition<T>[], parsedArguments: CommandLineOptions): PossibleOptionDefinition<T>[] =>\n commandLineConfig\n .filter((config) => config.required && parsedArguments[config.name] == null)\n .filter((config) => {\n if (config.type?.name === \"Boolean\") {\n // eslint-disable-next-line no-param-reassign\n parsedArguments[config.name] = false;\n\n return false;\n }\n\n return true;\n });\n\nexport default listMissingArguments;\n","import type { PossibleOptionDefinition } from \"../@types/command\";\n\n/**\n * Performs a simple merge of multiple argument lists. Does not mutate given\n * argument lists or argument.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst mergeArguments = <T = any>(argumentLists: PossibleOptionDefinition<T>[]): PossibleOptionDefinition<T>[] => {\n const argumentsByName = new Map<string, PossibleOptionDefinition<T>>();\n\n argumentLists.forEach((argument) => {\n argumentsByName.set(argument.name, { ...argumentsByName.get(argument.name), ...argument });\n });\n\n return [...argumentsByName.values()];\n};\n\nexport default mergeArguments;\n","import hideBin from \"./hide-bin\";\n\nconst COMMAND_DELIMITER = \" \";\n\n// eslint-disable-next-line security/detect-object-injection\nconst equals = (a: string[], b: string[]) => a.length === b.length && a.every((v, index) => v === b[index]);\n\n/**\n * Parses the raw command into an array of strings.\n *\n * @param commandArray Command string or list of command parts.\n * @returns The command as an array of strings.\n */\nconst parseRawCommand = (commandArray: string[] | string): string[] => {\n // use the command line options if not passed in\n if (typeof commandArray === \"string\") {\n return (commandArray as string).split(COMMAND_DELIMITER);\n }\n\n // remove the first 2 options if it comes from process.argv\n if (equals(commandArray as string[], process.argv)) {\n return hideBin(commandArray as string[]);\n }\n\n return commandArray as string[];\n};\n\nexport default parseRawCommand;\n","interface ElectronProcess extends NodeJS.Process {\n defaultApp?: boolean;\n versions: NodeJS.ProcessVersions & {\n electron: string;\n };\n}\n\n// process.versions.electron is either set by electron, or undefined\n// see https://github.com/electron/electron/blob/master/docs/api/process.md#processversionselectron-readonly\nconst isElectronApp = (): boolean => !!(process as ElectronProcess).versions.electron;\n\n// process.defaultApp is either set by electron in an electron unbundled app, or undefined\n// see https://github.com/electron/electron/blob/master/docs/api/process.md#processdefaultapp-readonly\nconst isBundledElectronApp = (): boolean => isElectronApp() && !(process as ElectronProcess).defaultApp;\n\nconst getProcessArgvBinIndex = (): number => {\n // The binary name is the first command line argument for:\n // - bundled Electron apps: bin argv1 argv2 ... argvn\n if (isBundledElectronApp()) {\n return 0;\n }\n\n // or the second one (default) for:\n // - standard node apps: node bin argv1 argv2 ... argvn\n // - unbundled Electron apps: electron bin argv1 arg2 ... argvn\n return 1;\n};\n\nconst hideBin = (argv: string[]): string[] => argv.slice(getProcessArgvBinIndex() + 1);\n\nexport default hideBin;\n","import type { Pail } from \"@visulima/pail/server\";\n\nconst registerExceptionHandler = (logger: Pail<never, string>): void => {\n // we want to see real exceptions with backtraces and stuff\n process.on(\"uncaughtException\", (error: Partial<Error> | null | undefined) => {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n logger.error(`Uncaught exception: ${error}`);\n\n if (error?.stack) {\n logger.error(error.stack);\n }\n\n process.exit(1);\n });\n\n process.on(\"unhandledRejection\", (error: Partial<Error> | null | undefined) => {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n logger.error(`Promise rejection: ${error}`);\n\n if (error?.stack) {\n logger.error(error.stack);\n }\n\n process.exit(1);\n });\n};\n\nexport default registerExceptionHandler;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/cerebro",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "A delightful toolkit for building Node-powered CLIs.",
5
5
  "keywords": [
6
6
  "command",
@@ -79,7 +79,7 @@
79
79
  "dependencies": {
80
80
  "@visulima/boxen": "1.0.10",
81
81
  "@visulima/colorize": "1.4.3",
82
- "@visulima/pail": "1.2.1",
82
+ "@visulima/pail": "1.2.2",
83
83
  "cli-table3": "^0.6.5",
84
84
  "command-line-args": "^5.2.1",
85
85
  "fastest-levenshtein": "^1.0.16"