Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0.0 #50

Merged
merged 30 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3a58b57
Add 'US' as an alternative name for the US
alpn Aug 12, 2023
02bec89
Create node.js.yml
BrodaNoel May 7, 2024
4127007
bring codebase to the modern era
meeDamian Aug 26, 2024
7ccb22a
Add and use xo parser able to handle import attributes
meeDamian Aug 26, 2024
74295a4
Make xo happy
meeDamian Aug 26, 2024
ebcd665
Make sure countries.json always maps string->array[1+]. Closes #47
meeDamian Aug 29, 2024
9651c9d
Add Python port. Close #40
meeDamian Aug 29, 2024
fc426dc
sort out README badges
meeDamian Aug 29, 2024
549a42e
Add modules example to README
meeDamian Aug 29, 2024
eacc294
first batch of countries.json necessary updates
meeDamian Aug 29, 2024
562f4be
Merge branch 'brodanoel/run-tests-on-each-new-pr' into v2.0.0
meeDamian Aug 29, 2024
05f68ef
Move CI to GH Actions
meeDamian Aug 29, 2024
e21eef1
only test on node 20+
meeDamian Aug 29, 2024
9061d45
Add .nvmrc = 20 as per #46
meeDamian Aug 29, 2024
4442dc9
Add name normalisation, as I can't imagine when "Virgin Islands, Brit…
meeDamian Aug 29, 2024
258646f
Handle & in country names as per #45
meeDamian Aug 29, 2024
721e516
Return Türkiye by default
meeDamian Aug 29, 2024
f49158c
Limit extent of output normalisation
meeDamian Aug 29, 2024
2872589
Replace test example
meeDamian Aug 29, 2024
47c5d4d
Make sure South Sudan is handled correctly. Closes #49
meeDamian Aug 29, 2024
cee9bab
Update .gitignore
meeDamian Aug 29, 2024
a25a1b1
pedantic space is pedantic
meeDamian Aug 29, 2024
c4ae409
Make xo happy
meeDamian Aug 29, 2024
0fec536
Fix coverage
meeDamian Aug 29, 2024
279038a
CI on push to selected branches only
meeDamian Aug 29, 2024
e0d8605
automate GH Release publishing to npm
meeDamian Aug 29, 2024
8ed8553
2.0.0-alpha.1
meeDamian Aug 29, 2024
b7c52e2
rid of GH actions complaining
meeDamian Aug 29, 2024
4bd7db8
2.0.0-alpha.2
meeDamian Aug 29, 2024
ea4638f
update README
meeDamian Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["@babel/preset-env"]
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-syntax-import-attributes"]
}
59 changes: 59 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: ['master', 'main']
pull_request:
branches: ['master', 'main']
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20, 22 ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- name: Publish to npm
run: |
if [[ "${{ github.ref }}" == *-beta* ]]; then
npm publish --tag beta
elif [[ "${{ github.ref }}" == *-alpha* ]]; then
npm publish --tag alpha
else
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.log
npm-debug.log*
coverage*
.nyc_output
node_modules
dist/
.idea/
countries.csv
countries-*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
# country-emoji

[![npm_svg]][npm_url]
[![travis_svg]][travis_url]
[![codeship_svg]][codeship_url]
[![npm_alpha_svg]][npm_url]
[![dl_url]][npm_url]
[![coveralls_svg]][coveralls_url]
[![codecov_svg]][codecov_url]
[![dl_url]][npm_url]
[![xo_svg]][xo_url]
[![license_svg]][license_url]
[![tippin_svg]][tippin_url]


[npm_svg]: https://img.shields.io/npm/v/country-emoji
[npm_alpha_svg]: https://img.shields.io/npm/v/country-emoji/alpha
[npm_url]: https://www.npmjs.com/package/country-emoji

[travis_svg]: https://travis-ci.org/meeDamian/country-emoji.svg?branch=master
[travis_url]: https://travis-ci.org/meeDamian/country-emoji

[codeship_svg]: https://app.codeship.com/projects/4c475430-6f94-0134-4dcc-3acc74581569/status?branch=master
[codeship_url]: https://app.codeship.com/projects/178069
[dl_url]: https://img.shields.io/npm/dw/country-emoji

[coveralls_svg]: https://coveralls.io/repos/github/meeDamian/country-emoji/badge.svg?branch=master
[coveralls_url]: https://coveralls.io/github/meeDamian/country-emoji?branch=master

[codecov_svg]: https://codecov.io/github/meeDamian/country-emoji/coverage.svg?branch=master
[codecov_url]: https://codecov.io/github/meeDamian/country-emoji?branch=master

[dl_url]: https://img.shields.io/npm/dw/country-emoji

