socket 0.14.33 → 0.14.35

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 +34 -4
  2. package/bin/npm-cli.js +3 -4
  3. package/bin/npx-cli.js +3 -4
  4. package/dist/constants.js +59 -0
  5. package/dist/module-sync/cli.d.ts +0 -1
  6. package/dist/module-sync/cli.js +637 -1423
  7. package/dist/module-sync/constants.d.ts +24 -21
  8. package/dist/module-sync/constants.d.ts.map +1 -0
  9. package/dist/module-sync/constants.js +2 -79
  10. package/dist/module-sync/npm-injection.js +116 -435
  11. package/dist/module-sync/path-resolve.js +24 -45
  12. package/dist/module-sync/sdk.js +69 -118
  13. package/dist/module-sync/shadow-bin.d.ts +2 -0
  14. package/dist/module-sync/shadow-bin.js +109 -0
  15. package/dist/require/cli.js +633 -1418
  16. package/dist/require/constants.d.ts.map +1 -0
  17. package/dist/require/constants.js +2 -79
  18. package/dist/require/npm-injection.js +116 -434
  19. package/dist/require/path-resolve.js +24 -45
  20. package/dist/require/sdk.js +67 -115
  21. package/dist/require/shadow-bin.js +109 -0
  22. package/dist/require/vendor.js +8300 -8798
  23. package/package.json +39 -54
  24. package/shadow-bin/npm +4 -0
  25. package/shadow-bin/npx +4 -0
  26. package/bin/shadow/module-sync/npm +0 -3
  27. package/bin/shadow/module-sync/npx +0 -3
  28. package/bin/shadow/require/npm +0 -3
  29. package/bin/shadow/require/npx +0 -3
  30. package/dist/module-sync/cli.d.ts.map +0 -1
  31. package/dist/module-sync/link.d.ts +0 -2
  32. package/dist/module-sync/link.js +0 -57
  33. package/dist/module-sync/npm-cli.d.ts +0 -2
  34. package/dist/module-sync/npm-cli.js +0 -97
  35. package/dist/module-sync/npx-cli.d.ts +0 -2
  36. package/dist/module-sync/npx-cli.js +0 -73
  37. package/dist/module-sync/vendor.js +0 -82
  38. package/dist/require/cli.d.ts +0 -3
  39. package/dist/require/cli.d.ts.map +0 -1
  40. package/dist/require/color-or-markdown.d.ts +0 -23
  41. package/dist/require/constants.d.ts +0 -21
  42. package/dist/require/errors.d.ts +0 -7
  43. package/dist/require/link.d.ts +0 -2
  44. package/dist/require/link.js +0 -57
  45. package/dist/require/npm-cli.d.ts +0 -2
  46. package/dist/require/npm-cli.js +0 -97
  47. package/dist/require/npm-injection.d.ts +0 -1
  48. package/dist/require/npx-cli.d.ts +0 -2
  49. package/dist/require/npx-cli.js +0 -73
  50. package/dist/require/path-resolve.d.ts +0 -8
  51. package/dist/require/sdk.d.ts +0 -8
  52. package/dist/require/settings.d.ts +0 -9
package/bin/cli.js CHANGED
@@ -1,7 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
3
 
4
- const DIST_TYPE = require('semver').satisfies(process.versions.node, '>=22.12')
5
- ? 'module-sync'
6
- : 'require'
7
- require(`../dist/${DIST_TYPE}/cli.js`)
4
+ const constants = require('../dist/constants')
5
+
6
+ const { DIST_TYPE } = constants
7
+
8
+ if (DIST_TYPE === 'require') {
9
+ require(`../dist/${DIST_TYPE}/cli.js`)
10
+ } else {
11
+ const path = require('node:path')
12
+ const spawn = require('@npmcli/promise-spawn')
13
+
14
+ const { abortSignal, execPath, rootDistPath } = constants
15
+
16
+ process.exitCode = 1
17
+ const spawnPromise = spawn(
18
+ execPath,
19
+ [
20
+ // Lazily access constants.nodeNoWarningsFlags.
21
+ ...constants.nodeNoWarningsFlags,
22
+ path.join(rootDistPath, DIST_TYPE, 'cli.js'),
23
+ ...process.argv.slice(2)
24
+ ],
25
+ {
26
+ signal: abortSignal,
27
+ stdio: 'inherit'
28
+ }
29
+ )
30
+ spawnPromise.process.on('exit', (code, signal) => {
31
+ if (signal) {
32
+ process.kill(process.pid, signal)
33
+ } else if (code !== null) {
34
+ process.exit(code)
35
+ }
36
+ })
37
+ }
package/bin/npm-cli.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
3
 
