4444 const axios = require('axios');
4545 const fs = require('fs');
4646
47+ // Read and parse the badges.json file
4748 const badges = JSON.parse(fs.readFileSync('./badges.json', 'utf-8'));
4849 const plugins = badges.plugins;
4950
@@ -55,26 +56,35 @@ jobs:
5556 const releaseUrl = plugin.releaseUrl;
5657
5758 try {
59+ // Generate API URL for the repository's latest release
5860 const repoName = repoUrl.replace('https://github.com/', '');
5961 const apiUrl = `https://api.github.com/repos/${repoName}/releases/latest`;
62+
63+ // Fetch the latest release information
6064 const response = await axios.get(apiUrl, {
6165 headers: { 'User-Agent': 'GitHub Actions', Accept: 'application/vnd.github.v3+json' }
6266 });
67+
68+ // Extract the download URL of the latest release's asset
6369 const latestDownloadUrl = response.data.assets[0]?.browser_download_url || null;
6470
6571 if (!latestDownloadUrl) {
72+ // No downloadable asset in the latest release
6673 console.warn(`⚠️ ${plugin.name}: No downloadable asset found in the latest release.`);
6774 console.log(`::warning file=badges.json,line=1::${plugin.name} has no downloadable asset in its latest release.`);
6875 } else if (releaseUrl === latestDownloadUrl) {
76+ // Download link matches the latest release
6977 console.log(`✅ ${plugin.name}: Download link is up-to-date.`);
7078 } else {
79+ // Download link is outdated
7180 console.error(`❌ ${plugin.name}: Download link is outdated.`);
7281 console.error(` Expected: ${latestDownloadUrl}`);
7382 console.error(` Found: ${releaseUrl}`);
7483 console.log(`::error file=badges.json,line=1::${plugin.name} has an outdated download link.`);
7584 hasErrors = true;
7685 }
7786 } catch (error) {
87+ // Handle errors during API call
7888 console.error(`⚠️ Error checking ${plugin.name}: ${error.message}`);
7989 console.log(`::error file=badges.json,line=1::${plugin.name} encountered an error: ${error.message}`);
8090 hasErrors = true;
8696 }
8797 }
8898
89- validateLinks();
99+ validateLinks().catch(err => {
100+ console.error("Unhandled error:", err.message);
101+ process.exit(1);
102+ });
90103 EOF
0 commit comments