@asyncapi/cli 3.2.0 → 3.3.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.
Files changed (191) hide show
  1. package/assets/create-template/templates/default/package-lock.json +4 -3
  2. package/lib/apps/api/app.d.ts +15 -0
  3. package/lib/apps/api/app.js +89 -0
  4. package/lib/apps/api/configs/development.json +16 -0
  5. package/lib/apps/api/configs/production.json +16 -0
  6. package/lib/apps/api/configs/test.json +16 -0
  7. package/lib/apps/api/constants.d.ts +1 -0
  8. package/lib/apps/api/constants.js +4 -0
  9. package/lib/apps/api/controllers/bundle.controller.d.ts +7 -0
  10. package/lib/apps/api/controllers/bundle.controller.js +44 -0
  11. package/lib/apps/api/controllers/convert.controller.d.ts +11 -0
  12. package/lib/apps/api/controllers/convert.controller.js +69 -0
  13. package/lib/apps/api/controllers/diff.controller.d.ts +7 -0
  14. package/lib/apps/api/controllers/diff.controller.js +42 -0
  15. package/lib/apps/api/controllers/docs.controller.d.ts +6 -0
  16. package/lib/apps/api/controllers/docs.controller.js +24 -0
  17. package/lib/apps/api/controllers/generate.controller.d.ts +22 -0
  18. package/lib/apps/api/controllers/generate.controller.js +176 -0
  19. package/lib/apps/api/controllers/help.controller.d.ts +6 -0
  20. package/lib/apps/api/controllers/help.controller.js +101 -0
  21. package/lib/apps/api/controllers/parse.controller.d.ts +10 -0
  22. package/lib/apps/api/controllers/parse.controller.js +35 -0
  23. package/lib/apps/api/controllers/validate.controller.d.ts +10 -0
  24. package/lib/apps/api/controllers/validate.controller.js +50 -0
  25. package/lib/apps/api/exceptions/problem.exception.d.ts +14 -0
  26. package/lib/apps/api/exceptions/problem.exception.js +10 -0
  27. package/lib/apps/api/index.d.ts +9 -0
  28. package/lib/apps/api/index.js +21 -0
  29. package/lib/apps/api/middlewares/problem.middleware.d.ts +6 -0
  30. package/lib/apps/api/middlewares/problem.middleware.js +27 -0
  31. package/lib/apps/api/middlewares/validation.middleware.d.ts +12 -0
  32. package/lib/apps/api/middlewares/validation.middleware.js +236 -0
  33. package/lib/apps/api/server.d.ts +3 -0
  34. package/lib/apps/api/server.js +19 -0
  35. package/lib/{commands → apps/cli/commands}/bundle.d.ts +1 -1
  36. package/lib/{commands → apps/cli/commands}/bundle.js +3 -3
  37. package/lib/{commands → apps/cli/commands}/config/analytics.d.ts +1 -1
  38. package/lib/{commands → apps/cli/commands}/config/analytics.js +4 -3
  39. package/lib/{commands → apps/cli/commands}/config/context/add.d.ts +1 -1
  40. package/lib/{commands → apps/cli/commands}/config/context/add.js +12 -6
  41. package/lib/{commands → apps/cli/commands}/config/context/current.d.ts +1 -1
  42. package/lib/{commands → apps/cli/commands}/config/context/current.js +4 -4
  43. package/lib/{commands → apps/cli/commands}/config/context/edit.d.ts +1 -1
  44. package/lib/{commands → apps/cli/commands}/config/context/edit.js +12 -6
  45. package/lib/{commands → apps/cli/commands}/config/context/index.d.ts +1 -1
  46. package/lib/{commands → apps/cli/commands}/config/context/index.js +1 -1
  47. package/lib/{commands → apps/cli/commands}/config/context/init.d.ts +1 -1
  48. package/lib/{commands → apps/cli/commands}/config/context/init.js +7 -4
  49. package/lib/{commands → apps/cli/commands}/config/context/list.d.ts +1 -1
  50. package/lib/{commands → apps/cli/commands}/config/context/list.js +4 -4
  51. package/lib/{commands → apps/cli/commands}/config/context/remove.d.ts +1 -1
  52. package/lib/{commands → apps/cli/commands}/config/context/remove.js +8 -5
  53. package/lib/{commands → apps/cli/commands}/config/context/use.d.ts +1 -1
  54. package/lib/{commands → apps/cli/commands}/config/context/use.js +8 -5
  55. package/lib/{commands → apps/cli/commands}/config/index.d.ts +1 -1
  56. package/lib/{commands → apps/cli/commands}/config/index.js +1 -1
  57. package/lib/{commands → apps/cli/commands}/config/versions.d.ts +1 -1
  58. package/lib/{commands → apps/cli/commands}/config/versions.js +2 -2
  59. package/lib/{commands → apps/cli/commands}/convert.d.ts +2 -7
  60. package/lib/apps/cli/commands/convert.js +85 -0
  61. package/lib/{commands → apps/cli/commands}/diff.d.ts +11 -2
  62. package/lib/{commands → apps/cli/commands}/diff.js +85 -31
  63. package/lib/{commands → apps/cli/commands}/format.d.ts +1 -1
  64. package/lib/{commands → apps/cli/commands}/format.js +4 -4
  65. package/lib/{commands → apps/cli/commands}/generate/fromTemplate.d.ts +4 -5
  66. package/lib/{commands → apps/cli/commands}/generate/fromTemplate.js +89 -122
  67. package/lib/{commands → apps/cli/commands}/generate/index.d.ts +1 -1
  68. package/lib/{commands → apps/cli/commands}/generate/index.js +1 -1
  69. package/lib/{commands → apps/cli/commands}/generate/models.d.ts +6 -1
  70. package/lib/{commands → apps/cli/commands}/generate/models.js +48 -9
  71. package/lib/{commands → apps/cli/commands}/new/file.d.ts +1 -1
  72. package/lib/{commands → apps/cli/commands}/new/file.js +11 -8
  73. package/lib/{commands → apps/cli/commands}/new/glee.d.ts +2 -2
  74. package/lib/{commands → apps/cli/commands}/new/glee.js +4 -4
  75. package/lib/{commands → apps/cli/commands}/new/index.d.ts +1 -1
  76. package/lib/{commands → apps/cli/commands}/new/index.js +1 -1
  77. package/lib/{commands → apps/cli/commands}/new/template.d.ts +1 -1
  78. package/lib/{commands → apps/cli/commands}/new/template.js +10 -8
  79. package/lib/{commands → apps/cli/commands}/optimize.d.ts +1 -1
  80. package/lib/{commands → apps/cli/commands}/optimize.js +71 -30
  81. package/lib/{commands → apps/cli/commands}/pretty.d.ts +1 -1
  82. package/lib/{commands → apps/cli/commands}/pretty.js +8 -5
  83. package/lib/apps/cli/commands/start/api.d.ts +11 -0
  84. package/lib/apps/cli/commands/start/api.js +23 -0
  85. package/lib/{commands → apps/cli/commands}/start/index.d.ts +1 -1
  86. package/lib/{commands → apps/cli/commands}/start/index.js +1 -1
  87. package/lib/{commands → apps/cli/commands}/start/preview.d.ts +1 -1
  88. package/lib/{commands → apps/cli/commands}/start/preview.js +9 -6
  89. package/lib/{commands → apps/cli/commands}/start/studio.d.ts +1 -1
  90. package/lib/{commands → apps/cli/commands}/start/studio.js +10 -7
  91. package/lib/{commands → apps/cli/commands}/validate.d.ts +4 -2
  92. package/lib/apps/cli/commands/validate.js +94 -0
  93. package/lib/{core → apps/cli/internal}/base.d.ts +1 -1
  94. package/lib/{core → apps/cli/internal}/base.js +12 -4
  95. package/lib/apps/cli/internal/flags/bundle.flags.js +26 -0
  96. package/lib/apps/cli/internal/flags/config/analytics.flags.js +24 -0
  97. package/lib/{core → apps/cli/internal}/flags/config/context.flags.js +1 -1
  98. package/lib/{core → apps/cli/internal}/flags/convert.flags.js +9 -2
  99. package/lib/{core → apps/cli/internal}/flags/diff.flags.d.ts +1 -1
  100. package/lib/{core → apps/cli/internal}/flags/diff.flags.js +3 -3
  101. package/lib/{core → apps/cli/internal}/flags/generate/fromTemplate.flags.js +12 -12
  102. package/lib/{core → apps/cli/internal}/flags/generate/models.flags.js +2 -2
  103. package/lib/{core → apps/cli/internal}/flags/global.flags.js +1 -1
  104. package/lib/{core → apps/cli/internal}/flags/new/file.flags.js +7 -2
  105. package/lib/{core → apps/cli/internal}/flags/optimize.flags.js +24 -4
  106. package/lib/apps/cli/internal/flags/parser.flags.d.ts +10 -0
  107. package/lib/apps/cli/internal/flags/parser.flags.js +28 -0
  108. package/lib/{core → apps/cli/internal}/flags/proxy.flags.js +3 -3
  109. package/lib/apps/cli/internal/flags/start/api.flags.d.ts +5 -0
  110. package/lib/apps/cli/internal/flags/start/api.flags.js +20 -0
  111. package/lib/apps/cli/internal/flags/start/preview.flags.js +31 -0
  112. package/lib/{core → apps/cli/internal}/flags/start/studio.flags.js +9 -2
  113. package/lib/{core → apps/cli/internal}/flags/validate.flags.d.ts +1 -1
  114. package/lib/{core → apps/cli/internal}/flags/validate.flags.js +2 -2
  115. package/lib/{core → apps/cli/internal}/globals.d.ts +1 -1
  116. package/lib/{core → apps/cli/internal}/globals.js +2 -4
  117. package/lib/{core → apps/cli/internal}/hooks/command_not_found/myhook.js +14 -4
  118. package/lib/{core → domains}/models/Context.js +1 -1
  119. package/lib/{core → domains}/models/Preview.js +35 -19
  120. package/lib/{core → domains}/models/SpecificationFile.d.ts +2 -2
  121. package/lib/{core → domains}/models/SpecificationFile.js +8 -5
  122. package/lib/{core → domains}/models/Studio.js +4 -4
  123. package/lib/domains/services/archiver.service.d.ts +17 -0
  124. package/lib/domains/services/archiver.service.js +53 -0
  125. package/lib/domains/services/base.service.d.ts +6 -0
  126. package/lib/domains/services/base.service.js +26 -0
  127. package/lib/domains/services/convert.service.d.ts +12 -0
  128. package/lib/domains/services/convert.service.js +65 -0
  129. package/lib/domains/services/generator.service.d.ts +15 -0
  130. package/lib/domains/services/generator.service.js +95 -0
  131. package/lib/domains/services/validation.service.d.ts +54 -0
  132. package/lib/domains/services/validation.service.js +288 -0
  133. package/lib/{core/errors → errors}/specification-file.js +1 -1
  134. package/lib/{core/errors → errors}/validation-error.js +6 -5
  135. package/lib/interfaces/index.d.ts +87 -0
  136. package/lib/interfaces/index.js +7 -0
  137. package/lib/utils/ajv.d.ts +2 -0
  138. package/lib/utils/ajv.js +18 -0
  139. package/lib/utils/app-openapi.d.ts +4 -0
  140. package/lib/utils/app-openapi.js +28 -0
  141. package/lib/{core/utils/generator.js → utils/fileWatcher.js} +8 -2
  142. package/lib/utils/logger.d.ts +6 -0
  143. package/lib/utils/logger.js +33 -0
  144. package/lib/utils/retrieve-language.d.ts +1 -0
  145. package/lib/utils/retrieve-language.js +9 -0
  146. package/lib/utils/temp-dir.d.ts +2 -0
  147. package/lib/utils/temp-dir.js +25 -0
  148. package/oclif.manifest.json +109 -1
  149. package/package.json +36 -10
  150. package/lib/commands/convert.js +0 -132
  151. package/lib/commands/validate.js +0 -47
  152. package/lib/core/flags/bundle.flags.js +0 -14
  153. package/lib/core/flags/config/analytics.flags.js +0 -13
  154. package/lib/core/flags/start/preview.flags.js +0 -15
  155. package/lib/core/parser.d.ts +0 -35
  156. package/lib/core/parser.js +0 -230
  157. /package/lib/{core → apps/cli/internal}/flags/bundle.flags.d.ts +0 -0
  158. /package/lib/{core → apps/cli/internal}/flags/config/analytics.flags.d.ts +0 -0
  159. /package/lib/{core → apps/cli/internal}/flags/config/context.flags.d.ts +0 -0
  160. /package/lib/{core → apps/cli/internal}/flags/convert.flags.d.ts +0 -0
  161. /package/lib/{core → apps/cli/internal}/flags/format.flags.d.ts +0 -0
  162. /package/lib/{core → apps/cli/internal}/flags/format.flags.js +0 -0
  163. /package/lib/{core → apps/cli/internal}/flags/generate/fromTemplate.flags.d.ts +0 -0
  164. /package/lib/{core → apps/cli/internal}/flags/generate/models.flags.d.ts +0 -0
  165. /package/lib/{core → apps/cli/internal}/flags/global.flags.d.ts +0 -0
  166. /package/lib/{core → apps/cli/internal}/flags/new/file.flags.d.ts +0 -0
  167. /package/lib/{core → apps/cli/internal}/flags/new/glee.flags.d.ts +0 -0
  168. /package/lib/{core → apps/cli/internal}/flags/new/glee.flags.js +0 -0
  169. /package/lib/{core → apps/cli/internal}/flags/new/template.flags.d.ts +0 -0
  170. /package/lib/{core → apps/cli/internal}/flags/new/template.flags.js +0 -0
  171. /package/lib/{core → apps/cli/internal}/flags/optimize.flags.d.ts +0 -0
  172. /package/lib/{core → apps/cli/internal}/flags/pretty.flags.d.ts +0 -0
  173. /package/lib/{core → apps/cli/internal}/flags/pretty.flags.js +0 -0
  174. /package/lib/{core → apps/cli/internal}/flags/proxy.flags.d.ts +0 -0
  175. /package/lib/{core → apps/cli/internal}/flags/start/preview.flags.d.ts +0 -0
  176. /package/lib/{core → apps/cli/internal}/flags/start/studio.flags.d.ts +0 -0
  177. /package/lib/{core → apps/cli/internal}/hooks/command_not_found/myhook.d.ts +0 -0
  178. /package/lib/{core → domains}/models/Context.d.ts +0 -0
  179. /package/lib/{core → domains}/models/Preview.d.ts +0 -0
  180. /package/lib/{core → domains}/models/Studio.d.ts +0 -0
  181. /package/lib/{core/errors → errors}/context-error.d.ts +0 -0
  182. /package/lib/{core/errors → errors}/context-error.js +0 -0
  183. /package/lib/{core/errors → errors}/diff-error.d.ts +0 -0
  184. /package/lib/{core/errors → errors}/diff-error.js +0 -0
  185. /package/lib/{core/errors → errors}/generator-error.d.ts +0 -0
  186. /package/lib/{core/errors → errors}/generator-error.js +0 -0
  187. /package/lib/{core/errors → errors}/specification-file.d.ts +0 -0
  188. /package/lib/{core/errors → errors}/validation-error.d.ts +0 -0
  189. /package/lib/{core/utils/generator.d.ts → utils/fileWatcher.d.ts} +0 -0
  190. /package/lib/{core/utils → utils}/scoreCalculator.d.ts +0 -0
  191. /package/lib/{core/utils → utils}/scoreCalculator.js +0 -0
