socket 0.14.124 → 0.14.125

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.
@@ -917,7 +917,7 @@ function emitBanner(name) {
917
917
  logger.logger.error(getAsciiHeader(name))
918
918
  }
919
919
  function getAsciiHeader(command) {
920
- const cliVersion = '0.14.124:5b2103f:da70cd14:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
920
+ const cliVersion = '0.14.125:11530dd:821f8925:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
921
921
  const nodeVersion = process$1.version
922
922
  const apiToken = shadowNpmInject.getDefaultToken()
923
923
  const defaultOrg = shadowNpmInject.getConfigValue('defaultOrg')
@@ -4180,7 +4180,6 @@ async function npmFix(
4180
4180
  )
4181
4181
  let error
4182
4182
  let errored = false
4183
- let installed = false
4184
4183
  let saved = false
4185
4184
 
4186
4185
  // eslint-disable-next-line no-await-in-loop
@@ -4196,7 +4195,6 @@ async function npmFix(
4196
4195
  await install$1(arb.idealTree, {
4197
4196
  cwd
4198
4197
  })
4199
- installed = true
4200
4198
  if (test) {
4201
4199
  if (!testedSpecs.has(newSpecKey)) {
4202
4200
  testedSpecs.add(newSpecKey)
@@ -4502,32 +4500,43 @@ async function pnpmFix(
4502
4500
  if (!packument) {
4503
4501
  continue
4504
4502
  }
4505
- const failedSpecs = new Set()
4506
4503
  const fixedSpecs = new Set()
4507
- const installedSpecs = new Set()
4508
- const testedSpecs = new Set()
4509
- const unavailableSpecs = new Set()
4510
- const revertedSpecs = new Set()
4511
4504
  for (const pkgJsonPath of pkgJsonPaths) {
4505
+ // Re-read actualTree to avoid lockfile state issues
4506
+ // eslint-disable-next-line no-await-in-loop
4507
+ actualTree = await getActualTree(cwd)
4508
+ const pkgPath = path$1.dirname(pkgJsonPath)
4509
+ const isWorkspaceRoot =
4510
+ pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
4511
+ const workspaceName = isWorkspaceRoot
4512
+ ? 'root'
4513
+ : path$1.relative(rootPath, pkgPath)
4514
+ const editablePkgJson = isWorkspaceRoot
4515
+ ? pkgEnvDetails.editablePkgJson
4516
+ : // eslint-disable-next-line no-await-in-loop
4517
+ await packages.readPackageJson(pkgJsonPath, {
4518
+ editable: true
4519
+ })
4520
+
4521
+ // Get current overrides for revert logic
4522
+ const oldPnpmSection = editablePkgJson.content[PNPM$8]
4523
+ const oldOverrides = oldPnpmSection?.[OVERRIDES$2]
4512
4524
  for (const oldVersion of oldVersions) {
4513
4525
  const oldSpec = `${name}@${oldVersion}`
4514
4526
  const oldPurl = `pkg:npm/${oldSpec}`
4527
+ const node = shadowNpmInject.findPackageNode(
4528
+ actualTree,
4529
+ name,
4530
+ oldVersion
4531
+ )
4532
+ if (!node) {
4533
+ debug.debugLog(`Skipping ${oldSpec}, no node found in ${pkgJsonPath}`)
4534
+ continue
4535
+ }
4515
4536
  for (const {
4516
4537
  firstPatchedVersionIdentifier,
4517
4538
  vulnerableVersionRange
4518
4539
  } of infos) {
4519
- const node = shadowNpmInject.findPackageNode(
4520
- actualTree,
4521
- name,
4522
- oldVersion
4523
- )
4524
- if (!node) {
4525
- debug.debugLog(
4526
- `Skipping ${oldSpec}, no node found in arborist.actualTree`,
4527
- pkgJsonPath
4528
- )
4529
- continue
4530
- }
4531
4540
  const availableVersions = Object.keys(packument.versions)
4532
4541
  const newVersion = shadowNpmInject.findBestPatchVersion(
4533
4542
  node,
@@ -4538,30 +4547,9 @@ async function pnpmFix(
4538
4547
  ? packument.versions[newVersion]
4539
4548
  : undefined
4540
4549
  if (!(newVersion && newVersionPackument)) {
4541
- if (!unavailableSpecs.has(oldSpec)) {
4542
- unavailableSpecs.add(oldSpec)
4543
- spinner?.fail(`No update available for ${oldSpec}`)
4544
- }
4550
+ spinner?.fail(`No update available for ${oldSpec}`)
4545
4551
  continue
4546
4552
  }
4547
- const isWorkspaceRoot =
4548
- pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
4549
- const workspaceName = isWorkspaceRoot
4550
- ? ''
4551
- : path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
4552
- const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
4553
- const editablePkgJson = isWorkspaceRoot
4554
- ? pkgEnvDetails.editablePkgJson
4555
- : // eslint-disable-next-line no-await-in-loop
4556
- await packages.readPackageJson(pkgJsonPath, {
4557
- editable: true
4558
- })
4559
- const oldPnpm = editablePkgJson.content[PNPM$8]
4560
- const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4561
- const oldOverrides = oldPnpm?.[OVERRIDES$2]
4562
- const oldOverridesCount = oldOverrides
4563
- ? Object.keys(oldOverrides).length
4564
- : 0
4565
4553
  const overrideKey = `${name}@${vulnerableVersionRange}`
4566
4554
  const newVersionRange = shadowNpmInject.applyRange(
4567
4555
  oldOverrides?.[overrideKey] ?? oldVersion,
@@ -4569,14 +4557,20 @@ async function pnpmFix(
4569
4557
  rangeStyle
4570
4558
  )
4571
4559
  const newSpec = `${name}@${newVersionRange}`
4572
- const newSpecKey = `${workspaceName ? `${workspaceName}>` : ''}${newSpec}`
4560
+ const newSpecKey = `${workspaceName}:${newSpec}`
4561
+ if (fixedSpecs.has(newSpecKey)) {
4562
+ debug.debugLog(
4563
+ `Already fixed ${newSpec} in ${workspaceName}, skipping`
4564
+ )
4565
+ continue
4566
+ }
4573
4567
  const updateData = isWorkspaceRoot
4574
4568
  ? {
4575
4569
  [PNPM$8]: {
4576
- ...oldPnpm,
4570
+ ...oldPnpmSection,
4577
4571
  [OVERRIDES$2]: {
4578
- [overrideKey]: newVersionRange,
4579
- ...oldOverrides
4572
+ ...oldOverrides,
4573
+ [overrideKey]: newVersionRange
4580
4574
  }
4581
4575
  }
4582
4576
  }
@@ -4584,44 +4578,28 @@ async function pnpmFix(
4584
4578
  const revertData = {
4585
4579
  ...(isWorkspaceRoot
4586
4580
  ? {
4587
- [PNPM$8]: oldPnpmKeyCount
4588
- ? {
4589
- ...oldPnpm,
4590
- [OVERRIDES$2]:
4591
- oldOverridesCount === 1
4592
- ? undefined
4593
- : {
4594
- [overrideKey]: undefined,
4595
- ...oldOverrides
4596
- }
4597
- }
4598
- : undefined
4581
+ [PNPM$8]: {
4582
+ ...oldPnpmSection,
4583
+ [OVERRIDES$2]:
4584
+ oldOverrides && Object.keys(oldOverrides).length > 1
4585
+ ? {
4586
+ ...oldOverrides,
4587
+ [overrideKey]: undefined
4588
+ }
4589
+ : undefined
4590
+ }
4599
4591
  }
4600
4592
  : {}),
4601
- ...(editablePkgJson.content.dependencies
4602
- ? {
4603
- dependencies: editablePkgJson.content.dependencies
4604
- }
4605
- : undefined),
4606
- ...(editablePkgJson.content.optionalDependencies
4607
- ? {
4608
- optionalDependencies:
4609
- editablePkgJson.content.optionalDependencies
4610
- }
4611
- : undefined),
4612
- ...(editablePkgJson.content.peerDependencies
4613
- ? {
4614
- peerDependencies: editablePkgJson.content.peerDependencies
4615
- }
4616
- : undefined)
4593
+ ...(editablePkgJson.content.dependencies && {
4594
+ dependencies: editablePkgJson.content.dependencies
4595
+ }),
4596
+ ...(editablePkgJson.content.optionalDependencies && {
4597
+ optionalDependencies: editablePkgJson.content.optionalDependencies
4598
+ }),
4599
+ ...(editablePkgJson.content.peerDependencies && {
4600
+ peerDependencies: editablePkgJson.content.peerDependencies
4601
+ })
4617
4602
  }
4618
- const branch = isCi
4619
- ? getSocketBranchName(oldPurl, newVersion, workspaceName)
4620
- : ''
4621
- const shouldOpenPr = isCi
4622
- ? // eslint-disable-next-line no-await-in-loop
4623
- !(await doesPullRequestExistForBranch(owner, repo, branch))
4624
- : false
4625
4603
  if (updateData) {
4626
4604
  editablePkgJson.update(updateData)
4627
4605
  }
@@ -4633,106 +4611,99 @@ async function pnpmFix(
4633
4611
  rangeStyle
4634
4612
  )
4635
4613
  debug.debugLog(`Updated package.json from node: ${modded}`)
4636
- let error
4637
- let errored = false
4638
- let installed = false
4639
4614
 
4640
4615
  // eslint-disable-next-line no-await-in-loop
4641
4616
  if (!(await editablePkgJson.save())) {
4642
4617
  debug.debugLog(
4643
- `Skipping nothing changed in ${editablePkgJson.filename}`
4618
+ `No changes saved for ${pkgJsonPath}, skipping install`
4644
4619
  )
4645
4620
  continue
4646
4621
  }
4647
- if (!installedSpecs.has(newSpecKey)) {
4648
- installedSpecs.add(newSpecKey)
4649
- spinner?.info(`Installing ${newSpec}${workspaceDetails}`)
4650
- }
4622
+ spinner?.info(`Installing ${newSpec} in ${workspaceName}`)
4623
+ let errored = false
4624
+ let error
4651
4625
  try {
4652
4626
  // eslint-disable-next-line no-await-in-loop
4653
4627
  actualTree = await install(pkgEnvDetails, {
4654
4628
  spinner
4655
4629
  })
4656
- installed = true
4657
4630
  if (test) {
4658
- if (!testedSpecs.has(newSpecKey)) {
4659
- testedSpecs.add(newSpecKey)
4660
- spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
4661
- }
4631
+ spinner?.info(`Testing ${newSpec} in ${workspaceName}`)
4662
4632
  // eslint-disable-next-line no-await-in-loop
4663
4633
  await npm.runScript(testScript, [], {
4664
4634
  spinner,
4665
4635
  stdio: 'ignore'
4666
4636
  })
4667
4637
  }
4668
- if (!fixedSpecs.has(newSpecKey)) {
4669
- fixedSpecs.add(newSpecKey)
4670
- spinner?.successAndStop(`Fixed ${name}${workspaceDetails}`)
4671
- spinner?.start()
4672
- }
4673
- } catch (e) {
4674
- error = e
4675
- errored = true
4676
- }
4677
- if (
4678
- !errored &&
4679
- shouldOpenPr &&
4680
- // eslint-disable-next-line no-await-in-loop
4681
- (await gitCreateAndPushBranchIfNeeded(
4682
- branch,
4683
- getSocketCommitMessage(oldPurl, newVersion, workspaceName),
4684
- cwd
4685
- ))
4686
- ) {
4687
- // eslint-disable-next-line no-await-in-loop
4688
- const prResponse = await openGitHubPullRequest(
4689
- owner,
4690
- repo,
4691
- baseBranch,
4692
- branch,
4638
+ fixedSpecs.add(newSpecKey)
4639
+ spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`)
4640
+ spinner?.start()
4641
+ const branch = getSocketBranchName(
4693
4642
  oldPurl,
4694
4643
  newVersion,
4695
- {
4696
- cwd,
4697
- workspaceName
4698
- }
4644
+ workspaceName
4699
4645
  )
4700
- if (prResponse) {
4701
- const { data } = prResponse
4702
- spinner?.info(`PR #${data.number} opened.`)
4703
- if (autoMerge) {
4704
- // eslint-disable-next-line no-await-in-loop
4705
- await enableAutoMerge(data)
4646
+ const shouldOpenPr = isCi
4647
+ ? // eslint-disable-next-line no-await-in-loop
4648
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4649
+ : false
4650
+ if (
4651
+ isCi &&
4652
+ shouldOpenPr &&
4653
+ // eslint-disable-next-line no-await-in-loop
4654
+ (await gitCreateAndPushBranchIfNeeded(
4655
+ branch,
4656
+ getSocketCommitMessage(oldPurl, newVersion, workspaceName),
4657
+ cwd
4658
+ ))
4659
+ ) {
4660
+ // eslint-disable-next-line no-await-in-loop
4661
+ const prResponse = await openGitHubPullRequest(
4662
+ owner,
4663
+ repo,
4664
+ baseBranch,
4665
+ branch,
4666
+ oldPurl,
4667
+ newVersion,
4668
+ {
4669
+ cwd,
4670
+ workspaceName
4671
+ }
4672
+ )
4673
+ if (prResponse) {
4674
+ const { data } = prResponse
4675
+ spinner?.info(`PR #${data.number} opened.`)
4676
+ if (autoMerge) {
4677
+ // eslint-disable-next-line no-await-in-loop
4678
+ await enableAutoMerge(data)
4679
+ }
4706
4680
  }
4707
4681
  }
4682
+ } catch (e) {
4683
+ error = e
4684
+ errored = true
4708
4685
  }
4709
4686
  if (errored || isCi) {
4710
- if (errored) {
4711
- if (!revertedSpecs.has(newSpecKey)) {
4712
- revertedSpecs.add(newSpecKey)
4713
- spinner?.error(`Reverting ${newSpec}${workspaceDetails}`, error)
4714
- }
4715
- }
4716
4687
  editablePkgJson.update(revertData)
4688
+
4717
4689
  // eslint-disable-next-line no-await-in-loop
4718
4690
  await Promise.all([
4719
4691
  shadowNpmInject.removeNodeModules(cwd),
4720
4692
  ...(isCi
4721
4693
  ? [gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)]
4722
4694
  : []),
4723
- ...(installed && !isCi ? [editablePkgJson.save()] : [])
4695
+ ...(isCi ? [] : [editablePkgJson.save()])
4724
4696
  ])
4697
+
4725
4698
  // eslint-disable-next-line no-await-in-loop
4726
4699
  actualTree = await install(pkgEnvDetails, {
4727
4700
  spinner
4728
4701
  })
4729
4702
  if (errored) {
4730
- if (!failedSpecs.has(newSpecKey)) {
4731
- failedSpecs.add(newSpecKey)
4732
- spinner?.failAndStop(
4733
- `Update failed for ${oldSpec}${workspaceDetails}`
4734
- )
4735
- }
4703
+ spinner?.failAndStop(
4704
+ `Update failed for ${oldSpec} in ${workspaceName}`,
4705
+ error
4706
+ )
4736
4707
  }
4737
4708
  }
4738
4709
  }
@@ -12307,7 +12278,7 @@ void (async () => {
12307
12278
  await vendor.updater({
12308
12279
  name: SOCKET_CLI_BIN_NAME,
12309
12280
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
12310
- version: '0.14.124',
12281
+ version: '0.14.125',
12311
12282
  ttl: 86_400_000 /* 24 hours in milliseconds */
12312
12283
  })
12313
12284
  try {
@@ -12375,5 +12346,5 @@ void (async () => {
12375
12346
  await shadowNpmInject.captureException(e)
12376
12347
  }
12377
12348
  })()
12378
- //# debugId=bf160d06-cec8-4139-929e-f01e353b895b
12349
+ //# debugId=8c8790a2-a162-431b-99ab-b980237160d8
12379
12350
  //# sourceMappingURL=cli.js.map