@socketsecurity/cli-with-sentry 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.
@@ -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.96:b940b80:d716bd90: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=105b1fb6-7f2c-4673-a2d5-408259e9f2dc
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":"105b1fb6-7f2c-4673-a2d5-408259e9f2dc"}
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.96:b940b80:d716bd90: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 (
@@ -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
@@ -4323,6 +4368,21 @@ async function pnpmFix(
4323
4368
  spinner?.failAndStop(`Could not patch ${oldSpec}`)
4324
4369
  return
4325
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
+ }
4326
4386
  const oldPnpm = editablePkgJson.content[PNPM$9]
4327
4387
  const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4328
4388
  const oldOverrides = oldPnpm?.[OVERRIDES$2]
@@ -4376,9 +4436,7 @@ async function pnpmFix(
4376
4436
  : undefined)
4377
4437
  }
4378
4438
  spinner?.info(`Installing ${fixSpec}`)
4379
- const { owner, repo } = getGitHubRepoInfo()
4380
4439
  const baseBranch = getBaseBranch()
4381
- const branch = getSocketBranchName(name, targetVersion)
4382
4440
 
4383
4441
  // eslint-disable-next-line no-await-in-loop
4384
4442
  await checkoutBaseBranchIfAvailable(baseBranch, cwd)
@@ -4428,12 +4486,13 @@ async function pnpmFix(
4428
4486
  spinner?.failAndStop(`Failed to fix ${oldSpec}`)
4429
4487
  return
4430
4488
  }
4431
- if (
4432
- // Lazily access constants.ENV[CI].
4433
- constants.ENV[CI] &&
4489
+ if (shouldOpenPr) {
4434
4490
  // eslint-disable-next-line no-await-in-loop
4435
- !(await doesPullRequestExistForBranch(owner, repo, branch))
4436
- ) {
4491
+ await createAndPushBranchIfNeeded(
4492
+ branch,
4493
+ `fix: upgrade ${name} to ${targetVersion}`,
4494
+ cwd
4495
+ )
4437
4496
  let prResponse
4438
4497
  try {
4439
4498
  // eslint-disable-next-line no-await-in-loop
@@ -11380,7 +11439,7 @@ void (async () => {
11380
11439
  await vendor.updater({
11381
11440
  name: SOCKET_CLI_BIN_NAME,
11382
11441
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11383
- version: '0.14.96',
11442
+ version: '0.14.97',
11384
11443
  ttl: 86_400_000 /* 24 hours in milliseconds */
11385
11444
  })
11386
11445
  try {
@@ -11448,5 +11507,5 @@ void (async () => {
11448
11507
  await shadowNpmInject.captureException(e)
11449
11508
  }
11450
11509
  })()
11451
- //# debugId=f7c27252-6de0-4577-9a6d-4ca8ce4c19fe
11510
+ //# debugId=bba1f45e-da3b-4698-9168-d6e8c394995d
11452
11511
  //# sourceMappingURL=cli.js.map