From 16dc73f6f5876f18f0f554ba19307513ff0324fe Mon Sep 17 00:00:00 2001 From: ghe Date: Mon, 17 Aug 2020 17:45:06 +0100 Subject: [PATCH] feat: add -p as alias for --prune-repeated-subdependencies add alias -p for --prune-repeated-subdependencies convert `prune-repeated-subdependencies` internally to camel case --- help/help.txt | 2 +- src/cli/args.ts | 2 ++ src/cli/commands/monitor/index.ts | 2 +- src/lib/snyk-test/run-test.ts | 2 +- src/lib/types.ts | 4 ++-- test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/help/help.txt b/help/help.txt index 145d24c9525..e6dd602896f 100644 --- a/help/help.txt +++ b/help/help.txt @@ -66,7 +66,7 @@ Options: -v, --version ...... The CLI version. --print-deps ....... (test and monitor commands only) Print the dependency tree before sending it for analysis. - --prune-repeated-subdependencies + -p, --prune-repeated-subdependencies (test and monitor command only) Prune dependency trees, removing duplicate sub-dependencies. Will still find all vulnerabilities, but potentially not all diff --git a/src/cli/args.ts b/src/cli/args.ts index ed956f8720b..02a964e89cd 100644 --- a/src/cli/args.ts +++ b/src/cli/args.ts @@ -26,6 +26,7 @@ const alias = abbrev( ); alias.d = 'debug'; // always make `-d` debug alias.t = 'test'; +alias.p = 'prune-repeated-subdependencies'; // The -d flag enables printing the messages for predefined namespaces. // Additional ones can be specified (comma-separated) in the DEBUG environment variable. @@ -202,6 +203,7 @@ export function args(rawArgv: string[]): Args { 'reachable-vulns-timeout', 'integration-name', 'integration-version', + 'prune-repeated-subdependencies', ]; for (const dashedArg of argumentsToTransform) { if (argv[dashedArg]) { diff --git a/src/cli/commands/monitor/index.ts b/src/cli/commands/monitor/index.ts index feb0fbd2af1..6d19f692c0a 100644 --- a/src/cli/commands/monitor/index.ts +++ b/src/cli/commands/monitor/index.ts @@ -304,7 +304,7 @@ function generateMonitorMeta(options, packageManager?): MonitorMeta { 'policy-path': options['policy-path'], 'project-name': options['project-name'] || config.PROJECT_NAME, isDocker: !!options.docker, - prune: !!options['prune-repeated-subdependencies'], + prune: !!options.pruneRepeatedSubdependencies, 'experimental-dep-graph': !!options['experimental-dep-graph'], 'remote-repo-url': options['remote-repo-url'], }; diff --git a/src/lib/snyk-test/run-test.ts b/src/lib/snyk-test/run-test.ts index 740899893c0..21fdef93643 100644 --- a/src/lib/snyk-test/run-test.ts +++ b/src/lib/snyk-test/run-test.ts @@ -521,7 +521,7 @@ async function assembleLocalPayloads( }); } - const pruneIsRequired = options['prune-repeated-subdependencies']; + const pruneIsRequired = options.pruneRepeatedSubdependencies; if (packageManager) { depGraph = await pruneGraph( diff --git a/src/lib/types.ts b/src/lib/types.ts index ef594231c78..b205bc9bd81 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -15,7 +15,7 @@ export type ShowVulnPaths = 'none' | 'some' | 'all'; export interface TestOptions { traverseNodeModules: boolean; interactive: boolean; - 'prune-repeated-subdependencies'?: boolean; + pruneRepeatedSubdependencies?: boolean; showVulnPaths: ShowVulnPaths; failOn?: FailOn; reachableVulns?: boolean; @@ -87,7 +87,7 @@ export interface MonitorOptions { scanAllUnmanaged?: boolean; allProjects?: boolean; // An experimental flag to allow monitoring of bigtrees (with degraded deps info and remediation advice). - 'prune-repeated-subdependencies'?: boolean; + pruneRepeatedSubdependencies?: boolean; // Used with the Docker plugin only. Allows requesting some experimental/unofficial features. experimental?: boolean; // Used with the Docker plugin only. Allows application scanning. diff --git a/test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts b/test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts index 40c1c13a750..4a708c6d011 100644 --- a/test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts +++ b/test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts @@ -240,7 +240,7 @@ if (!isWindows) { chdirWorkspaces(); await cli.monitor('npm-package-pruneable', { - 'prune-repeated-subdependencies': true, + pruneRepeatedSubdependencies: true, }); const req = server.popRequest(); t.equal(req.method, 'PUT', 'makes PUT request'); @@ -271,7 +271,7 @@ if (!isWindows) { chdirWorkspaces(); await cli.monitor('npm-package-pruneable', { - 'prune-repeated-subdependencies': true, + pruneRepeatedSubdependencies: true, 'experimental-dep-graph': true, }); const req = server.popRequest();