Skip to content

Commit

Permalink
feat: Upgrade Commander
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed May 11, 2024
1 parent 69a6b3e commit b29a8fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 9 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,10 @@ [email protected]:
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"
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit b29a8fe

Please sign in to comment.