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

Use conf package for CLI config file #394

Open
garrettjstevens opened this issue May 29, 2024 · 2 comments
Open

Use conf package for CLI config file #394

garrettjstevens opened this issue May 29, 2024 · 2 comments
Assignees

Comments

@garrettjstevens
Copy link
Contributor

I'd like for us to investigate the possibility of using the conf package to manage our CLI's config file. It's a widely-used package, and it provides some potentially useful features we may want in the future, such as config file version migrations (in case we need to change something about the config file in the future after a public release).

@garrettjstevens
Copy link
Contributor Author

@dariober I looked at a couple of the things we talked about at our pairing today regarding conf.

  • I couldn't reproduce the error with the custom cwd and fileExtension. Did you perhaps somehow accidentally create a directory called config.yaml?
  • It looks like conf doesn't allow us to add top-level properties to the schema (see https://github.com/sindresorhus/conf/issues/80), but since the schema is optional, I think we can continue with using conf without a schema and add in our own validation (we can probably keep the existing joi validation). If we subclass Conf, we can add our own validation like this:
class ApolloConf extends Conf {
  constructor(...options: ConstructorParameters<typeof Conf>) {
    super(...options)
    // validate this.store
  }

  get store() {
    const superStore = super.store
    // validate superStore
    return superStore
  }

  set store(newStore) {
    // validate newStore
    super.store = newStore
  }
}

@dariober
Copy link
Contributor

Did you perhaps somehow accidentally create a directory called config.yaml

Yes! It must have happened while playing with Conf


In branch use-conf I replaced the old implementation with the Conf package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants