@@ -14,6 +14,7 @@ import {
14
14
resolvePackageName ,
15
15
} from '@socketsecurity/registry/lib/packages'
16
16
import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
17
+ import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
17
18
18
19
import { getActiveBranchesForPackage } from './fix-branch-helpers.mts'
19
20
import { getActualTree } from './get-actual-tree.mts'
@@ -47,7 +48,7 @@ import { getPurlObject } from '../../utils/purl.mts'
47
48
import { applyRange } from '../../utils/semver.mts'
48
49
import { getCveInfoFromAlertsMap } from '../../utils/socket-package-alert.mts'
49
50
import { idToPurl } from '../../utils/spec.mts'
50
- import { overridesDataByAgent } from '../optimize/get-overrides-by-agent.mts'
51
+ import { getOverridesData } from '../optimize/get-overrides-by-agent.mts'
51
52
52
53
import type { CiEnv } from './fix-env-helpers.mts'
53
54
import type { PrMatch } from './open-pr.mts'
@@ -146,8 +147,6 @@ export async function agentFix(
146
147
( a , b ) => naturalCompare ( a [ 0 ] , b [ 0 ] ) ,
147
148
)
148
149
149
- const getOverridesData = overridesDataByAgent . get ( pkgEnvDetails . agent ) !
150
-
151
150
const cleanupInfoEntriesLoop = ( ) => {
152
151
logger . dedent ( )
153
152
spinner ?. dedent ( )
@@ -324,18 +323,17 @@ export async function agentFix(
324
323
continue infosLoop
325
324
}
326
325
327
- const oldOverrides = getOverridesData (
326
+ const { overrides : oldOverrides } = getOverridesData (
328
327
pkgEnvDetails ,
329
328
editablePkgJson . content ,
330
329
)
331
- const overrideKey = `${ name } @${ vulnerableVersionRange } `
332
-
333
- const newVersionRange = applyRange (
334
- ( oldOverrides as any ) ?. [ overrideKey ] ?? oldVersion ,
335
- newVersion ,
336
- rangeStyle ,
337
- )
338
- const newId = `${ name } @${ newVersionRange } `
330
+ let refRange = oldOverrides ?. [ `${ name } @${ vulnerableVersionRange } ` ]
331
+ if ( ! isNonEmptyString ( refRange ) ) {
332
+ refRange = oldOverrides ?. [ name ]
333
+ }
334
+ if ( ! isNonEmptyString ( refRange ) ) {
335
+ refRange = oldVersion
336
+ }
339
337
340
338
// eslint-disable-next-line no-await-in-loop
341
339
await beforeInstall (
@@ -346,7 +344,6 @@ export async function agentFix(
346
344
vulnerableVersionRange ,
347
345
options ,
348
346
)
349
-
350
347
updatePackageJsonFromNode (
351
348
editablePkgJson ,
352
349
actualTree ,
@@ -370,6 +367,8 @@ export async function agentFix(
370
367
workspaceLogCallCount = logger . logCallCount
371
368
}
372
369
370
+ const newId = `${ name } @${ applyRange ( refRange , newVersion , rangeStyle ) } `
371
+
373
372
spinner ?. start ( )
374
373
spinner ?. info ( `Installing ${ newId } in ${ workspace } .` )
375
374
0 commit comments