@@ -27,7 +27,6 @@ import { debugLog } from '../../../../utils/debug'
27
27
import { getSocketDevPackageOverviewUrl } from '../../../../utils/socket-url'
28
28
import { Edge , SafeEdge } from '../edge'
29
29
30
- import type { PackageDetail } from './diff'
31
30
import type { ArboristClass , ArboristReifyOptions } from './types'
32
31
import type { SocketArtifact } from '../../../../utils/alert/artifact'
33
32
import type { SafeNode } from '../node'
@@ -174,7 +173,7 @@ async function getPackagesAlerts(
174
173
fixable
175
174
} )
176
175
}
177
- if ( includeExisting && ! runningFixCmd ) {
176
+ if ( ! includeExisting ) {
178
177
// Before we ask about problematic issues, check to see if they
179
178
// already existed in the old version if they did, be quiet.
180
179
const existing = needInfoOn . find ( d =>
@@ -336,7 +335,7 @@ function updateNode(
336
335
packument : Packument ,
337
336
vulnerableVersionRange ?: string ,
338
337
firstPatchedVersionIdentifier ?: string
339
- ) {
338
+ ) : boolean {
340
339
const availableVersions = Object . keys ( packument . versions )
341
340
// Find the highest non-vulnerable version within the same major range
342
341
const targetVersion = findBestPatchVersion (
@@ -351,7 +350,7 @@ function updateNode(
351
350
// Check !targetVersion to make TypeScript happy.
352
351
if ( ! targetVersion || ! targetPackument ) {
353
352
// No suitable patch version found.
354
- return node
353
+ return false
355
354
}
356
355
// Use Object.defineProperty to override the version.
357
356
Object . defineProperty ( node , 'version' , {
@@ -394,6 +393,7 @@ function updateNode(
394
393
} ) ) as SafeEdge )
395
394
}
396
395
}
396
+ return true
397
397
}
398
398
399
399
export const kRiskyReify = Symbol ( 'riskyReify' )
@@ -407,17 +407,14 @@ export async function reify(
407
407
...args : Parameters < InstanceType < ArboristClass > [ 'reify' ] >
408
408
) : Promise < SafeNode > {
409
409
const IPC = await getIPC ( )
410
- const runningFixCmd = ! ! IPC [ SOCKET_CLI_IN_FIX_CMD ]
411
- const runningOptimizeCmd = ! ! IPC [ SOCKET_CLI_IN_OPTIMIZE_CMD ]
412
410
await updateSocketRegistryNodes ( this )
413
- if ( runningOptimizeCmd ) {
411
+ if ( IPC [ SOCKET_CLI_IN_FIX_CMD ] || IPC [ SOCKET_CLI_IN_OPTIMIZE_CMD ] ) {
414
412
return await this [ kRiskyReify ] ( ...args )
415
413
}
416
414
const { stderr : output , stdin : input } = process
417
415
const alerts = await getPackagesAlerts ( this , { output } )
418
416
if (
419
417
alerts . length &&
420
- ! runningFixCmd &&
421
418
! ( await confirm (
422
419
{
423
420
message : 'Accept risks of installing these packages?' ,
@@ -433,30 +430,4 @@ export async function reify(
433
430
throw new Error ( 'Socket npm exiting due to risks' )
434
431
}
435
432
return await this [ kRiskyReify ] ( ...args )
436
- // const prev = new Set(alerts.map(a => a.key))
437
- // let ret: SafeNode | undefined
438
- // /* eslint-disable no-await-in-loop */
439
- // while (alerts.length > 0) {
440
- // await updateAdvisoryNodes(this, alerts)
441
- // ret = await this[kRiskyReify](...args)
442
- // await this.loadActual()
443
- // await this.buildIdealTree()
444
- // needInfoOn = getPackagesToQueryFromDiff(this.diff, {
445
- // includeUnchanged: true
446
- // })
447
- // alerts = (
448
- // await getPackagesAlerts(needInfoOn, {
449
- // includeExisting: true,
450
- // includeUnfixable: true
451
- // })
452
- // ).filter(({ key }) => {
453
- // const unseen = !prev.has(key)
454
- // if (unseen) {
455
- // prev.add(key)
456
- // }
457
- // return unseen
458
- // })
459
- // }
460
- // /* eslint-enable no-await-in-loop */
461
- // return ret!
462
433
}
0 commit comments