diff --git a/devTools/regionsImporter/readme.md b/devTools/regionsImporter/readme.md index 73249c33af4..f1251253a20 100644 --- a/devTools/regionsImporter/readme.md +++ b/devTools/regionsImporter/readme.md @@ -9,10 +9,8 @@ The data file is used primarily for: - determining whether entities are states and which of those have country pages (see `regions.ts`) - establishing region → country mappings (see `WorldRegionsToProjection.ts`) - ## Updating Region Data The `regions.json` file can be updated manually by running `yarn importRegions` which triggers the `update.ts` script in `devTools/regionsImporter` and prints out a diff if anything has changed. If, after looking over the changes, everything looks good-to-go you can commit the updated `regions.json` and merge back into `master`. > Note: pay particular attention to changes in `slug` values for countries since this determines the URL of their country page. If a slug changes, be sure to add a redirect from the old value to the new one in WordPress. - diff --git a/devTools/regionsImporter/update.ts b/devTools/regionsImporter/update.ts index 338bd7cab76..1a21b6fda6e 100644 --- a/devTools/regionsImporter/update.ts +++ b/devTools/regionsImporter/update.ts @@ -116,20 +116,16 @@ async function main() { .value() }) - // generate new regions.json file compare to old version + // generate new regions.json file and compare to old version let newRegions = prettifiedJson(entities), oldRegions = await readFile(GRAPHER_REGIONS_PATH).catch((e) => ""), newHash = createHash("md5").update(newRegions).digest("hex"), - oldHash = createHash("md5").update(oldRegions).digest("hex") + oldHash = createHash("md5").update(oldRegions).digest("hex"), + message = newHash === oldHash ? "No changes" : "Contents changed" await writeFile(GRAPHER_REGIONS_PATH, newRegions) // report changes (if any) - console.log( - `${ - newHash === oldHash ? "No changes" : "Contents changed" - }: ${GRAPHER_REGIONS_PATH}` - ) - + console.log(`${message}: ${GRAPHER_REGIONS_PATH}`) if (newHash !== oldHash) { let diff = execFileSync("git", [ "diff", @@ -137,7 +133,9 @@ async function main() { GRAPHER_REGIONS_PATH, ]) console.log(diff.toString()) - console.log("Be sure to set up redirects for any slugs that have changed") + console.log( + "Be sure to set up redirects for any slugs that have changed" + ) } }