@socketsecurity/cli-with-sentry 0.14.123 → 0.14.124

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.123:ac83b62:6bf8f885:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
920
+ const cliVersion = '0.14.124:5b2103f:b9f122e3: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')
@@ -3739,7 +3739,7 @@ function getPkgNameFromPurlObj(purlObj) {
3739
3739
  function getBaseGitBranch() {
3740
3740
  // Lazily access constants.ENV[GITHUB_REF_NAME].
3741
3741
  return (
3742
- constants.ENV[GITHUB_REF_NAME] ??
3742
+ constants.ENV[GITHUB_REF_NAME] ||
3743
3743
  // GitHub defaults to branch name "main"
3744
3744
  // 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
3745
3745
  'main'
@@ -3858,16 +3858,6 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
3858
3858
  const rawFiles = stdout?.trim().split('\n') ?? []
3859
3859
  return rawFiles.map(relPath => path.normalizePath(relPath))
3860
3860
  }
3861
- async function isInGitRepo(cwd = process.cwd()) {
3862
- try {
3863
- await spawn.spawn('git', ['rev-parse', '--is-inside-work-tree'], {
3864
- cwd,
3865
- stdio: 'ignore'
3866
- })
3867
- return true
3868
- } catch {}
3869
- return false
3870
- }
3871
3861
 
3872
3862
  const { GITHUB_ACTIONS, GITHUB_REPOSITORY, SOCKET_SECURITY_GITHUB_PAT } =
3873
3863
  constants
@@ -4054,10 +4044,10 @@ async function npmFix(
4054
4044
 
4055
4045
  // Lazily access constants.ENV[CI].
4056
4046
  const isCi = constants.ENV[CI$1]
4057
- const { 0: isRepo, 1: workspacePkgJsonPaths } = await Promise.all([
4058
- isInGitRepo(cwd),
4059
- shadowNpmInject.globWorkspace(pkgEnvDetails.agent, rootPath)
4060
- ])
4047
+ const workspacePkgJsonPaths = await shadowNpmInject.globWorkspace(
4048
+ pkgEnvDetails.agent,
4049
+ rootPath
4050
+ )
4061
4051
  const pkgJsonPaths = [
4062
4052
  ...workspacePkgJsonPaths,
4063
4053
  // Process the workspace root last since it will add an override to package.json.
@@ -4075,7 +4065,7 @@ async function npmFix(
4075
4065
  const oldVersions = arrays.arrayUnique(
4076
4066
  shadowNpmInject
4077
4067
  .findPackageNodes(arb.idealTree, name)
4078
- .map(n => n.version)
4068
+ .map(n => n.target?.version ?? n.version)
4079
4069
  .filter(Boolean)
4080
4070
  )
4081
4071
  const packument =
@@ -4272,15 +4262,15 @@ async function npmFix(
4272
4262
  // eslint-disable-next-line no-await-in-loop
4273
4263
  await Promise.all([
4274
4264
  shadowNpmInject.removeNodeModules(cwd),
4275
- ...(isRepo ? [gitHardReset(cwd)] : []),
4276
- ...(saved && !isRepo ? [editablePkgJson.save()] : [])
4265
+ ...(isCi
4266
+ ? [gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)]
4267
+ : []),
4268
+ ...(saved && !isCi ? [editablePkgJson.save()] : [])
4277
4269
  ])
4278
- if (!isRepo && installed) {
4279
- // eslint-disable-next-line no-await-in-loop
4280
- await install$1(revertTree, {
4281
- cwd
4282
- })
4283
- }
4270
+ // eslint-disable-next-line no-await-in-loop
4271
+ await install$1(revertTree, {
4272
+ cwd
4273
+ })
4284
4274
  if (errored) {
4285
4275
  if (!failedSpecs.has(newSpecKey)) {
4286
4276
  failedSpecs.add(newSpecKey)
@@ -4480,37 +4470,34 @@ async function pnpmFix(
4480
4470
 
4481
4471
  // Lazily access constants.ENV[CI].
4482
4472
  const isCi = constants.ENV[CI]
4483
- const { 0: isRepo, 1: workspacePkgJsonPaths } = await Promise.all([
4484
- isInGitRepo(cwd),
4485
- shadowNpmInject.globWorkspace(pkgEnvDetails.agent, rootPath)
4486
- ])
4473
+ const workspacePkgJsonPaths = await shadowNpmInject.globWorkspace(
4474
+ pkgEnvDetails.agent,
4475
+ rootPath
4476
+ )
4477
+ const baseBranch = isCi ? getBaseGitBranch() : ''
4478
+ const { owner, repo } = isCi
4479
+ ? getGitHubEnvRepoInfo()
4480
+ : {
4481
+ owner: '',
4482
+ repo: ''
4483
+ }
4487
4484
  const pkgJsonPaths = [
4488
4485
  ...workspacePkgJsonPaths,
4489
4486
  // Process the workspace root last since it will add an override to package.json.
4490
4487
  pkgEnvDetails.editablePkgJson.filename
4491
4488
  ]
4492
- let actualTree
4489
+ let actualTree = await getActualTree(cwd)
4493
4490
  for (const { 0: name, 1: infos } of infoByPkg) {
4494
4491
  if (registry.getManifestData(NPM$c, name)) {
4495
4492
  spinner?.info(`Skipping ${name}. Socket Optimize package exists.`)
4496
4493
  continue
4497
4494
  }
4498
- // eslint-disable-next-line no-await-in-loop
4499
- await Promise.all([
4500
- shadowNpmInject.removeNodeModules(cwd),
4501
- ...(isRepo ? [gitHardReset(cwd)] : [])
4502
- ])
4503
- // eslint-disable-next-line no-await-in-loop
4504
- actualTree = await install(pkgEnvDetails, {
4505
- spinner
4506
- })
4507
4495
  const oldVersions = arrays.arrayUnique(
4508
4496
  shadowNpmInject
4509
4497
  .findPackageNodes(actualTree, name)
4510
- .map(n => n.version)
4498
+ .map(n => n.target?.version ?? n.version)
4511
4499
  .filter(Boolean)
4512
4500
  )
4513
- debug.debugLog(name, 'oldVersions', oldVersions)
4514
4501
  const packument =
4515
4502
  oldVersions.length && infos.length
4516
4503
  ? // eslint-disable-next-line no-await-in-loop
@@ -4533,15 +4520,6 @@ async function pnpmFix(
4533
4520
  firstPatchedVersionIdentifier,
4534
4521
  vulnerableVersionRange
4535
4522
  } of infos) {
4536
- // eslint-disable-next-line no-await-in-loop
4537
- await Promise.all([
4538
- shadowNpmInject.removeNodeModules(cwd),
4539
- ...(isRepo ? [gitHardReset(cwd)] : [])
4540
- ])
4541
- // eslint-disable-next-line no-await-in-loop
4542
- actualTree = await install(pkgEnvDetails, {
4543
- spinner
4544
- })
4545
4523
  const node = shadowNpmInject.findPackageNode(
4546
4524
  actualTree,
4547
4525
  name,
@@ -4644,21 +4622,10 @@ async function pnpmFix(
4644
4622
  const branch = isCi
4645
4623
  ? getSocketBranchName(oldPurl, newVersion, workspaceName)
4646
4624
  : ''
4647
- const baseBranch = isCi ? getBaseGitBranch() : ''
4648
- const { owner, repo } = isCi
4649
- ? getGitHubEnvRepoInfo()
4650
- : {
4651
- owner: '',
4652
- repo: ''
4653
- }
4654
4625
  const shouldOpenPr = isCi
4655
4626
  ? // eslint-disable-next-line no-await-in-loop
4656
4627
  !(await doesPullRequestExistForBranch(owner, repo, branch))
4657
4628
  : false
4658
- if (isCi) {
4659
- // eslint-disable-next-line no-await-in-loop
4660
- await gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
4661
- }
4662
4629
  if (updateData) {
4663
4630
  editablePkgJson.update(updateData)
4664
4631
  }
@@ -4754,11 +4721,10 @@ async function pnpmFix(
4754
4721
  // eslint-disable-next-line no-await-in-loop
4755
4722
  await Promise.all([
4756
4723
  shadowNpmInject.removeNodeModules(cwd),
4757
- ...(isRepo
4758
- ? [gitHardReset(cwd)]
4759
- : installed
4760
- ? [editablePkgJson.save()]
4761
- : [])
4724
+ ...(isCi
4725
+ ? [gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)]
4726
+ : []),
4727
+ ...(installed && !isCi ? [editablePkgJson.save()] : [])
4762
4728
  ])
4763
4729
  // eslint-disable-next-line no-await-in-loop
4764
4730
  actualTree = await install(pkgEnvDetails, {
@@ -12345,7 +12311,7 @@ void (async () => {
12345
12311
  await vendor.updater({
12346
12312
  name: SOCKET_CLI_BIN_NAME,
12347
12313
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
12348
- version: '0.14.123',
12314
+ version: '0.14.124',
12349
12315
  ttl: 86_400_000 /* 24 hours in milliseconds */
12350
12316
  })
12351
12317
  try {
@@ -12413,5 +12379,5 @@ void (async () => {
12413
12379
  await shadowNpmInject.captureException(e)
12414
12380
  }
12415
12381
  })()
12416
- //# debugId=645892ec-7104-4af0-915a-c1219b90c91c
12382
+ //# debugId=6c275bac-7bf4-4e55-8d6d-8b25adfc2eba
12417
12383
  //# sourceMappingURL=cli.js.map