@@ -62,6 +62,8 @@
62
62
  "isESM": false,
63
63
  "relativePath": [
64
64
  "lib",
65
+ "apps",
66
+ "cli",
65
67
  "commands",
66
68
  "bundle.js"
67
69
  ]
@@ -157,6 +159,8 @@
157
159
  "isESM": false,
158
160
  "relativePath": [
159
161
  "lib",
162
+ "apps",
163
+ "cli",
160
164
  "commands",
161
165
  "convert.js"
162
166
  ]
@@ -303,6 +307,8 @@
303
307
  "isESM": false,
304
308
  "relativePath": [
305
309
  "lib",
310
+ "apps",
311
+ "cli",
306
312
  "commands",
307
313
  "diff.js"
308
314
  ]
@@ -360,6 +366,8 @@
360
366
  "isESM": false,
361
367
  "relativePath": [
362
368
  "lib",
369
+ "apps",
370
+ "cli",
363
371
  "commands",
364
372
  "format.js"
365
373
  ]
@@ -468,6 +476,8 @@
468
476
  "isESM": false,
469
477
  "relativePath": [
470
478
  "lib",
479
+ "apps",
480
+ "cli",
471
481
  "commands",
472
482
  "optimize.js"
473
483
  ]
@@ -506,6 +516,8 @@
506
516
  "isESM": false,
