@socketsecurity/cli-with-sentry 0.14.105 → 0.14.106

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.
@@ -602,6 +602,8 @@ const commonFlags = {
602
602
  dryRun: {
603
603
  type: 'boolean',
604
604
  default: false,
605
+ hidden: true,
606
+ // Only show in root command
605
607
  description: 'Do input validation for a command and exit 0 when input is ok'
606
608
  },
607
609
  help: {
@@ -739,6 +741,21 @@ async function meowWithSubcommands(subcommands, options) {
739
741
  ...commonFlags,
740
742
  ...additionalOptions.flags
741
743
  }
744
+
745
+ // No further args or first arg is a flag (shrug)
746
+ if (
747
+ name === 'socket' &&
748
+ (!commandOrAliasName || commandOrAliasName?.startsWith('-'))
749
+ ) {
750
+ flags['dryRun'] = {
751
+ type: 'boolean',
752
+ default: false,
753
+ hidden: false,
754
+ // Only show on root
755
+ description:
756
+ 'Do input validation for a command and exit 0 when input is ok. Every command should support this flag (not shown on help screens)'
757
+ }
758
+ }
742
759
  const cli = vendor.meow(
743
760
  `
744
761
  Usage
@@ -900,7 +917,7 @@ function emitBanner(name) {
900
917
  logger.logger.error(getAsciiHeader(name))
901
918
  }
902
919
  function getAsciiHeader(command) {
903
- const cliVersion = '0.14.105:2179d68:84daf9f9:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
920
+ const cliVersion = '0.14.106:968fc98:d6f1d87a:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
904
921
  const nodeVersion = process$1.version
905
922
  const apiToken = shadowNpmInject.getDefaultToken()
906
923
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -923,8 +940,8 @@ function getAsciiHeader(command) {
923
940
  return ` ${body}\n`
924
941
  }
925
942
 
926
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$I } = constants
927
- const config$L = {
943
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$J } = constants
944
+ const config$M = {
928
945
  commandName: 'analytics',
929
946
  description: `Look up analytics data`,
930
947
  hidden: false,
@@ -979,14 +996,14 @@ const config$L = {
979
996
  `
980
997
  }
981
998
  const cmdAnalytics = {
982
- description: config$L.description,
983
- hidden: config$L.hidden,
984
- run: run$L
999
+ description: config$M.description,
1000
+ hidden: config$M.hidden,
1001
+ run: run$M
985
1002
  }
986
- async function run$L(argv, importMeta, { parentName }) {
1003
+ async function run$M(argv, importMeta, { parentName }) {
987
1004
  const cli = meowOrExit({
988
1005
  argv,
989
- config: config$L,
1006
+ config: config$M,
990
1007
  importMeta,
991
1008
  parentName
992
1009
  })
@@ -1041,7 +1058,7 @@ async function run$L(argv, importMeta, { parentName }) {
1041
1058
  return
1042
1059
  }
1043
1060
  if (cli.flags['dryRun']) {
1044
- logger.logger.log(DRY_RUN_BAIL_TEXT$I)
1061
+ logger.logger.log(DRY_RUN_BAIL_TEXT$J)
1045
1062
  return
1046
1063
  }
1047
1064
  assert(assertScope(scope))
@@ -1216,8 +1233,8 @@ async function handleAuditLog({ logType, orgSlug, outputKind, page, perPage }) {
1216
1233
  })
1217
1234
  }
1218
1235
 
1219
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$H } = constants
1220
- const config$K = {
1236
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$I } = constants
1237
+ const config$L = {
1221
1238
  commandName: 'audit-log',
1222
1239
  description: 'Look up the audit log for an organization',
1223
1240
  hidden: false,
@@ -1262,14 +1279,14 @@ const config$K = {
1262
1279
  `
1263
1280
  }
1264
1281
  const cmdAuditLog = {
1265
- description: config$K.description,
1266
- hidden: config$K.hidden,
1267
- run: run$K
1282
+ description: config$L.description,
1283
+ hidden: config$L.hidden,
1284
+ run: run$L
1268
1285
  }
1269
- async function run$K(argv, importMeta, { parentName }) {
1286
+ async function run$L(argv, importMeta, { parentName }) {
1270
1287
  const cli = meowOrExit({
1271
1288
  argv,
1272
- config: config$K,
1289
+ config: config$L,
1273
1290
  importMeta,
1274
1291
  parentName
1275
1292
  })
@@ -1306,7 +1323,7 @@ async function run$K(argv, importMeta, { parentName }) {
1306
1323
  return
1307
1324
  }
1308
1325
  if (cli.flags['dryRun']) {
1309
- logger.logger.log(DRY_RUN_BAIL_TEXT$H)
1326
+ logger.logger.log(DRY_RUN_BAIL_TEXT$I)
1310
1327
  return
1311
1328
  }
1312
1329
  await handleAuditLog({
@@ -1436,7 +1453,7 @@ function isHelpFlag(cmdArg) {
1436
1453
  }
1437
1454
 
1438
1455
  // import { meowOrExit } from '../../utils/meow-with-subcommands'
1439
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$G } = constants
1456
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$H } = constants
1440
1457
 
1441
1458
  // TODO: convert yargs to meow. Or convert all the other things to yargs.
1442
1459
  const toLower = arg => arg.toLowerCase()
@@ -1552,7 +1569,7 @@ const yargsConfig = {
1552
1569
  'spec-version'
1553
1570
  ]
1554
1571
  }
1555
- const config$J = {
1572
+ const config$K = {
1556
1573
  commandName: 'cdxgen',
1557
1574
  description: 'Create an SBOM with CycloneDX generator (cdxgen)',
1558
1575
  hidden: false,
@@ -1568,16 +1585,16 @@ const config$J = {
1568
1585
  `
1569
1586
  }
1570
1587
  const cmdCdxgen = {
1571
- description: config$J.description,
1572
- hidden: config$J.hidden,
1573
- run: run$J
1588
+ description: config$K.description,
1589
+ hidden: config$K.hidden,
1590
+ run: run$K
1574
1591
  }
1575
- async function run$J(argv, importMeta, { parentName }) {
1592
+ async function run$K(argv, importMeta, { parentName }) {
1576
1593
  const cli = meowOrExit({
1577
1594
  allowUnknownFlags: true,
1578
1595
  // Don't let meow take over --help.
1579
1596
  argv: argv.filter(a => !isHelpFlag(a)),
1580
- config: config$J,
1597
+ config: config$K,
1581
1598
  importMeta,
1582
1599
  parentName
1583
1600
  })
@@ -1599,7 +1616,7 @@ async function run$J(argv, importMeta, { parentName }) {
1599
1616
  return
1600
1617
  }
1601
1618
  if (cli.flags['dryRun']) {
1602
- logger.logger.log(DRY_RUN_BAIL_TEXT$G)
1619
+ logger.logger.log(DRY_RUN_BAIL_TEXT$H)
1603
1620
  return
1604
1621
  }
1605
1622
  if (yargv.output === undefined) {
@@ -2447,8 +2464,8 @@ async function handleCI() {
2447
2464
  })
2448
2465
  }
2449
2466
 
2450
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$F } = constants
2451
- const config$I = {
2467
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$G } = constants
2468
+ const config$J = {
2452
2469
  commandName: 'ci',
2453
2470
  description:
2454
2471
  'Create a new scan and report whether it passes your security policy',
@@ -2468,19 +2485,19 @@ const config$I = {
2468
2485
  `
2469
2486
  }
2470
2487
  const cmdCI = {
2471
- description: config$I.description,
2472
- hidden: config$I.hidden,
2473
- run: run$I
2488
+ description: config$J.description,
2489
+ hidden: config$J.hidden,
2490
+ run: run$J
2474
2491
  }
2475
- async function run$I(argv, importMeta, { parentName }) {
2492
+ async function run$J(argv, importMeta, { parentName }) {
2476
2493
  const cli = meowOrExit({
2477
2494
  argv,
2478
- config: config$I,
2495
+ config: config$J,
2479
2496
  importMeta,
2480
2497
  parentName
2481
2498
  })
2482
2499
  if (cli.flags['dryRun']) {
2483
- logger.logger.log(DRY_RUN_BAIL_TEXT$F)
2500
+ logger.logger.log(DRY_RUN_BAIL_TEXT$G)
2484
2501
  return
2485
2502
  }
2486
2503
  await handleCI()
@@ -2727,8 +2744,8 @@ async function handleConfigAuto({ key, outputKind }) {
2727
2744
  await outputConfigAuto(key, result, outputKind)
2728
2745
  }
2729
2746
 
2730
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$E } = constants
2731
- const config$H = {
2747
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$F } = constants
2748
+ const config$I = {
2732
2749
  commandName: 'auto',
2733
2750
  description: 'Automatically discover and set the correct value config item',
2734
2751
  hidden: false,
@@ -2759,14 +2776,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
2759
2776
  `
2760
2777
  }
2761
2778
  const cmdConfigAuto = {
2762
- description: config$H.description,
2763
- hidden: config$H.hidden,
2764
- run: run$H
2779
+ description: config$I.description,
2780
+ hidden: config$I.hidden,
2781
+ run: run$I
2765
2782
  }
2766
- async function run$H(argv, importMeta, { parentName }) {
2783
+ async function run$I(argv, importMeta, { parentName }) {
2767
2784
  const cli = meowOrExit({
2768
2785
  argv,
2769
- config: config$H,
2786
+ config: config$I,
2770
2787
  importMeta,
2771
2788
  parentName
2772
2789
  })
@@ -2792,7 +2809,7 @@ async function run$H(argv, importMeta, { parentName }) {
2792
2809
  return
2793
2810
  }
2794
2811
  if (cli.flags['dryRun']) {
2795
- logger.logger.log(DRY_RUN_BAIL_TEXT$E)
2812
+ logger.logger.log(DRY_RUN_BAIL_TEXT$F)
2796
2813
  return
2797
2814
  }
2798
2815
  await handleConfigAuto({
@@ -2846,8 +2863,8 @@ async function handleConfigGet({ key, outputKind }) {
2846
2863
  await outputConfigGet(key, value, readOnly, outputKind)
2847
2864
  }
2848
2865
 
2849
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$D } = constants
2850
- const config$G = {
2866
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$E } = constants
2867
+ const config$H = {
2851
2868
  commandName: 'get',
2852
2869
  description: 'Get the value of a local CLI config item',
2853
2870
  hidden: false,
@@ -2873,14 +2890,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
2873
2890
  `
2874
2891
  }
2875
2892
  const cmdConfigGet = {
2876
- description: config$G.description,
2877
- hidden: config$G.hidden,
2878
- run: run$G
2893
+ description: config$H.description,
2894
+ hidden: config$H.hidden,
2895
+ run: run$H
2879
2896
  }
2880
- async function run$G(argv, importMeta, { parentName }) {
2897
+ async function run$H(argv, importMeta, { parentName }) {
2881
2898
  const cli = meowOrExit({
2882
2899
  argv,
2883
- config: config$G,
2900
+ config: config$H,
2884
2901
  importMeta,
2885
2902
  parentName
2886
2903
  })
@@ -2906,7 +2923,7 @@ async function run$G(argv, importMeta, { parentName }) {
2906
2923
  return
2907
2924
  }
2908
2925
  if (cli.flags['dryRun']) {
2909
- logger.logger.log(DRY_RUN_BAIL_TEXT$D)
2926
+ logger.logger.log(DRY_RUN_BAIL_TEXT$E)
2910
2927
  return
2911
2928
  }
2912
2929
  await handleConfigGet({
@@ -2968,8 +2985,8 @@ async function outputConfigList({ full, outputKind }) {
2968
2985
  }
2969
2986
  }
2970
2987
 
2971
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$C } = constants
2972
- const config$F = {
2988
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$D } = constants
2989
+ const config$G = {
2973
2990
  commandName: 'list',
2974
2991
  description: 'Show all local CLI config items and their values',
2975
2992
  hidden: false,
@@ -3000,14 +3017,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
3000
3017
  `
3001
3018
  }
3002
3019
  const cmdConfigList = {
3003
- description: config$F.description,
3004
- hidden: config$F.hidden,
3005
- run: run$F
3020
+ description: config$G.description,
3021
+ hidden: config$G.hidden,
3022
+ run: run$G
3006
3023
  }
3007
- async function run$F(argv, importMeta, { parentName }) {
3024
+ async function run$G(argv, importMeta, { parentName }) {
3008
3025
  const cli = meowOrExit({
3009
3026
  argv,
3010
- config: config$F,
3027
+ config: config$G,
3011
3028
  importMeta,
3012
3029
  parentName
3013
3030
  })
@@ -3024,7 +3041,7 @@ async function run$F(argv, importMeta, { parentName }) {
3024
3041
  return
3025
3042
  }
3026
3043
  if (cli.flags['dryRun']) {
3027
- logger.logger.log(DRY_RUN_BAIL_TEXT$C)
3044
+ logger.logger.log(DRY_RUN_BAIL_TEXT$D)
3028
3045
  return
3029
3046
  }
3030
3047
  await outputConfigList({
@@ -3069,8 +3086,8 @@ async function handleConfigSet({ key, outputKind, value }) {
3069
3086
  await outputConfigSet(key, value, readOnly, outputKind)
3070
3087
  }
3071
3088
 
3072
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B } = constants
3073
- const config$E = {
3089
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$C } = constants
3090
+ const config$F = {
3074
3091
  commandName: 'set',
3075
3092
  description: 'Update the value of a local CLI config item',
3076
3093
  hidden: false,
@@ -3101,14 +3118,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
3101
3118
  `
3102
3119
  }
3103
3120
  const cmdConfigSet = {
3104
- description: config$E.description,
3105
- hidden: config$E.hidden,
3106
- run: run$E
3121
+ description: config$F.description,
3122
+ hidden: config$F.hidden,
3123
+ run: run$F
3107
3124
  }
3108
- async function run$E(argv, importMeta, { parentName }) {
3125
+ async function run$F(argv, importMeta, { parentName }) {
3109
3126
  const cli = meowOrExit({
3110
3127
  argv,
3111
- config: config$E,
3128
+ config: config$F,
3112
3129
  importMeta,
3113
3130
  parentName
3114
3131
  })
@@ -3143,7 +3160,7 @@ async function run$E(argv, importMeta, { parentName }) {
3143
3160
  return
3144
3161
  }
3145
3162
  if (cli.flags['dryRun']) {
3146
- logger.logger.log(DRY_RUN_BAIL_TEXT$B)
3163
+ logger.logger.log(DRY_RUN_BAIL_TEXT$C)
3147
3164
  return
3148
3165
  }
3149
3166
  await handleConfigSet({
@@ -3175,8 +3192,8 @@ async function handleConfigUnset({ key, outputKind }) {
3175
3192
  await outputConfigUnset(key, outputKind)
3176
3193
  }
3177
3194
 
3178
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A } = constants
3179
- const config$D = {
3195
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B } = constants
3196
+ const config$E = {
3180
3197
  commandName: 'unset',
3181
3198
  description: 'Clear the value of a local CLI config item',
3182
3199
  hidden: false,
@@ -3202,14 +3219,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
3202
3219
  `
3203
3220
  }
3204
3221
  const cmdConfigUnset = {
3205
- description: config$D.description,
3206
- hidden: config$D.hidden,
3207
- run: run$D
3222
+ description: config$E.description,
3223
+ hidden: config$E.hidden,
3224
+ run: run$E
3208
3225
  }
3209
- async function run$D(argv, importMeta, { parentName }) {
3226
+ async function run$E(argv, importMeta, { parentName }) {
3210
3227
  const cli = meowOrExit({
3211
3228
  argv,
3212
- config: config$D,
3229
+ config: config$E,
3213
3230
  importMeta,
3214
3231
  parentName
3215
3232
  })
@@ -3235,7 +3252,7 @@ async function run$D(argv, importMeta, { parentName }) {
3235
3252
  return
3236
3253
  }
3237
3254
  if (cli.flags['dryRun']) {
3238
- logger.logger.log(DRY_RUN_BAIL_TEXT$A)
3255
+ logger.logger.log(DRY_RUN_BAIL_TEXT$B)
3239
3256
  return
3240
3257
  }
3241
3258
  await handleConfigUnset({
@@ -3362,8 +3379,8 @@ async function handleDependencies({ limit, offset, outputKind }) {
3362
3379
  })
3363
3380
  }
3364
3381
 
3365
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z } = constants
3366
- const config$C = {
3382
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A } = constants
3383
+ const config$D = {
3367
3384
  commandName: 'dependencies',
3368
3385
  description:
3369
3386
  'Search for any dependency that is being used in your organization',
@@ -3400,14 +3417,14 @@ const config$C = {
3400
3417
  `
3401
3418
  }
3402
3419
  const cmdScanCreate$1 = {
3403
- description: config$C.description,
3404
- hidden: config$C.hidden,
3405
- run: run$C
3420
+ description: config$D.description,
3421
+ hidden: config$D.hidden,
3422
+ run: run$D
3406
3423
  }
3407
- async function run$C(argv, importMeta, { parentName }) {
3424
+ async function run$D(argv, importMeta, { parentName }) {
3408
3425
  const cli = meowOrExit({
3409
3426
  argv,
3410
- config: config$C,
3427
+ config: config$D,
3411
3428
  importMeta,
3412
3429
  parentName
3413
3430
  })
@@ -3435,7 +3452,7 @@ async function run$C(argv, importMeta, { parentName }) {
3435
3452
  return
3436
3453
  }
3437
3454
  if (cli.flags['dryRun']) {
3438
- logger.logger.log(DRY_RUN_BAIL_TEXT$z)
3455
+ logger.logger.log(DRY_RUN_BAIL_TEXT$A)
3439
3456
  return
3440
3457
  }
3441
3458
  await handleDependencies({
@@ -3549,8 +3566,8 @@ async function handleDiffScan$1({
3549
3566
  })
3550
3567
  }
3551
3568
 
3552
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y } = constants
3553
- const config$B = {
3569
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z } = constants
3570
+ const config$C = {
3554
3571
  commandName: 'get',
3555
3572
  description: 'Get a diff scan for an organization',
3556
3573
  hidden: false,
@@ -3609,14 +3626,14 @@ const config$B = {
3609
3626
  `
3610
3627
  }
3611
3628
  const cmdDiffScanGet = {
3612
- description: config$B.description,
3613
- hidden: config$B.hidden,
3614
- run: run$B
3629
+ description: config$C.description,
3630
+ hidden: config$C.hidden,
3631
+ run: run$C
3615
3632
  }
3616
- async function run$B(argv, importMeta, { parentName }) {
3633
+ async function run$C(argv, importMeta, { parentName }) {
3617
3634
  const cli = meowOrExit({
3618
3635
  argv,
3619
- config: config$B,
3636
+ config: config$C,
3620
3637
  importMeta,
3621
3638
  parentName
3622
3639
  })
@@ -3668,7 +3685,7 @@ async function run$B(argv, importMeta, { parentName }) {
3668
3685
  'Warning: this command is deprecated in favor of `socket scan diff` and will be removed in the next major bump.'
3669
3686
  )
3670
3687
  if (cli.flags['dryRun']) {
3671
- logger.logger.log(DRY_RUN_BAIL_TEXT$y)
3688
+ logger.logger.log(DRY_RUN_BAIL_TEXT$z)
3672
3689
  return
3673
3690
  }
3674
3691
  await handleDiffScan$1({
@@ -3798,9 +3815,17 @@ async function gitCreateAndPushBranchIfNeeded(
3798
3815
  await spawn.spawn('git', ['checkout', '-b', branch], {
3799
3816
  cwd
3800
3817
  })
3801
- await spawn.spawn('git', ['add', 'package.json', 'pnpm-lock.yaml'], {
3802
- cwd
3803
- })
3818
+ const relFilepaths = await vendor.distExports.glob(
3819
+ '**/{package.json,package-lock.json,pnpm-lock.yaml}',
3820
+ {
3821
+ cwd
3822
+ }
3823
+ )
3824
+ if (relFilepaths.length) {
3825
+ await spawn.spawn('git', ['add', ...relFilepaths], {
3826
+ cwd
3827
+ })
3828
+ }
3804
3829
  await spawn.spawn('git', ['commit', '-m', commitMsg], {
3805
3830
  cwd
3806
3831
  })
@@ -5134,8 +5159,8 @@ async function runFix(options_) {
5134
5159
  }
5135
5160
  }
5136
5161
 
5137
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
5138
- const config$A = {
5162
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y } = constants
5163
+ const config$B = {
5139
5164
  commandName: 'fix',
5140
5165
  description: 'Fix "fixable" Socket alerts',
5141
5166
  hidden: true,
@@ -5192,14 +5217,14 @@ const config$A = {
5192
5217
  `
5193
5218
  }
5194
5219
  const cmdFix = {
5195
- description: config$A.description,
5196
- hidden: config$A.hidden,
5197
- run: run$A
5220
+ description: config$B.description,
5221
+ hidden: config$B.hidden,
5222
+ run: run$B
5198
5223
  }
5199
- async function run$A(argv, importMeta, { parentName }) {
5224
+ async function run$B(argv, importMeta, { parentName }) {
5200
5225
  const cli = meowOrExit({
5201
5226
  argv,
5202
- config: config$A,
5227
+ config: config$B,
5203
5228
  importMeta,
5204
5229
  parentName
5205
5230
  })
@@ -5213,7 +5238,7 @@ async function run$A(argv, importMeta, { parentName }) {
5213
5238
  return
5214
5239
  }
5215
5240
  if (cli.flags['dryRun']) {
5216
- logger.logger.log(DRY_RUN_BAIL_TEXT$x)
5241
+ logger.logger.log(DRY_RUN_BAIL_TEXT$y)
5217
5242
  return
5218
5243
  }
5219
5244
 
@@ -5416,8 +5441,8 @@ async function handlePackageInfo({
5416
5441
  }
5417
5442
  }
5418
5443
 
5419
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
5420
- const config$z = {
5444
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
5445
+ const config$A = {
5421
5446
  commandName: 'info',
5422
5447
  description: 'Look up info regarding a package',
5423
5448
  hidden: true,
@@ -5442,14 +5467,14 @@ const config$z = {
5442
5467
  `
5443
5468
  }
5444
5469
  const cmdInfo = {
5445
- description: config$z.description,
5446
- hidden: config$z.hidden,
5447
- run: run$z
5470
+ description: config$A.description,
5471
+ hidden: config$A.hidden,
5472
+ run: run$A
5448
5473
  }
5449
- async function run$z(argv, importMeta, { parentName }) {
5474
+ async function run$A(argv, importMeta, { parentName }) {
5450
5475
  const cli = meowOrExit({
5451
5476
  argv,
5452
- config: config$z,
5477
+ config: config$A,
5453
5478
  importMeta,
5454
5479
  parentName
5455
5480
  })
@@ -5487,11 +5512,11 @@ async function run$z(argv, importMeta, { parentName }) {
5487
5512
  const pkgVersion =
5488
5513
  versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1)
5489
5514
  if (cli.flags['dryRun']) {
5490
- logger.logger.log(DRY_RUN_BAIL_TEXT$w)
5515
+ logger.logger.log(DRY_RUN_BAIL_TEXT$x)
5491
5516
  return
5492
5517
  }
5493
5518
  await handlePackageInfo({
5494
- commandName: `${parentName} ${config$z.commandName}`,
5519
+ commandName: `${parentName} ${config$A.commandName}`,
5495
5520
  includeAllIssues: Boolean(all),
5496
5521
  outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
5497
5522
  pkgName,
@@ -5578,8 +5603,8 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
5578
5603
  }
5579
5604
  }
5580
5605
 
5581
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
5582
- const config$y = {
5606
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
5607
+ const config$z = {
5583
5608
  commandName: 'login',
5584
5609
  description: 'Socket API login',
5585
5610
  hidden: false,
@@ -5612,21 +5637,21 @@ const config$y = {
5612
5637
  `
5613
5638
  }
5614
5639
  const cmdLogin = {
5615
- description: config$y.description,
5616
- hidden: config$y.hidden,
5617
- run: run$y
5640
+ description: config$z.description,
5641
+ hidden: config$z.hidden,
5642
+ run: run$z
5618
5643
  }
5619
- async function run$y(argv, importMeta, { parentName }) {
5644
+ async function run$z(argv, importMeta, { parentName }) {
5620
5645
  const cli = meowOrExit({
5621
5646
  argv,
5622
- config: config$y,
5647
+ config: config$z,
5623
5648
  importMeta,
5624
5649
  parentName
5625
5650
  })
5626
5651
  const apiBaseUrl = cli.flags['apiBaseUrl']
5627
5652
  const apiProxy = cli.flags['apiProxy']
5628
5653
  if (cli.flags['dryRun']) {
5629
- logger.logger.log(DRY_RUN_BAIL_TEXT$v)
5654
+ logger.logger.log(DRY_RUN_BAIL_TEXT$w)
5630
5655
  return
5631
5656
  }
5632
5657
  if (!isInteractive()) {
@@ -5659,8 +5684,8 @@ function attemptLogout() {
5659
5684
  }
5660
5685
  }
5661
5686
 
5662
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
5663
- const config$x = {
5687
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
5688
+ const config$y = {
5664
5689
  commandName: 'logout',
5665
5690
  description: 'Socket API logout',
5666
5691
  hidden: false,
@@ -5675,6 +5700,247 @@ const config$x = {
5675
5700
  `
5676
5701
  }
5677
5702
  const cmdLogout = {
5703
+ description: config$y.description,
5704
+ hidden: config$y.hidden,
5705
+ run: run$y
5706
+ }
5707
+ async function run$y(argv, importMeta, { parentName }) {
5708
+ const cli = meowOrExit({
5709
+ argv,
5710
+ config: config$y,
5711
+ importMeta,
5712
+ parentName
5713
+ })
5714
+ if (cli.flags['dryRun']) {
5715
+ logger.logger.log(DRY_RUN_BAIL_TEXT$v)
5716
+ return
5717
+ }
5718
+ attemptLogout()
5719
+ }
5720
+
5721
+ async function convertCondaToRequirements(target, cwd, verbose) {
5722
+ let contents
5723
+ if (target === '-') {
5724
+ if (verbose) {
5725
+ logger.logger.error(`[VERBOSE] reading input from stdin`)
5726
+ }
5727
+ const buf = []
5728
+ contents = await new Promise((resolve, reject) => {
5729
+ process.stdin.on('data', chunk => {
5730
+ const input = chunk.toString()
5731
+ buf.push(input)
5732
+ })
5733
+ process.stdin.on('end', () => {
5734
+ resolve(buf.join(''))
5735
+ })
5736
+ process.stdin.on('error', e => {
5737
+ if (verbose) {
5738
+ logger.logger.error('Unexpected error while reading from stdin:', e)
5739
+ }
5740
+ reject(e)
5741
+ })
5742
+ process.stdin.on('close', () => {
5743
+ if (buf.length === 0) {
5744
+ if (verbose) {
5745
+ logger.logger.error('stdin closed explicitly without data received')
5746
+ }
5747
+ reject(new Error('No data received from stdin'))
5748
+ } else {
5749
+ if (verbose) {
5750
+ logger.logger.error(
5751
+ 'warning: stdin closed explicitly with some data received'
5752
+ )
5753
+ }
5754
+ resolve(buf.join(''))
5755
+ }
5756
+ })
5757
+ })
5758
+ if (!contents) {
5759
+ return {
5760
+ ok: false,
5761
+ message: 'No data received from stdin',
5762
+ data: undefined
5763
+ }
5764
+ }
5765
+ } else {
5766
+ const f = path$1.resolve(cwd, target)
5767
+ if (verbose) {
5768
+ logger.logger.error(`[VERBOSE] target file: ${f}`)
5769
+ }
5770
+ if (!fs$1.existsSync(f)) {
5771
+ return {
5772
+ ok: false,
5773
+ message: `Input file not found at ${f}`,
5774
+ data: undefined
5775
+ }
5776
+ }
5777
+ contents = fs$1.readFileSync(target, 'utf8')
5778
+ if (!contents) {
5779
+ return {
5780
+ ok: false,
5781
+ message: 'File is empty',
5782
+ data: undefined
5783
+ }
5784
+ }
5785
+ }
5786
+ return {
5787
+ ok: true,
5788
+ message: '',
5789
+ data: {
5790
+ contents,
5791
+ pip: convertCondaToRequirementsFromInput(contents)
5792
+ }
5793
+ }
5794
+ }
5795
+
5796
+ // Just extract the first pip block, if one exists at all.
5797
+ function convertCondaToRequirementsFromInput(input) {
5798
+ const keeping = []
5799
+ let collecting = false
5800
+ let delim = '-'
5801
+ let indent = ''
5802
+ input.split('\n').some(line => {
5803
+ if (!line) {
5804
+ // Ignore empty lines
5805
+ return
5806
+ }
5807
+ if (collecting) {
5808
+ if (line.startsWith('#')) {
5809
+ // Ignore comment lines (keep?)
5810
+ return
5811
+ }
5812
+ if (line.startsWith(delim)) {
5813
+ // In this case we have a line with the same indentation as the
5814
+ // `- pip:` line, so we have reached the end of the pip block.
5815
+ return true // the end
5816
+ } else {
5817
+ if (!indent) {
5818
+ // Store the indentation of the block
5819
+ if (line.trim().startsWith('-')) {
5820
+ indent = line.split('-')[0] + '-'
5821
+ if (indent.length <= delim.length) {
5822
+ // The first line after the `pip:` line does not indent further
5823
+ // than that so the block is empty?
5824
+ return true
5825
+ }
5826
+ }
5827
+ }
5828
+ if (line.startsWith(indent)) {
5829
+ keeping.push(line.slice(indent.length).trim())
5830
+ } else {
5831
+ // Unexpected input. bail.
5832
+ return true
5833
+ }
5834
+ }
5835
+ } else {
5836
+ // Note: the line may end with a line comment so don't === it.
5837
+ if (line.trim().startsWith('- pip:')) {
5838
+ delim = line.split('-')[0] + '-'
5839
+ collecting = true
5840
+ }
5841
+ }
5842
+ })
5843
+ return keeping.join('\n')
5844
+ }
5845
+
5846
+ async function outputRequirements(data, outputKind, out) {
5847
+ if (outputKind === 'json') {
5848
+ const json = JSON.stringify(
5849
+ {
5850
+ ok: true,
5851
+ data: {
5852
+ pip: data.pip
5853
+ }
5854
+ },
5855
+ undefined,
5856
+ 2
5857
+ )
5858
+ if (out === '-') {
5859
+ logger.logger.log(json)
5860
+ } else {
5861
+ fs$1.writeFileSync(out, json, 'utf8')
5862
+ }
5863
+ return
5864
+ }
5865
+ if (outputKind === 'markdown') {
5866
+ const arr = []
5867
+ arr.push('# Converted Conda file')
5868
+ arr.push('')
5869
+ arr.push(
5870
+ 'This is the Conda `environment.yml` file converted to python `requirements.txt`:'
5871
+ )
5872
+ arr.push('')
5873
+ arr.push('```file=requirements.txt')
5874
+ arr.push(data.pip)
5875
+ arr.push('```')
5876
+ arr.push('')
5877
+ const md = arr.join('\n')
5878
+ if (out === '-') {
5879
+ logger.logger.log(md)
5880
+ } else {
5881
+ fs$1.writeFileSync(out, md, 'utf8')
5882
+ }
5883
+ return
5884
+ }
5885
+ if (out === '-') {
5886
+ logger.logger.log(data.pip)
5887
+ logger.logger.log('')
5888
+ } else {
5889
+ fs$1.writeFileSync(out, data.pip, 'utf8')
5890
+ }
5891
+ }
5892
+
5893
+ async function handleManifestConda(target, out, outputKind, cwd, verbose) {
5894
+ const data = await convertCondaToRequirements(target, cwd, verbose)
5895
+ if (!data) {
5896
+ return
5897
+ }
5898
+ if (!data.ok) {
5899
+ logger.logger.fail(data.message)
5900
+ return
5901
+ }
5902
+ await outputRequirements(data.data, outputKind, out)
5903
+ }
5904
+
5905
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
5906
+ const config$x = {
5907
+ commandName: 'conda',
5908
+ description:
5909
+ '[beta] Convert a Conda environment.yml file to a python requirements.txt',
5910
+ hidden: false,
5911
+ flags: {
5912
+ ...commonFlags,
5913
+ ...outputFlags,
5914
+ cwd: {
5915
+ type: 'string',
5916
+ description: 'Set the cwd, defaults to process.cwd()'
5917
+ },
5918
+ out: {
5919
+ type: 'string',
5920
+ default: '-',
5921
+ description: 'Output target (use `-` or omit to print to stdout)'
5922
+ },
5923
+ verbose: {
5924
+ type: 'boolean',
5925
+ description: 'Print debug messages'
5926
+ }
5927
+ },
5928
+ help: (command, config) => `
5929
+ Usage
5930
+ $ ${command} FILE
5931
+
5932
+ Note: FILE can be a dash (-) to indicate stdin. This way you can pipe the
5933
+ contents of a file to have it processed.
5934
+
5935
+ Options
5936
+ ${getFlagListOutput(config.flags, 6)}
5937
+
5938
+ Examples
5939
+
5940
+ $ ${command} ./environment.yml
5941
+ `
5942
+ }
5943
+ const cmdManifestConda = {
5678
5944
  description: config$x.description,
5679
5945
  hidden: config$x.hidden,
5680
5946
  run: run$x
@@ -5686,11 +5952,59 @@ async function run$x(argv, importMeta, { parentName }) {
5686
5952
  importMeta,
5687
5953
  parentName
5688
5954
  })
5955
+ const {
5956
+ cwd = process.cwd(),
5957
+ json = false,
5958
+ markdown = false,
5959
+ out = '-',
5960
+ verbose = false
5961
+ } = cli.flags
5962
+ const [target = ''] = cli.input
5963
+ if (verbose) {
5964
+ logger.logger.group('- ', parentName, config$x.commandName, ':')
5965
+ logger.logger.group('- flags:', cli.flags)
5966
+ logger.logger.groupEnd()
5967
+ logger.logger.log('- target:', target)
5968
+ logger.logger.log('- output:', out)
5969
+ logger.logger.groupEnd()
5970
+ }
5971
+ const wasBadInput = handleBadInput(
5972
+ {
5973
+ test: !!target,
5974
+ message: 'The FILE arg is required',
5975
+ pass: 'ok',
5976
+ fail: 'missing'
5977
+ },
5978
+ {
5979
+ nook: true,
5980
+ test: cli.input.length <= 1,
5981
+ message: 'Can only accept one DIR (make sure to escape spaces!)',
5982
+ pass: 'ok',
5983
+ fail: 'received ' + cli.input.length
5984
+ },
5985
+ {
5986
+ nook: true,
5987
+ test: !json || !markdown,
5988
+ message:
5989
+ 'The `--json` and `--markdown` flags can not be used at the same time',
5990
+ pass: 'ok',
5991
+ fail: 'bad'
5992
+ }
5993
+ )
5994
+ if (wasBadInput) {
5995
+ return
5996
+ }
5689
5997
  if (cli.flags['dryRun']) {
5690
5998
  logger.logger.log(DRY_RUN_BAIL_TEXT$u)
5691
5999
  return
5692
6000
  }
5693
- attemptLogout()
6001
+ await handleManifestConda(
6002
+ target,
6003
+ String(out || ''),
6004
+ json ? 'json' : markdown ? 'markdown' : 'text',
6005
+ String(cwd),
6006
+ Boolean(verbose)
6007
+ )
5694
6008
  }
5695
6009
 
5696
6010
  async function convertGradleToMaven(target, bin, cwd, verbose, gradleOpts) {
@@ -6296,6 +6610,25 @@ async function run$u(argv, importMeta, { parentName }) {
6296
6610
  })
6297
6611
  return
6298
6612
  }
6613
+ const envyml = path$1.join(dir, 'environment.yml')
6614
+ const hasEnvyml = fs$1.existsSync(envyml)
6615
+ const envyaml = path$1.join(dir, 'environment.yaml')
6616
+ const hasEnvyaml = !hasEnvyml && fs$1.existsSync(envyaml)
6617
+ if (hasEnvyml || hasEnvyaml) {
6618
+ logger.logger.log(
6619
+ 'Detected an environment.yml file, running default Conda generator...'
6620
+ )
6621
+ // This command takes the TARGET as first arg.
6622
+ subArgs.push(hasEnvyml ? envyml : hasEnvyaml ? envyaml : '')
6623
+ if (cli.flags['dryRun']) {
6624
+ logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6625
+ return
6626
+ }
6627
+ await cmdManifestConda.run(subArgs, importMeta, {
6628
+ parentName
6629
+ })
6630
+ return
6631
+ }
6299
6632
  if (cli.flags['dryRun']) {
6300
6633
  logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6301
6634
  return
@@ -6486,6 +6819,7 @@ async function run$s(argv, importMeta, { parentName }) {
6486
6819
  await meowWithSubcommands(
6487
6820
  {
6488
6821
  auto: cmdManifestAuto,
6822
+ conda: cmdManifestConda,
6489
6823
  scala: cmdManifestScala,
6490
6824
  gradle: cmdManifestGradle,
6491
6825
  kotlin: cmdManifestKotlin
@@ -9929,11 +10263,6 @@ const config$8 = {
9929
10263
  description:
9930
10264
  'Set the default branch of the repository to the branch of this full-scan. Should only need to be done once, for example for the "main" or "master" branch.'
9931
10265
  },
9932
- dryRun: {
9933
- type: 'boolean',
9934
- description:
9935
- 'Run input validation part of command without any concrete side effects'
9936
- },
9937
10266
  pendingHead: {
9938
10267
  type: 'boolean',
9939
10268
  default: true,
@@ -11938,7 +12267,7 @@ void (async () => {
11938
12267
  await vendor.updater({
11939
12268
  name: SOCKET_CLI_BIN_NAME,
11940
12269
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11941
- version: '0.14.105',
12270
+ version: '0.14.106',
11942
12271
  ttl: 86_400_000 /* 24 hours in milliseconds */
11943
12272
  })
11944
12273
  try {
@@ -12006,5 +12335,5 @@ void (async () => {
12006
12335
  await shadowNpmInject.captureException(e)
12007
12336
  }
12008
12337
  })()
12009
- //# debugId=1651050b-5b34-4e33-bf0e-95c55f069093
12338
+ //# debugId=262dd99f-490c-457b-886d-df52563318d8
12010
12339
  //# sourceMappingURL=cli.js.map