@socketsecurity/cli-with-sentry 0.14.45 → 0.14.47

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.
@@ -24,11 +24,12 @@ var path = require('node:path');
24
24
  var ndjson = _socketInterop(require('ndjson'));
25
25
  var index = require('./index.js');
26
26
  var objects = require('@socketsecurity/registry/lib/objects');
27
+ var regexps = require('@socketsecurity/registry/lib/regexps');
28
+ var constants = require('./constants.js');
27
29
  var fs$1 = require('node:fs/promises');
28
30
  var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
29
31
  var contrib = _socketInterop(require('blessed-contrib'));
30
32
  var spinner = require('@socketsecurity/registry/lib/spinner');
31
- var constants = require('./constants.js');
32
33
  var prompts = require('@socketsecurity/registry/lib/prompts');
33
34
  var yargsParse = _socketInterop(require('yargs-parser'));
34
35
  var words = require('@socketsecurity/registry/lib/words');
@@ -51,14 +52,12 @@ var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
51
52
  var sorts = require('@socketsecurity/registry/lib/sorts');
52
53
  var strings = require('@socketsecurity/registry/lib/strings');
53
54
  var yaml = _socketInterop(require('yaml'));
54
- var regexps = require('@socketsecurity/registry/lib/regexps');
55
55
  var npm$1 = require('./npm.js');
56
56
  var npmPaths = require('./npm-paths.js');
57
57
  var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
58
58
  var config$A = require('@socketsecurity/config');
59
59
  var readline = require('node:readline/promises');
60
60
  var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
61
- var os = require('node:os');
62
61
  var readline$1 = require('node:readline');
63
62
 
64
63
  // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/classes.py
@@ -1318,6 +1317,11 @@ const commonFlags = {
1318
1317
  default: false,
1319
1318
  shortFlag: 'h',
1320
1319
  description: 'Print this help.'
1320
+ },
1321
+ dryRun: {
1322
+ type: 'boolean',
1323
+ default: false,
1324
+ description: 'Do input validation for a command and exit 0 when input is ok'
1321
1325
  }
1322
1326
  };
1323
1327
  const outputFlags = {
@@ -1347,10 +1351,9 @@ const validationFlags = {
1347
1351
  }
1348
1352
  };
1349
1353
 
