Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit c6f5645

Browse files
committed
fix: Added graceful handling of malformed GameMaker URLs and missing data
1 parent 4cf4ea6 commit c6f5645

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

packages/releases/src/feeds.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Pathy } from '@bscotch/pathy';
2-
import { assert } from '@bscotch/utility/browser';
32
import { z } from 'zod';
43
import { defaultNotesCachePath } from './constants.js';
54
import { downloadRssFeed, findPairedRuntime } from './feeds.lib.js';
@@ -23,14 +22,15 @@ export async function computeReleasesSummaryWithNotes(
2322
releases ||= await computeReleasesSummary();
2423
const notes = await listReleaseNotes(releases, cache);
2524
const withNotes: GameMakerReleaseWithNotes[] = [];
25+
const emptyChanges = {
26+
changes: {
27+
since: null,
28+
groups: [],
29+
},
30+
};
2631
for (const release of releases) {
27-
const ideNotes = notes[release.ide.notesUrl];
28-
assert(ideNotes, `No notes found for IDE release ${release.ide.version}`);
29-
const runtimeNotes = notes[release.runtime.notesUrl];
30-
assert(
31-
runtimeNotes,
32-
`No notes found for IDE release ${release.runtime.version}`,
33-
);
32+
const ideNotes = notes[release.ide.notesUrl] || emptyChanges;
33+
const runtimeNotes = notes[release.runtime.notesUrl] || emptyChanges;
3434
const ide = { ...release.ide, notes: ideNotes.changes };
3535
const runtime = { ...release.runtime, notes: runtimeNotes.changes };
3636
withNotes.push({

packages/releases/src/notes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export async function listReleaseNotes(
2525
const cacheData = await cachePath.read({ fallback: {} });
2626
for (const release of releases) {
2727
for (const type of ['ide', 'runtime'] as const) {
28-
const url = release[type].notesUrl;
28+
let url = release[type].notesUrl;
29+
// URL can be malformed
30+
url = url.replace(/^(.+\.cloudfront\.net)(release.*)$/, '$1/$2');
2931
if (cacheData[url]) {
3032
if (!cacheData[url].type) {
3133
cacheData[url].type = type;
@@ -92,7 +94,7 @@ function cleanNotes(cachedNotes: RawReleaseNotesCache) {
9294
const notesByUrl = cleanedNotes.reduce((acc, note) => {
9395
acc[note.url] = note;
9496
return acc;
95-
}, {} as Record<string, typeof cleanedNotes[0]>);
97+
}, {} as Record<string, (typeof cleanedNotes)[0]>);
9698
return notesByUrl;
9799
}
98100

scripts/update-releases-summary.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { pathy } from '@bscotch/pathy';
2-
import { listReleasesWithNotes } from '../packages/releases/dist/index.js';
2+
import { computeReleasesSummaryWithNotes } from '../packages/releases/dist/index.js';
33
import fs from 'fs';
44

55
const notesCache = pathy('packages/releases/release-notes-cache.json');
66
const summaryPath = pathy('packages/releases/releases-summary.json');
7-
const releases = await listReleasesWithNotes(undefined, notesCache);
7+
const releases = await computeReleasesSummaryWithNotes(undefined, notesCache);
88
await summaryPath.write(releases);
99
// Write to the file that GitHub Workflow uses to store env vars
1010
fs.appendFileSync(

0 commit comments

Comments
 (0)