Skip to content

Commit 6e48930

Browse files
gbfs-validator npm package ready (#176)
* gbfs-validator npm package ready
1 parent b3d2358 commit 6e48930

File tree

6 files changed

+127
-8
lines changed

6 files changed

+127
-8
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: GBFS Validator CLI - Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Navigate CLI Directory
17+
run: cd gbfs-validator
18+
19+
- name: Get current published version
20+
id: get_current_published_version
21+
run: echo "::set-output name=get_current_published_version::$(npm info gbfs-validator version)"
22+
23+
- name: Get current local version
24+
id: get_current_local_version
25+
run: echo "::set-output name=get_current_local_version::$(jq -r '.version' package.json)"
26+
27+
- name: Check if version changed
28+
run: |
29+
if [ "${{ steps.get_current_published_version.outputs.get_current_published_version }}" != "${{ steps.get_current_local_version.outputs.get_current_local_version }}" ]; then
30+
echo "Version changed from ${{ steps.get_current_published_version.outputs.get_current_published_version }} to ${{ steps.get_current_local_version.outputs.get_current_local_version }}"
31+
else
32+
echo "Version did not change"
33+
exit 0
34+
fi
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v2
38+
with:
39+
node-version: '18'
40+
registry-url: 'https://registry.npmjs.org'
41+
42+
- name: Install dependencies
43+
run: npm install
44+
45+
- name: Publish to npm
46+
run: npm publish
47+
env:
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
49+

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ Options:
107107
-h, --help display help for command
108108
```
109109

110+
### Npm package
111+
The gbfs-validator Node.js npm package is now accessible for integration into your projects. To learn how to install and utilize it effectively, please refer to the [README](./gbfs-validator/README.md) for comprehensive guidance.
112+
110113
## Projects based on this validator
111114

112115
[transport.data.gouv.fr GBFS validator tool](https://transport.data.gouv.fr/validation?type=gbfs) - Tool displaying interactive geofencing, station, and vehicle maps, the validation results, and metadata of GBFS feeds.

gbfs-validator/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# GBFS-Validator
2+
3+
[![npm version](https://badge.fury.io/js/gbfs-validator.svg)](http://badge.fury.io/js/gbfs-validator)
4+
5+
GBFS Validator is a command-line tool for validating General Bikeshare Feed Specification (GBFS) data feed and outputing the report in a JSON file
6+
7+
## Add the Dependency
8+
9+
To use `gbfs-validator` in your own project, you need to
10+
first install our [Node.js npm package](https://www.npmjs.com/package/gbfs-validator):
11+
12+
```
13+
npm install gbfs-validator
14+
```
15+
16+
## Example Code
17+
```
18+
const GBFS = require('gbfs-validator');
19+
20+
const feedUrl = "https://gbfs.velobixi.com/gbfs/gbfs.json";
21+
const feedOptions = {}
22+
const gbfs = new GBFS(feedUrl, feedOptions)
23+
24+
gbfs.validation().then((reportResults) => {
25+
// reportResults: GBFS Validation Report Results in JSON
26+
}).catch(error => {
27+
// error handling
28+
})
29+
30+
gbfs.getFiles().then((gbfsFeedFiles) => {
31+
// gbfsFeedFiles: Info about GBFS feed
32+
}).catch(error => {
33+
// error handling
34+
})
35+
```
36+
37+
## Usage of the Command Line Interface
38+
39+
How to validate a feed and place the report in a located file
40+
```
41+
gbfs-validator -u {http_address_of_gbfs_dataset} -s {local_path_to_output_report_file}
42+
```
43+
44+
## Example of the CLI
45+
46+
```
47+
gbfs-validator -u https://gbfs.velobixi.com/gbfs/gbfs.json -s ~/Documents/log.json
48+
```
49+
50+
## Options
51+
52+
```
53+
-v, --version: output the version number
54+
-u, --url <feed_url>: URL of the GBFS feed
55+
-vb, --verbose: Verbose mode prints debugging console logs
56+
-s, --save-report <report_path>: Local path to output report file
57+
-pr, --print-report <yes_no>: Print report to standard output (choices: "yes", "no", default: "yes")
58+
-h, --help: display help for command
59+
```

gbfs-validator/__test__/gbfs.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ describe('conditional required vehicle_type_id', () => {
546546
return gbfs.validation().then(result => {
547547
expect(result).toMatchObject({
548548
summary: expect.objectContaining({
549-
validatorVersion: '1.0.0',
550549
version: { detected: '2.2', validated: '2.2' },
551550
hasErrors: true,
552551
errorsCount: 2
@@ -603,7 +602,6 @@ describe('conditional no required vehicle_type_id', () => {
603602
return gbfs.validation().then(result => {
604603
expect(result).toMatchObject({
605604
summary: expect.objectContaining({
606-
validatorVersion: '1.0.0',
607605
version: { detected: '2.2', validated: '2.2' }
608606
}),
609607
files: expect.arrayContaining([

gbfs-validator/__test__/gbfs.v3.0-RC2.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ describe('default feed', () => {
5151
expect(result).toMatchObject({
5252
summary: expect.objectContaining({
5353
version: { detected: '3.0-RC2', validated: '3.0-RC2' },
54-
validatorVersion: '1.0.0',
5554
hasErrors: false
5655
}),
5756
files: expect.any(Array)
@@ -98,7 +97,6 @@ describe('invalid feed', () => {
9897
expect(result).toMatchObject({
9998
summary: expect.objectContaining({
10099
version: { detected: '3.0-RC2', validated: '3.0-RC2' },
101-
validatorVersion: '1.0.0',
102100
hasErrors: true,
103101
errorsCount: 1
104102
}),
@@ -143,7 +141,6 @@ describe('exaustive feed', () => {
143141
expect(result).toMatchObject({
144142
summary: expect.objectContaining({
145143
version: { detected: '3.0-RC2', validated: '3.0-RC2' },
146-
validatorVersion: '1.0.0',
147144
hasErrors: false
148145
}),
149146
files: expect.any(Array)

gbfs-validator/package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
{
22
"name": "gbfs-validator",
3-
"version": "1.0.0",
4-
"author": "Pierrick <[email protected]>",
3+
"version": "1.0.5",
4+
"author": "MobilityData",
55
"main": "index.js",
66
"license": "MIT",
7-
"bin": "./cli.js",
7+
"description": "Node-based libraries to validate GBFS feeds",
8+
"tags": [
9+
"gbfs-validator"
10+
],
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/MobilityData/gbfs-validator.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/MobilityData/gbfs-validator/issues"
17+
},
18+
"bin": {
19+
"gbfs-validator": "./cli.js"
20+
},
821
"scripts": {
922
"test": "jest"
1023
},

0 commit comments

Comments
 (0)