1350
- // Property names are picked such that the name is at the top when the props
1351
- // get ordered by alphabet while flags is near the bottom and the help text
1352
- // at the bottom, because they tend ot occupy the most lines of code.
1353
-
1354
+ const {
1355
+ SOCKET_CLI_SHOW_BANNER
1356
+ } = constants;
1354
1357
  async function meowWithSubcommands(subcommands, options) {
1355
1358
  const {
1356
1359
  aliases = {},
@@ -1363,12 +1366,12 @@ async function meowWithSubcommands(subcommands, options) {
1363
1366
  ...options
1364
1367
  };
1365
1368
  const [commandOrAliasName, ...rawCommandArgv] = argv;
1366
- // If we got at least some args, then lets find out if we can find a command
1369
+ // If we got at least some args, then lets find out if we can find a command.
1367
1370
  if (commandOrAliasName) {
1368
1371
  const alias = aliases[commandOrAliasName];
1369
- // First: Resolve argv data from alias if its an alias that's been given
1372
+ // First: Resolve argv data from alias if its an alias that's been given.
1370
1373
  const [commandName, ...commandArgv] = alias ? [...alias.argv, ...rawCommandArgv] : [commandOrAliasName, ...rawCommandArgv];
1371
- // Second: Find a command definition using that data
1374
+ // Second: Find a command definition using that data.
1372
1375
  const commandDefinition = commandName ? subcommands[commandName] : undefined;
1373
1376
  // Third: If a valid command has been found, then we run it...
1374
1377
  if (commandDefinition) {
@@ -1381,7 +1384,13 @@ async function meowWithSubcommands(subcommands, options) {
1381
1384
  ...commonFlags,
1382
1385
  ...additionalOptions.flags
1383
1386
  };
1384
- // ...else we provide basic instructions and help
1387
+ // ...else we provide basic instructions and help.
1388
+
1389
+ // Temp disable until we clear the --json and --markdown usage
1390
+ // Lazily access constants.ENV[SOCKET_CLI_SHOW_BANNER].
1391
+ if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) {
1392
+ console.log(getAsciiHeader(name));
1393
+ }
1385
1394
  const cli = vendor.meow(`
1386
1395
  Usage
1387
1396
  $ ${name} <command>
@@ -1412,9 +1421,15 @@ async function meowWithSubcommands(subcommands, options) {
1412
1421
  argv,
1413
1422
  importMeta,
1414
1423
  ...additionalOptions,
1415
- flags
1424
+ flags,
1425
+ autoHelp: false // otherwise we can't exit(0)
1416
1426
  });
1417
- cli.showHelp();
1427
+ if (!cli.flags['help'] && cli.flags['dryRun']) {
1428
+ console.log('[DryRun]: noop, call a sub-command; ok');
1429
+ process.exitCode = 0;
1430
+ } else {
1431
+ cli.showHelp();
1432
+ }
1418
1433
  }
1419
1434
 
1420
1435
  /**
@@ -1429,19 +1444,40 @@ function meowOrExit({
1429
1444
  parentName
1430
1445
  }) {
1431
1446
  const command = `${parentName} ${config.commandName}`;
1432
- const help = config.help(command, config);
1433
-
1447
+ // Temp disable until we clear the --json and --markdown usage.
1448
+ // Lazily access constants.ENV[SOCKET_CLI_SHOW_BANNER].
1449
+ if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) {
1450
+ console.log(getAsciiHeader(command));
1451
+ }
1434
1452
  // This exits if .printHelp() is called either by meow itself or by us.
1435
1453
  const cli = vendor.meow({
1436
1454
  argv,
1437
1455
  description: config.description,
1438
- help,
1456
+ help: config.help(command, config),
1439
1457
  importMeta,
1440
1458
  flags: config.flags,
1441
- allowUnknownFlags: Boolean(allowUnknownFlags)
1459
+ allowUnknownFlags: Boolean(allowUnknownFlags),
1460
+ autoHelp: false // otherwise we can't exit(0)
1442
1461
  });
1462
+ if (cli.flags['help']) {
1463
+ cli.showHelp();
1464
+ }
1443
1465
  return cli;
1444
1466
  }
1467
+ function getAsciiHeader(command) {
1468
+ const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']".
1469
+ "0.14.47:e0c97e0:714b50c6:pub";
1470
+ const nodeVersion = process.version;
1471
+ // Get the last 5 characters of the API token before the trailing "_api".
1472
+ const lastFiveCharsOfApiToken = index.getSetting('apiToken')?.slice(-9, -4) || 'no';
1473
+ const relCwd = process.cwd().replace(new RegExp(`^${regexps.escapeRegExp(constants.homePath)}`, 'i'), '~/');
1474
+ const body = `
1475
+ _____ _ _ /---------------
1476
+ | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
1477
+ |__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${lastFiveCharsOfApiToken}
1478
+ |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart();
1479
+ return ` ${body}\n`;
1480
+ }
1445
1481
 
1446
1482
  // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/socketcli.py
1447
1483
 
@@ -1468,12 +1504,11 @@ const config$z = {
1468
1504
  description: 'After marker'
1469
1505
  }
1470
1506
  },
1471
- help: (parentName, {
1472
- commandName,
1507
+ help: (command, {
1473
1508
  flags
1474
1509
  }) => `
1475
1510
  Usage
1476
- $ ${parentName} ${commandName} [options]
1511
+ $ ${command} [options]
1477
1512
 
1478
1513
  Options
1479
1514
  ${getFlagListOutput(flags, 6)}
@@ -1495,6 +1530,7 @@ async function run$z(argv, importMeta, {
1495
1530
  });
1496
1531
  const githubEventBefore = String(cli.flags['githubEventBefore'] || '');
1497
1532
  const githubEventAfter = String(cli.flags['githubEventAfter'] || '');
1533
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
1498
1534
  await runAction(githubEventBefore, githubEventAfter);
1499
1535
  }
1500
1536
 
@@ -1760,12 +1796,11 @@ const config$y = {
1760
1796
  description: 'Path to a local file to save the output'
1761
1797
  }
1762
1798
  },
1763
- help: (parentName, {
1764
- commandName,
1799
+ help: (command, {
1765
1800
  flags
1766
1801
  }) => `
1767
1802
  Usage
1768
- $ ${parentName} ${commandName} --scope=<scope> --time=<time filter>
1803
+ $ ${command} --scope=<scope> --time=<time filter>
1769
1804
 
1770
1805
  Default parameters are set to show the organization-level analytics over the
1771
1806
  last 7 days.
@@ -1774,9 +1809,9 @@ const config$y = {
1774
1809
  ${getFlagListOutput(flags, 6)}
1775
1810
 
1776
1811
  Examples
1777
- $ ${parentName} ${commandName} --scope=org --time=7
1778
- $ ${parentName} ${commandName} --scope=org --time=30
1779
- $ ${parentName} ${commandName} --scope=repo --repo=test-repo --time=30
1812
+ $ ${command} --scope=org --time=7
1813
+ $ ${command} --scope=org --time=30
1814
+ $ ${command} --scope=repo --repo=test-repo --time=30
1780
1815
  `
1781
1816
  };
1782
1817
  const cmdAnalytics = {
@@ -1802,14 +1837,17 @@ async function run$y(argv, importMeta, {
1802
1837
  const badTime = time !== 7 && time !== 30 && time !== 90;
1803
1838
  const badRepo = scope === 'repo' && !repo;
1804
1839
  if (badScope || badTime || badRepo) {
1840
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
1841
+ // options or missing arguments.
1842
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
1843
+ process.exitCode = 2;
1805
1844
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
1806
1845
  - Scope must be "repo" or "org" ${badScope ? colors.red('(bad!)') : colors.green('(ok)')}\n
1807
1846
  - The time filter must either be 7, 30 or 90 ${badTime ? colors.red('(bad!)') : colors.green('(ok)')}\n
1808
- - Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}\n
1809
- `);
1810
- cli.showHelp();
1847
+ - Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}\n`);
1811
1848
  return;
1812
1849
  }
1850
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
1813
1851
  const apiToken = index.getDefaultToken();
1814
1852
  if (!apiToken) {
1815
1853
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API token.');
@@ -1929,12 +1967,15 @@ async function run$x(argv, importMeta, {
1929
1967
  const type = String(cli.flags['type'] || '');
1930
1968
  const [orgSlug = ''] = cli.input;
1931
1969
  if (!orgSlug) {
1970
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
1971
+ // options or missing arguments.
1972
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
1973
+ process.exitCode = 2;
1932
1974
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
1933
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
1934
- `);
1935
- config$x.help(parentName, config$x);
1975
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
1936
1976
  return;
1937
1977
  }
1978
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
1938
1979
  const apiToken = index.getDefaultToken();
1939
1980
  if (!apiToken) {
1940
1981
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -2025,7 +2066,6 @@ function argvToArray(argv) {
2025
2066
  }
2026
2067
 
2027
2068
  // import { meowOrExit } from '../../utils/meow-with-subcommands'
2028
-
2029
2069
  // TODO: convert yargs to meow. Or convert all the other things to yargs.
2030
2070
  const toLower = arg => arg.toLowerCase();
2031
2071
  const arrayToLower = arg => arg.map(toLower);
@@ -2097,23 +2137,36 @@ const yargsConfig = {
2097
2137
  string: ['api-key', 'lifecycle', 'output', 'parent-project-id', 'profile', 'project-group', 'project-name', 'project-version', 'project-id', 'server-host', 'server-port', 'server-url', 'spec-version']
2098
2138
  };
2099
2139
  const config$w = {
2140
+ commandName: 'cdxgen',
2100
2141
  description: 'Create an SBOM with CycloneDX generator (cdxgen)',
2101
- hidden: false};
2142
+ hidden: false,
2143
+ flags: {
2144
+ // TODO: convert from yargsConfig
2145
+ },
2146
+ help: (command, config) => `
2147
+ Usage
2148
+ $ ${command} [options]
2149
+
2150
+ Options
2151
+ ${getFlagListOutput(config.flags, 6)}
2152
+ `
2153
+ };
2102
2154
  const cmdCdxgen = {
2103
2155
  description: config$w.description,
2104
2156
  hidden: config$w.hidden,
2105
2157
  run: run$w
2106
2158
  };
2107
- async function run$w(argv, _importMeta, {
2108
- parentName: _parentName
2159
+ async function run$w(argv, importMeta, {
2160
+ parentName
2109
2161
  }) {
2110
- // const cli = meowOrExit({
2111
- // allowUnknownFlags: true,
2112
- // argv,
2113
- // config,
2114
- // importMeta,
2115
- // parentName,
2116
- // })
2162
+ const cli = meowOrExit({
2163
+ allowUnknownFlags: true,
2164
+ argv: argv.filter(s => s !== '--help' && s !== '-h'),
2165
+ // Don't let meow take over --help
2166
+ config: config$w,
2167
+ importMeta,
2168
+ parentName
2169
+ });
2117
2170
  //
2118
2171
  //
2119
2172
  // if (cli.input.length)
@@ -2134,13 +2187,17 @@ async function run$w(argv, _importMeta, {
2134
2187
  length: unknownLength
2135
2188
  } = unknown;
2136
2189
  if (unknownLength) {
2137
- process$1.exitCode = 1;
2190
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
2191
+ // options or missing arguments.
2192
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
2193
+ process$1.exitCode = 2;
2138
2194
  console.error(`Unknown ${words.pluralize('argument', unknownLength)}: ${yargv._.join(', ')}`);
2139
2195
  return;
2140
2196
  }
2141
2197
  if (yargv.output === undefined) {
2142
2198
  yargv.output = 'socket-cdx.json';
2143
2199
  }
2200
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2144
2201
  await runCycloneDX(yargv);
2145
2202
  }
2146
2203
 
@@ -2243,6 +2300,7 @@ async function run$v(argv, importMeta, {
2243
2300
  importMeta,
2244
2301
  parentName
2245
2302
  });
2303
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2246
2304
 
2247
2305
  // TODO: markdown flag is ignored
2248
2306
  await findDependencies({
@@ -2354,14 +2412,17 @@ async function run$u(argv, importMeta, {
2354
2412
  const after = String(cli.flags['after'] || '');
2355
2413
  const [orgSlug = ''] = cli.input;
2356
2414
  if (!before || !after || cli.input.length < 1) {
2415
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
2416
+ // options or missing arguments.
2417
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
2418
+ process.exitCode = 2;
2357
2419
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
2358
2420
  - Specify a before and after full scan ID ${!before && !after ? colors.red('(missing before and after!)') : !before ? colors.red('(missing before!)') : !after ? colors.red('(missing after!)') : colors.green('(ok)')}\n
2359
2421
  - To get full scans IDs, you can run the command "socket scan list <your org slug>".
2360
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n}
2361
- `);
2362
- config$u.help(parentName, config$u);
2422
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
2363
2423
  return;
2364
2424
  }
2425
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2365
2426
  const apiToken = index.getDefaultToken();
2366
2427
  if (!apiToken) {
2367
2428
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -2504,7 +2565,9 @@ const config$t = {
2504
2565
  commandName: 'fix',
2505
2566
  description: 'Fix "fixable" Socket alerts',
2506
2567
  hidden: true,
2507
- flags: {},
2568
+ flags: {
2569
+ ...commonFlags
2570
+ },
2508
2571
  help: (command, config) => `
2509
2572
  Usage
2510
2573
  $ ${command}
@@ -2521,12 +2584,13 @@ const cmdFix = {
2521
2584
  async function run$t(argv, importMeta, {
2522
2585
  parentName
2523
2586
  }) {
2524
- meowOrExit({
2587
+ const cli = meowOrExit({
2525
2588
  argv,
2526
2589
  config: config$t,
2527
2590
  importMeta,
2528
2591
  parentName
2529
2592
  });
2593
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2530
2594
  await runFix();
2531
2595
  }
2532
2596
 
@@ -2775,23 +2839,21 @@ async function run$s(argv, importMeta, {
2775
2839
  importMeta,
2776
2840
  parentName
2777
2841
  });
2778
- if (cli.input.length > 1) {
2779
- throw new index.InputError('Only one package lookup supported at once');
2780
- }
2781
- const {
2782
- 0: rawPkgName = ''
2783
- } = cli.input;
2784
- let showHelp = cli.flags['help'];
2785
- if (!rawPkgName) {
2786
- showHelp = true;
2787
- }
2788
- if (showHelp) {
2789
- cli.showHelp();
2842
+ const [rawPkgName = ''] = cli.input;
2843
+ if (!rawPkgName || cli.input.length > 1) {
2844
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
2845
+ // options or missing arguments.
2846
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
2847
+ process.exitCode = 2;
2848
+ console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
2849
+ - Expecting a package name ${!rawPkgName ? colors.red('(missing!)') : colors.green('(ok)')}\n
2850
+ - Can only accept one package at a time ${cli.input.length > 1 ? colors.red('(got ' + cli.input.length + '!)') : colors.green('(ok)')}\n`);
2790
2851
  return;
2791
2852
  }
2792
2853
  const versionSeparator = rawPkgName.lastIndexOf('@');
2793
2854
  const pkgName = versionSeparator < 1 ? rawPkgName : rawPkgName.slice(0, versionSeparator);
2794
2855
  const pkgVersion = versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1);
2856
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2795
2857
  await getPackageInfo({
2796
2858
  commandName: `${parentName} ${config$s.commandName}`,
2797
2859
  includeAllIssues: Boolean(cli.flags['all']),
@@ -2880,6 +2942,7 @@ const config$r = {
2880
2942
  description: 'Socket API login',
2881
2943
  hidden: false,
2882
2944
  flags: {
2945
+ ...commonFlags,
2883
2946
  apiBaseUrl: {
2884
2947
  type: 'string',
2885
2948
  description: 'API server to connect to for login'
@@ -2917,11 +2980,12 @@ async function run$r(argv, importMeta, {
2917
2980
  importMeta,
2918
2981
  parentName
2919
2982
  });
2983
+ let apiBaseUrl = cli.flags['apiBaseUrl'];
2984
+ let apiProxy = cli.flags['apiProxy'];
2985
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2920
2986
  if (!isInteractive()) {
2921
2987
  throw new index.InputError('Cannot prompt for credentials in a non-interactive shell');
2922
2988
  }
2923
- let apiBaseUrl = cli.flags['apiBaseUrl'];
2924
- let apiProxy = cli.flags['apiProxy'];
2925
2989
  await attemptLogin(apiBaseUrl, apiProxy);
2926
2990
  }
2927
2991
 
@@ -2945,7 +3009,9 @@ const config$q = {
2945
3009
  commandName: 'logout',
2946
3010
  description: 'Socket API logout',
2947
3011
  hidden: false,
2948
- flags: {},
3012
+ flags: {
3013
+ ...commonFlags
3014
+ },
2949
3015
  help: (command, _config) => `
2950
3016
  Usage
2951
3017
  $ ${command}
@@ -2961,12 +3027,13 @@ const cmdLogout = {
2961
3027
  async function run$q(argv, importMeta, {
2962
3028
  parentName
2963
3029
  }) {
2964
- meowOrExit({
3030
+ const cli = meowOrExit({
2965
3031
  argv,
2966
3032
  config: config$q,
2967
3033
  importMeta,
2968
3034
  parentName
2969
3035
  });
3036
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
2970
3037
  attemptLogout();
2971
3038
  }
2972
3039
 
@@ -3143,13 +3210,11 @@ const cmdManifestGradle = {
3143
3210
  async function run$p(argv, importMeta, {
3144
3211
  parentName
3145
3212
  }) {
3146
- // note: meow will exit if it prints the --help screen
3147
- const cli = vendor.meow(config$p.help(parentName, config$p), {
3148
- flags: config$p.flags,
3149
- argv: argv.length === 0 ? ['--help'] : argv,
3150
- description: config$p.description,
3151
- allowUnknownFlags: false,
3152
- importMeta
3213
+ const cli = meowOrExit({
3214
+ argv,
3215
+ config: config$p,
3216
+ importMeta,
3217
+ parentName
3153
3218
  });
3154
3219
  const verbose = Boolean(cli.flags['verbose']);
3155
3220
  if (verbose) {
@@ -3160,15 +3225,18 @@ async function run$p(argv, importMeta, {
3160
3225
  console.groupEnd();
3161
3226
  }
3162
3227
  const target = cli.input[0];
3163
- if (!target) {
3164
- // will exit.
3165
- new spinner.Spinner().start('Parsing...').error(`Failure: Missing DIR argument. See \`${parentName} ${config$p.commandName} --help\` for details.`);
3166
- process.exit(1);
3167
- }
3168
- if (cli.input.length > 1) {
3169
- // will exit.
3170
- new spinner.Spinner().start('Parsing...').error(`Failure: Can only accept one FILE or DIR, received ${cli.input.length} (make sure to escape spaces!). See \`${parentName} ${config$p.commandName} --help\` for details.`);
3171
- process.exit(1);
3228
+
3229
+ // TODO: I'm not sure it's feasible to parse source file from stdin. We could try, store contents in a file in some folder, target that folder... what would the file name be?
3230
+
3231
+ if (!target || target === '-' || cli.input.length > 1) {
3232
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
3233
+ // options or missing arguments.
3234
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
3235
+ process.exitCode = 2;
3236
+ console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
3237
+ - The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
3238
+ - Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
3239
+ return;
3172
3240
  }
3173
3241
  let bin;
3174
3242
  if (cli.flags['bin']) {
@@ -3183,12 +3251,6 @@ async function run$p(argv, importMeta, {
3183
3251
  if (cli.flags['stdout']) {
3184
3252
  out = '-';
3185
3253
  }
3186
-
3187
- // TODO: I'm not sure it's feasible to parse source file from stdin. We could try, store contents in a file in some folder, target that folder... what would the file name be?
3188
- if (target === '-') {
3189
- new spinner.Spinner().start('Parsing...').error(`Failure: Currently source code from stdin is not supported. See \`${parentName} ${config$p.commandName} --help\` for details.`);
3190
- process.exit(1);
3191
- }
3192
3254
  if (verbose) {
3193
3255
  console.group();
3194
3256
  console.log('- target:', target);
@@ -3200,6 +3262,7 @@ async function run$p(argv, importMeta, {
3200
3262
  if (cli.flags['gradleOpts']) {
3201
3263
  gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
3202
3264
  }
3265
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3203
3266
  await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
3204
3267
  }
3205
3268
 
@@ -3296,7 +3359,7 @@ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
3296
3359
  }
3297
3360
 
3298
3361
  const config$o = {
3299
- commandName: 'kotlin',
3362
+ commandName: 'scala',
3300
3363
  description: "[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
3301
3364
  hidden: false,
3302
3365
  flags: {
@@ -3373,13 +3436,11 @@ async function run$o(argv, importMeta, {
3373
3436
  parentName
3374
3437
  }) {
3375
3438
  // console.log('scala', argv, parentName)
3376
- // note: meow will exit if it prints the --help screen
3377
- const cli = vendor.meow(config$o.help(parentName, config$o), {
3378
- flags: config$o.flags,
3379
- argv: argv.length === 0 ? ['--help'] : argv,
3380
- description: config$o.description,
3381
- allowUnknownFlags: false,
3382
- importMeta
3439
+ const cli = meowOrExit({
3440
+ argv,
3441
+ config: config$o,
3442
+ importMeta,
3443
+ parentName
3383
3444
  });
3384
3445
  const verbose = Boolean(cli.flags['verbose']);
3385
3446
  if (verbose) {
@@ -3390,15 +3451,18 @@ async function run$o(argv, importMeta, {
3390
3451
  console.groupEnd();
3391
3452
  }
3392
3453
  const target = cli.input[0];
3393
- if (!target) {
3394
- // will exit.
3395
- new spinner.Spinner().start('Parsing...').error(`Failure: Missing FILE|DIR argument. See \`${parentName} ${config$o.commandName} --help\` for details.`);
3396
- process.exit(1);
3397
- }
3398
- if (cli.input.length > 1) {
3399
- // will exit.
3400
- new spinner.Spinner().start('Parsing...').error(`Failure: Can only accept one FILE or DIR, received ${cli.input.length} (make sure to escape spaces!). See \`${parentName} ${config$o.commandName} --help\` for details.`);
3401
- process.exit(1);
3454
+
3455
+ // TODO: I'm not sure it's feasible to parse source file from stdin. We could try, store contents in a file in some folder, target that folder... what would the file name be?
3456
+
3457
+ if (!target || target === '-' || cli.input.length > 1) {
3458
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
3459
+ // options or missing arguments.
3460
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
3461
+ process.exitCode = 2;
3462
+ console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
3463
+ - The DIR or FILE arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
3464
+ - Can only accept one DIR or FILE (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
3465
+ return;
3402
3466
  }
3403
3467
  let bin = 'sbt';
3404
3468
  if (cli.flags['bin']) {
@@ -3418,16 +3482,11 @@ async function run$o(argv, importMeta, {
3418
3482
  console.log('- out:', out);
3419
3483
  console.groupEnd();
3420
3484
  }
3421
-
3422
- // TODO: we can make `-` (accept from stdin) work by storing it into /tmp
3423
- if (target === '-') {
3424
- new spinner.Spinner().start('Parsing...').error(`Failure: Currently source code from stdin is not supported. See \`${parentName} ${config$o.commandName} --help\` for details.`);
3425
- process.exit(1);
3426
- }
3427
3485
  let sbtOpts = [];
3428
3486
  if (cli.flags['sbtOpts']) {
3429
3487
  sbtOpts = cli.flags['sbtOpts'].split(' ').map(s => s.trim()).filter(Boolean);
3430
3488
  }
3489
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3431
3490
  await convertSbtToMaven(target, bin, out, verbose, sbtOpts);
3432
3491
  }
3433
3492
 
@@ -3468,12 +3527,11 @@ const cmdManifestAuto = {
3468
3527
  async function run$n(argv, importMeta, {
3469
3528
  parentName
3470
3529
  }) {
3471
- const cli = vendor.meow(config$n.help(parentName, config$n), {
3530
+ const cli = meowOrExit({
3472
3531
  argv,
3473
- description: config$n.description,
3532
+ config: config$n,
3474
3533
  importMeta,
3475
- flags: config$n.flags,
3476
- allowUnknownFlags: false
3534
+ parentName
3477
3535
  });
3478
3536
  const verbose = !!cli.flags['verbose'];
3479
3537
  const cwd = cli.flags['cwd'] ?? process.cwd();
@@ -3496,6 +3554,7 @@ async function run$n(argv, importMeta, {
3496
3554
  subArgs.push('--cwd', cwd);
3497
3555
  }
3498
3556
  subArgs.push(dir);
3557
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3499
3558
  await cmdManifestScala.run(subArgs, importMeta, {
3500
3559
  parentName
3501
3560
  });
@@ -3507,11 +3566,13 @@ async function run$n(argv, importMeta, {
3507
3566
  // This command takes the cwd as first arg.
3508
3567
  subArgs.push(cwd);
3509
3568
  }
3569
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3510
3570
  await cmdManifestGradle.run(subArgs, importMeta, {
3511
3571
  parentName
3512
3572
  });
3513
3573
  return;
3514
3574
  }
3575
+
3515
3576
  // Show new help screen and exit.
3516
3577
  vendor.meow(`
3517
3578
  $ ${parentName} ${config$n.commandName}
@@ -3616,13 +3677,11 @@ const cmdManifestKotlin = {
3616
3677
  async function run$m(argv, importMeta, {
3617
3678
  parentName
3618
3679
  }) {
3619
- // note: meow will exit if it prints the --help screen
3620
- const cli = vendor.meow(config$m.help(parentName, config$m), {
3621
- flags: config$m.flags,
3622
- argv: argv.length === 0 ? ['--help'] : argv,
3623
- description: config$m.description,
3624
- allowUnknownFlags: false,
3625
- importMeta
3680
+ const cli = meowOrExit({
3681
+ argv,
3682
+ config: config$m,
3683
+ importMeta,
3684
+ parentName
3626
3685
  });
3627
3686
  const verbose = Boolean(cli.flags['verbose']);
3628
3687
  if (verbose) {
@@ -3633,15 +3692,18 @@ async function run$m(argv, importMeta, {
3633
3692
  console.groupEnd();
3634
3693
  }
3635
3694
  const target = cli.input[0];
3636
- if (!target) {
3637
- // will exit.
3638
- new spinner.Spinner().start('Parsing...').error(`Failure: Missing DIR argument. See \`${parentName} ${config$m.commandName} --help\` for details.`);
3639
- process.exit(1);
3640
- }
3641
- if (cli.input.length > 1) {
3642
- // will exit.
3643
- new spinner.Spinner().start('Parsing...').error(`Failure: Can only accept one FILE or DIR, received ${cli.input.length} (make sure to escape spaces!). See \`${parentName} ${config$m.commandName} --help\` for details.`);
3644
- process.exit(1);
3695
+
3696
+ // TODO: I'm not sure it's feasible to parse source file from stdin. We could try, store contents in a file in some folder, target that folder... what would the file name be?
3697
+
3698
+ if (!target || target === '-' || cli.input.length > 1) {
3699
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
3700
+ // options or missing arguments.
3701
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
3702
+ process.exitCode = 2;
3703
+ console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
3704
+ - The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
3705
+ - Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
3706
+ return;
3645
3707
  }
3646
3708
  let bin;
3647
3709
  if (cli.flags['bin']) {
@@ -3656,12 +3718,6 @@ async function run$m(argv, importMeta, {
3656
3718
  if (cli.flags['stdout']) {
3657
3719
  out = '-';
3658
3720
  }
3659
-
3660
- // TODO: I'm not sure it's feasible to parse source file from stdin. We could try, store contents in a file in some folder, target that folder... what would the file name be?
3661
- if (target === '-') {
3662
- new spinner.Spinner().start('Parsing...').error(`Failure: Currently source code from stdin is not supported. See \`${parentName} ${config$m.commandName} --help\` for details.`);
3663
- process.exit(1);
3664
- }
3665
3721
  if (verbose) {
3666
3722
  console.group();
3667
3723
  console.log('- target:', target);
@@ -3673,6 +3729,7 @@ async function run$m(argv, importMeta, {
3673
3729
  if (cli.flags['gradleOpts']) {
3674
3730
  gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
3675
3731
  }
3732
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3676
3733
  await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
3677
3734
  }
3678
3735
 
@@ -3743,13 +3800,14 @@ const cmdNpm = {
3743
3800
  async function run$k(argv, importMeta, {
3744
3801
  parentName
3745
3802
  }) {
3746
- meowOrExit({
3803
+ const cli = meowOrExit({
3747
3804
  allowUnknownFlags: true,
3748
3805
  argv,
3749
3806
  config: config$k,
3750
3807
  importMeta,
3751
3808
  parentName
3752
3809
  });
3810
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3753
3811
  await wrapNpm(argv);
3754
3812
  }
3755
3813
 
@@ -3784,13 +3842,14 @@ const cmdNpx = {
3784
3842
  async function run$j(argv, importMeta, {
3785
3843
  parentName
3786
3844
  }) {
3787
- meowOrExit({
3845
+ const cli = meowOrExit({
3788
3846
  allowUnknownFlags: true,
3789
3847
  argv,
3790
3848
  config: config$j,
3791
3849
  importMeta,
3792
3850
  parentName
3793
3851
  });
3852
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3794
3853
  await wrapNpx(argv);
3795
3854
  }
3796
3855
 
@@ -3798,7 +3857,9 @@ const config$i = {
3798
3857
  commandName: 'oops',
3799
3858
  description: 'Trigger an intentional error (for development)',
3800
3859
  hidden: true,
3801
- flags: {},
3860
+ flags: {
3861
+ ...commonFlags
3862
+ },
3802
3863
  help: (parentName, config) => `
3803
3864
  Usage
3804
3865
  $ ${parentName} ${config.commandName}
@@ -3814,12 +3875,13 @@ const cmdOops = {
3814
3875
  async function run$i(argv, importMeta, {
3815
3876
  parentName
3816
3877
  }) {
3817
- vendor.meow(config$i.help(parentName, config$i), {
3878
+ const cli = meowOrExit({
3818
3879
  argv,
3819
- description: config$i.description,
3880
+ config: config$i,
3820
3881
  importMeta,
3821
- flags: config$i.flags
3882
+ parentName
3822
3883
  });
3884
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
3823
3885
  throw new Error('This error was intentionally left blank');
3824
3886
  }
3825
3887
 
@@ -4852,7 +4914,7 @@ async function addOverrides({
4852
4914
  }
4853
4915
 
4854
4916
  const config$h = {
4855
- commandName: 'create',
4917
+ commandName: 'optimize',
4856
4918
  description: 'Optimize dependencies with @socketregistry overrides',
4857
4919
  hidden: false,
4858
4920
  flags: {
@@ -4895,6 +4957,7 @@ async function run$h(argv, importMeta, {
4895
4957
  parentName
4896
4958
  });
4897
4959
  const cwd = process$1.cwd();
4960
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
4898
4961
  await applyOptimization(cwd, Boolean(cli.flags['pin']), Boolean(cli.flags['prod']));
4899
4962
  }
4900
4963
 
@@ -4941,12 +5004,13 @@ const cmdOrganizations = {
4941
5004
  async function run$g(argv, importMeta, {
4942
5005
  parentName
4943
5006
  }) {
4944
- meowOrExit({
5007
+ const cli = meowOrExit({
4945
5008
  argv,
4946
5009
  config: config$g,
4947
5010
  importMeta,
4948
5011
  parentName
4949
5012
  });
5013
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
4950
5014
  await getOrganizations();
4951
5015
  }
4952
5016
 
@@ -4999,13 +5063,14 @@ const cmdRawNpm = {
4999
5063
  async function run$f(argv, importMeta, {
5000
5064
  parentName
5001
5065
  }) {
5002
- meowOrExit({
5066
+ const cli = meowOrExit({
5003
5067
  allowUnknownFlags: true,
5004
5068
  argv,
5005
5069
  config: config$f,
5006
5070
  importMeta,
5007
5071
  parentName
5008
5072
  });
5073
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5009
5074
  await runRawNpm(argv);
5010
5075
  }
5011
5076
 
@@ -5058,13 +5123,14 @@ const cmdRawNpx = {
5058
5123
  async function run$e(argv, importMeta, {
5059
5124
  parentName
5060
5125
  }) {
5061
- meowOrExit({
5126
+ const cli = meowOrExit({
5062
5127
  allowUnknownFlags: true,
5063
5128
  argv,
5064
5129
  config: config$e,
5065
5130
  importMeta,
5066
5131
  parentName
5067
5132
  });
5133
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5068
5134
  await runRawNpx(argv);
5069
5135
  }
5070
5136
 
@@ -5260,15 +5326,15 @@ async function run$d(argv, importMeta, {
5260
5326
  const strict = Boolean(cli.flags['strict']);
5261
5327
  const includeAllIssues = Boolean(cli.flags['all']);
5262
5328
  const view = Boolean(cli.flags['view']);
5329
+
5330
+ // Note exiting earlier to skirt a hidden auth requirement
5331
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5263
5332
  const socketConfig = await getSocketConfig(absoluteConfigPath);
5264
5333
  const result = await createReport(socketConfig, cli.input, {
5265
5334
  cwd,
5266
5335
  dryRun
5267
5336
  });
5268
5337
  const commandName = `${parentName} ${config$d.commandName}`;
5269
- if (dryRun && view) {
5270
- console.log('[dryrun] Ignoring view flag since no report was actually generated');
5271
- }
5272
5338
  if (result?.success) {
5273
5339
  if (view) {
5274
5340
  const reportId = result.data.id;
@@ -5329,13 +5395,16 @@ async function run$c(argv, importMeta, {
5329
5395
 
5330
5396
  // Validate the input.
5331
5397
  if (extraInput.length || !reportId) {
5398
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5399
+ // options or missing arguments.
5400
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5401
+ process.exitCode = 2;
5332
5402
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5333
5403
  - Need at least one report ID ${!reportId ? colors.red('(missing!)') : colors.green('(ok)')}\n
5334
- - Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}\n
5335
- `);
5336
- cli.showHelp();
5404
+ - Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}\n`);
5337
5405
  return;
5338
5406
  }
5407
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5339
5408
  await viewReport(reportId, {
5340
5409
  all: Boolean(cli.flags['all']),
5341
5410
  commandName: `${parentName} ${config$c.commandName}`,
@@ -5462,13 +5531,16 @@ async function run$b(argv, importMeta, {
5462
5531
  const repoName = cli.flags['repoName'];
5463
5532
  const [orgSlug = ''] = cli.input;
5464
5533
  if (!repoName || typeof repoName !== 'string' || !orgSlug) {
5534
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5535
+ // options or missing arguments.
5536
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5537
+ process.exitCode = 2;
5465
5538
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5466
5539
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5467
- - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
5468
- `);
5469
- cli.showHelp();
5540
+ - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
5470
5541
  return;
5471
5542
  }
5543
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5472
5544
  const apiToken = index.getDefaultToken();
5473
5545
  if (!apiToken) {
5474
5546
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -5501,19 +5573,24 @@ async function deleteRepo(orgSlug, repoName, apiToken) {
5501
5573
  }
5502
5574
 
5503
5575
  const config$a = {
5504
- commandName: 'delete',
5576
+ commandName: 'del',
5505
5577
  description: 'Delete a repository in an organization',
5506
5578
  hidden: false,
5507
- flags: {},
5508
- help: (command, _config) => `
5579
+ flags: {
5580
+ ...commonFlags
5581
+ },
5582
+ help: (command, config) => `
5509
5583
  Usage
5510
5584
  $ ${command} <org slug> <repo slug>
5511
5585
 
5586
+ Options
5587
+ ${getFlagListOutput(config.flags, 6)}
5588
+
5512
5589
  Examples
5513
5590
  $ ${command} FakeOrg test-repo
5514
5591
  `
5515
5592
  };
5516
- const cmdReposDelete = {
5593
+ const cmdReposDel = {
5517
5594
  description: config$a.description,
5518
5595
  hidden: config$a.hidden,
5519
5596
  run: run$a
@@ -5529,14 +5606,17 @@ async function run$a(argv, importMeta, {
5529
5606
  });
5530
5607
  const [orgSlug = '', repoName = ''] = cli.input;
5531
5608
  if (!orgSlug || !repoName) {
5609
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5610
+ // options or missing arguments.
5611
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5612
+ process.exitCode = 2;
5532
5613
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5533
5614
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5534
5615
  - Repository name as the second argument ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
5535
- - At least one TARGET (e.g. \`.\` or \`./package.json\`
5536
- `);
5537
- cli.showHelp();
5616
+ - At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
5538
5617
  return;
5539
5618
  }
5619
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5540
5620
  const apiToken = index.getDefaultToken();
5541
5621
  if (!apiToken) {
5542
5622
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -5652,13 +5732,16 @@ async function run$9(argv, importMeta, {
5652
5732
  });
5653
5733
  const [orgSlug = ''] = cli.input;
5654
5734
  if (!orgSlug) {
5735
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5736
+ // options or missing arguments.
5737
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5738
+ process.exitCode = 2;
5655
5739
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5656
5740
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5657
- - At least one TARGET (e.g. \`.\` or \`./package.json\`
5658
- `);
5659
- cli.showHelp();
5741
+ - At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
5660
5742
  return;
5661
5743
  }
5744
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5662
5745
  const apiToken = index.getDefaultToken();
5663
5746
  if (!apiToken) {
5664
5747
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -5709,7 +5792,7 @@ async function updateRepo({
5709
5792
  }
5710
5793
 
5711
5794
  const config$8 = {
5712
- commandName: 'create',
5795
+ commandName: 'update',
5713
5796
  description: 'Update a repository in an organization',
5714
5797
  hidden: false,
5715
5798
  flags: {
@@ -5774,14 +5857,17 @@ async function run$8(argv, importMeta, {
5774
5857
  const repoName = cli.flags['repoName'];
5775
5858
  const [orgSlug = ''] = cli.input;
5776
5859
  if (!repoName || typeof repoName !== 'string' || !orgSlug) {
5860
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5861
+ // options or missing arguments.
5862
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5863
+ process.exitCode = 2;
5777
5864
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5778
5865
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5779
5866
  - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
5780
- - At least one TARGET (e.g. \`.\` or \`./package.json\`
5781
- `);
5782
- cli.showHelp();
5867
+ - At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
5783
5868
  return;
5784
5869
  }
5870
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5785
5871
  const apiToken = index.getDefaultToken();
5786
5872
  if (!apiToken) {
5787
5873
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -5874,13 +5960,16 @@ async function run$7(argv, importMeta, {
5874
5960
  const repoName = cli.flags['repoName'];
5875
5961
  const [orgSlug = ''] = cli.input;
5876
5962
  if (!repoName || typeof repoName !== 'string' || !orgSlug) {
5963
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5964
+ // options or missing arguments.
5965
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5966
+ process.exitCode = 2;
5877
5967
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5878
5968
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5879
- - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
5880
- `);
5881
- cli.showHelp();
5969
+ - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
5882
5970
  return;
5883
5971
  }
5972
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
5884
5973
  const apiToken = index.getDefaultToken();
5885
5974
  if (!apiToken) {
5886
5975
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -5895,16 +5984,16 @@ const cmdRepos = {
5895
5984
  parentName
5896
5985
  }) {
5897
5986
  await meowWithSubcommands({
5898
- cmdReposCreate,
5899
- cmdReposView,
5900
- cmdReposList,
5901
- cmdReposDelete,
5902
- cmdReposUpdate
5987
+ create: cmdReposCreate,
5988
+ view: cmdReposView,
5989
+ list: cmdReposList,
5990
+ del: cmdReposDel,
5991
+ update: cmdReposUpdate
5903
5992
  }, {
5904
5993
  argv,
5905
5994
  description: description$1,
5906
5995
  importMeta,
5907
- name: `${parentName} repo`
5996
+ name: `${parentName} repos`
5908
5997
  });
5909
5998
  }
5910
5999
  };
@@ -5988,6 +6077,10 @@ const config$6 = {
5988
6077
  type: 'string',
5989
6078
  description: 'working directory, defaults to process.cwd()'
5990
6079
  },
6080
+ dryRun: {
6081
+ type: 'boolean',
6082
+ description: 'run input validation part of command without any concrete side effects'
6083
+ },
5991
6084
  pullRequest: {
5992
6085
  type: 'number',
5993
6086
  shortFlag: 'pr',
@@ -6050,6 +6143,9 @@ async function run$6(argv, importMeta, {
6050
6143
  });
6051
6144
  const [orgSlug = '', ...targets] = cli.input;
6052
6145
  const cwd = cli.flags['cwd'] && cli.flags['cwd'] !== 'process.cwd()' ? String(cli.flags['cwd']) : process$1.cwd();
6146
+
6147
+ // Note exiting earlier to skirt a hidden auth requirement
6148
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
6053
6149
  const socketSdk = await index.setupSdk();
6054
6150
  const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
6055
6151
  if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
@@ -6066,12 +6162,15 @@ async function run$6(argv, importMeta, {
6066
6162
  repo: repoName
6067
6163
  } = cli.flags;
6068
6164
  if (!orgSlug || !repoName || !branchName || !packagePaths.length) {
6165
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
6166
+ // options or missing arguments.
6167
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6168
+ process$1.exitCode = 2;
6069
6169
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6070
6170
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6071
6171
  - Repository name using --repo ${!repoName ? colors.red('(missing!)') : colors.green('(ok)')}\n
6072
6172
  - Branch name using --branch ${!branchName ? colors.red('(missing!)') : colors.green('(ok)')}\n
6073
- - At least one TARGET (e.g. \`.\` or \`./package.json\`) ${!packagePaths.length ? colors.red(targets.length > 0 ? '(TARGET' + (targets.length ? 's' : '') + ' contained no matching/supported files!)' : '(missing)') : colors.green('(ok)')}`);
6074
- config$6.help(parentName, config$6);
6173
+ - At least one TARGET (e.g. \`.\` or \`./package.json\`) ${!packagePaths.length ? colors.red(targets.length > 0 ? '(TARGET' + (targets.length ? 's' : '') + ' contained no matching/supported files!)' : '(missing)') : colors.green('(ok)')}\n`);
6075
6174
  return;
6076
6175
  }
6077
6176
  const apiToken = index.getDefaultToken();
@@ -6128,7 +6227,7 @@ const config$5 = {
6128
6227
  $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
6129
6228
  `
6130
6229
  };
6131
- const cmdScanDelete = {
6230
+ const cmdScanDel = {
6132
6231
  description: config$5.description,
6133
6232
  hidden: config$5.hidden,
6134
6233
  run: run$5
@@ -6136,21 +6235,24 @@ const cmdScanDelete = {
6136
6235
  async function run$5(argv, importMeta, {
6137
6236
  parentName
6138
6237
  }) {
6139
- const cli = vendor.meow(config$5.help(parentName, config$5), {
6238
+ const cli = meowOrExit({
6140
6239
  argv,
6141
- description: config$5.description,
6240
+ config: config$5,
6142
6241
  importMeta,
6143
- flags: config$5.flags
6242
+ parentName
6144
6243
  });
6145
6244
  const [orgSlug = '', fullScanId = ''] = cli.input;
6146
6245
  if (!orgSlug || !fullScanId) {
6246
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
6247
+ // options or missing arguments.
6248
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6249
+ process.exitCode = 2;
6147
6250
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6148
6251
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6149
- - Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
6150
- `);
6151
- config$5.help(parentName, config$5);
6252
+ - Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
6152
6253
  return;
6153
6254
  }
6255
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
6154
6256
  const apiToken = index.getDefaultToken();
6155
6257
  if (!apiToken) {
6156
6258
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -6264,19 +6366,23 @@ const cmdScanList = {
6264
6366
  async function run$4(argv, importMeta, {
6265
6367
  parentName
6266
6368
  }) {
6267
- const cli = vendor.meow(config$4.help(parentName, config$4), {
6369
+ const cli = meowOrExit({
6268
6370
  argv,
6269
- description: config$4.description,
6371
+ config: config$4,
6270
6372
  importMeta,
6271
- flags: config$4.flags
6373
+ parentName
6272
6374
  });
6273
6375
  const orgSlug = cli.input[0];
6274
6376
  if (!orgSlug) {
6377
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
6378
+ // options or missing arguments.
6379
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6380
+ process.exitCode = 2;
6275
6381
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6276
- - Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}`);
6277
- config$4.help(parentName, config$4);
6382
+ - Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
6278
6383
  return;
6279
6384
  }
6385
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
6280
6386
  const apiToken = index.getDefaultToken();
6281
6387
  if (!apiToken) {
6282
6388
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -6338,21 +6444,24 @@ const cmdScanMetadata = {
6338
6444
  async function run$3(argv, importMeta, {
6339
6445
  parentName
6340
6446
  }) {
6341
- const cli = vendor.meow(config$3.help(parentName, config$3), {
6447
+ const cli = meowOrExit({
6342
6448
  argv,
6343
- description: config$3.description,
6449
+ config: config$3,
6344
6450
  importMeta,
6345
- flags: config$3.flags
6451
+ parentName
6346
6452
  });
6347
6453
  const [orgSlug = '', fullScanId = ''] = cli.input;
6348
6454
  if (!orgSlug || !fullScanId) {
6455
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
6456
+ // options or missing arguments.
6457
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6458
+ process.exitCode = 2;
6349
6459
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6350
6460
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6351
- - Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
6352
- `);
6353
- config$3.help(parentName, config$3);
6461
+ - Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
6354
6462
  return;
6355
6463
  }
6464
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
6356
6465
  const apiToken = index.getDefaultToken();
6357
6466
  if (!apiToken) {
6358
6467
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -6403,21 +6512,24 @@ const cmdScanStream = {
6403
6512
  async function run$2(argv, importMeta, {
6404
6513
  parentName
6405
6514
  }) {
6406
- const cli = vendor.meow(config$2.help(parentName, config$2), {
6515
+ const cli = meowOrExit({
6407
6516
  argv,
6408
- description: config$2.description,
6517
+ config: config$2,
6409
6518
  importMeta,
6410
- flags: config$2.flags
6519
+ parentName
6411
6520
  });
6412
6521
  const [orgSlug = '', fullScanId = '', file = '-'] = cli.input;
6413
6522
  if (!orgSlug || !fullScanId) {
6523
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
6524
+ // options or missing arguments.
6525
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6526
+ process.exitCode = 2;
6414
6527
  console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6415
6528
  - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6416
- - Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
6417
- `);
6418
- config$2.help(parentName, config$2);
6529
+ - Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
6419
6530
  return;
6420
6531
  }
6532
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
6421
6533
  const apiToken = index.getDefaultToken();
6422
6534
  if (!apiToken) {
6423
6535
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -6435,7 +6547,7 @@ const cmdScan = {
6435
6547
  create: cmdScanCreate,
6436
6548
  stream: cmdScanStream,
6437
6549
  list: cmdScanList,
6438
- del: cmdScanDelete,
6550
+ del: cmdScanDel,
6439
6551
  metadata: cmdScanMetadata
6440
6552
  }, {
6441
6553
  argv,
@@ -6580,6 +6692,7 @@ async function run$1(argv, importMeta, {
6580
6692
  importMeta,
6581
6693
  parentName
6582
6694
  });
6695
+ if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
6583
6696
  const apiToken = index.getDefaultToken();
6584
6697
  if (!apiToken) {
6585
6698
  throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
@@ -6618,11 +6731,13 @@ function checkSocketWrapperSetup(file) {
6618
6731
  return false;
6619
6732
  }
6620
6733
 
6621
- const HOME_DIR$1 = os.homedir();
6622
- const BASH_FILE$1 = `${HOME_DIR$1}/.bashrc`;
6623
- const ZSH_BASH_FILE$1 = `${HOME_DIR$1}/.zshrc`;
6624
6734
  function postinstallWrapper() {
6625
- const socketWrapperEnabled = fs.existsSync(BASH_FILE$1) && checkSocketWrapperSetup(BASH_FILE$1) || fs.existsSync(ZSH_BASH_FILE$1) && checkSocketWrapperSetup(ZSH_BASH_FILE$1);
6735
+ // Lazily access constants.bashRcPath and constants.zshRcPath.
6736
+ const {
6737
+ bashRcPath,
6738
+ zshRcPath
6739
+ } = constants;
6740
+ const socketWrapperEnabled = fs.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
6626
6741
  if (!socketWrapperEnabled) {
6627
6742
  installSafeNpm(`The Socket CLI is now successfully installed! 🎉
6628
6743
 
@@ -6648,12 +6763,17 @@ function installSafeNpm(query) {
6648
6763
  function askQuestion(rl, query) {
6649
6764
  rl.question(query, ans => {
6650
6765
  if (ans.toLowerCase() === 'y') {
6766
+ // Lazily access constants.bashRcPath and constants.zshRcPath.
6767
+ const {
6768
+ bashRcPath,
6769
+ zshRcPath
6770
+ } = constants;
6651
6771
  try {
6652
- if (fs.existsSync(BASH_FILE$1)) {
6653
- addSocketWrapper(BASH_FILE$1);
6772
+ if (fs.existsSync(bashRcPath)) {
6773
+ addSocketWrapper(bashRcPath);
6654
6774
  }
6655
- if (fs.existsSync(ZSH_BASH_FILE$1)) {
6656
- addSocketWrapper(ZSH_BASH_FILE$1);
6775
+ if (fs.existsSync(zshRcPath)) {
6776
+ addSocketWrapper(zshRcPath);
6657
6777
  }
6658
6778
  } catch (e) {
6659
6779
  throw new Error(`There was an issue setting up the alias: ${e}`);
@@ -6688,14 +6808,12 @@ function removeSocketWrapper(file) {
6688
6808
  });
6689
6809
  }
6690
6810
 
6691
- const HOME_DIR = os.homedir();
6692
- const BASH_FILE = `${HOME_DIR}/.bashrc`;
6693
- const ZSH_BASH_FILE = `${HOME_DIR}/.zshrc`;
6694
6811
  const config = {
6695
6812
  commandName: 'wrapper',
6696
6813
  description: 'Enable or disable the Socket npm/npx wrapper',
6697
6814
  hidden: false,
6698
6815
  flags: {
6816
+ ...commonFlags,
6699
6817
  enable: {
6700
6818
  type: 'boolean',
6701
6819
  default: false,
@@ -6739,31 +6857,42 @@ async function run(argv, importMeta, {
6739
6857
  parentName
6740
6858
  });
6741
6859
  const {
6742
- disable,
6743
6860
  enable
6744
6861
  } = cli.flags;
6745
- if (!enable && !disable) {
6746
- cli.showHelp();
6862
+ if (!enable && !cli.flags['disable']) {
6863
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
6864
+ // options or missing arguments.
6865
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6866
+ process.exitCode = 2;
6867
+ console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required flags:\n
6868
+ - Must use --enabled or --disabled\n`);
6747
6869
  return;
6748
6870
  }
6871
+ if (cli.flags['dryRun']) {
6872
+ return console.log('[DryRun] Bailing now');
6873
+ }
6874
+
6875
+ // Lazily access constants.bashRcPath and constants.zshRcPath.
6876
+ const {
6877
+ bashRcPath,
6878
+ zshRcPath
6879
+ } = constants;
6749
6880
  if (enable) {
6750
- if (fs.existsSync(BASH_FILE)) {
6751
- const socketWrapperEnabled = checkSocketWrapperSetup(BASH_FILE);
6752
- !socketWrapperEnabled && addSocketWrapper(BASH_FILE);
6881
+ if (fs.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
6882
+ addSocketWrapper(bashRcPath);
6753
6883
  }
6754
- if (fs.existsSync(ZSH_BASH_FILE)) {
6755
- const socketWrapperEnabled = checkSocketWrapperSetup(ZSH_BASH_FILE);
6756
- !socketWrapperEnabled && addSocketWrapper(ZSH_BASH_FILE);
6884
+ if (fs.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
6885
+ addSocketWrapper(zshRcPath);
6757
6886
  }
6758
6887
  } else {
6759
- if (fs.existsSync(BASH_FILE)) {
6760
- removeSocketWrapper(BASH_FILE);
6888
+ if (fs.existsSync(bashRcPath)) {
6889
+ removeSocketWrapper(bashRcPath);
6761
6890
  }
6762
- if (fs.existsSync(ZSH_BASH_FILE)) {
6763
- removeSocketWrapper(ZSH_BASH_FILE);
6891
+ if (fs.existsSync(zshRcPath)) {
6892
+ removeSocketWrapper(zshRcPath);
6764
6893
  }
6765
6894
  }
6766
- if (!fs.existsSync(BASH_FILE) && !fs.existsSync(ZSH_BASH_FILE)) {
6895
+ if (!fs.existsSync(bashRcPath) && !fs.existsSync(zshRcPath)) {
6767
6896
  console.error('There was an issue setting up the alias in your bash profile');
6768
6897
  }
6769
6898
  }
@@ -6844,5 +6973,5 @@ void (async () => {
6844
6973
  await index.captureException(e);
6845
6974
  }
6846
6975
  })();
6847
- //# debugId=a4acc1e3-c084-4a1d-93c2-9d46f8d72142
6976
+ //# debugId=aa82067c-1e23-4114-af76-11c9c451168b
6848
6977
  //# sourceMappingURL=cli.js.map