Skip to content

Commit

Permalink
Merge pull request #45 from ciatph/dev
Browse files Browse the repository at this point in the history
v1.0.5
  • Loading branch information
ciatph authored Jan 28, 2023
2 parents eda06bc + 446f6b0 commit 05ae4d6
Show file tree
Hide file tree
Showing 14 changed files with 408 additions and 352 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
runs-on: ubuntu-latest
needs: build-on-win
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules/
dist/
.github/
.env
.vscode
*.xlsx
*.json
*.zip

.env.example
.eslintrc.js
.eslintrc_win.js
.gitignore
.npmignore

# Ignore all JSON files except:
!package.json
!package-lock.json
!data/regions.json

# Ignore all Excel files except:
!data/regions.json
!data/day1.xlsx
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,47 +156,62 @@ Fix JavaScript lint errors.

### Load and Parse a Local Excel File

Below is a simple usage example of the `ExcelFile` class. Check out `/src/scripts/sample_usage.js` for more examples.

```javascript
const path = require('path')
const { ExcelFile } = require('./classes/excel')
const ExcelFile = require('./classes/excel')

// Use the the following if installed via npm
// const ExcelFile = require('ph-municipalities')

// Reads an existing excel file on /data/day1.xlsx
file = new ExcelFile({
pathToFile: path.join(__dirname, '..', 'data', 'day1.xlsx')
pathToFile: path.join(__dirname, 'data', 'day1.xlsx')
})

try {
file.init()
} catch (err) {
console.log(`[ERROR]: ${err.message}`)
}
// listMunicipalities() lists all municipalities
// for each province
const municipalitiesFromProvince =
file.listMunicipalities(['Albay','Masbate','Sorsogon'])

// writeMunicipalities() writes municipalities data in a JSON file
file.writeMunicipalities({
provinces: municipalitiesFromProvince,
fileName: path.join(__dirname, 'municipalities.json'),
prettify: true
})

// JSON data of the parsed excel file will be accessible on
// file.datalist
console.log(file.datalist)
```

### Download and Parse a Remote Excel File

Adding a `url` field in the constructor parameter will download a remote excel file for data source.

```javascript
require('dotenv').config()
const path = require('path')
const { ExcelFile } = require('./classes/excel')
const ExcelFile = require('./classes/excel')

// Use the the following if installed via npm
// const ExcelFile = require('ph-municipalities')

const main = async () => {
// Excel file will be downloaded to /data/day1.xlsx
file = new ExcelFile({
pathToFile: path.join(__dirname, '..', 'data', 'day1.xlsx'),
pathToFile: path.join(__dirname, 'data', 'day1.xlsx'),
url: process.env.EXCEL_FILE_URL
})

try {
await file.init()
console.log(file.datalist)
} catch (err) {
console.log(err.message)
}

// JSON data of the parsed excel file will be accessible on
// file.datalist
}

main()
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require('dotenv').config()
const ExcelFile = require('./src/classes/excel')
const ExcelFactory = require('./src/classes/excelfactory')

module.exports = {
ExcelFile,
ExcelFactory
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "municipalities-by-province",
"version": "1.0.0",
"description": "Extract the `municipalities` of a given `province` from an excel file and write them in a JSON file.",
"name": "ph-municipalities",
"version": "1.0.5",
"description": "List and write the `municipalities` of Philippines provinces or regions into JSON files",
"main": "index.js",
"scripts": {
"start": "npm run list:region",
Expand All @@ -11,22 +11,22 @@
"build:win:region": "pkg ./src/scripts/by_region.js -c package.json --compress GZip -o ./dist/ph-regions-win",
"build:win:province": "pkg ./src/scripts/by_province.js -c package.json --compress GZip -o ./dist/ph-provinces-win",
"build:win:all": "npm run build:win:region && npm run build:win:province",
"minify:region": "ncc build src/scripts/by_region.js -m -o dist/region",
"minify:province": "ncc build src/scripts/by_province.js -m -o dist/province",
"minify:region": "ncc dist src/scripts/by_region.js -m -o dist/region",
"minify:province": "ncc dist src/scripts/by_province.js -m -o dist/province",
"minify:all": "npm run minify:region && npm run minify:province",
"lint": "eslint src",
"lint:fix": "eslint src --fix"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ciatph/municipalities-by-province.git"
"url": "git+https://github.com/ciatph/ph-municipalities.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/ciatph/municipalities-by-province/issues"
"url": "https://github.com/ciatph/ph-municipalities/issues"
},
"homepage": "https://github.com/ciatph/municipalities-by-province#readme",
"homepage": "https://github.com/ciatph/ph-municipalities#readme",
"devDependencies": {
"@vercel/ncc": "^0.34.0",
"eslint": "^8.21.0",
Expand Down
Loading

0 comments on commit 05ae4d6

Please sign in to comment.