@asyncapi/cli 5.0.5 → 5.0.7

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.
@@ -3330,9 +3330,10 @@
3330
3330
  }
3331
3331
  },
3332
3332
  "node_modules/lodash": {
3333
- "version": "4.17.21",
3334
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
3335
- "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
3333
+ "version": "4.17.23",
3334
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
3335
+ "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
3336
+ "license": "MIT"
3336
3337
  },
3337
3338
  "node_modules/lodash.debounce": {
3338
3339
  "version": "4.0.8",
@@ -44,6 +44,29 @@ const convertGitHubWebUrl = (url) => {
44
44
  }
45
45
  return url;
46
46
  };
47
+ /**
48
+ * Helper function to fetch with error handling
49
+ */
50
+ const fetchWithErrorHandling = (url, headers, errorMessage) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
51
+ const res = yield fetch(url, { headers });
52
+ if (!res.ok) {
53
+ throw new Error(`${errorMessage}: ${url} - ${res.statusText}`);
54
+ }
55
+ return res;
56
+ });
57
+ /**
58
+ * Helper function to fetch content from GitHub API
59
+ */
60
+ const fetchGitHubApiContent = (url, headers) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
61
+ headers['Accept'] = 'application/vnd.github.v3+json';
62
+ const res = yield fetchWithErrorHandling(url, headers, 'Failed to fetch GitHub API URL');
63
+ const fileInfo = (yield res.json());
64
+ if (!fileInfo.download_url) {
65
+ throw new Error(`No download URL found in GitHub API response for: ${url}`);
66
+ }
67
+ const contentRes = yield fetchWithErrorHandling(fileInfo.download_url, headers, 'Failed to fetch content from download URL');
68
+ return yield contentRes.text();
69
+ });
47
70
  /**
48
71
  * Custom resolver for private repositories
49
72
  */
@@ -65,36 +88,15 @@ const createHttpWithAuthResolver = () => ({
65
88
  Object.assign(headers, authInfo.headers); // merge custom headers
66
89
  }
67
90
  if (url.includes('api.github.com')) {
68
- headers['Accept'] = 'application/vnd.github.v3+json';
69
- const res = yield fetch(url, { headers });
70
- if (!res.ok) {
71
- throw new Error(`Failed to fetch GitHub API URL: ${url} - ${res.statusText}`);
72
- }
73
- const fileInfo = (yield res.json());
74
- if (fileInfo.download_url) {
75
- const contentRes = yield fetch(fileInfo.download_url, { headers });
76
- if (!contentRes.ok) {
77
- throw new Error(`Failed to fetch content from download URL: ${fileInfo.download_url} - ${contentRes.statusText}`);
78
- }
79
- return yield contentRes.text();
80
- }
81
- throw new Error(`No download URL found in GitHub API response for: ${url}`);
91
+ return yield fetchGitHubApiContent(url, headers);
82
92
  }
83
- else if (url.includes('raw.githubusercontent.com')) {
93
+ if (url.includes('raw.githubusercontent.com')) {
84
94
  headers['Accept'] = 'application/vnd.github.v3.raw';
85
- const res = yield fetch(url, { headers });
86
- if (!res.ok) {
87
- throw new Error(`Failed to fetch GitHub URL: ${url} - ${res.statusText}`);
88
- }
89
- return yield res.text();
90
- }
91
- else {
92
- const res = yield fetch(url, { headers });
93
- if (!res.ok) {
94
- throw new Error(`Failed to fetch URL: ${url} - ${res.statusText}`);
95
- }
95
+ const res = yield fetchWithErrorHandling(url, headers, 'Failed to fetch GitHub URL');
96
96
  return yield res.text();
97
97
  }
98
+ const res = yield fetchWithErrorHandling(url, headers, 'Failed to fetch URL');
99
+ return yield res.text();
98
100
  }),
99
101
  });
100
102
  const { writeFile } = fs_1.promises;
@@ -1427,6 +1427,162 @@
1427
1427
  "models.js"
1428
1428
  ]
1429
1429
  },
