mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 22:58:20 -05:00
add generateCountryOptions.ts
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
"axios": "^1.7.2",
|
||||
"buffer": "^6.0.3",
|
||||
"chai": "^4.3.8",
|
||||
"country-emoji": "^1.5.6",
|
||||
"country-iso-3-to-2": "^1.1.1",
|
||||
"elliptic": "^6.5.5",
|
||||
"fs": "^0.0.1-security",
|
||||
"js-sha1": "^0.7.0",
|
||||
|
||||
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