airline-codes 1.0.3 → 1.1.1

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,28 @@
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
+ - name: Publish if version not already published
22
+ run: |
23
+ VERSION=$(node -p "require('./package.json').version")
24
+ if npm view "airline-codes@$VERSION" version &>/dev/null; then
25
+ echo "Version $VERSION already published, skipping."
26
+ else
27
+ unset NODE_AUTH_TOKEN && npm publish --provenance --access public
28
+ fi
@@ -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
@@ -1,4 +1,6 @@
1
1
  # Airline Codes
2
+
3
+ [![Docs](https://img.shields.io/badge/docs-mintlify-18a34a?style=flat-square)](https://mintlify.com/npow/airline-codes)
2
4
  > Airline codes (IATA) and information pulled from OpenFlights.org
3
5
 
4
6
  ## Install
@@ -27,19 +29,27 @@ require('airline-codes/airlines.json');
27
29
 
28
30
  ## Update the list of Airline Codes
29
31
 
30
- ### Fetch Airline codes
32
+ Data is synced automatically every week from [jpatokal/openflights](https://github.com/jpatokal/openflights). To update manually:
31
33
 
32
34
  ```
33
35
  $ wget https://raw.githubusercontent.com/jpatokal/openflights/master/data/airlines.dat
36
+ $ node normalize.js # apply local corrections (country names, etc.)
37
+ $ node convert.js # regenerate airlines.json from airlines.dat
34
38
  ```
35
39
 
36
- ### Generate the list
40
+ ### Adding corrections
37
41
 
38
- Convert the list of airlines codes from csv format to JSON.
42
+ 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
43
 
44
+ ```javascript
45
+ var COUNTRY_CORRECTIONS = {
46
+ 'Macao': 'Macau',
47
+ 'Republic of Korea': 'South Korea',
48
+ // add new entries here ...
49
+ };
40
50
  ```
41
- node convert.js
42
- ```
51
+
52
+ After editing, re-run the pipeline above to apply the change.
43
53
 
44
54
  ## Thanks
45
55