@socketsecurity/cli 0.14.102 → 0.14.104

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.
@@ -12,7 +12,7 @@ function _socketInterop(e) {
12
12
  }
13
13
 
14
14
  const process$1 = require('node:process')
15
- const require$$0$2 = require('node:url')
15
+ const require$$0$1 = require('node:url')
16
16
  const vendor = require('./vendor.js')
17
17
  const debug = require('@socketsecurity/registry/lib/debug')
18
18
  const logger = require('@socketsecurity/registry/lib/logger')
@@ -26,11 +26,11 @@ const objects = require('@socketsecurity/registry/lib/objects')
26
26
  const path = require('@socketsecurity/registry/lib/path')
27
27
  const regexps = require('@socketsecurity/registry/lib/regexps')
28
28
  const words = require('@socketsecurity/registry/lib/words')
29
- const require$$0 = require('node:fs')
29
+ const fs$1 = require('node:fs')
30
30
  const shadowBin = require('./shadow-bin.js')
31
31
  const prompts = require('@socketsecurity/registry/lib/prompts')
32
32
  const shadowNpmPaths = require('./shadow-npm-paths.js')
33
- const require$$0$1 = require('node:util')
33
+ const require$$0 = require('node:util')
34
34
  const arrays = require('@socketsecurity/registry/lib/arrays')
35
35
  const registry = require('@socketsecurity/registry')
36
36
  const npm = require('@socketsecurity/registry/lib/npm')
@@ -347,7 +347,7 @@ function renderJson(data) {
347
347
  }
348
348
  }
