jsverse / transloco-keys-manager

🦄 The Key to a Better Translation Experience
https://github.com/jsverse/transloco/
MIT License
203 stars 49 forks source link

fix: resolveProjectBasePath could not find source root when directory… #158

Open JelleBruisten opened 1 year ago

JelleBruisten commented 1 year ago

… name and project name are different

prior to this change we would look for **/<projectName> however this does not work when we have a folder structure like: /libs/ui/my-button where the project name would be ui-my-button causing the keys not to be detected this change would look for all project.json files and look for the correct project.json by comparing the name property within

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Currently when having a folder structure where the project name does not match the folder name transloco-key-manager is unable to find the source root.

for example if we would have libs/booking/ui/button when looking for a project with the name booking-ui-button transloco won't find the source root of this project causing the error: image

Issue Number: N/A

What is the new behavior?

with the changes in this PR we look for all project.json and compare the name property to find out if it is the correct config file.

this enables us to have folder structures like /booking/ui/button /booking/ui/card /invoicing/ui/button

And before when running npx transloco-keys-manager extract --project=button it would match one of these libraries but never the other. This change would also make this possible where everything is correctly matched based on the project name that is specified in project.json ( project name should still be unique in each workspace else nx will not work correctly either ).

Does this PR introduce a breaking change?


[ ] Yes
[X ] No

## Other information
stackblitz[bot] commented 1 year ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

evanfuture commented 1 year ago

Hi, any reason why this hasn't been merged? I was wondering why some keys on my project weren't being extracted. Turns out, a lot weren't because of this. Applied it locally and works fine...

shaharkazaz commented 1 year ago

I'll try to review this week 👍