@cyclonedx/cdxgen 9.0.1 → 9.1.1

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.
@@ -0,0 +1,621 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "http://cyclonedx.org/schema/spdx.schema.json",
4
+ "$comment": "v1.0-3.21",
5
+ "type": "string",
6
+ "enum": [
7
+ "0BSD",
8
+ "AAL",
9
+ "Abstyles",
10
+ "AdaCore-doc",
11
+ "Adobe-2006",
12
+ "Adobe-Glyph",
13
+ "ADSL",
14
+ "AFL-1.1",
15
+ "AFL-1.2",
16
+ "AFL-2.0",
17
+ "AFL-2.1",
18
+ "AFL-3.0",
19
+ "Afmparse",
20
+ "AGPL-1.0",
21
+ "AGPL-1.0-only",
22
+ "AGPL-1.0-or-later",
23
+ "AGPL-3.0",
24
+ "AGPL-3.0-only",
25
+ "AGPL-3.0-or-later",
26
+ "Aladdin",
27
+ "AMDPLPA",
28
+ "AML",
29
+ "AMPAS",
30
+ "ANTLR-PD",
31
+ "ANTLR-PD-fallback",
32
+ "Apache-1.0",
33
+ "Apache-1.1",
34
+ "Apache-2.0",
35
+ "APAFML",
36
+ "APL-1.0",
37
+ "App-s2p",
38
+ "APSL-1.0",
39
+ "APSL-1.1",
40
+ "APSL-1.2",
41
+ "APSL-2.0",
42
+ "Arphic-1999",
43
+ "Artistic-1.0",
44
+ "Artistic-1.0-cl8",
45
+ "Artistic-1.0-Perl",
46
+ "Artistic-2.0",
47
+ "ASWF-Digital-Assets-1.0",
48
+ "ASWF-Digital-Assets-1.1",
49
+ "Baekmuk",
50
+ "Bahyph",
51
+ "Barr",
52
+ "Beerware",
53
+ "Bitstream-Charter",
54
+ "Bitstream-Vera",
55
+ "BitTorrent-1.0",
56
+ "BitTorrent-1.1",
57
+ "blessing",
58
+ "BlueOak-1.0.0",
59
+ "Boehm-GC",
60
+ "Borceux",
61
+ "Brian-Gladman-3-Clause",
62
+ "BSD-1-Clause",
63
+ "BSD-2-Clause",
64
+ "BSD-2-Clause-FreeBSD",
65
+ "BSD-2-Clause-NetBSD",
66
+ "BSD-2-Clause-Patent",
67
+ "BSD-2-Clause-Views",
68
+ "BSD-3-Clause",
69
+ "BSD-3-Clause-Attribution",
70
+ "BSD-3-Clause-Clear",
71
+ "BSD-3-Clause-LBNL",
72
+ "BSD-3-Clause-Modification",
73
+ "BSD-3-Clause-No-Military-License",
74
+ "BSD-3-Clause-No-Nuclear-License",
75
+ "BSD-3-Clause-No-Nuclear-License-2014",
76
+ "BSD-3-Clause-No-Nuclear-Warranty",
77
+ "BSD-3-Clause-Open-MPI",
78
+ "BSD-4-Clause",
79
+ "BSD-4-Clause-Shortened",
80
+ "BSD-4-Clause-UC",
81
+ "BSD-4.3RENO",
82
+ "BSD-4.3TAHOE",
83
+ "BSD-Advertising-Acknowledgement",
84
+ "BSD-Attribution-HPND-disclaimer",
85
+ "BSD-Protection",
86
+ "BSD-Source-Code",
87
+ "BSL-1.0",
88
+ "BUSL-1.1",
89
+ "bzip2-1.0.5",
90
+ "bzip2-1.0.6",
91
+ "C-UDA-1.0",
92
+ "CAL-1.0",
93
+ "CAL-1.0-Combined-Work-Exception",
94
+ "Caldera",
95
+ "CATOSL-1.1",
96
+ "CC-BY-1.0",
97
+ "CC-BY-2.0",
98
+ "CC-BY-2.5",
99
+ "CC-BY-2.5-AU",
100
+ "CC-BY-3.0",
101
+ "CC-BY-3.0-AT",
102
+ "CC-BY-3.0-DE",
103
+ "CC-BY-3.0-IGO",
104
+ "CC-BY-3.0-NL",
105
+ "CC-BY-3.0-US",
106
+ "CC-BY-4.0",
107
+ "CC-BY-NC-1.0",
108
+ "CC-BY-NC-2.0",
109
+ "CC-BY-NC-2.5",
110
+ "CC-BY-NC-3.0",
111
+ "CC-BY-NC-3.0-DE",
112
+ "CC-BY-NC-4.0",
113
+ "CC-BY-NC-ND-1.0",
114
+ "CC-BY-NC-ND-2.0",
115
+ "CC-BY-NC-ND-2.5",
116
+ "CC-BY-NC-ND-3.0",
117
+ "CC-BY-NC-ND-3.0-DE",
118
+ "CC-BY-NC-ND-3.0-IGO",
119
+ "CC-BY-NC-ND-4.0",
120
+ "CC-BY-NC-SA-1.0",
121
+ "CC-BY-NC-SA-2.0",
122
+ "CC-BY-NC-SA-2.0-DE",
123
+ "CC-BY-NC-SA-2.0-FR",
124
+ "CC-BY-NC-SA-2.0-UK",
125
+ "CC-BY-NC-SA-2.5",
126
+ "CC-BY-NC-SA-3.0",
127
+ "CC-BY-NC-SA-3.0-DE",
128
+ "CC-BY-NC-SA-3.0-IGO",
129
+ "CC-BY-NC-SA-4.0",
130
+ "CC-BY-ND-1.0",
131
+ "CC-BY-ND-2.0",
132
+ "CC-BY-ND-2.5",
133
+ "CC-BY-ND-3.0",
134
+ "CC-BY-ND-3.0-DE",
135
+ "CC-BY-ND-4.0",
136
+ "CC-BY-SA-1.0",
137
+ "CC-BY-SA-2.0",
138
+ "CC-BY-SA-2.0-UK",
139
+ "CC-BY-SA-2.1-JP",
140
+ "CC-BY-SA-2.5",
141
+ "CC-BY-SA-3.0",
142
+ "CC-BY-SA-3.0-AT",
143
+ "CC-BY-SA-3.0-DE",
144
+ "CC-BY-SA-3.0-IGO",
145
+ "CC-BY-SA-4.0",
146
+ "CC-PDDC",
147
+ "CC0-1.0",
148
+ "CDDL-1.0",
149
+ "CDDL-1.1",
150
+ "CDL-1.0",
151
+ "CDLA-Permissive-1.0",
152
+ "CDLA-Permissive-2.0",
153
+ "CDLA-Sharing-1.0",
154
+ "CECILL-1.0",
155
+ "CECILL-1.1",
156
+ "CECILL-2.0",
157
+ "CECILL-2.1",
158
+ "CECILL-B",
159
+ "CECILL-C",
160
+ "CERN-OHL-1.1",
161
+ "CERN-OHL-1.2",
162
+ "CERN-OHL-P-2.0",
163
+ "CERN-OHL-S-2.0",
164
+ "CERN-OHL-W-2.0",
165
+ "CFITSIO",
166
+ "checkmk",
167
+ "ClArtistic",
168
+ "Clips",
169
+ "CMU-Mach",
170
+ "CNRI-Jython",
171
+ "CNRI-Python",
172
+ "CNRI-Python-GPL-Compatible",
173
+ "COIL-1.0",
174
+ "Community-Spec-1.0",
175
+ "Condor-1.1",
176
+ "copyleft-next-0.3.0",
177
+ "copyleft-next-0.3.1",
178
+ "Cornell-Lossless-JPEG",
179
+ "CPAL-1.0",
180
+ "CPL-1.0",
181
+ "CPOL-1.02",
182
+ "Crossword",
183
+ "CrystalStacker",
184
+ "CUA-OPL-1.0",
185
+ "Cube",
186
+ "curl",
187
+ "D-FSL-1.0",
188
+ "diffmark",
189
+ "DL-DE-BY-2.0",
190
+ "DOC",
191
+ "Dotseqn",
192
+ "DRL-1.0",
193
+ "DSDP",
194
+ "dtoa",
195
+ "dvipdfm",
196
+ "ECL-1.0",
197
+ "ECL-2.0",
198
+ "eCos-2.0",
199
+ "EFL-1.0",
200
+ "EFL-2.0",
201
+ "eGenix",
202
+ "Elastic-2.0",
203
+ "Entessa",
204
+ "EPICS",
205
+ "EPL-1.0",
206
+ "EPL-2.0",
207
+ "ErlPL-1.1",
208
+ "etalab-2.0",
209
+ "EUDatagrid",
210
+ "EUPL-1.0",
211
+ "EUPL-1.1",
212
+ "EUPL-1.2",
213
+ "Eurosym",
214
+ "Fair",
215
+ "FDK-AAC",
216
+ "Frameworx-1.0",
217
+ "FreeBSD-DOC",
218
+ "FreeImage",
219
+ "FSFAP",
220
+ "FSFUL",
221
+ "FSFULLR",
222
+ "FSFULLRWD",
223
+ "FTL",
224
+ "GD",
225
+ "GFDL-1.1",
226
+ "GFDL-1.1-invariants-only",
227
+ "GFDL-1.1-invariants-or-later",
228
+ "GFDL-1.1-no-invariants-only",
229
+ "GFDL-1.1-no-invariants-or-later",
230
+ "GFDL-1.1-only",
231
+ "GFDL-1.1-or-later",
232
+ "GFDL-1.2",
233
+ "GFDL-1.2-invariants-only",
234
+ "GFDL-1.2-invariants-or-later",
235
+ "GFDL-1.2-no-invariants-only",
236
+ "GFDL-1.2-no-invariants-or-later",
237
+ "GFDL-1.2-only",
238
+ "GFDL-1.2-or-later",
239
+ "GFDL-1.3",
240
+ "GFDL-1.3-invariants-only",
241
+ "GFDL-1.3-invariants-or-later",
242
+ "GFDL-1.3-no-invariants-only",
243
+ "GFDL-1.3-no-invariants-or-later",
244
+ "GFDL-1.3-only",
245
+ "GFDL-1.3-or-later",
246
+ "Giftware",
247
+ "GL2PS",
248
+ "Glide",
249
+ "Glulxe",
250
+ "GLWTPL",
251
+ "gnuplot",
252
+ "GPL-1.0",
253
+ "GPL-1.0+",
254
+ "GPL-1.0-only",
255
+ "GPL-1.0-or-later",
256
+ "GPL-2.0",
257
+ "GPL-2.0+",
258
+ "GPL-2.0-only",
259
+ "GPL-2.0-or-later",
260
+ "GPL-2.0-with-autoconf-exception",
261
+ "GPL-2.0-with-bison-exception",
262
+ "GPL-2.0-with-classpath-exception",
263
+ "GPL-2.0-with-font-exception",
264
+ "GPL-2.0-with-GCC-exception",
265
+ "GPL-3.0",
266
+ "GPL-3.0+",
267
+ "GPL-3.0-only",
268
+ "GPL-3.0-or-later",
269
+ "GPL-3.0-with-autoconf-exception",
270
+ "GPL-3.0-with-GCC-exception",
271
+ "Graphics-Gems",
272
+ "gSOAP-1.3b",
273
+ "HaskellReport",
274
+ "Hippocratic-2.1",
275
+ "HP-1986",
276
+ "HPND",
277
+ "HPND-export-US",
278
+ "HPND-Markus-Kuhn",
279
+ "HPND-sell-variant",
280
+ "HPND-sell-variant-MIT-disclaimer",
281
+ "HTMLTIDY",
282
+ "IBM-pibs",
283
+ "ICU",
284
+ "IEC-Code-Components-EULA",
285
+ "IJG",
286
+ "IJG-short",
287
+ "ImageMagick",
288
+ "iMatix",
289
+ "Imlib2",
290
+ "Info-ZIP",
291
+ "Inner-Net-2.0",
292
+ "Intel",
293
+ "Intel-ACPI",
294
+ "Interbase-1.0",
295
+ "IPA",
296
+ "IPL-1.0",
297
+ "ISC",
298
+ "Jam",
299
+ "JasPer-2.0",
300
+ "JPL-image",
301
+ "JPNIC",
302
+ "JSON",
303
+ "Kazlib",
304
+ "Knuth-CTAN",
305
+ "LAL-1.2",
306
+ "LAL-1.3",
307
+ "Latex2e",
308
+ "Latex2e-translated-notice",
309
+ "Leptonica",
310
+ "LGPL-2.0",
311
+ "LGPL-2.0+",
312
+ "LGPL-2.0-only",
313
+ "LGPL-2.0-or-later",
314
+ "LGPL-2.1",
315
+ "LGPL-2.1+",
316
+ "LGPL-2.1-only",
317
+ "LGPL-2.1-or-later",
318
+ "LGPL-3.0",
319
+ "LGPL-3.0+",
320
+ "LGPL-3.0-only",
321
+ "LGPL-3.0-or-later",
322
+ "LGPLLR",
323
+ "Libpng",
324
+ "libpng-2.0",
325
+ "libselinux-1.0",
326
+ "libtiff",
327
+ "libutil-David-Nugent",
328
+ "LiLiQ-P-1.1",
329
+ "LiLiQ-R-1.1",
330
+ "LiLiQ-Rplus-1.1",
331
+ "Linux-man-pages-1-para",
332
+ "Linux-man-pages-copyleft",
333
+ "Linux-man-pages-copyleft-2-para",
334
+ "Linux-man-pages-copyleft-var",
335
+ "Linux-OpenIB",
336
+ "LOOP",
337
+ "LPL-1.0",
338
+ "LPL-1.02",
339
+ "LPPL-1.0",
340
+ "LPPL-1.1",
341
+ "LPPL-1.2",
342
+ "LPPL-1.3a",
343
+ "LPPL-1.3c",
344
+ "LZMA-SDK-9.11-to-9.20",
345
+ "LZMA-SDK-9.22",
346
+ "MakeIndex",
347
+ "Martin-Birgmeier",
348
+ "metamail",
349
+ "Minpack",
350
+ "MirOS",
351
+ "MIT",
352
+ "MIT-0",
353
+ "MIT-advertising",
354
+ "MIT-CMU",
355
+ "MIT-enna",
356
+ "MIT-feh",
357
+ "MIT-Festival",
358
+ "MIT-Modern-Variant",
359
+ "MIT-open-group",
360
+ "MIT-Wu",
361
+ "MITNFA",
362
+ "Motosoto",
363
+ "mpi-permissive",
364
+ "mpich2",
365
+ "MPL-1.0",
366
+ "MPL-1.1",
367
+ "MPL-2.0",
368
+ "MPL-2.0-no-copyleft-exception",
369
+ "mplus",
370
+ "MS-LPL",
371
+ "MS-PL",
372
+ "MS-RL",
373
+ "MTLL",
374
+ "MulanPSL-1.0",
375
+ "MulanPSL-2.0",
376
+ "Multics",
377
+ "Mup",
378
+ "NAIST-2003",
379
+ "NASA-1.3",
380
+ "Naumen",
381
+ "NBPL-1.0",
382
+ "NCGL-UK-2.0",
383
+ "NCSA",
384
+ "Net-SNMP",
385
+ "NetCDF",
386
+ "Newsletr",
387
+ "NGPL",
388
+ "NICTA-1.0",
389
+ "NIST-PD",
390
+ "NIST-PD-fallback",
391
+ "NIST-Software",
392
+ "NLOD-1.0",
393
+ "NLOD-2.0",
394
+ "NLPL",
395
+ "Nokia",
396
+ "NOSL",
397
+ "Noweb",
398
+ "NPL-1.0",
399
+ "NPL-1.1",
400
+ "NPOSL-3.0",
401
+ "NRL",
402
+ "NTP",
403
+ "NTP-0",
404
+ "Nunit",
405
+ "O-UDA-1.0",
406
+ "OCCT-PL",
407
+ "OCLC-2.0",
408
+ "ODbL-1.0",
409
+ "ODC-By-1.0",
410
+ "OFFIS",
411
+ "OFL-1.0",
412
+ "OFL-1.0-no-RFN",
413
+ "OFL-1.0-RFN",
414
+ "OFL-1.1",
415
+ "OFL-1.1-no-RFN",
416
+ "OFL-1.1-RFN",
417
+ "OGC-1.0",
418
+ "OGDL-Taiwan-1.0",
419
+ "OGL-Canada-2.0",
420
+ "OGL-UK-1.0",
421
+ "OGL-UK-2.0",
422
+ "OGL-UK-3.0",
423
+ "OGTSL",
424
+ "OLDAP-1.1",
425
+ "OLDAP-1.2",
426
+ "OLDAP-1.3",
427
+ "OLDAP-1.4",
428
+ "OLDAP-2.0",
429
+ "OLDAP-2.0.1",
430
+ "OLDAP-2.1",
431
+ "OLDAP-2.2",
432
+ "OLDAP-2.2.1",
433
+ "OLDAP-2.2.2",
434
+ "OLDAP-2.3",
435
+ "OLDAP-2.4",
436
+ "OLDAP-2.5",
437
+ "OLDAP-2.6",
438
+ "OLDAP-2.7",
439
+ "OLDAP-2.8",
440
+ "OLFL-1.3",
441
+ "OML",
442
+ "OpenPBS-2.3",
443
+ "OpenSSL",
444
+ "OPL-1.0",
445
+ "OPL-UK-3.0",
446
+ "OPUBL-1.0",
447
+ "OSET-PL-2.1",
448
+ "OSL-1.0",
449
+ "OSL-1.1",
450
+ "OSL-2.0",
451
+ "OSL-2.1",
452
+ "OSL-3.0",
453
+ "Parity-6.0.0",
454
+ "Parity-7.0.0",
455
+ "PDDL-1.0",
456
+ "PHP-3.0",
457
+ "PHP-3.01",
458
+ "Plexus",
459
+ "PolyForm-Noncommercial-1.0.0",
460
+ "PolyForm-Small-Business-1.0.0",
461
+ "PostgreSQL",
462
+ "PSF-2.0",
463
+ "psfrag",
464
+ "psutils",
465
+ "Python-2.0",
466
+ "Python-2.0.1",
467
+ "Qhull",
468
+ "QPL-1.0",
469
+ "QPL-1.0-INRIA-2004",
470
+ "Rdisc",
471
+ "RHeCos-1.1",
472
+ "RPL-1.1",
473
+ "RPL-1.5",
474
+ "RPSL-1.0",
475
+ "RSA-MD",
476
+ "RSCPL",
477
+ "Ruby",
478
+ "SAX-PD",
479
+ "Saxpath",
480
+ "SCEA",
481
+ "SchemeReport",
482
+ "Sendmail",
483
+ "Sendmail-8.23",
484
+ "SGI-B-1.0",
485
+ "SGI-B-1.1",
486
+ "SGI-B-2.0",
487
+ "SGP4",
488
+ "SHL-0.5",
489
+ "SHL-0.51",
490
+ "SimPL-2.0",
491
+ "SISSL",
492
+ "SISSL-1.2",
493
+ "Sleepycat",
494
+ "SMLNJ",
495
+ "SMPPL",
496
+ "SNIA",
497
+ "snprintf",
498
+ "Spencer-86",
499
+ "Spencer-94",
500
+ "Spencer-99",
501
+ "SPL-1.0",
502
+ "SSH-OpenSSH",
503
+ "SSH-short",
504
+ "SSPL-1.0",
505
+ "StandardML-NJ",
506
+ "SugarCRM-1.1.3",
507
+ "SunPro",
508
+ "SWL",
509
+ "Symlinks",
510
+ "TAPR-OHL-1.0",
511
+ "TCL",
512
+ "TCP-wrappers",
513
+ "TermReadKey",
514
+ "TMate",
515
+ "TORQUE-1.1",
516
+ "TOSL",
517
+ "TPDL",
518
+ "TPL-1.0",
519
+ "TTWL",
520
+ "TU-Berlin-1.0",
521
+ "TU-Berlin-2.0",
522
+ "UCAR",
523
+ "UCL-1.0",
524
+ "Unicode-DFS-2015",
525
+ "Unicode-DFS-2016",
526
+ "Unicode-TOU",
527
+ "UnixCrypt",
528
+ "Unlicense",
529
+ "UPL-1.0",
530
+ "Vim",
531
+ "VOSTROM",
532
+ "VSL-1.0",
533
+ "W3C",
534
+ "W3C-19980720",
535
+ "W3C-20150513",
536
+ "w3m",
537
+ "Watcom-1.0",
538
+ "Widget-Workshop",
539
+ "Wsuipa",
540
+ "WTFPL",
541
+ "wxWindows",
542
+ "X11",
543
+ "X11-distribute-modifications-variant",
544
+ "Xdebug-1.03",
545
+ "Xerox",
546
+ "Xfig",
547
+ "XFree86-1.1",
548
+ "xinetd",
549
+ "xlock",
550
+ "Xnet",
551
+ "xpp",
552
+ "XSkat",
553
+ "YPL-1.0",
554
+ "YPL-1.1",
555
+ "Zed",
556
+ "Zend-2.0",
557
+ "Zimbra-1.3",
558
+ "Zimbra-1.4",
559
+ "Zlib",
560
+ "zlib-acknowledgement",
561
+ "ZPL-1.1",
562
+ "ZPL-2.0",
563
+ "ZPL-2.1",
564
+ "389-exception",
565
+ "Asterisk-exception",
566
+ "Autoconf-exception-2.0",
567
+ "Autoconf-exception-3.0",
568
+ "Autoconf-exception-generic",
569
+ "Autoconf-exception-macro",
570
+ "Bison-exception-2.2",
571
+ "Bootloader-exception",
572
+ "Classpath-exception-2.0",
573
+ "CLISP-exception-2.0",
574
+ "cryptsetup-OpenSSL-exception",
575
+ "DigiRule-FOSS-exception",
576
+ "eCos-exception-2.0",
577
+ "Fawkes-Runtime-exception",
578
+ "FLTK-exception",
579
+ "Font-exception-2.0",
580
+ "freertos-exception-2.0",
581
+ "GCC-exception-2.0",
582
+ "GCC-exception-3.1",
583
+ "GNAT-exception",
584
+ "gnu-javamail-exception",
585
+ "GPL-3.0-interface-exception",
586
+ "GPL-3.0-linking-exception",
587
+ "GPL-3.0-linking-source-exception",
588
+ "GPL-CC-1.0",
589
+ "GStreamer-exception-2005",
590
+ "GStreamer-exception-2008",
591
+ "i2p-gpl-java-exception",
592
+ "KiCad-libraries-exception",
593
+ "LGPL-3.0-linking-exception",
594
+ "libpri-OpenH323-exception",
595
+ "Libtool-exception",
596
+ "Linux-syscall-note",
597
+ "LLGPL",
598
+ "LLVM-exception",
599
+ "LZMA-exception",
600
+ "mif-exception",
601
+ "Nokia-Qt-exception-1.1",
602
+ "OCaml-LGPL-linking-exception",
603
+ "OCCT-exception-1.0",
604
+ "OpenJDK-assembly-exception-1.0",
605
+ "openvpn-openssl-exception",
606
+ "PS-or-PDF-font-exception-20170817",
607
+ "QPL-1.0-INRIA-2004-exception",
608
+ "Qt-GPL-exception-1.0",
609
+ "Qt-LGPL-exception-1.1",
610
+ "Qwt-exception-1.0",
611
+ "SHL-2.0",
612
+ "SHL-2.1",
613
+ "SWI-exception",
614
+ "Swift-exception",
615
+ "u-boot-exception-2.0",
616
+ "Universal-FOSS-exception-1.0",
617
+ "vsftpd-openssl-exception",
618
+ "WxWindows-exception-3.1",
619
+ "x11vnc-openssl-exception"
620
+ ]
621
+ }
package/display.js ADDED
@@ -0,0 +1,102 @@
1
+ import { table } from "table";
2
+
3
+ // https://github.com/yangshun/tree-node-cli/blob/master/src/index.js
4
+ const SYMBOLS_ANSI = {
5
+ BRANCH: "├── ",
6
+ EMPTY: "",
7
+ INDENT: " ",
8
+ LAST_BRANCH: "└── ",
9
+ VERTICAL: "│ "
10
+ };
11
+
12
+ export const printTable = (bomJson) => {
13
+ const data = [["Group", "Name", "Version", "Scope"]];
14
+ for (const comp of bomJson.components) {
15
+ data.push([comp.group || "", comp.name, comp.version, comp.scope || ""]);
16
+ }
17
+ const config = {
18
+ header: {
19
+ alignment: "center",
20
+ content: "Software Bill-of-Materials\nGenerated by @cyclonedx/cdxgen"
21
+ }
22
+ };
23
+ console.log(table(data, config));
24
+ console.log(
25
+ "BOM includes",
26
+ bomJson.components.length,
27
+ "components and",
28
+ bomJson.dependencies.length,
29
+ "dependencies"
30
+ );
31
+ };
32
+ export const printDependencyTree = (bomJson) => {
33
+ const dependencies = bomJson.dependencies || [];
34
+ if (!dependencies.length) {
35
+ return;
36
+ }
37
+ const depMap = {};
38
+ for (const d of dependencies) {
39
+ if (d.dependsOn && d.dependsOn.length) {
40
+ depMap[d.ref] = d.dependsOn;
41
+ }
42
+ }
43
+ const shownList = [];
44
+ const treeGraphics = [];
45
+ recursePrint(depMap, dependencies, 0, shownList, treeGraphics);
46
+ if (treeGraphics && treeGraphics.length) {
47
+ // Patch up the last line
48
+ treeGraphics[treeGraphics.length - 1] = treeGraphics[
49
+ treeGraphics.length - 1
50
+ ].replace(SYMBOLS_ANSI.BRANCH, SYMBOLS_ANSI.LAST_BRANCH);
51
+ if (treeGraphics[treeGraphics.length - 1].includes(SYMBOLS_ANSI.VERTICAL)) {
52
+ treeGraphics[treeGraphics.length - 1] = treeGraphics[
53
+ treeGraphics.length - 1
54
+ ]
55
+ .replace(SYMBOLS_ANSI.VERTICAL, SYMBOLS_ANSI.LAST_BRANCH)
56
+ .replace(
57
+ SYMBOLS_ANSI.INDENT + SYMBOLS_ANSI.LAST_BRANCH,
58
+ SYMBOLS_ANSI.LAST_BRANCH
59
+ );
60
+ }
61
+ }
62
+ const config = {
63
+ header: {
64
+ alignment: "center",
65
+ content: "Dependency Tree\nGenerated with \u2665 by cdxgen"
66
+ }
67
+ };
68
+ console.log(table([[treeGraphics.join("\n")]], config));
69
+ };
70
+
71
+ const levelPrefix = (level) => {
72
+ if (level === 0) {
73
+ return SYMBOLS_ANSI.EMPTY;
74
+ }
75
+ let prefix = `${SYMBOLS_ANSI.BRANCH}`;
76
+ for (let i = 0; i < level - 1; i++) {
77
+ prefix = `${SYMBOLS_ANSI.VERTICAL}${SYMBOLS_ANSI.INDENT}${prefix}`;
78
+ }
79
+ return prefix;
80
+ };
81
+
82
+ const recursePrint = (depMap, subtree, level, shownList, treeGraphics) => {
83
+ const listToUse = Array.isArray(subtree) ? subtree : [subtree];
84
+ for (const l of listToUse) {
85
+ const refStr = l.ref || l;
86
+ if (!shownList.includes(refStr.toLowerCase())) {
87
+ shownList.push(refStr.toLowerCase());
88
+ treeGraphics.push(`${levelPrefix(level)}${refStr}`);
89
+ if (l && depMap[refStr]) {
90
+ if (level < 3) {
91
+ recursePrint(
92
+ depMap,
93
+ depMap[refStr],
94
+ level + 1,
95
+ shownList,
96
+ treeGraphics
97
+ );
98
+ }
99
+ }
100
+ }
101
+ }
102
+ };