@socketsecurity/cli-with-sentry 0.14.78 → 0.14.80

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.78:559893b:39cd3a2a:pub'
44
+ '0.14.80:4ef7be7:e324b7e4: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=841d3af6-f33a-4fa0-8575-d1f7f900ed7a
59
+ //# debugId=13c1f3c0-9588-4aab-bec2-c189e03b21f9
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":"841d3af6-f33a-4fa0-8575-d1f7f900ed7a"}
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":"13c1f3c0-9588-4aab-bec2-c189e03b21f9"}
@@ -38,6 +38,7 @@ const prompts = require('@socketsecurity/registry/lib/prompts')
38
38
  const shadowNpmPaths = require('./shadow-npm-paths.js')
39
39
  const chalkTable = _socketInterop(require('chalk-table'))
40
40
  const util = require('node:util')
41
+ const terminalLink = _socketInterop(require('terminal-link'))
41
42
  const arrays = require('@socketsecurity/registry/lib/arrays')
42
43
  const registry = require('@socketsecurity/registry')
43
44
  const npm = require('@socketsecurity/registry/lib/npm')
@@ -55,7 +56,6 @@ const index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs')
55
56
  const sorts = require('@socketsecurity/registry/lib/sorts')
56
57
  const registryConstants = require('@socketsecurity/registry/lib/constants')
57
58
  const isInteractive = require('@socketregistry/is-interactive/index.cjs')
58
- const terminalLink = _socketInterop(require('terminal-link'))
59
59
  const npa = _socketInterop(require('npm-package-arg'))
60
60
  const tinyglobby = _socketInterop(require('tinyglobby'))
61
61
  const promises = require('@socketsecurity/registry/lib/promises')
@@ -915,7 +915,7 @@ function emitBanner(name) {
915
915
  logger.logger.error(getAsciiHeader(name))
916
916
  }
917
917
  function getAsciiHeader(command) {
918
- const cliVersion = '0.14.78:559893b:39cd3a2a:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
918
+ const cliVersion = '0.14.80:4ef7be7:e324b7e4:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
919
919
  const nodeVersion = process$1.version
920
920
  const apiToken = shadowNpmInject.getDefaultToken()
921
921
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -3778,6 +3778,35 @@ function getOctokit() {
3778
3778
  }
3779
3779
  return _octokit
3780
3780
  }
3781
+ async function enableAutoMerge(prResponseData) {
3782
+ const octokit = getOctokit()
3783
+ const { node_id: prId, number: prNumber } = prResponseData
3784
+ try {
3785
+ await octokit.graphql(
3786
+ `
3787
+ mutation EnableAutoMerge($pullRequestId: ID!) {
3788
+ enablePullRequestAutoMerge(input: {
3789
+ pullRequestId: $pullRequestId,
3790
+ mergeMethod: SQUASH
3791
+ }) {
3792
+ pullRequest {
3793
+ number
3794
+ autoMergeRequest {
3795
+ enabledAt
3796
+ }
3797
+ }
3798
+ }
3799
+ }
3800
+ `,
3801
+ {
3802
+ pullRequestId: prId
3803
+ }
3804
+ )
3805
+ logger.logger.info(`Auto-merge enabled for PR #${prNumber}`)
3806
+ } catch (e) {
3807
+ logger.logger.error(`Failed to enable auto-merge for PR #${prNumber}:`, e)
3808
+ }
3809
+ }
3781
3810
  async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
3782
3811
  // Lazily access constants.ENV[GITHUB_ACTIONS].
3783
3812
  if (constants.ENV[GITHUB_ACTIONS]) {
@@ -3819,7 +3848,7 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
3819
3848
  })
3820
3849
  }
3821
3850
  const octokit = getOctokit()
