Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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(),
},
outputFile: {
type: 'string',
default: '',
description: 'Path to store result as json.',
Comment thread
barslev marked this conversation as resolved.
Outdated
},
computeFixesOnly: {
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.',
},
}

const hiddenFlags: MeowFlags = {
Expand Down Expand Up @@ -188,6 +199,8 @@ async function run(
// We patched in this feature with `npx custompatch meow` at
// socket-cli/patches/meow#13.2.0.patch.
unknownFlags = [],
outputFile,
computeFixesOnly,
} = cli.flags as {
autopilot: boolean
limit: number
Expand All @@ -198,6 +211,8 @@ async function run(
prCheck: boolean
rangeStyle: RangeStyle
unknownFlags?: string[]
outputFile: string
computeFixesOnly: boolean
}

const dryRun = !!cli.flags['dryRun']
Expand Down Expand Up @@ -266,5 +281,7 @@ async function run(
rangeStyle,
spinner,
unknownFlags,
computeFixesOnly,
outputFile,
})
}
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,
orgSlug,
spinner,
computeFixesOnly,
outputFile,
} = 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,
...(computeFixesOnly ? ['--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[]
computeFixesOnly: boolean
outputFile: string
}
>

Expand Down Expand Up @@ -97,6 +99,8 @@ export async function handleFix({
rangeStyle,
spinner,
unknownFlags,
computeFixesOnly,
outputFile,
}: HandleFixConfig) {
await outputFixResult(
await coanaFix({
Expand All @@ -111,6 +115,8 @@ export async function handleFix({
rangeStyle,
spinner,
unknownFlags,
computeFixesOnly,
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[]
computeFixesOnly: boolean
outputFile: string
}