@socketsecurity/cli 0.11.1 → 0.12.0
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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +957 -448
- package/package.json +5 -2
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var vendor = require('./vendor.js');
|
|
5
5
|
var require$$0 = require('node:fs');
|
|
6
6
|
var require$$1 = require('node:path');
|
|
7
|
-
var require$$2$
|
|
7
|
+
var require$$2$4 = require('node:url');
|
|
8
8
|
var require$$6 = require('pony-cause');
|
|
9
9
|
var require$$5 = require('yargs-parser');
|
|
10
10
|
var sdk = require('./sdk.js');
|
|
@@ -18,6 +18,9 @@ var require$$3$1 = require('node:readline');
|
|
|
18
18
|
var require$$0$3 = require('node:process');
|
|
19
19
|
var require$$2$1 = require('node:readline/promises');
|
|
20
20
|
var require$$2$2 = require('chalk-table');
|
|
21
|
+
var require$$1$2 = require('blessed');
|
|
22
|
+
var require$$2$3 = require('blessed-contrib');
|
|
23
|
+
var require$$0$4 = require('node:util');
|
|
21
24
|
|
|
22
25
|
var cli$1 = {};
|
|
23
26
|
|
|
@@ -27,14 +30,14 @@ var commands = {};
|
|
|
27
30
|
|
|
28
31
|
var cdxgen = {};
|
|
29
32
|
|
|
30
|
-
var _interopRequireDefault$
|
|
33
|
+
var _interopRequireDefault$q = vendor.interopRequireDefault.default;
|
|
31
34
|
Object.defineProperty(cdxgen, "__esModule", {
|
|
32
35
|
value: true
|
|
33
36
|
});
|
|
34
37
|
cdxgen.cdxgen = void 0;
|
|
35
38
|
var _nodeFs$2 = require$$0;
|
|
36
39
|
var _nodePath$4 = require$$1;
|
|
37
|
-
var _chalk$
|
|
40
|
+
var _chalk$j = _interopRequireDefault$q(vendor.source);
|
|
38
41
|
var _execa = vendor.execa;
|
|
39
42
|
var _yargsParser = require$$5;
|
|
40
43
|
const distPath$3 = __dirname;
|
|
@@ -192,7 +195,7 @@ cdxgen.cdxgen = {
|
|
|
192
195
|
}
|
|
193
196
|
const fullOutputPath = _nodePath$4.join(process.cwd(), yargv.output);
|
|
194
197
|
if ((0, _nodeFs$2.existsSync)(fullOutputPath)) {
|
|
195
|
-
console.log(_chalk$
|
|
198
|
+
console.log(_chalk$j.default.cyanBright(`${yargv.output} created!`));
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
};
|
|
@@ -246,23 +249,25 @@ flags.validationFlags = {
|
|
|
246
249
|
|
|
247
250
|
var apiHelpers = {};
|
|
248
251
|
|
|
249
|
-
var _interopRequireDefault$
|
|
252
|
+
var _interopRequireDefault$p = vendor.interopRequireDefault.default;
|
|
250
253
|
Object.defineProperty(apiHelpers, "__esModule", {
|
|
251
254
|
value: true
|
|
252
255
|
});
|
|
256
|
+
apiHelpers.handleAPIError = handleAPIError;
|
|
253
257
|
apiHelpers.handleApiCall = handleApiCall;
|
|
254
258
|
apiHelpers.handleUnsuccessfulApiResponse = handleUnsuccessfulApiResponse;
|
|
255
|
-
|
|
259
|
+
apiHelpers.queryAPI = queryAPI;
|
|
260
|
+
var _chalk$i = _interopRequireDefault$p(vendor.source);
|
|
256
261
|
var _ponyCause$4 = require$$6;
|
|
257
|
-
var _errors$
|
|
262
|
+
var _errors$k = sdk.errors;
|
|
258
263
|
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
259
264
|
const resultError = 'error' in result && result.error && typeof result.error === 'object' ? result.error : {};
|
|
260
265
|
const message = 'message' in resultError && typeof resultError.message === 'string' ? resultError.message : 'No error message returned';
|
|
261
266
|
if (result.status === 401 || result.status === 403) {
|
|
262
267
|
spinner.stop();
|
|
263
|
-
throw new _errors$
|
|
268
|
+
throw new _errors$k.AuthError(message);
|
|
264
269
|
}
|
|
265
|
-
spinner.fail(_chalk$
|
|
270
|
+
spinner.fail(_chalk$i.default.white.bgRed('API returned an error:') + ' ' + message);
|
|
266
271
|
process.exit(1);
|
|
267
272
|
}
|
|
268
273
|
async function handleApiCall(value, description) {
|
|
@@ -276,6 +281,22 @@ async function handleApiCall(value, description) {
|
|
|
276
281
|
}
|
|
277
282
|
return result;
|
|
278
283
|
}
|
|
284
|
+
async function handleAPIError(code) {
|
|
285
|
+
if (code === 400) {
|
|
286
|
+
return `One of the options passed might be incorrect.`;
|
|
287
|
+
} else if (code === 403) {
|
|
288
|
+
return `You might be trying to access an organization that is not linked to the API key you are logged in with.`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const API_V0_URL = 'https://api.socket.dev/v0';
|
|
292
|
+
async function queryAPI(path, apiKey) {
|
|
293
|
+
return await fetch(`${API_V0_URL}/orgs/${path}`, {
|
|
294
|
+
method: 'GET',
|
|
295
|
+
headers: {
|
|
296
|
+
'Authorization': 'Basic ' + btoa(`${apiKey}:${apiKey}`)
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
279
300
|
|
|
280
301
|
var formatIssues = {};
|
|
281
302
|
|
|
@@ -395,32 +416,32 @@ function printFlagList(list, indent, {
|
|
|
395
416
|
});
|
|
396
417
|
}
|
|
397
418
|
|
|
398
|
-
var _interopRequireDefault$
|
|
419
|
+
var _interopRequireDefault$o = vendor.interopRequireDefault.default;
|
|
399
420
|
Object.defineProperty(info$1, "__esModule", {
|
|
400
421
|
value: true
|
|
401
422
|
});
|
|
402
423
|
info$1.info = void 0;
|
|
403
|
-
var _chalk$
|
|
404
|
-
var _meow$
|
|
405
|
-
var _ora$
|
|
406
|
-
var _flags$
|
|
407
|
-
var _apiHelpers$
|
|
424
|
+
var _chalk$h = _interopRequireDefault$o(vendor.source);
|
|
425
|
+
var _meow$n = _interopRequireDefault$o(vendor.build);
|
|
426
|
+
var _ora$j = _interopRequireDefault$o(vendor.ora);
|
|
427
|
+
var _flags$h = flags;
|
|
428
|
+
var _apiHelpers$h = apiHelpers;
|
|
408
429
|
var _chalkMarkdown$3 = sdk.chalkMarkdown;
|
|
409
|
-
var _errors$
|
|
430
|
+
var _errors$j = sdk.errors;
|
|
410
431
|
var _formatIssues$1 = formatIssues;
|
|
411
|
-
var _formatting$
|
|
432
|
+
var _formatting$k = formatting;
|
|
412
433
|
var _misc$2 = misc;
|
|
413
|
-
var _sdk$
|
|
434
|
+
var _sdk$i = sdk.sdk;
|
|
414
435
|
const info = info$1.info = {
|
|
415
436
|
description: 'Look up info regarding a package',
|
|
416
437
|
async run(argv, importMeta, {
|
|
417
438
|
parentName
|
|
418
439
|
}) {
|
|
419
440
|
const name = parentName + ' info';
|
|
420
|
-
const input = setupCommand$
|
|
441
|
+
const input = setupCommand$k(name, info.description, argv, importMeta);
|
|
421
442
|
if (input) {
|
|
422
443
|
const spinnerText = input.pkgVersion === 'latest' ? `Looking up data for the latest version of ${input.pkgName}\n` : `Looking up data for version ${input.pkgVersion} of ${input.pkgName}\n`;
|
|
423
|
-
const spinner = (0, _ora$
|
|
444
|
+
const spinner = (0, _ora$j.default)(spinnerText).start();
|
|
424
445
|
const packageData = await fetchPackageData(input.pkgName, input.pkgVersion, input, spinner);
|
|
425
446
|
if (packageData) {
|
|
426
447
|
formatPackageDataOutput(packageData, {
|
|
@@ -434,17 +455,17 @@ const info = info$1.info = {
|
|
|
434
455
|
|
|
435
456
|
// Internal functions
|
|
436
457
|
|
|
437
|
-
function setupCommand$
|
|
458
|
+
function setupCommand$k(name, description, argv, importMeta) {
|
|
438
459
|
const flags = {
|
|
439
|
-
..._flags$
|
|
440
|
-
..._flags$
|
|
460
|
+
..._flags$h.outputFlags,
|
|
461
|
+
..._flags$h.validationFlags
|
|
441
462
|
};
|
|
442
|
-
const cli = (0, _meow$
|
|
463
|
+
const cli = (0, _meow$n.default)(`
|
|
443
464
|
Usage
|
|
444
465
|
$ ${name} <name>
|
|
445
466
|
|
|
446
467
|
Options
|
|
447
|
-
${(0, _formatting$
|
|
468
|
+
${(0, _formatting$k.printFlagList)(flags, 6)}
|
|
448
469
|
|
|
449
470
|
Examples
|
|
450
471
|
$ ${name} webtorrent
|
|
@@ -462,7 +483,7 @@ function setupCommand$i(name, description, argv, importMeta) {
|
|
|
462
483
|
strict
|
|
463
484
|
} = cli.flags;
|
|
464
485
|
if (cli.input.length > 1) {
|
|
465
|
-
throw new _errors$
|
|
486
|
+
throw new _errors$j.InputError('Only one package lookup supported at once');
|
|
466
487
|
}
|
|
467
488
|
const [rawPkgName = ''] = cli.input;
|
|
468
489
|
if (!rawPkgName) {
|
|
@@ -484,14 +505,14 @@ function setupCommand$i(name, description, argv, importMeta) {
|
|
|
484
505
|
async function fetchPackageData(pkgName, pkgVersion, {
|
|
485
506
|
includeAllIssues
|
|
486
507
|
}, spinner) {
|
|
487
|
-
const socketSdk = await (0, _sdk$
|
|
488
|
-
const result = await (0, _apiHelpers$
|
|
489
|
-
const scoreResult = await (0, _apiHelpers$
|
|
508
|
+
const socketSdk = await (0, _sdk$i.setupSdk)((0, _sdk$i.getDefaultKey)() || _sdk$i.FREE_API_KEY);
|
|
509
|
+
const result = await (0, _apiHelpers$h.handleApiCall)(socketSdk.getIssuesByNPMPackage(pkgName, pkgVersion), 'looking up package');
|
|
510
|
+
const scoreResult = await (0, _apiHelpers$h.handleApiCall)(socketSdk.getScoreByNPMPackage(pkgName, pkgVersion), 'looking up package score');
|
|
490
511
|
if (result.success === false) {
|
|
491
|
-
return (0, _apiHelpers$
|
|
512
|
+
return (0, _apiHelpers$h.handleUnsuccessfulApiResponse)('getIssuesByNPMPackage', result, spinner);
|
|
492
513
|
}
|
|
493
514
|
if (scoreResult.success === false) {
|
|
494
|
-
return (0, _apiHelpers$
|
|
515
|
+
return (0, _apiHelpers$h.handleUnsuccessfulApiResponse)('getScoreByNPMPackage', scoreResult, spinner);
|
|
495
516
|
}
|
|
496
517
|
const severityCount = (0, _formatIssues$1.getSeverityCount)(result.data, includeAllIssues ? undefined : 'high');
|
|
497
518
|
return {
|
|
@@ -545,7 +566,7 @@ function formatPackageDataOutput({
|
|
|
545
566
|
}));
|
|
546
567
|
}
|
|
547
568
|
if (!outputMarkdown) {
|
|
548
|
-
console.log(_chalk$
|
|
569
|
+
console.log(_chalk$h.default.dim('\nOr rerun', _chalk$h.default.italic(name), 'using the', _chalk$h.default.italic('--json'), 'flag to get full JSON output'));
|
|
549
570
|
}
|
|
550
571
|
}
|
|
551
572
|
if (strict && (0, _misc$2.objectSome)(severityCount)) {
|
|
@@ -583,9 +604,9 @@ function formatPackageIssuesDetails(packageData, outputMarkdown) {
|
|
|
583
604
|
}
|
|
584
605
|
}
|
|
585
606
|
function formatScore(score) {
|
|
586
|
-
const error = _chalk$
|
|
587
|
-
const warning = _chalk$
|
|
588
|
-
const success = _chalk$
|
|
607
|
+
const error = _chalk$h.default.hex('#de7c7b');
|
|
608
|
+
const warning = _chalk$h.default.hex('#e59361');
|
|
609
|
+
const success = _chalk$h.default.hex('#a4cb9d');
|
|
589
610
|
if (score > 80) {
|
|
590
611
|
return `${success(score)}`;
|
|
591
612
|
} else if (score < 80 && score > 60) {
|
|
@@ -596,23 +617,23 @@ function formatScore(score) {
|
|
|
596
617
|
|
|
597
618
|
var login = {};
|
|
598
619
|
|
|
599
|
-
var _interopRequireDefault$
|
|
620
|
+
var _interopRequireDefault$n = vendor.interopRequireDefault.default;
|
|
600
621
|
Object.defineProperty(login, "__esModule", {
|
|
601
622
|
value: true
|
|
602
623
|
});
|
|
603
624
|
login.login = void 0;
|
|
604
625
|
var _prompts$1 = require$$1$1;
|
|
605
|
-
var _isInteractive = _interopRequireDefault$
|
|
606
|
-
var _meow$
|
|
607
|
-
var _ora$
|
|
608
|
-
var _terminalLink = _interopRequireDefault$
|
|
609
|
-
var _errors$
|
|
610
|
-
var _formatting$
|
|
611
|
-
var _sdk$
|
|
626
|
+
var _isInteractive = _interopRequireDefault$n(vendor.isInteractive);
|
|
627
|
+
var _meow$m = _interopRequireDefault$n(vendor.build);
|
|
628
|
+
var _ora$i = _interopRequireDefault$n(vendor.ora);
|
|
629
|
+
var _terminalLink = _interopRequireDefault$n(vendor.terminalLink);
|
|
630
|
+
var _errors$i = sdk.errors;
|
|
631
|
+
var _formatting$j = formatting;
|
|
632
|
+
var _sdk$h = sdk.sdk;
|
|
612
633
|
var _settings$1 = sdk.settings;
|
|
613
|
-
const description$
|
|
634
|
+
const description$7 = 'Socket API login';
|
|
614
635
|
login.login = {
|
|
615
|
-
description: description$
|
|
636
|
+
description: description$7,
|
|
616
637
|
run: async (argv, importMeta, {
|
|
617
638
|
parentName
|
|
618
639
|
}) => {
|
|
@@ -627,14 +648,14 @@ login.login = {
|
|
|
627
648
|
}
|
|
628
649
|
};
|
|
629
650
|
const name = `${parentName} login`;
|
|
630
|
-
const cli = (0, _meow$
|
|
651
|
+
const cli = (0, _meow$m.default)(`
|
|
631
652
|
Usage
|
|
632
653
|
$ ${name}
|
|
633
654
|
|
|
634
655
|
Logs into the Socket API by prompting for an API key
|
|
635
656
|
|
|
636
657
|
Options
|
|
637
|
-
${(0, _formatting$
|
|
658
|
+
${(0, _formatting$j.printFlagList)({
|
|
638
659
|
'api-base-url': flags['apiBaseUrl'].description,
|
|
639
660
|
'api-proxy': flags['apiProxy'].description
|
|
640
661
|
}, 8)}
|
|
@@ -643,7 +664,7 @@ login.login = {
|
|
|
643
664
|
$ ${name}
|
|
644
665
|
`, {
|
|
645
666
|
argv,
|
|
646
|
-
description: description$
|
|
667
|
+
description: description$7,
|
|
647
668
|
importMeta,
|
|
648
669
|
flags
|
|
649
670
|
});
|
|
@@ -651,22 +672,22 @@ login.login = {
|
|
|
651
672
|
cli.showHelp();
|
|
652
673
|
}
|
|
653
674
|
if (!(0, _isInteractive.default)()) {
|
|
654
|
-
throw new _errors$
|
|
675
|
+
throw new _errors$i.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
655
676
|
}
|
|
656
677
|
const apiKey = (await (0, _prompts$1.password)({
|
|
657
678
|
message: `Enter your ${(0, _terminalLink.default)('Socket.dev API key', 'https://docs.socket.dev/docs/api-keys')} (leave blank for a public key)`
|
|
658
|
-
})) || _sdk$
|
|
679
|
+
})) || _sdk$h.FREE_API_KEY;
|
|
659
680
|
let apiBaseUrl = cli.flags['apiBaseUrl'];
|
|
660
681
|
apiBaseUrl ??= (0, _settings$1.getSetting)('apiBaseUrl') ?? undefined;
|
|
661
682
|
let apiProxy = cli.flags['apiProxy'];
|
|
662
683
|
apiProxy ??= (0, _settings$1.getSetting)('apiProxy') ?? undefined;
|
|
663
|
-
const spinner = (0, _ora$
|
|
684
|
+
const spinner = (0, _ora$i.default)('Verifying API key...').start();
|
|
664
685
|
let orgs;
|
|
665
686
|
try {
|
|
666
|
-
const sdk = await (0, _sdk$
|
|
687
|
+
const sdk = await (0, _sdk$h.setupSdk)(apiKey, apiBaseUrl, apiProxy);
|
|
667
688
|
const result = await sdk.getOrganizations();
|
|
668
689
|
if (!result.success) {
|
|
669
|
-
throw new _errors$
|
|
690
|
+
throw new _errors$i.AuthError();
|
|
670
691
|
}
|
|
671
692
|
orgs = result.data;
|
|
672
693
|
spinner.succeed('API key verified\n');
|
|
@@ -715,22 +736,22 @@ login.login = {
|
|
|
715
736
|
|
|
716
737
|
var logout = {};
|
|
717
738
|
|
|
718
|
-
var _interopRequireDefault$
|
|
739
|
+
var _interopRequireDefault$m = vendor.interopRequireDefault.default;
|
|
719
740
|
Object.defineProperty(logout, "__esModule", {
|
|
720
741
|
value: true
|
|
721
742
|
});
|
|
722
743
|
logout.logout = void 0;
|
|
723
|
-
var _meow$
|
|
724
|
-
var _ora$
|
|
744
|
+
var _meow$l = _interopRequireDefault$m(vendor.build);
|
|
745
|
+
var _ora$h = _interopRequireDefault$m(vendor.ora);
|
|
725
746
|
var _settings = sdk.settings;
|
|
726
|
-
const description$
|
|
747
|
+
const description$6 = 'Socket API logout';
|
|
727
748
|
logout.logout = {
|
|
728
|
-
description: description$
|
|
749
|
+
description: description$6,
|
|
729
750
|
run: async (argv, importMeta, {
|
|
730
751
|
parentName
|
|
731
752
|
}) => {
|
|
732
753
|
const name = `${parentName} logout`;
|
|
733
|
-
const cli = (0, _meow$
|
|
754
|
+
const cli = (0, _meow$l.default)(`
|
|
734
755
|
Usage
|
|
735
756
|
$ ${name}
|
|
736
757
|
|
|
@@ -740,7 +761,7 @@ logout.logout = {
|
|
|
740
761
|
$ ${name}
|
|
741
762
|
`, {
|
|
742
763
|
argv,
|
|
743
|
-
description: description$
|
|
764
|
+
description: description$6,
|
|
744
765
|
importMeta
|
|
745
766
|
});
|
|
746
767
|
if (cli.input.length) {
|
|
@@ -750,7 +771,7 @@ logout.logout = {
|
|
|
750
771
|
(0, _settings.updateSetting)('apiBaseUrl', null);
|
|
751
772
|
(0, _settings.updateSetting)('apiProxy', null);
|
|
752
773
|
(0, _settings.updateSetting)('enforcedOrgs', null);
|
|
753
|
-
(0, _ora$
|
|
774
|
+
(0, _ora$h.default)('Successfully logged out').succeed();
|
|
754
775
|
}
|
|
755
776
|
};
|
|
756
777
|
|
|
@@ -763,9 +784,9 @@ npm.npm = void 0;
|
|
|
763
784
|
var _nodeChild_process$1 = require$$0$1;
|
|
764
785
|
var _nodePath$3 = require$$1;
|
|
765
786
|
const distPath$2 = __dirname;
|
|
766
|
-
const description$
|
|
787
|
+
const description$5 = 'npm wrapper functionality';
|
|
767
788
|
npm.npm = {
|
|
768
|
-
description: description$
|
|
789
|
+
description: description$5,
|
|
769
790
|
run: async (argv, _importMeta, _ctx) => {
|
|
770
791
|
const npmVersion = (0, _nodeChild_process$1.execSync)('npm -v').toString();
|
|
771
792
|
const wrapperPath = _nodePath$3.join(distPath$2, 'npm-cli.js');
|
|
@@ -795,9 +816,9 @@ npx.npx = void 0;
|
|
|
795
816
|
var _child_process$1 = require$$0$1;
|
|
796
817
|
var _nodePath$2 = require$$1;
|
|
797
818
|
const distPath$1 = __dirname;
|
|
798
|
-
const description$
|
|
819
|
+
const description$4 = 'npx wrapper functionality';
|
|
799
820
|
npx.npx = {
|
|
800
|
-
description: description$
|
|
821
|
+
description: description$4,
|
|
801
822
|
run: async (argv, _importMeta, _ctx) => {
|
|
802
823
|
const wrapperPath = _nodePath$2.join(distPath$1, 'npx-cli.js');
|
|
803
824
|
process.exitCode = 1;
|
|
@@ -815,32 +836,32 @@ npx.npx = {
|
|
|
815
836
|
|
|
816
837
|
var organization = {};
|
|
817
838
|
|
|
818
|
-
var _interopRequireDefault$
|
|
839
|
+
var _interopRequireDefault$l = vendor.interopRequireDefault.default;
|
|
819
840
|
Object.defineProperty(organization, "__esModule", {
|
|
820
841
|
value: true
|
|
821
842
|
});
|
|
822
843
|
organization.organizations = void 0;
|
|
823
|
-
var _chalk$
|
|
824
|
-
var _meow$
|
|
825
|
-
var _ora$
|
|
826
|
-
var _apiHelpers$
|
|
827
|
-
var _sdk$
|
|
828
|
-
var _errors$
|
|
844
|
+
var _chalk$g = _interopRequireDefault$l(vendor.source);
|
|
845
|
+
var _meow$k = _interopRequireDefault$l(vendor.build);
|
|
846
|
+
var _ora$g = _interopRequireDefault$l(vendor.ora);
|
|
847
|
+
var _apiHelpers$g = apiHelpers;
|
|
848
|
+
var _sdk$g = sdk.sdk;
|
|
849
|
+
var _errors$h = sdk.errors;
|
|
829
850
|
const organizations = organization.organizations = {
|
|
830
851
|
description: 'List organizations associated with the API key used',
|
|
831
852
|
async run(argv, importMeta, {
|
|
832
853
|
parentName
|
|
833
854
|
}) {
|
|
834
855
|
const name = `${parentName} organizations`;
|
|
835
|
-
setupCommand$
|
|
856
|
+
setupCommand$j(name, organizations.description, argv, importMeta);
|
|
836
857
|
await fetchOrganizations();
|
|
837
858
|
}
|
|
838
859
|
};
|
|
839
860
|
|
|
840
861
|
// Internal functions
|
|
841
862
|
|
|
842
|
-
function setupCommand$
|
|
843
|
-
(0, _meow$
|
|
863
|
+
function setupCommand$j(name, description, argv, importMeta) {
|
|
864
|
+
(0, _meow$k.default)(`
|
|
844
865
|
Usage
|
|
845
866
|
$ ${name}
|
|
846
867
|
`, {
|
|
@@ -850,20 +871,20 @@ function setupCommand$h(name, description, argv, importMeta) {
|
|
|
850
871
|
});
|
|
851
872
|
}
|
|
852
873
|
async function fetchOrganizations() {
|
|
853
|
-
const apiKey = (0, _sdk$
|
|
874
|
+
const apiKey = (0, _sdk$g.getDefaultKey)();
|
|
854
875
|
if (!apiKey) {
|
|
855
|
-
throw new _errors$
|
|
876
|
+
throw new _errors$h.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
856
877
|
}
|
|
857
|
-
const socketSdk = await (0, _sdk$
|
|
858
|
-
const spinner = (0, _ora$
|
|
859
|
-
const result = await (0, _apiHelpers$
|
|
878
|
+
const socketSdk = await (0, _sdk$g.setupSdk)(apiKey);
|
|
879
|
+
const spinner = (0, _ora$g.default)('Fetching organizations...').start();
|
|
880
|
+
const result = await (0, _apiHelpers$g.handleApiCall)(socketSdk.getOrganizations(), 'looking up organizations');
|
|
860
881
|
if (result.success === false) {
|
|
861
|
-
(0, _apiHelpers$
|
|
882
|
+
(0, _apiHelpers$g.handleUnsuccessfulApiResponse)('getOrganizations', result, spinner);
|
|
862
883
|
return;
|
|
863
884
|
}
|
|
864
885
|
spinner.stop();
|
|
865
886
|
const organizations = Object.values(result.data.organizations);
|
|
866
|
-
console.log(`List of organizations associated with your API key: ${_chalk$
|
|
887
|
+
console.log(`List of organizations associated with your API key: ${_chalk$g.default.italic(apiKey)}`);
|
|
867
888
|
for (const o of organizations) {
|
|
868
889
|
console.log(`
|
|
869
890
|
Name: ${o?.name}
|
|
@@ -875,32 +896,32 @@ Plan: ${o?.plan}
|
|
|
875
896
|
|
|
876
897
|
var rawNpm$1 = {};
|
|
877
898
|
|
|
878
|
-
var _interopRequireDefault$
|
|
899
|
+
var _interopRequireDefault$k = vendor.interopRequireDefault.default;
|
|
879
900
|
Object.defineProperty(rawNpm$1, "__esModule", {
|
|
880
901
|
value: true
|
|
881
902
|
});
|
|
882
903
|
rawNpm$1.rawNpm = void 0;
|
|
883
904
|
var _nodeChild_process = require$$0$1;
|
|
884
|
-
var _meow$
|
|
885
|
-
var _flags$
|
|
886
|
-
var _formatting$
|
|
905
|
+
var _meow$j = _interopRequireDefault$k(vendor.build);
|
|
906
|
+
var _flags$g = flags;
|
|
907
|
+
var _formatting$i = formatting;
|
|
887
908
|
const rawNpm = rawNpm$1.rawNpm = {
|
|
888
909
|
description: 'Temporarily disable the Socket npm wrapper',
|
|
889
910
|
async run(argv, importMeta, {
|
|
890
911
|
parentName
|
|
891
912
|
}) {
|
|
892
913
|
const name = `${parentName} raw-npm`;
|
|
893
|
-
setupCommand$
|
|
914
|
+
setupCommand$i(name, rawNpm.description, argv, importMeta);
|
|
894
915
|
}
|
|
895
916
|
};
|
|
896
|
-
function setupCommand$
|
|
897
|
-
const flags = _flags$
|
|
898
|
-
const cli = (0, _meow$
|
|
917
|
+
function setupCommand$i(name, description, argv, importMeta) {
|
|
918
|
+
const flags = _flags$g.validationFlags;
|
|
919
|
+
const cli = (0, _meow$j.default)(`
|
|
899
920
|
Usage
|
|
900
921
|
$ ${name} <npm command>
|
|
901
922
|
|
|
902
923
|
Options
|
|
903
|
-
${(0, _formatting$
|
|
924
|
+
${(0, _formatting$i.printFlagList)(flags, 6)}
|
|
904
925
|
|
|
905
926
|
Examples
|
|
906
927
|
$ ${name} install
|
|
@@ -928,32 +949,32 @@ function setupCommand$g(name, description, argv, importMeta) {
|
|
|
928
949
|
|
|
929
950
|
var rawNpx$1 = {};
|
|
930
951
|
|
|
931
|
-
var _interopRequireDefault$
|
|
952
|
+
var _interopRequireDefault$j = vendor.interopRequireDefault.default;
|
|
932
953
|
Object.defineProperty(rawNpx$1, "__esModule", {
|
|
933
954
|
value: true
|
|
934
955
|
});
|
|
935
956
|
rawNpx$1.rawNpx = void 0;
|
|
936
957
|
var _child_process = require$$0$1;
|
|
937
|
-
var _meow$
|
|
938
|
-
var _flags$
|
|
939
|
-
var _formatting$
|
|
958
|
+
var _meow$i = _interopRequireDefault$j(vendor.build);
|
|
959
|
+
var _flags$f = flags;
|
|
960
|
+
var _formatting$h = formatting;
|
|
940
961
|
const rawNpx = rawNpx$1.rawNpx = {
|
|
941
962
|
description: 'Temporarily disable the Socket npm/npx wrapper',
|
|
942
963
|
async run(argv, importMeta, {
|
|
943
964
|
parentName
|
|
944
965
|
}) {
|
|
945
966
|
const name = `${parentName} raw-npx`;
|
|
946
|
-
setupCommand$
|
|
967
|
+
setupCommand$h(name, rawNpx.description, argv, importMeta);
|
|
947
968
|
}
|
|
948
969
|
};
|
|
949
|
-
function setupCommand$
|
|
950
|
-
const flags = _flags$
|
|
951
|
-
const cli = (0, _meow$
|
|
970
|
+
function setupCommand$h(name, description, argv, importMeta) {
|
|
971
|
+
const flags = _flags$f.validationFlags;
|
|
972
|
+
const cli = (0, _meow$i.default)(`
|
|
952
973
|
Usage
|
|
953
974
|
$ ${name} <npx command>
|
|
954
975
|
|
|
955
976
|
Options
|
|
956
|
-
${(0, _formatting$
|
|
977
|
+
${(0, _formatting$h.printFlagList)(flags, 6)}
|
|
957
978
|
|
|
958
979
|
Examples
|
|
959
980
|
$ ${name} install
|
|
@@ -985,31 +1006,31 @@ var create$5 = {};
|
|
|
985
1006
|
|
|
986
1007
|
var view$3 = {};
|
|
987
1008
|
|
|
988
|
-
var _interopRequireDefault$
|
|
1009
|
+
var _interopRequireDefault$i = vendor.interopRequireDefault.default;
|
|
989
1010
|
Object.defineProperty(view$3, "__esModule", {
|
|
990
1011
|
value: true
|
|
991
1012
|
});
|
|
992
1013
|
view$3.fetchReportData = fetchReportData;
|
|
993
1014
|
view$3.formatReportDataOutput = formatReportDataOutput;
|
|
994
1015
|
view$3.view = void 0;
|
|
995
|
-
var _chalk$
|
|
996
|
-
var _meow$
|
|
997
|
-
var _ora$
|
|
1016
|
+
var _chalk$f = _interopRequireDefault$i(vendor.source);
|
|
1017
|
+
var _meow$h = _interopRequireDefault$i(vendor.build);
|
|
1018
|
+
var _ora$f = _interopRequireDefault$i(vendor.ora);
|
|
998
1019
|
var _ponyCause$3 = require$$6;
|
|
999
|
-
var _flags$
|
|
1000
|
-
var _apiHelpers$
|
|
1020
|
+
var _flags$e = flags;
|
|
1021
|
+
var _apiHelpers$f = apiHelpers;
|
|
1001
1022
|
var _chalkMarkdown$2 = sdk.chalkMarkdown;
|
|
1002
|
-
var _errors$
|
|
1023
|
+
var _errors$g = sdk.errors;
|
|
1003
1024
|
var _formatIssues = formatIssues;
|
|
1004
|
-
var _formatting$
|
|
1005
|
-
var _sdk$
|
|
1025
|
+
var _formatting$g = formatting;
|
|
1026
|
+
var _sdk$f = sdk.sdk;
|
|
1006
1027
|
const view$2 = view$3.view = {
|
|
1007
1028
|
description: 'View a project report',
|
|
1008
1029
|
async run(argv, importMeta, {
|
|
1009
1030
|
parentName
|
|
1010
1031
|
}) {
|
|
1011
1032
|
const name = `${parentName} view`;
|
|
1012
|
-
const input = setupCommand$
|
|
1033
|
+
const input = setupCommand$g(name, view$2.description, argv, importMeta);
|
|
1013
1034
|
const result = input ? await fetchReportData(input.reportId, input) : undefined;
|
|
1014
1035
|
if (result) {
|
|
1015
1036
|
formatReportDataOutput(result, {
|
|
@@ -1022,17 +1043,17 @@ const view$2 = view$3.view = {
|
|
|
1022
1043
|
|
|
1023
1044
|
// Internal functions
|
|
1024
1045
|
|
|
1025
|
-
function setupCommand$
|
|
1046
|
+
function setupCommand$g(name, description, argv, importMeta) {
|
|
1026
1047
|
const flags = {
|
|
1027
|
-
..._flags$
|
|
1028
|
-
..._flags$
|
|
1048
|
+
..._flags$e.outputFlags,
|
|
1049
|
+
..._flags$e.validationFlags
|
|
1029
1050
|
};
|
|
1030
|
-
const cli = (0, _meow$
|
|
1051
|
+
const cli = (0, _meow$h.default)(`
|
|
1031
1052
|
Usage
|
|
1032
1053
|
$ ${name} <report-identifier>
|
|
1033
1054
|
|
|
1034
1055
|
Options
|
|
1035
|
-
${(0, _formatting$
|
|
1056
|
+
${(0, _formatting$g.printFlagList)(flags, 6)}
|
|
1036
1057
|
|
|
1037
1058
|
Examples
|
|
1038
1059
|
$ ${name} QXU8PmK7LfH608RAwfIKdbcHgwEd_ZeWJ9QEGv05FJUQ
|
|
@@ -1060,7 +1081,7 @@ function setupCommand$e(name, description, argv, importMeta) {
|
|
|
1060
1081
|
// Validate the input
|
|
1061
1082
|
|
|
1062
1083
|
if (extraInput.length) {
|
|
1063
|
-
throw new _errors$
|
|
1084
|
+
throw new _errors$g.InputError(`Can only handle a single report ID at a time, but got ${cli.input.length} report ID:s: ${cli.input.join(', ')}`);
|
|
1064
1085
|
}
|
|
1065
1086
|
return {
|
|
1066
1087
|
includeAllIssues,
|
|
@@ -1077,12 +1098,12 @@ async function fetchReportData(reportId, {
|
|
|
1077
1098
|
}) {
|
|
1078
1099
|
// Do the API call
|
|
1079
1100
|
|
|
1080
|
-
const socketSdk = await (0, _sdk$
|
|
1081
|
-
const spinner = (0, _ora$
|
|
1101
|
+
const socketSdk = await (0, _sdk$f.setupSdk)();
|
|
1102
|
+
const spinner = (0, _ora$f.default)(`Fetching report with ID ${reportId} (this could take a while)`).start();
|
|
1082
1103
|
let result;
|
|
1083
1104
|
for (let retry = 1; !result; ++retry) {
|
|
1084
1105
|
try {
|
|
1085
|
-
result = await (0, _apiHelpers$
|
|
1106
|
+
result = await (0, _apiHelpers$f.handleApiCall)(socketSdk.getReport(reportId), 'fetching report');
|
|
1086
1107
|
} catch (err) {
|
|
1087
1108
|
if (retry >= MAX_TIMEOUT_RETRY || !(err instanceof _ponyCause$3.ErrorWithCause) || err.cause?.cause?.response?.statusCode !== 524) {
|
|
1088
1109
|
throw err;
|
|
@@ -1090,7 +1111,7 @@ async function fetchReportData(reportId, {
|
|
|
1090
1111
|
}
|
|
1091
1112
|
}
|
|
1092
1113
|
if (result.success === false) {
|
|
1093
|
-
return (0, _apiHelpers$
|
|
1114
|
+
return (0, _apiHelpers$f.handleUnsuccessfulApiResponse)('getReport', result, spinner);
|
|
1094
1115
|
}
|
|
1095
1116
|
|
|
1096
1117
|
// Conclude the status of the API call
|
|
@@ -1125,7 +1146,7 @@ function formatReportDataOutput(data, {
|
|
|
1125
1146
|
fallbackToUrl: true
|
|
1126
1147
|
}));
|
|
1127
1148
|
if (!outputMarkdown) {
|
|
1128
|
-
console.log(_chalk$
|
|
1149
|
+
console.log(_chalk$f.default.dim('\nOr rerun', _chalk$f.default.italic(name), 'using the', _chalk$f.default.italic('--json'), 'flag to get full JSON output'));
|
|
1129
1150
|
}
|
|
1130
1151
|
}
|
|
1131
1152
|
if (strict && data.healthy === false) {
|
|
@@ -1133,7 +1154,7 @@ function formatReportDataOutput(data, {
|
|
|
1133
1154
|
}
|
|
1134
1155
|
}
|
|
1135
1156
|
|
|
1136
|
-
var _interopRequireDefault$
|
|
1157
|
+
var _interopRequireDefault$h = vendor.interopRequireDefault.default;
|
|
1137
1158
|
Object.defineProperty(create$5, "__esModule", {
|
|
1138
1159
|
value: true
|
|
1139
1160
|
});
|
|
@@ -1141,25 +1162,25 @@ create$5.create = void 0;
|
|
|
1141
1162
|
var _nodePath$1 = require$$1;
|
|
1142
1163
|
var _betterAjvErrors = require$$2;
|
|
1143
1164
|
var _config = require$$3;
|
|
1144
|
-
var _meow$
|
|
1145
|
-
var _ora$
|
|
1165
|
+
var _meow$g = _interopRequireDefault$h(vendor.build);
|
|
1166
|
+
var _ora$e = _interopRequireDefault$h(vendor.ora);
|
|
1146
1167
|
var _ponyCause$2 = require$$6;
|
|
1147
1168
|
var _view$2 = view$3;
|
|
1148
|
-
var _flags$
|
|
1149
|
-
var _apiHelpers$
|
|
1169
|
+
var _flags$d = flags;
|
|
1170
|
+
var _apiHelpers$e = apiHelpers;
|
|
1150
1171
|
var _chalkMarkdown$1 = sdk.chalkMarkdown;
|
|
1151
|
-
var _errors$
|
|
1152
|
-
var _formatting$
|
|
1172
|
+
var _errors$f = sdk.errors;
|
|
1173
|
+
var _formatting$f = formatting;
|
|
1153
1174
|
var _misc$1 = misc;
|
|
1154
1175
|
var _pathResolve$1 = pathResolve.pathResolve;
|
|
1155
|
-
var _sdk$
|
|
1176
|
+
var _sdk$e = sdk.sdk;
|
|
1156
1177
|
const create$4 = create$5.create = {
|
|
1157
1178
|
description: 'Create a project report',
|
|
1158
1179
|
async run(argv, importMeta, {
|
|
1159
1180
|
parentName
|
|
1160
1181
|
}) {
|
|
1161
1182
|
const name = `${parentName} create`;
|
|
1162
|
-
const input = await setupCommand$
|
|
1183
|
+
const input = await setupCommand$f(name, create$4.description, argv, importMeta);
|
|
1163
1184
|
if (input) {
|
|
1164
1185
|
const {
|
|
1165
1186
|
config,
|
|
@@ -1207,10 +1228,10 @@ const create$4 = create$5.create = {
|
|
|
1207
1228
|
|
|
1208
1229
|
// Internal functions
|
|
1209
1230
|
|
|
1210
|
-
async function setupCommand$
|
|
1231
|
+
async function setupCommand$f(name, description, argv, importMeta) {
|
|
1211
1232
|
const flags = {
|
|
1212
|
-
..._flags$
|
|
1213
|
-
..._flags$
|
|
1233
|
+
..._flags$d.outputFlags,
|
|
1234
|
+
..._flags$d.validationFlags,
|
|
1214
1235
|
debug: {
|
|
1215
1236
|
type: 'boolean',
|
|
1216
1237
|
shortFlag: 'd',
|
|
@@ -1229,7 +1250,7 @@ async function setupCommand$d(name, description, argv, importMeta) {
|
|
|
1229
1250
|
description: 'Will wait for and return the created report'
|
|
1230
1251
|
}
|
|
1231
1252
|
};
|
|
1232
|
-
const cli = (0, _meow$
|
|
1253
|
+
const cli = (0, _meow$g.default)(`
|
|
1233
1254
|
Usage
|
|
1234
1255
|
$ ${name} <paths-to-package-folders-and-files>
|
|
1235
1256
|
|
|
@@ -1243,7 +1264,7 @@ async function setupCommand$d(name, description, argv, importMeta) {
|
|
|
1243
1264
|
default ignores from the "ignore-by-default" module.
|
|
1244
1265
|
|
|
1245
1266
|
Options
|
|
1246
|
-
${(0, _formatting$
|
|
1267
|
+
${(0, _formatting$f.printFlagList)({
|
|
1247
1268
|
all: 'Include all issues',
|
|
1248
1269
|
debug: 'Output debug information',
|
|
1249
1270
|
'dry-run': 'Only output what will be done without actually doing it',
|
|
@@ -1290,16 +1311,16 @@ async function setupCommand$d(name, description, argv, importMeta) {
|
|
|
1290
1311
|
errors: cause.validationErrors,
|
|
1291
1312
|
schema: cause.schema
|
|
1292
1313
|
});
|
|
1293
|
-
throw new _errors$
|
|
1314
|
+
throw new _errors$f.InputError('The socket.yml config is not valid', betterErrors.map(err => `[${err.path}] ${err.message}.${err.suggestion ? err.suggestion : ''}`).join('\n'));
|
|
1294
1315
|
} else {
|
|
1295
1316
|
throw new _ponyCause$2.ErrorWithCause('Failed to read socket.yml config', {
|
|
1296
1317
|
cause
|
|
1297
1318
|
});
|
|
1298
1319
|
}
|
|
1299
1320
|
});
|
|
1300
|
-
const socketSdk = await (0, _sdk$
|
|
1321
|
+
const socketSdk = await (0, _sdk$e.setupSdk)();
|
|
1301
1322
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
1302
|
-
if (!res.success) (0, _apiHelpers$
|
|
1323
|
+
if (!res.success) (0, _apiHelpers$e.handleUnsuccessfulApiResponse)('getReportSupportedFiles', res, (0, _ora$e.default)());
|
|
1303
1324
|
return res.data;
|
|
1304
1325
|
}).catch(cause => {
|
|
1305
1326
|
throw new _ponyCause$2.ErrorWithCause('Failed getting supported files for report', {
|
|
@@ -1330,12 +1351,12 @@ async function createReport(packagePaths, {
|
|
|
1330
1351
|
if (dryRun) {
|
|
1331
1352
|
return;
|
|
1332
1353
|
}
|
|
1333
|
-
const socketSdk = await (0, _sdk$
|
|
1334
|
-
const spinner = (0, _ora$
|
|
1354
|
+
const socketSdk = await (0, _sdk$e.setupSdk)();
|
|
1355
|
+
const spinner = (0, _ora$e.default)(`Creating report with ${packagePaths.length} package files`).start();
|
|
1335
1356
|
const apiCall = socketSdk.createReportFromFilePaths(packagePaths, cwd, config?.issueRules);
|
|
1336
|
-
const result = await (0, _apiHelpers$
|
|
1357
|
+
const result = await (0, _apiHelpers$e.handleApiCall)(apiCall, 'creating report');
|
|
1337
1358
|
if (result.success === false) {
|
|
1338
|
-
return (0, _apiHelpers$
|
|
1359
|
+
return (0, _apiHelpers$e.handleUnsuccessfulApiResponse)('createReport', result, spinner);
|
|
1339
1360
|
}
|
|
1340
1361
|
|
|
1341
1362
|
// Conclude the status of the API call
|
|
@@ -1359,13 +1380,13 @@ function formatReportCreationOutput(data, {
|
|
|
1359
1380
|
|
|
1360
1381
|
var meowWithSubcommands$1 = {};
|
|
1361
1382
|
|
|
1362
|
-
var _interopRequireDefault$
|
|
1383
|
+
var _interopRequireDefault$g = vendor.interopRequireDefault.default;
|
|
1363
1384
|
Object.defineProperty(meowWithSubcommands$1, "__esModule", {
|
|
1364
1385
|
value: true
|
|
1365
1386
|
});
|
|
1366
1387
|
meowWithSubcommands$1.meowWithSubcommands = meowWithSubcommands;
|
|
1367
|
-
var _meow$
|
|
1368
|
-
var _formatting$
|
|
1388
|
+
var _meow$f = _interopRequireDefault$g(vendor.build);
|
|
1389
|
+
var _formatting$e = formatting;
|
|
1369
1390
|
function sortKeys(object) {
|
|
1370
1391
|
return Object.fromEntries(Object.keys(object).sort().map(k => [k, object[k]]));
|
|
1371
1392
|
}
|
|
@@ -1398,18 +1419,18 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1398
1419
|
}
|
|
1399
1420
|
|
|
1400
1421
|
// ...else we provide basic instructions and help
|
|
1401
|
-
const cli = (0, _meow$
|
|
1422
|
+
const cli = (0, _meow$f.default)(`
|
|
1402
1423
|
Usage
|
|
1403
1424
|
$ ${name} <command>
|
|
1404
1425
|
|
|
1405
1426
|
Commands
|
|
1406
|
-
${(0, _formatting$
|
|
1427
|
+
${(0, _formatting$e.printHelpList)({
|
|
1407
1428
|
...sortKeys(subcommands),
|
|
1408
1429
|
...sortKeys(aliases)
|
|
1409
1430
|
}, 6)}
|
|
1410
1431
|
|
|
1411
1432
|
Options
|
|
1412
|
-
${(0, _formatting$
|
|
1433
|
+
${(0, _formatting$e.printFlagList)({}, 6)}
|
|
1413
1434
|
|
|
1414
1435
|
Examples
|
|
1415
1436
|
$ ${name} --help
|
|
@@ -1427,19 +1448,19 @@ Object.defineProperty(report, "__esModule", {
|
|
|
1427
1448
|
report.report = void 0;
|
|
1428
1449
|
var _create$2 = create$5;
|
|
1429
1450
|
var _view$1 = view$3;
|
|
1430
|
-
var _meowWithSubcommands$
|
|
1431
|
-
const description$
|
|
1451
|
+
var _meowWithSubcommands$4 = meowWithSubcommands$1;
|
|
1452
|
+
const description$3 = '[Deprecated] Project report related commands';
|
|
1432
1453
|
report.report = {
|
|
1433
|
-
description: description$
|
|
1454
|
+
description: description$3,
|
|
1434
1455
|
run: async (argv, importMeta, {
|
|
1435
1456
|
parentName
|
|
1436
1457
|
}) => {
|
|
1437
|
-
await (0, _meowWithSubcommands$
|
|
1458
|
+
await (0, _meowWithSubcommands$4.meowWithSubcommands)({
|
|
1438
1459
|
create: _create$2.create,
|
|
1439
1460
|
view: _view$1.view
|
|
1440
1461
|
}, {
|
|
1441
1462
|
argv,
|
|
1442
|
-
description: description$
|
|
1463
|
+
description: description$3,
|
|
1443
1464
|
importMeta,
|
|
1444
1465
|
name: parentName + ' report'
|
|
1445
1466
|
});
|
|
@@ -1448,7 +1469,7 @@ report.report = {
|
|
|
1448
1469
|
|
|
1449
1470
|
var wrapper$1 = {};
|
|
1450
1471
|
|
|
1451
|
-
var _interopRequireDefault$
|
|
1472
|
+
var _interopRequireDefault$f = vendor.interopRequireDefault.default;
|
|
1452
1473
|
Object.defineProperty(wrapper$1, "__esModule", {
|
|
1453
1474
|
value: true
|
|
1454
1475
|
});
|
|
@@ -1456,9 +1477,9 @@ wrapper$1.wrapper = void 0;
|
|
|
1456
1477
|
var _nodeFs$1 = require$$0;
|
|
1457
1478
|
var _nodeOs = require$$0$2;
|
|
1458
1479
|
var _nodeReadline = require$$3$1;
|
|
1459
|
-
var _meow$
|
|
1460
|
-
var _flags$
|
|
1461
|
-
var _formatting$
|
|
1480
|
+
var _meow$e = _interopRequireDefault$f(vendor.build);
|
|
1481
|
+
var _flags$c = flags;
|
|
1482
|
+
var _formatting$d = formatting;
|
|
1462
1483
|
const BASH_FILE = `${_nodeOs.homedir()}/.bashrc`;
|
|
1463
1484
|
const ZSH_BASH_FILE = `${_nodeOs.homedir()}/.zshrc`;
|
|
1464
1485
|
const wrapper = wrapper$1.wrapper = {
|
|
@@ -1467,17 +1488,17 @@ const wrapper = wrapper$1.wrapper = {
|
|
|
1467
1488
|
parentName
|
|
1468
1489
|
}) {
|
|
1469
1490
|
const name = `${parentName} wrapper`;
|
|
1470
|
-
setupCommand$
|
|
1491
|
+
setupCommand$e(name, wrapper.description, argv, importMeta);
|
|
1471
1492
|
}
|
|
1472
1493
|
};
|
|
1473
|
-
function setupCommand$
|
|
1474
|
-
const flags = _flags$
|
|
1475
|
-
const cli = (0, _meow$
|
|
1494
|
+
function setupCommand$e(name, description, argv, importMeta) {
|
|
1495
|
+
const flags = _flags$c.commandFlags;
|
|
1496
|
+
const cli = (0, _meow$e.default)(`
|
|
1476
1497
|
Usage
|
|
1477
1498
|
$ ${name} <flag>
|
|
1478
1499
|
|
|
1479
1500
|
Options
|
|
1480
|
-
${(0, _formatting$
|
|
1501
|
+
${(0, _formatting$d.printFlagList)(flags, 6)}
|
|
1481
1502
|
|
|
1482
1503
|
Examples
|
|
1483
1504
|
$ ${name} --enable
|
|
@@ -1607,38 +1628,38 @@ var scan = {};
|
|
|
1607
1628
|
|
|
1608
1629
|
var create$3 = {};
|
|
1609
1630
|
|
|
1610
|
-
var _interopRequireDefault$
|
|
1631
|
+
var _interopRequireDefault$e = vendor.interopRequireDefault.default;
|
|
1611
1632
|
Object.defineProperty(create$3, "__esModule", {
|
|
1612
1633
|
value: true
|
|
1613
1634
|
});
|
|
1614
1635
|
create$3.create = void 0;
|
|
1615
1636
|
var _nodeProcess = require$$0$3;
|
|
1616
1637
|
var _promises = require$$2$1;
|
|
1617
|
-
var _chalk$
|
|
1618
|
-
var _meow$
|
|
1619
|
-
var _open = _interopRequireDefault$
|
|
1620
|
-
var _ora$
|
|
1638
|
+
var _chalk$e = _interopRequireDefault$e(vendor.source);
|
|
1639
|
+
var _meow$d = _interopRequireDefault$e(vendor.build);
|
|
1640
|
+
var _open = _interopRequireDefault$e(vendor.open);
|
|
1641
|
+
var _ora$d = _interopRequireDefault$e(vendor.ora);
|
|
1621
1642
|
var _ponyCause$1 = require$$6;
|
|
1622
|
-
var _apiHelpers$
|
|
1623
|
-
var _formatting$
|
|
1643
|
+
var _apiHelpers$d = apiHelpers;
|
|
1644
|
+
var _formatting$c = formatting;
|
|
1624
1645
|
var _misc = misc;
|
|
1625
1646
|
var _pathResolve = pathResolve.pathResolve;
|
|
1626
|
-
var _sdk$
|
|
1627
|
-
var _errors$
|
|
1647
|
+
var _sdk$d = sdk.sdk;
|
|
1648
|
+
var _errors$e = sdk.errors;
|
|
1628
1649
|
const create$2 = create$3.create = {
|
|
1629
1650
|
description: 'Create a scan',
|
|
1630
1651
|
async run(argv, importMeta, {
|
|
1631
1652
|
parentName
|
|
1632
1653
|
}) {
|
|
1633
1654
|
const name = `${parentName} create`;
|
|
1634
|
-
const input = await setupCommand$
|
|
1655
|
+
const input = await setupCommand$d(name, create$2.description, argv, importMeta);
|
|
1635
1656
|
if (input) {
|
|
1636
|
-
const apiKey = (0, _sdk$
|
|
1657
|
+
const apiKey = (0, _sdk$d.getDefaultKey)();
|
|
1637
1658
|
if (!apiKey) {
|
|
1638
|
-
throw new _errors$
|
|
1659
|
+
throw new _errors$e.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
1639
1660
|
}
|
|
1640
1661
|
const spinnerText = 'Creating a scan... \n';
|
|
1641
|
-
const spinner = (0, _ora$
|
|
1662
|
+
const spinner = (0, _ora$d.default)(spinnerText).start();
|
|
1642
1663
|
await createFullScan(input, spinner, apiKey);
|
|
1643
1664
|
}
|
|
1644
1665
|
}
|
|
@@ -1701,16 +1722,16 @@ const createFullScanFlags = {
|
|
|
1701
1722
|
|
|
1702
1723
|
// Internal functions
|
|
1703
1724
|
|
|
1704
|
-
async function setupCommand$
|
|
1725
|
+
async function setupCommand$d(name, description, argv, importMeta) {
|
|
1705
1726
|
const flags = {
|
|
1706
1727
|
...createFullScanFlags
|
|
1707
1728
|
};
|
|
1708
|
-
const cli = (0, _meow$
|
|
1729
|
+
const cli = (0, _meow$d.default)(`
|
|
1709
1730
|
Usage
|
|
1710
1731
|
$ ${name} [...options]
|
|
1711
1732
|
|
|
1712
1733
|
Options
|
|
1713
|
-
${(0, _formatting$
|
|
1734
|
+
${(0, _formatting$c.printFlagList)(flags, 6)}
|
|
1714
1735
|
|
|
1715
1736
|
Examples
|
|
1716
1737
|
$ ${name} --org=FakeOrg --repo=test-repo --branch=main ./package.json
|
|
@@ -1739,9 +1760,9 @@ async function setupCommand$b(name, description, argv, importMeta) {
|
|
|
1739
1760
|
0: orgSlug = ''
|
|
1740
1761
|
} = cli.input;
|
|
1741
1762
|
const cwd = process.cwd();
|
|
1742
|
-
const socketSdk = await (0, _sdk$
|
|
1763
|
+
const socketSdk = await (0, _sdk$d.setupSdk)();
|
|
1743
1764
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
1744
|
-
if (!res.success) (0, _apiHelpers$
|
|
1765
|
+
if (!res.success) (0, _apiHelpers$d.handleUnsuccessfulApiResponse)('getReportSupportedFiles', res, (0, _ora$d.default)());
|
|
1745
1766
|
return res.data;
|
|
1746
1767
|
}).catch( /** @type {(cause: Error) => never} */
|
|
1747
1768
|
cause => {
|
|
@@ -1752,7 +1773,7 @@ async function setupCommand$b(name, description, argv, importMeta) {
|
|
|
1752
1773
|
const debugLog = (0, _misc.createDebugLogger)(false);
|
|
1753
1774
|
const packagePaths = await (0, _pathResolve.getPackageFilesFullScans)(cwd, cli.input, supportedFiles, debugLog);
|
|
1754
1775
|
if (!repoName || !branchName || !packagePaths.length) {
|
|
1755
|
-
console.error(`${_chalk$
|
|
1776
|
+
console.error(`${_chalk$e.default.bgRed('Input error')}: Please provide the required fields:\n
|
|
1756
1777
|
- Repository name using --repo,\n
|
|
1757
1778
|
- Branch name using --branch\n
|
|
1758
1779
|
- At least one file path (e.g. ./package.json).\n`);
|
|
@@ -1774,7 +1795,7 @@ async function setupCommand$b(name, description, argv, importMeta) {
|
|
|
1774
1795
|
};
|
|
1775
1796
|
}
|
|
1776
1797
|
async function createFullScan(input, spinner, apiKey) {
|
|
1777
|
-
const socketSdk = await (0, _sdk$
|
|
1798
|
+
const socketSdk = await (0, _sdk$d.setupSdk)(apiKey);
|
|
1778
1799
|
const {
|
|
1779
1800
|
orgSlug,
|
|
1780
1801
|
repoName,
|
|
@@ -1785,7 +1806,7 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
1785
1806
|
tmp,
|
|
1786
1807
|
packagePaths
|
|
1787
1808
|
} = input;
|
|
1788
|
-
const result = await (0, _apiHelpers$
|
|
1809
|
+
const result = await (0, _apiHelpers$d.handleApiCall)(socketSdk.createOrgFullScan(orgSlug, {
|
|
1789
1810
|
repo: repoName,
|
|
1790
1811
|
branch: branchName,
|
|
1791
1812
|
commit_message: commitMessage,
|
|
@@ -1794,12 +1815,12 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
1794
1815
|
tmp
|
|
1795
1816
|
}, packagePaths), 'Creating scan');
|
|
1796
1817
|
if (!result.success) {
|
|
1797
|
-
(0, _apiHelpers$
|
|
1818
|
+
(0, _apiHelpers$d.handleUnsuccessfulApiResponse)('CreateOrgFullScan', result, spinner);
|
|
1798
1819
|
return;
|
|
1799
1820
|
}
|
|
1800
1821
|
spinner.stop();
|
|
1801
1822
|
console.log('\n✅ Scan created successfully\n');
|
|
1802
|
-
const link = _chalk$
|
|
1823
|
+
const link = _chalk$e.default.hex('#00FFFF').underline(`${result.data.html_report_url}`);
|
|
1803
1824
|
console.log(`Available at: ${link}\n`);
|
|
1804
1825
|
const rl = _promises.createInterface({
|
|
1805
1826
|
input: _nodeProcess.stdin,
|
|
@@ -1814,33 +1835,33 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
1814
1835
|
|
|
1815
1836
|
var _delete$3 = {};
|
|
1816
1837
|
|
|
1817
|
-
var _interopRequireDefault$
|
|
1838
|
+
var _interopRequireDefault$d = vendor.interopRequireDefault.default;
|
|
1818
1839
|
Object.defineProperty(_delete$3, "__esModule", {
|
|
1819
1840
|
value: true
|
|
1820
1841
|
});
|
|
1821
1842
|
_delete$3.del = void 0;
|
|
1822
|
-
var _chalk$
|
|
1823
|
-
var _meow$
|
|
1824
|
-
var _ora$
|
|
1825
|
-
var _flags$
|
|
1826
|
-
var _apiHelpers$
|
|
1827
|
-
var _formatting$
|
|
1828
|
-
var _sdk$
|
|
1829
|
-
var _errors$
|
|
1843
|
+
var _chalk$d = _interopRequireDefault$d(vendor.source);
|
|
1844
|
+
var _meow$c = _interopRequireDefault$d(vendor.build);
|
|
1845
|
+
var _ora$c = _interopRequireDefault$d(vendor.ora);
|
|
1846
|
+
var _flags$b = flags;
|
|
1847
|
+
var _apiHelpers$c = apiHelpers;
|
|
1848
|
+
var _formatting$b = formatting;
|
|
1849
|
+
var _sdk$c = sdk.sdk;
|
|
1850
|
+
var _errors$d = sdk.errors;
|
|
1830
1851
|
const del$1 = _delete$3.del = {
|
|
1831
1852
|
description: 'Delete a scan',
|
|
1832
1853
|
async run(argv, importMeta, {
|
|
1833
1854
|
parentName
|
|
1834
1855
|
}) {
|
|
1835
1856
|
const name = `${parentName} del`;
|
|
1836
|
-
const input = setupCommand$
|
|
1857
|
+
const input = setupCommand$c(name, del$1.description, argv, importMeta);
|
|
1837
1858
|
if (input) {
|
|
1838
|
-
const apiKey = (0, _sdk$
|
|
1859
|
+
const apiKey = (0, _sdk$c.getDefaultKey)();
|
|
1839
1860
|
if (!apiKey) {
|
|
1840
|
-
throw new _errors$
|
|
1861
|
+
throw new _errors$d.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
1841
1862
|
}
|
|
1842
1863
|
const spinnerText = 'Deleting scan...';
|
|
1843
|
-
const spinner = (0, _ora$
|
|
1864
|
+
const spinner = (0, _ora$c.default)(spinnerText).start();
|
|
1844
1865
|
await deleteOrgFullScan(input.orgSlug, input.fullScanId, spinner, apiKey);
|
|
1845
1866
|
}
|
|
1846
1867
|
}
|
|
@@ -1848,16 +1869,16 @@ const del$1 = _delete$3.del = {
|
|
|
1848
1869
|
|
|
1849
1870
|
// Internal functions
|
|
1850
1871
|
|
|
1851
|
-
function setupCommand$
|
|
1872
|
+
function setupCommand$c(name, description, argv, importMeta) {
|
|
1852
1873
|
const flags = {
|
|
1853
|
-
..._flags$
|
|
1874
|
+
..._flags$b.outputFlags
|
|
1854
1875
|
};
|
|
1855
|
-
const cli = (0, _meow$
|
|
1876
|
+
const cli = (0, _meow$c.default)(`
|
|
1856
1877
|
Usage
|
|
1857
1878
|
$ ${name} <org slug> <scan ID>
|
|
1858
1879
|
|
|
1859
1880
|
Options
|
|
1860
|
-
${(0, _formatting$
|
|
1881
|
+
${(0, _formatting$b.printFlagList)(flags, 6)}
|
|
1861
1882
|
|
|
1862
1883
|
Examples
|
|
1863
1884
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -1872,7 +1893,7 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
1872
1893
|
markdown: outputMarkdown
|
|
1873
1894
|
} = cli.flags;
|
|
1874
1895
|
if (cli.input.length < 2) {
|
|
1875
|
-
console.error(`${_chalk$
|
|
1896
|
+
console.error(`${_chalk$d.default.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
1876
1897
|
cli.showHelp();
|
|
1877
1898
|
return;
|
|
1878
1899
|
}
|
|
@@ -1888,10 +1909,10 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
1888
1909
|
};
|
|
1889
1910
|
}
|
|
1890
1911
|
async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
1891
|
-
const socketSdk = await (0, _sdk$
|
|
1892
|
-
const result = await (0, _apiHelpers$
|
|
1912
|
+
const socketSdk = await (0, _sdk$c.setupSdk)(apiKey);
|
|
1913
|
+
const result = await (0, _apiHelpers$c.handleApiCall)(socketSdk.deleteOrgFullScan(orgSlug, fullScanId), 'Deleting scan');
|
|
1893
1914
|
if (!result.success) {
|
|
1894
|
-
(0, _apiHelpers$
|
|
1915
|
+
(0, _apiHelpers$c.handleUnsuccessfulApiResponse)('deleteOrgFullScan', result, spinner);
|
|
1895
1916
|
return;
|
|
1896
1917
|
}
|
|
1897
1918
|
spinner.stop();
|
|
@@ -1900,20 +1921,20 @@ async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
|
1900
1921
|
|
|
1901
1922
|
var list$3 = {};
|
|
1902
1923
|
|
|
1903
|
-
var _interopRequireDefault$
|
|
1924
|
+
var _interopRequireDefault$c = vendor.interopRequireDefault.default;
|
|
1904
1925
|
Object.defineProperty(list$3, "__esModule", {
|
|
1905
1926
|
value: true
|
|
1906
1927
|
});
|
|
1907
1928
|
list$3.list = void 0;
|
|
1908
|
-
var _chalk$
|
|
1929
|
+
var _chalk$c = _interopRequireDefault$c(vendor.source);
|
|
1909
1930
|
var _chalkTable$3 = require$$2$2;
|
|
1910
|
-
var _meow$
|
|
1911
|
-
var _ora$
|
|
1912
|
-
var _flags$
|
|
1913
|
-
var _apiHelpers$
|
|
1914
|
-
var _formatting$
|
|
1915
|
-
var _sdk$
|
|
1916
|
-
var _errors$
|
|
1931
|
+
var _meow$b = _interopRequireDefault$c(vendor.build);
|
|
1932
|
+
var _ora$b = _interopRequireDefault$c(vendor.ora);
|
|
1933
|
+
var _flags$a = flags;
|
|
1934
|
+
var _apiHelpers$b = apiHelpers;
|
|
1935
|
+
var _formatting$a = formatting;
|
|
1936
|
+
var _sdk$b = sdk.sdk;
|
|
1937
|
+
var _errors$c = sdk.errors;
|
|
1917
1938
|
// @ts-ignore
|
|
1918
1939
|
|
|
1919
1940
|
const list$2 = list$3.list = {
|
|
@@ -1922,14 +1943,14 @@ const list$2 = list$3.list = {
|
|
|
1922
1943
|
parentName
|
|
1923
1944
|
}) {
|
|
1924
1945
|
const name = `${parentName} list`;
|
|
1925
|
-
const input = setupCommand$
|
|
1946
|
+
const input = setupCommand$b(name, list$2.description, argv, importMeta);
|
|
1926
1947
|
if (input) {
|
|
1927
|
-
const apiKey = (0, _sdk$
|
|
1948
|
+
const apiKey = (0, _sdk$b.getDefaultKey)();
|
|
1928
1949
|
if (!apiKey) {
|
|
1929
|
-
throw new _errors$
|
|
1950
|
+
throw new _errors$c.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
1930
1951
|
}
|
|
1931
1952
|
const spinnerText = 'Listing scans... \n';
|
|
1932
|
-
const spinner = (0, _ora$
|
|
1953
|
+
const spinner = (0, _ora$b.default)(spinnerText).start();
|
|
1933
1954
|
await listOrgFullScan(input.orgSlug, input, spinner, apiKey);
|
|
1934
1955
|
}
|
|
1935
1956
|
}
|
|
@@ -1975,17 +1996,17 @@ const listFullScanFlags = {
|
|
|
1975
1996
|
|
|
1976
1997
|
// Internal functions
|
|
1977
1998
|
|
|
1978
|
-
function setupCommand$
|
|
1999
|
+
function setupCommand$b(name, description, argv, importMeta) {
|
|
1979
2000
|
const flags = {
|
|
1980
|
-
..._flags$
|
|
2001
|
+
..._flags$a.outputFlags,
|
|
1981
2002
|
...listFullScanFlags
|
|
1982
2003
|
};
|
|
1983
|
-
const cli = (0, _meow$
|
|
2004
|
+
const cli = (0, _meow$b.default)(`
|
|
1984
2005
|
Usage
|
|
1985
2006
|
$ ${name} <org slug>
|
|
1986
2007
|
|
|
1987
2008
|
Options
|
|
1988
|
-
${(0, _formatting$
|
|
2009
|
+
${(0, _formatting$a.printFlagList)(flags, 6)}
|
|
1989
2010
|
|
|
1990
2011
|
Examples
|
|
1991
2012
|
$ ${name} FakeOrg
|
|
@@ -2006,7 +2027,7 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2006
2027
|
untilTime
|
|
2007
2028
|
} = cli.flags;
|
|
2008
2029
|
if (!cli.input[0]) {
|
|
2009
|
-
console.error(`${_chalk$
|
|
2030
|
+
console.error(`${_chalk$c.default.bgRed('Input error')}: Please specify an organization slug.\n`);
|
|
2010
2031
|
cli.showHelp();
|
|
2011
2032
|
return;
|
|
2012
2033
|
}
|
|
@@ -2026,10 +2047,10 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2026
2047
|
};
|
|
2027
2048
|
}
|
|
2028
2049
|
async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
2029
|
-
const socketSdk = await (0, _sdk$
|
|
2030
|
-
const result = await (0, _apiHelpers$
|
|
2050
|
+
const socketSdk = await (0, _sdk$b.setupSdk)(apiKey);
|
|
2051
|
+
const result = await (0, _apiHelpers$b.handleApiCall)(socketSdk.getOrgFullScanList(orgSlug, input), 'Listing scans');
|
|
2031
2052
|
if (!result.success) {
|
|
2032
|
-
(0, _apiHelpers$
|
|
2053
|
+
(0, _apiHelpers$b.handleUnsuccessfulApiResponse)('getOrgFullScanList', result, spinner);
|
|
2033
2054
|
return;
|
|
2034
2055
|
}
|
|
2035
2056
|
spinner.stop();
|
|
@@ -2037,22 +2058,22 @@ async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
|
2037
2058
|
const options = {
|
|
2038
2059
|
columns: [{
|
|
2039
2060
|
field: 'id',
|
|
2040
|
-
name: _chalk$
|
|
2061
|
+
name: _chalk$c.default.magenta('ID')
|
|
2041
2062
|
}, {
|
|
2042
2063
|
field: 'report_url',
|
|
2043
|
-
name: _chalk$
|
|
2064
|
+
name: _chalk$c.default.magenta('Scan URL')
|
|
2044
2065
|
}, {
|
|
2045
2066
|
field: 'branch',
|
|
2046
|
-
name: _chalk$
|
|
2067
|
+
name: _chalk$c.default.magenta('Branch')
|
|
2047
2068
|
}, {
|
|
2048
2069
|
field: 'created_at',
|
|
2049
|
-
name: _chalk$
|
|
2070
|
+
name: _chalk$c.default.magenta('Created at')
|
|
2050
2071
|
}]
|
|
2051
2072
|
};
|
|
2052
2073
|
const formattedResults = result.data.results.map(d => {
|
|
2053
2074
|
return {
|
|
2054
2075
|
id: d.id,
|
|
2055
|
-
report_url: _chalk$
|
|
2076
|
+
report_url: _chalk$c.default.underline(`${d.html_report_url}`),
|
|
2056
2077
|
created_at: d.created_at ? new Date(d.created_at).toLocaleDateString('en-us', {
|
|
2057
2078
|
year: 'numeric',
|
|
2058
2079
|
month: 'numeric',
|
|
@@ -2066,33 +2087,33 @@ async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
|
2066
2087
|
|
|
2067
2088
|
var metadata$1 = {};
|
|
2068
2089
|
|
|
2069
|
-
var _interopRequireDefault$
|
|
2090
|
+
var _interopRequireDefault$b = vendor.interopRequireDefault.default;
|
|
2070
2091
|
Object.defineProperty(metadata$1, "__esModule", {
|
|
2071
2092
|
value: true
|
|
2072
2093
|
});
|
|
2073
2094
|
metadata$1.metadata = void 0;
|
|
2074
|
-
var _chalk$
|
|
2075
|
-
var _meow$
|
|
2076
|
-
var _ora$
|
|
2077
|
-
var _flags$
|
|
2078
|
-
var _apiHelpers$
|
|
2079
|
-
var _formatting$
|
|
2080
|
-
var _sdk$
|
|
2081
|
-
var _errors$
|
|
2095
|
+
var _chalk$b = _interopRequireDefault$b(vendor.source);
|
|
2096
|
+
var _meow$a = _interopRequireDefault$b(vendor.build);
|
|
2097
|
+
var _ora$a = _interopRequireDefault$b(vendor.ora);
|
|
2098
|
+
var _flags$9 = flags;
|
|
2099
|
+
var _apiHelpers$a = apiHelpers;
|
|
2100
|
+
var _formatting$9 = formatting;
|
|
2101
|
+
var _sdk$a = sdk.sdk;
|
|
2102
|
+
var _errors$b = sdk.errors;
|
|
2082
2103
|
const metadata = metadata$1.metadata = {
|
|
2083
2104
|
description: "Get a scan's metadata",
|
|
2084
2105
|
async run(argv, importMeta, {
|
|
2085
2106
|
parentName
|
|
2086
2107
|
}) {
|
|
2087
2108
|
const name = `${parentName} metadata`;
|
|
2088
|
-
const input = setupCommand$
|
|
2109
|
+
const input = setupCommand$a(name, metadata.description, argv, importMeta);
|
|
2089
2110
|
if (input) {
|
|
2090
|
-
const apiKey = (0, _sdk$
|
|
2111
|
+
const apiKey = (0, _sdk$a.getDefaultKey)();
|
|
2091
2112
|
if (!apiKey) {
|
|
2092
|
-
throw new _errors$
|
|
2113
|
+
throw new _errors$b.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2093
2114
|
}
|
|
2094
2115
|
const spinnerText = "Getting scan's metadata... \n";
|
|
2095
|
-
const spinner = (0, _ora$
|
|
2116
|
+
const spinner = (0, _ora$a.default)(spinnerText).start();
|
|
2096
2117
|
await getOrgScanMetadata(input.orgSlug, input.scanID, spinner, apiKey);
|
|
2097
2118
|
}
|
|
2098
2119
|
}
|
|
@@ -2100,16 +2121,16 @@ const metadata = metadata$1.metadata = {
|
|
|
2100
2121
|
|
|
2101
2122
|
// Internal functions
|
|
2102
2123
|
|
|
2103
|
-
function setupCommand$
|
|
2124
|
+
function setupCommand$a(name, description, argv, importMeta) {
|
|
2104
2125
|
const flags = {
|
|
2105
|
-
..._flags$
|
|
2126
|
+
..._flags$9.outputFlags
|
|
2106
2127
|
};
|
|
2107
|
-
const cli = (0, _meow$
|
|
2128
|
+
const cli = (0, _meow$a.default)(`
|
|
2108
2129
|
Usage
|
|
2109
2130
|
$ ${name} <org slug> <scan id>
|
|
2110
2131
|
|
|
2111
2132
|
Options
|
|
2112
|
-
${(0, _formatting$
|
|
2133
|
+
${(0, _formatting$9.printFlagList)(flags, 6)}
|
|
2113
2134
|
|
|
2114
2135
|
Examples
|
|
2115
2136
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -2124,7 +2145,7 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
2124
2145
|
markdown: outputMarkdown
|
|
2125
2146
|
} = cli.flags;
|
|
2126
2147
|
if (cli.input.length < 2) {
|
|
2127
|
-
console.error(`${_chalk$
|
|
2148
|
+
console.error(`${_chalk$b.default.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2128
2149
|
cli.showHelp();
|
|
2129
2150
|
return;
|
|
2130
2151
|
}
|
|
@@ -2140,10 +2161,10 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
2140
2161
|
};
|
|
2141
2162
|
}
|
|
2142
2163
|
async function getOrgScanMetadata(orgSlug, scanId, spinner, apiKey) {
|
|
2143
|
-
const socketSdk = await (0, _sdk$
|
|
2144
|
-
const result = await (0, _apiHelpers$
|
|
2164
|
+
const socketSdk = await (0, _sdk$a.setupSdk)(apiKey);
|
|
2165
|
+
const result = await (0, _apiHelpers$a.handleApiCall)(socketSdk.getOrgFullScanMetadata(orgSlug, scanId), 'Listing scans');
|
|
2145
2166
|
if (!result.success) {
|
|
2146
|
-
(0, _apiHelpers$
|
|
2167
|
+
(0, _apiHelpers$a.handleUnsuccessfulApiResponse)('getOrgFullScanMetadata', result, spinner);
|
|
2147
2168
|
return;
|
|
2148
2169
|
}
|
|
2149
2170
|
spinner.stop();
|
|
@@ -2153,33 +2174,33 @@ async function getOrgScanMetadata(orgSlug, scanId, spinner, apiKey) {
|
|
|
2153
2174
|
|
|
2154
2175
|
var stream$1 = {};
|
|
2155
2176
|
|
|
2156
|
-
var _interopRequireDefault$
|
|
2177
|
+
var _interopRequireDefault$a = vendor.interopRequireDefault.default;
|
|
2157
2178
|
Object.defineProperty(stream$1, "__esModule", {
|
|
2158
2179
|
value: true
|
|
2159
2180
|
});
|
|
2160
2181
|
stream$1.stream = void 0;
|
|
2161
|
-
var _chalk$
|
|
2162
|
-
var _meow$
|
|
2163
|
-
var _ora$
|
|
2164
|
-
var _flags$
|
|
2165
|
-
var _apiHelpers$
|
|
2166
|
-
var _formatting$
|
|
2167
|
-
var _sdk$
|
|
2168
|
-
var _errors$
|
|
2182
|
+
var _chalk$a = _interopRequireDefault$a(vendor.source);
|
|
2183
|
+
var _meow$9 = _interopRequireDefault$a(vendor.build);
|
|
2184
|
+
var _ora$9 = _interopRequireDefault$a(vendor.ora);
|
|
2185
|
+
var _flags$8 = flags;
|
|
2186
|
+
var _apiHelpers$9 = apiHelpers;
|
|
2187
|
+
var _formatting$8 = formatting;
|
|
2188
|
+
var _sdk$9 = sdk.sdk;
|
|
2189
|
+
var _errors$a = sdk.errors;
|
|
2169
2190
|
const stream = stream$1.stream = {
|
|
2170
2191
|
description: 'Stream the output of a scan',
|
|
2171
2192
|
async run(argv, importMeta, {
|
|
2172
2193
|
parentName
|
|
2173
2194
|
}) {
|
|
2174
2195
|
const name = `${parentName} stream`;
|
|
2175
|
-
const input = setupCommand$
|
|
2196
|
+
const input = setupCommand$9(name, stream.description, argv, importMeta);
|
|
2176
2197
|
if (input) {
|
|
2177
|
-
const apiKey = (0, _sdk$
|
|
2198
|
+
const apiKey = (0, _sdk$9.getDefaultKey)();
|
|
2178
2199
|
if (!apiKey) {
|
|
2179
|
-
throw new _errors$
|
|
2200
|
+
throw new _errors$a.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2180
2201
|
}
|
|
2181
2202
|
const spinnerText = 'Streaming scan...\n';
|
|
2182
|
-
const spinner = (0, _ora$
|
|
2203
|
+
const spinner = (0, _ora$9.default)(spinnerText).start();
|
|
2183
2204
|
await getOrgFullScan(input.orgSlug, input.fullScanId, input.file, spinner, apiKey);
|
|
2184
2205
|
}
|
|
2185
2206
|
}
|
|
@@ -2187,16 +2208,16 @@ const stream = stream$1.stream = {
|
|
|
2187
2208
|
|
|
2188
2209
|
// Internal functions
|
|
2189
2210
|
|
|
2190
|
-
function setupCommand$
|
|
2211
|
+
function setupCommand$9(name, description, argv, importMeta) {
|
|
2191
2212
|
const flags = {
|
|
2192
|
-
..._flags$
|
|
2213
|
+
..._flags$8.outputFlags
|
|
2193
2214
|
};
|
|
2194
|
-
const cli = (0, _meow$
|
|
2215
|
+
const cli = (0, _meow$9.default)(`
|
|
2195
2216
|
Usage
|
|
2196
2217
|
$ ${name} <org slug> <scan ID> <path to output file>
|
|
2197
2218
|
|
|
2198
2219
|
Options
|
|
2199
|
-
${(0, _formatting$
|
|
2220
|
+
${(0, _formatting$8.printFlagList)(flags, 6)}
|
|
2200
2221
|
|
|
2201
2222
|
Examples
|
|
2202
2223
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
|
|
@@ -2211,7 +2232,7 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
2211
2232
|
markdown: outputMarkdown
|
|
2212
2233
|
} = cli.flags;
|
|
2213
2234
|
if (cli.input.length < 2) {
|
|
2214
|
-
console.error(`${_chalk$
|
|
2235
|
+
console.error(`${_chalk$a.default.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2215
2236
|
cli.showHelp();
|
|
2216
2237
|
return;
|
|
2217
2238
|
}
|
|
@@ -2229,10 +2250,10 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
2229
2250
|
};
|
|
2230
2251
|
}
|
|
2231
2252
|
async function getOrgFullScan(orgSlug, fullScanId, file, spinner, apiKey) {
|
|
2232
|
-
const socketSdk = await (0, _sdk$
|
|
2233
|
-
const result = await (0, _apiHelpers$
|
|
2253
|
+
const socketSdk = await (0, _sdk$9.setupSdk)(apiKey);
|
|
2254
|
+
const result = await (0, _apiHelpers$9.handleApiCall)(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a scan');
|
|
2234
2255
|
if (!result?.success) {
|
|
2235
|
-
(0, _apiHelpers$
|
|
2256
|
+
(0, _apiHelpers$9.handleUnsuccessfulApiResponse)('getOrgFullScan', result, spinner);
|
|
2236
2257
|
return;
|
|
2237
2258
|
}
|
|
2238
2259
|
spinner.stop();
|
|
@@ -2248,14 +2269,14 @@ var _delete$2 = _delete$3;
|
|
|
2248
2269
|
var _list$1 = list$3;
|
|
2249
2270
|
var _metadata = metadata$1;
|
|
2250
2271
|
var _stream = stream$1;
|
|
2251
|
-
var _meowWithSubcommands$
|
|
2252
|
-
const description$
|
|
2272
|
+
var _meowWithSubcommands$3 = meowWithSubcommands$1;
|
|
2273
|
+
const description$2 = 'Scans related commands';
|
|
2253
2274
|
scan.scan = {
|
|
2254
|
-
description: description$
|
|
2275
|
+
description: description$2,
|
|
2255
2276
|
run: async (argv, importMeta, {
|
|
2256
2277
|
parentName
|
|
2257
2278
|
}) => {
|
|
2258
|
-
await (0, _meowWithSubcommands$
|
|
2279
|
+
await (0, _meowWithSubcommands$3.meowWithSubcommands)({
|
|
2259
2280
|
create: _create$1.create,
|
|
2260
2281
|
stream: _stream.stream,
|
|
2261
2282
|
list: _list$1.list,
|
|
@@ -2263,7 +2284,7 @@ scan.scan = {
|
|
|
2263
2284
|
metadata: _metadata.metadata
|
|
2264
2285
|
}, {
|
|
2265
2286
|
argv,
|
|
2266
|
-
description: description$
|
|
2287
|
+
description: description$2,
|
|
2267
2288
|
importMeta,
|
|
2268
2289
|
name: parentName + ' scan'
|
|
2269
2290
|
});
|
|
@@ -2272,33 +2293,33 @@ scan.scan = {
|
|
|
2272
2293
|
|
|
2273
2294
|
var auditLog$1 = {};
|
|
2274
2295
|
|
|
2275
|
-
var _interopRequireDefault$
|
|
2296
|
+
var _interopRequireDefault$9 = vendor.interopRequireDefault.default;
|
|
2276
2297
|
Object.defineProperty(auditLog$1, "__esModule", {
|
|
2277
2298
|
value: true
|
|
2278
2299
|
});
|
|
2279
2300
|
auditLog$1.auditLog = void 0;
|
|
2280
2301
|
var _prompts = require$$1$1;
|
|
2281
|
-
var _chalk$
|
|
2282
|
-
var _meow$
|
|
2283
|
-
var _ora$
|
|
2284
|
-
var _flags$
|
|
2285
|
-
var _apiHelpers$
|
|
2286
|
-
var _formatting$
|
|
2287
|
-
var _sdk$
|
|
2288
|
-
var _errors$
|
|
2302
|
+
var _chalk$9 = _interopRequireDefault$9(vendor.source);
|
|
2303
|
+
var _meow$8 = _interopRequireDefault$9(vendor.build);
|
|
2304
|
+
var _ora$8 = _interopRequireDefault$9(vendor.ora);
|
|
2305
|
+
var _flags$7 = flags;
|
|
2306
|
+
var _apiHelpers$8 = apiHelpers;
|
|
2307
|
+
var _formatting$7 = formatting;
|
|
2308
|
+
var _sdk$8 = sdk.sdk;
|
|
2309
|
+
var _errors$9 = sdk.errors;
|
|
2289
2310
|
const auditLog = auditLog$1.auditLog = {
|
|
2290
2311
|
description: 'Look up the audit log for an organization',
|
|
2291
2312
|
async run(argv, importMeta, {
|
|
2292
2313
|
parentName
|
|
2293
2314
|
}) {
|
|
2294
2315
|
const name = parentName + ' audit-log';
|
|
2295
|
-
const input = setupCommand$
|
|
2316
|
+
const input = setupCommand$8(name, auditLog.description, argv, importMeta);
|
|
2296
2317
|
if (input) {
|
|
2297
|
-
const apiKey = (0, _sdk$
|
|
2318
|
+
const apiKey = (0, _sdk$8.getDefaultKey)();
|
|
2298
2319
|
if (!apiKey) {
|
|
2299
|
-
throw new _errors$
|
|
2320
|
+
throw new _errors$9.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2300
2321
|
}
|
|
2301
|
-
const spinner = (0, _ora$
|
|
2322
|
+
const spinner = (0, _ora$8.default)(`Looking up audit log for ${input.orgSlug}\n`).start();
|
|
2302
2323
|
await fetchOrgAuditLog(input.orgSlug, input, spinner, apiKey);
|
|
2303
2324
|
}
|
|
2304
2325
|
}
|
|
@@ -2326,17 +2347,17 @@ const auditLogFlags = {
|
|
|
2326
2347
|
|
|
2327
2348
|
// Internal functions
|
|
2328
2349
|
|
|
2329
|
-
function setupCommand$
|
|
2350
|
+
function setupCommand$8(name, description, argv, importMeta) {
|
|
2330
2351
|
const flags = {
|
|
2331
2352
|
...auditLogFlags,
|
|
2332
|
-
..._flags$
|
|
2353
|
+
..._flags$7.outputFlags
|
|
2333
2354
|
};
|
|
2334
|
-
const cli = (0, _meow$
|
|
2355
|
+
const cli = (0, _meow$8.default)(`
|
|
2335
2356
|
Usage
|
|
2336
2357
|
$ ${name} <org slug>
|
|
2337
2358
|
|
|
2338
2359
|
Options
|
|
2339
|
-
${(0, _formatting$
|
|
2360
|
+
${(0, _formatting$7.printFlagList)(flags, 6)}
|
|
2340
2361
|
|
|
2341
2362
|
Examples
|
|
2342
2363
|
$ ${name} FakeOrg
|
|
@@ -2354,7 +2375,7 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
2354
2375
|
} = cli.flags;
|
|
2355
2376
|
const type = cli.flags['type'];
|
|
2356
2377
|
if (cli.input.length < 1) {
|
|
2357
|
-
console.error(`${_chalk$
|
|
2378
|
+
console.error(`${_chalk$9.default.bgRed('Input error')}: Please provide an organization slug \n`);
|
|
2358
2379
|
cli.showHelp();
|
|
2359
2380
|
return;
|
|
2360
2381
|
}
|
|
@@ -2369,10 +2390,10 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
2369
2390
|
};
|
|
2370
2391
|
}
|
|
2371
2392
|
async function fetchOrgAuditLog(orgSlug, input, spinner, apiKey) {
|
|
2372
|
-
const socketSdk = await (0, _sdk$
|
|
2373
|
-
const result = await (0, _apiHelpers$
|
|
2393
|
+
const socketSdk = await (0, _sdk$8.setupSdk)(apiKey);
|
|
2394
|
+
const result = await (0, _apiHelpers$8.handleApiCall)(socketSdk.getAuditLogEvents(orgSlug, input), `Looking up audit log for ${orgSlug}\n`);
|
|
2374
2395
|
if (!result.success) {
|
|
2375
|
-
(0, _apiHelpers$
|
|
2396
|
+
(0, _apiHelpers$8.handleUnsuccessfulApiResponse)('getAuditLogEvents', result, spinner);
|
|
2376
2397
|
return;
|
|
2377
2398
|
}
|
|
2378
2399
|
spinner.stop();
|
|
@@ -2405,33 +2426,33 @@ var repos = {};
|
|
|
2405
2426
|
|
|
2406
2427
|
var create$1 = {};
|
|
2407
2428
|
|
|
2408
|
-
var _interopRequireDefault$
|
|
2429
|
+
var _interopRequireDefault$8 = vendor.interopRequireDefault.default;
|
|
2409
2430
|
Object.defineProperty(create$1, "__esModule", {
|
|
2410
2431
|
value: true
|
|
2411
2432
|
});
|
|
2412
2433
|
create$1.create = void 0;
|
|
2413
|
-
var _chalk$
|
|
2414
|
-
var _meow$
|
|
2415
|
-
var _ora$
|
|
2416
|
-
var _flags$
|
|
2417
|
-
var _apiHelpers$
|
|
2418
|
-
var _formatting$
|
|
2419
|
-
var _sdk$
|
|
2420
|
-
var _errors$
|
|
2434
|
+
var _chalk$8 = _interopRequireDefault$8(vendor.source);
|
|
2435
|
+
var _meow$7 = _interopRequireDefault$8(vendor.build);
|
|
2436
|
+
var _ora$7 = _interopRequireDefault$8(vendor.ora);
|
|
2437
|
+
var _flags$6 = flags;
|
|
2438
|
+
var _apiHelpers$7 = apiHelpers;
|
|
2439
|
+
var _formatting$6 = formatting;
|
|
2440
|
+
var _sdk$7 = sdk.sdk;
|
|
2441
|
+
var _errors$8 = sdk.errors;
|
|
2421
2442
|
const create = create$1.create = {
|
|
2422
2443
|
description: 'Create a repository in an organization',
|
|
2423
2444
|
async run(argv, importMeta, {
|
|
2424
2445
|
parentName
|
|
2425
2446
|
}) {
|
|
2426
2447
|
const name = `${parentName} create`;
|
|
2427
|
-
const input = setupCommand$
|
|
2448
|
+
const input = setupCommand$7(name, create.description, argv, importMeta);
|
|
2428
2449
|
if (input) {
|
|
2429
|
-
const apiKey = (0, _sdk$
|
|
2450
|
+
const apiKey = (0, _sdk$7.getDefaultKey)();
|
|
2430
2451
|
if (!apiKey) {
|
|
2431
|
-
throw new _errors$
|
|
2452
|
+
throw new _errors$8.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2432
2453
|
}
|
|
2433
2454
|
const spinnerText = 'Creating repository... \n';
|
|
2434
|
-
const spinner = (0, _ora$
|
|
2455
|
+
const spinner = (0, _ora$7.default)(spinnerText).start();
|
|
2435
2456
|
await createRepo(input.orgSlug, input, spinner, apiKey);
|
|
2436
2457
|
}
|
|
2437
2458
|
}
|
|
@@ -2471,17 +2492,17 @@ const repositoryCreationFlags = {
|
|
|
2471
2492
|
|
|
2472
2493
|
// Internal functions
|
|
2473
2494
|
|
|
2474
|
-
function setupCommand$
|
|
2495
|
+
function setupCommand$7(name, description, argv, importMeta) {
|
|
2475
2496
|
const flags = {
|
|
2476
|
-
..._flags$
|
|
2497
|
+
..._flags$6.outputFlags,
|
|
2477
2498
|
...repositoryCreationFlags
|
|
2478
2499
|
};
|
|
2479
|
-
const cli = (0, _meow$
|
|
2500
|
+
const cli = (0, _meow$7.default)(`
|
|
2480
2501
|
Usage
|
|
2481
2502
|
$ ${name} <org slug>
|
|
2482
2503
|
|
|
2483
2504
|
Options
|
|
2484
|
-
${(0, _formatting$
|
|
2505
|
+
${(0, _formatting$6.printFlagList)(flags, 6)}
|
|
2485
2506
|
|
|
2486
2507
|
Examples
|
|
2487
2508
|
$ ${name} FakeOrg --repoName=test-repo
|
|
@@ -2502,12 +2523,12 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
2502
2523
|
} = cli.flags;
|
|
2503
2524
|
const [orgSlug = ''] = cli.input;
|
|
2504
2525
|
if (!orgSlug) {
|
|
2505
|
-
console.error(`${_chalk$
|
|
2526
|
+
console.error(`${_chalk$8.default.bgRed('Input error')}: Please provide an organization slug \n`);
|
|
2506
2527
|
cli.showHelp();
|
|
2507
2528
|
return;
|
|
2508
2529
|
}
|
|
2509
2530
|
if (!repoName) {
|
|
2510
|
-
console.error(`${_chalk$
|
|
2531
|
+
console.error(`${_chalk$8.default.bgRed('Input error')}: Repository name is required. \n`);
|
|
2511
2532
|
cli.showHelp();
|
|
2512
2533
|
return;
|
|
2513
2534
|
}
|
|
@@ -2523,10 +2544,10 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
2523
2544
|
};
|
|
2524
2545
|
}
|
|
2525
2546
|
async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
2526
|
-
const socketSdk = await (0, _sdk$
|
|
2527
|
-
const result = await (0, _apiHelpers$
|
|
2547
|
+
const socketSdk = await (0, _sdk$7.setupSdk)(apiKey);
|
|
2548
|
+
const result = await (0, _apiHelpers$7.handleApiCall)(socketSdk.createOrgRepo(orgSlug, input), 'creating repository');
|
|
2528
2549
|
if (!result.success) {
|
|
2529
|
-
(0, _apiHelpers$
|
|
2550
|
+
(0, _apiHelpers$7.handleUnsuccessfulApiResponse)('createOrgRepo', result, spinner);
|
|
2530
2551
|
return;
|
|
2531
2552
|
}
|
|
2532
2553
|
spinner.stop();
|
|
@@ -2535,31 +2556,31 @@ async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
|
2535
2556
|
|
|
2536
2557
|
var _delete$1 = {};
|
|
2537
2558
|
|
|
2538
|
-
var _interopRequireDefault$
|
|
2559
|
+
var _interopRequireDefault$7 = vendor.interopRequireDefault.default;
|
|
2539
2560
|
Object.defineProperty(_delete$1, "__esModule", {
|
|
2540
2561
|
value: true
|
|
2541
2562
|
});
|
|
2542
2563
|
_delete$1.del = void 0;
|
|
2543
|
-
var _chalk$
|
|
2544
|
-
var _meow$
|
|
2545
|
-
var _ora$
|
|
2546
|
-
var _apiHelpers$
|
|
2547
|
-
var _sdk$
|
|
2548
|
-
var _errors$
|
|
2564
|
+
var _chalk$7 = _interopRequireDefault$7(vendor.source);
|
|
2565
|
+
var _meow$6 = _interopRequireDefault$7(vendor.build);
|
|
2566
|
+
var _ora$6 = _interopRequireDefault$7(vendor.ora);
|
|
2567
|
+
var _apiHelpers$6 = apiHelpers;
|
|
2568
|
+
var _sdk$6 = sdk.sdk;
|
|
2569
|
+
var _errors$7 = sdk.errors;
|
|
2549
2570
|
const del = _delete$1.del = {
|
|
2550
2571
|
description: 'Delete a repository in an organization',
|
|
2551
2572
|
async run(argv, importMeta, {
|
|
2552
2573
|
parentName
|
|
2553
2574
|
}) {
|
|
2554
2575
|
const name = `${parentName} del`;
|
|
2555
|
-
const input = setupCommand$
|
|
2576
|
+
const input = setupCommand$6(name, del.description, argv, importMeta);
|
|
2556
2577
|
if (input) {
|
|
2557
|
-
const apiKey = (0, _sdk$
|
|
2578
|
+
const apiKey = (0, _sdk$6.getDefaultKey)();
|
|
2558
2579
|
if (!apiKey) {
|
|
2559
|
-
throw new _errors$
|
|
2580
|
+
throw new _errors$7.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2560
2581
|
}
|
|
2561
2582
|
const spinnerText = 'Deleting repository... \n';
|
|
2562
|
-
const spinner = (0, _ora$
|
|
2583
|
+
const spinner = (0, _ora$6.default)(spinnerText).start();
|
|
2563
2584
|
await deleteRepository(input.orgSlug, input.repoName, spinner, apiKey);
|
|
2564
2585
|
}
|
|
2565
2586
|
}
|
|
@@ -2567,8 +2588,8 @@ const del = _delete$1.del = {
|
|
|
2567
2588
|
|
|
2568
2589
|
// Internal functions
|
|
2569
2590
|
|
|
2570
|
-
function setupCommand$
|
|
2571
|
-
const cli = (0, _meow$
|
|
2591
|
+
function setupCommand$6(name, description, argv, importMeta) {
|
|
2592
|
+
const cli = (0, _meow$6.default)(`
|
|
2572
2593
|
Usage
|
|
2573
2594
|
$ ${name} <org slug> <repo slug>
|
|
2574
2595
|
|
|
@@ -2584,7 +2605,7 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
2584
2605
|
1: repoName = ''
|
|
2585
2606
|
} = cli.input;
|
|
2586
2607
|
if (!orgSlug || !repoName) {
|
|
2587
|
-
console.error(`${_chalk$
|
|
2608
|
+
console.error(`${_chalk$7.default.bgRed('Input error')}: Please provide an organization slug and repository slug \n`);
|
|
2588
2609
|
cli.showHelp();
|
|
2589
2610
|
return;
|
|
2590
2611
|
}
|
|
@@ -2594,10 +2615,10 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
2594
2615
|
};
|
|
2595
2616
|
}
|
|
2596
2617
|
async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
|
|
2597
|
-
const socketSdk = await (0, _sdk$
|
|
2598
|
-
const result = await (0, _apiHelpers$
|
|
2618
|
+
const socketSdk = await (0, _sdk$6.setupSdk)(apiKey);
|
|
2619
|
+
const result = await (0, _apiHelpers$6.handleApiCall)(socketSdk.deleteOrgRepo(orgSlug, repoName), 'deleting repository');
|
|
2599
2620
|
if (!result.success) {
|
|
2600
|
-
(0, _apiHelpers$
|
|
2621
|
+
(0, _apiHelpers$6.handleUnsuccessfulApiResponse)('deleteOrgRepo', result, spinner);
|
|
2601
2622
|
return;
|
|
2602
2623
|
}
|
|
2603
2624
|
spinner.stop();
|
|
@@ -2606,20 +2627,20 @@ async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
|
|
|
2606
2627
|
|
|
2607
2628
|
var list$1 = {};
|
|
2608
2629
|
|
|
2609
|
-
var _interopRequireDefault$
|
|
2630
|
+
var _interopRequireDefault$6 = vendor.interopRequireDefault.default;
|
|
2610
2631
|
Object.defineProperty(list$1, "__esModule", {
|
|
2611
2632
|
value: true
|
|
2612
2633
|
});
|
|
2613
2634
|
list$1.list = void 0;
|
|
2614
|
-
var _chalk$
|
|
2635
|
+
var _chalk$6 = _interopRequireDefault$6(vendor.source);
|
|
2615
2636
|
var _chalkTable$2 = require$$2$2;
|
|
2616
|
-
var _meow$
|
|
2617
|
-
var _ora$
|
|
2618
|
-
var _flags$
|
|
2619
|
-
var _apiHelpers$
|
|
2620
|
-
var _formatting$
|
|
2621
|
-
var _sdk$
|
|
2622
|
-
var _errors$
|
|
2637
|
+
var _meow$5 = _interopRequireDefault$6(vendor.build);
|
|
2638
|
+
var _ora$5 = _interopRequireDefault$6(vendor.ora);
|
|
2639
|
+
var _flags$5 = flags;
|
|
2640
|
+
var _apiHelpers$5 = apiHelpers;
|
|
2641
|
+
var _formatting$5 = formatting;
|
|
2642
|
+
var _sdk$5 = sdk.sdk;
|
|
2643
|
+
var _errors$6 = sdk.errors;
|
|
2623
2644
|
// @ts-ignore
|
|
2624
2645
|
|
|
2625
2646
|
const list = list$1.list = {
|
|
@@ -2628,14 +2649,14 @@ const list = list$1.list = {
|
|
|
2628
2649
|
parentName
|
|
2629
2650
|
}) {
|
|
2630
2651
|
const name = `${parentName} list`;
|
|
2631
|
-
const input = setupCommand$
|
|
2652
|
+
const input = setupCommand$5(name, list.description, argv, importMeta);
|
|
2632
2653
|
if (input) {
|
|
2633
|
-
const apiKey = (0, _sdk$
|
|
2654
|
+
const apiKey = (0, _sdk$5.getDefaultKey)();
|
|
2634
2655
|
if (!apiKey) {
|
|
2635
|
-
throw new _errors$
|
|
2656
|
+
throw new _errors$6.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2636
2657
|
}
|
|
2637
2658
|
const spinnerText = 'Listing repositories... \n';
|
|
2638
|
-
const spinner = (0, _ora$
|
|
2659
|
+
const spinner = (0, _ora$5.default)(spinnerText).start();
|
|
2639
2660
|
await listOrgRepos(input.orgSlug, input, spinner, apiKey);
|
|
2640
2661
|
}
|
|
2641
2662
|
}
|
|
@@ -2668,17 +2689,17 @@ const listRepoFlags = {
|
|
|
2668
2689
|
|
|
2669
2690
|
// Internal functions
|
|
2670
2691
|
|
|
2671
|
-
function setupCommand$
|
|
2692
|
+
function setupCommand$5(name, description, argv, importMeta) {
|
|
2672
2693
|
const flags = {
|
|
2673
|
-
..._flags$
|
|
2694
|
+
..._flags$5.outputFlags,
|
|
2674
2695
|
...listRepoFlags
|
|
2675
2696
|
};
|
|
2676
|
-
const cli = (0, _meow$
|
|
2697
|
+
const cli = (0, _meow$5.default)(`
|
|
2677
2698
|
Usage
|
|
2678
2699
|
$ ${name} <org slug>
|
|
2679
2700
|
|
|
2680
2701
|
Options
|
|
2681
|
-
${(0, _formatting$
|
|
2702
|
+
${(0, _formatting$5.printFlagList)(flags, 6)}
|
|
2682
2703
|
|
|
2683
2704
|
Examples
|
|
2684
2705
|
$ ${name} FakeOrg
|
|
@@ -2697,7 +2718,7 @@ function setupCommand$3(name, description, argv, importMeta) {
|
|
|
2697
2718
|
page
|
|
2698
2719
|
} = cli.flags;
|
|
2699
2720
|
if (!cli.input[0]) {
|
|
2700
|
-
console.error(`${_chalk$
|
|
2721
|
+
console.error(`${_chalk$6.default.bgRed('Input error')}: Please provide an organization slug \n`);
|
|
2701
2722
|
cli.showHelp();
|
|
2702
2723
|
return;
|
|
2703
2724
|
}
|
|
@@ -2715,29 +2736,29 @@ function setupCommand$3(name, description, argv, importMeta) {
|
|
|
2715
2736
|
};
|
|
2716
2737
|
}
|
|
2717
2738
|
async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
2718
|
-
const socketSdk = await (0, _sdk$
|
|
2719
|
-
const result = await (0, _apiHelpers$
|
|
2739
|
+
const socketSdk = await (0, _sdk$5.setupSdk)(apiKey);
|
|
2740
|
+
const result = await (0, _apiHelpers$5.handleApiCall)(socketSdk.getOrgRepoList(orgSlug, input), 'listing repositories');
|
|
2720
2741
|
if (!result.success) {
|
|
2721
|
-
(0, _apiHelpers$
|
|
2742
|
+
(0, _apiHelpers$5.handleUnsuccessfulApiResponse)('getOrgRepoList', result, spinner);
|
|
2722
2743
|
return;
|
|
2723
2744
|
}
|
|
2724
2745
|
spinner.stop();
|
|
2725
2746
|
const options = {
|
|
2726
2747
|
columns: [{
|
|
2727
2748
|
field: 'id',
|
|
2728
|
-
name: _chalk$
|
|
2749
|
+
name: _chalk$6.default.magenta('ID')
|
|
2729
2750
|
}, {
|
|
2730
2751
|
field: 'name',
|
|
2731
|
-
name: _chalk$
|
|
2752
|
+
name: _chalk$6.default.magenta('Name')
|
|
2732
2753
|
}, {
|
|
2733
2754
|
field: 'visibility',
|
|
2734
|
-
name: _chalk$
|
|
2755
|
+
name: _chalk$6.default.magenta('Visibility')
|
|
2735
2756
|
}, {
|
|
2736
2757
|
field: 'default_branch',
|
|
2737
|
-
name: _chalk$
|
|
2758
|
+
name: _chalk$6.default.magenta('Default branch')
|
|
2738
2759
|
}, {
|
|
2739
2760
|
field: 'archived',
|
|
2740
|
-
name: _chalk$
|
|
2761
|
+
name: _chalk$6.default.magenta('Archived')
|
|
2741
2762
|
}]
|
|
2742
2763
|
};
|
|
2743
2764
|
console.log(`${_chalkTable$2(options, result.data.results)}\n`);
|
|
@@ -2745,33 +2766,33 @@ async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
|
2745
2766
|
|
|
2746
2767
|
var update$1 = {};
|
|
2747
2768
|
|
|
2748
|
-
var _interopRequireDefault$
|
|
2769
|
+
var _interopRequireDefault$5 = vendor.interopRequireDefault.default;
|
|
2749
2770
|
Object.defineProperty(update$1, "__esModule", {
|
|
2750
2771
|
value: true
|
|
2751
2772
|
});
|
|
2752
2773
|
update$1.update = void 0;
|
|
2753
|
-
var _chalk$
|
|
2754
|
-
var _meow$
|
|
2755
|
-
var _ora$
|
|
2756
|
-
var _flags$
|
|
2757
|
-
var _apiHelpers$
|
|
2758
|
-
var _formatting$
|
|
2759
|
-
var _sdk$
|
|
2760
|
-
var _errors$
|
|
2774
|
+
var _chalk$5 = _interopRequireDefault$5(vendor.source);
|
|
2775
|
+
var _meow$4 = _interopRequireDefault$5(vendor.build);
|
|
2776
|
+
var _ora$4 = _interopRequireDefault$5(vendor.ora);
|
|
2777
|
+
var _flags$4 = flags;
|
|
2778
|
+
var _apiHelpers$4 = apiHelpers;
|
|
2779
|
+
var _formatting$4 = formatting;
|
|
2780
|
+
var _sdk$4 = sdk.sdk;
|
|
2781
|
+
var _errors$5 = sdk.errors;
|
|
2761
2782
|
const update = update$1.update = {
|
|
2762
2783
|
description: 'Update a repository in an organization',
|
|
2763
2784
|
async run(argv, importMeta, {
|
|
2764
2785
|
parentName
|
|
2765
2786
|
}) {
|
|
2766
2787
|
const name = `${parentName} update`;
|
|
2767
|
-
const input = setupCommand$
|
|
2788
|
+
const input = setupCommand$4(name, update.description, argv, importMeta);
|
|
2768
2789
|
if (input) {
|
|
2769
|
-
const apiKey = (0, _sdk$
|
|
2790
|
+
const apiKey = (0, _sdk$4.getDefaultKey)();
|
|
2770
2791
|
if (!apiKey) {
|
|
2771
|
-
throw new _errors$
|
|
2792
|
+
throw new _errors$5.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2772
2793
|
}
|
|
2773
2794
|
const spinnerText = 'Updating repository... \n';
|
|
2774
|
-
const spinner = (0, _ora$
|
|
2795
|
+
const spinner = (0, _ora$4.default)(spinnerText).start();
|
|
2775
2796
|
await updateRepository(input.orgSlug, input, spinner, apiKey);
|
|
2776
2797
|
}
|
|
2777
2798
|
}
|
|
@@ -2811,17 +2832,17 @@ const repositoryUpdateFlags = {
|
|
|
2811
2832
|
|
|
2812
2833
|
// Internal functions
|
|
2813
2834
|
|
|
2814
|
-
function setupCommand$
|
|
2835
|
+
function setupCommand$4(name, description, argv, importMeta) {
|
|
2815
2836
|
const flags = {
|
|
2816
|
-
..._flags$
|
|
2837
|
+
..._flags$4.outputFlags,
|
|
2817
2838
|
...repositoryUpdateFlags
|
|
2818
2839
|
};
|
|
2819
|
-
const cli = (0, _meow$
|
|
2840
|
+
const cli = (0, _meow$4.default)(`
|
|
2820
2841
|
Usage
|
|
2821
2842
|
$ ${name} <org slug>
|
|
2822
2843
|
|
|
2823
2844
|
Options
|
|
2824
|
-
${(0, _formatting$
|
|
2845
|
+
${(0, _formatting$4.printFlagList)(flags, 6)}
|
|
2825
2846
|
|
|
2826
2847
|
Examples
|
|
2827
2848
|
$ ${name} FakeOrg
|
|
@@ -2842,12 +2863,12 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
2842
2863
|
} = cli.flags;
|
|
2843
2864
|
const [orgSlug = ''] = cli.input;
|
|
2844
2865
|
if (!orgSlug) {
|
|
2845
|
-
console.error(`${_chalk$
|
|
2866
|
+
console.error(`${_chalk$5.default.bgRed('Input error')}: Please provide an organization slug and repository name \n`);
|
|
2846
2867
|
cli.showHelp();
|
|
2847
2868
|
return;
|
|
2848
2869
|
}
|
|
2849
2870
|
if (!repoName) {
|
|
2850
|
-
console.error(`${_chalk$
|
|
2871
|
+
console.error(`${_chalk$5.default.bgRed('Input error')}: Repository name is required. \n`);
|
|
2851
2872
|
cli.showHelp();
|
|
2852
2873
|
return;
|
|
2853
2874
|
}
|
|
@@ -2863,10 +2884,10 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
2863
2884
|
};
|
|
2864
2885
|
}
|
|
2865
2886
|
async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
2866
|
-
const socketSdk = await (0, _sdk$
|
|
2867
|
-
const result = await (0, _apiHelpers$
|
|
2887
|
+
const socketSdk = await (0, _sdk$4.setupSdk)(apiKey);
|
|
2888
|
+
const result = await (0, _apiHelpers$4.handleApiCall)(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'updating repository');
|
|
2868
2889
|
if (!result.success) {
|
|
2869
|
-
(0, _apiHelpers$
|
|
2890
|
+
(0, _apiHelpers$4.handleUnsuccessfulApiResponse)('updateOrgRepo', result, spinner);
|
|
2870
2891
|
return;
|
|
2871
2892
|
}
|
|
2872
2893
|
spinner.stop();
|
|
@@ -2875,20 +2896,20 @@ async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
|
2875
2896
|
|
|
2876
2897
|
var view$1 = {};
|
|
2877
2898
|
|
|
2878
|
-
var _interopRequireDefault$
|
|
2899
|
+
var _interopRequireDefault$4 = vendor.interopRequireDefault.default;
|
|
2879
2900
|
Object.defineProperty(view$1, "__esModule", {
|
|
2880
2901
|
value: true
|
|
2881
2902
|
});
|
|
2882
2903
|
view$1.view = void 0;
|
|
2883
|
-
var _chalk$
|
|
2904
|
+
var _chalk$4 = _interopRequireDefault$4(vendor.source);
|
|
2884
2905
|
var _chalkTable$1 = require$$2$2;
|
|
2885
|
-
var _meow$
|
|
2886
|
-
var _ora$
|
|
2887
|
-
var _flags$
|
|
2888
|
-
var _apiHelpers$
|
|
2889
|
-
var _formatting$
|
|
2890
|
-
var _sdk$
|
|
2891
|
-
var _errors$
|
|
2906
|
+
var _meow$3 = _interopRequireDefault$4(vendor.build);
|
|
2907
|
+
var _ora$3 = _interopRequireDefault$4(vendor.ora);
|
|
2908
|
+
var _flags$3 = flags;
|
|
2909
|
+
var _apiHelpers$3 = apiHelpers;
|
|
2910
|
+
var _formatting$3 = formatting;
|
|
2911
|
+
var _sdk$3 = sdk.sdk;
|
|
2912
|
+
var _errors$4 = sdk.errors;
|
|
2892
2913
|
// @ts-ignore
|
|
2893
2914
|
|
|
2894
2915
|
const view = view$1.view = {
|
|
@@ -2897,14 +2918,14 @@ const view = view$1.view = {
|
|
|
2897
2918
|
parentName
|
|
2898
2919
|
}) {
|
|
2899
2920
|
const name = `${parentName} view`;
|
|
2900
|
-
const input = setupCommand$
|
|
2921
|
+
const input = setupCommand$3(name, view.description, argv, importMeta);
|
|
2901
2922
|
if (input) {
|
|
2902
|
-
const apiKey = (0, _sdk$
|
|
2923
|
+
const apiKey = (0, _sdk$3.getDefaultKey)();
|
|
2903
2924
|
if (!apiKey) {
|
|
2904
|
-
throw new _errors$
|
|
2925
|
+
throw new _errors$4.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2905
2926
|
}
|
|
2906
2927
|
const spinnerText = 'Fetching repository... \n';
|
|
2907
|
-
const spinner = (0, _ora$
|
|
2928
|
+
const spinner = (0, _ora$3.default)(spinnerText).start();
|
|
2908
2929
|
await viewRepository(input.orgSlug, input.repositoryName, spinner, apiKey);
|
|
2909
2930
|
}
|
|
2910
2931
|
}
|
|
@@ -2912,16 +2933,16 @@ const view = view$1.view = {
|
|
|
2912
2933
|
|
|
2913
2934
|
// Internal functions
|
|
2914
2935
|
|
|
2915
|
-
function setupCommand$
|
|
2936
|
+
function setupCommand$3(name, description, argv, importMeta) {
|
|
2916
2937
|
const flags = {
|
|
2917
|
-
..._flags$
|
|
2938
|
+
..._flags$3.outputFlags
|
|
2918
2939
|
};
|
|
2919
|
-
const cli = (0, _meow$
|
|
2940
|
+
const cli = (0, _meow$3.default)(`
|
|
2920
2941
|
Usage
|
|
2921
2942
|
$ ${name} <org slug>
|
|
2922
2943
|
|
|
2923
2944
|
Options
|
|
2924
|
-
${(0, _formatting$
|
|
2945
|
+
${(0, _formatting$3.printFlagList)(flags, 6)}
|
|
2925
2946
|
|
|
2926
2947
|
Examples
|
|
2927
2948
|
$ ${name} FakeOrg
|
|
@@ -2936,7 +2957,7 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
2936
2957
|
markdown: outputMarkdown
|
|
2937
2958
|
} = cli.flags;
|
|
2938
2959
|
if (!cli.input[0]) {
|
|
2939
|
-
console.error(`${_chalk$
|
|
2960
|
+
console.error(`${_chalk$4.default.bgRed('Input error')}: Please provide an organization slug and repository name \n`);
|
|
2940
2961
|
cli.showHelp();
|
|
2941
2962
|
return;
|
|
2942
2963
|
}
|
|
@@ -2952,35 +2973,35 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
2952
2973
|
};
|
|
2953
2974
|
}
|
|
2954
2975
|
async function viewRepository(orgSlug, repoName, spinner, apiKey) {
|
|
2955
|
-
const socketSdk = await (0, _sdk$
|
|
2956
|
-
const result = await (0, _apiHelpers$
|
|
2976
|
+
const socketSdk = await (0, _sdk$3.setupSdk)(apiKey);
|
|
2977
|
+
const result = await (0, _apiHelpers$3.handleApiCall)(socketSdk.getOrgRepo(orgSlug, repoName), 'fetching repository');
|
|
2957
2978
|
if (!result.success) {
|
|
2958
|
-
(0, _apiHelpers$
|
|
2979
|
+
(0, _apiHelpers$3.handleUnsuccessfulApiResponse)('getOrgRepo', result, spinner);
|
|
2959
2980
|
return;
|
|
2960
2981
|
}
|
|
2961
2982
|
spinner.stop();
|
|
2962
2983
|
const options = {
|
|
2963
2984
|
columns: [{
|
|
2964
2985
|
field: 'id',
|
|
2965
|
-
name: _chalk$
|
|
2986
|
+
name: _chalk$4.default.magenta('ID')
|
|
2966
2987
|
}, {
|
|
2967
2988
|
field: 'name',
|
|
2968
|
-
name: _chalk$
|
|
2989
|
+
name: _chalk$4.default.magenta('Name')
|
|
2969
2990
|
}, {
|
|
2970
2991
|
field: 'visibility',
|
|
2971
|
-
name: _chalk$
|
|
2992
|
+
name: _chalk$4.default.magenta('Visibility')
|
|
2972
2993
|
}, {
|
|
2973
2994
|
field: 'default_branch',
|
|
2974
|
-
name: _chalk$
|
|
2995
|
+
name: _chalk$4.default.magenta('Default branch')
|
|
2975
2996
|
}, {
|
|
2976
2997
|
field: 'homepage',
|
|
2977
|
-
name: _chalk$
|
|
2998
|
+
name: _chalk$4.default.magenta('Homepage')
|
|
2978
2999
|
}, {
|
|
2979
3000
|
field: 'archived',
|
|
2980
|
-
name: _chalk$
|
|
3001
|
+
name: _chalk$4.default.magenta('Archived')
|
|
2981
3002
|
}, {
|
|
2982
3003
|
field: 'created_at',
|
|
2983
|
-
name: _chalk$
|
|
3004
|
+
name: _chalk$4.default.magenta('Created at')
|
|
2984
3005
|
}]
|
|
2985
3006
|
};
|
|
2986
3007
|
console.log(`${_chalkTable$1(options, [result.data])}\n`);
|
|
@@ -2995,14 +3016,14 @@ var _delete = _delete$1;
|
|
|
2995
3016
|
var _list = list$1;
|
|
2996
3017
|
var _update = update$1;
|
|
2997
3018
|
var _view = view$1;
|
|
2998
|
-
var _meowWithSubcommands$
|
|
2999
|
-
const description = 'Repositories related commands';
|
|
3019
|
+
var _meowWithSubcommands$2 = meowWithSubcommands$1;
|
|
3020
|
+
const description$1 = 'Repositories related commands';
|
|
3000
3021
|
repos.repo = {
|
|
3001
|
-
description,
|
|
3022
|
+
description: description$1,
|
|
3002
3023
|
run: async (argv, importMeta, {
|
|
3003
3024
|
parentName
|
|
3004
3025
|
}) => {
|
|
3005
|
-
await (0, _meowWithSubcommands$
|
|
3026
|
+
await (0, _meowWithSubcommands$2.meowWithSubcommands)({
|
|
3006
3027
|
create: _create.create,
|
|
3007
3028
|
view: _view.view,
|
|
3008
3029
|
list: _list.list,
|
|
@@ -3010,7 +3031,7 @@ repos.repo = {
|
|
|
3010
3031
|
update: _update.update
|
|
3011
3032
|
}, {
|
|
3012
3033
|
argv,
|
|
3013
|
-
description,
|
|
3034
|
+
description: description$1,
|
|
3014
3035
|
importMeta,
|
|
3015
3036
|
name: `${parentName} repo`
|
|
3016
3037
|
});
|
|
@@ -3019,20 +3040,20 @@ repos.repo = {
|
|
|
3019
3040
|
|
|
3020
3041
|
var dependencies$1 = {};
|
|
3021
3042
|
|
|
3022
|
-
var _interopRequireDefault$
|
|
3043
|
+
var _interopRequireDefault$3 = vendor.interopRequireDefault.default;
|
|
3023
3044
|
Object.defineProperty(dependencies$1, "__esModule", {
|
|
3024
3045
|
value: true
|
|
3025
3046
|
});
|
|
3026
3047
|
dependencies$1.dependencies = void 0;
|
|
3027
|
-
var _chalk$
|
|
3048
|
+
var _chalk$3 = _interopRequireDefault$3(vendor.source);
|
|
3028
3049
|
var _chalkTable = require$$2$2;
|
|
3029
|
-
var _meow = _interopRequireDefault$
|
|
3030
|
-
var _ora = _interopRequireDefault$
|
|
3031
|
-
var _flags = flags;
|
|
3032
|
-
var _apiHelpers = apiHelpers;
|
|
3033
|
-
var _formatting = formatting;
|
|
3034
|
-
var _sdk = sdk.sdk;
|
|
3035
|
-
var _errors$
|
|
3050
|
+
var _meow$2 = _interopRequireDefault$3(vendor.build);
|
|
3051
|
+
var _ora$2 = _interopRequireDefault$3(vendor.ora);
|
|
3052
|
+
var _flags$2 = flags;
|
|
3053
|
+
var _apiHelpers$2 = apiHelpers;
|
|
3054
|
+
var _formatting$2 = formatting;
|
|
3055
|
+
var _sdk$2 = sdk.sdk;
|
|
3056
|
+
var _errors$3 = sdk.errors;
|
|
3036
3057
|
// @ts-ignore
|
|
3037
3058
|
|
|
3038
3059
|
const dependencies = dependencies$1.dependencies = {
|
|
@@ -3041,7 +3062,7 @@ const dependencies = dependencies$1.dependencies = {
|
|
|
3041
3062
|
parentName
|
|
3042
3063
|
}) {
|
|
3043
3064
|
const name = parentName + ' dependencies';
|
|
3044
|
-
const input = setupCommand(name, dependencies.description, argv, importMeta);
|
|
3065
|
+
const input = setupCommand$2(name, dependencies.description, argv, importMeta);
|
|
3045
3066
|
if (input) {
|
|
3046
3067
|
await searchDeps(input);
|
|
3047
3068
|
}
|
|
@@ -3064,17 +3085,17 @@ const dependenciesFlags = {
|
|
|
3064
3085
|
|
|
3065
3086
|
// Internal functions
|
|
3066
3087
|
|
|
3067
|
-
function setupCommand(name, description, argv, importMeta) {
|
|
3088
|
+
function setupCommand$2(name, description, argv, importMeta) {
|
|
3068
3089
|
const flags = {
|
|
3069
|
-
..._flags.outputFlags,
|
|
3090
|
+
..._flags$2.outputFlags,
|
|
3070
3091
|
...dependenciesFlags
|
|
3071
3092
|
};
|
|
3072
|
-
const cli = (0, _meow.default)(`
|
|
3093
|
+
const cli = (0, _meow$2.default)(`
|
|
3073
3094
|
Usage
|
|
3074
3095
|
$ ${name}
|
|
3075
3096
|
|
|
3076
3097
|
Options
|
|
3077
|
-
${(0, _formatting.printFlagList)(flags, 6)}
|
|
3098
|
+
${(0, _formatting$2.printFlagList)(flags, 6)}
|
|
3078
3099
|
|
|
3079
3100
|
Examples
|
|
3080
3101
|
$ ${name}
|
|
@@ -3102,19 +3123,19 @@ async function searchDeps({
|
|
|
3102
3123
|
offset,
|
|
3103
3124
|
outputJson
|
|
3104
3125
|
}) {
|
|
3105
|
-
const apiKey = (0, _sdk.getDefaultKey)();
|
|
3126
|
+
const apiKey = (0, _sdk$2.getDefaultKey)();
|
|
3106
3127
|
if (!apiKey) {
|
|
3107
|
-
throw new _errors$
|
|
3128
|
+
throw new _errors$3.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3108
3129
|
}
|
|
3109
3130
|
const spinnerText = 'Searching dependencies...';
|
|
3110
|
-
const spinner = (0, _ora.default)(spinnerText).start();
|
|
3111
|
-
const socketSdk = await (0, _sdk.setupSdk)(apiKey);
|
|
3112
|
-
const result = await (0, _apiHelpers.handleApiCall)(socketSdk.searchDependencies({
|
|
3131
|
+
const spinner = (0, _ora$2.default)(spinnerText).start();
|
|
3132
|
+
const socketSdk = await (0, _sdk$2.setupSdk)(apiKey);
|
|
3133
|
+
const result = await (0, _apiHelpers$2.handleApiCall)(socketSdk.searchDependencies({
|
|
3113
3134
|
limit,
|
|
3114
3135
|
offset
|
|
3115
3136
|
}), 'Searching dependencies');
|
|
3116
3137
|
if (!result.success) {
|
|
3117
|
-
(0, _apiHelpers.handleUnsuccessfulApiResponse)('searchDependencies', result, spinner);
|
|
3138
|
+
(0, _apiHelpers$2.handleUnsuccessfulApiResponse)('searchDependencies', result, spinner);
|
|
3118
3139
|
return;
|
|
3119
3140
|
}
|
|
3120
3141
|
spinner.stop();
|
|
@@ -3126,30 +3147,496 @@ async function searchDeps({
|
|
|
3126
3147
|
const options = {
|
|
3127
3148
|
columns: [{
|
|
3128
3149
|
field: 'namespace',
|
|
3129
|
-
name: _chalk$
|
|
3150
|
+
name: _chalk$3.default.cyan('Namespace')
|
|
3130
3151
|
}, {
|
|
3131
3152
|
field: 'name',
|
|
3132
|
-
name: _chalk$
|
|
3153
|
+
name: _chalk$3.default.cyan('Name')
|
|
3133
3154
|
}, {
|
|
3134
3155
|
field: 'version',
|
|
3135
|
-
name: _chalk$
|
|
3156
|
+
name: _chalk$3.default.cyan('Version')
|
|
3136
3157
|
}, {
|
|
3137
3158
|
field: 'repository',
|
|
3138
|
-
name: _chalk$
|
|
3159
|
+
name: _chalk$3.default.cyan('Repository')
|
|
3139
3160
|
}, {
|
|
3140
3161
|
field: 'branch',
|
|
3141
|
-
name: _chalk$
|
|
3162
|
+
name: _chalk$3.default.cyan('Branch')
|
|
3142
3163
|
}, {
|
|
3143
3164
|
field: 'type',
|
|
3144
|
-
name: _chalk$
|
|
3165
|
+
name: _chalk$3.default.cyan('Type')
|
|
3145
3166
|
}, {
|
|
3146
3167
|
field: 'direct',
|
|
3147
|
-
name: _chalk$
|
|
3168
|
+
name: _chalk$3.default.cyan('Direct')
|
|
3148
3169
|
}]
|
|
3149
3170
|
};
|
|
3150
3171
|
console.log(`${_chalkTable(options, result.data.rows)}\n`);
|
|
3151
3172
|
}
|
|
3152
3173
|
|
|
3174
|
+
var analytics$1 = {};
|
|
3175
|
+
|
|
3176
|
+
var _interopRequireDefault$2 = vendor.interopRequireDefault.default;
|
|
3177
|
+
Object.defineProperty(analytics$1, "__esModule", {
|
|
3178
|
+
value: true
|
|
3179
|
+
});
|
|
3180
|
+
analytics$1.analytics = void 0;
|
|
3181
|
+
var _blessed = require$$1$2;
|
|
3182
|
+
var _blessedContrib = require$$2$3;
|
|
3183
|
+
var _fs$1 = require$$0;
|
|
3184
|
+
var _meow$1 = _interopRequireDefault$2(vendor.build);
|
|
3185
|
+
var _ora$1 = _interopRequireDefault$2(vendor.ora);
|
|
3186
|
+
var _flags$1 = flags;
|
|
3187
|
+
var _apiHelpers$1 = apiHelpers;
|
|
3188
|
+
var _errors$2 = sdk.errors;
|
|
3189
|
+
var _formatting$1 = formatting;
|
|
3190
|
+
var _sdk$1 = sdk.sdk;
|
|
3191
|
+
var _chalk$2 = _interopRequireDefault$2(vendor.source);
|
|
3192
|
+
// @ts-ignore
|
|
3193
|
+
|
|
3194
|
+
// @ts-ignore
|
|
3195
|
+
|
|
3196
|
+
const analytics = analytics$1.analytics = {
|
|
3197
|
+
description: `Look up analytics data \n
|
|
3198
|
+
Default parameters are set to show the organization-level analytics over the last 7 days.`,
|
|
3199
|
+
async run(argv, importMeta, {
|
|
3200
|
+
parentName
|
|
3201
|
+
}) {
|
|
3202
|
+
const name = parentName + ' analytics';
|
|
3203
|
+
const input = setupCommand$1(name, analytics.description, argv, importMeta);
|
|
3204
|
+
if (input) {
|
|
3205
|
+
const apiKey = (0, _sdk$1.getDefaultKey)();
|
|
3206
|
+
if (!apiKey) {
|
|
3207
|
+
throw new _errors$2.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3208
|
+
}
|
|
3209
|
+
const spinner = (0, _ora$1.default)('Fetching analytics data').start();
|
|
3210
|
+
if (input.scope === 'org') {
|
|
3211
|
+
await fetchOrgAnalyticsData(input.time, spinner, apiKey, input.outputJson, input.file);
|
|
3212
|
+
} else {
|
|
3213
|
+
if (input.repo) {
|
|
3214
|
+
await fetchRepoAnalyticsData(input.repo, input.time, spinner, apiKey, input.outputJson, input.file);
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
};
|
|
3220
|
+
const analyticsFlags = {
|
|
3221
|
+
scope: {
|
|
3222
|
+
type: 'string',
|
|
3223
|
+
shortFlag: 's',
|
|
3224
|
+
default: 'org',
|
|
3225
|
+
description: "Scope of the analytics data - either 'org' or 'repo'"
|
|
3226
|
+
},
|
|
3227
|
+
time: {
|
|
3228
|
+
type: 'number',
|
|
3229
|
+
shortFlag: 't',
|
|
3230
|
+
default: 7,
|
|
3231
|
+
description: 'Time filter - either 7, 30 or 90'
|
|
3232
|
+
},
|
|
3233
|
+
repo: {
|
|
3234
|
+
type: 'string',
|
|
3235
|
+
shortFlag: 'r',
|
|
3236
|
+
default: '',
|
|
3237
|
+
description: "Name of the repository"
|
|
3238
|
+
},
|
|
3239
|
+
file: {
|
|
3240
|
+
type: 'string',
|
|
3241
|
+
shortFlag: 'f',
|
|
3242
|
+
default: '',
|
|
3243
|
+
description: "Path to a local file to save the output"
|
|
3244
|
+
}
|
|
3245
|
+
};
|
|
3246
|
+
|
|
3247
|
+
// Internal functions
|
|
3248
|
+
|
|
3249
|
+
function setupCommand$1(name, description, argv, importMeta) {
|
|
3250
|
+
const flags = {
|
|
3251
|
+
..._flags$1.outputFlags,
|
|
3252
|
+
...analyticsFlags
|
|
3253
|
+
};
|
|
3254
|
+
const cli = (0, _meow$1.default)(`
|
|
3255
|
+
Usage
|
|
3256
|
+
$ ${name} --scope=<scope> --time=<time filter>
|
|
3257
|
+
|
|
3258
|
+
Options
|
|
3259
|
+
${(0, _formatting$1.printFlagList)(flags, 6)}
|
|
3260
|
+
|
|
3261
|
+
Examples
|
|
3262
|
+
$ ${name} --scope=org --time=7
|
|
3263
|
+
$ ${name} --scope=org --time=30
|
|
3264
|
+
$ ${name} --scope=repo --repo=test-repo --time=30
|
|
3265
|
+
`, {
|
|
3266
|
+
argv,
|
|
3267
|
+
description,
|
|
3268
|
+
importMeta,
|
|
3269
|
+
flags
|
|
3270
|
+
});
|
|
3271
|
+
const {
|
|
3272
|
+
json: outputJson,
|
|
3273
|
+
scope,
|
|
3274
|
+
time,
|
|
3275
|
+
repo,
|
|
3276
|
+
file
|
|
3277
|
+
} = cli.flags;
|
|
3278
|
+
if (scope !== 'org' && scope !== 'repo') {
|
|
3279
|
+
throw new _errors$2.InputError("The scope must either be 'org' or 'repo'");
|
|
3280
|
+
}
|
|
3281
|
+
if (time !== 7 && time !== 30 && time !== 90) {
|
|
3282
|
+
throw new _errors$2.InputError('The time filter must either be 7, 30 or 90');
|
|
3283
|
+
}
|
|
3284
|
+
if (scope === 'repo' && !repo) {
|
|
3285
|
+
console.error(`${_chalk$2.default.bgRed.white('Input error')}: Please provide a repository name when using the repository scope. \n`);
|
|
3286
|
+
cli.showHelp();
|
|
3287
|
+
return;
|
|
3288
|
+
}
|
|
3289
|
+
return {
|
|
3290
|
+
scope,
|
|
3291
|
+
time,
|
|
3292
|
+
repo,
|
|
3293
|
+
outputJson,
|
|
3294
|
+
file
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
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'];
|
|
3298
|
+
async function fetchOrgAnalyticsData(time, spinner, apiKey, outputJson, filePath) {
|
|
3299
|
+
const socketSdk = await (0, _sdk$1.setupSdk)(apiKey);
|
|
3300
|
+
const result = await (0, _apiHelpers$1.handleApiCall)(socketSdk.getOrgAnalytics(time.toString()), 'fetching analytics data');
|
|
3301
|
+
if (result.success === false) {
|
|
3302
|
+
return (0, _apiHelpers$1.handleUnsuccessfulApiResponse)('getOrgAnalytics', result, spinner);
|
|
3303
|
+
}
|
|
3304
|
+
spinner.stop();
|
|
3305
|
+
if (!result.data.length) {
|
|
3306
|
+
return console.log('No analytics data is available for this organization yet.');
|
|
3307
|
+
}
|
|
3308
|
+
const data = formatData(result.data, 'org');
|
|
3309
|
+
if (outputJson && !filePath) {
|
|
3310
|
+
return console.log(result.data);
|
|
3311
|
+
}
|
|
3312
|
+
if (filePath) {
|
|
3313
|
+
_fs$1.writeFile(filePath, JSON.stringify(result.data), err => {
|
|
3314
|
+
err ? console.error(err) : console.log(`Data successfully written to ${filePath}`);
|
|
3315
|
+
});
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
return displayAnalyticsScreen(data);
|
|
3319
|
+
}
|
|
3320
|
+
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
3321
|
+
const formatDate = date => {
|
|
3322
|
+
return `${months[new Date(date).getMonth()]} ${new Date(date).getDate()}`;
|
|
3323
|
+
};
|
|
3324
|
+
const formatData = (data, scope) => {
|
|
3325
|
+
let formattedData, sortedTopFivealerts;
|
|
3326
|
+
if (scope === 'org') {
|
|
3327
|
+
const topFiveAlerts = data.map(d => d['top_five_alert_types']);
|
|
3328
|
+
const totalTopAlerts = topFiveAlerts.reduce((acc, current) => {
|
|
3329
|
+
const alertTypes = Object.keys(current);
|
|
3330
|
+
alertTypes.map(type => {
|
|
3331
|
+
if (!acc[type]) {
|
|
3332
|
+
acc[type] = current[type];
|
|
3333
|
+
} else {
|
|
3334
|
+
acc[type] += current[type];
|
|
3335
|
+
}
|
|
3336
|
+
return acc;
|
|
3337
|
+
});
|
|
3338
|
+
return acc;
|
|
3339
|
+
}, {});
|
|
3340
|
+
sortedTopFivealerts = Object.entries(totalTopAlerts).sort(([, a], [, b]) => b - a).slice(0, 5).reduce((r, [k, v]) => ({
|
|
3341
|
+
...r,
|
|
3342
|
+
[k]: v
|
|
3343
|
+
}), {});
|
|
3344
|
+
const formatData = label => {
|
|
3345
|
+
return data.reduce((acc, current) => {
|
|
3346
|
+
const date = formatDate(current['created_at']);
|
|
3347
|
+
if (!acc[date]) {
|
|
3348
|
+
acc[date] = current[label];
|
|
3349
|
+
} else {
|
|
3350
|
+
acc[date] += current[label];
|
|
3351
|
+
}
|
|
3352
|
+
return acc;
|
|
3353
|
+
}, {});
|
|
3354
|
+
};
|
|
3355
|
+
formattedData = METRICS.reduce((acc, current) => {
|
|
3356
|
+
acc[current] = formatData(current);
|
|
3357
|
+
return acc;
|
|
3358
|
+
}, {});
|
|
3359
|
+
} else if (scope === 'repo') {
|
|
3360
|
+
const topAlerts = data.reduce((acc, current) => {
|
|
3361
|
+
const alertTypes = Object.keys(current['top_five_alert_types']);
|
|
3362
|
+
alertTypes.map(type => {
|
|
3363
|
+
if (!acc[type]) {
|
|
3364
|
+
acc[type] = current['top_five_alert_types'][type];
|
|
3365
|
+
} else {
|
|
3366
|
+
if (current['top_five_alert_types'][type] > (acc[type] || 0)) {
|
|
3367
|
+
acc[type] = current['top_five_alert_types'][type];
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
return acc;
|
|
3371
|
+
});
|
|
3372
|
+
return acc;
|
|
3373
|
+
}, {});
|
|
3374
|
+
sortedTopFivealerts = Object.entries(topAlerts).sort(([, a], [, b]) => b - a).slice(0, 5).reduce((r, [k, v]) => ({
|
|
3375
|
+
...r,
|
|
3376
|
+
[k]: v
|
|
3377
|
+
}), {});
|
|
3378
|
+
formattedData = data.reduce((acc, current) => {
|
|
3379
|
+
METRICS.forEach(m => {
|
|
3380
|
+
if (!acc[m]) {
|
|
3381
|
+
acc[m] = {};
|
|
3382
|
+
}
|
|
3383
|
+
acc[m][formatDate(current['created_at'])] = current[m];
|
|
3384
|
+
return acc;
|
|
3385
|
+
});
|
|
3386
|
+
return acc;
|
|
3387
|
+
}, {});
|
|
3388
|
+
}
|
|
3389
|
+
return {
|
|
3390
|
+
...formattedData,
|
|
3391
|
+
top_five_alert_types: sortedTopFivealerts
|
|
3392
|
+
};
|
|
3393
|
+
};
|
|
3394
|
+
async function fetchRepoAnalyticsData(repo, time, spinner, apiKey, outputJson, filePath) {
|
|
3395
|
+
const socketSdk = await (0, _sdk$1.setupSdk)(apiKey);
|
|
3396
|
+
const result = await (0, _apiHelpers$1.handleApiCall)(socketSdk.getRepoAnalytics(repo, time.toString()), 'fetching analytics data');
|
|
3397
|
+
if (result.success === false) {
|
|
3398
|
+
return (0, _apiHelpers$1.handleUnsuccessfulApiResponse)('getRepoAnalytics', result, spinner);
|
|
3399
|
+
}
|
|
3400
|
+
spinner.stop();
|
|
3401
|
+
if (!result.data.length) {
|
|
3402
|
+
return console.log('No analytics data is available for this organization yet.');
|
|
3403
|
+
}
|
|
3404
|
+
const data = formatData(result.data, 'repo');
|
|
3405
|
+
if (outputJson && !filePath) {
|
|
3406
|
+
return console.log(result.data);
|
|
3407
|
+
}
|
|
3408
|
+
if (filePath) {
|
|
3409
|
+
_fs$1.writeFile(filePath, JSON.stringify(result.data), err => {
|
|
3410
|
+
err ? console.error(err) : console.log(`Data successfully written to ${filePath}`);
|
|
3411
|
+
});
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3414
|
+
return displayAnalyticsScreen(data);
|
|
3415
|
+
}
|
|
3416
|
+
const displayAnalyticsScreen = data => {
|
|
3417
|
+
const screen = _blessed.screen();
|
|
3418
|
+
// eslint-disable-next-line
|
|
3419
|
+
const grid = new _blessedContrib.grid({
|
|
3420
|
+
rows: 5,
|
|
3421
|
+
cols: 4,
|
|
3422
|
+
screen
|
|
3423
|
+
});
|
|
3424
|
+
renderLineCharts(grid, screen, 'Total critical alerts', [0, 0, 1, 2], data['total_critical_alerts']);
|
|
3425
|
+
renderLineCharts(grid, screen, 'Total high alerts', [0, 2, 1, 2], data['total_high_alerts']);
|
|
3426
|
+
renderLineCharts(grid, screen, 'Total critical alerts added to the main branch', [1, 0, 1, 2], data['total_critical_added']);
|
|
3427
|
+
renderLineCharts(grid, screen, 'Total high alerts added to the main branch', [1, 2, 1, 2], data['total_high_added']);
|
|
3428
|
+
renderLineCharts(grid, screen, 'Total critical alerts prevented from the main branch', [2, 0, 1, 2], data['total_critical_prevented']);
|
|
3429
|
+
renderLineCharts(grid, screen, 'Total high alerts prevented from the main branch', [2, 2, 1, 2], data['total_high_prevented']);
|
|
3430
|
+
renderLineCharts(grid, screen, 'Total medium alerts prevented from the main branch', [3, 0, 1, 2], data['total_medium_prevented']);
|
|
3431
|
+
renderLineCharts(grid, screen, 'Total low alerts prevented from the main branch', [3, 2, 1, 2], data['total_low_prevented']);
|
|
3432
|
+
const bar = grid.set(4, 0, 1, 2, _blessedContrib.bar, {
|
|
3433
|
+
label: 'Top 5 alert types',
|
|
3434
|
+
barWidth: 10,
|
|
3435
|
+
barSpacing: 17,
|
|
3436
|
+
xOffset: 0,
|
|
3437
|
+
maxHeight: 9,
|
|
3438
|
+
barBgColor: 'magenta'
|
|
3439
|
+
});
|
|
3440
|
+
screen.append(bar); //must append before setting data
|
|
3441
|
+
|
|
3442
|
+
bar.setData({
|
|
3443
|
+
titles: Object.keys(data.top_five_alert_types),
|
|
3444
|
+
data: Object.values(data.top_five_alert_types)
|
|
3445
|
+
});
|
|
3446
|
+
screen.render();
|
|
3447
|
+
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
3448
|
+
};
|
|
3449
|
+
const renderLineCharts = (grid, screen, title, coords, data) => {
|
|
3450
|
+
const line = grid.set(...coords, _blessedContrib.line, {
|
|
3451
|
+
style: {
|
|
3452
|
+
line: "cyan",
|
|
3453
|
+
text: "cyan",
|
|
3454
|
+
baseline: "black"
|
|
3455
|
+
},
|
|
3456
|
+
xLabelPadding: 0,
|
|
3457
|
+
xPadding: 0,
|
|
3458
|
+
xOffset: 0,
|
|
3459
|
+
wholeNumbersOnly: true,
|
|
3460
|
+
legend: {
|
|
3461
|
+
width: 1
|
|
3462
|
+
},
|
|
3463
|
+
label: title
|
|
3464
|
+
});
|
|
3465
|
+
screen.append(line);
|
|
3466
|
+
const lineData = {
|
|
3467
|
+
x: Object.keys(data),
|
|
3468
|
+
y: Object.values(data)
|
|
3469
|
+
};
|
|
3470
|
+
line.setData([lineData]);
|
|
3471
|
+
};
|
|
3472
|
+
|
|
3473
|
+
var diffScan = {};
|
|
3474
|
+
|
|
3475
|
+
var get$1 = {};
|
|
3476
|
+
|
|
3477
|
+
var _interopRequireDefault$1 = vendor.interopRequireDefault.default;
|
|
3478
|
+
Object.defineProperty(get$1, "__esModule", {
|
|
3479
|
+
value: true
|
|
3480
|
+
});
|
|
3481
|
+
get$1.get = void 0;
|
|
3482
|
+
var _chalk$1 = _interopRequireDefault$1(vendor.source);
|
|
3483
|
+
var _fs = require$$0;
|
|
3484
|
+
var _meow = _interopRequireDefault$1(vendor.build);
|
|
3485
|
+
var _ora = _interopRequireDefault$1(vendor.ora);
|
|
3486
|
+
var _util = require$$0$4;
|
|
3487
|
+
var _flags = flags;
|
|
3488
|
+
var _formatting = formatting;
|
|
3489
|
+
var _sdk = sdk.sdk;
|
|
3490
|
+
var _errors$1 = sdk.errors;
|
|
3491
|
+
var _apiHelpers = apiHelpers;
|
|
3492
|
+
const get = get$1.get = {
|
|
3493
|
+
description: 'Get a diff scan for an organization',
|
|
3494
|
+
async run(argv, importMeta, {
|
|
3495
|
+
parentName
|
|
3496
|
+
}) {
|
|
3497
|
+
const name = `${parentName} get`;
|
|
3498
|
+
const input = setupCommand(name, get.description, argv, importMeta);
|
|
3499
|
+
if (input) {
|
|
3500
|
+
const apiKey = (0, _sdk.getDefaultKey)();
|
|
3501
|
+
if (!apiKey) {
|
|
3502
|
+
throw new _errors$1.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3503
|
+
}
|
|
3504
|
+
const spinnerText = 'Getting diff scan... \n';
|
|
3505
|
+
const spinner = (0, _ora.default)(spinnerText).start();
|
|
3506
|
+
await getDiffScan(input, spinner, apiKey);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
};
|
|
3510
|
+
const getDiffScanFlags = {
|
|
3511
|
+
before: {
|
|
3512
|
+
type: 'string',
|
|
3513
|
+
shortFlag: 'b',
|
|
3514
|
+
default: '',
|
|
3515
|
+
description: 'The full scan ID of the base scan'
|
|
3516
|
+
},
|
|
3517
|
+
after: {
|
|
3518
|
+
type: 'string',
|
|
3519
|
+
shortFlag: 'a',
|
|
3520
|
+
default: '',
|
|
3521
|
+
description: 'The full scan ID of the head scan'
|
|
3522
|
+
},
|
|
3523
|
+
preview: {
|
|
3524
|
+
type: 'boolean',
|
|
3525
|
+
shortFlag: 'p',
|
|
3526
|
+
default: true,
|
|
3527
|
+
description: 'A boolean flag to persist or not the diff scan result'
|
|
3528
|
+
},
|
|
3529
|
+
file: {
|
|
3530
|
+
type: 'string',
|
|
3531
|
+
shortFlag: 'f',
|
|
3532
|
+
default: '',
|
|
3533
|
+
description: 'Path to a local file where the output should be saved'
|
|
3534
|
+
}
|
|
3535
|
+
};
|
|
3536
|
+
|
|
3537
|
+
// Internal functions
|
|
3538
|
+
|
|
3539
|
+
function setupCommand(name, description, argv, importMeta) {
|
|
3540
|
+
const flags = {
|
|
3541
|
+
..._flags.outputFlags,
|
|
3542
|
+
...getDiffScanFlags
|
|
3543
|
+
};
|
|
3544
|
+
const cli = (0, _meow.default)(`
|
|
3545
|
+
Usage
|
|
3546
|
+
$ ${name} <org slug> --before=<before> --after=<after>
|
|
3547
|
+
|
|
3548
|
+
Options
|
|
3549
|
+
${(0, _formatting.printFlagList)(flags, 6)}
|
|
3550
|
+
|
|
3551
|
+
Examples
|
|
3552
|
+
$ ${name} FakeCorp --before=aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 --after=aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
|
|
3553
|
+
`, {
|
|
3554
|
+
argv,
|
|
3555
|
+
description,
|
|
3556
|
+
importMeta,
|
|
3557
|
+
flags
|
|
3558
|
+
});
|
|
3559
|
+
const {
|
|
3560
|
+
json: outputJson,
|
|
3561
|
+
markdown: outputMarkdown,
|
|
3562
|
+
before,
|
|
3563
|
+
after,
|
|
3564
|
+
preview,
|
|
3565
|
+
file
|
|
3566
|
+
} = cli.flags;
|
|
3567
|
+
if (!before || !after) {
|
|
3568
|
+
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`);
|
|
3569
|
+
cli.showHelp();
|
|
3570
|
+
return;
|
|
3571
|
+
}
|
|
3572
|
+
if (cli.input.length < 1) {
|
|
3573
|
+
console.error(`${_chalk$1.default.bgRed.white('Input error')}: Please provide an organization slug \n`);
|
|
3574
|
+
cli.showHelp();
|
|
3575
|
+
return;
|
|
3576
|
+
}
|
|
3577
|
+
const [orgSlug = ''] = cli.input;
|
|
3578
|
+
return {
|
|
3579
|
+
outputJson,
|
|
3580
|
+
outputMarkdown,
|
|
3581
|
+
before,
|
|
3582
|
+
after,
|
|
3583
|
+
preview,
|
|
3584
|
+
orgSlug,
|
|
3585
|
+
file
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
async function getDiffScan({
|
|
3589
|
+
before,
|
|
3590
|
+
after,
|
|
3591
|
+
orgSlug,
|
|
3592
|
+
file
|
|
3593
|
+
}, spinner, apiKey) {
|
|
3594
|
+
const response = await (0, _apiHelpers.queryAPI)(`${orgSlug}/full-scans/diff?before=${before}&after=${after}&preview`, apiKey);
|
|
3595
|
+
const data = await response.json();
|
|
3596
|
+
if (!response.ok) {
|
|
3597
|
+
spinner.stop();
|
|
3598
|
+
const err = await (0, _apiHelpers.handleAPIError)(response.status);
|
|
3599
|
+
console.error(`${_chalk$1.default.bgRed.white(response.statusText)}: ${err} \n`);
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3602
|
+
spinner.stop();
|
|
3603
|
+
if (file) {
|
|
3604
|
+
_fs.writeFile(file, JSON.stringify(data), err => {
|
|
3605
|
+
err ? console.error(err) : console.log(`Data successfully written to ${file}`);
|
|
3606
|
+
});
|
|
3607
|
+
return;
|
|
3608
|
+
}
|
|
3609
|
+
console.log(`\n Diff scan result: \n`);
|
|
3610
|
+
console.log(_util.inspect(data, {
|
|
3611
|
+
showHidden: false,
|
|
3612
|
+
depth: null,
|
|
3613
|
+
colors: true
|
|
3614
|
+
}));
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
Object.defineProperty(diffScan, "__esModule", {
|
|
3618
|
+
value: true
|
|
3619
|
+
});
|
|
3620
|
+
diffScan.diffScan = void 0;
|
|
3621
|
+
var _get = get$1;
|
|
3622
|
+
var _meowWithSubcommands$1 = meowWithSubcommands$1;
|
|
3623
|
+
const description = 'Diff scans related commands';
|
|
3624
|
+
diffScan.diffScan = {
|
|
3625
|
+
description,
|
|
3626
|
+
run: async (argv, importMeta, {
|
|
3627
|
+
parentName
|
|
3628
|
+
}) => {
|
|
3629
|
+
await (0, _meowWithSubcommands$1.meowWithSubcommands)({
|
|
3630
|
+
get: _get.get
|
|
3631
|
+
}, {
|
|
3632
|
+
argv,
|
|
3633
|
+
description,
|
|
3634
|
+
importMeta,
|
|
3635
|
+
name: parentName + ' diff-scan'
|
|
3636
|
+
});
|
|
3637
|
+
}
|
|
3638
|
+
};
|
|
3639
|
+
|
|
3153
3640
|
(function (exports) {
|
|
3154
3641
|
|
|
3155
3642
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -3319,6 +3806,28 @@ async function searchDeps({
|
|
|
3319
3806
|
return _dependencies[key];
|
|
3320
3807
|
}
|
|
3321
3808
|
});
|
|
3809
|
+
});
|
|
3810
|
+
var _analytics = analytics$1;
|
|
3811
|
+
Object.keys(_analytics).forEach(function (key) {
|
|
3812
|
+
if (key === "default" || key === "__esModule") return;
|
|
3813
|
+
if (key in exports && exports[key] === _analytics[key]) return;
|
|
3814
|
+
Object.defineProperty(exports, key, {
|
|
3815
|
+
enumerable: true,
|
|
3816
|
+
get: function () {
|
|
3817
|
+
return _analytics[key];
|
|
3818
|
+
}
|
|
3819
|
+
});
|
|
3820
|
+
});
|
|
3821
|
+
var _diffScan = diffScan;
|
|
3822
|
+
Object.keys(_diffScan).forEach(function (key) {
|
|
3823
|
+
if (key === "default" || key === "__esModule") return;
|
|
3824
|
+
if (key in exports && exports[key] === _diffScan[key]) return;
|
|
3825
|
+
Object.defineProperty(exports, key, {
|
|
3826
|
+
enumerable: true,
|
|
3827
|
+
get: function () {
|
|
3828
|
+
return _diffScan[key];
|
|
3829
|
+
}
|
|
3830
|
+
});
|
|
3322
3831
|
});
|
|
3323
3832
|
} (commands));
|
|
3324
3833
|
|
|
@@ -3326,7 +3835,7 @@ var _interopRequireWildcard = vendor.interopRequireWildcard.default;
|
|
|
3326
3835
|
var _interopRequireDefault = vendor.interopRequireDefault.default;
|
|
3327
3836
|
var _nodeFs = require$$0;
|
|
3328
3837
|
var _nodePath = require$$1;
|
|
3329
|
-
var _nodeUrl = require$$2$
|
|
3838
|
+
var _nodeUrl = require$$2$4;
|
|
3330
3839
|
var _chalk = _interopRequireDefault(vendor.source);
|
|
3331
3840
|
var _ponyCause = require$$6;
|
|
3332
3841
|
var _updateNotifier = _interopRequireDefault(vendor.updateNotifier);
|