@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
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var vendor = require('./vendor.js');
|
|
5
|
-
var require$$1 = require('node:path');
|
|
6
5
|
var require$$8$2 = require('node:url');
|
|
7
6
|
var require$$1$2 = require('yoctocolors-cjs');
|
|
8
|
-
var require$$
|
|
7
|
+
var require$$4$1 = require('pony-cause');
|
|
9
8
|
var require$$0 = require('node:fs');
|
|
9
|
+
var require$$1 = require('node:path');
|
|
10
10
|
var require$$1$1 = require('@npmcli/promise-spawn');
|
|
11
11
|
var require$$4 = require('yargs-parser');
|
|
12
12
|
var require$$5 = require('@socketsecurity/registry/lib/words');
|
|
13
|
+
var constants = require('./constants.js');
|
|
13
14
|
var require$$3 = require('@socketregistry/yocto-spinner');
|
|
14
15
|
var sdk = require('./sdk.js');
|
|
15
16
|
var require$$1$3 = require('@inquirer/prompts');
|
|
16
17
|
var require$$1$4 = require('node:fs/promises');
|
|
17
|
-
var require$$5$
|
|
18
|
-
var require$$
|
|
18
|
+
var require$$5$2 = require('npm-package-arg');
|
|
19
|
+
var require$$4$2 = require('semver');
|
|
19
20
|
var require$$8$1 = require('tinyglobby');
|
|
20
21
|
var require$$9$1 = require('yaml');
|
|
21
22
|
var require$$10 = require('@socketsecurity/registry');
|
|
@@ -25,11 +26,11 @@ var require$$13 = require('@socketsecurity/registry/lib/promises');
|
|
|
25
26
|
var require$$14 = require('@socketsecurity/registry/lib/regexps');
|
|
26
27
|
var require$$9 = require('@socketsecurity/registry/lib/strings');
|
|
27
28
|
var require$$2 = require('browserslist');
|
|
28
|
-
var require$$4$
|
|
29
|
-
var require$$5$
|
|
30
|
-
var require$$
|
|
29
|
+
var require$$4$3 = require('which');
|
|
30
|
+
var require$$5$1 = require('@socketregistry/hyrious__bun.lockb');
|
|
31
|
+
var require$$3$1 = require('@socketsecurity/registry/lib/constants');
|
|
31
32
|
var require$$2$1 = require('@apideck/better-ajv-errors');
|
|
32
|
-
var require$$6
|
|
33
|
+
var require$$6 = require('@socketsecurity/config');
|
|
33
34
|
var pathResolve = require('./path-resolve.js');
|
|
34
35
|
var require$$1$5 = require('node:os');
|
|
35
36
|
var require$$3$2 = require('node:readline');
|
|
@@ -38,14 +39,14 @@ var require$$2$2 = require('node:readline/promises');
|
|
|
38
39
|
var require$$2$3 = require('chalk-table');
|
|
39
40
|
var require$$2$4 = require('blessed/lib/widgets/screen');
|
|
40
41
|
var require$$3$3 = require('blessed-contrib/lib/widget/charts/bar');
|
|
41
|
-
var require$$4$
|
|
42
|
-
var require$$5$
|
|
42
|
+
var require$$4$4 = require('blessed-contrib/lib/layout/grid');
|
|
43
|
+
var require$$5$3 = require('blessed-contrib/lib/widget/charts/line');
|
|
43
44
|
var require$$0$2 = require('node:util');
|
|
44
45
|
var require$$2$5 = require('blessed-contrib/lib/widget/table');
|
|
45
46
|
|
|
46
|
-
var cli$
|
|
47
|
+
var cli$2 = {};
|
|
47
48
|
|
|
48
|
-
var cli = {};
|
|
49
|
+
var cli$1 = {};
|
|
49
50
|
|
|
50
51
|
var commands = {};
|
|
51
52
|
|
|
@@ -56,19 +57,15 @@ Object.defineProperty(cdxgen, "__esModule", {
|
|
|
56
57
|
});
|
|
57
58
|
cdxgen.cdxgen = void 0;
|
|
58
59
|
var _nodeFs$3 = require$$0;
|
|
59
|
-
var _nodePath$
|
|
60
|
+
var _nodePath$6 = require$$1;
|
|
60
61
|
var _promiseSpawn$6 = require$$1$1;
|
|
61
62
|
var _yoctocolorsCjs$j = require$$1$2;
|
|
62
63
|
var _yargsParser = require$$4;
|
|
63
64
|
var _words$1 = require$$5;
|
|
64
|
-
|
|
65
|
+
var _constants$6 = constants.constants;
|
|
65
66
|
const {
|
|
66
67
|
execPath
|
|
67
68
|
} = process;
|
|
68
|
-
const rootPath$1 = _nodePath$7.resolve(distPath$4, '..');
|
|
69
|
-
const binPath = _nodePath$7.join(rootPath$1, 'node_modules/.bin');
|
|
70
|
-
const cdxgenBinPath = _nodePath$7.join(binPath, 'cdxgen');
|
|
71
|
-
const synpBinPath = _nodePath$7.join(binPath, 'synp');
|
|
72
69
|
const {
|
|
73
70
|
SBOM_SIGN_ALGORITHM,
|
|
74
71
|
// Algorithm. Example: RS512
|
|
@@ -194,7 +191,7 @@ cdxgen.cdxgen = {
|
|
|
194
191
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
195
192
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
196
193
|
try {
|
|
197
|
-
await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(synpBinPath), '--source-file', './yarn.lock'], {
|
|
194
|
+
await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(_constants$6.synpBinPath), '--source-file', './yarn.lock'], {
|
|
198
195
|
shell: true
|
|
199
196
|
});
|
|
200
197
|
yargv.type = 'npm';
|
|
@@ -205,7 +202,7 @@ cdxgen.cdxgen = {
|
|
|
205
202
|
if (yargv.output === undefined) {
|
|
206
203
|
yargv.output = 'socket-cdx.json';
|
|
207
204
|
}
|
|
208
|
-
await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(cdxgenBinPath), ...argvToArray(yargv)], {
|
|
205
|
+
await _promiseSpawn$6(execPath, [await _nodeFs$3.promises.realpath(_constants$6.cdxgenBinPath), ...argvToArray(yargv)], {
|
|
209
206
|
env: {
|
|
210
207
|
NODE_ENV: '',
|
|
211
208
|
SBOM_SIGN_ALGORITHM,
|
|
@@ -220,7 +217,7 @@ cdxgen.cdxgen = {
|
|
|
220
217
|
await _nodeFs$3.promises.unlink('./package-lock.json');
|
|
221
218
|
} catch {}
|
|
222
219
|
}
|
|
223
|
-
const fullOutputPath = _nodePath$
|
|
220
|
+
const fullOutputPath = _nodePath$6.join(process.cwd(), yargv.output);
|
|
224
221
|
if ((0, _nodeFs$3.existsSync)(fullOutputPath)) {
|
|
225
222
|
console.log(_yoctocolorsCjs$j.cyanBright(`${yargv.output} created!`));
|
|
226
223
|
}
|
|
@@ -292,12 +289,13 @@ apiHelpers.handleApiCall = handleApiCall;
|
|
|
292
289
|
apiHelpers.handleUnsuccessfulApiResponse = handleUnsuccessfulApiResponse;
|
|
293
290
|
apiHelpers.queryAPI = queryAPI;
|
|
294
291
|
var _yoctocolorsCjs$i = require$$1$2;
|
|
295
|
-
var _ponyCause$4 = require$$
|
|
292
|
+
var _ponyCause$4 = require$$4$1;
|
|
296
293
|
var _errors$l = sdk.errors;
|
|
297
|
-
var _constants$
|
|
294
|
+
var _constants$5 = constants.constants;
|
|
298
295
|
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
299
|
-
|
|
300
|
-
const
|
|
296
|
+
// SocketSdkErrorType['error'] is not typed.
|
|
297
|
+
const resultErrorMessage = result.error?.message;
|
|
298
|
+
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
301
299
|
if (result.status === 401 || result.status === 403) {
|
|
302
300
|
spinner.stop();
|
|
303
301
|
throw new _errors$l.AuthError(message);
|
|
@@ -318,16 +316,16 @@ async function handleApiCall(value, description) {
|
|
|
318
316
|
}
|
|
319
317
|
async function handleAPIError(code) {
|
|
320
318
|
if (code === 400) {
|
|
321
|
-
return
|
|
319
|
+
return 'One of the options passed might be incorrect.';
|
|
322
320
|
} else if (code === 403) {
|
|
323
|
-
return
|
|
321
|
+
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
324
|
async function queryAPI(path, apiKey) {
|
|
327
|
-
return await fetch(`${_constants$
|
|
325
|
+
return await fetch(`${_constants$5.API_V0_URL}/${path}`, {
|
|
328
326
|
method: 'GET',
|
|
329
327
|
headers: {
|
|
330
|
-
Authorization:
|
|
328
|
+
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
331
329
|
}
|
|
332
330
|
});
|
|
333
331
|
}
|
|
@@ -813,16 +811,16 @@ Object.defineProperty(npm, "__esModule", {
|
|
|
813
811
|
value: true
|
|
814
812
|
});
|
|
815
813
|
npm.npm = void 0;
|
|
816
|
-
var _nodePath$
|
|
814
|
+
var _nodePath$5 = require$$1;
|
|
817
815
|
var _promiseSpawn$5 = require$$1$1;
|
|
818
|
-
|
|
816
|
+
var _constants$4 = constants.constants;
|
|
819
817
|
const description$5 = 'npm wrapper functionality';
|
|
820
818
|
npm.npm = {
|
|
821
819
|
description: description$5,
|
|
822
820
|
async run(argv, _importMeta, _ctx) {
|
|
823
|
-
const wrapperPath = _nodePath$
|
|
821
|
+
const wrapperPath = _nodePath$5.join(_constants$4.distPath, 'npm-cli.js');
|
|
824
822
|
process.exitCode = 1;
|
|
825
|
-
const spawnPromise = _promiseSpawn$5(process.execPath, [wrapperPath, ...argv], {
|
|
823
|
+
const spawnPromise = _promiseSpawn$5(process.execPath, ['--disable-warning', 'ExperimentalWarning', wrapperPath, ...argv], {
|
|
826
824
|
stdio: 'inherit'
|
|
827
825
|
});
|
|
828
826
|
spawnPromise.process.on('exit', (code, signal) => {
|
|
@@ -842,16 +840,16 @@ Object.defineProperty(npx, "__esModule", {
|
|
|
842
840
|
value: true
|
|
843
841
|
});
|
|
844
842
|
npx.npx = void 0;
|
|
845
|
-
var _nodePath$
|
|
843
|
+
var _nodePath$4 = require$$1;
|
|
846
844
|
var _promiseSpawn$4 = require$$1$1;
|
|
847
|
-
|
|
845
|
+
var _constants$3 = constants.constants;
|
|
848
846
|
const description$4 = 'npx wrapper functionality';
|
|
849
847
|
npx.npx = {
|
|
850
848
|
description: description$4,
|
|
851
849
|
async run(argv, _importMeta, _ctx) {
|
|
852
|
-
const wrapperPath = _nodePath$
|
|
850
|
+
const wrapperPath = _nodePath$4.join(_constants$3.distPath, 'npx-cli.js');
|
|
853
851
|
process.exitCode = 1;
|
|
854
|
-
const spawnPromise = _promiseSpawn$4(process.execPath, [wrapperPath, ...argv], {
|
|
852
|
+
const spawnPromise = _promiseSpawn$4(process.execPath, ['--disable-warning', 'ExperimentalWarning', wrapperPath, ...argv], {
|
|
855
853
|
stdio: 'inherit'
|
|
856
854
|
});
|
|
857
855
|
spawnPromise.process.on('exit', (code, signal) => {
|
|
@@ -877,7 +875,7 @@ fs.findUp = findUp;
|
|
|
877
875
|
fs.readFileBinary = readFileBinary;
|
|
878
876
|
fs.readFileUtf8 = readFileUtf8;
|
|
879
877
|
var _nodeFs$2 = require$$0;
|
|
880
|
-
var _nodePath$
|
|
878
|
+
var _nodePath$3 = require$$1;
|
|
881
879
|
function existsSync(filepath) {
|
|
882
880
|
try {
|
|
883
881
|
return filepath ? (0, _nodeFs$2.existsSync)(filepath) : false;
|
|
@@ -887,14 +885,14 @@ function existsSync(filepath) {
|
|
|
887
885
|
async function findUp(name, {
|
|
888
886
|
cwd = process.cwd()
|
|
889
887
|
}) {
|
|
890
|
-
let dir = _nodePath$
|
|
888
|
+
let dir = _nodePath$3.resolve(cwd);
|
|
891
889
|
const {
|
|
892
890
|
root
|
|
893
|
-
} = _nodePath$
|
|
891
|
+
} = _nodePath$3.parse(dir);
|
|
894
892
|
const names = [name].flat();
|
|
895
893
|
while (dir && dir !== root) {
|
|
896
894
|
for (const name of names) {
|
|
897
|
-
const filePath = _nodePath$
|
|
895
|
+
const filePath = _nodePath$3.join(dir, name);
|
|
898
896
|
try {
|
|
899
897
|
// eslint-disable-next-line no-await-in-loop
|
|
900
898
|
const stats = await _nodeFs$2.promises.stat(filePath);
|
|
@@ -903,7 +901,7 @@ async function findUp(name, {
|
|
|
903
901
|
}
|
|
904
902
|
} catch {}
|
|
905
903
|
}
|
|
906
|
-
dir = _nodePath$
|
|
904
|
+
dir = _nodePath$3.dirname(dir);
|
|
907
905
|
}
|
|
908
906
|
return undefined;
|
|
909
907
|
}
|
|
@@ -927,13 +925,13 @@ Object.defineProperty(packageManagerDetector, "__esModule", {
|
|
|
927
925
|
});
|
|
928
926
|
packageManagerDetector.AGENTS = void 0;
|
|
929
927
|
packageManagerDetector.detect = detect;
|
|
930
|
-
var _nodePath$
|
|
928
|
+
var _nodePath$2 = require$$1;
|
|
931
929
|
var _promiseSpawn$3 = require$$1$1;
|
|
932
930
|
var _browserslist = require$$2;
|
|
933
|
-
var _semver$1 = require$$
|
|
934
|
-
var _which = require$$4$
|
|
935
|
-
var _hyrious__bun = require$$5$
|
|
936
|
-
var _constants = require$$
|
|
931
|
+
var _semver$1 = require$$4$2;
|
|
932
|
+
var _which = require$$4$3;
|
|
933
|
+
var _hyrious__bun = require$$5$1;
|
|
934
|
+
var _constants$2 = require$$3$1;
|
|
937
935
|
var _objects$2 = require$$7;
|
|
938
936
|
var _packages$1 = require$$8;
|
|
939
937
|
var _strings$1 = require$$9;
|
|
@@ -1021,10 +1019,10 @@ async function detect({
|
|
|
1021
1019
|
cwd
|
|
1022
1020
|
});
|
|
1023
1021
|
const isHiddenLockFile = lockPath?.endsWith('.package-lock.json') ?? false;
|
|
1024
|
-
const pkgJsonPath = lockPath ? _nodePath$
|
|
1022
|
+
const pkgJsonPath = lockPath ? _nodePath$2.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await (0, _fs$1.findUp)('package.json', {
|
|
1025
1023
|
cwd
|
|
1026
1024
|
});
|
|
1027
|
-
const pkgPath = (0, _fs$1.existsSync)(pkgJsonPath) ? _nodePath$
|
|
1025
|
+
const pkgPath = (0, _fs$1.existsSync)(pkgJsonPath) ? _nodePath$2.dirname(pkgJsonPath) : undefined;
|
|
1028
1026
|
const editablePkgJson = pkgPath ? await (0, _packages$1.readPackageJson)(pkgPath, {
|
|
1029
1027
|
editable: true
|
|
1030
1028
|
}) : undefined;
|
|
@@ -1046,7 +1044,7 @@ async function detect({
|
|
|
1046
1044
|
}
|
|
1047
1045
|
}
|
|
1048
1046
|
if (agent === undefined && !isHiddenLockFile && typeof pkgJsonPath === 'string' && typeof lockPath === 'string') {
|
|
1049
|
-
agent = LOCKS[_nodePath$
|
|
1047
|
+
agent = LOCKS[_nodePath$2.basename(lockPath)];
|
|
1050
1048
|
}
|
|
1051
1049
|
if (agent === undefined) {
|
|
1052
1050
|
agent = 'npm';
|
|
@@ -1066,7 +1064,7 @@ async function detect({
|
|
|
1066
1064
|
};
|
|
1067
1065
|
let lockSrc;
|
|
1068
1066
|
// Lazily access constants.maintainedNodeVersions.
|
|
1069
|
-
let minimumNodeVersion = _constants.maintainedNodeVersions.previous;
|
|
1067
|
+
let minimumNodeVersion = _constants$2.maintainedNodeVersions.previous;
|
|
1070
1068
|
if (pkgJson) {
|
|
1071
1069
|
const browserField = pkgJson.browser;
|
|
1072
1070
|
if ((0, _strings$1.isNonEmptyString)(browserField) || (0, _objects$2.isObjectObject)(browserField)) {
|
|
@@ -1094,7 +1092,7 @@ async function detect({
|
|
|
1094
1092
|
}
|
|
1095
1093
|
}
|
|
1096
1094
|
// Lazily access constants.maintainedNodeVersions.
|
|
1097
|
-
targets.node = _constants.maintainedNodeVersions.some(v => _semver$1.satisfies(v, `>=${minimumNodeVersion}`));
|
|
1095
|
+
targets.node = _constants$2.maintainedNodeVersions.some(v => _semver$1.satisfies(v, `>=${minimumNodeVersion}`));
|
|
1098
1096
|
lockSrc = typeof lockPath === 'string' ? await readLockFileByAgent[agent](lockPath, agentExecPath) : undefined;
|
|
1099
1097
|
} else {
|
|
1100
1098
|
lockPath = undefined;
|
|
@@ -1120,12 +1118,12 @@ Object.defineProperty(optimize$1, "__esModule", {
|
|
|
1120
1118
|
});
|
|
1121
1119
|
optimize$1.optimize = void 0;
|
|
1122
1120
|
var _promises$2 = require$$1$4;
|
|
1123
|
-
var _nodePath$
|
|
1121
|
+
var _nodePath$1 = require$$1;
|
|
1124
1122
|
var _promiseSpawn$2 = require$$1$1;
|
|
1125
1123
|
var _meow$m = _interopRequireDefault$n(vendor.build);
|
|
1126
|
-
var _npmPackageArg = require$$5$
|
|
1124
|
+
var _npmPackageArg = require$$5$2;
|
|
1127
1125
|
var _yoctoSpinner$i = require$$3;
|
|
1128
|
-
var _semver = require$$
|
|
1126
|
+
var _semver = require$$4$2;
|
|
1129
1127
|
var _tinyglobby = require$$8$1;
|
|
1130
1128
|
var _yaml = require$$9$1;
|
|
1131
1129
|
var _registry = require$$10;
|
|
@@ -1135,16 +1133,17 @@ var _promises2 = require$$13;
|
|
|
1135
1133
|
var _regexps = require$$14;
|
|
1136
1134
|
var _strings = require$$9;
|
|
1137
1135
|
var _words = require$$5;
|
|
1136
|
+
var _constants$1 = constants.constants;
|
|
1138
1137
|
var _flags$j = flags$1;
|
|
1139
1138
|
var _formatting$k = formatting;
|
|
1140
1139
|
var _fs = fs;
|
|
1141
1140
|
var _packageManagerDetector = packageManagerDetector;
|
|
1142
1141
|
const COMMAND_TITLE = 'Socket Optimize';
|
|
1143
1142
|
const OVERRIDES_FIELD_NAME = 'overrides';
|
|
1143
|
+
const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/7025';
|
|
1144
1144
|
const PNPM_FIELD_NAME = 'pnpm';
|
|
1145
1145
|
const PNPM_WORKSPACE = 'pnpm-workspace';
|
|
1146
1146
|
const RESOLUTIONS_FIELD_NAME = 'resolutions';
|
|
1147
|
-
const distPath$1 = __dirname;
|
|
1148
1147
|
const manifestNpmOverrides = (0, _registry.getManifestData)('npm');
|
|
1149
1148
|
const getOverridesDataByAgent = {
|
|
1150
1149
|
bun(pkgJson) {
|
|
@@ -1504,7 +1503,7 @@ function getDependencyEntries(pkgJson) {
|
|
|
1504
1503
|
async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
|
|
1505
1504
|
let workspacePatterns;
|
|
1506
1505
|
if (agent === 'pnpm') {
|
|
1507
|
-
for (const workspacePath of [_nodePath$
|
|
1506
|
+
for (const workspacePath of [_nodePath$1.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), _nodePath$1.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
|
|
1508
1507
|
if ((0, _fs.existsSync)(workspacePath)) {
|
|
1509
1508
|
try {
|
|
1510
1509
|
workspacePatterns = (0, _yaml.parse)(
|
|
@@ -1575,7 +1574,7 @@ async function addOverrides({
|
|
|
1575
1574
|
} = editablePkgJson;
|
|
1576
1575
|
const isRoot = pkgPath === rootPath;
|
|
1577
1576
|
const isLockScanned = isRoot && !prod;
|
|
1578
|
-
const workspaceName = _nodePath$
|
|
1577
|
+
const workspaceName = _nodePath$1.relative(rootPath, pkgPath);
|
|
1579
1578
|
const workspaceGlobs = await getWorkspaceGlobs(agent, pkgPath, pkgJson);
|
|
1580
1579
|
const isWorkspace = !!workspaceGlobs;
|
|
1581
1580
|
if (isWorkspace && agent === 'pnpm' && npmExecPath === 'npm' && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
@@ -1694,7 +1693,7 @@ async function addOverrides({
|
|
|
1694
1693
|
manifestEntries,
|
|
1695
1694
|
npmExecPath,
|
|
1696
1695
|
pin,
|
|
1697
|
-
pkgPath: _nodePath$
|
|
1696
|
+
pkgPath: _nodePath$1.dirname(workspacePkgJsonPath),
|
|
1698
1697
|
prod,
|
|
1699
1698
|
rootPath
|
|
1700
1699
|
}, createAddOverridesState({
|
|
@@ -1758,7 +1757,7 @@ const optimize = optimize$1.optimize = {
|
|
|
1758
1757
|
console.error(`✖️ ${COMMAND_TITLE}: ${agent} does not support overrides. Soon, though ⚡`);
|
|
1759
1758
|
return;
|
|
1760
1759
|
}
|
|
1761
|
-
const lockName = lockPath ? _nodePath$
|
|
1760
|
+
const lockName = lockPath ? _nodePath$1.basename(lockPath) : 'lock file';
|
|
1762
1761
|
if (lockSrc === undefined) {
|
|
1763
1762
|
console.error(`✖️ ${COMMAND_TITLE}: No ${lockName} found`);
|
|
1764
1763
|
return;
|
|
@@ -1775,7 +1774,7 @@ const optimize = optimize$1.optimize = {
|
|
|
1775
1774
|
console.error(`✖️ ${COMMAND_TITLE}: --prod not supported for ${agent}${agentVersion ? `@${agentVersion.toString()}` : ''}`);
|
|
1776
1775
|
return;
|
|
1777
1776
|
}
|
|
1778
|
-
if (lockPath && _nodePath$
|
|
1777
|
+
if (lockPath && _nodePath$1.relative(cwd, lockPath).startsWith('.')) {
|
|
1779
1778
|
console.warn(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
|
|
1780
1779
|
}
|
|
1781
1780
|
const spinner = _yoctoSpinner$i({
|
|
@@ -1822,12 +1821,12 @@ const optimize = optimize$1.optimize = {
|
|
|
1822
1821
|
spinner.start(`Updating ${lockName}...`);
|
|
1823
1822
|
try {
|
|
1824
1823
|
if (isNpm) {
|
|
1825
|
-
const wrapperPath = _nodePath$
|
|
1826
|
-
await _promiseSpawn$2(process.execPath, [wrapperPath, 'install', '--
|
|
1824
|
+
const wrapperPath = _nodePath$1.join(_constants$1.distPath, 'npm-cli.js');
|
|
1825
|
+
await _promiseSpawn$2(process.execPath, [wrapperPath, 'install', '--silent'], {
|
|
1827
1826
|
stdio: 'ignore',
|
|
1828
1827
|
env: {
|
|
1829
1828
|
...process.env,
|
|
1830
|
-
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: '1'
|
|
1829
|
+
[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
|
|
1831
1830
|
}
|
|
1832
1831
|
});
|
|
1833
1832
|
} else {
|
|
@@ -1838,7 +1837,7 @@ const optimize = optimize$1.optimize = {
|
|
|
1838
1837
|
}
|
|
1839
1838
|
spinner.stop();
|
|
1840
1839
|
if (isNpm) {
|
|
1841
|
-
console.log(`💡 Re-run ${COMMAND_TITLE} whenever ${lockName} changes.\n This can be skipped once npm ships
|
|
1840
|
+
console.log(`💡 Re-run ${COMMAND_TITLE} whenever ${lockName} changes.\n This can be skipped once npm ships ${NPM_OVERRIDE_PR_URL}.`);
|
|
1842
1841
|
}
|
|
1843
1842
|
} catch {
|
|
1844
1843
|
spinner.error(`${COMMAND_TITLE}: ${agent} install failed to update ${lockName}`);
|
|
@@ -2089,7 +2088,7 @@ view$3.view = void 0;
|
|
|
2089
2088
|
var _yoctocolorsCjs$f = require$$1$2;
|
|
2090
2089
|
var _meow$i = _interopRequireDefault$j(vendor.build);
|
|
2091
2090
|
var _yoctoSpinner$g = require$$3;
|
|
2092
|
-
var _ponyCause$3 = require$$
|
|
2091
|
+
var _ponyCause$3 = require$$4$1;
|
|
2093
2092
|
var _flags$g = flags$1;
|
|
2094
2093
|
var _apiHelpers$g = apiHelpers;
|
|
2095
2094
|
var _colorOrMarkdown$2 = sdk.colorOrMarkdown;
|
|
@@ -2229,12 +2228,12 @@ Object.defineProperty(create$5, "__esModule", {
|
|
|
2229
2228
|
value: true
|
|
2230
2229
|
});
|
|
2231
2230
|
create$5.create = void 0;
|
|
2232
|
-
var _nodePath
|
|
2231
|
+
var _nodePath = require$$1;
|
|
2233
2232
|
var _betterAjvErrors = require$$2$1;
|
|
2234
2233
|
var _meow$h = _interopRequireDefault$i(vendor.build);
|
|
2235
2234
|
var _yoctoSpinner$f = require$$3;
|
|
2236
|
-
var _ponyCause$2 = require$$
|
|
2237
|
-
var _config = require$$6
|
|
2235
|
+
var _ponyCause$2 = require$$4$1;
|
|
2236
|
+
var _config = require$$6;
|
|
2238
2237
|
var _view$2 = view$3;
|
|
2239
2238
|
var _flags$f = flags$1;
|
|
2240
2239
|
var _apiHelpers$f = apiHelpers;
|
|
@@ -2371,7 +2370,7 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2371
2370
|
|
|
2372
2371
|
// TODO: Allow setting a custom cwd and/or configFile path?
|
|
2373
2372
|
const cwd = process.cwd();
|
|
2374
|
-
const absoluteConfigPath = _nodePath
|
|
2373
|
+
const absoluteConfigPath = _nodePath.join(cwd, 'socket.yml');
|
|
2375
2374
|
const config = await (0, _config.readSocketConfig)(absoluteConfigPath).catch(cause => {
|
|
2376
2375
|
if (cause && typeof cause === 'object' && cause instanceof _config.SocketValidationError) {
|
|
2377
2376
|
// Inspired by workbox-build:
|
|
@@ -2714,7 +2713,7 @@ var _yoctocolorsCjs$e = require$$1$2;
|
|
|
2714
2713
|
var _meow$e = _interopRequireDefault$f(vendor.build);
|
|
2715
2714
|
var _open = _interopRequireDefault$f(vendor.open);
|
|
2716
2715
|
var _yoctoSpinner$e = require$$3;
|
|
2717
|
-
var _ponyCause$1 = require$$
|
|
2716
|
+
var _ponyCause$1 = require$$4$1;
|
|
2718
2717
|
var _apiHelpers$e = apiHelpers;
|
|
2719
2718
|
var _errors$f = sdk.errors;
|
|
2720
2719
|
var _formatting$d = formatting;
|
|
@@ -4269,8 +4268,8 @@ analytics$1.analytics = void 0;
|
|
|
4269
4268
|
var _promises = require$$1$4;
|
|
4270
4269
|
var _screen$1 = require$$2$4;
|
|
4271
4270
|
var _bar = require$$3$3;
|
|
4272
|
-
var _grid = require$$4$
|
|
4273
|
-
var _line = require$$5$
|
|
4271
|
+
var _grid = require$$4$4;
|
|
4272
|
+
var _line = require$$5$3;
|
|
4274
4273
|
var _meow$2 = _interopRequireDefault$3(vendor.build);
|
|
4275
4274
|
var _yoctocolorsCjs$2 = require$$1$2;
|
|
4276
4275
|
var _yoctoSpinner$2 = require$$3;
|
|
@@ -5155,19 +5154,15 @@ const getMinDiff = (start, end) => Math.floor((end - start) / 60000);
|
|
|
5155
5154
|
|
|
5156
5155
|
var _interopRequireWildcard = vendor.interopRequireWildcard.default;
|
|
5157
5156
|
var _interopRequireDefault = vendor.interopRequireDefault.default;
|
|
5158
|
-
var _nodePath = require$$1;
|
|
5159
5157
|
var _nodeUrl = require$$8$2;
|
|
5160
5158
|
var _yoctocolorsCjs = require$$1$2;
|
|
5161
|
-
var _ponyCause = require$$
|
|
5159
|
+
var _ponyCause = require$$4$1;
|
|
5162
5160
|
var _tinyUpdater = _interopRequireDefault(vendor.dist);
|
|
5163
5161
|
var cliCommands = _interopRequireWildcard(commands, true);
|
|
5162
|
+
var _constants = constants.constants;
|
|
5164
5163
|
var _colorOrMarkdown = sdk.colorOrMarkdown;
|
|
5165
5164
|
var _errors = sdk.errors;
|
|
5166
5165
|
var _meowWithSubcommands = meowWithSubcommands$1;
|
|
5167
|
-
const distPath = __dirname;
|
|
5168
|
-
const rootPath = _nodePath.resolve(distPath, '..');
|
|
5169
|
-
const rootPkgJsonPath = _nodePath.join(rootPath, 'package.json');
|
|
5170
|
-
const rootPkgJson = require(rootPkgJsonPath);
|
|
5171
5166
|
const formattedCliCommands = Object.fromEntries(Object.entries(cliCommands).map(entry => {
|
|
5172
5167
|
const key = entry[0];
|
|
5173
5168
|
entry[0] = camelToHyphen(key);
|
|
@@ -5179,6 +5174,7 @@ function camelToHyphen(str) {
|
|
|
5179
5174
|
|
|
5180
5175
|
// TODO: Add autocompletion using https://socket.dev/npm/package/omelette
|
|
5181
5176
|
void (async () => {
|
|
5177
|
+
const rootPkgJson = require(_constants.rootPkgJsonPath);
|
|
5182
5178
|
await (0, _tinyUpdater.default)({
|
|
5183
5179
|
name: rootPkgJson.name,
|
|
5184
5180
|
version: rootPkgJson.version,
|
|
@@ -5237,7 +5233,7 @@ void (async () => {
|
|
|
5237
5233
|
return _cli.default;
|
|
5238
5234
|
}
|
|
5239
5235
|
});
|
|
5240
|
-
var _cli = _interopRequireWildcard(cli, true);
|
|
5236
|
+
var _cli = _interopRequireWildcard(cli$1, true);
|
|
5241
5237
|
Object.keys(_cli).forEach(function (key) {
|
|
5242
5238
|
if (key === "default" || key === "__esModule") return;
|
|
5243
5239
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -5249,6 +5245,8 @@ void (async () => {
|
|
|
5249
5245
|
}
|
|
5250
5246
|
});
|
|
5251
5247
|
});
|
|
5252
|
-
} (cli$
|
|
5248
|
+
} (cli$2));
|
|
5249
|
+
|
|
5250
|
+
var cli = /*@__PURE__*/vendor.getDefaultExportFromCjs(cli$2);
|
|
5253
5251
|
|
|
5254
|
-
module.exports = cli
|
|
5252
|
+
module.exports = cli;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const logSymbols: {
|
|
2
|
+
__proto__: null;
|
|
3
|
+
info: string;
|
|
4
|
+
success: string;
|
|
5
|
+
warning: string;
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
declare class ColorOrMarkdown {
|
|
9
|
+
useMarkdown: boolean;
|
|
10
|
+
constructor(useMarkdown: boolean);
|
|
11
|
+
header(text: string, level?: number): string;
|
|
12
|
+
bold(text: string): string;
|
|
13
|
+
italic(text: string): string;
|
|
14
|
+
hyperlink(text: string, url: string | undefined, { fallback, fallbackToUrl }?: {
|
|
15
|
+
fallback?: boolean;
|
|
16
|
+
fallbackToUrl?: boolean;
|
|
17
|
+
}): string;
|
|
18
|
+
list(items: string[]): string;
|
|
19
|
+
get logSymbols(): typeof logSymbols;
|
|
20
|
+
indent(text: string, level?: number): string;
|
|
21
|
+
json(value: unknown): string;
|
|
22
|
+
}
|
|
23
|
+
export { logSymbols, ColorOrMarkdown };
|
|
@@ -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,67 @@
|
|
|
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
|
+
var constants = {};
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(constants, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
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;
|
|
15
|
+
var _nodeFs = require$$0;
|
|
16
|
+
var _nodePath = require$$1;
|
|
17
|
+
var _env = require$$2;
|
|
18
|
+
var _constants = require$$3;
|
|
19
|
+
var _semver = require$$4;
|
|
20
|
+
const {
|
|
21
|
+
PACKAGE_JSON
|
|
22
|
+
} = _constants;
|
|
23
|
+
const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
|
|
24
|
+
constants.API_V0_URL = 'https://api.socket.dev/v0';
|
|
25
|
+
const DIST_TYPE = constants.DIST_TYPE = SUPPORTS_SYNC_ESM ? 'module-sync' : 'require';
|
|
26
|
+
constants.LOOP_SENTINEL = 1_000_000;
|
|
27
|
+
constants.NPM_REGISTRY_URL = 'https://registry.npmjs.org';
|
|
28
|
+
const SOCKET_CLI_ISSUES_URL = constants.SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
|
|
29
|
+
const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = constants.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
|
|
30
|
+
constants.ENV = Object.freeze({
|
|
31
|
+
// Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
|
|
32
|
+
[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: (0, _env.envAsBoolean)(process.env[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE])
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Dynamically detect the rootPath so constants.ts can be used in tests.
|
|
36
|
+
const rootPath = constants.rootPath = (() => {
|
|
37
|
+
let oldPath;
|
|
38
|
+
let currPath = (0, _nodeFs.realpathSync)(__dirname);
|
|
39
|
+
// Dirname stops when at the filepath root, e.g. '/' for posix and 'C:\\' for win32,
|
|
40
|
+
// so `currPath` equal `oldPath`.
|
|
41
|
+
while (currPath !== oldPath) {
|
|
42
|
+
const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
|
|
43
|
+
if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
|
|
44
|
+
try {
|
|
45
|
+
// Content matching @socketsecurity/cli is replaced by
|
|
46
|
+
// the @rollup/plugin-replace plugin used in .config/rollup.base.config.mjs
|
|
47
|
+
// with either 'socket' or '@socketsecurity/cli'.
|
|
48
|
+
if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
|
|
49
|
+
return currPath;
|
|
50
|
+
}
|
|
51
|
+
} catch {}
|
|
52
|
+
}
|
|
53
|
+
oldPath = currPath;
|
|
54
|
+
currPath = _nodePath.dirname(currPath);
|
|
55
|
+
}
|
|
56
|
+
throw new TypeError(`Socket CLI initialization error: rootPath cannot be resolved.\n\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`);
|
|
57
|
+
})();
|
|
58
|
+
const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
|
|
59
|
+
constants.rootBinPath = _nodePath.join(rootPath, 'bin');
|
|
60
|
+
constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
|
|
61
|
+
const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
|
|
62
|
+
constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
|
|
63
|
+
constants.distPath = _nodePath.join(rootDistPath, DIST_TYPE);
|
|
64
|
+
constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', DIST_TYPE);
|
|
65
|
+
constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
|
|
66
|
+
|
|
67
|
+
exports.constants = constants;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var require$$0 = require('node:fs');
|
|
4
|
+
var require$$1 = require('node:path');
|
|
5
|
+
var require$$4 = require('which');
|
|
6
|
+
|
|
7
|
+
var link = {};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(link, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
link.installLinks = installLinks;
|
|
13
|
+
var _nodeFs = require$$0;
|
|
14
|
+
var _nodePath = require$$1;
|
|
15
|
+
var _which = require$$4;
|
|
16
|
+
function installLinks(realDirname, binName) {
|
|
17
|
+
const realShadowBinDir = realDirname;
|
|
18
|
+
// find package manager being shadowed by this process
|
|
19
|
+
const bins = _which.sync(binName, {
|
|
20
|
+
all: true
|
|
21
|
+
});
|
|
22
|
+
let shadowIndex = -1;
|
|
23
|
+
const binPath = bins.find((binPath, i) => {
|
|
24
|
+
if ((0, _nodeFs.realpathSync)(_nodePath.dirname(binPath)) === realShadowBinDir) {
|
|
25
|
+
shadowIndex = i;
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
});
|
|
30
|
+
const isWin = process.platform === 'win32';
|
|
31
|
+
if (isWin && binPath) {
|
|
32
|
+
return binPath;
|
|
33
|
+
}
|
|
34
|
+
if (!binPath) {
|
|
35
|
+
console.error(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
36
|
+
process.exit(127);
|
|
37
|
+
}
|
|
38
|
+
if (shadowIndex === -1) {
|
|
39
|
+
const binDir = _nodePath.join(realDirname);
|
|
40
|
+
process.env['PATH'] = `${binDir}${isWin ? ';' : ':'}${process.env['PATH']}`;
|
|
41
|
+
}
|
|
42
|
+
return binPath;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.link = link;
|