3822
- await octokit.pulls.create({
3851
+ return await octokit.pulls.create({
3823
3852
  owner,
3824
3853
  repo,
3825
3854
  title: commitMsg,
@@ -3846,16 +3875,10 @@ async function install$1(idealTree, options) {
3846
3875
  arb2.idealTree = idealTree
3847
3876
  await arb2.reify()
3848
3877
  }
3849
- async function npmFix(_pkgEnvDetails, options) {
3850
- const {
3851
- cwd = process.cwd(),
3852
- spinner,
3853
- test = false,
3854
- testScript = 'test'
3855
- } = {
3856
- __proto__: null,
3857
- ...options
3858
- }
3878
+ async function npmFix(
3879
+ _pkgEnvDetails,
3880
+ { autoMerge, cwd, rangeStyle, spinner, test, testScript }
3881
+ ) {
3859
3882
  spinner?.start()
3860
3883
  const arb = new shadowNpmInject.SafeArborist({
3861
3884
  path: cwd,
@@ -3951,7 +3974,8 @@ async function npmFix(_pkgEnvDetails, options) {
3951
3974
  shadowNpmInject.updatePackageJsonFromNode(
3952
3975
  editablePkgJson,
3953
3976
  arb.idealTree,
3954
- node
3977
+ node,
3978
+ rangeStyle
3955
3979
  )
3956
3980
  // eslint-disable-next-line no-await-in-loop
3957
3981
  await editablePkgJson.save()
@@ -3975,7 +3999,15 @@ async function npmFix(_pkgEnvDetails, options) {
3975
3999
  // Lazily access constants.ENV[CI].
3976
4000
  if (constants.ENV[CI$1]) {
3977
4001
  // eslint-disable-next-line no-await-in-loop
3978
- await openGitHubPullRequest(name, targetVersion, cwd)
4002
+ const prResponse = await openGitHubPullRequest(
4003
+ name,
4004
+ targetVersion,
4005
+ cwd
4006
+ )
4007
+ if (autoMerge) {
4008
+ // eslint-disable-next-line no-await-in-loop
4009
+ await enableAutoMerge(prResponse.data)
4010
+ }
3979
4011
  }
3980
4012
  } catch {
3981
4013
  spinner?.error(`Reverting ${fixSpec}`)
@@ -4210,16 +4242,10 @@ async function install(pkgEnvDetails, options) {
4210
4242
  stdio: 'ignore'
4211
4243
  })
4212
4244
  }
4213
- async function pnpmFix(pkgEnvDetails, options) {
4214
- const {
4215
- cwd = process.cwd(),
4216
- spinner,
4217
- test = false,
4218
- testScript = 'test'
4219
- } = {
4220
- __proto__: null,
4221
- ...options
4222
- }
4245
+ async function pnpmFix(
4246
+ pkgEnvDetails,
4247
+ { autoMerge, cwd, rangeStyle, spinner, test, testScript }
4248
+ ) {
4223
4249
  const lockfile = await lockfile_fs.readWantedLockfile(cwd, {
4224
4250
  ignoreIncompatible: false
4225
4251
  })
@@ -4276,7 +4302,7 @@ async function pnpmFix(pkgEnvDetails, options) {
4276
4302
  vulnerableVersionRange
4277
4303
  } of infos) {
4278
4304
  const node = shadowNpmInject.findPackageNode(
4279
- arb.idealTree,
4305
+ arb.actualTree,
4280
4306
  name,
4281
4307
  oldVersion
4282
4308
  )
@@ -4349,7 +4375,8 @@ async function pnpmFix(pkgEnvDetails, options) {
4349
4375
  shadowNpmInject.updatePackageJsonFromNode(
4350
4376
  editablePkgJson,
4351
4377
  arb.actualTree,
4352
- node
4378
+ node,
4379
+ rangeStyle
4353
4380
  )
4354
4381
  // eslint-disable-next-line no-await-in-loop
4355
4382
  await editablePkgJson.save()
@@ -4374,7 +4401,15 @@ async function pnpmFix(pkgEnvDetails, options) {
4374
4401
  // Lazily access constants.ENV[CI].
4375
4402
  if (constants.ENV[CI]) {
4376
4403
  // eslint-disable-next-line no-await-in-loop
4377
- await openGitHubPullRequest(name, targetVersion, cwd)
4404
+ const prResponse = await openGitHubPullRequest(
4405
+ name,
4406
+ targetVersion,
4407
+ cwd
4408
+ )
4409
+ if (autoMerge) {
4410
+ // eslint-disable-next-line no-await-in-loop
4411
+ await enableAutoMerge(prResponse.data)
4412
+ }
4378
4413
  }
4379
4414
  } catch {
4380
4415
  spinner?.error(`Reverting ${fixSpec}`)
@@ -4801,48 +4836,27 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
4801
4836
 
4802
4837
  const { NPM: NPM$a, PNPM: PNPM$7 } = constants
4803
4838
  const CMD_NAME$2 = 'socket fix'
4804
- async function runFix({
4805
- cwd = process.cwd(),
4806
- rangeStyle,
4807
- spinner,
4808
- test = false,
4809
- testScript = 'test'
4810
- }) {
4811
- const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
4839
+ async function runFix(options_) {
4840
+ const options = shadowNpmInject.assignDefaultFixOptions({
4841
+ __proto__: null,
4842
+ ...options_
4843
+ })
4844
+ const pkgEnvDetails = await detectAndValidatePackageEnvironment(options.cwd, {
4812
4845
  cmdName: CMD_NAME$2,
4813
4846
  logger: logger.logger
4814
4847
  })
4815
4848
  if (!pkgEnvDetails) {
4816
- spinner?.stop()
4817
4849
  return
4818
4850
  }
4819
4851
  logger.logger.info(`Fixing packages for ${pkgEnvDetails.agent}`)
4820
- switch (pkgEnvDetails.agent) {
4821
- case NPM$a: {
4822
- await npmFix(pkgEnvDetails, {
4823
- rangeStyle,
4824
- spinner,
4825
- test,
4826
- testScript
4827
- })
4828
- break
4829
- }
4830
- case PNPM$7: {
4831
- await pnpmFix(pkgEnvDetails, {
4832
- rangeStyle,
4833
- spinner,
4834
- test,
4835
- testScript
4836
- })
4837
- break
4838
- }
4852
+ const { agent } = pkgEnvDetails
4853
+ if (agent === NPM$a) {
4854
+ await npmFix(pkgEnvDetails, options)
4855
+ } else if (agent === PNPM$7) {
4856
+ await pnpmFix(pkgEnvDetails, options)
4839
4857
  }
4840
- spinner?.stop()
4841
- // spinner.successAndStop('Socket.dev fix successful')
4842
4858
  }
4843
4859
 
4844
- const RangeStyles = ['caret', 'gt', 'lt', 'pin', 'preserve', 'tilde']
4845
-
4846
4860
  const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
4847
4861
  const config$z = {
4848
4862
  commandName: 'fix',
@@ -4850,6 +4864,11 @@ const config$z = {
4850
4864
  hidden: true,
4851
4865
  flags: {
4852
4866
  ...commonFlags,
4867
+ autoMerge: {
4868
+ type: 'boolean',
4869
+ default: true,
4870
+ 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.`
4871
+ },
4853
4872
  rangeStyle: {
4854
4873
  type: 'string',
4855
4874
  default: 'preserve',
@@ -4867,7 +4886,7 @@ const config$z = {
4867
4886
  test: {
4868
4887
  type: 'boolean',
4869
4888
  default: true,
4870
- description: 'Very the fix by running unit tests'
4889
+ description: 'Verify the fix by running unit tests'
4871
4890
  },
4872
4891
  testScript: {
4873
4892
  type: 'string',
@@ -4896,8 +4915,8 @@ async function run$z(argv, importMeta, { parentName }) {
4896
4915
  parentName
4897
4916
  })
4898
4917
  const wasBadInput = handleBadInput({
4899
- test: RangeStyles.includes(cli.flags['rangeStyle']),
4900
- message: `Expecting range style of ${arrays.joinOr(RangeStyles)}`,
4918
+ test: shadowNpmInject.RangeStyles.includes(cli.flags['rangeStyle']),
4919
+ message: `Expecting range style of ${arrays.joinOr(shadowNpmInject.RangeStyles)}`,
4901
4920
  pass: 'ok',
4902
4921
  fail: 'missing'
4903
4922
  })
@@ -4912,6 +4931,7 @@ async function run$z(argv, importMeta, { parentName }) {
4912
4931
  // Lazily access constants.spinner.
4913
4932
  const { spinner } = constants
4914
4933
  await runFix({
4934
+ autoMerge: Boolean(cli.flags['autoMerge']),
4915
4935
  spinner,
4916
4936
  rangeStyle: cli.flags['rangeStyle'] ?? undefined,
4917
4937
  test: Boolean(cli.flags['test']),
@@ -11285,7 +11305,7 @@ void (async () => {
11285
11305
  await updateNotifier({
11286
11306
  name: SOCKET_CLI_BIN_NAME,
11287
11307
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11288
- version: '0.14.78',
11308
+ version: '0.14.80',
11289
11309
  ttl: 86_400_000 /* 24 hours in milliseconds */
11290
11310
  })
11291
11311
  try {
@@ -11353,5 +11373,5 @@ void (async () => {
11353
11373
  await shadowNpmInject.captureException(e)
11354
11374
  }
11355
11375
  })()
11356
- //# debugId=113140e8-e205-41ef-b024-e029f5376cbc
11376
+ //# debugId=6d52c4d0-3501-45eb-a093-4cafbc5990e3
11357
11377
  //# sourceMappingURL=cli.js.map