@socketsecurity/cli-with-sentry 0.14.106 → 0.14.108

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.106:968fc98:d6f1d87a:pub'
44
+ '0.14.108:342eeb0:d9332f95: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=d1310559-3c56-4c67-b04a-f71c213ee79
59
+ //# debugId=443aef59-6954-4c72-864c-34892e5490ee
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":"d1310559-3c56-4c67-b04a-f71c213ee79"}
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":"443aef59-6954-4c72-864c-34892e5490ee"}
@@ -917,9 +917,11 @@ function emitBanner(name) {
917
917
  logger.logger.error(getAsciiHeader(name))
918
918
  }
919
919
  function getAsciiHeader(command) {
920
- const cliVersion = '0.14.106:968fc98:d6f1d87a:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
920
+ const cliVersion = '0.14.108:342eeb0:d9332f95: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
+ const defaultOrg = shadowNpmInject.getConfigValue('defaultOrg')
924
+ const readOnlyConfig = shadowNpmInject.isReadOnlyConfig() ? '*' : '.'
923
925
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
924
926
  const relCwd = path.normalizePath(
925
927
  process$1
@@ -935,7 +937,7 @@ function getAsciiHeader(command) {
935
937
  const body = `
936
938
  _____ _ _ /---------------
937
939
  | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
938
- |__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}
940
+ |__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `, default org: ${defaultOrg}` : ''}
939
941
  |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart()
940
942
  return ` ${body}\n`
941
943
  }
@@ -2301,7 +2303,7 @@ async function handleScanReport({
2301
2303
  })
2302
2304
  }
2303
2305
 
2304
- async function outputCreateNewScan(data, outputKind) {
2306
+ async function outputCreateNewScan(data, outputKind, interactive) {
2305
2307
  if (!data.id) {
2306
2308
  logger.logger.fail('Did not receive a scan ID from the API...')
2307
2309
  process.exitCode = 1
@@ -2341,10 +2343,11 @@ async function outputCreateNewScan(data, outputKind) {
2341
2343
  )
2342
2344
  logger.logger.log(`Available at: ${link}`)
2343
2345
  if (
2344
- await prompts.confirm({
2346
+ interactive &&
2347
+ (await prompts.confirm({
2345
2348
  message: 'Would you like to open it in your browser?',
2346
2349
  default: false
2347
- })
2350
+ }))
2348
2351
  ) {
2349
2352
  await vendor.open(`${data.html_report_url}`)
2350
2353
  }
@@ -2357,6 +2360,7 @@ async function handleCreateNewScan({
2357
2360
  committers,
2358
2361
  cwd,
2359
2362
  defaultBranch,
2363
+ interactive,
2360
2364
  orgSlug,
2361
2365
  outputKind,
2362
2366
  pendingHead,
@@ -2428,7 +2432,7 @@ async function handleCreateNewScan({
2428
2432
  process.exitCode = 1
2429
2433
  }
2430
2434
  } else {
2431
- await outputCreateNewScan(data, outputKind)
2435
+ await outputCreateNewScan(data, outputKind, interactive)
2432
2436
  }
2433
2437
  }
2434
2438
 
@@ -2451,6 +2455,7 @@ async function handleCI() {
2451
2455
  committers: '',
2452
2456
  cwd: process.cwd(),
2453
2457
  defaultBranch: false,
2458
+ interactive: false,
2454
2459
  orgSlug,
2455
2460
  outputKind: 'json',
2456
2461
  pendingHead: true,
@@ -3815,14 +3820,16 @@ async function gitCreateAndPushBranchIfNeeded(
3815
3820
  await spawn.spawn('git', ['checkout', '-b', branch], {
3816
3821
  cwd
3817
3822
  })
3818
- const relFilepaths = await vendor.distExports.glob(
3819
- '**/{package.json,package-lock.json,pnpm-lock.yaml}',
3820
- {
3821
- cwd
3822
- }
3823
- )
3824
- if (relFilepaths.length) {
3825
- await spawn.spawn('git', ['add', ...relFilepaths], {
3823
+ const moddedFilepaths = (await gitUnstagedModifiedFiles(cwd)).filter(p => {
3824
+ const basename = path$1.basename(p)
3825
+ return (
3826
+ basename === 'package.json' ||
3827
+ basename === 'package-lock.json' ||
3828
+ basename === 'pnpm-lock.yaml'
3829
+ )
3830
+ })
3831
+ if (moddedFilepaths.length) {
3832
+ await spawn.spawn('git', ['add', ...moddedFilepaths], {
3826
3833
  cwd
3827
3834
  })
3828
3835
  }
@@ -3839,6 +3846,13 @@ async function gitHardReset(cwd = process.cwd()) {
3839
3846
  cwd
3840
3847
  })
3841
3848
  }
3849
+ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
3850
+ const { stdout } = await spawn.spawn('git', ['diff', '--name-only'], {
3851
+ cwd
3852
+ })
3853
+ const rawFiles = stdout?.trim().split('\n') ?? []
3854
+ return rawFiles.map(relPath => path.normalizePath(relPath))
3855
+ }
3842
3856
  async function isInGitRepo(cwd = process.cwd()) {
3843
3857
  try {
3844
3858
  await spawn.spawn('git', ['rev-parse', '--is-inside-work-tree'], {
@@ -3876,13 +3890,17 @@ function getOctokitGraphql() {
3876
3890
  }
3877
3891
  async function doesPullRequestExistForBranch(owner, repo, branch) {
3878
3892
  const octokit = getOctokit()
3879
- const { data: prs } = await octokit.pulls.list({
3880
- owner,
3881
- repo,
3882
- head: `${owner}:${branch}`,
3883
- state: 'open'
3884
- })
3885
- return prs.length > 0
3893
+ try {
3894
+ const { data: prs } = await octokit.pulls.list({
3895
+ owner,
3896
+ repo,
3897
+ head: `${owner}:${branch}`,
3898
+ state: 'open'
3899
+ })
3900
+ debug.debugLog('doesPullRequestExistForBranch > prs', prs)
3901
+ return prs.length > 0
3902
+ } catch {}
3903
+ return false
3886
3904
  }
3887
3905
  async function enableAutoMerge({ node_id: prId, number: prNumber }) {
3888
3906
  const octokitGraphql = getOctokitGraphql()
@@ -4459,6 +4477,7 @@ async function pnpmFix(
4459
4477
  pkgEnvDetails.editablePkgJson.filename,
4460
4478
  ...workspacePkgJsonPaths
4461
4479
  ]
4480
+ debug.debugLog('workspacePkgJsonPaths', workspacePkgJsonPaths)
4462
4481
  let actualTree = initialTree
4463
4482
  for (const { 0: name, 1: infos } of infoByPkg) {
4464
4483
  if (registry.getManifestData(NPM$c, name)) {
@@ -4513,6 +4532,7 @@ async function pnpmFix(
4513
4532
  }
4514
4533
  continue
4515
4534
  }
4535
+ debug.debugLog('pkgJsonPaths', pkgJsonPaths)
4516
4536
  for (const pkgJsonPath of pkgJsonPaths) {
4517
4537
  const isWorkspaceRoot =
4518
4538
  pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
@@ -10263,6 +10283,12 @@ const config$8 = {
10263
10283
  description:
10264
10284
  'Set the default branch of the repository to the branch of this full-scan. Should only need to be done once, for example for the "main" or "master" branch.'
10265
10285
  },
10286
+ interactive: {
10287
+ type: 'boolean',
10288
+ default: true,
10289
+ description:
10290
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
10291
+ },
10266
10292
  pendingHead: {
10267
10293
  type: 'boolean',
10268
10294
  default: true,
@@ -10359,6 +10385,7 @@ async function run$8(argv, importMeta, { parentName }) {
10359
10385
  cwd: cwdOverride,
10360
10386
  defaultBranch,
10361
10387
  dryRun,
10388
+ interactive = true,
10362
10389
  json,
10363
10390
  markdown,
10364
10391
  pendingHead,
@@ -10384,7 +10411,7 @@ async function run$8(argv, importMeta, { parentName }) {
10384
10411
  // If we updated any inputs then we should print the command line to repeat
10385
10412
  // the command without requiring user input, as a suggestion.
10386
10413
  let updatedInput = false
10387
- if (!targets.length && !dryRun) {
10414
+ if (!targets.length && !dryRun && interactive) {
10388
10415
  const received = await suggestTarget()
10389
10416
  targets = received ?? []
10390
10417
  updatedInput = true
@@ -10393,7 +10420,7 @@ async function run$8(argv, importMeta, { parentName }) {
10393
10420
  // If the current cwd is unknown and is used as a repo slug anyways, we will
10394
10421
  // first need to register the slug before we can use it.
10395
10422
  // Only do suggestions with an apiToken and when not in dryRun mode
10396
- if (apiToken && !dryRun) {
10423
+ if (apiToken && !dryRun && interactive) {
10397
10424
  if (!orgSlug) {
10398
10425
  const suggestion = await suggestOrgSlug()
10399
10426
  if (suggestion) {
@@ -10481,6 +10508,7 @@ async function run$8(argv, importMeta, { parentName }) {
10481
10508
  committers: (committers && String(committers)) || '',
10482
10509
  cwd,
10483
10510
  defaultBranch: Boolean(defaultBranch),
10511
+ interactive: Boolean(interactive),
10484
10512
  orgSlug,
10485
10513
  outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
10486
10514
  pendingHead: Boolean(pendingHead),
@@ -12267,7 +12295,7 @@ void (async () => {
12267
12295
  await vendor.updater({
12268
12296
  name: SOCKET_CLI_BIN_NAME,
12269
12297
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
12270
- version: '0.14.106',
12298
+ version: '0.14.108',
12271
12299
  ttl: 86_400_000 /* 24 hours in milliseconds */
12272
12300
  })
12273
12301
  try {
@@ -12335,5 +12363,5 @@ void (async () => {
12335
12363
  await shadowNpmInject.captureException(e)
12336
12364
  }
12337
12365
  })()
12338
- //# debugId=262dd99f-490c-457b-886d-df52563318d8
12366
+ //# debugId=d0923c39-8309-4e38-ada6-57f9f02b7bcd
12339
12367
  //# sourceMappingURL=cli.js.map