mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
add generateCountryOptions.ts
This commit is contained in:
24
common/src/scripts/generateCountryOptions.ts
Normal file
24
common/src/scripts/generateCountryOptions.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { countryCodes } from '../constants/constants';
|
||||
import getCountryISO2 from "country-iso-3-to-2";
|
||||
import { flag } from 'country-emoji';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
try {
|
||||
console.log('Generating country options...');
|
||||
|
||||
const countryOptions = Object.keys(countryCodes).map((countryCode, index) => ({
|
||||
countryCode,
|
||||
countryName: countryCodes[countryCode as keyof typeof countryCodes],
|
||||
flagEmoji: flag(getCountryISO2(countryCode)),
|
||||
index,
|
||||
}));
|
||||
|
||||
const outputPath = path.join(__dirname, './countryOptions.json');
|
||||
fs.writeFileSync(outputPath, JSON.stringify(countryOptions, null, 2));
|
||||
|
||||
console.log(`Generated country options at ${outputPath}`);
|
||||
} catch (error) {
|
||||
console.error('Error generating country options:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user