koliveira15 / nx-sonarqube

A Nx plugin that scans projects using SonarQube / SonarCloud.
MIT License
51 stars 21 forks source link

Failed to find apps/<app-name>/package.json when run the command #46

Closed destnguyxn2 closed 1 year ago

destnguyxn2 commented 1 year ago

Hello,

When I try to run the plugin using nx run-many, the plugin try to find the package.json in the dỉectory of each application end raise an error ENOENT: no such file or directory since there is only project.json

It is not make the command failed but seem annoying when I try to read the console log. Could you check this please?

Thank you

gcko commented 1 year ago

@koliveira15 The issue for me is that I define a package.json at the root level, and not for each application. Reading the code in utils.js, I notice that it is expecting each application to have a package.json file. I suggest you add a fallback to check the root directory for a package.json file and use the version from there

gcko commented 1 year ago

@destnguyxn a "quick fix" to remove the error is to add projectVersion to your sonar options:

{
...
"sonar": {
      "executor": "@koliveira15/nx-sonarqube:scan",
      "options": {
        "projectVersion": "1.0",
        ...
      }
    }
  }
}
destnguyxn2 commented 1 year ago

@gcko the plugin does have a fallback to the root directory when not found the package.json , it just the error message seems annoying and may cause misunderstanding.

Thank you for the quick fix 😄

gcko commented 1 year ago

@destnguyxn ah! well in that case, the solution would be to change it from an ERROR to an INFO message, or WARN