Added flags to Geo.
|
@ -8,7 +8,11 @@ const { argv } = require('yargs');
|
||||||
const countries = require('./countries.json');
|
const countries = require('./countries.json');
|
||||||
const states = require('./states-us.json');
|
const states = require('./states-us.json');
|
||||||
|
|
||||||
const data = { countries, states };
|
const data = {
|
||||||
|
countries,
|
||||||
|
states,
|
||||||
|
flags: countries,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
async function fetchCountries() {
|
async function fetchCountries() {
|
||||||
|
@ -26,13 +30,18 @@ async function fetchCountries() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const type = argv.states ? 'states' : 'countries';
|
const type = argv.type || 'countries';
|
||||||
|
|
||||||
const countryImgs = await fs.readdir(`./assets/${type}`);
|
const countryImgs = await fs.readdir(`./assets/${type}`);
|
||||||
const countriesByCode = Object.fromEntries(data[type].map((country) => [country.alpha2, country]));
|
const countriesByCode = Object.fromEntries(data[type].map((country) => [country.alpha2, country]));
|
||||||
|
|
||||||
const imgCountries = await Promise.all(countryImgs.filter((file) => !['encoded', 'disabled'].includes(file)).map(async (file) => {
|
const imgCountries = await Promise.all(countryImgs.map(async (file) => {
|
||||||
const code = file.match(/(\w+).png/)[1];
|
const code = file.match(/(\w+).png/)?.[1];
|
||||||
|
|
||||||
|
if (!code || !countriesByCode[code]) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const filename = `${crypto.createHash('md5').update(code).digest('hex').slice(0, 4)}.png`;
|
const filename = `${crypto.createHash('md5').update(code).digest('hex').slice(0, 4)}.png`;
|
||||||
|
|
||||||
await fs.copyFile(`./assets/${type}/${file}`, `./assets/${type}/encoded/${filename}`);
|
await fs.copyFile(`./assets/${type}/${file}`, `./assets/${type}/encoded/${filename}`);
|
||||||
|
@ -42,7 +51,7 @@ async function init() {
|
||||||
code,
|
code,
|
||||||
...countriesByCode[code],
|
...countriesByCode[code],
|
||||||
};
|
};
|
||||||
}));
|
}).filter(Boolean));
|
||||||
|
|
||||||
await fs.writeFile(`./assets/${type}-curated.json`, JSON.stringify(imgCountries, null, 4));
|
await fs.writeFile(`./assets/${type}-curated.json`, JSON.stringify(imgCountries, null, 4));
|
||||||
|
|
||||||
|
|
|
@ -1222,12 +1222,14 @@
|
||||||
{
|
{
|
||||||
"alpha2": "VG",
|
"alpha2": "VG",
|
||||||
"code": 92,
|
"code": 92,
|
||||||
"name": "Virgin Islands (UK)"
|
"name": "Virgin Islands",
|
||||||
|
"fullName": "Virgin Islands (UK)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"alpha2": "VI",
|
"alpha2": "VI",
|
||||||
"code": 850,
|
"code": 850,
|
||||||
"name": "Virgin Islands (US)"
|
"name": "Virgin Islands",
|
||||||
|
"fullName": "Virgin Islands (US)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"alpha2": "WF",
|
"alpha2": "WF",
|
||||||
|
|
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 773 B |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 753 B |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 787 B |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 481 B |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 745 B |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 617 B |
After Width: | Height: | Size: 703 B |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 566 B |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 664 B |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 657 B |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 554 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 721 B |
After Width: | Height: | Size: 753 B |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 20 KiB |