diff --git a/src/commands/fix/cmd-fix.mts b/src/commands/fix/cmd-fix.mts index 150d9386e..11de6f43e 100644 --- a/src/commands/fix/cmd-fix.mts +++ b/src/commands/fix/cmd-fix.mts @@ -83,6 +83,17 @@ Available styles: * preserve - Retain the existing version range style as-is `.trim(), }, + onlyCompute: { + type: 'boolean', + default: false, + description: + 'Compute fixes only, do not apply them. Logs what upgrades would be applied. If combined with --output-file, the output file will contain the upgrades that would be applied.', + }, + outputFile: { + type: 'string', + default: '', + description: 'Path to store upgrades as a JSON file at this path.', + }, } const hiddenFlags: MeowFlags = { @@ -183,6 +194,8 @@ async function run( limit, markdown, maxSatisfying, + onlyCompute, + outputFile, prCheck, rangeStyle, // We patched in this feature with `npx custompatch meow` at @@ -198,6 +211,8 @@ async function run( prCheck: boolean rangeStyle: RangeStyle unknownFlags?: string[] + outputFile: string + onlyCompute: boolean } const dryRun = !!cli.flags['dryRun'] @@ -266,5 +281,7 @@ async function run( rangeStyle, spinner, unknownFlags, + onlyCompute, + outputFile, }) } diff --git a/src/commands/fix/cmd-fix.test.mts b/src/commands/fix/cmd-fix.test.mts index 016011cb1..9104babf8 100644 --- a/src/commands/fix/cmd-fix.test.mts +++ b/src/commands/fix/cmd-fix.test.mts @@ -72,6 +72,8 @@ describe('socket fix', async () => { --json Output result as json --limit The number of fixes to attempt at a time (default 10) --markdown Output result as markdown + --only-compute Compute fixes only, do not apply them. Logs what upgrades would be applied. If combined with --output-file, the output file will contain the upgrades that would be applied. + --output-file Path to store upgrades as a JSON file at this path. --range-style Define how dependency version ranges are updated in package.json (default 'preserve'). Available styles: * pin - Use the exact version (e.g. 1.2.3) diff --git a/src/commands/fix/coana-fix.mts b/src/commands/fix/coana-fix.mts index 635907b67..4da699412 100644 --- a/src/commands/fix/coana-fix.mts +++ b/src/commands/fix/coana-fix.mts @@ -37,7 +37,16 @@ import type { CResult } from '../../types.mts' export async function coanaFix( fixConfig: FixConfig, ): Promise> { - const { autopilot, cwd, ghsas, limit, orgSlug, spinner } = fixConfig + const { + autopilot, + cwd, + ghsas, + limit, + onlyCompute, + orgSlug, + outputFile, + spinner, + } = fixConfig const fixEnv = await getFixEnv() debugDir('inspect', { fixEnv }) @@ -108,6 +117,8 @@ export async function coanaFix( ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags, + ...(onlyCompute ? ['--dry-run'] : []), + ...(outputFile ? ['--output-file', outputFile] : []), ], fixConfig.orgSlug, { cwd, spinner, stdio: 'inherit' }, diff --git a/src/commands/fix/handle-fix.mts b/src/commands/fix/handle-fix.mts index 6b4abdc28..9d2a2b702 100644 --- a/src/commands/fix/handle-fix.mts +++ b/src/commands/fix/handle-fix.mts @@ -18,6 +18,8 @@ export type HandleFixConfig = Remap< orgSlug: string outputKind: OutputKind unknownFlags: string[] + onlyCompute: boolean + outputFile: string } > @@ -91,7 +93,9 @@ export async function handleFix({ ghsas, limit, minSatisfying, + onlyCompute, orgSlug, + outputFile, outputKind, prCheck, rangeStyle, @@ -111,6 +115,8 @@ export async function handleFix({ rangeStyle, spinner, unknownFlags, + onlyCompute, + outputFile, }), outputKind, ) diff --git a/src/commands/fix/types.mts b/src/commands/fix/types.mts index 789711f73..3a92152dd 100644 --- a/src/commands/fix/types.mts +++ b/src/commands/fix/types.mts @@ -12,4 +12,6 @@ export type FixConfig = { rangeStyle: RangeStyle spinner: Spinner | undefined unknownFlags: string[] + onlyCompute: boolean + outputFile: string }