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

0.0.1 - Initial version #1

Merged
merged 20 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Pull Request Check
on:
pull_request:
branches:
- dev/*
- master
jobs:
unit-tests:
name: Unit Tests
uses: ./.github/workflows/unit-tests.yml
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish
on:
push:
branches: master
jobs:
unit-tests:
name: Unit Tests
uses: ./.github/workflows/unit-tests.yml
publish:
name: Publish
needs: unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Get package.json
id: get-package
run: echo PACKAGE=$(cat ./package.json) >> $GITHUB_OUTPUT
- name: Get package version
id: get-package-version
run: echo VERSION="${{ fromJson(steps.get-package.outputs.PACKAGE).version }}" >> $GITHUB_OUTPUT
- name: Install
run: npm ci
- name: Build & Pack
run: npm run pack
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tag
run: |
git config --global user.name "ponlawat-w"
git config --global user.email "[email protected]"
git tag -fa "v${{ steps.get-package-version.outputs.VERSION }}" -m "v${{ steps.get-package-version.outputs.VERSION }}"
git push --force origin v${{ steps.get-package-version.outputs.VERSION }}
19 changes: 19 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Unit Tests
on: workflow_call
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install
run: npm ci
- name: Test
run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ dist
.ionide

# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode

tests/data/ignore/*
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# GTFS-IO

IO Operations for GTFS dataset in node / javascript.

## Installation

```bash
npm i gtfs-io
```

## Examples

### Load Feed

```ts
// Synchronously
import { GTFSFeedReader } from 'gtfs-io';
const reader = GTFSFeedReader.fromZip('gtfs.zip');
const reader = GTFSFeedReader.fromDirectory('path/to/dir');
const feed = reader.loadFeed();
console.log(feed.stops[0].stop_id);
console.log(feed.trips[1].trip_id);

// Asynchronously
import { GTFSAsyncFeedReader } from 'gtfs-io';
const reader = GTFSAsyncFeedReader.fromZip('gtfs.zip');
const reader = GTFSAsyncFeedReader.fromDirectory('path/to/dir');
const feed = await reader.loadFeed();
console.log(feed.stops[0].stop_id);
console.log(feed.trips[1].trip_id);
```

### Write Feed

```ts
import { GTFSLoadedFeed } from 'gtfs-io';
const feed = new GTFSLoadedFeed({
agency: [{ agency_id: '...', agency_name: '...', ... }, ...],
stops: [{ stop_id: '...', ... }, { ... }, ...],
routes: [{ ... }, { ... }, ...],
trips: [{ ... }, ...],
...
});

// Synchronously
import { GTFSFeedWriter } from 'gtfs-io';
GTFSFeedWriter.writeZip(feed, 'gtfs.zip');
GTFSFeedWriter.writeDirectory(feed, 'path/to/dir');

// Asynchronously
import { GTFSAsyncFeedWriter } from 'gtfs-io';
await GTFSAsyncFeedWriter.writeZip(feed, 'gtfs.zip');
await GTFSAsyncFeedWriter.writeDirectory(feed, 'path/to/dir');
```

---
Loading