@socketsecurity/cli 0.14.28 → 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/module-sync/npm-injection.js +1595 -0
  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} +70 -74
  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/{npm-injection.js → require/npm-injection.js} +124 -104
  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} +6 -1
  38. package/package.json +53 -18
  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
@@ -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,62 @@
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
+ function getDefaultExportFromCjs (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
13
+ var constants = {};
14
+
15
+ Object.defineProperty(constants, "__esModule", {
16
+ value: true
17
+ });
18
+ 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;
19
+ var _nodeFs = require$$0;
20
+ var _nodePath = require$$1;
21
+ var _env = require$$2;
22
+ var _constants = require$$3;
23
+ var _semver = require$$4;
24
+ const {
25
+ PACKAGE_JSON
26
+ } = _constants;
27
+ constants.API_V0_URL = 'https://api.socket.dev/v0';
28
+ constants.ENV = Object.freeze({
29
+ // Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
30
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: (0, _env.envAsBoolean)(process.env['UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'])
31
+ });
32
+ const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
33
+ const rootPath = constants.rootPath = (() => {
34
+ let oldPath;
35
+ let currPath = (0, _nodeFs.realpathSync)(__dirname);
36
+ while (currPath !== oldPath) {
37
+ const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
38
+ if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
39
+ try {
40
+ // @socketsecurity/cli is replaced by .config/rollup.base.config.mjs
41
+ // with either 'socket' or '@socketsecurity/cli'.
42
+ if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
43
+ return currPath;
44
+ }
45
+ } catch {}
46
+ }
47
+ oldPath = currPath;
48
+ currPath = _nodePath.dirname(currPath);
49
+ }
50
+ throw new TypeError('rootPath cannot be resolved.');
51
+ })();
52
+ const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
53
+ constants.rootBinPath = _nodePath.join(rootPath, 'bin');
54
+ constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
55
+ const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
56
+ constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
57
+ constants.distPath = _nodePath.join(rootDistPath, SUPPORTS_SYNC_ESM ? 'module-sync' : 'require');
58
+ constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', SUPPORTS_SYNC_ESM ? 'module-sync' : 'require');
59
+ constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
60
+
61
+ exports.constants = constants;
62
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var constants = require('./constants.js');
5
+ var require$$0$1 = require('@babel/runtime/helpers/interopRequireWildcard');
6
+ var require$$0 = require('node:fs');
7
+ var require$$1 = require('node:path');
8
+ var require$$1$1 = require('@npmcli/promise-spawn');
9
+ var link = require('./link.js');
10
+ var pathResolve = require('./path-resolve.js');
11
+
12
+ var npmCli$2 = {};
13
+
14
+ var npmCli$1 = {};
15
+
16
+ var _nodeFs = require$$0;
17
+ var _nodePath = require$$1;
18
+ var _promiseSpawn = require$$1$1;
19
+ var _constants = constants.constants;
20
+ var _link = link.link;
21
+ var _pathResolve = pathResolve.pathResolve;
22
+ const npmPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
23
+ const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
24
+
25
+ // Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
26
+ // is found to fix a UX issue when running the command with recent versions of
27
+ // npm (input swallowed by the standard npm spinner)
28
+ const npmArgs = process.argv.slice(2);
29
+ if (npmArgs.includes('install') && !npmArgs.includes('--no-progress') && !npmArgs.includes('--quiet')) {
30
+ const npmEntrypoint = (0, _nodeFs.realpathSync)(npmPath);
31
+ const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
32
+ if (npmRootPath === undefined) {
33
+ process.exit(127);
34
+ }
35
+ const npmDepPath = _nodePath.join(npmRootPath, 'node_modules');
36
+ let procLog;
37
+ try {
38
+ procLog = require(_nodePath.join(npmDepPath, 'proc-log/lib/index.js')).log;
39
+ } catch {}
40
+ if (procLog) {
41
+ npmArgs.push('--no-progress', '--quiet');
42
+ }
43
+ }
44
+ process.exitCode = 1;
45
+ const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npmPath, ...npmArgs], {
46
+ stdio: 'inherit'
47
+ });
48
+ spawnPromise.process.on('exit', (code, signal) => {
49
+ if (signal) {
50
+ process.kill(process.pid, signal);
51
+ } else if (code !== null) {
52
+ process.exit(code);
53
+ }
54
+ });
55
+
56
+ (function (exports) {
57
+
58
+ var _interopRequireWildcard = require$$0$1.default;
59
+ Object.defineProperty(exports, "__esModule", {
60
+ value: true
61
+ });
62
+ var _exportNames = {};
63
+ Object.defineProperty(exports, "default", {
64
+ enumerable: true,
65
+ get: function () {
66
+ return _npmCli.default;
67
+ }
68
+ });
69
+ var _npmCli = _interopRequireWildcard(npmCli$1, true);
70
+ Object.keys(_npmCli).forEach(function (key) {
71
+ if (key === "default" || key === "__esModule") return;
72
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
73
+ if (key in exports && exports[key] === _npmCli[key]) return;
74
+ Object.defineProperty(exports, key, {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _npmCli[key];
78
+ }
79
+ });
80
+ });
81
+ } (npmCli$2));
82
+
83
+ var npmCli = /*@__PURE__*/constants.getDefaultExportFromCjs(npmCli$2);
84
+
85
+ module.exports = npmCli;