socket 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:b0be6037:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
920
+ const cliVersion = '0.14.106:968fc98:d2acc868: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
  })
@@ -5130,8 +5155,8 @@ async function runFix(options_) {
5130
5155
  }
5131
5156
  }
5132
5157
 
5133
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
5134
- const config$A = {
5158
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y } = constants
5159
+ const config$B = {
5135
5160
  commandName: 'fix',
5136
5161
  description: 'Fix "fixable" Socket alerts',
5137
5162
  hidden: true,
@@ -5188,14 +5213,14 @@ const config$A = {
5188
5213
  `
5189
5214
  }
5190
5215
  const cmdFix = {
5191
- description: config$A.description,
5192
- hidden: config$A.hidden,
5193
- run: run$A
5216
+ description: config$B.description,
5217
+ hidden: config$B.hidden,
5218
+ run: run$B
5194
5219
  }
5195
- async function run$A(argv, importMeta, { parentName }) {
5220
+ async function run$B(argv, importMeta, { parentName }) {
5196
5221
  const cli = meowOrExit({
5197
5222
  argv,
5198
- config: config$A,
5223
+ config: config$B,
5199
5224
  importMeta,
5200
5225
  parentName
5201
5226
  })
@@ -5209,7 +5234,7 @@ async function run$A(argv, importMeta, { parentName }) {
5209
5234
  return
5210
5235
  }
5211
5236
  if (cli.flags['dryRun']) {
5212
- logger.logger.log(DRY_RUN_BAIL_TEXT$x)
5237
+ logger.logger.log(DRY_RUN_BAIL_TEXT$y)
5213
5238
  return
5214
5239
  }
5215
5240
 
@@ -5412,8 +5437,8 @@ async function handlePackageInfo({
5412
5437
  }
5413
5438
  }
5414
5439
 
5415
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
5416
- const config$z = {
5440
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
5441
+ const config$A = {
5417
5442
  commandName: 'info',
5418
5443
  description: 'Look up info regarding a package',
5419
5444
  hidden: true,
@@ -5438,14 +5463,14 @@ const config$z = {
5438
5463
  `
5439
5464
  }
5440
5465
  const cmdInfo = {
5441
- description: config$z.description,
5442
- hidden: config$z.hidden,
5443
- run: run$z
5466
+ description: config$A.description,
5467
+ hidden: config$A.hidden,
5468
+ run: run$A
5444
5469
  }
5445
- async function run$z(argv, importMeta, { parentName }) {
5470
+ async function run$A(argv, importMeta, { parentName }) {
5446
5471
  const cli = meowOrExit({
5447
5472
  argv,
5448
- config: config$z,
5473
+ config: config$A,
5449
5474
  importMeta,
5450
5475
  parentName
5451
5476
  })
@@ -5483,11 +5508,11 @@ async function run$z(argv, importMeta, { parentName }) {
5483
5508
  const pkgVersion =
5484
5509
  versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1)
5485
5510
  if (cli.flags['dryRun']) {
5486
- logger.logger.log(DRY_RUN_BAIL_TEXT$w)
5511
+ logger.logger.log(DRY_RUN_BAIL_TEXT$x)
5487
5512
  return
5488
5513
  }
5489
5514
  await handlePackageInfo({
5490
- commandName: `${parentName} ${config$z.commandName}`,
5515
+ commandName: `${parentName} ${config$A.commandName}`,
5491
5516
  includeAllIssues: Boolean(all),
5492
5517
  outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
5493
5518
  pkgName,
@@ -5574,8 +5599,8 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
5574
5599
  }
5575
5600
  }
5576
5601
 
5577
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
5578
- const config$y = {
5602
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
5603
+ const config$z = {
5579
5604
  commandName: 'login',
5580
5605
  description: 'Socket API login',
5581
5606
  hidden: false,
@@ -5608,21 +5633,21 @@ const config$y = {
5608
5633
  `
5609
5634
  }
5610
5635
  const cmdLogin = {
5611
- description: config$y.description,
5612
- hidden: config$y.hidden,
5613
- run: run$y
5636
+ description: config$z.description,
5637
+ hidden: config$z.hidden,
5638
+ run: run$z
5614
5639
  }
5615
- async function run$y(argv, importMeta, { parentName }) {
5640
+ async function run$z(argv, importMeta, { parentName }) {
5616
5641
  const cli = meowOrExit({
5617
5642
  argv,
5618
- config: config$y,
5643
+ config: config$z,
5619
5644
  importMeta,
5620
5645
  parentName
5621
5646
  })
5622
5647
  const apiBaseUrl = cli.flags['apiBaseUrl']
5623
5648
  const apiProxy = cli.flags['apiProxy']
5624
5649
  if (cli.flags['dryRun']) {
5625
- logger.logger.log(DRY_RUN_BAIL_TEXT$v)
5650
+ logger.logger.log(DRY_RUN_BAIL_TEXT$w)
5626
5651
  return
5627
5652
  }
5628
5653
  if (!isInteractive()) {
@@ -5655,8 +5680,8 @@ function attemptLogout() {
5655
5680
  }
5656
5681
  }
5657
5682
 
5658
- const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
5659
- const config$x = {
5683
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
5684
+ const config$y = {
5660
5685
  commandName: 'logout',
5661
5686
  description: 'Socket API logout',
5662
5687
  hidden: false,
@@ -5671,6 +5696,247 @@ const config$x = {
5671
5696
  `
5672
5697
  }
5673
5698
  const cmdLogout = {
5699
+ description: config$y.description,
5700
+ hidden: config$y.hidden,
5701
+ run: run$y
5702
+ }
5703
+ async function run$y(argv, importMeta, { parentName }) {
5704
+ const cli = meowOrExit({
5705
+ argv,
5706
+ config: config$y,
5707
+ importMeta,
5708
+ parentName
5709
+ })
5710
+ if (cli.flags['dryRun']) {
5711
+ logger.logger.log(DRY_RUN_BAIL_TEXT$v)
5712
+ return
5713
+ }
5714
+ attemptLogout()
5715
+ }
5716
+
5717
+ async function convertCondaToRequirements(target, cwd, verbose) {
5718
+ let contents
5719
+ if (target === '-') {
5720
+ if (verbose) {
5721
+ logger.logger.error(`[VERBOSE] reading input from stdin`)
5722
+ }
5723
+ const buf = []
5724
+ contents = await new Promise((resolve, reject) => {
5725
+ process.stdin.on('data', chunk => {
5726
+ const input = chunk.toString()
5727
+ buf.push(input)
5728
+ })
5729
+ process.stdin.on('end', () => {
5730
+ resolve(buf.join(''))
5731
+ })
5732
+ process.stdin.on('error', e => {
5733
+ if (verbose) {
5734
+ logger.logger.error('Unexpected error while reading from stdin:', e)
5735
+ }
5736
+ reject(e)
5737
+ })
5738
+ process.stdin.on('close', () => {
5739
+ if (buf.length === 0) {
5740
+ if (verbose) {
5741
+ logger.logger.error('stdin closed explicitly without data received')
5742
+ }
5743
+ reject(new Error('No data received from stdin'))
5744
+ } else {
5745
+ if (verbose) {
5746
+ logger.logger.error(
5747
+ 'warning: stdin closed explicitly with some data received'
5748
+ )
5749
+ }
5750
+ resolve(buf.join(''))
5751
+ }
5752
+ })
5753
+ })
5754
+ if (!contents) {
5755
+ return {
5756
+ ok: false,
5757
+ message: 'No data received from stdin',
5758
+ data: undefined
5759
+ }
5760
+ }
5761
+ } else {
5762
+ const f = path$1.resolve(cwd, target)
5763
+ if (verbose) {
5764
+ logger.logger.error(`[VERBOSE] target file: ${f}`)
5765
+ }
5766
+ if (!fs$1.existsSync(f)) {
5767
+ return {
5768
+ ok: false,
5769
+ message: `Input file not found at ${f}`,
5770
+ data: undefined
5771
+ }
5772
+ }
5773
+ contents = fs$1.readFileSync(target, 'utf8')
5774
+ if (!contents) {
5775
+ return {
5776
+ ok: false,
5777
+ message: 'File is empty',
5778
+ data: undefined
5779
+ }
5780
+ }
5781
+ }
5782
+ return {
5783
+ ok: true,
5784
+ message: '',
5785
+ data: {
5786
+ contents,
5787
+ pip: convertCondaToRequirementsFromInput(contents)
5788
+ }
5789
+ }
5790
+ }
5791
+
5792
+ // Just extract the first pip block, if one exists at all.
5793
+ function convertCondaToRequirementsFromInput(input) {
5794
+ const keeping = []
5795
+ let collecting = false
5796
+ let delim = '-'
5797
+ let indent = ''
5798
+ input.split('\n').some(line => {
5799
+ if (!line) {
5800
+ // Ignore empty lines
5801
+ return
5802
+ }
5803
+ if (collecting) {
5804
+ if (line.startsWith('#')) {
5805
+ // Ignore comment lines (keep?)
5806
+ return
5807
+ }
5808
+ if (line.startsWith(delim)) {
5809
+ // In this case we have a line with the same indentation as the
5810
+ // `- pip:` line, so we have reached the end of the pip block.
5811
+ return true // the end
5812
+ } else {
5813
+ if (!indent) {
5814
+ // Store the indentation of the block
5815
+ if (line.trim().startsWith('-')) {
5816
+ indent = line.split('-')[0] + '-'
5817
+ if (indent.length <= delim.length) {
5818
+ // The first line after the `pip:` line does not indent further
5819
+ // than that so the block is empty?
5820
+ return true
5821
+ }
5822
+ }
5823
+ }
5824
+ if (line.startsWith(indent)) {
5825
+ keeping.push(line.slice(indent.length).trim())
5826
+ } else {
5827
+ // Unexpected input. bail.
5828
+ return true
5829
+ }
5830
+ }
5831
+ } else {
5832
+ // Note: the line may end with a line comment so don't === it.
5833
+ if (line.trim().startsWith('- pip:')) {
5834
+ delim = line.split('-')[0] + '-'
5835
+ collecting = true
5836
+ }
5837
+ }
5838
+ })
5839
+ return keeping.join('\n')
5840
+ }
5841
+
5842
+ async function outputRequirements(data, outputKind, out) {
5843
+ if (outputKind === 'json') {
5844
+ const json = JSON.stringify(
5845
+ {
5846
+ ok: true,
5847
+ data: {
5848
+ pip: data.pip
5849
+ }
5850
+ },
5851
+ undefined,
5852
+ 2
5853
+ )
5854
+ if (out === '-') {
5855
+ logger.logger.log(json)
5856
+ } else {
5857
+ fs$1.writeFileSync(out, json, 'utf8')
5858
+ }
5859
+ return
5860
+ }
5861
+ if (outputKind === 'markdown') {
5862
+ const arr = []
5863
+ arr.push('# Converted Conda file')
5864
+ arr.push('')
5865
+ arr.push(
5866
+ 'This is the Conda `environment.yml` file converted to python `requirements.txt`:'
5867
+ )
5868
+ arr.push('')
5869
+ arr.push('```file=requirements.txt')
5870
+ arr.push(data.pip)
5871
+ arr.push('```')
5872
+ arr.push('')
5873
+ const md = arr.join('\n')
5874
+ if (out === '-') {
5875
+ logger.logger.log(md)
5876
+ } else {
5877
+ fs$1.writeFileSync(out, md, 'utf8')
5878
+ }
5879
+ return
5880
+ }
5881
+ if (out === '-') {
5882
+ logger.logger.log(data.pip)
5883
+ logger.logger.log('')
5884
+ } else {
5885
+ fs$1.writeFileSync(out, data.pip, 'utf8')
5886
+ }
5887
+ }
5888
+
5889
+ async function handleManifestConda(target, out, outputKind, cwd, verbose) {
5890
+ const data = await convertCondaToRequirements(target, cwd, verbose)
5891
+ if (!data) {
5892
+ return
5893
+ }
5894
+ if (!data.ok) {
5895
+ logger.logger.fail(data.message)
5896
+ return
5897
+ }
5898
+ await outputRequirements(data.data, outputKind, out)
5899
+ }
5900
+
5901
+ const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
5902
+ const config$x = {
5903
+ commandName: 'conda',
5904
+ description:
5905
+ '[beta] Convert a Conda environment.yml file to a python requirements.txt',
5906
+ hidden: false,
5907
+ flags: {
5908
+ ...commonFlags,
5909
+ ...outputFlags,
5910
+ cwd: {
5911
+ type: 'string',
5912
+ description: 'Set the cwd, defaults to process.cwd()'
5913
+ },
5914
+ out: {
5915
+ type: 'string',
5916
+ default: '-',
5917
+ description: 'Output target (use `-` or omit to print to stdout)'
5918
+ },
5919
+ verbose: {
5920
+ type: 'boolean',
5921
+ description: 'Print debug messages'
5922
+ }
5923
+ },
5924
+ help: (command, config) => `
5925
+ Usage
5926
+ $ ${command} FILE
5927
+
5928
+ Note: FILE can be a dash (-) to indicate stdin. This way you can pipe the
5929
+ contents of a file to have it processed.
5930
+
5931
+ Options
5932
+ ${getFlagListOutput(config.flags, 6)}
5933
+
5934
+ Examples
5935
+
5936
+ $ ${command} ./environment.yml
5937
+ `
5938
+ }
5939
+ const cmdManifestConda = {
5674
5940
  description: config$x.description,
5675
5941
  hidden: config$x.hidden,
5676
5942
  run: run$x
@@ -5682,11 +5948,59 @@ async function run$x(argv, importMeta, { parentName }) {
5682
5948
  importMeta,
5683
5949
  parentName
5684
5950
  })
5951
+ const {
5952
+ cwd = process.cwd(),
5953
+ json = false,
5954
+ markdown = false,
5955
+ out = '-',
5956
+ verbose = false
5957
+ } = cli.flags
5958
+ const [target = ''] = cli.input
5959
+ if (verbose) {
5960
+ logger.logger.group('- ', parentName, config$x.commandName, ':')
5961
+ logger.logger.group('- flags:', cli.flags)
5962
+ logger.logger.groupEnd()
5963
+ logger.logger.log('- target:', target)
5964
+ logger.logger.log('- output:', out)
5965
+ logger.logger.groupEnd()
5966
+ }
5967
+ const wasBadInput = handleBadInput(
5968
+ {
5969
+ test: !!target,
5970
+ message: 'The FILE arg is required',
5971
+ pass: 'ok',
5972
+ fail: 'missing'
5973
+ },
5974
+ {
5975
+ nook: true,
5976
+ test: cli.input.length <= 1,
5977
+ message: 'Can only accept one DIR (make sure to escape spaces!)',
5978
+ pass: 'ok',
5979
+ fail: 'received ' + cli.input.length
5980
+ },
5981
+ {
5982
+ nook: true,
5983
+ test: !json || !markdown,
5984
+ message:
5985
+ 'The `--json` and `--markdown` flags can not be used at the same time',
5986
+ pass: 'ok',
5987
+ fail: 'bad'
5988
+ }
5989
+ )
5990
+ if (wasBadInput) {
5991
+ return
5992
+ }
5685
5993
  if (cli.flags['dryRun']) {
5686
5994
  logger.logger.log(DRY_RUN_BAIL_TEXT$u)
5687
5995
  return
5688
5996
  }
5689
- attemptLogout()
5997
+ await handleManifestConda(
5998
+ target,
5999
+ String(out || ''),
6000
+ json ? 'json' : markdown ? 'markdown' : 'text',
6001
+ String(cwd),
6002
+ Boolean(verbose)
6003
+ )
5690
6004
  }
5691
6005
 
5692
6006
  async function convertGradleToMaven(target, bin, cwd, verbose, gradleOpts) {
@@ -6292,6 +6606,25 @@ async function run$u(argv, importMeta, { parentName }) {
6292
6606
  })
6293
6607
  return
6294
6608
  }
6609
+ const envyml = path$1.join(dir, 'environment.yml')
6610
+ const hasEnvyml = fs$1.existsSync(envyml)
6611
+ const envyaml = path$1.join(dir, 'environment.yaml')
6612
+ const hasEnvyaml = !hasEnvyml && fs$1.existsSync(envyaml)
6613
+ if (hasEnvyml || hasEnvyaml) {
6614
+ logger.logger.log(
6615
+ 'Detected an environment.yml file, running default Conda generator...'
6616
+ )
6617
+ // This command takes the TARGET as first arg.
6618
+ subArgs.push(hasEnvyml ? envyml : hasEnvyaml ? envyaml : '')
6619
+ if (cli.flags['dryRun']) {
6620
+ logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6621
+ return
6622
+ }
6623
+ await cmdManifestConda.run(subArgs, importMeta, {
6624
+ parentName
6625
+ })
6626
+ return
6627
+ }
6295
6628
  if (cli.flags['dryRun']) {
6296
6629
  logger.logger.log(DRY_RUN_BAIL_TEXT$r)
6297
6630
  return
@@ -6482,6 +6815,7 @@ async function run$s(argv, importMeta, { parentName }) {
6482
6815
  await meowWithSubcommands(
6483
6816
  {
6484
6817
  auto: cmdManifestAuto,
6818
+ conda: cmdManifestConda,
6485
6819
  scala: cmdManifestScala,
6486
6820
  gradle: cmdManifestGradle,
6487
6821
  kotlin: cmdManifestKotlin
@@ -9925,11 +10259,6 @@ const config$8 = {
9925
10259
  description:
9926
10260
  '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.'
9927
10261
  },
9928
- dryRun: {
9929
- type: 'boolean',
9930
- description:
9931
- 'Run input validation part of command without any concrete side effects'
9932
- },
9933
10262
  pendingHead: {
9934
10263
  type: 'boolean',
9935
10264
  default: true,
@@ -11934,7 +12263,7 @@ void (async () => {
11934
12263
  await vendor.updater({
11935
12264
  name: SOCKET_CLI_BIN_NAME,
11936
12265
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11937
- version: '0.14.105',
12266
+ version: '0.14.106',
11938
12267
  ttl: 86_400_000 /* 24 hours in milliseconds */
11939
12268
  })
11940
12269
  try {
@@ -12002,5 +12331,5 @@ void (async () => {
12002
12331
  await shadowNpmInject.captureException(e)
12003
12332
  }
12004
12333
  })()
12005
- //# debugId=355c3c9c-6359-4420-bd4f-783c50a21ad6
12334
+ //# debugId=b25de489-8925-4012-8959-2813dc2dbb5c
12006
12335
  //# sourceMappingURL=cli.js.map