Skip to content

Commit be9c503

Browse files
author
cpandya25
committed
Fix changelog download script: correct expo repository URL and add error handling
1 parent 2da6e5a commit be9c503

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

scripts/download-changelogs.mjs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const changelogs = {
1010
capacitor: 'https://raw.githubusercontent.com/cleverpush/cleverpush-capacitor-sdk/master/CHANGELOG.md',
1111
'react-native': 'https://raw.githubusercontent.com/cleverpush/cleverpush-react-native-sdk/master/CHANGELOG.md',
1212
flutter: 'https://raw.githubusercontent.com/cleverpush/cleverpush-flutter-sdk/master/CHANGELOG.md',
13-
expo: 'https://raw.githubusercontent.com/cleverpush/cleverpush-expo-sdk/master/CHANGELOG.md',
13+
expo: 'https://raw.githubusercontent.com/cleverpush/cleverpush-expo-plugin/master/CHANGELOG.md',
1414
};
1515

1616
const UTF_8 = 'utf-8';
@@ -62,21 +62,32 @@ function httpsRequest(requestOptions) {
6262
}
6363

6464
for (const [sdk, url] of Object.entries(changelogs)) {
65-
const parsedUrl = nodeUrl.parse(url);
65+
try {
66+
const parsedUrl = nodeUrl.parse(url);
6667

67-
const requestOptions = {
68-
hostname: parsedUrl.hostname,
69-
path: parsedUrl.path,
70-
method: 'GET',
71-
};
68+
const requestOptions = {
69+
hostname: parsedUrl.hostname,
70+
path: parsedUrl.path,
71+
method: 'GET',
72+
};
7273

73-
let emailOptInForm = '';
74-
if (EMAIL_OPT_IN_FORM_IDS[sdk]) {
75-
emailOptInForm = EMAIL_OPT_IN_FORM_HTML(EMAIL_OPT_IN_FORM_IDS[sdk]) + '\n\n';
76-
}
74+
let emailOptInForm = '';
75+
if (EMAIL_OPT_IN_FORM_IDS[sdk]) {
76+
emailOptInForm = EMAIL_OPT_IN_FORM_HTML(EMAIL_OPT_IN_FORM_IDS[sdk]) + '\n\n';
77+
}
7778

78-
const response = await httpsRequest(requestOptions);
79-
fs.writeFileSync(`./docs/sdks/${sdk}/changelog.md`, CHANGELOG_HEADER + emailOptInForm + response.replace('# Changelog', ''));
79+
const response = await httpsRequest(requestOptions);
80+
fs.writeFileSync(`./docs/sdks/${sdk}/changelog.md`, CHANGELOG_HEADER + emailOptInForm + response.replace('# Changelog', ''));
81+
console.log(`✓ Downloaded changelog for ${sdk}`);
82+
} catch (error) {
83+
console.error(`✗ Failed to download changelog for ${sdk}: ${error.message}`);
84+
// Create an empty changelog file with just the header
85+
let emailOptInForm = '';
86+
if (EMAIL_OPT_IN_FORM_IDS[sdk]) {
87+
emailOptInForm = EMAIL_OPT_IN_FORM_HTML(EMAIL_OPT_IN_FORM_IDS[sdk]) + '\n\n';
88+
}
89+
fs.writeFileSync(`./docs/sdks/${sdk}/changelog.md`, CHANGELOG_HEADER + emailOptInForm + 'Changelog not available.\n');
90+
}
8091
}
8192

8293
console.log('Changelogs downloaded successfully');

0 commit comments

Comments
 (0)