Skip to content

Commit 45b30c6

Browse files
mtorpjdalton
authored andcommitted
backport --exclude and --include flags for socket fix to v1
1 parent 4240347 commit 45b30c6

File tree

4 files changed

+52
-30
lines changed

4 files changed

+52
-30
lines changed

src/commands/fix/cmd-fix.mts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,20 @@ const hiddenFlags: MeowFlags = {
131131
...generalFlags['id'],
132132
hidden: true,
133133
} as MeowFlag,
134-
glob: {
134+
exclude: {
135135
type: 'string',
136-
default: '',
137-
description: 'Glob pattern to filter workspaces by',
136+
default: [],
137+
description:
138+
'Exclude workspaces matching these patterns. Can be provided as comma separated values or as multiple flags',
139+
isMultiple: true,
140+
hidden: true,
141+
},
142+
include: {
143+
type: 'string',
144+
default: [],
145+
description:
146+
'Include workspaces matching these patterns. Can be provided as comma separated values or as multiple flags',
147+
isMultiple: true,
138148
hidden: true,
139149
},
140150
maxSatisfying: {
@@ -246,7 +256,8 @@ async function run(
246256
const {
247257
applyFixes,
248258
autopilot,
249-
glob,
259+
exclude,
260+
include,
250261
json,
251262
limit,
252263
majorUpdates,
@@ -261,21 +272,22 @@ async function run(
261272
// socket-cli/patches/meow#13.2.0.patch.
262273
unknownFlags = [],
263274
} = cli.flags as {
264-
autopilot: boolean
265275
applyFixes: boolean
266-
glob: string
267-
limit: number
276+
autopilot: boolean
277+
exclude: string[]
278+
include: string[]
268279
json: boolean
280+
limit: number
269281
majorUpdates: boolean
270282
markdown: boolean
271283
maxSatisfying: boolean
272284
minSatisfying: boolean
285+
minimumReleaseAge: string
286+
outputFile: string
273287
prCheck: boolean
274288
rangeStyle: RangeStyle
275289
showAffectedDirectDependencies: boolean
276290
unknownFlags?: string[]
277-
outputFile: string
278-
minimumReleaseAge: string
279291
}
280292

281293
const dryRun = !!cli.flags['dryRun']
@@ -334,23 +346,27 @@ async function run(
334346
...cmdFlagValueToArray(cli.flags['purl']),
335347
])
336348

349+
const includePatterns = cmdFlagValueToArray(include)
350+
const excludePatterns = cmdFlagValueToArray(exclude)
351+
337352
await handleFix({
338-
autopilot,
339353
applyFixes,
354+
autopilot,
340355
cwd,
341356
disableMajorUpdates,
357+
exclude: excludePatterns,
342358
ghsas,
343-
glob,
359+
include: includePatterns,
344360
limit,
345361
minimumReleaseAge,
346362
minSatisfying,
347-
prCheck,
348363
orgSlug,
364+
outputFile,
349365
outputKind,
366+
prCheck,
350367
rangeStyle,
351368
showAffectedDirectDependencies,
352369
spinner,
353370
unknownFlags,
354-
outputFile,
355371
})
356372
}

src/commands/fix/coana-fix.mts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export async function coanaFix(
4747
autopilot,
4848
cwd,
4949
disableMajorUpdates,
50+
exclude,
5051
ghsas,
51-
glob,
52+
include,
5253
limit,
5354
minimumReleaseAge,
5455
orgSlug,
@@ -148,7 +149,8 @@ export async function coanaFix(
148149
...(minimumReleaseAge
149150
? ['--minimum-release-age', minimumReleaseAge]
150151
: []),
151-
...(glob ? ['--glob', glob] : []),
152+
...(include.length ? ['--include', ...include] : []),
153+
...(exclude.length ? ['--exclude', ...exclude] : []),
152154
...(!applyFixes ? [FLAG_DRY_RUN] : []),
153155
...(outputFile ? ['--output-file', outputFile] : []),
154156
...(disableMajorUpdates ? ['--disable-major-updates'] : []),
@@ -207,7 +209,8 @@ export async function coanaFix(
207209
...(minimumReleaseAge
208210
? ['--minimum-release-age', minimumReleaseAge]
209211
: []),
210-
...(glob ? ['--glob', glob] : []),
212+
...(include.length ? ['--include', ...include] : []),
213+
...(exclude.length ? ['--exclude', ...exclude] : []),
211214
...(disableMajorUpdates ? ['--disable-major-updates'] : []),
212215
...(showAffectedDirectDependencies
213216
? ['--show-affected-direct-dependencies']
@@ -271,7 +274,8 @@ export async function coanaFix(
271274
...(minimumReleaseAge
272275
? ['--minimum-release-age', minimumReleaseAge]
273276
: []),
274-
...(glob ? ['--glob', glob] : []),
277+
...(include.length ? ['--include', ...include] : []),
278+
...(exclude.length ? ['--exclude', ...exclude] : []),
275279
...(disableMajorUpdates ? ['--disable-major-updates'] : []),
276280
...(showAffectedDirectDependencies
277281
? ['--show-affected-direct-dependencies']

src/commands/fix/handle-fix.mts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ export type HandleFixConfig = Remap<
1818
FixConfig & {
1919
applyFixes: boolean
2020
ghsas: string[]
21-
glob: string
2221
orgSlug: string
2322
outputKind: OutputKind
2423
unknownFlags: string[]
25-
outputFile: string
26-
minimumReleaseAge: string
2724
}
2825
>
2926

@@ -103,8 +100,9 @@ export async function handleFix({
103100
autopilot,
104101
cwd,
105102
disableMajorUpdates,
103+
exclude,
106104
ghsas,
107-
glob,
105+
include,
108106
limit,
109107
minSatisfying,
110108
minimumReleaseAge,
@@ -119,14 +117,16 @@ export async function handleFix({
119117
}: HandleFixConfig) {
120118
debugFn('notice', `Starting fix command for ${orgSlug}`)
121119
debugDir('inspect', {
120+
applyFixes,
122121
autopilot,
123122
cwd,
124123
disableMajorUpdates,
124+
exclude,
125125
ghsas,
126-
glob,
126+
include,
127127
limit,
128128
minSatisfying,
129-
applyFixes,
129+
minimumReleaseAge,
130130
outputFile,
131131
outputKind,
132132
prCheck,
@@ -137,23 +137,24 @@ export async function handleFix({
137137

138138
await outputFixResult(
139139
await coanaFix({
140-
autopilot,
141140
applyFixes,
141+
autopilot,
142142
cwd,
143143
disableMajorUpdates,
144-
// Convert mixed CVE/GHSA/PURL inputs to GHSA IDs only
144+
exclude,
145+
// Convert mixed CVE/GHSA/PURL inputs to GHSA IDs only.
145146
ghsas: await convertIdsToGhsas(ghsas),
146-
glob,
147+
include,
147148
limit,
148149
minimumReleaseAge,
149150
minSatisfying,
150151
orgSlug,
152+
outputFile,
151153
prCheck,
152154
rangeStyle,
153155
showAffectedDirectDependencies,
154156
spinner,
155157
unknownFlags,
156-
outputFile,
157158
}),
158159
outputKind,
159160
)

src/commands/fix/types.mts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ import type { RangeStyle } from '../../utils/semver.mts'
22
import type { Spinner } from '@socketsecurity/registry/lib/spinner'
33

44
export type FixConfig = {
5-
autopilot: boolean
65
applyFixes: boolean
6+
autopilot: boolean
77
cwd: string
88
disableMajorUpdates: boolean
9+
exclude: string[]
910
ghsas: string[]
10-
glob: string
11+
include: string[]
1112
limit: number
1213
minimumReleaseAge: string
1314
minSatisfying: boolean
1415
orgSlug: string
16+
outputFile: string
1517
prCheck: boolean
1618
rangeStyle: RangeStyle
1719
showAffectedDirectDependencies: boolean
1820
spinner: Spinner | undefined
1921
unknownFlags: string[]
20-
outputFile: string
2122
}

0 commit comments

Comments
 (0)