|
3 | 3 | // - prerelease.json : latest pre-release (version, date, downloads, checksums) |
4 | 4 | // |
5 | 5 | // Both files use the exact same shape and are built the same way — there is |
6 | | -// nothing to bump by hand. The committed JSON files only act as an offline |
7 | | -// fallback (last known values); every real build overwrites them with fresh data. |
| 6 | +// nothing to bump by hand. Every real build overwrites them with fresh data; |
| 7 | +// the committed JSON files are just the last known-good values checked into |
| 8 | +// git so the repo is never without one. If the fetch fails, the build fails |
| 9 | +// (see main() below) rather than silently deploying stale data. |
8 | 10 | // |
9 | 11 | // Why build-time instead of client-side: |
10 | 12 | // - The GitHub API (api.github.com) supports CORS but is rate limited |
@@ -162,22 +164,13 @@ async function main() { |
162 | 164 | if (!res.ok) throw new Error(`HTTP ${res.status} for ${apiUrl}`); |
163 | 165 | const releases = await res.json(); |
164 | 166 |
|
165 | | - // Each step is independent so a single failure keeps that file's committed |
166 | | - // fallback instead of failing the whole build. |
167 | | - for (const [label, fn] of [ |
168 | | - ["stable", updateStable], |
169 | | - ["pre-release", updatePrerelease], |
170 | | - ]) { |
171 | | - try { |
172 | | - } catch (err) { |
173 | | - const msg = err instanceof Error ? err.message : String(err); |
174 | | - console.warn(`[release-data] ${label} skipped: ${msg}`); |
175 | | - } |
176 | | - } |
| 167 | + await updateStable(releases); |
| 168 | + await updatePrerelease(releases); |
177 | 169 | } |
178 | 170 |
|
179 | 171 | main().catch((err) => { |
180 | | - // Non-fatal: keep all committed fallbacks so offline / CI builds still succeed. |
| 172 | + // Fatal: fail the build rather than silently deploying stale/wrong data. |
181 | 173 | const msg = err instanceof Error ? err.message : String(err); |
182 | | - console.warn(`[release-data] Skipped update: ${msg}`); |
| 174 | + console.error(`[release-data] Failed to update release data: ${msg}`); |
| 175 | + process.exitCode = 1; |
183 | 176 | }); |
0 commit comments