Bump commander to version 9.1.0

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-04-04 15:19:21 +02:00
parent e9b48b20c9
commit 344ea56acc
53 changed files with 309 additions and 285 deletions
+5 -5
View File
@@ -16,7 +16,7 @@
import { relative as relativePath } from 'path';
import { spawn } from 'child_process';
import { Command } from 'commander';
import { OptionValues } from 'commander';
import { findPaths } from '@backstage/cli-common';
import { platform } from 'os';
import { ExitCodeError } from './errors';
@@ -25,7 +25,7 @@ import { ExitCodeError } from './errors';
const paths = findPaths(__dirname);
export function createCodemodAction(name: string) {
return async (_: unknown, cmd: Command) => {
return async (dirs: string[], opts: OptionValues) => {
const transformPath = relativePath(
process.cwd(),
paths.resolveOwn('transforms', `${name}.js`),
@@ -39,12 +39,12 @@ export function createCodemodAction(name: string) {
'--ignore-pattern=**/node_modules/**',
];
if (cmd.dry) {
if (opts.dry) {
args.push('--dry');
}
if (cmd.args.length) {
args.push(...cmd.args);
if (dirs.length) {
args.push(...dirs);
} else {
args.push('.');
}
+3 -3
View File
@@ -20,7 +20,7 @@
* @packageDocumentation
*/
import program from 'commander';
import { program } from 'commander';
import chalk from 'chalk';
import { codemods } from './codemods';
import { exitWithError } from './errors';
@@ -31,14 +31,14 @@ async function main(argv: string[]) {
program.name('backstage-codemods').version(version);
const applyCommand = program
.command('apply <codemod> [<target-dirs...>]')
.command('apply <codemod> [target-dirs...]')
.description(
'Apply a codemod to target directories, defaulting to the current directory',
);
for (const codemod of codemods) {
applyCommand
.command(`${codemod.name} [<target-dirs...>]`)
.command(`${codemod.name} [target-dirs...]`)
.description(codemod.description)
.option('-d, --dry', 'Dry run, no changes written to files')
.action(createCodemodAction(codemod.name));