Plazide / fauna-gql-upload

A tool for managing your FaunaDB database using files. Create resources such as functions by simply creating a new file.
https://fgu-docs.com
MIT No Attribution
54 stars 10 forks source link

Feature: Allow loading custom `.fauna.json` file #26

Closed Vadorequest closed 3 years ago

Vadorequest commented 3 years ago

I'd like to have 2 different envPath (e.g: .env.local.production and .env.local.staging) which would both define FAUNADB_SERVER_SECRET_KEY pointing to 2 different Fauna DBs (staging, production)

Right now, I don't think I can achieve that because the .fauna.json path is hardcoded and can't be changed.

Could an option to fauna-gql script could be added to allow specifying a custom config file?

https://github.com/Plazide/fauna-gql-upload/blob/746d86acc377773a6576f781caa8d1a474ea1450/src/util/getConfig.ts#L44

Plazide commented 3 years ago

Yes, that sounds like a good idea.

It would also be nice to have command-line options for each specific property in .fauna.json, so that you wouldn't need multiple configs with just one or two different options. In your case, you could simply add a script like this:

fgu --envPath .env.local.production

And to specify a different config altogether, you would do:

fgu --config .fauna.prod.json

I'll add this ASAP.

Plazide commented 3 years ago

Okay,

Custom path for config file is now supported with version 2.1.0, simply use:

fgu --config custom.config.json

You can also pass in command-line options for every property supported in the config file. So you could specify a custom environment file with the following:

fgu --envPath .custom.env
Vadorequest commented 3 years ago

Awesome, thank you! I'll try it out ASAP

Vadorequest commented 3 years ago

Works like a charm!

    "fauna:sync": "fauna-gql --envPath .env.staging.local",
    "fauna:sync:production": "fauna-gql --envPath .env.production.local",
    "fauna:override": "fauna-gql --override --envPath .env.staging.local",
    "fauna:override:production": "fauna-gql --envPath .env.production.local",