From b29a8fe9e171808c1e1a53f765b96aaae38a101e Mon Sep 17 00:00:00 2001 From: Benny Neugebauer Date: Sat, 11 May 2024 09:07:50 +0200 Subject: [PATCH] feat: Upgrade Commander --- package.json | 2 +- src/cli.ts | 15 +++++++++------ yarn.lock | 9 +++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index abcf4379..a78d1255 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "axios": "1.6.8", "ci-info": "4.0.0", "cli-interact": "0.1.9", - "commander": "6.2.1", + "commander": "12.0.0", "fs-extra": "11.2.0", "handlebars": "4.7.8", "openapi-types": "8.0.0", diff --git a/src/cli.ts b/src/cli.ts index 52551729..b01568cb 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,12 +1,11 @@ #!/usr/bin/env node - -import program from 'commander'; +import {Command} from 'commander'; import path from 'path'; - import {writeClient} from './Swaxios'; const {bin, description, name, version} = require('../package.json'); const binName = Object.keys(bin)[0] || name; +const program = new Command(); program .name(binName) @@ -17,14 +16,18 @@ program .option('-f, --force', 'Force deleting the output directory before generating') .parse(process.argv); -if (!program.input || !program.output) { +const input = program.getOptionValue('input'); +const output = program.getOptionValue('output'); +const force = program.getOptionValue('force'); + +if (!input || !output) { program.outputHelp(); process.exit(1); } -const outputDirectory = path.resolve(program.output || '.'); +const outputDirectory = path.resolve(output || '.'); -writeClient(program.input, outputDirectory, program.force) +writeClient(input, outputDirectory, force) .then(() => console.log(`Created API client in "${outputDirectory}".`)) .catch(error => { console.error(error); diff --git a/yarn.lock b/yarn.lock index b6c763c0..4fd280f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -764,10 +764,10 @@ commander@11.1.0: resolved "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz#62fdce76006a68e5c1ab3314dc92e800eb83d906" integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ== -commander@6.2.1: - version "6.2.1" - resolved "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" - integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== +commander@12.0.0: + version "12.0.0" + resolved "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz#b929db6df8546080adfd004ab215ed48cf6f2592" + integrity sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA== commander@^2.12.1, commander@^2.9.0: version "2.20.3" @@ -2037,6 +2037,7 @@ string-width@^7.0.0: strip-ansi "^7.1.0" "strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.1: + name strip-ansi-cjs version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==