@socketsecurity/cli 0.14.27 → 0.14.29

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.
Files changed (52) hide show
  1. package/bin/cli.js +9 -0
  2. package/bin/npm-cli.js +9 -0
  3. package/bin/npx-cli.js +9 -0
  4. package/bin/shadow/module-sync/npm +3 -0
  5. package/bin/shadow/module-sync/npx +3 -0
  6. package/bin/shadow/require/npm +3 -0
  7. package/bin/shadow/require/npx +3 -0
  8. package/dist/module-sync/cli.d.ts.map +1 -0
  9. package/dist/module-sync/cli.js +5256 -0
  10. package/dist/module-sync/constants.d.ts +15 -0
  11. package/dist/module-sync/constants.js +62 -0
  12. package/dist/module-sync/npm-cli.js +85 -0
  13. package/dist/{npm-injection.js → module-sync/npm-injection.js} +78 -92
  14. package/dist/module-sync/npx-cli.js +61 -0
  15. package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
  16. package/dist/module-sync/sdk.js +253 -0
  17. package/dist/require/cli.d.ts +3 -0
  18. package/dist/require/cli.d.ts.map +1 -0
  19. package/dist/{cli.js → require/cli.js} +72 -76
  20. package/dist/require/color-or-markdown.d.ts +23 -0
  21. package/dist/require/constants.d.ts +15 -0
  22. package/dist/require/constants.js +57 -0
  23. package/dist/require/errors.d.ts +7 -0
  24. package/dist/require/link.d.ts +2 -0
  25. package/dist/require/link.js +45 -0
  26. package/dist/require/npm-cli.d.ts +2 -0
  27. package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
  28. package/dist/require/npm-injection.d.ts +1 -0
  29. package/dist/require/npm-injection.js +1830 -0
  30. package/dist/require/npx-cli.d.ts +2 -0
  31. package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
  32. package/dist/require/path-resolve.d.ts +8 -0
  33. package/dist/require/path-resolve.js +183 -0
  34. package/dist/require/sdk.d.ts +9 -0
  35. package/dist/{sdk.js → require/sdk.js} +16 -36
  36. package/dist/require/settings.d.ts +9 -0
  37. package/dist/{vendor.js → require/vendor.js} +126 -13
  38. package/package.json +68 -36
  39. package/bin/npm +0 -2
  40. package/bin/npx +0 -2
  41. package/dist/cli.d.ts.map +0 -1
  42. /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
  43. /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
  44. /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
  45. /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
  46. /package/dist/{link.js → module-sync/link.js} +0 -0
  47. /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
  48. /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
  49. /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
  50. /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
  51. /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
  52. /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
@@ -2,20 +2,21 @@
2
2
  'use strict';
3
3
 
4
4
  var vendor = require('./vendor.js');
5
- var require$$1 = require('node:path');
6
5
  var require$$8$2 = require('node:url');
7
6
  var require$$1$2 = require('yoctocolors-cjs');
8
- var require$$5$1 = require('pony-cause');
7
+ var require$$4$1 = require('pony-cause');
9
8
  var require$$0 = require('node:fs');
9
+ var require$$1 = require('node:path');
10
10
  var require$$1$1 = require('@npmcli/promise-spawn');
11
11
  var require$$4 = require('yargs-parser');
12
12
  var require$$5 = require('@socketsecurity/registry/lib/words');
13
+ var constants = require('./constants.js');
13
14
  var require$$3 = require('@socketregistry/yocto-spinner');
14
15
  var sdk = require('./sdk.js');
15
16
  var require$$1$3 = require('@inquirer/prompts');
16
17
  var require$$1$4 = require('node:fs/promises');
17
- var require$$5$3 = require('npm-package-arg');
18
- var require$$3$1 = require('semver');
18
+ var require$$5$2 = require('npm-package-arg');
19
+ var require$$4$2 = require('semver');
19
20
  var require$$8$1 = require('tinyglobby');
20
21
  var require$$9$1 = require('yaml');
21
22
  var require$$10 = require('@socketsecurity/registry');
@@ -25,11 +26,11 @@ var require$$13 = require('@socketsecurity/registry/lib/promises');
25
26
  var require$$14 = require('@socketsecurity/registry/lib/regexps');
26
27
  var require$$9 = require('@socketsecurity/registry/lib/strings');
27
28
  var require$$2 = require('browserslist');
28
- var require$$4$1 = require('which');
29
- var require$$5$2 = require('@socketregistry/hyrious__bun.lockb');
30
- var require$$6 = require('@socketsecurity/registry/lib/constants');
29
+ var require$$4$3 = require('which');
30
+ var require$$5$1 = require('@socketregistry/hyrious__bun.lockb');
31
+ var require$$3$1 = require('@socketsecurity/registry/lib/constants');
31
32
  var require$$2$1 = require('@apideck/better-ajv-errors');
