socket 0.14.35 → 0.14.37

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