Skip to content
Merged
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
25 changes: 24 additions & 1 deletion gh-pages/bin/create-cldr-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import child_process from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import semver from 'semver';

const PROJECT_ROOT = path
.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
Expand All @@ -18,8 +19,30 @@ const VERSIONS = JSON.parse(fs.readFileSync(`${DATADIR}/versions.json`));
if (!fs.existsSync(`${DATADIR}/versions`)) {
fs.mkdirSync(`${DATADIR}/versions`);
}
if (VERSIONS.length === 0) {
throw new Error('No versions found in versions.json');
}
VERSIONS.forEach((version, index) => {
if (index <= 0) {
return;
}
const previousVersion = VERSIONS[index - 1];
const previousVersionCoerced = semver.coerce(previousVersion, {includePrerelease: true});
if (!previousVersionCoerced) {
throw new Error(`Invalid version in ${DATADIR}/versions.json: ${previousVersion}`);
}
const versionCoerced = semver.coerce(version, {includePrerelease: true});
if (!versionCoerced) {
throw new Error(`Invalid version in ${DATADIR}/versions.json: ${version}`);
}
if (semver.lte(previousVersionCoerced.version, versionCoerced.version)) {
throw new Error(
`Versions in ${DATADIR}/versions.json are not in descending order: ${previousVersion} is greater than ${version}`,
);
}
});

for (let version of VERSIONS) {
for (let version of VERSIONS.reverse()) {
const outputFileCompressed = `${DATADIR}/versions/${version}.min.json`;
const outputFileUncompressed = `${DATADIR}/versions/${version}.json`;
if (
Expand Down
Loading