transloco-keys-manager: Bug: transloco-key-manager breaks in a nx workspace of version 15.7.0 or higher

Is there an existing issue for this?

  • I have searched the existing issues

Is this a regression?

Yes

Current behavior

When running the transloco-key-manager in a nx workspace of version 15.7.x the key manager does not work, upon trying to run it with

npx transloco-keys-manager extract or npx transloco-keys-manager find

You will get the following output.

Unable to load workspace config from angular.json, .angular.json, workspace.json. Defaulting source root to 'src'
Input path provided doesn't exists!

nx version 15.7.x removed the angular.json, which is causing the error in the key manager. When restoring this file the error goes away, but nx will then no longer work correctly.

Expected behavior

transloco-key-manager working as before/intended

Please provide a link to a minimal reproduction of the bug

Transloco Config

No response

Debug Logs

Unable to load workspace config from angular.json, .angular.json, workspace.json. Defaulting source root to 'src'
Input path provided doesn't exists!


### Please provide the environment you discovered this bug in

```markdown
Transloco: 4.2.2
Transloco Keys Manager: 3.5.0
Angular: 15.1.4
Node: 18.13.0
Package Manager: yarn
OS: Windows & Linux ( Ubuntu )
nx: 15.7.2

Additional context

No response

I would like to make a pull request for this bug

No

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 25 (4 by maintainers)

Most upvoted comments

@pookdeveloper It’s not working on the reproduction repo that @robertIsaac provided?

no… I try in my repo

@shaharkazaz

@JelleBruisten Specifying the project when you don’t have a root config is mandatory, otherwise there is no way for me to tell which project you need (no default) Would you like to open a PR to update the docs? maybe also add the recipe for nx?

Yeah I noticed from looking at the source, and yes I can make a PR ( likely tomorrow )

@robertIsaac It’s based on the project name but there is an assumption that it will be found under a folder with the same name, since there is no root workspace config there is no mapping for project name -> path

in the repro yes I forget to pass the project in the real project no, I was passing the project

I confirm the repro works now when passing the project, I need to double check what’s wrong with the real project and get back to you

I have a similar problem with running npx transloco-keys-manager extract however I am able to work around the problem with running: npx transloco-keys-manager extract --project foo

So specifying the project you wan’t to extract does work now, calling it like before for all projects in a workspace does not however.

Workaround you can add a target to your project.json of your projects within a nx workspace like so:

    "i18n-extract": {
      "executor": "nx:run-commands",
      "options": {
        "command": "npx transloco-keys-manager extract --project foo"
      }
    }

Then you can also run this like this: nx affected --target=i18n-extract so you will just extract affected libraries by your code changes or run on all: nx run-many --target=i18n-extract

@robertIsaac Please share a link to a reproduction repo, once shared I’ll reopen.