koala73/worldmonitor
View on GitHubchore(military): add generator script to refresh ICAO→IATA airline lookup table
Open
#1995 opened on Mar 21, 2026
area: militarychoreenhancementgood first issue
Description
Background
server/_shared/airline-codes.ts contains a hand-curated static map of ~100 airline ICAO→IATA mappings used to resolve Wingbits callsigns (e.g. UAE528→EK528 Emirates). The map was seeded from OpenFlights airlines.dat and is sufficient for current traffic.
To keep it current without full manual curation, we need a generator script.
Task
Write scripts/generate-airline-codes.mjs that:
- Fetches
https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat(public domain CSV) - Parses each row:
ID, Name, Alias, IATA, ICAO, Callsign, Country, Active - Filters to:
Active == "Y", 2-char IATA, 3-char ICAO, both non-null/non-\N - Emits all strings via
JSON.stringifyto prevent quote/newline injection - Re-writes only the
GENERATEDblock insideserver/_shared/airline-codes.ts, leaving theOVERRIDEtable intact - Prints a summary: N entries written, N removed, N added vs. previous run
Maintenance cadence
Run quarterly (or when a gap is reported in prod via missing IATA header in popup):
node scripts/generate-airline-codes.mjs
# Review diff in server/_shared/airline-codes.ts
# Commit as chore(deps): refresh airline ICAO-IATA lookup table
For immediate corrections (wrong mapping, rebranded airline): add to the OVERRIDE table directly — no script needed.
Notes
- The
OVERRIDEtable must always survive a re-run (script should not touch it) - Strings must be
JSON.stringify-escaped to avoid TS syntax errors from airline names with quotes - Consider pinning the source commit SHA or checksum in the script header for auditability