From 9efd7c029d78ea401db29fa375468e41ee9160b1 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Wed, 26 Feb 2025 15:18:35 +0100 Subject: [PATCH 1/6] Add command header and dry-run flag --- src/commands/action/cmd-action.ts | 6 +- src/commands/analytics/cmd-analytics.ts | 14 +- src/commands/audit-log/cmd-audit-log.ts | 4 +- src/commands/cdxgen/cmd-cdxgen.ts | 26 +- src/commands/dependencies/cmd-dependencies.ts | 2 + src/commands/diff-scan/cmd-diff-scan-get.ts | 4 +- src/commands/fix/cmd-fix.ts | 9 +- src/commands/info/cmd-info.ts | 24 +- src/commands/login/cmd-login.ts | 8 +- src/commands/logout/cmd-logout.ts | 9 +- src/commands/manifest/cmd-manifest-auto.ts | 15 +- src/commands/manifest/cmd-manifest-gradle.ts | 57 +- src/commands/manifest/cmd-manifest-kotlin.ts | 45 +- src/commands/manifest/cmd-manifest-scala.ts | 47 +- src/commands/npm/cmd-npm.ts | 4 +- src/commands/npx/cmd-npx.ts | 4 +- src/commands/oops/cmd-oops.ts | 17 +- src/commands/optimize/cmd-optimize.ts | 4 +- .../organizations/cmd-organizations.ts | 4 +- src/commands/raw-npm/cmd-raw-npm.ts | 4 +- src/commands/raw-npx/cmd-raw-npx.ts | 4 +- src/commands/report/cmd-report-create.ts | 4 +- src/commands/report/cmd-report-view.ts | 4 +- src/commands/repos/cmd-repos-create.ts | 4 +- .../{cmd-repos-delete.ts => cmd-repos-del.ts} | 19 +- src/commands/repos/cmd-repos-list.ts | 4 +- src/commands/repos/cmd-repos-update.ts | 6 +- src/commands/repos/cmd-repos-view.ts | 4 +- src/commands/repos/cmd-repos.ts | 14 +- src/commands/scan/cmd-scan-create.ts | 9 +- .../{cmd-scan-delete.ts => cmd-scan-del.ts} | 14 +- src/commands/scan/cmd-scan-list.ts | 12 +- src/commands/scan/cmd-scan-metadata.ts | 12 +- src/commands/scan/cmd-scan-stream.ts | 12 +- src/commands/scan/cmd-scan.ts | 4 +- src/commands/threat-feed/cmd-threat-feed.ts | 2 + src/commands/wrapper/cmd-wrapper.ts | 13 +- src/flags.ts | 5 + src/utils/meow-with-subcommands.ts | 50 +- test/dry-run.test.ts | 915 ++++++++++++++++++ test/socket-cdxgen.test.ts | 7 +- 41 files changed, 1233 insertions(+), 192 deletions(-) rename src/commands/repos/{cmd-repos-delete.ts => cmd-repos-del.ts} (80%) rename src/commands/scan/{cmd-scan-delete.ts => cmd-scan-del.ts} (87%) create mode 100644 test/dry-run.test.ts diff --git a/src/commands/action/cmd-action.ts b/src/commands/action/cmd-action.ts index b8e7db161..99144dce3 100644 --- a/src/commands/action/cmd-action.ts +++ b/src/commands/action/cmd-action.ts @@ -28,9 +28,9 @@ const config: CliCommandConfig = { description: 'After marker' } }, - help: (parentName, { commandName, flags }) => ` + help: (command, { flags }) => ` Usage - $ ${parentName} ${commandName} [options] + $ ${command} [options] Options ${getFlagListOutput(flags, 6)} @@ -58,5 +58,7 @@ async function run( const githubEventBefore = String(cli.flags['githubEventBefore'] || '') const githubEventAfter = String(cli.flags['githubEventAfter'] || '') + if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now') + await runAction(githubEventBefore, githubEventAfter) } diff --git a/src/commands/analytics/cmd-analytics.ts b/src/commands/analytics/cmd-analytics.ts index b993bfb31..7e618cb0a 100644 --- a/src/commands/analytics/cmd-analytics.ts +++ b/src/commands/analytics/cmd-analytics.ts @@ -42,9 +42,9 @@ const config: CliCommandConfig = { description: 'Path to a local file to save the output' } }, - help: (parentName, { commandName, flags }) => ` + help: (command, { flags }) => ` Usage - $ ${parentName} ${commandName} --scope= --time=