@socketsecurity/cli-with-sentry 1.0.110 → 1.1.0

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.
Files changed (38) hide show
  1. package/dist/cli.js +150 -1298
  2. package/dist/cli.js.map +1 -1
  3. package/dist/constants.js +6 -5
  4. package/dist/constants.js.map +1 -1
  5. package/dist/shadow-npm-bin.js +10 -4
  6. package/dist/shadow-npm-bin.js.map +1 -1
  7. package/dist/shadow-npm-inject.js +21 -240
  8. package/dist/shadow-npm-inject.js.map +1 -1
  9. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  10. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  11. package/dist/types/commands/fix/coana-fix.d.mts +1 -1
  12. package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
  13. package/dist/types/commands/fix/handle-fix.d.mts +1 -1
  14. package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
  15. package/dist/types/commands/fix/types.d.mts +18 -0
  16. package/dist/types/commands/fix/types.d.mts.map +1 -0
  17. package/dist/types/constants.d.mts.map +1 -1
  18. package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts.map +1 -1
  19. package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -1
  20. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
  21. package/dist/types/shadow/npm/bin.d.mts.map +1 -1
  22. package/dist/types/utils/alerts-map.d.mts.map +1 -1
  23. package/dist/types/utils/fs.d.mts +3 -1
  24. package/dist/types/utils/fs.d.mts.map +1 -1
  25. package/dist/utils.js +990 -1222
  26. package/dist/utils.js.map +1 -1
  27. package/dist/vendor.js +111951 -119286
  28. package/package.json +6 -6
  29. package/dist/types/commands/fix/agent-fix.d.mts +0 -42
  30. package/dist/types/commands/fix/agent-fix.d.mts.map +0 -1
  31. package/dist/types/commands/fix/get-actual-tree.d.mts +0 -3
  32. package/dist/types/commands/fix/get-actual-tree.d.mts.map +0 -1
  33. package/dist/types/commands/fix/npm-fix.d.mts +0 -7
  34. package/dist/types/commands/fix/npm-fix.d.mts.map +0 -1
  35. package/dist/types/commands/fix/pnpm-fix.d.mts +0 -7
  36. package/dist/types/commands/fix/pnpm-fix.d.mts.map +0 -1
  37. package/dist/types/commands/fix/shared.d.mts +0 -10
  38. package/dist/types/commands/fix/shared.d.mts.map +0 -1
package/dist/cli.js CHANGED
@@ -19,14 +19,11 @@ var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
19
19
  var strings = require('../external/@socketsecurity/registry/lib/strings');
20
20
  var arrays = require('../external/@socketsecurity/registry/lib/arrays');
21
21
  var regexps = require('../external/@socketsecurity/registry/lib/regexps');
22
- var registry = require('../external/@socketsecurity/registry');
23
- var npm = require('../external/@socketsecurity/registry/lib/npm');
24
- var packages = require('../external/@socketsecurity/registry/lib/packages');
25
- var sorts = require('../external/@socketsecurity/registry/lib/sorts');
26
- var shadowNpmInject = require('./shadow-npm-inject.js');
27
- var require$$10 = require('../external/@socketsecurity/registry/lib/objects');
28
22
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
29
23
  var shadowNpmBin = require('./shadow-npm-bin.js');
24
+ var require$$10 = require('../external/@socketsecurity/registry/lib/objects');
25
+ var registry = require('../external/@socketsecurity/registry');
26
+ var packages = require('../external/@socketsecurity/registry/lib/packages');
30
27
  var require$$11 = require('../external/@socketsecurity/registry/lib/promises');
31
28
  var require$$1 = require('node:util');
32
29
  var os = require('node:os');
@@ -318,7 +315,7 @@ async function handleAnalytics({
318
315
  });
319
316
  }
320
317
 
321
- const CMD_NAME$x = 'analytics';
318
+ const CMD_NAME$w = 'analytics';
322
319
  const description$D = 'Look up analytics data';
323
320
  const hidden$v = false;
