ccxt 4.1.88 → 4.1.89

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/README.md CHANGED
@@ -208,13 +208,13 @@ console.log(version, Object.keys(exchanges));
208
208
 
209
209
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
210
210
 
211
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.88/dist/ccxt.browser.js
212
- * unpkg: https://unpkg.com/ccxt@4.1.88/dist/ccxt.browser.js
211
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.89/dist/ccxt.browser.js
212
+ * unpkg: https://unpkg.com/ccxt@4.1.89/dist/ccxt.browser.js
213
213
 
214
214
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
215
215
 
216
216
  ```HTML
217
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.88/dist/ccxt.browser.js"></script>
217
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.89/dist/ccxt.browser.js"></script>
218
218
  ```
219
219
 
220
220
  Creates a global `ccxt` object:
package/changelog.js ADDED
@@ -0,0 +1,101 @@
1
+ import fs from 'fs/promises';
2
+
3
+ const owner = 'ccxt';
4
+ const repo = 'ccxt';
5
+
6
+ const tagsUrl = `https://api.github.com/repos/${owner}/${repo}/tags?per_page=100&page=1`;
7
+ const prsUrl = `https://api.github.com/repos/${owner}/${repo}/pulls?state=closed&per_page=100&page=1`;
8
+ const filePath = 'CHANGELOG.md';
9
+
10
+ const token = 'GITHUB_TOKEN'; // Replace with your GitHub personal access token
11
+
12
+ const headers = {
13
+ Authorization: `Bearer ${token}`,
14
+ 'Content-Type': 'application/json',
15
+ };
16
+
17
+ // Function to fetch data from GitHub API with pagination
18
+ async function fetchPaginatedData(url) {
19
+ let page = 1;
20
+ let allData = [];
21
+
22
+ while (true) {
23
+ console.log(`Fetching page ${page}...`)
24
+ const response = await fetch(`${url}&page=${page}`, { headers });
25
+
26
+ if (!response.ok) {
27
+ throw new Error(`Failed to fetch data from ${url}. Status: ${response.status}`);
28
+ }
29
+
30
+ const data = await response.json();
31
+
32
+ if (data.length === 0) {
33
+ break; // No more data
34
+ }
35
+
36
+ allData = allData.concat(data);
37
+ page++;
38
+ }
39
+
40
+ return allData;
41
+ }
42
+
43
+ // Function to get all tags
44
+ async function getAllTags() {
45
+ return await fetchPaginatedData(tagsUrl);
46
+ }
47
+
48
+ // Function to get all PRs
49
+ async function getAllPRs() {
50
+ return await fetchPaginatedData(prsUrl);
51
+ }
52
+
53
+ async function fetchAndWriteFullChangelog() {
54
+ try {
55
+ const tags = await getAllTags();
56
+
57
+ const changelogContent = await generateChangelog(tags);
58
+ await fs.writeFile('CHANGELOG.md', changelogContent);
59
+ console.log('Changelog created successfully.');
60
+ } catch (error) {
61
+ console.error('Error fetching data:', error.message);
62
+ }
63
+ }
64
+
65
+ async function generateChangelog(tags) {
66
+ let changelog = '# Changelog\n\n';
67
+
68
+ const prs = await getAllPRs();
69
+ for (let i = 0; i < tags.length - 1; i++) {
70
+ const currentTag = tags[i];
71
+ const nextTag = tags[i + 1];
72
+
73
+ changelog += `## ${nextTag.name}\n\n`;
74
+
75
+ const commitsBetweenTags = await getCommitsBetweenTags(currentTag.name, nextTag.name);
76
+
77
+ commitsBetweenTags.forEach(commit => {
78
+ const pr = prs.find(pr => pr.merge_commit_sha === commit);
79
+ if (pr) changelog += `- ${pr.title} [#${pr.number}](${pr.html_url})\n`;
80
+ });
81
+
82
+ changelog += '\n\n';
83
+ }
84
+
85
+ return changelog;
86
+ }
87
+
88
+ // Function to get the commits between two tags
89
+ async function getCommitsBetweenTags(tag1, tag2) {
90
+ console.log(`Fetching commits for ${tag2}...`)
91
+ const commitsUrl = `https://api.github.com/repos/${owner}/${repo}/compare/${tag2}...${tag1}`;
92
+ const commitsData = await fetch(commitsUrl, { headers }).then(res => res.json()).catch(err => console.log(err));
93
+ if (commitsData && commitsData.commits) {
94
+ return commitsData.commits.map(commit => commit.sha)
95
+ } else {
96
+ console.log ('No commits found: ' + JSON.stringify (commitsData))
97
+ return [];
98
+ }
99
+ }
100
+
101
+ fetchAndWriteFullChangelog();