Skip to content

chore(military): add generator script to refresh ICAO→IATA airline lookup table #1995

@koala73

Description

@koala73

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:

  1. Fetches https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat (public domain CSV)
  2. Parses each row: ID, Name, Alias, IATA, ICAO, Callsign, Country, Active
  3. Filters to: Active == "Y", 2-char IATA, 3-char ICAO, both non-null/non-\N
  4. Emits all strings via JSON.stringify to prevent quote/newline injection
  5. Re-writes only the GENERATED block inside server/_shared/airline-codes.ts, leaving the OVERRIDE table intact
  6. 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 OVERRIDE table 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: militaryMilitary flights, vessel trackingchoreMaintenance, linting, toolingenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions