socket 0.14.34 → 0.14.36

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 (37) hide show
  1. package/bin/cli.js +37 -1
  2. package/bin/npm-cli.js +2 -1
  3. package/bin/npx-cli.js +2 -1
  4. package/dist/constants.js +69 -38
  5. package/dist/module-sync/cli.js +773 -1555
  6. package/dist/module-sync/constants.d.ts +16 -79
  7. package/dist/module-sync/constants.d.ts.map +1 -0
  8. package/dist/module-sync/npm-injection.js +77 -395
  9. package/dist/module-sync/path-resolve.d.ts +6 -1
  10. package/dist/module-sync/path-resolve.js +47 -38
  11. package/dist/module-sync/sdk.js +60 -110
  12. package/dist/module-sync/shadow-bin.d.ts +2 -0
  13. package/dist/module-sync/shadow-bin.js +103 -0
  14. package/dist/require/cli.js +768 -1549
  15. package/dist/require/constants.d.ts.map +1 -0
  16. package/dist/require/npm-injection.js +76 -393
  17. package/dist/require/path-resolve.js +47 -38
  18. package/dist/require/sdk.js +57 -106
  19. package/dist/require/shadow-bin.js +103 -0
  20. package/dist/require/vendor.js +8295 -8708
  21. package/package.json +30 -31
  22. package/shadow-bin/npm +4 -0
  23. package/shadow-bin/npx +4 -0
  24. package/bin/shadow/module-sync/npm +0 -3
  25. package/bin/shadow/module-sync/npx +0 -3
  26. package/bin/shadow/require/npm +0 -3
  27. package/bin/shadow/require/npx +0 -3
  28. package/dist/module-sync/link.d.ts +0 -2
  29. package/dist/module-sync/link.js +0 -54
  30. package/dist/module-sync/npm-cli.d.ts +0 -2
  31. package/dist/module-sync/npm-cli.js +0 -101
  32. package/dist/module-sync/npx-cli.d.ts +0 -2
  33. package/dist/module-sync/npx-cli.js +0 -77
  34. package/dist/module-sync/vendor.js +0 -70
  35. package/dist/require/link.js +0 -54
  36. package/dist/require/npm-cli.js +0 -101
  37. package/dist/require/npx-cli.js +0 -77
package/bin/cli.js CHANGED
@@ -2,4 +2,40 @@
2
2
  'use strict'
3
3
 
4
4
  const constants = require('../dist/constants')
5
- require(`../dist/${constants.DIST_TYPE}/cli.js`)
5
+
6
+ const { DIST_TYPE, distPath } = constants
7
+
8
+ if (DIST_TYPE === 'require') {
9
+ require(`${distPath}/cli.js`)
10
+ } else {
11
+ const path = require('node:path')
12
+ const spawn = require('@npmcli/promise-spawn')
13
+
14
+ const { abortSignal, distPath, execPath } = constants
15
+
16
+ process.exitCode = 1
17
+ const spawnPromise = spawn(
18
+ execPath,
19
+ [
20
+ // Lazily access constants.nodeNoWarningsFlags.
21
+ ...constants.nodeNoWarningsFlags,
22
+ path.join(distPath, 'cli.js'),
23
+ ...process.argv.slice(2)
24
+ ],
25
+ {
26
+ signal: abortSignal,
27
+ stdio: 'inherit'
28
+ }
29
+ )
30
+ // See https://nodejs.org/api/all.html#all_child_process_event-exit.
31
+ spawnPromise.process.on('exit', (code, signalName) => {
32
+ if (abortSignal.aborted) {
33
+ return
34
+ }
35
+ if (signalName) {
36
+ process.kill(process.pid, signalName)
37
+ } else if (code !== null) {
38
+ process.exit(code)
39
+ }
40
+ })
41
+ }
package/bin/npm-cli.js CHANGED
@@ -2,4 +2,5 @@
2
2
  'use strict'
3
3
 
4
4
  const constants = require('../dist/constants')
5
- require(`../dist/${constants.DIST_TYPE}/npm-cli.js`)
5
+ const shadowBin = require(`${constants.distPath}/shadow-bin.js`)
6
+ shadowBin(constants.NPM)
package/bin/npx-cli.js CHANGED
@@ -2,4 +2,5 @@
2
2
  'use strict'
3
3
 
4
4
  const constants = require('../dist/constants')
5
- require(`../dist/${constants.DIST_TYPE}/npx-cli.js`)
5
+ const shadowBin = require(`${constants.distPath}/shadow-bin.js`)
6
+ shadowBin(constants.NPX)
package/dist/constants.js CHANGED
@@ -1,68 +1,99 @@
1
1
  'use strict';
2
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');
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var env = require('@socketsecurity/registry/lib/env');
6
+ var registryConstants = require('@socketsecurity/registry/lib/constants');
7
7
 
8
- var _nodeFs = require$$0;
9
- var _nodePath = require$$1;
10
- var _env = require$$2;
11
- var _constants = require$$3;
12
8
  const {
13
- kInternalsSymbol,
14
9
  PACKAGE_JSON,
10
+ kInternalsSymbol,
15
11
  [kInternalsSymbol]: {
16
12
  createConstantsObject
17
13
  }
18
- } = _constants;
14
+ } = registryConstants;
19
15
  const API_V0_URL = 'https://api.socket.dev/v0';
