Skip to content

Commit b38f6ae

Browse files
committed
Revert "chore(repo): Update changelog.js to avoid rate limits"
1 parent e796103 commit b38f6ae

1 file changed

Lines changed: 16 additions & 62 deletions

File tree

‎.changeset/changelog.js‎

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,30 @@
11
const { getInfo, getInfoFromPullRequest } = require('@changesets/get-github-info');
22

3-
// mocks for local testing
4-
// const getInfo = async (...args) => {
5-
// return {
6-
// links: {
7-
// commit: 'commit-link',
8-
// },
9-
// };
10-
// }
11-
//
12-
// const getInfoFromPullRequest = async (...args) => {
13-
// return {
14-
// links: {
15-
// pull: 'pull-link',
16-
// },
17-
// };
18-
// }
19-
203
const repo = 'clerk/javascript';
214

22-
const delayRandomJitter = async (maxSeconds) => {
23-
const seconds = Math.random() * (maxSeconds || 10);
24-
await new Promise(resolve => setTimeout(resolve, seconds * 1000));
25-
}
26-
275
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
28-
await delayRandomJitter(5);
29-
console.log('dependenciesUpdated ------------')
306
if (dependenciesUpdated.length === 0) return '';
317

32-
const fetchLinksWithRetry = async commit => {
33-
let retries = 0;
34-
while (retries < 3) {
35-
try {
36-
const { links } = await getInfo({repo, commit});
37-
return links;
38-
} catch (e) {
39-
retries++;
40-
console.log('retrying', retries);
41-
await delayRandomJitter(2);
42-
}
43-
}
44-
}
8+
const changesetLink = `- Updated dependencies [${(
9+
await Promise.all(
10+
changesets.map(async cs => {
11+
if (cs.commit) {
12+
let { links } = await getInfo({
13+
repo,
14+
commit: cs.commit,
15+
});
16+
return links.commit;
17+
}
18+
}),
19+
)
20+
)
21+
.filter(_ => _)
22+
.join(', ')}]:`;
4523

46-
const getLinksCommitFromChangeset = async changeset => {
47-
if(!changeset.commit) {
48-
return
49-
}
50-
console.log('fetching links for commit', changeset.commit);
51-
return fetchLinksWithRetry(changeset.commit).then(links => links.commit);
52-
}
53-
54-
const batchSize = 3;
55-
const batches = [];
56-
for (let i = 0; i < changesets.length; i += batchSize) {
57-
batches.push(changesets.slice(i, i + batchSize).map(cs => () => getLinksCommitFromChangeset(cs)));
58-
}
59-
60-
const resolvedPromises = [];
61-
for (let i = 0; i < batches.length; i++) {
62-
console.log('batch', i)
63-
const batch = batches[i];
64-
const resolvedBatch = await Promise.all(batch.map(fn => fn()));
65-
resolvedPromises.push(resolvedBatch);
66-
await new Promise(resolve => setTimeout(resolve, 2000));
67-
}
68-
69-
const list = (resolvedPromises.flat()).filter(_ => _).join(', ')
70-
const changesetLink = `- Updated dependencies [${list}]:`;
7124
const updatedDependenciesList = dependenciesUpdated.map(
7225
dependency => ` - ${dependency.name}@${dependency.newVersion}`,
7326
);
27+
7428
return [changesetLink, ...updatedDependenciesList].join('\n');
7529
};
7630

0 commit comments

Comments
 (0)