@socketsecurity/cli-with-sentry 0.14.95 → 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.
@@ -41,7 +41,7 @@ const relConstantsPath = './constants'
41
41
  Sentry.setTag(
42
42
  'version',
43
43
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
44
- '0.14.95:3360fca:82287460:pub'
44
+ '0.14.97:f7d4687:6a21dfff:pub'
45
45
  )
46
46
  const constants = require(relConstantsPath)
47
47
  if (constants.ENV.SOCKET_CLI_DEBUG) {
@@ -56,5 +56,5 @@ const relConstantsPath = './constants'
56
56
  } = constants
57
57
  setSentry(Sentry)
58
58
  }
59
- //# debugId=b34a5eaf-bc7e-44dc-99f9-614b9ed86a2
59
+ //# debugId=69b16c6f-575a-4ad6-ad24-7674c1cfa148
60
60
  //# sourceMappingURL=instrument-with-sentry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrument-with-sentry.js","sources":["../../src/instrument-with-sentry.ts"],"sourcesContent":["// This should ONLY be included in the special Sentry build!\n// Otherwise the Sentry dependency won't even be present in the manifest.\n\nimport { logger } from '@socketsecurity/registry/lib/logger'\n\n// Require constants with require(relConstantsPath) instead of require('./constants')\n// so Rollup doesn't generate a constants2.js chunk.\nconst relConstantsPath = './constants'\n// The '@rollup/plugin-replace' will replace \"process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']\".\nif (process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']) {\n const Sentry = require('@sentry/node')\n Sentry.init({\n onFatalError(error: Error) {\n // Defer module loads until after Sentry.init is called.\n if (require(relConstantsPath).ENV.SOCKET_CLI_DEBUG) {\n logger.fail('[DEBUG] [Sentry onFatalError]:', error)\n }\n },\n dsn: 'https://66736701db8e4ffac046bd09fa6aaced@o555220.ingest.us.sentry.io/4508846967619585',\n enabled: true,\n integrations: []\n })\n Sentry.setTag(\n 'environment',\n // The '@rollup/plugin-replace' will replace \"process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD']\".\n process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD']\n ? 'pub'\n : // The NODE_ENV convention is used by apps to define the runtime environment.\n // https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production\n process.env['NODE_ENV']\n )\n Sentry.setTag(\n 'version',\n // The '@rollup/plugin-replace' will replace \"process.env['INLINED_SOCKET_CLI_VERSION_HASH']\".\n process.env['INLINED_SOCKET_CLI_VERSION_HASH']\n )\n const constants = require(relConstantsPath)\n if (constants.ENV.SOCKET_CLI_DEBUG) {\n Sentry.setTag('debugging', true)\n logger.log('[DEBUG] Set up Sentry.')\n } else {\n Sentry.setTag('debugging', false)\n }\n const {\n kInternalsSymbol,\n [kInternalsSymbol as unknown as 'Symbol(kInternalsSymbol)']: { setSentry }\n } = constants\n setSentry(Sentry)\n} else if (require(relConstantsPath).ENV.SOCKET_CLI_DEBUG) {\n logger.log('[DEBUG] Sentry disabled explicitly.')\n}\n"],"names":["logger","dsn","enabled","integrations","process","Sentry","setSentry"],"mappings":";;;;;;;;;;;;;AAAA;AACA;;;AAIA;AACA;AACA;AACA;AACoD;AAClD;;;AAGI;;AAEEA;AACF;;AAEFC;AACAC;AACAC;AACF;;AAGE;AACAC;;AAQA;AACAA;AAEF;AACA;AACEC;AACAL;AACF;AACEK;AACF;;;AAGE;AAA+DC;AAAU;AAC3E;;AAEF","debugId":"b34a5eaf-bc7e-44dc-99f9-614b9ed86a2"}
