( newVersion: VersionSchema, tomlData: TomlVersionSchema, jsonVersions: JsonVersionSchema[] )
| 38 | } |
| 39 | |
| 40 | async 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 | |
| 74 | async function main() { |
| 75 | try { |
no test coverage detected