Skip to content

Commit

Permalink
Switch to Turborepo, TypeScript 5; ESM/CJS/IIFE support (#109)
Browse files Browse the repository at this point in the history
* WIP: move files; scripts are working

* Update node CI

* Revert some changes for PHP

* CJS, ESM, IIFE builds; turbo task order for CI
  • Loading branch information
dmythro authored May 6, 2023
1 parent a3479fd commit 3c39c8f
Show file tree
Hide file tree
Showing 78 changed files with 10,202 additions and 15,206 deletions.
30 changes: 10 additions & 20 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,37 @@ on:
branches:
- master
paths:
- '.github/workflows/*.yml'
- 'data/**'
- '*.js'
- '*.json'
- '*.ts'
- '.github/workflows/nodejs.yml'
- 'packages/countries/src/**'
- '!.editorconfig'
- '!.travis.yml'
- '!**LICENSE*'
- '!**README*'

jobs:
build:
nodejs:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 16, 14, 12]
node-version: [20, 18, 16]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: ${{ matrix.node-version }}

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('./package-lock.json') }}
- name: NPM install
run: npm ci --prefer-offline --no-audit --no-optional --ignore-scripts
run: npm install --prefer-offline --no-audit
env:
CI: true

- name: Build & Test
run: npm run build --if-present
# Test is intentionally glued with `build` script
# - run: npm test
# Runs lint, build & tests
run: npm run ci
env:
CI: true
18 changes: 9 additions & 9 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ on:
branches:
- master
paths:
- '.github/workflows/*.yml'
- 'data/**'
- '.github/workflows/phpunit.yml'
- 'dist/**.json'
- 'dist/*.php'
- 'test/*.php'
- '*.js'
- '*.json'
- '*.ts'
- 'packages/countries/data/**'
- 'packages/test-php/**'
- 'phpunit.xml'
- '!.editorconfig'
- '!.travis.yml'
- '!**LICENSE*'
Expand All @@ -25,12 +24,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: php-actions/composer@v5
- uses: php-actions/composer@v6

- name: PHPUnit Tests
uses: php-actions/phpunit@v2
uses: php-actions/phpunit@v3
with:
version: 9
configuration: phpunit.xml
args: --coverage-text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
coverage
.eslintcache
.phpunit.cache
.turbo

composer.phar

Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
24 changes: 0 additions & 24 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coverage/*

*.json
dist/*

*.min.*
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
- '20'
- '18'
os:
- linux
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Package is available via:

## Usage

Module exports `continents`, `countries`, `languages`, `languagesAll` and functions:
Module exports `continents`, `countries`, `languages` and functions:

- `getEmojiFlag(countryCode)`, where `countryCode` is alpha-2 `String`
- `getUnicode(emoji)`, where `emoji` is alpha-2 emoji flag `String`
Expand All @@ -36,13 +36,14 @@ The `./data` directory contains source data.

The consistent data is available from `./dist/data.*` files (JSON, SQL).

**Note**: ES5 UMD build is here: `./dist/index.es5.min.js`.
**Note**: ES6 builds:
- CJS `./dist/index.js`.
- ESM `./dist/index.mjs`.
- IIFE `./dist/index.iife.js`.

**Note**: Country item `languages` field is an `Array` in JSON files to easily count and match items with a Language item.
But `currency` and `phone` calling codes may be a comma-separated `String`.

**Note**: Languages list only contains languages used in Countries data. Full list of known languages is exported as `languagesAll` from `./dist/languages.all.json`.

## Data example

```
Expand Down
29 changes: 0 additions & 29 deletions bower.json

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"authors": [
{
"name": "Dmytro",
"email": "[email protected]",
"email": "[email protected]",
"homepage": "https://github.com/dmythro"
}
],
Expand All @@ -35,7 +35,7 @@
"require": {},
"autoload": {
"files": [
"dist/index.php"
"index.php"
]
},
"homepage": "http://annexare.github.io/Countries/",
Expand Down
9 changes: 0 additions & 9 deletions data/continents.json

This file was deleted.

Loading

0 comments on commit 3c39c8f

Please sign in to comment.