Skip to content

Commit 079d6f4

Browse files
authored
Check versions published in GH pages (#68)
* gh-pages: update npm dependencies * Check versions published in GH pages * Tell TypeScript we are sure about the types
1 parent f234bf7 commit 079d6f4

5 files changed

Lines changed: 1073 additions & 572 deletions

File tree

gh-pages/bin/create-cldr-data.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import child_process from 'node:child_process';
22
import fs from 'node:fs';
33
import path from 'node:path';
44
import {fileURLToPath} from 'node:url';
5+
import semver from 'semver';
56

67
const PROJECT_ROOT = path
78
.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
@@ -18,8 +19,30 @@ const VERSIONS = JSON.parse(fs.readFileSync(`${DATADIR}/versions.json`));
1819
if (!fs.existsSync(`${DATADIR}/versions`)) {
1920
fs.mkdirSync(`${DATADIR}/versions`);
2021
}
22+
if (VERSIONS.length === 0) {
23+
throw new Error('No versions found in versions.json');
24+
}
25+
VERSIONS.forEach((version, index) => {
26+
if (index <= 0) {
27+
return;
28+
}
29+
const previousVersion = VERSIONS[index - 1];
30+
const previousVersionCoerced = semver.coerce(previousVersion, {includePrerelease: true});
31+
if (!previousVersionCoerced) {
32+
throw new Error(`Invalid version in ${DATADIR}/versions.json: ${previousVersion}`);
33+
}
34+
const versionCoerced = semver.coerce(version, {includePrerelease: true});
35+
if (!versionCoerced) {
36+
throw new Error(`Invalid version in ${DATADIR}/versions.json: ${version}`);
37+
}
38+
if (semver.lte(previousVersionCoerced.version, versionCoerced.version)) {
39+
throw new Error(
40+
`Versions in ${DATADIR}/versions.json are not in descending order: ${previousVersion} is greater than ${version}`,
41+
);
42+
}
43+
});
2144

22-
for (let version of VERSIONS) {
45+
for (let version of VERSIONS.reverse()) {
2346
const outputFileCompressed = `${DATADIR}/versions/${version}.min.json`;
2447
const outputFileUncompressed = `${DATADIR}/versions/${version}.json`;
2548
if (

0 commit comments

Comments
 (0)