@@ -7,7 +7,6 @@ const pacote = require('pacote')
7
7
const promiseAllRejectLate = require ( 'promise-all-reject-late' )
8
8
const runScript = require ( '@npmcli/run-script' )
9
9
const { callLimit : promiseCallLimit } = require ( 'promise-call-limit' )
10
- const { checkEngine, checkPlatform } = require ( 'npm-install-checks' )
11
10
const { depth : dfwalk } = require ( 'treeverse' )
12
11
const { dirname, resolve, relative, join } = require ( 'node:path' )
13
12
const { log, time } = require ( 'proc-log' )
@@ -74,7 +73,6 @@ module.exports = cls => class Reifier extends cls {
74
73
#dryRun
75
74
#nmValidated = new Set ( )
76
75
#omit
77
- #omitted
78
76
#retiredPaths = { }
79
77
#retiredUnchanged = { }
80
78
#savePrefix
@@ -99,7 +97,6 @@ module.exports = cls => class Reifier extends cls {
99
97
}
100
98
101
99
this . #omit = new Set ( options . omit )
102
- this . #omitted = new Set ( )
103
100
104
101
// start tracker block
105
102
this . addTracker ( 'reify' )
@@ -132,15 +129,17 @@ module.exports = cls => class Reifier extends cls {
132
129
this . idealTree = oldTree
133
130
}
134
131
await this [ _saveIdealTree ] ( options )
135
- // clean omitted
136
- for ( const node of this . #omitted) {
137
- node . parent = null
132
+ // clean inert
133
+ for ( const node of this . idealTree . inventory . values ( ) ) {
134
+ if ( node . inert ) {
135
+ node . parent = null
136
+ }
138
137
}
139
138
// clean up any trash that is still in the tree
140
139
for ( const path of this [ _trashList ] ) {
141
140
const loc = relpath ( this . idealTree . realpath , path )
142
141
const node = this . idealTree . inventory . get ( loc )
143
- if ( node && node . root === this . idealTree && ! node . ideallyInert ) {
142
+ if ( node && node . root === this . idealTree ) {
144
143
node . parent = null
145
144
}
146
145
}
@@ -228,18 +227,6 @@ module.exports = cls => class Reifier extends cls {
228
227
this . idealTree . meta . hiddenLockfile = true
229
228
this . idealTree . meta . lockfileVersion = defaultLockfileVersion
230
229
231
- // Preserve inertness for failed stuff.
232
- if ( this . actualTree ) {
233
- for ( const [ loc , actual ] of this . actualTree . inventory . entries ( ) ) {
234
- if ( actual . ideallyInert ) {
235
- const ideal = this . idealTree . inventory . get ( loc )
236
- if ( ideal ) {
237
- ideal . ideallyInert = true
238
- }
239
- }
240
- }
241
- }
242
-
243
230
this . actualTree = this . idealTree
244
231
this . idealTree = null
245
232
@@ -465,7 +452,6 @@ module.exports = cls => class Reifier extends cls {
465
452
// and ideal trees.
466
453
this . diff = Diff . calculate ( {
467
454
omit : this . #omit,
468
- omitted : this . #omitted,
469
455
shrinkwrapInflated : this . #shrinkwrapInflated,
470
456
filterNodes,
471
457
actual : this . actualTree ,
@@ -566,9 +552,6 @@ module.exports = cls => class Reifier extends cls {
566
552
// retire the same path at the same time.
567
553
const dirsChecked = new Set ( )
568
554
return promiseAllRejectLate ( leaves . map ( async node => {
569
- if ( node . ideallyInert ) {
570
- return
571
- }
572
555
for ( const d of walkUp ( node . path ) ) {
573
556
if ( d === node . top . path ) {
574
557
break
@@ -662,18 +645,7 @@ module.exports = cls => class Reifier extends cls {
662
645
const timeEnd = time . start ( `reifyNode:${ node . location } ` )
663
646
this . addTracker ( 'reify' , node . name , node . location )
664
647
665
- const { npmVersion, nodeVersion, cpu, os, libc } = this . options
666
648
const p = Promise . resolve ( ) . then ( async ( ) => {
667
- // when we reify an optional node, check the engine and platform
668
- // first. be sure to ignore the --force and --engine-strict flags,
669
- // since we always want to skip any optional packages we can't install.
670
- // these checks throwing will result in a rollback and removal
671
- // of the mismatches
672
- // eslint-disable-next-line promise/always-return
673
- if ( node . optional ) {
674
- checkEngine ( node . package , npmVersion , nodeVersion , false )
675
- checkPlatform ( node . package , false , { cpu, os, libc } )
676
- }
677
649
await this [ _checkBins ] ( node )
678
650
await this . #extractOrLink( node )
679
651
const { _id, deprecated } = node . package
@@ -707,10 +679,6 @@ module.exports = cls => class Reifier extends cls {
707
679
}
708
680
709
681
async #extractOrLink ( node ) {
710
- if ( node . ideallyInert ) {
711
- return
712
- }
713
-
714
682
const nm = resolve ( node . parent . path , 'node_modules' )
715
683
await this . #validateNodeModules( nm )
716
684
@@ -791,9 +759,9 @@ module.exports = cls => class Reifier extends cls {
791
759
[ _handleOptionalFailure ] ( node , p ) {
792
760
return ( node . optional ? p . catch ( ( ) => {
793
761
const set = optionalSet ( node )
794
- for ( node of set ) {
762
+ for ( const node of set ) {
795
763
log . verbose ( 'reify' , 'failed optional dependency' , node . path )
796
- node . ideallyInert = true
764
+ node . inert = true
797
765
this [ _addNodeToTrashList ] ( node )
798
766
}
799
767
} ) : p ) . then ( ( ) => node )
@@ -1165,9 +1133,6 @@ module.exports = cls => class Reifier extends cls {
1165
1133
1166
1134
this . #retiredUnchanged[ retireFolder ] = [ ]
1167
1135
return promiseAllRejectLate ( diff . unchanged . map ( node => {
1168
- if ( node . ideallyInert ) {
1169
- return
1170
- }
1171
1136
// no need to roll back links, since we'll just delete them anyway
1172
1137
if ( node . isLink ) {
1173
1138
return mkdir ( dirname ( node . path ) , { recursive : true , force : true } )
@@ -1247,7 +1212,7 @@ module.exports = cls => class Reifier extends cls {
1247
1212
// skip links that only live within node_modules as they are most
1248
1213
// likely managed by packages we installed, we only want to rebuild
1249
1214
// unchanged links we directly manage
1250
- const linkedFromRoot = ( node . parent === tree && ! node . ideallyInert ) || node . target . fsTop === tree
1215
+ const linkedFromRoot = ( node . parent === tree && ! node . inert ) || node . target . fsTop === tree
1251
1216
if ( node . isLink && linkedFromRoot ) {
1252
1217
nodes . push ( node )
1253
1218
}
0 commit comments