349
349
  function renderMarkdown(data, days, repoSlug) {
350
- return vendor.stripIndents`
350
+ return vendor.html`
351
351
  # Socket Alert Analytics
352
352
 
353
353
  These are the Socket.dev stats are analytics for the ${repoSlug ? `${repoSlug} repo` : 'org'} of the past ${days} days
@@ -387,7 +387,7 @@ ${[
387
387
  ]
388
388
  ]
389
389
  .map(
390
- ([title, table]) => vendor.stripIndents`
390
+ ([title, table]) => vendor.html`
391
391
  ## ${title}
392
392
 
393
393
  ${table}
@@ -900,7 +900,7 @@ function emitBanner(name) {
900
900
  logger.logger.error(getAsciiHeader(name))
901
901
  }
902
902
  function getAsciiHeader(command) {
903
- const cliVersion = '0.14.102:51e000d:d5838d89:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
903
+ const cliVersion = '0.14.104:da4a527:c0794558:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
904
904
  const nodeVersion = process$1.version
905
905
  const apiToken = shadowNpmInject.getDefaultToken()
906
906
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -923,8 +923,8 @@ function getAsciiHeader(command) {
923
923
  return ` ${body}\n`
924
924
  }
925
925
 
926
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$H } = constants
927
- const config$K = {
926
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$I } = constants
927
+ const config$L = {
928
928
  commandName: 'analytics',
929
929
  description: `Look up analytics data`,
930
930
  hidden: false,
@@ -979,14 +979,14 @@ const config$K = {
979
979
  `
980
980
  }
981
981
  const cmdAnalytics = {
982
- description: config$K.description,
983
- hidden: config$K.hidden,
984
- run: run$K
982
+ description: config$L.description,
983
+ hidden: config$L.hidden,
984
+ run: run$L
985
985
  }
986
- async function run$K(argv, importMeta, { parentName }) {
986
+ async function run$L(argv, importMeta, { parentName }) {
987
987
  const cli = meowOrExit({
988
988
  argv,
989
- config: config$K,
989
+ config: config$L,
990
990
  importMeta,
991
991
  parentName
992
992
  })
@@ -1041,7 +1041,7 @@ async function run$K(argv, importMeta, { parentName }) {
1041
1041
  return
1042
1042
  }
1043
1043
  if (cli.flags['dryRun']) {
1044
- logger.logger.log(DRY_RUN_BAIL_TEXT$H)
1044
+ logger.logger.log(DRY_RUN_BAIL_TEXT$I)
1045
1045
  return
1046
1046
  }
1047
1047
  assert(assertScope(scope))
@@ -1216,8 +1216,8 @@ async function handleAuditLog({ logType, orgSlug, outputKind, page, perPage }) {
1216
1216
  })
1217
1217
  }
1218
1218
 
1219
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$G } = constants
1220
- const config$J = {
1219
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$H } = constants
1220
+ const config$K = {
1221
1221
  commandName: 'audit-log',
1222
1222
  description: 'Look up the audit log for an organization',
1223
1223
  hidden: false,
@@ -1262,14 +1262,14 @@ const config$J = {
1262
1262
  `
1263
1263
  }
1264
1264
  const cmdAuditLog = {
1265
- description: config$J.description,
1266
- hidden: config$J.hidden,
1267
- run: run$J
1265
+ description: config$K.description,
1266
+ hidden: config$K.hidden,
1267
+ run: run$K
1268
1268
  }
1269
- async function run$J(argv, importMeta, { parentName }) {
1269
+ async function run$K(argv, importMeta, { parentName }) {
1270
1270
  const cli = meowOrExit({
1271
1271
  argv,
1272
- config: config$J,
1272
+ config: config$K,
1273
1273
  importMeta,
1274
1274
  parentName
1275
1275
  })
@@ -1306,7 +1306,7 @@ async function run$J(argv, importMeta, { parentName }) {
1306
1306
  return
1307
1307
  }
1308
1308
  if (cli.flags['dryRun']) {
1309
- logger.logger.log(DRY_RUN_BAIL_TEXT$G)
1309
+ logger.logger.log(DRY_RUN_BAIL_TEXT$H)
1310
1310
  return
1311
1311
  }
1312
1312
  await handleAuditLog({
@@ -1322,7 +1322,7 @@ const {
1322
1322
  NPM: NPM$g,
1323
1323
  NPX: NPX$3,
1324
1324
  PACKAGE_LOCK_JSON,
1325
- PNPM: PNPM$b,
1325
+ PNPM: PNPM$a,
1326
1326
  YARN: YARN$1,
1327
1327
  YARN_LOCK
1328
1328
  } = constants
@@ -1331,7 +1331,7 @@ const nodejsPlatformTypes = new Set([
1331
1331
  'js',
1332
1332
  'nodejs',
1333
1333
  NPM$g,
1334
- PNPM$b,
1334
+ PNPM$a,
1335
1335
  'ts',
1336
1336
  'tsx',
1337
1337
  'typescript'
@@ -1346,9 +1346,9 @@ async function runCycloneDX(yargvWithYes) {
1346
1346
  if (
1347
1347
  yargv.type !== YARN$1 &&
1348
1348
  nodejsPlatformTypes.has(yargv.type) &&
1349
- require$$0.existsSync(`./${YARN_LOCK}`)
1349
+ fs$1.existsSync(`./${YARN_LOCK}`)
1350
1350
  ) {
1351
- if (require$$0.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
1351
+ if (fs$1.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
1352
1352
  yargv.type = NPM$g
1353
1353
  } else {
1354
1354
  // Use synp to create a package-lock.json from the yarn.lock,
@@ -1369,16 +1369,16 @@ async function runCycloneDX(yargvWithYes) {
1369
1369
  await shadowBin(NPX$3, [
1370
1370
  ...yesArgs,
1371
1371
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_CYCLONEDX_CDXGEN_VERSION']".
1372
- `@cyclonedx/cdxgen@${'11.2.3'}`,
1372
+ `@cyclonedx/cdxgen@${'11.2.4'}`,
1373
1373
  ...argvToArray(yargv)
1374
1374
  ])
1375
1375
  if (cleanupPackageLock) {
1376
1376
  try {
1377
- await require$$0.promises.rm(`./${PACKAGE_LOCK_JSON}`)
1377
+ await fs$1.promises.rm(`./${PACKAGE_LOCK_JSON}`)
1378
1378
  } catch {}
1379
1379
  }
1380
1380
  const fullOutputPath = path$1.join(process$1.cwd(), yargv.output)
1381
- if (require$$0.existsSync(fullOutputPath)) {
1381
+ if (fs$1.existsSync(fullOutputPath)) {
1382
1382
  logger.logger.log(
1383
1383
  vendor.yoctocolorsCjsExports.cyanBright(`${yargv.output} created!`)
1384
1384
  )
@@ -1436,7 +1436,7 @@ function isHelpFlag(cmdArg) {
1436
1436
  }
1437
1437
 
1438
1438
  // import { meowOrExit } from '../../utils/meow-with-subcommands'
1439
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$F } = constants
1439
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$G } = constants
1440
1440
 
1441
1441
  // TODO: convert yargs to meow. Or convert all the other things to yargs.
1442
1442
  const toLower = arg => arg.toLowerCase()
@@ -1552,7 +1552,7 @@ const yargsConfig = {
1552
1552
  'spec-version'
1553
1553
  ]
1554
1554
  }
1555
- const config$I = {
1555
+ const config$J = {
1556
1556
  commandName: 'cdxgen',
1557
1557
  description: 'Create an SBOM with CycloneDX generator (cdxgen)',
1558
1558
  hidden: false,
@@ -1568,16 +1568,16 @@ const config$I = {
1568
1568
  `
1569
1569
  }
1570
1570
  const cmdCdxgen = {
1571
- description: config$I.description,
1572
- hidden: config$I.hidden,
1573
- run: run$I
1571
+ description: config$J.description,
1572
+ hidden: config$J.hidden,
1573
+ run: run$J
1574
1574
  }
1575
- async function run$I(argv, importMeta, { parentName }) {
1575
+ async function run$J(argv, importMeta, { parentName }) {
1576
1576
  const cli = meowOrExit({
1577
1577
  allowUnknownFlags: true,
1578
1578
  // Don't let meow take over --help.
1579
1579
  argv: argv.filter(a => !isHelpFlag(a)),
1580
- config: config$I,
1580
+ config: config$J,
1581
1581
  importMeta,
1582
1582
  parentName
1583
1583
  })
@@ -1599,7 +1599,7 @@ async function run$I(argv, importMeta, { parentName }) {
1599
1599
  return
1600
1600
  }
1601
1601
  if (cli.flags['dryRun']) {
1602
- logger.logger.log(DRY_RUN_BAIL_TEXT$F)
1602
+ logger.logger.log(DRY_RUN_BAIL_TEXT$G)
1603
1603
  return
1604
1604
  }
1605
1605
  if (yargv.output === undefined) {
@@ -2447,8 +2447,8 @@ async function handleCI() {
2447
2447
  })
2448
2448
  }
2449
2449
 
2450
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$E } = constants
2451
- const config$H = {
2450
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$F } = constants
2451
+ const config$I = {
2452
2452
  commandName: 'ci',
2453
2453
  description:
2454
2454
  'Create a new scan and report whether it passes your security policy',
@@ -2468,19 +2468,19 @@ const config$H = {
2468
2468
  `
2469
2469
  }
2470
2470
  const cmdCI = {
2471
- description: config$H.description,
2472
- hidden: config$H.hidden,
2473
- run: run$H
2471
+ description: config$I.description,
2472
+ hidden: config$I.hidden,
2473
+ run: run$I
2474
2474
  }
2475
- async function run$H(argv, importMeta, { parentName }) {
2475
+ async function run$I(argv, importMeta, { parentName }) {
2476
2476
  const cli = meowOrExit({
2477
2477
  argv,
2478
- config: config$H,
2478
+ config: config$I,
2479
2479
  importMeta,
2480
2480
  parentName
2481
2481
  })
2482
2482
  if (cli.flags['dryRun']) {
2483
- logger.logger.log(DRY_RUN_BAIL_TEXT$E)
2483
+ logger.logger.log(DRY_RUN_BAIL_TEXT$F)
2484
2484
  return
2485
2485
  }
2486
2486
  await handleCI()
@@ -2727,8 +2727,8 @@ async function handleConfigAuto({ key, outputKind }) {
2727
2727
  await outputConfigAuto(key, result, outputKind)
2728
2728
  }
2729
2729
 
2730
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$D } = constants
2731
- const config$G = {
2730
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$E } = constants
2731
+ const config$H = {
2732
2732
  commandName: 'auto',
2733
2733
  description: 'Automatically discover and set the correct value config item',
2734
2734
  hidden: false,
@@ -2759,14 +2759,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
2759
2759
  `
2760
2760
  }
2761
2761
  const cmdConfigAuto = {
2762
- description: config$G.description,
2763
- hidden: config$G.hidden,
2764
- run: run$G
2762
+ description: config$H.description,
2763
+ hidden: config$H.hidden,
2764
+ run: run$H
2765
2765
  }
2766
- async function run$G(argv, importMeta, { parentName }) {
2766
+ async function run$H(argv, importMeta, { parentName }) {
2767
2767
  const cli = meowOrExit({
2768
2768
  argv,
2769
- config: config$G,
2769
+ config: config$H,
2770
2770
  importMeta,
2771
2771
  parentName
2772
2772
  })
@@ -2792,7 +2792,7 @@ async function run$G(argv, importMeta, { parentName }) {
2792
2792
  return
2793
2793
  }
2794
2794
  if (cli.flags['dryRun']) {
2795
- logger.logger.log(DRY_RUN_BAIL_TEXT$D)
2795
+ logger.logger.log(DRY_RUN_BAIL_TEXT$E)
2796
2796
  return
2797
2797
  }
2798
2798
  await handleConfigAuto({
@@ -2846,8 +2846,8 @@ async function handleConfigGet({ key, outputKind }) {
2846
2846
  await outputConfigGet(key, value, readOnly, outputKind)
2847
2847
  }
2848
2848
 
2849
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$C } = constants
2850
- const config$F = {
2849
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$D } = constants
2850
+ const config$G = {
2851
2851
  commandName: 'get',
2852
2852
  description: 'Get the value of a local CLI config item',
2853
2853
  hidden: false,
@@ -2873,14 +2873,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
2873
2873
  `
2874
2874
  }
2875
2875
  const cmdConfigGet = {
2876
- description: config$F.description,
2877
- hidden: config$F.hidden,
2878
- run: run$F
2876
+ description: config$G.description,
2877
+ hidden: config$G.hidden,
2878
+ run: run$G
2879
2879
  }
2880
- async function run$F(argv, importMeta, { parentName }) {
2880
+ async function run$G(argv, importMeta, { parentName }) {
2881
2881
  const cli = meowOrExit({
2882
2882
  argv,
2883
- config: config$F,
2883
+ config: config$G,
2884
2884
  importMeta,
2885
2885
  parentName
2886
2886
  })
@@ -2906,7 +2906,7 @@ async function run$F(argv, importMeta, { parentName }) {
2906
2906
  return
2907
2907
  }
2908
2908
  if (cli.flags['dryRun']) {
2909
- logger.logger.log(DRY_RUN_BAIL_TEXT$C)
2909
+ logger.logger.log(DRY_RUN_BAIL_TEXT$D)
2910
2910
  return
2911
2911
  }
2912
2912
  await handleConfigGet({
@@ -2968,8 +2968,8 @@ async function outputConfigList({ full, outputKind }) {
2968
2968
  }
2969
2969
  }
2970
2970
 
2971
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B } = constants
2972
- const config$E = {
2971
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$C } = constants
2972
+ const config$F = {
2973
2973
  commandName: 'list',
2974
2974
  description: 'Show all local CLI config items and their values',
2975
2975
  hidden: false,
@@ -3000,14 +3000,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
3000
3000
  `
3001
3001
  }
3002
3002
  const cmdConfigList = {
3003
- description: config$E.description,
3004
- hidden: config$E.hidden,
3005
- run: run$E
3003
+ description: config$F.description,
3004
+ hidden: config$F.hidden,
3005
+ run: run$F
3006
3006
  }
3007
- async function run$E(argv, importMeta, { parentName }) {
3007
+ async function run$F(argv, importMeta, { parentName }) {
3008
3008
  const cli = meowOrExit({
3009
3009
  argv,
3010
- config: config$E,
3010
+ config: config$F,
3011
3011
  importMeta,
3012
3012
  parentName
3013
3013
  })
@@ -3024,7 +3024,7 @@ async function run$E(argv, importMeta, { parentName }) {
3024
3024
  return
3025
3025
  }
3026
3026
  if (cli.flags['dryRun']) {
3027
- logger.logger.log(DRY_RUN_BAIL_TEXT$B)
3027
+ logger.logger.log(DRY_RUN_BAIL_TEXT$C)
3028
3028
  return
3029
3029
  }
3030
3030
  await outputConfigList({
@@ -3069,8 +3069,8 @@ async function handleConfigSet({ key, outputKind, value }) {
3069
3069
  await outputConfigSet(key, value, readOnly, outputKind)
3070
3070
  }
3071
3071
 
3072
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A } = constants
3073
- const config$D = {
3072
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B } = constants
3073
+ const config$E = {
3074
3074
  commandName: 'set',
3075
3075
  description: 'Update the value of a local CLI config item',
3076
3076
  hidden: false,
@@ -3101,14 +3101,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
3101
3101
  `
3102
3102
  }
3103
3103
  const cmdConfigSet = {
3104
- description: config$D.description,
3105
- hidden: config$D.hidden,
3106
- run: run$D
3104
+ description: config$E.description,
3105
+ hidden: config$E.hidden,
3106
+ run: run$E
3107
3107
  }
3108
- async function run$D(argv, importMeta, { parentName }) {
3108
+ async function run$E(argv, importMeta, { parentName }) {
3109
3109
  const cli = meowOrExit({
3110
3110
  argv,
3111
- config: config$D,
3111
+ config: config$E,
3112
3112
  importMeta,
3113
3113
  parentName
3114
3114
  })
@@ -3143,7 +3143,7 @@ async function run$D(argv, importMeta, { parentName }) {
3143
3143
  return
3144
3144
  }
3145
3145
  if (cli.flags['dryRun']) {
3146
- logger.logger.log(DRY_RUN_BAIL_TEXT$A)
3146
+ logger.logger.log(DRY_RUN_BAIL_TEXT$B)
3147
3147
  return
3148
3148
  }
3149
3149
  await handleConfigSet({
@@ -3175,8 +3175,8 @@ async function handleConfigUnset({ key, outputKind }) {
3175
3175
  await outputConfigUnset(key, outputKind)
3176
3176
  }
3177
3177
 
3178
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z } = constants
3179
- const config$C = {
3178
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A } = constants
3179
+ const config$D = {
3180
3180
  commandName: 'unset',
3181
3181
  description: 'Clear the value of a local CLI config item',
3182
3182
  hidden: false,
@@ -3202,14 +3202,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
3202
3202
  `
3203
3203
  }
3204
3204
  const cmdConfigUnset = {
3205
- description: config$C.description,
3206
- hidden: config$C.hidden,
3207
- run: run$C
3205
+ description: config$D.description,
3206
+ hidden: config$D.hidden,
3207
+ run: run$D
3208
3208
  }
3209
- async function run$C(argv, importMeta, { parentName }) {
3209
+ async function run$D(argv, importMeta, { parentName }) {
3210
3210
  const cli = meowOrExit({
3211
3211
  argv,
3212
- config: config$C,
3212
+ config: config$D,
3213
3213
  importMeta,
3214
3214
  parentName
3215
3215
  })
@@ -3235,7 +3235,7 @@ async function run$C(argv, importMeta, { parentName }) {
3235
3235
  return
3236
3236
  }
3237
3237
  if (cli.flags['dryRun']) {
3238
- logger.logger.log(DRY_RUN_BAIL_TEXT$z)
3238
+ logger.logger.log(DRY_RUN_BAIL_TEXT$A)
3239
3239
  return
3240
3240
  }
3241
3241
  await handleConfigUnset({
@@ -3362,8 +3362,8 @@ async function handleDependencies({ limit, offset, outputKind }) {
3362
3362
  })
3363
3363
  }
3364
3364
 
3365
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y } = constants
3366
- const config$B = {
3365
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z } = constants
3366
+ const config$C = {
3367
3367
  commandName: 'dependencies',
3368
3368
  description:
3369
3369
  'Search for any dependency that is being used in your organization',
@@ -3400,14 +3400,14 @@ const config$B = {
3400
3400
  `
3401
3401
  }
3402
3402
  const cmdScanCreate$1 = {
3403
- description: config$B.description,
3404
- hidden: config$B.hidden,
3405
- run: run$B
3403
+ description: config$C.description,
3404
+ hidden: config$C.hidden,
3405
+ run: run$C
3406
3406
  }
3407
- async function run$B(argv, importMeta, { parentName }) {
3407
+ async function run$C(argv, importMeta, { parentName }) {
3408
3408
  const cli = meowOrExit({
3409
3409
  argv,
3410
- config: config$B,
3410
+ config: config$C,
3411
3411
  importMeta,
3412
3412
  parentName
3413
3413
  })
@@ -3435,7 +3435,7 @@ async function run$B(argv, importMeta, { parentName }) {
3435
3435
  return
3436
3436
  }
3437
3437
  if (cli.flags['dryRun']) {
3438
- logger.logger.log(DRY_RUN_BAIL_TEXT$y)
3438
+ logger.logger.log(DRY_RUN_BAIL_TEXT$z)
3439
3439
  return
3440
3440
  }
3441
3441
  await handleDependencies({
@@ -3445,7 +3445,7 @@ async function run$B(argv, importMeta, { parentName }) {
3445
3445
  })
3446
3446
  }
3447
3447
 
3448
- async function fetchDiffScan({ after, before, orgSlug }) {
3448
+ async function fetchDiffScan$1({ after, before, orgSlug }) {
3449
3449
  const apiToken = shadowNpmInject.getDefaultToken()
3450
3450
 
3451
3451
  // Lazily access constants.spinner.
@@ -3468,7 +3468,7 @@ async function fetchDiffScan({ after, before, orgSlug }) {
3468
3468
  return result
3469
3469
  }
3470
3470
 
3471
- async function outputDiffScan(result, { depth, file, outputKind }) {
3471
+ async function outputDiffScan$1(result, { depth, file, outputKind }) {
3472
3472
  const dashboardUrl = result.diff_report_url
3473
3473
  const dashboardMessage = dashboardUrl
3474
3474
  ? `\n View this diff scan in the Socket dashboard: ${vendor.yoctocolorsCjsExports.cyan(dashboardUrl)}`
@@ -3490,7 +3490,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
3490
3490
  }
3491
3491
  if (file && file !== '-') {
3492
3492
  logger.logger.log(`Writing json to \`${file}\``)
3493
- require$$0.writeFile(file, JSON.stringify(result, null, 2), err => {
3493
+ fs$1.writeFile(file, JSON.stringify(result, null, 2), err => {
3494
3494
  if (err) {
3495
3495
  logger.logger.fail(`Writing to \`${file}\` failed...`)
3496
3496
  logger.logger.error(err)
@@ -3513,7 +3513,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
3513
3513
 
3514
3514
  logger.logger.log('Diff scan result:')
3515
3515
  logger.logger.log(
3516
- require$$0$1.inspect(result, {
3516
+ require$$0.inspect(result, {
3517
3517
  showHidden: false,
3518
3518
  depth: depth > 0 ? depth : null,
3519
3519
  colors: true,
@@ -3526,7 +3526,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
3526
3526
  logger.logger.log(dashboardMessage)
3527
3527
  }
3528
3528
 
3529
- async function handleDiffScan({
3529
+ async function handleDiffScan$1({
3530
3530
  after,
3531
3531
  before,
3532
3532
  depth,
@@ -3534,7 +3534,7 @@ async function handleDiffScan({
3534
3534
  orgSlug,
3535
3535
  outputKind
3536
3536
  }) {
3537
- const data = await fetchDiffScan({
3537
+ const data = await fetchDiffScan$1({
3538
3538
  after,
3539
3539
  before,
3540
3540
  orgSlug
@@ -3542,15 +3542,15 @@ async function handleDiffScan({
3542
3542
  if (!data) {
3543
3543
  return
3544
3544
  }
3545
- await outputDiffScan(data, {
3545
+ await outputDiffScan$1(data, {
3546
3546
  depth,
3547
3547
  file,
3548
3548
  outputKind
3549
3549
  })
3550
3550
  }
3551
3551
 
3552
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
3553
- const config$A = {
3552
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y } = constants
3553
+ const config$B = {
3554
3554
  commandName: 'get',
3555
3555
  description: 'Get a diff scan for an organization',
3556
3556
  hidden: false,
@@ -3609,14 +3609,14 @@ const config$A = {
3609
3609
  `
3610
3610
  }
3611
3611
  const cmdDiffScanGet = {
3612
- description: config$A.description,
3613
- hidden: config$A.hidden,
3614
- run: run$A
3612
+ description: config$B.description,
3613
+ hidden: config$B.hidden,
3614
+ run: run$B
3615
3615
  }
3616
- async function run$A(argv, importMeta, { parentName }) {
3616
+ async function run$B(argv, importMeta, { parentName }) {
3617
3617
  const cli = meowOrExit({
3618
3618
  argv,
3619
- config: config$A,
3619
+ config: config$B,
3620
3620
  importMeta,
3621
3621
  parentName
3622
3622
  })
@@ -3664,11 +3664,14 @@ async function run$A(argv, importMeta, { parentName }) {
3664
3664
  if (wasBadInput) {
3665
3665
  return
3666
3666
  }
3667
+ logger.logger.fail(
3668
+ 'Warning: this command is deprecated in favor of `socket scan diff` and will be removed in the next major bump.'
3669
+ )
3667
3670
  if (cli.flags['dryRun']) {
3668
- logger.logger.log(DRY_RUN_BAIL_TEXT$x)
3671
+ logger.logger.log(DRY_RUN_BAIL_TEXT$y)
3669
3672
  return
3670
3673
  }
3671
- await handleDiffScan({
3674
+ await handleDiffScan$1({
3672
3675
  before: String(before || ''),
3673
3676
  after: String(after || ''),
3674
3677
  depth: Number(depth),
@@ -3708,7 +3711,45 @@ function formatBranchName(str) {
3708
3711
  function getPkgNameFromPurlObj(purlObj) {
3709
3712
  return `${purlObj.namespace ? `${purlObj.namespace}/` : ''}${purlObj.name}`
3710
3713
  }
3711
- async function branchExists(branch, cwd = process.cwd()) {
3714
+ function getBaseGitBranch() {
3715
+ // Lazily access constants.ENV[GITHUB_REF_NAME].
3716
+ return (
3717
+ constants.ENV[GITHUB_REF_NAME] ??
3718
+ // GitHub defaults to branch name "main"
3719
+ // 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
3720
+ 'main'
3721
+ )
3722
+ }
3723
+ function getSocketBranchName(purl, newVersion, workspaceName) {
3724
+ const purlObj = packageurlJs.PackageURL.fromString(purl)
3725
+ const maybeWorkspaceName = workspaceName
3726
+ ? `${formatBranchName(workspaceName)}-`
3727
+ : ''
3728
+ const maybeNamespace = purlObj.namespace
3729
+ ? `${formatBranchName(purlObj.namespace)}-`
3730
+ : ''
3731
+ const fullName = `${maybeWorkspaceName}${maybeNamespace}${formatBranchName(purlObj.name)}`
3732
+ return `socket-fix-${fullName}-${formatBranchName(newVersion)}`
3733
+ }
3734
+ function getSocketPullRequestTitle(purl, newVersion, workspaceName) {
3735
+ const purlObj = packageurlJs.PackageURL.fromString(purl)
3736
+ const pkgName = getPkgNameFromPurlObj(purlObj)
3737
+ const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
3738
+ return `Bump ${pkgName} from ${purlObj.version} to ${newVersion}${workspaceDetails}`
3739
+ }
3740
+ function getSocketPullRequestBody(purl, newVersion, workspaceName) {
3741
+ const purlObj = packageurlJs.PackageURL.fromString(purl)
3742
+ const pkgName = getPkgNameFromPurlObj(purlObj)
3743
+ const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
3744
+ return `Bumps [${pkgName}](https://socket.dev/${purlObj.type}/package/${pkgName}) from ${purlObj.version} to ${newVersion}${workspaceDetails}.`
3745
+ }
3746
+ function getSocketCommitMessage(purl, newVersion, workspaceName) {
3747
+ const purlObj = packageurlJs.PackageURL.fromString(purl)
3748
+ const pkgName = getPkgNameFromPurlObj(purlObj)
3749
+ const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
3750
+ return `socket: Bump ${pkgName} from ${purlObj.version} to ${newVersion}${workspaceDetails}`
3751
+ }
3752
+ async function gitBranchExists(branch, cwd = process.cwd()) {
3712
3753
  try {
3713
3754
  await spawn.spawn(
3714
3755
  'git',
@@ -3722,8 +3763,12 @@ async function branchExists(branch, cwd = process.cwd()) {
3722
3763
  } catch {}
3723
3764
  return false
3724
3765
  }
3725
- async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3766
+ async function gitCheckoutBaseBranchIfAvailable(
3767
+ baseBranch,
3768
+ cwd = process.cwd()
3769
+ ) {
3726
3770
  try {
3771
+ await gitHardReset()
3727
3772
  await spawn.spawn('git', ['fetch', '--depth=1', 'origin', baseBranch], {
3728
3773
  cwd
3729
3774
  })
@@ -3741,12 +3786,12 @@ async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
3741
3786
  debug.debugLog(e)
3742
3787
  }
3743
3788
  }
3744
- async function createAndPushBranchIfNeeded(
3789
+ async function gitCreateAndPushBranchIfNeeded(
3745
3790
  branch,
3746
3791
  commitMsg,
3747
3792
  cwd = process.cwd()
3748
3793
  ) {
3749
- if (await branchExists(branch, cwd)) {
3794
+ if (await gitBranchExists(branch, cwd)) {
3750
3795
  logger.logger.warn(`Branch "${branch}" already exists. Skipping creation.`)
3751
3796
  return false
3752
3797
  }
@@ -3764,37 +3809,20 @@ async function createAndPushBranchIfNeeded(
3764
3809
  })
3765
3810
  return true
3766
3811
  }
3767
- function getBaseBranch() {
3768
- // Lazily access constants.ENV[GITHUB_REF_NAME].
3769
- return (
3770
- constants.ENV[GITHUB_REF_NAME] ??
3771
- // GitHub defaults to branch name "main"
3772
- // 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
3773
- 'main'
3774
- )
3775
- }
3776
- function getSocketBranchName(purl, toVersion) {
3777
- const purlObj = packageurlJs.PackageURL.fromString(purl)
3778
- const namespace = formatBranchName(purlObj.namespace ?? '')
3779
- const name = formatBranchName(purlObj.name)
3780
- const version = formatBranchName(toVersion)
3781
- const fullName = `${namespace ? `${namespace}-` : ''}${name}`
3782
- return `socket-fix-${fullName}-${version}`
3783
- }
3784
- function getSocketPullRequestTitle(purl, toVersion) {
3785
- const purlObj = packageurlJs.PackageURL.fromString(purl)
3786
- const pkgName = getPkgNameFromPurlObj(purlObj)
3787
- return `Bump ${pkgName} from ${purlObj.version} to ${toVersion}`
3788
- }
3789
- function getSocketPullRequestBody(purl, toVersion) {
3790
- const purlObj = packageurlJs.PackageURL.fromString(purl)
3791
- const pkgName = getPkgNameFromPurlObj(purlObj)
3792
- return `Bumps [${pkgName}](https://socket.dev/${purlObj.type}/package/${pkgName}) from ${purlObj.version} to ${toVersion}.`
3812
+ async function gitHardReset(cwd = process.cwd()) {
3813
+ await spawn.spawn('git', ['reset', '--hard'], {
3814
+ cwd
3815
+ })
3793
3816
  }
3794
- function getSocketCommitMessage(purl, toVersion) {
3795
- const purlObj = packageurlJs.PackageURL.fromString(purl)
3796
- const pkgName = getPkgNameFromPurlObj(purlObj)
3797
- return `socket: Bump ${pkgName} from ${purlObj.version} to ${toVersion}`
3817
+ async function isInGitRepo(cwd = process.cwd()) {
3818
+ try {
3819
+ await spawn.spawn('git', ['rev-parse', '--is-inside-work-tree'], {
3820
+ cwd,
3821
+ stdio: 'ignore'
3822
+ })
3823
+ return true
3824
+ } catch {}
3825
+ return false
3798
3826
  }
3799
3827
 
3800
3828
  const { GITHUB_ACTIONS, GITHUB_REPOSITORY, SOCKET_SECURITY_GITHUB_PAT } =
@@ -3835,7 +3863,7 @@ async function enableAutoMerge({ node_id: prId, number: prNumber }) {
3835
3863
  const octokitGraphql = getOctokitGraphql()
3836
3864
  try {
3837
3865
  await octokitGraphql(
3838
- `
3866
+ vendor.html`
3839
3867
  mutation EnableAutoMerge($pullRequestId: ID!) {
3840
3868
  enablePullRequestAutoMerge(input: {
3841
3869
  pullRequestId: $pullRequestId,
@@ -3859,7 +3887,9 @@ async function enableAutoMerge({ node_id: prId, number: prNumber }) {
3859
3887
  } catch (e) {
3860
3888
  let message = `Failed to enable auto-merge for PR #${prNumber}`
3861
3889
  if (e instanceof vendor.GraphqlResponseError && e.errors) {
3862
- const details = e.errors.map(({ message }) => ` - ${message}`).join('\n')
3890
+ const details = e.errors
3891
+ .map(({ message }) => ` - ${message.trim()}`)
3892
+ .join('\n')
3863
3893
  message += `:\n${details}`
3864
3894
  }
3865
3895
  logger.logger.error(message)
@@ -3884,9 +3914,13 @@ async function openGitHubPullRequest(
3884
3914
  baseBranch,
3885
3915
  branch,
3886
3916
  purl,
3887
- toVersion,
3888
- cwd = process.cwd()
3917
+ newVersion,
3918
+ options
3889
3919
  ) {
3920
+ const { cwd = process.cwd(), workspaceName } = {
3921
+ __proto__: null,
3922
+ ...options
3923
+ }
3890
3924
  // Lazily access constants.ENV[GITHUB_ACTIONS].
3891
3925
  if (constants.ENV[GITHUB_ACTIONS]) {
3892
3926
  // Lazily access constants.ENV[SOCKET_SECURITY_GITHUB_PAT].
@@ -3903,10 +3937,10 @@ async function openGitHubPullRequest(
3903
3937
  return await octokit.pulls.create({
3904
3938
  owner,
3905
3939
  repo,
3906
- title: getSocketPullRequestTitle(purl, toVersion),
3940
+ title: getSocketPullRequestTitle(purl, newVersion, workspaceName),
3907
3941
  head: branch,
3908
3942
  base: baseBranch,
3909
- body: getSocketPullRequestBody(purl, toVersion)
3943
+ body: getSocketPullRequestBody(purl, newVersion, workspaceName)
3910
3944
  })
3911
3945
  } catch (e) {
3912
3946
  let message = `Failed to open pull request`
@@ -3916,7 +3950,7 @@ async function openGitHubPullRequest(
3916
3950
  const details = restErrors
3917
3951
  .map(
3918
3952
  restErr =>
3919
- `- ${restErr.message ?? `${restErr.resource}.${restErr.field} (${restErr.code})`}`
3953
+ `- ${restErr.message?.trim() ?? `${restErr.resource}.${restErr.field} (${restErr.code})`}`
3920
3954
  )
3921
3955
  .join('\n')
3922
3956
  message += `:\n${details}`
@@ -3942,17 +3976,17 @@ async function install$1(idealTree, options) {
3942
3976
  await arb2.reify()
3943
3977
  }
3944
3978
  async function npmFix(
3945
- _pkgEnvDetails,
3946
- { autoMerge, cwd, rangeStyle, spinner, test, testScript }
3979
+ pkgEnvDetails,
3980
+ { autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
3947
3981
  ) {
3948
3982
  spinner?.start()
3949
3983
  const arb = new shadowNpmInject.SafeArborist({
3950
- path: cwd,
3984
+ path: pkgEnvDetails.pkgPath,
3951
3985
  ...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
3952
3986
  })
3953
3987
  // Calling arb.reify() creates the arb.diff object and nulls-out arb.idealTree.
3954
3988
  await arb.reify()
3955
- const alertsMap = await shadowNpmInject.getAlertsMapFromArborist(arb, {
3989
+ const alertMapOptions = {
3956
3990
  consolidate: true,
3957
3991
  include: {
3958
3992
  existing: true,
@@ -3960,17 +3994,27 @@ async function npmFix(
3960
3994
  upgradable: false
3961
3995
  },
3962
3996
  nothrow: true
3963
- })
3997
+ }
3998
+ const alertsMap = purls.length
3999
+ ? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
4000
+ : await shadowNpmInject.getAlertsMapFromArborist(arb, alertMapOptions)
3964
4001
  const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
3965
4002
  if (!infoByPkg) {
3966
4003
  spinner?.stop()
3967
4004
  return
3968
4005
  }
3969
- const editablePkgJson = await packages.readPackageJson(cwd, {
3970
- editable: true
3971
- })
4006
+
3972
4007
  // Lazily access constants.ENV[CI].
3973
4008
  const isCi = constants.ENV[CI$1]
4009
+ const { pkgPath: rootPath } = pkgEnvDetails
4010
+ const { 0: isRepo, 1: workspacePkgJsonPaths } = await Promise.all([
4011
+ isInGitRepo(cwd),
4012
+ shadowNpmPaths.globWorkspace(pkgEnvDetails)
4013
+ ])
4014
+ const pkgJsonPaths = [
4015
+ pkgEnvDetails.editablePkgJson.filename,
4016
+ ...workspacePkgJsonPaths
4017
+ ]
3974
4018
  await arb.buildIdealTree()
3975
4019
  for (const { 0: name, 1: infos } of infoByPkg) {
3976
4020
  const hasUpgrade = !!registry.getManifestData(NPM$f, name)
@@ -3978,25 +4022,26 @@ async function npmFix(
3978
4022
  spinner?.info(`Skipping ${name}. Socket Optimize package exists.`)
3979
4023
  continue
3980
4024
  }
3981
- const specs = arrays.arrayUnique(
3982
- shadowNpmInject
3983
- .findPackageNodes(arb.idealTree, name)
3984
- .map(n => `${n.name}@${n.version}`)
4025
+ const oldVersions = arrays.arrayUnique(
4026
+ shadowNpmInject.findPackageNodes(arb.idealTree, name).map(n => n.version)
3985
4027
  )
3986
4028
  const packument =
3987
- specs.length && infos.length
4029
+ oldVersions.length && infos.length
3988
4030
  ? // eslint-disable-next-line no-await-in-loop
3989
4031
  await packages.fetchPackagePackument(name)
3990
4032
  : null
3991
4033
  if (!packument) {
3992
4034
  continue
3993
4035
  }
3994
- for (const spec of specs) {
3995
- const lastAtSignIndex = spec.lastIndexOf('@')
3996
- const name = spec.slice(0, lastAtSignIndex)
3997
- const fromVersion = spec.slice(lastAtSignIndex + 1)
3998
- const fromSpec = `${name}@${fromVersion}`
3999
- const fromPurl = `pkg:npm/${fromSpec}`
4036
+ const failedSpecs = new Set()
4037
+ const fixedSpecs = new Set()
4038
+ const installedSpecs = new Set()
4039
+ const testedSpecs = new Set()
4040
+ const unavailableSpecs = new Set()
4041
+ const revertedSpecs = new Set()
4042
+ for (const oldVersion of oldVersions) {
4043
+ const oldSpec = `${name}@${oldVersion}`
4044
+ const oldPurl = `pkg:npm/${oldSpec}`
4000
4045
  for (const {
4001
4046
  firstPatchedVersionIdentifier,
4002
4047
  vulnerableVersionRange
@@ -4008,7 +4053,7 @@ async function npmFix(
4008
4053
  const node = shadowNpmInject.findPackageNode(
4009
4054
  arb.idealTree,
4010
4055
  name,
4011
- fromVersion
4056
+ oldVersion
4012
4057
  )
4013
4058
  if (!node) {
4014
4059
  continue
@@ -4016,124 +4061,170 @@ async function npmFix(
4016
4061
  if (
4017
4062
  !shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
4018
4063
  ) {
4019
- spinner?.fail(`Could not patch ${fromSpec}`)
4064
+ if (!unavailableSpecs.has(oldSpec)) {
4065
+ unavailableSpecs.add(oldSpec)
4066
+ spinner?.fail(`No update available for ${oldSpec}`)
4067
+ }
4020
4068
  continue
4021
4069
  }
4022
- const toVersion = node.package.version
4023
- const toVersionRange = shadowNpmInject.applyRange(
4024
- fromVersion,
4025
- toVersion,
4026
- rangeStyle
4027
- )
4028
- const toSpec = `${name}@${toVersionRange}`
4029
- const branch = isCi ? getSocketBranchName(fromPurl, toVersion) : ''
4030
- const { owner, repo } = isCi
4031
- ? getGitHubEnvRepoInfo()
4032
- : {
4033
- owner: '',
4034
- repo: ''
4035
- }
4036
- const shouldOpenPr = isCi
4037
- ? // eslint-disable-next-line no-await-in-loop
4038
- !(await doesPullRequestExistForBranch(owner, repo, branch))
4039
- : false
4040
- const revertData = {
4041
- ...(editablePkgJson.content.dependencies
4042
- ? {
4043
- dependencies: editablePkgJson.content.dependencies
4044
- }
4045
- : undefined),
4046
- ...(editablePkgJson.content.optionalDependencies
4047
- ? {
4048
- optionalDependencies:
4049
- editablePkgJson.content.optionalDependencies
4050
- }
4051
- : undefined),
4052
- ...(editablePkgJson.content.peerDependencies
4053
- ? {
4054
- peerDependencies: editablePkgJson.content.peerDependencies
4055
- }
4056
- : undefined)
4057
- }
4058
- spinner?.info(`Installing ${toSpec}`)
4059
- const baseBranch = getBaseBranch()
4060
-
4061
- // eslint-disable-next-line no-await-in-loop
4062
- await checkoutBaseBranchIfAvailable(baseBranch, cwd)
4063
- let error
4064
- let errored = false
4065
- let installed = false
4066
- let saved = false
4067
- try {
4068
- shadowNpmInject.updatePackageJsonFromNode(
4069
- editablePkgJson,
4070
- arb.idealTree,
4071
- node,
4072
- toVersion,
4070
+ for (const pkgJsonPath of pkgJsonPaths) {
4071
+ const isWorkspaceRoot =
4072
+ pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
4073
+ const workspaceName = isWorkspaceRoot
4074
+ ? ''
4075
+ : path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
4076
+ const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
4077
+ const editablePkgJson = isWorkspaceRoot
4078
+ ? pkgEnvDetails.editablePkgJson
4079
+ : // eslint-disable-next-line no-await-in-loop
4080
+ await packages.readPackageJson(pkgJsonPath, {
4081
+ editable: true
4082
+ })
4083
+ const newVersion = node.package.version
4084
+ const newVersionRange = shadowNpmInject.applyRange(
4085
+ oldVersion,
4086
+ newVersion,
4073
4087
  rangeStyle
4074
4088
  )
4075
- // eslint-disable-next-line no-await-in-loop
4076
- await editablePkgJson.save()
4077
- saved = true
4078
-
4079
- // eslint-disable-next-line no-await-in-loop
4080
- await install$1(arb.idealTree, {
4081
- cwd
4082
- })
4083
- installed = true
4084
- if (test) {
4085
- spinner?.info(`Testing ${toSpec}`)
4086
- // eslint-disable-next-line no-await-in-loop
4087
- await npm.runScript(testScript, [], {
4088
- spinner,
4089
- stdio: 'ignore'
4090
- })
4089
+ const newSpec = `${name}@${newVersionRange}`
4090
+ const newSpecKey = `${workspaceName ? `${workspaceName}>` : ''}${newSpec}`
4091
+ const branch = isCi
4092
+ ? getSocketBranchName(oldPurl, newVersion, workspaceName)
4093
+ : ''
4094
+ const { owner, repo } = isCi
4095
+ ? getGitHubEnvRepoInfo()
4096
+ : {
4097
+ owner: '',
4098
+ repo: ''
4099
+ }
4100
+ const shouldOpenPr = isCi
4101
+ ? // eslint-disable-next-line no-await-in-loop
4102
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4103
+ : false
4104
+ const revertData = {
4105
+ ...(editablePkgJson.content.dependencies
4106
+ ? {
4107
+ dependencies: editablePkgJson.content.dependencies
4108
+ }
4109
+ : undefined),
4110
+ ...(editablePkgJson.content.optionalDependencies
4111
+ ? {
4112
+ optionalDependencies:
4113
+ editablePkgJson.content.optionalDependencies
4114
+ }
4115
+ : undefined),
4116
+ ...(editablePkgJson.content.peerDependencies
4117
+ ? {
4118
+ peerDependencies: editablePkgJson.content.peerDependencies
4119
+ }
4120
+ : undefined)
4091
4121
  }
4092
- spinner?.successAndStop(`Fixed ${name}`)
4093
- spinner?.start()
4094
- } catch (e) {
4095
- error = e
4096
- errored = true
4097
- }
4098
- if (!errored && shouldOpenPr) {
4099
- // eslint-disable-next-line no-await-in-loop
4100
- await createAndPushBranchIfNeeded(
4101
- branch,
4102
- getSocketCommitMessage(fromPurl, toVersion),
4103
- cwd
4104
- )
4122
+ if (!installedSpecs.has(newSpecKey)) {
4123
+ testedSpecs.add(newSpecKey)
4124
+ spinner?.info(`Installing ${newSpec}${workspaceDetails}`)
4125
+ }
4126
+ const baseBranch = getBaseGitBranch()
4127
+
4105
4128
  // eslint-disable-next-line no-await-in-loop
4106
- const prResponse = await openGitHubPullRequest(
4107
- owner,
4108
- repo,
4109
- baseBranch,
4110
- branch,
4111
- fromPurl,
4112
- toVersion,
4113
- cwd
4114
- )
4115
- if (prResponse && autoMerge) {
4129
+ await gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
4130
+ let error
4131
+ let errored = false
4132
+ let installed = false
4133
+ let saved = false
4134
+ try {
4135
+ shadowNpmInject.updatePackageJsonFromNode(
4136
+ editablePkgJson,
4137
+ arb.idealTree,
4138
+ node,
4139
+ newVersion,
4140
+ rangeStyle
4141
+ )
4116
4142
  // eslint-disable-next-line no-await-in-loop
4117
- await enableAutoMerge(prResponse.data)
4118
- }
4119
- }
4120
- if (errored || isCi) {
4121
- if (errored) {
4122
- spinner?.error(`Reverting ${toSpec}`, error)
4123
- }
4124
- if (saved) {
4125
- editablePkgJson.update(revertData)
4143
+ if (await editablePkgJson.save()) {
4144
+ saved = true
4145
+ }
4126
4146
  // eslint-disable-next-line no-await-in-loop
4127
- await editablePkgJson.save()
4147
+ await install$1(arb.idealTree, {
4148
+ cwd
4149
+ })
4150
+ installed = true
4151
+ if (test) {
4152
+ if (!testedSpecs.has(newSpecKey)) {
4153
+ testedSpecs.add(newSpecKey)
4154
+ spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
4155
+ }
4156
+ // eslint-disable-next-line no-await-in-loop
4157
+ await npm.runScript(testScript, [], {
4158
+ spinner,
4159
+ stdio: 'ignore'
4160
+ })
4161
+ }
4162
+ if (!fixedSpecs.has(newSpecKey)) {
4163
+ fixedSpecs.add(newSpecKey)
4164
+ spinner?.successAndStop(`Fixed ${name}${workspaceDetails}`)
4165
+ spinner?.start()
4166
+ }
4167
+ } catch (e) {
4168
+ error = e
4169
+ errored = true
4128
4170
  }
4129
- if (installed) {
4171
+ if (!errored && shouldOpenPr) {
4130
4172
  // eslint-disable-next-line no-await-in-loop
4131
- await install$1(revertTree, {
4173
+ await gitCreateAndPushBranchIfNeeded(
4174
+ branch,
4175
+ getSocketCommitMessage(oldPurl, newVersion, workspaceName),
4132
4176
  cwd
4133
- })
4177
+ )
4178
+ // eslint-disable-next-line no-await-in-loop
4179
+ const prResponse = await openGitHubPullRequest(
4180
+ owner,
4181
+ repo,
4182
+ baseBranch,
4183
+ branch,
4184
+ oldPurl,
4185
+ newVersion,
4186
+ {
4187
+ cwd,
4188
+ workspaceName
4189
+ }
4190
+ )
4191
+ if (prResponse && autoMerge) {
4192
+ // eslint-disable-next-line no-await-in-loop
4193
+ await enableAutoMerge(prResponse.data)
4194
+ }
4134
4195
  }
4135
- if (errored) {
4136
- spinner?.failAndStop(`Failed to fix ${fromSpec}`)
4196
+ if (errored || isCi) {
4197
+ if (errored) {
4198
+ if (!revertedSpecs.has(newSpecKey)) {
4199
+ revertedSpecs.add(newSpecKey)
4200
+ spinner?.error(`Reverting ${newSpec}${workspaceDetails}`, error)
4201
+ }
4202
+ }
4203
+ if (isRepo) {
4204
+ // eslint-disable-next-line no-await-in-loop
4205
+ await gitHardReset(cwd)
4206
+ }
4207
+ if (saved) {
4208
+ editablePkgJson.update(revertData)
4209
+ if (!isRepo) {
4210
+ // eslint-disable-next-line no-await-in-loop
4211
+ await editablePkgJson.save()
4212
+ }
4213
+ }
4214
+ if (!isRepo && installed) {
4215
+ // eslint-disable-next-line no-await-in-loop
4216
+ await install$1(revertTree, {
4217
+ cwd
4218
+ })
4219
+ }
4220
+ if (errored) {
4221
+ if (!failedSpecs.has(newSpecKey)) {
4222
+ failedSpecs.add(newSpecKey)
4223
+ spinner?.failAndStop(
4224
+ `Update failed for ${oldSpec}${workspaceDetails}`
4225
+ )
4226
+ }
4227
+ }
4137
4228
  }
4138
4229
  }
4139
4230
  }
@@ -4142,78 +4233,6 @@ async function npmFix(
4142
4233
  spinner?.stop()
4143
4234
  }
4144
4235
 
4145
- async function getAlertsMapFromPnpmLockfile(lockfile, options_) {
4146
- const options = {
4147
- __proto__: null,
4148
- consolidate: false,
4149
- nothrow: false,
4150
- ...options_
4151
- }
4152
- const include = {
4153
- __proto__: null,
4154
- actions: undefined,
4155
- blocked: true,
4156
- critical: true,
4157
- cve: true,
4158
- existing: false,
4159
- unfixable: true,
4160
- upgradable: false,
4161
- ...options.include
4162
- }
4163
- const { spinner } = options
4164
- const depTypes = vendor.libExports$2.detectDepTypes(lockfile)
4165
- const pkgIds = Object.keys(depTypes)
4166
- let { length: remaining } = pkgIds
4167
- const alertsByPkgId = new Map()
4168
- if (!remaining) {
4169
- return alertsByPkgId
4170
- }
4171
- const getText = () => `Looking up data for ${remaining} packages`
4172
- spinner?.start(getText())
4173
- const sockSdk = await shadowNpmInject.setupSdk(
4174
- shadowNpmInject.getPublicToken()
4175
- )
4176
- const toAlertsMapOptions = {
4177
- overrides: lockfile.overrides,
4178
- consolidate: options.consolidate,
4179
- include,
4180
- spinner
4181
- }
4182
- for await (const batchResult of sockSdk.batchPackageStream(
4183
- {
4184
- alerts: 'true',
4185
- compact: 'true',
4186
- fixable: include.unfixable ? 'false' : 'true'
4187
- },
4188
- {
4189
- components: pkgIds.map(id => ({
4190
- purl: `pkg:npm/${id}`
4191
- }))
4192
- }
4193
- )) {
4194
- if (batchResult.success) {
4195
- await shadowNpmInject.addArtifactToAlertsMap(
4196
- batchResult.data,
4197
- alertsByPkgId,
4198
- toAlertsMapOptions
4199
- )
4200
- } else if (!options.nothrow) {
4201
- const statusCode = batchResult.status ?? 'unknown'
4202
- const statusMessage = batchResult.error ?? 'No status message'
4203
- throw new Error(
4204
- `Socket API server error (${statusCode}): ${statusMessage}`
4205
- )
4206
- }
4207
- remaining -= 1
4208
- if (spinner && remaining > 0) {
4209
- spinner.start()
4210
- spinner.setText(getText())
4211
- }
4212
- }
4213
- spinner?.stop()
4214
- return alertsByPkgId
4215
- }
4216
-
4217
4236
  const {
4218
4237
  NPM: NPM$e,
4219
4238
  SOCKET_CLI_SAFE_BIN,
@@ -4300,7 +4319,7 @@ function safeNpmInstall(options) {
4300
4319
  return spawnPromise
4301
4320
  }
4302
4321
 
4303
- const { NPM: NPM$d, PNPM: PNPM$a } = constants
4322
+ const { NPM: NPM$d, PNPM: PNPM$9 } = constants
4304
4323
  function runAgentInstall(pkgEnvDetails, options) {
4305
4324
  const { agent, agentExecPath } = pkgEnvDetails
4306
4325
  // All package managers support the "install" command.
@@ -4319,7 +4338,7 @@ function runAgentInstall(pkgEnvDetails, options) {
4319
4338
  ...options
4320
4339
  }
4321
4340
  const skipNodeHardenFlags =
4322
- agent === PNPM$a && pkgEnvDetails.agentVersion.major < 11
4341
+ agent === PNPM$9 && pkgEnvDetails.agentVersion.major < 11
4323
4342
  return spawn.spawn(agentExecPath, ['install', ...args], {
4324
4343
  spinner,
4325
4344
  stdio: 'inherit',
@@ -4339,7 +4358,7 @@ function runAgentInstall(pkgEnvDetails, options) {
4339
4358
  })
4340
4359
  }
4341
4360
 
4342
- const { CI, NPM: NPM$c, OVERRIDES: OVERRIDES$2, PNPM: PNPM$9 } = constants
4361
+ const { CI, NPM: NPM$c, OVERRIDES: OVERRIDES$2, PNPM: PNPM$8 } = constants
4343
4362
  async function getActualTree(cwd = process.cwd()) {
4344
4363
  const arb = new shadowNpmInject.SafeArborist({
4345
4364
  path: cwd,
@@ -4361,15 +4380,18 @@ async function install(pkgEnvDetails, options) {
4361
4380
  }
4362
4381
  async function pnpmFix(
4363
4382
  pkgEnvDetails,
4364
- { autoMerge, cwd, rangeStyle, spinner, test, testScript }
4383
+ { autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
4365
4384
  ) {
4366
- const lockfile = await vendor.libExports$3.readWantedLockfile(cwd, {
4367
- ignoreIncompatible: false
4368
- })
4385
+ const lockfile = await vendor.libExports$3.readWantedLockfile(
4386
+ pkgEnvDetails.pkgPath,
4387
+ {
4388
+ ignoreIncompatible: false
4389
+ }
4390
+ )
4369
4391
  if (!lockfile) {
4370
4392
  return
4371
4393
  }
4372
- const alertsMap = await getAlertsMapFromPnpmLockfile(lockfile, {
4394
+ const alertMapOptions = {
4373
4395
  consolidate: true,
4374
4396
  include: {
4375
4397
  existing: true,
@@ -4377,42 +4399,61 @@ async function pnpmFix(
4377
4399
  upgradable: false
4378
4400
  },
4379
4401
  nothrow: true
4380
- })
4402
+ }
4403
+ const alertsMap = purls.length
4404
+ ? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
4405
+ : await shadowNpmInject.getAlertsMapFromPnpmLockfile(
4406
+ lockfile,
4407
+ alertMapOptions
4408
+ )
4381
4409
  const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
4382
4410
  if (!infoByPkg) {
4383
4411
  return
4384
4412
  }
4385
4413
  spinner?.start()
4386
- const editablePkgJson = await packages.readPackageJson(cwd, {
4387
- editable: true
4388
- })
4414
+
4389
4415
  // Lazily access constants.ENV[CI].
4390
4416
  const isCi = constants.ENV[CI]
4391
- let actualTree = await getActualTree(cwd)
4417
+ const { pkgPath: rootPath } = pkgEnvDetails
4418
+ const {
4419
+ 0: isRepo,
4420
+ 1: workspacePkgJsonPaths,
4421
+ 2: initialTree
4422
+ } = await Promise.all([
4423
+ isInGitRepo(cwd),
4424
+ shadowNpmPaths.globWorkspace(pkgEnvDetails),
4425
+ getActualTree(cwd)
4426
+ ])
4427
+ const pkgJsonPaths = [
4428
+ pkgEnvDetails.editablePkgJson.filename,
4429
+ ...workspacePkgJsonPaths
4430
+ ]
4431
+ let actualTree = initialTree
4392
4432
  for (const { 0: name, 1: infos } of infoByPkg) {
4393
4433
  if (registry.getManifestData(NPM$c, name)) {
4394
4434
  spinner?.info(`Skipping ${name}. Socket Optimize package exists.`)
4395
4435
  continue
4396
4436
  }
4397
- const specs = arrays.arrayUnique(
4398
- shadowNpmInject
4399
- .findPackageNodes(actualTree, name)
4400
- .map(n => `${n.name}@${n.version}`)
4437
+ const oldVersions = arrays.arrayUnique(
4438
+ shadowNpmInject.findPackageNodes(actualTree, name).map(n => n.version)
4401
4439
  )
4402
4440
  const packument =
4403
- specs.length && infos.length
4441
+ oldVersions.length && infos.length
4404
4442
  ? // eslint-disable-next-line no-await-in-loop
4405
4443
  await packages.fetchPackagePackument(name)
4406
4444
  : null
4407
4445
  if (!packument) {
4408
4446
  continue
4409
4447
  }
4410
- for (const spec of specs) {
4411
- const lastAtSignIndex = spec.lastIndexOf('@')
4412
- const name = spec.slice(0, lastAtSignIndex)
4413
- const fromVersion = spec.slice(lastAtSignIndex + 1)
4414
- const fromSpec = `${name}@${fromVersion}`
4415
- const fromPurl = `pkg:npm/${fromSpec}`
4448
+ const failedSpecs = new Set()
4449
+ const fixedSpecs = new Set()
4450
+ const installedSpecs = new Set()
4451
+ const testedSpecs = new Set()
4452
+ const unavailableSpecs = new Set()
4453
+ const revertedSpecs = new Set()
4454
+ for (const oldVersion of oldVersions) {
4455
+ const oldSpec = `${name}@${oldVersion}`
4456
+ const oldPurl = `pkg:npm/${oldSpec}`
4416
4457
  for (const {
4417
4458
  firstPatchedVersionIdentifier,
4418
4459
  vulnerableVersionRange
@@ -4420,167 +4461,224 @@ async function pnpmFix(
4420
4461
  const node = shadowNpmInject.findPackageNode(
4421
4462
  actualTree,
4422
4463
  name,
4423
- fromVersion
4464
+ oldVersion
4424
4465
  )
4425
4466
  if (!node) {
4426
4467
  continue
4427
4468
  }
4428
4469
  const availableVersions = Object.keys(packument.versions)
4429
- const toVersion = shadowNpmInject.findBestPatchVersion(
4470
+ const newVersion = shadowNpmInject.findBestPatchVersion(
4430
4471
  node,
4431
4472
  availableVersions,
4432
4473
  vulnerableVersionRange
4433
4474
  )
4434
- const targetPackument = toVersion
4435
- ? packument.versions[toVersion]
4475
+ const newVersionPackument = newVersion
4476
+ ? packument.versions[newVersion]
4436
4477
  : undefined
4437
- if (!(toVersion && targetPackument)) {
4438
- spinner?.fail(`Could not patch ${fromSpec}`)
4439
- continue
4440
- }
4441
- const oldPnpm = editablePkgJson.content[PNPM$9]
4442
- const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4443
- const oldOverrides = oldPnpm?.[OVERRIDES$2]
4444
- const oldOverridesCount = oldOverrides
4445
- ? Object.keys(oldOverrides).length
4446
- : 0
4447
- const overrideKey = `${name}@${vulnerableVersionRange}`
4448
- const toVersionRange = shadowNpmInject.applyRange(
4449
- oldOverrides?.[overrideKey] ?? fromVersion,
4450
- toVersion,
4451
- rangeStyle
4452
- )
4453
- const toSpec = `${name}@${toVersionRange}`
4454
- const branch = isCi ? getSocketBranchName(fromPurl, toVersion) : ''
4455
- const { owner, repo } = isCi
4456
- ? getGitHubEnvRepoInfo()
4457
- : {
4458
- owner: '',
4459
- repo: ''
4460
- }
4461
- const shouldOpenPr = isCi
4462
- ? // eslint-disable-next-line no-await-in-loop
4463
- !(await doesPullRequestExistForBranch(owner, repo, branch))
4464
- : false
4465
- const updateData = {
4466
- [PNPM$9]: {
4467
- ...oldPnpm,
4468
- [OVERRIDES$2]: {
4469
- [overrideKey]: toVersionRange,
4470
- ...oldOverrides
4471
- }
4478
+ if (!(newVersion && newVersionPackument)) {
4479
+ if (!unavailableSpecs.has(oldSpec)) {
4480
+ unavailableSpecs.add(oldSpec)
4481
+ spinner?.fail(`No update available for ${oldSpec}`)
4472
4482
  }
4483
+ continue
4473
4484
  }
4474
- const revertData = {
4475
- [PNPM$9]: oldPnpmKeyCount
4476
- ? {
4477
- ...oldPnpm,
4478
- [OVERRIDES$2]:
4479
- oldOverridesCount === 1
4480
- ? undefined
4481
- : {
4482
- [overrideKey]: undefined,
4483
- ...oldOverrides
4484
- }
4485
- }
4486
- : undefined,
4487
- ...(editablePkgJson.content.dependencies
4488
- ? {
4489
- dependencies: editablePkgJson.content.dependencies
4490
- }
4491
- : undefined),
4492
- ...(editablePkgJson.content.optionalDependencies
4493
- ? {
4494
- optionalDependencies:
4495
- editablePkgJson.content.optionalDependencies
4485
+ for (const pkgJsonPath of pkgJsonPaths) {
4486
+ const isWorkspaceRoot =
4487
+ pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
4488
+ const workspaceName = isWorkspaceRoot
4489
+ ? ''
4490
+ : path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
4491
+ const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
4492
+ const editablePkgJson = isWorkspaceRoot
4493
+ ? pkgEnvDetails.editablePkgJson
4494
+ : // eslint-disable-next-line no-await-in-loop
4495
+ await packages.readPackageJson(pkgJsonPath, {
4496
+ editable: true
4497
+ })
4498
+ const oldPnpm = editablePkgJson.content[PNPM$8]
4499
+ const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
4500
+ const oldOverrides = oldPnpm?.[OVERRIDES$2]
4501
+ const oldOverridesCount = oldOverrides
4502
+ ? Object.keys(oldOverrides).length
4503
+ : 0
4504
+ const overrideKey = `${name}@${vulnerableVersionRange}`
4505
+ const newVersionRange = shadowNpmInject.applyRange(
4506
+ oldOverrides?.[overrideKey] ?? oldVersion,
4507
+ newVersion,
4508
+ rangeStyle
4509
+ )
4510
+ const newSpec = `${name}@${newVersionRange}`
4511
+ const newSpecKey = `${workspaceName ? `${workspaceName}>` : ''}${newSpec}`
4512
+ const branch = isCi
4513
+ ? getSocketBranchName(oldPurl, newVersion, workspaceName)
4514
+ : ''
4515
+ const baseBranch = isCi ? getBaseGitBranch() : ''
4516
+ const { owner, repo } = isCi
4517
+ ? getGitHubEnvRepoInfo()
4518
+ : {
4519
+ owner: '',
4520
+ repo: ''
4496
4521
  }
4497
- : undefined),
4498
- ...(editablePkgJson.content.peerDependencies
4522
+ const shouldOpenPr = isCi
4523
+ ? // eslint-disable-next-line no-await-in-loop
4524
+ !(await doesPullRequestExistForBranch(owner, repo, branch))
4525
+ : false
4526
+ const updateData = isWorkspaceRoot
4499
4527
  ? {
4500
- peerDependencies: editablePkgJson.content.peerDependencies
4528
+ [PNPM$8]: {
4529
+ ...oldPnpm,
4530
+ [OVERRIDES$2]: {
4531
+ [overrideKey]: newVersionRange,
4532
+ ...oldOverrides
4533
+ }
4534
+ }
4501
4535
  }
4502
- : undefined)
4503
- }
4504
- spinner?.info(`Installing ${toSpec}`)
4505
- const baseBranch = getBaseBranch()
4506
-
4507
- // eslint-disable-next-line no-await-in-loop
4508
- await checkoutBaseBranchIfAvailable(baseBranch, cwd)
4509
- let error
4510
- let errored = false
4511
- let installed = false
4512
- let saved = false
4513
- try {
4514
- editablePkgJson.update(updateData)
4515
- shadowNpmInject.updatePackageJsonFromNode(
4516
- editablePkgJson,
4517
- actualTree,
4518
- node,
4519
- toVersion,
4520
- rangeStyle
4521
- )
4522
- // eslint-disable-next-line no-await-in-loop
4523
- await editablePkgJson.save()
4524
- saved = true
4525
-
4526
- // eslint-disable-next-line no-await-in-loop
4527
- actualTree = await install(pkgEnvDetails, {
4528
- spinner
4529
- })
4530
- installed = true
4531
- if (test) {
4532
- spinner?.info(`Testing ${toSpec}`)
4533
- // eslint-disable-next-line no-await-in-loop
4534
- await npm.runScript(testScript, [], {
4535
- spinner,
4536
- stdio: 'ignore'
4537
- })
4538
- }
4539
- spinner?.successAndStop(`Fixed ${name}`)
4540
- spinner?.start()
4541
- } catch (e) {
4542
- error = e
4543
- errored = true
4544
- }
4545
- if (!errored && shouldOpenPr) {
4546
- // eslint-disable-next-line no-await-in-loop
4547
- await createAndPushBranchIfNeeded(
4548
- branch,
4549
- getSocketCommitMessage(fromPurl, toVersion),
4550
- cwd
4551
- )
4552
- // eslint-disable-next-line no-await-in-loop
4553
- const prResponse = await openGitHubPullRequest(
4554
- owner,
4555
- repo,
4556
- baseBranch,
4557
- branch,
4558
- fromPurl,
4559
- toVersion,
4560
- cwd
4561
- )
4562
- if (prResponse && autoMerge) {
4563
- // eslint-disable-next-line no-await-in-loop
4564
- await enableAutoMerge(prResponse.data)
4536
+ : {}
4537
+ const revertData = {
4538
+ ...(isWorkspaceRoot
4539
+ ? {
4540
+ [PNPM$8]: oldPnpmKeyCount
4541
+ ? {
4542
+ ...oldPnpm,
4543
+ [OVERRIDES$2]:
4544
+ oldOverridesCount === 1
4545
+ ? undefined
4546
+ : {
4547
+ [overrideKey]: undefined,
4548
+ ...oldOverrides
4549
+ }
4550
+ }
4551
+ : undefined
4552
+ }
4553
+ : {}),
4554
+ ...(editablePkgJson.content.dependencies
4555
+ ? {
4556
+ dependencies: editablePkgJson.content.dependencies
4557
+ }
4558
+ : undefined),
4559
+ ...(editablePkgJson.content.optionalDependencies
4560
+ ? {
4561
+ optionalDependencies:
4562
+ editablePkgJson.content.optionalDependencies
4563
+ }
4564
+ : undefined),
4565
+ ...(editablePkgJson.content.peerDependencies
4566
+ ? {
4567
+ peerDependencies: editablePkgJson.content.peerDependencies
4568
+ }
4569
+ : undefined)
4565
4570
  }
4566
- }
4567
- if (errored || isCi) {
4568
- if (errored) {
4569
- spinner?.error(`Reverting ${toSpec}`, error)
4571
+ if (!installedSpecs.has(newSpecKey)) {
4572
+ installedSpecs.add(newSpecKey)
4573
+ spinner?.info(`Installing ${newSpec}${workspaceDetails}`)
4570
4574
  }
4571
- if (saved) {
4572
- editablePkgJson.update(revertData)
4575
+ if (isCi) {
4573
4576
  // eslint-disable-next-line no-await-in-loop
4574
- await editablePkgJson.save()
4577
+ await gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
4575
4578
  }
4576
- if (installed) {
4579
+ let error
4580
+ let errored = false
4581
+ let installed = false
4582
+ let saved = false
4583
+ try {
4584
+ editablePkgJson.update(updateData)
4585
+ shadowNpmInject.updatePackageJsonFromNode(
4586
+ editablePkgJson,
4587
+ actualTree,
4588
+ node,
4589
+ newVersion,
4590
+ rangeStyle
4591
+ )
4592
+ // eslint-disable-next-line no-await-in-loop
4593
+ if (!(await editablePkgJson.save())) {
4594
+ continue
4595
+ }
4596
+ saved = true
4577
4597
  // eslint-disable-next-line no-await-in-loop
4578
4598
  actualTree = await install(pkgEnvDetails, {
4579
4599
  spinner
4580
4600
  })
4601
+ installed = true
4602
+ if (test) {
4603
+ if (!testedSpecs.has(newSpecKey)) {
4604
+ testedSpecs.add(newSpecKey)
4605
+ spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
4606
+ }
4607
+ // eslint-disable-next-line no-await-in-loop
4608
+ await npm.runScript(testScript, [], {
4609
+ spinner,
4610
+ stdio: 'ignore'
4611
+ })
4612
+ }
4613
+ if (!fixedSpecs.has(newSpecKey)) {
4614
+ fixedSpecs.add(newSpecKey)
4615
+ spinner?.successAndStop(`Fixed ${name}${workspaceDetails}`)
4616
+ spinner?.start()
4617
+ }
4618
+ } catch (e) {
4619
+ error = e
4620
+ errored = true
4621
+ }
4622
+ if (!errored && shouldOpenPr) {
4623
+ // eslint-disable-next-line no-await-in-loop
4624
+ await gitCreateAndPushBranchIfNeeded(
4625
+ branch,
4626
+ getSocketCommitMessage(oldPurl, newVersion, workspaceName),
4627
+ cwd
4628
+ )
4629
+ // eslint-disable-next-line no-await-in-loop
4630
+ const prResponse = await openGitHubPullRequest(
4631
+ owner,
4632
+ repo,
4633
+ baseBranch,
4634
+ branch,
4635
+ oldPurl,
4636
+ newVersion,
4637
+ {
4638
+ cwd,
4639
+ workspaceName
4640
+ }
4641
+ )
4642
+ if (prResponse && autoMerge) {
4643
+ // eslint-disable-next-line no-await-in-loop
4644
+ await enableAutoMerge(prResponse.data)
4645
+ }
4581
4646
  }
4582
- if (errored) {
4583
- spinner?.failAndStop(`Failed to fix ${fromSpec}`)
4647
+ if (errored || isCi) {
4648
+ if (errored) {
4649
+ if (!revertedSpecs.has(newSpecKey)) {
4650
+ revertedSpecs.add(newSpecKey)
4651
+ spinner?.error(`Reverting ${newSpec}${workspaceDetails}`, error)
4652
+ }
4653
+ }
4654
+ if (isRepo) {
4655
+ // eslint-disable-next-line no-await-in-loop
4656
+ await gitHardReset(cwd)
4657
+ }
4658
+ if (saved) {
4659
+ editablePkgJson.update(revertData)
4660
+ if (!isRepo) {
4661
+ // eslint-disable-next-line no-await-in-loop
4662
+ await editablePkgJson.save()
4663
+ }
4664
+ }
4665
+ if (isRepo) {
4666
+ // eslint-disable-next-line no-await-in-loop
4667
+ actualTree = await getActualTree(cwd)
4668
+ } else if (installed) {
4669
+ // eslint-disable-next-line no-await-in-loop
4670
+ actualTree = await install(pkgEnvDetails, {
4671
+ spinner
4672
+ })
4673
+ }
4674
+ if (errored) {
4675
+ if (!failedSpecs.has(newSpecKey)) {
4676
+ failedSpecs.add(newSpecKey)
4677
+ spinner?.failAndStop(
4678
+ `Update failed for ${oldSpec}${workspaceDetails}`
4679
+ )
4680
+ }
4681
+ }
4584
4682
  }
4585
4683
  }
4586
4684
  }
@@ -4589,6 +4687,29 @@ async function pnpmFix(
4589
4687
  spinner?.stop()
4590
4688
  }
4591
4689
 
4690
+ const CMD_NAME$1 = 'socket fix'
4691
+ function assignDefaultFixOptions(options) {
4692
+ if (options.autoPilot === undefined) {
4693
+ options.autoPilot = false
4694
+ }
4695
+ if (options.autoMerge === undefined) {
4696
+ options.autoMerge = !!options.autoPilot
4697
+ }
4698
+ if (options.cwd === undefined) {
4699
+ options.cwd = process.cwd()
4700
+ }
4701
+ if (options.rangeStyle === undefined) {
4702
+ options.rangeStyle = 'preserve'
4703
+ }
4704
+ if (options.test === undefined) {
4705
+ options.test = !!options.autoPilot || !!options.testScript
4706
+ }
4707
+ if (options.testScript === undefined) {
4708
+ options.testScript = 'test'
4709
+ }
4710
+ return options
4711
+ }
4712
+
4592
4713
  const {
4593
4714
  BINARY_LOCK_EXT,
4594
4715
  BUN: BUN$5,
@@ -4597,7 +4718,7 @@ const {
4597
4718
  NPM: NPM$b,
4598
4719
  NPM_BUGGY_OVERRIDES_PATCHED_VERSION: NPM_BUGGY_OVERRIDES_PATCHED_VERSION$1,
4599
4720
  PACKAGE_JSON,
4600
- PNPM: PNPM$8,
4721
+ PNPM: PNPM$7,
4601
4722
  VLT: VLT$5,
4602
4723
  YARN,
4603
4724
  YARN_BERRY: YARN_BERRY$5,
@@ -4606,7 +4727,7 @@ const {
4606
4727
  const AGENTS = new Set([
4607
4728
  BUN$5,
4608
4729
  NPM$b,
4609
- PNPM$8,
4730
+ PNPM$7,
4610
4731
  YARN_BERRY$5,
4611
4732
  YARN_CLASSIC$6,
4612
4733
  VLT$5
@@ -4614,7 +4735,7 @@ const AGENTS = new Set([
4614
4735
  const binByAgent = new Map([
4615
4736
  [BUN$5, BUN$5],
4616
4737
  [NPM$b, NPM$b],
4617
- [PNPM$8, PNPM$8],
4738
+ [PNPM$7, PNPM$7],
4618
4739
  [YARN_BERRY$5, YARN],
4619
4740
  [YARN_CLASSIC$6, YARN],
4620
4741
  [VLT$5, VLT$5]
@@ -4622,7 +4743,7 @@ const binByAgent = new Map([
4622
4743
  async function getAgentExecPath(agent) {
4623
4744
  const binName = binByAgent.get(agent)
4624
4745
  return (
4625
- (await vendor.libExports$1(binName, {
4746
+ (await vendor.libExports$2(binName, {
4626
4747
  nothrow: true
4627
4748
  })) ?? binName
4628
4749
  )
@@ -4656,8 +4777,8 @@ const LOCKS = {
4656
4777
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
4657
4778
  'npm-shrinkwrap.json': NPM$b,
4658
4779
  'package-lock.json': NPM$b,
4659
- 'pnpm-lock.yaml': PNPM$8,
4660
- 'pnpm-lock.yml': PNPM$8,
4780
+ 'pnpm-lock.yaml': PNPM$7,
4781
+ 'pnpm-lock.yml': PNPM$7,
4661
4782
  [`yarn${LOCK_EXT$1}`]: YARN_CLASSIC$6,
4662
4783
  'vlt-lock.json': VLT$5,
4663
4784
  // Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
@@ -4704,7 +4825,7 @@ const readLockFileByAgent = (() => {
4704
4825
  })
4705
4826
  ],
4706
4827
  [NPM$b, defaultReader],
4707
- [PNPM$8, defaultReader],
4828
+ [PNPM$7, defaultReader],
4708
4829
  [VLT$5, defaultReader],
4709
4830
  [YARN_BERRY$5, defaultReader],
4710
4831
  [YARN_CLASSIC$6, defaultReader]
@@ -4728,7 +4849,7 @@ async function detectPackageEnvironment({
4728
4849
  cwd
4729
4850
  })
4730
4851
  const pkgPath =
4731
- pkgJsonPath && require$$0.existsSync(pkgJsonPath)
4852
+ pkgJsonPath && fs$1.existsSync(pkgJsonPath)
4732
4853
  ? path$1.dirname(pkgJsonPath)
4733
4854
  : undefined
4734
4855
  const editablePkgJson = pkgPath
@@ -4856,6 +4977,7 @@ async function detectPackageEnvironment({
4856
4977
  agentExecPath,
4857
4978
  agentSupported,
4858
4979
  agentVersion,
4980
+ editablePkgJson,
4859
4981
  features: {
4860
4982
  npmBuggyOverrides
4861
4983
  },
@@ -4865,7 +4987,6 @@ async function detectPackageEnvironment({
4865
4987
  nodeSupported,
4866
4988
  nodeVersion,
4867
4989
  npmExecPath,
4868
- pkgJson: editablePkgJson,
4869
4990
  pkgPath,
4870
4991
  pkgRequirements: {
4871
4992
  agent: pkgAgentRange ?? `>=${pkgMinAgentVersion}`,
@@ -4989,15 +5110,14 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
4989
5110
  return details
4990
5111
  }
4991
5112
 
4992
- const { NPM: NPM$a, PNPM: PNPM$7 } = constants
4993
- const CMD_NAME$2 = 'socket fix'
5113
+ const { NPM: NPM$a, PNPM: PNPM$6 } = constants
4994
5114
  async function runFix(options_) {
4995
- const options = shadowNpmInject.assignDefaultFixOptions({
5115
+ const options = assignDefaultFixOptions({
4996
5116
  __proto__: null,
4997
5117
  ...options_
4998
5118
  })
4999
5119
  const pkgEnvDetails = await detectAndValidatePackageEnvironment(options.cwd, {
5000
- cmdName: CMD_NAME$2,
5120
+ cmdName: CMD_NAME$1,
5001
5121
  logger: logger.logger
5002
5122
  })
5003
5123
  if (!pkgEnvDetails) {
@@ -5007,13 +5127,13 @@ async function runFix(options_) {
5007
5127
  const { agent } = pkgEnvDetails
5008
5128
  if (agent === NPM$a) {
5009
5129
  await npmFix(pkgEnvDetails, options)
5010
- } else if (agent === PNPM$7) {
5130
+ } else if (agent === PNPM$6) {
5011
5131
  await pnpmFix(pkgEnvDetails, options)
5012
5132
  }
5013
5133
  }
5014
5134
 
5015
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
5016
- const config$z = {
5135
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
5136
+ const config$A = {
5017
5137
  commandName: 'fix',
5018
5138
  description: 'Fix "fixable" Socket alerts',
5019
5139
  hidden: true,
@@ -5029,10 +5149,17 @@ const config$z = {
5029
5149
  default: false,
5030
5150
  description: `Enable auto-merge for pull requests that Socket opens.\n See ${vendor.terminalLinkExports('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.`
5031
5151
  },
5152
+ purl: {
5153
+ type: 'string',
5154
+ default: [],
5155
+ description: `User provided PURL to fix`,
5156
+ isMultiple: true,
5157
+ shortFlag: 'p'
5158
+ },
5032
5159
  rangeStyle: {
5033
5160
  type: 'string',
5034
5161
  default: 'preserve',
5035
- description: vendor.stripIndent`
5162
+ description: vendor.html`
5036
5163
  Define how updated dependency versions should be written in package.json.
5037
5164
  Available styles:
5038
5165
  * caret - Use ^ range for compatible updates (e.g. ^1.2.3)
@@ -5063,14 +5190,14 @@ const config$z = {
5063
5190
  `
5064
5191
  }
5065
5192
  const cmdFix = {
5066
- description: config$z.description,
5067
- hidden: config$z.hidden,
5068
- run: run$z
5193
+ description: config$A.description,
5194
+ hidden: config$A.hidden,
5195
+ run: run$A
5069
5196
  }
5070
- async function run$z(argv, importMeta, { parentName }) {
5197
+ async function run$A(argv, importMeta, { parentName }) {
5071
5198
  const cli = meowOrExit({
5072
5199
  argv,
5073
- config: config$z,
5200
+ config: config$A,
5074
5201
  importMeta,
5075
5202
  parentName
5076
5203
  })
@@ -5084,7 +5211,7 @@ async function run$z(argv, importMeta, { parentName }) {
5084
5211
  return
5085
5212
  }
5086
5213
  if (cli.flags['dryRun']) {
5087
- logger.logger.log(DRY_RUN_BAIL_TEXT$w)
5214
+ logger.logger.log(DRY_RUN_BAIL_TEXT$x)
5088
5215
  return
5089
5216
  }
5090
5217
 
@@ -5093,6 +5220,7 @@ async function run$z(argv, importMeta, { parentName }) {
5093
5220
  await runFix({
5094
5221
  autoMerge: Boolean(cli.flags['autoMerge']),
5095
5222
  autoPilot: Boolean(cli.flags['autoPilot']),
5223
+ purls: Array.isArray(cli.flags['purl']) ? cli.flags['purl'] : [],
5096
5224
  spinner,
5097
5225
  rangeStyle: cli.flags['rangeStyle'] ?? undefined,
5098
5226
  test: Boolean(cli.flags['test']),
@@ -5193,7 +5321,7 @@ function outputPackageInfo(
5193
5321
  return
5194
5322
  }
5195
5323
  if (outputKind === 'markdown') {
5196
- logger.logger.log(vendor.stripIndents`
5324
+ logger.logger.log(vendor.html`
5197
5325
  # Package report for ${pkgName}
5198
5326
 
5199
5327
  Package report card:
@@ -5286,11 +5414,12 @@ async function handlePackageInfo({
5286
5414
  }
5287
5415
  }
5288
5416
 
5289
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
5290
- const config$y = {
5417
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
5418
+ const config$z = {
5291
5419
  commandName: 'info',
5292
5420
  description: 'Look up info regarding a package',
5293
- hidden: false,
5421
+ hidden: true,
5422
+ // Deprecated
5294
5423
  flags: {
5295
5424
  ...commonFlags,
5296
5425
  ...outputFlags,
@@ -5311,14 +5440,14 @@ const config$y = {
5311
5440
  `
5312
5441
  }
5313
5442
  const cmdInfo = {
5314
- description: config$y.description,
5315
- hidden: config$y.hidden,
5316
- run: run$y
5443
+ description: config$z.description,
5444
+ hidden: config$z.hidden,
5445
+ run: run$z
5317
5446
  }
5318
- async function run$y(argv, importMeta, { parentName }) {
5447
+ async function run$z(argv, importMeta, { parentName }) {
5319
5448
  const cli = meowOrExit({
5320
5449
  argv,
5321
- config: config$y,
5450
+ config: config$z,
5322
5451
  importMeta,
5323
5452
  parentName
5324
5453
  })
@@ -5356,11 +5485,11 @@ async function run$y(argv, importMeta, { parentName }) {
5356
5485
  const pkgVersion =
5357
5486
  versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1)
5358
5487
  if (cli.flags['dryRun']) {
5359
- logger.logger.log(DRY_RUN_BAIL_TEXT$v)
5488
+ logger.logger.log(DRY_RUN_BAIL_TEXT$w)
5360
5489
  return
5361
5490
  }
5362
5491
  await handlePackageInfo({
5363
- commandName: `${parentName} ${config$y.commandName}`,
5492
+ commandName: `${parentName} ${config$z.commandName}`,
5364
5493
  includeAllIssues: Boolean(all),
5365
5494
  outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
5366
5495
  pkgName,
@@ -5436,7 +5565,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
5436
5565
  logger.logger.success(
5437
5566
  `API credentials ${previousPersistedToken === apiToken ? 'refreshed' : previousPersistedToken ? 'updated' : 'set'}`
5438
5567
  )
5439
- if (!shadowNpmInject.isReadOnlyConfig()) {
5568
+ if (shadowNpmInject.isReadOnlyConfig()) {
5440
5569
  logger.logger.log('')
5441
5570
  logger.logger.warn(
5442
5571
  'Note: config is in read-only mode, at least one key was overridden through flag/env, so the login was not persisted!'
@@ -5447,8 +5576,8 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
5447
5576
  }
5448
5577
  }
5449
5578
 
5450
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
5451
- const config$x = {
5579
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
5580
+ const config$y = {
5452
5581
  commandName: 'login',
5453
5582
  description: 'Socket API login',
5454
5583
  hidden: false,
@@ -5481,21 +5610,21 @@ const config$x = {
5481
5610
  `
5482
5611
  }
5483
5612
  const cmdLogin = {
5484
- description: config$x.description,
5485
- hidden: config$x.hidden,
5486
- run: run$x
5613
+ description: config$y.description,
5614
+ hidden: config$y.hidden,
5615
+ run: run$y
5487
5616
  }
5488
- async function run$x(argv, importMeta, { parentName }) {
5617
+ async function run$y(argv, importMeta, { parentName }) {
5489
5618
  const cli = meowOrExit({
5490
5619
  argv,
5491
- config: config$x,
5620
+ config: config$y,
5492
5621
  importMeta,
5493
5622
  parentName
5494
5623
  })
5495
5624
  const apiBaseUrl = cli.flags['apiBaseUrl']
5496
5625
  const apiProxy = cli.flags['apiProxy']
5497
5626
  if (cli.flags['dryRun']) {
5498
- logger.logger.log(DRY_RUN_BAIL_TEXT$u)
5627
+ logger.logger.log(DRY_RUN_BAIL_TEXT$v)
5499
5628
  return
5500
5629
  }
5501
5630
  if (!isInteractive()) {
@@ -5517,7 +5646,7 @@ function attemptLogout() {
5517
5646
  try {
5518
5647
  applyLogout()
5519
5648
  logger.logger.success('Successfully logged out')
5520
- if (!shadowNpmInject.isReadOnlyConfig()) {
5649
+ if (shadowNpmInject.isReadOnlyConfig()) {
5521
5650
  logger.logger.log('')
5522
5651
  logger.logger.warn(
5523
5652
  'Note: config is in read-only mode, at least one key was overridden through flag/env, so the logout was not persisted!'
@@ -5528,8 +5657,8 @@ function attemptLogout() {
5528
5657
  }
5529
5658
  }
5530
5659
 
5531
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$t } = constants
5532
- const config$w = {
5660
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
5661
+ const config$x = {
5533
5662
  commandName: 'logout',
5534
5663
  description: 'Socket API logout',
5535
5664
  hidden: false,
@@ -5544,42 +5673,60 @@ const config$w = {
5544
5673
  `
5545
5674
  }
5546
5675
  const cmdLogout = {
5547
- description: config$w.description,
5548
- hidden: config$w.hidden,
5549
- run: run$w
5676
+ description: config$x.description,
5677
+ hidden: config$x.hidden,
5678
+ run: run$x
5550
5679
  }
5551
- async function run$w(argv, importMeta, { parentName }) {
5680
+ async function run$x(argv, importMeta, { parentName }) {
5552
5681
  const cli = meowOrExit({
5553
5682
  argv,
5554
- config: config$w,
5683
+ config: config$x,
5555
5684
  importMeta,
5556
5685
  parentName
5557
5686
  })
5558
5687
  if (cli.flags['dryRun']) {
5559
- logger.logger.log(DRY_RUN_BAIL_TEXT$t)
5688
+ logger.logger.log(DRY_RUN_BAIL_TEXT$u)
5560
5689
  return
5561
5690
  }
5562
5691
  attemptLogout()
5563
5692
  }
5564
5693
 
5565
- async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
5566
- // Lazily access constants.spinner.
5567
- const { spinner } = constants
5568
- const rbin = path$1.resolve(bin)
5569
- const rtarget = path$1.resolve(target)
5694
+ async function convertGradleToMaven(target, bin, cwd, verbose, gradleOpts) {
5570
5695
  if (verbose) {
5571
- logger.logger.group('gradle2maven:')
5572
- logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\``)
5573
- logger.logger.log(`[VERBOSE] - Absolute target path: \`${rtarget}\``)
5574
- logger.logger.groupEnd()
5696
+ logger.logger.log('[VERBOSE] Resolving:', [cwd, bin])
5697
+ }
5698
+ const rbin = path$1.resolve(cwd, bin)
5699
+ if (verbose) {
5700
+ logger.logger.log('[VERBOSE] Resolving:', [cwd, target])
5701
+ }
5702
+ const rtarget = path$1.resolve(cwd, target)
5703
+ const binExists = fs$1.existsSync(rbin)
5704
+ const targetExists = fs$1.existsSync(rtarget)
5705
+ logger.logger.group('gradle2maven:')
5706
+ if (verbose || debug.isDebug()) {
5707
+ logger.logger.log(
5708
+ `[VERBOSE] - Absolute bin path: \`${rbin}\` (${binExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`
5709
+ )
5710
+ logger.logger.log(
5711
+ `[VERBOSE] - Absolute target path: \`${rtarget}\` (${targetExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`
5712
+ )
5575
5713
  } else {
5576
- logger.logger.group('gradle2maven:')
5577
- logger.logger.log(`- executing: \`${bin}\``)
5578
- logger.logger.log(`- src dir: \`${target}\``)
5579
- logger.logger.groupEnd()
5714
+ logger.logger.log(`- executing: \`${rbin}\``)
5715
+ if (!binExists) {
5716
+ logger.logger.warn(
5717
+ 'Warning: It appears the executable could not be found at this location. An error might be printed later because of that.'
5718
+ )
5719
+ }
5720
+ logger.logger.log(`- src dir: \`${rtarget}\``)
5721
+ if (!targetExists) {
5722
+ logger.logger.warn(
5723
+ 'Warning: It appears the src dir could not be found at this location. An error might be printed later because of that.'
5724
+ )
5725
+ }
5580
5726
  }
5727
+ logger.logger.groupEnd()
5581
5728
  try {
5582
- // Run sbt with the init script we provide which should yield zero or more
5729
+ // Run gradlew with the init script we provide which should yield zero or more
5583
5730
  // pom files. We have to figure out where to store those pom files such that
5584
5731
  // we can upload them and predict them through the GitHub API. We could do a
5585
5732
  // .socket folder. We could do a socket.pom.gz with all the poms, although
@@ -5589,26 +5736,23 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
5589
5736
  const initLocation = path$1.join(constants.rootDistPath, 'init.gradle')
5590
5737
  const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom']
5591
5738
  if (verbose) {
5592
- logger.logger.log('[VERBOSE] Executing:', bin, commandArgs)
5739
+ logger.logger.log('[VERBOSE] Executing:', [bin], ', args:', commandArgs)
5593
5740
  }
5594
- spinner.start(
5595
- `Converting gradle to maven from \`${bin}\` on \`${target}\`...`
5741
+ logger.logger.log(
5742
+ `Converting gradle to maven from \`${bin}\` on \`${target}\` ...`
5596
5743
  )
5597
- const output = await spawn.spawn(bin, commandArgs, {
5598
- cwd: target || '.'
5599
- })
5600
- spinner.stop()
5744
+ const output = await execGradleWithSpinner(rbin, commandArgs, rtarget, cwd)
5601
5745
  if (verbose) {
5602
5746
  logger.logger.group('[VERBOSE] gradle stdout:')
5603
5747
  logger.logger.log(output)
5604
5748
  logger.logger.groupEnd()
5605
5749
  }
5606
- if (output.stderr) {
5750
+ if (output.code !== 0) {
5607
5751
  process.exitCode = 1
5608
- logger.logger.fail('There were errors while running gradle')
5752
+ logger.logger.fail(`Gradle exited with exit code ${output.code}`)
5609
5753
  // (In verbose mode, stderr was printed above, no need to repeat it)
5610
5754
  if (!verbose) {
5611
- logger.logger.group('[VERBOSE] stderr:')
5755
+ logger.logger.group('stderr:')
5612
5756
  logger.logger.error(output.stderr)
5613
5757
  logger.logger.groupEnd()
5614
5758
  }
@@ -5620,41 +5764,15 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
5620
5764
  logger.logger.log('- ', fn)
5621
5765
  return fn
5622
5766
  })
5623
-
5624
- // const loc = output.stdout?.match(/Wrote (.*?.pom)\n/)?.[1]?.trim()
5625
- // if (!loc) {
5626
- // logger.fail(
5627
- // 'There were no errors from sbt but could not find the location of resulting .pom file either'
5628
- // )
5629
- // // eslint-disable-next-line n/no-process-exit
5630
- // process.exit(1)
5631
- // }
5632
- //
5633
- // // Move the pom file to ...? initial cwd? loc will be an absolute path, or dump to stdout
5634
- // if (out === '-') {
5635
- // spinner.start('Result:\n```')
5636
- // spinner.log(await safeReadFile(loc))
5637
- // spinner.log('```')
5638
- // spinner.successAndStop(`OK`)
5639
- // } else {
5640
- // spinner.start()
5641
- // if (verbose) {
5642
- // spinner.log(
5643
- // `Moving manifest file from \`${loc.replace(/^\/home\/[^/]*?\//, '~/')}\` to \`${out}\``
5644
- // )
5645
- // } else {
5646
- // spinner.log('Moving output pom file')
5647
- // }
5648
- // // TODO: do we prefer fs-extra? renaming can be gnarly on windows and fs-extra's version is better
5649
- // await renamep(loc, out)
5650
- // spinner.successAndStop(`OK. File should be available in \`${out}\``)
5651
- // }
5767
+ logger.logger.log('')
5768
+ logger.logger.log(
5769
+ 'Next step is to generate a Scan by running the `socket scan create` command on the same directory'
5770
+ )
5652
5771
  } catch (e) {
5653
5772
  process.exitCode = 1
5654
- spinner.stop()
5655
5773
  logger.logger.fail(
5656
- 'There was an unexpected error while running this' +
5657
- (verbose ? '' : ' (use --verbose for details)')
5774
+ 'There was an unexpected error while generating manifests' +
5775
+ (verbose ? '' : ' (use --verbose for details)')
5658
5776
  )
5659
5777
  if (verbose) {
5660
5778
  logger.logger.group('[VERBOSE] error:')
@@ -5663,9 +5781,39 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
5663
5781
  }
5664
5782
  }
5665
5783
  }
5784
+ async function execGradleWithSpinner(bin, commandArgs, target, cwd) {
5785
+ // Lazily access constants.spinner.
5786
+ const { spinner } = constants
5787
+ let pass = false
5788
+ try {
5789
+ spinner.start(
5790
+ `Running gradlew... (this can take a while, it depends on how long gradlew has to run)`
5791
+ )
5792
+ const output = await spawn.spawn(bin, commandArgs, {
5793
+ // We can pipe the output through to have the user see the result
5794
+ // of running gradlew, but then we can't (easily) gather the output
5795
+ // to discover the generated files... probably a flag we should allow?
5796
+ // stdio: isDebug() ? 'inherit' : undefined,
5797
+ cwd: target || cwd
5798
+ })
5799
+ pass = true
5800
+ const { code, stderr, stdout } = output
5801
+ return {
5802
+ code,
5803
+ stdout,
5804
+ stderr
5805
+ }
5806
+ } finally {
5807
+ if (pass) {
5808
+ spinner.successAndStop('Completed gradlew execution')
5809
+ } else {
5810
+ spinner.failAndStop('There was an error while trying to run gradlew.')
5811
+ }
5812
+ }
5813
+ }
5666
5814
 
5667
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$s } = constants
5668
- const config$v = {
5815
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$t } = constants
5816
+ const config$w = {
5669
5817
  commandName: 'gradle',
5670
5818
  description:
5671
5819
  '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Gradle/Java/Kotlin/etc project',
@@ -5686,16 +5834,6 @@ const config$v = {
5686
5834
  description:
5687
5835
  'Additional options to pass on to ./gradlew, see `./gradlew --help`'
5688
5836
  },
5689
- out: {
5690
- type: 'string',
5691
- default: './socket.pom.xml',
5692
- description:
5693
- 'Path of output file; where to store the resulting manifest, see also --stdout'
5694
- },
5695
- stdout: {
5696
- type: 'boolean',
5697
- description: 'Print resulting pom.xml to stdout (supersedes --out)'
5698
- },
5699
5837
  task: {
5700
5838
  type: 'string',
5701
5839
  default: 'all',
@@ -5740,20 +5878,20 @@ const config$v = {
5740
5878
  `
5741
5879
  }
5742
5880
  const cmdManifestGradle = {
5743
- description: config$v.description,
5744
- hidden: config$v.hidden,
5745
- run: run$v
5881
+ description: config$w.description,
5882
+ hidden: config$w.hidden,
5883
+ run: run$w
5746
5884
  }
5747
- async function run$v(argv, importMeta, { parentName }) {
5885
+ async function run$w(argv, importMeta, { parentName }) {
5748
5886
  const cli = meowOrExit({
5749
5887
  argv,
5750
- config: config$v,
5888
+ config: config$w,
5751
5889
  importMeta,
5752
5890
  parentName
5753
5891
  })
5754
5892
  const verbose = Boolean(cli.flags['verbose'])
5755
5893
  if (verbose) {
5756
- logger.logger.group('- ', parentName, config$v.commandName, ':')
5894
+ logger.logger.group('- ', parentName, config$w.commandName, ':')
5757
5895
  logger.logger.group('- flags:', cli.flags)
5758
5896
  logger.logger.groupEnd()
5759
5897
  logger.logger.log('- input:', cli.input)
@@ -5774,7 +5912,7 @@ async function run$v(argv, importMeta, { parentName }) {
5774
5912
  },
5775
5913
  {
5776
5914
  nook: true,
5777
- test: cli.input.length === 1,
5915
+ test: cli.input.length <= 1,
5778
5916
  message: 'Can only accept one DIR (make sure to escape spaces!)',
5779
5917
  pass: 'ok',
5780
5918
  fail: 'received ' + cli.input.length
@@ -5783,24 +5921,12 @@ async function run$v(argv, importMeta, { parentName }) {
5783
5921
  if (wasBadInput) {
5784
5922
  return
5785
5923
  }
5786
- let bin
5787
- if (cli.flags['bin']) {
5788
- bin = cli.flags['bin']
5789
- } else {
5790
- bin = path$1.join(target, 'gradlew')
5791
- }
5792
- let out = './socket.pom.xml'
5793
- if (cli.flags['out']) {
5794
- out = cli.flags['out']
5795
- }
5796
- if (cli.flags['stdout']) {
5797
- out = '-'
5798
- }
5924
+ const { bin = path$1.join(target, 'gradlew'), cwd = process.cwd() } =
5925
+ cli.flags
5799
5926
  if (verbose) {
5800
5927
  logger.logger.group()
5801
5928
  logger.logger.log('- target:', target)
5802
5929
  logger.logger.log('- gradle bin:', bin)
5803
- logger.logger.log('- out:', out)
5804
5930
  logger.logger.groupEnd()
5805
5931
  }
5806
5932
  let gradleOpts = []
@@ -5811,10 +5937,16 @@ async function run$v(argv, importMeta, { parentName }) {
5811
5937
  .filter(Boolean)
5812
5938
  }
5813
5939
  if (cli.flags['dryRun']) {
5814
- logger.logger.log(DRY_RUN_BAIL_TEXT$s)
5940
+ logger.logger.log(DRY_RUN_BAIL_TEXT$t)
5815
5941
  return
5816
5942
  }
5817
- await convertGradleToMaven(target, bin, out, verbose, gradleOpts)
5943
+ await convertGradleToMaven(
5944
+ target,
5945
+ String(bin),
5946
+ String(cwd),
5947
+ verbose,
5948
+ gradleOpts
5949
+ )
5818
5950
  }
5819
5951
 
5820
5952
  async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
@@ -5920,8 +6052,8 @@ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
5920
6052
  }
5921
6053
  }
5922
6054
 
5923
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$r } = constants
5924
- const config$u = {
6055
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$s } = constants
6056
+ const config$v = {
5925
6057
  commandName: 'scala',
5926
6058
  description:
5927
6059
  "[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
@@ -5996,20 +6128,20 @@ const config$u = {
5996
6128
  `
5997
6129
  }
5998
6130
  const cmdManifestScala = {
5999
- description: config$u.description,
6000
- hidden: config$u.hidden,
6001
- run: run$u
6131
+ description: config$v.description,
6132
+ hidden: config$v.hidden,
6133
+ run: run$v
6002
6134
  }
6003
- async function run$u(argv, importMeta, { parentName }) {
6135
+ async function run$v(argv, importMeta, { parentName }) {
6004
6136
  const cli = meowOrExit({
6005
6137
  argv,
6006
- config: config$u,
6138
+ config: config$v,
6007
6139
  importMeta,
6008
6140
  parentName
6009
6141
  })
6010
6142
  const verbose = Boolean(cli.flags['verbose'])
6011
6143
  if (verbose) {
6012
- logger.logger.group('- ', parentName, config$u.commandName, ':')
6144
+ logger.logger.group('- ', parentName, config$v.commandName, ':')
6013
6145
  logger.logger.group('- flags:', cli.flags)
6014
6146
  logger.logger.groupEnd()
6015
6147
  logger.logger.log('- input:', cli.input)
@@ -6030,7 +6162,7 @@ async function run$u(argv, importMeta, { parentName }) {
6030
6162
  },
6031
6163
  {
6032
6164
  nook: true,
6033
- test: cli.input.length === 1,
6165
+ test: cli.input.length <= 1,
6034
6166
  message: 'Can only accept one DIR (make sure to escape spaces!)',
6035
6167
  pass: 'ok',
6036
6168
  fail: 'received ' + cli.input.length
@@ -6065,14 +6197,14 @@ async function run$u(argv, importMeta, { parentName }) {
6065
6197
  .filter(Boolean)
6066
6198
  }
6067
6199
  if (cli.flags['dryRun']) {
6068
- logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6200
+ logger.logger.log(DRY_RUN_BAIL_TEXT$s)
6069
6201
  return
6070
6202
  }
6071
6203
  await convertSbtToMaven(target, bin, out, verbose, sbtOpts)
6072
6204
  }
6073
6205
 
6074
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$q } = constants
6075
- const config$t = {
6206
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$r } = constants
6207
+ const config$u = {
6076
6208
  commandName: 'auto',
6077
6209
  description: 'Auto-detect build and attempt to generate manifest file',
6078
6210
  hidden: false,
@@ -6102,21 +6234,21 @@ const config$t = {
6102
6234
  `
6103
6235
  }
6104
6236
  const cmdManifestAuto = {
6105
- description: config$t.description,
6106
- hidden: config$t.hidden,
6107
- run: run$t
6237
+ description: config$u.description,
6238
+ hidden: config$u.hidden,
6239
+ run: run$u
6108
6240
  }
6109
- async function run$t(argv, importMeta, { parentName }) {
6241
+ async function run$u(argv, importMeta, { parentName }) {
6110
6242
  const cli = meowOrExit({
6111
6243
  argv,
6112
- config: config$t,
6244
+ config: config$u,
6113
6245
  importMeta,
6114
6246
  parentName
6115
6247
  })
6116
6248
  const verbose = !!cli.flags['verbose']
6117
6249
  const cwd = cli.flags['cwd'] ?? process.cwd()
6118
6250
  if (verbose) {
6119
- logger.logger.group('- ', parentName, config$t.commandName, ':')
6251
+ logger.logger.group('- ', parentName, config$u.commandName, ':')
6120
6252
  logger.logger.group('- flags:', cli.flags)
6121
6253
  logger.logger.groupEnd()
6122
6254
  logger.logger.log('- input:', cli.input)
@@ -6128,7 +6260,7 @@ async function run$t(argv, importMeta, { parentName }) {
6128
6260
  subArgs.push('--verbose')
6129
6261
  }
6130
6262
  const dir = cwd
6131
- if (require$$0.existsSync(path$1.join(dir, 'build.sbt'))) {
6263
+ if (fs$1.existsSync(path$1.join(dir, 'build.sbt'))) {
6132
6264
  logger.logger.log(
6133
6265
  'Detected a Scala sbt build, running default Scala generator...'
6134
6266
  )
@@ -6137,7 +6269,7 @@ async function run$t(argv, importMeta, { parentName }) {
6137
6269
  }
6138
6270
  subArgs.push(dir)
6139
6271
  if (cli.flags['dryRun']) {
6140
- logger.logger.log(DRY_RUN_BAIL_TEXT$q)
6272
+ logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6141
6273
  return
6142
6274
  }
6143
6275
  await cmdManifestScala.run(subArgs, importMeta, {
@@ -6145,7 +6277,7 @@ async function run$t(argv, importMeta, { parentName }) {
6145
6277
  })
6146
6278
  return
6147
6279
  }
6148
- if (require$$0.existsSync(path$1.join(dir, 'gradlew'))) {
6280
+ if (fs$1.existsSync(path$1.join(dir, 'gradlew'))) {
6149
6281
  logger.logger.log(
6150
6282
  'Detected a gradle build, running default gradle generator...'
6151
6283
  )
@@ -6154,7 +6286,7 @@ async function run$t(argv, importMeta, { parentName }) {
6154
6286
  subArgs.push(cwd)
6155
6287
  }
6156
6288
  if (cli.flags['dryRun']) {
6157
- logger.logger.log(DRY_RUN_BAIL_TEXT$q)
6289
+ logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6158
6290
  return
6159
6291
  }
6160
6292
  await cmdManifestGradle.run(subArgs, importMeta, {
@@ -6163,7 +6295,7 @@ async function run$t(argv, importMeta, { parentName }) {
6163
6295
  return
6164
6296
  }
6165
6297
  if (cli.flags['dryRun']) {
6166
- logger.logger.log(DRY_RUN_BAIL_TEXT$q)
6298
+ logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6167
6299
  return
6168
6300
  }
6169
6301
 
@@ -6171,7 +6303,7 @@ async function run$t(argv, importMeta, { parentName }) {
6171
6303
  vendor
6172
6304
  .meow(
6173
6305
  `
6174
- $ ${parentName} ${config$t.commandName}
6306
+ $ ${parentName} ${config$u.commandName}
6175
6307
 
6176
6308
  Unfortunately this script did not discover a supported language in the
6177
6309
  current folder.
@@ -6185,21 +6317,21 @@ async function run$t(argv, importMeta, { parentName }) {
6185
6317
  `,
6186
6318
  {
6187
6319
  argv: [],
6188
- description: config$t.description,
6320
+ description: config$u.description,
6189
6321
  importMeta
6190
6322
  }
6191
6323
  )
6192
6324
  .showHelp()
6193
6325
  }
6194
6326
 
6195
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$p } = constants
6327
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$q } = constants
6196
6328
 
6197
6329
  // TODO: we may want to dedupe some pieces for all gradle languages. I think it
6198
6330
  // makes sense to have separate commands for them and I think it makes
6199
6331
  // sense for the help panels to note the requested language, rather than
6200
6332
  // `socket manifest kotlin` to print help screens with `gradle` as the
6201
6333
  // command. Room for improvement.
6202
- const config$s = {
6334
+ const config$t = {
6203
6335
  commandName: 'kotlin',
6204
6336
  description:
6205
6337
  '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Kotlin project',
@@ -6220,16 +6352,6 @@ const config$s = {
6220
6352
  description:
6221
6353
  'Additional options to pass on to ./gradlew, see `./gradlew --help`'
6222
6354
  },
6223
- out: {
6224
- type: 'string',
6225
- default: './socket.pom.xml',
6226
- description:
6227
- 'Path of output file; where to store the resulting manifest, see also --stdout'
6228
- },
6229
- stdout: {
6230
- type: 'boolean',
6231
- description: 'Print resulting pom.xml to stdout (supersedes --out)'
6232
- },
6233
6355
  task: {
6234
6356
  type: 'string',
6235
6357
  default: 'all',
@@ -6274,20 +6396,20 @@ const config$s = {
6274
6396
  `
6275
6397
  }
6276
6398
  const cmdManifestKotlin = {
6277
- description: config$s.description,
6278
- hidden: config$s.hidden,
6279
- run: run$s
6399
+ description: config$t.description,
6400
+ hidden: config$t.hidden,
6401
+ run: run$t
6280
6402
  }
6281
- async function run$s(argv, importMeta, { parentName }) {
6403
+ async function run$t(argv, importMeta, { parentName }) {
6282
6404
  const cli = meowOrExit({
6283
6405
  argv,
6284
- config: config$s,
6406
+ config: config$t,
6285
6407
  importMeta,
6286
6408
  parentName
6287
6409
  })
6288
6410
  const verbose = Boolean(cli.flags['verbose'])
6289
6411
  if (verbose) {
6290
- logger.logger.group('- ', parentName, config$s.commandName, ':')
6412
+ logger.logger.group('- ', parentName, config$t.commandName, ':')
6291
6413
  logger.logger.group('- flags:', cli.flags)
6292
6414
  logger.logger.groupEnd()
6293
6415
  logger.logger.log('- input:', cli.input)
@@ -6308,7 +6430,7 @@ async function run$s(argv, importMeta, { parentName }) {
6308
6430
  },
6309
6431
  {
6310
6432
  nook: true,
6311
- test: cli.input.length === 1,
6433
+ test: cli.input.length <= 1,
6312
6434
  message: 'Can only accept one DIR (make sure to escape spaces!)',
6313
6435
  pass: 'ok',
6314
6436
  fail: 'received ' + cli.input.length
@@ -6317,24 +6439,12 @@ async function run$s(argv, importMeta, { parentName }) {
6317
6439
  if (wasBadInput) {
6318
6440
  return
6319
6441
  }
6320
- let bin
6321
- if (cli.flags['bin']) {
6322
- bin = cli.flags['bin']
6323
- } else {
6324
- bin = path$1.join(target, 'gradlew')
6325
- }
6326
- let out = './socket.pom.xml'
6327
- if (cli.flags['out']) {
6328
- out = cli.flags['out']
6329
- }
6330
- if (cli.flags['stdout']) {
6331
- out = '-'
6332
- }
6442
+ const { bin = path$1.join(target, 'gradlew'), cwd = process.cwd() } =
6443
+ cli.flags
6333
6444
  if (verbose) {
6334
6445
  logger.logger.group()
6335
6446
  logger.logger.log('- target:', target)
6336
6447
  logger.logger.log('- gradle bin:', bin)
6337
- logger.logger.log('- out:', out)
6338
6448
  logger.logger.groupEnd()
6339
6449
  }
6340
6450
  let gradleOpts = []
@@ -6345,13 +6455,19 @@ async function run$s(argv, importMeta, { parentName }) {
6345
6455
  .filter(Boolean)
6346
6456
  }
6347
6457
  if (cli.flags['dryRun']) {
6348
- logger.logger.log(DRY_RUN_BAIL_TEXT$p)
6458
+ logger.logger.log(DRY_RUN_BAIL_TEXT$q)
6349
6459
  return
6350
6460
  }
6351
- await convertGradleToMaven(target, bin, out, verbose, gradleOpts)
6461
+ await convertGradleToMaven(
6462
+ target,
6463
+ String(bin),
6464
+ String(cwd),
6465
+ verbose,
6466
+ gradleOpts
6467
+ )
6352
6468
  }
6353
6469
 
6354
- const config$r = {
6470
+ const config$s = {
6355
6471
  commandName: 'manifest',
6356
6472
  description: 'Generate a dependency manifest for given file or dir',
6357
6473
  hidden: false,
@@ -6360,11 +6476,11 @@ const config$r = {
6360
6476
  }
6361
6477
  }
6362
6478
  const cmdManifest = {
6363
- description: config$r.description,
6364
- hidden: config$r.hidden,
6365
- run: run$r
6479
+ description: config$s.description,
6480
+ hidden: config$s.hidden,
6481
+ run: run$s
6366
6482
  }
6367
- async function run$r(argv, importMeta, { parentName }) {
6483
+ async function run$s(argv, importMeta, { parentName }) {
6368
6484
  await meowWithSubcommands(
6369
6485
  {
6370
6486
  auto: cmdManifestAuto,
@@ -6376,15 +6492,15 @@ async function run$r(argv, importMeta, { parentName }) {
6376
6492
  argv,
6377
6493
  aliases: {
6378
6494
  yolo: {
6379
- description: config$r.description,
6495
+ description: config$s.description,
6380
6496
  hidden: true,
6381
6497
  argv: ['auto']
6382
6498
  }
6383
6499
  },
6384
- description: config$r.description,
6500
+ description: config$s.description,
6385
6501
  importMeta,
6386
- flags: config$r.flags,
6387
- name: `${parentName} ${config$r.commandName}`
6502
+ flags: config$s.flags,
6503
+ name: `${parentName} ${config$s.commandName}`
6388
6504
  }
6389
6505
  )
6390
6506
  }
@@ -6396,8 +6512,8 @@ async function wrapNpm(argv) {
6396
6512
  await shadowBin(NPM$8, argv)
6397
6513
  }
6398
6514
 
6399
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$o, NPM: NPM$7 } = constants
6400
- const config$q = {
6515
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$p, NPM: NPM$7 } = constants
6516
+ const config$r = {
6401
6517
  commandName: 'npm',
6402
6518
  description: `${NPM$7} wrapper functionality`,
6403
6519
  hidden: false,
@@ -6410,20 +6526,20 @@ const config$q = {
6410
6526
  `
6411
6527
  }
6412
6528
  const cmdNpm = {
6413
- description: config$q.description,
6414
- hidden: config$q.hidden,
6415
- run: run$q
6529
+ description: config$r.description,
6530
+ hidden: config$r.hidden,
6531
+ run: run$r
6416
6532
  }
6417
- async function run$q(argv, importMeta, { parentName }) {
6533
+ async function run$r(argv, importMeta, { parentName }) {
6418
6534
  const cli = meowOrExit({
6419
6535
  allowUnknownFlags: true,
6420
6536
  argv,
6421
- config: config$q,
6537
+ config: config$r,
6422
6538
  importMeta,
6423
6539
  parentName
6424
6540
  })
6425
6541
  if (cli.flags['dryRun']) {
6426
- logger.logger.log(DRY_RUN_BAIL_TEXT$o)
6542
+ logger.logger.log(DRY_RUN_BAIL_TEXT$p)
6427
6543
  return
6428
6544
  }
6429
6545
  await wrapNpm(argv)
@@ -6436,8 +6552,8 @@ async function wrapNpx(argv) {
6436
6552
  await shadowBin(NPX$2, argv)
6437
6553
  }
6438
6554
 
6439
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$n, NPX: NPX$1 } = constants
6440
- const config$p = {
6555
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$o, NPX: NPX$1 } = constants
6556
+ const config$q = {
6441
6557
  commandName: 'npx',
6442
6558
  description: `${NPX$1} wrapper functionality`,
6443
6559
  hidden: false,
@@ -6450,27 +6566,27 @@ const config$p = {
6450
6566
  `
6451
6567
  }
6452
6568
  const cmdNpx = {
6453
- description: config$p.description,
6454
- hidden: config$p.hidden,
6455
- run: run$p
6569
+ description: config$q.description,
6570
+ hidden: config$q.hidden,
6571
+ run: run$q
6456
6572
  }
6457
- async function run$p(argv, importMeta, { parentName }) {
6573
+ async function run$q(argv, importMeta, { parentName }) {
6458
6574
  const cli = meowOrExit({
6459
6575
  allowUnknownFlags: true,
6460
6576
  argv,
6461
- config: config$p,
6577
+ config: config$q,
6462
6578
  importMeta,
6463
6579
  parentName
6464
6580
  })
6465
6581
  if (cli.flags['dryRun']) {
6466
- logger.logger.log(DRY_RUN_BAIL_TEXT$n)
6582
+ logger.logger.log(DRY_RUN_BAIL_TEXT$o)
6467
6583
  return
6468
6584
  }
6469
6585
  await wrapNpx(argv)
6470
6586
  }
6471
6587
 
6472
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$m } = constants
6473
- const config$o = {
6588
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$n } = constants
6589
+ const config$p = {
6474
6590
  commandName: 'oops',
6475
6591
  description: 'Trigger an intentional error (for development)',
6476
6592
  hidden: true,
@@ -6485,19 +6601,19 @@ const config$o = {
6485
6601
  `
6486
6602
  }
6487
6603
  const cmdOops = {
6488
- description: config$o.description,
6489
- hidden: config$o.hidden,
6490
- run: run$o
6604
+ description: config$p.description,
6605
+ hidden: config$p.hidden,
6606
+ run: run$p
6491
6607
  }
6492
- async function run$o(argv, importMeta, { parentName }) {
6608
+ async function run$p(argv, importMeta, { parentName }) {
6493
6609
  const cli = meowOrExit({
6494
6610
  argv,
6495
- config: config$o,
6611
+ config: config$p,
6496
6612
  importMeta,
6497
6613
  parentName
6498
6614
  })
6499
6615
  if (cli.flags['dryRun']) {
6500
- logger.logger.log(DRY_RUN_BAIL_TEXT$m)
6616
+ logger.logger.log(DRY_RUN_BAIL_TEXT$n)
6501
6617
  return
6502
6618
  }
6503
6619
  throw new Error('This error was intentionally left blank')
@@ -6506,7 +6622,7 @@ async function run$o(argv, importMeta, { parentName }) {
6506
6622
  const {
6507
6623
  BUN: BUN$4,
6508
6624
  NPM: NPM$6,
6509
- PNPM: PNPM$6,
6625
+ PNPM: PNPM$5,
6510
6626
  VLT: VLT$4,
6511
6627
  YARN_BERRY: YARN_BERRY$4,
6512
6628
  YARN_CLASSIC: YARN_CLASSIC$5
@@ -6520,19 +6636,19 @@ function matchQueryCmdStdout(stdout, name) {
6520
6636
  const depsIncludesByAgent = new Map([
6521
6637
  [BUN$4, matchLsCmdViewHumanStdout],
6522
6638
  [NPM$6, matchQueryCmdStdout],
6523
- [PNPM$6, matchQueryCmdStdout],
6639
+ [PNPM$5, matchQueryCmdStdout],
6524
6640
  [VLT$4, matchQueryCmdStdout],
6525
6641
  [YARN_BERRY$4, matchLsCmdViewHumanStdout],
6526
6642
  [YARN_CLASSIC$5, matchLsCmdViewHumanStdout]
6527
6643
  ])
6528
6644
 
6529
- function getDependencyEntries(editablePkgJson) {
6645
+ function getDependencyEntries(pkgEnvDetails) {
6530
6646
  const {
6531
6647
  dependencies,
6532
6648
  devDependencies,
6533
6649
  optionalDependencies,
6534
6650
  peerDependencies
6535
- } = editablePkgJson.content
6651
+ } = pkgEnvDetails.editablePkgJson.content
6536
6652
  return [
6537
6653
  [
6538
6654
  'dependencies',
@@ -6577,14 +6693,14 @@ const {
6577
6693
  BUN: BUN$3,
6578
6694
  NPM: NPM$5,
6579
6695
  OVERRIDES: OVERRIDES$1,
6580
- PNPM: PNPM$5,
6696
+ PNPM: PNPM$4,
6581
6697
  RESOLUTIONS: RESOLUTIONS$1,
6582
6698
  VLT: VLT$3,
6583
6699
  YARN_BERRY: YARN_BERRY$3,
6584
6700
  YARN_CLASSIC: YARN_CLASSIC$4
6585
6701
  } = constants
6586
- function getOverridesDataBun(editablePkgJson) {
6587
- const overrides = editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
6702
+ function getOverridesDataBun(pkgEnvDetails) {
6703
+ const overrides = pkgEnvDetails.editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
6588
6704
  return {
6589
6705
  type: YARN_BERRY$3,
6590
6706
  overrides
@@ -6593,8 +6709,8 @@ function getOverridesDataBun(editablePkgJson) {
6593
6709
 
6594
6710
  // npm overrides documentation:
6595
6711
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
6596
- function getOverridesDataNpm(editablePkgJson) {
6597
- const overrides = editablePkgJson.content?.[OVERRIDES$1] ?? {}
6712
+ function getOverridesDataNpm(pkgEnvDetails) {
6713
+ const overrides = pkgEnvDetails.editablePkgJson.content?.[OVERRIDES$1] ?? {}
6598
6714
  return {
6599
6715
  type: NPM$5,
6600
6716
  overrides
@@ -6603,15 +6719,16 @@ function getOverridesDataNpm(editablePkgJson) {
6603
6719
 
6604
6720
  // pnpm overrides documentation:
6605
6721
  // https://pnpm.io/package_json#pnpmoverrides
6606
- function getOverridesDataPnpm(editablePkgJson) {
6607
- const overrides = editablePkgJson.content?.[PNPM$5]?.[OVERRIDES$1] ?? {}
6722
+ function getOverridesDataPnpm(pkgEnvDetails) {
6723
+ const overrides =
6724
+ pkgEnvDetails.editablePkgJson.content?.[PNPM$4]?.[OVERRIDES$1] ?? {}
6608
6725
  return {
6609
- type: PNPM$5,
6726
+ type: PNPM$4,
6610
6727
  overrides
6611
6728
  }
6612
6729
  }
6613
- function getOverridesDataVlt(editablePkgJson) {
6614
- const overrides = editablePkgJson.content?.[OVERRIDES$1] ?? {}
6730
+ function getOverridesDataVlt(pkgEnvDetails) {
6731
+ const overrides = pkgEnvDetails.editablePkgJson.content?.[OVERRIDES$1] ?? {}
6615
6732
  return {
6616
6733
  type: VLT$3,
6617
6734
  overrides
@@ -6620,8 +6737,8 @@ function getOverridesDataVlt(editablePkgJson) {
6620
6737
 
6621
6738
  // Yarn resolutions documentation:
6622
6739
  // https://yarnpkg.com/configuration/manifest#resolutions
6623
- function getOverridesDataYarn(editablePkgJson) {
6624
- const overrides = editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
6740
+ function getOverridesDataYarn(pkgEnvDetails) {
6741
+ const overrides = pkgEnvDetails.editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
6625
6742
  return {
6626
6743
  type: YARN_BERRY$3,
6627
6744
  overrides
@@ -6630,8 +6747,8 @@ function getOverridesDataYarn(editablePkgJson) {
6630
6747
 
6631
6748
  // Yarn resolutions documentation:
6632
6749
  // https://classic.yarnpkg.com/en/docs/selective-version-resolutions
6633
- function getOverridesDataYarnClassic(editablePkgJson) {
6634
- const overrides = editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
6750
+ function getOverridesDataYarnClassic(pkgEnvDetails) {
6751
+ const overrides = pkgEnvDetails.editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
6635
6752
  return {
6636
6753
  type: YARN_CLASSIC$4,
6637
6754
  overrides
@@ -6640,62 +6757,12 @@ function getOverridesDataYarnClassic(editablePkgJson) {
6640
6757
  const overridesDataByAgent = new Map([
6641
6758
  [BUN$3, getOverridesDataBun],
6642
6759
  [NPM$5, getOverridesDataNpm],
6643
- [PNPM$5, getOverridesDataPnpm],
6760
+ [PNPM$4, getOverridesDataPnpm],
6644
6761
  [VLT$3, getOverridesDataVlt],
6645
6762
  [YARN_BERRY$3, getOverridesDataYarn],
6646
6763
  [YARN_CLASSIC$4, getOverridesDataYarnClassic]
6647
6764
  ])
6648
6765
 
6649
- const { PNPM: PNPM$4 } = constants
6650
- const PNPM_WORKSPACE = `${PNPM$4}-workspace`
6651
- async function getWorkspaceGlobs(agent, pkgPath, editablePkgJson) {
6652
- let workspacePatterns
6653
- if (agent === PNPM$4) {
6654
- for (const workspacePath of [
6655
- path$1.join(pkgPath, `${PNPM_WORKSPACE}.yaml`),
6656
- path$1.join(pkgPath, `${PNPM_WORKSPACE}.yml`)
6657
- ]) {
6658
- // eslint-disable-next-line no-await-in-loop
6659
- const yml = await shadowNpmInject.safeReadFile(workspacePath)
6660
- if (yml) {
6661
- try {
6662
- workspacePatterns = vendor.distExports$1.parse(yml)?.packages
6663
- } catch {}
6664
- if (workspacePatterns) {
6665
- break
6666
- }
6667
- }
6668
- }
6669
- } else {
6670
- workspacePatterns = editablePkgJson.content['workspaces']
6671
- }
6672
- return Array.isArray(workspacePatterns)
6673
- ? workspacePatterns
6674
- .filter(strings.isNonEmptyString)
6675
- .map(workspacePatternToGlobPattern)
6676
- : undefined
6677
- }
6678
- function workspacePatternToGlobPattern(workspace) {
6679
- const { length } = workspace
6680
- if (!length) {
6681
- return ''
6682
- }
6683
- // If the workspace ends with "/"
6684
- if (workspace.charCodeAt(length - 1) === 47 /*'/'*/) {
6685
- return `${workspace}/*/package.json`
6686
- }
6687
- // If the workspace ends with "/**"
6688
- if (
6689
- workspace.charCodeAt(length - 1) === 42 /*'*'*/ &&
6690
- workspace.charCodeAt(length - 2) === 42 /*'*'*/ &&
6691
- workspace.charCodeAt(length - 3) === 47 /*'/'*/
6692
- ) {
6693
- return `${workspace}/*/**/package.json`
6694
- }
6695
- // Things like "packages/a" or "packages/*"
6696
- return `${workspace}/package.json`
6697
- }
6698
-
6699
6766
  const {
6700
6767
  BUN: BUN$2,
6701
6768
  LOCK_EXT,
@@ -6813,22 +6880,22 @@ async function npmQuery(npmExecPath, cwd) {
6813
6880
  } catch {}
6814
6881
  return cleanupQueryStdout(stdout)
6815
6882
  }
6816
- async function lsBun(agentExecPath, cwd) {
6883
+ async function lsBun(pkgEnvDetails, cwd) {
6817
6884
  try {
6818
6885
  // Bun does not support filtering by production packages yet.
6819
6886
  // https://github.com/oven-sh/bun/issues/8283
6820
6887
  return (
6821
- await spawn.spawn(agentExecPath, ['pm', 'ls', '--all'], {
6888
+ await spawn.spawn(pkgEnvDetails.agentExecPath, ['pm', 'ls', '--all'], {
6822
6889
  cwd
6823
6890
  })
6824
6891
  ).stdout
6825
6892
  } catch {}
6826
6893
  return ''
6827
6894
  }
6828
- async function lsNpm(agentExecPath, cwd) {
6829
- return await npmQuery(agentExecPath, cwd)
6895
+ async function lsNpm(pkgEnvDetails, cwd) {
6896
+ return await npmQuery(pkgEnvDetails.agentExecPath, cwd)
6830
6897
  }
6831
- async function lsPnpm(agentExecPath, cwd, options) {
6898
+ async function lsPnpm(pkgEnvDetails, cwd, options) {
6832
6899
  const npmExecPath = options?.npmExecPath
6833
6900
  if (npmExecPath && npmExecPath !== NPM$3) {
6834
6901
  const result = await npmQuery(npmExecPath, cwd)
@@ -6840,7 +6907,7 @@ async function lsPnpm(agentExecPath, cwd, options) {
6840
6907
  try {
6841
6908
  stdout = (
6842
6909
  await spawn.spawn(
6843
- agentExecPath,
6910
+ pkgEnvDetails.agentExecPath,
6844
6911
  // Pnpm uses the alternative spelling of parsable.
6845
6912
  // https://en.wiktionary.org/wiki/parsable
6846
6913
  ['ls', '--parseable', '--prod', '--depth', 'Infinity'],
@@ -6852,13 +6919,13 @@ async function lsPnpm(agentExecPath, cwd, options) {
6852
6919
  } catch {}
6853
6920
  return parsableToQueryStdout(stdout)
6854
6921
  }
6855
- async function lsVlt(agentExecPath, cwd) {
6922
+ async function lsVlt(pkgEnvDetails, cwd) {
6856
6923
  let stdout = ''
6857
6924
  try {
6858
6925
  // See https://docs.vlt.sh/cli/commands/list#options.
6859
6926
  stdout = (
6860
6927
  await spawn.spawn(
6861
- agentExecPath,
6928
+ pkgEnvDetails.agentExecPath,
6862
6929
  ['ls', '--view', 'human', ':not(.dev)'],
6863
6930
  {
6864
6931
  cwd
@@ -6868,14 +6935,14 @@ async function lsVlt(agentExecPath, cwd) {
6868
6935
  } catch {}
6869
6936
  return cleanupQueryStdout(stdout)
6870
6937
  }
6871
- async function lsYarnBerry(agentExecPath, cwd) {
6938
+ async function lsYarnBerry(pkgEnvDetails, cwd) {
6872
6939
  try {
6873
6940
  return (
6874
6941
  // Yarn Berry does not support filtering by production packages yet.
6875
6942
  // https://github.com/yarnpkg/berry/issues/5117
6876
6943
  (
6877
6944
  await spawn.spawn(
6878
- agentExecPath,
6945
+ pkgEnvDetails.agentExecPath,
6879
6946
  ['info', '--recursive', '--name-only'],
6880
6947
  {
6881
6948
  cwd
@@ -6886,14 +6953,14 @@ async function lsYarnBerry(agentExecPath, cwd) {
6886
6953
  } catch {}
6887
6954
  return ''
6888
6955
  }
6889
- async function lsYarnClassic(agentExecPath, cwd) {
6956
+ async function lsYarnClassic(pkgEnvDetails, cwd) {
6890
6957
  try {
6891
6958
  // However, Yarn Classic does support it.
6892
6959
  // https://github.com/yarnpkg/yarn/releases/tag/v1.0.0
6893
6960
  // > Fix: Excludes dev dependencies from the yarn list output when the
6894
6961
  // environment is production
6895
6962
  return (
6896
- await spawn.spawn(agentExecPath, ['list', '--prod'], {
6963
+ await spawn.spawn(pkgEnvDetails.agentExecPath, ['list', '--prod'], {
6897
6964
  cwd
6898
6965
  })
6899
6966
  ).stdout.trim()
@@ -6909,6 +6976,8 @@ const lsByAgent = new Map([
6909
6976
  [YARN_CLASSIC$2, lsYarnClassic]
6910
6977
  ])
6911
6978
 
6979
+ const CMD_NAME = 'socket optimize'
6980
+
6912
6981
  const {
6913
6982
  BUN,
6914
6983
  NPM: NPM$2,
@@ -7038,14 +7107,14 @@ function updatePkgJsonField(editablePkgJson, field, value) {
7038
7107
  `${JSON.stringify(Object.fromEntries(entries), null, 2)}\n`
7039
7108
  )
7040
7109
  }
7041
- function updateOverridesField(editablePkgJson, overrides) {
7042
- updatePkgJsonField(editablePkgJson, OVERRIDES, overrides)
7110
+ function updateOverridesField(pkgEnvDetails, overrides) {
7111
+ updatePkgJsonField(pkgEnvDetails.editablePkgJson, OVERRIDES, overrides)
7043
7112
  }
7044
- function updateResolutionsField(editablePkgJson, overrides) {
7045
- updatePkgJsonField(editablePkgJson, RESOLUTIONS, overrides)
7113
+ function updateResolutionsField(pkgEnvDetails, overrides) {
7114
+ updatePkgJsonField(pkgEnvDetails.editablePkgJson, RESOLUTIONS, overrides)
7046
7115
  }
7047
- function updatePnpmField(editablePkgJson, overrides) {
7048
- updatePkgJsonField(editablePkgJson, PNPM$1, overrides)
7116
+ function updatePnpmField(pkgEnvDetails, overrides) {
7117
+ updatePkgJsonField(pkgEnvDetails.editablePkgJson, PNPM$1, overrides)
7049
7118
  }
7050
7119
  const updateManifestByAgent = new Map([
7051
7120
  [BUN, updateResolutionsField],
@@ -7057,12 +7126,10 @@ const updateManifestByAgent = new Map([
7057
7126
  ])
7058
7127
 
7059
7128
  const { NPM: NPM$1, PNPM, YARN_CLASSIC } = constants
7060
- const CMD_NAME$1 = 'socket optimize'
7061
7129
  const manifestNpmOverrides = registry.getManifestData(NPM$1)
7062
- async function addOverrides(pkgPath, pkgEnvDetails, options) {
7130
+ async function addOverrides(pkgEnvDetails, pkgPath, options) {
7063
7131
  const {
7064
7132
  agent,
7065
- agentExecPath,
7066
7133
  lockName,
7067
7134
  lockSrc,
7068
7135
  npmExecPath,
@@ -7078,27 +7145,19 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
7078
7145
  addedInWorkspaces: new Set(),
7079
7146
  updated: new Set(),
7080
7147
  updatedInWorkspaces: new Set(),
7081
- warnedPnpmWorkspaceRequiresNpm: false
7148
+ warnedPnpmWorkspaceRequiresNpm: false,
7149
+ workspacePkgJsonPaths: await shadowNpmPaths.globWorkspace(pkgEnvDetails)
7082
7150
  }
7083
7151
  } = {
7084
7152
  __proto__: null,
7085
7153
  ...options
7086
7154
  }
7087
- let { pkgJson: editablePkgJson } = pkgEnvDetails
7088
- if (editablePkgJson === undefined) {
7089
- editablePkgJson = await packages.readPackageJson(pkgPath, {
7090
- editable: true
7091
- })
7092
- }
7093
- const workspaceName = path$1.relative(rootPath, pkgPath)
7094
- const workspaceGlobs = await getWorkspaceGlobs(
7095
- agent,
7096
- pkgPath,
7097
- editablePkgJson
7098
- )
7099
- const isRoot = pkgPath === rootPath
7100
- const isLockScanned = isRoot && !prod
7101
- const isWorkspace = !!workspaceGlobs
7155
+ const isWorkspace = state.workspacePkgJsonPaths.length > 0
7156
+ const isWorkspaceRoot = pkgPath === rootPath
7157
+ const isLockScanned = isWorkspaceRoot && !prod
7158
+ const workspaceName = isWorkspaceRoot
7159
+ ? ''
7160
+ : path$1.relative(rootPath, pkgPath)
7102
7161
  if (
7103
7162
  isWorkspace &&
7104
7163
  agent === PNPM &&
@@ -7109,25 +7168,25 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
7109
7168
  state.warnedPnpmWorkspaceRequiresNpm = true
7110
7169
  logger?.warn(
7111
7170
  cmdPrefixMessage(
7112
- CMD_NAME$1,
7171
+ CMD_NAME,
7113
7172
  `${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``
7114
7173
  )
7115
7174
  )
7116
7175
  }
7117
7176
  const overridesDataObjects = []
7118
- if (editablePkgJson.content['private'] || isWorkspace) {
7119
- overridesDataObjects.push(overridesDataByAgent.get(agent)(editablePkgJson))
7177
+ if (isWorkspace || pkgEnvDetails.editablePkgJson.content['private']) {
7178
+ overridesDataObjects.push(overridesDataByAgent.get(agent)(pkgEnvDetails))
7120
7179
  } else {
7121
7180
  overridesDataObjects.push(
7122
- overridesDataByAgent.get(NPM$1)(editablePkgJson),
7123
- overridesDataByAgent.get(YARN_CLASSIC)(editablePkgJson)
7181
+ overridesDataByAgent.get(NPM$1)(pkgEnvDetails),
7182
+ overridesDataByAgent.get(YARN_CLASSIC)(pkgEnvDetails)
7124
7183
  )
7125
7184
  }
7126
7185
  spinner?.setText(
7127
7186
  `Adding overrides${workspaceName ? ` to ${workspaceName}` : ''}...`
7128
7187
  )
7129
7188
  const depAliasMap = new Map()
7130
- const depEntries = getDependencyEntries(editablePkgJson)
7189
+ const depEntries = getDependencyEntries(pkgEnvDetails)
7131
7190
  const manifestEntries = manifestNpmOverrides.filter(({ 1: data }) =>
7132
7191
  vendor.semverExports.satisfies(
7133
7192
  // Roughly check Node range as semver.coerce will strip leading
@@ -7178,7 +7237,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
7178
7237
  depAliasMap.set(origPkgName, thisSpec)
7179
7238
  }
7180
7239
  }
7181
- if (isRoot) {
7240
+ if (isWorkspaceRoot) {
7182
7241
  // The AgentDepsIncludesFn and AgentLockIncludesFn types overlap in their
7183
7242
  // first two parameters. AgentLockIncludesFn accepts an optional third
7184
7243
  // parameter which AgentDepsIncludesFn will ignore so we cast thingScanner
@@ -7188,7 +7247,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
7188
7247
  : depsIncludesByAgent.get(agent)
7189
7248
  const thingToScan = isLockScanned
7190
7249
  ? lockSrc
7191
- : await lsByAgent.get(agent)(agentExecPath, pkgPath, {
7250
+ : await lsByAgent.get(agent)(pkgEnvDetails, pkgPath, {
7192
7251
  npmExecPath
7193
7252
  })
7194
7253
  // Chunk package names to process them in parallel 3 at a time.
@@ -7254,28 +7313,21 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
7254
7313
  )
7255
7314
  }
7256
7315
  })
7257
- if (workspaceGlobs) {
7258
- const workspacePkgJsonPaths = await vendor.distExports.glob(
7259
- workspaceGlobs,
7260
- {
7261
- absolute: true,
7262
- cwd: pkgPath,
7263
- ignore: ['**/node_modules/**', '**/bower_components/**']
7264
- }
7265
- )
7316
+ if (isWorkspace) {
7266
7317
  // Chunk package names to process them in parallel 3 at a time.
7267
7318
  await promises.pEach(
7268
- workspacePkgJsonPaths,
7319
+ state.workspacePkgJsonPaths,
7269
7320
  3,
7270
7321
  async workspacePkgJsonPath => {
7271
7322
  const otherState = await addOverrides(
7272
- path$1.dirname(workspacePkgJsonPath),
7273
7323
  pkgEnvDetails,
7324
+ path$1.dirname(workspacePkgJsonPath),
7274
7325
  {
7275
7326
  logger,
7276
7327
  pin,
7277
7328
  prod,
7278
- spinner
7329
+ spinner,
7330
+ state
7279
7331
  }
7280
7332
  )
7281
7333
  for (const key of [
@@ -7292,14 +7344,14 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
7292
7344
  )
7293
7345
  }
7294
7346
  if (state.added.size > 0 || state.updated.size > 0) {
7295
- editablePkgJson.update(Object.fromEntries(depEntries))
7347
+ pkgEnvDetails.editablePkgJson.update(Object.fromEntries(depEntries))
7296
7348
  for (const { overrides, type } of overridesDataObjects) {
7297
7349
  updateManifestByAgent.get(type)(
7298
- editablePkgJson,
7350
+ pkgEnvDetails,
7299
7351
  objects.toSortedObject(overrides)
7300
7352
  )
7301
7353
  }
7302
- await editablePkgJson.save()
7354
+ await pkgEnvDetails.editablePkgJson.save()
7303
7355
  }
7304
7356
  return state
7305
7357
  }
@@ -7345,7 +7397,6 @@ async function updateLockfile(pkgEnvDetails, options) {
7345
7397
  }
7346
7398
  }
7347
7399
 
7348
- const CMD_NAME = 'socket optimize'
7349
7400
  function createActionMessage(verb, overrideCount, workspaceCount) {
7350
7401
  return `${verb} ${overrideCount} Socket.dev optimized ${words.pluralize('override', overrideCount)}${workspaceCount ? ` in ${workspaceCount} ${words.pluralize('workspace', workspaceCount)}` : ''}`
7351
7402
  }
@@ -7361,7 +7412,7 @@ async function applyOptimization(cwd, pin, prod) {
7361
7412
  // Lazily access constants.spinner.
7362
7413
  const { spinner } = constants
7363
7414
  spinner.start('Socket optimizing...')
7364
- const state = await addOverrides(pkgEnvDetails.pkgPath, pkgEnvDetails, {
7415
+ const state = await addOverrides(pkgEnvDetails, pkgEnvDetails.pkgPath, {
7365
7416
  logger: logger.logger,
7366
7417
  pin,
7367
7418
  prod,
@@ -7394,8 +7445,8 @@ async function applyOptimization(cwd, pin, prod) {
7394
7445
  }
7395
7446
  }
7396
7447
 
7397
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$l } = constants
7398
- const config$n = {
7448
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$m } = constants
7449
+ const config$o = {
7399
7450
  commandName: 'optimize',
7400
7451
  description: 'Optimize dependencies with @socketregistry overrides',
7401
7452
  hidden: false,
@@ -7425,20 +7476,20 @@ const config$n = {
7425
7476
  `
7426
7477
  }
7427
7478
  const cmdOptimize = {
7428
- description: config$n.description,
7429
- hidden: config$n.hidden,
7430
- run: run$n
7479
+ description: config$o.description,
7480
+ hidden: config$o.hidden,
7481
+ run: run$o
7431
7482
  }
7432
- async function run$n(argv, importMeta, { parentName }) {
7483
+ async function run$o(argv, importMeta, { parentName }) {
7433
7484
  const cli = meowOrExit({
7434
7485
  argv,
7435
- config: config$n,
7486
+ config: config$o,
7436
7487
  importMeta,
7437
7488
  parentName
7438
7489
  })
7439
7490
  const cwd = process.cwd()
7440
7491
  if (cli.flags['dryRun']) {
7441
- logger.logger.log(DRY_RUN_BAIL_TEXT$l)
7492
+ logger.logger.log(DRY_RUN_BAIL_TEXT$m)
7442
7493
  return
7443
7494
  }
7444
7495
  await applyOptimization(
@@ -7539,8 +7590,8 @@ async function handleOrganizationList(outputKind = 'text') {
7539
7590
  await outputOrganizationList(data, outputKind)
7540
7591
  }
7541
7592
 
7542
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k } = constants
7543
- const config$m = {
7593
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$l } = constants
7594
+ const config$n = {
7544
7595
  commandName: 'list',
7545
7596
  description: 'List organizations associated with the API key used',
7546
7597
  hidden: false,
@@ -7557,18 +7608,18 @@ const config$m = {
7557
7608
  - Permissions: none (does need a token)
7558
7609
 
7559
7610
  Options
7560
- ${getFlagListOutput(config$m.flags, 6)}
7611
+ ${getFlagListOutput(config$n.flags, 6)}
7561
7612
  `
7562
7613
  }
7563
7614
  const cmdOrganizationList = {
7564
- description: config$m.description,
7565
- hidden: config$m.hidden,
7566
- run: run$m
7615
+ description: config$n.description,
7616
+ hidden: config$n.hidden,
7617
+ run: run$n
7567
7618
  }
7568
- async function run$m(argv, importMeta, { parentName }) {
7619
+ async function run$n(argv, importMeta, { parentName }) {
7569
7620
  const cli = meowOrExit({
7570
7621
  argv,
7571
- config: config$m,
7622
+ config: config$n,
7572
7623
  importMeta,
7573
7624
  parentName
7574
7625
  })
@@ -7596,7 +7647,7 @@ async function run$m(argv, importMeta, { parentName }) {
7596
7647
  return
7597
7648
  }
7598
7649
  if (cli.flags['dryRun']) {
7599
- logger.logger.log(DRY_RUN_BAIL_TEXT$k)
7650
+ logger.logger.log(DRY_RUN_BAIL_TEXT$l)
7600
7651
  return
7601
7652
  }
7602
7653
  await handleOrganizationList(json ? 'json' : markdown ? 'markdown' : 'text')
@@ -7640,8 +7691,7 @@ async function outputLicensePolicy(data, outputKind) {
7640
7691
  logger.logger.log('This is the license policy for your organization:')
7641
7692
  logger.logger.log('')
7642
7693
  const rules = data.license_policy
7643
- // @ts-ignore -- not sure what it's complaining about
7644
- const entries = Object.entries(rules)
7694
+ const entries = rules ? Object.entries(rules) : []
7645
7695
  const mapped = entries.map(([key, value]) => [
7646
7696
  key,
7647
7697
  value.allowed ? ' yes' : ' no'
@@ -7659,10 +7709,10 @@ async function handleLicensePolicy(orgSlug, outputKind) {
7659
7709
  await outputLicensePolicy(data, outputKind)
7660
7710
  }
7661
7711
 
7662
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$j } = constants
7712
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k } = constants
7663
7713
 
7664
7714
  // TODO: secret toplevel alias `socket license policy`?
7665
- const config$l = {
7715
+ const config$m = {
7666
7716
  commandName: 'license',
7667
7717
  description: 'Retrieve the license policy of an organization',
7668
7718
  hidden: true,
@@ -7679,7 +7729,7 @@ const config$l = {
7679
7729
  - Permissions: license-policy:read
7680
7730
 
7681
7731
  Options
7682
- ${getFlagListOutput(config$l.flags, 6)}
7732
+ ${getFlagListOutput(config$m.flags, 6)}
7683
7733
 
7684
7734
  Your API token will need the \`license-policy:read\` permission otherwise
7685
7735
  the request will fail with an authentication error.
@@ -7690,14 +7740,14 @@ const config$l = {
7690
7740
  `
7691
7741
  }
7692
7742
  const cmdOrganizationPolicyLicense = {
7693
- description: config$l.description,
7694
- hidden: config$l.hidden,
7695
- run: run$l
7743
+ description: config$m.description,
7744
+ hidden: config$m.hidden,
7745
+ run: run$m
7696
7746
  }
7697
- async function run$l(argv, importMeta, { parentName }) {
7747
+ async function run$m(argv, importMeta, { parentName }) {
7698
7748
  const cli = meowOrExit({
7699
7749
  argv,
7700
- config: config$l,
7750
+ config: config$m,
7701
7751
  importMeta,
7702
7752
  parentName
7703
7753
  })
@@ -7734,7 +7784,7 @@ async function run$l(argv, importMeta, { parentName }) {
7734
7784
  return
7735
7785
  }
7736
7786
  if (cli.flags['dryRun']) {
7737
- logger.logger.log(DRY_RUN_BAIL_TEXT$j)
7787
+ logger.logger.log(DRY_RUN_BAIL_TEXT$k)
7738
7788
  return
7739
7789
  }
7740
7790
  await handleLicensePolicy(
@@ -7786,7 +7836,7 @@ async function outputSecurityPolicy(data, outputKind) {
7786
7836
  )
7787
7837
  logger.logger.log('')
7788
7838
  const rules = data.securityPolicyRules
7789
- const entries = Object.entries(rules)
7839
+ const entries = rules ? Object.entries(rules) : []
7790
7840
  const mapped = entries.map(([key, value]) => [key, value.action])
7791
7841
  mapped.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
7792
7842
  logger.logger.log(mdTableOfPairs(mapped, ['name', 'action']))
@@ -7801,10 +7851,10 @@ async function handleSecurityPolicy(orgSlug, outputKind) {
7801
7851
  await outputSecurityPolicy(data, outputKind)
7802
7852
  }
7803
7853
 
7804
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$i } = constants
7854
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$j } = constants
7805
7855
 
7806
7856
  // TODO: secret toplevel alias `socket security policy`?
7807
- const config$k = {
7857
+ const config$l = {
7808
7858
  commandName: 'security',
7809
7859
  description: 'Retrieve the security policy of an organization',
7810
7860
  hidden: true,
@@ -7821,7 +7871,7 @@ const config$k = {
7821
7871
  - Permissions: security-policy:read
7822
7872
 
7823
7873
  Options
7824
- ${getFlagListOutput(config$k.flags, 6)}
7874
+ ${getFlagListOutput(config$l.flags, 6)}
7825
7875
 
7826
7876
  Your API token will need the \`security-policy:read\` permission otherwise
7827
7877
  the request will fail with an authentication error.
@@ -7832,14 +7882,14 @@ const config$k = {
7832
7882
  `
7833
7883
  }
7834
7884
  const cmdOrganizationPolicyPolicy = {
7835
- description: config$k.description,
7836
- hidden: config$k.hidden,
7837
- run: run$k
7885
+ description: config$l.description,
7886
+ hidden: config$l.hidden,
7887
+ run: run$l
7838
7888
  }
7839
- async function run$k(argv, importMeta, { parentName }) {
7889
+ async function run$l(argv, importMeta, { parentName }) {
7840
7890
  const cli = meowOrExit({
7841
7891
  argv,
7842
- config: config$k,
7892
+ config: config$l,
7843
7893
  importMeta,
7844
7894
  parentName
7845
7895
  })
@@ -7876,7 +7926,7 @@ async function run$k(argv, importMeta, { parentName }) {
7876
7926
  return
7877
7927
  }
7878
7928
  if (cli.flags['dryRun']) {
7879
- logger.logger.log(DRY_RUN_BAIL_TEXT$i)
7929
+ logger.logger.log(DRY_RUN_BAIL_TEXT$j)
7880
7930
  return
7881
7931
  }
7882
7932
  await handleSecurityPolicy(
@@ -7962,8 +8012,8 @@ async function handleQuota(outputKind = 'text') {
7962
8012
  await outputQuota(data, outputKind)
7963
8013
  }
7964
8014
 
7965
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$h } = constants
7966
- const config$j = {
8015
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$i } = constants
8016
+ const config$k = {
7967
8017
  commandName: 'quota',
7968
8018
  description: 'List organizations associated with the API key used',
7969
8019
  hidden: true,
@@ -7976,18 +8026,18 @@ const config$j = {
7976
8026
  $ ${command}
7977
8027
 
7978
8028
  Options
7979
- ${getFlagListOutput(config$j.flags, 6)}
8029
+ ${getFlagListOutput(config$k.flags, 6)}
7980
8030
  `
7981
8031
  }
7982
8032
  const cmdOrganizationQuota = {
7983
- description: config$j.description,
7984
- hidden: config$j.hidden,
7985
- run: run$j
8033
+ description: config$k.description,
8034
+ hidden: config$k.hidden,
8035
+ run: run$k
7986
8036
  }
7987
- async function run$j(argv, importMeta, { parentName }) {
8037
+ async function run$k(argv, importMeta, { parentName }) {
7988
8038
  const cli = meowOrExit({
7989
8039
  argv,
7990
- config: config$j,
8040
+ config: config$k,
7991
8041
  importMeta,
7992
8042
  parentName
7993
8043
  })
@@ -8015,7 +8065,7 @@ async function run$j(argv, importMeta, { parentName }) {
8015
8065
  return
8016
8066
  }
8017
8067
  if (cli.flags['dryRun']) {
8018
- logger.logger.log(DRY_RUN_BAIL_TEXT$h)
8068
+ logger.logger.log(DRY_RUN_BAIL_TEXT$i)
8019
8069
  return
8020
8070
  }
8021
8071
  await handleQuota(json ? 'json' : markdown ? 'markdown' : 'text')
@@ -8356,8 +8406,8 @@ function parsePackageSpecifiers(ecosystem, pkgs) {
8356
8406
  }
8357
8407
  }
8358
8408
 
8359
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$g } = constants
8360
- const config$i = {
8409
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$h } = constants
8410
+ const config$j = {
8361
8411
  commandName: 'score',
8362
8412
  description:
8363
8413
  '[beta] Look up score for one package which reflects all of its transitive dependencies as well',
@@ -8400,14 +8450,14 @@ const config$i = {
8400
8450
  `
8401
8451
  }
8402
8452
  const cmdPackageScore = {
8403
- description: config$i.description,
8404
- hidden: config$i.hidden,
8405
- run: run$i
8453
+ description: config$j.description,
8454
+ hidden: config$j.hidden,
8455
+ run: run$j
8406
8456
  }
8407
- async function run$i(argv, importMeta, { parentName }) {
8457
+ async function run$j(argv, importMeta, { parentName }) {
8408
8458
  const cli = meowOrExit({
8409
8459
  argv,
8410
- config: config$i,
8460
+ config: config$j,
8411
8461
  importMeta,
8412
8462
  parentName
8413
8463
  })
@@ -8448,7 +8498,7 @@ async function run$i(argv, importMeta, { parentName }) {
8448
8498
  return
8449
8499
  }
8450
8500
  if (cli.flags['dryRun']) {
8451
- logger.logger.log(DRY_RUN_BAIL_TEXT$g)
8501
+ logger.logger.log(DRY_RUN_BAIL_TEXT$h)
8452
8502
  return
8453
8503
  }
8454
8504
  await handlePurlDeepScore(
@@ -8513,7 +8563,7 @@ function outputPurlsShallowScore(purls, packageData, outputKind) {
8513
8563
  return true // not found
8514
8564
  })
8515
8565
  if (outputKind === 'markdown') {
8516
- logger.logger.log(vendor.stripIndents`
8566
+ logger.logger.log(vendor.html`
8517
8567
  # Shallow Package Report
8518
8568
 
8519
8569
  This report contains the response for requesting data on some package url(s).
@@ -8654,8 +8704,8 @@ async function handlePurlsShallowScore({ outputKind, purls }) {
8654
8704
  outputPurlsShallowScore(purls, packageData.data, outputKind)
8655
8705
  }
8656
8706
 
8657
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$f } = constants
8658
- const config$h = {
8707
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$g } = constants
8708
+ const config$i = {
8659
8709
  commandName: 'shallow',
8660
8710
  description:
8661
8711
  '[beta] Look up info regarding one or more packages but not their transitives',
@@ -8698,21 +8748,21 @@ const config$h = {
8698
8748
  `
8699
8749
  }
8700
8750
  const cmdPackageShallow = {
8701
- description: config$h.description,
8702
- hidden: config$h.hidden,
8751
+ description: config$i.description,
8752
+ hidden: config$i.hidden,
8703
8753
  alias: {
8704
8754
  shallowScore: {
8705
- description: config$h.description,
8755
+ description: config$i.description,
8706
8756
  hidden: true,
8707
8757
  argv: []
8708
8758
  }
8709
8759
  },
8710
- run: run$h
8760
+ run: run$i
8711
8761
  }
8712
- async function run$h(argv, importMeta, { parentName }) {
8762
+ async function run$i(argv, importMeta, { parentName }) {
8713
8763
  const cli = meowOrExit({
8714
8764
  argv,
8715
- config: config$h,
8765
+ config: config$i,
8716
8766
  importMeta,
8717
8767
  parentName
8718
8768
  })
@@ -8745,7 +8795,7 @@ async function run$h(argv, importMeta, { parentName }) {
8745
8795
  return
8746
8796
  }
8747
8797
  if (cli.flags['dryRun']) {
8748
- logger.logger.log(DRY_RUN_BAIL_TEXT$f)
8798
+ logger.logger.log(DRY_RUN_BAIL_TEXT$g)
8749
8799
  return
8750
8800
  }
8751
8801
  await handlePurlsShallowScore({
@@ -8797,8 +8847,8 @@ async function runRawNpm(argv) {
8797
8847
  await spawnPromise
8798
8848
  }
8799
8849
 
8800
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$e, NPM } = constants
8801
- const config$g = {
8850
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$f, NPM } = constants
8851
+ const config$h = {
8802
8852
  commandName: 'raw-npm',
8803
8853
  description: `Temporarily disable the Socket ${NPM} wrapper`,
8804
8854
  hidden: false,
@@ -8812,20 +8862,20 @@ const config$g = {
8812
8862
  `
8813
8863
  }
8814
8864
  const cmdRawNpm = {
8815
- description: config$g.description,
8816
- hidden: config$g.hidden,
8817
- run: run$g
8865
+ description: config$h.description,
8866
+ hidden: config$h.hidden,
8867
+ run: run$h
8818
8868
  }
8819
- async function run$g(argv, importMeta, { parentName }) {
8869
+ async function run$h(argv, importMeta, { parentName }) {
8820
8870
  const cli = meowOrExit({
8821
8871
  allowUnknownFlags: true,
8822
8872
  argv,
8823
- config: config$g,
8873
+ config: config$h,
8824
8874
  importMeta,
8825
8875
  parentName
8826
8876
  })
8827
8877
  if (cli.flags['dryRun']) {
8828
- logger.logger.log(DRY_RUN_BAIL_TEXT$e)
8878
+ logger.logger.log(DRY_RUN_BAIL_TEXT$f)
8829
8879
  return
8830
8880
  }
8831
8881
  await runRawNpm(argv)
@@ -8847,8 +8897,8 @@ async function runRawNpx(argv) {
8847
8897
  await spawnPromise
8848
8898
  }
8849
8899
 
8850
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d, NPX } = constants
8851
- const config$f = {
8900
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$e, NPX } = constants
8901
+ const config$g = {
8852
8902
  commandName: 'raw-npx',
8853
8903
  description: `Temporarily disable the Socket ${NPX} wrapper`,
8854
8904
  hidden: false,
@@ -8862,26 +8912,26 @@ const config$f = {
8862
8912
  `
8863
8913
  }
8864
8914
  const cmdRawNpx = {
8865
- description: config$f.description,
8866
- hidden: config$f.hidden,
8867
- run: run$f
8915
+ description: config$g.description,
8916
+ hidden: config$g.hidden,
8917
+ run: run$g
8868
8918
  }
8869
- async function run$f(argv, importMeta, { parentName }) {
8919
+ async function run$g(argv, importMeta, { parentName }) {
8870
8920
  const cli = meowOrExit({
8871
8921
  allowUnknownFlags: true,
8872
8922
  argv,
8873
- config: config$f,
8923
+ config: config$g,
8874
8924
  importMeta,
8875
8925
  parentName
8876
8926
  })
8877
8927
  if (cli.flags['dryRun']) {
8878
- logger.logger.log(DRY_RUN_BAIL_TEXT$d)
8928
+ logger.logger.log(DRY_RUN_BAIL_TEXT$e)
8879
8929
  return
8880
8930
  }
8881
8931
  await runRawNpx(argv)
8882
8932
  }
8883
8933
 
8884
- const config$e = {
8934
+ const config$f = {
8885
8935
  commandName: 'create',
8886
8936
  description: '[Deprecated] Create a project report',
8887
8937
  hidden: false,
@@ -8895,14 +8945,14 @@ const config$e = {
8895
8945
  `
8896
8946
  }
8897
8947
  const cmdReportCreate = {
8898
- description: config$e.description,
8899
- hidden: config$e.hidden,
8900
- run: run$e
8948
+ description: config$f.description,
8949
+ hidden: config$f.hidden,
8950
+ run: run$f
8901
8951
  }
8902
- async function run$e(argv, importMeta, { parentName }) {
8952
+ async function run$f(argv, importMeta, { parentName }) {
8903
8953
  meowOrExit({
8904
8954
  argv,
8905
- config: config$e,
8955
+ config: config$f,
8906
8956
  importMeta,
8907
8957
  parentName
8908
8958
  })
@@ -8912,7 +8962,7 @@ async function run$e(argv, importMeta, { parentName }) {
8912
8962
  process.exitCode = 1
8913
8963
  }
8914
8964
 
8915
- const config$d = {
8965
+ const config$e = {
8916
8966
  commandName: 'view',
8917
8967
  description: '[Deprecated] View a project report',
8918
8968
  hidden: false,
@@ -8926,14 +8976,14 @@ const config$d = {
8926
8976
  `
8927
8977
  }
8928
8978
  const cmdReportView = {
8929
- description: config$d.description,
8930
- hidden: config$d.hidden,
8931
- run: run$d
8979
+ description: config$e.description,
8980
+ hidden: config$e.hidden,
8981
+ run: run$e
8932
8982
  }
8933
- async function run$d(argv, importMeta, { parentName }) {
8983
+ async function run$e(argv, importMeta, { parentName }) {
8934
8984
  meowOrExit({
8935
8985
  argv,
8936
- config: config$d,
8986
+ config: config$e,
8937
8987
  importMeta,
8938
8988
  parentName
8939
8989
  })
@@ -9020,8 +9070,8 @@ async function handleCreateRepo({
9020
9070
  await outputCreateRepo()
9021
9071
  }
9022
9072
 
9023
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$c } = constants
9024
- const config$c = {
9073
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d } = constants
9074
+ const config$d = {
9025
9075
  commandName: 'create',
9026
9076
  description: 'Create a repository in an organization',
9027
9077
  hidden: false,
@@ -9074,14 +9124,14 @@ const config$c = {
9074
9124
  `
9075
9125
  }
9076
9126
  const cmdReposCreate = {
9077
- description: config$c.description,
9078
- hidden: config$c.hidden,
9079
- run: run$c
9127
+ description: config$d.description,
9128
+ hidden: config$d.hidden,
9129
+ run: run$d
9080
9130
  }
9081
- async function run$c(argv, importMeta, { parentName }) {
9131
+ async function run$d(argv, importMeta, { parentName }) {
9082
9132
  const cli = meowOrExit({
9083
9133
  argv,
9084
- config: config$c,
9134
+ config: config$d,
9085
9135
  importMeta,
9086
9136
  parentName
9087
9137
  })
@@ -9116,7 +9166,7 @@ async function run$c(argv, importMeta, { parentName }) {
9116
9166
  return
9117
9167
  }
9118
9168
  if (cli.flags['dryRun']) {
9119
- logger.logger.log(DRY_RUN_BAIL_TEXT$c)
9169
+ logger.logger.log(DRY_RUN_BAIL_TEXT$d)
9120
9170
  return
9121
9171
  }
9122
9172
  await handleCreateRepo({
@@ -9145,8 +9195,8 @@ async function handleDeleteRepo(orgSlug, repoName) {
9145
9195
  spinner.successAndStop('Repository deleted successfully')
9146
9196
  }
9147
9197
 
9148
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$b } = constants
9149
- const config$b = {
9198
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$c } = constants
9199
+ const config$c = {
9150
9200
  commandName: 'del',
9151
9201
  description: 'Delete a repository in an organization',
9152
9202
  hidden: false,
@@ -9169,14 +9219,14 @@ const config$b = {
9169
9219
  `
9170
9220
  }
9171
9221
  const cmdReposDel = {
9172
- description: config$b.description,
9173
- hidden: config$b.hidden,
9174
- run: run$b
9222
+ description: config$c.description,
9223
+ hidden: config$c.hidden,
9224
+ run: run$c
9175
9225
  }
9176
- async function run$b(argv, importMeta, { parentName }) {
9226
+ async function run$c(argv, importMeta, { parentName }) {
9177
9227
  const cli = meowOrExit({
9178
9228
  argv,
9179
- config: config$b,
9229
+ config: config$c,
9180
9230
  importMeta,
9181
9231
  parentName
9182
9232
  })
@@ -9211,7 +9261,7 @@ async function run$b(argv, importMeta, { parentName }) {
9211
9261
  return
9212
9262
  }
9213
9263
  if (cli.flags['dryRun']) {
9214
- logger.logger.log(DRY_RUN_BAIL_TEXT$b)
9264
+ logger.logger.log(DRY_RUN_BAIL_TEXT$c)
9215
9265
  return
9216
9266
  }
9217
9267
  await handleDeleteRepo(orgSlug, repoName)
@@ -9300,8 +9350,8 @@ async function handleListRepos({
9300
9350
  await outputListRepos(data, outputKind)
9301
9351
  }
9302
9352
 
9303
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$a } = constants
9304
- const config$a = {
9353
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$b } = constants
9354
+ const config$b = {
9305
9355
  commandName: 'list',
9306
9356
  description: 'List repositories in an organization',
9307
9357
  hidden: false,
@@ -9348,14 +9398,14 @@ const config$a = {
9348
9398
  `
9349
9399
  }
9350
9400
  const cmdReposList = {
9351
- description: config$a.description,
9352
- hidden: config$a.hidden,
9353
- run: run$a
9401
+ description: config$b.description,
9402
+ hidden: config$b.hidden,
9403
+ run: run$b
9354
9404
  }
9355
- async function run$a(argv, importMeta, { parentName }) {
9405
+ async function run$b(argv, importMeta, { parentName }) {
9356
9406
  const cli = meowOrExit({
9357
9407
  argv,
9358
- config: config$a,
9408
+ config: config$b,
9359
9409
  importMeta,
9360
9410
  parentName
9361
9411
  })
@@ -9392,7 +9442,7 @@ async function run$a(argv, importMeta, { parentName }) {
9392
9442
  return
9393
9443
  }
9394
9444
  if (cli.flags['dryRun']) {
9395
- logger.logger.log(DRY_RUN_BAIL_TEXT$a)
9445
+ logger.logger.log(DRY_RUN_BAIL_TEXT$b)
9396
9446
  return
9397
9447
  }
9398
9448
  await handleListRepos({
@@ -9462,8 +9512,8 @@ async function handleUpdateRepo({
9462
9512
  await outputUpdateRepo()
9463
9513
  }
9464
9514
 
9465
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$9 } = constants
9466
- const config$9 = {
9515
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$a } = constants
9516
+ const config$a = {
9467
9517
  commandName: 'update',
9468
9518
  description: 'Update a repository in an organization',
9469
9519
  hidden: false,
@@ -9516,14 +9566,14 @@ const config$9 = {
9516
9566
  `
9517
9567
  }
9518
9568
  const cmdReposUpdate = {
9519
- description: config$9.description,
9520
- hidden: config$9.hidden,
9521
- run: run$9
9569
+ description: config$a.description,
9570
+ hidden: config$a.hidden,
9571
+ run: run$a
9522
9572
  }
9523
- async function run$9(argv, importMeta, { parentName }) {
9573
+ async function run$a(argv, importMeta, { parentName }) {
9524
9574
  const cli = meowOrExit({
9525
9575
  argv,
9526
- config: config$9,
9576
+ config: config$a,
9527
9577
  importMeta,
9528
9578
  parentName
9529
9579
  })
@@ -9558,7 +9608,7 @@ async function run$9(argv, importMeta, { parentName }) {
9558
9608
  return
9559
9609
  }
9560
9610
  if (cli.flags['dryRun']) {
9561
- logger.logger.log(DRY_RUN_BAIL_TEXT$9)
9611
+ logger.logger.log(DRY_RUN_BAIL_TEXT$a)
9562
9612
  return
9563
9613
  }
9564
9614
  await handleUpdateRepo({
@@ -9660,8 +9710,8 @@ async function handleViewRepo(orgSlug, repoName, outputKind) {
9660
9710
  await outputViewRepo(data, outputKind)
9661
9711
  }
9662
9712
 
9663
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$8 } = constants
9664
- const config$8 = {
9713
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$9 } = constants
9714
+ const config$9 = {
9665
9715
  commandName: 'view',
9666
9716
  description: 'View repositories in an organization',
9667
9717
  hidden: false,
@@ -9690,14 +9740,14 @@ const config$8 = {
9690
9740
  `
9691
9741
  }
9692
9742
  const cmdReposView = {
9693
- description: config$8.description,
9694
- hidden: config$8.hidden,
9695
- run: run$8
9743
+ description: config$9.description,
9744
+ hidden: config$9.hidden,
9745
+ run: run$9
9696
9746
  }
9697
- async function run$8(argv, importMeta, { parentName }) {
9747
+ async function run$9(argv, importMeta, { parentName }) {
9698
9748
  const cli = meowOrExit({
9699
9749
  argv,
9700
- config: config$8,
9750
+ config: config$9,
9701
9751
  importMeta,
9702
9752
  parentName
9703
9753
  })
@@ -9740,7 +9790,7 @@ async function run$8(argv, importMeta, { parentName }) {
9740
9790
  return
9741
9791
  }
9742
9792
  if (cli.flags['dryRun']) {
9743
- logger.logger.log(DRY_RUN_BAIL_TEXT$8)
9793
+ logger.logger.log(DRY_RUN_BAIL_TEXT$9)
9744
9794
  return
9745
9795
  }
9746
9796
  await handleViewRepo(
@@ -9835,8 +9885,8 @@ async function suggestTarget() {
9835
9885
  }
9836
9886
  }
9837
9887
 
9838
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$7 } = constants
9839
- const config$7 = {
9888
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$8 } = constants
9889
+ const config$8 = {
9840
9890
  commandName: 'create',
9841
9891
  description: 'Create a scan',
9842
9892
  hidden: false,
@@ -9942,6 +9992,9 @@ const config$7 = {
9942
9992
  When a FILE is given only that FILE is targeted. Otherwise any eligible
9943
9993
  files in the given DIR will be considered.
9944
9994
 
9995
+ The --repo and --branch flags tell Socket to associate this Scan with that
9996
+ repo/branch. The names will show up on your dashboard on the Socket website.
9997
+
9945
9998
  Note: for a first run you probably want to set --defaultBranch to indicate
9946
9999
  the default branch name, like "main" or "master".
9947
10000
 
@@ -9956,14 +10009,14 @@ const config$7 = {
9956
10009
  `
9957
10010
  }
9958
10011
  const cmdScanCreate = {
9959
- description: config$7.description,
9960
- hidden: config$7.hidden,
9961
- run: run$7
10012
+ description: config$8.description,
10013
+ hidden: config$8.hidden,
10014
+ run: run$8
9962
10015
  }
9963
- async function run$7(argv, importMeta, { parentName }) {
10016
+ async function run$8(argv, importMeta, { parentName }) {
9964
10017
  const cli = meowOrExit({
9965
10018
  argv,
9966
- config: config$7,
10019
+ config: config$8,
9967
10020
  importMeta,
9968
10021
  parentName
9969
10022
  })
@@ -10015,154 +10068,484 @@ async function run$7(argv, importMeta, { parentName }) {
10015
10068
  if (suggestion) {
10016
10069
  orgSlug = suggestion
10017
10070
  }
10018
- updatedInput = true
10071
+ updatedInput = true
10072
+ }
10073
+ }
10074
+ if (updatedInput && orgSlug && targets?.length) {
10075
+ logger.logger.error(
10076
+ 'Note: You can invoke this command next time to skip the interactive questions:'
10077
+ )
10078
+ logger.logger.error('```')
10079
+ logger.logger.error(
10080
+ ` socket scan create [other flags...] ${defaultOrgSlug ? '' : orgSlug} ${targets.join(' ')}`
10081
+ )
10082
+ logger.logger.error('```\n')
10083
+ }
10084
+ const wasBadInput = handleBadInput(
10085
+ {
10086
+ nook: !!defaultOrgSlug,
10087
+ test: !!orgSlug && orgSlug !== '.',
10088
+ message: 'Org name as the first argument',
10089
+ pass: 'ok',
10090
+ fail:
10091
+ orgSlug === '.'
10092
+ ? 'dot is an invalid org, most likely you forgot the org name here?'
10093
+ : 'missing'
10094
+ },
10095
+ {
10096
+ test: !!targets.length,
10097
+ message: 'At least one TARGET (e.g. `.` or `./package.json`)',
10098
+ pass: 'ok',
10099
+ fail: 'missing (or perhaps you forgot the org slug?)'
10100
+ },
10101
+ {
10102
+ nook: true,
10103
+ test: !json || !markdown,
10104
+ message: 'The json and markdown flags cannot be both set, pick one',
10105
+ pass: 'ok',
10106
+ fail: 'omit one'
10107
+ },
10108
+ {
10109
+ nook: true,
10110
+ test: !!apiToken,
10111
+ message: 'This command requires an API token for access',
10112
+ pass: 'ok',
10113
+ fail: 'missing (try `socket login`)'
10114
+ },
10115
+ {
10116
+ nook: true,
10117
+ test: !pendingHead || !tmp,
10118
+ message: 'Can not use --pendingHead and --tmp at the same time',
10119
+ pass: 'ok',
10120
+ fail: 'remove at least one flag'
10121
+ },
10122
+ {
10123
+ nook: true,
10124
+ test: !pendingHead || !!branchName,
10125
+ message: 'When --pendingHead is set, --branch is mandatory',
10126
+ pass: 'ok',
10127
+ fail: 'missing branch name'
10128
+ },
10129
+ {
10130
+ nook: true,
10131
+ test: !defaultBranch || !!branchName,
10132
+ message: 'When --defaultBranch is set, --branch is mandatory',
10133
+ pass: 'ok',
10134
+ fail: 'missing branch name'
10135
+ }
10136
+ )
10137
+ if (wasBadInput) {
10138
+ return
10139
+ }
10140
+
10141
+ // Note exiting earlier to skirt a hidden auth requirement
10142
+ if (dryRun) {
10143
+ logger.logger.log(DRY_RUN_BAIL_TEXT$8)
10144
+ return
10145
+ }
10146
+ await handleCreateNewScan({
10147
+ branchName: branchName,
10148
+ commitHash: (commitHash && String(commitHash)) || '',
10149
+ commitMessage: (commitMessage && String(commitMessage)) || '',
10150
+ committers: (committers && String(committers)) || '',
10151
+ cwd,
10152
+ defaultBranch: Boolean(defaultBranch),
10153
+ orgSlug,
10154
+ outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
10155
+ pendingHead: Boolean(pendingHead),
10156
+ pullRequest: Number(pullRequest),
10157
+ readOnly: Boolean(readOnly),
10158
+ repoName: repoName,
10159
+ report,
10160
+ targets,
10161
+ tmp: Boolean(tmp)
10162
+ })
10163
+ }
10164
+
10165
+ async function fetchDeleteOrgFullScan(orgSlug, scanId) {
10166
+ const sockSdk = await shadowNpmInject.setupSdk()
10167
+
10168
+ // Lazily access constants.spinner.
10169
+ const { spinner } = constants
10170
+ spinner.start('Requesting the scan to be deleted...')
10171
+ const result = await handleApiCall(
10172
+ sockSdk.deleteOrgFullScan(orgSlug, scanId),
10173
+ 'Deleting scan'
10174
+ )
10175
+ spinner.successAndStop('Received response for deleting a scan.')
10176
+ if (!result.success) {
10177
+ handleUnsuccessfulApiResponse('deleteOrgFullScan', result)
10178
+ }
10179
+ return result.data
10180
+ }
10181
+
10182
+ async function outputDeleteScan(_data) {
10183
+ logger.logger.success('Scan deleted successfully')
10184
+ }
10185
+
10186
+ async function handleDeleteScan(orgSlug, scanId) {
10187
+ const data = await fetchDeleteOrgFullScan(orgSlug, scanId)
10188
+ if (!data) {
10189
+ return
10190
+ }
10191
+ await outputDeleteScan()
10192
+ }
10193
+
10194
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$7 } = constants
10195
+ const config$7 = {
10196
+ commandName: 'del',
10197
+ description: 'Delete a scan',
10198
+ hidden: false,
10199
+ flags: {
10200
+ ...commonFlags,
10201
+ ...outputFlags
10202
+ },
10203
+ help: (command, config) => `
10204
+ Usage
10205
+ $ ${command} <org slug> <scan ID>
10206
+
10207
+ API Token Requirements
10208
+ - Quota: 1 unit
10209
+ - Permissions: full-scans:delete
10210
+
10211
+ Options
10212
+ ${getFlagListOutput(config.flags, 6)}
10213
+
10214
+ Examples
10215
+ $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
10216
+ `
10217
+ }
10218
+ const cmdScanDel = {
10219
+ description: config$7.description,
10220
+ hidden: config$7.hidden,
10221
+ run: run$7
10222
+ }
10223
+ async function run$7(argv, importMeta, { parentName }) {
10224
+ const cli = meowOrExit({
10225
+ argv,
10226
+ config: config$7,
10227
+ importMeta,
10228
+ parentName
10229
+ })
10230
+ const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10231
+ const orgSlug = defaultOrgSlug || cli.input[0] || ''
10232
+ const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
10233
+ const apiToken = shadowNpmInject.getDefaultToken()
10234
+ const wasBadInput = handleBadInput(
10235
+ {
10236
+ nook: !!defaultOrgSlug,
10237
+ test: !!orgSlug && orgSlug !== '.',
10238
+ message: 'Org name as the first argument',
10239
+ pass: 'ok',
10240
+ fail:
10241
+ orgSlug === '.'
10242
+ ? 'dot is an invalid org, most likely you forgot the org name here?'
10243
+ : 'missing'
10244
+ },
10245
+ {
10246
+ test: !!scanId,
10247
+ message: 'Scan ID to delete',
10248
+ pass: 'ok',
10249
+ fail: 'missing'
10250
+ },
10251
+ {
10252
+ nook: true,
10253
+ test: !!apiToken,
10254
+ message:
10255
+ 'You need to be logged in to use this command. See `socket login`.',
10256
+ pass: 'ok',
10257
+ fail: 'missing API token'
10258
+ }
10259
+ )
10260
+ if (wasBadInput) {
10261
+ return
10262
+ }
10263
+ if (cli.flags['dryRun']) {
10264
+ logger.logger.log(DRY_RUN_BAIL_TEXT$7)
10265
+ return
10266
+ }
10267
+ await handleDeleteScan(orgSlug, scanId)
10268
+ }
10269
+
10270
+ async function fetchDiffScan({ id1, id2, orgSlug }) {
10271
+ const apiToken = shadowNpmInject.getDefaultToken()
10272
+
10273
+ // Lazily access constants.spinner.
10274
+ const { spinner } = constants
10275
+ logger.logger.error('Scan ID 1:', id1)
10276
+ logger.logger.error('Scan ID 2:', id2)
10277
+ spinner.start('Fetching scan diff... (this may take a while)')
10278
+ const response = await queryApi(
10279
+ `orgs/${orgSlug}/full-scans/diff?before=${encodeURIComponent(id1)}&after=${encodeURIComponent(id2)}`,
10280
+ apiToken || ''
10281
+ )
10282
+ spinner.successAndStop('Received scan diff response')
10283
+ if (!response.ok) {
10284
+ const err = await handleApiError(response.status)
10285
+ logger.logger.fail(failMsgWithBadge(response.statusText, err))
10286
+ return
10287
+ }
10288
+ const result = await handleApiCall(
10289
+ await response.json(),
10290
+ 'Deserializing json'
10291
+ )
10292
+ return result
10293
+ }
10294
+
10295
+ const SOCKET_SBOM_URL_PREFIX$1 =
10296
+ 'https://socket.dev/dashboard/org/SocketDev/sbom/'
10297
+ async function outputDiffScan(result, { depth, file, outputKind }) {
10298
+ const dashboardUrl = result.diff_report_url
10299
+ const dashboardMessage = dashboardUrl
10300
+ ? `\n View this diff scan in the Socket dashboard: ${vendor.yoctocolorsCjsExports.cyan(dashboardUrl)}`
10301
+ : ''
10302
+
10303
+ // When forcing json, or dumping to file, serialize to string such that it
10304
+ // won't get truncated. The only way to dump the full raw JSON to stdout is
10305
+ // to use `--json --file -` (the dash is a standard notation for stdout)
10306
+ if (outputKind === 'json' || file) {
10307
+ let json
10308
+ try {
10309
+ json = JSON.stringify(result, null, 2)
10310
+ } catch (e) {
10311
+ process.exitCode = 1
10312
+ // Most likely caused by a circular reference (or OOM)
10313
+ logger.logger.fail('There was a problem converting the data to JSON')
10314
+ logger.logger.error(e)
10315
+ return
10316
+ }
10317
+ if (file && file !== '-') {
10318
+ logger.logger.log(`Writing json to \`${file}\``)
10319
+ fs$1.writeFile(file, JSON.stringify(result, null, 2), err => {
10320
+ if (err) {
10321
+ logger.logger.fail(`Writing to \`${file}\` failed...`)
10322
+ logger.logger.error(err)
10323
+ } else {
10324
+ logger.logger.log(`Data successfully written to \`${file}\``)
10325
+ }
10326
+ logger.logger.error(dashboardMessage)
10327
+ })
10328
+ } else {
10329
+ // TODO: expose different method for writing to stderr when simply dodging stdout
10330
+ logger.logger.error(`\n Diff scan result: \n`)
10331
+ logger.logger.log(json)
10332
+ logger.logger.error(dashboardMessage)
10333
+ }
10334
+ return
10335
+ }
10336
+ if (outputKind === 'markdown') {
10337
+ logger.logger.log('# Scan diff result')
10338
+ logger.logger.log('')
10339
+ logger.logger.log(
10340
+ 'This Socket.dev report shows the changes between two scans:'
10341
+ )
10342
+ logger.logger.log(
10343
+ `- [${result.before.id}](${SOCKET_SBOM_URL_PREFIX$1}${result.before.id})`
10344
+ )
10345
+ logger.logger.log(
10346
+ `- [${result.after.id}](${SOCKET_SBOM_URL_PREFIX$1}${result.after.id})`
10347
+ )
10348
+ logger.logger.log('')
10349
+ logger.logger.log(
10350
+ `You can [view this report in your dashboard](${result.diff_report_url})`
10351
+ )
10352
+ logger.logger.log('')
10353
+ logger.logger.log('## Changes')
10354
+ logger.logger.log('')
10355
+ logger.logger.log(
10356
+ `- directDependenciesChanged: ${result.directDependenciesChanged}`
10357
+ )
10358
+ logger.logger.log(`- Added packages: ${result.artifacts.added.length}`)
10359
+ if (result.artifacts.added.length > 0) {
10360
+ result.artifacts.added.slice(0, 10).forEach(artifact => {
10361
+ logger.logger.log(
10362
+ ` - ${artifact.type} ${artifact.name}@${artifact.version}`
10363
+ )
10364
+ })
10365
+ if (result.artifacts.added.length > 10) {
10366
+ logger.logger.log(
10367
+ ` ... and ${result.artifacts.added.length - 10} more`
10368
+ )
10369
+ }
10370
+ }
10371
+ logger.logger.log(`- Removed packages: ${result.artifacts.removed.length}`)
10372
+ if (result.artifacts.removed.length > 0) {
10373
+ result.artifacts.removed.slice(0, 10).forEach(artifact => {
10374
+ logger.logger.log(
10375
+ ` - ${artifact.type} ${artifact.name}@${artifact.version}`
10376
+ )
10377
+ })
10378
+ if (result.artifacts.removed.length > 10) {
10379
+ logger.logger.log(
10380
+ ` ... and ${result.artifacts.removed.length - 10} more`
10381
+ )
10382
+ }
10383
+ }
10384
+ logger.logger.log(
10385
+ `- Replaced packages: ${result.artifacts.replaced.length}`
10386
+ )
10387
+ if (result.artifacts.replaced.length > 0) {
10388
+ result.artifacts.replaced.slice(0, 10).forEach(artifact => {
10389
+ logger.logger.log(
10390
+ ` - ${artifact.type} ${artifact.name}@${artifact.version}`
10391
+ )
10392
+ })
10393
+ if (result.artifacts.replaced.length > 10) {
10394
+ logger.logger.log(
10395
+ ` ... and ${result.artifacts.replaced.length - 10} more`
10396
+ )
10397
+ }
10398
+ }
10399
+ logger.logger.log(`- Updated packages: ${result.artifacts.updated.length}`)
10400
+ if (result.artifacts.updated.length > 0) {
10401
+ result.artifacts.updated.slice(0, 10).forEach(artifact => {
10402
+ logger.logger.log(
10403
+ ` - ${artifact.type} ${artifact.name}@${artifact.version}`
10404
+ )
10405
+ })
10406
+ if (result.artifacts.updated.length > 10) {
10407
+ logger.logger.log(
10408
+ ` ... and ${result.artifacts.updated.length - 10} more`
10409
+ )
10410
+ }
10411
+ }
10412
+ logger.logger.log(
10413
+ `- Unchanged packages: ${result.artifacts.unchanged.length}`
10414
+ )
10415
+ if (result.artifacts.unchanged.length > 0) {
10416
+ result.artifacts.unchanged.slice(0, 10).forEach(artifact => {
10417
+ logger.logger.log(
10418
+ ` - ${artifact.type} ${artifact.name}@${artifact.version}`
10419
+ )
10420
+ })
10421
+ if (result.artifacts.unchanged.length > 10) {
10422
+ logger.logger.log(
10423
+ ` ... and ${result.artifacts.unchanged.length - 10} more`
10424
+ )
10425
+ }
10019
10426
  }
10020
- }
10021
- if (updatedInput && orgSlug && targets?.length) {
10022
- logger.logger.error(
10023
- 'Note: You can invoke this command next time to skip the interactive questions:'
10427
+ logger.logger.log('')
10428
+ logger.logger.log(`## Scan ${result.before.id}`)
10429
+ logger.logger.log('')
10430
+ logger.logger.log(
10431
+ 'This Scan was considered to be the "base" / "from" / "before" Scan.'
10024
10432
  )
10025
- logger.logger.error('```')
10026
- logger.logger.error(
10027
- ` socket scan create [other flags...] ${defaultOrgSlug ? '' : orgSlug} ${targets.join(' ')}`
10433
+ logger.logger.log('')
10434
+ for (const [key, value] of Object.entries(result.before)) {
10435
+ if (key === 'pull_request' && !value) {
10436
+ continue
10437
+ }
10438
+ if (!['id', 'organization_id', 'repository_id'].includes(key)) {
10439
+ logger.logger.group(
10440
+ `- ${key === 'repository_slug' ? 'repo' : key === 'organization_slug' ? 'org' : key}: ${value}`
10441
+ )
10442
+ logger.logger.groupEnd()
10443
+ }
10444
+ }
10445
+ logger.logger.log('')
10446
+ logger.logger.log(`## Scan ${result.after.id}`)
10447
+ logger.logger.log('')
10448
+ logger.logger.log(
10449
+ 'This Scan was considered to be the "head" / "to" / "after" Scan.'
10028
10450
  )
10029
- logger.logger.error('```\n')
10030
- }
10031
- const wasBadInput = handleBadInput(
10032
- {
10033
- nook: !!defaultOrgSlug,
10034
- test: !!orgSlug && orgSlug !== '.',
10035
- message: 'Org name as the first argument',
10036
- pass: 'ok',
10037
- fail:
10038
- orgSlug === '.'
10039
- ? 'dot is an invalid org, most likely you forgot the org name here?'
10040
- : 'missing'
10041
- },
10042
- {
10043
- test: !!targets.length,
10044
- message: 'At least one TARGET (e.g. `.` or `./package.json`)',
10045
- pass: 'ok',
10046
- fail: 'missing (or perhaps you forgot the org slug?)'
10047
- },
10048
- {
10049
- nook: true,
10050
- test: !json || !markdown,
10051
- message: 'The json and markdown flags cannot be both set, pick one',
10052
- pass: 'ok',
10053
- fail: 'omit one'
10054
- },
10055
- {
10056
- nook: true,
10057
- test: !!apiToken,
10058
- message: 'This command requires an API token for access',
10059
- pass: 'ok',
10060
- fail: 'missing (try `socket login`)'
10061
- },
10062
- {
10063
- nook: true,
10064
- test: !pendingHead || !tmp,
10065
- message: 'Can not use --pendingHead and --tmp at the same time',
10066
- pass: 'ok',
10067
- fail: 'remove at least one flag'
10068
- },
10069
- {
10070
- nook: true,
10071
- test: !pendingHead || !!branchName,
10072
- message: 'When --pendingHead is set, --branch is mandatory',
10073
- pass: 'ok',
10074
- fail: 'missing branch name'
10075
- },
10076
- {
10077
- nook: true,
10078
- test: !defaultBranch || !!branchName,
10079
- message: 'When --defaultBranch is set, --branch is mandatory',
10080
- pass: 'ok',
10081
- fail: 'missing branch name'
10451
+ logger.logger.log('')
10452
+ for (const [key, value] of Object.entries(result.after)) {
10453
+ if (key === 'pull_request' && !value) {
10454
+ continue
10455
+ }
10456
+ if (!['id', 'organization_id', 'repository_id'].includes(key)) {
10457
+ logger.logger.group(
10458
+ `- ${key === 'repository_slug' ? 'repo' : key === 'organization_slug' ? 'org' : key}: ${value}`
10459
+ )
10460
+ logger.logger.groupEnd()
10461
+ }
10082
10462
  }
10083
- )
10084
- if (wasBadInput) {
10085
- return
10086
- }
10087
-
10088
- // Note exiting earlier to skirt a hidden auth requirement
10089
- if (dryRun) {
10090
- logger.logger.log(DRY_RUN_BAIL_TEXT$7)
10463
+ logger.logger.log('')
10091
10464
  return
10092
10465
  }
10093
- await handleCreateNewScan({
10094
- branchName: branchName,
10095
- commitHash: (commitHash && String(commitHash)) || '',
10096
- commitMessage: (commitMessage && String(commitMessage)) || '',
10097
- committers: (committers && String(committers)) || '',
10098
- cwd,
10099
- defaultBranch: Boolean(defaultBranch),
10100
- orgSlug,
10101
- outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
10102
- pendingHead: Boolean(pendingHead),
10103
- pullRequest: Number(pullRequest),
10104
- readOnly: Boolean(readOnly),
10105
- repoName: repoName,
10106
- report,
10107
- targets,
10108
- tmp: Boolean(tmp)
10109
- })
10110
- }
10111
10466
 
10112
- async function fetchDeleteOrgFullScan(orgSlug, scanId) {
10113
- const sockSdk = await shadowNpmInject.setupSdk()
10467
+ // In this case neither the --json nor the --file flag was passed
10468
+ // Dump the JSON to CLI and let NodeJS deal with truncation
10114
10469
 
10115
- // Lazily access constants.spinner.
10116
- const { spinner } = constants
10117
- spinner.start('Requesting the scan to be deleted...')
10118
- const result = await handleApiCall(
10119
- sockSdk.deleteOrgFullScan(orgSlug, scanId),
10120
- 'Deleting scan'
10470
+ logger.logger.log('Diff scan result:')
10471
+ logger.logger.log(
10472
+ require$$0.inspect(result, {
10473
+ showHidden: false,
10474
+ depth: depth > 0 ? depth : null,
10475
+ colors: true,
10476
+ maxArrayLength: null
10477
+ })
10121
10478
  )
10122
- spinner.successAndStop('Received response for deleting a scan.')
10123
- if (!result.success) {
10124
- handleUnsuccessfulApiResponse('deleteOrgFullScan', result)
10125
- }
10126
- return result.data
10127
- }
10128
-
10129
- async function outputDeleteScan(_data) {
10130
- logger.logger.success('Scan deleted successfully')
10479
+ logger.logger.error(
10480
+ `\n 📝 To display the detailed report in the terminal, use the --json flag. For a friendlier report, use the --markdown flag.\n`
10481
+ )
10482
+ logger.logger.log(dashboardMessage)
10131
10483
  }
10132
10484
 
10133
- async function handleDeleteScan(orgSlug, scanId) {
10134
- const data = await fetchDeleteOrgFullScan(orgSlug, scanId)
10485
+ async function handleDiffScan({ depth, file, id1, id2, orgSlug, outputKind }) {
10486
+ const data = await fetchDiffScan({
10487
+ id1,
10488
+ id2,
10489
+ orgSlug
10490
+ })
10135
10491
  if (!data) {
10136
10492
  return
10137
10493
  }
10138
- await outputDeleteScan()
10494
+ await outputDiffScan(data, {
10495
+ depth,
10496
+ file,
10497
+ outputKind
10498
+ })
10139
10499
  }
10140
10500
 
10141
10501
  const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$6 } = constants
10502
+ const SOCKET_SBOM_URL_PREFIX =
10503
+ 'https://socket.dev/dashboard/org/SocketDev/sbom/'
10142
10504
  const config$6 = {
10143
- commandName: 'del',
10144
- description: 'Delete a scan',
10505
+ commandName: 'diff',
10506
+ description: 'See what changed between two Scans',
10145
10507
  hidden: false,
10146
10508
  flags: {
10147
10509
  ...commonFlags,
10148
- ...outputFlags
10510
+ ...outputFlags,
10511
+ depth: {
10512
+ type: 'number',
10513
+ default: 2,
10514
+ description:
10515
+ 'Max depth of JSON to display before truncating, use zero for no limit (without --json/--file)'
10516
+ },
10517
+ file: {
10518
+ type: 'string',
10519
+ shortFlag: 'f',
10520
+ default: '',
10521
+ description:
10522
+ 'Path to a local file where the output should be saved. Use `-` to force stdout.'
10523
+ }
10149
10524
  },
10150
10525
  help: (command, config) => `
10151
10526
  Usage
10152
- $ ${command} <org slug> <scan ID>
10527
+ $ ${command} <org slug> <ID1> <ID2>
10153
10528
 
10154
10529
  API Token Requirements
10155
10530
  - Quota: 1 unit
10156
- - Permissions: full-scans:delete
10531
+ - Permissions: full-scans:list
10532
+
10533
+ This command displays the package changes between two scans. The full output
10534
+ can be pretty large depending on the size of your repo and time range. It is
10535
+ best stored to disk (with --json) to be further analyzed by other tools.
10536
+
10537
+ Note: First Scan ID is assumed to be the older ID. This is only relevant for
10538
+ the added/removed list (similar to diffing two files with git).
10157
10539
 
10158
10540
  Options
10159
10541
  ${getFlagListOutput(config.flags, 6)}
10160
10542
 
10161
10543
  Examples
10162
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
10544
+ $ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
10545
+ $ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1 --json
10163
10546
  `
10164
10547
  }
10165
- const cmdScanDel = {
10548
+ const cmdScanDiff = {
10166
10549
  description: config$6.description,
10167
10550
  hidden: config$6.hidden,
10168
10551
  run: run$6
@@ -10174,27 +10557,46 @@ async function run$6(argv, importMeta, { parentName }) {
10174
10557
  importMeta,
10175
10558
  parentName
10176
10559
  })
10560
+ const { depth, file, json, markdown } = cli.flags
10177
10561
  const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10178
10562
  const orgSlug = defaultOrgSlug || cli.input[0] || ''
10179
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
10563
+ let id1 = cli.input[defaultOrgSlug ? 0 : 1] || ''
10564
+ let id2 = cli.input[defaultOrgSlug ? 1 : 2] || ''
10565
+ if (id1.startsWith(SOCKET_SBOM_URL_PREFIX)) {
10566
+ id1 = id1.slice(SOCKET_SBOM_URL_PREFIX.length)
10567
+ }
10568
+ if (id2.startsWith(SOCKET_SBOM_URL_PREFIX)) {
10569
+ id2 = id2.slice(SOCKET_SBOM_URL_PREFIX.length)
10570
+ }
10180
10571
  const apiToken = shadowNpmInject.getDefaultToken()
10181
10572
  const wasBadInput = handleBadInput(
10182
10573
  {
10183
- nook: !!defaultOrgSlug,
10184
- test: !!orgSlug && orgSlug !== '.',
10185
- message: 'Org name as the first argument',
10574
+ test: !!(id1 && id2),
10575
+ message:
10576
+ 'Specify two Scan IDs.\nA Scan ID looks like `aaa0aa0a-aaaa-0000-0a0a-0000000a00a0`.',
10186
10577
  pass: 'ok',
10187
10578
  fail:
10188
- orgSlug === '.'
10189
- ? 'dot is an invalid org, most likely you forgot the org name here?'
10190
- : 'missing'
10579
+ !id1 && !id2
10580
+ ? 'missing both Scan IDs'
10581
+ : !id2
10582
+ ? 'missing second Scan ID'
10583
+ : 'missing first Scan ID' // Not sure how this can happen but ok.
10191
10584
  },
10192
10585
  {
10193
- test: !!scanId,
10194
- message: 'Scan ID to delete',
10586
+ test: !!orgSlug,
10587
+ nook: true,
10588
+ message: 'Org name as the first argument',
10195
10589
  pass: 'ok',
10196
10590
  fail: 'missing'
10197
10591
  },
10592
+ {
10593
+ nook: true,
10594
+ test: !json || !markdown,
10595
+ message:
10596
+ 'The `--json` and `--markdown` flags can not be used at the same time',
10597
+ pass: 'ok',
10598
+ fail: 'bad'
10599
+ },
10198
10600
  {
10199
10601
  nook: true,
10200
10602
  test: !!apiToken,
@@ -10211,15 +10613,24 @@ async function run$6(argv, importMeta, { parentName }) {
10211
10613
  logger.logger.log(DRY_RUN_BAIL_TEXT$6)
10212
10614
  return
10213
10615
  }
10214
- await handleDeleteScan(orgSlug, scanId)
10616
+ await handleDiffScan({
10617
+ id1: String(id1 || ''),
10618
+ id2: String(id2 || ''),
10619
+ depth: Number(depth),
10620
+ orgSlug,
10621
+ outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
10622
+ file: String(file || '')
10623
+ })
10215
10624
  }
10216
10625
 
10217
10626
  async function fetchListScans({
10627
+ branch,
10218
10628
  direction,
10219
10629
  from_time,
10220
10630
  orgSlug,
10221
10631
  page,
10222
10632
  per_page,
10633
+ repo,
10223
10634
  sort
10224
10635
  }) {
10225
10636
  const sockSdk = await shadowNpmInject.setupSdk()
@@ -10229,6 +10640,16 @@ async function fetchListScans({
10229
10640
  spinner.start('Fetching list of scans...')
10230
10641
  const result = await handleApiCall(
10231
10642
  sockSdk.getOrgFullScanList(orgSlug, {
10643
+ ...(branch
10644
+ ? {
10645
+ branch
10646
+ }
10647
+ : {}),
10648
+ ...(repo
10649
+ ? {
10650
+ repo
10651
+ }
10652
+ : {}),
10232
10653
  sort,
10233
10654
  direction,
10234
10655
  per_page: String(per_page),
@@ -10260,6 +10681,10 @@ async function outputListScans(data, outputKind) {
10260
10681
  field: 'report_url',
10261
10682
  name: vendor.yoctocolorsCjsExports.magenta('Scan URL')
10262
10683
  },
10684
+ {
10685
+ field: 'repo',
10686
+ name: vendor.yoctocolorsCjsExports.magenta('Repo')
10687
+ },
10263
10688
  {
10264
10689
  field: 'branch',
10265
10690
  name: vendor.yoctocolorsCjsExports.magenta('Branch')
@@ -10283,6 +10708,7 @@ async function outputListScans(data, outputKind) {
10283
10708
  day: 'numeric'
10284
10709
  })
10285
10710
  : '',
10711
+ repo: d.repo,
10286
10712
  branch: d.branch
10287
10713
  }
10288
10714
  })
@@ -10290,20 +10716,24 @@ async function outputListScans(data, outputKind) {
10290
10716
  }
10291
10717
 
10292
10718
  async function handleListScans({
10719
+ branch,
10293
10720
  direction,
10294
10721
  from_time,
10295
10722
  orgSlug,
10296
10723
  outputKind,
10297
10724
  page,
10298
10725
  per_page,
10726
+ repo,
10299
10727
  sort
10300
10728
  }) {
10301
10729
  const data = await fetchListScans({
10730
+ branch,
10302
10731
  direction,
10303
10732
  from_time,
10304
10733
  orgSlug,
10305
10734
  page,
10306
10735
  per_page,
10736
+ repo,
10307
10737
  sort
10308
10738
  })
10309
10739
  if (!data) {
@@ -10320,12 +10750,9 @@ const config$5 = {
10320
10750
  flags: {
10321
10751
  ...commonFlags,
10322
10752
  ...outputFlags,
10323
- sort: {
10753
+ branch: {
10324
10754
  type: 'string',
10325
- shortFlag: 's',
10326
- default: 'created_at',
10327
- description:
10328
- 'Sorting option (`name` or `created_at`) - default is `created_at`'
10755
+ description: 'Filter to show only scans with this branch name'
10329
10756
  },
10330
10757
  direction: {
10331
10758
  type: 'string',
@@ -10333,11 +10760,11 @@ const config$5 = {
10333
10760
  default: 'desc',
10334
10761
  description: 'Direction option (`desc` or `asc`) - Default is `desc`'
10335
10762
  },
10336
- perPage: {
10337
- type: 'number',
10338
- shortFlag: 'pp',
10339
- default: 30,
10340
- description: 'Results per page - Default is 30'
10763
+ fromTime: {
10764
+ type: 'string',
10765
+ shortFlag: 'f',
10766
+ default: '',
10767
+ description: 'From time - as a unix timestamp'
10341
10768
  },
10342
10769
  page: {
10343
10770
  type: 'number',
@@ -10345,11 +10772,22 @@ const config$5 = {
10345
10772
  default: 1,
10346
10773
  description: 'Page number - Default is 1'
10347
10774
  },
10348
- fromTime: {
10775
+ perPage: {
10776
+ type: 'number',
10777
+ shortFlag: 'pp',
10778
+ default: 30,
10779
+ description: 'Results per page - Default is 30'
10780
+ },
10781
+ repo: {
10349
10782
  type: 'string',
10350
- shortFlag: 'f',
10351
- default: '',
10352
- description: 'From time - as a unix timestamp'
10783
+ description: 'Filter to show only scans with this repository name'
10784
+ },
10785
+ sort: {
10786
+ type: 'string',
10787
+ shortFlag: 's',
10788
+ default: 'created_at',
10789
+ description:
10790
+ 'Sorting option (`name` or `created_at`) - default is `created_at`'
10353
10791
  },
10354
10792
  untilTime: {
10355
10793
  type: 'string',
@@ -10385,7 +10823,7 @@ async function run$5(argv, importMeta, { parentName }) {
10385
10823
  importMeta,
10386
10824
  parentName
10387
10825
  })
10388
- const { json, markdown } = cli.flags
10826
+ const { branch, json, markdown, repo } = cli.flags
10389
10827
  const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10390
10828
  const orgSlug = defaultOrgSlug || cli.input[0] || ''
10391
10829
  const apiToken = shadowNpmInject.getDefaultToken()
@@ -10424,12 +10862,14 @@ async function run$5(argv, importMeta, { parentName }) {
10424
10862
  return
10425
10863
  }
10426
10864
  await handleListScans({
10865
+ branch: branch ? String(branch) : '',
10427
10866
  direction: String(cli.flags['direction'] || ''),
10428
10867
  from_time: String(cli.flags['fromTime'] || ''),
10429
10868
  orgSlug,
10430
10869
  outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
10431
10870
  page: Number(cli.flags['page'] || 1),
10432
10871
  per_page: Number(cli.flags['perPage'] || 30),
10872
+ repo: repo ? String(repo) : '',
10433
10873
  sort: String(cli.flags['sort'] || '')
10434
10874
  })
10435
10875
  }
@@ -10919,6 +11359,7 @@ const cmdScan = {
10919
11359
  create: cmdScanCreate,
10920
11360
  list: cmdScanList,
10921
11361
  del: cmdScanDel,
11362
+ diff: cmdScanDiff,
10922
11363
  metadata: cmdScanMetadata,
10923
11364
  report: cmdScanReport,
10924
11365
  view: cmdScanView
@@ -11287,7 +11728,7 @@ async function run$1(argv, importMeta, { parentName }) {
11287
11728
  }
11288
11729
 
11289
11730
  function addSocketWrapper(file) {
11290
- return require$$0.appendFile(
11731
+ return fs$1.appendFile(
11291
11732
  file,
11292
11733
  'alias npm="socket npm"\nalias npx="socket npx"\n',
11293
11734
  err => {
@@ -11296,7 +11737,7 @@ function addSocketWrapper(file) {
11296
11737
  }
11297
11738
  // TODO: pretty sure you need to source the file or restart
11298
11739
  // any terminal session before changes are reflected.
11299
- logger.logger.log(vendor.stripIndents`
11740
+ logger.logger.log(vendor.html`
11300
11741
  The alias was added to ${file}. Running 'npm install' will now be wrapped in Socket's "safe npm" 🎉
11301
11742
  If you want to disable it at any time, run \`socket wrapper --disable\`
11302
11743
  `)
@@ -11305,7 +11746,7 @@ If you want to disable it at any time, run \`socket wrapper --disable\`
11305
11746
  }
11306
11747
 
11307
11748
  function checkSocketWrapperSetup(file) {
11308
- const fileContent = require$$0.readFileSync(file, 'utf8')
11749
+ const fileContent = fs$1.readFileSync(file, 'utf8')
11309
11750
  const linesWithSocketAlias = fileContent
11310
11751
  .split('\n')
11311
11752
  .filter(
@@ -11324,11 +11765,10 @@ async function postinstallWrapper() {
11324
11765
  // Lazily access constants.bashRcPath and constants.zshRcPath.
11325
11766
  const { bashRcPath, zshRcPath } = constants
11326
11767
  const socketWrapperEnabled =
11327
- (require$$0.existsSync(bashRcPath) &&
11328
- checkSocketWrapperSetup(bashRcPath)) ||
11329
- (require$$0.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath))
11768
+ (fs$1.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath)) ||
11769
+ (fs$1.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath))
11330
11770
  if (!socketWrapperEnabled) {
11331
- await installSafeNpm(vendor.stripIndents`
11771
+ await installSafeNpm(vendor.html`
11332
11772
  The Socket CLI is now successfully installed! 🎉
11333
11773
 
11334
11774
  To better protect yourself against supply-chain attacks, our "safe npm" wrapper can warn you about malicious packages whenever you run 'npm install'.
@@ -11353,10 +11793,10 @@ async function installSafeNpm(query) {
11353
11793
  // Lazily access constants.bashRcPath and constants.zshRcPath.
11354
11794
  const { bashRcPath, zshRcPath } = constants
11355
11795
  try {
11356
- if (require$$0.existsSync(bashRcPath)) {
11796
+ if (fs$1.existsSync(bashRcPath)) {
11357
11797
  addSocketWrapper(bashRcPath)
11358
11798
  }
11359
- if (require$$0.existsSync(zshRcPath)) {
11799
+ if (fs$1.existsSync(zshRcPath)) {
11360
11800
  addSocketWrapper(zshRcPath)
11361
11801
  }
11362
11802
  } catch (e) {
@@ -11368,7 +11808,7 @@ async function installSafeNpm(query) {
11368
11808
  }
11369
11809
 
11370
11810
  function removeSocketWrapper(file) {
11371
- return require$$0.readFile(file, 'utf8', function (err, data) {
11811
+ return fs$1.readFile(file, 'utf8', function (err, data) {
11372
11812
  if (err) {
11373
11813
  logger.logger.fail('There was an error removing the alias:')
11374
11814
  logger.logger.error(err)
@@ -11380,7 +11820,7 @@ function removeSocketWrapper(file) {
11380
11820
  l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"'
11381
11821
  )
11382
11822
  const updatedFileContent = linesWithoutSocketAlias.join('\n')
11383
- require$$0.writeFile(file, updatedFileContent, function (err) {
11823
+ fs$1.writeFile(file, updatedFileContent, function (err) {
11384
11824
  if (err) {
11385
11825
  logger.logger.error(err)
11386
11826
  return
@@ -11468,27 +11908,21 @@ async function run(argv, importMeta, { parentName }) {
11468
11908
  // Lazily access constants.bashRcPath and constants.zshRcPath.
11469
11909
  const { bashRcPath, zshRcPath } = constants
11470
11910
  if (enable) {
11471
- if (
11472
- require$$0.existsSync(bashRcPath) &&
11473
- !checkSocketWrapperSetup(bashRcPath)
11474
- ) {
11911
+ if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
11475
11912
  addSocketWrapper(bashRcPath)
11476
11913
  }
11477
- if (
11478
- require$$0.existsSync(zshRcPath) &&
11479
- !checkSocketWrapperSetup(zshRcPath)
11480
- ) {
11914
+ if (fs$1.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
11481
11915
  addSocketWrapper(zshRcPath)
11482
11916
  }
11483
11917
  } else {
11484
- if (require$$0.existsSync(bashRcPath)) {
11918
+ if (fs$1.existsSync(bashRcPath)) {
11485
11919
  removeSocketWrapper(bashRcPath)
11486
11920
  }
11487
- if (require$$0.existsSync(zshRcPath)) {
11921
+ if (fs$1.existsSync(zshRcPath)) {
11488
11922
  removeSocketWrapper(zshRcPath)
11489
11923
  }
11490
11924
  }
11491
- if (!require$$0.existsSync(bashRcPath) && !require$$0.existsSync(zshRcPath)) {
11925
+ if (!fs$1.existsSync(bashRcPath) && !fs$1.existsSync(zshRcPath)) {
11492
11926
  logger.logger.fail(
11493
11927
  'There was an issue setting up the alias in your bash profile'
11494
11928
  )
@@ -11502,7 +11936,7 @@ void (async () => {
11502
11936
  await vendor.updater({
11503
11937
  name: SOCKET_CLI_BIN_NAME,
11504
11938
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11505
- version: '0.14.102',
11939
+ version: '0.14.104',
11506
11940
  ttl: 86_400_000 /* 24 hours in milliseconds */
11507
11941
  })
11508
11942
  try {
@@ -11539,7 +11973,7 @@ void (async () => {
11539
11973
  argv: process$1.argv.slice(2),
11540
11974
  name: SOCKET_CLI_BIN_NAME,
11541
11975
  importMeta: {
11542
- url: `${require$$0$2.pathToFileURL(__filename)}`
11976
+ url: `${require$$0$1.pathToFileURL(__filename)}`
11543
11977
  }
11544
11978
  }
11545
11979
  )
@@ -11570,5 +12004,5 @@ void (async () => {
11570
12004
  await shadowNpmInject.captureException(e)
11571
12005
  }
11572
12006
  })()
11573
- //# debugId=984cfa2c-d022-400b-b6cb-a91395f63be5
12007
+ //# debugId=35cb6fe4-28c3-408a-9222-5359160941e5
11574
12008
  //# sourceMappingURL=cli.js.map