orval icon indicating copy to clipboard operation
orval copied to clipboard

Angular Builder to run the generation

Open jogelin opened this issue 2 years ago • 1 comments

Usually, in Angular development, we are using the Angular CLI that is specifying a way to run/configure/test/etc... the project.

For example, you can have multiple applications and you can start them by using:

yarn start myApp
yarn start myOtherApp

The start is considered as a target of your application. We can create our custom target by creating a builder.

So it would be useful to have an orval builder that could be used in the angular.json:

{
  "myApp": {
    ...
    "architect": {
      "orval": {
        "builder": "orval:generate",
        "options": {
          "config": "./apps/my-app/orval.config.js",
          ... // all configuration could be set here but starting with the link to the orval config is already good
        },
      },
      ...

jogelin avatar Aug 20 '21 10:08 jogelin

For Nx Users, this approach could be used too:

"targets": {
    ...
    "orval": {
      "executor": "@nrwl/workspace:run-commands",
      "outputs": ["libs/my-app/core/api/src/lib/*/generated"],
      "options": {
        "commands": ["npx orval --config libs/my-app/core/api/orval.config.js"]
      }
    }
  },

And add orval script in your package.json:

    ...
    "orval": "nx orval",
    ...

And run the target like this:

yarn orval my-app-core-api

But this is just an alternative of a real builder

jogelin avatar Aug 20 '21 11:08 jogelin

@jogelin there has been no other requests or upvotes on this issue so I am going to mark it as workaround provided and close it. I can reopen if a PR is provided.

melloware avatar Nov 15 '23 01:11 melloware