@socketsecurity/cli-with-sentry 0.15.24 → 0.15.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var Module = require('node:module');
4
+ var vendor = require('./vendor.js');
4
5
  var path = require('node:path');
5
6
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
6
7
  var constants = require('./constants.js');
7
8
  var utils = require('./utils.js');
8
9
  var logger = require('../external/@socketsecurity/registry/lib/logger');
9
- var vendor = require('./vendor.js');
10
10
  var registry = require('../external/@socketsecurity/registry');
11
11
  var objects = require('../external/@socketsecurity/registry/lib/objects');
12
- var strings = require('../external/@socketsecurity/registry/lib/strings');
13
12
 
14
13
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
15
- const DiffAction = utils.createEnum({
16
- add: 'ADD',
17
- change: 'CHANGE',
18
- remove: 'REMOVE'
19
- });
20
-
21
14
  let _arboristPkgPath;
22
15
  function getArboristPackagePath() {
23
16
  if (_arboristPkgPath === undefined) {
@@ -36,13 +29,6 @@ function getArboristClassPath() {
36
29
  }
37
30
  return _arboristClassPath;
38
31
  }
39
- let _arboristDepValidPath;
40
- function getArboristDepValidPath() {
41
- if (_arboristDepValidPath === undefined) {
42
- _arboristDepValidPath = path.join(getArboristPackagePath(), 'lib/dep-valid.js');
43
- }
44
- return _arboristDepValidPath;
45
- }
46
32
  let _arboristEdgeClassPath;
47
33
  function getArboristEdgeClassPath() {
48
34
  if (_arboristEdgeClassPath === undefined) {
@@ -65,713 +51,11 @@ function getArboristOverrideSetClassPath() {
65
51
  return _arboristOverrideSetClassPath;
66
52
  }
67
53
 
68
- const require$6 =Module.createRequire(require('u' + 'rl').pathToFileURL(__filename).href)
69
- let _depValid;
70
- function depValid(child, requested, accept, requester) {
71
- if (_depValid === undefined) {
72
- _depValid = require$6(getArboristDepValidPath());
73
- }
74
- return _depValid(child, requested, accept, requester);
75
- }
76
-
77
- const {
78
- UNDEFINED_TOKEN
79
- } = constants;
80
- function tryRequire(req, ...ids) {
81
- for (const data of ids) {
82
- let id;
83
- let transformer;
84
- if (Array.isArray(data)) {
85
- id = data[0];
86
- transformer = data[1];
87
- } else {
88
- id = data;
89
- transformer = mod => mod;
90
- }
91
- try {
92
- // Check that the transformed value isn't `undefined` because older
93
- // versions of packages like 'proc-log' may not export a `log` method.
94
- const exported = transformer(req(id));
95
- if (exported !== undefined) {
96
- return exported;
97
- }
98
- } catch {}
99
- }
100
- return undefined;
101
- }
102
- let _log = UNDEFINED_TOKEN;
103
- function getLogger() {
104
- if (_log === UNDEFINED_TOKEN) {
105
- _log = tryRequire(utils.getNpmRequire(), ['proc-log/lib/index.js',
106
- // The proc-log DefinitelyTyped definition is incorrect. The type definition
107
- // is really that of its export log.
108
- mod => mod.log], 'npmlog/lib/log.js');
109
- }
110
- return _log;
111
- }
112
-
113
- const require$5 =Module.createRequire(require('u' + 'rl').pathToFileURL(__filename).href)
114
- const OverrideSet = require$5(getArboristOverrideSetClassPath());
115
-
116
- // Implementation code not related to patch https://github.com/npm/cli/pull/8089
117
- // is based on https://github.com/npm/cli/blob/v11.0.0/workspaces/arborist/lib/override-set.js:
118
- class SafeOverrideSet extends OverrideSet {
119
- // Patch adding doOverrideSetsConflict is based on
120
- // https://github.com/npm/cli/pull/8089.
121
- static doOverrideSetsConflict(first, second) {
122
- // If override sets contain one another then we can try to use the more
123
- // specific one. If neither one is more specific, then we consider them to
124
- // be in conflict.
125
- return this.findSpecificOverrideSet(first, second) === undefined;
126
- }
127
-
128
- // Patch adding findSpecificOverrideSet is based on
129
- // https://github.com/npm/cli/pull/8089.
130
- static findSpecificOverrideSet(first, second) {
131
- for (let overrideSet = second; overrideSet; overrideSet = overrideSet.parent) {
132
- if (overrideSet.isEqual(first)) {
133
- return second;
134
- }
135
- }
136
- for (let overrideSet = first; overrideSet; overrideSet = overrideSet.parent) {
137
- if (overrideSet.isEqual(second)) {
138
- return first;
139
- }
140
- }
141
- // The override sets are incomparable. Neither one contains the other.
142
- const log = getLogger();
143
- log?.silly('Conflicting override sets', first, second);
144
- return undefined;
145
- }
146
-
147
- // Patch adding childrenAreEqual is based on
148
- // https://github.com/npm/cli/pull/8089.
149
- childrenAreEqual(otherOverrideSet) {
150
- if (this.children.size !== otherOverrideSet.children.size) {
151
- return false;
152
- }
153
- for (const {
154
- 0: key,
155
- 1: childOverrideSet
156
- } of this.children) {
157
- const otherChildOverrideSet = otherOverrideSet.children.get(key);
158
- if (!otherChildOverrideSet) {
159
- return false;
160
- }
161
- if (childOverrideSet.value !== otherChildOverrideSet.value) {
162
- return false;
163
- }
164
- if (!childOverrideSet.childrenAreEqual(otherChildOverrideSet)) {
165
- return false;
166
- }
167
- }
168
- return true;
169
- }
170
- getEdgeRule(edge) {
171
- for (const rule of this.ruleset.values()) {
172
- if (rule.name !== edge.name) {
173
- continue;
174
- }
175
- // If keySpec is * we found our override.
176
- if (rule.keySpec === '*') {
177
- return rule;
178
- }
179
- // Patch replacing
180
- // let spec = npa(`${edge.name}@${edge.spec}`)
181
- // is based on https://github.com/npm/cli/pull/8089.
182
- //
183
- // We need to use the rawSpec here, because the spec has the overrides
184
- // applied to it already. The rawSpec can be undefined, so we need to use
185
- // the fallback value of spec if it is.
186
- let spec = vendor.npaExports(`${edge.name}@${edge.rawSpec || edge.spec}`);
187
- if (spec.type === 'alias') {
188
- spec = spec.subSpec;
189
- }
190
- if (spec.type === 'git') {
191
- if (spec.gitRange && vendor.semverExports.intersects(spec.gitRange, rule.keySpec)) {
192
- return rule;
193
- }
194
- continue;
195
- }
196
- if (spec.type === 'range' || spec.type === 'version') {
197
- if (vendor.semverExports.intersects(spec.fetchSpec, rule.keySpec)) {
198
- return rule;
199
- }
200
- continue;
201
- }
202
- // If we got this far, the spec type is one of tag, directory or file
203
- // which means we have no real way to make version comparisons, so we
204
- // just accept the override.
205
- return rule;
206
- }
207
- return this;
208
- }
209
-
210
- // Patch adding isEqual is based on
211
- // https://github.com/npm/cli/pull/8089.
212
- isEqual(otherOverrideSet) {
213
- if (this === otherOverrideSet) {
214
- return true;
215
- }
216
- if (!otherOverrideSet) {
217
- return false;
218
- }
219
- if (this.key !== otherOverrideSet.key || this.value !== otherOverrideSet.value) {
220
- return false;
221
- }
222
- if (!this.childrenAreEqual(otherOverrideSet)) {
223
- return false;
224
- }
225
- if (!this.parent) {
226
- return !otherOverrideSet.parent;
227
- }
228
- return this.parent.isEqual(otherOverrideSet.parent);
229
- }
230
- }
231
-
232
- const require$4 =Module.createRequire(require('u' + 'rl').pathToFileURL(__filename).href)
233
- const Node = require$4(getArboristNodeClassPath());
234
-
235
- // Implementation code not related to patch https://github.com/npm/cli/pull/8089
236
- // is based on https://github.com/npm/cli/blob/v11.0.0/workspaces/arborist/lib/node.js:
237
- class SafeNode extends Node {
238
- // Return true if it's safe to remove this node, because anything that is
239
- // depending on it would be fine with the thing that they would resolve to if
240
- // it was removed, or nothing is depending on it in the first place.
241
- canDedupe(preferDedupe = false) {
242
- // Not allowed to mess with shrinkwraps or bundles.
243
- if (this.inDepBundle || this.inShrinkwrap) {
244
- return false;
245
- }
246
- // It's a top level pkg, or a dep of one.
247
- if (!this.resolveParent?.resolveParent) {
248
- return false;
249
- }
250
- // No one wants it, remove it.
251
- if (this.edgesIn.size === 0) {
252
- return true;
253
- }
254
- const other = this.resolveParent.resolveParent.resolve(this.name);
255
- // Nothing else, need this one.
256
- if (!other) {
257
- return false;
258
- }
259
- // If it's the same thing, then always fine to remove.
260
- if (other.matches(this)) {
261
- return true;
262
- }
263
- // If the other thing can't replace this, then skip it.
264
- if (!other.canReplace(this)) {
265
- return false;
266
- }
267
- // Patch replacing
268
- // if (preferDedupe || semver.gte(other.version, this.version)) {
269
- // return true
270
- // }
271
- // is based on https://github.com/npm/cli/pull/8089.
272
- //
273
- // If we prefer dedupe, or if the version is equal, take the other.
274
- if (preferDedupe || vendor.semverExports.eq(other.version, this.version)) {
275
- return true;
276
- }
277
- // If our current version isn't the result of an override, then prefer to
278
- // take the greater version.
279
- if (!this.overridden && vendor.semverExports.gt(other.version, this.version)) {
280
- return true;
281
- }
282
- return false;
283
- }
284
-
285
- // Is it safe to replace one node with another? check the edges to
286
- // make sure no one will get upset. Note that the node might end up
287
- // having its own unmet dependencies, if the new node has new deps.
288
- // Note that there are cases where Arborist will opt to insert a node
289
- // into the tree even though this function returns false! This is
290
- // necessary when a root dependency is added or updated, or when a
291
- // root dependency brings peer deps along with it. In that case, we
292
- // will go ahead and create the invalid state, and then try to resolve
293
- // it with more tree construction, because it's a user request.
294
- canReplaceWith(node, ignorePeers) {
295
- if (this.name !== node.name || this.packageName !== node.packageName) {
296
- return false;
297
- }
298
- // Patch replacing
299
- // if (node.overrides !== this.overrides) {
300
- // return false
301
- // }
302
- // is based on https://github.com/npm/cli/pull/8089.
303
- //
304
- // If this node has no dependencies, then it's irrelevant to check the
305
- // override rules of the replacement node.
306
- if (this.edgesOut.size) {
307
- // XXX need to check for two root nodes?
308
- if (node.overrides) {
309
- if (!node.overrides.isEqual(this.overrides)) {
310
- return false;
311
- }
312
- } else {
313
- if (this.overrides) {
314
- return false;
315
- }
316
- }
317
- }
318
- // To satisfy the patch we ensure `node.overrides === this.overrides`
319
- // so that the condition we want to replace,
320
- // if (this.overrides !== node.overrides) {
321
- // , is not hit.`
322
- const oldOverrideSet = this.overrides;
323
- let result = true;
324
- if (oldOverrideSet !== node.overrides) {
325
- this.overrides = node.overrides;
326
- }
327
- try {
328
- result = super.canReplaceWith(node, ignorePeers);
329
- this.overrides = oldOverrideSet;
330
- } catch (e) {
331
- this.overrides = oldOverrideSet;
332
- throw e;
333
- }
334
- return result;
335
- }
336
-
337
- // Patch adding deleteEdgeIn is based on https://github.com/npm/cli/pull/8089.
338
- deleteEdgeIn(edge) {
339
- this.edgesIn.delete(edge);
340
- const {
341
- overrides
342
- } = edge;
343
- if (overrides) {
344
- this.updateOverridesEdgeInRemoved(overrides);
345
- }
346
- }
347
- addEdgeIn(edge) {
348
- // Patch replacing
349
- // if (edge.overrides) {
350
- // this.overrides = edge.overrides
351
- // }
352
- // is based on https://github.com/npm/cli/pull/8089.
353
- //
354
- // We need to handle the case where the new edge in has an overrides field
355
- // which is different from the current value.
356
- if (!this.overrides || !this.overrides.isEqual(edge.overrides)) {
357
- this.updateOverridesEdgeInAdded(edge.overrides);
358
- }
359
- this.edgesIn.add(edge);
360
- // Try to get metadata from the yarn.lock file.
361
- this.root.meta?.addEdge(edge);
362
- }
363
-
364
- // @ts-ignore: Incorrectly typed as a property instead of an accessor.
365
- get overridden() {
366
- // Patch replacing
367
- // return !!(this.overrides && this.overrides.value && this.overrides.name === this.name)
368
- // is based on https://github.com/npm/cli/pull/8089.
369
- if (!this.overrides || !this.overrides.value || this.overrides.name !== this.name) {
370
- return false;
371
- }
372
- // The overrides rule is for a package with this name, but some override
373
- // rules only apply to specific versions. To make sure this package was
374
- // actually overridden, we check whether any edge going in had the rule
375
- // applied to it, in which case its overrides set is different than its
376
- // source node.
377
- for (const edge of this.edgesIn) {
378
- if (edge.overrides && edge.overrides.name === this.name && edge.overrides.value === this.version) {
379
- if (!edge.overrides.isEqual(edge.from?.overrides)) {
380
- return true;
381
- }
382
- }
383
- }
384
- return false;
385
- }
386
- set parent(newParent) {
387
- // Patch removing
388
- // if (parent.overrides) {
389
- // this.overrides = parent.overrides.getNodeRule(this)
390
- // }
391
- // is based on https://github.com/npm/cli/pull/8089.
392
- //
393
- // The "parent" setter is a really large and complex function. To satisfy
394
- // the patch we hold on to the old overrides value and set `this.overrides`
395
- // to `undefined` so that the condition we want to remove is not hit.
396
- const {
397
- overrides
398
- } = this;
399
- if (overrides) {
400
- this.overrides = undefined;
401
- }
402
- try {
403
- super.parent = newParent;
404
- this.overrides = overrides;
405
- } catch (e) {
406
- this.overrides = overrides;
407
- throw e;
408
- }
409
- }
410
-
411
- // Patch adding recalculateOutEdgesOverrides is based on
412
- // https://github.com/npm/cli/pull/8089.
413
- recalculateOutEdgesOverrides() {
414
- // For each edge out propagate the new overrides through.
415
- for (const edge of this.edgesOut.values()) {
416
- edge.reload(true);
417
- if (edge.to) {
418
- edge.to.updateOverridesEdgeInAdded(edge.overrides);
419
- }
420
- }
421
- }
422
-
423
- // @ts-ignore: Incorrectly typed to accept null.
424
- set root(newRoot) {
425
- // Patch removing
426
- // if (!this.overrides && this.parent && this.parent.overrides) {
427
- // this.overrides = this.parent.overrides.getNodeRule(this)
428
- // }
429
- // is based on https://github.com/npm/cli/pull/8089.
430
- //
431
- // The "root" setter is a really large and complex function. To satisfy the
432
- // patch we add a dummy value to `this.overrides` so that the condition we
433
- // want to remove is not hit.
434
- if (!this.overrides) {
435
- this.overrides = new SafeOverrideSet({
436
- overrides: ''
437
- });
438
- }
439
- try {
440
- super.root = newRoot;
441
- this.overrides = undefined;
442
- } catch (e) {
443
- this.overrides = undefined;
444
- throw e;
445
- }
446
- }
447
-
448
- // Patch adding updateOverridesEdgeInAdded is based on
449
- // https://github.com/npm/cli/pull/7025.
450
- //
451
- // This logic isn't perfect either. When we have two edges in that have
452
- // different override sets, then we have to decide which set is correct. This
453
- // function assumes the more specific override set is applicable, so if we have
454
- // dependencies A->B->C and A->C and an override set that specifies what happens
455
- // for C under A->B, this will work even if the new A->C edge comes along and
456
- // tries to change the override set. The strictly correct logic is not to allow
457
- // two edges with different overrides to point to the same node, because even
458
- // if this node can satisfy both, one of its dependencies might need to be
459
- // different depending on the edge leading to it. However, this might cause a
460
- // lot of duplication, because the conflict in the dependencies might never
461
- // actually happen.
462
- updateOverridesEdgeInAdded(otherOverrideSet) {
463
- if (!otherOverrideSet) {
464
- // Assuming there are any overrides at all, the overrides field is never
465
- // undefined for any node at the end state of the tree. So if the new edge's
466
- // overrides is undefined it will be updated later. So we can wait with
467
- // updating the node's overrides field.
468
- return false;
469
- }
470
- if (!this.overrides) {
471
- this.overrides = otherOverrideSet;
472
- this.recalculateOutEdgesOverrides();
473
- return true;
474
- }
475
- if (this.overrides.isEqual(otherOverrideSet)) {
476
- return false;
477
- }
478
- const newOverrideSet = SafeOverrideSet.findSpecificOverrideSet(this.overrides, otherOverrideSet);
479
- if (newOverrideSet) {
480
- if (this.overrides.isEqual(newOverrideSet)) {
481
- return false;
482
- }
483
- this.overrides = newOverrideSet;
484
- this.recalculateOutEdgesOverrides();
485
- return true;
486
- }
487
- // This is an error condition. We can only get here if the new override set
488
- // is in conflict with the existing.
489
- const log = getLogger();
490
- log?.silly('Conflicting override sets', this.name);
491
- return false;
492
- }
493
-
494
- // Patch adding updateOverridesEdgeInRemoved is based on
495
- // https://github.com/npm/cli/pull/7025.
496
- updateOverridesEdgeInRemoved(otherOverrideSet) {
497
- // If this edge's overrides isn't equal to this node's overrides,
498
- // then removing it won't change newOverrideSet later.
499
- if (!this.overrides || !this.overrides.isEqual(otherOverrideSet)) {
500
- return false;
501
- }
502
- let newOverrideSet;
503
- for (const edge of this.edgesIn) {
504
- const {
505
- overrides: edgeOverrides
506
- } = edge;
507
- if (newOverrideSet && edgeOverrides) {
508
- newOverrideSet = SafeOverrideSet.findSpecificOverrideSet(edgeOverrides, newOverrideSet);
509
- } else {
510
- newOverrideSet = edgeOverrides;
511
- }
512
- }
513
- if (this.overrides.isEqual(newOverrideSet)) {
514
- return false;
515
- }
516
- this.overrides = newOverrideSet;
517
- if (newOverrideSet) {
518
- // Optimization: If there's any override set at all, then no non-extraneous
519
- // node has an empty override set. So if we temporarily have no override set
520
- // (for example, we removed all the edges in), there's no use updating all
521
- // the edges out right now. Let's just wait until we have an actual override
522
- // set later.
523
- this.recalculateOutEdgesOverrides();
524
- }
525
- return true;
526
- }
527
- }
528
-
529
- const require$3 =Module.createRequire(require('u' + 'rl').pathToFileURL(__filename).href)
530
- const Edge = require$3(getArboristEdgeClassPath());
531
-
532
- // The Edge class makes heavy use of private properties which subclasses do NOT
533
- // have access to. So we have to recreate any functionality that relies on those
534
- // private properties and use our own "safe" prefixed non-conflicting private
535
- // properties. Implementation code not related to patch https://github.com/npm/cli/pull/8089
536
- // is based on https://github.com/npm/cli/blob/v11.0.0/workspaces/arborist/lib/edge.js.
537
- //
538
- // The npm application
539
- // Copyright (c) npm, Inc. and Contributors
540
- // Licensed on the terms of The Artistic License 2.0
541
- //
542
- // An edge in the dependency graph.
543
- // Represents a dependency relationship of some kind.
544
- class SafeEdge extends Edge {
545
- #safeError;
546
- #safeExplanation;
547
- #safeFrom;
548
- #safeTo;
549
- constructor(options) {
550
- const {
551
- from
552
- } = options;
553
- // Defer to supper to validate options and assign non-private values.
554
- super(options);
555
- if (from.constructor !== SafeNode) {
556
- Reflect.setPrototypeOf(from, SafeNode.prototype);
557
- }
558
- this.#safeError = null;
559
- this.#safeExplanation = null;
560
- this.#safeFrom = from;
561
- this.#safeTo = null;
562
- this.reload(true);
563
- }
564
- get bundled() {
565
- return !!this.#safeFrom?.package?.bundleDependencies?.includes(this.name);
566
- }
567
- get error() {
568
- if (!this.#safeError) {
569
- if (!this.#safeTo) {
570
- if (this.optional) {
571
- this.#safeError = null;
572
- } else {
573
- this.#safeError = 'MISSING';
574
- }
575
- } else if (this.peer && this.#safeFrom === this.#safeTo.parent &&
576
- // Patch adding "?." use based on
577
- // https://github.com/npm/cli/pull/8089.
578
- !this.#safeFrom?.isTop) {
579
- this.#safeError = 'PEER LOCAL';
580
- } else if (!this.satisfiedBy(this.#safeTo)) {
581
- this.#safeError = 'INVALID';
582
- }
583
- // Patch adding "else if" condition is based on
584
- // https://github.com/npm/cli/pull/8089.
585
- else if (this.overrides && this.#safeTo.edgesOut.size && SafeOverrideSet.doOverrideSetsConflict(this.overrides, this.#safeTo.overrides)) {
586
- // Any inconsistency between the edge's override set and the target's
587
- // override set is potentially problematic. But we only say the edge is
588
- // in error if the override sets are plainly conflicting. Note that if
589
- // the target doesn't have any dependencies of their own, then this
590
- // inconsistency is irrelevant.
591
- this.#safeError = 'INVALID';
592
- } else {
593
- this.#safeError = 'OK';
594
- }
595
- }
596
- if (this.#safeError === 'OK') {
597
- return null;
598
- }
599
- return this.#safeError;
600
- }
601
-
602
- // @ts-ignore: Incorrectly typed as a property instead of an accessor.
603
- get from() {
604
- return this.#safeFrom;
605
- }
606
-
607
- // @ts-ignore: Incorrectly typed as a property instead of an accessor.
608
- get spec() {
609
- if (this.overrides?.value && this.overrides.value !== '*' && this.overrides.name === this.name) {
610
- if (this.overrides.value.startsWith('$')) {
611
- const ref = this.overrides.value.slice(1);
612
- // We may be a virtual root, if we are we want to resolve reference
613
- // overrides from the real root, not the virtual one.
614
- //
615
- // Patch adding "?." use based on
616
- // https://github.com/npm/cli/pull/8089.
617
- const pkg = this.#safeFrom?.sourceReference ? this.#safeFrom?.sourceReference.root.package : this.#safeFrom?.root?.package;
618
- if (pkg?.devDependencies?.[ref]) {
619
- return pkg.devDependencies[ref];
620
- }
621
- if (pkg?.optionalDependencies?.[ref]) {
622
- return pkg.optionalDependencies[ref];
623
- }
624
- if (pkg?.dependencies?.[ref]) {
625
- return pkg.dependencies[ref];
626
- }
627
- if (pkg?.peerDependencies?.[ref]) {
628
- return pkg.peerDependencies[ref];
629
- }
630
- throw new Error(`Unable to resolve reference ${this.overrides.value}`);
631
- }
632
- return this.overrides.value;
633
- }
634
- return this.rawSpec;
635
- }
636
-
637
- // @ts-ignore: Incorrectly typed as a property instead of an accessor.
638
- get to() {
639
- return this.#safeTo;
640
- }
641
- detach() {
642
- this.#safeExplanation = null;
643
- // Patch replacing
644
- // if (this.#to) {
645
- // this.#to.edgesIn.delete(this)
646
- // }
647
- // this.#from.edgesOut.delete(this.#name)
648
- // is based on https://github.com/npm/cli/pull/8089.
649
- this.#safeTo?.deleteEdgeIn(this);
650
- this.#safeFrom?.edgesOut.delete(this.name);
651
- this.#safeTo = null;
652
- this.#safeError = 'DETACHED';
653
- this.#safeFrom = null;
654
- }
655
-
656
- // Return the edge data, and an explanation of how that edge came to be here.
657
- // @ts-ignore: Edge#explain is defined with an unused `seen = []` param.
658
- explain() {
659
- if (!this.#safeExplanation) {
660
- const explanation = {
661
- type: this.type,
662
- name: this.name,
663
- spec: this.spec,
664
- bundled: false,
665
- overridden: false,
666
- error: undefined,
667
- from: undefined,
668
- rawSpec: undefined
669
- };
670
- if (this.rawSpec !== this.spec) {
671
- explanation.rawSpec = this.rawSpec;
672
- explanation.overridden = true;
673
- }
674
- if (this.bundled) {
675
- explanation.bundled = this.bundled;
676
- }
677
- if (this.error) {
678
- explanation.error = this.error;
679
- }
680
- if (this.#safeFrom) {
681
- explanation.from = this.#safeFrom.explain();
682
- }
683
- this.#safeExplanation = explanation;
684
- }
685
- return this.#safeExplanation;
686
- }
687
- reload(hard = false) {
688
- this.#safeExplanation = null;
689
- // Patch replacing
690
- // if (this.#from.overrides) {
691
- // is based on https://github.com/npm/cli/pull/8089.
692
- let needToUpdateOverrideSet = false;
693
- let newOverrideSet;
694
- let oldOverrideSet;
695
- if (this.#safeFrom?.overrides) {
696
- newOverrideSet = this.#safeFrom.overrides.getEdgeRule(this);
697
- if (newOverrideSet && !newOverrideSet.isEqual(this.overrides)) {
698
- // If there's a new different override set we need to propagate it to
699
- // the nodes. If we're deleting the override set then there's no point
700
- // propagating it right now since it will be filled with another value
701
- // later.
702
- needToUpdateOverrideSet = true;
703
- oldOverrideSet = this.overrides;
704
- this.overrides = newOverrideSet;
705
- }
706
- } else {
707
- this.overrides = undefined;
708
- }
709
- // Patch adding "?." use based on
710
- // https://github.com/npm/cli/pull/8089.
711
- const newTo = this.#safeFrom?.resolve(this.name);
712
- if (newTo !== this.#safeTo) {
713
- // Patch replacing
714
- // this.#to.edgesIn.delete(this)
715
- // is based on https://github.com/npm/cli/pull/8089.
716
- this.#safeTo?.deleteEdgeIn(this);
717
- this.#safeTo = newTo ?? null;
718
- this.#safeError = null;
719
- this.#safeTo?.addEdgeIn(this);
720
- } else if (hard) {
721
- this.#safeError = null;
722
- }
723
- // Patch adding "else if" condition based on
724
- // https://github.com/npm/cli/pull/8089.
725
- else if (needToUpdateOverrideSet && this.#safeTo) {
726
- // Propagate the new override set to the target node.
727
- this.#safeTo.updateOverridesEdgeInRemoved(oldOverrideSet);
728
- this.#safeTo.updateOverridesEdgeInAdded(newOverrideSet);
729
- }
730
- }
731
- satisfiedBy(node) {
732
- // Patch replacing
733
- // if (node.name !== this.#name) {
734
- // return false
735
- // }
736
- // is based on https://github.com/npm/cli/pull/8089.
737
- if (node.name !== this.name || !this.#safeFrom) {
738
- return false;
739
- }
740
- // NOTE: this condition means we explicitly do not support overriding
741
- // bundled or shrinkwrapped dependencies
742
- if (node.hasShrinkwrap || node.inShrinkwrap || node.inBundle) {
743
- return depValid(node, this.rawSpec, this.accept, this.#safeFrom);
744
- }
745
- // Patch replacing
746
- // return depValid(node, this.spec, this.#accept, this.#from)
747
- // is based on https://github.com/npm/cli/pull/8089.
748
- //
749
- // If there's no override we just use the spec.
750
- if (!this.overrides?.keySpec) {
751
- return depValid(node, this.spec, this.accept, this.#safeFrom);
752
- }
753
- // There's some override. If the target node satisfies the overriding spec
754
- // then it's okay.
755
- if (depValid(node, this.spec, this.accept, this.#safeFrom)) {
756
- return true;
757
- }
758
- // If it doesn't, then it should at least satisfy the original spec.
759
- if (!depValid(node, this.rawSpec, this.accept, this.#safeFrom)) {
760
- return false;
761
- }
762
- // It satisfies the original spec, not the overriding spec. We need to make
763
- // sure it doesn't use the overridden spec.
764
- // For example:
765
- // we might have an ^8.0.0 rawSpec, and an override that makes
766
- // keySpec=8.23.0 and the override value spec=9.0.0.
767
- // If the node is 9.0.0, then it's okay because it's consistent with spec.
768
- // If the node is 8.24.0, then it's okay because it's consistent with the rawSpec.
769
- // If the node is 8.23.0, then it's not okay because even though it's consistent
770
- // with the rawSpec, it's also consistent with the keySpec.
771
- // So we're looking for ^8.0.0 or 9.0.0 and not 8.23.0.
772
- return !depValid(node, this.overrides.keySpec, this.accept, this.#safeFrom);
773
- }
774
- }
54
+ const DiffAction = utils.createEnum({
55
+ add: 'ADD',
56
+ change: 'CHANGE',
57
+ remove: 'REMOVE'
58
+ });
775
59
 
776
60
  const {
777
61
  LOOP_SENTINEL,
@@ -1067,10 +351,17 @@ function updatePackageJsonFromNode(editablePkgJson, tree, node, newVersion, rang
1067
351
  for (const depField of ['dependencies', 'optionalDependencies', 'peerDependencies']) {
1068
352
  const depObject = editablePkgJson.content[depField];
1069
353
  const oldRange = objects.hasOwn(depObject, name) ? depObject[name] : undefined;
1070
- const oldMin = strings.isNonEmptyString(oldRange) ? vendor.semverExports.minVersion(oldRange) : null;
354
+ if (typeof oldRange !== 'string' || oldRange.startsWith('catalog:')) {
355
+ continue;
356
+ }
357
+ const npaResult = utils.npa(oldRange);
358
+ if (!npaResult || npaResult.subSpec) {
359
+ continue;
360
+ }
361
+ const oldMin = utils.getMinVersion(npaResult.rawSpec);
1071
362
  const newRange = oldMin &&
1072
363
  // Ensure we're on the same major version...
1073
- vendor.semverExports.major(newVersion) === vendor.semverExports.major(oldMin.version) &&
364
+ utils.getMajor(newVersion) === oldMin.major &&
1074
365
  // and not a downgrade.
1075
366
  vendor.semverExports.gte(newVersion, oldMin.version) ? utils.applyRange(oldRange, newVersion, rangeStyle) : oldRange;
1076
367
  if (oldRange !== newRange) {
@@ -1086,7 +377,7 @@ function updatePackageJsonFromNode(editablePkgJson, tree, node, newVersion, rang
1086
377
  return result;
1087
378
  }
1088
379
 
1089
- const require$2 =Module.createRequire(require('u' + 'rl').pathToFileURL(__filename).href)
380
+ // @ts-ignore
1090
381
  const {
1091
382
  NPM,
1092
383
  NPX,
@@ -1099,7 +390,7 @@ const {
1099
390
  getIpc
1100
391
  }
1101
392
  } = constants;
1102
- const SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES = {
393
+ const SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES$1 = {
1103
394
  __proto__: null,
1104
395
  audit: false,
1105
396
  dryRun: true,
@@ -1112,7 +403,7 @@ const SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES = {
1112
403
  };
1113
404
  const kCtorArgs = Symbol('ctorArgs');
1114
405
  const kRiskyReify = Symbol('riskyReify');
1115
- const Arborist = require$2(getArboristClassPath());
406
+ const Arborist = vendor.arboristExports;
1116
407
 
1117
408
  // Implementation code not related to our custom behavior is based on
1118
409
  // https://github.com/npm/cli/blob/v11.0.0/workspaces/arborist/lib/arborist/index.js:
@@ -1121,7 +412,7 @@ class SafeArborist extends Arborist {
1121
412
  super({
1122
413
  path: (ctorArgs.length ? ctorArgs[0]?.path : undefined) ?? process.cwd(),
1123
414
  ...(ctorArgs.length ? ctorArgs[0] : undefined),
1124
- ...SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
415
+ ...SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES$1
1125
416
  }, ...ctorArgs.slice(1));
1126
417
  this[kCtorArgs] = ctorArgs;
1127
418
  }
@@ -1152,7 +443,7 @@ class SafeArborist extends Arborist {
1152
443
  }
1153
444
  await super.reify({
1154
445
  ...options,
1155
- ...SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES,
446
+ ...SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES$1,
1156
447
  progress: false
1157
448
  },
1158
449
  // @ts-ignore: TypeScript gets grumpy about rest parameters.
@@ -1201,6 +492,20 @@ class SafeArborist extends Arborist {
1201
492
  }
1202
493
 
1203
494
  const require$1 =Module.createRequire(require('u' + 'rl').pathToFileURL(__filename).href)
495
+ const SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES = {
496
+ __proto__: null,
497
+ audit: false,
498
+ dryRun: true,
499
+ fund: false,
500
+ ignoreScripts: true,
501
+ progress: false,
502
+ save: false,
503
+ saveBundle: false,
504
+ silent: true
505
+ };
506
+ const Edge = vendor.edgeExports;
507
+ const Node = vendor.nodeExports;
508
+ const OverrideSet = vendor.overrideSetExports;
1204
509
  function installSafeArborist() {
1205
510
  // Override '@npmcli/arborist' module exports with patched variants based on
1206
511
  // https://github.com/npm/cli/pull/8089.
@@ -1209,13 +514,13 @@ function installSafeArborist() {
1209
514
  exports: SafeArborist
1210
515
  };
1211
516
  cache[getArboristEdgeClassPath()] = {
1212
- exports: SafeEdge
517
+ exports: Edge
1213
518
  };
1214
519
  cache[getArboristNodeClassPath()] = {
1215
- exports: SafeNode
520
+ exports: Node
1216
521
  };
1217
522
  cache[getArboristOverrideSetClassPath()] = {
1218
- exports: SafeOverrideSet
523
+ exports: OverrideSet
1219
524
  };
1220
525
  }
1221
526
 
@@ -1223,12 +528,11 @@ installSafeArborist();
1223
528
 
1224
529
  exports.Arborist = Arborist;
1225
530
  exports.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES = SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES;
1226
- exports.SafeArborist = SafeArborist;
1227
531
  exports.findBestPatchVersion = findBestPatchVersion;
1228
532
  exports.findPackageNode = findPackageNode;
1229
533
  exports.findPackageNodes = findPackageNodes;
1230
534
  exports.getAlertsMapFromArborist = getAlertsMapFromArborist;
1231
535
  exports.updateNode = updateNode;
1232
536
  exports.updatePackageJsonFromNode = updatePackageJsonFromNode;
1233
- //# debugId=aa999c00-ac0b-4e97-b4fe-41280eca7c7b
537
+ //# debugId=8064dcdf-3aa8-4cd5-b56c-354d369825da
1234
538
  //# sourceMappingURL=shadow-inject.js.map