@socketsecurity/cli 0.14.28 → 0.14.30
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 +7 -0
- package/bin/npm-cli.js +7 -0
- package/bin/npx-cli.js +7 -0
- package/bin/shadow/module-sync/npm +3 -0
- package/bin/shadow/module-sync/npx +3 -0
- package/bin/shadow/require/npm +3 -0
- package/bin/shadow/require/npx +3 -0
- package/dist/module-sync/cli.d.ts.map +1 -0
- package/dist/module-sync/cli.js +5258 -0
- package/dist/module-sync/constants.d.ts +20 -0
- package/dist/module-sync/constants.js +72 -0
- package/dist/module-sync/npm-cli.js +85 -0
- package/dist/module-sync/npm-injection.js +1609 -0
- package/dist/module-sync/npx-cli.js +61 -0
- package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
- package/dist/module-sync/sdk.js +253 -0
- package/dist/require/cli.d.ts +3 -0
- package/dist/require/cli.d.ts.map +1 -0
- package/dist/{cli.js → require/cli.js} +80 -82
- package/dist/require/color-or-markdown.d.ts +23 -0
- package/dist/require/constants.d.ts +20 -0
- package/dist/require/constants.js +67 -0
- package/dist/require/errors.d.ts +7 -0
- package/dist/require/link.d.ts +2 -0
- package/dist/require/link.js +45 -0
- package/dist/require/npm-cli.d.ts +2 -0
- package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
- package/dist/require/npm-injection.d.ts +1 -0
- package/dist/{npm-injection.js → require/npm-injection.js} +169 -135
- package/dist/require/npx-cli.d.ts +2 -0
- package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
- package/dist/require/path-resolve.d.ts +8 -0
- package/dist/require/path-resolve.js +183 -0
- package/dist/require/sdk.d.ts +9 -0
- package/dist/{sdk.js → require/sdk.js} +16 -36
- package/dist/require/settings.d.ts +9 -0
- package/dist/{vendor.js → require/vendor.js} +6 -1
- package/package.json +54 -19
- package/translations.json +190 -287
- package/bin/npm +0 -2
- package/bin/npx +0 -2
- package/dist/cli.d.ts.map +0 -1
- /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
- /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
- /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
- /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
- /package/dist/{link.js → module-sync/link.js} +0 -0
- /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
- /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
- /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
- /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
- /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
- /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const SUPPORTS_SYNC_ESM: boolean;
|
|
2
|
+
declare const API_V0_URL = "https://api.socket.dev/v0";
|
|
3
|
+
declare const DIST_TYPE: string;
|
|
4
|
+
declare const LOOP_SENTINEL = 1000000;
|
|
5
|
+
declare const NPM_REGISTRY_URL = "https://registry.npmjs.org";
|
|
6
|
+
declare const SOCKET_CLI_ISSUES_URL = "https://github.com/SocketDev/socket-cli/issues";
|
|
7
|
+
declare const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = "UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE";
|
|
8
|
+
declare const ENV: Readonly<{
|
|
9
|
+
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
declare const rootPath: string;
|
|
12
|
+
declare const rootDistPath: string;
|
|
13
|
+
declare const rootBinPath: string;
|
|
14
|
+
declare const rootPkgJsonPath: string;
|
|
15
|
+
declare const nmBinPath: string;
|
|
16
|
+
declare const cdxgenBinPath: string;
|
|
17
|
+
declare const distPath: string;
|
|
18
|
+
declare const shadowBinPath: string;
|
|
19
|
+
declare const synpBinPath: string;
|
|
20
|
+
export { SUPPORTS_SYNC_ESM, API_V0_URL, DIST_TYPE, LOOP_SENTINEL, NPM_REGISTRY_URL, SOCKET_CLI_ISSUES_URL, UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE, ENV, rootPath, rootDistPath, rootBinPath, rootPkgJsonPath, nmBinPath, cdxgenBinPath, distPath, shadowBinPath, synpBinPath };
|
|
@@ -0,0 +1,72 @@
|
|
|
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.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = constants.SUPPORTS_SYNC_ESM = constants.SOCKET_CLI_ISSUES_URL = constants.NPM_REGISTRY_URL = constants.LOOP_SENTINEL = constants.ENV = constants.DIST_TYPE = 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
|
+
const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
|
|
28
|
+
constants.API_V0_URL = 'https://api.socket.dev/v0';
|
|
29
|
+
const DIST_TYPE = constants.DIST_TYPE = SUPPORTS_SYNC_ESM ? 'module-sync' : 'require';
|
|
30
|
+
constants.LOOP_SENTINEL = 1_000_000;
|
|
31
|
+
constants.NPM_REGISTRY_URL = 'https://registry.npmjs.org';
|
|
32
|
+
const SOCKET_CLI_ISSUES_URL = constants.SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
|
|
33
|
+
const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = constants.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
|
|
34
|
+
constants.ENV = Object.freeze({
|
|
35
|
+
// Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
|
|
36
|
+
[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: (0, _env.envAsBoolean)(process.env[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE])
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Dynamically detect the rootPath so constants.ts can be used in tests.
|
|
40
|
+
const rootPath = constants.rootPath = (() => {
|
|
41
|
+
let oldPath;
|
|
42
|
+
let currPath = (0, _nodeFs.realpathSync)(__dirname);
|
|
43
|
+
// Dirname stops when at the filepath root, e.g. '/' for posix and 'C:\\' for win32,
|
|
44
|
+
// so `currPath` equal `oldPath`.
|
|
45
|
+
while (currPath !== oldPath) {
|
|
46
|
+
const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
|
|
47
|
+
if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
|
|
48
|
+
try {
|
|
49
|
+
// Content matching @socketsecurity/cli is replaced by
|
|
50
|
+
// the @rollup/plugin-replace plugin used in .config/rollup.base.config.mjs
|
|
51
|
+
// with either 'socket' or '@socketsecurity/cli'.
|
|
52
|
+
if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
|
|
53
|
+
return currPath;
|
|
54
|
+
}
|
|
55
|
+
} catch {}
|
|
56
|
+
}
|
|
57
|
+
oldPath = currPath;
|
|
58
|
+
currPath = _nodePath.dirname(currPath);
|
|
59
|
+
}
|
|
60
|
+
throw new TypeError(`Socket CLI initialization error: rootPath cannot be resolved.\n\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`);
|
|
61
|
+
})();
|
|
62
|
+
const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
|
|
63
|
+
constants.rootBinPath = _nodePath.join(rootPath, 'bin');
|
|
64
|
+
constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
|
|
65
|
+
const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
|
|
66
|
+
constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
|
|
67
|
+
constants.distPath = _nodePath.join(rootDistPath, DIST_TYPE);
|
|
68
|
+
constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', DIST_TYPE);
|
|
69
|
+
constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
|
|
70
|
+
|
|
71
|
+
exports.constants = constants;
|
|
72
|
+
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;
|