MCPcopy
hub / github.com/mongodb/node-mongodb-native / updateSiteTemplateForNewVersion

Function updateSiteTemplateForNewVersion

etc/docs/build.ts:40–72  ·  view source on GitHub ↗
(
  newVersion: VersionSchema,
  tomlData: TomlVersionSchema,
  jsonVersions: JsonVersionSchema[]
)

Source from the content-addressed store, hash-verified

38}
39
40async function updateSiteTemplateForNewVersion(
41 newVersion: VersionSchema,
42 tomlData: TomlVersionSchema,
43 jsonVersions: JsonVersionSchema[]
44) {
45 const versionExists = jsonVersions.some(({ version }) => version === newVersion.tag);
46 if (versionExists) {
47 const existingVersionIndex = tomlData.versions.findIndex(({ tag }) => tag === newVersion.tag);
48 tomlData.versions[existingVersionIndex] = newVersion;
49 } else {
50 for (const version of tomlData.versions) {
51 // This new version is going to be the latest, we have to change the previous one to supported
52 if (version.status === 'latest') {
53 version.status = 'supported';
54 }
55 }
56
57 tomlData.versions.unshift(newVersion);
58 jsonVersions.unshift({ version: newVersion.tag });
59 }
60
61 tomlData.versions.sort((a, b) => customSemverCompare(a.tag, b.tag));
62 tomlData.current = tomlData.versions.find(
63 ({ tag }) => tag.toLowerCase() !== LATEST_TAG.toLowerCase()
64 ).version;
65
66 jsonVersions.sort((a, b) => customSemverCompare(a.version, b.version));
67
68 await writeFile(RELEASES_TOML_FILE, stringify(tomlData as any));
69 await writeFile(RELEASES_JSON_FILE, JSON.stringify(jsonVersions, null, 4));
70 // generate the site from the template
71 await exec(`hugo -s template -d ../temp -b "/node-mongodb-native"`);
72}
73
74async function main() {
75 try {

Callers 1

mainFunction · 0.85

Calls 4

customSemverCompareFunction · 0.90
unshiftMethod · 0.80
sortMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected