@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.
@@ -1522,7 +1522,7 @@ function emitBanner(name) {
1522
1522
  }
1523
1523
  function getAsciiHeader(command) {
1524
1524
  const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']".
1525
- "0.14.58:f270068:05655527:pub";
1525
+ "0.14.59:e40b009:5200cfd8:pub";
1526
1526
  const nodeVersion = process.version;
1527
1527
  const apiToken = shadowNpmInject.getSetting('apiToken');
1528
1528
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
@@ -2255,22 +2255,22 @@ async function run$x(argv, importMeta, {
2255
2255
  }
2256
2256
 
2257
2257
  const {
2258
- NPM: NPM$g,
2258
+ NPM: NPM$f,
2259
2259
  NPX: NPX$3,
2260
2260
  PNPM: PNPM$a
2261
2261
  } = constants;
2262
- const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$g, PNPM$a, 'ts', 'tsx', 'typescript']);
2262
+ const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$f, PNPM$a, 'ts', 'tsx', 'typescript']);
2263
2263
  async function runCycloneDX(yargv) {
2264
2264
  let cleanupPackageLock = false;
2265
2265
  if (yargv.type !== 'yarn' && nodejsPlatformTypes.has(yargv.type) && fs.existsSync('./yarn.lock')) {
2266
2266
  if (fs.existsSync('./package-lock.json')) {
2267
- yargv.type = NPM$g;
2267
+ yargv.type = NPM$f;
2268
2268
  } else {
2269
2269
  // Use synp to create a package-lock.json from the yarn.lock,
2270
2270
  // based on the node_modules folder, for a more accurate SBOM.
2271
2271
  try {
2272
2272
  await shadowBin(NPX$3, ['synp@1.9.14', '--', '--source-file', './yarn.lock'], 2);
2273
- yargv.type = NPM$g;
2273
+ yargv.type = NPM$f;
2274
2274
  cleanupPackageLock = true;
2275
2275
  } catch {}
2276
2276
  }
@@ -2791,7 +2791,7 @@ const cmdDiffScan = {
2791
2791
  };
2792
2792
 
2793
2793
  const {
2794
- NPM: NPM$f
2794
+ NPM: NPM$e
2795
2795
  } = constants;
2796
2796
  function isTopLevel(tree, node) {
2797
2797
  return tree.children.get(node.name) === node;
@@ -2835,7 +2835,7 @@ async function npmFix(_pkgEnvDetails, cwd, options) {
2835
2835
  // eslint-disable-next-line no-await-in-loop
2836
2836
  await arb.buildIdealTree();
2837
2837
  const tree = arb.idealTree;
2838
- const hasUpgrade = !!registry.getManifestData(NPM$f, name);
2838
+ const hasUpgrade = !!registry.getManifestData(NPM$e, name);
2839
2839
  if (hasUpgrade) {
2840
2840
  spinner?.info(`Skipping ${name}. Socket Optimize package exists.`);
2841
2841
  continue;
@@ -2952,8 +2952,13 @@ function cmdFlagsToString(args) {
2952
2952
  }
2953
2953
  return result.join(' ');
2954
2954
  }
2955
+ function cmdPrefixMessage(cmdName, text) {
2956
+ const cmdPrefix = cmdName ? `${cmdName}: ` : '';
2957
+ return `${cmdPrefix}${text}`;
2958
+ }
2955
2959
 
2956
2960
  const {
2961
+ SOCKET_CLI_SENTRY_BUILD,
2957
2962
  SOCKET_IPC_HANDSHAKE
2958
2963
  } = constants;
2959
2964
  function safeNpmInstall(options) {
@@ -2980,7 +2985,11 @@ function safeNpmInstall(options) {
2980
2985
  // Lazily access constants.nodeHardenFlags.
2981
2986
  ...constants.nodeHardenFlags,
2982
2987
  // Lazily access constants.nodeNoWarningsFlags.
2983
- ...constants.nodeNoWarningsFlags, '--require',
2988
+ ...constants.nodeNoWarningsFlags,
2989
+ // Lazily access constants.ENV[SOCKET_CLI_SENTRY_BUILD].
2990
+ ...(constants.ENV[SOCKET_CLI_SENTRY_BUILD] ? ['--require',
2991
+ // Lazily access constants.distInstrumentWithSentryPath.
2992
+ constants.distInstrumentWithSentryPath] : []), '--require',
2984
2993
  // Lazily access constants.distShadowNpmInjectPath.
2985
2994
  constants.distShadowNpmInjectPath, agentExecPath, 'install',
2986
2995
  // Avoid code paths for 'audit' and 'fund'.
@@ -3011,7 +3020,7 @@ function safeNpmInstall(options) {
3011
3020
  }
3012
3021
 
3013
3022
  const {
3014
- NPM: NPM$e
3023
+ NPM: NPM$d
3015
3024
  } = constants;
3016
3025
  function runAgentInstall(pkgEnvDetails, options) {
3017
3026
  const {
@@ -3019,7 +3028,7 @@ function runAgentInstall(pkgEnvDetails, options) {
3019
3028
  agentExecPath
3020
3029
  } = pkgEnvDetails;
3021
3030
  // All package managers support the "install" command.
3022
- if (agent === NPM$e) {
3031
+ if (agent === NPM$d) {
3023
3032
  return safeNpmInstall({
3024
3033
  agentExecPath,
3025
3034
  ...options
@@ -3050,7 +3059,7 @@ function runAgentInstall(pkgEnvDetails, options) {
3050
3059
  }
3051
3060
 
3052
3061
  const {
3053
- NPM: NPM$d,
3062
+ NPM: NPM$c,
3054
3063
  OVERRIDES: OVERRIDES$2,
3055
3064
  PNPM: PNPM$9
3056
3065
  } = constants;
@@ -3098,7 +3107,7 @@ async function pnpmFix(pkgEnvDetails, cwd, options) {
3098
3107
  1: infos
3099
3108
  } of infoByPkg) {
3100
3109
  const tree = arb.actualTree;
3101
- const hasUpgrade = !!registry.getManifestData(NPM$d, name);
3110
+ const hasUpgrade = !!registry.getManifestData(NPM$c, name);
3102
3111
  if (hasUpgrade) {
3103
3112
  spinner?.info(`Skipping ${name}. Socket Optimize package exists.`);
3104
3113
  continue;
@@ -3163,24 +3172,25 @@ async function pnpmFix(pkgEnvDetails, cwd, options) {
3163
3172
 
3164
3173
  const {
3165
3174
  BINARY_LOCK_EXT,
3166
- BUN: BUN$6,
3175
+ BUN: BUN$5,
3167
3176
  LOCK_EXT: LOCK_EXT$1,
3168
- NPM: NPM$c,
3177
+ NPM: NPM$b,
3178
+ NPM_BUGGY_OVERRIDES_PATCHED_VERSION: NPM_BUGGY_OVERRIDES_PATCHED_VERSION$1,
3169
3179
  PNPM: PNPM$8,
3170
- VLT: VLT$6,
3180
+ VLT: VLT$5,
3171
3181
  YARN,
3172
- YARN_BERRY: YARN_BERRY$6,
3182
+ YARN_BERRY: YARN_BERRY$5,
3173
3183
  YARN_CLASSIC: YARN_CLASSIC$6
3174
3184
  } = constants;
3175
- const AGENTS = [BUN$6, NPM$c, PNPM$8, YARN_BERRY$6, YARN_CLASSIC$6, VLT$6];
3185
+ const AGENTS = [BUN$5, NPM$b, PNPM$8, YARN_BERRY$5, YARN_CLASSIC$6, VLT$5];
3176
3186
  const binByAgent = {
3177
3187
  __proto__: null,
3178
- [BUN$6]: BUN$6,
3179
- [NPM$c]: NPM$c,
3188
+ [BUN$5]: BUN$5,
3189
+ [NPM$b]: NPM$b,
3180
3190
  [PNPM$8]: PNPM$8,
3181
- [YARN_BERRY$6]: YARN,
3191
+ [YARN_BERRY$5]: YARN,
3182
3192
  [YARN_CLASSIC$6]: YARN,
3183
- [VLT$6]: VLT$6
3193
+ [VLT$5]: VLT$5
3184
3194
  };
3185
3195
  async function getAgentExecPath(agent) {
3186
3196
  const binName = binByAgent[agent];
@@ -3202,24 +3212,24 @@ async function getAgentVersion(agentExecPath, cwd) {
3202
3212
 
3203
3213
  // The order of LOCKS properties IS significant as it affects iteration order.
3204
3214
  const LOCKS = {
3205
- [`bun${LOCK_EXT$1}`]: BUN$6,
3206
- [`bun${BINARY_LOCK_EXT}`]: BUN$6,
3215
+ [`bun${LOCK_EXT$1}`]: BUN$5,
3216
+ [`bun${BINARY_LOCK_EXT}`]: BUN$5,
3207
3217
  // If both package-lock.json and npm-shrinkwrap.json are present in the root
3208
3218
  // of a project, npm-shrinkwrap.json will take precedence and package-lock.json
3209
3219
  // will be ignored.
3210
3220
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
3211
- 'npm-shrinkwrap.json': NPM$c,
3212
- 'package-lock.json': NPM$c,
3221
+ 'npm-shrinkwrap.json': NPM$b,
3222
+ 'package-lock.json': NPM$b,
3213
3223
  'pnpm-lock.yaml': PNPM$8,
3214
3224
  'pnpm-lock.yml': PNPM$8,
3215
3225
  [`yarn${LOCK_EXT$1}`]: YARN_CLASSIC$6,
3216
- 'vlt-lock.json': VLT$6,
3226
+ 'vlt-lock.json': VLT$5,
3217
3227
  // Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
3218
3228
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
3219
3229
  //
3220
3230
  // Unlike the other LOCKS keys this key contains a directory AND filename so
3221
3231
  // it has to be handled differently.
3222
- 'node_modules/.package-lock.json': NPM$c
3232
+ 'node_modules/.package-lock.json': NPM$b
3223
3233
  };
3224
3234
  const readLockFileByAgent = (() => {
3225
3235
  function wrapReader(reader) {
@@ -3233,7 +3243,7 @@ const readLockFileByAgent = (() => {
3233
3243
  const binaryReader = wrapReader(shadowNpmInject.readFileBinary);
3234
3244
  const defaultReader = wrapReader(async lockPath => await shadowNpmInject.readFileUtf8(lockPath));
3235
3245
  return {
3236
- [BUN$6]: wrapReader(async (lockPath, agentExecPath) => {
3246
+ [BUN$5]: wrapReader(async (lockPath, agentExecPath) => {
3237
3247
  const ext = path.extname(lockPath);
3238
3248
  if (ext === LOCK_EXT$1) {
3239
3249
  return await defaultReader(lockPath);
@@ -3252,10 +3262,10 @@ const readLockFileByAgent = (() => {
3252
3262
  }
3253
3263
  return undefined;
3254
3264
  }),
3255
- [NPM$c]: defaultReader,
3265
+ [NPM$b]: defaultReader,
3256
3266
  [PNPM$8]: defaultReader,
3257
- [VLT$6]: defaultReader,
3258
- [YARN_BERRY$6]: defaultReader,
3267
+ [VLT$5]: defaultReader,
3268
+ [YARN_BERRY$5]: defaultReader,
3259
3269
  [YARN_CLASSIC$6]: defaultReader
3260
3270
  };
3261
3271
  })();
@@ -3296,16 +3306,16 @@ async function detectPackageEnvironment({
3296
3306
  agent = LOCKS[lockName];
3297
3307
  }
3298
3308
  if (agent === undefined) {
3299
- agent = NPM$c;
3309
+ agent = NPM$b;
3300
3310
  onUnknown?.(pkgManager);
3301
3311
  }
3302
3312
  const agentExecPath = await getAgentExecPath(agent);
3303
- const npmExecPath = agent === NPM$c ? agentExecPath : await getAgentExecPath(NPM$c);
3313
+ const npmExecPath = agent === NPM$b ? agentExecPath : await getAgentExecPath(NPM$b);
3304
3314
  if (agentVersion === undefined) {
3305
3315
  agentVersion = await getAgentVersion(agentExecPath, cwd);
3306
3316
  }
3307
3317
  if (agent === YARN_CLASSIC$6 && (agentVersion?.major ?? 0) > 1) {
3308
- agent = YARN_BERRY$6;
3318
+ agent = YARN_BERRY$5;
3309
3319
  }
3310
3320
  const targets = {
3311
3321
  browser: false,
@@ -3347,6 +3357,8 @@ async function detectPackageEnvironment({
3347
3357
  lockName = undefined;
3348
3358
  lockPath = undefined;
3349
3359
  }
3360
+ const pkgSupported = targets.browser || targets.node;
3361
+ const npmBuggyOverrides = agent === NPM$b && !!agentVersion && semver.lt(agentVersion, NPM_BUGGY_OVERRIDES_PATCHED_VERSION$1);
3350
3362
  return {
3351
3363
  agent,
3352
3364
  agentExecPath,
@@ -3358,19 +3370,16 @@ async function detectPackageEnvironment({
3358
3370
  npmExecPath,
3359
3371
  pkgJson: editablePkgJson,
3360
3372
  pkgPath,
3361
- supported: targets.browser || targets.node,
3373
+ pkgSupported,
3374
+ features: {
3375
+ npmBuggyOverrides
3376
+ },
3362
3377
  targets
3363
3378
  };
3364
3379
  }
3365
-
3366
- const {
3367
- BUN: BUN$5,
3368
- VLT: VLT$5,
3369
- YARN_BERRY: YARN_BERRY$5
3370
- } = constants;
3371
- const COMMAND_TITLE$2 = 'Socket Optimize';
3372
3380
  async function detectAndValidatePackageEnvironment(cwd, options) {
3373
3381
  const {
3382
+ cmdName = '',
3374
3383
  logger,
3375
3384
  prod
3376
3385
  } = {
@@ -3380,44 +3389,45 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
3380
3389
  const details = await detectPackageEnvironment({
3381
3390
  cwd,
3382
3391
  onUnknown(pkgManager) {
3383
- logger?.warn(`${COMMAND_TITLE$2}: Unknown package manager${pkgManager ? ` ${pkgManager}` : ''}, defaulting to npm`);
3392
+ logger?.warn(cmdPrefixMessage(cmdName, `Unknown package manager${pkgManager ? ` ${pkgManager}` : ''}, defaulting to npm`));
3384
3393
  }
3385
3394
  });
3386
- if (!details.supported) {
3387
- logger?.fail(`${COMMAND_TITLE$2}: No supported Node or browser range detected`);
3395
+ if (!details.pkgSupported) {
3396
+ logger?.fail(cmdPrefixMessage(cmdName, 'No supported Node or browser range detected'));
3388
3397
  return;
3389
3398
  }
3390
3399
  if (details.agent === VLT$5) {
3391
- logger?.fail(`${COMMAND_TITLE$2}: ${details.agent} does not support overrides. Soon, though ⚡`);
3400
+ logger?.fail(cmdPrefixMessage(cmdName, `${details.agent} does not support overrides. Soon, though ⚡`));
3392
3401
  return;
3393
3402
  }
3394
3403
  const lockName = details.lockName ?? 'lock file';
3395
3404
  if (details.lockName === undefined || details.lockSrc === undefined) {
3396
- logger?.fail(`${COMMAND_TITLE$2}: No ${lockName} found`);
3405
+ logger?.fail(cmdPrefixMessage(cmdName, `No ${lockName} found`));
3397
3406
  return;
3398
3407
  }
3399
3408
  if (details.lockSrc.trim() === '') {
3400
- logger?.fail(`${COMMAND_TITLE$2}: ${lockName} is empty`);
3409
+ logger?.fail(cmdPrefixMessage(cmdName, `${lockName} is empty`));
3401
3410
  return;
3402
3411
  }
3403
3412
  if (details.pkgPath === undefined) {
3404
- logger?.fail(`${COMMAND_TITLE$2}: No package.json found`);
3413
+ logger?.fail(cmdPrefixMessage(cmdName, 'No package.json found'));
3405
3414
  return;
3406
3415
  }
3407
3416
  if (prod && (details.agent === BUN$5 || details.agent === YARN_BERRY$5)) {
3408
- logger?.fail(`${COMMAND_TITLE$2}: --prod not supported for ${details.agent}${details.agentVersion ? `@${details.agentVersion.toString()}` : ''}`);
3417
+ logger?.fail(cmdPrefixMessage(cmdName, `--prod not supported for ${details.agent}${details.agentVersion ? `@${details.agentVersion.version}` : ''}`));
3409
3418
  return;
3410
3419
  }
3411
3420
  if (details.lockPath && path.relative(cwd, details.lockPath).startsWith('.')) {
3412
- logger?.warn(`${COMMAND_TITLE$2}: Package ${lockName} found at ${details.lockPath}`);
3421
+ logger?.warn(cmdPrefixMessage(cmdName, `Package ${lockName} found at ${details.lockPath}`));
3413
3422
  }
3414
3423
  return details;
3415
3424
  }
3416
3425
 
3417
3426
  const {
3418
- NPM: NPM$b,
3427
+ NPM: NPM$a,
3419
3428
  PNPM: PNPM$7
3420
3429
  } = constants;
3430
+ const CMD_NAME$1 = 'socket fix';
3421
3431
  async function runFix() {
3422
3432
  // Lazily access constants.spinner.
3423
3433
  const {
@@ -3426,6 +3436,7 @@ async function runFix() {
3426
3436
  spinner.start();
3427
3437
  const cwd = process.cwd();
3428
3438
  const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
3439
+ cmdName: CMD_NAME$1,
3429
3440
  logger: logger.logger
3430
3441
  });
3431
3442
  if (!pkgEnvDetails) {
@@ -3433,7 +3444,7 @@ async function runFix() {
3433
3444
  return;
3434
3445
  }
3435
3446
  switch (pkgEnvDetails.agent) {
3436
- case NPM$b:
3447
+ case NPM$a:
3437
3448
  {
3438
3449
  await npmFix(pkgEnvDetails, cwd);
3439
3450
  break;
@@ -3505,7 +3516,7 @@ async function fetchPackageInfo(pkgName, pkgVersion, includeAllIssues) {
3505
3516
  }
3506
3517
 
3507
3518
  const {
3508
- NPM: NPM$a
3519
+ NPM: NPM$9
3509
3520
  } = registryConstants;
3510
3521
  function formatScore(score) {
3511
3522
  if (score > 80) {
@@ -3589,7 +3600,7 @@ function logPackageInfo({
3589
3600
  logger.logger.log('Package has no issues');
3590
3601
  }
3591
3602
  const format = new shadowNpmInject.ColorOrMarkdown(outputKind === 'markdown');
3592
- const url = shadowNpmInject.getSocketDevPackageOverviewUrl(NPM$a, pkgName, pkgVersion);
3603
+ const url = shadowNpmInject.getSocketDevPackageOverviewUrl(NPM$9, pkgName, pkgVersion);
3593
3604
  logger.logger.log('\n');
3594
3605
  if (pkgVersion === 'latest') {
3595
3606
  logger.logger.log(`Detailed info on socket.dev: ${format.hyperlink(`${pkgName}`, url, {
@@ -4677,21 +4688,21 @@ async function run$l(argv, importMeta, {
4677
4688
  }
4678
4689
 
4679
4690
  const {
4680
- NPM: NPM$9
4691
+ NPM: NPM$8
4681
4692
  } = constants;
4682
4693
  async function wrapNpm(argv) {
4683
4694
  // Lazily access constants.distShadowNpmBinPath.
4684
4695
  const shadowBin = require(constants.distShadowNpmBinPath);
4685
- await shadowBin(NPM$9, argv);
4696
+ await shadowBin(NPM$8, argv);
4686
4697
  }
4687
4698
 
4688
4699
  const {
4689
4700
  DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k,
4690
- NPM: NPM$8
4701
+ NPM: NPM$7
4691
4702
  } = constants;
4692
4703
  const config$k = {
4693
4704
  commandName: 'npm',
4694
- description: `${NPM$8} wrapper functionality`,
4705
+ description: `${NPM$7} wrapper functionality`,
4695
4706
  hidden: false,
4696
4707
  flags: {},
4697
4708
  help: (command, _config) => `
@@ -4806,7 +4817,7 @@ async function run$i(argv, importMeta, {
4806
4817
 
4807
4818
  const {
4808
4819
  BUN: BUN$4,
4809
- NPM: NPM$7,
4820
+ NPM: NPM$6,
4810
4821
  PNPM: PNPM$6,
4811
4822
  VLT: VLT$4,
4812
4823
  YARN_BERRY: YARN_BERRY$4,
@@ -4818,7 +4829,7 @@ function matchLsCmdViewHumanStdout(stdout, name) {
4818
4829
  function matchQueryCmdStdout(stdout, name) {
4819
4830
  return stdout.includes(`"${name}"`);
4820
4831
  }
4821
- const depsIncludesByAgent = new Map([[BUN$4, matchLsCmdViewHumanStdout], [NPM$7, matchQueryCmdStdout], [PNPM$6, matchQueryCmdStdout], [VLT$4, matchQueryCmdStdout], [YARN_BERRY$4, matchLsCmdViewHumanStdout], [YARN_CLASSIC$5, matchLsCmdViewHumanStdout]]);
4832
+ const depsIncludesByAgent = new Map([[BUN$4, matchLsCmdViewHumanStdout], [NPM$6, matchQueryCmdStdout], [PNPM$6, matchQueryCmdStdout], [VLT$4, matchQueryCmdStdout], [YARN_BERRY$4, matchLsCmdViewHumanStdout], [YARN_CLASSIC$5, matchLsCmdViewHumanStdout]]);
4822
4833
 
4823
4834
  function getDependencyEntries(pkgJson) {
4824
4835
  const {
@@ -4846,7 +4857,7 @@ function getDependencyEntries(pkgJson) {
4846
4857
 
4847
4858
  const {
4848
4859
  BUN: BUN$3,
4849
- NPM: NPM$6,
4860
+ NPM: NPM$5,
4850
4861
  OVERRIDES: OVERRIDES$1,
4851
4862
  PNPM: PNPM$5,
4852
4863
  RESOLUTIONS: RESOLUTIONS$1,
@@ -4867,7 +4878,7 @@ function getOverridesDataBun(pkgJson) {
4867
4878
  function getOverridesDataNpm(pkgJson) {
4868
4879
  const overrides = pkgJson?.[OVERRIDES$1] ?? {};
4869
4880
  return {
4870
- type: NPM$6,
4881
+ type: NPM$5,
4871
4882
  overrides
4872
4883
  };
4873
4884
  }
@@ -4908,7 +4919,7 @@ function getOverridesDataClassic(pkgJson) {
4908
4919
  overrides
4909
4920
  };
4910
4921
  }
4911
- const overridesDataByAgent = new Map([[BUN$3, getOverridesDataBun], [NPM$6, getOverridesDataNpm], [PNPM$5, getOverridesDataPnpm], [VLT$3, getOverridesDataVlt], [YARN_BERRY$3, getOverridesDataYarn], [YARN_CLASSIC$4, getOverridesDataClassic]]);
4922
+ const overridesDataByAgent = new Map([[BUN$3, getOverridesDataBun], [NPM$5, getOverridesDataNpm], [PNPM$5, getOverridesDataPnpm], [VLT$3, getOverridesDataVlt], [YARN_BERRY$3, getOverridesDataYarn], [YARN_CLASSIC$4, getOverridesDataClassic]]);
4912
4923
 
4913
4924
  const {
4914
4925
  PNPM: PNPM$4
@@ -4956,7 +4967,7 @@ function workspacePatternToGlobPattern(workspace) {
4956
4967
  const {
4957
4968
  BUN: BUN$2,
4958
4969
  LOCK_EXT,
4959
- NPM: NPM$5,
4970
+ NPM: NPM$4,
4960
4971
  PNPM: PNPM$3,
4961
4972
  VLT: VLT$2,
4962
4973
  YARN_BERRY: YARN_BERRY$2,
@@ -5000,11 +5011,11 @@ function includesYarn(lockSrc, name) {
5000
5011
  // , name@
5001
5012
  `(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
5002
5013
  }
5003
- const lockfileIncludesByAgent = new Map([[BUN$2, includesBun], [NPM$5, includesNpm], [PNPM$3, includesPnpm], [VLT$2, includesVlt], [YARN_BERRY$2, includesYarn], [YARN_CLASSIC$3, includesYarn]]);
5014
+ const lockfileIncludesByAgent = new Map([[BUN$2, includesBun], [NPM$4, includesNpm], [PNPM$3, includesPnpm], [VLT$2, includesVlt], [YARN_BERRY$2, includesYarn], [YARN_CLASSIC$3, includesYarn]]);
5004
5015
 
5005
5016
  const {
5006
5017
  BUN: BUN$1,
5007
- NPM: NPM$4,
5018
+ NPM: NPM$3,
5008
5019
  PNPM: PNPM$2,
5009
5020
  VLT: VLT$1,
5010
5021
  YARN_BERRY: YARN_BERRY$1,
@@ -5074,7 +5085,7 @@ async function lsNpm(agentExecPath, cwd) {
5074
5085
  }
5075
5086
  async function lsPnpm(agentExecPath, cwd, options) {
5076
5087
  const npmExecPath = options?.npmExecPath;
5077
- if (npmExecPath && npmExecPath !== NPM$4) {
5088
+ if (npmExecPath && npmExecPath !== NPM$3) {
5078
5089
  const result = await npmQuery(npmExecPath, cwd);
5079
5090
  if (result) {
5080
5091
  return result;
@@ -5125,14 +5136,14 @@ async function lsYarnClassic(agentExecPath, cwd) {
5125
5136
  } catch {}
5126
5137
  return '';
5127
5138
  }
5128
- const lsByAgent = new Map([[BUN$1, lsBun], [NPM$4, lsNpm], [PNPM$2, lsPnpm], [VLT$1, lsVlt], [YARN_BERRY$1, lsYarnBerry], [YARN_CLASSIC$2, lsYarnClassic]]);
5139
+ const lsByAgent = new Map([[BUN$1, lsBun], [NPM$3, lsNpm], [PNPM$2, lsPnpm], [VLT$1, lsVlt], [YARN_BERRY$1, lsYarnBerry], [YARN_CLASSIC$2, lsYarnClassic]]);
5129
5140
 
5130
5141
  const {
5131
- NPM: NPM$3
5142
+ NPM_BUGGY_OVERRIDES_PATCHED_VERSION
5132
5143
  } = constants;
5133
- const COMMAND_TITLE$1 = 'Socket Optimize';
5134
5144
  async function updateLockfile(pkgEnvDetails, options) {
5135
5145
  const {
5146
+ cmdName = '',
5136
5147
  logger,
5137
5148
  spinner
5138
5149
  } = {
@@ -5145,12 +5156,12 @@ async function updateLockfile(pkgEnvDetails, options) {
5145
5156
  spinner
5146
5157
  });
5147
5158
  spinner?.stop();
5148
- if (pkgEnvDetails.agent === NPM$3) {
5149
- logger?.log(`💡 Re-run ${COMMAND_TITLE$1} whenever ${pkgEnvDetails.lockName} changes.\n This can be skipped once npm v11.2.0 is released.`);
5159
+ if (pkgEnvDetails.features.npmBuggyOverrides) {
5160
+ logger?.log(`💡 Re-run ${cmdName ? `${cmdName} ` : ''}whenever ${pkgEnvDetails.lockName} changes.\n This can be skipped for ${pkgEnvDetails.agent} >=${NPM_BUGGY_OVERRIDES_PATCHED_VERSION}.`);
5150
5161
  }
5151
5162
  } catch (e) {
5152
5163
  spinner?.stop();
5153
- logger?.fail(`${COMMAND_TITLE$1}: ${pkgEnvDetails.agent} install failed to update ${pkgEnvDetails.lockName}`);
5164
+ logger?.fail(cmdPrefixMessage(cmdName, `${pkgEnvDetails.agent} install failed to update ${pkgEnvDetails.lockName}`));
5154
5165
  logger?.error(e);
5155
5166
  }
5156
5167
  }
@@ -5270,7 +5281,7 @@ const {
5270
5281
  PNPM,
5271
5282
  YARN_CLASSIC
5272
5283
  } = constants;
5273
- const COMMAND_TITLE = 'Socket Optimize';
5284
+ const CMD_NAME = 'socket optimize';
5274
5285
  const manifestNpmOverrides = registry.getManifestData(NPM$1);
5275
5286
  async function addOverrides(pkgPath, pkgEnvDetails, options) {
5276
5287
  const {
@@ -5315,7 +5326,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
5315
5326
  const isWorkspace = !!workspaceGlobs;
5316
5327
  if (isWorkspace && agent === PNPM && npmExecPath === NPM$1 && !state.warnedPnpmWorkspaceRequiresNpm) {
5317
5328
  state.warnedPnpmWorkspaceRequiresNpm = true;
5318
- logger?.warn(`${COMMAND_TITLE}: pnpm workspace support requires \`npm ls\`, falling back to \`pnpm list\``);
5329
+ logger?.warn(cmdPrefixMessage(CMD_NAME, 'pnpm workspace support requires `npm ls`, falling back to `pnpm list`'));
5319
5330
  }
5320
5331
  const thingToScan = isLockScanned ? lockSrc : await lsByAgent.get(agent)(agentExecPath, pkgPath, {
5321
5332
  npmExecPath
@@ -5455,6 +5466,7 @@ function createActionMessage(verb, overrideCount, workspaceCount) {
5455
5466
  }
5456
5467
  async function applyOptimization(cwd, pin, prod) {
5457
5468
  const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
5469
+ cmdName: CMD_NAME,
5458
5470
  logger: logger.logger,
5459
5471
  prod
5460
5472
  });
@@ -5486,10 +5498,9 @@ async function applyOptimization(cwd, pin, prod) {
5486
5498
  } else {
5487
5499
  logger.logger?.log('Congratulations! Already Socket.dev optimized 🎉');
5488
5500
  }
5489
- if (pkgEnvDetails.agent === NPM$1 || pkgJsonChanged) {
5490
- // Always update package-lock.json until the npm overrides PR lands:
5491
- // https://github.com/npm/cli/pull/8089
5501
+ if (pkgJsonChanged || pkgEnvDetails.features.npmBuggyOverrides) {
5492
5502
  await updateLockfile(pkgEnvDetails, {
5503
+ cmdName: CMD_NAME,
5493
5504
  logger: logger.logger,
5494
5505
  spinner
5495
5506
  });
@@ -8226,14 +8237,14 @@ async function run(argv, importMeta, {
8226
8237
  }
8227
8238
 
8228
8239
  const {
8229
- SOCKET,
8240
+ SOCKET_CLI_BIN_NAME,
8230
8241
  rootPkgJsonPath
8231
8242
  } = constants;
8232
8243
 
8233
8244
  // TODO: Add autocompletion using https://socket.dev/npm/package/omelette
8234
8245
  void (async () => {
8235
8246
  await vendor.updater({
8236
- name: SOCKET,
8247
+ name: SOCKET_CLI_BIN_NAME,
8237
8248
  version: require(rootPkgJsonPath).version,
8238
8249
  ttl: 86_400_000 /* 24 hours in milliseconds */
8239
8250
  });
@@ -8270,7 +8281,7 @@ void (async () => {
8270
8281
  }
8271
8282
  },
8272
8283
  argv: process$1.argv.slice(2),
8273
- name: SOCKET,
8284
+ name: SOCKET_CLI_BIN_NAME,
8274
8285
  importMeta: {
8275
8286
  url: `${require$$0.pathToFileURL(__filename)}`
8276
8287
  }
@@ -8294,12 +8305,12 @@ void (async () => {
8294
8305
  } else {
8295
8306
  errorTitle = 'Unexpected error with no details';
8296
8307
  }
8297
- logger.logger.fail(`${colors.bgRed(colors.white(errorTitle + ':'))} ${errorMessage}`);
8308
+ logger.logger.fail(`${colors.bgRed(colors.white(`${errorTitle}:`))} ${errorMessage}`);
8298
8309
  if (errorBody) {
8299
8310
  logger.logger.error(`\n${errorBody}`);
8300
8311
  }
8301
8312
  await shadowNpmInject.captureException(e);
8302
8313
  }
8303
8314
  })();
8304
- //# debugId=b5131c8e-e05e-4ce0-8d35-03afa5b09043
8315
+ //# debugId=2e8d9d04-20b0-4f47-8b02-b404f72bd2d
8305
8316
  //# sourceMappingURL=cli.js.map