Skip to content

Commit

Permalink
Sort entries (2factorauth#8251)
Browse files Browse the repository at this point in the history
Signed-off-by: Carl <[email protected]>
Co-authored-by: H. Kamran <[email protected]>
  • Loading branch information
Carlgo11 and hkamran80 authored Nov 14, 2024
1 parent d102636 commit 8266501
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/APIv1-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const generateApi = async (entries, categoriesData, regionsData) => {
entryCountsByRegion[region] = 0;
}

categories.forEach((category) => {
categories?.forEach((category) => {
categoriesByRegion[region][category] =
categoriesByRegion[region][category] || {};
categoriesByRegion[region][category][domain] = apiEntry;
Expand Down Expand Up @@ -262,10 +262,13 @@ const generateApi = async (entries, categoriesData, regionsData) => {

// Write category files
const categoryWrites = Object.entries(categoriesByRegion[region])
.sort()
.map(([category, entries]) =>
writeJSONFile(path.join(regionDir, `${category}.json`), entries)
);
.sort().map(([category, entries]) => {
const sortedEntries = Object.fromEntries(
Object.keys(entries).sort((a, b) => a.localeCompare(b)).map(entry => [entry, entries[entry]]),
);
writeJSONFile(path.join(regionDir, `${category}.json`), sortedEntries);
},
);

// Write categories.json file
const categoriesUsed = categoriesUsedByRegion[region];
Expand Down

0 comments on commit 8266501

Please sign in to comment.