chore: upgrade commander dependency

Upgrades `commander` to latest version across the repo.
This commit is contained in:
43081j 2024-08-10 00:44:22 +01:00
parent e5960ffe5b
commit aec16d5b49
25 changed files with 54 additions and 57 deletions

View File

@ -337,7 +337,7 @@
"chai": "^4.4.1",
"chalk": "^5.3.0",
"cli-table3": "^0.6.1",
"commander": "^6.2.1",
"commander": "^12.1.0",
"comment-parser": "^1.4.1",
"compression": "^1.7.4",
"copy-to-clipboard": "^3.3.1",

View File

@ -4,7 +4,7 @@ import { addToGlobalContext } from '@storybook/core/telemetry';
import { logger } from '@storybook/core/node-logger';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { findPackageSync } from 'fd-package-json';
import leven from 'leven';
import invariant from 'tiny-invariant';
@ -69,7 +69,7 @@ command('dev')
'URL path to be appended when visiting Storybook for the first time'
)
.action(async (options) => {
logger.setLevel(program.loglevel);
logger.setLevel(options.loglevel);
consoleLogger.log(chalk.bold(`${pkg.name} v${pkg.version}`) + chalk.reset('\n'));
// The key is the field created in `options` variable for
@ -109,7 +109,7 @@ command('build')
.option('--test', 'Build stories optimized for testing purposes.')
.action(async (options) => {
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
logger.setLevel(program.loglevel);
logger.setLevel(options.loglevel);
consoleLogger.log(chalk.bold(`${pkg.name} v${pkg.version}\n`));
// The key is the field created in `options` variable for
@ -132,8 +132,7 @@ program.on('command:*', ([invalidCmd]) => {
' Invalid command: %s.\n See --help for a list of available commands.',
invalidCmd
);
// eslint-disable-next-line no-underscore-dangle
const availableCommands = program.commands.map((cmd) => cmd._name);
const availableCommands = program.commands.map((cmd) => cmd.name());
const suggestion = availableCommands.find((cmd) => leven(cmd, invalidCmd) < 3);
if (suggestion) {
consoleLogger.info(`\n Did you mean ${suggestion}?`);

View File

@ -45,7 +45,7 @@
"@storybook/codemod": "workspace:*",
"@types/semver": "^7.3.4",
"chalk": "^4.1.0",
"commander": "^6.2.1",
"commander": "^12.1.0",
"create-storybook": "workspace:*",
"cross-spawn": "^7.0.3",
"envinfo": "^7.7.3",

View File

@ -8,7 +8,7 @@ import { logger } from 'storybook/internal/node-logger';
import { addToGlobalContext, telemetry } from 'storybook/internal/telemetry';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import envinfo from 'envinfo';
import { findPackageSync } from 'fd-package-json';
import leven from 'leven';
@ -186,8 +186,7 @@ program.on('command:*', ([invalidCmd]) => {
' Invalid command: %s.\n See --help for a list of available commands.',
invalidCmd
);
// eslint-disable-next-line no-underscore-dangle
const availableCommands = program.commands.map((cmd) => cmd._name);
const availableCommands = program.commands.map((cmd) => cmd.name());
const suggestion = availableCommands.find((cmd) => leven(cmd, invalidCmd) < 3);
if (suggestion) {
consoleLogger.info(`\n Did you mean ${suggestion}?`);

View File

@ -57,7 +57,7 @@
"dependencies": {
"@types/semver": "^7.3.4",
"chalk": "^4.1.0",
"commander": "^6.2.1",
"commander": "^12.1.0",
"execa": "^5.0.0",
"fd-package-json": "^1.2.0",
"find-up": "^5.0.0",

View File

@ -1,7 +1,7 @@
import { versions } from 'storybook/internal/common';
import { addToGlobalContext } from 'storybook/internal/telemetry';
import program from 'commander';
import { program } from 'commander';
import { findPackageSync } from 'fd-package-json';
import invariant from 'tiny-invariant';

View File

@ -5664,7 +5664,7 @@ __metadata:
"@types/semver": "npm:^7.3.4"
boxen: "npm:^7.1.1"
chalk: "npm:^4.1.0"
commander: "npm:^6.2.1"
commander: "npm:^12.1.0"
create-storybook: "workspace:*"
cross-spawn: "npm:^7.0.3"
envinfo: "npm:^7.7.3"
@ -5838,7 +5838,7 @@ __metadata:
chai: "npm:^4.4.1"
chalk: "npm:^5.3.0"
cli-table3: "npm:^0.6.1"
commander: "npm:^6.2.1"
commander: "npm:^12.1.0"
comment-parser: "npm:^1.4.1"
compression: "npm:^1.7.4"
copy-to-clipboard: "npm:^3.3.1"
@ -11657,6 +11657,13 @@ __metadata:
languageName: node
linkType: hard
"commander@npm:^12.1.0":
version: 12.1.0
resolution: "commander@npm:12.1.0"
checksum: 10c0/6e1996680c083b3b897bfc1cfe1c58dfbcd9842fd43e1aaf8a795fbc237f65efcc860a3ef457b318e73f29a4f4a28f6403c3d653d021d960e4632dd45bde54a9
languageName: node
linkType: hard
"commander@npm:^2.18.0, commander@npm:^2.19.0, commander@npm:^2.20.0":
version: 2.20.3
resolution: "commander@npm:2.20.3"
@ -11671,13 +11678,6 @@ __metadata:
languageName: node
linkType: hard
"commander@npm:^6.2.1":
version: 6.2.1
resolution: "commander@npm:6.2.1"
checksum: 10c0/85748abd9d18c8bc88febed58b98f66b7c591d9b5017cad459565761d7b29ca13b7783ea2ee5ce84bf235897333706c4ce29adf1ce15c8252780e7000e2ce9ea
languageName: node
linkType: hard
"commander@npm:^8.3.0":
version: 8.3.0
resolution: "commander@npm:8.3.0"
@ -12066,7 +12066,7 @@ __metadata:
"@types/util-deprecate": "npm:^1.0.0"
boxen: "npm:^7.1.1"
chalk: "npm:^4.1.0"
commander: "npm:^6.2.1"
commander: "npm:^12.1.0"
execa: "npm:^5.0.0"
fd-package-json: "npm:^1.2.0"
find-up: "npm:^5.0.0"

View File

@ -1,5 +1,5 @@
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { execaCommand } from 'execa';
import { readJSON } from 'fs-extra';
import { posix, resolve, sep } from 'path';

View File

@ -2,7 +2,7 @@
// without having to build dts files for all packages in the monorepo.
// It is not implemented yet for angular, svelte and vue.
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { execaCommand } from 'execa';
import { readJSON } from 'fs-extra';
import { resolve } from 'path';

View File

@ -100,7 +100,7 @@
"chalk": "^4.1.0",
"chromatic": "^11.5.5",
"codecov": "^3.8.1",
"commander": "^6.2.1",
"commander": "^12.1.0",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"danger": "^12.3.3",

View File

@ -3,7 +3,7 @@
* It will fetch all active runs for the preparation workflows, and cancel them.
*/
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { dedent } from 'ts-dedent';
import { esMain } from '../utils/esmain';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import semver from 'semver';
import { dedent } from 'ts-dedent';
import { z } from 'zod';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { readJson } from 'fs-extra';
import path from 'path';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import semver from 'semver';
import { esMain } from '../utils/esmain';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { esMain } from '../utils/esmain';
import { getCurrentVersion } from './get-current-version';

View File

@ -1,4 +1,4 @@
import program from 'commander';
import { program } from 'commander';
import ora from 'ora';
import { v4 as uuidv4 } from 'uuid';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import ora from 'ora';
import invariant from 'tiny-invariant';

View File

@ -1,5 +1,5 @@
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { execaCommand } from 'execa';
import { readJson } from 'fs-extra';
import pRetry from 'p-retry';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { intersection } from 'lodash';
import { z } from 'zod';

View File

@ -1,6 +1,6 @@
import { setOutput } from '@actions/core';
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { execaCommand } from 'execa';
import { readFile, readJson, writeFile, writeJson } from 'fs-extra';
import path from 'path';

View File

@ -1,5 +1,5 @@
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
import { readFile, writeFile, writeJson } from 'fs-extra';
import path from 'path';
import semver from 'semver';

View File

@ -1,6 +1,6 @@
import chalk from 'chalk';
import { exec } from 'child_process';
import program from 'commander';
import { program } from 'commander';
import { execa, execaSync } from 'execa';
import { pathExists, readJSON, remove } from 'fs-extra';
import { mkdir } from 'fs/promises';

View File

@ -1,4 +1,4 @@
import program from 'commander';
import { program } from 'commander';
import { execaCommand } from 'execa';
import { existsSync } from 'fs';
import { copy, emptyDir, remove, writeFile } from 'fs-extra';

View File

@ -2,7 +2,7 @@
* Use commander and prompts to gather a list of options for a script
*/
import chalk from 'chalk';
import program from 'commander';
import { program } from 'commander';
// eslint-disable-next-line import/extensions
import kebabCase from 'lodash/kebabCase.js';
import prompts from 'prompts';
@ -116,8 +116,14 @@ function longFlag(key: OptionId, option: Option) {
return inverse ? `no-${kebabCase(key)}` : kebabCase(key);
}
function optionFlags(key: OptionId, option: Option) {
const base = `-${shortFlag(key, option)}, --${longFlag(key, option)}`;
function optionFlags(key: OptionId, option: Option, existingOptions: program.Option[]) {
const optionShortFlag = `-${shortFlag(key, option)}`;
let base;
if (existingOptions.some((opt) => opt.short === optionShortFlag)) {
base = `--${longFlag(key, option)}`;
} else {
base = `${optionShortFlag}, --${longFlag(key, option)}`;
}
if (option.type === 'string' || option.type === 'string[]') {
return `${base} <${key}>`;
}
@ -131,7 +137,7 @@ export function getOptions<TOptions extends OptionSpecifier>(
): MaybeOptionValues<TOptions> {
Object.entries(options)
.reduce((acc, [key, option]) => {
const flags = optionFlags(key, option);
const flags = optionFlags(key, option, acc.options);
if (option.type === 'boolean') {
return acc.option(flags, option.description, !!option.inverse);

View File

@ -1536,7 +1536,7 @@ __metadata:
chalk: "npm:^4.1.0"
chromatic: "npm:^11.5.5"
codecov: "npm:^3.8.1"
commander: "npm:^6.2.1"
commander: "npm:^12.1.0"
cross-env: "npm:^7.0.3"
cross-spawn: "npm:^7.0.3"
danger: "npm:^12.3.3"
@ -4124,6 +4124,13 @@ __metadata:
languageName: node
linkType: hard
"commander@npm:^12.1.0, commander@npm:~12.1.0":
version: 12.1.0
resolution: "commander@npm:12.1.0"
checksum: 10c0/6e1996680c083b3b897bfc1cfe1c58dfbcd9842fd43e1aaf8a795fbc237f65efcc860a3ef457b318e73f29a4f4a28f6403c3d653d021d960e4632dd45bde54a9
languageName: node
linkType: hard
"commander@npm:^2.18.0, commander@npm:^2.8.1":
version: 2.20.3
resolution: "commander@npm:2.20.3"
@ -4138,20 +4145,6 @@ __metadata:
languageName: node
linkType: hard
"commander@npm:^6.2.1":
version: 6.2.1
resolution: "commander@npm:6.2.1"
checksum: 10c0/85748abd9d18c8bc88febed58b98f66b7c591d9b5017cad459565761d7b29ca13b7783ea2ee5ce84bf235897333706c4ce29adf1ce15c8252780e7000e2ce9ea
languageName: node
linkType: hard
"commander@npm:~12.1.0":
version: 12.1.0
resolution: "commander@npm:12.1.0"
checksum: 10c0/6e1996680c083b3b897bfc1cfe1c58dfbcd9842fd43e1aaf8a795fbc237f65efcc860a3ef457b318e73f29a4f4a28f6403c3d653d021d960e4632dd45bde54a9
languageName: node
linkType: hard
"compare-versions@npm:^3.6.0":
version: 3.6.0
resolution: "compare-versions@npm:3.6.0"