507
517
  "relativePath": [
508
518
  "lib",
519
+ "apps",
520
+ "cli",
509
521
  "commands",
510
522
  "pretty.js"
511
523
  ]
@@ -629,6 +641,8 @@
629
641
  "isESM": false,
630
642
  "relativePath": [
631
643
  "lib",
644
+ "apps",
645
+ "cli",
632
646
  "commands",
633
647
  "validate.js"
634
648
  ]
@@ -677,6 +691,8 @@
677
691
  "isESM": false,
678
692
  "relativePath": [
679
693
  "lib",
694
+ "apps",
695
+ "cli",
680
696
  "commands",
681
697
  "config",
682
698
  "analytics.js"
@@ -697,6 +713,8 @@
697
713
  "isESM": false,
698
714
  "relativePath": [
699
715
  "lib",
716
+ "apps",
717
+ "cli",
700
718
  "commands",
701
719
  "config",
702
720
  "index.js"
@@ -725,6 +743,8 @@
725
743
  "isESM": false,
726
744
  "relativePath": [
727
745
  "lib",
746
+ "apps",
747
+ "cli",
728
748
  "commands",
729
749
  "config",
730
750
  "versions.js"
@@ -883,6 +903,8 @@
883
903
  "isESM": false,
884
904
  "relativePath": [
885
905
  "lib",
906
+ "apps",
907
+ "cli",
886
908
  "commands",
887
909
  "generate",
888
910
  "fromTemplate.js"
@@ -903,6 +925,8 @@
903
925
  "isESM": false,
904
926
  "relativePath": [
905
927
  "lib",
928
+ "apps",
929
+ "cli",
906
930
  "commands",
907
931
  "generate",
908
932
  "index.js"
@@ -1230,6 +1254,8 @@
1230
1254
  "isESM": false,
1231
1255
  "relativePath": [
1232
1256
  "lib",
1257
+ "apps",
1258
+ "cli",
1233
1259
  "commands",
1234
1260
  "generate",
1235
1261
  "models.js"
@@ -1299,6 +1325,8 @@
1299
1325
  "isESM": false,
1300
1326
  "relativePath": [
1301
1327
  "lib",
1328
+ "apps",
1329
+ "cli",
1302
1330
  "commands",
1303
1331
  "new",
1304
1332
  "file.js"
@@ -1360,6 +1388,8 @@
1360
1388
  "isESM": false,
1361
1389
  "relativePath": [
1362
1390
  "lib",
1391
+ "apps",
1392
+ "cli",
1363
1393
  "commands",
1364
1394
  "new",
1365
1395
  "glee.js"
@@ -1380,6 +1410,8 @@
1380
1410
  "isESM": false,
1381
1411
  "relativePath": [
1382
1412
  "lib",
1413
+ "apps",
1414
+ "cli",
1383
1415
  "commands",
1384
1416
  "new",
1385
1417
  "index.js"
@@ -1441,11 +1473,65 @@
1441
1473
  "isESM": false,
1442
1474
  "relativePath": [
1443
1475
  "lib",
1476
+ "apps",
1477
+ "cli",
1444
1478
  "commands",
1445
1479
  "new",
1446
1480
  "template.js"
1447
1481
  ]
1448
1482
  },
1483
+ "start:api": {
1484
+ "aliases": [],
1485
+ "args": {},
1486
+ "description": "starts the AsyncAPI server API.",
1487
+ "flags": {
1488
+ "help": {
1489
+ "char": "h",
1490
+ "description": "Show CLI help.",
1491
+ "name": "help",
1492
+ "allowNo": false,
1493
+ "type": "boolean"
1494
+ },
1495
+ "mode": {
1496
+ "char": "m",
1497
+ "description": "mode in which to start the API",
1498
+ "name": "mode",
1499
+ "default": "production",
1500
+ "hasDynamicHelp": false,
1501
+ "multiple": false,
1502
+ "options": [
1503
+ "development",
1504
+ "production",
1505
+ "test"
1506
+ ],
1507
+ "type": "option"
1508
+ },
1509
+ "port": {
1510
+ "char": "p",
1511
+ "description": "port in which to start the API",
1512
+ "name": "port",
1513
+ "hasDynamicHelp": false,
1514
+ "multiple": false,
1515
+ "type": "option"
1516
+ }
1517
+ },
1518
+ "hasDynamicHelp": false,
1519
+ "hiddenAliases": [],
1520
+ "id": "start:api",
1521
+ "pluginAlias": "@asyncapi/cli",
1522
+ "pluginName": "@asyncapi/cli",
1523
+ "pluginType": "core",
1524
+ "strict": true,
1525
+ "isESM": false,
1526
+ "relativePath": [
1527
+ "lib",
1528
+ "apps",
1529
+ "cli",
1530
+ "commands",
1531
+ "start",
1532
+ "api.js"
1533
+ ]
1534
+ },
1449
1535
  "start": {
1450
1536
  "aliases": [],
1451
1537
  "args": {},
@@ -1461,6 +1547,8 @@
1461
1547
  "isESM": false,
1462
1548
  "relativePath": [
1463
1549
  "lib",
1550
+ "apps",
1551
+ "cli",
1464
1552
  "commands",
1465
1553
  "start",
1466
1554
  "index.js"
@@ -1533,6 +1621,8 @@
1533
1621
  "isESM": false,
1534
1622
  "relativePath": [
1535
1623
  "lib",
1624
+ "apps",
1625
+ "cli",
1536
1626
  "commands",
1537
1627
  "start",
1538
1628
  "preview.js"
@@ -1591,6 +1681,8 @@
1591
1681
  "isESM": false,
1592
1682
  "relativePath": [
1593
1683
  "lib",
1684
+ "apps",
1685
+ "cli",
1594
1686
  "commands",
1595
1687
  "start",
1596
1688
  "studio.js"
@@ -1638,6 +1730,8 @@
1638
1730
  "isESM": false,
1639
1731
  "relativePath": [
1640
1732
  "lib",
1733
+ "apps",
1734
+ "cli",
1641
1735
  "commands",
1642
1736
  "config",
1643
1737
  "context",
@@ -1667,6 +1761,8 @@
1667
1761
  "isESM": false,
1668
1762
  "relativePath": [
1669
1763
  "lib",
1764
+ "apps",
1765
+ "cli",
1670
1766
  "commands",
1671
1767
  "config",
1672
1768
  "context",
@@ -1707,6 +1803,8 @@
1707
1803
  "isESM": false,
1708
1804
  "relativePath": [
1709
1805
  "lib",
1806
+ "apps",
1807
+ "cli",
1710
1808
  "commands",
1711
1809
  "config",
1712
1810
  "context",
@@ -1728,6 +1826,8 @@
1728
1826
  "isESM": false,
1729
1827
  "relativePath": [
1730
1828
  "lib",
1829
+ "apps",
1830
+ "cli",
1731
1831
  "commands",
1732
1832
  "config",
1733
1833
  "context",
@@ -1764,6 +1864,8 @@
1764
1864
  "isESM": false,
1765
1865
  "relativePath": [
1766
1866
  "lib",
1867
+ "apps",
1868
+ "cli",
1767
1869
  "commands",
1768
1870
  "config",
1769
1871
  "context",
@@ -1793,6 +1895,8 @@
1793
1895
  "isESM": false,
1794
1896
  "relativePath": [
1795
1897
  "lib",
1898
+ "apps",
1899
+ "cli",
1796
1900
  "commands",
1797
1901
  "config",
1798
1902
  "context",
@@ -1828,6 +1932,8 @@
1828
1932
  "isESM": false,
1829
1933
  "relativePath": [
1830
1934
  "lib",
1935
+ "apps",
1936
+ "cli",
1831
1937
  "commands",
1832
1938
  "config",
1833
1939
  "context",
@@ -1863,6 +1969,8 @@
1863
1969
  "isESM": false,
1864
1970
  "relativePath": [
1865
1971
  "lib",
1972
+ "apps",
1973
+ "cli",
1866
1974
  "commands",
1867
1975
  "config",
1868
1976
  "context",
@@ -1870,5 +1978,5 @@
1870
1978
  ]
1871
1979
  }
1872
1980
  },
1873
- "version": "3.2.0"
1981
+ "version": "3.3.0"
1874
1982
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asyncapi/cli",
3
3
  "description": "All in one CLI for all AsyncAPI tools",
4
- "version": "3.2.0",
4
+ "version": "3.3.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -17,6 +17,7 @@
17
17
  "@asyncapi/openapi-schema-parser": "^3.0.24",
18
18
  "@asyncapi/optimizer": "^1.0.4",
19
19
  "@asyncapi/parser": "^3.3.0",
20
+ "@asyncapi/problem": "^1.0.0",
20
21
  "@asyncapi/protobuf-schema-parser": "^3.5.1",
21
22
  "@asyncapi/raml-dt-schema-parser": "^4.0.24",
22
23
  "@asyncapi/studio": "^0.24.2",
@@ -26,29 +27,46 @@
26
27
  "@oclif/plugin-autocomplete": "^3.2.26",
27
28
  "@smoya/asyncapi-adoption-metrics": "^2.4.9",
28
29
  "@stoplight/spectral-cli": "6.9.0",
30
+ "archiver": "^7.0.1",
31
+ "body-parser": "^2.2.0",
29
32
  "chalk": "^4.1.0",
30
33
  "chokidar": "^3.5.2",
34
+ "compression": "^1.8.0",
35
+ "config": "^4.0.0",
36
+ "cors": "^2.8.5",
37
+ "express": "^4.17.1",
31
38
  "fast-levenshtein": "^3.0.0",
32
39
  "fs-extra": "^11.1.0",
33
- "generator-v2": "npm:@asyncapi/generator@^2.4.1",
40
+ "generator-v2": "npm:@asyncapi/generator@2.4.1",
41
+ "helmet": "^8.1.0",
34
42
  "https-proxy-agent": "^7.0.6",
35
43
  "inquirer": "^8.2.0",
36
44
  "js-yaml": "^4.1.0",
37
45
  "next": "^15.2.4",
38
46
  "oclif": "^4.17.34",
39
47
  "open": "^8.4.0",
40
- "picocolors": "^1.0.0",
48
+ "picocolors": "^1.1.0",
49
+ "redoc-express": "^2.1.0",
41
50
  "unzipper": "^0.10.11",
42
51
  "uuid": "^11.1.0",
52
+ "winston": "^3.17.0",
43
53
  "ws": "^8.2.3",
44
54
  "yaml": "^2.6.1"
45
55
  },
46
56
  "devDependencies": {
47
57
  "@asyncapi/minimaltemplate": "./test/fixtures/minimaltemplate",
48
58
  "@asyncapi/newtemplate": "./test/fixtures/newtemplate",
59
+ "@commitlint/cli": "^19.8.1",
60
+ "@commitlint/config-conventional": "^19.8.1",
49
61
  "@oclif/test": "^2",
50
62
  "@swc/core": "^1.3.2",
63
+ "@types/archiver": "^6.0.3",
64
+ "@types/body-parser": "^1.19.6",
51
65
  "@types/chai": "^4.3.6",
66
+ "@types/compression": "^1.8.1",
67
+ "@types/config": "^3.3.5",
68
+ "@types/cors": "^2.8.19",
69
+ "@types/express": "^5.0.3",
52
70
  "@types/fast-levenshtein": "^0.0.2",
53
71
  "@types/fs-extra": "^11.0.1",
54
72
  "@types/inquirer": "^8.1.3",
@@ -68,12 +86,16 @@
68
86
  "eslint-plugin-github": "^4.3.7",
69
87
  "eslint-plugin-security": "^1.4.0",
70
88
  "eslint-plugin-sonarjs": "^0.15.0",
89
+ "lefthook": "^1.12.2",
71
90
  "markdown-toc": "^1.2.0",
72
91
  "mocha": "^10.2.0",
92
+ "nodemon": "^3.1.10",
73
93
  "nyc": "^15.1.0",
74
94
  "rimraf": "^3.0.2",
75
95
  "simple-git": "^3.16.0",
76
96
  "ts-node": "^10.9.1",
97
+ "tsc-alias": "^1.8.16",
98
+ "tsconfig-paths": "^4.2.0",
77
99
  "typescript": "^5.8.2"
78
100
  },
79
101
  "engines": {
@@ -94,14 +116,14 @@
94
116
  "license": "Apache-2.0",
95
117
  "main": "lib/index.js",
96
118
  "oclif": {
97
- "commands": "./lib/commands",
119
+ "commands": "./lib/apps/cli/commands",
98
120
  "bin": "asyncapi",
99
121
  "additionalVersionFlags": [
100
122
  "--v"
101
123
  ],
102
124
  "hooks": {
103
125
  "command_not_found": [
104
- "./lib/core/hooks/command_not_found/myhook"
126
+ "./lib/apps/cli/internal/hooks/command_not_found/myhook"
105
127
  ]
106
128
  },
107
129
  "macos": {
@@ -135,7 +157,7 @@
135
157
  },
136
158
  "repository": "asyncapi/cli",
137
159
  "scripts": {
138
- "build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && oclif manifest && echo \"Build Completed\"",
160
+ "build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && tsc-alias --project tsconfig.json && oclif manifest && echo \"Build Completed\"",
139
161
  "bump:github-action": "cd github-action/lib/ && node bump-action-version.js",
140
162
  "bump:version": "npx -p @changesets/cli@2.27.7 changeset version && npm run bump:github-action",
141
163
  "dev": "tsc --watch",
@@ -145,6 +167,7 @@
145
167
  "generate:assets": "npm run generate:readme:toc && npm run generate:commands",
146
168
  "generate:commands": "npm run generate:readme:create && npm run generate:readme:commands && node ./scripts/updateUsageDocs.js && rimraf ./scripts/README.md",
147
169
  "generate:readme:toc": "markdown-toc -i README.md",
170
+ "prepare": "lefthook install",
148
171
  "lint": "eslint --max-warnings 5 --config .eslintrc .",
149
172
  "lint:fix": "eslint --max-warnings 5 --config .eslintrc . --fix",
150
173
  "pack:macos": "oclif pack macos && npm run pack:rename",
@@ -157,14 +180,17 @@
157
180
  "pretest:coverage": "npm run build",
158
181
  "posttest": "rimraf ./test.asyncapi-cli",
159
182
  "postinstall": "node ./scripts/enableAutoComplete.js",
160
- "test": "npm run test:unit && npm run action:test",
161
- "test:unit": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" nyc --extension .ts mocha --require ts-node/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/**/*.test.ts\"",
162
- "test:one": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" nyc --extension .ts mocha --require ts-node/register --require test/helpers/init.js --reporter spec --timeout 100000",
183
+ "test": "npm run cli:test && npm run action:test",
184
+ "cli:test": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" nyc --extension .ts mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/**/*.test.ts\"",
185
+ "test:one": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" nyc --extension .ts mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000",
163
186
  "get-version": "echo $npm_package_version",
164
187
  "createhook": "oclif generate hook myhook --event=command_not_found",
165
188
  "createhookinit": "oclif generate hook inithook --event=init",
166
189
  "action:docker:build": "docker build -f github-action/Dockerfile -t asyncapi/github-action-for-cli:latest .",
167
- "action:test": "npm run build && cd github-action && make test"
190
+ "action:test": "npm run build && cd github-action && make test",
191
+ "api:dev": "cross-env NODE_ENV=development PORT=3000 nodemon",
192
+ "api:build": "",
193
+ "api:test": ""
168
194
  },
169
195
  "types": "lib/index.d.ts"
170
196
  }
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /* eslint-disable @typescript-eslint/ban-ts-comment */
5
- const fs_1 = require("fs");
6
- const core_1 = require("@oclif/core");
7
- const base_1 = tslib_1.__importDefault(require("../core/base"));
8
- const validation_error_1 = require("../core/errors/validation-error");
9
- const SpecificationFile_1 = require("../core/models/SpecificationFile");
10
- const specification_file_1 = require("../core/errors/specification-file");
11
- const converter_1 = require("@asyncapi/converter");
12
- const picocolors_1 = require("picocolors");
13
- const proxy_flags_1 = require("../core/flags/proxy.flags");
14
- // @ts-ignore
15
- const specs_1 = tslib_1.__importDefault(require("@asyncapi/specs"));
16
- const convert_flags_1 = require("../core/flags/convert.flags");
17
- const latestVersion = Object.keys(specs_1.default.schemas).pop();
18
- class Convert extends base_1.default {
19
- run() {
20
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
- const { args, flags } = yield this.parse(Convert);
22
- let filePath = args['spec-file'];
23
- const proxyHost = flags['proxyHost'];
24
- const proxyPort = flags['proxyPort'];
25
- if (proxyHost && proxyPort) {
26
- const proxyUrl = `http://${proxyHost}:${proxyPort}`;
27
- filePath = `${filePath}+${proxyUrl}`; // Update filePath with proxyUrl
28
- }
29
- let convertedFile;
30
- let convertedFileFormatted;
31
- try {
32
- // LOAD FILE
33
- this.specFile = yield (0, SpecificationFile_1.load)(filePath);
34
- // eslint-disable-next-line sonarjs/no-duplicate-string
35
- this.metricsMetadata.to_version = flags['target-version'];
36
- // Determine if the input is OpenAPI or AsyncAPI
37
- const isOpenAPI = flags['format'] === 'openapi';
38
- const isAsyncAPI = flags['format'] === 'asyncapi';
39
- // CONVERSION
40
- convertedFile = this.handleConversion(isOpenAPI, isAsyncAPI, flags);
41
- // Handle file output or log the result
42
- convertedFileFormatted = this.formatConvertedFile(convertedFile);
43
- yield this.handleOutput(flags.output, convertedFileFormatted);
44
- }
45
- catch (err) {
46
- this.handleError(err, filePath !== null && filePath !== void 0 ? filePath : 'unknown', flags);
47
- }
48
- });
49
- }
50
- // Helper function to handle conversion logic
51
- handleConversion(isOpenAPI, isAsyncAPI, flags) {
52
- var _a;
53
- const specJson = (_a = this.specFile) === null || _a === void 0 ? void 0 : _a.toJson();
54
- if (isOpenAPI) {
55
- return this.convertOpenAPI(specJson, flags);
56
- }
57
- else if (isAsyncAPI) {
58
- return this.convertAsyncAPI(flags);
59
- }
60
- return this.convertPostman(flags);
61
- }
62
- convertOpenAPI(specJson, flags) {
63
- var _a, _b;
64
- const convertedFile = (0, converter_1.convertOpenAPI)((_b = (_a = this.specFile) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : '', specJson.openapi, {
65
- perspective: flags['perspective']
66
- });
67
- this.log(`🎉 The OpenAPI document has been successfully converted to AsyncAPI version ${(0, picocolors_1.green)(flags['target-version'])}!`);
68
- return convertedFile;
69
- }
70
- convertAsyncAPI(flags) {
71
- var _a, _b, _c, _d, _e, _f;
72
- const convertedFile = (0, converter_1.convert)((_b = (_a = this.specFile) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : '', flags['target-version']);
73
- if ((_c = this.specFile) === null || _c === void 0 ? void 0 : _c.getFilePath()) {
74
- this.log(`🎉 The ${(0, picocolors_1.cyan)((_d = this.specFile) === null || _d === void 0 ? void 0 : _d.getFilePath())} file has been successfully converted to version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
75
- }
76
- else if ((_e = this.specFile) === null || _e === void 0 ? void 0 : _e.getFileURL()) {
77
- this.log(`🎉 The URL ${(0, picocolors_1.cyan)((_f = this.specFile) === null || _f === void 0 ? void 0 : _f.getFileURL())} has been successfully converted to version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
78
- }
79
- return convertedFile;
80
- }
81
- convertPostman(flags) {
82
- var _a, _b, _c, _d, _e, _f;
83
- const convertedFile = (0, converter_1.convertPostman)((_b = (_a = this.specFile) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : '', '3.0.0', {
84
- perspective: flags['perspective']
85
- });
86
- if ((_c = this.specFile) === null || _c === void 0 ? void 0 : _c.getFilePath()) {
87
- this.log(`🎉 The ${(0, picocolors_1.cyan)((_d = this.specFile) === null || _d === void 0 ? void 0 : _d.getFilePath())} file has been successfully converted to asyncapi of version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
88
- }
89
- else if ((_e = this.specFile) === null || _e === void 0 ? void 0 : _e.getFileURL()) {
90
- this.log(`🎉 The URL ${(0, picocolors_1.cyan)((_f = this.specFile) === null || _f === void 0 ? void 0 : _f.getFileURL())} has been successfully converted to asyncapi of version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
91
- }
92
- return convertedFile;
93
- }
94
- // Helper function to format the converted file
95
- formatConvertedFile(convertedFile) {
96
- return typeof convertedFile === 'object' ? JSON.stringify(convertedFile, null, 4) : convertedFile;
97
- }
98
- // Helper function to handle output
99
- handleOutput(outputPath, convertedFileFormatted) {
100
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
101
- if (outputPath) {
102
- yield fs_1.promises.writeFile(`${outputPath}`, convertedFileFormatted, { encoding: 'utf8' });
103
- }
104
- else {
105
- this.log(convertedFileFormatted);
106
- }
107
- });
108
- }
109
- // Helper function to handle errors
110
- handleError(err, filePath, flags) {
111
- var _a;
112
- if (err instanceof specification_file_1.SpecificationFileNotFound) {
113
- this.error(new validation_error_1.ValidationError({
114
- type: 'invalid-file',
115
- filepath: filePath
116
- }));
117
- }
118
- else if (((_a = this.specFile) === null || _a === void 0 ? void 0 : _a.toJson().asyncapi) > flags['target-version']) {
119
- this.error(`The ${(0, picocolors_1.cyan)(filePath)} file cannot be converted to an older version. Downgrading is not supported.`);
120
- }
121
- else {
122
- this.error(err);
123
- }
124
- }
125
- }
126
- Convert.metricsMetadata = {};
127
- Convert.description = 'Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI';
128
- Convert.flags = Object.assign(Object.assign({}, (0, convert_flags_1.convertFlags)(latestVersion)), (0, proxy_flags_1.proxyFlags)());
129
- Convert.args = {
130
- 'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
131
- };
132
- exports.default = Convert;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const core_1 = require("@oclif/core");
5
- const base_1 = tslib_1.__importDefault(require("../core/base"));
6
- const parser_1 = require("../core/parser");
7
- const SpecificationFile_1 = require("../core/models/SpecificationFile");
8
- const globals_1 = require("../core/globals");
9
- const validate_flags_1 = require("../core/flags/validate.flags");
10
- const proxy_flags_1 = require("../core/flags/proxy.flags");
11
- const scoreCalculator_1 = require("../core/utils/scoreCalculator");
12
- class Validate extends base_1.default {
13
- run() {
14
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
- const { args, flags } = yield this.parse(Validate); //NOSONAR
16
- let filePath = args['spec-file'];
17
- const proxyHost = flags['proxyHost'];
18
- const proxyPort = flags['proxyPort'];
19
- if (proxyHost && proxyPort) {
20
- const proxyUrl = `http://${proxyHost}:${proxyPort}`;
21
- filePath = `${filePath}+${proxyUrl}`; // Update filePath with proxyUrl
22
- }
23
- this.specFile = yield (0, SpecificationFile_1.load)(filePath);
24
- const watchMode = flags.watch;
25
- if (flags['score']) {
26
- const { document } = yield (0, parser_1.parse)(this, this.specFile);
27
- this.log(`The score of the asyncapi document is ${yield (0, scoreCalculator_1.calculateScore)(document)}`);
28
- }
29
- if (watchMode) {
30
- (0, globals_1.specWatcher)({ spec: this.specFile, handler: this, handlerName: 'validate' });
31
- }
32
- // Prepare validate options
33
- const validateOptions = Object.assign(Object.assign({}, flags), { suppressWarnings: flags['suppressWarnings'], suppressAllWarnings: flags['suppressAllWarnings'] });
34
- const result = yield (0, parser_1.validate)(this, this.specFile, validateOptions);
35
- this.metricsMetadata.validation_result = result;
36
- if (result === parser_1.ValidationStatus.INVALID) {
37
- process.exitCode = 1;
38
- }
39
- });
40
- }
41
- }
42
- Validate.description = 'validate asyncapi file';
43
- Validate.flags = Object.assign(Object.assign({}, (0, validate_flags_1.validateFlags)()), (0, proxy_flags_1.proxyFlags)());
44
- Validate.args = {
45
- 'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
46
- };
47
- exports.default = Validate;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bundleFlags = void 0;
4
- const core_1 = require("@oclif/core");
5
- const bundleFlags = () => {
6
- return {
7
- help: core_1.Flags.help({ char: 'h' }),
8
- output: core_1.Flags.string({ char: 'o', description: 'The output file name. Omitting this flag the result will be printed in the console.' }),
9
- base: core_1.Flags.string({ char: 'b', description: 'Path to the file which will act as a base. This is required when some properties need to be overwritten.' }),
10
- baseDir: core_1.Flags.string({ char: 'd', description: 'One relative/absolute path to directory relative to which paths to AsyncAPI Documents that should be bundled will be resolved.' }),
11
- xOrigin: core_1.Flags.boolean({ char: 'x', description: 'Pass this switch to generate properties "x-origin" that will contain historical values of dereferenced "$ref"s.' }),
12
- };
13
- };
14
- exports.bundleFlags = bundleFlags;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.analyticsFlags = void 0;
4
- const core_1 = require("@oclif/core");
5
- const analyticsFlags = () => {
6
- return {
7
- help: core_1.Flags.help({ char: 'h' }),
8
- disable: core_1.Flags.boolean({ char: 'd', description: 'disable analytics', default: false }),
9
- enable: core_1.Flags.boolean({ char: 'e', description: 'enable analytics', default: false }),
10
- status: core_1.Flags.boolean({ char: 's', description: 'show current status of analytics' }),
11
- };
12
- };
13
- exports.analyticsFlags = analyticsFlags;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.previewFlags = void 0;
4
- const core_1 = require("@oclif/core");
5
- const previewFlags = () => {
6
- return {
7
- help: core_1.Flags.help({ char: 'h' }),
8
- port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio in the preview mode' }),
9
- base: core_1.Flags.string({ char: 'b', description: 'Path to the file which will act as a base. This is required when some properties need to be overwritten while bundling with the file.' }),
10
- baseDir: core_1.Flags.string({ char: 'd', description: 'One relative/absolute path to directory relative to which paths to AsyncAPI Documents that should be bundled will be resolved.' }),
11
- xOrigin: core_1.Flags.boolean({ char: 'x', description: 'Pass this switch to generate properties "x-origin" that will contain historical values of dereferenced "$ref"s.' }),
12
- suppressLogs: core_1.Flags.boolean({ char: 'l', description: 'Pass this to suppress the detiled error logs.', default: false })
13
- };
14
- };
15
- exports.previewFlags = previewFlags;