socket 0.14.20 → 0.14.21

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/cli.js CHANGED
@@ -511,8 +511,8 @@ async function fetchPackageData(pkgName, pkgVersion, {
511
511
  }
512
512
  function formatPackageDataOutput({
513
513
  data,
514
- severityCount,
515
- score
514
+ score,
515
+ severityCount
516
516
  }, {
517
517
  name,
518
518
  outputJson,
@@ -915,7 +915,7 @@ var _which = require$$6$1;
915
915
  var _fs$1 = fs;
916
916
  var _objects$1 = sdk.objects;
917
917
  var _strings$1 = strings;
918
- const AGENTS = packageManagerDetector.AGENTS = ['bun', 'npm', 'pnpm', 'yarn/berry', 'yarn/classic'];
918
+ const AGENTS = packageManagerDetector.AGENTS = ['bun', 'npm', 'pnpm', 'yarn/berry', 'yarn/classic', 'vlt'];
919
919
  const numericCollator = new Intl.Collator(undefined, {
920
920
  numeric: true,
921
921
  sensitivity: 'base'
@@ -923,6 +923,22 @@ const numericCollator = new Intl.Collator(undefined, {
923
923
  const {
924
924
  compare: alphaNumericComparator
925
925
  } = numericCollator;
926
+ async function getAgentExecPath(agent) {
927
+ return (await _which(agent, {
928
+ nothrow: true
929
+ })) ?? agent;
930
+ }
931
+ async function getAgentVersion(agentExecPath, cwd) {
932
+ let result;
933
+ try {
934
+ result = _semver$1.coerce(
935
+ // All package managers support the "--version" flag.
936
+ (await _promiseSpawn$3(agentExecPath, ['--version'], {
937
+ cwd
938
+ })).stdout) ?? undefined;
939
+ } catch {}
940
+ return result;
941
+ }
926
942
  const maintainedNodeVersions = (() => {
927
943
  // Under the hood browserlist uses the node-releases package which is out of date:
928
944
  // https://github.com/chicoxyzzy/node-releases/issues/37
@@ -950,15 +966,16 @@ const maintainedNodeVersions = (() => {
950
966
  })();
951
967
  const LOCKS = {
952
968
  'bun.lockb': 'bun',
953
- 'pnpm-lock.yaml': 'pnpm',
954
- 'pnpm-lock.yml': 'pnpm',
955
- 'yarn.lock': 'yarn/classic',
956
969
  // If both package-lock.json and npm-shrinkwrap.json are present in the root
957
970
  // of a project, npm-shrinkwrap.json will take precedence and package-lock.json
958
971
  // will be ignored.
959
972
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
960
973
  'npm-shrinkwrap.json': 'npm',
961
974
  'package-lock.json': 'npm',
975
+ 'pnpm-lock.yaml': 'pnpm',
976
+ 'pnpm-lock.yml': 'pnpm',
977
+ 'yarn.lock': 'yarn/classic',
978
+ 'vlt-lock.json': 'vlt',
962
979
  // Look for a hidden lock file if .npmrc has package-lock=false:
963
980
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
964
981
  //
@@ -975,6 +992,7 @@ const readLockFileByAgent = (() => {
975
992
  return undefined;
976
993
  };
977
994
  }
995
+ const defaultReader = wrapReader(async lockPath => await (0, _fs$1.readFileUtf8)(lockPath));
978
996
  return {
979
997
  bun: wrapReader(async (lockPath, agentExecPath) => {
980
998
  let lockBuffer;
@@ -986,14 +1004,16 @@ const readLockFileByAgent = (() => {
986
1004
  try {
987
1005
  return (0, _hyrious__bun.parse)(lockBuffer);
988
1006
  } catch {}
989
- // To print a Yarn lockfile to your console without writing it to disk use `bun bun.lockb`.
1007
+ // To print a Yarn lockfile to your console without writing it to disk
1008
+ // use `bun bun.lockb`.
990
1009
  // https://bun.sh/guides/install/yarnlock
991
1010
  return (await _promiseSpawn$3(agentExecPath, [lockPath])).stdout.trim();
992
1011
  }),
993
- npm: wrapReader(async lockPath => await (0, _fs$1.readFileUtf8)(lockPath)),
994
- pnpm: wrapReader(async lockPath => await (0, _fs$1.readFileUtf8)(lockPath)),
995
- 'yarn/berry': wrapReader(async lockPath => await (0, _fs$1.readFileUtf8)(lockPath)),
996
- 'yarn/classic': wrapReader(async lockPath => await (0, _fs$1.readFileUtf8)(lockPath))
1012
+ npm: defaultReader,
1013
+ pnpm: defaultReader,
1014
+ vlt: defaultReader,
1015
+ 'yarn/berry': defaultReader,
1016
+ 'yarn/classic': defaultReader
997
1017
  };
998
1018
  })();
999
1019
  async function detect({
@@ -1033,17 +1053,10 @@ async function detect({
1033
1053
  agent = 'npm';
1034
1054
  onUnknown?.(pkgManager);
1035
1055
  }
1036
- const agentExecPath = (await _which(agent, {
1037
- nothrow: true
1038
- })) ?? agent;
1056
+ const agentExecPath = await getAgentExecPath(agent);
1057
+ const npmExecPath = agent === 'npm' ? agentExecPath : await getAgentExecPath('npm');
1039
1058
  if (agentVersion === undefined) {
1040
- try {
1041
- agentVersion = _semver$1.coerce(
1042
- // All package managers support the "--version" flag.
1043
- (await _promiseSpawn$3(agentExecPath, ['--version'], {
1044
- cwd
1045
- })).stdout) ?? undefined;
1046
- } catch {}
1059
+ agentVersion = await getAgentVersion(agentExecPath, cwd);
1047
1060
  }
1048
1061
  if (agent === 'yarn/classic' && (agentVersion?.major ?? 0) > 1) {
1049
1062
  agent = 'yarn/berry';
@@ -1092,6 +1105,7 @@ async function detect({
1092
1105
  lockPath,
1093
1106
  lockSrc,
1094
1107
  minimumNodeVersion,
1108
+ npmExecPath,
1095
1109
  pkgJson: editablePkgJson,
1096
1110
  pkgPath,
1097
1111
  supported: targets.browser || targets.node,
@@ -1244,6 +1258,13 @@ const getOverridesDataByAgent = {
1244
1258
  overrides
1245
1259
  };
1246
1260
  },
1261
+ vlt(pkgJson) {
1262
+ const overrides = pkgJson?.overrides ?? {};
1263
+ return {
1264
+ type: 'vlt',
1265
+ overrides
1266
+ };
1267
+ },
1247
1268
  // Yarn resolutions documentation:
1248
1269
  // https://yarnpkg.com/configuration/manifest#resolutions
1249
1270
  'yarn/berry'(pkgJson) {
@@ -1264,7 +1285,7 @@ const getOverridesDataByAgent = {
1264
1285
  }
1265
1286
  };
1266
1287
  const lockIncludesByAgent = (() => {
1267
- const yarn = (lockSrc, name) => {
1288
+ function yarnLockIncludes(lockSrc, name) {
1268
1289
  const escapedName = (0, _regexps.escapeRegExp)(name);
1269
1290
  return new RegExp(
1270
1291
  // Detects the package name in the following cases:
@@ -1273,9 +1294,9 @@ const lockIncludesByAgent = (() => {
1273
1294
  // name@
1274
1295
  // , name@
1275
1296
  `(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
1276
- };
1297
+ }
1277
1298
  return {
1278
- bun: yarn,
1299
+ bun: yarnLockIncludes,
1279
1300
  npm(lockSrc, name) {
1280
1301
  // Detects the package name in the following cases:
1281
1302
  // "name":
@@ -1291,111 +1312,179 @@ const lockIncludesByAgent = (() => {
1291
1312
  // name@
1292
1313
  `(?<=^\\s*)(?:(['/])${escapedName}\\1|${escapedName}(?=[:@]))`, 'm').test(lockSrc);
1293
1314
  },
1294
- 'yarn/berry': yarn,
1295
- 'yarn/classic': yarn
1315
+ vlt(lockSrc, name) {
1316
+ // Detects the package name in the following cases:
1317
+ // "name"
1318
+ return lockSrc.includes(`"${name}"`);
1319
+ },
1320
+ 'yarn/berry': yarnLockIncludes,
1321
+ 'yarn/classic': yarnLockIncludes
1296
1322
  };
1297
1323
  })();
1298
- const updateManifestByAgent = {
1299
- bun(pkgJson, overrides) {
1300
- pkgJson.update({
1301
- [RESOLUTIONS_FIELD_NAME]: overrides
1302
- });
1303
- },
1304
- npm(pkgJson, overrides) {
1324
+ const updateManifestByAgent = (() => {
1325
+ function updateOverrides(pkgJson, overrides) {
1305
1326
  pkgJson.update({
1306
1327
  [OVERRIDES_FIELD_NAME]: overrides
1307
1328
  });
1308
- },
1309
- pnpm(pkgJson, overrides) {
1310
- pkgJson.update({
1311
- pnpm: {
1312
- ...pkgJson.content['pnpm'],
1313
- [OVERRIDES_FIELD_NAME]: overrides
1314
- }
1315
- });
1316
- },
1317
- 'yarn/berry'(pkgJson, overrides) {
1318
- pkgJson.update({
1319
- [RESOLUTIONS_FIELD_NAME]: overrides
1320
- });
1321
- },
1322
- 'yarn/classic'(pkgJson, overrides) {
1329
+ }
1330
+ function updateResolutions(pkgJson, overrides) {
1323
1331
  pkgJson.update({
1324
1332
  [RESOLUTIONS_FIELD_NAME]: overrides
1325
1333
  });
1326
1334
  }
1327
- };
1328
- const lsByAgent = {
1329
- async bun(agentExecPath, cwd, _rootPath) {
1330
- try {
1331
- // Bun does not support filtering by production packages yet.
1332
- // https://github.com/oven-sh/bun/issues/8283
1333
- return (await _promiseSpawn$2(agentExecPath, ['pm', 'ls', '--all'], {
1334
- cwd
1335
- })).stdout;
1336
- } catch {}
1337
- return '';
1338
- },
1339
- async npm(agentExecPath, cwd, rootPath) {
1340
- try {
1341
- let {
1342
- stdout
1343
- } = await _promiseSpawn$2(agentExecPath, ['ls', '--parseable', '--omit', 'dev', '--all'], {
1344
- cwd
1345
- });
1346
- stdout = stdout.trim();
1347
- stdout = stdout.replaceAll(cwd, '');
1348
- stdout = rootPath === cwd ? stdout : stdout.replaceAll(rootPath, '');
1349
- return stdout.replaceAll('\\', '/');
1350
- } catch {}
1351
- return '';
1352
- },
1353
- async pnpm(agentExecPath, cwd, rootPath) {
1354
- try {
1355
- let {
1356
- stdout
1357
- } = await _promiseSpawn$2(agentExecPath, ['ls', '--parseable', '--prod', '--depth', 'Infinity'], {
1358
- cwd
1335
+ return {
1336
+ bun: updateResolutions,
1337
+ npm: updateOverrides,
1338
+ pnpm(pkgJson, overrides) {
1339
+ pkgJson.update({
1340
+ pnpm: {
1341
+ ...pkgJson.content['pnpm'],
1342
+ [OVERRIDES_FIELD_NAME]: overrides
1343
+ }
1359
1344
  });
1360
- stdout = stdout.trim();
1361
- stdout = stdout.replaceAll(cwd, '');
1362
- stdout = rootPath === cwd ? stdout : stdout.replaceAll(rootPath, '');
1363
- return stdout.replaceAll('\\', '/');
1364
- } catch {}
1365
- return '';
1366
- },
1367
- async 'yarn/berry'(agentExecPath, cwd, _rootPath) {
1345
+ },
1346
+ vlt: updateOverrides,
1347
+ 'yarn/berry': updateResolutions,
1348
+ 'yarn/classic': updateResolutions
1349
+ };
1350
+ })();
1351
+ const lsByAgent = (() => {
1352
+ function cleanupQueryStdout(stdout) {
1353
+ if (stdout === '') {
1354
+ return '';
1355
+ }
1356
+ let pkgs;
1368
1357
  try {
1369
- return (
1370
- // Yarn Berry does not support filtering by production packages yet.
1371
- // https://github.com/yarnpkg/berry/issues/5117
1372
- (await _promiseSpawn$2(agentExecPath, ['info', '--recursive', '--name-only'], {
1373
- cwd
1374
- })).stdout.trim()
1375
- );
1358
+ pkgs = JSON.parse(stdout);
1376
1359
  } catch {}
1377
- return '';
1378
- },
1379
- async 'yarn/classic'(agentExecPath, cwd, _rootPath) {
1360
+ if (!Array.isArray(pkgs)) {
1361
+ return '';
1362
+ }
1363
+ const names = new Set();
1364
+ for (const {
1365
+ _id,
1366
+ name,
1367
+ pkgid
1368
+ } of pkgs) {
1369
+ // `npm query` results may not have a "name" property, in which case we
1370
+ // fallback to "_id" and then "pkgid".
1371
+ // `vlt ls --view json` results always have a "name" property.
1372
+ const fallback = _id ?? pkgid ?? '';
1373
+ const resolvedName = name ?? fallback.slice(0, fallback.indexOf('@', 1));
1374
+ if (resolvedName) {
1375
+ names.add(resolvedName);
1376
+ }
1377
+ }
1378
+ return JSON.stringify([...names], null, 2);
1379
+ }
1380
+ function parseableToQueryStdout(stdout) {
1381
+ if (stdout === '') {
1382
+ return '';
1383
+ }
1384
+ // Convert the parseable stdout into a json array of unique names.
1385
+ // The matchAll regexp looks for a forward (posix) or backward (win32) slash
1386
+ // and matches one or more non-slashes until the newline.
1387
+ const names = new Set(stdout.matchAll(/(?<=[/\\])[^/\\]+(?=\n)/g));
1388
+ return JSON.stringify([...names], null, 2);
1389
+ }
1390
+ async function npmQuery(npmExecPath, cwd) {
1391
+ let stdout = '';
1380
1392
  try {
1381
- // However, Yarn Classic does support it.
1382
- // https://github.com/yarnpkg/yarn/releases/tag/v1.0.0
1383
- // > Fix: Excludes dev dependencies from the yarn list output when the
1384
- // environment is production
1385
- return (await _promiseSpawn$2(agentExecPath, ['list', '--prod'], {
1393
+ stdout = (await _promiseSpawn$2(npmExecPath, ['query', ':not(.dev)'], {
1386
1394
  cwd
1387
- })).stdout.trim();
1395
+ })).stdout;
1388
1396
  } catch {}
1389
- return '';
1397
+ return cleanupQueryStdout(stdout);
1390
1398
  }
1391
- };
1392
- const depsIncludesByAgent = {
1393
- bun: (stdout, name) => stdout.includes(` ${name}@`),
1394
- npm: (stdout, name) => stdout.includes(`/${name}\n`),
1395
- pnpm: (stdout, name) => stdout.includes(`/${name}\n`),
1396
- 'yarn/berry': (stdout, name) => stdout.includes(` ${name}@`),
1397
- 'yarn/classic': (stdout, name) => stdout.includes(` ${name}@`)
1398
- };
1399
+ return {
1400
+ async bun(agentExecPath, cwd) {
1401
+ try {
1402
+ // Bun does not support filtering by production packages yet.
1403
+ // https://github.com/oven-sh/bun/issues/8283
1404
+ return (await _promiseSpawn$2(agentExecPath, ['pm', 'ls', '--all'], {
1405
+ cwd
1406
+ })).stdout;
1407
+ } catch {}
1408
+ return '';
1409
+ },
1410
+ async npm(agentExecPath, cwd) {
1411
+ return await npmQuery(agentExecPath, cwd);
1412
+ },
1413
+ async pnpm(agentExecPath, cwd, options) {
1414
+ const {
1415
+ npmExecPath
1416
+ } = {
1417
+ __proto__: null,
1418
+ ...options
1419
+ };
1420
+ if (npmExecPath && npmExecPath !== 'npm') {
1421
+ const result = await npmQuery(npmExecPath, cwd);
1422
+ if (result) {
1423
+ return result;
1424
+ }
1425
+ }
1426
+ let stdout = '';
1427
+ try {
1428
+ stdout = (await _promiseSpawn$2(agentExecPath, ['ls', '--parseable', '--prod', '--depth', 'Infinity'], {
1429
+ cwd
1430
+ })).stdout;
1431
+ } catch {}
1432
+ return parseableToQueryStdout(stdout);
1433
+ },
1434
+ async vlt(agentExecPath, cwd) {
1435
+ let stdout = '';
1436
+ try {
1437
+ stdout = (await _promiseSpawn$2(agentExecPath, ['ls', '--view', 'human', ':not(.dev)'], {
1438
+ cwd
1439
+ })).stdout;
1440
+ } catch {}
1441
+ return cleanupQueryStdout(stdout);
1442
+ },
1443
+ async 'yarn/berry'(agentExecPath, cwd) {
1444
+ try {
1445
+ return (
1446
+ // Yarn Berry does not support filtering by production packages yet.
1447
+ // https://github.com/yarnpkg/berry/issues/5117
1448
+ (await _promiseSpawn$2(agentExecPath, ['info', '--recursive', '--name-only'], {
1449
+ cwd
1450
+ })).stdout.trim()
1451
+ );
1452
+ } catch {}
1453
+ return '';
1454
+ },
1455
+ async 'yarn/classic'(agentExecPath, cwd) {
1456
+ try {
1457
+ // However, Yarn Classic does support it.
1458
+ // https://github.com/yarnpkg/yarn/releases/tag/v1.0.0
1459
+ // > Fix: Excludes dev dependencies from the yarn list output when the
1460
+ // environment is production
1461
+ return (await _promiseSpawn$2(agentExecPath, ['list', '--prod'], {
1462
+ cwd
1463
+ })).stdout.trim();
1464
+ } catch {}
1465
+ return '';
1466
+ }
1467
+ };
1468
+ })();
1469
+ const depsIncludesByAgent = (() => {
1470
+ function matchHumanStdout(stdout, name) {
1471
+ return stdout.includes(` ${name}@`);
1472
+ }
1473
+ function matchQueryStdout(stdout, name) {
1474
+ return stdout.includes(`"${name}"`);
1475
+ }
1476
+ return {
1477
+ bun: matchHumanStdout,
1478
+ npm: matchQueryStdout,
1479
+ pnpm: matchQueryStdout,
1480
+ vlt: matchQueryStdout,
1481
+ 'yarn/berry': matchHumanStdout,
1482
+ 'yarn/classic': matchHumanStdout
1483
+ };
1484
+ })();
1485
+ function createActionMessage(verb, overrideCount, workspaceCount) {
1486
+ return `${verb} ${overrideCount} Socket.dev optimized overrides${workspaceCount ? ` in ${workspaceCount} workspace${workspaceCount > 1 ? 's' : ''}` : ''}`;
1487
+ }
1399
1488
  function getDependencyEntries(pkgJson) {
1400
1489
  const {
1401
1490
  dependencies,
@@ -1419,28 +1508,33 @@ function getDependencyEntries(pkgJson) {
1419
1508
  1: o
1420
1509
  }) => o);
1421
1510
  }
1422
- async function getWorkspaces(agent, pkgPath, pkgJson) {
1423
- if (agent !== 'pnpm') {
1424
- return Array.isArray(pkgJson['workspaces']) ? pkgJson['workspaces'].filter(_strings.isNonEmptyString) : undefined;
1425
- }
1426
- for (const workspacePath of [_nodePath$2.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), _nodePath$2.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
1427
- if ((0, _fs.existsSync)(workspacePath)) {
1428
- let packages;
1429
- try {
1430
- // eslint-disable-next-line no-await-in-loop
1431
- packages = (0, _yaml.parse)(await _promises$2.readFile(workspacePath, 'utf8'))?.packages;
1432
- } catch {}
1433
- if (Array.isArray(packages)) {
1434
- return packages.filter(_strings.isNonEmptyString);
1511
+ async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
1512
+ let workspacePatterns;
1513
+ if (agent === 'pnpm') {
1514
+ for (const workspacePath of [_nodePath$2.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), _nodePath$2.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
1515
+ if ((0, _fs.existsSync)(workspacePath)) {
1516
+ try {
1517
+ workspacePatterns = (0, _yaml.parse)(
1518
+ // eslint-disable-next-line no-await-in-loop
1519
+ await _promises$2.readFile(workspacePath, 'utf8'))?.packages;
1520
+ } catch {}
1521
+ if (workspacePatterns) {
1522
+ break;
1523
+ }
1435
1524
  }
1436
1525
  }
1526
+ } else {
1527
+ workspacePatterns = pkgJson['workspaces'];
1437
1528
  }
1438
- return undefined;
1529
+ return Array.isArray(workspacePatterns) ? workspacePatterns.filter(_strings.isNonEmptyString).map(workspacePatternToGlobPattern) : undefined;
1439
1530
  }
1440
- function workspaceToGlobPattern(workspace) {
1531
+ function workspacePatternToGlobPattern(workspace) {
1441
1532
  const {
1442
1533
  length
1443
1534
  } = workspace;
1535
+ if (!length) {
1536
+ return '';
1537
+ }
1444
1538
  // If the workspace ends with "/"
1445
1539
  if (workspace.charCodeAt(length - 1) === 47 /*'/'*/) {
1446
1540
  return `${workspace}/*/package.json`;
@@ -1452,21 +1546,29 @@ function workspaceToGlobPattern(workspace) {
1452
1546
  // Things like "packages/a" or "packages/*"
1453
1547
  return `${workspace}/package.json`;
1454
1548
  }
1549
+ function createAddOverridesState(initials) {
1550
+ return {
1551
+ added: new Set(),
1552
+ addedInWorkspaces: new Set(),
1553
+ spinner: undefined,
1554
+ updated: new Set(),
1555
+ updatedInWorkspaces: new Set(),
1556
+ warnedPnpmWorkspaceRequiresNpm: false,
1557
+ ...initials
1558
+ };
1559
+ }
1455
1560
  async function addOverrides({
1456
1561
  agent,
1457
1562
  agentExecPath,
1458
1563
  lockSrc,
1459
1564
  manifestEntries,
1565
+ npmExecPath,
1460
1566
  pin,
1461
1567
  pkgJson: editablePkgJson,
1462
1568
  pkgPath,
1463
1569
  prod,
1464
1570
  rootPath
1465
- }, state = {
1466
- added: new Set(),
1467
- spinner: undefined,
1468
- updated: new Set()
1469
- }) {
1571
+ }, state = createAddOverridesState()) {
1470
1572
  if (editablePkgJson === undefined) {
1471
1573
  editablePkgJson = await _packageJson.load(pkgPath);
1472
1574
  }
@@ -1476,19 +1578,26 @@ async function addOverrides({
1476
1578
  const pkgJson = editablePkgJson.content;
1477
1579
  const isRoot = pkgPath === rootPath;
1478
1580
  const isLockScanned = isRoot && !prod;
1479
- const thingToScan = isLockScanned ? lockSrc : await lsByAgent[agent](agentExecPath, pkgPath, rootPath);
1581
+ const workspaceName = _nodePath$2.relative(rootPath, pkgPath);
1582
+ const workspaceGlobs = await getWorkspaceGlobs(agent, pkgPath, pkgJson);
1583
+ const isWorkspace = !!workspaceGlobs;
1584
+ if (isWorkspace && agent === 'pnpm' && npmExecPath === 'npm' && !state.warnedPnpmWorkspaceRequiresNpm) {
1585
+ state.warnedPnpmWorkspaceRequiresNpm = true;
1586
+ console.log(`⚠️ ${COMMAND_TITLE}: pnpm workspace support requires \`npm ls\`, falling back to \`pnpm list\``);
1587
+ }
1588
+ const thingToScan = isLockScanned ? lockSrc : await lsByAgent[agent](agentExecPath, pkgPath, {
1589
+ npmExecPath
1590
+ });
1480
1591
  const thingScanner = isLockScanned ? lockIncludesByAgent[agent] : depsIncludesByAgent[agent];
1481
1592
  const depEntries = getDependencyEntries(pkgJson);
1482
- const workspaces = await getWorkspaces(agent, pkgPath, pkgJson);
1483
- const isWorkspace = !!workspaces;
1484
1593
  const overridesDataObjects = [];
1485
1594
  if (pkgJson['private'] || isWorkspace) {
1486
1595
  overridesDataObjects.push(getOverridesDataByAgent[agent](pkgJson));
1487
1596
  } else {
1488
- overridesDataObjects.push(getOverridesDataByAgent['npm'](pkgJson), getOverridesDataByAgent['yarn/classic'](pkgJson));
1597
+ overridesDataObjects.push(getOverridesDataByAgent.npm(pkgJson), getOverridesDataByAgent['yarn/classic'](pkgJson));
1489
1598
  }
1490
1599
  if (spinner) {
1491
- spinner.text = `Adding overrides${isRoot ? '' : ` to ${_nodePath$2.relative(rootPath, pkgPath)}`}...`;
1600
+ spinner.text = `Adding overrides${workspaceName ? ` to ${workspaceName}` : ''}...`;
1492
1601
  }
1493
1602
  const depAliasMap = new Map();
1494
1603
  // Chunk package names to process them in parallel 3 at a time.
@@ -1517,6 +1626,7 @@ async function addOverrides({
1517
1626
  pkgSpec = `${regSpecStartsLike}^${version}`;
1518
1627
  depObj[origPkgName] = pkgSpec;
1519
1628
  state.added.add(regPkgName);
1629
+ state.addedInWorkspaces.add(workspaceName);
1520
1630
  }
1521
1631
  depAliasMap.set(origPkgName, {
1522
1632
  id: pkgSpec,
@@ -1557,46 +1667,43 @@ async function addOverrides({
1557
1667
  }
1558
1668
  }
1559
1669
  if (newSpec !== oldSpec) {
1670
+ overrides[origPkgName] = newSpec;
1560
1671
  if (overrideExists) {
1561
1672
  state.updated.add(regPkgName);
1673
+ state.updatedInWorkspaces.add(workspaceName);
1562
1674
  } else {
1563
1675
  state.added.add(regPkgName);
1676
+ state.addedInWorkspaces.add(workspaceName);
1564
1677
  }
1565
- overrides[origPkgName] = newSpec;
1566
1678
  }
1567
1679
  }
1568
1680
  });
1569
1681
  });
1570
- if (workspaces) {
1571
- const wsPkgJsonPaths = await (0, _tinyglobby.glob)(workspaces.map(workspaceToGlobPattern), {
1682
+ if (workspaceGlobs) {
1683
+ const workspacePkgJsonPaths = await (0, _tinyglobby.glob)(workspaceGlobs, {
1572
1684
  absolute: true,
1573
1685
  cwd: pkgPath,
1574
1686
  ignore: ['**/node_modules/**', '**/bower_components/**']
1575
1687
  });
1576
1688
  // Chunk package names to process them in parallel 3 at a time.
1577
- await (0, _promises2.pEach)(wsPkgJsonPaths, 3, async wsPkgJsonPath => {
1578
- const {
1579
- added,
1580
- updated
1581
- } = await addOverrides({
1689
+ await (0, _promises2.pEach)(workspacePkgJsonPaths, 3, async workspacePkgJsonPath => {
1690
+ const otherState = await addOverrides({
1582
1691
  agent,
1583
1692
  agentExecPath,
1584
1693
  lockSrc,
1585
1694
  manifestEntries,
1695
+ npmExecPath,
1586
1696
  pin,
1587
- pkgPath: _nodePath$2.dirname(wsPkgJsonPath),
1697
+ pkgPath: _nodePath$2.dirname(workspacePkgJsonPath),
1588
1698
  prod,
1589
1699
  rootPath
1590
- }, {
1591
- added: new Set(),
1592
- spinner,
1593
- updated: new Set()
1594
- });
1595
- for (const regPkgName of added) {
1596
- state.added.add(regPkgName);
1597
- }
1598
- for (const regPkgName of updated) {
1599
- state.updated.add(regPkgName);
1700
+ }, createAddOverridesState({
1701
+ spinner
1702
+ }));
1703
+ for (const key of ['added', 'addedInWorkspaces', 'updated', 'updatedInWorkspaces']) {
1704
+ for (const value of otherState[key]) {
1705
+ state[key].add(value);
1706
+ }
1600
1707
  }
1601
1708
  });
1602
1709
  }
@@ -1680,9 +1787,10 @@ const optimize = optimize$1.optimize = {
1680
1787
  agent,
1681
1788
  agentExecPath,
1682
1789
  agentVersion,
1683
- lockSrc,
1684
1790
  lockPath,
1791
+ lockSrc,
1685
1792
  minimumNodeVersion,
1793
+ npmExecPath,
1686
1794
  pkgJson,
1687
1795
  pkgPath,
1688
1796
  supported
@@ -1696,6 +1804,10 @@ const optimize = optimize$1.optimize = {
1696
1804
  console.log(`✘ ${COMMAND_TITLE}: No supported Node or browser range detected`);
1697
1805
  return;
1698
1806
  }
1807
+ if (agent === 'vlt') {
1808
+ console.log(`✘ ${COMMAND_TITLE}: ${agent} does not support overrides. Soon, though ⚡`);
1809
+ return;
1810
+ }
1699
1811
  const lockName = lockPath ? _nodePath$2.basename(lockPath) : 'lock file';
1700
1812
  if (lockSrc === undefined) {
1701
1813
  console.log(`✘ ${COMMAND_TITLE}: No ${lockName} found`);
@@ -1717,11 +1829,9 @@ const optimize = optimize$1.optimize = {
1717
1829
  console.log(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
1718
1830
  }
1719
1831
  const spinner = (0, _ora$i.default)('Socket optimizing...');
1720
- const state = {
1721
- added: new Set(),
1722
- spinner,
1723
- updated: new Set()
1724
- };
1832
+ const state = createAddOverridesState({
1833
+ spinner
1834
+ });
1725
1835
  spinner.start();
1726
1836
  const nodeRange = `>=${minimumNodeVersion}`;
1727
1837
  const manifestEntries = manifestNpmOverrides.filter(({
@@ -1732,6 +1842,7 @@ const optimize = optimize$1.optimize = {
1732
1842
  agentExecPath,
1733
1843
  lockSrc,
1734
1844
  manifestEntries,
1845
+ npmExecPath,
1735
1846
  pin,
1736
1847
  pkgJson,
1737
1848
  pkgPath,
@@ -1739,13 +1850,15 @@ const optimize = optimize$1.optimize = {
1739
1850
  rootPath: pkgPath
1740
1851
  }, state);
1741
1852
  spinner.stop();
1742
- const pkgJsonChanged = state.added.size > 0 || state.updated.size > 0;
1853
+ const addedCount = state.added.size;
1854
+ const updatedCount = state.updated.size;
1855
+ const pkgJsonChanged = addedCount > 0 || updatedCount > 0;
1743
1856
  if (pkgJsonChanged) {
1744
- if (state.updated.size > 0) {
1745
- console.log(`Updated ${state.updated.size} Socket.dev optimized overrides ${state.added.size ? '.' : '🚀'}`);
1857
+ if (updatedCount > 0) {
1858
+ console.log(`${createActionMessage('Updated', updatedCount, state.updatedInWorkspaces.size)}${addedCount ? '.' : '🚀'}`);
1746
1859
  }
1747
- if (state.added.size > 0) {
1748
- console.log(`Added ${state.added.size} Socket.dev optimized overrides 🚀`);
1860
+ if (addedCount > 0) {
1861
+ console.log(`${createActionMessage('Added', addedCount, state.addedInWorkspaces.size)} 🚀`);
1749
1862
  }
1750
1863
  } else {
1751
1864
  console.log('Congratulations! Already Socket.dev optimized 🎉');
@@ -1759,7 +1872,7 @@ const optimize = optimize$1.optimize = {
1759
1872
  if (isNpm) {
1760
1873
  const wrapperPath = _nodePath$2.join(distPath$1, 'npm-cli.js');
1761
1874
  await _promiseSpawn$2(process.execPath, [wrapperPath, 'install', '--no-audit', '--no-fund'], {
1762
- stdio: 'pipe',
1875
+ stdio: 'ignore',
1763
1876
  env: {
1764
1877
  ...process.env,
1765
1878
  UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: '1'
@@ -1768,7 +1881,7 @@ const optimize = optimize$1.optimize = {
1768
1881
  } else {
1769
1882
  // All package managers support the "install" command.
1770
1883
  await _promiseSpawn$2(agentExecPath, ['install'], {
1771
- stdio: 'pipe'
1884
+ stdio: 'ignore'
1772
1885
  });
1773
1886
  }
1774
1887
  spinner.stop();
@@ -2397,8 +2510,8 @@ async function meowWithSubcommands(subcommands, options) {
2397
2510
  const {
2398
2511
  aliases = {},
2399
2512
  argv,
2400
- name,
2401
2513
  importMeta,
2514
+ name,
2402
2515
  ...additionalOptions
2403
2516
  } = {
2404
2517
  __proto__: null,
@@ -2526,8 +2639,8 @@ function setupCommand$f(name, description, argv, importMeta) {
2526
2639
  return;
2527
2640
  }
2528
2641
  const {
2529
- enable,
2530
- disable
2642
+ disable,
2643
+ enable
2531
2644
  } = cli.flags;
2532
2645
  let showHelp = cli.flags['help'];
2533
2646
  if (!enable && !disable) {
@@ -2774,8 +2887,8 @@ async function setupCommand$e(name, description, argv, importMeta) {
2774
2887
  const debugLog = (0, _misc.createDebugLogger)(false);
2775
2888
  const packagePaths = await (0, _pathResolve.getPackageFilesFullScans)(cwd, cli.input, supportedFiles, debugLog);
2776
2889
  const {
2777
- repo: repoName,
2778
- branch: branchName
2890
+ branch: branchName,
2891
+ repo: repoName
2779
2892
  } = cli.flags;
2780
2893
  if (!repoName || !branchName || !packagePaths.length) {
2781
2894
  showHelp = true;
@@ -2805,14 +2918,14 @@ async function setupCommand$e(name, description, argv, importMeta) {
2805
2918
  async function createFullScan(input, spinner, apiKey) {
2806
2919
  const socketSdk = await (0, _sdk$e.setupSdk)(apiKey);
2807
2920
  const {
2808
- orgSlug,
2809
- repoName,
2810
2921
  branchName,
2811
2922
  commitMessage,
2812
2923
  defaultBranch,
2924
+ orgSlug,
2925
+ packagePaths,
2813
2926
  pendingHead,
2814
- tmp,
2815
- packagePaths
2927
+ repoName,
2928
+ tmp
2816
2929
  } = input;
2817
2930
  const result = await (0, _apiHelpers$e.handleApiCall)(socketSdk.createOrgFullScan(orgSlug, {
2818
2931
  repo: repoName,
@@ -4117,8 +4230,8 @@ function setupCommand$3(name, description, argv, importMeta) {
4117
4230
  });
4118
4231
  const {
4119
4232
  json: outputJson,
4120
- markdown: outputMarkdown,
4121
4233
  limit,
4234
+ markdown: outputMarkdown,
4122
4235
  offset
4123
4236
  } = cli.flags;
4124
4237
  return {
@@ -4588,8 +4701,8 @@ function setupCommand$1(name, description, argv, importMeta) {
4588
4701
  flags
4589
4702
  });
4590
4703
  const {
4591
- before,
4592
- after
4704
+ after,
4705
+ before
4593
4706
  } = cli.flags;
4594
4707
  let showHelp = cli.flags['help'];
4595
4708
  if (!before || !after) {
@@ -4615,10 +4728,10 @@ function setupCommand$1(name, description, argv, importMeta) {
4615
4728
  };
4616
4729
  }
4617
4730
  async function getDiffScan({
4618
- before,
4619
4731
  after,
4620
- orgSlug,
4732
+ before,
4621
4733
  file,
4734
+ orgSlug,
4622
4735
  outputJson
4623
4736
  }, spinner, apiKey) {
4624
4737
  const response = await (0, _apiHelpers$1.queryAPI)(`${orgSlug}/full-scans/diff?before=${before}&after=${after}&preview`, apiKey);
@@ -4764,12 +4877,12 @@ function setupCommand(name, description, argv, importMeta) {
4764
4877
  flags
4765
4878
  });
4766
4879
  const {
4880
+ direction,
4881
+ filter,
4767
4882
  json: outputJson,
4768
4883
  markdown: outputMarkdown,
4769
- perPage: per_page,
4770
4884
  page,
4771
- direction,
4772
- filter
4885
+ perPage: per_page
4773
4886
  } = cli.flags;
4774
4887
  return {
4775
4888
  outputJson,
@@ -4781,11 +4894,11 @@ function setupCommand(name, description, argv, importMeta) {
4781
4894
  };
4782
4895
  }
4783
4896
  async function fetchThreatFeed({
4784
- per_page,
4785
- page,
4786
4897
  direction,
4787
4898
  filter,
4788
- outputJson
4899
+ outputJson,
4900
+ page,
4901
+ per_page
4789
4902
  }, spinner, apiKey) {
4790
4903
  const formattedQueryParams = formatQueryParams({
4791
4904
  per_page,