Skip to content

Commit 5be710e

Browse files
feat: creating function to get record of newest event versions
1 parent 516f05b commit 5be710e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/generate-docs.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,27 @@ const getContractFileNames = async (
1515
return files.filter((fileName) => fileName.includes("Contract"));
1616
};
1717

18+
const getRecordOfNewestVersions = (
19+
newestVersions: Record<string, number>,
20+
detailType: string,
21+
detailVersion: number
22+
): Record<string, number> => {
23+
if ("detailType" in newestVersions) {
24+
if (newestVersions[detailType] < detailVersion) {
25+
newestVersions[detailType] = detailVersion;
26+
}
27+
} else {
28+
newestVersions[detailType] = detailVersion;
29+
}
30+
return newestVersions;
31+
};
32+
1833
export const generateDocumentation = async (
1934
pathToContractsFolder: string,
2035
pathToDocumentationFolder: string
2136
): Promise<void> => {
2237
const contractFileNames = await getContractFileNames(pathToContractsFolder);
38+
let newestVersions: Record<string, number> = {};
2339

2440
for (const contractFileName of contractFileNames) {
2541
const { detailType, detailVersion, schema } = generateSchemaDetails(
@@ -40,6 +56,14 @@ export const generateDocumentation = async (
4056
);
4157

4258
await writeSchemaFile(pathToContractDocumentationFolder, schema);
59+
60+
newestVersions = getRecordOfNewestVersions(
61+
newestVersions,
62+
detailType,
63+
detailVersion
64+
);
65+
4366
console.log(`Created docs for ${contractFileName}`);
67+
console.log(newestVersions);
4468
}
4569
};

0 commit comments

Comments
 (0)