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 +11 -7
- package/bin/npm-cli.js +2 -2
- package/bin/npx-cli.js +2 -2
- package/dist/constants.js +66 -22
- package/dist/module-sync/cli.js +212 -173
- package/dist/module-sync/constants.d.ts +9 -0
- package/dist/module-sync/constants.d.ts.map +1 -1
- package/dist/module-sync/npm-injection.js +1 -1
- package/dist/module-sync/path-resolve.d.ts +6 -1
- package/dist/module-sync/path-resolve.js +31 -4
- package/dist/module-sync/shadow-bin.d.ts +1 -1
- package/dist/module-sync/shadow-bin.js +17 -23
- package/dist/require/cli.js +212 -173
- package/dist/require/constants.d.ts.map +1 -1
- package/dist/require/npm-injection.js +1 -1
- package/dist/require/path-resolve.js +31 -4
- package/dist/require/shadow-bin.js +17 -23
- package/package.json +12 -12
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(
|
|
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,
|
|
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(
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
package/bin/npx-cli.js
CHANGED
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
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
});
|