phrase / phrase-cli

CLI for the Phrase API
https://developers.phrase.com
MIT License
42 stars 6 forks source link

Allow "bubbling" for .phrase.yml #100

Open dunklesToast opened 2 years ago

dunklesToast commented 2 years ago

Currently the Phrase CLI seems to only search for the .phrase.yml in the current working dir. It'd be great if the CLI would bubble up the working tree until it finds a config. This comes in handy for Monorepos where the config is at the repos root but you're currently working on a specific package.

.
└── monorepo/
    ├── package1/
    │   ├── src
    │   ├── package.json
    │   └── tsconfig.json
    ├── package2/
    │   └── src/
    │       └── i18n
    └── .phrase.yml

With bubbling the CLI would use the .phrase.yml even if I am in package1 or package2. The CLI should use the .phrase.yml location as cwd to resolve filepaths.

theSoenke commented 2 years ago

Hey, I know that many popular tools allow this merging based on the directory structure. For the CLI config, it could be a bit more problematic as it is not just a simple flat key-value config but has multiple nestings. While merging multiple configs would be possible it could get somewhat confusing how the final used configuration is looking like with which configuration options. For now, we do not have plans to add this to the CLI but we might revisit this in the future

To use a config in a specific path it's also possible to use the --config <path> parameter to use a different config than in the current directory

dunklesToast commented 2 years ago

I wouldn't require merging multiple configs. I'd be happy if the CLI would just traverse the filetree up and search for the first config that it finds and uses that. Would that be possible?

theSoenke commented 2 years ago

Ah thanks for the clarification. That also sounds like something that could come in quite handy. That should also be definitely doable to implement. I don't think we can add it right away though as we're currently working on some other improvements for the CLI but this is something we might pick up after that. Also feel free to take a look at the code yourself and open a PR if you like. The code in this repo is generated here https://github.com/phrase/openapi/tree/master/clients/cli