@socketsecurity/cli-with-sentry 0.14.58 → 0.14.59
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 +1 -0
- package/dist/constants.js +4 -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 +95 -84
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/require/cli.js +95 -84
- package/dist/require/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/module-sync/cli.js
CHANGED
|
@@ -1525,7 +1525,7 @@ function emitBanner(name) {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
function getAsciiHeader(command) {
|
|
1527
1527
|
const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']".
|
|
1528
|
-
"0.14.
|
|
1528
|
+
"0.14.59:e40b009:5200cfd8:pub";
|
|
1529
1529
|
const nodeVersion = process.version;
|
|
1530
1530
|
const apiToken = shadowNpmInject.getSetting('apiToken');
|
|
1531
1531
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
|
|
@@ -2258,22 +2258,22 @@ async function run$x(argv, importMeta, {
|
|
|
2258
2258
|
}
|
|
2259
2259
|
|
|
2260
2260
|
const {
|
|
2261
|
-
NPM: NPM$
|
|
2261
|
+
NPM: NPM$f,
|
|
2262
2262
|
NPX: NPX$3,
|
|
2263
2263
|
PNPM: PNPM$a
|
|
2264
2264
|
} = constants;
|
|
2265
|
-
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$
|
|
2265
|
+
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$f, PNPM$a, 'ts', 'tsx', 'typescript']);
|
|
2266
2266
|
async function runCycloneDX(yargv) {
|
|
2267
2267
|
let cleanupPackageLock = false;
|
|
2268
2268
|
if (yargv.type !== 'yarn' && nodejsPlatformTypes.has(yargv.type) && fs.existsSync('./yarn.lock')) {
|
|
2269
2269
|
if (fs.existsSync('./package-lock.json')) {
|
|
2270
|
-
yargv.type = NPM$
|
|
2270
|
+
yargv.type = NPM$f;
|
|
2271
2271
|
} else {
|
|
2272
2272
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
2273
2273
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
2274
2274
|
try {
|
|
2275
2275
|
await shadowBin(NPX$3, ['synp@1.9.14', '--', '--source-file', './yarn.lock'], 2);
|
|
2276
|
-
yargv.type = NPM$
|
|
2276
|
+
yargv.type = NPM$f;
|
|
2277
2277
|
cleanupPackageLock = true;
|
|
2278
2278
|
} catch {}
|
|
2279
2279
|
}
|
|
@@ -2794,7 +2794,7 @@ const cmdDiffScan = {
|
|
|
2794
2794
|
};
|
|
2795
2795
|
|
|
2796
2796
|
const {
|
|
2797
|
-
NPM: NPM$
|
|
2797
|
+
NPM: NPM$e
|
|
2798
2798
|
} = constants;
|
|
2799
2799
|
function isTopLevel(tree, node) {
|
|
2800
2800
|
return tree.children.get(node.name) === node;
|
|
@@ -2838,7 +2838,7 @@ async function npmFix(_pkgEnvDetails, cwd, options) {
|
|
|
2838
2838
|
// eslint-disable-next-line no-await-in-loop
|
|
2839
2839
|
await arb.buildIdealTree();
|
|
2840
2840
|
const tree = arb.idealTree;
|
|
2841
|
-
const hasUpgrade = !!registry.getManifestData(NPM$
|
|
2841
|
+
const hasUpgrade = !!registry.getManifestData(NPM$e, name);
|
|
2842
2842
|
if (hasUpgrade) {
|
|
2843
2843
|
spinner?.info(`Skipping ${name}. Socket Optimize package exists.`);
|
|
2844
2844
|
continue;
|
|
@@ -2955,8 +2955,13 @@ function cmdFlagsToString(args) {
|
|
|
2955
2955
|
}
|
|
2956
2956
|
return result.join(' ');
|
|
2957
2957
|
}
|
|
2958
|
+
function cmdPrefixMessage(cmdName, text) {
|
|
2959
|
+
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
2960
|
+
return `${cmdPrefix}${text}`;
|
|
2961
|
+
}
|
|
2958
2962
|
|
|
2959
2963
|
const {
|
|
2964
|
+
SOCKET_CLI_SENTRY_BUILD,
|
|
2960
2965
|
SOCKET_IPC_HANDSHAKE
|
|
2961
2966
|
} = constants;
|
|
2962
2967
|
function safeNpmInstall(options) {
|
|
@@ -2983,7 +2988,11 @@ function safeNpmInstall(options) {
|
|
|
2983
2988
|
// Lazily access constants.nodeHardenFlags.
|
|
2984
2989
|
...constants.nodeHardenFlags,
|
|
2985
2990
|
// Lazily access constants.nodeNoWarningsFlags.
|
|
2986
|
-
...constants.nodeNoWarningsFlags,
|
|
2991
|
+
...constants.nodeNoWarningsFlags,
|
|
2992
|
+
// Lazily access constants.ENV[SOCKET_CLI_SENTRY_BUILD].
|
|
2993
|
+
...(constants.ENV[SOCKET_CLI_SENTRY_BUILD] ? ['--require',
|
|
2994
|
+
// Lazily access constants.distInstrumentWithSentryPath.
|
|
2995
|
+
constants.distInstrumentWithSentryPath] : []), '--require',
|
|
2987
2996
|
// Lazily access constants.distShadowNpmInjectPath.
|
|
2988
2997
|
constants.distShadowNpmInjectPath, agentExecPath, 'install',
|
|
2989
2998
|
// Avoid code paths for 'audit' and 'fund'.
|
|
@@ -3014,7 +3023,7 @@ function safeNpmInstall(options) {
|
|
|
3014
3023
|
}
|
|
3015
3024
|
|
|
3016
3025
|
const {
|
|
3017
|
-
NPM: NPM$
|
|
3026
|
+
NPM: NPM$d
|
|
3018
3027
|
} = constants;
|
|
3019
3028
|
function runAgentInstall(pkgEnvDetails, options) {
|
|
3020
3029
|
const {
|
|
@@ -3022,7 +3031,7 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
3022
3031
|
agentExecPath
|
|
3023
3032
|
} = pkgEnvDetails;
|
|
3024
3033
|
// All package managers support the "install" command.
|
|
3025
|
-
if (agent === NPM$
|
|
3034
|
+
if (agent === NPM$d) {
|
|
3026
3035
|
return safeNpmInstall({
|
|
3027
3036
|
agentExecPath,
|
|
3028
3037
|
...options
|
|
@@ -3053,7 +3062,7 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
3053
3062
|
}
|
|
3054
3063
|
|
|
3055
3064
|
const {
|
|
3056
|
-
NPM: NPM$
|
|
3065
|
+
NPM: NPM$c,
|
|
3057
3066
|
OVERRIDES: OVERRIDES$2,
|
|
3058
3067
|
PNPM: PNPM$9
|
|
3059
3068
|
} = constants;
|
|
@@ -3101,7 +3110,7 @@ async function pnpmFix(pkgEnvDetails, cwd, options) {
|
|
|
3101
3110
|
1: infos
|
|
3102
3111
|
} of infoByPkg) {
|
|
3103
3112
|
const tree = arb.actualTree;
|
|
3104
|
-
const hasUpgrade = !!registry.getManifestData(NPM$
|
|
3113
|
+
const hasUpgrade = !!registry.getManifestData(NPM$c, name);
|
|
3105
3114
|
if (hasUpgrade) {
|
|
3106
3115
|
spinner?.info(`Skipping ${name}. Socket Optimize package exists.`);
|
|
3107
3116
|
continue;
|
|
@@ -3166,24 +3175,25 @@ async function pnpmFix(pkgEnvDetails, cwd, options) {
|
|
|
3166
3175
|
|
|
3167
3176
|
const {
|
|
3168
3177
|
BINARY_LOCK_EXT,
|
|
3169
|
-
BUN: BUN$
|
|
3178
|
+
BUN: BUN$5,
|
|
3170
3179
|
LOCK_EXT: LOCK_EXT$1,
|
|
3171
|
-
NPM: NPM$
|
|
3180
|
+
NPM: NPM$b,
|
|
3181
|
+
NPM_BUGGY_OVERRIDES_PATCHED_VERSION: NPM_BUGGY_OVERRIDES_PATCHED_VERSION$1,
|
|
3172
3182
|
PNPM: PNPM$8,
|
|
3173
|
-
VLT: VLT$
|
|
3183
|
+
VLT: VLT$5,
|
|
3174
3184
|
YARN,
|
|
3175
|
-
YARN_BERRY: YARN_BERRY$
|
|
3185
|
+
YARN_BERRY: YARN_BERRY$5,
|
|
3176
3186
|
YARN_CLASSIC: YARN_CLASSIC$6
|
|
3177
3187
|
} = constants;
|
|
3178
|
-
const AGENTS = [BUN$
|
|
3188
|
+
const AGENTS = [BUN$5, NPM$b, PNPM$8, YARN_BERRY$5, YARN_CLASSIC$6, VLT$5];
|
|
3179
3189
|
const binByAgent = {
|
|
3180
3190
|
__proto__: null,
|
|
3181
|
-
[BUN$
|
|
3182
|
-
[NPM$
|
|
3191
|
+
[BUN$5]: BUN$5,
|
|
3192
|
+
[NPM$b]: NPM$b,
|
|
3183
3193
|
[PNPM$8]: PNPM$8,
|
|
3184
|
-
[YARN_BERRY$
|
|
3194
|
+
[YARN_BERRY$5]: YARN,
|
|
3185
3195
|
[YARN_CLASSIC$6]: YARN,
|
|
3186
|
-
[VLT$
|
|
3196
|
+
[VLT$5]: VLT$5
|
|
3187
3197
|
};
|
|
3188
3198
|
async function getAgentExecPath(agent) {
|
|
3189
3199
|
const binName = binByAgent[agent];
|
|
@@ -3205,24 +3215,24 @@ async function getAgentVersion(agentExecPath, cwd) {
|
|
|
3205
3215
|
|
|
3206
3216
|
// The order of LOCKS properties IS significant as it affects iteration order.
|
|
3207
3217
|
const LOCKS = {
|
|
3208
|
-
[`bun${LOCK_EXT$1}`]: BUN$
|
|
3209
|
-
[`bun${BINARY_LOCK_EXT}`]: BUN$
|
|
3218
|
+
[`bun${LOCK_EXT$1}`]: BUN$5,
|
|
3219
|
+
[`bun${BINARY_LOCK_EXT}`]: BUN$5,
|
|
3210
3220
|
// If both package-lock.json and npm-shrinkwrap.json are present in the root
|
|
3211
3221
|
// of a project, npm-shrinkwrap.json will take precedence and package-lock.json
|
|
3212
3222
|
// will be ignored.
|
|
3213
3223
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
|
|
3214
|
-
'npm-shrinkwrap.json': NPM$
|
|
3215
|
-
'package-lock.json': NPM$
|
|
3224
|
+
'npm-shrinkwrap.json': NPM$b,
|
|
3225
|
+
'package-lock.json': NPM$b,
|
|
3216
3226
|
'pnpm-lock.yaml': PNPM$8,
|
|
3217
3227
|
'pnpm-lock.yml': PNPM$8,
|
|
3218
3228
|
[`yarn${LOCK_EXT$1}`]: YARN_CLASSIC$6,
|
|
3219
|
-
'vlt-lock.json': VLT$
|
|
3229
|
+
'vlt-lock.json': VLT$5,
|
|
3220
3230
|
// Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
|
|
3221
3231
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
|
|
3222
3232
|
//
|
|
3223
3233
|
// Unlike the other LOCKS keys this key contains a directory AND filename so
|
|
3224
3234
|
// it has to be handled differently.
|
|
3225
|
-
'node_modules/.package-lock.json': NPM$
|
|
3235
|
+
'node_modules/.package-lock.json': NPM$b
|
|
3226
3236
|
};
|
|
3227
3237
|
const readLockFileByAgent = (() => {
|
|
3228
3238
|
function wrapReader(reader) {
|
|
@@ -3236,7 +3246,7 @@ const readLockFileByAgent = (() => {
|
|
|
3236
3246
|
const binaryReader = wrapReader(shadowNpmInject.readFileBinary);
|
|
3237
3247
|
const defaultReader = wrapReader(async lockPath => await shadowNpmInject.readFileUtf8(lockPath));
|
|
3238
3248
|
return {
|
|
3239
|
-
[BUN$
|
|
3249
|
+
[BUN$5]: wrapReader(async (lockPath, agentExecPath) => {
|
|
3240
3250
|
const ext = path.extname(lockPath);
|
|
3241
3251
|
if (ext === LOCK_EXT$1) {
|
|
3242
3252
|
return await defaultReader(lockPath);
|
|
@@ -3255,10 +3265,10 @@ const readLockFileByAgent = (() => {
|
|
|
3255
3265
|
}
|
|
3256
3266
|
return undefined;
|
|
3257
3267
|
}),
|
|
3258
|
-
[NPM$
|
|
3268
|
+
[NPM$b]: defaultReader,
|
|
3259
3269
|
[PNPM$8]: defaultReader,
|
|
3260
|
-
[VLT$
|
|
3261
|
-
[YARN_BERRY$
|
|
3270
|
+
[VLT$5]: defaultReader,
|
|
3271
|
+
[YARN_BERRY$5]: defaultReader,
|
|
3262
3272
|
[YARN_CLASSIC$6]: defaultReader
|
|
3263
3273
|
};
|
|
3264
3274
|
})();
|
|
@@ -3299,16 +3309,16 @@ async function detectPackageEnvironment({
|
|
|
3299
3309
|
agent = LOCKS[lockName];
|
|
3300
3310
|
}
|
|
3301
3311
|
if (agent === undefined) {
|
|
3302
|
-
agent = NPM$
|
|
3312
|
+
agent = NPM$b;
|
|
3303
3313
|
onUnknown?.(pkgManager);
|
|
3304
3314
|
}
|
|
3305
3315
|
const agentExecPath = await getAgentExecPath(agent);
|
|
3306
|
-
const npmExecPath = agent === NPM$
|
|
3316
|
+
const npmExecPath = agent === NPM$b ? agentExecPath : await getAgentExecPath(NPM$b);
|
|
3307
3317
|
if (agentVersion === undefined) {
|
|
3308
3318
|
agentVersion = await getAgentVersion(agentExecPath, cwd);
|
|
3309
3319
|
}
|
|
3310
3320
|
if (agent === YARN_CLASSIC$6 && (agentVersion?.major ?? 0) > 1) {
|
|
3311
|
-
agent = YARN_BERRY$
|
|
3321
|
+
agent = YARN_BERRY$5;
|
|
3312
3322
|
}
|
|
3313
3323
|
const targets = {
|
|
3314
3324
|
browser: false,
|
|
@@ -3350,6 +3360,8 @@ async function detectPackageEnvironment({
|
|
|
3350
3360
|
lockName = undefined;
|
|
3351
3361
|
lockPath = undefined;
|
|
3352
3362
|
}
|
|
3363
|
+
const pkgSupported = targets.browser || targets.node;
|
|
3364
|
+
const npmBuggyOverrides = agent === NPM$b && !!agentVersion && semver.lt(agentVersion, NPM_BUGGY_OVERRIDES_PATCHED_VERSION$1);
|
|
3353
3365
|
return {
|
|
3354
3366
|
agent,
|
|
3355
3367
|
agentExecPath,
|
|
@@ -3361,19 +3373,16 @@ async function detectPackageEnvironment({
|
|
|
3361
3373
|
npmExecPath,
|
|
3362
3374
|
pkgJson: editablePkgJson,
|
|
3363
3375
|
pkgPath,
|
|
3364
|
-
|
|
3376
|
+
pkgSupported,
|
|
3377
|
+
features: {
|
|
3378
|
+
npmBuggyOverrides
|
|
3379
|
+
},
|
|
3365
3380
|
targets
|
|
3366
3381
|
};
|
|
3367
3382
|
}
|
|
3368
|
-
|
|
3369
|
-
const {
|
|
3370
|
-
BUN: BUN$5,
|
|
3371
|
-
VLT: VLT$5,
|
|
3372
|
-
YARN_BERRY: YARN_BERRY$5
|
|
3373
|
-
} = constants;
|
|
3374
|
-
const COMMAND_TITLE$2 = 'Socket Optimize';
|
|
3375
3383
|
async function detectAndValidatePackageEnvironment(cwd, options) {
|
|
3376
3384
|
const {
|
|
3385
|
+
cmdName = '',
|
|
3377
3386
|
logger,
|
|
3378
3387
|
prod
|
|
3379
3388
|
} = {
|
|
@@ -3383,44 +3392,45 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
|
|
|
3383
3392
|
const details = await detectPackageEnvironment({
|
|
3384
3393
|
cwd,
|
|
3385
3394
|
onUnknown(pkgManager) {
|
|
3386
|
-
logger?.warn(
|
|
3395
|
+
logger?.warn(cmdPrefixMessage(cmdName, `Unknown package manager${pkgManager ? ` ${pkgManager}` : ''}, defaulting to npm`));
|
|
3387
3396
|
}
|
|
3388
3397
|
});
|
|
3389
|
-
if (!details.
|
|
3390
|
-
logger?.fail(
|
|
3398
|
+
if (!details.pkgSupported) {
|
|
3399
|
+
logger?.fail(cmdPrefixMessage(cmdName, 'No supported Node or browser range detected'));
|
|
3391
3400
|
return;
|
|
3392
3401
|
}
|
|
3393
3402
|
if (details.agent === VLT$5) {
|
|
3394
|
-
logger?.fail(`${
|
|
3403
|
+
logger?.fail(cmdPrefixMessage(cmdName, `${details.agent} does not support overrides. Soon, though ⚡`));
|
|
3395
3404
|
return;
|
|
3396
3405
|
}
|
|
3397
3406
|
const lockName = details.lockName ?? 'lock file';
|
|
3398
3407
|
if (details.lockName === undefined || details.lockSrc === undefined) {
|
|
3399
|
-
logger?.fail(
|
|
3408
|
+
logger?.fail(cmdPrefixMessage(cmdName, `No ${lockName} found`));
|
|
3400
3409
|
return;
|
|
3401
3410
|
}
|
|
3402
3411
|
if (details.lockSrc.trim() === '') {
|
|
3403
|
-
logger?.fail(`${
|
|
3412
|
+
logger?.fail(cmdPrefixMessage(cmdName, `${lockName} is empty`));
|
|
3404
3413
|
return;
|
|
3405
3414
|
}
|
|
3406
3415
|
if (details.pkgPath === undefined) {
|
|
3407
|
-
logger?.fail(
|
|
3416
|
+
logger?.fail(cmdPrefixMessage(cmdName, 'No package.json found'));
|
|
3408
3417
|
return;
|
|
3409
3418
|
}
|
|
3410
3419
|
if (prod && (details.agent === BUN$5 || details.agent === YARN_BERRY$5)) {
|
|
3411
|
-
logger?.fail(
|
|
3420
|
+
logger?.fail(cmdPrefixMessage(cmdName, `--prod not supported for ${details.agent}${details.agentVersion ? `@${details.agentVersion.version}` : ''}`));
|
|
3412
3421
|
return;
|
|
3413
3422
|
}
|
|
3414
3423
|
if (details.lockPath && path.relative(cwd, details.lockPath).startsWith('.')) {
|
|
3415
|
-
logger?.warn(
|
|
3424
|
+
logger?.warn(cmdPrefixMessage(cmdName, `Package ${lockName} found at ${details.lockPath}`));
|
|
3416
3425
|
}
|
|
3417
3426
|
return details;
|
|
3418
3427
|
}
|
|
3419
3428
|
|
|
3420
3429
|
const {
|
|
3421
|
-
NPM: NPM$
|
|
3430
|
+
NPM: NPM$a,
|
|
3422
3431
|
PNPM: PNPM$7
|
|
3423
3432
|
} = constants;
|
|
3433
|
+
const CMD_NAME$1 = 'socket fix';
|
|
3424
3434
|
async function runFix() {
|
|
3425
3435
|
// Lazily access constants.spinner.
|
|
3426
3436
|
const {
|
|
@@ -3429,6 +3439,7 @@ async function runFix() {
|
|
|
3429
3439
|
spinner.start();
|
|
3430
3440
|
const cwd = process.cwd();
|
|
3431
3441
|
const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
|
|
3442
|
+
cmdName: CMD_NAME$1,
|
|
3432
3443
|
logger: logger.logger
|
|
3433
3444
|
});
|
|
3434
3445
|
if (!pkgEnvDetails) {
|
|
@@ -3436,7 +3447,7 @@ async function runFix() {
|
|
|
3436
3447
|
return;
|
|
3437
3448
|
}
|
|
3438
3449
|
switch (pkgEnvDetails.agent) {
|
|
3439
|
-
case NPM$
|
|
3450
|
+
case NPM$a:
|
|
3440
3451
|
{
|
|
3441
3452
|
await npmFix(pkgEnvDetails, cwd);
|
|
3442
3453
|
break;
|
|
@@ -3508,7 +3519,7 @@ async function fetchPackageInfo(pkgName, pkgVersion, includeAllIssues) {
|
|
|
3508
3519
|
}
|
|
3509
3520
|
|
|
3510
3521
|
const {
|
|
3511
|
-
NPM: NPM$
|
|
3522
|
+
NPM: NPM$9
|
|
3512
3523
|
} = registryConstants;
|
|
3513
3524
|
function formatScore(score) {
|
|
3514
3525
|
if (score > 80) {
|
|
@@ -3592,7 +3603,7 @@ function logPackageInfo({
|
|
|
3592
3603
|
logger.logger.log('Package has no issues');
|
|
3593
3604
|
}
|
|
3594
3605
|
const format = new shadowNpmInject.ColorOrMarkdown(outputKind === 'markdown');
|
|
3595
|
-
const url = shadowNpmInject.getSocketDevPackageOverviewUrl(NPM$
|
|
3606
|
+
const url = shadowNpmInject.getSocketDevPackageOverviewUrl(NPM$9, pkgName, pkgVersion);
|
|
3596
3607
|
logger.logger.log('\n');
|
|
3597
3608
|
if (pkgVersion === 'latest') {
|
|
3598
3609
|
logger.logger.log(`Detailed info on socket.dev: ${format.hyperlink(`${pkgName}`, url, {
|
|
@@ -4680,21 +4691,21 @@ async function run$l(argv, importMeta, {
|
|
|
4680
4691
|
}
|
|
4681
4692
|
|
|
4682
4693
|
const {
|
|
4683
|
-
NPM: NPM$
|
|
4694
|
+
NPM: NPM$8
|
|
4684
4695
|
} = constants;
|
|
4685
4696
|
async function wrapNpm(argv) {
|
|
4686
4697
|
// Lazily access constants.distShadowNpmBinPath.
|
|
4687
4698
|
const shadowBin = require(constants.distShadowNpmBinPath);
|
|
4688
|
-
await shadowBin(NPM$
|
|
4699
|
+
await shadowBin(NPM$8, argv);
|
|
4689
4700
|
}
|
|
4690
4701
|
|
|
4691
4702
|
const {
|
|
4692
4703
|
DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k,
|
|
4693
|
-
NPM: NPM$
|
|
4704
|
+
NPM: NPM$7
|
|
4694
4705
|
} = constants;
|
|
4695
4706
|
const config$k = {
|
|
4696
4707
|
commandName: 'npm',
|
|
4697
|
-
description: `${NPM$
|
|
4708
|
+
description: `${NPM$7} wrapper functionality`,
|
|
4698
4709
|
hidden: false,
|
|
4699
4710
|
flags: {},
|
|
4700
4711
|
help: (command, _config) => `
|
|
@@ -4809,7 +4820,7 @@ async function run$i(argv, importMeta, {
|
|
|
4809
4820
|
|
|
4810
4821
|
const {
|
|
4811
4822
|
BUN: BUN$4,
|
|
4812
|
-
NPM: NPM$
|
|
4823
|
+
NPM: NPM$6,
|
|
4813
4824
|
PNPM: PNPM$6,
|
|
4814
4825
|
VLT: VLT$4,
|
|
4815
4826
|
YARN_BERRY: YARN_BERRY$4,
|
|
@@ -4821,7 +4832,7 @@ function matchLsCmdViewHumanStdout(stdout, name) {
|
|
|
4821
4832
|
function matchQueryCmdStdout(stdout, name) {
|
|
4822
4833
|
return stdout.includes(`"${name}"`);
|
|
4823
4834
|
}
|
|
4824
|
-
const depsIncludesByAgent = new Map([[BUN$4, matchLsCmdViewHumanStdout], [NPM$
|
|
4835
|
+
const depsIncludesByAgent = new Map([[BUN$4, matchLsCmdViewHumanStdout], [NPM$6, matchQueryCmdStdout], [PNPM$6, matchQueryCmdStdout], [VLT$4, matchQueryCmdStdout], [YARN_BERRY$4, matchLsCmdViewHumanStdout], [YARN_CLASSIC$5, matchLsCmdViewHumanStdout]]);
|
|
4825
4836
|
|
|
4826
4837
|
function getDependencyEntries(pkgJson) {
|
|
4827
4838
|
const {
|
|
@@ -4849,7 +4860,7 @@ function getDependencyEntries(pkgJson) {
|
|
|
4849
4860
|
|
|
4850
4861
|
const {
|
|
4851
4862
|
BUN: BUN$3,
|
|
4852
|
-
NPM: NPM$
|
|
4863
|
+
NPM: NPM$5,
|
|
4853
4864
|
OVERRIDES: OVERRIDES$1,
|
|
4854
4865
|
PNPM: PNPM$5,
|
|
4855
4866
|
RESOLUTIONS: RESOLUTIONS$1,
|
|
@@ -4870,7 +4881,7 @@ function getOverridesDataBun(pkgJson) {
|
|
|
4870
4881
|
function getOverridesDataNpm(pkgJson) {
|
|
4871
4882
|
const overrides = pkgJson?.[OVERRIDES$1] ?? {};
|
|
4872
4883
|
return {
|
|
4873
|
-
type: NPM$
|
|
4884
|
+
type: NPM$5,
|
|
4874
4885
|
overrides
|
|
4875
4886
|
};
|
|
4876
4887
|
}
|
|
@@ -4911,7 +4922,7 @@ function getOverridesDataClassic(pkgJson) {
|
|
|
4911
4922
|
overrides
|
|
4912
4923
|
};
|
|
4913
4924
|
}
|
|
4914
|
-
const overridesDataByAgent = new Map([[BUN$3, getOverridesDataBun], [NPM$
|
|
4925
|
+
const overridesDataByAgent = new Map([[BUN$3, getOverridesDataBun], [NPM$5, getOverridesDataNpm], [PNPM$5, getOverridesDataPnpm], [VLT$3, getOverridesDataVlt], [YARN_BERRY$3, getOverridesDataYarn], [YARN_CLASSIC$4, getOverridesDataClassic]]);
|
|
4915
4926
|
|
|
4916
4927
|
const {
|
|
4917
4928
|
PNPM: PNPM$4
|
|
@@ -4959,7 +4970,7 @@ function workspacePatternToGlobPattern(workspace) {
|
|
|
4959
4970
|
const {
|
|
4960
4971
|
BUN: BUN$2,
|
|
4961
4972
|
LOCK_EXT,
|
|
4962
|
-
NPM: NPM$
|
|
4973
|
+
NPM: NPM$4,
|
|
4963
4974
|
PNPM: PNPM$3,
|
|
4964
4975
|
VLT: VLT$2,
|
|
4965
4976
|
YARN_BERRY: YARN_BERRY$2,
|
|
@@ -5003,11 +5014,11 @@ function includesYarn(lockSrc, name) {
|
|
|
5003
5014
|
// , name@
|
|
5004
5015
|
`(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
|
|
5005
5016
|
}
|
|
5006
|
-
const lockfileIncludesByAgent = new Map([[BUN$2, includesBun], [NPM$
|
|
5017
|
+
const lockfileIncludesByAgent = new Map([[BUN$2, includesBun], [NPM$4, includesNpm], [PNPM$3, includesPnpm], [VLT$2, includesVlt], [YARN_BERRY$2, includesYarn], [YARN_CLASSIC$3, includesYarn]]);
|
|
5007
5018
|
|
|
5008
5019
|
const {
|
|
5009
5020
|
BUN: BUN$1,
|
|
5010
|
-
NPM: NPM$
|
|
5021
|
+
NPM: NPM$3,
|
|
5011
5022
|
PNPM: PNPM$2,
|
|
5012
5023
|
VLT: VLT$1,
|
|
5013
5024
|
YARN_BERRY: YARN_BERRY$1,
|
|
@@ -5077,7 +5088,7 @@ async function lsNpm(agentExecPath, cwd) {
|
|
|
5077
5088
|
}
|
|
5078
5089
|
async function lsPnpm(agentExecPath, cwd, options) {
|
|
5079
5090
|
const npmExecPath = options?.npmExecPath;
|
|
5080
|
-
if (npmExecPath && npmExecPath !== NPM$
|
|
5091
|
+
if (npmExecPath && npmExecPath !== NPM$3) {
|
|
5081
5092
|
const result = await npmQuery(npmExecPath, cwd);
|
|
5082
5093
|
if (result) {
|
|
5083
5094
|
return result;
|
|
@@ -5128,14 +5139,14 @@ async function lsYarnClassic(agentExecPath, cwd) {
|
|
|
5128
5139
|
} catch {}
|
|
5129
5140
|
return '';
|
|
5130
5141
|
}
|
|
5131
|
-
const lsByAgent = new Map([[BUN$1, lsBun], [NPM$
|
|
5142
|
+
const lsByAgent = new Map([[BUN$1, lsBun], [NPM$3, lsNpm], [PNPM$2, lsPnpm], [VLT$1, lsVlt], [YARN_BERRY$1, lsYarnBerry], [YARN_CLASSIC$2, lsYarnClassic]]);
|
|
5132
5143
|
|
|
5133
5144
|
const {
|
|
5134
|
-
|
|
5145
|
+
NPM_BUGGY_OVERRIDES_PATCHED_VERSION
|
|
5135
5146
|
} = constants;
|
|
5136
|
-
const COMMAND_TITLE$1 = 'Socket Optimize';
|
|
5137
5147
|
async function updateLockfile(pkgEnvDetails, options) {
|
|
5138
5148
|
const {
|
|
5149
|
+
cmdName = '',
|
|
5139
5150
|
logger,
|
|
5140
5151
|
spinner
|
|
5141
5152
|
} = {
|
|
@@ -5148,12 +5159,12 @@ async function updateLockfile(pkgEnvDetails, options) {
|
|
|
5148
5159
|
spinner
|
|
5149
5160
|
});
|
|
5150
5161
|
spinner?.stop();
|
|
5151
|
-
if (pkgEnvDetails.
|
|
5152
|
-
logger?.log(`💡 Re-run ${
|
|
5162
|
+
if (pkgEnvDetails.features.npmBuggyOverrides) {
|
|
5163
|
+
logger?.log(`💡 Re-run ${cmdName ? `${cmdName} ` : ''}whenever ${pkgEnvDetails.lockName} changes.\n This can be skipped for ${pkgEnvDetails.agent} >=${NPM_BUGGY_OVERRIDES_PATCHED_VERSION}.`);
|
|
5153
5164
|
}
|
|
5154
5165
|
} catch (e) {
|
|
5155
5166
|
spinner?.stop();
|
|
5156
|
-
logger?.fail(`${
|
|
5167
|
+
logger?.fail(cmdPrefixMessage(cmdName, `${pkgEnvDetails.agent} install failed to update ${pkgEnvDetails.lockName}`));
|
|
5157
5168
|
logger?.error(e);
|
|
5158
5169
|
}
|
|
5159
5170
|
}
|
|
@@ -5273,7 +5284,7 @@ const {
|
|
|
5273
5284
|
PNPM,
|
|
5274
5285
|
YARN_CLASSIC
|
|
5275
5286
|
} = constants;
|
|
5276
|
-
const
|
|
5287
|
+
const CMD_NAME = 'socket optimize';
|
|
5277
5288
|
const manifestNpmOverrides = registry.getManifestData(NPM$1);
|
|
5278
5289
|
async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
5279
5290
|
const {
|
|
@@ -5318,7 +5329,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
5318
5329
|
const isWorkspace = !!workspaceGlobs;
|
|
5319
5330
|
if (isWorkspace && agent === PNPM && npmExecPath === NPM$1 && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
5320
5331
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
5321
|
-
logger?.warn(
|
|
5332
|
+
logger?.warn(cmdPrefixMessage(CMD_NAME, 'pnpm workspace support requires `npm ls`, falling back to `pnpm list`'));
|
|
5322
5333
|
}
|
|
5323
5334
|
const thingToScan = isLockScanned ? lockSrc : await lsByAgent.get(agent)(agentExecPath, pkgPath, {
|
|
5324
5335
|
npmExecPath
|
|
@@ -5458,6 +5469,7 @@ function createActionMessage(verb, overrideCount, workspaceCount) {
|
|
|
5458
5469
|
}
|
|
5459
5470
|
async function applyOptimization(cwd, pin, prod) {
|
|
5460
5471
|
const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
|
|
5472
|
+
cmdName: CMD_NAME,
|
|
5461
5473
|
logger: logger.logger,
|
|
5462
5474
|
prod
|
|
5463
5475
|
});
|
|
@@ -5489,10 +5501,9 @@ async function applyOptimization(cwd, pin, prod) {
|
|
|
5489
5501
|
} else {
|
|
5490
5502
|
logger.logger?.log('Congratulations! Already Socket.dev optimized 🎉');
|
|
5491
5503
|
}
|
|
5492
|
-
if (
|
|
5493
|
-
// Always update package-lock.json until the npm overrides PR lands:
|
|
5494
|
-
// https://github.com/npm/cli/pull/8089
|
|
5504
|
+
if (pkgJsonChanged || pkgEnvDetails.features.npmBuggyOverrides) {
|
|
5495
5505
|
await updateLockfile(pkgEnvDetails, {
|
|
5506
|
+
cmdName: CMD_NAME,
|
|
5496
5507
|
logger: logger.logger,
|
|
5497
5508
|
spinner
|
|
5498
5509
|
});
|
|
@@ -8229,14 +8240,14 @@ async function run(argv, importMeta, {
|
|
|
8229
8240
|
}
|
|
8230
8241
|
|
|
8231
8242
|
const {
|
|
8232
|
-
|
|
8243
|
+
SOCKET_CLI_BIN_NAME,
|
|
8233
8244
|
rootPkgJsonPath
|
|
8234
8245
|
} = constants;
|
|
8235
8246
|
|
|
8236
8247
|
// TODO: Add autocompletion using https://socket.dev/npm/package/omelette
|
|
8237
8248
|
void (async () => {
|
|
8238
8249
|
await updateNotifier({
|
|
8239
|
-
name:
|
|
8250
|
+
name: SOCKET_CLI_BIN_NAME,
|
|
8240
8251
|
version: require(rootPkgJsonPath).version,
|
|
8241
8252
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
8242
8253
|
});
|
|
@@ -8273,7 +8284,7 @@ void (async () => {
|
|
|
8273
8284
|
}
|
|
8274
8285
|
},
|
|
8275
8286
|
argv: process$1.argv.slice(2),
|
|
8276
|
-
name:
|
|
8287
|
+
name: SOCKET_CLI_BIN_NAME,
|
|
8277
8288
|
importMeta: {
|
|
8278
8289
|
url: `${node_url.pathToFileURL(__filename)}`
|
|
8279
8290
|
}
|
|
@@ -8297,12 +8308,12 @@ void (async () => {
|
|
|
8297
8308
|
} else {
|
|
8298
8309
|
errorTitle = 'Unexpected error with no details';
|
|
8299
8310
|
}
|
|
8300
|
-
logger.logger.fail(`${colors.bgRed(colors.white(errorTitle
|
|
8311
|
+
logger.logger.fail(`${colors.bgRed(colors.white(`${errorTitle}:`))} ${errorMessage}`);
|
|
8301
8312
|
if (errorBody) {
|
|
8302
8313
|
logger.logger.error(`\n${errorBody}`);
|
|
8303
8314
|
}
|
|
8304
8315
|
await shadowNpmInject.captureException(e);
|
|
8305
8316
|
}
|
|
8306
8317
|
})();
|
|
8307
|
-
//# debugId=
|
|
8318
|
+
//# debugId=c1c67343-d5ad-409c-8f8e-9236e0fb545a
|
|
8308
8319
|
//# sourceMappingURL=cli.js.map
|