socket 0.14.12 → 0.14.13
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/README.md +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +617 -430
- package/dist/npm-injection.js +9 -9
- package/dist/path-resolve.d.ts +3 -6
- package/dist/path-resolve.js +119 -70
- package/dist/vendor.js +184 -1368
- package/package.json +48 -27
package/dist/cli.js
CHANGED
|
@@ -12,6 +12,8 @@ var sdk = require('./sdk.js');
|
|
|
12
12
|
var require$$1$2 = require('@inquirer/prompts');
|
|
13
13
|
var require$$3$2 = require('@npmcli/package-json');
|
|
14
14
|
var require$$4 = require('@socketsecurity/registry');
|
|
15
|
+
var require$$6$1 = require('npm-package-arg');
|
|
16
|
+
var require$$8 = require('pacote');
|
|
15
17
|
var require$$3$1 = require('semver');
|
|
16
18
|
var require$$1$3 = require('@socketregistry/hyrious__bun.lockb');
|
|
17
19
|
var require$$3 = require('browserslist');
|
|
@@ -24,6 +26,7 @@ var require$$3$4 = require('node:readline');
|
|
|
24
26
|
var require$$0$1 = require('node:process');
|
|
25
27
|
var require$$2$2 = require('node:readline/promises');
|
|
26
28
|
var require$$2$3 = require('chalk-table');
|
|
29
|
+
var require$$1$4 = require('node:fs/promises');
|
|
27
30
|
var require$$2$4 = require('blessed');
|
|
28
31
|
var require$$3$5 = require('blessed-contrib');
|
|
29
32
|
var require$$0$2 = require('node:util');
|
|
@@ -41,7 +44,7 @@ Object.defineProperty(cdxgen, "__esModule", {
|
|
|
41
44
|
value: true
|
|
42
45
|
});
|
|
43
46
|
cdxgen.cdxgen = void 0;
|
|
44
|
-
var _nodeFs$
|
|
47
|
+
var _nodeFs$4 = require$$0;
|
|
45
48
|
var _nodePath$7 = require$$1;
|
|
46
49
|
var _promiseSpawn$6 = require$$1$1;
|
|
47
50
|
var _chalk$j = _interopRequireDefault$s(vendor.source);
|
|
@@ -168,14 +171,14 @@ cdxgen.cdxgen = {
|
|
|
168
171
|
return;
|
|
169
172
|
}
|
|
170
173
|
let cleanupPackageLock = false;
|
|
171
|
-
if (yargv.type !== 'yarn' && nodejsPlatformTypes.includes(yargv.type) && (0, _nodeFs$
|
|
172
|
-
if ((0, _nodeFs$
|
|
174
|
+
if (yargv.type !== 'yarn' && nodejsPlatformTypes.includes(yargv.type) && (0, _nodeFs$4.existsSync)('./yarn.lock')) {
|
|
175
|
+
if ((0, _nodeFs$4.existsSync)('./package-lock.json')) {
|
|
173
176
|
yargv.type = 'npm';
|
|
174
177
|
} else {
|
|
175
178
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
176
179
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
177
180
|
try {
|
|
178
|
-
await _promiseSpawn$6(execPath, [await _nodeFs$
|
|
181
|
+
await _promiseSpawn$6(execPath, [await _nodeFs$4.promises.realpath(synpBinPath), '--source-file', './yarn.lock'], {
|
|
179
182
|
shell: true
|
|
180
183
|
});
|
|
181
184
|
yargv.type = 'npm';
|
|
@@ -186,7 +189,7 @@ cdxgen.cdxgen = {
|
|
|
186
189
|
if (yargv.output === undefined) {
|
|
187
190
|
yargv.output = 'socket-cdx.json';
|
|
188
191
|
}
|
|
189
|
-
await _promiseSpawn$6(execPath, [await _nodeFs$
|
|
192
|
+
await _promiseSpawn$6(execPath, [await _nodeFs$4.promises.realpath(cdxgenBinPath), ...argvToArray(yargv)], {
|
|
190
193
|
env: {
|
|
191
194
|
NODE_ENV: '',
|
|
192
195
|
SBOM_SIGN_ALGORITHM,
|
|
@@ -198,11 +201,11 @@ cdxgen.cdxgen = {
|
|
|
198
201
|
});
|
|
199
202
|
if (cleanupPackageLock) {
|
|
200
203
|
try {
|
|
201
|
-
await _nodeFs$
|
|
204
|
+
await _nodeFs$4.promises.unlink('./package-lock.json');
|
|
202
205
|
} catch {}
|
|
203
206
|
}
|
|
204
207
|
const fullOutputPath = _nodePath$7.join(process.cwd(), yargv.output);
|
|
205
|
-
if ((0, _nodeFs$
|
|
208
|
+
if ((0, _nodeFs$4.existsSync)(fullOutputPath)) {
|
|
206
209
|
console.log(_chalk$j.default.cyanBright(`${yargv.output} created!`));
|
|
207
210
|
}
|
|
208
211
|
}
|
|
@@ -215,7 +218,15 @@ var flags$1 = {};
|
|
|
215
218
|
Object.defineProperty(flags$1, "__esModule", {
|
|
216
219
|
value: true
|
|
217
220
|
});
|
|
218
|
-
flags$1.validationFlags = flags$1.outputFlags = flags$1.commandFlags = void 0;
|
|
221
|
+
flags$1.validationFlags = flags$1.outputFlags = flags$1.commonFlags = flags$1.commandFlags = void 0;
|
|
222
|
+
flags$1.commonFlags = {
|
|
223
|
+
help: {
|
|
224
|
+
type: 'boolean',
|
|
225
|
+
default: false,
|
|
226
|
+
shortFlag: 'h',
|
|
227
|
+
description: 'Print this help.'
|
|
228
|
+
}
|
|
229
|
+
};
|
|
219
230
|
flags$1.commandFlags = {
|
|
220
231
|
enable: {
|
|
221
232
|
type: 'boolean',
|
|
@@ -313,15 +324,10 @@ var objects = {};
|
|
|
313
324
|
Object.defineProperty(objects, "__esModule", {
|
|
314
325
|
value: true
|
|
315
326
|
});
|
|
316
|
-
objects.getOwn = getOwn;
|
|
317
327
|
objects.hasOwn = hasOwn;
|
|
318
328
|
objects.isObjectObject = isObjectObject;
|
|
319
329
|
objects.objectSome = objectSome;
|
|
320
330
|
objects.pick = pick;
|
|
321
|
-
function getOwn(obj, propKey) {
|
|
322
|
-
if (obj === null || obj === undefined) return undefined;
|
|
323
|
-
return Object.hasOwn(obj, propKey) ? obj[propKey] : undefined;
|
|
324
|
-
}
|
|
325
331
|
function hasOwn(obj, propKey) {
|
|
326
332
|
if (obj === null || obj === undefined) return false;
|
|
327
333
|
return Object.hasOwn(obj, propKey);
|
|
@@ -403,8 +409,6 @@ function printFlagList(list, indent, {
|
|
|
403
409
|
padName
|
|
404
410
|
} = {}) {
|
|
405
411
|
return printHelpList({
|
|
406
|
-
help: 'Print this help and exits.',
|
|
407
|
-
version: 'Prints current version and exits.',
|
|
408
412
|
...list
|
|
409
413
|
}, indent, {
|
|
410
414
|
keyPrefix,
|
|
@@ -415,8 +419,8 @@ function printHelpList(list, indent, {
|
|
|
415
419
|
keyPrefix = '',
|
|
416
420
|
padName = 18
|
|
417
421
|
} = {}) {
|
|
418
|
-
const names = Object.keys(list).sort();
|
|
419
422
|
let result = '';
|
|
423
|
+
const names = Object.keys(list).sort();
|
|
420
424
|
for (const name of names) {
|
|
421
425
|
const rawDescription = list[name];
|
|
422
426
|
const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
|
|
@@ -433,7 +437,7 @@ info$1.info = void 0;
|
|
|
433
437
|
var _chalk$h = _interopRequireDefault$q(vendor.source);
|
|
434
438
|
var _meow$p = _interopRequireDefault$q(vendor.build);
|
|
435
439
|
var _ora$l = _interopRequireDefault$q(vendor.ora);
|
|
436
|
-
var _flags$
|
|
440
|
+
var _flags$k = flags$1;
|
|
437
441
|
var _apiHelpers$i = apiHelpers;
|
|
438
442
|
var _chalkMarkdown$3 = sdk.chalkMarkdown;
|
|
439
443
|
var _errors$k = sdk.errors;
|
|
@@ -467,8 +471,9 @@ const info = info$1.info = {
|
|
|
467
471
|
function setupCommand$m(name, description, argv, importMeta) {
|
|
468
472
|
const flags = {
|
|
469
473
|
__proto__: null,
|
|
470
|
-
..._flags$
|
|
471
|
-
..._flags$
|
|
474
|
+
..._flags$k.commonFlags,
|
|
475
|
+
..._flags$k.outputFlags,
|
|
476
|
+
..._flags$k.validationFlags
|
|
472
477
|
};
|
|
473
478
|
const cli = (0, _meow$p.default)(`
|
|
474
479
|
Usage
|
|
@@ -486,19 +491,17 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
486
491
|
importMeta,
|
|
487
492
|
flags
|
|
488
493
|
});
|
|
489
|
-
const {
|
|
490
|
-
all: includeAllIssues,
|
|
491
|
-
json: outputJson,
|
|
492
|
-
markdown: outputMarkdown,
|
|
493
|
-
strict
|
|
494
|
-
} = cli.flags;
|
|
495
494
|
if (cli.input.length > 1) {
|
|
496
495
|
throw new _errors$k.InputError('Only one package lookup supported at once');
|
|
497
496
|
}
|
|
498
497
|
const {
|
|
499
498
|
0: rawPkgName = ''
|
|
500
499
|
} = cli.input;
|
|
500
|
+
let showHelp = cli.flags['help'];
|
|
501
501
|
if (!rawPkgName) {
|
|
502
|
+
showHelp = true;
|
|
503
|
+
}
|
|
504
|
+
if (showHelp) {
|
|
502
505
|
cli.showHelp();
|
|
503
506
|
return;
|
|
504
507
|
}
|
|
@@ -506,12 +509,12 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
506
509
|
const pkgName = versionSeparator < 1 ? rawPkgName : rawPkgName.slice(0, versionSeparator);
|
|
507
510
|
const pkgVersion = versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1);
|
|
508
511
|
return {
|
|
509
|
-
includeAllIssues,
|
|
510
|
-
outputJson,
|
|
511
|
-
outputMarkdown,
|
|
512
|
+
includeAllIssues: cli.flags['all'],
|
|
513
|
+
outputJson: cli.flags['json'],
|
|
514
|
+
outputMarkdown: cli.flags['markdown'],
|
|
512
515
|
pkgName,
|
|
513
516
|
pkgVersion,
|
|
514
|
-
strict
|
|
517
|
+
strict: cli.flags['strict']
|
|
515
518
|
};
|
|
516
519
|
}
|
|
517
520
|
async function fetchPackageData(pkgName, pkgVersion, {
|
|
@@ -654,6 +657,9 @@ const flags = {
|
|
|
654
657
|
description: 'Proxy to use when making connection to API server'
|
|
655
658
|
}
|
|
656
659
|
};
|
|
660
|
+
function nonNullish(value) {
|
|
661
|
+
return value !== null && value !== undefined;
|
|
662
|
+
}
|
|
657
663
|
login.login = {
|
|
658
664
|
description: description$7,
|
|
659
665
|
async run(argv, importMeta, {
|
|
@@ -680,8 +686,13 @@ login.login = {
|
|
|
680
686
|
importMeta,
|
|
681
687
|
flags
|
|
682
688
|
});
|
|
689
|
+
let showHelp = cli.flags['help'];
|
|
683
690
|
if (cli.input.length) {
|
|
691
|
+
showHelp = true;
|
|
692
|
+
}
|
|
693
|
+
if (showHelp) {
|
|
684
694
|
cli.showHelp();
|
|
695
|
+
return;
|
|
685
696
|
}
|
|
686
697
|
if (!(0, _isInteractive.default)()) {
|
|
687
698
|
throw new _errors$j.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
@@ -707,7 +718,6 @@ login.login = {
|
|
|
707
718
|
spinner.fail('Invalid API key');
|
|
708
719
|
return;
|
|
709
720
|
}
|
|
710
|
-
const nonNullish = value => value != null;
|
|
711
721
|
const enforcedChoices = Object.values(orgs.organizations).filter(nonNullish).filter(org => org.plan === 'enterprise').map(org => ({
|
|
712
722
|
name: org.name,
|
|
713
723
|
value: org.id
|
|
@@ -776,8 +786,13 @@ logout.logout = {
|
|
|
776
786
|
description: description$6,
|
|
777
787
|
importMeta
|
|
778
788
|
});
|
|
789
|
+
let showHelp = cli.flags['help'];
|
|
779
790
|
if (cli.input.length) {
|
|
791
|
+
showHelp = true;
|
|
792
|
+
}
|
|
793
|
+
if (showHelp) {
|
|
780
794
|
cli.showHelp();
|
|
795
|
+
return;
|
|
781
796
|
}
|
|
782
797
|
(0, _settings.updateSetting)('apiKey', null);
|
|
783
798
|
(0, _settings.updateSetting)('apiBaseUrl', null);
|
|
@@ -858,11 +873,11 @@ fs.existsSync = existsSync;
|
|
|
858
873
|
fs.findUp = findUp;
|
|
859
874
|
fs.readFileBinary = readFileBinary;
|
|
860
875
|
fs.readFileUtf8 = readFileUtf8;
|
|
861
|
-
var _nodeFs$
|
|
876
|
+
var _nodeFs$3 = require$$0;
|
|
862
877
|
var _nodePath$4 = require$$1;
|
|
863
878
|
function existsSync(filepath) {
|
|
864
879
|
try {
|
|
865
|
-
return filepath ? (0, _nodeFs$
|
|
880
|
+
return filepath ? (0, _nodeFs$3.existsSync)(filepath) : false;
|
|
866
881
|
} catch {}
|
|
867
882
|
return false;
|
|
868
883
|
}
|
|
@@ -879,7 +894,7 @@ async function findUp(name, {
|
|
|
879
894
|
const filePath = _nodePath$4.join(dir, name);
|
|
880
895
|
try {
|
|
881
896
|
// eslint-disable-next-line no-await-in-loop
|
|
882
|
-
const stats = await _nodeFs$
|
|
897
|
+
const stats = await _nodeFs$3.promises.stat(filePath);
|
|
883
898
|
if (stats.isFile()) {
|
|
884
899
|
return filePath;
|
|
885
900
|
}
|
|
@@ -890,13 +905,13 @@ async function findUp(name, {
|
|
|
890
905
|
return undefined;
|
|
891
906
|
}
|
|
892
907
|
async function readFileBinary(filepath, options) {
|
|
893
|
-
return await _nodeFs$
|
|
908
|
+
return await _nodeFs$3.promises.readFile(filepath, {
|
|
894
909
|
...options,
|
|
895
910
|
encoding: 'binary'
|
|
896
911
|
});
|
|
897
912
|
}
|
|
898
913
|
async function readFileUtf8(filepath, options) {
|
|
899
|
-
return await _nodeFs$
|
|
914
|
+
return await _nodeFs$3.promises.readFile(filepath, {
|
|
900
915
|
...options,
|
|
901
916
|
encoding: 'utf8'
|
|
902
917
|
});
|
|
@@ -932,7 +947,7 @@ function isNonEmptyString(value) {
|
|
|
932
947
|
Object.defineProperty(packageManagerDetector, "__esModule", {
|
|
933
948
|
value: true
|
|
934
949
|
});
|
|
935
|
-
packageManagerDetector.
|
|
950
|
+
packageManagerDetector.AGENTS = void 0;
|
|
936
951
|
packageManagerDetector.detect = detect;
|
|
937
952
|
var _nodePath$3 = require$$1;
|
|
938
953
|
var _hyrious__bun = require$$1$3;
|
|
@@ -943,10 +958,41 @@ var _which = require$$5$1;
|
|
|
943
958
|
var _fs = fs;
|
|
944
959
|
var _json = json;
|
|
945
960
|
var _objects$1 = objects;
|
|
946
|
-
var _strings = strings;
|
|
947
|
-
const PNPM_WORKSPACE = 'pnpm-workspace';
|
|
961
|
+
var _strings$1 = strings;
|
|
948
962
|
const AGENTS = packageManagerDetector.AGENTS = ['bun', 'npm', 'pnpm', 'yarn'];
|
|
949
|
-
const
|
|
963
|
+
const numericCollator = new Intl.Collator(undefined, {
|
|
964
|
+
numeric: true,
|
|
965
|
+
sensitivity: 'base'
|
|
966
|
+
});
|
|
967
|
+
const {
|
|
968
|
+
compare: alphaNumericComparator
|
|
969
|
+
} = numericCollator;
|
|
970
|
+
const maintainedNodeVersions = (() => {
|
|
971
|
+
// Under the hood browserlist uses the node-releases package which is out of date:
|
|
972
|
+
// https://github.com/chicoxyzzy/node-releases/issues/37
|
|
973
|
+
// So we maintain a manual version list for now.
|
|
974
|
+
// https://nodejs.org/en/about/previous-releases#looking-for-latest-release-of-a-version-branch
|
|
975
|
+
const manualPrev = '18.20.4';
|
|
976
|
+
const manualCurr = '20.18.0';
|
|
977
|
+
const manualNext = '22.10.0';
|
|
978
|
+
const query = _browserslist('maintained node versions')
|
|
979
|
+
// Trim value, e.g. 'node 22.5.0' to '22.5.0'.
|
|
980
|
+
.map(s => s.slice(5 /*'node '.length*/))
|
|
981
|
+
// Sort ascending.
|
|
982
|
+
.toSorted(alphaNumericComparator);
|
|
983
|
+
const queryPrev = query.at(0) ?? manualPrev;
|
|
984
|
+
const queryCurr = query.at(1) ?? manualCurr;
|
|
985
|
+
const queryNext = query.at(2) ?? manualNext;
|
|
986
|
+
const previous = _semver$1.maxSatisfying([queryPrev, manualPrev], `^${_semver$1.major(queryPrev)}`);
|
|
987
|
+
const current = _semver$1.maxSatisfying([queryCurr, manualCurr], `^${_semver$1.major(queryCurr)}`);
|
|
988
|
+
const next = _semver$1.maxSatisfying([queryNext, manualNext], `^${_semver$1.major(queryNext)}`);
|
|
989
|
+
return Object.freeze(Object.assign([previous, current, next], {
|
|
990
|
+
previous,
|
|
991
|
+
current,
|
|
992
|
+
next
|
|
993
|
+
}));
|
|
994
|
+
})();
|
|
995
|
+
const LOCKS = {
|
|
950
996
|
'bun.lockb': 'bun',
|
|
951
997
|
'pnpm-lock.yaml': 'pnpm',
|
|
952
998
|
'pnpm-lock.yml': 'pnpm',
|
|
@@ -964,16 +1010,16 @@ const LOCKS = packageManagerDetector.LOCKS = {
|
|
|
964
1010
|
// it has to be handled differently.
|
|
965
1011
|
'node_modules/.package-lock.json': 'npm'
|
|
966
1012
|
};
|
|
967
|
-
const
|
|
968
|
-
// Trim value, e.g. 'node 22.5.0' to '22.5.0'
|
|
969
|
-
.map(v => v.slice(5));
|
|
1013
|
+
const PNPM_WORKSPACE = 'pnpm-workspace';
|
|
970
1014
|
const readLockFileByAgent = (() => {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1015
|
+
function wrapReader(reader) {
|
|
1016
|
+
return async (lockPath, agentExecPath) => {
|
|
1017
|
+
try {
|
|
1018
|
+
return await reader(lockPath, agentExecPath);
|
|
1019
|
+
} catch {}
|
|
1020
|
+
return undefined;
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
977
1023
|
return {
|
|
978
1024
|
bun: wrapReader(async (lockPath, agentExecPath) => {
|
|
979
1025
|
let lockBuffer;
|
|
@@ -987,7 +1033,7 @@ const readLockFileByAgent = (() => {
|
|
|
987
1033
|
} catch {}
|
|
988
1034
|
// To print a Yarn lockfile to your console without writing it to disk use `bun bun.lockb`.
|
|
989
1035
|
// https://bun.sh/guides/install/yarnlock
|
|
990
|
-
return (await _promiseSpawn$3(agentExecPath
|
|
1036
|
+
return (await _promiseSpawn$3(agentExecPath, [lockPath])).stdout;
|
|
991
1037
|
}),
|
|
992
1038
|
npm: wrapReader(async lockPath => await (0, _fs.readFileUtf8)(lockPath)),
|
|
993
1039
|
pnpm: wrapReader(async lockPath => await (0, _fs.readFileUtf8)(lockPath)),
|
|
@@ -1009,7 +1055,7 @@ async function detect({
|
|
|
1009
1055
|
// https://nodejs.org/api/packages.html#packagemanager
|
|
1010
1056
|
const pkgJsonStr = (0, _fs.existsSync)(pkgJsonPath) ? await (0, _fs.readFileUtf8)(pkgJsonPath) : undefined;
|
|
1011
1057
|
const pkgJson = typeof pkgJsonStr === 'string' ? (0, _json.parseJSONObject)(pkgJsonStr) ?? undefined : undefined;
|
|
1012
|
-
const pkgManager = (0, _strings
|
|
1058
|
+
const pkgManager = (0, _strings$1.isNonEmptyString)(pkgJson?.['packageManager']) ? pkgJson['packageManager'] : undefined;
|
|
1013
1059
|
let agent;
|
|
1014
1060
|
let agentVersion;
|
|
1015
1061
|
if (pkgManager) {
|
|
@@ -1033,50 +1079,44 @@ async function detect({
|
|
|
1033
1079
|
const agentExecPath = (await _which(agent, {
|
|
1034
1080
|
nothrow: true
|
|
1035
1081
|
})) ?? agent;
|
|
1036
|
-
let lockSrc;
|
|
1037
1082
|
const targets = {
|
|
1038
1083
|
browser: false,
|
|
1039
1084
|
node: true
|
|
1040
1085
|
};
|
|
1086
|
+
let lockSrc;
|
|
1041
1087
|
let isPrivate = false;
|
|
1042
1088
|
let isWorkspace = false;
|
|
1089
|
+
let minimumNodeVersion = maintainedNodeVersions.previous;
|
|
1043
1090
|
if (pkgJson) {
|
|
1044
1091
|
const pkgPath = _nodePath$3.dirname(pkgJsonPath);
|
|
1045
1092
|
isPrivate = !!pkgJson['private'];
|
|
1046
1093
|
isWorkspace = !!pkgJson['workspaces'] || (0, _fs.existsSync)(_nodePath$3.join(pkgPath, `${PNPM_WORKSPACE}.yaml`)) || (0, _fs.existsSync)(_nodePath$3.join(pkgPath, `${PNPM_WORKSPACE}.yml`));
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
if ((0, _strings.isNonEmptyString)(browserField) || (0, _objects$1.isObjectObject)(browserField)) {
|
|
1051
|
-
browser = true;
|
|
1094
|
+
const browserField = pkgJson['browser'];
|
|
1095
|
+
if ((0, _strings$1.isNonEmptyString)(browserField) || (0, _objects$1.isObjectObject)(browserField)) {
|
|
1096
|
+
targets.browser = true;
|
|
1052
1097
|
}
|
|
1053
|
-
const nodeRange =
|
|
1054
|
-
if ((0, _strings.isNonEmptyString)(nodeRange)) {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1098
|
+
const nodeRange = pkgJson['engines']?.['node'];
|
|
1099
|
+
if ((0, _strings$1.isNonEmptyString)(nodeRange)) {
|
|
1100
|
+
const coerced = _semver$1.coerce(nodeRange);
|
|
1101
|
+
if (coerced && _semver$1.lt(coerced, minimumNodeVersion)) {
|
|
1102
|
+
minimumNodeVersion = coerced.version;
|
|
1103
|
+
}
|
|
1059
1104
|
}
|
|
1060
|
-
const browserslistQuery =
|
|
1105
|
+
const browserslistQuery = pkgJson['browserslist'];
|
|
1061
1106
|
if (Array.isArray(browserslistQuery)) {
|
|
1062
|
-
const browserslistTargets = _browserslist(browserslistQuery);
|
|
1063
|
-
const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5));
|
|
1064
|
-
if (browser
|
|
1065
|
-
browser = browserslistTargets.length !== browserslistNodeTargets.length;
|
|
1107
|
+
const browserslistTargets = _browserslist(browserslistQuery).map(s => s.toLowerCase()).toSorted(alphaNumericComparator);
|
|
1108
|
+
const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5 /*'node '.length*/));
|
|
1109
|
+
if (!targets.browser && browserslistTargets.length) {
|
|
1110
|
+
targets.browser = browserslistTargets.length !== browserslistNodeTargets.length;
|
|
1066
1111
|
}
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1112
|
+
if (browserslistNodeTargets.length) {
|
|
1113
|
+
const coerced = _semver$1.coerce(browserslistNodeTargets[0]);
|
|
1114
|
+
if (coerced && _semver$1.lt(coerced, minimumNodeVersion)) {
|
|
1115
|
+
minimumNodeVersion = coerced.version;
|
|
1116
|
+
}
|
|
1072
1117
|
}
|
|
1073
1118
|
}
|
|
1074
|
-
|
|
1075
|
-
targets.browser = browser;
|
|
1076
|
-
}
|
|
1077
|
-
if (node !== undefined) {
|
|
1078
|
-
targets.node = node;
|
|
1079
|
-
}
|
|
1119
|
+
targets.node = maintainedNodeVersions.some(v => _semver$1.satisfies(v, `>=${minimumNodeVersion}`));
|
|
1080
1120
|
lockSrc = typeof lockPath === 'string' ? await readLockFileByAgent[agent](lockPath, agentExecPath) : undefined;
|
|
1081
1121
|
} else {
|
|
1082
1122
|
lockPath = undefined;
|
|
@@ -1089,6 +1129,7 @@ async function detect({
|
|
|
1089
1129
|
isWorkspace,
|
|
1090
1130
|
lockPath,
|
|
1091
1131
|
lockSrc,
|
|
1132
|
+
minimumNodeVersion,
|
|
1092
1133
|
pkgJson,
|
|
1093
1134
|
pkgJsonPath,
|
|
1094
1135
|
pkgJsonStr,
|
|
@@ -1097,6 +1138,57 @@ async function detect({
|
|
|
1097
1138
|
};
|
|
1098
1139
|
}
|
|
1099
1140
|
|
|
1141
|
+
var promises = {};
|
|
1142
|
+
|
|
1143
|
+
var arrays = {};
|
|
1144
|
+
|
|
1145
|
+
Object.defineProperty(arrays, "__esModule", {
|
|
1146
|
+
value: true
|
|
1147
|
+
});
|
|
1148
|
+
arrays.arrayChunk = arrayChunk;
|
|
1149
|
+
arrays.arrayUnique = arrayUnique;
|
|
1150
|
+
function arrayChunk(arr, size = 2) {
|
|
1151
|
+
const {
|
|
1152
|
+
length
|
|
1153
|
+
} = arr;
|
|
1154
|
+
const chunkSize = Math.min(length, size);
|
|
1155
|
+
const chunks = [];
|
|
1156
|
+
for (let i = 0; i < length; i += chunkSize) {
|
|
1157
|
+
chunks.push(arr.slice(i, i + chunkSize));
|
|
1158
|
+
}
|
|
1159
|
+
return chunks;
|
|
1160
|
+
}
|
|
1161
|
+
function arrayUnique(arr) {
|
|
1162
|
+
return [...new Set(arr)];
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
Object.defineProperty(promises, "__esModule", {
|
|
1166
|
+
value: true
|
|
1167
|
+
});
|
|
1168
|
+
promises.pEach = pEach;
|
|
1169
|
+
promises.pEachChunk = pEachChunk;
|
|
1170
|
+
var _arrays = arrays;
|
|
1171
|
+
async function pEach(array, concurrency, callbackFn, options) {
|
|
1172
|
+
await pEachChunk((0, _arrays.arrayChunk)(array, concurrency), callbackFn, options);
|
|
1173
|
+
}
|
|
1174
|
+
async function pEachChunk(chunks, callbackFn, options) {
|
|
1175
|
+
const {
|
|
1176
|
+
signal
|
|
1177
|
+
} = {
|
|
1178
|
+
__proto__: null,
|
|
1179
|
+
...options
|
|
1180
|
+
};
|
|
1181
|
+
for (const chunk of chunks) {
|
|
1182
|
+
if (signal?.aborted) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1186
|
+
await Promise.all(chunk.map(value => signal?.aborted ? undefined : callbackFn(value, {
|
|
1187
|
+
signal
|
|
1188
|
+
})));
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1100
1192
|
var regexps = {};
|
|
1101
1193
|
|
|
1102
1194
|
Object.defineProperty(regexps, "__esModule", {
|
|
@@ -1138,20 +1230,24 @@ var _promiseSpawn$2 = require$$1$1;
|
|
|
1138
1230
|
var _packageJson = require$$3$2;
|
|
1139
1231
|
var _registry = require$$4;
|
|
1140
1232
|
var _meow$m = _interopRequireDefault$n(vendor.build);
|
|
1233
|
+
var _npmPackageArg = require$$6$1;
|
|
1141
1234
|
var _ora$i = _interopRequireDefault$n(vendor.ora);
|
|
1235
|
+
var _pacote = require$$8;
|
|
1142
1236
|
var _semver = require$$3$1;
|
|
1237
|
+
var _flags$j = flags$1;
|
|
1143
1238
|
var _formatting$k = formatting;
|
|
1144
1239
|
var _objects = objects;
|
|
1145
1240
|
var _packageManagerDetector = packageManagerDetector;
|
|
1241
|
+
var _promises$2 = promises;
|
|
1146
1242
|
var _regexps = regexps;
|
|
1147
1243
|
var _sorts$1 = sorts;
|
|
1244
|
+
var _strings = strings;
|
|
1148
1245
|
const distPath$1 = __dirname;
|
|
1149
1246
|
const COMMAND_TITLE = 'Socket Optimize';
|
|
1150
1247
|
const OVERRIDES_FIELD_NAME = 'overrides';
|
|
1151
1248
|
const RESOLUTIONS_FIELD_NAME = 'resolutions';
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
}) => d.engines?.node?.startsWith('>=18'));
|
|
1249
|
+
const manifestNpmOverrides = (0, _registry.getManifestData)('npm');
|
|
1250
|
+
const packumentCache = new Map();
|
|
1155
1251
|
const getOverridesDataByAgent = {
|
|
1156
1252
|
// npm overrides documentation:
|
|
1157
1253
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
|
|
@@ -1238,11 +1334,10 @@ async function addOverrides({
|
|
|
1238
1334
|
isWorkspace,
|
|
1239
1335
|
lockSrc,
|
|
1240
1336
|
lockIncludes,
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
} = aoState;
|
|
1337
|
+
manifestEntries,
|
|
1338
|
+
pkgJsonPath,
|
|
1339
|
+
pin
|
|
1340
|
+
}, state) {
|
|
1246
1341
|
const editablePkgJson = await _packageJson.load(_nodePath$2.dirname(pkgJsonPath));
|
|
1247
1342
|
const {
|
|
1248
1343
|
dependencies,
|
|
@@ -1271,10 +1366,12 @@ async function addOverrides({
|
|
|
1271
1366
|
} else {
|
|
1272
1367
|
overridesDataObjects.push(getOverridesDataByAgent['npm'](editablePkgJson.content), getOverridesDataByAgent['yarn'](editablePkgJson.content));
|
|
1273
1368
|
}
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1369
|
+
const depAliasMap = new Map();
|
|
1370
|
+
const spinner = (0, _ora$i.default)(`Fetching override manifests...`).start();
|
|
1371
|
+
// Chunk package names to process them in parallel 3 at a time.
|
|
1372
|
+
await (0, _promises$2.pEach)(manifestEntries, 3, async ({
|
|
1276
1373
|
1: data
|
|
1277
|
-
}
|
|
1374
|
+
}) => {
|
|
1278
1375
|
const {
|
|
1279
1376
|
name: regPkgName,
|
|
1280
1377
|
package: origPkgName,
|
|
@@ -1285,145 +1382,194 @@ async function addOverrides({
|
|
|
1285
1382
|
} of depEntries) {
|
|
1286
1383
|
let pkgSpec = depObj[origPkgName];
|
|
1287
1384
|
if (pkgSpec) {
|
|
1385
|
+
let thisVersion = version;
|
|
1288
1386
|
// Add package aliases for direct dependencies to avoid npm EOVERRIDE errors.
|
|
1289
1387
|
// https://docs.npmjs.com/cli/v8/using-npm/package-spec#aliases
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1388
|
+
const specStartsWith = `npm:${regPkgName}@`;
|
|
1389
|
+
const existingVersion = pkgSpec.startsWith(specStartsWith) ? _semver.coerce(_npmPackageArg(pkgSpec).rawSpec)?.version ?? '' : '';
|
|
1390
|
+
if (existingVersion) {
|
|
1391
|
+
thisVersion = existingVersion;
|
|
1293
1392
|
} else {
|
|
1294
|
-
|
|
1295
|
-
pkgSpec = `${overrideSpecPrefix}^${version}`;
|
|
1393
|
+
pkgSpec = `${specStartsWith}^${version}`;
|
|
1296
1394
|
depObj[origPkgName] = pkgSpec;
|
|
1395
|
+
state.added.add(regPkgName);
|
|
1297
1396
|
}
|
|
1298
|
-
|
|
1397
|
+
depAliasMap.set(origPkgName, {
|
|
1398
|
+
id: pkgSpec,
|
|
1399
|
+
version: thisVersion
|
|
1400
|
+
});
|
|
1299
1401
|
}
|
|
1300
1402
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
overrides
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
// With npm
|
|
1309
|
-
//
|
|
1403
|
+
// Chunk package names to process them in parallel 3 at a time.
|
|
1404
|
+
await (0, _promises$2.pEach)(overridesDataObjects, 3, async ({
|
|
1405
|
+
overrides,
|
|
1406
|
+
type
|
|
1407
|
+
}) => {
|
|
1408
|
+
const overrideExists = (0, _objects.hasOwn)(overrides, origPkgName);
|
|
1409
|
+
if (overrideExists || lockIncludes(lockSrc, origPkgName)) {
|
|
1410
|
+
// With npm one may not set an override for a package that one directly
|
|
1411
|
+
// depends on unless both the dependency and the override itself share
|
|
1310
1412
|
// the exact same spec. To make this limitation easier to deal with,
|
|
1311
1413
|
// overrides may also be defined as a reference to a spec for a direct
|
|
1312
|
-
// dependency by prefixing the name of the package
|
|
1313
|
-
//
|
|
1414
|
+
// dependency by prefixing the name of the package to match the version
|
|
1415
|
+
// of with a $.
|
|
1314
1416
|
// https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
|
|
1315
|
-
|
|
1417
|
+
const oldSpec = overrides[origPkgName];
|
|
1418
|
+
const depAlias = depAliasMap.get(origPkgName);
|
|
1419
|
+
const thisVersion = overrideExists && (0, _strings.isNonEmptyString)(oldSpec) ? (await fetchPackageManifest(oldSpec.startsWith('$') ? depAlias?.id ?? oldSpec : oldSpec))?.version ?? version : version;
|
|
1420
|
+
const newSpec = depAlias && type === 'npm' ? `$${origPkgName}` : `npm:${regPkgName}@^${pin ? thisVersion : _semver.major(thisVersion)}`;
|
|
1421
|
+
if (newSpec !== oldSpec) {
|
|
1422
|
+
if (overrideExists) {
|
|
1423
|
+
state.updated.add(regPkgName);
|
|
1424
|
+
} else {
|
|
1425
|
+
state.added.add(regPkgName);
|
|
1426
|
+
}
|
|
1427
|
+
overrides[origPkgName] = newSpec;
|
|
1428
|
+
}
|
|
1316
1429
|
}
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1430
|
+
});
|
|
1431
|
+
});
|
|
1432
|
+
spinner.stop();
|
|
1433
|
+
if (state.added.size || state.updated.size) {
|
|
1320
1434
|
editablePkgJson.update(Object.fromEntries(depEntries));
|
|
1321
1435
|
for (const {
|
|
1322
|
-
|
|
1323
|
-
|
|
1436
|
+
overrides,
|
|
1437
|
+
type
|
|
1324
1438
|
} of overridesDataObjects) {
|
|
1325
1439
|
updateManifestByAgent[type](editablePkgJson, (0, _sorts$1.toSortedObject)(overrides));
|
|
1326
1440
|
}
|
|
1327
1441
|
await editablePkgJson.save();
|
|
1328
1442
|
}
|
|
1329
|
-
return
|
|
1443
|
+
return state;
|
|
1444
|
+
}
|
|
1445
|
+
async function fetchPackageManifest(pkgNameOrId, options) {
|
|
1446
|
+
const pacoteOptions = {
|
|
1447
|
+
__proto__: null,
|
|
1448
|
+
...options,
|
|
1449
|
+
packumentCache,
|
|
1450
|
+
preferOffline: true
|
|
1451
|
+
};
|
|
1452
|
+
const {
|
|
1453
|
+
signal
|
|
1454
|
+
} = pacoteOptions;
|
|
1455
|
+
if (signal?.aborted) {
|
|
1456
|
+
return null;
|
|
1457
|
+
}
|
|
1458
|
+
let result;
|
|
1459
|
+
try {
|
|
1460
|
+
result = await _pacote.manifest(pkgNameOrId, pacoteOptions);
|
|
1461
|
+
} catch {}
|
|
1462
|
+
if (signal?.aborted) {
|
|
1463
|
+
return null;
|
|
1464
|
+
}
|
|
1465
|
+
return result;
|
|
1330
1466
|
}
|
|
1331
1467
|
const optimize = optimize$1.optimize = {
|
|
1332
1468
|
description: 'Optimize dependencies with @socketregistry overrides',
|
|
1333
1469
|
async run(argv, importMeta, {
|
|
1334
1470
|
parentName
|
|
1335
1471
|
}) {
|
|
1336
|
-
const commandContext = setupCommand$l(`${parentName}
|
|
1337
|
-
if (commandContext) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1472
|
+
const commandContext = setupCommand$l(`${parentName} optimize`, optimize.description, argv, importMeta);
|
|
1473
|
+
if (!commandContext) {
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
const {
|
|
1477
|
+
pin
|
|
1478
|
+
} = commandContext;
|
|
1479
|
+
const cwd = process.cwd();
|
|
1480
|
+
const {
|
|
1481
|
+
agent,
|
|
1482
|
+
agentExecPath,
|
|
1483
|
+
isPrivate,
|
|
1484
|
+
isWorkspace,
|
|
1485
|
+
lockSrc,
|
|
1486
|
+
lockPath,
|
|
1487
|
+
minimumNodeVersion,
|
|
1488
|
+
pkgJsonPath,
|
|
1489
|
+
pkgJson,
|
|
1490
|
+
supported
|
|
1491
|
+
} = await (0, _packageManagerDetector.detect)({
|
|
1492
|
+
cwd,
|
|
1493
|
+
onUnknown(pkgManager) {
|
|
1494
|
+
console.log(`⚠️ ${COMMAND_TITLE}: Unknown package manager${pkgManager ? ` ${pkgManager}` : ''}, defaulting to npm`);
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
if (!supported) {
|
|
1498
|
+
console.log(`✘ ${COMMAND_TITLE}: No supported Node or browser range detected`);
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
const lockName = lockPath ? _nodePath$2.basename(lockPath) : 'lock file';
|
|
1502
|
+
if (lockSrc === undefined) {
|
|
1503
|
+
console.log(`✘ ${COMMAND_TITLE}: No ${lockName} found`);
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
if (pkgJson === undefined) {
|
|
1507
|
+
console.log(`✘ ${COMMAND_TITLE}: No package.json found`);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (lockPath && _nodePath$2.relative(cwd, lockPath).startsWith('.')) {
|
|
1511
|
+
console.log(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
|
|
1512
|
+
}
|
|
1513
|
+
const state = {
|
|
1514
|
+
added: new Set(),
|
|
1515
|
+
updated: new Set()
|
|
1516
|
+
};
|
|
1517
|
+
if (lockSrc) {
|
|
1518
|
+
const lockIncludes = agent === 'bun' ? lockIncludesByAgent.yarn : lockIncludesByAgent[agent];
|
|
1519
|
+
const nodeRange = `>=${minimumNodeVersion}`;
|
|
1520
|
+
const manifestEntries = manifestNpmOverrides.filter(({
|
|
1521
|
+
1: data
|
|
1522
|
+
}) => _semver.satisfies(_semver.coerce(data.engines.node), nodeRange));
|
|
1523
|
+
await addOverrides({
|
|
1524
|
+
__proto__: null,
|
|
1525
|
+
agent: agent === 'bun' ? 'yarn' : agent,
|
|
1342
1526
|
isPrivate,
|
|
1343
1527
|
isWorkspace,
|
|
1528
|
+
lockIncludes,
|
|
1344
1529
|
lockSrc,
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1530
|
+
manifestEntries,
|
|
1531
|
+
pin,
|
|
1532
|
+
pkgJsonPath
|
|
1533
|
+
}, state);
|
|
1534
|
+
}
|
|
1535
|
+
const pkgJsonChanged = state.updated.size > 0 || state.updated.size > 0;
|
|
1536
|
+
if (state.updated.size > 0) {
|
|
1537
|
+
console.log(`Updated ${state.updated.size} Socket.dev optimized overrides ${state.added.size ? '.' : '🚀'}`);
|
|
1538
|
+
}
|
|
1539
|
+
if (state.added.size > 0) {
|
|
1540
|
+
console.log(`Added ${state.added.size} Socket.dev optimized overrides 🚀`);
|
|
1541
|
+
}
|
|
1542
|
+
if (!pkgJsonChanged) {
|
|
1543
|
+
console.log('Congratulations! Already Socket.dev optimized 🎉');
|
|
1544
|
+
}
|
|
1545
|
+
const isNpm = agent === 'npm';
|
|
1546
|
+
if (isNpm || pkgJsonChanged) {
|
|
1547
|
+
// Always update package-lock.json until the npm overrides PR lands:
|
|
1548
|
+
// https://github.com/npm/cli/pull/7025
|
|
1549
|
+
const spinner = (0, _ora$i.default)(`Updating ${lockName}...`).start();
|
|
1550
|
+
try {
|
|
1551
|
+
if (isNpm) {
|
|
1552
|
+
const wrapperPath = _nodePath$2.join(distPath$1, 'npm-cli.js');
|
|
1553
|
+
await _promiseSpawn$2(process.execPath, [wrapperPath, 'install'], {
|
|
1554
|
+
stdio: 'pipe',
|
|
1555
|
+
env: {
|
|
1556
|
+
__proto__: null,
|
|
1557
|
+
...process.env,
|
|
1558
|
+
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: '1'
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
} else {
|
|
1562
|
+
await _promiseSpawn$2(agentExecPath, ['install'], {
|
|
1563
|
+
stdio: 'pipe'
|
|
1564
|
+
});
|
|
1354
1565
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
const lockName = lockPath ? _nodePath$2.basename(lockPath) : 'lock file';
|
|
1361
|
-
if (lockSrc === undefined) {
|
|
1362
|
-
console.log(`✘ ${COMMAND_TITLE}: No ${lockName} found`);
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
if (pkgJson === undefined) {
|
|
1366
|
-
console.log(`✘ ${COMMAND_TITLE}: No package.json found`);
|
|
1367
|
-
return;
|
|
1368
|
-
}
|
|
1369
|
-
if (lockPath && _nodePath$2.relative(cwd, lockPath).startsWith('.')) {
|
|
1370
|
-
console.log(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
|
|
1371
|
-
}
|
|
1372
|
-
const aoState = {
|
|
1373
|
-
output: pkgJsonStr,
|
|
1374
|
-
packageNames: new Set()
|
|
1375
|
-
};
|
|
1376
|
-
if (lockSrc) {
|
|
1377
|
-
const lockIncludes = agent === 'bun' ? lockIncludesByAgent.yarn : lockIncludesByAgent[agent];
|
|
1378
|
-
await addOverrides({
|
|
1379
|
-
__proto__: null,
|
|
1380
|
-
agent: agent === 'bun' ? 'yarn' : agent,
|
|
1381
|
-
isPrivate,
|
|
1382
|
-
isWorkspace,
|
|
1383
|
-
lockIncludes,
|
|
1384
|
-
lockSrc,
|
|
1385
|
-
pkgJsonPath,
|
|
1386
|
-
pkgJsonStr,
|
|
1387
|
-
pkgJson
|
|
1388
|
-
}, aoState);
|
|
1389
|
-
}
|
|
1390
|
-
const {
|
|
1391
|
-
size: count
|
|
1392
|
-
} = aoState.packageNames;
|
|
1393
|
-
if (count) {
|
|
1394
|
-
console.log(`Added ${count} Socket.dev optimized overrides 🚀`);
|
|
1395
|
-
} else {
|
|
1396
|
-
console.log('Congratulations! Already Socket.dev optimized 🎉');
|
|
1397
|
-
}
|
|
1398
|
-
const isNpm = agent === 'npm';
|
|
1399
|
-
if (isNpm || count) {
|
|
1400
|
-
// Always update package-lock.json until the npm overrides PR lands:
|
|
1401
|
-
// https://github.com/npm/cli/pull/7025
|
|
1402
|
-
const spinner = (0, _ora$i.default)(`Updating ${lockName}...`).start();
|
|
1403
|
-
try {
|
|
1404
|
-
if (isNpm) {
|
|
1405
|
-
const wrapperPath = _nodePath$2.join(distPath$1, 'npm-cli.js');
|
|
1406
|
-
await _promiseSpawn$2(process.execPath, [wrapperPath, 'install'], {
|
|
1407
|
-
stdio: 'pipe',
|
|
1408
|
-
env: {
|
|
1409
|
-
__proto__: null,
|
|
1410
|
-
...process.env,
|
|
1411
|
-
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: '1'
|
|
1412
|
-
}
|
|
1413
|
-
});
|
|
1414
|
-
} else {
|
|
1415
|
-
await _promiseSpawn$2(agentExecPath, ['install'], {
|
|
1416
|
-
stdio: 'pipe'
|
|
1417
|
-
});
|
|
1418
|
-
}
|
|
1419
|
-
spinner.stop();
|
|
1420
|
-
if (isNpm) {
|
|
1421
|
-
console.log(`💡 Re-run ${COMMAND_TITLE} whenever ${lockName} changes.\n This can be skipped once npm ships https://github.com/npm/cli/pull/7025.`);
|
|
1422
|
-
}
|
|
1423
|
-
} catch {
|
|
1424
|
-
spinner.stop();
|
|
1425
|
-
console.log(`✘ ${COMMAND_TITLE}: ${agent} install failed to update ${lockName}`);
|
|
1566
|
+
spinner.stop();
|
|
1567
|
+
if (isNpm) {
|
|
1568
|
+
console.log(`💡 Re-run ${COMMAND_TITLE} whenever ${lockName} changes.\n This can be skipped once npm ships https://github.com/npm/cli/pull/7025.`);
|
|
1426
1569
|
}
|
|
1570
|
+
} catch {
|
|
1571
|
+
spinner.stop();
|
|
1572
|
+
console.log(`✘ ${COMMAND_TITLE}: ${agent} install failed to update ${lockName}`);
|
|
1427
1573
|
}
|
|
1428
1574
|
}
|
|
1429
1575
|
}
|
|
@@ -1432,7 +1578,15 @@ const optimize = optimize$1.optimize = {
|
|
|
1432
1578
|
// Internal functions
|
|
1433
1579
|
|
|
1434
1580
|
function setupCommand$l(name, description, argv, importMeta) {
|
|
1435
|
-
const flags = {
|
|
1581
|
+
const flags = {
|
|
1582
|
+
__proto__: null,
|
|
1583
|
+
..._flags$j.commonFlags,
|
|
1584
|
+
pin: {
|
|
1585
|
+
type: 'boolean',
|
|
1586
|
+
default: false,
|
|
1587
|
+
description: 'Pin overrides to their latest version'
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1436
1590
|
const cli = (0, _meow$m.default)(`
|
|
1437
1591
|
Usage
|
|
1438
1592
|
$ ${name}
|
|
@@ -1449,16 +1603,15 @@ function setupCommand$l(name, description, argv, importMeta) {
|
|
|
1449
1603
|
flags
|
|
1450
1604
|
});
|
|
1451
1605
|
const {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
limit,
|
|
1455
|
-
offset
|
|
1606
|
+
help,
|
|
1607
|
+
pin
|
|
1456
1608
|
} = cli.flags;
|
|
1609
|
+
if (help) {
|
|
1610
|
+
cli.showHelp();
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1457
1613
|
return {
|
|
1458
|
-
|
|
1459
|
-
outputMarkdown,
|
|
1460
|
-
limit,
|
|
1461
|
-
offset
|
|
1614
|
+
pin
|
|
1462
1615
|
};
|
|
1463
1616
|
}
|
|
1464
1617
|
|
|
@@ -1530,7 +1683,7 @@ Object.defineProperty(rawNpm$1, "__esModule", {
|
|
|
1530
1683
|
rawNpm$1.rawNpm = void 0;
|
|
1531
1684
|
var _promiseSpawn$1 = require$$1$1;
|
|
1532
1685
|
var _meow$k = _interopRequireDefault$l(vendor.build);
|
|
1533
|
-
var _flags$
|
|
1686
|
+
var _flags$i = flags$1;
|
|
1534
1687
|
var _formatting$j = formatting;
|
|
1535
1688
|
const rawNpm = rawNpm$1.rawNpm = {
|
|
1536
1689
|
description: 'Temporarily disable the Socket npm wrapper',
|
|
@@ -1541,7 +1694,11 @@ const rawNpm = rawNpm$1.rawNpm = {
|
|
|
1541
1694
|
}
|
|
1542
1695
|
};
|
|
1543
1696
|
async function setupCommand$j(name, description, argv, importMeta) {
|
|
1544
|
-
const flags =
|
|
1697
|
+
const flags = {
|
|
1698
|
+
__proto__: null,
|
|
1699
|
+
..._flags$i.commonFlags,
|
|
1700
|
+
..._flags$i.validationFlags
|
|
1701
|
+
};
|
|
1545
1702
|
const cli = (0, _meow$k.default)(`
|
|
1546
1703
|
Usage
|
|
1547
1704
|
$ ${name} <npm command>
|
|
@@ -1557,7 +1714,11 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1557
1714
|
importMeta,
|
|
1558
1715
|
flags
|
|
1559
1716
|
});
|
|
1717
|
+
let showHelp = cli.flags['help'];
|
|
1560
1718
|
if (!argv[0]) {
|
|
1719
|
+
showHelp = true;
|
|
1720
|
+
}
|
|
1721
|
+
if (showHelp) {
|
|
1561
1722
|
cli.showHelp();
|
|
1562
1723
|
return;
|
|
1563
1724
|
}
|
|
@@ -1583,7 +1744,7 @@ Object.defineProperty(rawNpx$1, "__esModule", {
|
|
|
1583
1744
|
rawNpx$1.rawNpx = void 0;
|
|
1584
1745
|
var _promiseSpawn = require$$1$1;
|
|
1585
1746
|
var _meow$j = _interopRequireDefault$k(vendor.build);
|
|
1586
|
-
var _flags$
|
|
1747
|
+
var _flags$h = flags$1;
|
|
1587
1748
|
var _formatting$i = formatting;
|
|
1588
1749
|
const rawNpx = rawNpx$1.rawNpx = {
|
|
1589
1750
|
description: 'Temporarily disable the Socket npm/npx wrapper',
|
|
@@ -1594,7 +1755,11 @@ const rawNpx = rawNpx$1.rawNpx = {
|
|
|
1594
1755
|
}
|
|
1595
1756
|
};
|
|
1596
1757
|
async function setupCommand$i(name, description, argv, importMeta) {
|
|
1597
|
-
const flags =
|
|
1758
|
+
const flags = {
|
|
1759
|
+
__proto__: null,
|
|
1760
|
+
..._flags$h.commonFlags,
|
|
1761
|
+
..._flags$h.validationFlags
|
|
1762
|
+
};
|
|
1598
1763
|
const cli = (0, _meow$j.default)(`
|
|
1599
1764
|
Usage
|
|
1600
1765
|
$ ${name} <npx command>
|
|
@@ -1610,7 +1775,11 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1610
1775
|
importMeta,
|
|
1611
1776
|
flags
|
|
1612
1777
|
});
|
|
1778
|
+
let showHelp = cli.flags['help'];
|
|
1613
1779
|
if (!argv[0]) {
|
|
1780
|
+
showHelp = true;
|
|
1781
|
+
}
|
|
1782
|
+
if (showHelp) {
|
|
1614
1783
|
cli.showHelp();
|
|
1615
1784
|
return;
|
|
1616
1785
|
}
|
|
@@ -1644,7 +1813,7 @@ var _chalk$f = _interopRequireDefault$j(vendor.source);
|
|
|
1644
1813
|
var _meow$i = _interopRequireDefault$j(vendor.build);
|
|
1645
1814
|
var _ora$g = _interopRequireDefault$j(vendor.ora);
|
|
1646
1815
|
var _ponyCause$3 = require$$6;
|
|
1647
|
-
var _flags$
|
|
1816
|
+
var _flags$g = flags$1;
|
|
1648
1817
|
var _apiHelpers$g = apiHelpers;
|
|
1649
1818
|
var _chalkMarkdown$2 = sdk.chalkMarkdown;
|
|
1650
1819
|
var _errors$h = sdk.errors;
|
|
@@ -1673,8 +1842,9 @@ const view$2 = view$3.view = {
|
|
|
1673
1842
|
function setupCommand$h(name, description, argv, importMeta) {
|
|
1674
1843
|
const flags = {
|
|
1675
1844
|
__proto__: null,
|
|
1676
|
-
..._flags$
|
|
1677
|
-
..._flags$
|
|
1845
|
+
..._flags$g.commonFlags,
|
|
1846
|
+
..._flags$g.outputFlags,
|
|
1847
|
+
..._flags$g.validationFlags
|
|
1678
1848
|
};
|
|
1679
1849
|
const cli = (0, _meow$i.default)(`
|
|
1680
1850
|
Usage
|
|
@@ -1691,32 +1861,26 @@ function setupCommand$h(name, description, argv, importMeta) {
|
|
|
1691
1861
|
importMeta,
|
|
1692
1862
|
flags
|
|
1693
1863
|
});
|
|
1694
|
-
|
|
1695
|
-
// Extract the input
|
|
1696
|
-
|
|
1697
|
-
const {
|
|
1698
|
-
all: includeAllIssues,
|
|
1699
|
-
json: outputJson,
|
|
1700
|
-
markdown: outputMarkdown,
|
|
1701
|
-
strict
|
|
1702
|
-
} = cli.flags;
|
|
1864
|
+
// Extract the input.
|
|
1703
1865
|
const [reportId, ...extraInput] = cli.input;
|
|
1704
|
-
|
|
1866
|
+
let showHelp = cli.flags['help'];
|
|
1867
|
+
if (reportId) {
|
|
1868
|
+
showHelp = true;
|
|
1869
|
+
}
|
|
1870
|
+
if (showHelp) {
|
|
1705
1871
|
cli.showHelp();
|
|
1706
1872
|
return;
|
|
1707
1873
|
}
|
|
1708
|
-
|
|
1709
|
-
// Validate the input
|
|
1710
|
-
|
|
1874
|
+
// Validate the input.
|
|
1711
1875
|
if (extraInput.length) {
|
|
1712
1876
|
throw new _errors$h.InputError(`Can only handle a single report ID at a time, but got ${cli.input.length} report ID:s: ${cli.input.join(', ')}`);
|
|
1713
1877
|
}
|
|
1714
1878
|
return {
|
|
1715
|
-
includeAllIssues,
|
|
1716
|
-
outputJson,
|
|
1717
|
-
outputMarkdown,
|
|
1879
|
+
includeAllIssues: cli.flags['all'],
|
|
1880
|
+
outputJson: cli.flags['json'],
|
|
1881
|
+
outputMarkdown: cli.flags['markdown'],
|
|
1718
1882
|
reportId,
|
|
1719
|
-
strict
|
|
1883
|
+
strict: cli.flags['strict']
|
|
1720
1884
|
};
|
|
1721
1885
|
}
|
|
1722
1886
|
const MAX_TIMEOUT_RETRY = 5;
|
|
@@ -1725,7 +1889,6 @@ async function fetchReportData(reportId, {
|
|
|
1725
1889
|
strict
|
|
1726
1890
|
}) {
|
|
1727
1891
|
// Do the API call
|
|
1728
|
-
|
|
1729
1892
|
const socketSdk = await (0, _sdk$g.setupSdk)();
|
|
1730
1893
|
const spinner = (0, _ora$g.default)(`Fetching report with ID ${reportId} (this could take a while)`).start();
|
|
1731
1894
|
let result;
|
|
@@ -1795,7 +1958,7 @@ var _meow$h = _interopRequireDefault$i(vendor.build);
|
|
|
1795
1958
|
var _ora$f = _interopRequireDefault$i(vendor.ora);
|
|
1796
1959
|
var _ponyCause$2 = require$$6;
|
|
1797
1960
|
var _view$2 = view$3;
|
|
1798
|
-
var _flags$
|
|
1961
|
+
var _flags$f = flags$1;
|
|
1799
1962
|
var _apiHelpers$f = apiHelpers;
|
|
1800
1963
|
var _chalkMarkdown$1 = sdk.chalkMarkdown;
|
|
1801
1964
|
var _errors$g = sdk.errors;
|
|
@@ -1860,8 +2023,9 @@ const create$4 = create$5.create = {
|
|
|
1860
2023
|
async function setupCommand$g(name, description, argv, importMeta) {
|
|
1861
2024
|
const flags = {
|
|
1862
2025
|
__proto__: null,
|
|
1863
|
-
..._flags$
|
|
1864
|
-
..._flags$
|
|
2026
|
+
..._flags$f.commonFlags,
|
|
2027
|
+
..._flags$f.outputFlags,
|
|
2028
|
+
..._flags$f.validationFlags,
|
|
1865
2029
|
debug: {
|
|
1866
2030
|
type: 'boolean',
|
|
1867
2031
|
shortFlag: 'd',
|
|
@@ -1915,18 +2079,17 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
1915
2079
|
importMeta,
|
|
1916
2080
|
flags
|
|
1917
2081
|
});
|
|
1918
|
-
|
|
1919
|
-
all: includeAllIssues,
|
|
1920
|
-
dryRun,
|
|
1921
|
-
json: outputJson,
|
|
1922
|
-
markdown: outputMarkdown,
|
|
1923
|
-
strict,
|
|
1924
|
-
view
|
|
1925
|
-
} = cli.flags;
|
|
2082
|
+
let showHelp = cli.flags['help'];
|
|
1926
2083
|
if (!cli.input[0]) {
|
|
2084
|
+
showHelp = true;
|
|
2085
|
+
}
|
|
2086
|
+
if (showHelp) {
|
|
1927
2087
|
cli.showHelp();
|
|
1928
2088
|
return;
|
|
1929
2089
|
}
|
|
2090
|
+
const {
|
|
2091
|
+
dryRun
|
|
2092
|
+
} = cli.flags;
|
|
1930
2093
|
const debugLog = (0, _misc$1.createDebugLogger)(!dryRun || cli.flags['debug']);
|
|
1931
2094
|
|
|
1932
2095
|
// TODO: Allow setting a custom cwd and/or configFile path?
|
|
@@ -1964,12 +2127,12 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
1964
2127
|
cwd,
|
|
1965
2128
|
debugLog,
|
|
1966
2129
|
dryRun,
|
|
1967
|
-
includeAllIssues,
|
|
1968
|
-
outputJson,
|
|
1969
|
-
outputMarkdown,
|
|
2130
|
+
includeAllIssues: cli.flags['all'],
|
|
2131
|
+
outputJson: cli.flags['json'],
|
|
2132
|
+
outputMarkdown: cli.flags['markdown'],
|
|
1970
2133
|
packagePaths,
|
|
1971
|
-
strict,
|
|
1972
|
-
view
|
|
2134
|
+
strict: cli.flags['strict'],
|
|
2135
|
+
view: cli.flags['view']
|
|
1973
2136
|
};
|
|
1974
2137
|
}
|
|
1975
2138
|
async function createReport(packagePaths, {
|
|
@@ -2019,6 +2182,7 @@ meowWithSubcommands$1.meowWithSubcommands = meowWithSubcommands;
|
|
|
2019
2182
|
var _meow$g = _interopRequireDefault$h(vendor.build);
|
|
2020
2183
|
var _formatting$f = formatting;
|
|
2021
2184
|
var _sorts = sorts;
|
|
2185
|
+
var _flags$e = flags$1;
|
|
2022
2186
|
async function meowWithSubcommands(subcommands, options) {
|
|
2023
2187
|
const {
|
|
2024
2188
|
aliases = {},
|
|
@@ -2026,19 +2190,18 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2026
2190
|
name,
|
|
2027
2191
|
importMeta,
|
|
2028
2192
|
...additionalOptions
|
|
2029
|
-
} =
|
|
2193
|
+
} = {
|
|
2194
|
+
__proto__: null,
|
|
2195
|
+
...options
|
|
2196
|
+
};
|
|
2030
2197
|
const [commandOrAliasName, ...rawCommandArgv] = argv;
|
|
2031
|
-
|
|
2032
2198
|
// If we got at least some args, then lets find out if we can find a command
|
|
2033
2199
|
if (commandOrAliasName) {
|
|
2034
2200
|
const alias = aliases[commandOrAliasName];
|
|
2035
|
-
|
|
2036
2201
|
// First: Resolve argv data from alias if its an alias that's been given
|
|
2037
2202
|
const [commandName, ...commandArgv] = alias ? [...alias.argv, ...rawCommandArgv] : [commandOrAliasName, ...rawCommandArgv];
|
|
2038
|
-
|
|
2039
2203
|
// Second: Find a command definition using that data
|
|
2040
2204
|
const commandDefinition = commandName ? subcommands[commandName] : undefined;
|
|
2041
|
-
|
|
2042
2205
|
// Third: If a valid command has been found, then we run it...
|
|
2043
2206
|
if (commandDefinition) {
|
|
2044
2207
|
return await commandDefinition.run(commandArgv, importMeta, {
|
|
@@ -2046,7 +2209,11 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2046
2209
|
});
|
|
2047
2210
|
}
|
|
2048
2211
|
}
|
|
2049
|
-
|
|
2212
|
+
const flags = {
|
|
2213
|
+
__proto__: null,
|
|
2214
|
+
..._flags$e.commonFlags,
|
|
2215
|
+
...additionalOptions.flags
|
|
2216
|
+
};
|
|
2050
2217
|
// ...else we provide basic instructions and help
|
|
2051
2218
|
const cli = (0, _meow$g.default)(`
|
|
2052
2219
|
Usage
|
|
@@ -2059,14 +2226,15 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2059
2226
|
}, 6)}
|
|
2060
2227
|
|
|
2061
2228
|
Options
|
|
2062
|
-
${(0, _formatting$f.printFlagList)(
|
|
2229
|
+
${(0, _formatting$f.printFlagList)(flags, 6)}
|
|
2063
2230
|
|
|
2064
2231
|
Examples
|
|
2065
2232
|
$ ${name} --help
|
|
2066
2233
|
`, {
|
|
2067
2234
|
argv,
|
|
2068
2235
|
importMeta,
|
|
2069
|
-
...additionalOptions
|
|
2236
|
+
...additionalOptions,
|
|
2237
|
+
flags
|
|
2070
2238
|
});
|
|
2071
2239
|
cli.showHelp();
|
|
2072
2240
|
}
|
|
@@ -2103,7 +2271,7 @@ Object.defineProperty(wrapper$1, "__esModule", {
|
|
|
2103
2271
|
value: true
|
|
2104
2272
|
});
|
|
2105
2273
|
wrapper$1.wrapper = void 0;
|
|
2106
|
-
var _nodeFs$
|
|
2274
|
+
var _nodeFs$2 = require$$0;
|
|
2107
2275
|
var _nodeOs = require$$2$1;
|
|
2108
2276
|
var _nodeReadline = require$$3$4;
|
|
2109
2277
|
var _meow$f = _interopRequireDefault$g(vendor.build);
|
|
@@ -2137,12 +2305,8 @@ function setupCommand$f(name, description, argv, importMeta) {
|
|
|
2137
2305
|
importMeta,
|
|
2138
2306
|
flags
|
|
2139
2307
|
});
|
|
2140
|
-
const {
|
|
2141
|
-
enable,
|
|
2142
|
-
disable
|
|
2143
|
-
} = cli.flags;
|
|
2144
2308
|
if (argv[0] === '--postinstall') {
|
|
2145
|
-
const socketWrapperEnabled = _nodeFs$
|
|
2309
|
+
const socketWrapperEnabled = _nodeFs$2.existsSync(BASH_FILE) && checkSocketWrapperAlreadySetup(BASH_FILE) || _nodeFs$2.existsSync(ZSH_BASH_FILE) && checkSocketWrapperAlreadySetup(ZSH_BASH_FILE);
|
|
2146
2310
|
if (!socketWrapperEnabled) {
|
|
2147
2311
|
installSafeNpm(`The Socket CLI is now successfully installed! 🎉
|
|
2148
2312
|
|
|
@@ -2152,31 +2316,38 @@ function setupCommand$f(name, description, argv, importMeta) {
|
|
|
2152
2316
|
}
|
|
2153
2317
|
return;
|
|
2154
2318
|
}
|
|
2319
|
+
const {
|
|
2320
|
+
enable,
|
|
2321
|
+
disable
|
|
2322
|
+
} = cli.flags;
|
|
2323
|
+
let showHelp = cli.flags['help'];
|
|
2155
2324
|
if (!enable && !disable) {
|
|
2325
|
+
showHelp = true;
|
|
2326
|
+
}
|
|
2327
|
+
if (showHelp) {
|
|
2156
2328
|
cli.showHelp();
|
|
2157
2329
|
return;
|
|
2158
2330
|
}
|
|
2159
2331
|
if (enable) {
|
|
2160
|
-
if (_nodeFs$
|
|
2332
|
+
if (_nodeFs$2.existsSync(BASH_FILE)) {
|
|
2161
2333
|
const socketWrapperEnabled = checkSocketWrapperAlreadySetup(BASH_FILE);
|
|
2162
2334
|
!socketWrapperEnabled && addAlias(BASH_FILE);
|
|
2163
2335
|
}
|
|
2164
|
-
if (_nodeFs$
|
|
2336
|
+
if (_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2165
2337
|
const socketWrapperEnabled = checkSocketWrapperAlreadySetup(ZSH_BASH_FILE);
|
|
2166
2338
|
!socketWrapperEnabled && addAlias(ZSH_BASH_FILE);
|
|
2167
2339
|
}
|
|
2168
2340
|
} else if (disable) {
|
|
2169
|
-
if (_nodeFs$
|
|
2341
|
+
if (_nodeFs$2.existsSync(BASH_FILE)) {
|
|
2170
2342
|
removeAlias(BASH_FILE);
|
|
2171
2343
|
}
|
|
2172
|
-
if (_nodeFs$
|
|
2344
|
+
if (_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2173
2345
|
removeAlias(ZSH_BASH_FILE);
|
|
2174
2346
|
}
|
|
2175
2347
|
}
|
|
2176
|
-
if (!_nodeFs$
|
|
2348
|
+
if (!_nodeFs$2.existsSync(BASH_FILE) && !_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2177
2349
|
console.error('There was an issue setting up the alias in your bash profile');
|
|
2178
2350
|
}
|
|
2179
|
-
return;
|
|
2180
2351
|
}
|
|
2181
2352
|
const installSafeNpm = query => {
|
|
2182
2353
|
console.log(`
|
|
@@ -2196,10 +2367,10 @@ const askQuestion = (rl, query) => {
|
|
|
2196
2367
|
rl.question(query, ans => {
|
|
2197
2368
|
if (ans.toLowerCase() === 'y') {
|
|
2198
2369
|
try {
|
|
2199
|
-
if (_nodeFs$
|
|
2370
|
+
if (_nodeFs$2.existsSync(BASH_FILE)) {
|
|
2200
2371
|
addAlias(BASH_FILE);
|
|
2201
2372
|
}
|
|
2202
|
-
if (_nodeFs$
|
|
2373
|
+
if (_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2203
2374
|
addAlias(ZSH_BASH_FILE);
|
|
2204
2375
|
}
|
|
2205
2376
|
} catch (e) {
|
|
@@ -2214,7 +2385,7 @@ const askQuestion = (rl, query) => {
|
|
|
2214
2385
|
});
|
|
2215
2386
|
};
|
|
2216
2387
|
const addAlias = file => {
|
|
2217
|
-
return _nodeFs$
|
|
2388
|
+
return _nodeFs$2.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
|
|
2218
2389
|
if (err) {
|
|
2219
2390
|
return new Error(`There was an error setting up the alias: ${err}`);
|
|
2220
2391
|
}
|
|
@@ -2225,14 +2396,14 @@ If you want to disable it at any time, run \`socket wrapper --disable\`
|
|
|
2225
2396
|
});
|
|
2226
2397
|
};
|
|
2227
2398
|
const removeAlias = file => {
|
|
2228
|
-
return _nodeFs$
|
|
2399
|
+
return _nodeFs$2.readFile(file, 'utf8', function (err, data) {
|
|
2229
2400
|
if (err) {
|
|
2230
2401
|
console.error(`There was an error removing the alias: ${err}`);
|
|
2231
2402
|
return;
|
|
2232
2403
|
}
|
|
2233
2404
|
const linesWithoutSocketAlias = data.split('\n').filter(l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"');
|
|
2234
2405
|
const updatedFileContent = linesWithoutSocketAlias.join('\n');
|
|
2235
|
-
_nodeFs$
|
|
2406
|
+
_nodeFs$2.writeFile(file, updatedFileContent, function (err) {
|
|
2236
2407
|
if (err) {
|
|
2237
2408
|
console.log(err);
|
|
2238
2409
|
return;
|
|
@@ -2243,7 +2414,7 @@ const removeAlias = file => {
|
|
|
2243
2414
|
});
|
|
2244
2415
|
};
|
|
2245
2416
|
const checkSocketWrapperAlreadySetup = file => {
|
|
2246
|
-
const fileContent = _nodeFs$
|
|
2417
|
+
const fileContent = _nodeFs$2.readFileSync(file, 'utf-8');
|
|
2247
2418
|
const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
|
|
2248
2419
|
if (linesWithSocketAlias.length) {
|
|
2249
2420
|
console.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
|
|
@@ -2262,7 +2433,7 @@ Object.defineProperty(create$3, "__esModule", {
|
|
|
2262
2433
|
});
|
|
2263
2434
|
create$3.create = void 0;
|
|
2264
2435
|
var _nodeProcess = require$$0$1;
|
|
2265
|
-
var _promises = require$$2$2;
|
|
2436
|
+
var _promises$1 = require$$2$2;
|
|
2266
2437
|
var _chalk$e = _interopRequireDefault$f(vendor.source);
|
|
2267
2438
|
var _meow$e = _interopRequireDefault$f(vendor.build);
|
|
2268
2439
|
var _open = _interopRequireDefault$f(vendor.open);
|
|
@@ -2369,18 +2540,11 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2369
2540
|
importMeta,
|
|
2370
2541
|
flags
|
|
2371
2542
|
});
|
|
2372
|
-
|
|
2373
|
-
repo: repoName,
|
|
2374
|
-
branch: branchName,
|
|
2375
|
-
commitMessage,
|
|
2376
|
-
defaultBranch,
|
|
2377
|
-
pendingHead,
|
|
2378
|
-
tmp,
|
|
2379
|
-
committers,
|
|
2380
|
-
commitHash,
|
|
2381
|
-
pullRequest
|
|
2382
|
-
} = cli.flags;
|
|
2543
|
+
let showHelp = cli.flags['help'];
|
|
2383
2544
|
if (!cli.input[0]) {
|
|
2545
|
+
showHelp = true;
|
|
2546
|
+
}
|
|
2547
|
+
if (showHelp) {
|
|
2384
2548
|
cli.showHelp();
|
|
2385
2549
|
return;
|
|
2386
2550
|
}
|
|
@@ -2400,11 +2564,18 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2400
2564
|
});
|
|
2401
2565
|
const debugLog = (0, _misc.createDebugLogger)(false);
|
|
2402
2566
|
const packagePaths = await (0, _pathResolve.getPackageFilesFullScans)(cwd, cli.input, supportedFiles, debugLog);
|
|
2567
|
+
const {
|
|
2568
|
+
repo: repoName,
|
|
2569
|
+
branch: branchName
|
|
2570
|
+
} = cli.flags;
|
|
2403
2571
|
if (!repoName || !branchName || !packagePaths.length) {
|
|
2572
|
+
showHelp = true;
|
|
2404
2573
|
console.error(`${_chalk$e.default.white.bgRed('Input error')}: Please provide the required fields:\n
|
|
2405
|
-
- Repository name using --repo,\n
|
|
2406
|
-
- Branch name using --branch\n
|
|
2407
|
-
- At least one file path (e.g. ./package.json)
|
|
2574
|
+
- Repository name using --repo,\n
|
|
2575
|
+
- Branch name using --branch\n
|
|
2576
|
+
- At least one file path (e.g. ./package.json).`);
|
|
2577
|
+
}
|
|
2578
|
+
if (showHelp) {
|
|
2408
2579
|
cli.showHelp();
|
|
2409
2580
|
return;
|
|
2410
2581
|
}
|
|
@@ -2412,14 +2583,14 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2412
2583
|
orgSlug,
|
|
2413
2584
|
repoName,
|
|
2414
2585
|
branchName,
|
|
2415
|
-
commitMessage,
|
|
2416
|
-
defaultBranch,
|
|
2417
|
-
pendingHead,
|
|
2418
|
-
tmp,
|
|
2586
|
+
commitMessage: cli.flags['commitMessage'],
|
|
2587
|
+
defaultBranch: cli.flags['defaultBranch'],
|
|
2588
|
+
pendingHead: cli.flags['pendingHead'],
|
|
2589
|
+
tmp: cli.flags['tmp'],
|
|
2419
2590
|
packagePaths,
|
|
2420
|
-
commitHash,
|
|
2421
|
-
committers,
|
|
2422
|
-
pullRequest
|
|
2591
|
+
commitHash: cli.flags['commitHash'],
|
|
2592
|
+
committers: cli.flags['committers'],
|
|
2593
|
+
pullRequest: cli.flags['pullRequest']
|
|
2423
2594
|
};
|
|
2424
2595
|
}
|
|
2425
2596
|
async function createFullScan(input, spinner, apiKey) {
|
|
@@ -2450,7 +2621,7 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
2450
2621
|
console.log('\n✅ Scan created successfully\n');
|
|
2451
2622
|
const link = _chalk$e.default.hex('#00FFFF').underline(`${result.data.html_report_url}`);
|
|
2452
2623
|
console.log(`Available at: ${link}\n`);
|
|
2453
|
-
const rl = _promises.createInterface({
|
|
2624
|
+
const rl = _promises$1.createInterface({
|
|
2454
2625
|
input: _nodeProcess.stdin,
|
|
2455
2626
|
output: _nodeProcess.stdout
|
|
2456
2627
|
});
|
|
@@ -2499,6 +2670,8 @@ const del$1 = _delete$3.del = {
|
|
|
2499
2670
|
|
|
2500
2671
|
function setupCommand$d(name, description, argv, importMeta) {
|
|
2501
2672
|
const flags = {
|
|
2673
|
+
__proto__: null,
|
|
2674
|
+
..._flags$c.commonFlags,
|
|
2502
2675
|
..._flags$c.outputFlags
|
|
2503
2676
|
};
|
|
2504
2677
|
const cli = (0, _meow$d.default)(`
|
|
@@ -2516,12 +2689,12 @@ function setupCommand$d(name, description, argv, importMeta) {
|
|
|
2516
2689
|
importMeta,
|
|
2517
2690
|
flags
|
|
2518
2691
|
});
|
|
2519
|
-
|
|
2520
|
-
json: outputJson,
|
|
2521
|
-
markdown: outputMarkdown
|
|
2522
|
-
} = cli.flags;
|
|
2692
|
+
let showHelp = cli.flags['help'];
|
|
2523
2693
|
if (cli.input.length < 2) {
|
|
2694
|
+
showHelp = true;
|
|
2524
2695
|
console.error(`${_chalk$d.default.white.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2696
|
+
}
|
|
2697
|
+
if (showHelp) {
|
|
2525
2698
|
cli.showHelp();
|
|
2526
2699
|
return;
|
|
2527
2700
|
}
|
|
@@ -2530,8 +2703,8 @@ function setupCommand$d(name, description, argv, importMeta) {
|
|
|
2530
2703
|
1: fullScanId = ''
|
|
2531
2704
|
} = cli.input;
|
|
2532
2705
|
return {
|
|
2533
|
-
outputJson,
|
|
2534
|
-
outputMarkdown,
|
|
2706
|
+
outputJson: cli.flags['json'],
|
|
2707
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2535
2708
|
orgSlug,
|
|
2536
2709
|
fullScanId
|
|
2537
2710
|
};
|
|
@@ -2544,7 +2717,7 @@ async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
|
2544
2717
|
return;
|
|
2545
2718
|
}
|
|
2546
2719
|
spinner.stop();
|
|
2547
|
-
console.log('
|
|
2720
|
+
console.log('✅ Scan deleted successfully');
|
|
2548
2721
|
}
|
|
2549
2722
|
|
|
2550
2723
|
var list$3 = {};
|
|
@@ -2626,8 +2799,10 @@ const listFullScanFlags = {
|
|
|
2626
2799
|
|
|
2627
2800
|
function setupCommand$c(name, description, argv, importMeta) {
|
|
2628
2801
|
const flags = {
|
|
2629
|
-
|
|
2630
|
-
...
|
|
2802
|
+
__proto__: null,
|
|
2803
|
+
..._flags$b.commonFlags,
|
|
2804
|
+
...listFullScanFlags,
|
|
2805
|
+
..._flags$b.outputFlags
|
|
2631
2806
|
};
|
|
2632
2807
|
const cli = (0, _meow$c.default)(`
|
|
2633
2808
|
Usage
|
|
@@ -2644,18 +2819,12 @@ function setupCommand$c(name, description, argv, importMeta) {
|
|
|
2644
2819
|
importMeta,
|
|
2645
2820
|
flags
|
|
2646
2821
|
});
|
|
2647
|
-
|
|
2648
|
-
json: outputJson,
|
|
2649
|
-
markdown: outputMarkdown,
|
|
2650
|
-
sort,
|
|
2651
|
-
direction,
|
|
2652
|
-
perPage,
|
|
2653
|
-
page,
|
|
2654
|
-
fromTime,
|
|
2655
|
-
untilTime
|
|
2656
|
-
} = cli.flags;
|
|
2822
|
+
let showHelp = cli.flags['help'];
|
|
2657
2823
|
if (!cli.input[0]) {
|
|
2824
|
+
showHelp = true;
|
|
2658
2825
|
console.error(`${_chalk$c.default.white.bgRed('Input error')}: Please specify an organization slug.\n`);
|
|
2826
|
+
}
|
|
2827
|
+
if (showHelp) {
|
|
2659
2828
|
cli.showHelp();
|
|
2660
2829
|
return;
|
|
2661
2830
|
}
|
|
@@ -2663,15 +2832,15 @@ function setupCommand$c(name, description, argv, importMeta) {
|
|
|
2663
2832
|
0: orgSlug = ''
|
|
2664
2833
|
} = cli.input;
|
|
2665
2834
|
return {
|
|
2666
|
-
outputJson,
|
|
2667
|
-
outputMarkdown,
|
|
2835
|
+
outputJson: cli.flags['json'],
|
|
2836
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2668
2837
|
orgSlug,
|
|
2669
|
-
sort,
|
|
2670
|
-
direction,
|
|
2671
|
-
per_page: perPage,
|
|
2672
|
-
page,
|
|
2673
|
-
from_time: fromTime,
|
|
2674
|
-
until_time: untilTime
|
|
2838
|
+
sort: cli.flags['sort'],
|
|
2839
|
+
direction: cli.flags['direction'],
|
|
2840
|
+
per_page: cli.flags['perPage'],
|
|
2841
|
+
page: cli.flags['page'],
|
|
2842
|
+
from_time: cli.flags['fromTime'],
|
|
2843
|
+
until_time: cli.flags['untilTime']
|
|
2675
2844
|
};
|
|
2676
2845
|
}
|
|
2677
2846
|
async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
@@ -2751,6 +2920,8 @@ const metadata = metadata$1.metadata = {
|
|
|
2751
2920
|
|
|
2752
2921
|
function setupCommand$b(name, description, argv, importMeta) {
|
|
2753
2922
|
const flags = {
|
|
2923
|
+
__proto__: null,
|
|
2924
|
+
..._flags$a.commonFlags,
|
|
2754
2925
|
..._flags$a.outputFlags
|
|
2755
2926
|
};
|
|
2756
2927
|
const cli = (0, _meow$b.default)(`
|
|
@@ -2768,12 +2939,12 @@ function setupCommand$b(name, description, argv, importMeta) {
|
|
|
2768
2939
|
importMeta,
|
|
2769
2940
|
flags
|
|
2770
2941
|
});
|
|
2771
|
-
|
|
2772
|
-
json: outputJson,
|
|
2773
|
-
markdown: outputMarkdown
|
|
2774
|
-
} = cli.flags;
|
|
2942
|
+
let showHelp = cli.flags['help'];
|
|
2775
2943
|
if (cli.input.length < 2) {
|
|
2944
|
+
showHelp = true;
|
|
2776
2945
|
console.error(`${_chalk$b.default.white.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2946
|
+
}
|
|
2947
|
+
if (showHelp) {
|
|
2777
2948
|
cli.showHelp();
|
|
2778
2949
|
return;
|
|
2779
2950
|
}
|
|
@@ -2782,8 +2953,8 @@ function setupCommand$b(name, description, argv, importMeta) {
|
|
|
2782
2953
|
1: scanID = ''
|
|
2783
2954
|
} = cli.input;
|
|
2784
2955
|
return {
|
|
2785
|
-
outputJson,
|
|
2786
|
-
outputMarkdown,
|
|
2956
|
+
outputJson: cli.flags['json'],
|
|
2957
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2787
2958
|
orgSlug,
|
|
2788
2959
|
scanID
|
|
2789
2960
|
};
|
|
@@ -2838,6 +3009,8 @@ const stream = stream$1.stream = {
|
|
|
2838
3009
|
|
|
2839
3010
|
function setupCommand$a(name, description, argv, importMeta) {
|
|
2840
3011
|
const flags = {
|
|
3012
|
+
__proto__: null,
|
|
3013
|
+
..._flags$9.commonFlags,
|
|
2841
3014
|
..._flags$9.outputFlags
|
|
2842
3015
|
};
|
|
2843
3016
|
const cli = (0, _meow$a.default)(`
|
|
@@ -2855,12 +3028,12 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
2855
3028
|
importMeta,
|
|
2856
3029
|
flags
|
|
2857
3030
|
});
|
|
2858
|
-
|
|
2859
|
-
json: outputJson,
|
|
2860
|
-
markdown: outputMarkdown
|
|
2861
|
-
} = cli.flags;
|
|
3031
|
+
let showHelp = cli.flags['help'];
|
|
2862
3032
|
if (cli.input.length < 2) {
|
|
3033
|
+
showHelp = true;
|
|
2863
3034
|
console.error(`${_chalk$a.default.white.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
3035
|
+
}
|
|
3036
|
+
if (showHelp) {
|
|
2864
3037
|
cli.showHelp();
|
|
2865
3038
|
return;
|
|
2866
3039
|
}
|
|
@@ -2870,8 +3043,8 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
2870
3043
|
2: file
|
|
2871
3044
|
} = cli.input;
|
|
2872
3045
|
return {
|
|
2873
|
-
outputJson,
|
|
2874
|
-
outputMarkdown,
|
|
3046
|
+
outputJson: cli.flags['json'],
|
|
3047
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2875
3048
|
orgSlug,
|
|
2876
3049
|
fullScanId,
|
|
2877
3050
|
file
|
|
@@ -2979,6 +3152,7 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2979
3152
|
const flags = {
|
|
2980
3153
|
__proto__: null,
|
|
2981
3154
|
...auditLogFlags,
|
|
3155
|
+
..._flags$8.commonFlags,
|
|
2982
3156
|
..._flags$8.outputFlags
|
|
2983
3157
|
};
|
|
2984
3158
|
const cli = (0, _meow$9.default)(`
|
|
@@ -2996,6 +3170,15 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2996
3170
|
importMeta,
|
|
2997
3171
|
flags
|
|
2998
3172
|
});
|
|
3173
|
+
let showHelp = cli.flags['help'];
|
|
3174
|
+
if (cli.input.length < 1) {
|
|
3175
|
+
showHelp = true;
|
|
3176
|
+
console.error(`${_chalk$9.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3177
|
+
}
|
|
3178
|
+
if (showHelp) {
|
|
3179
|
+
cli.showHelp();
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
2999
3182
|
const {
|
|
3000
3183
|
json: outputJson,
|
|
3001
3184
|
markdown: outputMarkdown,
|
|
@@ -3003,11 +3186,6 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
3003
3186
|
perPage
|
|
3004
3187
|
} = cli.flags;
|
|
3005
3188
|
const type = cli.flags['type'];
|
|
3006
|
-
if (cli.input.length < 1) {
|
|
3007
|
-
console.error(`${_chalk$9.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3008
|
-
cli.showHelp();
|
|
3009
|
-
return;
|
|
3010
|
-
}
|
|
3011
3189
|
const {
|
|
3012
3190
|
0: orgSlug = ''
|
|
3013
3191
|
} = cli.input;
|
|
@@ -3126,6 +3304,7 @@ const repositoryCreationFlags = {
|
|
|
3126
3304
|
function setupCommand$8(name, description, argv, importMeta) {
|
|
3127
3305
|
const flags = {
|
|
3128
3306
|
__proto__: null,
|
|
3307
|
+
..._flags$7.commonFlags,
|
|
3129
3308
|
..._flags$7.outputFlags,
|
|
3130
3309
|
...repositoryCreationFlags
|
|
3131
3310
|
};
|
|
@@ -3145,34 +3324,30 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
3145
3324
|
flags
|
|
3146
3325
|
});
|
|
3147
3326
|
const {
|
|
3148
|
-
|
|
3149
|
-
markdown: outputMarkdown,
|
|
3150
|
-
repoName,
|
|
3151
|
-
repoDescription,
|
|
3152
|
-
homepage,
|
|
3153
|
-
defaultBranch,
|
|
3154
|
-
visibility
|
|
3327
|
+
repoName
|
|
3155
3328
|
} = cli.flags;
|
|
3156
3329
|
const [orgSlug = ''] = cli.input;
|
|
3330
|
+
let showHelp = cli.flags['help'];
|
|
3157
3331
|
if (!orgSlug) {
|
|
3332
|
+
showHelp = true;
|
|
3158
3333
|
console.error(`${_chalk$8.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
}
|
|
3162
|
-
if (!repoName) {
|
|
3334
|
+
} else if (!repoName) {
|
|
3335
|
+
showHelp = true;
|
|
3163
3336
|
console.error(`${_chalk$8.default.white.bgRed('Input error')}: Repository name is required.\n`);
|
|
3337
|
+
}
|
|
3338
|
+
if (showHelp) {
|
|
3164
3339
|
cli.showHelp();
|
|
3165
3340
|
return;
|
|
3166
3341
|
}
|
|
3167
3342
|
return {
|
|
3168
|
-
outputJson,
|
|
3169
|
-
outputMarkdown,
|
|
3343
|
+
outputJson: cli.flags['json'],
|
|
3344
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3170
3345
|
orgSlug,
|
|
3171
3346
|
name: repoName,
|
|
3172
|
-
description: repoDescription,
|
|
3173
|
-
homepage,
|
|
3174
|
-
default_branch: defaultBranch,
|
|
3175
|
-
visibility
|
|
3347
|
+
description: cli.flags['repoDescription'],
|
|
3348
|
+
homepage: cli.flags['homepage'],
|
|
3349
|
+
default_branch: cli.flags['defaultBranch'],
|
|
3350
|
+
visibility: cli.flags['visibility']
|
|
3176
3351
|
};
|
|
3177
3352
|
}
|
|
3178
3353
|
async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
@@ -3236,8 +3411,12 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
3236
3411
|
0: orgSlug = '',
|
|
3237
3412
|
1: repoName = ''
|
|
3238
3413
|
} = cli.input;
|
|
3414
|
+
let showHelp = cli.flags['help'];
|
|
3239
3415
|
if (!orgSlug || !repoName) {
|
|
3416
|
+
showHelp = true;
|
|
3240
3417
|
console.error(`${_chalk$7.default.white.bgRed('Input error')}: Please provide an organization slug and repository slug\n`);
|
|
3418
|
+
}
|
|
3419
|
+
if (showHelp) {
|
|
3241
3420
|
cli.showHelp();
|
|
3242
3421
|
return;
|
|
3243
3422
|
}
|
|
@@ -3323,8 +3502,10 @@ const listRepoFlags = {
|
|
|
3323
3502
|
|
|
3324
3503
|
function setupCommand$6(name, description, argv, importMeta) {
|
|
3325
3504
|
const flags = {
|
|
3326
|
-
|
|
3327
|
-
...
|
|
3505
|
+
__proto__: null,
|
|
3506
|
+
..._flags$6.commonFlags,
|
|
3507
|
+
...listRepoFlags,
|
|
3508
|
+
..._flags$6.outputFlags
|
|
3328
3509
|
};
|
|
3329
3510
|
const cli = (0, _meow$6.default)(`
|
|
3330
3511
|
Usage
|
|
@@ -3341,16 +3522,12 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
3341
3522
|
importMeta,
|
|
3342
3523
|
flags
|
|
3343
3524
|
});
|
|
3344
|
-
|
|
3345
|
-
json: outputJson,
|
|
3346
|
-
markdown: outputMarkdown,
|
|
3347
|
-
perPage,
|
|
3348
|
-
sort,
|
|
3349
|
-
direction,
|
|
3350
|
-
page
|
|
3351
|
-
} = cli.flags;
|
|
3525
|
+
let showHelp = cli.flags['help'];
|
|
3352
3526
|
if (!cli.input[0]) {
|
|
3527
|
+
showHelp = true;
|
|
3353
3528
|
console.error(`${_chalk$6.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3529
|
+
}
|
|
3530
|
+
if (showHelp) {
|
|
3354
3531
|
cli.showHelp();
|
|
3355
3532
|
return;
|
|
3356
3533
|
}
|
|
@@ -3358,13 +3535,13 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
3358
3535
|
0: orgSlug = ''
|
|
3359
3536
|
} = cli.input;
|
|
3360
3537
|
return {
|
|
3361
|
-
outputJson,
|
|
3362
|
-
outputMarkdown,
|
|
3538
|
+
outputJson: cli.flags['json'],
|
|
3539
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3363
3540
|
orgSlug,
|
|
3364
|
-
sort,
|
|
3365
|
-
direction,
|
|
3366
|
-
page,
|
|
3367
|
-
per_page: perPage
|
|
3541
|
+
sort: cli.flags['sort'],
|
|
3542
|
+
direction: cli.flags['direction'],
|
|
3543
|
+
page: cli.flags['page'],
|
|
3544
|
+
per_page: cli.flags['perPage']
|
|
3368
3545
|
};
|
|
3369
3546
|
}
|
|
3370
3547
|
async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
@@ -3466,6 +3643,8 @@ const repositoryUpdateFlags = {
|
|
|
3466
3643
|
|
|
3467
3644
|
function setupCommand$5(name, description, argv, importMeta) {
|
|
3468
3645
|
const flags = {
|
|
3646
|
+
__proto__: null,
|
|
3647
|
+
..._flags$5.commonFlags,
|
|
3469
3648
|
..._flags$5.outputFlags,
|
|
3470
3649
|
...repositoryUpdateFlags
|
|
3471
3650
|
};
|
|
@@ -3485,34 +3664,30 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
3485
3664
|
flags
|
|
3486
3665
|
});
|
|
3487
3666
|
const {
|
|
3488
|
-
|
|
3489
|
-
markdown: outputMarkdown,
|
|
3490
|
-
repoName,
|
|
3491
|
-
repoDescription,
|
|
3492
|
-
homepage,
|
|
3493
|
-
defaultBranch,
|
|
3494
|
-
visibility
|
|
3667
|
+
repoName
|
|
3495
3668
|
} = cli.flags;
|
|
3496
3669
|
const [orgSlug = ''] = cli.input;
|
|
3670
|
+
let showHelp = cli.flags['help'];
|
|
3497
3671
|
if (!orgSlug) {
|
|
3672
|
+
showHelp = true;
|
|
3498
3673
|
console.error(`${_chalk$5.default.white.bgRed('Input error')}: Please provide an organization slug and repository name\n`);
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
}
|
|
3502
|
-
if (!repoName) {
|
|
3674
|
+
} else if (!repoName) {
|
|
3675
|
+
showHelp = true;
|
|
3503
3676
|
console.error(`${_chalk$5.default.white.bgRed('Input error')}: Repository name is required.\n`);
|
|
3677
|
+
}
|
|
3678
|
+
if (showHelp) {
|
|
3504
3679
|
cli.showHelp();
|
|
3505
3680
|
return;
|
|
3506
3681
|
}
|
|
3507
3682
|
return {
|
|
3508
|
-
outputJson,
|
|
3509
|
-
outputMarkdown,
|
|
3683
|
+
outputJson: cli.flags['json'],
|
|
3684
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3510
3685
|
orgSlug,
|
|
3511
3686
|
name: repoName,
|
|
3512
|
-
description: repoDescription,
|
|
3513
|
-
homepage,
|
|
3514
|
-
default_branch: defaultBranch,
|
|
3515
|
-
visibility
|
|
3687
|
+
description: cli.flags['repoDescription'],
|
|
3688
|
+
homepage: cli.flags['homepage'],
|
|
3689
|
+
default_branch: cli.flags['defaultBranch'],
|
|
3690
|
+
visibility: cli.flags['visibility']
|
|
3516
3691
|
};
|
|
3517
3692
|
}
|
|
3518
3693
|
async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
@@ -3567,6 +3742,8 @@ const view = view$1.view = {
|
|
|
3567
3742
|
|
|
3568
3743
|
function setupCommand$4(name, description, argv, importMeta) {
|
|
3569
3744
|
const flags = {
|
|
3745
|
+
__proto__: null,
|
|
3746
|
+
..._flags$4.commonFlags,
|
|
3570
3747
|
..._flags$4.outputFlags
|
|
3571
3748
|
};
|
|
3572
3749
|
const cli = (0, _meow$4.default)(`
|
|
@@ -3584,12 +3761,12 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
3584
3761
|
importMeta,
|
|
3585
3762
|
flags
|
|
3586
3763
|
});
|
|
3587
|
-
|
|
3588
|
-
json: outputJson,
|
|
3589
|
-
markdown: outputMarkdown
|
|
3590
|
-
} = cli.flags;
|
|
3764
|
+
let showHelp = cli.flags['help'];
|
|
3591
3765
|
if (!cli.input[0]) {
|
|
3766
|
+
showHelp = true;
|
|
3592
3767
|
console.error(`${_chalk$4.default.white.bgRed('Input error')}: Please provide an organization slug and repository name\n`);
|
|
3768
|
+
}
|
|
3769
|
+
if (showHelp) {
|
|
3593
3770
|
cli.showHelp();
|
|
3594
3771
|
return;
|
|
3595
3772
|
}
|
|
@@ -3598,8 +3775,8 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
3598
3775
|
1: repositoryName = ''
|
|
3599
3776
|
} = cli.input;
|
|
3600
3777
|
return {
|
|
3601
|
-
outputJson,
|
|
3602
|
-
outputMarkdown,
|
|
3778
|
+
outputJson: cli.flags['json'],
|
|
3779
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3603
3780
|
orgSlug,
|
|
3604
3781
|
repositoryName
|
|
3605
3782
|
};
|
|
@@ -3720,8 +3897,9 @@ const dependenciesFlags = {
|
|
|
3720
3897
|
function setupCommand$3(name, description, argv, importMeta) {
|
|
3721
3898
|
const flags = {
|
|
3722
3899
|
__proto__: null,
|
|
3723
|
-
..._flags$3.
|
|
3724
|
-
...dependenciesFlags
|
|
3900
|
+
..._flags$3.commonFlags,
|
|
3901
|
+
...dependenciesFlags,
|
|
3902
|
+
..._flags$3.outputFlags
|
|
3725
3903
|
};
|
|
3726
3904
|
const cli = (0, _meow$3.default)(`
|
|
3727
3905
|
Usage
|
|
@@ -3811,7 +3989,7 @@ Object.defineProperty(analytics$1, "__esModule", {
|
|
|
3811
3989
|
value: true
|
|
3812
3990
|
});
|
|
3813
3991
|
analytics$1.analytics = void 0;
|
|
3814
|
-
var
|
|
3992
|
+
var _promises = require$$1$4;
|
|
3815
3993
|
var _blessed$1 = require$$2$4;
|
|
3816
3994
|
var _blessedContrib$1 = require$$3$5;
|
|
3817
3995
|
var _chalk$2 = _interopRequireDefault$3(vendor.source);
|
|
@@ -3880,6 +4058,7 @@ const analyticsFlags = {
|
|
|
3880
4058
|
function setupCommand$2(name, description, argv, importMeta) {
|
|
3881
4059
|
const flags = {
|
|
3882
4060
|
__proto__: null,
|
|
4061
|
+
..._flags$2.commonFlags,
|
|
3883
4062
|
..._flags$2.outputFlags,
|
|
3884
4063
|
...analyticsFlags
|
|
3885
4064
|
};
|
|
@@ -3901,11 +4080,9 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3901
4080
|
flags
|
|
3902
4081
|
});
|
|
3903
4082
|
const {
|
|
3904
|
-
json: outputJson,
|
|
3905
|
-
scope,
|
|
3906
|
-
time,
|
|
3907
4083
|
repo,
|
|
3908
|
-
|
|
4084
|
+
scope,
|
|
4085
|
+
time
|
|
3909
4086
|
} = cli.flags;
|
|
3910
4087
|
if (scope !== 'org' && scope !== 'repo') {
|
|
3911
4088
|
throw new _errors$3.InputError("The scope must either be 'org' or 'repo'");
|
|
@@ -3913,8 +4090,12 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3913
4090
|
if (time !== 7 && time !== 30 && time !== 90) {
|
|
3914
4091
|
throw new _errors$3.InputError('The time filter must either be 7, 30 or 90');
|
|
3915
4092
|
}
|
|
4093
|
+
let showHelp = cli.flags['help'];
|
|
3916
4094
|
if (scope === 'repo' && !repo) {
|
|
4095
|
+
showHelp = true;
|
|
3917
4096
|
console.error(`${_chalk$2.default.bgRed.white('Input error')}: Please provide a repository name when using the repository scope. \n`);
|
|
4097
|
+
}
|
|
4098
|
+
if (showHelp) {
|
|
3918
4099
|
cli.showHelp();
|
|
3919
4100
|
return;
|
|
3920
4101
|
}
|
|
@@ -3922,8 +4103,8 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3922
4103
|
scope,
|
|
3923
4104
|
time,
|
|
3924
4105
|
repo,
|
|
3925
|
-
outputJson,
|
|
3926
|
-
file
|
|
4106
|
+
outputJson: cli.flags['json'],
|
|
4107
|
+
file: cli.flags['file']
|
|
3927
4108
|
};
|
|
3928
4109
|
}
|
|
3929
4110
|
const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
|
|
@@ -3942,9 +4123,12 @@ async function fetchOrgAnalyticsData(time, spinner, apiKey, outputJson, filePath
|
|
|
3942
4123
|
return console.log(result.data);
|
|
3943
4124
|
}
|
|
3944
4125
|
if (filePath) {
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
4126
|
+
try {
|
|
4127
|
+
await _promises.writeFile(filePath, JSON.stringify(result.data), 'utf8');
|
|
4128
|
+
console.log(`Data successfully written to ${filePath}`);
|
|
4129
|
+
} catch (e) {
|
|
4130
|
+
console.error(e);
|
|
4131
|
+
}
|
|
3948
4132
|
return;
|
|
3949
4133
|
}
|
|
3950
4134
|
return displayAnalyticsScreen(data);
|
|
@@ -4052,9 +4236,12 @@ async function fetchRepoAnalyticsData(repo, time, spinner, apiKey, outputJson, f
|
|
|
4052
4236
|
return console.log(result.data);
|
|
4053
4237
|
}
|
|
4054
4238
|
if (filePath) {
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4239
|
+
try {
|
|
4240
|
+
await _promises.writeFile(filePath, JSON.stringify(result.data), 'utf8');
|
|
4241
|
+
console.log(`Data successfully written to ${filePath}`);
|
|
4242
|
+
} catch (e) {
|
|
4243
|
+
console.error(e);
|
|
4244
|
+
}
|
|
4058
4245
|
return;
|
|
4059
4246
|
}
|
|
4060
4247
|
return displayAnalyticsScreen(data);
|
|
@@ -4184,8 +4371,9 @@ const getDiffScanFlags = {
|
|
|
4184
4371
|
function setupCommand$1(name, description, argv, importMeta) {
|
|
4185
4372
|
const flags = {
|
|
4186
4373
|
__proto__: null,
|
|
4187
|
-
..._flags$1.
|
|
4188
|
-
...getDiffScanFlags
|
|
4374
|
+
..._flags$1.commonFlags,
|
|
4375
|
+
...getDiffScanFlags,
|
|
4376
|
+
..._flags$1.outputFlags
|
|
4189
4377
|
};
|
|
4190
4378
|
const cli = (0, _meow$1.default)(`
|
|
4191
4379
|
Usage
|
|
@@ -4203,32 +4391,30 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
4203
4391
|
flags
|
|
4204
4392
|
});
|
|
4205
4393
|
const {
|
|
4206
|
-
json: outputJson,
|
|
4207
|
-
markdown: outputMarkdown,
|
|
4208
4394
|
before,
|
|
4209
|
-
after
|
|
4210
|
-
preview,
|
|
4211
|
-
file
|
|
4395
|
+
after
|
|
4212
4396
|
} = cli.flags;
|
|
4397
|
+
let showHelp = cli.flags['help'];
|
|
4213
4398
|
if (!before || !after) {
|
|
4399
|
+
showHelp = true;
|
|
4214
4400
|
console.error(`${_chalk$1.default.bgRed.white('Input error')}: Please specify a before and after full scan ID. To get full scans IDs, you can run the command "socket scan list <your org slug>".\n`);
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
}
|
|
4218
|
-
if (cli.input.length < 1) {
|
|
4401
|
+
} else if (cli.input.length < 1) {
|
|
4402
|
+
showHelp = true;
|
|
4219
4403
|
console.error(`${_chalk$1.default.bgRed.white('Input error')}: Please provide an organization slug\n`);
|
|
4404
|
+
}
|
|
4405
|
+
if (showHelp) {
|
|
4220
4406
|
cli.showHelp();
|
|
4221
4407
|
return;
|
|
4222
4408
|
}
|
|
4223
4409
|
const [orgSlug = ''] = cli.input;
|
|
4224
4410
|
return {
|
|
4225
|
-
outputJson,
|
|
4226
|
-
outputMarkdown,
|
|
4411
|
+
outputJson: cli.flags['json'],
|
|
4412
|
+
outputMarkdown: cli.flags['markdown'],
|
|
4227
4413
|
before,
|
|
4228
4414
|
after,
|
|
4229
|
-
preview,
|
|
4415
|
+
preview: cli.flags['preview'],
|
|
4230
4416
|
orgSlug,
|
|
4231
|
-
file
|
|
4417
|
+
file: cli.flags['file']
|
|
4232
4418
|
};
|
|
4233
4419
|
}
|
|
4234
4420
|
async function getDiffScan({
|
|
@@ -4361,8 +4547,9 @@ const threatFeedFlags = {
|
|
|
4361
4547
|
function setupCommand(name, description, argv, importMeta) {
|
|
4362
4548
|
const flags = {
|
|
4363
4549
|
__proto__: null,
|
|
4364
|
-
...
|
|
4365
|
-
..._flags.outputFlags
|
|
4550
|
+
..._flags.commonFlags,
|
|
4551
|
+
..._flags.outputFlags,
|
|
4552
|
+
...threatFeedFlags
|
|
4366
4553
|
};
|
|
4367
4554
|
const cli = (0, _meow.default)(`
|
|
4368
4555
|
Usage
|