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

NX commands interceptor/middleware #4927

Closed
Bielik20 opened this issue Mar 1, 2021 · 6 comments
Closed

NX commands interceptor/middleware #4927

Bielik20 opened this issue Mar 1, 2021 · 6 comments

Comments

@Bielik20
Copy link
Contributor

Bielik20 commented Mar 1, 2021

Description

It would be amazing if you could introduce workspace wide interceptor for all commands run.

In workspace.json we would add field

{
  "interceptors": ["./tools/interceptors/print-args"]
}

Then print-args file would be something like:

export default async function printArgs(input: Input, next: (input: Input) => Promise<Output>): Promise<Output> {
  console.log(input);
  const output = await next(input);
  console.log(output);
  return output;
}

Input would be Options, plus builder/executor/generator/schematic identificator (should also say if it is builder, executor, generator or schematic).

Output would probably be { success: boolean }.

Calling next invokes next interceptor or actual builder/executor/generator/schematic if there are none left. It would be very similar to Angular's HttpInterceptor but for all NX commands.

Motivation

Ability to modify parameters and output of various commands would be very useful to make workspace more suited for individual teams. Our use case is that we have parameter alias which we use to setup different environments on AWS, frontend builders etc. This parameter needs to be of a specific format, no longer than 10 character, only alpha numeric values etc. Right now, for each builder we use I have to write elaborate modification that parses this param if needed. It would be great to have one alias-interceptor which would listen for that param and modify it if needed for every builder/executor.

Suggested Implementation

I haven't worked on that yet, I would like to hear your opinion first.

Alternate Implementations

Same.

@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Mar 6, 2021
@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Mar 29, 2021
@Bielik20
Copy link
Contributor Author

I know it may not be the smallest or simplest change, but I think it deserves conversation. It would add a lot of personalisation capabilities to the workspace. In the future even stuff like dotnet could be moved to such an interceptor allowing executors to be free of that.

@github-actions github-actions bot removed the stale label Mar 30, 2021
@github-actions
Copy link

github-actions bot commented Dec 6, 2021

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Dec 6, 2021
@Bielik20
Copy link
Contributor Author

Bielik20 commented Dec 6, 2021

Keep alive.

@github-actions github-actions bot removed the stale label Dec 7, 2021
@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants