@socketsecurity/cli 0.14.12 → 0.14.14
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 +625 -433
- 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 +49 -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);
|
|
@@ -87,7 +90,12 @@ const yargsConfig = {
|
|
|
87
90
|
//evidence: false,
|
|
88
91
|
//'include-crypto': false,
|
|
89
92
|
//'include-formulation': false,
|
|
90
|
-
|
|
93
|
+
|
|
94
|
+
// Default 'install-deps' to `false` and 'lifecycle' to 'pre-build' to
|
|
95
|
+
// sidestep arbitrary code execution during a cdxgen scan.
|
|
96
|
+
// https://github.com/CycloneDX/cdxgen/issues/1328
|
|
97
|
+
'install-deps': false,
|
|
98
|
+
lifecycle: 'pre-build',
|
|
91
99
|
//output: 'bom.json',
|
|
92
100
|
//profile: 'generic',
|
|
93
101
|
//'project-version': '',
|
|
@@ -124,7 +132,7 @@ const yargsConfig = {
|
|
|
124
132
|
type: 'string'
|
|
125
133
|
}],
|
|
126
134
|
boolean: ['auto-compositions', 'babel', 'deep', 'evidence', 'fail-on-error', 'generate-key-and-sign', 'help', 'include-formulation', 'include-crypto', 'install-deps', 'print', 'required-only', 'server', 'validate', 'version'],
|
|
127
|
-
string: ['api-key', 'output', 'parent-project-id', 'profile', 'project-group', 'project-name', 'project-version', 'project-id', 'server-host', 'server-port', 'server-url', 'spec-version']
|
|
135
|
+
string: ['api-key', 'lifecycle', 'output', 'parent-project-id', 'profile', 'project-group', 'project-name', 'project-version', 'project-id', 'server-host', 'server-port', 'server-url', 'spec-version']
|
|
128
136
|
};
|
|
129
137
|
function argvToArray(argv) {
|
|
130
138
|
if (argv['help']) return ['--help'];
|
|
@@ -141,7 +149,7 @@ function argvToArray(argv) {
|
|
|
141
149
|
} else if (value === true) {
|
|
142
150
|
result.push(`--${key}`);
|
|
143
151
|
} else if (typeof value === 'string') {
|
|
144
|
-
result.push(`--${key}
|
|
152
|
+
result.push(`--${key}`, String(value));
|
|
145
153
|
} else if (Array.isArray(value)) {
|
|
146
154
|
result.push(`--${key}`, ...value.map(String));
|
|
147
155
|
}
|
|
@@ -168,14 +176,14 @@ cdxgen.cdxgen = {
|
|
|
168
176
|
return;
|
|
169
177
|
}
|
|
170
178
|
let cleanupPackageLock = false;
|
|
171
|
-
if (yargv.type !== 'yarn' && nodejsPlatformTypes.includes(yargv.type) && (0, _nodeFs$
|
|
172
|
-
if ((0, _nodeFs$
|
|
179
|
+
if (yargv.type !== 'yarn' && nodejsPlatformTypes.includes(yargv.type) && (0, _nodeFs$4.existsSync)('./yarn.lock')) {
|
|
180
|
+
if ((0, _nodeFs$4.existsSync)('./package-lock.json')) {
|
|
173
181
|
yargv.type = 'npm';
|
|
174
182
|
} else {
|
|
175
183
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
176
184
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
177
185
|
try {
|
|
178
|
-
await _promiseSpawn$6(execPath, [await _nodeFs$
|
|
186
|
+
await _promiseSpawn$6(execPath, [await _nodeFs$4.promises.realpath(synpBinPath), '--source-file', './yarn.lock'], {
|
|
179
187
|
shell: true
|
|
180
188
|
});
|
|
181
189
|
yargv.type = 'npm';
|
|
@@ -186,7 +194,7 @@ cdxgen.cdxgen = {
|
|
|
186
194
|
if (yargv.output === undefined) {
|
|
187
195
|
yargv.output = 'socket-cdx.json';
|
|
188
196
|
}
|
|
189
|
-
await _promiseSpawn$6(execPath, [await _nodeFs$
|
|
197
|
+
await _promiseSpawn$6(execPath, [await _nodeFs$4.promises.realpath(cdxgenBinPath), ...argvToArray(yargv)], {
|
|
190
198
|
env: {
|
|
191
199
|
NODE_ENV: '',
|
|
192
200
|
SBOM_SIGN_ALGORITHM,
|
|
@@ -198,11 +206,11 @@ cdxgen.cdxgen = {
|
|
|
198
206
|
});
|
|
199
207
|
if (cleanupPackageLock) {
|
|
200
208
|
try {
|
|
201
|
-
await _nodeFs$
|
|
209
|
+
await _nodeFs$4.promises.unlink('./package-lock.json');
|
|
202
210
|
} catch {}
|
|
203
211
|
}
|
|
204
212
|
const fullOutputPath = _nodePath$7.join(process.cwd(), yargv.output);
|
|
205
|
-
if ((0, _nodeFs$
|
|
213
|
+
if ((0, _nodeFs$4.existsSync)(fullOutputPath)) {
|
|
206
214
|
console.log(_chalk$j.default.cyanBright(`${yargv.output} created!`));
|
|
207
215
|
}
|
|
208
216
|
}
|
|
@@ -215,7 +223,15 @@ var flags$1 = {};
|
|
|
215
223
|
Object.defineProperty(flags$1, "__esModule", {
|
|
216
224
|
value: true
|
|
217
225
|
});
|
|
218
|
-
flags$1.validationFlags = flags$1.outputFlags = flags$1.commandFlags = void 0;
|
|
226
|
+
flags$1.validationFlags = flags$1.outputFlags = flags$1.commonFlags = flags$1.commandFlags = void 0;
|
|
227
|
+
flags$1.commonFlags = {
|
|
228
|
+
help: {
|
|
229
|
+
type: 'boolean',
|
|
230
|
+
default: false,
|
|
231
|
+
shortFlag: 'h',
|
|
232
|
+
description: 'Print this help.'
|
|
233
|
+
}
|
|
234
|
+
};
|
|
219
235
|
flags$1.commandFlags = {
|
|
220
236
|
enable: {
|
|
221
237
|
type: 'boolean',
|
|
@@ -313,15 +329,10 @@ var objects = {};
|
|
|
313
329
|
Object.defineProperty(objects, "__esModule", {
|
|
314
330
|
value: true
|
|
315
331
|
});
|
|
316
|
-
objects.getOwn = getOwn;
|
|
317
332
|
objects.hasOwn = hasOwn;
|
|
318
333
|
objects.isObjectObject = isObjectObject;
|
|
319
334
|
objects.objectSome = objectSome;
|
|
320
335
|
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
336
|
function hasOwn(obj, propKey) {
|
|
326
337
|
if (obj === null || obj === undefined) return false;
|
|
327
338
|
return Object.hasOwn(obj, propKey);
|
|
@@ -403,8 +414,6 @@ function printFlagList(list, indent, {
|
|
|
403
414
|
padName
|
|
404
415
|
} = {}) {
|
|
405
416
|
return printHelpList({
|
|
406
|
-
help: 'Print this help and exits.',
|
|
407
|
-
version: 'Prints current version and exits.',
|
|
408
417
|
...list
|
|
409
418
|
}, indent, {
|
|
410
419
|
keyPrefix,
|
|
@@ -415,8 +424,8 @@ function printHelpList(list, indent, {
|
|
|
415
424
|
keyPrefix = '',
|
|
416
425
|
padName = 18
|
|
417
426
|
} = {}) {
|
|
418
|
-
const names = Object.keys(list).sort();
|
|
419
427
|
let result = '';
|
|
428
|
+
const names = Object.keys(list).sort();
|
|
420
429
|
for (const name of names) {
|
|
421
430
|
const rawDescription = list[name];
|
|
422
431
|
const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
|
|
@@ -433,7 +442,7 @@ info$1.info = void 0;
|
|
|
433
442
|
var _chalk$h = _interopRequireDefault$q(vendor.source);
|
|
434
443
|
var _meow$p = _interopRequireDefault$q(vendor.build);
|
|
435
444
|
var _ora$l = _interopRequireDefault$q(vendor.ora);
|
|
436
|
-
var _flags$
|
|
445
|
+
var _flags$k = flags$1;
|
|
437
446
|
var _apiHelpers$i = apiHelpers;
|
|
438
447
|
var _chalkMarkdown$3 = sdk.chalkMarkdown;
|
|
439
448
|
var _errors$k = sdk.errors;
|
|
@@ -467,8 +476,9 @@ const info = info$1.info = {
|
|
|
467
476
|
function setupCommand$m(name, description, argv, importMeta) {
|
|
468
477
|
const flags = {
|
|
469
478
|
__proto__: null,
|
|
470
|
-
..._flags$
|
|
471
|
-
..._flags$
|
|
479
|
+
..._flags$k.commonFlags,
|
|
480
|
+
..._flags$k.outputFlags,
|
|
481
|
+
..._flags$k.validationFlags
|
|
472
482
|
};
|
|
473
483
|
const cli = (0, _meow$p.default)(`
|
|
474
484
|
Usage
|
|
@@ -486,19 +496,17 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
486
496
|
importMeta,
|
|
487
497
|
flags
|
|
488
498
|
});
|
|
489
|
-
const {
|
|
490
|
-
all: includeAllIssues,
|
|
491
|
-
json: outputJson,
|
|
492
|
-
markdown: outputMarkdown,
|
|
493
|
-
strict
|
|
494
|
-
} = cli.flags;
|
|
495
499
|
if (cli.input.length > 1) {
|
|
496
500
|
throw new _errors$k.InputError('Only one package lookup supported at once');
|
|
497
501
|
}
|
|
498
502
|
const {
|
|
499
503
|
0: rawPkgName = ''
|
|
500
504
|
} = cli.input;
|
|
505
|
+
let showHelp = cli.flags['help'];
|
|
501
506
|
if (!rawPkgName) {
|
|
507
|
+
showHelp = true;
|
|
508
|
+
}
|
|
509
|
+
if (showHelp) {
|
|
502
510
|
cli.showHelp();
|
|
503
511
|
return;
|
|
504
512
|
}
|
|
@@ -506,12 +514,12 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
506
514
|
const pkgName = versionSeparator < 1 ? rawPkgName : rawPkgName.slice(0, versionSeparator);
|
|
507
515
|
const pkgVersion = versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1);
|
|
508
516
|
return {
|
|
509
|
-
includeAllIssues,
|
|
510
|
-
outputJson,
|
|
511
|
-
outputMarkdown,
|
|
517
|
+
includeAllIssues: cli.flags['all'],
|
|
518
|
+
outputJson: cli.flags['json'],
|
|
519
|
+
outputMarkdown: cli.flags['markdown'],
|
|
512
520
|
pkgName,
|
|
513
521
|
pkgVersion,
|
|
514
|
-
strict
|
|
522
|
+
strict: cli.flags['strict']
|
|
515
523
|
};
|
|
516
524
|
}
|
|
517
525
|
async function fetchPackageData(pkgName, pkgVersion, {
|
|
@@ -654,6 +662,9 @@ const flags = {
|
|
|
654
662
|
description: 'Proxy to use when making connection to API server'
|
|
655
663
|
}
|
|
656
664
|
};
|
|
665
|
+
function nonNullish(value) {
|
|
666
|
+
return value !== null && value !== undefined;
|
|
667
|
+
}
|
|
657
668
|
login.login = {
|
|
658
669
|
description: description$7,
|
|
659
670
|
async run(argv, importMeta, {
|
|
@@ -680,8 +691,13 @@ login.login = {
|
|
|
680
691
|
importMeta,
|
|
681
692
|
flags
|
|
682
693
|
});
|
|
694
|
+
let showHelp = cli.flags['help'];
|
|
683
695
|
if (cli.input.length) {
|
|
696
|
+
showHelp = true;
|
|
697
|
+
}
|
|
698
|
+
if (showHelp) {
|
|
684
699
|
cli.showHelp();
|
|
700
|
+
return;
|
|
685
701
|
}
|
|
686
702
|
if (!(0, _isInteractive.default)()) {
|
|
687
703
|
throw new _errors$j.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
@@ -707,7 +723,6 @@ login.login = {
|
|
|
707
723
|
spinner.fail('Invalid API key');
|
|
708
724
|
return;
|
|
709
725
|
}
|
|
710
|
-
const nonNullish = value => value != null;
|
|
711
726
|
const enforcedChoices = Object.values(orgs.organizations).filter(nonNullish).filter(org => org.plan === 'enterprise').map(org => ({
|
|
712
727
|
name: org.name,
|
|
713
728
|
value: org.id
|
|
@@ -776,8 +791,13 @@ logout.logout = {
|
|
|
776
791
|
description: description$6,
|
|
777
792
|
importMeta
|
|
778
793
|
});
|
|
794
|
+
let showHelp = cli.flags['help'];
|
|
779
795
|
if (cli.input.length) {
|
|
796
|
+
showHelp = true;
|
|
797
|
+
}
|
|
798
|
+
if (showHelp) {
|
|
780
799
|
cli.showHelp();
|
|
800
|
+
return;
|
|
781
801
|
}
|
|
782
802
|
(0, _settings.updateSetting)('apiKey', null);
|
|
783
803
|
(0, _settings.updateSetting)('apiBaseUrl', null);
|
|
@@ -858,11 +878,11 @@ fs.existsSync = existsSync;
|
|
|
858
878
|
fs.findUp = findUp;
|
|
859
879
|
fs.readFileBinary = readFileBinary;
|
|
860
880
|
fs.readFileUtf8 = readFileUtf8;
|
|
861
|
-
var _nodeFs$
|
|
881
|
+
var _nodeFs$3 = require$$0;
|
|
862
882
|
var _nodePath$4 = require$$1;
|
|
863
883
|
function existsSync(filepath) {
|
|
864
884
|
try {
|
|
865
|
-
return filepath ? (0, _nodeFs$
|
|
885
|
+
return filepath ? (0, _nodeFs$3.existsSync)(filepath) : false;
|
|
866
886
|
} catch {}
|
|
867
887
|
return false;
|
|
868
888
|
}
|
|
@@ -879,7 +899,7 @@ async function findUp(name, {
|
|
|
879
899
|
const filePath = _nodePath$4.join(dir, name);
|
|
880
900
|
try {
|
|
881
901
|
// eslint-disable-next-line no-await-in-loop
|
|
882
|
-
const stats = await _nodeFs$
|
|
902
|
+
const stats = await _nodeFs$3.promises.stat(filePath);
|
|
883
903
|
if (stats.isFile()) {
|
|
884
904
|
return filePath;
|
|
885
905
|
}
|
|
@@ -890,13 +910,13 @@ async function findUp(name, {
|
|
|
890
910
|
return undefined;
|
|
891
911
|
}
|
|
892
912
|
async function readFileBinary(filepath, options) {
|
|
893
|
-
return await _nodeFs$
|
|
913
|
+
return await _nodeFs$3.promises.readFile(filepath, {
|
|
894
914
|
...options,
|
|
895
915
|
encoding: 'binary'
|
|
896
916
|
});
|
|
897
917
|
}
|
|
898
918
|
async function readFileUtf8(filepath, options) {
|
|
899
|
-
return await _nodeFs$
|
|
919
|
+
return await _nodeFs$3.promises.readFile(filepath, {
|
|
900
920
|
...options,
|
|
901
921
|
encoding: 'utf8'
|
|
902
922
|
});
|
|
@@ -932,7 +952,7 @@ function isNonEmptyString(value) {
|
|
|
932
952
|
Object.defineProperty(packageManagerDetector, "__esModule", {
|
|
933
953
|
value: true
|
|
934
954
|
});
|
|
935
|
-
packageManagerDetector.
|
|
955
|
+
packageManagerDetector.AGENTS = void 0;
|
|
936
956
|
packageManagerDetector.detect = detect;
|
|
937
957
|
var _nodePath$3 = require$$1;
|
|
938
958
|
var _hyrious__bun = require$$1$3;
|
|
@@ -943,10 +963,41 @@ var _which = require$$5$1;
|
|
|
943
963
|
var _fs = fs;
|
|
944
964
|
var _json = json;
|
|
945
965
|
var _objects$1 = objects;
|
|
946
|
-
var _strings = strings;
|
|
947
|
-
const PNPM_WORKSPACE = 'pnpm-workspace';
|
|
966
|
+
var _strings$1 = strings;
|
|
948
967
|
const AGENTS = packageManagerDetector.AGENTS = ['bun', 'npm', 'pnpm', 'yarn'];
|
|
949
|
-
const
|
|
968
|
+
const numericCollator = new Intl.Collator(undefined, {
|
|
969
|
+
numeric: true,
|
|
970
|
+
sensitivity: 'base'
|
|
971
|
+
});
|
|
972
|
+
const {
|
|
973
|
+
compare: alphaNumericComparator
|
|
974
|
+
} = numericCollator;
|
|
975
|
+
const maintainedNodeVersions = (() => {
|
|
976
|
+
// Under the hood browserlist uses the node-releases package which is out of date:
|
|
977
|
+
// https://github.com/chicoxyzzy/node-releases/issues/37
|
|
978
|
+
// So we maintain a manual version list for now.
|
|
979
|
+
// https://nodejs.org/en/about/previous-releases#looking-for-latest-release-of-a-version-branch
|
|
980
|
+
const manualPrev = '18.20.4';
|
|
981
|
+
const manualCurr = '20.18.0';
|
|
982
|
+
const manualNext = '22.10.0';
|
|
983
|
+
const query = _browserslist('maintained node versions')
|
|
984
|
+
// Trim value, e.g. 'node 22.5.0' to '22.5.0'.
|
|
985
|
+
.map(s => s.slice(5 /*'node '.length*/))
|
|
986
|
+
// Sort ascending.
|
|
987
|
+
.toSorted(alphaNumericComparator);
|
|
988
|
+
const queryPrev = query.at(0) ?? manualPrev;
|
|
989
|
+
const queryCurr = query.at(1) ?? manualCurr;
|
|
990
|
+
const queryNext = query.at(2) ?? manualNext;
|
|
991
|
+
const previous = _semver$1.maxSatisfying([queryPrev, manualPrev], `^${_semver$1.major(queryPrev)}`);
|
|
992
|
+
const current = _semver$1.maxSatisfying([queryCurr, manualCurr], `^${_semver$1.major(queryCurr)}`);
|
|
993
|
+
const next = _semver$1.maxSatisfying([queryNext, manualNext], `^${_semver$1.major(queryNext)}`);
|
|
994
|
+
return Object.freeze(Object.assign([previous, current, next], {
|
|
995
|
+
previous,
|
|
996
|
+
current,
|
|
997
|
+
next
|
|
998
|
+
}));
|
|
999
|
+
})();
|
|
1000
|
+
const LOCKS = {
|
|
950
1001
|
'bun.lockb': 'bun',
|
|
951
1002
|
'pnpm-lock.yaml': 'pnpm',
|
|
952
1003
|
'pnpm-lock.yml': 'pnpm',
|
|
@@ -964,16 +1015,16 @@ const LOCKS = packageManagerDetector.LOCKS = {
|
|
|
964
1015
|
// it has to be handled differently.
|
|
965
1016
|
'node_modules/.package-lock.json': 'npm'
|
|
966
1017
|
};
|
|
967
|
-
const
|
|
968
|
-
// Trim value, e.g. 'node 22.5.0' to '22.5.0'
|
|
969
|
-
.map(v => v.slice(5));
|
|
1018
|
+
const PNPM_WORKSPACE = 'pnpm-workspace';
|
|
970
1019
|
const readLockFileByAgent = (() => {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1020
|
+
function wrapReader(reader) {
|
|
1021
|
+
return async (lockPath, agentExecPath) => {
|
|
1022
|
+
try {
|
|
1023
|
+
return await reader(lockPath, agentExecPath);
|
|
1024
|
+
} catch {}
|
|
1025
|
+
return undefined;
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
977
1028
|
return {
|
|
978
1029
|
bun: wrapReader(async (lockPath, agentExecPath) => {
|
|
979
1030
|
let lockBuffer;
|
|
@@ -987,7 +1038,7 @@ const readLockFileByAgent = (() => {
|
|
|
987
1038
|
} catch {}
|
|
988
1039
|
// To print a Yarn lockfile to your console without writing it to disk use `bun bun.lockb`.
|
|
989
1040
|
// https://bun.sh/guides/install/yarnlock
|
|
990
|
-
return (await _promiseSpawn$3(agentExecPath
|
|
1041
|
+
return (await _promiseSpawn$3(agentExecPath, [lockPath])).stdout;
|
|
991
1042
|
}),
|
|
992
1043
|
npm: wrapReader(async lockPath => await (0, _fs.readFileUtf8)(lockPath)),
|
|
993
1044
|
pnpm: wrapReader(async lockPath => await (0, _fs.readFileUtf8)(lockPath)),
|
|
@@ -1009,7 +1060,7 @@ async function detect({
|
|
|
1009
1060
|
// https://nodejs.org/api/packages.html#packagemanager
|
|
1010
1061
|
const pkgJsonStr = (0, _fs.existsSync)(pkgJsonPath) ? await (0, _fs.readFileUtf8)(pkgJsonPath) : undefined;
|
|
1011
1062
|
const pkgJson = typeof pkgJsonStr === 'string' ? (0, _json.parseJSONObject)(pkgJsonStr) ?? undefined : undefined;
|
|
1012
|
-
const pkgManager = (0, _strings
|
|
1063
|
+
const pkgManager = (0, _strings$1.isNonEmptyString)(pkgJson?.['packageManager']) ? pkgJson['packageManager'] : undefined;
|
|
1013
1064
|
let agent;
|
|
1014
1065
|
let agentVersion;
|
|
1015
1066
|
if (pkgManager) {
|
|
@@ -1033,50 +1084,44 @@ async function detect({
|
|
|
1033
1084
|
const agentExecPath = (await _which(agent, {
|
|
1034
1085
|
nothrow: true
|
|
1035
1086
|
})) ?? agent;
|
|
1036
|
-
let lockSrc;
|
|
1037
1087
|
const targets = {
|
|
1038
1088
|
browser: false,
|
|
1039
1089
|
node: true
|
|
1040
1090
|
};
|
|
1091
|
+
let lockSrc;
|
|
1041
1092
|
let isPrivate = false;
|
|
1042
1093
|
let isWorkspace = false;
|
|
1094
|
+
let minimumNodeVersion = maintainedNodeVersions.previous;
|
|
1043
1095
|
if (pkgJson) {
|
|
1044
1096
|
const pkgPath = _nodePath$3.dirname(pkgJsonPath);
|
|
1045
1097
|
isPrivate = !!pkgJson['private'];
|
|
1046
1098
|
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;
|
|
1099
|
+
const browserField = pkgJson['browser'];
|
|
1100
|
+
if ((0, _strings$1.isNonEmptyString)(browserField) || (0, _objects$1.isObjectObject)(browserField)) {
|
|
1101
|
+
targets.browser = true;
|
|
1052
1102
|
}
|
|
1053
|
-
const nodeRange =
|
|
1054
|
-
if ((0, _strings.isNonEmptyString)(nodeRange)) {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1103
|
+
const nodeRange = pkgJson['engines']?.['node'];
|
|
1104
|
+
if ((0, _strings$1.isNonEmptyString)(nodeRange)) {
|
|
1105
|
+
const coerced = _semver$1.coerce(nodeRange);
|
|
1106
|
+
if (coerced && _semver$1.lt(coerced, minimumNodeVersion)) {
|
|
1107
|
+
minimumNodeVersion = coerced.version;
|
|
1108
|
+
}
|
|
1059
1109
|
}
|
|
1060
|
-
const browserslistQuery =
|
|
1110
|
+
const browserslistQuery = pkgJson['browserslist'];
|
|
1061
1111
|
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;
|
|
1112
|
+
const browserslistTargets = _browserslist(browserslistQuery).map(s => s.toLowerCase()).toSorted(alphaNumericComparator);
|
|
1113
|
+
const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5 /*'node '.length*/));
|
|
1114
|
+
if (!targets.browser && browserslistTargets.length) {
|
|
1115
|
+
targets.browser = browserslistTargets.length !== browserslistNodeTargets.length;
|
|
1066
1116
|
}
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1117
|
+
if (browserslistNodeTargets.length) {
|
|
1118
|
+
const coerced = _semver$1.coerce(browserslistNodeTargets[0]);
|
|
1119
|
+
if (coerced && _semver$1.lt(coerced, minimumNodeVersion)) {
|
|
1120
|
+
minimumNodeVersion = coerced.version;
|
|
1121
|
+
}
|
|
1072
1122
|
}
|
|
1073
1123
|
}
|
|
1074
|
-
|
|
1075
|
-
targets.browser = browser;
|
|
1076
|
-
}
|
|
1077
|
-
if (node !== undefined) {
|
|
1078
|
-
targets.node = node;
|
|
1079
|
-
}
|
|
1124
|
+
targets.node = maintainedNodeVersions.some(v => _semver$1.satisfies(v, `>=${minimumNodeVersion}`));
|
|
1080
1125
|
lockSrc = typeof lockPath === 'string' ? await readLockFileByAgent[agent](lockPath, agentExecPath) : undefined;
|
|
1081
1126
|
} else {
|
|
1082
1127
|
lockPath = undefined;
|
|
@@ -1089,6 +1134,7 @@ async function detect({
|
|
|
1089
1134
|
isWorkspace,
|
|
1090
1135
|
lockPath,
|
|
1091
1136
|
lockSrc,
|
|
1137
|
+
minimumNodeVersion,
|
|
1092
1138
|
pkgJson,
|
|
1093
1139
|
pkgJsonPath,
|
|
1094
1140
|
pkgJsonStr,
|
|
@@ -1097,6 +1143,57 @@ async function detect({
|
|
|
1097
1143
|
};
|
|
1098
1144
|
}
|
|
1099
1145
|
|
|
1146
|
+
var promises = {};
|
|
1147
|
+
|
|
1148
|
+
var arrays = {};
|
|
1149
|
+
|
|
1150
|
+
Object.defineProperty(arrays, "__esModule", {
|
|
1151
|
+
value: true
|
|
1152
|
+
});
|
|
1153
|
+
arrays.arrayChunk = arrayChunk;
|
|
1154
|
+
arrays.arrayUnique = arrayUnique;
|
|
1155
|
+
function arrayChunk(arr, size = 2) {
|
|
1156
|
+
const {
|
|
1157
|
+
length
|
|
1158
|
+
} = arr;
|
|
1159
|
+
const chunkSize = Math.min(length, size);
|
|
1160
|
+
const chunks = [];
|
|
1161
|
+
for (let i = 0; i < length; i += chunkSize) {
|
|
1162
|
+
chunks.push(arr.slice(i, i + chunkSize));
|
|
1163
|
+
}
|
|
1164
|
+
return chunks;
|
|
1165
|
+
}
|
|
1166
|
+
function arrayUnique(arr) {
|
|
1167
|
+
return [...new Set(arr)];
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
Object.defineProperty(promises, "__esModule", {
|
|
1171
|
+
value: true
|
|
1172
|
+
});
|
|
1173
|
+
promises.pEach = pEach;
|
|
1174
|
+
promises.pEachChunk = pEachChunk;
|
|
1175
|
+
var _arrays = arrays;
|
|
1176
|
+
async function pEach(array, concurrency, callbackFn, options) {
|
|
1177
|
+
await pEachChunk((0, _arrays.arrayChunk)(array, concurrency), callbackFn, options);
|
|
1178
|
+
}
|
|
1179
|
+
async function pEachChunk(chunks, callbackFn, options) {
|
|
1180
|
+
const {
|
|
1181
|
+
signal
|
|
1182
|
+
} = {
|
|
1183
|
+
__proto__: null,
|
|
1184
|
+
...options
|
|
1185
|
+
};
|
|
1186
|
+
for (const chunk of chunks) {
|
|
1187
|
+
if (signal?.aborted) {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1191
|
+
await Promise.all(chunk.map(value => signal?.aborted ? undefined : callbackFn(value, {
|
|
1192
|
+
signal
|
|
1193
|
+
})));
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1100
1197
|
var regexps = {};
|
|
1101
1198
|
|
|
1102
1199
|
Object.defineProperty(regexps, "__esModule", {
|
|
@@ -1138,20 +1235,24 @@ var _promiseSpawn$2 = require$$1$1;
|
|
|
1138
1235
|
var _packageJson = require$$3$2;
|
|
1139
1236
|
var _registry = require$$4;
|
|
1140
1237
|
var _meow$m = _interopRequireDefault$n(vendor.build);
|
|
1238
|
+
var _npmPackageArg = require$$6$1;
|
|
1141
1239
|
var _ora$i = _interopRequireDefault$n(vendor.ora);
|
|
1240
|
+
var _pacote = require$$8;
|
|
1142
1241
|
var _semver = require$$3$1;
|
|
1242
|
+
var _flags$j = flags$1;
|
|
1143
1243
|
var _formatting$k = formatting;
|
|
1144
1244
|
var _objects = objects;
|
|
1145
1245
|
var _packageManagerDetector = packageManagerDetector;
|
|
1246
|
+
var _promises$2 = promises;
|
|
1146
1247
|
var _regexps = regexps;
|
|
1147
1248
|
var _sorts$1 = sorts;
|
|
1249
|
+
var _strings = strings;
|
|
1148
1250
|
const distPath$1 = __dirname;
|
|
1149
1251
|
const COMMAND_TITLE = 'Socket Optimize';
|
|
1150
1252
|
const OVERRIDES_FIELD_NAME = 'overrides';
|
|
1151
1253
|
const RESOLUTIONS_FIELD_NAME = 'resolutions';
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
}) => d.engines?.node?.startsWith('>=18'));
|
|
1254
|
+
const manifestNpmOverrides = (0, _registry.getManifestData)('npm');
|
|
1255
|
+
const packumentCache = new Map();
|
|
1155
1256
|
const getOverridesDataByAgent = {
|
|
1156
1257
|
// npm overrides documentation:
|
|
1157
1258
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
|
|
@@ -1238,11 +1339,10 @@ async function addOverrides({
|
|
|
1238
1339
|
isWorkspace,
|
|
1239
1340
|
lockSrc,
|
|
1240
1341
|
lockIncludes,
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
} = aoState;
|
|
1342
|
+
manifestEntries,
|
|
1343
|
+
pkgJsonPath,
|
|
1344
|
+
pin
|
|
1345
|
+
}, state) {
|
|
1246
1346
|
const editablePkgJson = await _packageJson.load(_nodePath$2.dirname(pkgJsonPath));
|
|
1247
1347
|
const {
|
|
1248
1348
|
dependencies,
|
|
@@ -1271,10 +1371,12 @@ async function addOverrides({
|
|
|
1271
1371
|
} else {
|
|
1272
1372
|
overridesDataObjects.push(getOverridesDataByAgent['npm'](editablePkgJson.content), getOverridesDataByAgent['yarn'](editablePkgJson.content));
|
|
1273
1373
|
}
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1374
|
+
const depAliasMap = new Map();
|
|
1375
|
+
const spinner = (0, _ora$i.default)(`Fetching override manifests...`).start();
|
|
1376
|
+
// Chunk package names to process them in parallel 3 at a time.
|
|
1377
|
+
await (0, _promises$2.pEach)(manifestEntries, 3, async ({
|
|
1276
1378
|
1: data
|
|
1277
|
-
}
|
|
1379
|
+
}) => {
|
|
1278
1380
|
const {
|
|
1279
1381
|
name: regPkgName,
|
|
1280
1382
|
package: origPkgName,
|
|
@@ -1285,145 +1387,194 @@ async function addOverrides({
|
|
|
1285
1387
|
} of depEntries) {
|
|
1286
1388
|
let pkgSpec = depObj[origPkgName];
|
|
1287
1389
|
if (pkgSpec) {
|
|
1390
|
+
let thisVersion = version;
|
|
1288
1391
|
// Add package aliases for direct dependencies to avoid npm EOVERRIDE errors.
|
|
1289
1392
|
// https://docs.npmjs.com/cli/v8/using-npm/package-spec#aliases
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1393
|
+
const specStartsWith = `npm:${regPkgName}@`;
|
|
1394
|
+
const existingVersion = pkgSpec.startsWith(specStartsWith) ? _semver.coerce(_npmPackageArg(pkgSpec).rawSpec)?.version ?? '' : '';
|
|
1395
|
+
if (existingVersion) {
|
|
1396
|
+
thisVersion = existingVersion;
|
|
1293
1397
|
} else {
|
|
1294
|
-
|
|
1295
|
-
pkgSpec = `${overrideSpecPrefix}^${version}`;
|
|
1398
|
+
pkgSpec = `${specStartsWith}^${version}`;
|
|
1296
1399
|
depObj[origPkgName] = pkgSpec;
|
|
1400
|
+
state.added.add(regPkgName);
|
|
1297
1401
|
}
|
|
1298
|
-
|
|
1402
|
+
depAliasMap.set(origPkgName, {
|
|
1403
|
+
id: pkgSpec,
|
|
1404
|
+
version: thisVersion
|
|
1405
|
+
});
|
|
1299
1406
|
}
|
|
1300
1407
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
overrides
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
// With npm
|
|
1309
|
-
//
|
|
1408
|
+
// Chunk package names to process them in parallel 3 at a time.
|
|
1409
|
+
await (0, _promises$2.pEach)(overridesDataObjects, 3, async ({
|
|
1410
|
+
overrides,
|
|
1411
|
+
type
|
|
1412
|
+
}) => {
|
|
1413
|
+
const overrideExists = (0, _objects.hasOwn)(overrides, origPkgName);
|
|
1414
|
+
if (overrideExists || lockIncludes(lockSrc, origPkgName)) {
|
|
1415
|
+
// With npm one may not set an override for a package that one directly
|
|
1416
|
+
// depends on unless both the dependency and the override itself share
|
|
1310
1417
|
// the exact same spec. To make this limitation easier to deal with,
|
|
1311
1418
|
// overrides may also be defined as a reference to a spec for a direct
|
|
1312
|
-
// dependency by prefixing the name of the package
|
|
1313
|
-
//
|
|
1419
|
+
// dependency by prefixing the name of the package to match the version
|
|
1420
|
+
// of with a $.
|
|
1314
1421
|
// https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
|
|
1315
|
-
|
|
1422
|
+
const oldSpec = overrides[origPkgName];
|
|
1423
|
+
const depAlias = depAliasMap.get(origPkgName);
|
|
1424
|
+
const thisVersion = overrideExists && (0, _strings.isNonEmptyString)(oldSpec) ? (await fetchPackageManifest(oldSpec.startsWith('$') ? depAlias?.id ?? oldSpec : oldSpec))?.version ?? version : version;
|
|
1425
|
+
const newSpec = depAlias && type === 'npm' ? `$${origPkgName}` : `npm:${regPkgName}@^${pin ? thisVersion : _semver.major(thisVersion)}`;
|
|
1426
|
+
if (newSpec !== oldSpec) {
|
|
1427
|
+
if (overrideExists) {
|
|
1428
|
+
state.updated.add(regPkgName);
|
|
1429
|
+
} else {
|
|
1430
|
+
state.added.add(regPkgName);
|
|
1431
|
+
}
|
|
1432
|
+
overrides[origPkgName] = newSpec;
|
|
1433
|
+
}
|
|
1316
1434
|
}
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1435
|
+
});
|
|
1436
|
+
});
|
|
1437
|
+
spinner.stop();
|
|
1438
|
+
if (state.added.size || state.updated.size) {
|
|
1320
1439
|
editablePkgJson.update(Object.fromEntries(depEntries));
|
|
1321
1440
|
for (const {
|
|
1322
|
-
|
|
1323
|
-
|
|
1441
|
+
overrides,
|
|
1442
|
+
type
|
|
1324
1443
|
} of overridesDataObjects) {
|
|
1325
1444
|
updateManifestByAgent[type](editablePkgJson, (0, _sorts$1.toSortedObject)(overrides));
|
|
1326
1445
|
}
|
|
1327
1446
|
await editablePkgJson.save();
|
|
1328
1447
|
}
|
|
1329
|
-
return
|
|
1448
|
+
return state;
|
|
1449
|
+
}
|
|
1450
|
+
async function fetchPackageManifest(pkgNameOrId, options) {
|
|
1451
|
+
const pacoteOptions = {
|
|
1452
|
+
__proto__: null,
|
|
1453
|
+
...options,
|
|
1454
|
+
packumentCache,
|
|
1455
|
+
preferOffline: true
|
|
1456
|
+
};
|
|
1457
|
+
const {
|
|
1458
|
+
signal
|
|
1459
|
+
} = pacoteOptions;
|
|
1460
|
+
if (signal?.aborted) {
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
let result;
|
|
1464
|
+
try {
|
|
1465
|
+
result = await _pacote.manifest(pkgNameOrId, pacoteOptions);
|
|
1466
|
+
} catch {}
|
|
1467
|
+
if (signal?.aborted) {
|
|
1468
|
+
return null;
|
|
1469
|
+
}
|
|
1470
|
+
return result;
|
|
1330
1471
|
}
|
|
1331
1472
|
const optimize = optimize$1.optimize = {
|
|
1332
1473
|
description: 'Optimize dependencies with @socketregistry overrides',
|
|
1333
1474
|
async run(argv, importMeta, {
|
|
1334
1475
|
parentName
|
|
1335
1476
|
}) {
|
|
1336
|
-
const commandContext = setupCommand$l(`${parentName}
|
|
1337
|
-
if (commandContext) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1477
|
+
const commandContext = setupCommand$l(`${parentName} optimize`, optimize.description, argv, importMeta);
|
|
1478
|
+
if (!commandContext) {
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
const {
|
|
1482
|
+
pin
|
|
1483
|
+
} = commandContext;
|
|
1484
|
+
const cwd = process.cwd();
|
|
1485
|
+
const {
|
|
1486
|
+
agent,
|
|
1487
|
+
agentExecPath,
|
|
1488
|
+
isPrivate,
|
|
1489
|
+
isWorkspace,
|
|
1490
|
+
lockSrc,
|
|
1491
|
+
lockPath,
|
|
1492
|
+
minimumNodeVersion,
|
|
1493
|
+
pkgJsonPath,
|
|
1494
|
+
pkgJson,
|
|
1495
|
+
supported
|
|
1496
|
+
} = await (0, _packageManagerDetector.detect)({
|
|
1497
|
+
cwd,
|
|
1498
|
+
onUnknown(pkgManager) {
|
|
1499
|
+
console.log(`⚠️ ${COMMAND_TITLE}: Unknown package manager${pkgManager ? ` ${pkgManager}` : ''}, defaulting to npm`);
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1502
|
+
if (!supported) {
|
|
1503
|
+
console.log(`✘ ${COMMAND_TITLE}: No supported Node or browser range detected`);
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
const lockName = lockPath ? _nodePath$2.basename(lockPath) : 'lock file';
|
|
1507
|
+
if (lockSrc === undefined) {
|
|
1508
|
+
console.log(`✘ ${COMMAND_TITLE}: No ${lockName} found`);
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
if (pkgJson === undefined) {
|
|
1512
|
+
console.log(`✘ ${COMMAND_TITLE}: No package.json found`);
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
if (lockPath && _nodePath$2.relative(cwd, lockPath).startsWith('.')) {
|
|
1516
|
+
console.log(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
|
|
1517
|
+
}
|
|
1518
|
+
const state = {
|
|
1519
|
+
added: new Set(),
|
|
1520
|
+
updated: new Set()
|
|
1521
|
+
};
|
|
1522
|
+
if (lockSrc) {
|
|
1523
|
+
const lockIncludes = agent === 'bun' ? lockIncludesByAgent.yarn : lockIncludesByAgent[agent];
|
|
1524
|
+
const nodeRange = `>=${minimumNodeVersion}`;
|
|
1525
|
+
const manifestEntries = manifestNpmOverrides.filter(({
|
|
1526
|
+
1: data
|
|
1527
|
+
}) => _semver.satisfies(_semver.coerce(data.engines.node), nodeRange));
|
|
1528
|
+
await addOverrides({
|
|
1529
|
+
__proto__: null,
|
|
1530
|
+
agent: agent === 'bun' ? 'yarn' : agent,
|
|
1342
1531
|
isPrivate,
|
|
1343
1532
|
isWorkspace,
|
|
1533
|
+
lockIncludes,
|
|
1344
1534
|
lockSrc,
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1535
|
+
manifestEntries,
|
|
1536
|
+
pin,
|
|
1537
|
+
pkgJsonPath
|
|
1538
|
+
}, state);
|
|
1539
|
+
}
|
|
1540
|
+
const pkgJsonChanged = state.updated.size > 0 || state.updated.size > 0;
|
|
1541
|
+
if (state.updated.size > 0) {
|
|
1542
|
+
console.log(`Updated ${state.updated.size} Socket.dev optimized overrides ${state.added.size ? '.' : '🚀'}`);
|
|
1543
|
+
}
|
|
1544
|
+
if (state.added.size > 0) {
|
|
1545
|
+
console.log(`Added ${state.added.size} Socket.dev optimized overrides 🚀`);
|
|
1546
|
+
}
|
|
1547
|
+
if (!pkgJsonChanged) {
|
|
1548
|
+
console.log('Congratulations! Already Socket.dev optimized 🎉');
|
|
1549
|
+
}
|
|
1550
|
+
const isNpm = agent === 'npm';
|
|
1551
|
+
if (isNpm || pkgJsonChanged) {
|
|
1552
|
+
// Always update package-lock.json until the npm overrides PR lands:
|
|
1553
|
+
// https://github.com/npm/cli/pull/7025
|
|
1554
|
+
const spinner = (0, _ora$i.default)(`Updating ${lockName}...`).start();
|
|
1555
|
+
try {
|
|
1556
|
+
if (isNpm) {
|
|
1557
|
+
const wrapperPath = _nodePath$2.join(distPath$1, 'npm-cli.js');
|
|
1558
|
+
await _promiseSpawn$2(process.execPath, [wrapperPath, 'install'], {
|
|
1559
|
+
stdio: 'pipe',
|
|
1560
|
+
env: {
|
|
1561
|
+
__proto__: null,
|
|
1562
|
+
...process.env,
|
|
1563
|
+
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: '1'
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
} else {
|
|
1567
|
+
await _promiseSpawn$2(agentExecPath, ['install'], {
|
|
1568
|
+
stdio: 'pipe'
|
|
1569
|
+
});
|
|
1354
1570
|
}
|
|
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}`);
|
|
1571
|
+
spinner.stop();
|
|
1572
|
+
if (isNpm) {
|
|
1573
|
+
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
1574
|
}
|
|
1575
|
+
} catch {
|
|
1576
|
+
spinner.stop();
|
|
1577
|
+
console.log(`✘ ${COMMAND_TITLE}: ${agent} install failed to update ${lockName}`);
|
|
1427
1578
|
}
|
|
1428
1579
|
}
|
|
1429
1580
|
}
|
|
@@ -1432,7 +1583,15 @@ const optimize = optimize$1.optimize = {
|
|
|
1432
1583
|
// Internal functions
|
|
1433
1584
|
|
|
1434
1585
|
function setupCommand$l(name, description, argv, importMeta) {
|
|
1435
|
-
const flags = {
|
|
1586
|
+
const flags = {
|
|
1587
|
+
__proto__: null,
|
|
1588
|
+
..._flags$j.commonFlags,
|
|
1589
|
+
pin: {
|
|
1590
|
+
type: 'boolean',
|
|
1591
|
+
default: false,
|
|
1592
|
+
description: 'Pin overrides to their latest version'
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1436
1595
|
const cli = (0, _meow$m.default)(`
|
|
1437
1596
|
Usage
|
|
1438
1597
|
$ ${name}
|
|
@@ -1449,16 +1608,15 @@ function setupCommand$l(name, description, argv, importMeta) {
|
|
|
1449
1608
|
flags
|
|
1450
1609
|
});
|
|
1451
1610
|
const {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
limit,
|
|
1455
|
-
offset
|
|
1611
|
+
help,
|
|
1612
|
+
pin
|
|
1456
1613
|
} = cli.flags;
|
|
1614
|
+
if (help) {
|
|
1615
|
+
cli.showHelp();
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1457
1618
|
return {
|
|
1458
|
-
|
|
1459
|
-
outputMarkdown,
|
|
1460
|
-
limit,
|
|
1461
|
-
offset
|
|
1619
|
+
pin
|
|
1462
1620
|
};
|
|
1463
1621
|
}
|
|
1464
1622
|
|
|
@@ -1530,7 +1688,7 @@ Object.defineProperty(rawNpm$1, "__esModule", {
|
|
|
1530
1688
|
rawNpm$1.rawNpm = void 0;
|
|
1531
1689
|
var _promiseSpawn$1 = require$$1$1;
|
|
1532
1690
|
var _meow$k = _interopRequireDefault$l(vendor.build);
|
|
1533
|
-
var _flags$
|
|
1691
|
+
var _flags$i = flags$1;
|
|
1534
1692
|
var _formatting$j = formatting;
|
|
1535
1693
|
const rawNpm = rawNpm$1.rawNpm = {
|
|
1536
1694
|
description: 'Temporarily disable the Socket npm wrapper',
|
|
@@ -1541,7 +1699,11 @@ const rawNpm = rawNpm$1.rawNpm = {
|
|
|
1541
1699
|
}
|
|
1542
1700
|
};
|
|
1543
1701
|
async function setupCommand$j(name, description, argv, importMeta) {
|
|
1544
|
-
const flags =
|
|
1702
|
+
const flags = {
|
|
1703
|
+
__proto__: null,
|
|
1704
|
+
..._flags$i.commonFlags,
|
|
1705
|
+
..._flags$i.validationFlags
|
|
1706
|
+
};
|
|
1545
1707
|
const cli = (0, _meow$k.default)(`
|
|
1546
1708
|
Usage
|
|
1547
1709
|
$ ${name} <npm command>
|
|
@@ -1557,7 +1719,11 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1557
1719
|
importMeta,
|
|
1558
1720
|
flags
|
|
1559
1721
|
});
|
|
1722
|
+
let showHelp = cli.flags['help'];
|
|
1560
1723
|
if (!argv[0]) {
|
|
1724
|
+
showHelp = true;
|
|
1725
|
+
}
|
|
1726
|
+
if (showHelp) {
|
|
1561
1727
|
cli.showHelp();
|
|
1562
1728
|
return;
|
|
1563
1729
|
}
|
|
@@ -1583,7 +1749,7 @@ Object.defineProperty(rawNpx$1, "__esModule", {
|
|
|
1583
1749
|
rawNpx$1.rawNpx = void 0;
|
|
1584
1750
|
var _promiseSpawn = require$$1$1;
|
|
1585
1751
|
var _meow$j = _interopRequireDefault$k(vendor.build);
|
|
1586
|
-
var _flags$
|
|
1752
|
+
var _flags$h = flags$1;
|
|
1587
1753
|
var _formatting$i = formatting;
|
|
1588
1754
|
const rawNpx = rawNpx$1.rawNpx = {
|
|
1589
1755
|
description: 'Temporarily disable the Socket npm/npx wrapper',
|
|
@@ -1594,7 +1760,11 @@ const rawNpx = rawNpx$1.rawNpx = {
|
|
|
1594
1760
|
}
|
|
1595
1761
|
};
|
|
1596
1762
|
async function setupCommand$i(name, description, argv, importMeta) {
|
|
1597
|
-
const flags =
|
|
1763
|
+
const flags = {
|
|
1764
|
+
__proto__: null,
|
|
1765
|
+
..._flags$h.commonFlags,
|
|
1766
|
+
..._flags$h.validationFlags
|
|
1767
|
+
};
|
|
1598
1768
|
const cli = (0, _meow$j.default)(`
|
|
1599
1769
|
Usage
|
|
1600
1770
|
$ ${name} <npx command>
|
|
@@ -1610,7 +1780,11 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1610
1780
|
importMeta,
|
|
1611
1781
|
flags
|
|
1612
1782
|
});
|
|
1783
|
+
let showHelp = cli.flags['help'];
|
|
1613
1784
|
if (!argv[0]) {
|
|
1785
|
+
showHelp = true;
|
|
1786
|
+
}
|
|
1787
|
+
if (showHelp) {
|
|
1614
1788
|
cli.showHelp();
|
|
1615
1789
|
return;
|
|
1616
1790
|
}
|
|
@@ -1644,7 +1818,7 @@ var _chalk$f = _interopRequireDefault$j(vendor.source);
|
|
|
1644
1818
|
var _meow$i = _interopRequireDefault$j(vendor.build);
|
|
1645
1819
|
var _ora$g = _interopRequireDefault$j(vendor.ora);
|
|
1646
1820
|
var _ponyCause$3 = require$$6;
|
|
1647
|
-
var _flags$
|
|
1821
|
+
var _flags$g = flags$1;
|
|
1648
1822
|
var _apiHelpers$g = apiHelpers;
|
|
1649
1823
|
var _chalkMarkdown$2 = sdk.chalkMarkdown;
|
|
1650
1824
|
var _errors$h = sdk.errors;
|
|
@@ -1673,8 +1847,9 @@ const view$2 = view$3.view = {
|
|
|
1673
1847
|
function setupCommand$h(name, description, argv, importMeta) {
|
|
1674
1848
|
const flags = {
|
|
1675
1849
|
__proto__: null,
|
|
1676
|
-
..._flags$
|
|
1677
|
-
..._flags$
|
|
1850
|
+
..._flags$g.commonFlags,
|
|
1851
|
+
..._flags$g.outputFlags,
|
|
1852
|
+
..._flags$g.validationFlags
|
|
1678
1853
|
};
|
|
1679
1854
|
const cli = (0, _meow$i.default)(`
|
|
1680
1855
|
Usage
|
|
@@ -1691,32 +1866,26 @@ function setupCommand$h(name, description, argv, importMeta) {
|
|
|
1691
1866
|
importMeta,
|
|
1692
1867
|
flags
|
|
1693
1868
|
});
|
|
1694
|
-
|
|
1695
|
-
// Extract the input
|
|
1696
|
-
|
|
1697
|
-
const {
|
|
1698
|
-
all: includeAllIssues,
|
|
1699
|
-
json: outputJson,
|
|
1700
|
-
markdown: outputMarkdown,
|
|
1701
|
-
strict
|
|
1702
|
-
} = cli.flags;
|
|
1869
|
+
// Extract the input.
|
|
1703
1870
|
const [reportId, ...extraInput] = cli.input;
|
|
1704
|
-
|
|
1871
|
+
let showHelp = cli.flags['help'];
|
|
1872
|
+
if (reportId) {
|
|
1873
|
+
showHelp = true;
|
|
1874
|
+
}
|
|
1875
|
+
if (showHelp) {
|
|
1705
1876
|
cli.showHelp();
|
|
1706
1877
|
return;
|
|
1707
1878
|
}
|
|
1708
|
-
|
|
1709
|
-
// Validate the input
|
|
1710
|
-
|
|
1879
|
+
// Validate the input.
|
|
1711
1880
|
if (extraInput.length) {
|
|
1712
1881
|
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
1882
|
}
|
|
1714
1883
|
return {
|
|
1715
|
-
includeAllIssues,
|
|
1716
|
-
outputJson,
|
|
1717
|
-
outputMarkdown,
|
|
1884
|
+
includeAllIssues: cli.flags['all'],
|
|
1885
|
+
outputJson: cli.flags['json'],
|
|
1886
|
+
outputMarkdown: cli.flags['markdown'],
|
|
1718
1887
|
reportId,
|
|
1719
|
-
strict
|
|
1888
|
+
strict: cli.flags['strict']
|
|
1720
1889
|
};
|
|
1721
1890
|
}
|
|
1722
1891
|
const MAX_TIMEOUT_RETRY = 5;
|
|
@@ -1725,7 +1894,6 @@ async function fetchReportData(reportId, {
|
|
|
1725
1894
|
strict
|
|
1726
1895
|
}) {
|
|
1727
1896
|
// Do the API call
|
|
1728
|
-
|
|
1729
1897
|
const socketSdk = await (0, _sdk$g.setupSdk)();
|
|
1730
1898
|
const spinner = (0, _ora$g.default)(`Fetching report with ID ${reportId} (this could take a while)`).start();
|
|
1731
1899
|
let result;
|
|
@@ -1795,7 +1963,7 @@ var _meow$h = _interopRequireDefault$i(vendor.build);
|
|
|
1795
1963
|
var _ora$f = _interopRequireDefault$i(vendor.ora);
|
|
1796
1964
|
var _ponyCause$2 = require$$6;
|
|
1797
1965
|
var _view$2 = view$3;
|
|
1798
|
-
var _flags$
|
|
1966
|
+
var _flags$f = flags$1;
|
|
1799
1967
|
var _apiHelpers$f = apiHelpers;
|
|
1800
1968
|
var _chalkMarkdown$1 = sdk.chalkMarkdown;
|
|
1801
1969
|
var _errors$g = sdk.errors;
|
|
@@ -1860,8 +2028,9 @@ const create$4 = create$5.create = {
|
|
|
1860
2028
|
async function setupCommand$g(name, description, argv, importMeta) {
|
|
1861
2029
|
const flags = {
|
|
1862
2030
|
__proto__: null,
|
|
1863
|
-
..._flags$
|
|
1864
|
-
..._flags$
|
|
2031
|
+
..._flags$f.commonFlags,
|
|
2032
|
+
..._flags$f.outputFlags,
|
|
2033
|
+
..._flags$f.validationFlags,
|
|
1865
2034
|
debug: {
|
|
1866
2035
|
type: 'boolean',
|
|
1867
2036
|
shortFlag: 'd',
|
|
@@ -1915,18 +2084,17 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
1915
2084
|
importMeta,
|
|
1916
2085
|
flags
|
|
1917
2086
|
});
|
|
1918
|
-
|
|
1919
|
-
all: includeAllIssues,
|
|
1920
|
-
dryRun,
|
|
1921
|
-
json: outputJson,
|
|
1922
|
-
markdown: outputMarkdown,
|
|
1923
|
-
strict,
|
|
1924
|
-
view
|
|
1925
|
-
} = cli.flags;
|
|
2087
|
+
let showHelp = cli.flags['help'];
|
|
1926
2088
|
if (!cli.input[0]) {
|
|
2089
|
+
showHelp = true;
|
|
2090
|
+
}
|
|
2091
|
+
if (showHelp) {
|
|
1927
2092
|
cli.showHelp();
|
|
1928
2093
|
return;
|
|
1929
2094
|
}
|
|
2095
|
+
const {
|
|
2096
|
+
dryRun
|
|
2097
|
+
} = cli.flags;
|
|
1930
2098
|
const debugLog = (0, _misc$1.createDebugLogger)(!dryRun || cli.flags['debug']);
|
|
1931
2099
|
|
|
1932
2100
|
// TODO: Allow setting a custom cwd and/or configFile path?
|
|
@@ -1964,12 +2132,12 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
1964
2132
|
cwd,
|
|
1965
2133
|
debugLog,
|
|
1966
2134
|
dryRun,
|
|
1967
|
-
includeAllIssues,
|
|
1968
|
-
outputJson,
|
|
1969
|
-
outputMarkdown,
|
|
2135
|
+
includeAllIssues: cli.flags['all'],
|
|
2136
|
+
outputJson: cli.flags['json'],
|
|
2137
|
+
outputMarkdown: cli.flags['markdown'],
|
|
1970
2138
|
packagePaths,
|
|
1971
|
-
strict,
|
|
1972
|
-
view
|
|
2139
|
+
strict: cli.flags['strict'],
|
|
2140
|
+
view: cli.flags['view']
|
|
1973
2141
|
};
|
|
1974
2142
|
}
|
|
1975
2143
|
async function createReport(packagePaths, {
|
|
@@ -2019,6 +2187,7 @@ meowWithSubcommands$1.meowWithSubcommands = meowWithSubcommands;
|
|
|
2019
2187
|
var _meow$g = _interopRequireDefault$h(vendor.build);
|
|
2020
2188
|
var _formatting$f = formatting;
|
|
2021
2189
|
var _sorts = sorts;
|
|
2190
|
+
var _flags$e = flags$1;
|
|
2022
2191
|
async function meowWithSubcommands(subcommands, options) {
|
|
2023
2192
|
const {
|
|
2024
2193
|
aliases = {},
|
|
@@ -2026,19 +2195,18 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2026
2195
|
name,
|
|
2027
2196
|
importMeta,
|
|
2028
2197
|
...additionalOptions
|
|
2029
|
-
} =
|
|
2198
|
+
} = {
|
|
2199
|
+
__proto__: null,
|
|
2200
|
+
...options
|
|
2201
|
+
};
|
|
2030
2202
|
const [commandOrAliasName, ...rawCommandArgv] = argv;
|
|
2031
|
-
|
|
2032
2203
|
// If we got at least some args, then lets find out if we can find a command
|
|
2033
2204
|
if (commandOrAliasName) {
|
|
2034
2205
|
const alias = aliases[commandOrAliasName];
|
|
2035
|
-
|
|
2036
2206
|
// First: Resolve argv data from alias if its an alias that's been given
|
|
2037
2207
|
const [commandName, ...commandArgv] = alias ? [...alias.argv, ...rawCommandArgv] : [commandOrAliasName, ...rawCommandArgv];
|
|
2038
|
-
|
|
2039
2208
|
// Second: Find a command definition using that data
|
|
2040
2209
|
const commandDefinition = commandName ? subcommands[commandName] : undefined;
|
|
2041
|
-
|
|
2042
2210
|
// Third: If a valid command has been found, then we run it...
|
|
2043
2211
|
if (commandDefinition) {
|
|
2044
2212
|
return await commandDefinition.run(commandArgv, importMeta, {
|
|
@@ -2046,7 +2214,11 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2046
2214
|
});
|
|
2047
2215
|
}
|
|
2048
2216
|
}
|
|
2049
|
-
|
|
2217
|
+
const flags = {
|
|
2218
|
+
__proto__: null,
|
|
2219
|
+
..._flags$e.commonFlags,
|
|
2220
|
+
...additionalOptions.flags
|
|
2221
|
+
};
|
|
2050
2222
|
// ...else we provide basic instructions and help
|
|
2051
2223
|
const cli = (0, _meow$g.default)(`
|
|
2052
2224
|
Usage
|
|
@@ -2059,14 +2231,15 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2059
2231
|
}, 6)}
|
|
2060
2232
|
|
|
2061
2233
|
Options
|
|
2062
|
-
${(0, _formatting$f.printFlagList)(
|
|
2234
|
+
${(0, _formatting$f.printFlagList)(flags, 6)}
|
|
2063
2235
|
|
|
2064
2236
|
Examples
|
|
2065
2237
|
$ ${name} --help
|
|
2066
2238
|
`, {
|
|
2067
2239
|
argv,
|
|
2068
2240
|
importMeta,
|
|
2069
|
-
...additionalOptions
|
|
2241
|
+
...additionalOptions,
|
|
2242
|
+
flags
|
|
2070
2243
|
});
|
|
2071
2244
|
cli.showHelp();
|
|
2072
2245
|
}
|
|
@@ -2103,7 +2276,7 @@ Object.defineProperty(wrapper$1, "__esModule", {
|
|
|
2103
2276
|
value: true
|
|
2104
2277
|
});
|
|
2105
2278
|
wrapper$1.wrapper = void 0;
|
|
2106
|
-
var _nodeFs$
|
|
2279
|
+
var _nodeFs$2 = require$$0;
|
|
2107
2280
|
var _nodeOs = require$$2$1;
|
|
2108
2281
|
var _nodeReadline = require$$3$4;
|
|
2109
2282
|
var _meow$f = _interopRequireDefault$g(vendor.build);
|
|
@@ -2137,12 +2310,8 @@ function setupCommand$f(name, description, argv, importMeta) {
|
|
|
2137
2310
|
importMeta,
|
|
2138
2311
|
flags
|
|
2139
2312
|
});
|
|
2140
|
-
const {
|
|
2141
|
-
enable,
|
|
2142
|
-
disable
|
|
2143
|
-
} = cli.flags;
|
|
2144
2313
|
if (argv[0] === '--postinstall') {
|
|
2145
|
-
const socketWrapperEnabled = _nodeFs$
|
|
2314
|
+
const socketWrapperEnabled = _nodeFs$2.existsSync(BASH_FILE) && checkSocketWrapperAlreadySetup(BASH_FILE) || _nodeFs$2.existsSync(ZSH_BASH_FILE) && checkSocketWrapperAlreadySetup(ZSH_BASH_FILE);
|
|
2146
2315
|
if (!socketWrapperEnabled) {
|
|
2147
2316
|
installSafeNpm(`The Socket CLI is now successfully installed! 🎉
|
|
2148
2317
|
|
|
@@ -2152,31 +2321,38 @@ function setupCommand$f(name, description, argv, importMeta) {
|
|
|
2152
2321
|
}
|
|
2153
2322
|
return;
|
|
2154
2323
|
}
|
|
2324
|
+
const {
|
|
2325
|
+
enable,
|
|
2326
|
+
disable
|
|
2327
|
+
} = cli.flags;
|
|
2328
|
+
let showHelp = cli.flags['help'];
|
|
2155
2329
|
if (!enable && !disable) {
|
|
2330
|
+
showHelp = true;
|
|
2331
|
+
}
|
|
2332
|
+
if (showHelp) {
|
|
2156
2333
|
cli.showHelp();
|
|
2157
2334
|
return;
|
|
2158
2335
|
}
|
|
2159
2336
|
if (enable) {
|
|
2160
|
-
if (_nodeFs$
|
|
2337
|
+
if (_nodeFs$2.existsSync(BASH_FILE)) {
|
|
2161
2338
|
const socketWrapperEnabled = checkSocketWrapperAlreadySetup(BASH_FILE);
|
|
2162
2339
|
!socketWrapperEnabled && addAlias(BASH_FILE);
|
|
2163
2340
|
}
|
|
2164
|
-
if (_nodeFs$
|
|
2341
|
+
if (_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2165
2342
|
const socketWrapperEnabled = checkSocketWrapperAlreadySetup(ZSH_BASH_FILE);
|
|
2166
2343
|
!socketWrapperEnabled && addAlias(ZSH_BASH_FILE);
|
|
2167
2344
|
}
|
|
2168
2345
|
} else if (disable) {
|
|
2169
|
-
if (_nodeFs$
|
|
2346
|
+
if (_nodeFs$2.existsSync(BASH_FILE)) {
|
|
2170
2347
|
removeAlias(BASH_FILE);
|
|
2171
2348
|
}
|
|
2172
|
-
if (_nodeFs$
|
|
2349
|
+
if (_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2173
2350
|
removeAlias(ZSH_BASH_FILE);
|
|
2174
2351
|
}
|
|
2175
2352
|
}
|
|
2176
|
-
if (!_nodeFs$
|
|
2353
|
+
if (!_nodeFs$2.existsSync(BASH_FILE) && !_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2177
2354
|
console.error('There was an issue setting up the alias in your bash profile');
|
|
2178
2355
|
}
|
|
2179
|
-
return;
|
|
2180
2356
|
}
|
|
2181
2357
|
const installSafeNpm = query => {
|
|
2182
2358
|
console.log(`
|
|
@@ -2196,10 +2372,10 @@ const askQuestion = (rl, query) => {
|
|
|
2196
2372
|
rl.question(query, ans => {
|
|
2197
2373
|
if (ans.toLowerCase() === 'y') {
|
|
2198
2374
|
try {
|
|
2199
|
-
if (_nodeFs$
|
|
2375
|
+
if (_nodeFs$2.existsSync(BASH_FILE)) {
|
|
2200
2376
|
addAlias(BASH_FILE);
|
|
2201
2377
|
}
|
|
2202
|
-
if (_nodeFs$
|
|
2378
|
+
if (_nodeFs$2.existsSync(ZSH_BASH_FILE)) {
|
|
2203
2379
|
addAlias(ZSH_BASH_FILE);
|
|
2204
2380
|
}
|
|
2205
2381
|
} catch (e) {
|
|
@@ -2214,7 +2390,7 @@ const askQuestion = (rl, query) => {
|
|
|
2214
2390
|
});
|
|
2215
2391
|
};
|
|
2216
2392
|
const addAlias = file => {
|
|
2217
|
-
return _nodeFs$
|
|
2393
|
+
return _nodeFs$2.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
|
|
2218
2394
|
if (err) {
|
|
2219
2395
|
return new Error(`There was an error setting up the alias: ${err}`);
|
|
2220
2396
|
}
|
|
@@ -2225,14 +2401,14 @@ If you want to disable it at any time, run \`socket wrapper --disable\`
|
|
|
2225
2401
|
});
|
|
2226
2402
|
};
|
|
2227
2403
|
const removeAlias = file => {
|
|
2228
|
-
return _nodeFs$
|
|
2404
|
+
return _nodeFs$2.readFile(file, 'utf8', function (err, data) {
|
|
2229
2405
|
if (err) {
|
|
2230
2406
|
console.error(`There was an error removing the alias: ${err}`);
|
|
2231
2407
|
return;
|
|
2232
2408
|
}
|
|
2233
2409
|
const linesWithoutSocketAlias = data.split('\n').filter(l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"');
|
|
2234
2410
|
const updatedFileContent = linesWithoutSocketAlias.join('\n');
|
|
2235
|
-
_nodeFs$
|
|
2411
|
+
_nodeFs$2.writeFile(file, updatedFileContent, function (err) {
|
|
2236
2412
|
if (err) {
|
|
2237
2413
|
console.log(err);
|
|
2238
2414
|
return;
|
|
@@ -2243,7 +2419,7 @@ const removeAlias = file => {
|
|
|
2243
2419
|
});
|
|
2244
2420
|
};
|
|
2245
2421
|
const checkSocketWrapperAlreadySetup = file => {
|
|
2246
|
-
const fileContent = _nodeFs$
|
|
2422
|
+
const fileContent = _nodeFs$2.readFileSync(file, 'utf-8');
|
|
2247
2423
|
const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
|
|
2248
2424
|
if (linesWithSocketAlias.length) {
|
|
2249
2425
|
console.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
|
|
@@ -2262,7 +2438,7 @@ Object.defineProperty(create$3, "__esModule", {
|
|
|
2262
2438
|
});
|
|
2263
2439
|
create$3.create = void 0;
|
|
2264
2440
|
var _nodeProcess = require$$0$1;
|
|
2265
|
-
var _promises = require$$2$2;
|
|
2441
|
+
var _promises$1 = require$$2$2;
|
|
2266
2442
|
var _chalk$e = _interopRequireDefault$f(vendor.source);
|
|
2267
2443
|
var _meow$e = _interopRequireDefault$f(vendor.build);
|
|
2268
2444
|
var _open = _interopRequireDefault$f(vendor.open);
|
|
@@ -2369,18 +2545,11 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2369
2545
|
importMeta,
|
|
2370
2546
|
flags
|
|
2371
2547
|
});
|
|
2372
|
-
|
|
2373
|
-
repo: repoName,
|
|
2374
|
-
branch: branchName,
|
|
2375
|
-
commitMessage,
|
|
2376
|
-
defaultBranch,
|
|
2377
|
-
pendingHead,
|
|
2378
|
-
tmp,
|
|
2379
|
-
committers,
|
|
2380
|
-
commitHash,
|
|
2381
|
-
pullRequest
|
|
2382
|
-
} = cli.flags;
|
|
2548
|
+
let showHelp = cli.flags['help'];
|
|
2383
2549
|
if (!cli.input[0]) {
|
|
2550
|
+
showHelp = true;
|
|
2551
|
+
}
|
|
2552
|
+
if (showHelp) {
|
|
2384
2553
|
cli.showHelp();
|
|
2385
2554
|
return;
|
|
2386
2555
|
}
|
|
@@ -2400,11 +2569,18 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2400
2569
|
});
|
|
2401
2570
|
const debugLog = (0, _misc.createDebugLogger)(false);
|
|
2402
2571
|
const packagePaths = await (0, _pathResolve.getPackageFilesFullScans)(cwd, cli.input, supportedFiles, debugLog);
|
|
2572
|
+
const {
|
|
2573
|
+
repo: repoName,
|
|
2574
|
+
branch: branchName
|
|
2575
|
+
} = cli.flags;
|
|
2403
2576
|
if (!repoName || !branchName || !packagePaths.length) {
|
|
2577
|
+
showHelp = true;
|
|
2404
2578
|
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)
|
|
2579
|
+
- Repository name using --repo,\n
|
|
2580
|
+
- Branch name using --branch\n
|
|
2581
|
+
- At least one file path (e.g. ./package.json).`);
|
|
2582
|
+
}
|
|
2583
|
+
if (showHelp) {
|
|
2408
2584
|
cli.showHelp();
|
|
2409
2585
|
return;
|
|
2410
2586
|
}
|
|
@@ -2412,14 +2588,14 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2412
2588
|
orgSlug,
|
|
2413
2589
|
repoName,
|
|
2414
2590
|
branchName,
|
|
2415
|
-
commitMessage,
|
|
2416
|
-
defaultBranch,
|
|
2417
|
-
pendingHead,
|
|
2418
|
-
tmp,
|
|
2591
|
+
commitMessage: cli.flags['commitMessage'],
|
|
2592
|
+
defaultBranch: cli.flags['defaultBranch'],
|
|
2593
|
+
pendingHead: cli.flags['pendingHead'],
|
|
2594
|
+
tmp: cli.flags['tmp'],
|
|
2419
2595
|
packagePaths,
|
|
2420
|
-
commitHash,
|
|
2421
|
-
committers,
|
|
2422
|
-
pullRequest
|
|
2596
|
+
commitHash: cli.flags['commitHash'],
|
|
2597
|
+
committers: cli.flags['committers'],
|
|
2598
|
+
pullRequest: cli.flags['pullRequest']
|
|
2423
2599
|
};
|
|
2424
2600
|
}
|
|
2425
2601
|
async function createFullScan(input, spinner, apiKey) {
|
|
@@ -2450,7 +2626,7 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
2450
2626
|
console.log('\n✅ Scan created successfully\n');
|
|
2451
2627
|
const link = _chalk$e.default.hex('#00FFFF').underline(`${result.data.html_report_url}`);
|
|
2452
2628
|
console.log(`Available at: ${link}\n`);
|
|
2453
|
-
const rl = _promises.createInterface({
|
|
2629
|
+
const rl = _promises$1.createInterface({
|
|
2454
2630
|
input: _nodeProcess.stdin,
|
|
2455
2631
|
output: _nodeProcess.stdout
|
|
2456
2632
|
});
|
|
@@ -2499,6 +2675,8 @@ const del$1 = _delete$3.del = {
|
|
|
2499
2675
|
|
|
2500
2676
|
function setupCommand$d(name, description, argv, importMeta) {
|
|
2501
2677
|
const flags = {
|
|
2678
|
+
__proto__: null,
|
|
2679
|
+
..._flags$c.commonFlags,
|
|
2502
2680
|
..._flags$c.outputFlags
|
|
2503
2681
|
};
|
|
2504
2682
|
const cli = (0, _meow$d.default)(`
|
|
@@ -2516,12 +2694,12 @@ function setupCommand$d(name, description, argv, importMeta) {
|
|
|
2516
2694
|
importMeta,
|
|
2517
2695
|
flags
|
|
2518
2696
|
});
|
|
2519
|
-
|
|
2520
|
-
json: outputJson,
|
|
2521
|
-
markdown: outputMarkdown
|
|
2522
|
-
} = cli.flags;
|
|
2697
|
+
let showHelp = cli.flags['help'];
|
|
2523
2698
|
if (cli.input.length < 2) {
|
|
2699
|
+
showHelp = true;
|
|
2524
2700
|
console.error(`${_chalk$d.default.white.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2701
|
+
}
|
|
2702
|
+
if (showHelp) {
|
|
2525
2703
|
cli.showHelp();
|
|
2526
2704
|
return;
|
|
2527
2705
|
}
|
|
@@ -2530,8 +2708,8 @@ function setupCommand$d(name, description, argv, importMeta) {
|
|
|
2530
2708
|
1: fullScanId = ''
|
|
2531
2709
|
} = cli.input;
|
|
2532
2710
|
return {
|
|
2533
|
-
outputJson,
|
|
2534
|
-
outputMarkdown,
|
|
2711
|
+
outputJson: cli.flags['json'],
|
|
2712
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2535
2713
|
orgSlug,
|
|
2536
2714
|
fullScanId
|
|
2537
2715
|
};
|
|
@@ -2544,7 +2722,7 @@ async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
|
2544
2722
|
return;
|
|
2545
2723
|
}
|
|
2546
2724
|
spinner.stop();
|
|
2547
|
-
console.log('
|
|
2725
|
+
console.log('✅ Scan deleted successfully');
|
|
2548
2726
|
}
|
|
2549
2727
|
|
|
2550
2728
|
var list$3 = {};
|
|
@@ -2626,8 +2804,10 @@ const listFullScanFlags = {
|
|
|
2626
2804
|
|
|
2627
2805
|
function setupCommand$c(name, description, argv, importMeta) {
|
|
2628
2806
|
const flags = {
|
|
2629
|
-
|
|
2630
|
-
...
|
|
2807
|
+
__proto__: null,
|
|
2808
|
+
..._flags$b.commonFlags,
|
|
2809
|
+
...listFullScanFlags,
|
|
2810
|
+
..._flags$b.outputFlags
|
|
2631
2811
|
};
|
|
2632
2812
|
const cli = (0, _meow$c.default)(`
|
|
2633
2813
|
Usage
|
|
@@ -2644,18 +2824,12 @@ function setupCommand$c(name, description, argv, importMeta) {
|
|
|
2644
2824
|
importMeta,
|
|
2645
2825
|
flags
|
|
2646
2826
|
});
|
|
2647
|
-
|
|
2648
|
-
json: outputJson,
|
|
2649
|
-
markdown: outputMarkdown,
|
|
2650
|
-
sort,
|
|
2651
|
-
direction,
|
|
2652
|
-
perPage,
|
|
2653
|
-
page,
|
|
2654
|
-
fromTime,
|
|
2655
|
-
untilTime
|
|
2656
|
-
} = cli.flags;
|
|
2827
|
+
let showHelp = cli.flags['help'];
|
|
2657
2828
|
if (!cli.input[0]) {
|
|
2829
|
+
showHelp = true;
|
|
2658
2830
|
console.error(`${_chalk$c.default.white.bgRed('Input error')}: Please specify an organization slug.\n`);
|
|
2831
|
+
}
|
|
2832
|
+
if (showHelp) {
|
|
2659
2833
|
cli.showHelp();
|
|
2660
2834
|
return;
|
|
2661
2835
|
}
|
|
@@ -2663,15 +2837,15 @@ function setupCommand$c(name, description, argv, importMeta) {
|
|
|
2663
2837
|
0: orgSlug = ''
|
|
2664
2838
|
} = cli.input;
|
|
2665
2839
|
return {
|
|
2666
|
-
outputJson,
|
|
2667
|
-
outputMarkdown,
|
|
2840
|
+
outputJson: cli.flags['json'],
|
|
2841
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2668
2842
|
orgSlug,
|
|
2669
|
-
sort,
|
|
2670
|
-
direction,
|
|
2671
|
-
per_page: perPage,
|
|
2672
|
-
page,
|
|
2673
|
-
from_time: fromTime,
|
|
2674
|
-
until_time: untilTime
|
|
2843
|
+
sort: cli.flags['sort'],
|
|
2844
|
+
direction: cli.flags['direction'],
|
|
2845
|
+
per_page: cli.flags['perPage'],
|
|
2846
|
+
page: cli.flags['page'],
|
|
2847
|
+
from_time: cli.flags['fromTime'],
|
|
2848
|
+
until_time: cli.flags['untilTime']
|
|
2675
2849
|
};
|
|
2676
2850
|
}
|
|
2677
2851
|
async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
@@ -2751,6 +2925,8 @@ const metadata = metadata$1.metadata = {
|
|
|
2751
2925
|
|
|
2752
2926
|
function setupCommand$b(name, description, argv, importMeta) {
|
|
2753
2927
|
const flags = {
|
|
2928
|
+
__proto__: null,
|
|
2929
|
+
..._flags$a.commonFlags,
|
|
2754
2930
|
..._flags$a.outputFlags
|
|
2755
2931
|
};
|
|
2756
2932
|
const cli = (0, _meow$b.default)(`
|
|
@@ -2768,12 +2944,12 @@ function setupCommand$b(name, description, argv, importMeta) {
|
|
|
2768
2944
|
importMeta,
|
|
2769
2945
|
flags
|
|
2770
2946
|
});
|
|
2771
|
-
|
|
2772
|
-
json: outputJson,
|
|
2773
|
-
markdown: outputMarkdown
|
|
2774
|
-
} = cli.flags;
|
|
2947
|
+
let showHelp = cli.flags['help'];
|
|
2775
2948
|
if (cli.input.length < 2) {
|
|
2949
|
+
showHelp = true;
|
|
2776
2950
|
console.error(`${_chalk$b.default.white.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2951
|
+
}
|
|
2952
|
+
if (showHelp) {
|
|
2777
2953
|
cli.showHelp();
|
|
2778
2954
|
return;
|
|
2779
2955
|
}
|
|
@@ -2782,8 +2958,8 @@ function setupCommand$b(name, description, argv, importMeta) {
|
|
|
2782
2958
|
1: scanID = ''
|
|
2783
2959
|
} = cli.input;
|
|
2784
2960
|
return {
|
|
2785
|
-
outputJson,
|
|
2786
|
-
outputMarkdown,
|
|
2961
|
+
outputJson: cli.flags['json'],
|
|
2962
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2787
2963
|
orgSlug,
|
|
2788
2964
|
scanID
|
|
2789
2965
|
};
|
|
@@ -2838,6 +3014,8 @@ const stream = stream$1.stream = {
|
|
|
2838
3014
|
|
|
2839
3015
|
function setupCommand$a(name, description, argv, importMeta) {
|
|
2840
3016
|
const flags = {
|
|
3017
|
+
__proto__: null,
|
|
3018
|
+
..._flags$9.commonFlags,
|
|
2841
3019
|
..._flags$9.outputFlags
|
|
2842
3020
|
};
|
|
2843
3021
|
const cli = (0, _meow$a.default)(`
|
|
@@ -2855,12 +3033,12 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
2855
3033
|
importMeta,
|
|
2856
3034
|
flags
|
|
2857
3035
|
});
|
|
2858
|
-
|
|
2859
|
-
json: outputJson,
|
|
2860
|
-
markdown: outputMarkdown
|
|
2861
|
-
} = cli.flags;
|
|
3036
|
+
let showHelp = cli.flags['help'];
|
|
2862
3037
|
if (cli.input.length < 2) {
|
|
3038
|
+
showHelp = true;
|
|
2863
3039
|
console.error(`${_chalk$a.default.white.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
3040
|
+
}
|
|
3041
|
+
if (showHelp) {
|
|
2864
3042
|
cli.showHelp();
|
|
2865
3043
|
return;
|
|
2866
3044
|
}
|
|
@@ -2870,8 +3048,8 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
2870
3048
|
2: file
|
|
2871
3049
|
} = cli.input;
|
|
2872
3050
|
return {
|
|
2873
|
-
outputJson,
|
|
2874
|
-
outputMarkdown,
|
|
3051
|
+
outputJson: cli.flags['json'],
|
|
3052
|
+
outputMarkdown: cli.flags['markdown'],
|
|
2875
3053
|
orgSlug,
|
|
2876
3054
|
fullScanId,
|
|
2877
3055
|
file
|
|
@@ -2979,6 +3157,7 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2979
3157
|
const flags = {
|
|
2980
3158
|
__proto__: null,
|
|
2981
3159
|
...auditLogFlags,
|
|
3160
|
+
..._flags$8.commonFlags,
|
|
2982
3161
|
..._flags$8.outputFlags
|
|
2983
3162
|
};
|
|
2984
3163
|
const cli = (0, _meow$9.default)(`
|
|
@@ -2996,6 +3175,15 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2996
3175
|
importMeta,
|
|
2997
3176
|
flags
|
|
2998
3177
|
});
|
|
3178
|
+
let showHelp = cli.flags['help'];
|
|
3179
|
+
if (cli.input.length < 1) {
|
|
3180
|
+
showHelp = true;
|
|
3181
|
+
console.error(`${_chalk$9.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3182
|
+
}
|
|
3183
|
+
if (showHelp) {
|
|
3184
|
+
cli.showHelp();
|
|
3185
|
+
return;
|
|
3186
|
+
}
|
|
2999
3187
|
const {
|
|
3000
3188
|
json: outputJson,
|
|
3001
3189
|
markdown: outputMarkdown,
|
|
@@ -3003,11 +3191,6 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
3003
3191
|
perPage
|
|
3004
3192
|
} = cli.flags;
|
|
3005
3193
|
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
3194
|
const {
|
|
3012
3195
|
0: orgSlug = ''
|
|
3013
3196
|
} = cli.input;
|
|
@@ -3126,6 +3309,7 @@ const repositoryCreationFlags = {
|
|
|
3126
3309
|
function setupCommand$8(name, description, argv, importMeta) {
|
|
3127
3310
|
const flags = {
|
|
3128
3311
|
__proto__: null,
|
|
3312
|
+
..._flags$7.commonFlags,
|
|
3129
3313
|
..._flags$7.outputFlags,
|
|
3130
3314
|
...repositoryCreationFlags
|
|
3131
3315
|
};
|
|
@@ -3145,34 +3329,30 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
3145
3329
|
flags
|
|
3146
3330
|
});
|
|
3147
3331
|
const {
|
|
3148
|
-
|
|
3149
|
-
markdown: outputMarkdown,
|
|
3150
|
-
repoName,
|
|
3151
|
-
repoDescription,
|
|
3152
|
-
homepage,
|
|
3153
|
-
defaultBranch,
|
|
3154
|
-
visibility
|
|
3332
|
+
repoName
|
|
3155
3333
|
} = cli.flags;
|
|
3156
3334
|
const [orgSlug = ''] = cli.input;
|
|
3335
|
+
let showHelp = cli.flags['help'];
|
|
3157
3336
|
if (!orgSlug) {
|
|
3337
|
+
showHelp = true;
|
|
3158
3338
|
console.error(`${_chalk$8.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
}
|
|
3162
|
-
if (!repoName) {
|
|
3339
|
+
} else if (!repoName) {
|
|
3340
|
+
showHelp = true;
|
|
3163
3341
|
console.error(`${_chalk$8.default.white.bgRed('Input error')}: Repository name is required.\n`);
|
|
3342
|
+
}
|
|
3343
|
+
if (showHelp) {
|
|
3164
3344
|
cli.showHelp();
|
|
3165
3345
|
return;
|
|
3166
3346
|
}
|
|
3167
3347
|
return {
|
|
3168
|
-
outputJson,
|
|
3169
|
-
outputMarkdown,
|
|
3348
|
+
outputJson: cli.flags['json'],
|
|
3349
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3170
3350
|
orgSlug,
|
|
3171
3351
|
name: repoName,
|
|
3172
|
-
description: repoDescription,
|
|
3173
|
-
homepage,
|
|
3174
|
-
default_branch: defaultBranch,
|
|
3175
|
-
visibility
|
|
3352
|
+
description: cli.flags['repoDescription'],
|
|
3353
|
+
homepage: cli.flags['homepage'],
|
|
3354
|
+
default_branch: cli.flags['defaultBranch'],
|
|
3355
|
+
visibility: cli.flags['visibility']
|
|
3176
3356
|
};
|
|
3177
3357
|
}
|
|
3178
3358
|
async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
@@ -3236,8 +3416,12 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
3236
3416
|
0: orgSlug = '',
|
|
3237
3417
|
1: repoName = ''
|
|
3238
3418
|
} = cli.input;
|
|
3419
|
+
let showHelp = cli.flags['help'];
|
|
3239
3420
|
if (!orgSlug || !repoName) {
|
|
3421
|
+
showHelp = true;
|
|
3240
3422
|
console.error(`${_chalk$7.default.white.bgRed('Input error')}: Please provide an organization slug and repository slug\n`);
|
|
3423
|
+
}
|
|
3424
|
+
if (showHelp) {
|
|
3241
3425
|
cli.showHelp();
|
|
3242
3426
|
return;
|
|
3243
3427
|
}
|
|
@@ -3323,8 +3507,10 @@ const listRepoFlags = {
|
|
|
3323
3507
|
|
|
3324
3508
|
function setupCommand$6(name, description, argv, importMeta) {
|
|
3325
3509
|
const flags = {
|
|
3326
|
-
|
|
3327
|
-
...
|
|
3510
|
+
__proto__: null,
|
|
3511
|
+
..._flags$6.commonFlags,
|
|
3512
|
+
...listRepoFlags,
|
|
3513
|
+
..._flags$6.outputFlags
|
|
3328
3514
|
};
|
|
3329
3515
|
const cli = (0, _meow$6.default)(`
|
|
3330
3516
|
Usage
|
|
@@ -3341,16 +3527,12 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
3341
3527
|
importMeta,
|
|
3342
3528
|
flags
|
|
3343
3529
|
});
|
|
3344
|
-
|
|
3345
|
-
json: outputJson,
|
|
3346
|
-
markdown: outputMarkdown,
|
|
3347
|
-
perPage,
|
|
3348
|
-
sort,
|
|
3349
|
-
direction,
|
|
3350
|
-
page
|
|
3351
|
-
} = cli.flags;
|
|
3530
|
+
let showHelp = cli.flags['help'];
|
|
3352
3531
|
if (!cli.input[0]) {
|
|
3532
|
+
showHelp = true;
|
|
3353
3533
|
console.error(`${_chalk$6.default.white.bgRed('Input error')}: Please provide an organization slug\n`);
|
|
3534
|
+
}
|
|
3535
|
+
if (showHelp) {
|
|
3354
3536
|
cli.showHelp();
|
|
3355
3537
|
return;
|
|
3356
3538
|
}
|
|
@@ -3358,13 +3540,13 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
3358
3540
|
0: orgSlug = ''
|
|
3359
3541
|
} = cli.input;
|
|
3360
3542
|
return {
|
|
3361
|
-
outputJson,
|
|
3362
|
-
outputMarkdown,
|
|
3543
|
+
outputJson: cli.flags['json'],
|
|
3544
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3363
3545
|
orgSlug,
|
|
3364
|
-
sort,
|
|
3365
|
-
direction,
|
|
3366
|
-
page,
|
|
3367
|
-
per_page: perPage
|
|
3546
|
+
sort: cli.flags['sort'],
|
|
3547
|
+
direction: cli.flags['direction'],
|
|
3548
|
+
page: cli.flags['page'],
|
|
3549
|
+
per_page: cli.flags['perPage']
|
|
3368
3550
|
};
|
|
3369
3551
|
}
|
|
3370
3552
|
async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
@@ -3466,6 +3648,8 @@ const repositoryUpdateFlags = {
|
|
|
3466
3648
|
|
|
3467
3649
|
function setupCommand$5(name, description, argv, importMeta) {
|
|
3468
3650
|
const flags = {
|
|
3651
|
+
__proto__: null,
|
|
3652
|
+
..._flags$5.commonFlags,
|
|
3469
3653
|
..._flags$5.outputFlags,
|
|
3470
3654
|
...repositoryUpdateFlags
|
|
3471
3655
|
};
|
|
@@ -3485,34 +3669,30 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
3485
3669
|
flags
|
|
3486
3670
|
});
|
|
3487
3671
|
const {
|
|
3488
|
-
|
|
3489
|
-
markdown: outputMarkdown,
|
|
3490
|
-
repoName,
|
|
3491
|
-
repoDescription,
|
|
3492
|
-
homepage,
|
|
3493
|
-
defaultBranch,
|
|
3494
|
-
visibility
|
|
3672
|
+
repoName
|
|
3495
3673
|
} = cli.flags;
|
|
3496
3674
|
const [orgSlug = ''] = cli.input;
|
|
3675
|
+
let showHelp = cli.flags['help'];
|
|
3497
3676
|
if (!orgSlug) {
|
|
3677
|
+
showHelp = true;
|
|
3498
3678
|
console.error(`${_chalk$5.default.white.bgRed('Input error')}: Please provide an organization slug and repository name\n`);
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
}
|
|
3502
|
-
if (!repoName) {
|
|
3679
|
+
} else if (!repoName) {
|
|
3680
|
+
showHelp = true;
|
|
3503
3681
|
console.error(`${_chalk$5.default.white.bgRed('Input error')}: Repository name is required.\n`);
|
|
3682
|
+
}
|
|
3683
|
+
if (showHelp) {
|
|
3504
3684
|
cli.showHelp();
|
|
3505
3685
|
return;
|
|
3506
3686
|
}
|
|
3507
3687
|
return {
|
|
3508
|
-
outputJson,
|
|
3509
|
-
outputMarkdown,
|
|
3688
|
+
outputJson: cli.flags['json'],
|
|
3689
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3510
3690
|
orgSlug,
|
|
3511
3691
|
name: repoName,
|
|
3512
|
-
description: repoDescription,
|
|
3513
|
-
homepage,
|
|
3514
|
-
default_branch: defaultBranch,
|
|
3515
|
-
visibility
|
|
3692
|
+
description: cli.flags['repoDescription'],
|
|
3693
|
+
homepage: cli.flags['homepage'],
|
|
3694
|
+
default_branch: cli.flags['defaultBranch'],
|
|
3695
|
+
visibility: cli.flags['visibility']
|
|
3516
3696
|
};
|
|
3517
3697
|
}
|
|
3518
3698
|
async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
@@ -3567,6 +3747,8 @@ const view = view$1.view = {
|
|
|
3567
3747
|
|
|
3568
3748
|
function setupCommand$4(name, description, argv, importMeta) {
|
|
3569
3749
|
const flags = {
|
|
3750
|
+
__proto__: null,
|
|
3751
|
+
..._flags$4.commonFlags,
|
|
3570
3752
|
..._flags$4.outputFlags
|
|
3571
3753
|
};
|
|
3572
3754
|
const cli = (0, _meow$4.default)(`
|
|
@@ -3584,12 +3766,12 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
3584
3766
|
importMeta,
|
|
3585
3767
|
flags
|
|
3586
3768
|
});
|
|
3587
|
-
|
|
3588
|
-
json: outputJson,
|
|
3589
|
-
markdown: outputMarkdown
|
|
3590
|
-
} = cli.flags;
|
|
3769
|
+
let showHelp = cli.flags['help'];
|
|
3591
3770
|
if (!cli.input[0]) {
|
|
3771
|
+
showHelp = true;
|
|
3592
3772
|
console.error(`${_chalk$4.default.white.bgRed('Input error')}: Please provide an organization slug and repository name\n`);
|
|
3773
|
+
}
|
|
3774
|
+
if (showHelp) {
|
|
3593
3775
|
cli.showHelp();
|
|
3594
3776
|
return;
|
|
3595
3777
|
}
|
|
@@ -3598,8 +3780,8 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
3598
3780
|
1: repositoryName = ''
|
|
3599
3781
|
} = cli.input;
|
|
3600
3782
|
return {
|
|
3601
|
-
outputJson,
|
|
3602
|
-
outputMarkdown,
|
|
3783
|
+
outputJson: cli.flags['json'],
|
|
3784
|
+
outputMarkdown: cli.flags['markdown'],
|
|
3603
3785
|
orgSlug,
|
|
3604
3786
|
repositoryName
|
|
3605
3787
|
};
|
|
@@ -3720,8 +3902,9 @@ const dependenciesFlags = {
|
|
|
3720
3902
|
function setupCommand$3(name, description, argv, importMeta) {
|
|
3721
3903
|
const flags = {
|
|
3722
3904
|
__proto__: null,
|
|
3723
|
-
..._flags$3.
|
|
3724
|
-
...dependenciesFlags
|
|
3905
|
+
..._flags$3.commonFlags,
|
|
3906
|
+
...dependenciesFlags,
|
|
3907
|
+
..._flags$3.outputFlags
|
|
3725
3908
|
};
|
|
3726
3909
|
const cli = (0, _meow$3.default)(`
|
|
3727
3910
|
Usage
|
|
@@ -3811,7 +3994,7 @@ Object.defineProperty(analytics$1, "__esModule", {
|
|
|
3811
3994
|
value: true
|
|
3812
3995
|
});
|
|
3813
3996
|
analytics$1.analytics = void 0;
|
|
3814
|
-
var
|
|
3997
|
+
var _promises = require$$1$4;
|
|
3815
3998
|
var _blessed$1 = require$$2$4;
|
|
3816
3999
|
var _blessedContrib$1 = require$$3$5;
|
|
3817
4000
|
var _chalk$2 = _interopRequireDefault$3(vendor.source);
|
|
@@ -3880,6 +4063,7 @@ const analyticsFlags = {
|
|
|
3880
4063
|
function setupCommand$2(name, description, argv, importMeta) {
|
|
3881
4064
|
const flags = {
|
|
3882
4065
|
__proto__: null,
|
|
4066
|
+
..._flags$2.commonFlags,
|
|
3883
4067
|
..._flags$2.outputFlags,
|
|
3884
4068
|
...analyticsFlags
|
|
3885
4069
|
};
|
|
@@ -3901,11 +4085,9 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3901
4085
|
flags
|
|
3902
4086
|
});
|
|
3903
4087
|
const {
|
|
3904
|
-
json: outputJson,
|
|
3905
|
-
scope,
|
|
3906
|
-
time,
|
|
3907
4088
|
repo,
|
|
3908
|
-
|
|
4089
|
+
scope,
|
|
4090
|
+
time
|
|
3909
4091
|
} = cli.flags;
|
|
3910
4092
|
if (scope !== 'org' && scope !== 'repo') {
|
|
3911
4093
|
throw new _errors$3.InputError("The scope must either be 'org' or 'repo'");
|
|
@@ -3913,8 +4095,12 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3913
4095
|
if (time !== 7 && time !== 30 && time !== 90) {
|
|
3914
4096
|
throw new _errors$3.InputError('The time filter must either be 7, 30 or 90');
|
|
3915
4097
|
}
|
|
4098
|
+
let showHelp = cli.flags['help'];
|
|
3916
4099
|
if (scope === 'repo' && !repo) {
|
|
4100
|
+
showHelp = true;
|
|
3917
4101
|
console.error(`${_chalk$2.default.bgRed.white('Input error')}: Please provide a repository name when using the repository scope. \n`);
|
|
4102
|
+
}
|
|
4103
|
+
if (showHelp) {
|
|
3918
4104
|
cli.showHelp();
|
|
3919
4105
|
return;
|
|
3920
4106
|
}
|
|
@@ -3922,8 +4108,8 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3922
4108
|
scope,
|
|
3923
4109
|
time,
|
|
3924
4110
|
repo,
|
|
3925
|
-
outputJson,
|
|
3926
|
-
file
|
|
4111
|
+
outputJson: cli.flags['json'],
|
|
4112
|
+
file: cli.flags['file']
|
|
3927
4113
|
};
|
|
3928
4114
|
}
|
|
3929
4115
|
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 +4128,12 @@ async function fetchOrgAnalyticsData(time, spinner, apiKey, outputJson, filePath
|
|
|
3942
4128
|
return console.log(result.data);
|
|
3943
4129
|
}
|
|
3944
4130
|
if (filePath) {
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
4131
|
+
try {
|
|
4132
|
+
await _promises.writeFile(filePath, JSON.stringify(result.data), 'utf8');
|
|
4133
|
+
console.log(`Data successfully written to ${filePath}`);
|
|
4134
|
+
} catch (e) {
|
|
4135
|
+
console.error(e);
|
|
4136
|
+
}
|
|
3948
4137
|
return;
|
|
3949
4138
|
}
|
|
3950
4139
|
return displayAnalyticsScreen(data);
|
|
@@ -4052,9 +4241,12 @@ async function fetchRepoAnalyticsData(repo, time, spinner, apiKey, outputJson, f
|
|
|
4052
4241
|
return console.log(result.data);
|
|
4053
4242
|
}
|
|
4054
4243
|
if (filePath) {
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4244
|
+
try {
|
|
4245
|
+
await _promises.writeFile(filePath, JSON.stringify(result.data), 'utf8');
|
|
4246
|
+
console.log(`Data successfully written to ${filePath}`);
|
|
4247
|
+
} catch (e) {
|
|
4248
|
+
console.error(e);
|
|
4249
|
+
}
|
|
4058
4250
|
return;
|
|
4059
4251
|
}
|
|
4060
4252
|
return displayAnalyticsScreen(data);
|
|
@@ -4184,8 +4376,9 @@ const getDiffScanFlags = {
|
|
|
4184
4376
|
function setupCommand$1(name, description, argv, importMeta) {
|
|
4185
4377
|
const flags = {
|
|
4186
4378
|
__proto__: null,
|
|
4187
|
-
..._flags$1.
|
|
4188
|
-
...getDiffScanFlags
|
|
4379
|
+
..._flags$1.commonFlags,
|
|
4380
|
+
...getDiffScanFlags,
|
|
4381
|
+
..._flags$1.outputFlags
|
|
4189
4382
|
};
|
|
4190
4383
|
const cli = (0, _meow$1.default)(`
|
|
4191
4384
|
Usage
|
|
@@ -4203,32 +4396,30 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
4203
4396
|
flags
|
|
4204
4397
|
});
|
|
4205
4398
|
const {
|
|
4206
|
-
json: outputJson,
|
|
4207
|
-
markdown: outputMarkdown,
|
|
4208
4399
|
before,
|
|
4209
|
-
after
|
|
4210
|
-
preview,
|
|
4211
|
-
file
|
|
4400
|
+
after
|
|
4212
4401
|
} = cli.flags;
|
|
4402
|
+
let showHelp = cli.flags['help'];
|
|
4213
4403
|
if (!before || !after) {
|
|
4404
|
+
showHelp = true;
|
|
4214
4405
|
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) {
|
|
4406
|
+
} else if (cli.input.length < 1) {
|
|
4407
|
+
showHelp = true;
|
|
4219
4408
|
console.error(`${_chalk$1.default.bgRed.white('Input error')}: Please provide an organization slug\n`);
|
|
4409
|
+
}
|
|
4410
|
+
if (showHelp) {
|
|
4220
4411
|
cli.showHelp();
|
|
4221
4412
|
return;
|
|
4222
4413
|
}
|
|
4223
4414
|
const [orgSlug = ''] = cli.input;
|
|
4224
4415
|
return {
|
|
4225
|
-
outputJson,
|
|
4226
|
-
outputMarkdown,
|
|
4416
|
+
outputJson: cli.flags['json'],
|
|
4417
|
+
outputMarkdown: cli.flags['markdown'],
|
|
4227
4418
|
before,
|
|
4228
4419
|
after,
|
|
4229
|
-
preview,
|
|
4420
|
+
preview: cli.flags['preview'],
|
|
4230
4421
|
orgSlug,
|
|
4231
|
-
file
|
|
4422
|
+
file: cli.flags['file']
|
|
4232
4423
|
};
|
|
4233
4424
|
}
|
|
4234
4425
|
async function getDiffScan({
|
|
@@ -4361,8 +4552,9 @@ const threatFeedFlags = {
|
|
|
4361
4552
|
function setupCommand(name, description, argv, importMeta) {
|
|
4362
4553
|
const flags = {
|
|
4363
4554
|
__proto__: null,
|
|
4364
|
-
...
|
|
4365
|
-
..._flags.outputFlags
|
|
4555
|
+
..._flags.commonFlags,
|
|
4556
|
+
..._flags.outputFlags,
|
|
4557
|
+
...threatFeedFlags
|
|
4366
4558
|
};
|
|
4367
4559
|
const cli = (0, _meow.default)(`
|
|
4368
4560
|
Usage
|