-
-
Couldn't load subscription status.
- Fork 85
feat: add possibility to override default path to config file #667
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I haven't tested it yet. I just took a look at the changed files and added a few comments. Please make sure that the exporter and importer functionality works too :)
| const config = await getConfigDiff(options) | ||
|
|
||
| await writeConfigToFile(config) | ||
| await writeConfigToFile(config, '.typesafe-i18n.json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need to use options.project here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I wrote this, I think that this setup method is used only for in-place config generation, not for generate config in path passed by --project path
We can add path here too if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more consistent if someone is able to pass the -p flag also to the setup function.
| logger.info(`version ${version}`) | ||
|
|
||
| await checkAndUpdateSchemaVersion() | ||
| await checkAndUpdateSchemaVersion(options.project) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a validation here?
The string should end with .json and we should check if the file exists (except if it is a setup call).
|
|
||
| export const readConfig = async (): Promise<GeneratorConfig> => { | ||
| const generatorConfig = await readRawConfig() | ||
| export const readConfig = async (configPath = '.typesafe-i18n.json'): Promise<GeneratorConfig> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not use default values anywhere. This makes it easy to miss a spot where we forgot to pass it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you have some ideas, how we can save backward compatibility with previous codebase that have hardcoded path to file, without default values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally it get's passed from the CLI and .typesafe-i18n.json is the default value there if -p does not get specified.
Without having a look at the code, I currently don't really know where this function get's called. But the call stack to this function should only be initiated from the CLI or the exporter & importer I think
|
@whalemare I saw this PR was not updated for a while. Do you plan to continue working on this PR? |
Yes, but little bit early. We can close this PR if you want and I reopen it or create new one, when I will be ready |
|
No it's fine. We can keep it open if you plan to continue working on it. |
Related to #656
Allow pass additional parameter to
clinamed as--project, that allow users to override default'.typesafe-i18n.json'path to config fileSave backward compatibility to allow current users change nothing in it's workflow.
Tested locally with command