Upgrade ADF CLI to latest Commander library (#9473)

* build(deps-dev): bump commander from 6.2.1 to 12.0.0

Bumps [commander](https://github.com/tj/commander.js) from 6.2.1 to 12.0.0.
- [Release notes](https://github.com/tj/commander.js/releases)
- [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tj/commander.js/compare/v6.2.1...v12.0.0)

---
updated-dependencies:
- dependency-name: commander
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: migrate CLI to latest commander library

* chore: migrate CLI to latest commander library [ci:force]

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Denys Vuika
2024-03-26 09:36:49 -04:00
committed by GitHub
parent 7cca017c12
commit 9d7608817d
13 changed files with 241 additions and 143 deletions

View File

@@ -22,7 +22,14 @@ import * as ejs from 'ejs';
import * as path from 'path';
import * as fs from 'fs';
import { argv, exit } from 'node:process';
import program from 'commander';
import { Command } from 'commander';
const program = new Command();
interface AuditCommandArgs {
package?: string;
outDir?: string;
}
/**
* Audit report command
@@ -44,10 +51,12 @@ export default function main(_args: string[], workingDir: string) {
exit(0);
}
const options = program.opts<AuditCommandArgs>();
let packagePath = path.resolve(workingDir, 'package.json');
if (program.package) {
packagePath = path.resolve(program.package);
if (options.package) {
packagePath = path.resolve(options.package);
}
if (!fs.existsSync(packagePath)) {
@@ -82,7 +91,7 @@ export default function main(_args: string[], workingDir: string) {
console.error(err);
reject(err);
} else {
const outputPath = path.resolve(program.outDir || workingDir);
const outputPath = path.resolve(options.outDir || workingDir);
const outputFile = path.join(outputPath, `audit-info-${packageJson.version}.md`);
fs.writeFileSync(outputFile, mdText);