socket 0.14.100 → 0.14.102

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.
@@ -900,7 +900,7 @@ function emitBanner(name) {
900
900
  logger.logger.error(getAsciiHeader(name))
901
901
  }
902
902
  function getAsciiHeader(command) {
903
- const cliVersion = '0.14.100:7c35eec:135794c2:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
903
+ const cliVersion = '0.14.102:51e000d:e352a2ef:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
904
904
  const nodeVersion = process$1.version
905
905
  const apiToken = shadowNpmInject.getDefaultToken()
906
906
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -3724,6 +3724,9 @@ async function branchExists(branch, cwd = process.cwd()) {
3724
3724
  }
3725
3725
  async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3726
3726
  try {
3727
+ await spawn.spawn('git', ['fetch', '--depth=1', 'origin', baseBranch], {
3728
+ cwd
3729
+ })
3727
3730
  await spawn.spawn('git', ['checkout', baseBranch], {
3728
3731
  cwd
3729
3732
  })
@@ -3731,10 +3734,11 @@ async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3731
3734
  cwd
3732
3735
  })
3733
3736
  logger.logger.info(`Checked out and reset to ${baseBranch}`)
3734
- } catch {
3737
+ } catch (e) {
3735
3738
  logger.logger.warn(
3736
3739
  `Could not switch to ${baseBranch}. Proceeding with HEAD.`
3737
3740
  )
3741
+ debug.debugLog(e)
3738
3742
  }
3739
3743
  }
