@asyncapi/cli 5.0.5 → 5.0.6
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.
|
@@ -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
|
-
|
|
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
|
-
|
|
93
|
+
if (url.includes('raw.githubusercontent.com')) {
|
|
84
94
|
headers['Accept'] = 'application/vnd.github.v3.raw';
|
|
85
|
-
const res = yield
|
|
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;
|
package/oclif.manifest.json
CHANGED
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.
|
|
4
|
+
"version": "5.0.6",
|
|
5
5
|
"author": "@asyncapi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"asyncapi": "./bin/run_bin"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@asyncapi/bundler": "^0.6.4",
|
|
17
17
|
"@asyncapi/converter": "^1.6.2",
|
|
18
18
|
"@asyncapi/diff": "^0.5.0",
|
|
19
|
-
"@asyncapi/generator": "^3.0
|
|
19
|
+
"@asyncapi/generator": "^3.1.0",
|
|
20
20
|
"@asyncapi/modelina-cli": "^5.10.1",
|
|
21
21
|
"@asyncapi/openapi-schema-parser": "^3.0.24",
|
|
22
22
|
"@asyncapi/optimizer": "^1.0.4",
|