MobilityData / gbfs-validator

The canonical GBFS validator. Maintained by the GBFS community, facilitated by MobilityData.
https://gbfs-validator.mobilitydata.org/
Apache License 2.0
18 stars 12 forks source link

CLI or http for local gbfs files #70

Closed aswinthomas closed 1 year ago

aswinthomas commented 2 years ago

Would it be possible to use the cli for validating gbfs files that are not hosted anywhere? For example:

node cli.js ~/Downloads/gbfs.json

The workaround I use now is using a local server python3 -m SimpleHTTPServer 8000

Also the example referenced in Issue #53 does not seem to work anymore (commit 35a22994fbc4f7435a7b8cc146619fbc8e2de114)

node cli.js https://transport.data.gouv.fr/gbfs/strasbourg/gbfs.json
gbfs-validator/gbfs-validator/gbfs.js:63
      lang.body?.data?.vehicle_types.map(vt => {
                ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (gbfs-validator/gbfs-validator/index.js:1:14)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
PierrickP commented 2 years ago

Hello @aswinthomas

For the second point, check your node version. For optionnal chaining (the ?., https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) you need at least, node 14 (LTS is 16.x)

Yes validate offline feed can be a good functunality :+1:

richfab commented 1 year ago

UPDATE: I had to change the workaround to python3 -m http.server 8000 for it to work. I was then able to use the CLI on a local GBFS feed: node cli -u http://localhost:8000/<Local path to the GBFS feed>

Moving the discussion to https://github.com/MobilityData/gbfs-validator/issues/70. Thank you!