@socketsecurity/cli 0.14.91 → 0.14.93

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.
@@ -43,8 +43,8 @@ const arrays = require('@socketsecurity/registry/lib/arrays')
43
43
  const registry = require('@socketsecurity/registry')
44
44
  const npm = require('@socketsecurity/registry/lib/npm')
45
45
  const packages = require('@socketsecurity/registry/lib/packages')
46
- const rest = _socketInterop(require('@octokit/rest'))
47
46
  const spawn = require('@socketsecurity/registry/lib/spawn')
47
+ const rest = _socketInterop(require('@octokit/rest'))
48
48
  const lockfile_fs = _socketInterop(require('@pnpm/lockfile.fs'))
49
49
  const lockfile_detectDepTypes = _socketInterop(
50
50
  require('@pnpm/lockfile.detect-dep-types')
@@ -420,7 +420,10 @@ ${mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
420
420
  }
421
421
  function displayAnalyticsScreen(data) {
422
422
  const ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'))
423
- const screen = new ScreenWidget({})
423
+ // Lazily access constants.blessedOptions.
424
+ const screen = new ScreenWidget({
425
+ ...constants.blessedOptions
426
+ })
424
427
  const contrib = _socketInterop(require('blessed-contrib'))
425
428
  const grid = new contrib.grid({
426
429
  rows: 5,
@@ -915,7 +918,7 @@ function emitBanner(name) {
915
918
  logger.logger.error(getAsciiHeader(name))
916
919
  }
917
920
  function getAsciiHeader(command) {
918
- const cliVersion = '0.14.91:5903afd:6fabd1c5:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
921
+ const cliVersion = '0.14.93:8908783:f86f0c84:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
919
922
  const nodeVersion = process$1.version
920
923
  const apiToken = shadowNpmInject.getDefaultToken()
921
924
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -3712,62 +3715,37 @@ const cmdDiffScan = {
3712
3715
  }
3713
3716
  }
3714
3717
 
3715
- const {
3716
- GITHUB_ACTIONS,
3717
- GITHUB_REF_NAME,
3718
- GITHUB_REPOSITORY,
3719
- SOCKET_SECURITY_GITHUB_PAT
3720
- } = constants
3721
- async function branchExists(branch, cwd = process.cwd()) {
3722
- try {
3723
- await spawn.spawn(
3724
- 'git',
3725
- ['show-ref', '--verify', '--quiet', `refs/heads/${branch}`],
3726
- {
3727
- cwd,
3728
- stdio: 'ignore'
3729
- }
3730
- )
3731
- return true
3732
- } catch {}
3733
- return false
3734
- }
3718
+ const { GITHUB_REF_NAME } = constants
3735
3719
  async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3736
3720
  try {
3737
- const currentBranch = (
3738
- await spawn.spawn('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
3739
- cwd
3740
- })
3741
- ).stdout.trim()
3742
- if (currentBranch === baseBranch) {
3743
- logger.logger.info(`Already on ${baseBranch}`)
3744
- return
3745
- }
3746
- logger.logger.info(
3747
- `Switching branch from ${currentBranch} to ${baseBranch}...`
3748
- )
3749
3721
  await spawn.spawn('git', ['checkout', baseBranch], {
3750
3722
  cwd
3751
3723
  })
3752
- logger.logger.info(`Checked out ${baseBranch}`)
3724
+ await spawn.spawn('git', ['reset', '--hard', `origin/${baseBranch}`], {
3725
+ cwd
3726
+ })
3727
+ logger.logger.info(`Checked out and reset to ${baseBranch}`)
3753
3728
  } catch {
3754
3729
  logger.logger.warn(
3755
3730
  `Could not switch to ${baseBranch}. Proceeding with HEAD.`
3756
3731
  )
3757
3732
  }
3758
3733
  }
3759
- function getGitHubRepoInfo() {
3760
- // Lazily access constants.ENV[GITHUB_REPOSITORY].
3761
- const ownerSlashRepo = constants.ENV[GITHUB_REPOSITORY]
3762
- const slashIndex = ownerSlashRepo.indexOf('/')
3763
- if (slashIndex === -1) {
3764
- throw new Error('GITHUB_REPOSITORY environment variable not set')
3765
- }
3766
- return {
3767
- owner: ownerSlashRepo.slice(0, slashIndex),
3768
- repo: ownerSlashRepo.slice(slashIndex + 1)
3769
- }
3734
+ function getBaseBranch() {
3735
+ // Lazily access constants.ENV[GITHUB_REF_NAME].
3736
+ return (
3737
+ constants.ENV[GITHUB_REF_NAME] ??
3738
+ // GitHub defaults to branch name "main"
3739
+ // https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch
3740
+ 'main'
3741
+ )
3742
+ }
3743
+ function getSocketBranchName(name, version) {
3744
+ return `socket-fix-${name}-${version.replace(/\./g, '-')}`
3770
3745
  }
3746
+
3747
+ const { GITHUB_ACTIONS, GITHUB_REPOSITORY, SOCKET_SECURITY_GITHUB_PAT } =
3748
+ constants
3771
3749
  let _octokit
3772
3750
  function getOctokit() {
3773
3751
  if (_octokit === undefined) {
@@ -3778,6 +3756,16 @@ function getOctokit() {
3778
3756
  }
3779
3757
  return _octokit
3780
3758
  }
3759
+ async function doesPullRequestExistForBranch(owner, repo, branch) {
3760
+ const octokit = getOctokit()
3761
+ const { data: prs } = await octokit.pulls.list({
3762
+ owner,
3763
+ repo,
3764
+ head: `${owner}:${branch}`,
3765
+ state: 'open'
3766
+ })
3767
+ return prs.length > 0
3768
+ }
3781
3769
  async function enableAutoMerge(prResponseData) {
3782
3770
  const octokit = getOctokit()
3783
3771
  const { node_id: prId, number: prNumber } = prResponseData
@@ -3807,7 +3795,27 @@ async function enableAutoMerge(prResponseData) {
3807
3795
  logger.logger.error(`Failed to enable auto-merge for PR #${prNumber}:`, e)
3808
3796
  }
3809
3797
  }
3810
- async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
3798
+ function getGitHubRepoInfo() {
3799
+ // Lazily access constants.ENV[GITHUB_REPOSITORY].
3800
+ const ownerSlashRepo = constants.ENV[GITHUB_REPOSITORY]
3801
+ const slashIndex = ownerSlashRepo.indexOf('/')
3802
+ if (slashIndex === -1) {
3803
+ throw new Error('GITHUB_REPOSITORY environment variable not set')
3804
+ }
3805
+ return {
3806
+ owner: ownerSlashRepo.slice(0, slashIndex),
3807
+ repo: ownerSlashRepo.slice(slashIndex + 1)
3808
+ }
3809
+ }
3810
+ async function openGitHubPullRequest(
3811
+ owner,
3812
+ repo,
3813
+ baseBranch,
3814
+ branch,
3815
+ name,
3816
+ version,
3817
+ cwd = process.cwd()
3818
+ ) {
3811
3819
  // Lazily access constants.ENV[GITHUB_ACTIONS].
3812
3820
  if (constants.ENV[GITHUB_ACTIONS]) {
3813
3821
  // Lazily access constants.ENV[SOCKET_SECURITY_GITHUB_PAT].
@@ -3815,38 +3823,11 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
3815
3823
  if (!pat) {
3816
3824
  throw new Error('Missing SOCKET_SECURITY_GITHUB_PAT environment variable')
3817
3825
  }
3818
- const baseBranch =
3819
- // Lazily access constants.ENV[GITHUB_REF_NAME].
3820
- constants.ENV[GITHUB_REF_NAME] ??
3821
- // GitHub defaults to branch name "main"
3822
- // https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch
3823
- 'main'
3824
- const branch = `socket-fix-${name}-${targetVersion.replace(/\./g, '-')}`
3825
- const commitMsg = `chore: upgrade ${name} to ${targetVersion}`
3826
- const { owner, repo } = getGitHubRepoInfo()
3826
+ const commitMsg = `chore: upgrade ${name} to ${version}`
3827
3827
  const url = `https://x-access-token:${pat}@github.com/${owner}/${repo}`
3828
3828
  await spawn.spawn('git', ['remote', 'set-url', 'origin', url], {
3829
3829
  cwd
3830
3830
  })
3831
- if (await branchExists(branch, cwd)) {
3832
- logger.logger.warn(
3833
- `Branch "${branch}" already exists. Skipping creation.`
3834
- )
3835
- } else {
3836
- await checkoutBaseBranchIfAvailable(baseBranch, cwd)
3837
- await spawn.spawn('git', ['checkout', '-b', branch], {
3838
- cwd
3839
- })
3840
- await spawn.spawn('git', ['add', 'package.json', 'pnpm-lock.yaml'], {
3841
- cwd
3842
- })
3843
- await spawn.spawn('git', ['commit', '-m', commitMsg], {
3844
- cwd
3845
- })
3846
- await spawn.spawn('git', ['push', '--set-upstream', 'origin', branch], {
3847
- cwd
3848
- })
3849
- }
3850
3831
  const octokit = getOctokit()
3851
3832
  return await octokit.pulls.create({
3852
3833
  owner,
@@ -3854,7 +3835,7 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
3854
3835
  title: commitMsg,
3855
3836
  head: branch,
3856
3837
  base: baseBranch,
3857
- body: `[socket] Upgrade \`${name}\` to ${targetVersion}`
3838
+ body: `[socket] Upgrade \`${name}\` to ${version}`
3858
3839
  })
3859
3840
  } else {
3860
3841
  throw new Error(
@@ -3944,92 +3925,102 @@ async function npmFix(
3944
3925
  continue
3945
3926
  }
3946
3927
  const oldSpec = `${name}@${oldVersion}`
3947
- let targetVersion
3948
- let failed = false
3949
- let installed = false
3950
- let saved = false
3951
3928
  if (
3952
- shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
3929
+ !shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
3953
3930
  ) {
3954
- targetVersion = node.package.version
3955
- const fixSpec = `${name}@^${targetVersion}`
3956
- const revertData = {
3957
- ...(editablePkgJson.content.dependencies
3958
- ? {
3959
- dependencies: editablePkgJson.content.dependencies
3960
- }
3961
- : undefined),
3962
- ...(editablePkgJson.content.optionalDependencies
3963
- ? {
3964
- optionalDependencies:
3965
- editablePkgJson.content.optionalDependencies
3966
- }
3967
- : undefined),
3968
- ...(editablePkgJson.content.peerDependencies
3969
- ? {
3970
- peerDependencies: editablePkgJson.content.peerDependencies
3971
- }
3972
- : undefined)
3931
+ spinner?.failAndStop(`Could not patch ${oldSpec}`)
3932
+ return
3933
+ }
3934
+ const targetVersion = node.package.version
3935
+ const fixSpec = `${name}@^${targetVersion}`
3936
+ const revertData = {
3937
+ ...(editablePkgJson.content.dependencies
3938
+ ? {
3939
+ dependencies: editablePkgJson.content.dependencies
3940
+ }
3941
+ : undefined),
3942
+ ...(editablePkgJson.content.optionalDependencies
3943
+ ? {
3944
+ optionalDependencies:
3945
+ editablePkgJson.content.optionalDependencies
3946
+ }
3947
+ : undefined),
3948
+ ...(editablePkgJson.content.peerDependencies
3949
+ ? {
3950
+ peerDependencies: editablePkgJson.content.peerDependencies
3951
+ }
3952
+ : undefined)
3953
+ }
3954
+ spinner?.info(`Installing ${fixSpec}`)
3955
+ const { owner, repo } = getGitHubRepoInfo()
3956
+ const baseBranch = getBaseBranch()
3957
+ const branch = getSocketBranchName(name, targetVersion)
3958
+
3959
+ // eslint-disable-next-line no-await-in-loop
3960
+ await checkoutBaseBranchIfAvailable(baseBranch, cwd)
3961
+ let installed = false
3962
+ let saved = false
3963
+ try {
3964
+ shadowNpmInject.updatePackageJsonFromNode(
3965
+ editablePkgJson,
3966
+ arb.idealTree,
3967
+ node,
3968
+ targetVersion,
3969
+ rangeStyle
3970
+ )
3971
+ // eslint-disable-next-line no-await-in-loop
3972
+ await editablePkgJson.save()
3973
+ saved = true
3974
+
3975
+ // eslint-disable-next-line no-await-in-loop
3976
+ await install$1(arb.idealTree, {
3977
+ cwd
3978
+ })
3979
+ installed = true
3980
+ if (test) {
3981
+ spinner?.info(`Testing ${fixSpec}`)
3982
+ // eslint-disable-next-line no-await-in-loop
3983
+ await npm.runScript(testScript, [], {
3984
+ spinner,
3985
+ stdio: 'ignore'
3986
+ })
3973
3987
  }
3974
- spinner?.info(`Installing ${fixSpec}`)
3975
- try {
3976
- shadowNpmInject.updatePackageJsonFromNode(
3977
- editablePkgJson,
3978
- arb.idealTree,
3979
- node,
3980
- targetVersion,
3981
- rangeStyle
3982
- )
3988
+ spinner?.successAndStop(`Fixed ${name}`)
3989
+ spinner?.start()
3990
+ } catch {
3991
+ spinner?.error(`Reverting ${fixSpec}`)
3992
+ if (saved) {
3993
+ editablePkgJson.update(revertData)
3983
3994
  // eslint-disable-next-line no-await-in-loop
3984
3995
  await editablePkgJson.save()
3985
- saved = true
3986
-
3996
+ }
3997
+ if (installed) {
3987
3998
  // eslint-disable-next-line no-await-in-loop
3988
- await install$1(arb.idealTree, {
3999
+ await install$1(revertTree, {
3989
4000
  cwd
3990
4001
  })
3991
- installed = true
3992
- if (test) {
3993
- spinner?.info(`Testing ${fixSpec}`)
3994
- // eslint-disable-next-line no-await-in-loop
3995
- await npm.runScript(testScript, [], {
3996
- spinner,
3997
- stdio: 'ignore'
3998
- })
3999
- }
4000
- spinner?.successAndStop(`Fixed ${name}`)
4001
- spinner?.start()
4002
- } catch {
4003
- failed = true
4004
- spinner?.error(`Reverting ${fixSpec}`)
4005
- if (saved) {
4006
- editablePkgJson.update(revertData)
4007
- // eslint-disable-next-line no-await-in-loop
4008
- await editablePkgJson.save()
4009
- }
4010
- if (installed) {
4011
- // eslint-disable-next-line no-await-in-loop
4012
- await install$1(revertTree, {
4013
- cwd
4014
- })
4015
- }
4016
- spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4017
4002
  }
4018
- } else {
4019
- failed = true
4020
- spinner?.failAndStop(`Could not patch ${oldSpec}`)
4003
+ spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4004
+ return
4021
4005
  }
4022
4006
  if (
4023
- !failed &&
4024
- // Check targetVersion to make TypeScript happy.
4025
- targetVersion &&
4026
4007
  // Lazily access constants.ENV[CI].
4027
- constants.ENV[CI$1]
4008
+ constants.ENV[CI$1] &&
4009
+ // eslint-disable-next-line no-await-in-loop
4010
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4028
4011
  ) {
4029
4012
  let prResponse
4030
4013
  try {
4031
4014
  // eslint-disable-next-line no-await-in-loop
4032
- prResponse = await openGitHubPullRequest(name, targetVersion, cwd)
4015
+ prResponse = await openGitHubPullRequest(
4016
+ owner,
4017
+ repo,
4018
+ baseBranch,
4019
+ branch,
4020
+ name,
4021
+ targetVersion,
4022
+ cwd
4023
+ )
4033
4024
  } catch (e) {
4034
4025
  logger.logger.error('Failed to open pull request', e)
4035
4026
  }
@@ -4340,122 +4331,133 @@ async function pnpmFix(
4340
4331
  const targetPackument = targetVersion
4341
4332
  ? packument.versions[targetVersion]
4342
4333
  : undefined
4343
- let failed = false
4334
+ if (!(targetVersion && targetPackument)) {
4335
+ spinner?.failAndStop(`Could not patch ${oldSpec}`)
4336
+ return
4337
+ }
4338
+ const oldPnpm = editablePkgJson.content[PNPM$9]
4339
+ const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4340
+ const oldOverrides = oldPnpm?.[OVERRIDES$2]
4341
+ const oldOverridesCount = oldOverrides
4342
+ ? Object.keys(oldOverrides).length
4343
+ : 0
4344
+ const overrideKey = `${node.name}@${vulnerableVersionRange}`
4345
+ const overrideRange = shadowNpmInject.applyRange(
4346
+ oldOverrides?.[overrideKey] ?? targetVersion,
4347
+ targetVersion,
4348
+ rangeStyle
4349
+ )
4350
+ const fixSpec = `${name}@${overrideRange}`
4351
+ const updateData = {
4352
+ [PNPM$9]: {
4353
+ ...oldPnpm,
4354
+ [OVERRIDES$2]: {
4355
+ [overrideKey]: overrideRange,
4356
+ ...oldOverrides
4357
+ }
4358
+ }
4359
+ }
4360
+ const revertData = {
4361
+ [PNPM$9]: oldPnpmKeyCount
4362
+ ? {
4363
+ ...oldPnpm,
4364
+ [OVERRIDES$2]:
4365
+ oldOverridesCount === 1
4366
+ ? undefined
4367
+ : {
4368
+ [overrideKey]: undefined,
4369
+ ...oldOverrides
4370
+ }
4371
+ }
4372
+ : undefined,
4373
+ ...(editablePkgJson.content.dependencies
4374
+ ? {
4375
+ dependencies: editablePkgJson.content.dependencies
4376
+ }
4377
+ : undefined),
4378
+ ...(editablePkgJson.content.optionalDependencies
4379
+ ? {
4380
+ optionalDependencies:
4381
+ editablePkgJson.content.optionalDependencies
4382
+ }
4383
+ : undefined),
4384
+ ...(editablePkgJson.content.peerDependencies
4385
+ ? {
4386
+ peerDependencies: editablePkgJson.content.peerDependencies
4387
+ }
4388
+ : undefined)
4389
+ }
4390
+ spinner?.info(`Installing ${fixSpec}`)
4391
+ const { owner, repo } = getGitHubRepoInfo()
4392
+ const baseBranch = getBaseBranch()
4393
+ const branch = getSocketBranchName(name, targetVersion)
4394
+
4395
+ // eslint-disable-next-line no-await-in-loop
4396
+ await checkoutBaseBranchIfAvailable(baseBranch, cwd)
4344
4397
  let installed = false
4345
4398
  let saved = false
4346
- if (targetVersion && targetPackument) {
4347
- const oldPnpm = editablePkgJson.content[PNPM$9]
4348
- const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4349
- const oldOverrides = oldPnpm?.[OVERRIDES$2]
4350
- const oldOverridesCount = oldOverrides
4351
- ? Object.keys(oldOverrides).length
4352
- : 0
4353
- const overrideKey = `${node.name}@${vulnerableVersionRange}`
4354
- const overrideRange = shadowNpmInject.applyRange(
4355
- oldOverrides?.[overrideKey] ?? targetVersion,
4399
+ try {
4400
+ editablePkgJson.update(updateData)
4401
+ shadowNpmInject.updatePackageJsonFromNode(
4402
+ editablePkgJson,
4403
+ actualTree,
4404
+ node,
4356
4405
  targetVersion,
4357
4406
  rangeStyle
4358
4407
  )
4359
- const fixSpec = `${name}@${overrideRange}`
4360
- const updateData = {
4361
- [PNPM$9]: {
4362
- ...oldPnpm,
4363
- [OVERRIDES$2]: {
4364
- [overrideKey]: overrideRange,
4365
- ...oldOverrides
4366
- }
4367
- }
4368
- }
4369
- const revertData = {
4370
- [PNPM$9]: oldPnpmKeyCount
4371
- ? {
4372
- ...oldPnpm,
4373
- [OVERRIDES$2]:
4374
- oldOverridesCount === 1
4375
- ? undefined
4376
- : {
4377
- [overrideKey]: undefined,
4378
- ...oldOverrides
4379
- }
4380
- }
4381
- : undefined,
4382
- ...(editablePkgJson.content.dependencies
4383
- ? {
4384
- dependencies: editablePkgJson.content.dependencies
4385
- }
4386
- : undefined),
4387
- ...(editablePkgJson.content.optionalDependencies
4388
- ? {
4389
- optionalDependencies:
4390
- editablePkgJson.content.optionalDependencies
4391
- }
4392
- : undefined),
4393
- ...(editablePkgJson.content.peerDependencies
4394
- ? {
4395
- peerDependencies: editablePkgJson.content.peerDependencies
4396
- }
4397
- : undefined)
4408
+ // eslint-disable-next-line no-await-in-loop
4409
+ await editablePkgJson.save()
4410
+ saved = true
4411
+
4412
+ // eslint-disable-next-line no-await-in-loop
4413
+ actualTree = await install(pkgEnvDetails, {
4414
+ spinner
4415
+ })
4416
+ installed = true
4417
+ if (test) {
4418
+ spinner?.info(`Testing ${fixSpec}`)
4419
+ // eslint-disable-next-line no-await-in-loop
4420
+ await npm.runScript(testScript, [], {
4421
+ spinner,
4422
+ stdio: 'ignore'
4423
+ })
4398
4424
  }
4399
- spinner?.info(`Installing ${fixSpec}`)
4400
- try {
4401
- editablePkgJson.update(updateData)
4402
- shadowNpmInject.updatePackageJsonFromNode(
4403
- editablePkgJson,
4404
- actualTree,
4405
- node,
4406
- targetVersion,
4407
- rangeStyle
4408
- )
4425
+ spinner?.successAndStop(`Fixed ${name}`)
4426
+ spinner?.start()
4427
+ } catch (e) {
4428
+ spinner?.error(`Reverting ${fixSpec}`, e)
4429
+ if (saved) {
4430
+ editablePkgJson.update(revertData)
4409
4431
  // eslint-disable-next-line no-await-in-loop
4410
4432
  await editablePkgJson.save()
4411
- saved = true
4412
-
4433
+ }
4434
+ if (installed) {
4413
4435
  // eslint-disable-next-line no-await-in-loop
4414
4436
  actualTree = await install(pkgEnvDetails, {
4415
4437
  spinner
4416
4438
  })
4417
- installed = true
4418
- if (test) {
4419
- spinner?.info(`Testing ${fixSpec}`)
4420
- // eslint-disable-next-line no-await-in-loop
4421
- await npm.runScript(testScript, [], {
4422
- spinner,
4423
- stdio: 'ignore'
4424
- })
4425
- }
4426
- spinner?.successAndStop(`Fixed ${name}`)
4427
- spinner?.start()
4428
- } catch (e) {
4429
- failed = true
4430
- spinner?.error(`Reverting ${fixSpec}`, e)
4431
- if (saved) {
4432
- editablePkgJson.update(revertData)
4433
- // eslint-disable-next-line no-await-in-loop
4434
- await editablePkgJson.save()
4435
- }
4436
- if (installed) {
4437
- // eslint-disable-next-line no-await-in-loop
4438
- actualTree = await install(pkgEnvDetails, {
4439
- spinner
4440
- })
4441
- }
4442
- spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4443
4439
  }
4444
- } else {
4445
- failed = true
4446
- spinner?.failAndStop(`Could not patch ${oldSpec}`)
4440
+ spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4441
+ return
4447
4442
  }
4448
4443
  if (
4449
- !failed &&
4450
- // Check targetVersion to make TypeScript happy.
4451
- targetVersion &&
4452
4444
  // Lazily access constants.ENV[CI].
4453
- constants.ENV[CI]
4445
+ constants.ENV[CI] &&
4446
+ // eslint-disable-next-line no-await-in-loop
4447
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4454
4448
  ) {
4455
4449
  let prResponse
4456
4450
  try {
4457
4451
  // eslint-disable-next-line no-await-in-loop
4458
- prResponse = await openGitHubPullRequest(name, targetVersion, cwd)
4452
+ prResponse = await openGitHubPullRequest(
4453
+ owner,
4454
+ repo,
4455
+ baseBranch,
4456
+ branch,
4457
+ name,
4458
+ targetVersion,
4459
+ cwd
4460
+ )
4459
4461
  } catch (e) {
4460
4462
  logger.logger.error('Failed to open pull request', e)
4461
4463
  }
@@ -4903,9 +4905,14 @@ const config$z = {
4903
4905
  hidden: true,
4904
4906
  flags: {
4905
4907
  ...commonFlags,
4908
+ autoPilot: {
4909
+ type: 'boolean',
4910
+ default: false,
4911
+ description: `Shorthand for --autoMerge --test`
4912
+ },
4906
4913
  autoMerge: {
4907
4914
  type: 'boolean',
4908
- default: true,
4915
+ default: false,
4909
4916
  description: `Enable auto-merge for pull requests that Socket opens.\n See ${terminalLink('GitHub documentation', 'https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository')} for managing auto-merge for pull requests in your repository.`
4910
4917
  },
4911
4918
  rangeStyle: {
@@ -4924,7 +4931,7 @@ const config$z = {
4924
4931
  },
4925
4932
  test: {
4926
4933
  type: 'boolean',
4927
- default: true,
4934
+ default: false,
4928
4935
  description: 'Verify the fix by running unit tests'
4929
4936
  },
4930
4937
  testScript: {
@@ -4971,6 +4978,7 @@ async function run$z(argv, importMeta, { parentName }) {
4971
4978
  const { spinner } = constants
4972
4979
  await runFix({
4973
4980
  autoMerge: Boolean(cli.flags['autoMerge']),
4981
+ autoPilot: Boolean(cli.flags['autoPilot']),
4974
4982
  spinner,
4975
4983
  rangeStyle: cli.flags['rangeStyle'] ?? undefined,
4976
4984
  test: Boolean(cli.flags['test']),
@@ -10839,7 +10847,10 @@ async function outputThreatFeed(data, { outputKind }) {
10839
10847
 
10840
10848
  // Note: this temporarily takes over the terminal (just like `man` does).
10841
10849
  const ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'))
10842
- const screen = new ScreenWidget()
10850
+ // Lazily access constants.blessedOptions.
10851
+ const screen = new ScreenWidget({
10852
+ ...constants.blessedOptions
10853
+ })
10843
10854
  // Register these keys first so you can always exit, even when it gets stuck
10844
10855
  // If we don't do this and the code crashes, the user must hard-kill the
10845
10856
  // node process just to exit it. That's very bad UX.
@@ -11346,7 +11357,7 @@ void (async () => {
11346
11357
  await updateNotifier({
11347
11358
  name: SOCKET_CLI_BIN_NAME,
11348
11359
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11349
- version: '0.14.91',
11360
+ version: '0.14.93',
11350
11361
  ttl: 86_400_000 /* 24 hours in milliseconds */
11351
11362
  })
11352
11363
  try {
@@ -11414,5 +11425,5 @@ void (async () => {
11414
11425
  await shadowNpmInject.captureException(e)
11415
11426
  }
11416
11427
  })()
11417
- //# debugId=6903030d-c196-4469-8bb6-0792eb90d5ed
11428
+ //# debugId=bbc2f5f5-47c6-498d-b900-1f71dff85e8e
11418
11429
  //# sourceMappingURL=cli.js.map