32
- var require$$6$1 = require('@socketsecurity/config');
33
+ var require$$6 = require('@socketsecurity/config');
33
34
  var pathResolve = require('./path-resolve.js');
34
35
  var require$$1$5 = require('node:os');
35
36
  var require$$3$2 = require('node:readline');
@@ -38,14 +39,14 @@ var require$$2$2 = require('node:readline/promises');
38
39
  var require$$2$3 = require('chalk-table');
39
40
  var require$$2$4 = require('blessed/lib/widgets/screen');
40
41
  var require$$3$3 = require('blessed-contrib/lib/widget/charts/bar');
41
- var require$$4$2 = require('blessed-contrib/lib/layout/grid');
42
- var require$$5$4 = require('blessed-contrib/lib/widget/charts/line');
42
+ var require$$4$4 = require('blessed-contrib/lib/layout/grid');
43
+ var require$$5$3 = require('blessed-contrib/lib/widget/charts/line');
43
44
  var require$$0$2 = require('node:util');
44
45
  var require$$2$5 = require('blessed-contrib/lib/widget/table');
45
46
 
46
- var cli$1 = {};
47
+ var cli$2 = {};
47
48
 
48
- var cli = {};
49
+ var cli$1 = {};
49
50
 
50
51
  var commands = {};
51
52
 
@@ -56,19 +57,15 @@ Object.defineProperty(cdxgen, "__esModule", {
56
57
  });
57
58
  cdxgen.cdxgen = void 0;
58
59
  var _nodeFs$3 = require$$0;
59
- var _nodePath$7 = require$$1;
60
+ var _nodePath$6 = require$$1;
60
61
  var _promiseSpawn$6 = require$$1$1;
61
62
  var _yoctocolorsCjs$j = require$$1$2;
62
63
  var _yargsParser = require$$4;
63
64
  var _words$1 = require$$5;
64
- const distPath$4 = __dirname;
65
+ var _constants$6 = constants.constants;
65
66
  const {
66
67
  execPath
67
68
  } = process;