16
+ const BABEL_RUNTIME = '@babel/runtime';
17
+ const BUN = 'bun';
20
18
  const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
19
+ const NPX = 'npx';
20
+ const PNPM = 'pnpm';
21
21
  const SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
22
22
  const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
23
- const ENV = Object.freeze({
24
- ..._constants.ENV,
23
+ const VLT = 'vlt';
24
+ const YARN_BERRY = 'yarn/berry';
25
+ const YARN_CLASSIC = 'yarn/classic';
26
+ const LAZY_DIST_TYPE = () => registryConstants.SUPPORTS_NODE_REQUIRE_MODULE ? 'module-sync' : 'require';
27
+ const LAZY_ENV = () => Object.freeze({
28
+ // Lazily access registryConstants.ENV.
29
+ ...registryConstants.ENV,
25
30
  // 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])
31
+ [UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: env.envAsBoolean(process.env[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE])
27
32
  });
28
- const rootPath = _nodePath.resolve((0, _nodeFs.realpathSync)(__dirname), '..');
29
- const rootDistPath = _nodePath.join(rootPath, 'dist');
30
- const rootBinPath = _nodePath.join(rootPath, 'bin');
31
- const rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
32
- const nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
33
- const cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
34
- const synpBinPath = _nodePath.join(nmBinPath, 'synp');
35
- const LAZY_DIST_TYPE = () => _constants.SUPPORTS_NODE_REQUIRE_MODULE ? 'module-sync' : 'require';
36
- const lazyConstants = () => constants;
37
- const lazyDistPath = () => _nodePath.join(rootDistPath, constants.DIST_TYPE);
38
- const lazyShadowBinPath = () => _nodePath.join(rootPath, 'shadow', constants.DIST_TYPE);
33
+ const lazyCdxgenBinPath = () =>
34
+ // Lazily access constants.nmBinPath.
35
+ path.join(constants.nmBinPath, 'cdxgen');
36
+ const lazyDistPath = () =>
37
+ // Lazily access constants.rootDistPath and constants.DIST_TYPE.
38
+ path.join(constants.rootDistPath, constants.DIST_TYPE);
39
+ const lazyNmBinPath = () =>
40
+ // Lazily access constants.rootPath.
41
+ path.join(constants.rootPath, 'node_modules/.bin');
42
+ const lazyRootBinPath = () =>
43
+ // Lazily access constants.rootPath.
44
+ path.join(constants.rootPath, 'bin');
45
+ const lazyRootDistPath = () =>
46
+ // Lazily access constants.rootPath.
47
+ path.join(constants.rootPath, 'dist');
48
+ const lazyRootPath = () => path.resolve(fs.realpathSync(__dirname), '..');
49
+ const lazyRootPkgJsonPath = () =>
50
+ // Lazily access constants.rootPath.
51
+ path.join(constants.rootPath, PACKAGE_JSON);
52
+ const lazyShadowBinPath = () =>
53
+ // Lazily access constants.rootPath.
54
+ path.join(constants.rootPath, 'shadow-bin');
55
+ const lazySynpBinPath = () =>
56
+ // Lazily access constants.nmBinPath.
57
+ path.join(constants.nmBinPath, 'synp');
39
58
  const constants = createConstantsObject({
40
59
  API_V0_URL,
41
- ENV,
60
+ BABEL_RUNTIME,
61
+ BUN,
62
+ ENV: undefined,
42
63
  // Lazily defined values are initialized as `undefined` to keep their key order.
43
64
  DIST_TYPE: undefined,
44
65
  NPM_REGISTRY_URL,
66
+ NPX,
67
+ PNPM,
45
68
  SOCKET_CLI_ISSUES_URL,
46
69
  UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
47
- cdxgenBinPath,
48
- constants: undefined,
70
+ VLT,
71
+ YARN_BERRY,
72
+ YARN_CLASSIC,
73
+ cdxgenBinPath: undefined,
49
74
  distPath: undefined,
50
- nmBinPath,
51
- rootBinPath,
52
- rootDistPath,
53
- rootPath,
54
- rootPkgJsonPath,
75
+ nmBinPath: undefined,
76
+ rootBinPath: undefined,
77
+ rootDistPath: undefined,
78
+ rootPath: undefined,
79
+ rootPkgJsonPath: undefined,
55
80
  shadowBinPath: undefined,
56
- synpBinPath
81
+ synpBinPath: undefined
57
82
  }, {
58
83
  getters: {
59
84
  DIST_TYPE: LAZY_DIST_TYPE,
60
- // Preserve rollup chunk compatibility.
61
- constants: lazyConstants,
85
+ ENV: LAZY_ENV,
62
86
  distPath: lazyDistPath,
63
- shadowBinPath: lazyShadowBinPath
87
+ cdxgenBinPath: lazyCdxgenBinPath,
88
+ nmBinPath: lazyNmBinPath,
89
+ rootBinPath: lazyRootBinPath,
90
+ rootDistPath: lazyRootDistPath,
91
+ rootPath: lazyRootPath,
92
+ rootPkgJsonPath: lazyRootPkgJsonPath,
93
+ shadowBinPath: lazyShadowBinPath,
94
+ synpBinPath: lazySynpBinPath
64
95
  },
65
- mixin: _constants
96
+ mixin: registryConstants
66
97
  });
67
98
 
68
- module.exports = constants
99
+ module.exports = constants;