@socketsecurity/cli-with-sentry 0.14.85 → 0.14.86

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.
@@ -912,7 +912,7 @@ function emitBanner(name) {
912
912
  logger.logger.error(getAsciiHeader(name))
913
913
  }
914
914
  function getAsciiHeader(command) {
915
- const cliVersion = '0.14.85:f285d45:d2e4291f:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
915
+ const cliVersion = '0.14.86:69093e9:7f5177c3:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
916
916
  const nodeVersion = process$1.version
917
917
  const apiToken = shadowNpmInject.getDefaultToken()
918
918
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -3942,10 +3942,14 @@ async function npmFix(
3942
3942
  continue
3943
3943
  }
3944
3944
  const oldSpec = `${name}@${oldVersion}`
3945
+ let targetVersion
3946
+ let failed = false
3947
+ let installed = false
3948
+ let saved = false
3945
3949
  if (
3946
3950
  shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
3947
3951
  ) {
3948
- const targetVersion = node.package.version
3952
+ targetVersion = node.package.version
3949
3953
  const fixSpec = `${name}@^${targetVersion}`
3950
3954
  const revertData = {
3951
3955
  ...(pkgJson.dependencies
@@ -3965,8 +3969,6 @@ async function npmFix(
3965
3969
  : undefined)
3966
3970
  }
3967
3971
  spinner?.info(`Installing ${fixSpec}`)
3968
- let saved = false
3969
- let installed = false
3970
3972
  try {
3971
3973
  shadowNpmInject.updatePackageJsonFromNode(
3972
3974
  editablePkgJson,
@@ -3993,20 +3995,8 @@ async function npmFix(
3993
3995
  }
3994
3996
  spinner?.successAndStop(`Fixed ${name}`)
3995
3997
  spinner?.start()
3996
- // Lazily access constants.ENV[CI].
3997
- if (constants.ENV[CI$1]) {
3998
- // eslint-disable-next-line no-await-in-loop
3999
- const prResponse = await openGitHubPullRequest(
4000
- name,
4001
- targetVersion,
4002
- cwd
4003
- )
4004
- if (autoMerge) {
4005
- // eslint-disable-next-line no-await-in-loop
4006
- await enableAutoMerge(prResponse.data)
4007
- }
4008
- }
4009
3998
  } catch {
3999
+ failed = true
4010
4000
  spinner?.error(`Reverting ${fixSpec}`)
4011
4001
  if (saved) {
4012
4002
  editablePkgJson.update(revertData)
@@ -4022,8 +4012,35 @@ async function npmFix(
4022
4012
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4023
4013
  }
4024
4014
  } else {
4015
+ failed = true
4025
4016
  spinner?.failAndStop(`Could not patch ${oldSpec}`)
4026
4017
  }
4018
+ if (
4019
+ !failed &&
4020
+ // Check targetVersion to make TypeScript happy.
4021
+ targetVersion &&
4022
+ // Lazily access constants.ENV[CI].
4023
+ constants.ENV[CI$1]
4024
+ ) {
4025
+ let prResponse
4026
+ try {
4027
+ // eslint-disable-next-line no-await-in-loop
4028
+ prResponse = await openGitHubPullRequest(name, targetVersion, cwd)
4029
+ } catch (e) {
4030
+ logger.logger.error('Failed to open pull request', e)
4031
+ }
4032
+ if (prResponse && autoMerge) {
4033
+ try {
4034
+ // eslint-disable-next-line no-await-in-loop
4035
+ await enableAutoMerge(prResponse.data)
4036
+ } catch (e) {
4037
+ logger.logger.error(
4038
+ 'Failed to enable auto-merge in pull request',
4039
+ e
4040
+ )
4041
+ }
4042
+ }
4043
+ }
4027
4044
  }
4028
4045
  }
4029
4046
  }
@@ -4211,7 +4228,7 @@ function runAgentInstall(pkgEnvDetails, options) {
4211
4228
  ...options
4212
4229
  }
4213
4230
  const skipNodeHardenFlags =
4214
- pkgEnvDetails.agent === PNPM$a && pkgEnvDetails.agentVersion.major < 11
4231
+ agent === PNPM$a && pkgEnvDetails.agentVersion.major < 11
4215
4232
  return spawn.spawn(agentExecPath, ['install', ...args], {
4216
4233
  spinner,
4217
4234
  stdio: 'inherit',
@@ -4232,8 +4249,15 @@ function runAgentInstall(pkgEnvDetails, options) {
4232
4249
  }
4233
4250
 
4234
4251
  const { CI, NPM: NPM$c, OVERRIDES: OVERRIDES$2, PNPM: PNPM$9 } = constants
4235
- async function install(pkgEnvDetails, arb, options) {
4236
- const { spinner } = {
4252
+ async function getActualTree(cwd = process.cwd()) {
4253
+ const arb = new shadowNpmInject.SafeArborist({
4254
+ path: cwd,
4255
+ ...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
4256
+ })
4257
+ return await arb.loadActual()
4258
+ }
4259
+ async function install(pkgEnvDetails, options) {
4260
+ const { cwd, spinner } = {
4237
4261
  __proto__: null,
4238
4262
  ...options
4239
4263
  }
@@ -4242,8 +4266,7 @@ async function install(pkgEnvDetails, arb, options) {
4242
4266
  spinner,
4243
4267
  stdio: debug.isDebug() ? 'inherit' : 'ignore'
4244
4268
  })
4245
- arb.actualTree = null
4246
- await arb.loadActual()
4269
+ return await getActualTree(cwd)
4247
4270
  }
4248
4271
  async function pnpmFix(
4249
4272
  pkgEnvDetails,
@@ -4273,11 +4296,7 @@ async function pnpmFix(
4273
4296
  editable: true
4274
4297
  })
4275
4298
  const { content: pkgJson } = editablePkgJson
4276
- const arb = new shadowNpmInject.SafeArborist({
4277
- path: cwd,
4278
- ...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
4279
- })
4280
- await arb.loadActual()
4299
+ let actualTree = await getActualTree(cwd)
4281
4300
  for (const { 0: name, 1: infos } of infoByPkg) {
4282
4301
  if (registry.getManifestData(NPM$c, name)) {
4283
4302
  spinner?.info(`Skipping ${name}. Socket Optimize package exists.`)
@@ -4285,7 +4304,7 @@ async function pnpmFix(
4285
4304
  }
4286
4305
  const specs = arrays.arrayUnique(
4287
4306
  shadowNpmInject
4288
- .findPackageNodes(arb.actualTree, name)
4307
+ .findPackageNodes(actualTree, name)
4289
4308
  .map(n => `${n.name}@${n.version}`)
4290
4309
  )
4291
4310
  const packument =
@@ -4305,7 +4324,7 @@ async function pnpmFix(
4305
4324
  vulnerableVersionRange
4306
4325
  } of infos) {
4307
4326
  const node = shadowNpmInject.findPackageNode(
4308
- arb.actualTree,
4327
+ actualTree,
4309
4328
  name,
4310
4329
  oldVersion
4311
4330
  )
@@ -4322,6 +4341,9 @@ async function pnpmFix(
4322
4341
  const targetPackument = targetVersion
4323
4342
  ? packument.versions[targetVersion]
4324
4343
  : undefined
4344
+ let failed = false
4345
+ let installed = false
4346
+ let saved = false
4325
4347
  if (targetVersion && targetPackument) {
4326
4348
  const oldPnpm = pkgJson[PNPM$9]
4327
4349
  const pnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
@@ -4371,13 +4393,11 @@ async function pnpmFix(
4371
4393
  : undefined)
4372
4394
  }
4373
4395
  spinner?.info(`Installing ${fixSpec}`)
4374
- let saved = false
4375
- let installed = false
4376
4396
  try {
4377
4397
  editablePkgJson.update(updateData)
4378
4398
  shadowNpmInject.updatePackageJsonFromNode(
4379
4399
  editablePkgJson,
4380
- arb.actualTree,
4400
+ actualTree,
4381
4401
  node,
4382
4402
  rangeStyle
4383
4403
  )
@@ -4386,7 +4406,7 @@ async function pnpmFix(
4386
4406
  saved = true
4387
4407
 
4388
4408
  // eslint-disable-next-line no-await-in-loop
4389
- await install(pkgEnvDetails, arb, {
4409
+ actualTree = await install(pkgEnvDetails, {
4390
4410
  spinner
4391
4411
  })
4392
4412
  installed = true
@@ -4400,21 +4420,8 @@ async function pnpmFix(
4400
4420
  }
4401
4421
  spinner?.successAndStop(`Fixed ${name}`)
4402
4422
  spinner?.start()
4403
-
4404
- // Lazily access constants.ENV[CI].
4405
- if (constants.ENV[CI]) {
4406
- // eslint-disable-next-line no-await-in-loop
4407
- const prResponse = await openGitHubPullRequest(
4408
- name,
4409
- targetVersion,
4410
- cwd
4411
- )
4412
- if (autoMerge) {
4413
- // eslint-disable-next-line no-await-in-loop
4414
- await enableAutoMerge(prResponse.data)
4415
- }
4416
- }
4417
4423
  } catch (e) {
4424
+ failed = true
4418
4425
  spinner?.error(`Reverting ${fixSpec}`, e)
4419
4426
  if (saved) {
4420
4427
  editablePkgJson.update(revertData)
@@ -4423,15 +4430,42 @@ async function pnpmFix(
4423
4430
  }
4424
4431
  if (installed) {
4425
4432
  // eslint-disable-next-line no-await-in-loop
4426
- await install(pkgEnvDetails, arb, {
4433
+ actualTree = await install(pkgEnvDetails, {
4427
4434
  spinner
4428
4435
  })
4429
4436
  }
4430
4437
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4431
4438
  }
4432
4439
  } else {
4440
+ failed = true
4433
4441
  spinner?.failAndStop(`Could not patch ${oldSpec}`)
4434
4442
  }
4443
+ if (
4444
+ !failed &&
4445
+ // Check targetVersion to make TypeScript happy.
4446
+ targetVersion &&
4447
+ // Lazily access constants.ENV[CI].
4448
+ constants.ENV[CI]
4449
+ ) {
4450
+ let prResponse
4451
+ try {
4452
+ // eslint-disable-next-line no-await-in-loop
4453
+ prResponse = await openGitHubPullRequest(name, targetVersion, cwd)
4454
+ } catch (e) {
4455
+ logger.logger.error('Failed to open pull request', e)
4456
+ }
4457
+ if (prResponse && autoMerge) {
4458
+ try {
4459
+ // eslint-disable-next-line no-await-in-loop
4460
+ await enableAutoMerge(prResponse.data)
4461
+ } catch (e) {
4462
+ logger.logger.error(
4463
+ 'Failed to enable auto-merge in pull request',
4464
+ e
4465
+ )
4466
+ }
4467
+ }
4468
+ }
4435
4469
  }
4436
4470
  }
4437
4471
  }
@@ -11307,7 +11341,7 @@ void (async () => {
11307
11341
  await vendor.updater({
11308
11342
  name: SOCKET_CLI_BIN_NAME,
11309
11343
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11310
- version: '0.14.85',
11344
+ version: '0.14.86',
11311
11345
  ttl: 86_400_000 /* 24 hours in milliseconds */
11312
11346
  })
11313
11347
  try {
@@ -11375,5 +11409,5 @@ void (async () => {
11375
11409
  await shadowNpmInject.captureException(e)
11376
11410
  }
11377
11411
  })()
11378
- //# debugId=4588b62f-01ad-45c5-b794-41f01c684e1f
11412
+ //# debugId=708624ad-8bb1-4c03-9aea-19bed2b49a26
11379
11413
  //# sourceMappingURL=cli.js.map