Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/sync/sync-rfcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ interface SyncState {
events: CachedIssueEvent[];
}
>;
documentStageOverrides?: Record<string, Stage>;
}

interface CachedIssueEvent {
Expand Down Expand Up @@ -340,7 +341,7 @@ async function main(): Promise<void> {
for (const discussion of await fetchAllDiscussions(token)) {
mergeDiscussion(records, discussion);
}
await mergeDocuments(records);
await mergeDocuments(records, state);
await addWgMentions(records);

const summaries = await writeGeneratedMarkdown(records);
Expand Down Expand Up @@ -377,20 +378,22 @@ async function main(): Promise<void> {
async function loadState(): Promise<SyncState> {
try {
const state = JSON.parse(await fs.readFile(STATE_PATH, "utf8")) as SyncState;
if (!state.issueEvents || typeof state.issueEvents !== "object") {
return {};
}
return {
issueEvents: Object.fromEntries(
const result: SyncState = {};
if (state.issueEvents && typeof state.issueEvents === "object") {
result.issueEvents = Object.fromEntries(
Object.entries(state.issueEvents).flatMap(([key, value]) => {
if (!value || typeof value !== "object" || !Array.isArray(value.events)) {
return [];
}
const events = value.events.filter(isCachedIssueEvent);
return [[key, { updatedAt: value.updatedAt ?? "", events }]];
}),
),
};
);
}
if (state.documentStageOverrides && typeof state.documentStageOverrides === "object") {
result.documentStageOverrides = state.documentStageOverrides;
}
return result;
} catch {
return {};
}
Expand Down Expand Up @@ -1010,7 +1013,7 @@ function mergeDiscussion(
});
}

async function mergeDocuments(records: Map<string, RfcRecord>): Promise<void> {
async function mergeDocuments(records: Map<string, RfcRecord>, state: SyncState): Promise<void> {
const docsDir = path.join(WG_DIR, "rfcs");
for (const entry of await fs.readdir(docsDir, { withFileTypes: true })) {
if (
Expand All @@ -1028,7 +1031,7 @@ async function mergeDocuments(records: Map<string, RfcRecord>): Promise<void> {
const record = getOrCreateRecord(records, identifier, tidyTitle(header));
record.title = tidyTitle(header);
record.shortname = record.title;
record.stage = record.stage ?? "0";
record.stage = record.stage ?? state.documentStageOverrides?.[identifier] ?? "0";
record.rfcDocUrl = `https://github.com/graphql/graphql-wg/blob/main/rfcs/${entry.name}`;
record.documentBody = pruneMarkdown(content);
record.updatedAt = maxDate(record.updatedAt, new Date().toISOString());
Expand Down
3 changes: 3 additions & 0 deletions state.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"documentStageOverrides": {
"MockSpec": "S"
},
"issueEvents": {
"graphql/graphql-spec#1010": {
"events": [
Expand Down