airline-codes 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # required for npm trusted publishing (OIDC)
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20'
18
+ registry-url: 'https://registry.npmjs.org'
19
+ - run: npm install -g npm@latest
20
+ - run: npm install
21
+ - run: unset NODE_AUTH_TOKEN && npm publish --provenance --access public
@@ -0,0 +1,37 @@
1
+ name: Update Airline Data
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 6 * * 1' # every Monday at 6am UTC
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ update:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20'
18
+ registry-url: 'https://registry.npmjs.org'
19
+ - run: npm ci
20
+ - name: Fetch latest airlines.dat from OpenFlights
21
+ run: wget -q https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat
22
+ - name: Apply local corrections to airlines.dat
23
+ run: node normalize.js
24
+ - name: Regenerate airlines.json
25
+ run: node convert.js
26
+ - name: Commit and push if data changed
27
+ run: |
28
+ git config user.name "github-actions[bot]"
29
+ git config user.email "github-actions[bot]@users.noreply.github.com"
30
+ if git diff --quiet airlines.dat airlines.json; then
31
+ echo "No data changes, skipping."
32
+ else
33
+ npm version patch --no-git-tag-version
34
+ git add airlines.dat airlines.json package.json package-lock.json
35
+ git commit -m "chore: update airline data from OpenFlights"
36
+ git push origin master
37
+ fi
package/README.md CHANGED
@@ -27,19 +27,27 @@ require('airline-codes/airlines.json');
27
27
 
28
28
  ## Update the list of Airline Codes
29
29
 
30
- ### Fetch Airline codes
30
+ Data is synced automatically every week from [jpatokal/openflights](https://github.com/jpatokal/openflights). To update manually:
31
31
 
32
32
  ```
33
33
  $ wget https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat
34
+ $ node normalize.js # apply local corrections (country names, etc.)
35
+ $ node convert.js # regenerate airlines.json from airlines.dat
34
36
  ```
35
37
 
36
- ### Generate the list
38
+ ### Adding corrections
37
39
 
38
- Convert the list of airlines codes from csv format to JSON.
40
+ Upstream data uses different conventions for some country names and contains occasional data quality issues. `normalize.js` maintains a `COUNTRY_CORRECTIONS` map that is applied automatically after every upstream fetch. To add a new correction, edit the map in `normalize.js`:
39
41
 
42
+ ```javascript
43
+ var COUNTRY_CORRECTIONS = {
44
+ 'Macao': 'Macau',
45
+ 'Republic of Korea': 'South Korea',
46
+ // add new entries here ...
47
+ };
40
48
  ```
41
- node convert.js
42
- ```
49
+
50
+ After editing, re-run the pipeline above to apply the change.
43
51
 
44
52
  ## Thanks
45
53