Skip to content
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

[BUG] Generated -types project does not uses nx.json configured generators values #816

Open
sharky98 opened this issue Jan 17, 2024 · 1 comment
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member

Comments

@sharky98
Copy link

Current Behavior

When creating a webapi application with skipSwaggerLib=false, a new -types project is created as expected. This project (I think?) is created using the @nx/js:library generator. I have in my nx.json configured to use vitest as the unit test runner. However, in the dry-run I see that files such as jest.config.ts are created, hinting that my configuration to use vitest is not considered.

{
  "generators": {
    "@nx/js": {
      "library": {
        "simpleName": true,
        "linter": "eslint",
        "bundler": "none",
        "unitTestRunner": "vitest",
        "projectNameAndRootFormat": "as-provided"
      }
    }
  }
}

Expected Behavior

The generated project uses my pre-configured vitest as the unit test runner.

Github Repo

No response

Steps to Reproduce

  1. Have a fresh Nx repo with nx-dotnet configured. Make sure that any init run during that setup does not install @nx/jest.
  2. Make sure that the generators for @nx/js:application in nx.json uses "unitTestRunner": "vitest".
  3. Run nx g @nx-dotnet/core:application --name=backend --language=C# --template=webapi --dry-run.

The dry-run output shows that files for jest are created, when they should not be (not also we observe bug #801 in that the generated projects are not under libs or apps).

In Nx 18, generating projects will no longer derive the name and root.
Please provide the exact project name and root in the future.
Example: nx g @nx/js:library generated-backend-types --directory generated/backend-types
CREATE apps/backend/project.json
CREATE apps/backend-test/project.json
CREATE generated/backend-swagger/project.json
CREATE generated/backend-types/tsconfig.json
CREATE generated/backend-types/README.md
CREATE generated/backend-types/src/index.ts
CREATE generated/backend-types/src/lib/generated-backend-types.spec.ts
CREATE generated/backend-types/src/lib/generated-backend-types.ts
CREATE generated/backend-types/tsconfig.lib.json
CREATE generated/backend-types/package.json
CREATE generated/backend-types/project.json
CREATE generated/backend-types/.eslintrc.json
CREATE jest.preset.js
UPDATE nx.json
CREATE jest.config.ts
UPDATE package.json
CREATE generated/backend-types/jest.config.ts
CREATE generated/backend-types/tsconfig.spec.json
UPDATE tsconfig.base.json
CREATE apps/backend/.gitignore

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.10.0
   OS     : win32-x64
   pnpm   : 8.14.1

   nx (global)        : 17.2.8
   nx                 : 17.2.8
   @nx/js             : 17.2.8
   @nx/eslint         : 17.2.8
   @nx/workspace      : 17.2.8
   @nx/cypress        : 17.2.8
   @nx/devkit         : 17.2.8
   @nx/eslint-plugin  : 17.2.8
   @nx/plugin         : 17.2.8
   @nx/react          : 17.2.8
   @nrwl/tao          : 17.2.8
   @nx/vite           : 17.2.8
   typescript         : 5.3.3
   ---------------------------------------
   Community plugins:
   @nx-dotnet/core : 2.1.2

nx.json

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "targetDefaults": {
    "build": {
      "cache": true,
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"]
    },
    "lint": {
      "cache": true,
      "inputs": ["default", "{workspaceRoot}/.eslintignore", "{workspaceRoot}/.eslintrc.json"]
    },
    "@nx/vite:test": {
      "cache": true,
      "inputs": ["default", "^production"]
    },
    "e2e": {
      "cache": true,
      "inputs": ["default", "^production"]
    }
  },
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": [
      "default",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/.eslintrc.json",
      "!{projectRoot}/cypress/**/*",
      "!{projectRoot}/**/*.cy.[jt]s?(x)",
      "!{projectRoot}/cypress.config.[jt]s"
    ],
    "sharedGlobals": []
  },
  "plugins": ["@nx-dotnet/core"],
  "generators": {
    "@nx/js": {
      "library": {
        "simpleName": true,
        "linter": "eslint",
        "bundler": "none",
        "unitTestRunner": "vitest",
        "projectNameAndRootFormat": "as-provided"
      }
    },
    "@nx/react": {
      "application": {
        "style": "none",
        "linter": "eslint",
        "bundler": "vite",
        "routing": false,
        "simpleName": true,
        "compiler": "swc",
        "e2eTestRunner": "cypress",
        "unitTestRunner": "vitest",
        "projectNameAndRootFormat": "as-provided",
        "babel": true
      },
      "library": {
        "style": "none",
        "linter": "eslint",
        "simpleName": true,
        "compiler": "swc",
        "bundler": "none",
        "unitTestRunner": "vitest",
        "projectNameAndRootFormat": "as-provided"
      },
      "component": {
        "style": "none"
      }
    },
    "@nx-dotnet/core": {
      "application": {
        "solutionFile": "root-dotnet.sln"
      },
      "library": {
        "solutionFile": "root-dotnet.sln"
      }
    }
  }
}

Failure Logs

No response

Additional Information

No response

@sharky98 sharky98 added bug Something isn't working needs-triage This issue has yet to be looked over by a core team member labels Jan 17, 2024
@sharky98
Copy link
Author

I was wondering if in the meantime, I can use add-swagger-target and swagger-typescript
generators to create the swagger and types in a pre-created library project? I am not certain on how the arguments work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member
Projects
None yet
Development

No branches or pull requests

1 participant