Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/commands/fix/cmd-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -183,6 +194,8 @@ async function run(
limit,
markdown,
maxSatisfying,
onlyCompute,
outputFile,
prCheck,
rangeStyle,
// We patched in this feature with `npx custompatch meow` at
Expand All @@ -198,6 +211,8 @@ async function run(
prCheck: boolean
rangeStyle: RangeStyle
unknownFlags?: string[]
outputFile: string
onlyCompute: boolean
}

const dryRun = !!cli.flags['dryRun']
Expand Down Expand Up @@ -266,5 +281,7 @@ async function run(
rangeStyle,
spinner,
unknownFlags,
onlyCompute,
outputFile,
})
}
2 changes: 2 additions & 0 deletions src/commands/fix/cmd-fix.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion src/commands/fix/coana-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ import type { CResult } from '../../types.mts'
export async function coanaFix(
fixConfig: FixConfig,
): Promise<CResult<{ fixed: boolean }>> {
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 })
Expand Down Expand Up @@ -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' },
Expand Down
6 changes: 6 additions & 0 deletions src/commands/fix/handle-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type HandleFixConfig = Remap<
orgSlug: string
outputKind: OutputKind
unknownFlags: string[]
onlyCompute: boolean
outputFile: string
}
>

Expand Down Expand Up @@ -91,7 +93,9 @@ export async function handleFix({
ghsas,
limit,
minSatisfying,
onlyCompute,
orgSlug,
outputFile,
outputKind,
prCheck,
rangeStyle,
Expand All @@ -111,6 +115,8 @@ export async function handleFix({
rangeStyle,
spinner,
unknownFlags,
onlyCompute,
outputFile,
}),
outputKind,
)
Expand Down
2 changes: 2 additions & 0 deletions src/commands/fix/types.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export type FixConfig = {
rangeStyle: RangeStyle
spinner: Spinner | undefined
unknownFlags: string[]
onlyCompute: boolean
outputFile: string
}