Skip to content

Commit

Permalink
chore: update folder paths, #66
Browse files Browse the repository at this point in the history
  • Loading branch information
ciatph committed Aug 23, 2024
1 parent 2c5e8d6 commit 9b97306
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ jobs:
node-version: 16.14.2
- name: Install Dependencies and lint
run: |
cd app
npm install
npm run lint
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
key: npm-${{ hashFiles('app/package-lock.json') }}
restore-keys: npm-

- name: Install Dependencies and lint
run: |
cd app
npm install
git rm .eslintrc.js
# Quick hack to fix unix to windows linebreak-style lint errors
Expand All @@ -36,6 +37,7 @@ jobs:
- name: Packge and archive the executable files
run: |
cd app
cp .env.example .env
npm run build:win:all
cd dist
Expand All @@ -46,8 +48,8 @@ jobs:
with:
name: dist
path: |
dist/ph-regions-win.exe
dist/ph-provinces-win.exe
app/dist/ph-regions-win.exe
app/dist/ph-provinces-win.exe
retention-days: 1

release:
Expand Down Expand Up @@ -88,6 +90,8 @@ jobs:
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm publish
- run: |
cd app
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**ph-municipalities** have **NPM scripts** that allow interactive querying of Philippines municipalities included in one or more provinces or from a whole region, with an option of writing them to JSON files from the command line.

It uses `/data/day1.xlsx` (downloaded and stored as of this 20220808) from PAGASA's [10-day weather forecast excel files](https://www.pagasa.dost.gov.ph/climate/climate-prediction/10-day-climate-forecast) as the default data source.
It uses `/app/data/day1.xlsx` (downloaded and stored as of this 20220808) from PAGASA's [10-day weather forecast excel files](https://www.pagasa.dost.gov.ph/climate/climate-prediction/10-day-climate-forecast) as the default data source.

It also asks users to key in the download URL of a remote PAGASA 10-Day weather forecast excel file should they want to use another excel file for a new and updated data source.

Expand Down Expand Up @@ -37,9 +37,9 @@ The following dependencies are used for this project. Feel free to use other dep
- node v16.14.2
- npm v8.5.0
4. Excel file
- ph-municipalities uses Excel files in the `/data` directory as data source.
- ph-municipalities uses Excel files in the `/app/data` directory as data source.
- At minimum, the excel file should have a **column** that contains municipality and province names following the pattern `"municipalityName (provinceName)"`
- Checkout the excel file format on the `/data/day1.xlsx` sample file for more information
- Checkout the excel file format on the `/app/data/day1.xlsx` sample file for more information
5. (Optional) Download URL for a remote excel file.
- See the `EXCEL_FILE_URL` variable on the [Installation](#installation) section.

Expand Down Expand Up @@ -74,24 +74,35 @@ The following dependencies are used for this project. Feel free to use other dep
`git clone https://github.com/ciatph/municipalities-by-province.git`

2. Install dependencies.<br>
`npm install`
```bash
cd app
npm install
```

1. Create a `.env` file from the `.env.example` file. Use the default values for the following environment variables.
1. Create a `.env` file from the `.env.example` file inside the `/app` directory. Use the default values for the following environment variables.

| Variable Name | Description |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Variable Name | Description |
| --- | --- |
| EXCEL_FILE_URL | (Optional) Remote excel file's download URL.<br>If provided, the excel file will be downloaded and saved on the specified `pathToFile` local filesystem location during the `ExcelFile` class initialization.<br>Read on [Usage](#usage) for more information. |
| SHEETJS_COLUMN | Column name read by [sheetjs](https://sheetjs.com/) in an excel file.<br>This column contains the municipality and province names following the string pattern<br>`"municipalityName (provinceName)"`<br>Default value is `__EMPTY`|
| SORT_ALPHABETICAL | Arranges the municipality names in alphabetical order.<br>Default value is `1`. Set to `0` to use the ordering as read from the Excel file. |
| SPECIAL_CHARACTERS | Key-value pairs of special characters or garbled text and their normalized text conversions, delimited by the `":"` character.<br>Multiple key-value pairs are delimited by the `","` character.<br>If a special character key's value is a an empty string, write it as i.e.,: `"some-garbled-text:"` |

## Available Scripts

> _**Note:** These NPM scripts run relative within the `/app` directory._<br>
To run, navigate first to the `/app` directory and execute a target script, for example:
```
cd app
npm run list:region
```

### `npm start` / `npm run list:region`

- Asks users to enter the download URL of a remote excel file or use the default local excel file
- Loads and parses the local excel file in `/data/day1.xlsx` by default.
- Loads and parses the downloaded excel file in `/data/datasource.xlsx` if download URL in the class constructor is provided.
- Loads and parses the local excel file in `/app/data/day1.xlsx` by default.
- Loads and parses the downloaded excel file in `/app/data/datasource.xlsx` if download URL in the class constructor is provided.
- Displays a list of available PH **region** names.
- Lists all provinces and municipalities of a specified region via commandline input.
- Asks for an option to write results to a JSON file.
Expand All @@ -101,8 +112,8 @@ The following dependencies are used for this project. Feel free to use other dep
### `npm run list:province`

- Asks users to enter the download URL of a remote excel file or use the default local excel file
- Loads and parses the local excel file in `/data/day1.xlsx` by default.
- Loads and parses the downloaded excel file in `/data/datasource.xlsx` if download URL in the class constructor is provided.
- Loads and parses the local excel file in `/app/data/day1.xlsx` by default.
- Loads and parses the downloaded excel file in `/app/data/datasource.xlsx` if download URL in the class constructor is provided.
- Lists all municipalities under specified province(s) via commandline input.
- Asks for an option to write results to a JSON file.
- Run the script as follows if installed using `npm i ph-municipalities`:
Expand Down Expand Up @@ -163,7 +174,7 @@ 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.
Below is a simple usage example of the `ExcelFile` class. Check out `/app/src/scripts/sample_usage.js` for more examples.

```javascript
const path = require('path')
Expand All @@ -172,7 +183,7 @@ 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
// Reads an existing excel file on /app/data/day1.xlsx
file = new ExcelFile({
pathToFile: path.join(__dirname, 'data', 'day1.xlsx'),
// fastload: false
Expand Down Expand Up @@ -221,7 +232,7 @@ const ExcelFile = require('./classes/excel')
// const { ExcelFile } = require('ph-municipalities')

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

0 comments on commit 9b97306

Please sign in to comment.