socket 0.14.96 → 0.14.97

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.
@@ -899,7 +899,7 @@ function emitBanner(name) {
899
899
  logger.logger.error(getAsciiHeader(name))
900
900
  }
901
901
  function getAsciiHeader(command) {
902
- const cliVersion = '0.14.96:b940b80:4d1e4dd0:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
902
+ const cliVersion = '0.14.97:f7d4687:082655df:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
903
903
  const nodeVersion = process$1.version
904
904
  const apiToken = shadowNpmInject.getDefaultToken()
905
905
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -3701,6 +3701,20 @@ const cmdDiffScan = {
3701
3701
  }
3702
3702
 
3703
3703
  const { GITHUB_REF_NAME } = constants
3704
+ async function branchExists(branch, cwd = process.cwd()) {
3705
+ try {
3706
+ await spawn.spawn(
3707
+ 'git',
3708
+ ['show-ref', '--verify', '--quiet', `refs/heads/${branch}`],
3709
+ {
3710
+ cwd,
3711
+ stdio: 'ignore'
3712
+ }
3713
+ )
3714
+ return true
3715
+ } catch {}
3716
+ return false
3717
+ }
3704
3718
  async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3705
3719
  try {
3706
3720
  await spawn.spawn('git', ['checkout', baseBranch], {
@@ -3716,6 +3730,29 @@ async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3716
3730
  )
3717
3731
  }
3718
3732
  }
3733
+ async function createAndPushBranchIfNeeded(
3734
+ branch,
3735
+ commitMsg,
3736
+ cwd = process.cwd()
3737
+ ) {
3738
+ if (await branchExists(branch, cwd)) {
3739
+ logger.logger.warn(`Branch "${branch}" already exists. Skipping creation.`)
3740
+ return false
3741
+ }
3742
+ await spawn.spawn('git', ['checkout', '-b', branch], {
3743
+ cwd
3744
+ })
3745
+ await spawn.spawn('git', ['add', 'package.json', 'pnpm-lock.yaml'], {
3746
+ cwd
3747
+ })
3748
+ await spawn.spawn('git', ['commit', '-m', commitMsg], {
3749
+ cwd
3750
+ })
3751
+ await spawn.spawn('git', ['push', '--set-upstream', 'origin', branch], {
3752
+ cwd
3753
+ })
3754
+ return true
3755
+ }
3719
3756
  function getBaseBranch() {
3720
3757
  // Lazily access constants.ENV[GITHUB_REF_NAME].
3721
3758
  return (
@@ -3916,6 +3953,21 @@ async function npmFix(
3916
3953
  return
3917
3954
  }
3918
3955
  const targetVersion = node.package.version
3956
+ let branch
3957
+ let owner
3958
+ let repo
3959
+ let shouldOpenPr = false
3960
+ // Lazily access constants.ENV[CI].
3961
+ if (constants.ENV[CI$1]) {
3962
+ ;({ owner, repo } = getGitHubRepoInfo())
3963
+ branch = getSocketBranchName(name, targetVersion)
3964
+ // eslint-disable-next-line no-await-in-loop
3965
+ shouldOpenPr = !(await doesPullRequestExistForBranch(
3966
+ owner,
3967
+ repo,
3968
+ branch
3969
+ ))
3970
+ }
3919
3971
  const fixSpec = `${name}@^${targetVersion}`
3920
3972
  const revertData = {
3921
3973
  ...(editablePkgJson.content.dependencies
@@ -3936,9 +3988,7 @@ async function npmFix(
3936
3988
  : undefined)
3937
3989
  }
3938
3990
  spinner?.info(`Installing ${fixSpec}`)
3939
- const { owner, repo } = getGitHubRepoInfo()
3940
3991
  const baseBranch = getBaseBranch()
3941
- const branch = getSocketBranchName(name, targetVersion)
3942
3992
 
3943
3993
  // eslint-disable-next-line no-await-in-loop
3944
3994
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
@@ -3987,12 +4037,7 @@ async function npmFix(
3987
4037
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
3988
4038
  return
3989
4039
  }
3990
- if (
3991
- // Lazily access constants.ENV[CI].
3992
- constants.ENV[CI$1] &&
3993
- // eslint-disable-next-line no-await-in-loop
3994
- !(await doesPullRequestExistForBranch(owner, repo, branch))
3995
- ) {
4040
+ if (shouldOpenPr) {
3996
4041
  let prResponse
3997
4042
  try {
3998
4043
  // eslint-disable-next-line no-await-in-loop
@@ -4319,6 +4364,21 @@ async function pnpmFix(
4319
4364
  spinner?.failAndStop(`Could not patch ${oldSpec}`)
4320
4365
  return
4321
4366
  }
4367
+ let branch
4368
+ let owner
4369
+ let repo
4370
+ let shouldOpenPr = false
4371
+ // Lazily access constants.ENV[CI].
4372
+ if (constants.ENV[CI]) {
4373
+ ;({ owner, repo } = getGitHubRepoInfo())
4374
+ branch = getSocketBranchName(name, targetVersion)
4375
+ // eslint-disable-next-line no-await-in-loop
4376
+ shouldOpenPr = !(await doesPullRequestExistForBranch(
4377
+ owner,
4378
+ repo,
4379
+ branch
4380
+ ))
4381
+ }
4322
4382
  const oldPnpm = editablePkgJson.content[PNPM$9]
4323
4383
  const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4324
4384
  const oldOverrides = oldPnpm?.[OVERRIDES$2]
@@ -4372,9 +4432,7 @@ async function pnpmFix(
4372
4432
  : undefined)
4373
4433
  }
4374
4434
  spinner?.info(`Installing ${fixSpec}`)
4375
- const { owner, repo } = getGitHubRepoInfo()
4376
4435
  const baseBranch = getBaseBranch()
4377
- const branch = getSocketBranchName(name, targetVersion)
4378
4436
 
4379
4437
  // eslint-disable-next-line no-await-in-loop
4380
4438
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
@@ -4424,12 +4482,13 @@ async function pnpmFix(
4424
4482
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4425
4483
  return
4426
4484
  }
4427
- if (
4428
- // Lazily access constants.ENV[CI].
4429
- constants.ENV[CI] &&
4485
+ if (shouldOpenPr) {
4430
4486
  // eslint-disable-next-line no-await-in-loop
4431
- !(await doesPullRequestExistForBranch(owner, repo, branch))
4432
- ) {
4487
+ await createAndPushBranchIfNeeded(
4488
+ branch,
4489
+ `fix: upgrade ${name} to ${targetVersion}`,
4490
+ cwd
4491
+ )
4433
4492
  let prResponse
4434
4493
  try {
4435
4494
  // eslint-disable-next-line no-await-in-loop
@@ -11376,7 +11435,7 @@ void (async () => {
11376
11435
  await vendor.updater({
11377
11436
  name: SOCKET_CLI_BIN_NAME,
11378
11437
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11379
- version: '0.14.96',
11438
+ version: '0.14.97',
11380
11439
  ttl: 86_400_000 /* 24 hours in milliseconds */
11381
11440
  })
11382
11441
  try {
@@ -11444,5 +11503,5 @@ void (async () => {
11444
11503
  await shadowNpmInject.captureException(e)
11445
11504
  }
11446
11505
  })()
11447
- //# debugId=c17c1611-cf3e-4a35-ac26-b683d683981a
11506
+ //# debugId=53d9bce0-9bbb-40a0-bcce-f9bb6e02c76
11448
11507
  //# sourceMappingURL=cli.js.map