3740
3744
  async function createAndPushBranchIfNeeded(
@@ -3965,6 +3969,8 @@ async function npmFix(
3965
3969
  const editablePkgJson = await packages.readPackageJson(cwd, {
3966
3970
  editable: true
3967
3971
  })
3972
+ // Lazily access constants.ENV[CI].
3973
+ const isCi = constants.ENV[CI$1]
3968
3974
  await arb.buildIdealTree()
3969
3975
  for (const { 0: name, 1: infos } of infoByPkg) {
3970
3976
  const hasUpgrade = !!registry.getManifestData(NPM$f, name)
@@ -4010,8 +4016,8 @@ async function npmFix(
4010
4016
  if (
4011
4017
  !shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
4012
4018
  ) {
4013
- spinner?.failAndStop(`Could not patch ${fromSpec}`)
4014
- return
4019
+ spinner?.fail(`Could not patch ${fromSpec}`)
4020
+ continue
4015
4021
  }
4016
4022
  const toVersion = node.package.version
4017
4023
  const toVersionRange = shadowNpmInject.applyRange(
@@ -4020,21 +4026,17 @@ async function npmFix(
4020
4026
  rangeStyle
4021
4027
  )
4022
4028
  const toSpec = `${name}@${toVersionRange}`
4023
- let branch
4024
- let owner
4025
- let repo
4026
- let shouldOpenPr = false
4027
- // Lazily access constants.ENV[CI].
4028
- if (constants.ENV[CI$1]) {
4029
- ;({ owner, repo } = getGitHubEnvRepoInfo())
4030
- branch = getSocketBranchName(fromPurl, toVersion)
4031
- // eslint-disable-next-line no-await-in-loop
4032
- shouldOpenPr = !(await doesPullRequestExistForBranch(
4033
- owner,
4034
- repo,
4035
- branch
4036
- ))
4037
- }
4029
+ const branch = isCi ? getSocketBranchName(fromPurl, toVersion) : ''
4030
+ const { owner, repo } = isCi
4031
+ ? getGitHubEnvRepoInfo()
4032
+ : {
4033
+ owner: '',
4034
+ repo: ''
4035
+ }
4036
+ const shouldOpenPr = isCi
4037
+ ? // eslint-disable-next-line no-await-in-loop
4038
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4039
+ : false
4038
4040
  const revertData = {
4039
4041
  ...(editablePkgJson.content.dependencies
4040
4042
  ? {
@@ -4058,6 +4060,8 @@ async function npmFix(
4058
4060
 
4059
4061
  // eslint-disable-next-line no-await-in-loop
4060
4062
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
4063
+ let error
4064
+ let errored = false
4061
4065
  let installed = false
4062
4066
  let saved = false
4063
4067
  try {
@@ -4087,23 +4091,11 @@ async function npmFix(
4087
4091
  }
4088
4092
  spinner?.successAndStop(`Fixed ${name}`)
4089
4093
  spinner?.start()
4090
- } catch {
4091
- spinner?.error(`Reverting ${toSpec}`)
4092
- if (saved) {
4093
- editablePkgJson.update(revertData)
4094
- // eslint-disable-next-line no-await-in-loop
4095
- await editablePkgJson.save()
4096
- }
4097
- if (installed) {
4098
- // eslint-disable-next-line no-await-in-loop
4099
- await install$1(revertTree, {
4100
- cwd
4101
- })
4102
- }
4103
- spinner?.failAndStop(`Failed to fix ${fromSpec}`)
4104
- return
4094
+ } catch (e) {
4095
+ error = e
4096
+ errored = true
4105
4097
  }
4106
- if (shouldOpenPr) {
4098
+ if (!errored && shouldOpenPr) {
4107
4099
  // eslint-disable-next-line no-await-in-loop
4108
4100
  await createAndPushBranchIfNeeded(
4109
4101
  branch,
@@ -4125,6 +4117,25 @@ async function npmFix(
4125
4117
  await enableAutoMerge(prResponse.data)
4126
4118
  }
4127
4119
  }
4120
+ if (errored || isCi) {
4121
+ if (errored) {
4122
+ spinner?.error(`Reverting ${toSpec}`, error)
4123
+ }
4124
+ if (saved) {
4125
+ editablePkgJson.update(revertData)
4126
+ // eslint-disable-next-line no-await-in-loop
4127
+ await editablePkgJson.save()
4128
+ }
4129
+ if (installed) {
4130
+ // eslint-disable-next-line no-await-in-loop
4131
+ await install$1(revertTree, {
4132
+ cwd
4133
+ })
4134
+ }
4135
+ if (errored) {
4136
+ spinner?.failAndStop(`Failed to fix ${fromSpec}`)
4137
+ }
4138
+ }
4128
4139
  }
4129
4140
  }
4130
4141
  }
@@ -4375,6 +4386,8 @@ async function pnpmFix(
4375
4386
  const editablePkgJson = await packages.readPackageJson(cwd, {
4376
4387
  editable: true
4377
4388
  })
4389
+ // Lazily access constants.ENV[CI].
4390
+ const isCi = constants.ENV[CI]
4378
4391
  let actualTree = await getActualTree(cwd)
4379
4392
  for (const { 0: name, 1: infos } of infoByPkg) {
4380
4393
  if (registry.getManifestData(NPM$c, name)) {
@@ -4422,8 +4435,8 @@ async function pnpmFix(
4422
4435
  ? packument.versions[toVersion]
4423
4436
  : undefined
4424
4437
  if (!(toVersion && targetPackument)) {
4425
- spinner?.failAndStop(`Could not patch ${fromSpec}`)
4426
- return
4438
+ spinner?.fail(`Could not patch ${fromSpec}`)
4439
+ continue
4427
4440
  }
4428
4441
  const oldPnpm = editablePkgJson.content[PNPM$9]
4429
4442
  const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
@@ -4438,21 +4451,17 @@ async function pnpmFix(
4438
4451
  rangeStyle
4439
4452
  )
4440
4453
  const toSpec = `${name}@${toVersionRange}`
4441
- let branch
4442
- let owner
4443
- let repo
4444
- let shouldOpenPr = false
4445
- // Lazily access constants.ENV[CI].
4446
- if (constants.ENV[CI]) {
4447
- ;({ owner, repo } = getGitHubEnvRepoInfo())
4448
- branch = getSocketBranchName(fromPurl, toVersion)
4449
- // eslint-disable-next-line no-await-in-loop
4450
- shouldOpenPr = !(await doesPullRequestExistForBranch(
4451
- owner,
4452
- repo,
4453
- branch
4454
- ))
4455
- }
4454
+ const branch = isCi ? getSocketBranchName(fromPurl, toVersion) : ''
4455
+ const { owner, repo } = isCi
4456
+ ? getGitHubEnvRepoInfo()
4457
+ : {
4458
+ owner: '',
4459
+ repo: ''
4460
+ }
4461
+ const shouldOpenPr = isCi
4462
+ ? // eslint-disable-next-line no-await-in-loop
4463
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4464
+ : false
4456
4465
  const updateData = {
4457
4466
  [PNPM$9]: {
4458
4467
  ...oldPnpm,
@@ -4497,6 +4506,8 @@ async function pnpmFix(
4497
4506
 
4498
4507
  // eslint-disable-next-line no-await-in-loop
4499
4508
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
4509
+ let error
4510
+ let errored = false
4500
4511
  let installed = false
4501
4512
  let saved = false
4502
4513
  try {
@@ -4528,22 +4539,10 @@ async function pnpmFix(
4528
4539
  spinner?.successAndStop(`Fixed ${name}`)
4529
4540
  spinner?.start()
4530
4541
  } catch (e) {
4531
- spinner?.error(`Reverting ${toSpec}`, e)
4532
- if (saved) {
4533
- editablePkgJson.update(revertData)
4534
- // eslint-disable-next-line no-await-in-loop
4535
- await editablePkgJson.save()
4536
- }
4537
- if (installed) {
4538
- // eslint-disable-next-line no-await-in-loop
4539
- actualTree = await install(pkgEnvDetails, {
4540
- spinner
4541
- })
4542
- }
4543
- spinner?.failAndStop(`Failed to fix ${fromSpec}`)
4544
- return
4542
+ error = e
4543
+ errored = true
4545
4544
  }
4546
- if (shouldOpenPr) {
4545
+ if (!errored && shouldOpenPr) {
4547
4546
  // eslint-disable-next-line no-await-in-loop
4548
4547
  await createAndPushBranchIfNeeded(
4549
4548
  branch,
@@ -4565,6 +4564,25 @@ async function pnpmFix(
4565
4564
  await enableAutoMerge(prResponse.data)
4566
4565
  }
4567
4566
  }
4567
+ if (errored || isCi) {
4568
+ if (errored) {
4569
+ spinner?.error(`Reverting ${toSpec}`, error)
4570
+ }
4571
+ if (saved) {
4572
+ editablePkgJson.update(revertData)
4573
+ // eslint-disable-next-line no-await-in-loop
4574
+ await editablePkgJson.save()
4575
+ }
4576
+ if (installed) {
4577
+ // eslint-disable-next-line no-await-in-loop
4578
+ actualTree = await install(pkgEnvDetails, {
4579
+ spinner
4580
+ })
4581
+ }
4582
+ if (errored) {
4583
+ spinner?.failAndStop(`Failed to fix ${fromSpec}`)
4584
+ }
4585
+ }
4568
4586
  }
4569
4587
  }
4570
4588
  }
@@ -11484,7 +11502,7 @@ void (async () => {
11484
11502
  await vendor.updater({
11485
11503
  name: SOCKET_CLI_BIN_NAME,
11486
11504
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11487
- version: '0.14.100',
11505
+ version: '0.14.102',
11488
11506
  ttl: 86_400_000 /* 24 hours in milliseconds */
11489
11507
  })
11490
11508
  try {
@@ -11552,5 +11570,5 @@ void (async () => {
11552
11570
  await shadowNpmInject.captureException(e)
11553
11571
  }
11554
11572
  })()
11555
- //# debugId=3dc0bb50-dadf-4426-8d9c-aec587ba7726
11573
+ //# debugId=53c889d4-b512-4df3-9241-7d2b2c18c461
11556
11574
  //# sourceMappingURL=cli.js.map