[xo_svg]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo_url]: https://github.com/sindresorhus/xo

[license_svg]: https://img.shields.io/npm/l/country-emoji
[license_url]: https://github.com/meeDamian/country-emoji/blob/master/LICENSE

[tippin_svg]: https://img.shields.io/badge/donate-lightning-FDD023?logo=bitcoin&style=flat
[tippin_url]: https://tippin.me/@meeDamian

Converts between country names, ISO 3166-1 codes and flag emojis. **Has zero dependencies.**

## Install

```
$ npm install --save country-emoji
# or
$ npm install --save country-emoji@alpha
```

## Usage

```js
const {flag, code, name, countries} = require('country-emoji');
// or
import {flag, code, name, countries} from 'country-emoji';

flag('CL')
// ~> 🇨🇱
Expand Down Expand Up @@ -101,8 +95,10 @@ Check out the following:

* **Swift:** [SwiftFlags](https://github.com/BubiDevs/SwiftFlags) (ref: [#16](https://github.com/meeDamian/country-emoji/issues/16))
* **Rust:** [country-emoji](https://github.com/leodutra/country-emoji) [[crates.io]] (ref: [#20](https://github.com/meeDamian/country-emoji/issues/20))
* **Python:** [country-emoji](https://github.com/Nnonexistent/country-emoji) [[PyPI]] (ref: [#40](https://github.com/meeDamian/country-emoji/issues/40))

[crates.io]: https://crates.io/crates/country-emoji
[PyPI]: https://pypi.org/project/country-emoji/

PS. Happy to add more here :).

Expand Down
32 changes: 16 additions & 16 deletions countries.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"AI": ["Anguilla", "Anguillian"],
"AL": ["Albania", "Albanian"],
"AM": ["Armenia", "Armenian"],
"AN": "Netherlands Antilles",
"AN": ["Netherlands Antilles"],
"AO": ["Angola", "Angolan"],
"AQ": ["Antarctica", "Antarctican"],
"AR": ["Argentina", "Argentine"],
Expand All @@ -28,12 +28,12 @@
"BL": ["Saint Barthélemy", "Barthélemois", "Saint Barth"],
"BM": ["Bermuda", "Bermudian"],
"BN": ["Brunei Darussalam", "Bruneian"],
"BO": ["Bolivia", "Bolivian"],
"BO": ["Bolivia, Plurinational State of", "Bolivian"],
"BR": ["Brazil", "Brazilian"],
"BS": ["Bahamas", "Bahamian"],
"BT": ["Bhutan", "Bhutanese"],
"BQ": "Caribbean Netherlands",
"BV": "Bouvet Island",
"BQ": ["Caribbean Netherlands"],
"BV": ["Bouvet Island"],
"BW": ["Botswana", "Motswana"],
"BY": ["Belarus", "Belarusian"],
"BZ": ["Belize", "Belizean"],
Expand All @@ -43,7 +43,7 @@
"CF": ["Central African Republic", "Central African"],
"CG": ["Congo"],
"CH": ["Switzerland", "Swiss"],
"CI": ["Cote D'Ivoire", "Ivorian"],
"CI": ["Cote D'Ivoire", "Côte d'Ivoire", "Ivorian"],
"CK": ["Cook Islands", "Cook Islander"],
"CL": ["Chile", "Chilean"],
"CM": ["Cameroon", "Cameroonian"],
Expand All @@ -69,7 +69,7 @@
"ER": ["Eritrea", "Eritrean"],
"ES": ["Spain", "Spanish"],
"ET": ["Ethiopia", "Ethiopian"],
"EU": "European Union",
"EU": ["European Union"],
"FI": ["Finland", "Finnish"],
"FJ": ["Fiji", "Fijian"],
"FK": ["Falkland Islands (Malvinas)", "Falkland Islander"],
Expand Down Expand Up @@ -126,7 +126,7 @@
"KW": ["Kuwait", "Kuwaiti"],
"KY": ["Cayman Islands", "Caymanian"],
"KZ": ["Kazakhstan", "Kazakhstani"],
"LA": ["Lao People's Democratic Republic", "Laotian"],
"LA": ["Lao People's Democratic Republic", "Laos", "Laotian"],
"LB": ["Lebanon", "Lebanese"],
"LC": ["Saint Lucia", "Saint Lucian"],
"LI": ["Liechtenstein", "Liechtensteiner"],
Expand All @@ -136,7 +136,7 @@
"LT": ["Lithuania", "Lithuanian"],
"LU": ["Luxembourg", "Luxembourger"],
"LV": ["Latvia", "Latvian"],
"LY": ["Libyan Arab Jamahiriya", "Libyan"],
"LY": ["Libyan Arab Jamahiriya", "Libya", "Libyan"],
"MA": ["Morocco", "Moroccan"],
"MC": ["Monaco", "Monegasque"],
"MD": ["Moldova, Republic of", "Moldovan"],
Expand Down Expand Up @@ -181,17 +181,17 @@
"PK": ["Pakistan", "Pakistani"],
"PL": ["Poland", "Polish"],
"PM": ["Saint Pierre and Miquelon"],
"PN": ["Pitcairn", "Pitcairn Islander"],
"PN": ["Pitcairn", "Pitcairn Islands", "Pitcairn Islander"],
"PR": ["Puerto Rico", "Puerto Rican"],
"PS": ["Palestinian Territory, Occupied", "Palestine", "Palestinian"],
"PT": ["Portugal", "Portuguese"],
"PW": ["Palau", "Palauan"],
"PY": ["Paraguay", "Paraguayan"],
"QA": ["Qatar", "Qatari"],
"RE": ["Reunion"],
"RE": ["Reunion", "Réunion"],
"RO": ["Romania", "Romanian"],
"RS": ["Serbia", "Serbian"],
"RU": ["Russian Federation", "Russian"],
"RU": ["Russian Federation", "Russia", "Russian"],
"RW": ["Rwanda", "Rwandan"],
"SA": ["Saudi Arabia", "Saudi Arabian"],
"SB": ["Solomon Islands", "Solomon Islander"],
Expand All @@ -209,11 +209,11 @@
"SO": ["Somalia", "Somali"],
"SR": ["Suriname", "Surinamer"],
"SS": ["Republic of South Sudan", "South Sudan", "South Sudanese"],
"ST": ["Sao Tome and Principe", "Sao Tomean"],
"ST": ["Sao Tome and Principe", "São Tomé and Príncipe", "Sao Tomean"],
"SV": ["El Salvador", "Salvadoran"],
"SX": ["Sint Maarten", "Sint Maartener"],
"SY": ["Syrian Arab Republic", "Syrian"],
"SZ": ["Swaziland", "Swazi"],
"SY": ["Syrian Arab Republic", "Syria", "Syrian"],
"SZ": ["Eswatini", "Swaziland", "Swazi"],
"TC": ["Turks and Caicos Islands", "Turks and Caicos Islander"],
"TD": ["Chad", "Chadian"],
"TF": ["French Southern Territories"],
Expand All @@ -225,15 +225,15 @@
"TM": ["Turkmenistan", "Turkmen"],
"TN": ["Tunisia", "Tunisian"],
"TO": ["Tonga", "Tongan"],
"TR": ["Turkey", "Turkish"],
"TR": ["Türkiye","Turkey", "Turkish"],
"TT": ["Trinidad and Tobago", "Trinidadian"],
"TV": ["Tuvalu", "Tuvaluan"],
"TW": ["Taiwan", "Taiwanese"],
"TZ": ["Tanzania, United Republic of", "Tanzanian"],
"UA": ["Ukraine", "Ukrainian"],
"UG": ["Uganda", "Ugandan"],
"UM": ["United States Minor Outlying Islands"],
"US": ["United States", "USA", "American"],
"US": ["United States", "USA", "US", "American"],
"UY": ["Uruguay", "Uruguayan"],
"UZ": ["Uzbekistan", "Uzbekistani"],
"VA": ["Holy See (Vatican City State)", "Vatican"],
Expand Down
15 changes: 7 additions & 8 deletions examples.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env node
'use strict';

function print(fnCall, out, comment = '') {
if (comment) {
comment = `// ${comment}\n`;
}
import {
flag, code, name, countries,
} from './src/main.js';

console.log(`${comment}${fnCall}\n // ~> ${out}\n`);
}
function print(functionCall, out, comment = '') {
comment &&= `// ${comment}\n`;

const {flag, code, name, countries} = require('./src/main.js');
console.log(`${comment}${functionCall}\n // ~> ${out}\n`);
}

print('flag(\'CL\')', flag('CL'));
print('code(\'🇨🇦\')', code('🇨🇦'));
Expand Down
7 changes: 3 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ declare module 'country-emoji' {
export function name(input: string): string | undefined;

/**
* Object that contains every single countries' name and language name.
* Object that contains every single country's name and language name.
* The value is an array of at least one string.
*
* @example {"BG": ["Bulgaria", "Bulgarian"]}; countries["BG"] would be ["Bulgaria", "Bulgarian"]
*
*/
export const countries: {
[key: string]: [string, string];
};
export const countries: Record<string, [string, ...string[]]>;
}
Loading
Loading