@socketsecurity/cli 0.14.33 → 0.14.34

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 (38) hide show
  1. package/bin/cli.js +2 -4
  2. package/bin/npm-cli.js +2 -4
  3. package/bin/npx-cli.js +2 -4
  4. package/dist/constants.js +68 -0
  5. package/dist/module-sync/cli.d.ts +0 -1
  6. package/dist/module-sync/cli.js +184 -164
  7. package/dist/module-sync/constants.d.ts +91 -18
  8. package/dist/module-sync/constants.js +2 -79
  9. package/dist/module-sync/link.js +9 -12
  10. package/dist/module-sync/npm-cli.js +23 -19
  11. package/dist/module-sync/npm-injection.js +98 -99
  12. package/dist/module-sync/npx-cli.js +21 -17
  13. package/dist/module-sync/path-resolve.js +11 -14
  14. package/dist/module-sync/sdk.js +30 -29
  15. package/dist/module-sync/vendor.js +0 -12
  16. package/dist/require/cli.js +168 -148
  17. package/dist/require/constants.js +2 -79
  18. package/dist/require/link.js +9 -12
  19. package/dist/require/npm-cli.js +23 -19
  20. package/dist/require/npm-injection.js +98 -99
  21. package/dist/require/npx-cli.js +21 -17
  22. package/dist/require/path-resolve.js +11 -14
  23. package/dist/require/sdk.js +26 -25
  24. package/dist/require/vendor.js +30 -115
  25. package/package.json +18 -32
  26. package/dist/module-sync/cli.d.ts.map +0 -1
  27. package/dist/require/cli.d.ts +0 -3
  28. package/dist/require/cli.d.ts.map +0 -1
  29. package/dist/require/color-or-markdown.d.ts +0 -23
  30. package/dist/require/constants.d.ts +0 -21
  31. package/dist/require/errors.d.ts +0 -7
  32. package/dist/require/link.d.ts +0 -2
  33. package/dist/require/npm-cli.d.ts +0 -2
  34. package/dist/require/npm-injection.d.ts +0 -1
  35. package/dist/require/npx-cli.d.ts +0 -2
  36. package/dist/require/path-resolve.d.ts +0 -8
  37. package/dist/require/sdk.d.ts +0 -8
  38. package/dist/require/settings.d.ts +0 -9
@@ -1,21 +1,94 @@
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_PUBLIC_API_KEY = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
7
- declare const SOCKET_CLI_ISSUES_URL = "https://github.com/SocketDev/socket-cli/issues";
8
- declare const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = "UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE";
9
1
  declare const ENV: Readonly<{
10
2
  UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
3
+ CI: boolean;
4
+ NODE_AUTH_TOKEN: string;
5
+ PRE_COMMIT: boolean;
11
6
  }>;