4
- const DIST_TYPE = require('semver').satisfies(process.versions.node, '>=22.12')
5
- ? 'module-sync'
6
- : 'require'
7
- require(`../dist/${DIST_TYPE}/npm-cli.js`)
4
+ const constants = require('../dist/constants')
5
+ const shadowBin = require(`../dist/${constants.DIST_TYPE}/shadow-bin.js`)
6
+ shadowBin('npm')
package/bin/npx-cli.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
3
 
4
- const DIST_TYPE = require('semver').satisfies(process.versions.node, '>=22.12')
5
- ? 'module-sync'
6
- : 'require'
7
- require(`../dist/${DIST_TYPE}/npx-cli.js`)
4
+ const constants = require('../dist/constants')
5
+ const shadowBin = require(`../dist/${constants.DIST_TYPE}/shadow-bin.js`)
6
+ shadowBin('npx')
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
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
+
8
+ const {
9
+ kInternalsSymbol,
10
+ PACKAGE_JSON,
11
+ [kInternalsSymbol]: {
12
+ createConstantsObject
13
+ }
14
+ } = registryConstants;
15
+ const API_V0_URL = 'https://api.socket.dev/v0';
16
+ const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
17
+ const SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
18
+ const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
19
+ const ENV = Object.freeze({
20
+ ...registryConstants.ENV,
21
+ // Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
22
+ [UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: env.envAsBoolean(process.env[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE])
23
+ });
24
+ const rootPath = path.resolve(fs.realpathSync(__dirname), '..');
25
+ const rootDistPath = path.join(rootPath, 'dist');
26
+ const rootBinPath = path.join(rootPath, 'bin');
27
+ const rootPkgJsonPath = path.join(rootPath, PACKAGE_JSON);
28
+ const nmBinPath = path.join(rootPath, 'node_modules/.bin');
29
+ const cdxgenBinPath = path.join(nmBinPath, 'cdxgen');
30
+ const shadowBinPath = path.join(rootPath, 'shadow-bin');
31
+ const synpBinPath = path.join(nmBinPath, 'synp');
32
+ const LAZY_DIST_TYPE = () => registryConstants.SUPPORTS_NODE_REQUIRE_MODULE ? 'module-sync' : 'require';
33
+ const lazyDistPath = () => path.join(rootDistPath, constants.DIST_TYPE);
34
+ const constants = createConstantsObject({
35
+ API_V0_URL,
36
+ ENV,
37
+ // Lazily defined values are initialized as `undefined` to keep their key order.
38
+ DIST_TYPE: undefined,
39
+ NPM_REGISTRY_URL,
40
+ SOCKET_CLI_ISSUES_URL,
41
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
42
+ cdxgenBinPath,
43
+ distPath: undefined,
44
+ nmBinPath,
45
+ rootBinPath,
46
+ rootDistPath,
47
+ rootPath,
48
+ rootPkgJsonPath,
49
+ shadowBinPath,
50
+ synpBinPath
51
+ }, {
52
+ getters: {
53
+ DIST_TYPE: LAZY_DIST_TYPE,
54
+ distPath: lazyDistPath
55
+ },
56
+ mixin: registryConstants
57
+ });
58
+
59
+ module.exports = constants;
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=cli.d.ts.map