@socketsecurity/cli-with-sentry 0.14.48 → 0.14.49
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 +6 -3
- package/dist/constants.js +2 -2
- 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 +397 -299
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/npm.d.ts +5 -3
- package/dist/module-sync/npm.js +23 -9
- package/dist/module-sync/npm.js.map +1 -1
- package/dist/require/cli.js +397 -299
- package/dist/require/cli.js.map +1 -1
- package/package.json +7 -4
package/dist/require/cli.js
CHANGED
|
@@ -52,8 +52,8 @@ var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
|
|
|
52
52
|
var sorts = require('@socketsecurity/registry/lib/sorts');
|
|
53
53
|
var strings = require('@socketsecurity/registry/lib/strings');
|
|
54
54
|
var yaml = _socketInterop(require('yaml'));
|
|
55
|
-
var npm$1 = require('./npm.js');
|
|
56
55
|
var npmPaths = require('./npm-paths.js');
|
|
56
|
+
var npm$1 = require('./npm.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');
|
|
@@ -1282,6 +1282,51 @@ async function runAction(githubEventBefore, githubEventAfter) {
|
|
|
1282
1282
|
}
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
1285
|
+
const {
|
|
1286
|
+
API_V0_URL
|
|
1287
|
+
} = constants;
|
|
1288
|
+
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
1289
|
+
// SocketSdkErrorType['error'] is not typed.
|
|
1290
|
+
const resultErrorMessage = result.error?.message;
|
|
1291
|
+
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
1292
|
+
if (result.status === 401 || result.status === 403) {
|
|
1293
|
+
spinner.stop();
|
|
1294
|
+
throw new index.AuthError(message);
|
|
1295
|
+
}
|
|
1296
|
+
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
1297
|
+
process$1.exit(1);
|
|
1298
|
+
}
|
|
1299
|
+
async function handleApiCall(value, description) {
|
|
1300
|
+
let result;
|
|
1301
|
+
try {
|
|
1302
|
+
result = await value;
|
|
1303
|
+
} catch (cause) {
|
|
1304
|
+
throw new Error(`Failed ${description}`, {
|
|
1305
|
+
cause
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
return result;
|
|
1309
|
+
}
|
|
1310
|
+
async function handleAPIError(code) {
|
|
1311
|
+
if (code === 400) {
|
|
1312
|
+
return 'One of the options passed might be incorrect.';
|
|
1313
|
+
} else if (code === 403) {
|
|
1314
|
+
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
function getLastFiveOfApiToken(token) {
|
|
1318
|
+
// Get the last 5 characters of the API token before the trailing "_api".
|
|
1319
|
+
return token.slice(-9, -4);
|
|
1320
|
+
}
|
|
1321
|
+
async function queryAPI(path, apiToken) {
|
|
1322
|
+
return await fetch(`${API_V0_URL}/${path}`, {
|
|
1323
|
+
method: 'GET',
|
|
1324
|
+
headers: {
|
|
1325
|
+
Authorization: `Basic ${btoa(`${apiToken}:${apiToken}`)}`
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1285
1330
|
function getFlagListOutput(list, indent, {
|
|
1286
1331
|
keyPrefix = '--',
|
|
1287
1332
|
padName
|
|
@@ -1449,6 +1494,7 @@ function meowOrExit({
|
|
|
1449
1494
|
if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) {
|
|
1450
1495
|
console.log(getAsciiHeader(command));
|
|
1451
1496
|
}
|
|
1497
|
+
|
|
1452
1498
|
// This exits if .printHelp() is called either by meow itself or by us.
|
|
1453
1499
|
const cli = vendor.meow({
|
|
1454
1500
|
argv,
|
|
@@ -1466,15 +1512,15 @@ function meowOrExit({
|
|
|
1466
1512
|
}
|
|
1467
1513
|
function getAsciiHeader(command) {
|
|
1468
1514
|
const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']".
|
|
1469
|
-
"0.14.
|
|
1515
|
+
"0.14.49:216163f:34d3aac1:pub";
|
|
1470
1516
|
const nodeVersion = process.version;
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1517
|
+
const apiToken = index.getSetting('apiToken');
|
|
1518
|
+
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
|
|
1473
1519
|
const relCwd = process.cwd().replace(new RegExp(`^${regexps.escapeRegExp(constants.homePath)}`, 'i'), '~/');
|
|
1474
1520
|
const body = `
|
|
1475
1521
|
_____ _ _ /---------------
|
|
1476
1522
|
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
|
|
1477
|
-
|__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${
|
|
1523
|
+
|__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}
|
|
1478
1524
|
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart();
|
|
1479
1525
|
return ` ${body}\n`;
|
|
1480
1526
|
}
|
|
@@ -1530,49 +1576,10 @@ async function run$z(argv, importMeta, {
|
|
|
1530
1576
|
});
|
|
1531
1577
|
const githubEventBefore = String(cli.flags['githubEventBefore'] || '');
|
|
1532
1578
|
const githubEventAfter = String(cli.flags['githubEventAfter'] || '');
|
|
1533
|
-
if (cli.flags['dryRun'])
|
|
1534
|
-
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
const {
|
|
1538
|
-
API_V0_URL
|
|
1539
|
-
} = constants;
|
|
1540
|
-
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
1541
|
-
// SocketSdkErrorType['error'] is not typed.
|
|
1542
|
-
const resultErrorMessage = result.error?.message;
|
|
1543
|
-
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
1544
|
-
if (result.status === 401 || result.status === 403) {
|
|
1545
|
-
spinner.stop();
|
|
1546
|
-
throw new index.AuthError(message);
|
|
1547
|
-
}
|
|
1548
|
-
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
1549
|
-
process$1.exit(1);
|
|
1550
|
-
}
|
|
1551
|
-
async function handleApiCall(value, description) {
|
|
1552
|
-
let result;
|
|
1553
|
-
try {
|
|
1554
|
-
result = await value;
|
|
1555
|
-
} catch (cause) {
|
|
1556
|
-
throw new Error(`Failed ${description}`, {
|
|
1557
|
-
cause
|
|
1558
|
-
});
|
|
1559
|
-
}
|
|
1560
|
-
return result;
|
|
1561
|
-
}
|
|
1562
|
-
async function handleAPIError(code) {
|
|
1563
|
-
if (code === 400) {
|
|
1564
|
-
return 'One of the options passed might be incorrect.';
|
|
1565
|
-
} else if (code === 403) {
|
|
1566
|
-
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
1579
|
+
if (cli.flags['dryRun']) {
|
|
1580
|
+
return console.log('[DryRun] Bailing now');
|
|
1567
1581
|
}
|
|
1568
|
-
|
|
1569
|
-
async function queryAPI(path, apiToken) {
|
|
1570
|
-
return await fetch(`${API_V0_URL}/${path}`, {
|
|
1571
|
-
method: 'GET',
|
|
1572
|
-
headers: {
|
|
1573
|
-
Authorization: `Basic ${btoa(`${apiToken}:${apiToken}`)}`
|
|
1574
|
-
}
|
|
1575
|
-
});
|
|
1582
|
+
await runAction(githubEventBefore, githubEventAfter);
|
|
1576
1583
|
}
|
|
1577
1584
|
|
|
1578
1585
|
// Note: Widgets does not seem to actually work as code :'(
|
|
@@ -1847,7 +1854,9 @@ async function run$y(argv, importMeta, {
|
|
|
1847
1854
|
- Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}\n`);
|
|
1848
1855
|
return;
|
|
1849
1856
|
}
|
|
1850
|
-
if (cli.flags['dryRun'])
|
|
1857
|
+
if (cli.flags['dryRun']) {
|
|
1858
|
+
return console.log('[DryRun] Bailing now');
|
|
1859
|
+
}
|
|
1851
1860
|
const apiToken = index.getDefaultToken();
|
|
1852
1861
|
if (!apiToken) {
|
|
1853
1862
|
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.');
|
|
@@ -1975,7 +1984,9 @@ async function run$x(argv, importMeta, {
|
|
|
1975
1984
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
1976
1985
|
return;
|
|
1977
1986
|
}
|
|
1978
|
-
if (cli.flags['dryRun'])
|
|
1987
|
+
if (cli.flags['dryRun']) {
|
|
1988
|
+
return console.log('[DryRun] Bailing now');
|
|
1989
|
+
}
|
|
1979
1990
|
const apiToken = index.getDefaultToken();
|
|
1980
1991
|
if (!apiToken) {
|
|
1981
1992
|
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.');
|
|
@@ -2197,7 +2208,9 @@ async function run$w(argv, importMeta, {
|
|
|
2197
2208
|
if (yargv.output === undefined) {
|
|
2198
2209
|
yargv.output = 'socket-cdx.json';
|
|
2199
2210
|
}
|
|
2200
|
-
if (cli.flags['dryRun'])
|
|
2211
|
+
if (cli.flags['dryRun']) {
|
|
2212
|
+
return console.log('[DryRun] Bailing now');
|
|
2213
|
+
}
|
|
2201
2214
|
await runCycloneDX(yargv);
|
|
2202
2215
|
}
|
|
2203
2216
|
|
|
@@ -2300,7 +2313,9 @@ async function run$v(argv, importMeta, {
|
|
|
2300
2313
|
importMeta,
|
|
2301
2314
|
parentName
|
|
2302
2315
|
});
|
|
2303
|
-
if (cli.flags['dryRun'])
|
|
2316
|
+
if (cli.flags['dryRun']) {
|
|
2317
|
+
return console.log('[DryRun] Bailing now');
|
|
2318
|
+
}
|
|
2304
2319
|
|
|
2305
2320
|
// TODO: markdown flag is ignored
|
|
2306
2321
|
await findDependencies({
|
|
@@ -2422,7 +2437,9 @@ async function run$u(argv, importMeta, {
|
|
|
2422
2437
|
- Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
2423
2438
|
return;
|
|
2424
2439
|
}
|
|
2425
|
-
if (cli.flags['dryRun'])
|
|
2440
|
+
if (cli.flags['dryRun']) {
|
|
2441
|
+
return console.log('[DryRun] Bailing now');
|
|
2442
|
+
}
|
|
2426
2443
|
const apiToken = index.getDefaultToken();
|
|
2427
2444
|
if (!apiToken) {
|
|
2428
2445
|
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.');
|
|
@@ -2455,7 +2472,7 @@ const cmdDiffScan = {
|
|
|
2455
2472
|
}
|
|
2456
2473
|
};
|
|
2457
2474
|
|
|
2458
|
-
// import { detect } from '../../utils/package-
|
|
2475
|
+
// import { detect } from '../../utils/package-environment-detector'
|
|
2459
2476
|
|
|
2460
2477
|
const {
|
|
2461
2478
|
NPM: NPM$d
|
|
@@ -2590,7 +2607,9 @@ async function run$t(argv, importMeta, {
|
|
|
2590
2607
|
importMeta,
|
|
2591
2608
|
parentName
|
|
2592
2609
|
});
|
|
2593
|
-
if (cli.flags['dryRun'])
|
|
2610
|
+
if (cli.flags['dryRun']) {
|
|
2611
|
+
return console.log('[DryRun] Bailing now');
|
|
2612
|
+
}
|
|
2594
2613
|
await runFix();
|
|
2595
2614
|
}
|
|
2596
2615
|
|
|
@@ -2853,7 +2872,9 @@ async function run$s(argv, importMeta, {
|
|
|
2853
2872
|
const versionSeparator = rawPkgName.lastIndexOf('@');
|
|
2854
2873
|
const pkgName = versionSeparator < 1 ? rawPkgName : rawPkgName.slice(0, versionSeparator);
|
|
2855
2874
|
const pkgVersion = versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1);
|
|
2856
|
-
if (cli.flags['dryRun'])
|
|
2875
|
+
if (cli.flags['dryRun']) {
|
|
2876
|
+
return console.log('[DryRun] Bailing now');
|
|
2877
|
+
}
|
|
2857
2878
|
await getPackageInfo({
|
|
2858
2879
|
commandName: `${parentName} ${config$s.commandName}`,
|
|
2859
2880
|
includeAllIssues: Boolean(cli.flags['all']),
|
|
@@ -2982,7 +3003,9 @@ async function run$r(argv, importMeta, {
|
|
|
2982
3003
|
});
|
|
2983
3004
|
let apiBaseUrl = cli.flags['apiBaseUrl'];
|
|
2984
3005
|
let apiProxy = cli.flags['apiProxy'];
|
|
2985
|
-
if (cli.flags['dryRun'])
|
|
3006
|
+
if (cli.flags['dryRun']) {
|
|
3007
|
+
return console.log('[DryRun] Bailing now');
|
|
3008
|
+
}
|
|
2986
3009
|
if (!isInteractive()) {
|
|
2987
3010
|
throw new index.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
2988
3011
|
}
|
|
@@ -3033,7 +3056,9 @@ async function run$q(argv, importMeta, {
|
|
|
3033
3056
|
importMeta,
|
|
3034
3057
|
parentName
|
|
3035
3058
|
});
|
|
3036
|
-
if (cli.flags['dryRun'])
|
|
3059
|
+
if (cli.flags['dryRun']) {
|
|
3060
|
+
return console.log('[DryRun] Bailing now');
|
|
3061
|
+
}
|
|
3037
3062
|
attemptLogout();
|
|
3038
3063
|
}
|
|
3039
3064
|
|
|
@@ -3262,7 +3287,9 @@ async function run$p(argv, importMeta, {
|
|
|
3262
3287
|
if (cli.flags['gradleOpts']) {
|
|
3263
3288
|
gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
|
|
3264
3289
|
}
|
|
3265
|
-
if (cli.flags['dryRun'])
|
|
3290
|
+
if (cli.flags['dryRun']) {
|
|
3291
|
+
return console.log('[DryRun] Bailing now');
|
|
3292
|
+
}
|
|
3266
3293
|
await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
|
|
3267
3294
|
}
|
|
3268
3295
|
|
|
@@ -3486,7 +3513,9 @@ async function run$o(argv, importMeta, {
|
|
|
3486
3513
|
if (cli.flags['sbtOpts']) {
|
|
3487
3514
|
sbtOpts = cli.flags['sbtOpts'].split(' ').map(s => s.trim()).filter(Boolean);
|
|
3488
3515
|
}
|
|
3489
|
-
if (cli.flags['dryRun'])
|
|
3516
|
+
if (cli.flags['dryRun']) {
|
|
3517
|
+
return console.log('[DryRun] Bailing now');
|
|
3518
|
+
}
|
|
3490
3519
|
await convertSbtToMaven(target, bin, out, verbose, sbtOpts);
|
|
3491
3520
|
}
|
|
3492
3521
|
|
|
@@ -3554,7 +3583,9 @@ async function run$n(argv, importMeta, {
|
|
|
3554
3583
|
subArgs.push('--cwd', cwd);
|
|
3555
3584
|
}
|
|
3556
3585
|
subArgs.push(dir);
|
|
3557
|
-
if (cli.flags['dryRun'])
|
|
3586
|
+
if (cli.flags['dryRun']) {
|
|
3587
|
+
return console.log('[DryRun] Bailing now');
|
|
3588
|
+
}
|
|
3558
3589
|
await cmdManifestScala.run(subArgs, importMeta, {
|
|
3559
3590
|
parentName
|
|
3560
3591
|
});
|
|
@@ -3566,7 +3597,9 @@ async function run$n(argv, importMeta, {
|
|
|
3566
3597
|
// This command takes the cwd as first arg.
|
|
3567
3598
|
subArgs.push(cwd);
|
|
3568
3599
|
}
|
|
3569
|
-
if (cli.flags['dryRun'])
|
|
3600
|
+
if (cli.flags['dryRun']) {
|
|
3601
|
+
return console.log('[DryRun] Bailing now');
|
|
3602
|
+
}
|
|
3570
3603
|
await cmdManifestGradle.run(subArgs, importMeta, {
|
|
3571
3604
|
parentName
|
|
3572
3605
|
});
|
|
@@ -3729,7 +3762,9 @@ async function run$m(argv, importMeta, {
|
|
|
3729
3762
|
if (cli.flags['gradleOpts']) {
|
|
3730
3763
|
gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
|
|
3731
3764
|
}
|
|
3732
|
-
if (cli.flags['dryRun'])
|
|
3765
|
+
if (cli.flags['dryRun']) {
|
|
3766
|
+
return console.log('[DryRun] Bailing now');
|
|
3767
|
+
}
|
|
3733
3768
|
await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
|
|
3734
3769
|
}
|
|
3735
3770
|
|
|
@@ -3807,7 +3842,9 @@ async function run$k(argv, importMeta, {
|
|
|
3807
3842
|
importMeta,
|
|
3808
3843
|
parentName
|
|
3809
3844
|
});
|
|
3810
|
-
if (cli.flags['dryRun'])
|
|
3845
|
+
if (cli.flags['dryRun']) {
|
|
3846
|
+
return console.log('[DryRun] Bailing now');
|
|
3847
|
+
}
|
|
3811
3848
|
await wrapNpm(argv);
|
|
3812
3849
|
}
|
|
3813
3850
|
|
|
@@ -3849,7 +3886,9 @@ async function run$j(argv, importMeta, {
|
|
|
3849
3886
|
importMeta,
|
|
3850
3887
|
parentName
|
|
3851
3888
|
});
|
|
3852
|
-
if (cli.flags['dryRun'])
|
|
3889
|
+
if (cli.flags['dryRun']) {
|
|
3890
|
+
return console.log('[DryRun] Bailing now');
|
|
3891
|
+
}
|
|
3853
3892
|
await wrapNpx(argv);
|
|
3854
3893
|
}
|
|
3855
3894
|
|
|
@@ -3881,7 +3920,9 @@ async function run$i(argv, importMeta, {
|
|
|
3881
3920
|
importMeta,
|
|
3882
3921
|
parentName
|
|
3883
3922
|
});
|
|
3884
|
-
if (cli.flags['dryRun'])
|
|
3923
|
+
if (cli.flags['dryRun']) {
|
|
3924
|
+
return console.log('[DryRun] Bailing now');
|
|
3925
|
+
}
|
|
3885
3926
|
throw new Error('This error was intentionally left blank');
|
|
3886
3927
|
}
|
|
3887
3928
|
|
|
@@ -3899,16 +3940,7 @@ function matchHumanStdout(stdout, name) {
|
|
|
3899
3940
|
function matchQueryStdout(stdout, name) {
|
|
3900
3941
|
return stdout.includes(`"${name}"`);
|
|
3901
3942
|
}
|
|
3902
|
-
const depsIncludesByAgent =
|
|
3903
|
-
// @ts-ignore
|
|
3904
|
-
__proto__: null,
|
|
3905
|
-
[BUN$6]: matchHumanStdout,
|
|
3906
|
-
[NPM$9]: matchQueryStdout,
|
|
3907
|
-
[PNPM$7]: matchQueryStdout,
|
|
3908
|
-
[VLT$6]: matchQueryStdout,
|
|
3909
|
-
[YARN_BERRY$6]: matchHumanStdout,
|
|
3910
|
-
[YARN_CLASSIC$6]: matchHumanStdout
|
|
3911
|
-
};
|
|
3943
|
+
const depsIncludesByAgent = new Map([[BUN$6, matchHumanStdout], [NPM$9, matchQueryStdout], [PNPM$7, matchQueryStdout], [VLT$6, matchQueryStdout], [YARN_BERRY$6, matchHumanStdout], [YARN_CLASSIC$6, matchHumanStdout]]);
|
|
3912
3944
|
|
|
3913
3945
|
const {
|
|
3914
3946
|
BINARY_LOCK_EXT,
|
|
@@ -4008,15 +4040,15 @@ const readLockFileByAgent = (() => {
|
|
|
4008
4040
|
[YARN_CLASSIC$5]: defaultReader
|
|
4009
4041
|
};
|
|
4010
4042
|
})();
|
|
4011
|
-
async function
|
|
4043
|
+
async function detectPackageEnvironment({
|
|
4012
4044
|
cwd = process$1.cwd(),
|
|
4013
4045
|
onUnknown
|
|
4014
4046
|
} = {}) {
|
|
4015
4047
|
let lockPath = await index.findUp(Object.keys(LOCKS), {
|
|
4016
4048
|
cwd
|
|
4017
4049
|
});
|
|
4018
|
-
let
|
|
4019
|
-
const isHiddenLockFile =
|
|
4050
|
+
let lockName = lockPath ? path.basename(lockPath) : undefined;
|
|
4051
|
+
const isHiddenLockFile = lockName === '.package-lock.json';
|
|
4020
4052
|
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await index.findUp('package.json', {
|
|
4021
4053
|
cwd
|
|
4022
4054
|
});
|
|
@@ -4041,8 +4073,8 @@ async function detect({
|
|
|
4041
4073
|
}
|
|
4042
4074
|
}
|
|
4043
4075
|
}
|
|
4044
|
-
if (agent === undefined && !isHiddenLockFile && typeof pkgJsonPath === 'string' && typeof
|
|
4045
|
-
agent = LOCKS[
|
|
4076
|
+
if (agent === undefined && !isHiddenLockFile && typeof pkgJsonPath === 'string' && typeof lockName === 'string') {
|
|
4077
|
+
agent = LOCKS[lockName];
|
|
4046
4078
|
}
|
|
4047
4079
|
if (agent === undefined) {
|
|
4048
4080
|
agent = NPM$8;
|
|
@@ -4093,14 +4125,14 @@ async function detect({
|
|
|
4093
4125
|
targets.node = constants.maintainedNodeVersions.some(v => semver.satisfies(v, `>=${minimumNodeVersion}`));
|
|
4094
4126
|
lockSrc = typeof lockPath === 'string' ? await readLockFileByAgent[agent](lockPath, agentExecPath) : undefined;
|
|
4095
4127
|
} else {
|
|
4096
|
-
|
|
4128
|
+
lockName = undefined;
|
|
4097
4129
|
lockPath = undefined;
|
|
4098
4130
|
}
|
|
4099
4131
|
return {
|
|
4100
4132
|
agent,
|
|
4101
4133
|
agentExecPath,
|
|
4102
4134
|
agentVersion,
|
|
4103
|
-
|
|
4135
|
+
lockName,
|
|
4104
4136
|
lockPath,
|
|
4105
4137
|
lockSrc,
|
|
4106
4138
|
minimumNodeVersion,
|
|
@@ -4114,74 +4146,53 @@ async function detect({
|
|
|
4114
4146
|
|
|
4115
4147
|
const {
|
|
4116
4148
|
BUN: BUN$4,
|
|
4117
|
-
NPM: NPM$7,
|
|
4118
4149
|
VLT: VLT$4,
|
|
4119
4150
|
YARN_BERRY: YARN_BERRY$4
|
|
4120
4151
|
} = constants;
|
|
4121
4152
|
const COMMAND_TITLE$2 = 'Socket Optimize';
|
|
4122
|
-
|
|
4123
|
-
async function detectAndValidatePackageManager(cwd, prod) {
|
|
4153
|
+
async function detectAndValidatePackageEnvironment(cwd, options) {
|
|
4124
4154
|
const {
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
npmExecPath,
|
|
4133
|
-
pkgJson,
|
|
4134
|
-
pkgPath,
|
|
4135
|
-
supported
|
|
4136
|
-
} = await detect({
|
|
4155
|
+
logger,
|
|
4156
|
+
prod
|
|
4157
|
+
} = {
|
|
4158
|
+
__proto__: null,
|
|
4159
|
+
...options
|
|
4160
|
+
};
|
|
4161
|
+
const details = await detectPackageEnvironment({
|
|
4137
4162
|
cwd,
|
|
4138
4163
|
onUnknown(pkgManager) {
|
|
4139
|
-
|
|
4164
|
+
logger?.warn(`⚠️ ${COMMAND_TITLE$2}: Unknown package manager${pkgManager ? ` ${pkgManager}` : ''}, defaulting to npm`);
|
|
4140
4165
|
}
|
|
4141
4166
|
});
|
|
4142
|
-
if (!supported) {
|
|
4143
|
-
|
|
4167
|
+
if (!details.supported) {
|
|
4168
|
+
logger?.error(`✖️ ${COMMAND_TITLE$2}: No supported Node or browser range detected`);
|
|
4144
4169
|
return;
|
|
4145
4170
|
}
|
|
4146
|
-
if (agent === VLT$4) {
|
|
4147
|
-
|
|
4171
|
+
if (details.agent === VLT$4) {
|
|
4172
|
+
logger?.error(`✖️ ${COMMAND_TITLE$2}: ${details.agent} does not support overrides. Soon, though ⚡`);
|
|
4148
4173
|
return;
|
|
4149
4174
|
}
|
|
4150
|
-
const lockName =
|
|
4151
|
-
if (
|
|
4152
|
-
|
|
4175
|
+
const lockName = details.lockName ?? 'lock file';
|
|
4176
|
+
if (details.lockName === undefined || details.lockSrc === undefined) {
|
|
4177
|
+
logger?.error(`✖️ ${COMMAND_TITLE$2}: No ${lockName} found`);
|
|
4153
4178
|
return;
|
|
4154
4179
|
}
|
|
4155
|
-
if (lockSrc.trim() === '') {
|
|
4156
|
-
|
|
4180
|
+
if (details.lockSrc.trim() === '') {
|
|
4181
|
+
logger?.error(`✖️ ${COMMAND_TITLE$2}: ${lockName} is empty`);
|
|
4157
4182
|
return;
|
|
4158
4183
|
}
|
|
4159
|
-
if (pkgPath === undefined) {
|
|
4160
|
-
|
|
4184
|
+
if (details.pkgPath === undefined) {
|
|
4185
|
+
logger?.error(`✖️ ${COMMAND_TITLE$2}: No package.json found`);
|
|
4161
4186
|
return;
|
|
4162
4187
|
}
|
|
4163
|
-
if (prod && (agent === BUN$4 || agent === YARN_BERRY$4)) {
|
|
4164
|
-
|
|
4188
|
+
if (prod && (details.agent === BUN$4 || details.agent === YARN_BERRY$4)) {
|
|
4189
|
+
logger?.error(`✖️ ${COMMAND_TITLE$2}: --prod not supported for ${details.agent}${details.agentVersion ? `@${details.agentVersion.toString()}` : ''}`);
|
|
4165
4190
|
return;
|
|
4166
4191
|
}
|
|
4167
|
-
if (lockPath && path.relative(cwd, lockPath).startsWith('.')) {
|
|
4168
|
-
|
|
4192
|
+
if (details.lockPath && path.relative(cwd, details.lockPath).startsWith('.')) {
|
|
4193
|
+
logger?.warn(`⚠️ ${COMMAND_TITLE$2}: Package ${lockName} found at ${details.lockPath}`);
|
|
4169
4194
|
}
|
|
4170
|
-
|
|
4171
|
-
const manifestEntries = manifestNpmOverrides.filter(({
|
|
4172
|
-
1: data
|
|
4173
|
-
}) => semver.satisfies(semver.coerce(data.engines.node), nodeRange));
|
|
4174
|
-
return {
|
|
4175
|
-
agent,
|
|
4176
|
-
agentExecPath,
|
|
4177
|
-
lockBasename,
|
|
4178
|
-
lockName,
|
|
4179
|
-
lockSrc,
|
|
4180
|
-
manifestEntries,
|
|
4181
|
-
npmExecPath,
|
|
4182
|
-
pkgJson,
|
|
4183
|
-
pkgPath
|
|
4184
|
-
};
|
|
4195
|
+
return details;
|
|
4185
4196
|
}
|
|
4186
4197
|
|
|
4187
4198
|
function getDependencyEntries(pkgJson) {
|
|
@@ -4210,7 +4221,7 @@ function getDependencyEntries(pkgJson) {
|
|
|
4210
4221
|
|
|
4211
4222
|
const {
|
|
4212
4223
|
BUN: BUN$3,
|
|
4213
|
-
NPM: NPM$
|
|
4224
|
+
NPM: NPM$7,
|
|
4214
4225
|
OVERRIDES: OVERRIDES$1,
|
|
4215
4226
|
PNPM: PNPM$5,
|
|
4216
4227
|
RESOLUTIONS: RESOLUTIONS$1,
|
|
@@ -4231,7 +4242,7 @@ function getOverridesDataBun(pkgJson) {
|
|
|
4231
4242
|
function getOverridesDataNpm(pkgJson) {
|
|
4232
4243
|
const overrides = pkgJson?.[OVERRIDES$1] ?? {};
|
|
4233
4244
|
return {
|
|
4234
|
-
type: NPM$
|
|
4245
|
+
type: NPM$7,
|
|
4235
4246
|
overrides
|
|
4236
4247
|
};
|
|
4237
4248
|
}
|
|
@@ -4272,16 +4283,7 @@ function getOverridesDataClassic(pkgJson) {
|
|
|
4272
4283
|
overrides
|
|
4273
4284
|
};
|
|
4274
4285
|
}
|
|
4275
|
-
const
|
|
4276
|
-
// @ts-ignore
|
|
4277
|
-
__proto__: null,
|
|
4278
|
-
[BUN$3]: getOverridesDataBun,
|
|
4279
|
-
[NPM$6]: getOverridesDataNpm,
|
|
4280
|
-
[PNPM$5]: getOverridesDataPnpm,
|
|
4281
|
-
[VLT$3]: getOverridesDataVlt,
|
|
4282
|
-
[YARN_BERRY$3]: getOverridesDataYarn,
|
|
4283
|
-
[YARN_CLASSIC$4]: getOverridesDataClassic
|
|
4284
|
-
};
|
|
4286
|
+
const overridesDataByAgent = new Map([[BUN$3, getOverridesDataBun], [NPM$7, getOverridesDataNpm], [PNPM$5, getOverridesDataPnpm], [VLT$3, getOverridesDataVlt], [YARN_BERRY$3, getOverridesDataYarn], [YARN_CLASSIC$4, getOverridesDataClassic]]);
|
|
4285
4287
|
|
|
4286
4288
|
const {
|
|
4287
4289
|
PNPM: PNPM$4
|
|
@@ -4329,7 +4331,7 @@ function workspacePatternToGlobPattern(workspace) {
|
|
|
4329
4331
|
const {
|
|
4330
4332
|
BUN: BUN$2,
|
|
4331
4333
|
LOCK_EXT,
|
|
4332
|
-
NPM: NPM$
|
|
4334
|
+
NPM: NPM$6,
|
|
4333
4335
|
PNPM: PNPM$3,
|
|
4334
4336
|
VLT: VLT$2,
|
|
4335
4337
|
YARN_BERRY: YARN_BERRY$2,
|
|
@@ -4340,12 +4342,12 @@ function lockIncludesNpm(lockSrc, name) {
|
|
|
4340
4342
|
// "name":
|
|
4341
4343
|
return lockSrc.includes(`"${name}":`);
|
|
4342
4344
|
}
|
|
4343
|
-
function lockIncludesBun(lockSrc, name,
|
|
4344
|
-
// This is a bit counterintuitive. When
|
|
4345
|
-
// we treat it as a yarn.lock. When
|
|
4345
|
+
function lockIncludesBun(lockSrc, name, lockName) {
|
|
4346
|
+
// This is a bit counterintuitive. When lockName ends with a .lockb
|
|
4347
|
+
// we treat it as a yarn.lock. When lockName ends with a .lock we
|
|
4346
4348
|
// treat it as a package-lock.json. The bun.lock format is not identical
|
|
4347
4349
|
// package-lock.json, however it close enough for npmLockIncludes to work.
|
|
4348
|
-
const lockScanner =
|
|
4350
|
+
const lockScanner = lockName?.endsWith(LOCK_EXT) ? lockIncludesNpm : lockIncludesYarn;
|
|
4349
4351
|
return lockScanner(lockSrc, name);
|
|
4350
4352
|
}
|
|
4351
4353
|
function lockIncludesPnpm(lockSrc, name) {
|
|
@@ -4373,20 +4375,11 @@ function lockIncludesYarn(lockSrc, name) {
|
|
|
4373
4375
|
// , name@
|
|
4374
4376
|
`(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
|
|
4375
4377
|
}
|
|
4376
|
-
const lockIncludesByAgent =
|
|
4377
|
-
// @ts-ignore
|
|
4378
|
-
__proto__: null,
|
|
4379
|
-
[BUN$2]: lockIncludesBun,
|
|
4380
|
-
[NPM$5]: lockIncludesNpm,
|
|
4381
|
-
[PNPM$3]: lockIncludesPnpm,
|
|
4382
|
-
[VLT$2]: lockIncludesVlt,
|
|
4383
|
-
[YARN_BERRY$2]: lockIncludesYarn,
|
|
4384
|
-
[YARN_CLASSIC$3]: lockIncludesYarn
|
|
4385
|
-
};
|
|
4378
|
+
const lockIncludesByAgent = new Map([[BUN$2, lockIncludesBun], [NPM$6, lockIncludesNpm], [PNPM$3, lockIncludesPnpm], [VLT$2, lockIncludesVlt], [YARN_BERRY$2, lockIncludesYarn], [YARN_CLASSIC$3, lockIncludesYarn]]);
|
|
4386
4379
|
|
|
4387
4380
|
const {
|
|
4388
4381
|
BUN: BUN$1,
|
|
4389
|
-
NPM: NPM$
|
|
4382
|
+
NPM: NPM$5,
|
|
4390
4383
|
PNPM: PNPM$2,
|
|
4391
4384
|
VLT: VLT$1,
|
|
4392
4385
|
YARN_BERRY: YARN_BERRY$1,
|
|
@@ -4456,7 +4449,7 @@ async function lsNpm(agentExecPath, cwd) {
|
|
|
4456
4449
|
}
|
|
4457
4450
|
async function lsPnpm(agentExecPath, cwd, options) {
|
|
4458
4451
|
const npmExecPath = options?.npmExecPath;
|
|
4459
|
-
if (npmExecPath && npmExecPath !== NPM$
|
|
4452
|
+
if (npmExecPath && npmExecPath !== NPM$5) {
|
|
4460
4453
|
const result = await npmQuery(npmExecPath, cwd);
|
|
4461
4454
|
if (result) {
|
|
4462
4455
|
return result;
|
|
@@ -4507,7 +4500,7 @@ const lsByAgent = {
|
|
|
4507
4500
|
// @ts-ignore
|
|
4508
4501
|
__proto__: null,
|
|
4509
4502
|
[BUN$1]: lsBun,
|
|
4510
|
-
[NPM$
|
|
4503
|
+
[NPM$5]: lsNpm,
|
|
4511
4504
|
[PNPM$2]: lsPnpm,
|
|
4512
4505
|
[VLT$1]: lsVlt,
|
|
4513
4506
|
[YARN_BERRY$1]: lsYarnBerry,
|
|
@@ -4516,7 +4509,7 @@ const lsByAgent = {
|
|
|
4516
4509
|
|
|
4517
4510
|
const {
|
|
4518
4511
|
BUN,
|
|
4519
|
-
NPM: NPM$
|
|
4512
|
+
NPM: NPM$4,
|
|
4520
4513
|
OVERRIDES,
|
|
4521
4514
|
PNPM: PNPM$1,
|
|
4522
4515
|
RESOLUTIONS,
|
|
@@ -4620,55 +4613,75 @@ function updateResolutions(editablePkgJson, overrides) {
|
|
|
4620
4613
|
function pnpmUpdatePkgJson(editablePkgJson, overrides) {
|
|
4621
4614
|
updatePkgJson(editablePkgJson, PNPM_FIELD_NAME, overrides);
|
|
4622
4615
|
}
|
|
4623
|
-
const updateManifestByAgent =
|
|
4624
|
-
// @ts-ignore
|
|
4625
|
-
__proto__: null,
|
|
4626
|
-
[BUN]: updateResolutions,
|
|
4627
|
-
[NPM$3]: updateOverrides,
|
|
4628
|
-
[PNPM$1]: pnpmUpdatePkgJson,
|
|
4629
|
-
[VLT]: updateOverrides,
|
|
4630
|
-
[YARN_BERRY]: updateResolutions,
|
|
4631
|
-
[YARN_CLASSIC$1]: updateResolutions
|
|
4632
|
-
};
|
|
4616
|
+
const updateManifestByAgent = new Map([[BUN, updateResolutions], [NPM$4, updateOverrides], [PNPM$1, pnpmUpdatePkgJson], [VLT, updateOverrides], [YARN_BERRY, updateResolutions], [YARN_CLASSIC$1, updateResolutions]]);
|
|
4633
4617
|
|
|
4634
4618
|
const {
|
|
4635
|
-
NPM: NPM$
|
|
4636
|
-
SOCKET_CLI_SAFE_WRAPPER,
|
|
4619
|
+
NPM: NPM$3,
|
|
4637
4620
|
abortSignal: abortSignal$2
|
|
4638
4621
|
} = constants;
|
|
4622
|
+
function runAgentInstall(agent, agentExecPath, options) {
|
|
4623
|
+
// All package managers support the "install" command.
|
|
4624
|
+
if (agent === NPM$3) {
|
|
4625
|
+
return npm$1.safeNpmInstall(options);
|
|
4626
|
+
}
|
|
4627
|
+
const {
|
|
4628
|
+
args = [],
|
|
4629
|
+
spinner,
|
|
4630
|
+
...spawnOptions
|
|
4631
|
+
} = {
|
|
4632
|
+
__proto__: null,
|
|
4633
|
+
...options
|
|
4634
|
+
};
|
|
4635
|
+
const isSilent = !npmPaths.isDebug();
|
|
4636
|
+
const isSpinning = spinner?.isSpinning ?? false;
|
|
4637
|
+
if (!isSilent) {
|
|
4638
|
+
spinner?.stop();
|
|
4639
|
+
}
|
|
4640
|
+
let spawnPromise = spawn(agentExecPath, ['install', ...args], {
|
|
4641
|
+
signal: abortSignal$2,
|
|
4642
|
+
stdio: isSilent ? 'ignore' : 'inherit',
|
|
4643
|
+
...spawnOptions,
|
|
4644
|
+
env: {
|
|
4645
|
+
...process.env,
|
|
4646
|
+
...spawnOptions.env
|
|
4647
|
+
}
|
|
4648
|
+
});
|
|
4649
|
+
if (!isSilent && isSpinning) {
|
|
4650
|
+
const oldSpawnPromise = spawnPromise;
|
|
4651
|
+
spawnPromise = spawnPromise.finally(() => {
|
|
4652
|
+
spinner?.start();
|
|
4653
|
+
});
|
|
4654
|
+
spawnPromise.process = oldSpawnPromise.process;
|
|
4655
|
+
spawnPromise.stdin = spawnPromise.stdin;
|
|
4656
|
+
}
|
|
4657
|
+
return spawnPromise;
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
const {
|
|
4661
|
+
NPM: NPM$2
|
|
4662
|
+
} = constants;
|
|
4639
4663
|
const COMMAND_TITLE$1 = 'Socket Optimize';
|
|
4640
4664
|
const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/8089';
|
|
4641
|
-
async function updatePackageLockJson(
|
|
4642
|
-
|
|
4665
|
+
async function updatePackageLockJson(pkgEnvDetails, options) {
|
|
4666
|
+
const {
|
|
4667
|
+
logger,
|
|
4668
|
+
spinner
|
|
4669
|
+
} = {
|
|
4670
|
+
__proto__: null,
|
|
4671
|
+
...options
|
|
4672
|
+
};
|
|
4673
|
+
spinner?.start(`Updating ${pkgEnvDetails.lockName}...`);
|
|
4643
4674
|
try {
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
});
|
|
4651
|
-
// TODO: This is a temporary workaround for a `npm ci` bug where it
|
|
4652
|
-
// will error out after Socket Optimize generates a lock file.
|
|
4653
|
-
// More investigation is needed.
|
|
4654
|
-
await npm$1.safeNpmInstall({
|
|
4655
|
-
args: ['--ignore-scripts', '--package-lock-only'],
|
|
4656
|
-
ipc
|
|
4657
|
-
});
|
|
4658
|
-
} else {
|
|
4659
|
-
// All package managers support the "install" command.
|
|
4660
|
-
await spawn(agentExecPath, ['install'], {
|
|
4661
|
-
signal: abortSignal$2,
|
|
4662
|
-
stdio: 'ignore'
|
|
4663
|
-
});
|
|
4664
|
-
}
|
|
4665
|
-
spinner.stop();
|
|
4666
|
-
if (agent === NPM$2) {
|
|
4667
|
-
console.log(`💡 Re-run ${COMMAND_TITLE$1} whenever ${lockName} changes.\n This can be skipped once npm ships ${NPM_OVERRIDE_PR_URL}.`);
|
|
4675
|
+
await runAgentInstall(pkgEnvDetails.agent, pkgEnvDetails.agentExecPath, {
|
|
4676
|
+
spinner
|
|
4677
|
+
});
|
|
4678
|
+
spinner?.stop();
|
|
4679
|
+
if (pkgEnvDetails.agent === NPM$2) {
|
|
4680
|
+
logger?.log(`💡 Re-run ${COMMAND_TITLE$1} whenever ${pkgEnvDetails.lockName} changes.\n This can be skipped once npm ships ${NPM_OVERRIDE_PR_URL}.`);
|
|
4668
4681
|
}
|
|
4669
4682
|
} catch (e) {
|
|
4670
|
-
spinner
|
|
4671
|
-
|
|
4683
|
+
spinner?.error(`${COMMAND_TITLE$1}: ${pkgEnvDetails.agent} install failed to update ${pkgEnvDetails.lockName}`);
|
|
4684
|
+
logger?.error(e);
|
|
4672
4685
|
}
|
|
4673
4686
|
}
|
|
4674
4687
|
|
|
@@ -4678,91 +4691,85 @@ const {
|
|
|
4678
4691
|
YARN_CLASSIC
|
|
4679
4692
|
} = constants;
|
|
4680
4693
|
const COMMAND_TITLE = 'Socket Optimize';
|
|
4694
|
+
const manifestNpmOverrides = registry.getManifestData(NPM$1);
|
|
4681
4695
|
async function applyOptimization(cwd, pin, prod) {
|
|
4682
|
-
const
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
manifestEntries,
|
|
4691
|
-
npmExecPath,
|
|
4692
|
-
pkgJson,
|
|
4693
|
-
pkgPath
|
|
4694
|
-
} = pkgMgrData;
|
|
4696
|
+
const logger = console;
|
|
4697
|
+
const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
|
|
4698
|
+
logger,
|
|
4699
|
+
prod
|
|
4700
|
+
});
|
|
4701
|
+
if (!pkgEnvDetails) {
|
|
4702
|
+
return;
|
|
4703
|
+
}
|
|
4695
4704
|
const spinner$1 = new spinner.Spinner({
|
|
4696
4705
|
text: 'Socket optimizing...'
|
|
4697
4706
|
});
|
|
4698
4707
|
spinner$1.start();
|
|
4699
|
-
const state = await addOverrides({
|
|
4700
|
-
|
|
4701
|
-
agentExecPath,
|
|
4702
|
-
lockBasename,
|
|
4703
|
-
lockSrc,
|
|
4704
|
-
manifestEntries,
|
|
4705
|
-
npmExecPath,
|
|
4708
|
+
const state = await addOverrides(pkgEnvDetails.pkgPath, pkgEnvDetails, {
|
|
4709
|
+
logger,
|
|
4706
4710
|
pin,
|
|
4707
|
-
pkgJson,
|
|
4708
|
-
pkgPath,
|
|
4709
4711
|
prod,
|
|
4710
|
-
|
|
4711
|
-
}
|
|
4712
|
+
spinner: spinner$1
|
|
4713
|
+
});
|
|
4712
4714
|
spinner$1.stop();
|
|
4713
4715
|
const addedCount = state.added.size;
|
|
4714
4716
|
const updatedCount = state.updated.size;
|
|
4715
4717
|
const pkgJsonChanged = addedCount > 0 || updatedCount > 0;
|
|
4716
4718
|
if (pkgJsonChanged) {
|
|
4717
4719
|
if (updatedCount > 0) {
|
|
4718
|
-
|
|
4720
|
+
logger?.log(`${createActionMessage('Updated', updatedCount, state.updatedInWorkspaces.size)}${addedCount ? '.' : '🚀'}`);
|
|
4719
4721
|
}
|
|
4720
4722
|
if (addedCount > 0) {
|
|
4721
|
-
|
|
4723
|
+
logger?.log(`${createActionMessage('Added', addedCount, state.addedInWorkspaces.size)} 🚀`);
|
|
4722
4724
|
}
|
|
4723
4725
|
} else {
|
|
4724
|
-
|
|
4726
|
+
logger?.log('Congratulations! Already Socket.dev optimized 🎉');
|
|
4725
4727
|
}
|
|
4726
|
-
if (agent === NPM$1 || pkgJsonChanged) {
|
|
4728
|
+
if (pkgEnvDetails.agent === NPM$1 || pkgJsonChanged) {
|
|
4727
4729
|
// Always update package-lock.json until the npm overrides PR lands:
|
|
4728
4730
|
// https://github.com/npm/cli/pull/8089
|
|
4729
|
-
await updatePackageLockJson(
|
|
4731
|
+
await updatePackageLockJson(pkgEnvDetails, {
|
|
4732
|
+
logger,
|
|
4733
|
+
spinner: spinner$1
|
|
4734
|
+
});
|
|
4730
4735
|
}
|
|
4731
4736
|
}
|
|
4732
4737
|
function createActionMessage(verb, overrideCount, workspaceCount) {
|
|
4733
4738
|
return `${verb} ${overrideCount} Socket.dev optimized ${words.pluralize('override', overrideCount)}${workspaceCount ? ` in ${workspaceCount} ${words.pluralize('workspace', workspaceCount)}` : ''}`;
|
|
4734
4739
|
}
|
|
4735
|
-
function
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4740
|
+
async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
4741
|
+
const {
|
|
4742
|
+
agent,
|
|
4743
|
+
agentExecPath,
|
|
4744
|
+
lockName,
|
|
4745
|
+
lockSrc,
|
|
4746
|
+
npmExecPath,
|
|
4747
|
+
pkgPath: rootPath
|
|
4748
|
+
} = pkgEnvDetails;
|
|
4749
|
+
const {
|
|
4750
|
+
logger,
|
|
4751
|
+
pin,
|
|
4752
|
+
prod,
|
|
4739
4753
|
spinner,
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4754
|
+
state = {
|
|
4755
|
+
added: new Set(),
|
|
4756
|
+
addedInWorkspaces: new Set(),
|
|
4757
|
+
updated: new Set(),
|
|
4758
|
+
updatedInWorkspaces: new Set(),
|
|
4759
|
+
warnedPnpmWorkspaceRequiresNpm: false
|
|
4760
|
+
}
|
|
4761
|
+
} = {
|
|
4762
|
+
__proto__: null,
|
|
4763
|
+
...options
|
|
4743
4764
|
};
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
agentExecPath,
|
|
4748
|
-
lockBasename,
|
|
4749
|
-
lockSrc,
|
|
4750
|
-
manifestEntries,
|
|
4751
|
-
npmExecPath,
|
|
4752
|
-
pin,
|
|
4753
|
-
pkgJson: editablePkgJson,
|
|
4754
|
-
pkgPath,
|
|
4755
|
-
prod,
|
|
4756
|
-
rootPath
|
|
4757
|
-
}, state) {
|
|
4765
|
+
let {
|
|
4766
|
+
pkgJson: editablePkgJson
|
|
4767
|
+
} = pkgEnvDetails;
|
|
4758
4768
|
if (editablePkgJson === undefined) {
|
|
4759
4769
|
editablePkgJson = await packages.readPackageJson(pkgPath, {
|
|
4760
4770
|
editable: true
|
|
4761
4771
|
});
|
|
4762
4772
|
}
|
|
4763
|
-
const {
|
|
4764
|
-
spinner
|
|
4765
|
-
} = state;
|
|
4766
4773
|
const {
|
|
4767
4774
|
content: pkgJson
|
|
4768
4775
|
} = editablePkgJson;
|
|
@@ -4773,7 +4780,7 @@ async function addOverrides({
|
|
|
4773
4780
|
const isWorkspace = !!workspaceGlobs;
|
|
4774
4781
|
if (isWorkspace && agent === PNPM && npmExecPath === NPM$1 && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
4775
4782
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
4776
|
-
|
|
4783
|
+
logger?.warn(`⚠️ ${COMMAND_TITLE}: pnpm workspace support requires \`npm ls\`, falling back to \`pnpm list\``);
|
|
4777
4784
|
}
|
|
4778
4785
|
const thingToScan = isLockScanned ? lockSrc : await lsByAgent[agent](agentExecPath, pkgPath, {
|
|
4779
4786
|
npmExecPath
|
|
@@ -4782,18 +4789,22 @@ async function addOverrides({
|
|
|
4782
4789
|
// first two parameters. AgentLockIncludesFn accepts an optional third
|
|
4783
4790
|
// parameter which AgentDepsIncludesFn will ignore so we cast thingScanner
|
|
4784
4791
|
// as an AgentLockIncludesFn type.
|
|
4785
|
-
const thingScanner = isLockScanned ? lockIncludesByAgent
|
|
4792
|
+
const thingScanner = isLockScanned ? lockIncludesByAgent.get(agent) : depsIncludesByAgent.get(agent);
|
|
4786
4793
|
const depEntries = getDependencyEntries(pkgJson);
|
|
4787
4794
|
const overridesDataObjects = [];
|
|
4788
4795
|
if (pkgJson['private'] || isWorkspace) {
|
|
4789
|
-
overridesDataObjects.push(
|
|
4796
|
+
overridesDataObjects.push(overridesDataByAgent.get(agent)(pkgJson));
|
|
4790
4797
|
} else {
|
|
4791
|
-
overridesDataObjects.push(
|
|
4798
|
+
overridesDataObjects.push(overridesDataByAgent.get(NPM$1)(pkgJson), overridesDataByAgent.get(YARN_CLASSIC)(pkgJson));
|
|
4792
4799
|
}
|
|
4793
4800
|
if (spinner) {
|
|
4794
4801
|
spinner.text = `Adding overrides${workspaceName ? ` to ${workspaceName}` : ''}...`;
|
|
4795
4802
|
}
|
|
4796
4803
|
const depAliasMap = new Map();
|
|
4804
|
+
const nodeRange = `>=${pkgEnvDetails.minimumNodeVersion}`;
|
|
4805
|
+
const manifestEntries = manifestNpmOverrides.filter(({
|
|
4806
|
+
1: data
|
|
4807
|
+
}) => semver.satisfies(semver.coerce(data.engines.node), nodeRange));
|
|
4797
4808
|
// Chunk package names to process them in parallel 3 at a time.
|
|
4798
4809
|
await promises.pEach(manifestEntries, 3, async ({
|
|
4799
4810
|
1: data
|
|
@@ -4836,7 +4847,7 @@ async function addOverrides({
|
|
|
4836
4847
|
type
|
|
4837
4848
|
}) => {
|
|
4838
4849
|
const overrideExists = objects.hasOwn(overrides, origPkgName);
|
|
4839
|
-
if (overrideExists || thingScanner(thingToScan, origPkgName,
|
|
4850
|
+
if (overrideExists || thingScanner(thingToScan, origPkgName, lockName)) {
|
|
4840
4851
|
const oldSpec = overrideExists ? overrides[origPkgName] : undefined;
|
|
4841
4852
|
const origDepAlias = depAliasMap.get(origPkgName);
|
|
4842
4853
|
const sockRegDepAlias = depAliasMap.get(sockRegPkgName);
|
|
@@ -4881,18 +4892,12 @@ async function addOverrides({
|
|
|
4881
4892
|
});
|
|
4882
4893
|
// Chunk package names to process them in parallel 3 at a time.
|
|
4883
4894
|
await promises.pEach(workspacePkgJsonPaths, 3, async workspacePkgJsonPath => {
|
|
4884
|
-
const otherState = await addOverrides({
|
|
4885
|
-
|
|
4886
|
-
agentExecPath,
|
|
4887
|
-
lockBasename,
|
|
4888
|
-
lockSrc,
|
|
4889
|
-
manifestEntries,
|
|
4890
|
-
npmExecPath,
|
|
4895
|
+
const otherState = await addOverrides(path.dirname(workspacePkgJsonPath), pkgEnvDetails, {
|
|
4896
|
+
logger,
|
|
4891
4897
|
pin,
|
|
4892
|
-
pkgPath: path.dirname(workspacePkgJsonPath),
|
|
4893
4898
|
prod,
|
|
4894
|
-
|
|
4895
|
-
}
|
|
4899
|
+
spinner
|
|
4900
|
+
});
|
|
4896
4901
|
for (const key of ['added', 'addedInWorkspaces', 'updated', 'updatedInWorkspaces']) {
|
|
4897
4902
|
for (const value of otherState[key]) {
|
|
4898
4903
|
state[key].add(value);
|
|
@@ -4906,7 +4911,7 @@ async function addOverrides({
|
|
|
4906
4911
|
overrides,
|
|
4907
4912
|
type
|
|
4908
4913
|
} of overridesDataObjects) {
|
|
4909
|
-
updateManifestByAgent
|
|
4914
|
+
updateManifestByAgent.get(type)(editablePkgJson, objects.toSortedObject(overrides));
|
|
4910
4915
|
}
|
|
4911
4916
|
await editablePkgJson.save();
|
|
4912
4917
|
}
|
|
@@ -4957,32 +4962,74 @@ async function run$h(argv, importMeta, {
|
|
|
4957
4962
|
parentName
|
|
4958
4963
|
});
|
|
4959
4964
|
const cwd = process$1.cwd();
|
|
4960
|
-
if (cli.flags['dryRun'])
|
|
4965
|
+
if (cli.flags['dryRun']) {
|
|
4966
|
+
return console.log('[DryRun] Bailing now');
|
|
4967
|
+
}
|
|
4961
4968
|
await applyOptimization(cwd, Boolean(cli.flags['pin']), Boolean(cli.flags['prod']));
|
|
4962
4969
|
}
|
|
4963
4970
|
|
|
4964
|
-
async function
|
|
4971
|
+
async function getOrganization(format = 'text') {
|
|
4965
4972
|
const apiToken = index.getDefaultToken();
|
|
4966
4973
|
if (!apiToken) {
|
|
4967
4974
|
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.');
|
|
4968
4975
|
}
|
|
4976
|
+
await printOrganizationsFromToken(apiToken, format);
|
|
4977
|
+
}
|
|
4978
|
+
async function printOrganizationsFromToken(apiToken, format = 'text') {
|
|
4969
4979
|
const spinner$1 = new spinner.Spinner({
|
|
4970
4980
|
text: 'Fetching organizations...'
|
|
4971
4981
|
}).start();
|
|
4972
4982
|
const socketSdk = await index.setupSdk(apiToken);
|
|
4973
4983
|
const result = await handleApiCall(socketSdk.getOrganizations(), 'looking up organizations');
|
|
4974
|
-
if (result.success
|
|
4984
|
+
if (!result.success) {
|
|
4975
4985
|
handleUnsuccessfulApiResponse('getOrganizations', result, spinner$1);
|
|
4976
4986
|
return;
|
|
4977
4987
|
}
|
|
4978
|
-
spinner$1.stop(
|
|
4988
|
+
spinner$1.stop();
|
|
4979
4989
|
const organizations = Object.values(result.data.organizations);
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4990
|
+
const lastFiveOfApiToken = getLastFiveOfApiToken(apiToken);
|
|
4991
|
+
switch (format) {
|
|
4992
|
+
case 'json':
|
|
4993
|
+
{
|
|
4994
|
+
console.log(JSON.stringify(organizations.map(o => ({
|
|
4995
|
+
name: o.name,
|
|
4996
|
+
id: o.id,
|
|
4997
|
+
plan: o.plan
|
|
4998
|
+
})), null, 2));
|
|
4999
|
+
return;
|
|
5000
|
+
}
|
|
5001
|
+
case 'markdown':
|
|
5002
|
+
{
|
|
5003
|
+
// | Syntax | Description |
|
|
5004
|
+
// | ----------- | ----------- |
|
|
5005
|
+
// | Header | Title |
|
|
5006
|
+
// | Paragraph | Text |
|
|
5007
|
+
let mw1 = 4;
|
|
5008
|
+
let mw2 = 2;
|
|
5009
|
+
let mw3 = 4;
|
|
5010
|
+
for (const o of organizations) {
|
|
5011
|
+
mw1 = Math.max(mw1, o.name.length);
|
|
5012
|
+
mw2 = Math.max(mw2, o.id.length);
|
|
5013
|
+
mw3 = Math.max(mw3, o.plan.length);
|
|
5014
|
+
}
|
|
5015
|
+
console.log('# Organizations\n');
|
|
5016
|
+
console.log(`List of organizations associated with your API key, ending with: ${colors.italic(lastFiveOfApiToken)}\n`);
|
|
5017
|
+
console.log(`| Name${' '.repeat(mw1 - 4)} | ID${' '.repeat(mw2 - 2)} | Plan${' '.repeat(mw3 - 4)} |`);
|
|
5018
|
+
console.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
5019
|
+
for (const o of organizations) {
|
|
5020
|
+
console.log(`| ${(o.name || '').padEnd(mw1, ' ')} | ${(o.id || '').padEnd(mw2, ' ')} | ${(o.plan || '').padEnd(mw3, ' ')} |`);
|
|
5021
|
+
}
|
|
5022
|
+
console.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
5023
|
+
return;
|
|
5024
|
+
}
|
|
5025
|
+
default:
|
|
5026
|
+
{
|
|
5027
|
+
console.log(`List of organizations associated with your API key, ending with: ${colors.italic(lastFiveOfApiToken)}\n`);
|
|
5028
|
+
// Just dump
|
|
5029
|
+
for (const o of organizations) {
|
|
5030
|
+
console.log(`- Name: ${colors.bold(o.name)}, ID: ${colors.bold(o.id)}, Plan: ${colors.bold(o.plan)}`);
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
4986
5033
|
}
|
|
4987
5034
|
}
|
|
4988
5035
|
|
|
@@ -4990,13 +5037,19 @@ const config$g = {
|
|
|
4990
5037
|
commandName: 'organizations',
|
|
4991
5038
|
description: 'List organizations associated with the API key used',
|
|
4992
5039
|
hidden: false,
|
|
4993
|
-
flags: {
|
|
5040
|
+
flags: {
|
|
5041
|
+
...commonFlags,
|
|
5042
|
+
...outputFlags
|
|
5043
|
+
},
|
|
4994
5044
|
help: (command, _config) => `
|
|
4995
5045
|
Usage
|
|
4996
5046
|
$ ${command}
|
|
5047
|
+
|
|
5048
|
+
Options
|
|
5049
|
+
${getFlagListOutput(config$g.flags, 6)}
|
|
4997
5050
|
`
|
|
4998
5051
|
};
|
|
4999
|
-
const
|
|
5052
|
+
const cmdOrganization = {
|
|
5000
5053
|
description: config$g.description,
|
|
5001
5054
|
hidden: config$g.hidden,
|
|
5002
5055
|
run: run$g
|
|
@@ -5010,8 +5063,23 @@ async function run$g(argv, importMeta, {
|
|
|
5010
5063
|
importMeta,
|
|
5011
5064
|
parentName
|
|
5012
5065
|
});
|
|
5013
|
-
|
|
5014
|
-
|
|
5066
|
+
const json = Boolean(cli.flags['json']);
|
|
5067
|
+
const markdown = Boolean(cli.flags['markdown']);
|
|
5068
|
+
if (json && markdown) {
|
|
5069
|
+
// Use exit status of 2 to indicate incorrect usage, generally invalid
|
|
5070
|
+
// options or missing arguments.
|
|
5071
|
+
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
|
|
5072
|
+
process.exitCode = 2;
|
|
5073
|
+
console.error(`
|
|
5074
|
+
${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
|
|
5075
|
+
- The json and markdown flags cannot be both set, pick one
|
|
5076
|
+
`);
|
|
5077
|
+
return;
|
|
5078
|
+
}
|
|
5079
|
+
if (cli.flags['dryRun']) {
|
|
5080
|
+
return console.log('[DryRun] Bailing now');
|
|
5081
|
+
}
|
|
5082
|
+
await getOrganization(json ? 'json' : markdown ? 'markdown' : 'text');
|
|
5015
5083
|
}
|
|
5016
5084
|
|
|
5017
5085
|
const {
|
|
@@ -5070,7 +5138,9 @@ async function run$f(argv, importMeta, {
|
|
|
5070
5138
|
importMeta,
|
|
5071
5139
|
parentName
|
|
5072
5140
|
});
|
|
5073
|
-
if (cli.flags['dryRun'])
|
|
5141
|
+
if (cli.flags['dryRun']) {
|
|
5142
|
+
return console.log('[DryRun] Bailing now');
|
|
5143
|
+
}
|
|
5074
5144
|
await runRawNpm(argv);
|
|
5075
5145
|
}
|
|
5076
5146
|
|
|
@@ -5130,7 +5200,9 @@ async function run$e(argv, importMeta, {
|
|
|
5130
5200
|
importMeta,
|
|
5131
5201
|
parentName
|
|
5132
5202
|
});
|
|
5133
|
-
if (cli.flags['dryRun'])
|
|
5203
|
+
if (cli.flags['dryRun']) {
|
|
5204
|
+
return console.log('[DryRun] Bailing now');
|
|
5205
|
+
}
|
|
5134
5206
|
await runRawNpx(argv);
|
|
5135
5207
|
}
|
|
5136
5208
|
|
|
@@ -5328,7 +5400,9 @@ async function run$d(argv, importMeta, {
|
|
|
5328
5400
|
const view = Boolean(cli.flags['view']);
|
|
5329
5401
|
|
|
5330
5402
|
// Note exiting earlier to skirt a hidden auth requirement
|
|
5331
|
-
if (cli.flags['dryRun'])
|
|
5403
|
+
if (cli.flags['dryRun']) {
|
|
5404
|
+
return console.log('[DryRun] Bailing now');
|
|
5405
|
+
}
|
|
5332
5406
|
const socketConfig = await getSocketConfig(absoluteConfigPath);
|
|
5333
5407
|
const result = await createReport(socketConfig, cli.input, {
|
|
5334
5408
|
cwd,
|
|
@@ -5404,7 +5478,9 @@ async function run$c(argv, importMeta, {
|
|
|
5404
5478
|
- Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}\n`);
|
|
5405
5479
|
return;
|
|
5406
5480
|
}
|
|
5407
|
-
if (cli.flags['dryRun'])
|
|
5481
|
+
if (cli.flags['dryRun']) {
|
|
5482
|
+
return console.log('[DryRun] Bailing now');
|
|
5483
|
+
}
|
|
5408
5484
|
await viewReport(reportId, {
|
|
5409
5485
|
all: Boolean(cli.flags['all']),
|
|
5410
5486
|
commandName: `${parentName} ${config$c.commandName}`,
|
|
@@ -5540,7 +5616,9 @@ async function run$b(argv, importMeta, {
|
|
|
5540
5616
|
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
|
|
5541
5617
|
return;
|
|
5542
5618
|
}
|
|
5543
|
-
if (cli.flags['dryRun'])
|
|
5619
|
+
if (cli.flags['dryRun']) {
|
|
5620
|
+
return console.log('[DryRun] Bailing now');
|
|
5621
|
+
}
|
|
5544
5622
|
const apiToken = index.getDefaultToken();
|
|
5545
5623
|
if (!apiToken) {
|
|
5546
5624
|
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.');
|
|
@@ -5616,7 +5694,9 @@ async function run$a(argv, importMeta, {
|
|
|
5616
5694
|
- At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
|
|
5617
5695
|
return;
|
|
5618
5696
|
}
|
|
5619
|
-
if (cli.flags['dryRun'])
|
|
5697
|
+
if (cli.flags['dryRun']) {
|
|
5698
|
+
return console.log('[DryRun] Bailing now');
|
|
5699
|
+
}
|
|
5620
5700
|
const apiToken = index.getDefaultToken();
|
|
5621
5701
|
if (!apiToken) {
|
|
5622
5702
|
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.');
|
|
@@ -5741,7 +5821,9 @@ async function run$9(argv, importMeta, {
|
|
|
5741
5821
|
- At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
|
|
5742
5822
|
return;
|
|
5743
5823
|
}
|
|
5744
|
-
if (cli.flags['dryRun'])
|
|
5824
|
+
if (cli.flags['dryRun']) {
|
|
5825
|
+
return console.log('[DryRun] Bailing now');
|
|
5826
|
+
}
|
|
5745
5827
|
const apiToken = index.getDefaultToken();
|
|
5746
5828
|
if (!apiToken) {
|
|
5747
5829
|
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.');
|
|
@@ -5867,7 +5949,9 @@ async function run$8(argv, importMeta, {
|
|
|
5867
5949
|
- At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
|
|
5868
5950
|
return;
|
|
5869
5951
|
}
|
|
5870
|
-
if (cli.flags['dryRun'])
|
|
5952
|
+
if (cli.flags['dryRun']) {
|
|
5953
|
+
return console.log('[DryRun] Bailing now');
|
|
5954
|
+
}
|
|
5871
5955
|
const apiToken = index.getDefaultToken();
|
|
5872
5956
|
if (!apiToken) {
|
|
5873
5957
|
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.');
|
|
@@ -5969,7 +6053,9 @@ async function run$7(argv, importMeta, {
|
|
|
5969
6053
|
- Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
|
|
5970
6054
|
return;
|
|
5971
6055
|
}
|
|
5972
|
-
if (cli.flags['dryRun'])
|
|
6056
|
+
if (cli.flags['dryRun']) {
|
|
6057
|
+
return console.log('[DryRun] Bailing now');
|
|
6058
|
+
}
|
|
5973
6059
|
const apiToken = index.getDefaultToken();
|
|
5974
6060
|
if (!apiToken) {
|
|
5975
6061
|
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.');
|
|
@@ -6145,7 +6231,9 @@ async function run$6(argv, importMeta, {
|
|
|
6145
6231
|
const cwd = cli.flags['cwd'] && cli.flags['cwd'] !== 'process.cwd()' ? String(cli.flags['cwd']) : process$1.cwd();
|
|
6146
6232
|
|
|
6147
6233
|
// Note exiting earlier to skirt a hidden auth requirement
|
|
6148
|
-
if (cli.flags['dryRun'])
|
|
6234
|
+
if (cli.flags['dryRun']) {
|
|
6235
|
+
return console.log('[DryRun] Bailing now');
|
|
6236
|
+
}
|
|
6149
6237
|
const socketSdk = await index.setupSdk();
|
|
6150
6238
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
6151
6239
|
if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
|
|
@@ -6252,7 +6340,9 @@ async function run$5(argv, importMeta, {
|
|
|
6252
6340
|
- Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6253
6341
|
return;
|
|
6254
6342
|
}
|
|
6255
|
-
if (cli.flags['dryRun'])
|
|
6343
|
+
if (cli.flags['dryRun']) {
|
|
6344
|
+
return console.log('[DryRun] Bailing now');
|
|
6345
|
+
}
|
|
6256
6346
|
const apiToken = index.getDefaultToken();
|
|
6257
6347
|
if (!apiToken) {
|
|
6258
6348
|
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.');
|
|
@@ -6382,7 +6472,9 @@ async function run$4(argv, importMeta, {
|
|
|
6382
6472
|
- Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6383
6473
|
return;
|
|
6384
6474
|
}
|
|
6385
|
-
if (cli.flags['dryRun'])
|
|
6475
|
+
if (cli.flags['dryRun']) {
|
|
6476
|
+
return console.log('[DryRun] Bailing now');
|
|
6477
|
+
}
|
|
6386
6478
|
const apiToken = index.getDefaultToken();
|
|
6387
6479
|
if (!apiToken) {
|
|
6388
6480
|
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.');
|
|
@@ -6461,7 +6553,9 @@ async function run$3(argv, importMeta, {
|
|
|
6461
6553
|
- Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6462
6554
|
return;
|
|
6463
6555
|
}
|
|
6464
|
-
if (cli.flags['dryRun'])
|
|
6556
|
+
if (cli.flags['dryRun']) {
|
|
6557
|
+
return console.log('[DryRun] Bailing now');
|
|
6558
|
+
}
|
|
6465
6559
|
const apiToken = index.getDefaultToken();
|
|
6466
6560
|
if (!apiToken) {
|
|
6467
6561
|
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.');
|
|
@@ -6529,7 +6623,9 @@ async function run$2(argv, importMeta, {
|
|
|
6529
6623
|
- Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
|
|
6530
6624
|
return;
|
|
6531
6625
|
}
|
|
6532
|
-
if (cli.flags['dryRun'])
|
|
6626
|
+
if (cli.flags['dryRun']) {
|
|
6627
|
+
return console.log('[DryRun] Bailing now');
|
|
6628
|
+
}
|
|
6533
6629
|
const apiToken = index.getDefaultToken();
|
|
6534
6630
|
if (!apiToken) {
|
|
6535
6631
|
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.');
|
|
@@ -6692,7 +6788,9 @@ async function run$1(argv, importMeta, {
|
|
|
6692
6788
|
importMeta,
|
|
6693
6789
|
parentName
|
|
6694
6790
|
});
|
|
6695
|
-
if (cli.flags['dryRun'])
|
|
6791
|
+
if (cli.flags['dryRun']) {
|
|
6792
|
+
return console.log('[DryRun] Bailing now');
|
|
6793
|
+
}
|
|
6696
6794
|
const apiToken = index.getDefaultToken();
|
|
6697
6795
|
if (!apiToken) {
|
|
6698
6796
|
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.');
|
|
@@ -6921,7 +7019,7 @@ void (async () => {
|
|
|
6921
7019
|
npx: cmdNpx,
|
|
6922
7020
|
oops: cmdOops,
|
|
6923
7021
|
optimize: cmdOptimize,
|
|
6924
|
-
organization:
|
|
7022
|
+
organization: cmdOrganization,
|
|
6925
7023
|
'raw-npm': cmdRawNpm,
|
|
6926
7024
|
'raw-npx': cmdRawNpx,
|
|
6927
7025
|
report: cmdReport,
|
|
@@ -6973,5 +7071,5 @@ void (async () => {
|
|
|
6973
7071
|
await index.captureException(e);
|
|
6974
7072
|
}
|
|
6975
7073
|
})();
|
|
6976
|
-
//# debugId=
|
|
7074
|
+
//# debugId=71018fb6-02eb-4cf4-8a1e-dce142ed200
|
|
6977
7075
|
//# sourceMappingURL=cli.js.map
|