jjangga0214 / hasura-cli

Hasura CLI as an npm package
https://www.npmjs.com/package/hasura-cli
90 stars 27 forks source link

Cannot find config file (directory context not right) when executing through yarn #108

Closed madmaxlax closed 11 months ago

madmaxlax commented 1 year ago

Hi I am trying to use the hasura-cli from the package install, rather than installing it globally. in my project repo, I want to keep my hasura details in a directory ./hasura within the repo (so my config file is at hasura/config.yaml) (I think this is the problem)

when I try to run hasura commands, it can't find the hasura command, or it can't find the config file

my-repo $ yarn hasura migrate create init 
FATA[0000] validating current directory failed: cannot find [config.yaml] | search stopped: filesystem boundary hit 

I think this is because it runs from the hasura binary location in node modules

or if I use yarn's --cwd to the directory with the config file I get an error that yarn can't find a package.json:

/hasura $ yarn --cwd ./ hasura migrate create init --from-server --endpoint https://cloud.hasura.io/project/78009faa-b745-4f97-8359-496a7d53d66b --admin-secret oqT7qJD8s9XGiiWhn4e2l9C3avyCcix0nK4rdRIO6CeoCOQhgYRDLalei7sGUX98 
Debugger attached.
yarn run v1.22.19
warning ../package.json: No license field
error Couldn't find a package.json file in "/Users/struevermax/dev/combined-primary-api-hasura-db/hasura"

is there any way to make this work with a subdirectory being where the hasura config lives?

putting the hasura details and config at the repo (alongside package.json) works . but I just wanted to try and keep the repo a bit more organized, and also not need to install the hasura cli globally

jjangga0214 commented 12 months ago

Hi!

Have you tried --project?

There's also an example from README.

package.json:

{
  "scripts": {
    "hasura": "hasura --project <your-preferred-path> --skip-update-check",
  }
}
madmaxlax commented 11 months ago

Hi!

Have you tried --project?

There's also an example from README.

package.json:


{

  "scripts": {

    "hasura": "hasura --project <your-preferred-path> --skip-update-check",

  }

}

Ah perfect! Thank you that should do it