1430
+ "new:file": {
1431
+ "aliases": [],
1432
+ "args": {},
1433
+ "description": "Creates a new asyncapi file",
1434
+ "examples": [
1435
+ "asyncapi new\t - start creation of a file in interactive mode",
1436
+ "asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
1437
+ ],
1438
+ "flags": {
1439
+ "help": {
1440
+ "char": "h",
1441
+ "description": "Show CLI help.",
1442
+ "name": "help",
1443
+ "allowNo": false,
1444
+ "type": "boolean"
1445
+ },
1446
+ "file-name": {
1447
+ "char": "n",
1448
+ "description": "name of the file",
1449
+ "name": "file-name",
1450
+ "hasDynamicHelp": false,
1451
+ "multiple": false,
1452
+ "type": "option"
1453
+ },
1454
+ "example": {
1455
+ "char": "e",
1456
+ "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - adeo-kafka-request-reply-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
1457
+ "name": "example",
1458
+ "hasDynamicHelp": false,
1459
+ "multiple": false,
1460
+ "type": "option"
1461
+ },
1462
+ "studio": {
1463
+ "char": "s",
1464
+ "description": "open in Studio",
1465
+ "name": "studio",
1466
+ "allowNo": false,
1467
+ "type": "boolean"
1468
+ },
1469
+ "port": {
1470
+ "char": "p",
1471
+ "description": "port in which to start Studio",
1472
+ "name": "port",
1473
+ "hasDynamicHelp": false,
1474
+ "multiple": false,
1475
+ "type": "option"
1476
+ },
1477
+ "no-tty": {
1478
+ "description": "do not use an interactive terminal",
1479
+ "name": "no-tty",
1480
+ "allowNo": false,
1481
+ "type": "boolean"
1482
+ }
1483
+ },
1484
+ "hasDynamicHelp": false,
1485
+ "hiddenAliases": [],
1486
+ "id": "new:file",
1487
+ "pluginAlias": "@asyncapi/cli",
1488
+ "pluginName": "@asyncapi/cli",
1489
+ "pluginType": "core",
1490
+ "strict": true,
1491
+ "isESM": false,
1492
+ "relativePath": [
1493
+ "lib",
1494
+ "apps",
1495
+ "cli",
1496
+ "commands",
1497
+ "new",
1498
+ "file.js"
1499
+ ]
1500
+ },
1501
+ "new": {
1502
+ "aliases": [],
1503
+ "args": {},
1504
+ "description": "Create a new AsyncAPI project, specification files, or templates for clients and applications.",
1505
+ "flags": {},
1506
+ "hasDynamicHelp": false,
1507
+ "hiddenAliases": [],
1508
+ "id": "new",
1509
+ "pluginAlias": "@asyncapi/cli",
1510
+ "pluginName": "@asyncapi/cli",
1511
+ "pluginType": "core",
1512
+ "strict": true,
1513
+ "isESM": false,
1514
+ "relativePath": [
1515
+ "lib",
1516
+ "apps",
1517
+ "cli",
1518
+ "commands",
1519
+ "new",
1520
+ "index.js"
1521
+ ]
1522
+ },
1523
+ "new:template": {
1524
+ "aliases": [],
1525
+ "args": {},
1526
+ "description": "Creates a new template",
1527
+ "flags": {
1528
+ "help": {
1529
+ "char": "h",
1530
+ "description": "Show CLI help.",
1531
+ "name": "help",
1532
+ "allowNo": false,
1533
+ "type": "boolean"
1534
+ },
1535
+ "name": {
1536
+ "char": "n",
1537
+ "description": "Name of the Project",
1538
+ "name": "name",
1539
+ "default": "project",
1540
+ "hasDynamicHelp": false,
1541
+ "multiple": false,
1542
+ "type": "option"
1543
+ },
1544
+ "template": {
1545
+ "char": "t",
1546
+ "description": "Name of the Template",
1547
+ "name": "template",
1548
+ "default": "default",
1549
+ "hasDynamicHelp": false,
1550
+ "multiple": false,
1551
+ "type": "option"
1552
+ },
1553
+ "file": {
1554
+ "char": "f",
1555
+ "description": "The path to the AsyncAPI file for generating a template.",
1556
+ "name": "file",
1557
+ "hasDynamicHelp": false,
1558
+ "multiple": false,
1559
+ "type": "option"
1560
+ },
1561
+ "force-write": {
1562
+ "description": "Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)",
1563
+ "name": "force-write",
1564
+ "allowNo": false,
1565
+ "type": "boolean"
1566
+ }
1567
+ },
1568
+ "hasDynamicHelp": false,
1569
+ "hiddenAliases": [],
1570
+ "id": "new:template",
1571
+ "pluginAlias": "@asyncapi/cli",
1572
+ "pluginName": "@asyncapi/cli",
1573
+ "pluginType": "core",
1574
+ "strict": true,
1575
+ "errorMessages": {},
1576
+ "isESM": false,
1577
+ "relativePath": [
1578
+ "lib",
1579
+ "apps",
1580
+ "cli",
1581
+ "commands",
1582
+ "new",
1583
+ "template.js"
1584
+ ]
1585
+ },
1430
1586
  "start:api": {
1431
1587
  "aliases": [],
1432
1588
  "args": {},
@@ -1649,162 +1805,6 @@
1649
1805
  "studio.js"
1650
1806
  ]
1651
1807
  },
