@socketsecurity/cli-with-sentry 0.14.46 → 0.14.48
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.
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +48 -25
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/cli.js +362 -233
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/edge.d.ts +0 -1
- package/dist/module-sync/index.d.ts +5 -5
- package/dist/module-sync/index.js +114 -131
- package/dist/module-sync/index.js.map +1 -1
- package/dist/module-sync/node.d.ts +5 -3
- package/dist/module-sync/npm-injection.js +2 -2
- package/dist/module-sync/npm-injection.js.map +1 -1
- package/dist/require/cli.d.ts +2 -0
- package/dist/require/cli.js +362 -233
- package/dist/require/cli.js.map +1 -0
- package/dist/require/vendor.js.map +1 -0
- package/package.json +17 -15
package/dist/module-sync/cli.js
CHANGED
|
@@ -26,11 +26,12 @@ var rest = _socketInterop(require('@octokit/rest'));
|
|
|
26
26
|
var index = require('./index.js');
|
|
27
27
|
var meow = _socketInterop(require('meow'));
|
|
28
28
|
var objects = require('@socketsecurity/registry/lib/objects');
|
|
29
|
+
var regexps = require('@socketsecurity/registry/lib/regexps');
|
|
30
|
+
var constants = require('./constants.js');
|
|
29
31
|
var fs$1 = require('node:fs/promises');
|
|
30
32
|
var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
|
|
31
33
|
var contrib = _socketInterop(require('blessed-contrib'));
|
|
32
34
|
var spinner = require('@socketsecurity/registry/lib/spinner');
|
|
33
|
-
var constants = require('./constants.js');
|
|
34
35
|
var prompts = require('@socketsecurity/registry/lib/prompts');
|
|
35
36
|
var yargsParse = _socketInterop(require('yargs-parser'));
|
|
36
37
|
var words = require('@socketsecurity/registry/lib/words');
|
|
@@ -53,7 +54,6 @@ var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
|
|
|
53
54
|
var sorts = require('@socketsecurity/registry/lib/sorts');
|
|
54
55
|
var strings = require('@socketsecurity/registry/lib/strings');
|
|
55
56
|
var yaml = _socketInterop(require('yaml'));
|
|
56
|
-
var regexps = require('@socketsecurity/registry/lib/regexps');
|
|
57
57
|
var npm$1 = require('./npm.js');
|
|
58
58
|
var npmPaths = require('./npm-paths.js');
|
|
59
59
|
var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
|
|
@@ -61,7 +61,6 @@ var config$A = require('@socketsecurity/config');
|
|
|
61
61
|
var readline = require('node:readline/promises');
|
|
62
62
|
var open = _socketInterop(require('open'));
|
|
63
63
|
var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
|
|
64
|
-
var os = require('node:os');
|
|
65
64
|
var readline$1 = require('node:readline');
|
|
66
65
|
|
|
67
66
|
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/classes.py
|
|
@@ -1321,6 +1320,11 @@ const commonFlags = {
|
|
|
1321
1320
|
default: false,
|
|
1322
1321
|
shortFlag: 'h',
|
|
1323
1322
|
description: 'Print this help.'
|
|
1323
|
+
},
|
|
1324
|
+
dryRun: {
|
|
1325
|
+
type: 'boolean',
|
|
1326
|
+
default: false,
|
|
1327
|
+
description: 'Do input validation for a command and exit 0 when input is ok'
|
|
1324
1328
|
}
|
|
1325
1329
|
};
|
|
1326
1330
|
const outputFlags = {
|
|
@@ -1350,10 +1354,9 @@ const validationFlags = {
|
|
|
1350
1354
|
}
|
|
1351
1355
|
};
|
|
1352
1356
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
+
const {
|
|
1358
|
+
SOCKET_CLI_SHOW_BANNER
|
|
1359
|
+
} = constants;
|
|
1357
1360
|
async function meowWithSubcommands(subcommands, options) {
|
|
1358
1361
|
const {
|
|
1359
1362
|
aliases = {},
|
|
@@ -1366,12 +1369,12 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1366
1369
|
...options
|
|
1367
1370
|
};
|
|
1368
1371
|
const [commandOrAliasName, ...rawCommandArgv] = argv;
|
|
1369
|
-
// If we got at least some args, then lets find out if we can find a command
|
|
1372
|
+
// If we got at least some args, then lets find out if we can find a command.
|
|
1370
1373
|
if (commandOrAliasName) {
|
|
1371
1374
|
const alias = aliases[commandOrAliasName];
|
|
1372
|
-
// First: Resolve argv data from alias if its an alias that's been given
|
|
1375
|
+
// First: Resolve argv data from alias if its an alias that's been given.
|
|
1373
1376
|
const [commandName, ...commandArgv] = alias ? [...alias.argv, ...rawCommandArgv] : [commandOrAliasName, ...rawCommandArgv];
|
|
1374
|
-
// Second: Find a command definition using that data
|
|
1377
|
+
// Second: Find a command definition using that data.
|
|
1375
1378
|
const commandDefinition = commandName ? subcommands[commandName] : undefined;
|
|
1376
1379
|
// Third: If a valid command has been found, then we run it...
|
|
1377
1380
|
if (commandDefinition) {
|
|
@@ -1384,7 +1387,13 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1384
1387
|
...commonFlags,
|
|
1385
1388
|
...additionalOptions.flags
|
|
1386
1389
|
};
|
|
1387
|
-
// ...else we provide basic instructions and help
|
|
1390
|
+
// ...else we provide basic instructions and help.
|
|
1391
|
+
|
|
1392
|
+
// Temp disable until we clear the --json and --markdown usage
|
|
1393
|
+
// Lazily access constants.ENV[SOCKET_CLI_SHOW_BANNER].
|
|
1394
|
+
if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) {
|
|
1395
|
+
console.log(getAsciiHeader(name));
|
|
1396
|
+
}
|
|
1388
1397
|
const cli = meow(`
|
|
1389
1398
|
Usage
|
|
1390
1399
|
$ ${name} <command>
|
|
@@ -1415,9 +1424,15 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1415
1424
|
argv,
|
|
1416
1425
|
importMeta,
|
|
1417
1426
|
...additionalOptions,
|
|
1418
|
-
flags
|
|
1427
|
+
flags,
|
|
1428
|
+
autoHelp: false // otherwise we can't exit(0)
|
|
1419
1429
|
});
|
|
1420
|
-
cli.
|
|
1430
|
+
if (!cli.flags['help'] && cli.flags['dryRun']) {
|
|
1431
|
+
console.log('[DryRun]: noop, call a sub-command; ok');
|
|
1432
|
+
process.exitCode = 0;
|
|
1433
|
+
} else {
|
|
1434
|
+
cli.showHelp();
|
|
1435
|
+
}
|
|
1421
1436
|
}
|
|
1422
1437
|
|
|
1423
1438
|
/**
|
|
@@ -1432,19 +1447,40 @@ function meowOrExit({
|
|
|
1432
1447
|
parentName
|
|
1433
1448
|
}) {
|
|
1434
1449
|
const command = `${parentName} ${config.commandName}`;
|
|
1435
|
-
|
|
1436
|
-
|
|
1450
|
+
// Temp disable until we clear the --json and --markdown usage.
|
|
1451
|
+
// Lazily access constants.ENV[SOCKET_CLI_SHOW_BANNER].
|
|
1452
|
+
if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) {
|
|
1453
|
+
console.log(getAsciiHeader(command));
|
|
1454
|
+
}
|
|
1437
1455
|
// This exits if .printHelp() is called either by meow itself or by us.
|
|
1438
1456
|
const cli = meow({
|
|
1439
1457
|
argv,
|
|
1440
1458
|
description: config.description,
|
|
1441
|
-
help,
|
|
1459
|
+
help: config.help(command, config),
|
|
1442
1460
|
importMeta,
|
|
1443
1461
|
flags: config.flags,
|
|
1444
|
-
allowUnknownFlags: Boolean(allowUnknownFlags)
|
|
1462
|
+
allowUnknownFlags: Boolean(allowUnknownFlags),
|
|
1463
|
+
autoHelp: false // otherwise we can't exit(0)
|
|
1445
1464
|
});
|
|
1465
|
+
if (cli.flags['help']) {
|
|
1466
|
+
cli.showHelp();
|
|
1467
|
+
}
|
|
1446
1468
|
return cli;
|
|
1447
1469
|
}
|
|
1470
|
+
function getAsciiHeader(command) {
|
|
1471
|
+
const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']".
|
|
1472
|
+
"0.14.48:61ff8dc:d16eb84e:pub";
|
|
1473
|
+
const nodeVersion = process.version;
|
|
1474
|
+
// Get the last 5 characters of the API token before the trailing "_api".
|
|
1475
|
+
const lastFiveCharsOfApiToken = index.getSetting('apiToken')?.slice(-9, -4) || 'no';
|
|
1476
|
+
const relCwd = process.cwd().replace(new RegExp(`^${regexps.escapeRegExp(constants.homePath)}`, 'i'), '~/');
|
|
1477
|
+
const body = `
|
|
1478
|
+
_____ _ _ /---------------
|
|
1479
|
+
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
|
|
1480
|
+
|__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${lastFiveCharsOfApiToken}
|
|
1481
|
+
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart();
|
|
1482
|
+
return ` ${body}\n`;
|
|
1483
|
+
}
|
|
1448
1484
|
|
|
1449
1485
|
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/socketcli.py
|
|
1450
1486
|
|
|
@@ -1471,12 +1507,11 @@ const config$z = {
|
|
|
1471
1507
|
description: 'After marker'
|
|
1472
1508
|
}
|
|
1473
1509
|
},
|
|
1474
|
-
help: (
|
|
1475
|
-
commandName,
|
|
1510
|
+
help: (command, {
|
|
1476
1511
|
flags
|
|
1477
1512
|
}) => `
|
|
1478
1513
|
Usage
|
|
1479
|
-
$ ${
|
|
1514
|
+
$ ${command} [options]
|
|
1480
1515
|
|
|
1481
1516
|
Options
|
|
1482
1517
|
${getFlagListOutput(flags, 6)}
|
|
@@ -1498,6 +1533,7 @@ async function run$z(argv, importMeta, {
|
|
|
1498
1533
|
});
|
|
1499
1534
|
const githubEventBefore = String(cli.flags['githubEventBefore'] || '');
|
|
1500
1535
|
const githubEventAfter = String(cli.flags['githubEventAfter'] || '');
|
|
1536
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
1501
1537
|
await runAction(githubEventBefore, githubEventAfter);
|
|
1502
1538
|
}
|
|
1503
1539
|
|
|
@@ -1763,12 +1799,11 @@ const config$y = {
|
|
|
1763
1799
|
description: 'Path to a local file to save the output'
|
|
1764
1800
|
}
|
|
1765
1801
|
},
|
|
1766
|
-
help: (
|
|
1767
|
-
commandName,
|
|
1802
|
+
help: (command, {
|
|
1768
1803
|
flags
|
|
1769
1804
|
}) => `
|
|
1770
1805
|
Usage
|
|
1771
|
-
$ ${
|
|
1806
|
+
$ ${command} --scope=<scope> --time=<time filter>
|
|
1772
1807
|
|
|
1773
1808
|
Default parameters are set to show the organization-level analytics over the
|
|
1774
1809
|
last 7 days.
|
|
@@ -1777,9 +1812,9 @@ const config$y = {
|
|
|
1777
1812
|
${getFlagListOutput(flags, 6)}
|
|
1778
1813
|
|
|
1779
1814
|
Examples
|
|
1780
|
-
$ ${
|
|
1781
|
-
$ ${
|
|
1782
|
-
$ ${
|
|
1815
|
+
$ ${command} --scope=org --time=7
|
|
1816
|
+
$ ${command} --scope=org --time=30
|
|
1817
|
+
$ ${command} --scope=repo --repo=test-repo --time=30
|
|
1783
1818
|
`
|
|
1784
1819
|
};
|
|
1785
1820
|
const cmdAnalytics = {
|
|
@@ -1805,14 +1840,17 @@ async function run$y(argv, importMeta, {
|
|
|
1805
1840
|
const badTime = time !== 7 && time !== 30 && time !== 90;
|
|
1806
1841
|
const badRepo = scope === 'repo' && !repo;
|
|
1807
1842
|
if (badScope || badTime || badRepo) {
|
|
1843
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
1844
|
+
// options or missing arguments.
|
|
1845
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
1846
|
+
process.exitCode = 2;
|
|
1808
1847
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
1809
1848
|
- Scope must be "repo" or "org" ${badScope ? colors.red('(bad!)') : colors.green('(ok)')}\n
|
|
1810
1849
|
- The time filter must either be 7, 30 or 90 ${badTime ? colors.red('(bad!)') : colors.green('(ok)')}\n
|
|
1811
|
-
- Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}\n
|
|
1812
|
-
`);
|
|
1813
|
-
cli.showHelp();
|
|
1850
|
+
- Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}\n`);
|
|
1814
1851
|
return;
|
|
1815
1852
|
}
|
|
1853
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
1816
1854
|
const apiToken = index.getDefaultToken();
|
|
1817
1855
|
if (!apiToken) {
|
|
1818
1856
|
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.');
|
|
@@ -1932,12 +1970,15 @@ async function run$x(argv, importMeta, {
|
|
|
1932
1970
|
const type = String(cli.flags['type'] || '');
|
|
1933
1971
|
const [orgSlug = ''] = cli.input;
|
|
1934
1972
|
if (!orgSlug) {
|
|
1973
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
1974
|
+
// options or missing arguments.
|
|
1975
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
1976
|
+
process.exitCode = 2;
|
|
1935
1977
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
1936
|
-
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
1937
|
-
`);
|
|
1938
|
-
config$x.help(parentName, config$x);
|
|
1978
|
+
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
1939
1979
|
return;
|
|
1940
1980
|
}
|
|
1981
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
1941
1982
|
const apiToken = index.getDefaultToken();
|
|
1942
1983
|
if (!apiToken) {
|
|
1943
1984
|
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.');
|
|
@@ -2028,7 +2069,6 @@ function argvToArray(argv) {
|
|
|
2028
2069
|
}
|
|
2029
2070
|
|
|
2030
2071
|
// import { meowOrExit } from '../../utils/meow-with-subcommands'
|
|
2031
|
-
|
|
2032
2072
|
// TODO: convert yargs to meow. Or convert all the other things to yargs.
|
|
2033
2073
|
const toLower = arg => arg.toLowerCase();
|
|
2034
2074
|
const arrayToLower = arg => arg.map(toLower);
|
|
@@ -2100,23 +2140,36 @@ const yargsConfig = {
|
|
|
2100
2140
|
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']
|
|
2101
2141
|
};
|
|
2102
2142
|
const config$w = {
|
|
2143
|
+
commandName: 'cdxgen',
|
|
2103
2144
|
description: 'Create an SBOM with CycloneDX generator (cdxgen)',
|
|
2104
|
-
hidden: false
|
|
2145
|
+
hidden: false,
|
|
2146
|
+
flags: {
|
|
2147
|
+
// TODO: convert from yargsConfig
|
|
2148
|
+
},
|
|
2149
|
+
help: (command, config) => `
|
|
2150
|
+
Usage
|
|
2151
|
+
$ ${command} [options]
|
|
2152
|
+
|
|
2153
|
+
Options
|
|
2154
|
+
${getFlagListOutput(config.flags, 6)}
|
|
2155
|
+
`
|
|
2156
|
+
};
|
|
2105
2157
|
const cmdCdxgen = {
|
|
2106
2158
|
description: config$w.description,
|
|
2107
2159
|
hidden: config$w.hidden,
|
|
2108
2160
|
run: run$w
|
|
2109
2161
|
};
|
|
2110
|
-
async function run$w(argv,
|
|
2111
|
-
parentName
|
|
2162
|
+
async function run$w(argv, importMeta, {
|
|
2163
|
+
parentName
|
|
2112
2164
|
}) {
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2165
|
+
const cli = meowOrExit({
|
|
2166
|
+
allowUnknownFlags: true,
|
|
2167
|
+
argv: argv.filter(s => s !== '--help' && s !== '-h'),
|
|
2168
|
+
// Don't let meow take over --help
|
|
2169
|
+
config: config$w,
|
|
2170
|
+
importMeta,
|
|
2171
|
+
parentName
|
|
2172
|
+
});
|
|
2120
2173
|
//
|
|
2121
2174
|
//
|
|
2122
2175
|
// if (cli.input.length)
|
|
@@ -2137,13 +2190,17 @@ async function run$w(argv, _importMeta, {
|
|
|
2137
2190
|
length: unknownLength
|
|
2138
2191
|
} = unknown;
|
|
2139
2192
|
if (unknownLength) {
|
|
2140
|
-
|
|
2193
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
2194
|
+
// options or missing arguments.
|
|
2195
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
2196
|
+
process$1.exitCode = 2;
|
|
2141
2197
|
console.error(`Unknown ${words.pluralize('argument', unknownLength)}: ${yargv._.join(', ')}`);
|
|
2142
2198
|
return;
|
|
2143
2199
|
}
|
|
2144
2200
|
if (yargv.output === undefined) {
|
|
2145
2201
|
yargv.output = 'socket-cdx.json';
|
|
2146
2202
|
}
|
|
2203
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2147
2204
|
await runCycloneDX(yargv);
|
|
2148
2205
|
}
|
|
2149
2206
|
|
|
@@ -2246,6 +2303,7 @@ async function run$v(argv, importMeta, {
|
|
|
2246
2303
|
importMeta,
|
|
2247
2304
|
parentName
|
|
2248
2305
|
});
|
|
2306
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2249
2307
|
|
|
2250
2308
|
// TODO: markdown flag is ignored
|
|
2251
2309
|
await findDependencies({
|
|
@@ -2357,14 +2415,17 @@ async function run$u(argv, importMeta, {
|
|
|
2357
2415
|
const after = String(cli.flags['after'] || '');
|
|
2358
2416
|
const [orgSlug = ''] = cli.input;
|
|
2359
2417
|
if (!before || !after || cli.input.length < 1) {
|
|
2418
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
2419
|
+
// options or missing arguments.
|
|
2420
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
2421
|
+
process.exitCode = 2;
|
|
2360
2422
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
2361
2423
|
- 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
|
|
2362
2424
|
- To get full scans IDs, you can run the command "socket scan list <your org slug>".
|
|
2363
|
-
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
2364
|
-
`);
|
|
2365
|
-
config$u.help(parentName, config$u);
|
|
2425
|
+
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
2366
2426
|
return;
|
|
2367
2427
|
}
|
|
2428
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2368
2429
|
const apiToken = index.getDefaultToken();
|
|
2369
2430
|
if (!apiToken) {
|
|
2370
2431
|
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.');
|
|
@@ -2507,7 +2568,9 @@ const config$t = {
|
|
|
2507
2568
|
commandName: 'fix',
|
|
2508
2569
|
description: 'Fix "fixable" Socket alerts',
|
|
2509
2570
|
hidden: true,
|
|
2510
|
-
flags: {
|
|
2571
|
+
flags: {
|
|
2572
|
+
...commonFlags
|
|
2573
|
+
},
|
|
2511
2574
|
help: (command, config) => `
|
|
2512
2575
|
Usage
|
|
2513
2576
|
$ ${command}
|
|
@@ -2524,12 +2587,13 @@ const cmdFix = {
|
|
|
2524
2587
|
async function run$t(argv, importMeta, {
|
|
2525
2588
|
parentName
|
|
2526
2589
|
}) {
|
|
2527
|
-
meowOrExit({
|
|
2590
|
+
const cli = meowOrExit({
|
|
2528
2591
|
argv,
|
|
2529
2592
|
config: config$t,
|
|
2530
2593
|
importMeta,
|
|
2531
2594
|
parentName
|
|
2532
2595
|
});
|
|
2596
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2533
2597
|
await runFix();
|
|
2534
2598
|
}
|
|
2535
2599
|
|
|
@@ -2778,23 +2842,21 @@ async function run$s(argv, importMeta, {
|
|
|
2778
2842
|
importMeta,
|
|
2779
2843
|
parentName
|
|
2780
2844
|
});
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
}
|
|
2791
|
-
if (showHelp) {
|
|
2792
|
-
cli.showHelp();
|
|
2845
|
+
const [rawPkgName = ''] = cli.input;
|
|
2846
|
+
if (!rawPkgName || cli.input.length > 1) {
|
|
2847
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
2848
|
+
// options or missing arguments.
|
|
2849
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
2850
|
+
process.exitCode = 2;
|
|
2851
|
+
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
2852
|
+
- Expecting a package name ${!rawPkgName ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
2853
|
+
- Can only accept one package at a time ${cli.input.length > 1 ? colors.red('(got ' + cli.input.length + '!)') : colors.green('(ok)')}\n`);
|
|
2793
2854
|
return;
|
|
2794
2855
|
}
|
|
2795
2856
|
const versionSeparator = rawPkgName.lastIndexOf('@');
|
|
2796
2857
|
const pkgName = versionSeparator < 1 ? rawPkgName : rawPkgName.slice(0, versionSeparator);
|
|
2797
2858
|
const pkgVersion = versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1);
|
|
2859
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2798
2860
|
await getPackageInfo({
|
|
2799
2861
|
commandName: `${parentName} ${config$s.commandName}`,
|
|
2800
2862
|
includeAllIssues: Boolean(cli.flags['all']),
|
|
@@ -2883,6 +2945,7 @@ const config$r = {
|
|
|
2883
2945
|
description: 'Socket API login',
|
|
2884
2946
|
hidden: false,
|
|
2885
2947
|
flags: {
|
|
2948
|
+
...commonFlags,
|
|
2886
2949
|
apiBaseUrl: {
|
|
2887
2950
|
type: 'string',
|
|
2888
2951
|
description: 'API server to connect to for login'
|
|
@@ -2920,11 +2983,12 @@ async function run$r(argv, importMeta, {
|
|
|
2920
2983
|
importMeta,
|
|
2921
2984
|
parentName
|
|
2922
2985
|
});
|
|
2986
|
+
let apiBaseUrl = cli.flags['apiBaseUrl'];
|
|
2987
|
+
let apiProxy = cli.flags['apiProxy'];
|
|
2988
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2923
2989
|
if (!isInteractive()) {
|
|
2924
2990
|
throw new index.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
2925
2991
|
}
|
|
2926
|
-
let apiBaseUrl = cli.flags['apiBaseUrl'];
|
|
2927
|
-
let apiProxy = cli.flags['apiProxy'];
|
|
2928
2992
|
await attemptLogin(apiBaseUrl, apiProxy);
|
|
2929
2993
|
}
|
|
2930
2994
|
|
|
@@ -2948,7 +3012,9 @@ const config$q = {
|
|
|
2948
3012
|
commandName: 'logout',
|
|
2949
3013
|
description: 'Socket API logout',
|
|
2950
3014
|
hidden: false,
|
|
2951
|
-
flags: {
|
|
3015
|
+
flags: {
|
|
3016
|
+
...commonFlags
|
|
3017
|
+
},
|
|
2952
3018
|
help: (command, _config) => `
|
|
2953
3019
|
Usage
|
|
2954
3020
|
$ ${command}
|
|
@@ -2964,12 +3030,13 @@ const cmdLogout = {
|
|
|
2964
3030
|
async function run$q(argv, importMeta, {
|
|
2965
3031
|
parentName
|
|
2966
3032
|
}) {
|
|
2967
|
-
meowOrExit({
|
|
3033
|
+
const cli = meowOrExit({
|
|
2968
3034
|
argv,
|
|
2969
3035
|
config: config$q,
|
|
2970
3036
|
importMeta,
|
|
2971
3037
|
parentName
|
|
2972
3038
|
});
|
|
3039
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
2973
3040
|
attemptLogout();
|
|
2974
3041
|
}
|
|
2975
3042
|
|
|
@@ -3146,13 +3213,11 @@ const cmdManifestGradle = {
|
|
|
3146
3213
|
async function run$p(argv, importMeta, {
|
|
3147
3214
|
parentName
|
|
3148
3215
|
}) {
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
allowUnknownFlags: false,
|
|
3155
|
-
importMeta
|
|
3216
|
+
const cli = meowOrExit({
|
|
3217
|
+
argv,
|
|
3218
|
+
config: config$p,
|
|
3219
|
+
importMeta,
|
|
3220
|
+
parentName
|
|
3156
3221
|
});
|
|
3157
3222
|
const verbose = Boolean(cli.flags['verbose']);
|
|
3158
3223
|
if (verbose) {
|
|
@@ -3163,15 +3228,18 @@ async function run$p(argv, importMeta, {
|
|
|
3163
3228
|
console.groupEnd();
|
|
3164
3229
|
}
|
|
3165
3230
|
const target = cli.input[0];
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
//
|
|
3173
|
-
|
|
3174
|
-
|
|
3231
|
+
|
|
3232
|
+
// 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?
|
|
3233
|
+
|
|
3234
|
+
if (!target || target === '-' || cli.input.length > 1) {
|
|
3235
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
3236
|
+
// options or missing arguments.
|
|
3237
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
3238
|
+
process.exitCode = 2;
|
|
3239
|
+
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
3240
|
+
- The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
|
|
3241
|
+
- Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
|
|
3242
|
+
return;
|
|
3175
3243
|
}
|
|
3176
3244
|
let bin;
|
|
3177
3245
|
if (cli.flags['bin']) {
|
|
@@ -3186,12 +3254,6 @@ async function run$p(argv, importMeta, {
|
|
|
3186
3254
|
if (cli.flags['stdout']) {
|
|
3187
3255
|
out = '-';
|
|
3188
3256
|
}
|
|
3189
|
-
|
|
3190
|
-
// 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?
|
|
3191
|
-
if (target === '-') {
|
|
3192
|
-
new spinner.Spinner().start('Parsing...').error(`Failure: Currently source code from stdin is not supported. See \`${parentName} ${config$p.commandName} --help\` for details.`);
|
|
3193
|
-
process.exit(1);
|
|
3194
|
-
}
|
|
3195
3257
|
if (verbose) {
|
|
3196
3258
|
console.group();
|
|
3197
3259
|
console.log('- target:', target);
|
|
@@ -3203,6 +3265,7 @@ async function run$p(argv, importMeta, {
|
|
|
3203
3265
|
if (cli.flags['gradleOpts']) {
|
|
3204
3266
|
gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
|
|
3205
3267
|
}
|
|
3268
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3206
3269
|
await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
|
|
3207
3270
|
}
|
|
3208
3271
|
|
|
@@ -3299,7 +3362,7 @@ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
|
|
|
3299
3362
|
}
|
|
3300
3363
|
|
|
3301
3364
|
const config$o = {
|
|
3302
|
-
commandName: '
|
|
3365
|
+
commandName: 'scala',
|
|
3303
3366
|
description: "[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
|
|
3304
3367
|
hidden: false,
|
|
3305
3368
|
flags: {
|
|
@@ -3376,13 +3439,11 @@ async function run$o(argv, importMeta, {
|
|
|
3376
3439
|
parentName
|
|
3377
3440
|
}) {
|
|
3378
3441
|
// console.log('scala', argv, parentName)
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
allowUnknownFlags: false,
|
|
3385
|
-
importMeta
|
|
3442
|
+
const cli = meowOrExit({
|
|
3443
|
+
argv,
|
|
3444
|
+
config: config$o,
|
|
3445
|
+
importMeta,
|
|
3446
|
+
parentName
|
|
3386
3447
|
});
|
|
3387
3448
|
const verbose = Boolean(cli.flags['verbose']);
|
|
3388
3449
|
if (verbose) {
|
|
@@ -3393,15 +3454,18 @@ async function run$o(argv, importMeta, {
|
|
|
3393
3454
|
console.groupEnd();
|
|
3394
3455
|
}
|
|
3395
3456
|
const target = cli.input[0];
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
//
|
|
3403
|
-
|
|
3404
|
-
|
|
3457
|
+
|
|
3458
|
+
// 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?
|
|
3459
|
+
|
|
3460
|
+
if (!target || target === '-' || cli.input.length > 1) {
|
|
3461
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
3462
|
+
// options or missing arguments.
|
|
3463
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
3464
|
+
process.exitCode = 2;
|
|
3465
|
+
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
3466
|
+
- The DIR or FILE arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
|
|
3467
|
+
- 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`);
|
|
3468
|
+
return;
|
|
3405
3469
|
}
|
|
3406
3470
|
let bin = 'sbt';
|
|
3407
3471
|
if (cli.flags['bin']) {
|
|
@@ -3421,16 +3485,11 @@ async function run$o(argv, importMeta, {
|
|
|
3421
3485
|
console.log('- out:', out);
|
|
3422
3486
|
console.groupEnd();
|
|
3423
3487
|
}
|
|
3424
|
-
|
|
3425
|
-
// TODO: we can make `-` (accept from stdin) work by storing it into /tmp
|
|
3426
|
-
if (target === '-') {
|
|
3427
|
-
new spinner.Spinner().start('Parsing...').error(`Failure: Currently source code from stdin is not supported. See \`${parentName} ${config$o.commandName} --help\` for details.`);
|
|
3428
|
-
process.exit(1);
|
|
3429
|
-
}
|
|
3430
3488
|
let sbtOpts = [];
|
|
3431
3489
|
if (cli.flags['sbtOpts']) {
|
|
3432
3490
|
sbtOpts = cli.flags['sbtOpts'].split(' ').map(s => s.trim()).filter(Boolean);
|
|
3433
3491
|
}
|
|
3492
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3434
3493
|
await convertSbtToMaven(target, bin, out, verbose, sbtOpts);
|
|
3435
3494
|
}
|
|
3436
3495
|
|
|
@@ -3471,12 +3530,11 @@ const cmdManifestAuto = {
|
|
|
3471
3530
|
async function run$n(argv, importMeta, {
|
|
3472
3531
|
parentName
|
|
3473
3532
|
}) {
|
|
3474
|
-
const cli =
|
|
3533
|
+
const cli = meowOrExit({
|
|
3475
3534
|
argv,
|
|
3476
|
-
|
|
3535
|
+
config: config$n,
|
|
3477
3536
|
importMeta,
|
|
3478
|
-
|
|
3479
|
-
allowUnknownFlags: false
|
|
3537
|
+
parentName
|
|
3480
3538
|
});
|
|
3481
3539
|
const verbose = !!cli.flags['verbose'];
|
|
3482
3540
|
const cwd = cli.flags['cwd'] ?? process.cwd();
|
|
@@ -3499,6 +3557,7 @@ async function run$n(argv, importMeta, {
|
|
|
3499
3557
|
subArgs.push('--cwd', cwd);
|
|
3500
3558
|
}
|
|
3501
3559
|
subArgs.push(dir);
|
|
3560
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3502
3561
|
await cmdManifestScala.run(subArgs, importMeta, {
|
|
3503
3562
|
parentName
|
|
3504
3563
|
});
|
|
@@ -3510,11 +3569,13 @@ async function run$n(argv, importMeta, {
|
|
|
3510
3569
|
// This command takes the cwd as first arg.
|
|
3511
3570
|
subArgs.push(cwd);
|
|
3512
3571
|
}
|
|
3572
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3513
3573
|
await cmdManifestGradle.run(subArgs, importMeta, {
|
|
3514
3574
|
parentName
|
|
3515
3575
|
});
|
|
3516
3576
|
return;
|
|
3517
3577
|
}
|
|
3578
|
+
|
|
3518
3579
|
// Show new help screen and exit.
|
|
3519
3580
|
meow(`
|
|
3520
3581
|
$ ${parentName} ${config$n.commandName}
|
|
@@ -3619,13 +3680,11 @@ const cmdManifestKotlin = {
|
|
|
3619
3680
|
async function run$m(argv, importMeta, {
|
|
3620
3681
|
parentName
|
|
3621
3682
|
}) {
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
allowUnknownFlags: false,
|
|
3628
|
-
importMeta
|
|
3683
|
+
const cli = meowOrExit({
|
|
3684
|
+
argv,
|
|
3685
|
+
config: config$m,
|
|
3686
|
+
importMeta,
|
|
3687
|
+
parentName
|
|
3629
3688
|
});
|
|
3630
3689
|
const verbose = Boolean(cli.flags['verbose']);
|
|
3631
3690
|
if (verbose) {
|
|
@@ -3636,15 +3695,18 @@ async function run$m(argv, importMeta, {
|
|
|
3636
3695
|
console.groupEnd();
|
|
3637
3696
|
}
|
|
3638
3697
|
const target = cli.input[0];
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
//
|
|
3646
|
-
|
|
3647
|
-
|
|
3698
|
+
|
|
3699
|
+
// 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?
|
|
3700
|
+
|
|
3701
|
+
if (!target || target === '-' || cli.input.length > 1) {
|
|
3702
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
3703
|
+
// options or missing arguments.
|
|
3704
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
3705
|
+
process.exitCode = 2;
|
|
3706
|
+
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
3707
|
+
- The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
|
|
3708
|
+
- Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
|
|
3709
|
+
return;
|
|
3648
3710
|
}
|
|
3649
3711
|
let bin;
|
|
3650
3712
|
if (cli.flags['bin']) {
|
|
@@ -3659,12 +3721,6 @@ async function run$m(argv, importMeta, {
|
|
|
3659
3721
|
if (cli.flags['stdout']) {
|
|
3660
3722
|
out = '-';
|
|
3661
3723
|
}
|
|
3662
|
-
|
|
3663
|
-
// 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?
|
|
3664
|
-
if (target === '-') {
|
|
3665
|
-
new spinner.Spinner().start('Parsing...').error(`Failure: Currently source code from stdin is not supported. See \`${parentName} ${config$m.commandName} --help\` for details.`);
|
|
3666
|
-
process.exit(1);
|
|
3667
|
-
}
|
|
3668
3724
|
if (verbose) {
|
|
3669
3725
|
console.group();
|
|
3670
3726
|
console.log('- target:', target);
|
|
@@ -3676,6 +3732,7 @@ async function run$m(argv, importMeta, {
|
|
|
3676
3732
|
if (cli.flags['gradleOpts']) {
|
|
3677
3733
|
gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
|
|
3678
3734
|
}
|
|
3735
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3679
3736
|
await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
|
|
3680
3737
|
}
|
|
3681
3738
|
|
|
@@ -3746,13 +3803,14 @@ const cmdNpm = {
|
|
|
3746
3803
|
async function run$k(argv, importMeta, {
|
|
3747
3804
|
parentName
|
|
3748
3805
|
}) {
|
|
3749
|
-
meowOrExit({
|
|
3806
|
+
const cli = meowOrExit({
|
|
3750
3807
|
allowUnknownFlags: true,
|
|
3751
3808
|
argv,
|
|
3752
3809
|
config: config$k,
|
|
3753
3810
|
importMeta,
|
|
3754
3811
|
parentName
|
|
3755
3812
|
});
|
|
3813
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3756
3814
|
await wrapNpm(argv);
|
|
3757
3815
|
}
|
|
3758
3816
|
|
|
@@ -3787,13 +3845,14 @@ const cmdNpx = {
|
|
|
3787
3845
|
async function run$j(argv, importMeta, {
|
|
3788
3846
|
parentName
|
|
3789
3847
|
}) {
|
|
3790
|
-
meowOrExit({
|
|
3848
|
+
const cli = meowOrExit({
|
|
3791
3849
|
allowUnknownFlags: true,
|
|
3792
3850
|
argv,
|
|
3793
3851
|
config: config$j,
|
|
3794
3852
|
importMeta,
|
|
3795
3853
|
parentName
|
|
3796
3854
|
});
|
|
3855
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3797
3856
|
await wrapNpx(argv);
|
|
3798
3857
|
}
|
|
3799
3858
|
|
|
@@ -3801,7 +3860,9 @@ const config$i = {
|
|
|
3801
3860
|
commandName: 'oops',
|
|
3802
3861
|
description: 'Trigger an intentional error (for development)',
|
|
3803
3862
|
hidden: true,
|
|
3804
|
-
flags: {
|
|
3863
|
+
flags: {
|
|
3864
|
+
...commonFlags
|
|
3865
|
+
},
|
|
3805
3866
|
help: (parentName, config) => `
|
|
3806
3867
|
Usage
|
|
3807
3868
|
$ ${parentName} ${config.commandName}
|
|
@@ -3817,12 +3878,13 @@ const cmdOops = {
|
|
|
3817
3878
|
async function run$i(argv, importMeta, {
|
|
3818
3879
|
parentName
|
|
3819
3880
|
}) {
|
|
3820
|
-
|
|
3881
|
+
const cli = meowOrExit({
|
|
3821
3882
|
argv,
|
|
3822
|
-
|
|
3883
|
+
config: config$i,
|
|
3823
3884
|
importMeta,
|
|
3824
|
-
|
|
3885
|
+
parentName
|
|
3825
3886
|
});
|
|
3887
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
3826
3888
|
throw new Error('This error was intentionally left blank');
|
|
3827
3889
|
}
|
|
3828
3890
|
|
|
@@ -4578,7 +4640,7 @@ const {
|
|
|
4578
4640
|
abortSignal: abortSignal$2
|
|
4579
4641
|
} = constants;
|
|
4580
4642
|
const COMMAND_TITLE$1 = 'Socket Optimize';
|
|
4581
|
-
const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/
|
|
4643
|
+
const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/8089';
|
|
4582
4644
|
async function updatePackageLockJson(lockName, agentExecPath, agent, spinner) {
|
|
4583
4645
|
spinner.start(`Updating ${lockName}...`);
|
|
4584
4646
|
try {
|
|
@@ -4666,7 +4728,7 @@ async function applyOptimization(cwd, pin, prod) {
|
|
|
4666
4728
|
}
|
|
4667
4729
|
if (agent === NPM$1 || pkgJsonChanged) {
|
|
4668
4730
|
// Always update package-lock.json until the npm overrides PR lands:
|
|
4669
|
-
// https://github.com/npm/cli/pull/
|
|
4731
|
+
// https://github.com/npm/cli/pull/8089
|
|
4670
4732
|
await updatePackageLockJson(lockName, agentExecPath, agent, spinner$1);
|
|
4671
4733
|
}
|
|
4672
4734
|
}
|
|
@@ -4855,7 +4917,7 @@ async function addOverrides({
|
|
|
4855
4917
|
}
|
|
4856
4918
|
|
|
4857
4919
|
const config$h = {
|
|
4858
|
-
commandName: '
|
|
4920
|
+
commandName: 'optimize',
|
|
4859
4921
|
description: 'Optimize dependencies with @socketregistry overrides',
|
|
4860
4922
|
hidden: false,
|
|
4861
4923
|
flags: {
|
|
@@ -4898,6 +4960,7 @@ async function run$h(argv, importMeta, {
|
|
|
4898
4960
|
parentName
|
|
4899
4961
|
});
|
|
4900
4962
|
const cwd = process$1.cwd();
|
|
4963
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
4901
4964
|
await applyOptimization(cwd, Boolean(cli.flags['pin']), Boolean(cli.flags['prod']));
|
|
4902
4965
|
}
|
|
4903
4966
|
|
|
@@ -4944,12 +5007,13 @@ const cmdOrganizations = {
|
|
|
4944
5007
|
async function run$g(argv, importMeta, {
|
|
4945
5008
|
parentName
|
|
4946
5009
|
}) {
|
|
4947
|
-
meowOrExit({
|
|
5010
|
+
const cli = meowOrExit({
|
|
4948
5011
|
argv,
|
|
4949
5012
|
config: config$g,
|
|
4950
5013
|
importMeta,
|
|
4951
5014
|
parentName
|
|
4952
5015
|
});
|
|
5016
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
4953
5017
|
await getOrganizations();
|
|
4954
5018
|
}
|
|
4955
5019
|
|
|
@@ -5002,13 +5066,14 @@ const cmdRawNpm = {
|
|
|
5002
5066
|
async function run$f(argv, importMeta, {
|
|
5003
5067
|
parentName
|
|
5004
5068
|
}) {
|
|
5005
|
-
meowOrExit({
|
|
5069
|
+
const cli = meowOrExit({
|
|
5006
5070
|
allowUnknownFlags: true,
|
|
5007
5071
|
argv,
|
|
5008
5072
|
config: config$f,
|
|
5009
5073
|
importMeta,
|
|
5010
5074
|
parentName
|
|
5011
5075
|
});
|
|
5076
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5012
5077
|
await runRawNpm(argv);
|
|
5013
5078
|
}
|
|
5014
5079
|
|
|
@@ -5061,13 +5126,14 @@ const cmdRawNpx = {
|
|
|
5061
5126
|
async function run$e(argv, importMeta, {
|
|
5062
5127
|
parentName
|
|
5063
5128
|
}) {
|
|
5064
|
-
meowOrExit({
|
|
5129
|
+
const cli = meowOrExit({
|
|
5065
5130
|
allowUnknownFlags: true,
|
|
5066
5131
|
argv,
|
|
5067
5132
|
config: config$e,
|
|
5068
5133
|
importMeta,
|
|
5069
5134
|
parentName
|
|
5070
5135
|
});
|
|
5136
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5071
5137
|
await runRawNpx(argv);
|
|
5072
5138
|
}
|
|
5073
5139
|
|
|
@@ -5263,15 +5329,15 @@ async function run$d(argv, importMeta, {
|
|
|
5263
5329
|
const strict = Boolean(cli.flags['strict']);
|
|
5264
5330
|
const includeAllIssues = Boolean(cli.flags['all']);
|
|
5265
5331
|
const view = Boolean(cli.flags['view']);
|
|
5332
|
+
|
|
5333
|
+
// Note exiting earlier to skirt a hidden auth requirement
|
|
5334
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5266
5335
|
const socketConfig = await getSocketConfig(absoluteConfigPath);
|
|
5267
5336
|
const result = await createReport(socketConfig, cli.input, {
|
|
5268
5337
|
cwd,
|
|
5269
5338
|
dryRun
|
|
5270
5339
|
});
|
|
5271
5340
|
const commandName = `${parentName} ${config$d.commandName}`;
|
|
5272
|
-
if (dryRun && view) {
|
|
5273
|
-
console.log('[dryrun] Ignoring view flag since no report was actually generated');
|
|
5274
|
-
}
|
|
5275
5341
|
if (result?.success) {
|
|
5276
5342
|
if (view) {
|
|
5277
5343
|
const reportId = result.data.id;
|
|
@@ -5332,13 +5398,16 @@ async function run$c(argv, importMeta, {
|
|
|
5332
5398
|
|
|
5333
5399
|
// Validate the input.
|
|
5334
5400
|
if (extraInput.length || !reportId) {
|
|
5401
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5402
|
+
// options or missing arguments.
|
|
5403
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5404
|
+
process.exitCode = 2;
|
|
5335
5405
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5336
5406
|
- Need at least one report ID ${!reportId ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
5337
|
-
- Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}\n
|
|
5338
|
-
`);
|
|
5339
|
-
cli.showHelp();
|
|
5407
|
+
- Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}\n`);
|
|
5340
5408
|
return;
|
|
5341
5409
|
}
|
|
5410
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5342
5411
|
await viewReport(reportId, {
|
|
5343
5412
|
all: Boolean(cli.flags['all']),
|
|
5344
5413
|
commandName: `${parentName} ${config$c.commandName}`,
|
|
@@ -5465,13 +5534,16 @@ async function run$b(argv, importMeta, {
|
|
|
5465
5534
|
const repoName = cli.flags['repoName'];
|
|
5466
5535
|
const [orgSlug = ''] = cli.input;
|
|
5467
5536
|
if (!repoName || typeof repoName !== 'string' || !orgSlug) {
|
|
5537
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5538
|
+
// options or missing arguments.
|
|
5539
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5540
|
+
process.exitCode = 2;
|
|
5468
5541
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5469
5542
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
5470
|
-
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
|
|
5471
|
-
`);
|
|
5472
|
-
cli.showHelp();
|
|
5543
|
+
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
|
|
5473
5544
|
return;
|
|
5474
5545
|
}
|
|
5546
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5475
5547
|
const apiToken = index.getDefaultToken();
|
|
5476
5548
|
if (!apiToken) {
|
|
5477
5549
|
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.');
|
|
@@ -5504,19 +5576,24 @@ async function deleteRepo(orgSlug, repoName, apiToken) {
|
|
|
5504
5576
|
}
|
|
5505
5577
|
|
|
5506
5578
|
const config$a = {
|
|
5507
|
-
commandName: '
|
|
5579
|
+
commandName: 'del',
|
|
5508
5580
|
description: 'Delete a repository in an organization',
|
|
5509
5581
|
hidden: false,
|
|
5510
|
-
flags: {
|
|
5511
|
-
|
|
5582
|
+
flags: {
|
|
5583
|
+
...commonFlags
|
|
5584
|
+
},
|
|
5585
|
+
help: (command, config) => `
|
|
5512
5586
|
Usage
|
|
5513
5587
|
$ ${command} <org slug> <repo slug>
|
|
5514
5588
|
|
|
5589
|
+
Options
|
|
5590
|
+
${getFlagListOutput(config.flags, 6)}
|
|
5591
|
+
|
|
5515
5592
|
Examples
|
|
5516
5593
|
$ ${command} FakeOrg test-repo
|
|
5517
5594
|
`
|
|
5518
5595
|
};
|
|
5519
|
-
const
|
|
5596
|
+
const cmdReposDel = {
|
|
5520
5597
|
description: config$a.description,
|
|
5521
5598
|
hidden: config$a.hidden,
|
|
5522
5599
|
run: run$a
|
|
@@ -5532,14 +5609,17 @@ async function run$a(argv, importMeta, {
|
|
|
5532
5609
|
});
|
|
5533
5610
|
const [orgSlug = '', repoName = ''] = cli.input;
|
|
5534
5611
|
if (!orgSlug || !repoName) {
|
|
5612
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5613
|
+
// options or missing arguments.
|
|
5614
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5615
|
+
process.exitCode = 2;
|
|
5535
5616
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5536
5617
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
5537
5618
|
- Repository name as the second argument ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
|
|
5538
|
-
- At least one TARGET (e.g. \`.\` or \`./package.json
|
|
5539
|
-
`);
|
|
5540
|
-
cli.showHelp();
|
|
5619
|
+
- At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
|
|
5541
5620
|
return;
|
|
5542
5621
|
}
|
|
5622
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5543
5623
|
const apiToken = index.getDefaultToken();
|
|
5544
5624
|
if (!apiToken) {
|
|
5545
5625
|
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.');
|
|
@@ -5655,13 +5735,16 @@ async function run$9(argv, importMeta, {
|
|
|
5655
5735
|
});
|
|
5656
5736
|
const [orgSlug = ''] = cli.input;
|
|
5657
5737
|
if (!orgSlug) {
|
|
5738
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5739
|
+
// options or missing arguments.
|
|
5740
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5741
|
+
process.exitCode = 2;
|
|
5658
5742
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5659
5743
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
5660
|
-
- At least one TARGET (e.g. \`.\` or \`./package.json
|
|
5661
|
-
`);
|
|
5662
|
-
cli.showHelp();
|
|
5744
|
+
- At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
|
|
5663
5745
|
return;
|
|
5664
5746
|
}
|
|
5747
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5665
5748
|
const apiToken = index.getDefaultToken();
|
|
5666
5749
|
if (!apiToken) {
|
|
5667
5750
|
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.');
|
|
@@ -5712,7 +5795,7 @@ async function updateRepo({
|
|
|
5712
5795
|
}
|
|
5713
5796
|
|
|
5714
5797
|
const config$8 = {
|
|
5715
|
-
commandName: '
|
|
5798
|
+
commandName: 'update',
|
|
5716
5799
|
description: 'Update a repository in an organization',
|
|
5717
5800
|
hidden: false,
|
|
5718
5801
|
flags: {
|
|
@@ -5777,14 +5860,17 @@ async function run$8(argv, importMeta, {
|
|
|
5777
5860
|
const repoName = cli.flags['repoName'];
|
|
5778
5861
|
const [orgSlug = ''] = cli.input;
|
|
5779
5862
|
if (!repoName || typeof repoName !== 'string' || !orgSlug) {
|
|
5863
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5864
|
+
// options or missing arguments.
|
|
5865
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5866
|
+
process.exitCode = 2;
|
|
5780
5867
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5781
5868
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
5782
5869
|
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
|
|
5783
|
-
- At least one TARGET (e.g. \`.\` or \`./package.json
|
|
5784
|
-
`);
|
|
5785
|
-
cli.showHelp();
|
|
5870
|
+
- At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
|
|
5786
5871
|
return;
|
|
5787
5872
|
}
|
|
5873
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5788
5874
|
const apiToken = index.getDefaultToken();
|
|
5789
5875
|
if (!apiToken) {
|
|
5790
5876
|
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.');
|
|
@@ -5877,13 +5963,16 @@ async function run$7(argv, importMeta, {
|
|
|
5877
5963
|
const repoName = cli.flags['repoName'];
|
|
5878
5964
|
const [orgSlug = ''] = cli.input;
|
|
5879
5965
|
if (!repoName || typeof repoName !== 'string' || !orgSlug) {
|
|
5966
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5967
|
+
// options or missing arguments.
|
|
5968
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5969
|
+
process.exitCode = 2;
|
|
5880
5970
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5881
5971
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
5882
|
-
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
|
|
5883
|
-
`);
|
|
5884
|
-
cli.showHelp();
|
|
5972
|
+
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
|
|
5885
5973
|
return;
|
|
5886
5974
|
}
|
|
5975
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
5887
5976
|
const apiToken = index.getDefaultToken();
|
|
5888
5977
|
if (!apiToken) {
|
|
5889
5978
|
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.');
|
|
@@ -5898,16 +5987,16 @@ const cmdRepos = {
|
|
|
5898
5987
|
parentName
|
|
5899
5988
|
}) {
|
|
5900
5989
|
await meowWithSubcommands({
|
|
5901
|
-
cmdReposCreate,
|
|
5902
|
-
cmdReposView,
|
|
5903
|
-
cmdReposList,
|
|
5904
|
-
|
|
5905
|
-
cmdReposUpdate
|
|
5990
|
+
create: cmdReposCreate,
|
|
5991
|
+
view: cmdReposView,
|
|
5992
|
+
list: cmdReposList,
|
|
5993
|
+
del: cmdReposDel,
|
|
5994
|
+
update: cmdReposUpdate
|
|
5906
5995
|
}, {
|
|
5907
5996
|
argv,
|
|
5908
5997
|
description: description$1,
|
|
5909
5998
|
importMeta,
|
|
5910
|
-
name: `${parentName}
|
|
5999
|
+
name: `${parentName} repos`
|
|
5911
6000
|
});
|
|
5912
6001
|
}
|
|
5913
6002
|
};
|
|
@@ -5991,6 +6080,10 @@ const config$6 = {
|
|
|
5991
6080
|
type: 'string',
|
|
5992
6081
|
description: 'working directory, defaults to process.cwd()'
|
|
5993
6082
|
},
|
|
6083
|
+
dryRun: {
|
|
6084
|
+
type: 'boolean',
|
|
6085
|
+
description: 'run input validation part of command without any concrete side effects'
|
|
6086
|
+
},
|
|
5994
6087
|
pullRequest: {
|
|
5995
6088
|
type: 'number',
|
|
5996
6089
|
shortFlag: 'pr',
|
|
@@ -6053,6 +6146,9 @@ async function run$6(argv, importMeta, {
|
|
|
6053
6146
|
});
|
|
6054
6147
|
const [orgSlug = '', ...targets] = cli.input;
|
|
6055
6148
|
const cwd = cli.flags['cwd'] && cli.flags['cwd'] !== 'process.cwd()' ? String(cli.flags['cwd']) : process$1.cwd();
|
|
6149
|
+
|
|
6150
|
+
// Note exiting earlier to skirt a hidden auth requirement
|
|
6151
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
6056
6152
|
const socketSdk = await index.setupSdk();
|
|
6057
6153
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
6058
6154
|
if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
|
|
@@ -6069,12 +6165,15 @@ async function run$6(argv, importMeta, {
|
|
|
6069
6165
|
repo: repoName
|
|
6070
6166
|
} = cli.flags;
|
|
6071
6167
|
if (!orgSlug || !repoName || !branchName || !packagePaths.length) {
|
|
6168
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
6169
|
+
// options or missing arguments.
|
|
6170
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
6171
|
+
process$1.exitCode = 2;
|
|
6072
6172
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
6073
6173
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
6074
6174
|
- Repository name using --repo ${!repoName ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
6075
6175
|
- Branch name using --branch ${!branchName ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
6076
|
-
- 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)')}`);
|
|
6077
|
-
config$6.help(parentName, config$6);
|
|
6176
|
+
- 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`);
|
|
6078
6177
|
return;
|
|
6079
6178
|
}
|
|
6080
6179
|
const apiToken = index.getDefaultToken();
|
|
@@ -6131,7 +6230,7 @@ const config$5 = {
|
|
|
6131
6230
|
$ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
6132
6231
|
`
|
|
6133
6232
|
};
|
|
6134
|
-
const
|
|
6233
|
+
const cmdScanDel = {
|
|
6135
6234
|
description: config$5.description,
|
|
6136
6235
|
hidden: config$5.hidden,
|
|
6137
6236
|
run: run$5
|
|
@@ -6139,21 +6238,24 @@ const cmdScanDelete = {
|
|
|
6139
6238
|
async function run$5(argv, importMeta, {
|
|
6140
6239
|
parentName
|
|
6141
6240
|
}) {
|
|
6142
|
-
const cli =
|
|
6241
|
+
const cli = meowOrExit({
|
|
6143
6242
|
argv,
|
|
6144
|
-
|
|
6243
|
+
config: config$5,
|
|
6145
6244
|
importMeta,
|
|
6146
|
-
|
|
6245
|
+
parentName
|
|
6147
6246
|
});
|
|
6148
6247
|
const [orgSlug = '', fullScanId = ''] = cli.input;
|
|
6149
6248
|
if (!orgSlug || !fullScanId) {
|
|
6249
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
6250
|
+
// options or missing arguments.
|
|
6251
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
6252
|
+
process.exitCode = 2;
|
|
6150
6253
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
6151
6254
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
6152
|
-
- Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
|
|
6153
|
-
`);
|
|
6154
|
-
config$5.help(parentName, config$5);
|
|
6255
|
+
- Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6155
6256
|
return;
|
|
6156
6257
|
}
|
|
6258
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
6157
6259
|
const apiToken = index.getDefaultToken();
|
|
6158
6260
|
if (!apiToken) {
|
|
6159
6261
|
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.');
|
|
@@ -6267,19 +6369,23 @@ const cmdScanList = {
|
|
|
6267
6369
|
async function run$4(argv, importMeta, {
|
|
6268
6370
|
parentName
|
|
6269
6371
|
}) {
|
|
6270
|
-
const cli =
|
|
6372
|
+
const cli = meowOrExit({
|
|
6271
6373
|
argv,
|
|
6272
|
-
|
|
6374
|
+
config: config$4,
|
|
6273
6375
|
importMeta,
|
|
6274
|
-
|
|
6376
|
+
parentName
|
|
6275
6377
|
});
|
|
6276
6378
|
const orgSlug = cli.input[0];
|
|
6277
6379
|
if (!orgSlug) {
|
|
6380
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
6381
|
+
// options or missing arguments.
|
|
6382
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
6383
|
+
process.exitCode = 2;
|
|
6278
6384
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
6279
|
-
- Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}`);
|
|
6280
|
-
config$4.help(parentName, config$4);
|
|
6385
|
+
- Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6281
6386
|
return;
|
|
6282
6387
|
}
|
|
6388
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
6283
6389
|
const apiToken = index.getDefaultToken();
|
|
6284
6390
|
if (!apiToken) {
|
|
6285
6391
|
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.');
|
|
@@ -6341,21 +6447,24 @@ const cmdScanMetadata = {
|
|
|
6341
6447
|
async function run$3(argv, importMeta, {
|
|
6342
6448
|
parentName
|
|
6343
6449
|
}) {
|
|
6344
|
-
const cli =
|
|
6450
|
+
const cli = meowOrExit({
|
|
6345
6451
|
argv,
|
|
6346
|
-
|
|
6452
|
+
config: config$3,
|
|
6347
6453
|
importMeta,
|
|
6348
|
-
|
|
6454
|
+
parentName
|
|
6349
6455
|
});
|
|
6350
6456
|
const [orgSlug = '', fullScanId = ''] = cli.input;
|
|
6351
6457
|
if (!orgSlug || !fullScanId) {
|
|
6458
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
6459
|
+
// options or missing arguments.
|
|
6460
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
6461
|
+
process.exitCode = 2;
|
|
6352
6462
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
6353
6463
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
6354
|
-
- Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
|
|
6355
|
-
`);
|
|
6356
|
-
config$3.help(parentName, config$3);
|
|
6464
|
+
- Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6357
6465
|
return;
|
|
6358
6466
|
}
|
|
6467
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
6359
6468
|
const apiToken = index.getDefaultToken();
|
|
6360
6469
|
if (!apiToken) {
|
|
6361
6470
|
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.');
|
|
@@ -6406,21 +6515,24 @@ const cmdScanStream = {
|
|
|
6406
6515
|
async function run$2(argv, importMeta, {
|
|
6407
6516
|
parentName
|
|
6408
6517
|
}) {
|
|
6409
|
-
const cli =
|
|
6518
|
+
const cli = meowOrExit({
|
|
6410
6519
|
argv,
|
|
6411
|
-
|
|
6520
|
+
config: config$2,
|
|
6412
6521
|
importMeta,
|
|
6413
|
-
|
|
6522
|
+
parentName
|
|
6414
6523
|
});
|
|
6415
6524
|
const [orgSlug = '', fullScanId = '', file = '-'] = cli.input;
|
|
6416
6525
|
if (!orgSlug || !fullScanId) {
|
|
6526
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
6527
|
+
// options or missing arguments.
|
|
6528
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
6529
|
+
process.exitCode = 2;
|
|
6417
6530
|
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
6418
6531
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
|
|
6419
|
-
- Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
|
|
6420
|
-
`);
|
|
6421
|
-
config$2.help(parentName, config$2);
|
|
6532
|
+
- Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6422
6533
|
return;
|
|
6423
6534
|
}
|
|
6535
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
6424
6536
|
const apiToken = index.getDefaultToken();
|
|
6425
6537
|
if (!apiToken) {
|
|
6426
6538
|
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.');
|
|
@@ -6438,7 +6550,7 @@ const cmdScan = {
|
|
|
6438
6550
|
create: cmdScanCreate,
|
|
6439
6551
|
stream: cmdScanStream,
|
|
6440
6552
|
list: cmdScanList,
|
|
6441
|
-
del:
|
|
6553
|
+
del: cmdScanDel,
|
|
6442
6554
|
metadata: cmdScanMetadata
|
|
6443
6555
|
}, {
|
|
6444
6556
|
argv,
|
|
@@ -6583,6 +6695,7 @@ async function run$1(argv, importMeta, {
|
|
|
6583
6695
|
importMeta,
|
|
6584
6696
|
parentName
|
|
6585
6697
|
});
|
|
6698
|
+
if (cli.flags['dryRun']) return console.log('[DryRun] Bailing now');
|
|
6586
6699
|
const apiToken = index.getDefaultToken();
|
|
6587
6700
|
if (!apiToken) {
|
|
6588
6701
|
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.');
|
|
@@ -6621,11 +6734,13 @@ function checkSocketWrapperSetup(file) {
|
|
|
6621
6734
|
return false;
|
|
6622
6735
|
}
|
|
6623
6736
|
|
|
6624
|
-
const HOME_DIR$1 = os.homedir();
|
|
6625
|
-
const BASH_FILE$1 = `${HOME_DIR$1}/.bashrc`;
|
|
6626
|
-
const ZSH_BASH_FILE$1 = `${HOME_DIR$1}/.zshrc`;
|
|
6627
6737
|
function postinstallWrapper() {
|
|
6628
|
-
|
|
6738
|
+
// Lazily access constants.bashRcPath and constants.zshRcPath.
|
|
6739
|
+
const {
|
|
6740
|
+
bashRcPath,
|
|
6741
|
+
zshRcPath
|
|
6742
|
+
} = constants;
|
|
6743
|
+
const socketWrapperEnabled = fs.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
|
|
6629
6744
|
if (!socketWrapperEnabled) {
|
|
6630
6745
|
installSafeNpm(`The Socket CLI is now successfully installed! 🎉
|
|
6631
6746
|
|
|
@@ -6651,12 +6766,17 @@ function installSafeNpm(query) {
|
|
|
6651
6766
|
function askQuestion(rl, query) {
|
|
6652
6767
|
rl.question(query, ans => {
|
|
6653
6768
|
if (ans.toLowerCase() === 'y') {
|
|
6769
|
+
// Lazily access constants.bashRcPath and constants.zshRcPath.
|
|
6770
|
+
const {
|
|
6771
|
+
bashRcPath,
|
|
6772
|
+
zshRcPath
|
|
6773
|
+
} = constants;
|
|
6654
6774
|
try {
|
|
6655
|
-
if (fs.existsSync(
|
|
6656
|
-
addSocketWrapper(
|
|
6775
|
+
if (fs.existsSync(bashRcPath)) {
|
|
6776
|
+
addSocketWrapper(bashRcPath);
|
|
6657
6777
|
}
|
|
6658
|
-
if (fs.existsSync(
|
|
6659
|
-
addSocketWrapper(
|
|
6778
|
+
if (fs.existsSync(zshRcPath)) {
|
|
6779
|
+
addSocketWrapper(zshRcPath);
|
|
6660
6780
|
}
|
|
6661
6781
|
} catch (e) {
|
|
6662
6782
|
throw new Error(`There was an issue setting up the alias: ${e}`);
|
|
@@ -6691,14 +6811,12 @@ function removeSocketWrapper(file) {
|
|
|
6691
6811
|
});
|
|
6692
6812
|
}
|
|
6693
6813
|
|
|
6694
|
-
const HOME_DIR = os.homedir();
|
|
6695
|
-
const BASH_FILE = `${HOME_DIR}/.bashrc`;
|
|
6696
|
-
const ZSH_BASH_FILE = `${HOME_DIR}/.zshrc`;
|
|
6697
6814
|
const config = {
|
|
6698
6815
|
commandName: 'wrapper',
|
|
6699
6816
|
description: 'Enable or disable the Socket npm/npx wrapper',
|
|
6700
6817
|
hidden: false,
|
|
6701
6818
|
flags: {
|
|
6819
|
+
...commonFlags,
|
|
6702
6820
|
enable: {
|
|
6703
6821
|
type: 'boolean',
|
|
6704
6822
|
default: false,
|
|
@@ -6742,31 +6860,42 @@ async function run(argv, importMeta, {
|
|
|
6742
6860
|
parentName
|
|
6743
6861
|
});
|
|
6744
6862
|
const {
|
|
6745
|
-
disable,
|
|
6746
6863
|
enable
|
|
6747
6864
|
} = cli.flags;
|
|
6748
|
-
if (!enable && !disable) {
|
|
6749
|
-
|
|
6865
|
+
if (!enable && !cli.flags['disable']) {
|
|
6866
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
6867
|
+
// options or missing arguments.
|
|
6868
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
6869
|
+
process.exitCode = 2;
|
|
6870
|
+
console.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required flags:\n
|
|
6871
|
+
- Must use --enabled or --disabled\n`);
|
|
6750
6872
|
return;
|
|
6751
6873
|
}
|
|
6874
|
+
if (cli.flags['dryRun']) {
|
|
6875
|
+
return console.log('[DryRun] Bailing now');
|
|
6876
|
+
}
|
|
6877
|
+
|
|
6878
|
+
// Lazily access constants.bashRcPath and constants.zshRcPath.
|
|
6879
|
+
const {
|
|
6880
|
+
bashRcPath,
|
|
6881
|
+
zshRcPath
|
|
6882
|
+
} = constants;
|
|
6752
6883
|
if (enable) {
|
|
6753
|
-
if (fs.existsSync(
|
|
6754
|
-
|
|
6755
|
-
!socketWrapperEnabled && addSocketWrapper(BASH_FILE);
|
|
6884
|
+
if (fs.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
|
|
6885
|
+
addSocketWrapper(bashRcPath);
|
|
6756
6886
|
}
|
|
6757
|
-
if (fs.existsSync(
|
|
6758
|
-
|
|
6759
|
-
!socketWrapperEnabled && addSocketWrapper(ZSH_BASH_FILE);
|
|
6887
|
+
if (fs.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
|
|
6888
|
+
addSocketWrapper(zshRcPath);
|
|
6760
6889
|
}
|
|
6761
6890
|
} else {
|
|
6762
|
-
if (fs.existsSync(
|
|
6763
|
-
removeSocketWrapper(
|
|
6891
|
+
if (fs.existsSync(bashRcPath)) {
|
|
6892
|
+
removeSocketWrapper(bashRcPath);
|
|
6764
6893
|
}
|
|
6765
|
-
if (fs.existsSync(
|
|
6766
|
-
removeSocketWrapper(
|
|
6894
|
+
if (fs.existsSync(zshRcPath)) {
|
|
6895
|
+
removeSocketWrapper(zshRcPath);
|
|
6767
6896
|
}
|
|
6768
6897
|
}
|
|
6769
|
-
if (!fs.existsSync(
|
|
6898
|
+
if (!fs.existsSync(bashRcPath) && !fs.existsSync(zshRcPath)) {
|
|
6770
6899
|
console.error('There was an issue setting up the alias in your bash profile');
|
|
6771
6900
|
}
|
|
6772
6901
|
}
|
|
@@ -6847,5 +6976,5 @@ void (async () => {
|
|
|
6847
6976
|
await index.captureException(e);
|
|
6848
6977
|
}
|
|
6849
6978
|
})();
|
|
6850
|
-
//# debugId=
|
|
6979
|
+
//# debugId=d30f7250-79de-4641-a3e0-e622cbd34263
|
|
6851
6980
|
//# sourceMappingURL=cli.js.map
|