koliveira15 / nx-sonarqube

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

Executor fails for nx 20 #116

Closed gcko closed 2 weeks ago

gcko commented 1 month ago

If possible, please provide a reproduction repository you discovered this bug in.

No response

Which area/package is the issue in?

@koliveira15/nx-sonarqube

Description

Currently, migrating to nx 20 will cause nx-sonarqube's executor to fail to run.

If applicable, please provide the Nx report

Node           : 22.9.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.12.1

nx (global)        : 20.0.0
nx                 : 20.0.0
@nx/js             : 20.0.0
@nx/jest           : 20.0.0
@nx/eslint         : 20.0.0
@nx/workspace      : 20.0.0
@nx/cypress        : 20.0.0
@nx/eslint-plugin  : 20.0.0
@nx/next           : 20.0.0
@nx/react          : 20.0.0
@nx/storybook      : 20.0.0
typescript         : 5.6.3
---------------------------------------
Registered Plugins:
@nx/cypress/plugin
@nx/next/plugin
@nx/eslint/plugin
---------------------------------------
Community plugins:
@koliveira15/nx-sonarqube : 4.1.0
nx-stylelint              : 18.0.0-beta.4

Please provide the exception or error you saw

The SonarQube scan failed for project '[REDACTED]'
TypeError: Cannot read properties of undefined (reading 'projects')
    at [REDACTED]/node_modules/.pnpm/@koliveira15+nx-sonarqube@4.1.0_@nx+devkit@20.0.0_nx@20.0.0_@swc-node+register@1.10.9_@swc+co_ak2va7zieaom4bi7d4q6krshfu/node_modules/@koliveira15/nx-sonarqube/src/executors/scan/utils/utils.js:70:56
    at Generator.next (<anonymous>)
    at fulfilled ([REDACTED]/node_modules/.pnpm/tslib@2.7.0/node_modules/tslib/tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Other information

I tracked the issue to the following: https://github.com/koliveira15/nx-sonarqube/blob/991ee6b20551bad29381a24099c517b6c72d92a9/packages/nx-sonarqube/src/executors/scan/utils/utils.ts#L96C32-L96C70

const projectConfiguration = context.workspace.projects[context.projectName];

i'm willing to submit a PR, however I would need to take time to dig into the issue - my guess is that nx-sonarqube needs to be updated to support nx 20

I would be willing to submit a PR to fix this issue

ak274 commented 1 month ago

Yeah Updating to nx v20.0.0 is failing the executor.

image

gcko commented 1 month ago

FYI @koliveira15, I created a bug on NX to make some adjustments to their release documentation for NX 20 as it was not announced that this breaking change was made -> https://github.com/nrwl/nx/issues/28461

tonvanalebeek commented 3 weeks ago

Any ideas on how to fix this? I'm trying to upgrade to 20.0.9 right now but keep running into this.

Tried applying a patch to the utils.js file for replacing context.workspace.projects with context.projectsConfigurations.projects but then I keep running into peer dependency issues after that

gcko commented 3 weeks ago

Any ideas on how to fix this? I'm trying to upgrade to 20.0.9 right now but keep running into this.

Tried applying a patch to the utils.js file for replacing context.workspace.projects with context.projectsConfigurations.projects but then I keep running into peer dependency issues after that

Pull my PR https://github.com/koliveira15/nx-sonarqube/pull/117

it is fixed there