324
321
  const cmdAnalytics = {
@@ -330,7 +327,7 @@ async function run$Q(argv, importMeta, {
330
327
  parentName
331
328
  }) {
332
329
  const config = {
333
- commandName: CMD_NAME$x,
330
+ commandName: CMD_NAME$w,
334
331
  description: description$D,
335
332
  hidden: hidden$v,
336
333
  flags: {
@@ -348,7 +345,7 @@ async function run$Q(argv, importMeta, {
348
345
  $ ${command} [options] [ "org" | "repo" <reponame>] [TIME]
349
346
 
350
347
  API Token Requirements
351
- ${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$x}`)}
348
+ ${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$w}`)}
352
349
 
353
350
  The scope is either org or repo level, defaults to org.
354
351
 
@@ -742,7 +739,7 @@ async function handleAuditLog({
742
739
  });
743
740
  }
744
741
 
745
- const CMD_NAME$w = 'audit-log';
742
+ const CMD_NAME$v = 'audit-log';
746
743
  const description$C = 'Look up the audit log for an organization';
747
744
  const hidden$u = false;
748
745
  const cmdAuditLog = {
@@ -754,7 +751,7 @@ async function run$P(argv, importMeta, {
754
751
  parentName
755
752
  }) {
756
753
  const config = {
757
- commandName: CMD_NAME$w,
754
+ commandName: CMD_NAME$v,
758
755
  description: description$C,
759
756
  hidden: hidden$u,
760
757
  flags: {
@@ -784,7 +781,7 @@ async function run$P(argv, importMeta, {
784
781
  $ ${command} [options] [FILTER]
785
782
 
786
783
  API Token Requirements
787
- ${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$w}`)}
784
+ ${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$v}`)}
788
785
 
789
786
  This feature requires an Enterprise Plan. To learn more about getting access
790
787
  to this feature and many more, please visit ${constants.SOCKET_WEBSITE_URL}/pricing
@@ -2599,7 +2596,7 @@ async function handleConfigAuto({
2599
2596
  await outputConfigAuto(key, result, outputKind);
2600
2597
  }
2601
2598
 
2602
- const CMD_NAME$v = 'auto';
2599
+ const CMD_NAME$u = 'auto';
2603
2600
  const description$B = 'Automatically discover and set the correct value config item';
2604
2601
  const hidden$t = false;
2605
2602
  const cmdConfigAuto = {
@@ -2611,7 +2608,7 @@ async function run$N(argv, importMeta, {
2611
2608
  parentName
2612
2609
  }) {
2613
2610
  const config = {
2614
- commandName: CMD_NAME$v,
2611
+ commandName: CMD_NAME$u,
2615
2612
  description: description$B,
2616
2613
  hidden: hidden$t,
2617
2614
  flags: {
@@ -2949,7 +2946,7 @@ async function handleConfigSet({
2949
2946
  await outputConfigSet(result, outputKind);
2950
2947
  }
2951
2948
 
2952
- const CMD_NAME$u = 'set';
2949
+ const CMD_NAME$t = 'set';
2953
2950
  const description$A = 'Update the value of a local CLI config item';
2954
2951
  const hidden$s = false;
2955
2952
  const cmdConfigSet = {
@@ -2961,7 +2958,7 @@ async function run$K(argv, importMeta, {
2961
2958
  parentName
2962
2959
  }) {
2963
2960
  const config = {
2964
- commandName: CMD_NAME$u,
2961
+ commandName: CMD_NAME$t,
2965
2962
  description: description$A,
2966
2963
  hidden: hidden$s,
2967
2964
  flags: {
@@ -3073,7 +3070,7 @@ async function handleConfigUnset({
3073
3070
  await outputConfigUnset(updateResult, outputKind);
3074
3071
  }
3075
3072
 
3076
- const CMD_NAME$t = 'unset';
3073
+ const CMD_NAME$s = 'unset';
3077
3074
  const description$z = 'Clear the value of a local CLI config item';
3078
3075
  const hidden$r = false;
3079
3076
  const cmdConfigUnset = {
@@ -3085,7 +3082,7 @@ async function run$J(argv, importMeta, {
3085
3082
  parentName
3086
3083
  }) {
3087
3084
  const config = {
3088
- commandName: CMD_NAME$t,
3085
+ commandName: CMD_NAME$s,
3089
3086
  description: description$z,
3090
3087
  hidden: hidden$r,
3091
3088
  flags: {
@@ -3194,25 +3191,7 @@ function createSocketBranchParser(options) {
3194
3191
  };
3195
3192
  };
3196
3193
  }
3197
- const genericSocketBranchParser = createSocketBranchParser();
3198
- function getSocketBranchFullNameComponent(pkgName) {
3199
- const purlObj = utils.getPurlObject(typeof pkgName === 'string' && !pkgName.startsWith('pkg:') ? vendor.packageurlJsExports.PackageURL.fromString(`pkg:unknown/${pkgName}`) : pkgName);
3200
- const branchMaybeNamespace = purlObj.namespace ? `${formatBranchName(purlObj.namespace)}--` : '';
3201
- return `${branchMaybeNamespace}${formatBranchName(purlObj.name)}`;
3202
- }
3203
- function getSocketBranchName(purl, newVersion, workspace) {
3204
- const purlObj = utils.getPurlObject(purl);
3205
- const branchType = getSocketBranchPurlTypeComponent(purlObj);
3206
- const branchWorkspace = getSocketBranchWorkspaceComponent(workspace);
3207
- const branchFullName = getSocketBranchFullNameComponent(purlObj);
3208
- const branchVersion = getSocketBranchPackageVersionComponent(purlObj.version);
3209
- const branchNewVersion = formatBranchName(newVersion);
3210
- return `socket/${branchType}/${branchWorkspace}/${branchFullName}_${branchVersion}_${branchNewVersion}`;
3211
- }
3212
- function getSocketBranchPackageVersionComponent(version) {
3213
- const purlObj = utils.getPurlObject(typeof version === 'string' && !version.startsWith('pkg:') ? vendor.packageurlJsExports.PackageURL.fromString(`pkg:unknown/unknown@${version}`) : version);
3214
- return formatBranchName(purlObj.version);
3215
- }
3194
+ createSocketBranchParser();
3216
3195
  function getSocketBranchPattern(options) {
3217
3196
  const {
3218
3197
  newVersion,
@@ -3231,29 +3210,6 @@ function getSocketBranchPattern(options) {
3231
3210
  const escNewVersion = newVersion ? regexps.escapeRegExp(formatBranchName(newVersion)) : '[^_]+';
3232
3211
  return new RegExp(`^socket/(${escType})/(${escWorkspace})/(${escFullName})_(${escVersion})_(${escNewVersion})$`);
3233
3212
  }
3234
- function getSocketBranchPurlTypeComponent(purl) {
3235
- const purlObj = utils.getPurlObject(purl);
3236
- return formatBranchName(purlObj.type);
3237
- }
3238
- function getSocketBranchWorkspaceComponent(workspace) {
3239
- return workspace ? formatBranchName(workspace) : 'root';
3240
- }
3241
- function getSocketCommitMessage(purl, newVersion, workspace) {
3242
- const purlObj = utils.getPurlObject(purl);
3243
- const fullName = utils.getPkgFullNameFromPurl(purlObj);
3244
- return `socket: Bump ${fullName} from ${purlObj.version} to ${newVersion}${workspace ? ` in ${workspace}` : ''}`;
3245
- }
3246
- function getSocketPullRequestBody(purl, newVersion, workspace) {
3247
- const purlObj = utils.getPurlObject(purl);
3248
- const fullName = utils.getPkgFullNameFromPurl(purlObj);
3249
- const pkgOverviewUrl = utils.getSocketDevPackageOverviewUrlFromPurl(purlObj);
3250
- return `Bump [${fullName}](${pkgOverviewUrl}) from ${purlObj.version} to ${newVersion}${workspace ? ` in ${workspace}` : ''}.`;
3251
- }
3252
- function getSocketPullRequestTitle(purl, newVersion, workspace) {
3253
- const purlObj = utils.getPurlObject(purl);
3254
- const fullName = utils.getPkgFullNameFromPurl(purlObj);
3255
- return `Bump ${fullName} from ${purlObj.version} to ${newVersion}${workspace ? ` in ${workspace}` : ''}`;
3256
- }
3257
3213
 
3258
3214
  let _octokit;
3259
3215
  function getOctokit() {
@@ -3375,85 +3331,6 @@ async function fetchGhsaDetails(ids) {
3375
3331
  }
3376
3332
  return results;
3377
3333
  }
3378
- async function cleanupPrs(owner, repo, options) {
3379
- const contextualMatches = await getSocketPrsWithContext(owner, repo, options);
3380
- if (!contextualMatches.length) {
3381
- return [];
3382
- }
3383
- const cachesToSave = new Map();
3384
- const {
3385
- newVersion
3386
- } = {
3387
- __proto__: null,
3388
- ...options
3389
- };
3390
- const branchParser = createSocketBranchParser(options);
3391
- const octokit = getOctokit();
3392
- const settledMatches = await Promise.allSettled(contextualMatches.map(async ({
3393
- context,
3394
- match
3395
- }) => {
3396
- const {
3397
- number: prNum
3398
- } = match;
3399
- const prRef = `PR #${prNum}`;
3400
- const parsedBranch = branchParser(match.headRefName);
3401
- const prToVersion = parsedBranch?.newVersion;
3402
-
3403
- // Close older PRs.
3404
- if (prToVersion && newVersion && vendor.semverExports.lt(prToVersion, newVersion)) {
3405
- try {
3406
- await octokit.pulls.update({
3407
- owner,
3408
- repo,
3409
- pull_number: prNum,
3410
- state: 'closed'
3411
- });
3412
- require$$9.debugFn('notice', `pr: closing ${prRef} for ${prToVersion}`);
3413
- // Remove entry from parent object.
3414
- context.parent.splice(context.index, 1);
3415
- // Mark cache to be saved.
3416
- cachesToSave.set(context.cacheKey, context.data);
3417
- return null;
3418
- } catch (e) {
3419
- require$$9.debugFn('error', `pr: failed to close ${prRef} for ${prToVersion}\n`, e?.message || 'Unknown error');
3420
- }
3421
- }
3422
- // Update stale PRs.
3423
- // https://docs.github.com/en/graphql/reference/enums#mergestatestatus
3424
- if (match.mergeStateStatus === 'BEHIND') {
3425
- try {
3426
- await octokit.repos.merge({
3427
- owner,
3428
- repo,
3429
- base: match.headRefName,
3430
- head: match.baseRefName
3431
- });
3432
- require$$9.debugFn('notice', `pr: updating stale ${prRef}`);
3433
- // Update entry entry.
3434
- if (context.apiType === 'graphql') {
3435
- context.entry.mergeStateStatus = 'CLEAN';
3436
- } else if (context.apiType === 'rest') {
3437
- context.entry.mergeable_state = 'clean';
3438
- }
3439
- // Mark cache to be saved.
3440
- cachesToSave.set(context.cacheKey, context.data);
3441
- } catch (e) {
3442
- const message = e?.message || 'Unknown error';
3443
- require$$9.debugFn('error', `pr: failed to update ${prRef} - ${message}`);
3444
- }
3445
- }
3446
- return match;
3447
- }));
3448
- if (cachesToSave.size) {
3449
- await Promise.allSettled(Array.from(cachesToSave).map(({
3450
- 0: key,
3451
- 1: data
3452
- }) => writeCache(key, data)));
3453
- }
3454
- const fulfilledMatches = settledMatches.filter(r => r.status === 'fulfilled' && r.value);
3455
- return fulfilledMatches.map(r => r.value.match);
3456
- }
3457
3334
  async function enablePrAutoMerge({
3458
3335
  node_id: prId
3459
3336
  }) {
@@ -3620,40 +3497,6 @@ async function getSocketPrsWithContext(owner, repo, options) {
3620
3497
  }
3621
3498
  return contextualMatches;
3622
3499
  }
3623
- async function openPr(owner, repo, branch, purl, newVersion, options) {
3624
- const {
3625
- baseBranch = 'main',
3626
- workspace
3627
- } = {
3628
- __proto__: null,
3629
- ...options
3630
- };
3631
- const purlObj = utils.getPurlObject(purl);
3632
- const octokit = getOctokit();
3633
- try {
3634
- const octokitPullsCreateParams = {
3635
- owner,
3636
- repo,
3637
- title: getSocketPullRequestTitle(purlObj, newVersion, workspace),
3638
- head: branch,
3639
- base: baseBranch,
3640
- body: getSocketPullRequestBody(purlObj, newVersion, workspace)
3641
- };
3642
- require$$9.debugDir('inspect', {
3643
- octokitPullsCreateParams
3644
- });
3645
- return await octokit.pulls.create(octokitPullsCreateParams);
3646
- } catch (e) {
3647
- let message = `Failed to open pull request`;
3648
- const errors = e instanceof vendor.RequestError ? e.response?.data?.['errors'] : undefined;
3649
- if (Array.isArray(errors) && errors.length) {
3650
- const details = errors.map(d => `- ${d.message?.trim() ?? `${d.resource}.${d.field} (${d.code})`}`).join('\n');
3651
- message += `:\n${details}`;
3652
- }
3653
- require$$9.debugFn('error', message);
3654
- }
3655
- return null;
3656
- }
3657
3500
  async function openCoanaPr(owner, repo, branch, ghsaIds, options) {
3658
3501
  const {
3659
3502
  baseBranch = 'main',
@@ -3833,7 +3676,7 @@ async function coanaFix(fixConfig) {
3833
3676
  data: uploadCResult.data
3834
3677
  };
3835
3678
  }
3836
- const isAll = ghsas.length === 1 && (ghsas[0] === 'all' || ghsas[0] === 'auto');
3679
+ const isAll = !ghsas.length || ghsas.length === 1 && (ghsas[0] === 'all' || ghsas[0] === 'auto');
3837
3680
  const shouldOpenPrs = fixEnv.isCi && fixEnv.repoInfo;
3838
3681
  if (!shouldOpenPrs) {
3839
3682
  const ids = isAll ? ['all'] : ghsas.slice(0, limit);
@@ -3863,8 +3706,7 @@ async function coanaFix(fixConfig) {
3863
3706
  if (isAll) {
3864
3707
  const foundCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3865
3708
  cwd,
3866
- spinner,
3867
- stdio: 'inherit'
3709
+ spinner
3868
3710
  });
3869
3711
  if (foundCResult.ok) {
3870
3712
  const foundIds = utils.cmdFlagValueToArray(/(?<=Vulnerabilities found:).*/.exec(foundCResult.data));
@@ -3904,7 +3746,7 @@ async function coanaFix(fixConfig) {
3904
3746
 
3905
3747
  // Apply fix for single GHSA ID.
3906
3748
  // eslint-disable-next-line no-await-in-loop
3907
- const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', id, ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3749
+ const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', id, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3908
3750
  cwd,
3909
3751
  spinner,
3910
3752
  stdio: 'inherit'
@@ -4026,1121 +3868,46 @@ async function coanaFix(fixConfig) {
4026
3868
  };
4027
3869
  }
4028
3870
 
4029
- function getPrsForPurl(fixEnv, partialPurl) {
4030
- if (!fixEnv) {
4031
- return [];
4032
- }
4033
- const prs = [];
4034
- const partialPurlObj = utils.getPurlObject(partialPurl);
4035
- const branchFullName = getSocketBranchFullNameComponent(partialPurlObj);
4036
- const branchPurlType = getSocketBranchPurlTypeComponent(partialPurlObj);
4037
- for (const pr of fixEnv.prs) {
4038
- const parsedBranch = genericSocketBranchParser(pr.headRefName);
4039
- if (branchPurlType === parsedBranch?.type && branchFullName === parsedBranch?.fullName) {
4040
- prs.push(pr);
4041
- }
4042
- }
4043
- if (require$$9.isDebug('notice,silly')) {
4044
- const fullName = packages.resolvePackageName(partialPurlObj);
4045
- if (prs.length) {
4046
- require$$9.debugFn('notice', `found: ${prs.length} PRs for ${fullName}`);
4047
- require$$9.debugDir('silly', {
4048
- prs
4049
- });
4050
- } else if (fixEnv.prs.length) {
4051
- require$$9.debugFn('notice', `miss: 0 PRs found for ${fullName}`);
4052
- }
3871
+ async function outputFixResult(result, outputKind) {
3872
+ if (!result.ok) {
3873
+ process.exitCode = result.code ?? 1;
4053
3874
  }
4054
- return prs;
4055
- }
4056
-
4057
- async function getActualTree(cwd = process.cwd()) {
4058
- try {
4059
- // @npmcli/arborist DOES have partial support for pnpm structured node_modules
4060
- // folders. However, support is iffy resulting in unhappy paths of errors and hangs.
4061
- // So, to avoid unhappy paths, we restrict our usage to --dry-run loading of the
4062
- // node_modules folder.
4063
- const arb = new shadowNpmInject.Arborist({
4064
- path: cwd,
4065
- ...shadowNpmInject.SAFE_NO_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES
4066
- });
4067
- return {
4068
- actualTree: await arb.loadActual()
4069
- };
4070
- } catch (e) {
4071
- return {
4072
- error: e
4073
- };
3875
+ if (outputKind === 'json') {
3876
+ logger.logger.log(utils.serializeResultJson(result));
3877
+ return;
4074
3878
  }
4075
- }
4076
-
4077
- const {
4078
- BUN: BUN$4,
4079
- NPM: NPM$4,
4080
- OVERRIDES: OVERRIDES$1,
4081
- PNPM: PNPM$4,
4082
- RESOLUTIONS: RESOLUTIONS$1,
4083
- VLT: VLT$5,
4084
- YARN_BERRY: YARN_BERRY$4,
4085
- YARN_CLASSIC: YARN_CLASSIC$4
4086
- } = constants;
4087
- function getOverridesDataBun(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
4088
- const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
4089
- return {
4090
- type: YARN_BERRY$4,
4091
- overrides
4092
- };
4093
- }
4094
-
4095
- // npm overrides documentation:
4096
- // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
4097
- function getOverridesDataNpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
4098
- const overrides = pkgJson?.[OVERRIDES$1] ?? {};
4099
- return {
4100
- type: NPM$4,
4101
- overrides
4102
- };
4103
- }
4104
-
4105
- // pnpm overrides documentation:
4106
- // https://pnpm.io/package_json#pnpmoverrides
4107
- function getOverridesDataPnpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
4108
- const overrides = pkgJson?.[PNPM$4]?.[OVERRIDES$1] ?? {};
4109
- return {
4110
- type: PNPM$4,
4111
- overrides
4112
- };
4113
- }
4114
- function getOverridesDataVlt(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
4115
- const overrides = pkgJson?.[OVERRIDES$1] ?? {};
4116
- return {
4117
- type: VLT$5,
4118
- overrides
4119
- };
4120
- }
4121
-
4122
- // Yarn resolutions documentation:
4123
- // https://yarnpkg.com/configuration/manifest#resolutions
4124
- function getOverridesDataYarn(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
4125
- const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
4126
- return {
4127
- type: YARN_BERRY$4,
4128
- overrides
4129
- };
4130
- }
4131
-
4132
- // Yarn resolutions documentation:
4133
- // https://classic.yarnpkg.com/en/docs/selective-version-resolutions
4134
- function getOverridesDataYarnClassic(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
4135
- const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
4136
- return {
4137
- type: YARN_CLASSIC$4,
4138
- overrides
4139
- };
4140
- }
4141
- function getOverridesData(pkgEnvDetails, pkgJson) {
4142
- switch (pkgEnvDetails.agent) {
4143
- case BUN$4:
4144
- return getOverridesDataBun(pkgEnvDetails, pkgJson);
4145
- case PNPM$4:
4146
- return getOverridesDataPnpm(pkgEnvDetails, pkgJson);
4147
- case VLT$5:
4148
- return getOverridesDataVlt(pkgEnvDetails, pkgJson);
4149
- case YARN_BERRY$4:
4150
- return getOverridesDataYarn(pkgEnvDetails, pkgJson);
4151
- case YARN_CLASSIC$4:
4152
- return getOverridesDataYarnClassic(pkgEnvDetails, pkgJson);
4153
- case NPM$4:
4154
- default:
4155
- return getOverridesDataNpm(pkgEnvDetails, pkgJson);
3879
+ if (!result.ok) {
3880
+ logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
3881
+ return;
4156
3882
  }
3883
+ logger.logger.log('');
3884
+ logger.logger.success('Finished!');
4157
3885
  }
4158
3886
 
4159
- const noopHandler = () => {};
4160
- async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
4161
- afterInstall = noopHandler,
4162
- afterUpdate = noopHandler,
4163
- beforeInstall = noopHandler,
4164
- revertInstall = noopHandler
4165
- }, fixConfig) {
4166
- const {
4167
- pkgPath: rootPath
4168
- } = pkgEnvDetails;
4169
- const fixEnv = await getFixEnv();
4170
- require$$9.debugDir('inspect', {
4171
- fixEnv
4172
- });
4173
- const {
3887
+ async function handleFix({
3888
+ autoMerge,
3889
+ cwd,
3890
+ ghsas,
3891
+ limit,
3892
+ minSatisfying,
3893
+ orgSlug,
3894
+ outputKind,
3895
+ prCheck,
3896
+ purls,
3897
+ rangeStyle,
3898
+ spinner,
3899
+ test,
3900
+ testScript,
3901
+ unknownFlags
3902
+ }) {
3903
+ await outputFixResult(await coanaFix({
4174
3904
  autoMerge,
4175
3905
  cwd,
3906
+ ghsas,
4176
3907
  limit,
4177
- minSatisfying,
4178
- prCheck,
3908
+ orgSlug,
4179
3909
  rangeStyle,
4180
3910
  spinner,
4181
- test,
4182
- testScript
4183
- } = fixConfig;
4184
- let count = 0;
4185
- const infoByPartialPurl = utils.getCveInfoFromAlertsMap(alertsMap, {
4186
- filter: {
4187
- upgradable: false
4188
- }
4189
- });
4190
- if (!infoByPartialPurl) {
4191
- spinner?.stop();
4192
- logger.logger.info('No fixable vulns found.');
4193
- if (alertsMap.size) {
4194
- require$$9.debugDir('inspect', {
4195
- alertsMap
4196
- });
4197
- } else {
4198
- require$$9.debugFn('inspect', '{ alertsMap: Map(0) {} }');
4199
- }
4200
- return {
4201
- ok: true,
4202
- data: {
4203
- fixed: false
4204
- }
4205
- };
4206
- }
4207
- if (require$$9.isDebug('notice,inspect')) {
4208
- spinner?.stop();
4209
- const partialPurls = Array.from(infoByPartialPurl.keys());
4210
- const {
4211
- length: purlsCount
4212
- } = partialPurls;
4213
- require$$9.debugFn('notice', `found: ${purlsCount} ${words.pluralize('PURL', purlsCount)} with CVEs`);
4214
- require$$9.debugDir('inspect', {
4215
- partialPurls
4216
- });
4217
- spinner?.start();
4218
- }
4219
- const {
4220
- packumentCache
4221
- } = constants;
4222
- const workspacePkgJsonPaths = await utils.globWorkspace(pkgEnvDetails.agent, rootPath);
4223
- const pkgJsonPaths = [...workspacePkgJsonPaths,
4224
- // Process the workspace root last since it will add an override to package.json.
4225
- pkgEnvDetails.editablePkgJson.filename];
4226
- const sortedInfoEntries = Array.from(infoByPartialPurl.entries()).sort((a, b) => sorts.naturalCompare(a[0], b[0]));
4227
- const cleanupInfoEntriesLoop = () => {
4228
- logger.logger.dedent();
4229
- spinner?.dedent();
4230
- packumentCache.clear();
4231
- };
4232
- const getModifiedFiles = async (cwd = process.cwd()) => {
4233
- const unstagedCResult = await utils.gitUnstagedModifiedFiles(cwd);
4234
- return unstagedCResult.ok ? unstagedCResult.data.filter(filepath => {
4235
- const basename = path.basename(filepath);
4236
- return basename === 'package.json' || basename === pkgEnvDetails.lockName;
4237
- }) : [];
4238
- };
4239
- const handleInstallFail = error => {
4240
- cleanupInfoEntriesLoop();
4241
- spinner?.stop();
4242
- return {
4243
- ok: false,
4244
- message: 'Install failed',
4245
- cause: `${pkgEnvDetails.agent} install failed${error ? `; ${error}` : ''}`
4246
- };
4247
- };
4248
- const hasModifiedFiles = async (cwd = process.cwd()) => {
4249
- return (await getModifiedFiles(cwd)).length > 0;
4250
- };
4251
- spinner?.stop();
4252
- infoEntriesLoop: for (let i = 0, {
4253
- length
4254
- } = sortedInfoEntries; i < length; i += 1) {
4255
- const isLastInfoEntry = i === length - 1;
4256
- const infoEntry = sortedInfoEntries[i];
4257
- const partialPurlObj = utils.getPurlObject(infoEntry[0]);
4258
- const name = packages.resolvePackageName(partialPurlObj);
4259
- const infos = Array.from(infoEntry[1].values());
4260
- if (!infos.length) {
4261
- require$$9.debugFn('notice', `miss: CVEs expected, but not found, for ${name}`);
4262
- continue infoEntriesLoop;
4263
- }
4264
- logger.logger.log(`Processing '${name}'`);
4265
- logger.logger.indent();
4266
- spinner?.indent();
4267
- if (registry.getManifestData(partialPurlObj.type, name)) {
4268
- require$$9.debugFn('notice', `found: Socket Optimize variant for ${name}`);
4269
- }
4270
- // eslint-disable-next-line no-await-in-loop
4271
- const packument = await packages.fetchPackagePackument(name);
4272
- if (!packument) {
4273
- logger.logger.warn(`Unexpected condition: No packument found for ${name}.\n`);
4274
- cleanupInfoEntriesLoop();
4275
- // Skip to next package.
4276
- continue infoEntriesLoop;
4277
- }
4278
- require$$9.debugDir('inspect', {
4279
- infos
4280
- });
4281
- const availableVersions = Object.keys(packument.versions);
4282
- const prs = getPrsForPurl(fixEnv, infoEntry[0]);
4283
- const warningsForAfter = new Set();
4284
- let changed = false;
4285
- // eslint-disable-next-line no-unused-labels
4286
- for (let j = 0, {
4287
- length: length_j
4288
- } = pkgJsonPaths; j < length_j; j += 1) {
4289
- const isLastPkgJsonPath = j === length_j - 1;
4290
- const pkgJsonPath = pkgJsonPaths[j];
4291
- const pkgPath = path.dirname(pkgJsonPath);
4292
- const isWorkspaceRoot = pkgJsonPath === pkgEnvDetails.editablePkgJson.filename;
4293
- const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
4294
- // actualTree may not be defined on the first iteration of pkgJsonPathsLoop.
4295
- if (!actualTree) {
4296
- if (!fixEnv.isCi) {
4297
- // eslint-disable-next-line no-await-in-loop
4298
- await utils.removeNodeModules(cwd);
4299
- }
4300
- if (fixEnv.isCi && fs$1.existsSync(path.join(rootPath, 'node_modules'))) {
4301
- // eslint-disable-next-line no-await-in-loop
4302
- const treeResult = await getActualTree(cwd);
4303
- const maybeActualTree = treeResult.actualTree;
4304
- if (!maybeActualTree) {
4305
- // Exit early if install fails.
4306
- return handleInstallFail(treeResult.error);
4307
- }
4308
- actualTree = maybeActualTree;
4309
- } else {
4310
- // eslint-disable-next-line no-await-in-loop
4311
- const installResult = await installer(pkgEnvDetails, {
4312
- cwd,
4313
- spinner
4314
- });
4315
- const maybeActualTree = installResult.actualTree;
4316
- if (!maybeActualTree) {
4317
- // Exit early if install fails.
4318
- return handleInstallFail(installResult.error);
4319
- }
4320
- actualTree = maybeActualTree;
4321
- }
4322
- if (!fs$1.existsSync(pkgEnvDetails.lockPath)) {
4323
- // Exit early if lockfile is missing.
4324
- return handleInstallFail(new Error(`Missing lockfile at ${pkgEnvDetails.lockPath}`));
4325
- }
4326
- }
4327
- const oldVersions = arrays.arrayUnique(shadowNpmInject.findPackageNodes(actualTree, name).map(n => n.version).filter(Boolean));
4328
- if (!oldVersions.length) {
4329
- require$$9.debugFn('notice', `skip: ${name} not found`);
4330
- cleanupInfoEntriesLoop();
4331
- // Skip to next package.
4332
- continue infoEntriesLoop;
4333
- }
4334
-
4335
- // Always re-read the editable package.json to avoid stale mutations
4336
- // across iterations.
4337
- // eslint-disable-next-line no-await-in-loop
4338
- const editablePkgJson = await packages.readPackageJson(pkgJsonPath, {
4339
- editable: true
4340
- });
4341
- const seenBranches = new Set();
4342
- const seenVersions = new Set();
4343
- let hasAnnouncedWorkspace = false;
4344
- let workspaceLogCallCount = logger.logger.logCallCount;
4345
- if (require$$9.isDebug('notice')) {
4346
- require$$9.debugFn('notice', `check: workspace ${workspace}`);
4347
- hasAnnouncedWorkspace = true;
4348
- workspaceLogCallCount = logger.logger.logCallCount;
4349
- }
4350
- oldVersionsLoop: for (const oldVersion of oldVersions) {
4351
- const oldId = `${name}@${oldVersion}`;
4352
- const oldPurl = utils.idToPurl(oldId, partialPurlObj.type);
4353
- const node = shadowNpmInject.findPackageNode(actualTree, name, oldVersion);
4354
- if (!node) {
4355
- require$$9.debugFn('notice', `skip: ${oldId} not found`);
4356
- continue oldVersionsLoop;
4357
- }
4358
- infosLoop: for (const {
4359
- firstPatchedVersionIdentifier,
4360
- vulnerableVersionRange
4361
- } of infos) {
4362
- const newVersion = shadowNpmInject.findBestPatchVersion(node, availableVersions, {
4363
- minSatisfying,
4364
- vulnerableVersionRange
4365
- });
4366
- const newVersionPackument = newVersion ? packument.versions[newVersion] : undefined;
4367
- if (!(newVersion && newVersionPackument)) {
4368
- warningsForAfter.add(`${oldId} not updated: requires >=${firstPatchedVersionIdentifier}`);
4369
- continue infosLoop;
4370
- }
4371
- if (seenVersions.has(newVersion)) {
4372
- continue infosLoop;
4373
- }
4374
- if (vendor.semverExports.gte(oldVersion, newVersion)) {
4375
- require$$9.debugFn('silly', `skip: ${oldId} is >= ${newVersion}`);
4376
- continue infosLoop;
4377
- }
4378
- const branch = getSocketBranchName(oldPurl, newVersion, workspace);
4379
- if (seenBranches.has(branch)) {
4380
- continue infosLoop;
4381
- }
4382
- const pr = prCheck ? prs.find(p => p.headRefName === branch) : undefined;
4383
- if (pr) {
4384
- require$$9.debugFn('notice', `skip: PR #${pr.number} for ${name}@${newVersion} exists`);
4385
- seenBranches.add(branch);
4386
- continue infosLoop;
4387
- }
4388
- if (fixEnv.isCi && (
4389
- // eslint-disable-next-line no-await-in-loop
4390
- await utils.gitRemoteBranchExists(branch, cwd))) {
4391
- require$$9.debugFn('notice', `skip: remote branch "${branch}" for ${name}@${newVersion} exists`);
4392
- seenBranches.add(branch);
4393
- continue infosLoop;
4394
- }
4395
- const {
4396
- overrides: oldOverrides
4397
- } = getOverridesData(pkgEnvDetails, editablePkgJson.content);
4398
- let refRange = oldOverrides?.[`${name}@${vulnerableVersionRange}`];
4399
- if (!strings.isNonEmptyString(refRange)) {
4400
- refRange = oldOverrides?.[name];
4401
- }
4402
- if (!strings.isNonEmptyString(refRange)) {
4403
- refRange = oldVersion;
4404
- }
4405
-
4406
- // eslint-disable-next-line no-await-in-loop
4407
- await beforeInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
4408
- shadowNpmInject.updatePackageJsonFromNode(editablePkgJson, actualTree, node, newVersion, rangeStyle);
4409
-
4410
- // eslint-disable-next-line no-await-in-loop
4411
- await editablePkgJson.save({
4412
- ignoreWhitespace: true
4413
- });
4414
-
4415
- // eslint-disable-next-line no-await-in-loop
4416
- await afterUpdate(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
4417
-
4418
- // eslint-disable-next-line no-await-in-loop
4419
- if (!(await hasModifiedFiles(cwd))) {
4420
- require$$9.debugFn('notice', `skip: no changes for ${name}@${newVersion}`);
4421
- seenVersions.add(newVersion);
4422
- // Reset things just in case.
4423
- if (fixEnv.isCi) {
4424
- // eslint-disable-next-line no-await-in-loop
4425
- await utils.gitResetAndClean(fixEnv.baseBranch, cwd);
4426
- // eslint-disable-next-line no-await-in-loop
4427
- await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
4428
- }
4429
- continue infosLoop;
4430
- }
4431
- spinner?.start();
4432
- if (!hasAnnouncedWorkspace) {
4433
- hasAnnouncedWorkspace = true;
4434
- workspaceLogCallCount = logger.logger.logCallCount;
4435
- }
4436
- const newId = `${name}@${utils.applyRange(refRange, newVersion, rangeStyle)}`;
4437
- spinner?.info(`Installing ${newId} in ${workspace}.`);
4438
- let error;
4439
- let errored = false;
4440
- try {
4441
- // eslint-disable-next-line no-await-in-loop
4442
- const installResult = await installer(pkgEnvDetails, {
4443
- cwd,
4444
- spinner
4445
- });
4446
- const maybeActualTree = installResult.actualTree;
4447
- if (!maybeActualTree) {
4448
- errored = true;
4449
- error = installResult.error;
4450
- } else if (!fs$1.existsSync(pkgEnvDetails.lockPath)) {
4451
- errored = true;
4452
- error = new Error(`Missing lockfile at ${pkgEnvDetails.lockPath}`);
4453
- } else {
4454
- actualTree = maybeActualTree;
4455
- // eslint-disable-next-line no-await-in-loop
4456
- await afterInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
4457
- if (test) {
4458
- spinner?.info(`Testing ${newId} in ${workspace}.`);
4459
- // eslint-disable-next-line no-await-in-loop
4460
- await npm.runNpmScript(testScript, [], {
4461
- spinner,
4462
- stdio: 'ignore'
4463
- });
4464
- }
4465
- spinner?.success(`Fixed ${name} in ${workspace}.`);
4466
- seenVersions.add(newVersion);
4467
- }
4468
- } catch (e) {
4469
- error = e;
4470
- errored = true;
4471
- }
4472
- spinner?.stop();
4473
-
4474
- // Check repoInfo to make TypeScript happy.
4475
- if (!errored && fixEnv.isCi && fixEnv.repoInfo) {
4476
- require$$9.debugFn('notice', 'pr: creating');
4477
- try {
4478
- const pushed =
4479
- // eslint-disable-next-line no-await-in-loop
4480
- (await utils.gitCreateBranch(branch, cwd)) && (
4481
- // eslint-disable-next-line no-await-in-loop
4482
- await utils.gitCheckoutBranch(branch, cwd)) && (
4483
- // eslint-disable-next-line no-await-in-loop
4484
- await utils.gitCommit(getSocketCommitMessage(oldPurl, newVersion, workspace),
4485
- // eslint-disable-next-line no-await-in-loop
4486
- await getModifiedFiles(cwd), {
4487
- cwd,
4488
- email: fixEnv.gitEmail,
4489
- user: fixEnv.gitUser
4490
- })) && (
4491
- // eslint-disable-next-line no-await-in-loop
4492
- await utils.gitPushBranch(branch, cwd));
4493
- if (!pushed) {
4494
- logger.logger.warn('Unexpected condition: Push failed, skipping PR creation.');
4495
- // eslint-disable-next-line no-await-in-loop
4496
- await utils.gitResetAndClean(fixEnv.baseBranch, cwd);
4497
- // eslint-disable-next-line no-await-in-loop
4498
- await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
4499
- // eslint-disable-next-line no-await-in-loop
4500
- await utils.gitDeleteBranch(branch, cwd);
4501
- // eslint-disable-next-line no-await-in-loop
4502
- const installResult = await installer(pkgEnvDetails, {
4503
- cwd,
4504
- spinner
4505
- });
4506
- const maybeActualTree = installResult.actualTree;
4507
- if (!maybeActualTree) {
4508
- // Exit early if install fails.
4509
- return handleInstallFail(installResult.error);
4510
- }
4511
- if (!fs$1.existsSync(pkgEnvDetails.lockPath)) {
4512
- // Exit early if lockfile is missing.
4513
- return handleInstallFail(new Error(`Missing lockfile at ${pkgEnvDetails.lockPath}`));
4514
- }
4515
- actualTree = maybeActualTree;
4516
- continue infosLoop;
4517
- }
4518
- seenBranches.add(branch);
4519
-
4520
- // eslint-disable-next-line no-await-in-loop
4521
- await Promise.allSettled([setGitRemoteGithubRepoUrl(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, fixEnv.githubToken, cwd), cleanupPrs(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, {
4522
- newVersion,
4523
- purl: oldPurl,
4524
- workspace
4525
- })]);
4526
- // eslint-disable-next-line no-await-in-loop
4527
- const prResponse = await openPr(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, branch, oldPurl, newVersion, {
4528
- baseBranch: fixEnv.baseBranch,
4529
- cwd,
4530
- workspace
4531
- });
4532
- if (prResponse) {
4533
- const {
4534
- data
4535
- } = prResponse;
4536
- const prRef = `PR #${data.number}`;
4537
- logger.logger.success(`Opened ${prRef}.`);
4538
- if (autoMerge) {
4539
- logger.logger.indent();
4540
- spinner?.indent();
4541
- // eslint-disable-next-line no-await-in-loop
4542
- const {
4543
- details,
4544
- enabled
4545
- } = await enablePrAutoMerge(data);
4546
- if (enabled) {
4547
- logger.logger.info(`Auto-merge enabled for ${prRef}.`);
4548
- } else {
4549
- const message = `Failed to enable auto-merge for ${prRef}${details ? `:\n${details.map(d => ` - ${d}`).join('\n')}` : '.'}`;
4550
- logger.logger.error(message);
4551
- }
4552
- logger.logger.dedent();
4553
- spinner?.dedent();
4554
- }
4555
- }
4556
- } catch (e) {
4557
- error = e;
4558
- errored = true;
4559
- }
4560
- } else if (fixEnv.isCi) {
4561
- require$$9.debugFn('notice', 'skip: PR creation');
4562
- }
4563
- if (fixEnv.isCi) {
4564
- spinner?.start();
4565
- // eslint-disable-next-line no-await-in-loop
4566
- await utils.gitResetAndClean(branch, cwd);
4567
- // eslint-disable-next-line no-await-in-loop
4568
- await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
4569
- // eslint-disable-next-line no-await-in-loop
4570
- const installResult = await installer(pkgEnvDetails, {
4571
- cwd,
4572
- spinner
4573
- });
4574
- spinner?.stop();
4575
- const maybeActualTree = installResult.actualTree;
4576
- if (maybeActualTree) {
4577
- actualTree = maybeActualTree;
4578
- } else {
4579
- errored = true;
4580
- error = installResult.error;
4581
- }
4582
- }
4583
- if (errored) {
4584
- if (!fixEnv.isCi) {
4585
- spinner?.start();
4586
- // eslint-disable-next-line no-await-in-loop
4587
- await revertInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
4588
- // eslint-disable-next-line no-await-in-loop
4589
- await Promise.all([utils.removeNodeModules(cwd), editablePkgJson.save({
4590
- ignoreWhitespace: true
4591
- })]);
4592
- // eslint-disable-next-line no-await-in-loop
4593
- const installResult = await installer(pkgEnvDetails, {
4594
- cwd,
4595
- spinner
4596
- });
4597
- spinner?.stop();
4598
- const maybeActualTree = installResult.actualTree;
4599
- if (!maybeActualTree) {
4600
- // Exit early if install fails.
4601
- return handleInstallFail(installResult.error);
4602
- }
4603
- actualTree = maybeActualTree;
4604
- }
4605
- return {
4606
- ok: false,
4607
- message: 'Update failed',
4608
- cause: `Update failed for ${oldId} in ${workspace}${error ? `; ${error}` : ''}`
4609
- };
4610
- } else {
4611
- changed = true;
4612
- }
4613
- require$$9.debugFn('notice', 'increment: count', count + 1);
4614
- if (++count >= limit) {
4615
- cleanupInfoEntriesLoop();
4616
- // Exit main loop.
4617
- break infoEntriesLoop;
4618
- }
4619
- }
4620
- }
4621
- if (!isLastPkgJsonPath && logger.logger.logCallCount > workspaceLogCallCount) {
4622
- logger.logger.logNewline();
4623
- }
4624
- }
4625
- for (const warningText of warningsForAfter) {
4626
- logger.logger.warn(warningText);
4627
- }
4628
- if (!changed && !warningsForAfter.size) {
4629
- logger.logger.info('No vulnerable versions found.');
4630
- }
4631
- if (!isLastInfoEntry) {
4632
- logger.logger.logNewline();
4633
- }
4634
- cleanupInfoEntriesLoop();
4635
- }
4636
- spinner?.stop();
4637
-
4638
- // Or, did we change anything?
4639
- return {
4640
- ok: true,
4641
- data: {
4642
- fixed: true
4643
- }
4644
- };
4645
- }
4646
-
4647
- const CMD_NAME$s = 'socket fix';
4648
- function getFixAlertsMapOptions(options = {}) {
4649
- return {
4650
- __proto__: null,
4651
- consolidate: true,
4652
- nothrow: true,
4653
- onlyFixable: true,
4654
- ...options,
4655
- filter: utils.toFilterConfig({
4656
- existing: true,
4657
- ...require$$10.getOwn(options, 'filter')
4658
- })
4659
- };
4660
- }
4661
-
4662
- async function install$1(pkgEnvDetails, options) {
4663
- const {
4664
- args: extraArgs,
4665
- cwd,
4666
- spinner
4667
- } = {
4668
- __proto__: null,
4669
- ...options
4670
- };
4671
- const useDebug = require$$9.isDebug('stdio');
4672
- const args = [
4673
- // If "true", npm does not run scripts specified in package.json files.
4674
- // Note that commands explicitly intended to run a particular script, such
4675
- // as `npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will
4676
- // still run their intended script if `ignore-scripts` is set, but they will
4677
- // not run any pre- or post-scripts.
4678
- // https://docs.npmjs.com/cli/v11/commands/npm-install#ignore-scripts
4679
- '--ignore-scripts',
4680
- // When "true" submit audit reports alongside the current npm command to the
4681
- // default registry and all registries configured for scopes. See the
4682
- // documentation for `npm audit` for details on what is submitted.
4683
- // https://docs.npmjs.com/cli/v11/commands/npm-install#audit
4684
- '--no-audit',
4685
- // When "true" displays the message at the end of each `npm install` acknowledging
4686
- // the number of dependencies looking for funding. See `npm fund` for details.
4687
- // https://docs.npmjs.com/cli/v11/commands/npm-install#fund
4688
- '--no-fund',
4689
- // When set to "true", npm will display a progress bar during time intensive
4690
- // operations, if `process.stderr` is a TTY. Set to "false" to suppress the
4691
- // progress bar.
4692
- // https://docs.npmjs.com/cli/v8/using-npm/config#progress
4693
- '--no-progress',
4694
- // What level of logs to report. All logs are written to a debug log, with
4695
- // the path to that file printed if the execution of a command fails. The
4696
- // default is "notice".
4697
- // https://docs.npmjs.com/cli/v8/using-npm/config#loglevel
4698
- ...(useDebug ? [] : ['--silent']), ...(extraArgs ?? [])];
4699
- const wasSpinning = !!spinner?.isSpinning;
4700
- spinner?.stop();
4701
- const quotedCmd = `\`${pkgEnvDetails.agent} install ${args.join(' ')}\``;
4702
- require$$9.debugFn('stdio', `spawn: ${quotedCmd}`);
4703
- try {
4704
- await utils.runAgentInstall(pkgEnvDetails, {
4705
- args,
4706
- spinner,
4707
- stdio: useDebug ? 'inherit' : 'ignore'
4708
- });
4709
- } catch (error) {
4710
- const result = {
4711
- error
4712
- };
4713
- require$$9.debugFn('error', `caught: ${quotedCmd} failed`);
4714
- require$$9.debugDir('inspect', result);
4715
- return result;
4716
- }
4717
- const treeResult = await getActualTree(cwd);
4718
- if (treeResult.actualTree) {
4719
- if (wasSpinning) {
4720
- spinner.start();
4721
- }
4722
- return treeResult;
4723
- }
4724
- require$$9.debugFn('error', 'caught: await arb.loadActual() error');
4725
- require$$9.debugDir('inspect', treeResult);
4726
- if (wasSpinning) {
4727
- spinner.start();
4728
- }
4729
- return treeResult;
4730
- }
4731
- async function npmFix(pkgEnvDetails, fixConfig) {
4732
- const {
4733
- purls,
4734
- spinner
4735
- } = fixConfig;
4736
- spinner?.start();
4737
- const flatConfig = await utils.getNpmConfig({
4738
- npmVersion: pkgEnvDetails.agentVersion
4739
- });
4740
- let actualTree;
4741
- let alertsMap;
4742
- try {
4743
- if (purls.length) {
4744
- alertsMap = await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions());
4745
- } else {
4746
- let arb;
4747
- try {
4748
- arb = new shadowNpmInject.Arborist({
4749
- path: pkgEnvDetails.pkgPath,
4750
- ...flatConfig,
4751
- ...shadowNpmInject.SAFE_WITH_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES
4752
- });
4753
- // Calling arb.reify() creates the arb.diff object, nulls-out arb.idealTree,
4754
- // and populates arb.actualTree.
4755
- actualTree = await arb.reify();
4756
- } catch (e) {
4757
- spinner?.stop();
4758
- require$$9.debugFn('error', 'caught: await arb.reify() error');
4759
- require$$9.debugDir('inspect', {
4760
- error: e
4761
- });
4762
- return {
4763
- ok: false,
4764
- message: 'npm error',
4765
- cause: e?.message || 'Unknown npm error.'
4766
- };
4767
- }
4768
- alertsMap = await shadowNpmInject.getAlertsMapFromArborist(arb, getFixAlertsMapOptions());
4769
- }
4770
- } catch (e) {
4771
- spinner?.stop();
4772
- require$$9.debugFn('error', 'caught: Socket batch PURL API error');
4773
- require$$9.debugDir('inspect', {
4774
- error: e
4775
- });
4776
- return {
4777
- ok: false,
4778
- message: 'Socket API error',
4779
- cause: e?.message || 'Unknown Socket batch PURL API error.'
4780
- };
4781
- }
4782
- let revertData;
4783
- return await agentFix(pkgEnvDetails, actualTree, alertsMap, install$1, {
4784
- async beforeInstall(editablePkgJson) {
4785
- revertData = {
4786
- // Track existing dependencies in the root package.json to revert to later.
4787
- ...(editablePkgJson.content.dependencies && {
4788
- dependencies: {
4789
- ...editablePkgJson.content.dependencies
4790
- }
4791
- }),
4792
- ...(editablePkgJson.content.optionalDependencies && {
4793
- optionalDependencies: {
4794
- ...editablePkgJson.content.optionalDependencies
4795
- }
4796
- }),
4797
- ...(editablePkgJson.content.peerDependencies && {
4798
- peerDependencies: {
4799
- ...editablePkgJson.content.peerDependencies
4800
- }
4801
- })
4802
- };
4803
- },
4804
- async afterUpdate(editablePkgJson, packument, oldVersion, newVersion) {
4805
- // Exit early if not the root workspace.
4806
- if (editablePkgJson.filename !== pkgEnvDetails.editablePkgJson.filename) {
4807
- return;
4808
- }
4809
- // Update package-lock.json using @npmcli/arborist.
4810
- const arb = new shadowNpmInject.Arborist({
4811
- path: pkgEnvDetails.pkgPath,
4812
- ...flatConfig,
4813
- ...shadowNpmInject.SAFE_WITH_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES
4814
- });
4815
- // Build the ideal tree of nodes that are used to generated the saved
4816
- // package-lock.json
4817
- const idealTree = await arb.buildIdealTree();
4818
- const node = shadowNpmInject.findPackageNode(idealTree, packument.name, oldVersion);
4819
- if (node) {
4820
- // Update the ideal tree node.
4821
- shadowNpmInject.updateNode(node, newVersion, packument.versions[newVersion]);
4822
- // Save package-lock.json lockfile.
4823
- await arb.reify();
4824
- }
4825
- },
4826
- async revertInstall(editablePkgJson) {
4827
- if (revertData) {
4828
- // Revert package.json.
4829
- editablePkgJson.update(revertData);
4830
- await editablePkgJson.save({
4831
- ignoreWhitespace: true
4832
- });
4833
- }
4834
- }
4835
- }, fixConfig);
4836
- }
4837
-
4838
- async function outputFixResult(result, outputKind) {
4839
- if (!result.ok) {
4840
- process.exitCode = result.code ?? 1;
4841
- }
4842
- if (outputKind === 'json') {
4843
- logger.logger.log(utils.serializeResultJson(result));
4844
- return;
4845
- }
4846
- if (!result.ok) {
4847
- logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
4848
- return;
4849
- }
4850
- logger.logger.log('');
4851
- logger.logger.success('Finished!');
4852
- }
4853
-
4854
- async function install(pkgEnvDetails, options) {
4855
- const {
4856
- args: extraArgs,
4857
- cwd,
4858
- spinner
4859
- } = {
4860
- __proto__: null,
4861
- ...options
4862
- };
4863
- const args = [
4864
- // Do not execute any scripts defined in the project package.json and its dependencies.
4865
- // https://pnpm.io/9.x/cli/install#--ignore-scripts
4866
- '--ignore-scripts',
4867
- // Enable pnpm updates to pnpm-lock.yaml in CI environments.
4868
- // https://pnpm.io/cli/install#--frozen-lockfile
4869
- '--no-frozen-lockfile',
4870
- // Enable a non-interactive pnpm install
4871
- // https://github.com/pnpm/pnpm/issues/6778
4872
- '--config.confirmModulesPurge=false', ...(extraArgs ?? [])];
4873
- const wasSpinning = !!spinner?.isSpinning;
4874
- spinner?.stop();
4875
- const quotedCmd = `\`${pkgEnvDetails.agent} install ${args.join(' ')}\``;
4876
- require$$9.debugFn('stdio', `spawn: ${quotedCmd}`);
4877
- try {
4878
- await utils.runAgentInstall(pkgEnvDetails, {
4879
- args,
4880
- spinner,
4881
- stdio: require$$9.isDebug('stdio') ? 'inherit' : 'ignore'
4882
- });
4883
- } catch (error) {
4884
- const result = {
4885
- error
4886
- };
4887
- require$$9.debugFn('error', `caught: ${quotedCmd} failed`);
4888
- require$$9.debugDir('inspect', result);
4889
- return result;
4890
- }
4891
- const treeResult = await getActualTree(cwd);
4892
- if (treeResult.actualTree) {
4893
- if (wasSpinning) {
4894
- spinner.start();
4895
- }
4896
- return treeResult;
4897
- }
4898
- require$$9.debugFn('error', 'caught: await arb.loadActual() error');
4899
- require$$9.debugDir('inspect', treeResult);
4900
- if (wasSpinning) {
4901
- spinner.start();
4902
- }
4903
- return treeResult;
4904
- }
4905
- async function pnpmFix(pkgEnvDetails, fixConfig) {
4906
- const {
4907
- cwd,
4908
- purls,
4909
- spinner
4910
- } = fixConfig;
4911
- spinner?.start();
4912
- let actualTree;
4913
- let lockSrc = pkgEnvDetails.lockSrc;
4914
- let lockfile = utils.parsePnpmLockfile(lockSrc);
4915
- // Update pnpm-lock.yaml if its version is older than what the installed pnpm
4916
- // produces.
4917
- if (pkgEnvDetails.agentVersion.major >= 10 && (utils.parsePnpmLockfileVersion(lockfile?.lockfileVersion)?.major ?? 0) <= 6) {
4918
- const installResult = await install(pkgEnvDetails, {
4919
- args: ['--lockfile-only'],
4920
- cwd,
4921
- spinner
4922
- });
4923
- const maybeActualTree = installResult.actualTree;
4924
- if (maybeActualTree) {
4925
- lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
4926
- } else {
4927
- lockSrc = '';
4928
- }
4929
- if (lockSrc) {
4930
- actualTree = maybeActualTree;
4931
- lockfile = utils.parsePnpmLockfile(lockSrc);
4932
- } else {
4933
- lockfile = null;
4934
- }
4935
- }
4936
-
4937
- // Exit early if pnpm-lock.yaml is not found or usable.
4938
- // Check !lockSrc to make TypeScript happy.
4939
- if (!lockfile || !lockSrc) {
4940
- spinner?.stop();
4941
- return {
4942
- ok: false,
4943
- message: 'Missing lockfile',
4944
- cause: 'Required pnpm-lock.yaml not found or usable'
4945
- };
4946
- }
4947
- let alertsMap;
4948
- try {
4949
- alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions()) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getFixAlertsMapOptions());
4950
- } catch (e) {
4951
- spinner?.stop();
4952
- require$$9.debugFn('error', 'caught: Socket batch PURL API error');
4953
- require$$9.debugDir('inspect', {
4954
- error: e
4955
- });
4956
- return {
4957
- ok: false,
4958
- message: 'Socket API error',
4959
- cause: e?.message || 'Unknown Socket batch PURL API error.'
4960
- };
4961
- }
4962
- let revertData;
4963
- let revertOverrides;
4964
- let revertOverridesSrc = '';
4965
- return await agentFix(pkgEnvDetails, actualTree, alertsMap, install, {
4966
- async beforeInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, options) {
4967
- lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
4968
-
4969
- // Update overrides for the root workspace.
4970
- if (editablePkgJson.filename === pkgEnvDetails.editablePkgJson.filename) {
4971
- const {
4972
- overrides: oldOverrides
4973
- } = getOverridesDataPnpm(pkgEnvDetails, editablePkgJson.content);
4974
- const oldPnpmSection = editablePkgJson.content['pnpm'];
4975
- const overrideKey = `${packument.name}@${vulnerableVersionRange}`;
4976
- revertOverridesSrc = utils.extractOverridesFromPnpmLockSrc(lockSrc);
4977
- // Track existing overrides in the root package.json to revert to later.
4978
- revertOverrides = {
4979
- pnpm: oldPnpmSection ? {
4980
- ...oldPnpmSection,
4981
- overrides: require$$10.hasKeys(oldOverrides) ? {
4982
- ...oldOverrides,
4983
- [overrideKey]: undefined
4984
- } :
4985
- // Properties with undefined values are deleted when saved as JSON.
4986
- undefined
4987
- } :
4988
- // Properties with undefined values are deleted when saved as JSON.
4989
- undefined
4990
- };
4991
- // Update overrides in the root package.json so that when `pnpm install`
4992
- // generates pnpm-lock.yaml it updates transitive dependencies too.
4993
- editablePkgJson.update({
4994
- pnpm: {
4995
- ...oldPnpmSection,
4996
- overrides: {
4997
- ...oldOverrides,
4998
- [overrideKey]: utils.applyRange(oldOverrides?.[overrideKey] ?? oldVersion, newVersion, options.rangeStyle)
4999
- }
5000
- }
5001
- });
5002
- } else {
5003
- revertOverrides = undefined;
5004
- revertOverridesSrc = '';
5005
- }
5006
- revertData = {
5007
- // If "pnpm" or "pnpm.overrides" fields are undefined they will be
5008
- // deleted when saved.
5009
- ...revertOverrides,
5010
- // Track existing dependencies in the root package.json to revert to later.
5011
- ...(editablePkgJson.content.dependencies && {
5012
- dependencies: {
5013
- ...editablePkgJson.content.dependencies
5014
- }
5015
- }),
5016
- ...(editablePkgJson.content.optionalDependencies && {
5017
- optionalDependencies: {
5018
- ...editablePkgJson.content.optionalDependencies
5019
- }
5020
- }),
5021
- ...(editablePkgJson.content.peerDependencies && {
5022
- peerDependencies: {
5023
- ...editablePkgJson.content.peerDependencies
5024
- }
5025
- })
5026
- };
5027
- },
5028
- async afterInstall(editablePkgJson) {
5029
- if (revertOverrides) {
5030
- // Revert overrides metadata in package.json now that pnpm-lock.yaml
5031
- // has been updated.
5032
- editablePkgJson.update(revertOverrides);
5033
- await editablePkgJson.save({
5034
- ignoreWhitespace: true
5035
- });
5036
- }
5037
- lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
5038
- // Remove "overrides" block from pnpm-lock.yaml lockfile when processing
5039
- // the root workspace.
5040
- if (editablePkgJson.filename === pkgEnvDetails.editablePkgJson.filename) {
5041
- const updatedOverridesContent = utils.extractOverridesFromPnpmLockSrc(lockSrc);
5042
- if (updatedOverridesContent) {
5043
- // Remove "overrides" block from pnpm-lock.yaml lockfile.
5044
- lockSrc = lockSrc.replace(updatedOverridesContent, revertOverridesSrc);
5045
- // Save pnpm-lock.yaml lockfile.
5046
- await fs$1.promises.writeFile(pkgEnvDetails.lockPath, lockSrc, 'utf8');
5047
- }
5048
- }
5049
- },
5050
- async revertInstall(editablePkgJson) {
5051
- if (revertData) {
5052
- // Revert package.json.
5053
- editablePkgJson.update(revertData);
5054
- await editablePkgJson.save({
5055
- ignoreWhitespace: true
5056
- });
5057
- // Revert pnpm-lock.yaml lockfile to be on the safe side.
5058
- await fs$1.promises.writeFile(pkgEnvDetails.lockPath, lockSrc, 'utf8');
5059
- }
5060
- }
5061
- }, fixConfig);
5062
- }
5063
-
5064
- async function handleFix({
5065
- autoMerge,
5066
- cwd,
5067
- ghsas,
5068
- limit,
5069
- minSatisfying,
5070
- orgSlug,
5071
- outputKind,
5072
- prCheck,
5073
- purls,
5074
- rangeStyle,
5075
- spinner,
5076
- test,
5077
- testScript,
5078
- unknownFlags
5079
- }) {
5080
- if (ghsas.length) {
5081
- await outputFixResult(await coanaFix({
5082
- autoMerge,
5083
- cwd,
5084
- ghsas,
5085
- limit,
5086
- orgSlug,
5087
- rangeStyle,
5088
- spinner,
5089
- unknownFlags
5090
- }), outputKind);
5091
- return;
5092
- }
5093
- const pkgEnvCResult = await utils.detectAndValidatePackageEnvironment(cwd, {
5094
- cmdName: CMD_NAME$s,
5095
- logger: logger.logger
5096
- });
5097
- if (!pkgEnvCResult.ok) {
5098
- await outputFixResult(pkgEnvCResult, outputKind);
5099
- return;
5100
- }
5101
- const {
5102
- data: pkgEnvDetails
5103
- } = pkgEnvCResult;
5104
- if (!pkgEnvDetails) {
5105
- await outputFixResult({
5106
- ok: false,
5107
- message: 'No package found.',
5108
- cause: `No valid package environment found for project path: ${cwd}`
5109
- }, outputKind);
5110
- return;
5111
- }
5112
- require$$9.debugDir('inspect', {
5113
- pkgEnvDetails
5114
- });
5115
- const {
5116
- agent,
5117
- agentVersion
5118
- } = pkgEnvDetails;
5119
- const isNpm = agent === 'npm';
5120
- const isPnpm = agent === 'pnpm';
5121
- if (!isNpm && !isPnpm) {
5122
- await outputFixResult({
5123
- ok: false,
5124
- message: 'Not supported.',
5125
- cause: `${agent} v${agentVersion} is not supported by this command.`
5126
- }, outputKind);
5127
- return;
5128
- }
5129
- logger.logger.info(`Fixing packages for ${agent} v${agentVersion}.\n`);
5130
- const fixer = isNpm ? npmFix : pnpmFix;
5131
- await outputFixResult(await fixer(pkgEnvDetails, {
5132
- autoMerge,
5133
- cwd,
5134
- ghsas,
5135
- limit,
5136
- minSatisfying,
5137
- orgSlug,
5138
- prCheck,
5139
- purls,
5140
- rangeStyle,
5141
- spinner,
5142
- test,
5143
- testScript,
5144
3911
  unknownFlags
5145
3912
  }), outputKind);
5146
3913
  }
@@ -5172,7 +3939,8 @@ async function run$I(argv, importMeta, {
5172
3939
  autopilot: {
5173
3940
  type: 'boolean',
5174
3941
  default: false,
5175
- description: `Shorthand for --auto-merge --test`
3942
+ description: `Shorthand for --auto-merge --test`,
3943
+ hidden: true
5176
3944
  },
5177
3945
  ghsa: {
5178
3946
  type: 'string',
@@ -5195,7 +3963,8 @@ async function run$I(argv, importMeta, {
5195
3963
  minSatisfying: {
5196
3964
  type: 'boolean',
5197
3965
  default: false,
5198
- description: 'Constrain dependency updates to the minimum satisfying version'
3966
+ description: 'Constrain dependency updates to the minimum satisfying version',
3967
+ hidden: true
5199
3968
  },
5200
3969
  prCheck: {
5201
3970
  type: 'boolean',
@@ -5208,7 +3977,8 @@ async function run$I(argv, importMeta, {
5208
3977
  default: [],
5209
3978
  description: `Provide a list of ${vendor.terminalLinkExports('PURLs', 'https://github.com/package-url/purl-spec?tab=readme-ov-file#purl')} to compute fixes for, as either a comma separated value or as\nmultiple flags, instead of querying the Socket API`,
5210
3979
  isMultiple: true,
5211
- shortFlag: 'p'
3980
+ shortFlag: 'p',
3981
+ hidden: true
5212
3982
  },
5213
3983
  rangeStyle: {
5214
3984
  type: 'string',
@@ -7669,12 +6439,12 @@ async function run$t(argv, importMeta, {
7669
6439
  }
7670
6440
 
7671
6441
  const {
7672
- BUN: BUN$3,
7673
- NPM: NPM$3,
7674
- PNPM: PNPM$3,
7675
- VLT: VLT$4,
7676
- YARN_BERRY: YARN_BERRY$3,
7677
- YARN_CLASSIC: YARN_CLASSIC$3
6442
+ BUN: BUN$4,
6443
+ NPM: NPM$4,
6444
+ PNPM: PNPM$4,
6445
+ VLT: VLT$5,
6446
+ YARN_BERRY: YARN_BERRY$4,
6447
+ YARN_CLASSIC: YARN_CLASSIC$4
7678
6448
  } = constants;
7679
6449
  function matchLsCmdViewHumanStdout(stdout, name) {
7680
6450
  return stdout.includes(` ${name}@`);
@@ -7684,13 +6454,13 @@ function matchQueryCmdStdout(stdout, name) {
7684
6454
  }
7685
6455
  function lsStdoutIncludes(pkgEnvDetails, stdout, name) {
7686
6456
  switch (pkgEnvDetails.agent) {
7687
- case BUN$3:
7688
- case YARN_BERRY$3:
7689
- case YARN_CLASSIC$3:
6457
+ case BUN$4:
6458
+ case YARN_BERRY$4:
6459
+ case YARN_CLASSIC$4:
7690
6460
  return matchLsCmdViewHumanStdout(stdout, name);
7691
- case PNPM$3:
7692
- case VLT$4:
7693
- case NPM$3:
6461
+ case PNPM$4:
6462
+ case VLT$5:
6463
+ case NPM$4:
7694
6464
  default:
7695
6465
  return matchQueryCmdStdout(stdout, name);
7696
6466
  }
@@ -7720,6 +6490,88 @@ function getDependencyEntries(pkgEnvDetails) {
7720
6490
  }) => o);
7721
6491
  }
7722
6492
 
6493
+ const {
6494
+ BUN: BUN$3,
6495
+ NPM: NPM$3,
6496
+ OVERRIDES: OVERRIDES$1,
6497
+ PNPM: PNPM$3,
6498
+ RESOLUTIONS: RESOLUTIONS$1,
6499
+ VLT: VLT$4,
6500
+ YARN_BERRY: YARN_BERRY$3,
6501
+ YARN_CLASSIC: YARN_CLASSIC$3
6502
+ } = constants;
6503
+ function getOverridesDataBun(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
6504
+ const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
6505
+ return {
6506
+ type: YARN_BERRY$3,
6507
+ overrides
6508
+ };
6509
+ }
6510
+
6511
+ // npm overrides documentation:
6512
+ // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
6513
+ function getOverridesDataNpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
6514
+ const overrides = pkgJson?.[OVERRIDES$1] ?? {};
6515
+ return {
6516
+ type: NPM$3,
6517
+ overrides
6518
+ };
6519
+ }
6520
+
6521
+ // pnpm overrides documentation:
6522
+ // https://pnpm.io/package_json#pnpmoverrides
6523
+ function getOverridesDataPnpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
6524
+ const overrides = pkgJson?.[PNPM$3]?.[OVERRIDES$1] ?? {};
6525
+ return {
6526
+ type: PNPM$3,
6527
+ overrides
6528
+ };
6529
+ }
6530
+ function getOverridesDataVlt(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
6531
+ const overrides = pkgJson?.[OVERRIDES$1] ?? {};
6532
+ return {
6533
+ type: VLT$4,
6534
+ overrides
6535
+ };
6536
+ }
6537
+
6538
+ // Yarn resolutions documentation:
6539
+ // https://yarnpkg.com/configuration/manifest#resolutions
6540
+ function getOverridesDataYarn(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
6541
+ const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
6542
+ return {
6543
+ type: YARN_BERRY$3,
6544
+ overrides
6545
+ };
6546
+ }
6547
+
6548
+ // Yarn resolutions documentation:
6549
+ // https://classic.yarnpkg.com/en/docs/selective-version-resolutions
6550
+ function getOverridesDataYarnClassic(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
6551
+ const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
6552
+ return {
6553
+ type: YARN_CLASSIC$3,
6554
+ overrides
6555
+ };
6556
+ }
6557
+ function getOverridesData(pkgEnvDetails, pkgJson) {
6558
+ switch (pkgEnvDetails.agent) {
6559
+ case BUN$3:
6560
+ return getOverridesDataBun(pkgEnvDetails, pkgJson);
6561
+ case PNPM$3:
6562
+ return getOverridesDataPnpm(pkgEnvDetails, pkgJson);
6563
+ case VLT$4:
6564
+ return getOverridesDataVlt(pkgEnvDetails, pkgJson);
6565
+ case YARN_BERRY$3:
6566
+ return getOverridesDataYarn(pkgEnvDetails, pkgJson);
6567
+ case YARN_CLASSIC$3:
6568
+ return getOverridesDataYarnClassic(pkgEnvDetails, pkgJson);
6569
+ case NPM$3:
6570
+ default:
6571
+ return getOverridesDataNpm(pkgEnvDetails, pkgJson);
6572
+ }
6573
+ }
6574
+
7723
6575
  const {
7724
6576
  BUN: BUN$2,
7725
6577
  LOCK_EXT,
@@ -15351,5 +14203,5 @@ void (async () => {
15351
14203
  await utils.captureException(e);
15352
14204
  }
15353
14205
  })();
15354
- //# debugId=90019b4f-8311-420b-bbc8-2645bd67f319
14206
+ //# debugId=2d71faa1-844b-480a-a713-c572fd14e2f4
15355
14207
  //# sourceMappingURL=cli.js.map