1
+ {"version":3,"file":"instrument-with-sentry.js","sources":["../../src/instrument-with-sentry.ts"],"sourcesContent":["// This should ONLY be included in the special Sentry build!\n// Otherwise the Sentry dependency won't even be present in the manifest.\n\nimport { logger } from '@socketsecurity/registry/lib/logger'\n\n// Require constants with require(relConstantsPath) instead of require('./constants')\n// so Rollup doesn't generate a constants2.js chunk.\nconst relConstantsPath = './constants'\n// The '@rollup/plugin-replace' will replace \"process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']\".\nif (process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']) {\n const Sentry = require('@sentry/node')\n Sentry.init({\n onFatalError(error: Error) {\n // Defer module loads until after Sentry.init is called.\n if (require(relConstantsPath).ENV.SOCKET_CLI_DEBUG) {\n logger.fail('[DEBUG] [Sentry onFatalError]:', error)\n }\n },\n dsn: 'https://66736701db8e4ffac046bd09fa6aaced@o555220.ingest.us.sentry.io/4508846967619585',\n enabled: true,\n integrations: []\n })\n Sentry.setTag(\n 'environment',\n // The '@rollup/plugin-replace' will replace \"process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD']\".\n process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD']\n ? 'pub'\n : // The NODE_ENV convention is used by apps to define the runtime environment.\n // https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production\n process.env['NODE_ENV']\n )\n Sentry.setTag(\n 'version',\n // The '@rollup/plugin-replace' will replace \"process.env['INLINED_SOCKET_CLI_VERSION_HASH']\".\n process.env['INLINED_SOCKET_CLI_VERSION_HASH']\n )\n const constants = require(relConstantsPath)\n if (constants.ENV.SOCKET_CLI_DEBUG) {\n Sentry.setTag('debugging', true)\n logger.log('[DEBUG] Set up Sentry.')\n } else {\n Sentry.setTag('debugging', false)\n }\n const {\n kInternalsSymbol,\n [kInternalsSymbol as unknown as 'Symbol(kInternalsSymbol)']: { setSentry }\n } = constants\n setSentry(Sentry)\n} else if (require(relConstantsPath).ENV.SOCKET_CLI_DEBUG) {\n logger.log('[DEBUG] Sentry disabled explicitly.')\n}\n"],"names":["logger","dsn","enabled","integrations","process","Sentry","setSentry"],"mappings":";;;;;;;;;;;;;AAAA;AACA;;;AAIA;AACA;AACA;AACA;AACoD;AAClD;;;AAGI;;AAEEA;AACF;;AAEFC;AACAC;AACAC;AACF;;AAGE;AACAC;;AAQA;AACAA;AAEF;AACA;AACEC;AACAL;AACF;AACEK;AACF;;;AAGE;AAA+DC;AAAU;AAC3E;;AAEF","debugId":"69b16c6f-575a-4ad6-ad24-7674c1cfa148"}
@@ -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.95:3360fca:82287460:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
902
+ const cliVersion = '0.14.97:f7d4687:6a21dfff: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 (
@@ -3808,7 +3845,6 @@ async function openGitHubPullRequest(
3808
3845
  if (!pat) {
3809
3846
  throw new Error('Missing SOCKET_SECURITY_GITHUB_PAT environment variable')
3810
3847
  }
3811
- const commitMsg = `chore: upgrade ${name} to ${version}`
3812
3848
  const url = `https://x-access-token:${pat}@github.com/${owner}/${repo}`
3813
3849
  await spawn.spawn('git', ['remote', 'set-url', 'origin', url], {
3814
3850
  cwd
@@ -3817,8 +3853,8 @@ async function openGitHubPullRequest(
3817
3853
  return await octokit.pulls.create({
3818
3854
  owner,
3819
3855
  repo,
3820
- title: commitMsg,
3821
- head: `${owner}:${branch}`,
3856
+ title: `chore: upgrade ${name} to ${version}`,
3857
+ head: branch,
3822
3858
  base: baseBranch,
3823
3859
  body: `[socket] Upgrade \`${name}\` to ${version}`
3824
3860
  })
@@ -3917,6 +3953,21 @@ async function npmFix(
3917
3953
  return
3918
3954
  }
3919
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
+ }
3920
3971
  const fixSpec = `${name}@^${targetVersion}`
3921
3972
  const revertData = {
3922
3973
  ...(editablePkgJson.content.dependencies
@@ -3937,9 +3988,7 @@ async function npmFix(
3937
3988
  : undefined)
3938
3989
  }
3939
3990
  spinner?.info(`Installing ${fixSpec}`)
3940
- const { owner, repo } = getGitHubRepoInfo()
3941
3991
  const baseBranch = getBaseBranch()
3942
- const branch = getSocketBranchName(name, targetVersion)
3943
3992
 
3944
3993
  // eslint-disable-next-line no-await-in-loop
3945
3994
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
@@ -3988,12 +4037,7 @@ async function npmFix(
3988
4037
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
3989
4038
  return
3990
4039
  }
3991
- if (
3992
- // Lazily access constants.ENV[CI].
3993
- constants.ENV[CI$1] &&
3994
- // eslint-disable-next-line no-await-in-loop
3995
- !(await doesPullRequestExistForBranch(owner, repo, branch))
3996
- ) {
4040
+ if (shouldOpenPr) {
3997
4041
  let prResponse
3998
4042
  try {
3999
4043
  // eslint-disable-next-line no-await-in-loop
@@ -4324,6 +4368,21 @@ async function pnpmFix(
4324
4368
  spinner?.failAndStop(`Could not patch ${oldSpec}`)
4325
4369
  return
4326
4370
  }
4371
+ let branch
4372
+ let owner
4373
+ let repo
4374
+ let shouldOpenPr = false
4375
+ // Lazily access constants.ENV[CI].
4376
+ if (constants.ENV[CI]) {
4377
+ ;({ owner, repo } = getGitHubRepoInfo())
4378
+ branch = getSocketBranchName(name, targetVersion)
4379
+ // eslint-disable-next-line no-await-in-loop
4380
+ shouldOpenPr = !(await doesPullRequestExistForBranch(
4381
+ owner,
4382
+ repo,
4383
+ branch
4384
+ ))
4385
+ }
4327
4386
  const oldPnpm = editablePkgJson.content[PNPM$9]
4328
4387
  const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4329
4388
  const oldOverrides = oldPnpm?.[OVERRIDES$2]
@@ -4377,9 +4436,7 @@ async function pnpmFix(
4377
4436
  : undefined)
4378
4437
  }
4379
4438
  spinner?.info(`Installing ${fixSpec}`)
4380
- const { owner, repo } = getGitHubRepoInfo()
4381
4439
  const baseBranch = getBaseBranch()
4382
- const branch = getSocketBranchName(name, targetVersion)
4383
4440
 
4384
4441
  // eslint-disable-next-line no-await-in-loop
4385
4442
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
@@ -4429,12 +4486,13 @@ async function pnpmFix(
4429
4486
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4430
4487
  return
4431
4488
  }
4432
- if (
4433
- // Lazily access constants.ENV[CI].
4434
- constants.ENV[CI] &&
4489
+ if (shouldOpenPr) {
4435
4490
  // eslint-disable-next-line no-await-in-loop
4436
- !(await doesPullRequestExistForBranch(owner, repo, branch))
4437
- ) {
4491
+ await createAndPushBranchIfNeeded(
4492
+ branch,
4493
+ `fix: upgrade ${name} to ${targetVersion}`,
4494
+ cwd
4495
+ )
4438
4496
  let prResponse
4439
4497
  try {
4440
4498
  // eslint-disable-next-line no-await-in-loop
@@ -11381,7 +11439,7 @@ void (async () => {
11381
11439
  await vendor.updater({
11382
11440
  name: SOCKET_CLI_BIN_NAME,
11383
11441
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11384
- version: '0.14.95',
11442
+ version: '0.14.97',
11385
11443
  ttl: 86_400_000 /* 24 hours in milliseconds */
11386
11444
  })
11387
11445
  try {
@@ -11449,5 +11507,5 @@ void (async () => {
11449
11507
  await shadowNpmInject.captureException(e)
11450
11508
  }
11451
11509
  })()
11452
- //# debugId=c34fd255-4999-4681-9636-3dc45d80a01d
11510
+ //# debugId=bba1f45e-da3b-4698-9168-d6e8c394995d
11453
11511
  //# sourceMappingURL=cli.js.map