1652
- "new:file": {
1653
- "aliases": [],
1654
- "args": {},
1655
- "description": "Creates a new asyncapi file",
1656
- "examples": [
1657
- "asyncapi new\t - start creation of a file in interactive mode",
1658
- "asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
1659
- ],
1660
- "flags": {
1661
- "help": {
1662
- "char": "h",
1663
- "description": "Show CLI help.",
1664
- "name": "help",
1665
- "allowNo": false,
1666
- "type": "boolean"
1667
- },
1668
- "file-name": {
1669
- "char": "n",
1670
- "description": "name of the file",
1671
- "name": "file-name",
1672
- "hasDynamicHelp": false,
1673
- "multiple": false,
1674
- "type": "option"
1675
- },
1676
- "example": {
1677
- "char": "e",
1678
- "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - adeo-kafka-request-reply-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
1679
- "name": "example",
1680
- "hasDynamicHelp": false,
1681
- "multiple": false,
1682
- "type": "option"
1683
- },
1684
- "studio": {
1685
- "char": "s",
1686
- "description": "open in Studio",
1687
- "name": "studio",
1688
- "allowNo": false,
1689
- "type": "boolean"
1690
- },
1691
- "port": {
1692
- "char": "p",
1693
- "description": "port in which to start Studio",
1694
- "name": "port",
1695
- "hasDynamicHelp": false,
1696
- "multiple": false,
1697
- "type": "option"
1698
- },
1699
- "no-tty": {
1700
- "description": "do not use an interactive terminal",
1701
- "name": "no-tty",
1702
- "allowNo": false,
1703
- "type": "boolean"
1704
- }
1705
- },
1706
- "hasDynamicHelp": false,
1707
- "hiddenAliases": [],
1708
- "id": "new:file",
1709
- "pluginAlias": "@asyncapi/cli",
1710
- "pluginName": "@asyncapi/cli",
1711
- "pluginType": "core",
1712
- "strict": true,
1713
- "isESM": false,
1714
- "relativePath": [
1715
- "lib",
1716
- "apps",
1717
- "cli",
1718
- "commands",
1719
- "new",
1720
- "file.js"
1721
- ]
1722
- },
1723
- "new": {
1724
- "aliases": [],
1725
- "args": {},
1726
- "description": "Create a new AsyncAPI project, specification files, or templates for clients and applications.",
1727
- "flags": {},
1728
- "hasDynamicHelp": false,
1729
- "hiddenAliases": [],
1730
- "id": "new",
1731
- "pluginAlias": "@asyncapi/cli",
1732
- "pluginName": "@asyncapi/cli",
1733
- "pluginType": "core",
1734
- "strict": true,
1735
- "isESM": false,
1736
- "relativePath": [
1737
- "lib",
1738
- "apps",
1739
- "cli",
1740
- "commands",
1741
- "new",
1742
- "index.js"
1743
- ]
1744
- },
1745
- "new:template": {
1746
- "aliases": [],
1747
- "args": {},
1748
- "description": "Creates a new template",
1749
- "flags": {
1750
- "help": {
1751
- "char": "h",
1752
- "description": "Show CLI help.",
1753
- "name": "help",
1754
- "allowNo": false,
1755
- "type": "boolean"
1756
- },
1757
- "name": {
1758
- "char": "n",
1759
- "description": "Name of the Project",
1760
- "name": "name",
1761
- "default": "project",
1762
- "hasDynamicHelp": false,
1763
- "multiple": false,
1764
- "type": "option"
1765
- },
1766
- "template": {
1767
- "char": "t",
1768
- "description": "Name of the Template",
1769
- "name": "template",
1770
- "default": "default",
1771
- "hasDynamicHelp": false,
1772
- "multiple": false,
1773
- "type": "option"
1774
- },
1775
- "file": {
1776
- "char": "f",
1777
- "description": "The path to the AsyncAPI file for generating a template.",
1778
- "name": "file",
1779
- "hasDynamicHelp": false,
1780
- "multiple": false,
1781
- "type": "option"
1782
- },
1783
- "force-write": {
1784
- "description": "Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)",
1785
- "name": "force-write",
1786
- "allowNo": false,
1787
- "type": "boolean"
1788
- }
1789
- },
1790
- "hasDynamicHelp": false,
1791
- "hiddenAliases": [],
1792
- "id": "new:template",
1793
- "pluginAlias": "@asyncapi/cli",
1794
- "pluginName": "@asyncapi/cli",
1795
- "pluginType": "core",
1796
- "strict": true,
1797
- "errorMessages": {},
1798
- "isESM": false,
1799
- "relativePath": [
1800
- "lib",
1801
- "apps",
1802
- "cli",
1803
- "commands",
1804
- "new",
1805
- "template.js"
1806
- ]
1807
- },
1808
1808
  "config:auth:add": {
1809
1809
  "aliases": [],
1810
1810
  "args": {
@@ -2146,5 +2146,5 @@
2146
2146
  ]
2147
2147
  }
2148
2148
  },
2149
- "version": "5.0.5"
2149
+ "version": "5.0.7"
2150
2150
  }
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": "5.0.5",
4
+ "version": "5.0.7",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -14,9 +14,9 @@
14
14
  "dependencies": {
15
15
  "@asyncapi/avro-schema-parser": "^3.0.24",
16
16
  "@asyncapi/bundler": "^0.6.4",
17
- "@asyncapi/converter": "^1.6.2",
17
+ "@asyncapi/converter": "^1.7.0",
18
18
  "@asyncapi/diff": "^0.5.0",
19
- "@asyncapi/generator": "^3.0.1",
19
+ "@asyncapi/generator": "^3.1.1",
20
20
  "@asyncapi/modelina-cli": "^5.10.1",
21
21
  "@asyncapi/openapi-schema-parser": "^3.0.24",
22
22
  "@asyncapi/optimizer": "^1.0.4",