12
- declare const rootPath: string;
13
- declare const rootDistPath: string;
14
- declare const rootBinPath: string;
15
- declare const rootPkgJsonPath: string;
16
- declare const nmBinPath: string;
17
- declare const cdxgenBinPath: string;
18
- declare const distPath: string;
19
- declare const shadowBinPath: string;
20
- declare const synpBinPath: string;
21
- export { SUPPORTS_SYNC_ESM, API_V0_URL, DIST_TYPE, LOOP_SENTINEL, NPM_REGISTRY_URL, SOCKET_PUBLIC_API_KEY, SOCKET_CLI_ISSUES_URL, UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE, ENV, rootPath, rootDistPath, rootBinPath, rootPkgJsonPath, nmBinPath, cdxgenBinPath, distPath, shadowBinPath, synpBinPath };
7
+ declare const constants: {
8
+ readonly API_V0_URL: 'https://api.socket.dev/v0';
9
+ readonly ENV: typeof ENV;
10
+ readonly DIST_TYPE: 'module-sync' | 'require';
11
+ readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org';
12
+ readonly SOCKET_CLI_ISSUES_URL: 'https://github.com/SocketDev/socket-cli/issues';
13
+ readonly UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
14
+ readonly cdxgenBinPath: string;
15
+ readonly distPath: string;
16
+ readonly nmBinPath: string;
17
+ readonly rootBinPath: string;
18
+ readonly rootDistPath: string;
19
+ readonly rootPath: string;
20
+ readonly rootPkgJsonPath: string;
21
+ readonly shadowBinPath: string;
22
+ readonly synpBinPath: string;
23
+ } & {
24
+ readonly 'Symbol(kInternalsSymbol)': Internals;
25
+ readonly COLUMN_LIMIT: 80;
26
+ readonly EMPTY_FILE: "/* empty */\n";
27
+ readonly ENV: ENV;
28
+ readonly ESLINT_CONFIG_JS: "eslint.config.js";
29
+ readonly ESNEXT: "esnext";
30
+ readonly GIT_IGNORE: ".gitignore";
31
+ readonly LATEST: "latest";
32
+ readonly LICENSE: "LICENSE";
33
+ readonly LICENSE_GLOB: "LICEN[CS]E{[.-]*,}";
34
+ readonly LICENSE_GLOB_RECURSIVE: "**/LICEN[CS]E{[.-]*,}";
35
+ readonly LICENSE_ORIGINAL: "LICENSE.original";
36
+ readonly LICENSE_ORIGINAL_GLOB: "*.original{.*,}";
37
+ readonly LICENSE_ORIGINAL_GLOB_RECURSIVE: "**/*.original{.*,}";
38
+ readonly LOOP_SENTINEL: 1000000;
39
+ readonly MANIFEST_JSON: "manifest.json";
40
+ readonly MIT: "MIT";
41
+ readonly NODE_MODULES: "node_modules";
42
+ readonly NODE_MODULES_GLOB_RECURSIVE: "**/node_modules";
43
+ readonly NODE_WORKSPACES: "node_workspaces";
44
+ readonly NODE_VERSION: string;
45
+ readonly NPM_ORG: "socketregistry";
46
+ readonly OVERRIDES: "overrides";
47
+ readonly PACKAGE_DEFAULT_SOCKET_CATEGORIES: readonly ["cleanup"];
48
+ readonly PACKAGE_DEFAULT_NODE_RANGE: string;
49
+ readonly PACKAGE_DEFAULT_VERSION: "1.0.0";
50
+ readonly PACKAGE_JSON: "package.json";
51
+ readonly PACKAGE_LOCK: "package-lock.json";
52
+ readonly PACKAGE_SCOPE: "@socketregistry";
53
+ readonly PRETTIER_IGNORE: ".prettierignore";
54
+ readonly PRETTIER_RC: ".prettierrc";
55
+ readonly README_GLOB: "README{.*,}";
56
+ readonly README_GLOB_RECURSIVE: "**/README{.*,}";
57
+ readonly README_MD: "README.md";
58
+ readonly REGISTRY_SCOPE_DELIMITER: "__";
59
+ readonly REGISTRY_WORKSPACE: "registry";
60
+ readonly SOCKET_PUBLIC_API_KEY: "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
61
+ readonly SOCKET_REPO_ORG: "SocketDev";
62
+ readonly SOCKET_REGISTRY_REPO_NAME: "socket-registry";
63
+ readonly SUPPORTS_NODE_DISABLE_WARNING_FLAG: boolean;
64
+ readonly SUPPORTS_NODE_REQUIRE_MODULE: boolean;
65
+ readonly SUPPORTS_NODE_RUN: boolean;
66
+ readonly TEMPLATE_CJS: "cjs";
67
+ readonly TEMPLATE_CJS_BROWSER: "cjs-browser";
68
+ readonly TEMPLATE_CJS_ESM: "cjs-esm";
69
+ readonly TEMPLATE_ES_SHIM_CONSTRUCTOR: "es-shim-constructor";
70
+ readonly TEMPLATE_ES_SHIM_PROTOTYPE_METHOD: "es-shim-prototype-method";
71
+ readonly TEMPLATE_ES_SHIM_STATIC_METHOD: "es-shim-static-method";
72
+ readonly TSCONFIG_JSON: "tsconfig.json";
73
+ readonly UNLICENCED: "UNLICENCED";
74
+ readonly UNLICENSED: "UNLICENSED";
75
+ readonly WIN32: boolean;
76
+ readonly copyLeftLicenses: ReadonlySet<string>;
77
+ readonly execPath: string;
78
+ readonly ignoreGlobs: readonly string[];
79
+ readonly kInternalsSymbol: unique symbol;
80
+ readonly lifecycleScriptNames: ReadonlySet<string>;
81
+ readonly maintainedNodeVersions: MaintainedNodeVersions;
82
+ readonly nodeNoWarningsFlags: readonly string[];
83
+ readonly npmExecPath: string;
84
+ readonly packageExtensions: readonly [string, object][];
85
+ readonly packumentCache: Map<unknown, unknown>;
86
+ readonly pacoteCachePath: string;
87
+ readonly parseArgsConfig: ParseArgsConfig;
88
+ readonly skipTestsByEcosystem: Readonly<Record<string, ReadonlySet<string>>>;
89
+ readonly tsLibsAvailable: ReadonlySet<string>;
90
+ readonly tsTypesAvailable: ReadonlySet<string>;
91
+ readonly win32EnsureTestsByEcosystem: Readonly<Record<string, ReadonlySet<string>>>;
92
+ readonly [kInternalsSymbol]: Internals;
93
+ };
94
+ export { constants as default };
@@ -1,80 +1,3 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
- function _interop(e) {
4
- let d
5
- if (e) {
6
- let c = 0
7
- for (const k in e) {
8
- d = c++ === 0 && k === 'default' ? e[k] : void 0
9
- if (!d) break
10
- }
11
- }
12
- return d ?? e
13
- }
14
-
15
- var require$$0 = _interop(require('node:fs'));
16
- var require$$1 = _interop(require('node:path'));
17
- var require$$2 = _interop(require('@socketsecurity/registry/lib/env'));
18
- var require$$3 = _interop(require('@socketsecurity/registry/lib/constants'));
19
- var require$$4 = _interop(require('semver'));
20
-
21
- var constants = {};
22
-
23
- Object.defineProperty(constants, "__esModule", {
24
- value: true
25
- });
26
- 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_PUBLIC_API_KEY = constants.SOCKET_CLI_ISSUES_URL = constants.NPM_REGISTRY_URL = constants.LOOP_SENTINEL = constants.ENV = constants.DIST_TYPE = constants.API_V0_URL = void 0;
27
- var _nodeFs = require$$0;
28
- var _nodePath = require$$1;
29
- var _env = require$$2;
30
- var _constants = require$$3;
31
- var _semver = require$$4;
32
- const {
33
- PACKAGE_JSON
34
- } = _constants;
35
- const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
36
- constants.API_V0_URL = 'https://api.socket.dev/v0';
37
- const DIST_TYPE = constants.DIST_TYPE = SUPPORTS_SYNC_ESM ? 'module-sync' : 'require';
38
- constants.LOOP_SENTINEL = 1_000_000;
39
- constants.NPM_REGISTRY_URL = 'https://registry.npmjs.org';
40
- constants.SOCKET_PUBLIC_API_KEY = 'sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api';
41
- const SOCKET_CLI_ISSUES_URL = constants.SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
42
- const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = constants.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
43
- constants.ENV = Object.freeze({
44
- // Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
45
- [UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: (0, _env.envAsBoolean)(process.env[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE])
46
- });
47
-
48
- // Dynamically detect the rootPath so constants.ts can be used in tests.
49
- const rootPath = constants.rootPath = (() => {
50
- let oldPath;
51
- let currPath = (0, _nodeFs.realpathSync)(__dirname);
52
- // Dirname stops when at the filepath root, e.g. '/' for posix and 'C:\\' for win32,
53
- // so `currPath` equal `oldPath`.
54
- while (currPath !== oldPath) {
55
- const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
56
- if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
57
- try {
58
- // Content matching @socketsecurity/cli is replaced by
59
- // the @rollup/plugin-replace plugin used in .config/rollup.base.config.mjs
60
- // with either 'socket' or '@socketsecurity/cli'.
61
- if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
62
- return currPath;
63
- }
64
- } catch {}
65
- }
66
- oldPath = currPath;
67
- currPath = _nodePath.dirname(currPath);
68
- }
69
- throw new TypeError(`Socket CLI initialization error: rootPath cannot be resolved.\n\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`);
70
- })();
71
- const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
72
- constants.rootBinPath = _nodePath.join(rootPath, 'bin');
73
- constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
74
- const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
75
- constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
76
- constants.distPath = _nodePath.join(rootDistPath, DIST_TYPE);
77
- constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', DIST_TYPE);
78
- constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
79
-
80
- exports.constants = constants;
3
+ module.exports = require('../constants.js')
@@ -1,20 +1,17 @@
1
1
  'use strict';