68
- const rootPath$1 = _nodePath$7.resolve(distPath$4, '..');
69
- const binPath = _nodePath$7.join(rootPath$1, 'node_modules/.bin');
70
- const cdxgenBinPath = _nodePath$7.join(binPath, 'cdxgen');
71
- const synpBinPath = _nodePath$7.join(binPath, 'synp');
72
69
  const {
73
70
  SBOM_SIGN_ALGORITHM,
74
71
  // Algorithm. Example: RS512
@@ -78,7 +75,7 @@ const {
78
75
  } = process.env;
79
76
  const toLower = arg => arg.toLowerCase();
80
77
  const arrayToLower = arg => arg.map(toLower);
81
- const nodejsPlatformTypes = ['javascript', 'js', 'nodejs', 'npm', 'pnpm', 'ts', 'tsx', 'typescript'];
78
+ const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', 'npm', 'pnpm', 'ts', 'tsx', 'typescript']);
82
79
  const yargsConfig = {
83
80
  configuration: {
84
81
  'camel-case-expansion': false,
@@ -187,14 +184,14 @@ cdxgen.cdxgen = {
187
184
  return;
188
185
  }
189
186
  let cleanupPackageLock = false;
190
- if (yargv.type !== 'yarn' && nodejsPlatformTypes.includes(yargv.type) && (0, _nodeFs$3.existsSync)('./yarn.lock')) {
187
+ if (yargv.type !== 'yarn' && nodejsPlatformTypes.has(yargv.type) && (0, _nodeFs$3.existsSync)('./yarn.lock')) {
191
188
  if ((0, _nodeFs$3.existsSync)('./package-lock.json')) {
192
189
  yargv.type = 'npm';
193
190
  } else {
194
191
  // Use synp to create a package-lock.json from the yarn.lock,
195
192
  // based on the node_modules folder, for a more accurate SBOM.
196
193
  try {
197
- await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(synpBinPath), '--source-file', './yarn.lock'], {
194
+ await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(_constants$6.synpBinPath), '--source-file', './yarn.lock'], {
198
195
  shell: true
199
196
  });
200
197
  yargv.type = 'npm';
@@ -205,7 +202,7 @@ cdxgen.cdxgen = {
205
202
  if (yargv.output === undefined) {
206
203
  yargv.output = 'socket-cdx.json';
207
204
  }
208
- await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(cdxgenBinPath), ...argvToArray(yargv)], {
205
+ await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(_constants$6.cdxgenBinPath), ...argvToArray(yargv)], {
209
206
  env: {
210
207
  NODE_ENV: '',
211
208
  SBOM_SIGN_ALGORITHM,
@@ -220,7 +217,7 @@ cdxgen.cdxgen = {
220
217
  await _nodeFs$3.promises.unlink('./package-lock.json');
221
218
  } catch {}
222
219
  }
223
- const fullOutputPath = _nodePath$7.join(process.cwd(), yargv.output);
220
+ const fullOutputPath = _nodePath$6.join(process.cwd(), yargv.output);
224
221
  if ((0, _nodeFs$3.existsSync)(fullOutputPath)) {
225
222
  console.log(_yoctocolorsCjs$j.cyanBright(`${yargv.output} created!`));
226
223
  }
@@ -292,9 +289,9 @@ apiHelpers.handleApiCall = handleApiCall;
292
289
  apiHelpers.handleUnsuccessfulApiResponse = handleUnsuccessfulApiResponse;
293
290
  apiHelpers.queryAPI = queryAPI;
294
291
  var _yoctocolorsCjs$i = require$$1$2;
295
- var _ponyCause$4 = require$$5$1;
292
+ var _ponyCause$4 = require$$4$1;
296
293
  var _errors$l = sdk.errors;
297
- var _constants$1 = sdk.constants;
294
+ var _constants$5 = constants.constants;
298
295
  function handleUnsuccessfulApiResponse(_name, result, spinner) {
299
296
  const resultError = 'error' in result && result.error && typeof result.error === 'object' ? result.error : {};
300
297
  const message = 'message' in resultError && typeof resultError.message === 'string' ? resultError.message : 'No error message returned';
@@ -324,7 +321,7 @@ async function handleAPIError(code) {
324
321
  }
325
322
  }
326
323
  async function queryAPI(path, apiKey) {
327
- return await fetch(`${_constants$1.API_V0_URL}/${path}`, {
324
+ return await fetch(`${_constants$5.API_V0_URL}/${path}`, {
328
325
  method: 'GET',
329
326
  headers: {
330
327
  Authorization: 'Basic ' + btoa(`${apiKey}:${apiKey}`)
@@ -813,16 +810,16 @@ Object.defineProperty(npm, "__esModule", {
813
810
  value: true
814
811
  });
815
812
  npm.npm = void 0;
816
- var _nodePath$6 = require$$1;
813
+ var _nodePath$5 = require$$1;
817
814
  var _promiseSpawn$5 = require$$1$1;
818
- const distPath$3 = __dirname;
815
+ var _constants$4 = constants.constants;
819
816
  const description$5 = 'npm wrapper functionality';
820
817
  npm.npm = {
821
818
  description: description$5,
822
819
  async run(argv, _importMeta, _ctx) {
823
- const wrapperPath = _nodePath$6.join(distPath$3, 'npm-cli.js');
820
+ const wrapperPath = _nodePath$5.join(_constants$4.distPath, 'npm-cli.js');
824
821
  process.exitCode = 1;
825
- const spawnPromise = _promiseSpawn$5(process.execPath, [wrapperPath, ...argv], {
822
+ const spawnPromise = _promiseSpawn$5(process.execPath, ['--disable-warning', 'ExperimentalWarning', wrapperPath, ...argv], {
826
823
  stdio: 'inherit'
827
824
  });
828
825
  spawnPromise.process.on('exit', (code, signal) => {
@@ -842,16 +839,16 @@ Object.defineProperty(npx, "__esModule", {
842
839
  value: true
843
840
  });
844
841
  npx.npx = void 0;
845
- var _nodePath$5 = require$$1;
842
+ var _nodePath$4 = require$$1;
846
843
  var _promiseSpawn$4 = require$$1$1;
847
- const distPath$2 = __dirname;
844
+ var _constants$3 = constants.constants;
848
845
  const description$4 = 'npx wrapper functionality';
849
846
  npx.npx = {
850
847
  description: description$4,
851
848
  async run(argv, _importMeta, _ctx) {
852
- const wrapperPath = _nodePath$5.join(distPath$2, 'npx-cli.js');
849
+ const wrapperPath = _nodePath$4.join(_constants$3.distPath, 'npx-cli.js');
853
850
  process.exitCode = 1;
854
- const spawnPromise = _promiseSpawn$4(process.execPath, [wrapperPath, ...argv], {
851
+ const spawnPromise = _promiseSpawn$4(process.execPath, ['--disable-warning', 'ExperimentalWarning', wrapperPath, ...argv], {
855
852
  stdio: 'inherit'
856
853
  });
857
854
  spawnPromise.process.on('exit', (code, signal) => {
@@ -877,7 +874,7 @@ fs.findUp = findUp;
877
874
  fs.readFileBinary = readFileBinary;
878
875
  fs.readFileUtf8 = readFileUtf8;
879
876
  var _nodeFs$2 = require$$0;
880
- var _nodePath$4 = require$$1;
877
+ var _nodePath$3 = require$$1;
881
878
  function existsSync(filepath) {
882
879
  try {
883
880
  return filepath ? (0, _nodeFs$2.existsSync)(filepath) : false;
@@ -887,14 +884,14 @@ function existsSync(filepath) {
887
884
  async function findUp(name, {
888
885
  cwd = process.cwd()
889
886
  }) {
890
- let dir = _nodePath$4.resolve(cwd);
887
+ let dir = _nodePath$3.resolve(cwd);
891
888
  const {
892
889
  root
893
- } = _nodePath$4.parse(dir);
890
+ } = _nodePath$3.parse(dir);
894
891
  const names = [name].flat();
895
892
  while (dir && dir !== root) {
896
893
  for (const name of names) {
897
- const filePath = _nodePath$4.join(dir, name);
894
+ const filePath = _nodePath$3.join(dir, name);
898
895
  try {
899
896
  // eslint-disable-next-line no-await-in-loop
900
897
  const stats = await _nodeFs$2.promises.stat(filePath);
@@ -903,7 +900,7 @@ async function findUp(name, {
903
900
  }
904
901
  } catch {}
905
902
  }
906
- dir = _nodePath$4.dirname(dir);
903
+ dir = _nodePath$3.dirname(dir);
907
904
  }
908
905
  return undefined;
909
906
  }
@@ -927,13 +924,13 @@ Object.defineProperty(packageManagerDetector, "__esModule", {
927
924
  });
928
925
  packageManagerDetector.AGENTS = void 0;
929
926
  packageManagerDetector.detect = detect;
930
- var _nodePath$3 = require$$1;
927
+ var _nodePath$2 = require$$1;
931
928
  var _promiseSpawn$3 = require$$1$1;
932
929
  var _browserslist = require$$2;
933
- var _semver$1 = require$$3$1;
934
- var _which = require$$4$1;
935
- var _hyrious__bun = require$$5$2;
936
- var _constants = require$$6;
930
+ var _semver$1 = require$$4$2;
931
+ var _which = require$$4$3;
932
+ var _hyrious__bun = require$$5$1;
933
+ var _constants$2 = require$$3$1;
937
934
  var _objects$2 = require$$7;
938
935
  var _packages$1 = require$$8;
939
936
  var _strings$1 = require$$9;
@@ -1021,10 +1018,10 @@ async function detect({
1021
1018
  cwd
1022
1019
  });
1023
1020
  const isHiddenLockFile = lockPath?.endsWith('.package-lock.json') ?? false;
1024
- const pkgJsonPath = lockPath ? _nodePath$3.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await (0, _fs$1.findUp)('package.json', {
1021
+ const pkgJsonPath = lockPath ? _nodePath$2.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await (0, _fs$1.findUp)('package.json', {
1025
1022
  cwd
1026
1023
  });
1027
- const pkgPath = (0, _fs$1.existsSync)(pkgJsonPath) ? _nodePath$3.dirname(pkgJsonPath) : undefined;
1024
+ const pkgPath = (0, _fs$1.existsSync)(pkgJsonPath) ? _nodePath$2.dirname(pkgJsonPath) : undefined;
1028
1025
  const editablePkgJson = pkgPath ? await (0, _packages$1.readPackageJson)(pkgPath, {
1029
1026
  editable: true
1030
1027
  }) : undefined;
@@ -1046,7 +1043,7 @@ async function detect({
1046
1043
  }
1047
1044
  }
1048
1045
  if (agent === undefined && !isHiddenLockFile && typeof pkgJsonPath === 'string' && typeof lockPath === 'string') {
1049
- agent = LOCKS[_nodePath$3.basename(lockPath)];
1046
+ agent = LOCKS[_nodePath$2.basename(lockPath)];
1050
1047
  }
1051
1048
  if (agent === undefined) {
1052
1049
  agent = 'npm';
@@ -1066,7 +1063,7 @@ async function detect({
1066
1063
  };
1067
1064
  let lockSrc;
1068
1065
  // Lazily access constants.maintainedNodeVersions.
1069
- let minimumNodeVersion = _constants.maintainedNodeVersions.previous;
1066
+ let minimumNodeVersion = _constants$2.maintainedNodeVersions.previous;
1070
1067
  if (pkgJson) {
1071
1068
  const browserField = pkgJson.browser;
1072
1069
  if ((0, _strings$1.isNonEmptyString)(browserField) || (0, _objects$2.isObjectObject)(browserField)) {
@@ -1094,7 +1091,7 @@ async function detect({
1094
1091
  }
1095
1092
  }
1096
1093
  // Lazily access constants.maintainedNodeVersions.
1097
- targets.node = _constants.maintainedNodeVersions.some(v => _semver$1.satisfies(v, `>=${minimumNodeVersion}`));
1094
+ targets.node = _constants$2.maintainedNodeVersions.some(v => _semver$1.satisfies(v, `>=${minimumNodeVersion}`));
1098
1095
  lockSrc = typeof lockPath === 'string' ? await readLockFileByAgent[agent](lockPath, agentExecPath) : undefined;
1099
1096
  } else {
1100
1097
  lockPath = undefined;
@@ -1120,12 +1117,12 @@ Object.defineProperty(optimize$1, "__esModule", {
1120
1117
  });
1121
1118
  optimize$1.optimize = void 0;
1122
1119
  var _promises$2 = require$$1$4;
1123
- var _nodePath$2 = require$$1;
1120
+ var _nodePath$1 = require$$1;
1124
1121
  var _promiseSpawn$2 = require$$1$1;
1125
1122
  var _meow$m = _interopRequireDefault$n(vendor.build);
1126
- var _npmPackageArg = require$$5$3;
1123
+ var _npmPackageArg = require$$5$2;
1127
1124
  var _yoctoSpinner$i = require$$3;
1128
- var _semver = require$$3$1;
1125
+ var _semver = require$$4$2;
1129
1126
  var _tinyglobby = require$$8$1;
1130
1127
  var _yaml = require$$9$1;
1131
1128
  var _registry = require$$10;
@@ -1135,6 +1132,7 @@ var _promises2 = require$$13;
1135
1132
  var _regexps = require$$14;
1136
1133
  var _strings = require$$9;
1137
1134
  var _words = require$$5;
1135
+ var _constants$1 = constants.constants;
1138
1136
  var _flags$j = flags$1;
1139
1137
  var _formatting$k = formatting;
1140
1138
  var _fs = fs;
@@ -1144,7 +1142,6 @@ const OVERRIDES_FIELD_NAME = 'overrides';
1144
1142
  const PNPM_FIELD_NAME = 'pnpm';
1145
1143
  const PNPM_WORKSPACE = 'pnpm-workspace';
1146
1144
  const RESOLUTIONS_FIELD_NAME = 'resolutions';
1147
- const distPath$1 = __dirname;
1148
1145
  const manifestNpmOverrides = (0, _registry.getManifestData)('npm');
1149
1146
  const getOverridesDataByAgent = {
1150
1147
  bun(pkgJson) {
@@ -1504,7 +1501,7 @@ function getDependencyEntries(pkgJson) {
1504
1501
  async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
1505
1502
  let workspacePatterns;
1506
1503
  if (agent === 'pnpm') {
1507
- for (const workspacePath of [_nodePath$2.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), _nodePath$2.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
1504
+ for (const workspacePath of [_nodePath$1.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), _nodePath$1.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
1508
1505
  if ((0, _fs.existsSync)(workspacePath)) {
1509
1506
  try {
1510
1507
  workspacePatterns = (0, _yaml.parse)(
@@ -1575,7 +1572,7 @@ async function addOverrides({
1575
1572
  } = editablePkgJson;
1576
1573
  const isRoot = pkgPath === rootPath;
1577
1574
  const isLockScanned = isRoot && !prod;
1578
- const workspaceName = _nodePath$2.relative(rootPath, pkgPath);
1575
+ const workspaceName = _nodePath$1.relative(rootPath, pkgPath);
1579
1576
  const workspaceGlobs = await getWorkspaceGlobs(agent, pkgPath, pkgJson);
1580
1577
  const isWorkspace = !!workspaceGlobs;
1581
1578
  if (isWorkspace && agent === 'pnpm' && npmExecPath === 'npm' && !state.warnedPnpmWorkspaceRequiresNpm) {
@@ -1694,7 +1691,7 @@ async function addOverrides({
1694
1691
  manifestEntries,
1695
1692
  npmExecPath,
1696
1693
  pin,
1697
- pkgPath: _nodePath$2.dirname(workspacePkgJsonPath),
1694
+ pkgPath: _nodePath$1.dirname(workspacePkgJsonPath),
1698
1695
  prod,
1699
1696
  rootPath
1700
1697
  }, createAddOverridesState({
@@ -1758,7 +1755,7 @@ const optimize = optimize$1.optimize = {
1758
1755
  console.error(`✖️ ${COMMAND_TITLE}: ${agent} does not support overrides. Soon, though ⚡`);
1759
1756
  return;
1760
1757
  }
1761
- const lockName = lockPath ? _nodePath$2.basename(lockPath) : 'lock file';
1758
+ const lockName = lockPath ? _nodePath$1.basename(lockPath) : 'lock file';
1762
1759
  if (lockSrc === undefined) {
1763
1760
  console.error(`✖️ ${COMMAND_TITLE}: No ${lockName} found`);
1764
1761
  return;
@@ -1775,7 +1772,7 @@ const optimize = optimize$1.optimize = {
1775
1772
  console.error(`✖️ ${COMMAND_TITLE}: --prod not supported for ${agent}${agentVersion ? `@${agentVersion.toString()}` : ''}`);
1776
1773
  return;
1777
1774
  }
1778
- if (lockPath && _nodePath$2.relative(cwd, lockPath).startsWith('.')) {
1775
+ if (lockPath && _nodePath$1.relative(cwd, lockPath).startsWith('.')) {
1779
1776
  console.warn(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
1780
1777
  }
1781
1778
  const spinner = _yoctoSpinner$i({
@@ -1822,7 +1819,7 @@ const optimize = optimize$1.optimize = {
1822
1819
  spinner.start(`Updating ${lockName}...`);
1823
1820
  try {
1824
1821
  if (isNpm) {
1825
- const wrapperPath = _nodePath$2.join(distPath$1, 'npm-cli.js');
1822
+ const wrapperPath = _nodePath$1.join(_constants$1.distPath, 'npm-cli.js');
1826
1823
  await _promiseSpawn$2(process.execPath, [wrapperPath, 'install', '--no-audit', '--no-fund'], {
1827
1824
  stdio: 'ignore',
1828
1825
  env: {
@@ -2089,7 +2086,7 @@ view$3.view = void 0;
2089
2086
  var _yoctocolorsCjs$f = require$$1$2;
2090
2087
  var _meow$i = _interopRequireDefault$j(vendor.build);
2091
2088
  var _yoctoSpinner$g = require$$3;
2092
- var _ponyCause$3 = require$$5$1;
2089
+ var _ponyCause$3 = require$$4$1;
2093
2090
  var _flags$g = flags$1;
2094
2091
  var _apiHelpers$g = apiHelpers;
2095
2092
  var _colorOrMarkdown$2 = sdk.colorOrMarkdown;
@@ -2229,12 +2226,12 @@ Object.defineProperty(create$5, "__esModule", {
2229
2226
  value: true
2230
2227
  });
2231
2228
  create$5.create = void 0;
2232
- var _nodePath$1 = require$$1;
2229
+ var _nodePath = require$$1;
2233
2230
  var _betterAjvErrors = require$$2$1;
2234
2231
  var _meow$h = _interopRequireDefault$i(vendor.build);
2235
2232
  var _yoctoSpinner$f = require$$3;
2236
- var _ponyCause$2 = require$$5$1;
2237
- var _config = require$$6$1;
2233
+ var _ponyCause$2 = require$$4$1;
2234
+ var _config = require$$6;
2238
2235
  var _view$2 = view$3;
2239
2236
  var _flags$f = flags$1;
2240
2237
  var _apiHelpers$f = apiHelpers;
@@ -2371,7 +2368,7 @@ async function setupCommand$g(name, description, argv, importMeta) {
2371
2368
 
2372
2369
  // TODO: Allow setting a custom cwd and/or configFile path?
2373
2370
  const cwd = process.cwd();
2374
- const absoluteConfigPath = _nodePath$1.join(cwd, 'socket.yml');
2371
+ const absoluteConfigPath = _nodePath.join(cwd, 'socket.yml');
2375
2372
  const config = await (0, _config.readSocketConfig)(absoluteConfigPath).catch(cause => {
2376
2373
  if (cause && typeof cause === 'object' && cause instanceof _config.SocketValidationError) {
2377
2374
  // Inspired by workbox-build:
@@ -2714,7 +2711,7 @@ var _yoctocolorsCjs$e = require$$1$2;
2714
2711
  var _meow$e = _interopRequireDefault$f(vendor.build);
2715
2712
  var _open = _interopRequireDefault$f(vendor.open);
2716
2713
  var _yoctoSpinner$e = require$$3;
2717
- var _ponyCause$1 = require$$5$1;
2714
+ var _ponyCause$1 = require$$4$1;
2718
2715
  var _apiHelpers$e = apiHelpers;
2719
2716
  var _errors$f = sdk.errors;
2720
2717
  var _formatting$d = formatting;
@@ -4269,8 +4266,8 @@ analytics$1.analytics = void 0;
4269
4266
  var _promises = require$$1$4;
4270
4267
  var _screen$1 = require$$2$4;
4271
4268
  var _bar = require$$3$3;
4272
- var _grid = require$$4$2;
4273
- var _line = require$$5$4;
4269
+ var _grid = require$$4$4;
4270
+ var _line = require$$5$3;
4274
4271
  var _meow$2 = _interopRequireDefault$3(vendor.build);
4275
4272
  var _yoctocolorsCjs$2 = require$$1$2;
4276
4273
  var _yoctoSpinner$2 = require$$3;
@@ -5155,19 +5152,15 @@ const getMinDiff = (start, end) => Math.floor((end - start) / 60000);
5155
5152
 
5156
5153
  var _interopRequireWildcard = vendor.interopRequireWildcard.default;
5157
5154
  var _interopRequireDefault = vendor.interopRequireDefault.default;
5158
- var _nodePath = require$$1;
5159
5155
  var _nodeUrl = require$$8$2;
5160
5156
  var _yoctocolorsCjs = require$$1$2;
5161
- var _ponyCause = require$$5$1;
5157
+ var _ponyCause = require$$4$1;
5162
5158
  var _tinyUpdater = _interopRequireDefault(vendor.dist);
5163
5159
  var cliCommands = _interopRequireWildcard(commands, true);
5160
+ var _constants = constants.constants;
5164
5161
  var _colorOrMarkdown = sdk.colorOrMarkdown;
5165
5162
  var _errors = sdk.errors;
5166
5163
  var _meowWithSubcommands = meowWithSubcommands$1;
5167
- const distPath = __dirname;
5168
- const rootPath = _nodePath.resolve(distPath, '..');
5169
- const rootPkgJsonPath = _nodePath.join(rootPath, 'package.json');
5170
- const rootPkgJson = require(rootPkgJsonPath);
5171
5164
  const formattedCliCommands = Object.fromEntries(Object.entries(cliCommands).map(entry => {
5172
5165
  const key = entry[0];
5173
5166
  entry[0] = camelToHyphen(key);
@@ -5179,6 +5172,7 @@ function camelToHyphen(str) {
5179
5172
 
5180
5173
  // TODO: Add autocompletion using https://socket.dev/npm/package/omelette
5181
5174
  void (async () => {
5175
+ const rootPkgJson = require(_constants.rootPkgJsonPath);
5182
5176
  await (0, _tinyUpdater.default)({
5183
5177
  name: rootPkgJson.name,
5184
5178
  version: rootPkgJson.version,
@@ -5237,7 +5231,7 @@ void (async () => {
5237
5231
  return _cli.default;
5238
5232
  }
5239
5233
  });
5240
- var _cli = _interopRequireWildcard(cli, true);
5234
+ var _cli = _interopRequireWildcard(cli$1, true);
5241
5235
  Object.keys(_cli).forEach(function (key) {
5242
5236
  if (key === "default" || key === "__esModule") return;
5243
5237
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -5249,6 +5243,8 @@ void (async () => {
5249
5243
  }
5250
5244
  });
5251
5245
  });
5252
- } (cli$1));
5246
+ } (cli$2));
5247
+
5248
+ var cli = /*@__PURE__*/vendor.getDefaultExportFromCjs(cli$2);
5253
5249
 
5254
- module.exports = cli$1;
5250
+ module.exports = cli;
@@ -0,0 +1,23 @@
1
+ declare const logSymbols: {
2
+ __proto__: null;
3
+ info: string;
4
+ success: string;
5
+ warning: string;
6
+ error: string;
7
+ };
8
+ declare class ColorOrMarkdown {
9
+ useMarkdown: boolean;
10
+ constructor(useMarkdown: boolean);
11
+ header(text: string, level?: number): string;
12
+ bold(text: string): string;
13
+ italic(text: string): string;
14
+ hyperlink(text: string, url: string | undefined, { fallback, fallbackToUrl }?: {
15
+ fallback?: boolean;
16
+ fallbackToUrl?: boolean;
17
+ }): string;
18
+ list(items: string[]): string;
19
+ get logSymbols(): typeof logSymbols;
20
+ indent(text: string, level?: number): string;
21
+ json(value: unknown): string;
22
+ }
23
+ export { logSymbols, ColorOrMarkdown };
@@ -0,0 +1,15 @@
1
+ declare const API_V0_URL = "https://api.socket.dev/v0";
2
+ declare const ENV: Readonly<{
3
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
4
+ }>;
5
+ declare const SUPPORTS_SYNC_ESM: boolean;
6
+ declare const rootPath: string;
7
+ declare const rootDistPath: string;
8
+ declare const rootBinPath: string;
9
+ declare const rootPkgJsonPath: string;
10
+ declare const nmBinPath: string;
11
+ declare const cdxgenBinPath: string;
12
+ declare const distPath: string;
13
+ declare const shadowBinPath: string;
14
+ declare const synpBinPath: string;
15
+ export { API_V0_URL, ENV, SUPPORTS_SYNC_ESM, rootPath, rootDistPath, rootBinPath, rootPkgJsonPath, nmBinPath, cdxgenBinPath, distPath, shadowBinPath, synpBinPath };
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('node:fs');
4
+ var require$$1 = require('node:path');
5
+ var require$$2 = require('@socketsecurity/registry/lib/env');
6
+ var require$$3 = require('@socketsecurity/registry/lib/constants');
7
+ var require$$4 = require('semver');
8
+
9
+ var constants = {};
10
+
11
+ Object.defineProperty(constants, "__esModule", {
12
+ value: true
13
+ });
14
+ constants.synpBinPath = constants.shadowBinPath = constants.rootPkgJsonPath = constants.rootPath = constants.rootDistPath = constants.rootBinPath = constants.nmBinPath = constants.distPath = constants.cdxgenBinPath = constants.SUPPORTS_SYNC_ESM = constants.ENV = constants.API_V0_URL = void 0;
15
+ var _nodeFs = require$$0;
16
+ var _nodePath = require$$1;
17
+ var _env = require$$2;
18
+ var _constants = require$$3;
19
+ var _semver = require$$4;
20
+ const {
21
+ PACKAGE_JSON
22
+ } = _constants;
23
+ constants.API_V0_URL = 'https://api.socket.dev/v0';
24
+ constants.ENV = Object.freeze({
25
+ // Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
26
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: (0, _env.envAsBoolean)(process.env['UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'])
27
+ });
28
+ const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
29
+ const rootPath = constants.rootPath = (() => {
30
+ let oldPath;
31
+ let currPath = (0, _nodeFs.realpathSync)(__dirname);
32
+ while (currPath !== oldPath) {
33
+ const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
34
+ if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
35
+ try {
36
+ // @socketsecurity/cli is replaced by .config/rollup.base.config.mjs
37
+ // with either 'socket' or '@socketsecurity/cli'.
38
+ if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
39
+ return currPath;
40
+ }
41
+ } catch {}
42
+ }
43
+ oldPath = currPath;
44
+ currPath = _nodePath.dirname(currPath);
45
+ }
46
+ throw new TypeError('rootPath cannot be resolved.');
47
+ })();
48
+ const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
49
+ constants.rootBinPath = _nodePath.join(rootPath, 'bin');
50
+ constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
51
+ const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
52
+ constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
53
+ constants.distPath = _nodePath.join(rootDistPath, SUPPORTS_SYNC_ESM ? 'module-sync' : 'require');
54
+ constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', SUPPORTS_SYNC_ESM ? 'module-sync' : 'require');
55
+ constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
56
+
57
+ exports.constants = constants;
@@ -0,0 +1,7 @@
1
+ declare class AuthError extends Error {
2
+ }
3
+ declare class InputError extends Error {
4
+ body: string | undefined;
5
+ constructor(message: string, body?: string);
6
+ }
7
+ export { AuthError, InputError };
@@ -0,0 +1,2 @@
1
+ declare function installLinks(realDirname: string, binName: 'npm' | 'npx'): string;
2
+ export { installLinks };
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('node:fs');
4
+ var require$$1 = require('node:path');
5
+ var require$$4 = require('which');
6
+
7
+ var link = {};
8
+
9
+ Object.defineProperty(link, "__esModule", {
10
+ value: true
11
+ });
12
+ link.installLinks = installLinks;
13
+ var _nodeFs = require$$0;
14
+ var _nodePath = require$$1;
15
+ var _which = require$$4;
16
+ function installLinks(realDirname, binName) {
17
+ const realShadowBinDir = realDirname;
18
+ // find package manager being shadowed by this process
19
+ const bins = _which.sync(binName, {
20
+ all: true
21
+ });
22
+ let shadowIndex = -1;
23
+ const binPath = bins.find((binPath, i) => {
24
+ if ((0, _nodeFs.realpathSync)(_nodePath.dirname(binPath)) === realShadowBinDir) {
25
+ shadowIndex = i;
26
+ return false;
27
+ }
28
+ return true;
29
+ });
30
+ const isWin = process.platform === 'win32';
31
+ if (isWin && binPath) {
32
+ return binPath;
33
+ }
34
+ if (!binPath) {
35
+ console.error(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
36
+ process.exit(127);
37
+ }
38
+ if (shadowIndex === -1) {
39
+ const binDir = _nodePath.join(realDirname);
40
+ process.env['PATH'] = `${binDir}${isWin ? ';' : ':'}${process.env['PATH']}`;
41
+ }
42
+ return binPath;
43
+ }
44
+
45
+ exports.link = link;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};