Skip to content

Commit 13fca8b

Browse files
committed
fix(dry-run): show computed query parameters in read-only commands
Enhanced outputDryRunFetch() to accept optional query parameters, so read-only commands now display the filters and parameters that would be used in API calls instead of generic "would fetch" messages. Updated 18 commands to show computed values: - threat-feed: org, ecosystem, type, package, version, pagination - analytics: scope, repo, time - audit-log: org, filter, pagination - organization commands: org, limit, offset - scan commands: org, scanId, filters, pagination - repository-list: org, all, sort, direction, pagination - package commands: purl, packages list - config-list: showFullTokens setting Added unit tests for outputDryRunFetch utility (7 tests).
1 parent 513d65d commit 13fca8b

18 files changed

+231
-33
lines changed

packages/cli/src/commands/analytics/cmd-analytics.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ async function run(
180180
}
181181

182182
if (dryRun) {
183-
outputDryRunFetch('analytics data')
183+
outputDryRunFetch('analytics data', {
184+
scope,
185+
repo: repoName || undefined,
186+
time: `${time} days`,
187+
})
184188
return
185189
}
186190

packages/cli/src/commands/audit-log/cmd-audit-log.mts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,20 @@ async function run(
176176
return
177177
}
178178

179-
if (dryRun) {
180-
outputDryRunFetch('audit log entries')
181-
return
182-
}
183-
184179
// Validate numeric pagination parameters.
185180
const validatedPage = Number(page || 0)
186181
const validatedPerPage = Number(perPage || 0)
187182

183+
if (dryRun) {
184+
outputDryRunFetch('audit log entries', {
185+
organization: orgSlug,
186+
filter: typeFilter || 'any',
187+
page: validatedPage || 1,
188+
perPage: validatedPerPage || 30,
189+
})
190+
return
191+
}
192+
188193
if (Number.isNaN(validatedPage) || validatedPage < 0) {
189194
throw new Error(`Invalid value for --page: ${page}`)
190195
}

packages/cli/src/commands/config/cmd-config-list.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ async function run(
7272
}
7373

7474
if (dryRun) {
75-
outputDryRunFetch('configuration settings')
75+
outputDryRunFetch('configuration settings', {
76+
showFullTokens: full ? 'yes' : 'no (masked)',
77+
})
7678
return
7779
}
7880

packages/cli/src/commands/organization/cmd-organization-dependencies.mts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,18 @@ async function run(
102102
return
103103
}
104104

105-
if (dryRun) {
106-
outputDryRunFetch('organization dependencies')
107-
return
108-
}
109-
110105
// Validate numeric pagination parameters.
111106
const validatedLimit = Number(limit || 0)
112107
const validatedOffset = Number(offset || 0)
113108

109+
if (dryRun) {
110+
outputDryRunFetch('organization dependencies', {
111+
limit: validatedLimit || 50,
112+
offset: validatedOffset,
113+
})
114+
return
115+
}
116+
114117
if (Number.isNaN(validatedLimit) || validatedLimit < 0) {
115118
throw new Error(`Invalid value for --limit: ${limit}`)
116119
}

packages/cli/src/commands/organization/cmd-organization-policy-license.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ async function run(
114114
}
115115

116116
if (dryRun) {
117-
outputDryRunFetch('organization license policy')
117+
outputDryRunFetch('organization license policy', {
118+
organization: orgSlug || '(will be determined)',
119+
})
118120
return
119121
}
120122

packages/cli/src/commands/organization/cmd-organization-policy-security.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ async function run(
114114
}
115115

116116
if (dryRun) {
117-
outputDryRunFetch('organization security policy')
117+
outputDryRunFetch('organization security policy', {
118+
organization: orgSlug || '(will be determined)',
119+
})
118120
return
119121
}
120122

packages/cli/src/commands/package/cmd-package-score.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ async function run(
128128
}
129129

130130
if (dryRun) {
131-
outputDryRunFetch('package score')
131+
outputDryRunFetch('package score', {
132+
package: purls[0] || '(invalid)',
133+
})
132134
return
133135
}
134136

packages/cli/src/commands/package/cmd-package-shallow.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ async function run(
126126
}
127127

128128
if (dryRun) {
129-
outputDryRunFetch('package information')
129+
outputDryRunFetch('package information', {
130+
packages: purls.length ? purls.join(', ') : '(none)',
131+
count: purls.length,
132+
})
130133
return
131134
}
132135

packages/cli/src/commands/repository/cmd-repository-list.mts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,14 @@ async function run(
172172
}
173173

174174
if (dryRun) {
175-
outputDryRunFetch('repositories')
175+
outputDryRunFetch('repositories', {
176+
organization: orgSlug,
177+
all: all || undefined,
178+
sort,
179+
direction,
180+
page: all ? undefined : page,
181+
perPage: all ? undefined : perPage,
182+
})
176183
return
177184
}
178185

packages/cli/src/commands/repository/repository-command-factory.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ ${spec.helpExamples.map(ex => ` $ ${command} ${ex}`).join('\n')}
170170
} else if (spec.commandName === 'del') {
171171
outputDryRunDelete('repository', identifier)
172172
} else {
173-
outputDryRunFetch(`repository ${identifier}`)
173+
outputDryRunFetch(`repository ${identifier}`, {
174+
organization: orgSlug,
175+
repository: repoName || undefined,
176+
})
174177
}
175178
return
176179
}

0 commit comments

Comments
 (0)