2
2
 
3
- function _interop(e) {
4
- let d
5
- if (e) {
6
- let c = 0
7
- for (const k in e) {
8
- d = c++ === 0 && k === 'default' ? e[k] : void 0
9
- if (!d) break
10
- }
3
+ function _socketInterop(e) {
4
+ let c = 0
5
+ for (const k in e ?? {}) {
6
+ c = c === 0 && k === 'default' ? 1 : 0
7
+ if (!c) break
11
8
  }
12
- return d ?? e
9
+ return c ? e.default : e
13
10
  }
14
11
 
15
- var require$$0 = _interop(require('node:fs'));
16
- var require$$1 = _interop(require('node:path'));
17
- var require$$4 = _interop(require('which'));
12
+ var require$$0 = require('node:fs');
13
+ var require$$1 = require('node:path');
14
+ var require$$4 = _socketInterop(require('which'));
18
15
 
19
16
  var link = {};
20
17
 
@@ -1,25 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- function _interop(e) {
5
- let d
6
- if (e) {
7
- let c = 0
8
- for (const k in e) {
9
- d = c++ === 0 && k === 'default' ? e[k] : void 0
10
- if (!d) break
11
- }
4
+ function _socketInterop(e) {
5
+ let c = 0
6
+ for (const k in e ?? {}) {
7
+ c = c === 0 && k === 'default' ? 1 : 0
8
+ if (!c) break
12
9
  }
13
- return d ?? e
10
+ return c ? e.default : e
14
11
  }
15
12
 
16
- var vendor = _interop(require('./vendor.js'));
17
- var require$$0 = _interop(require('node:fs'));
18
- var require$$1 = _interop(require('node:path'));
19
- var require$$1$1 = _interop(require('@npmcli/promise-spawn'));
20
- var constants = _interop(require('./constants.js'));
21
- var link = _interop(require('./link.js'));
22
- var pathResolve = _interop(require('./path-resolve.js'));
13
+ var vendor = require('./vendor.js');
14
+ var require$$0 = require('node:fs');
15
+ var require$$1 = require('node:path');
16
+ var require$$1$1 = _socketInterop(require('@npmcli/promise-spawn'));
17
+ var constants = require('./constants.js');
18
+ var link = require('./link.js');
19
+ var pathResolve = require('./path-resolve.js');
23
20
 
24
21
  var npmCli$2 = {};
25
22
 
@@ -31,8 +28,13 @@ var _promiseSpawn = require$$1$1;
31
28
  var _constants = constants.constants;
32
29
  var _link = link.link;
33
30
  var _pathResolve = pathResolve.pathResolve;
34
- const npmPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
35
- const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
31
+ const {
32
+ distPath,
33
+ execPath,
34
+ shadowBinPath
35
+ } = _constants;
36
+ const npmPath = (0, _link.installLinks)(shadowBinPath, 'npm');
37
+ const injectionPath = _nodePath.join(distPath, 'npm-injection.js');
36
38
 
37
39
  // Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
38
40
  // is found to fix a UX issue when running the command with recent versions of
@@ -54,7 +56,9 @@ if (npmArgs.includes('install') && !npmArgs.includes('--no-progress') && !npmArg
54
56
  }
55
57
  }
56
58
  process.exitCode = 1;
57
- const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npmPath, ...npmArgs], {
59
+ const spawnPromise = _promiseSpawn(execPath, [
60
+ // Lazily access constants.nodeNoWarningsFlags.
61
+ ..._constants.nodeNoWarningsFlags, '--require', injectionPath, npmPath, ...npmArgs], {
58
62
  stdio: 'inherit'
59
63
  });
60
64
  spawnPromise.process.on('exit', (code, signal) => {