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

[Feature] Explore Nx executors to standardize tasks across projects #2652

Open
1 task done
tschaffter opened this issue Apr 26, 2024 · 1 comment · May be fixed by #2655
Open
1 task done

[Feature] Explore Nx executors to standardize tasks across projects #2652

tschaffter opened this issue Apr 26, 2024 · 1 comment · May be fixed by #2655
Assignees

Comments

@tschaffter
Copy link
Member

What product(s) is this feature for?

Sage Monorepo

Description

A simple executor could be to print information about a project using NX CLI.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@tschaffter tschaffter self-assigned this Apr 26, 2024
@tschaffter
Copy link
Member Author

tschaffter commented Apr 26, 2024

Creating an Nx executor

Create a TS project in the monorepo that will contains multiple executors:

nx g @nx/js:lib sage-monorepo --bundler=tsc --directory=libs/sage-monorepo --unitTestRunner=jest \
  --projectNameAndRootFormat=as-provided --dry-run

Generate an executor:

nx generate @nx/plugin:executor about --directory=libs/sage-monorepo/src/executors/about \
  --nameAndDirectoryFormat=as-provided

Update tsconfig.base.json so that we import the executor as @sagebionetworks/sage-monorepo:about (standard format suggested by Nx) instead of sage-monorepo:about:

      "@sagebionetworks/sage-monorepo": [
        "libs/sage-monorepo/src/index.ts"
      ]

Add the task about to a openchallenges-api-description project by updating its project.json:

    "about": {
      "executor": "@sagebionetworks/sage-monorepo:about"
    }

Run the task:

$ nx about openchallenges-api-description

> nx run openchallenges-api-description:about

Executor ran for About {}

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target about for project openchallenges-api-description (1s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant