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

feat(nx-plugin): Update executor generator #16982

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

MJez29
Copy link
Contributor

@MJez29 MJez29 commented May 12, 2023

Current Behavior

The executor generator generates

import { MyPluginExecutorSchema } from "./schema";

export default async function runExecutor(options: MyPluginExecutorSchema) {
  console.log("Executor ran for MyPlugin", options);
  return {
    success: true,
  };
}

Expected Behavior

The above code does not make it obvious that an executor has a second context argument or that it can return an AsyncIterableIterator. By typing the function against the Executor type the user will have typesafety to know that they are implementing the interface of their executor correctly and an easy way to view the type definition of an executor

import { Executor } from "@nx/devkit";

import { MyPluginExecutorSchema } from "./schema";

const runExecutor: Executor<MyPluginExecutorSchema> = async (
  options,
  context
) => {
  console.log("Executor ran for MyPlugin", options);
  return {
    success: true,
  };
};

export default runExecutor;

@vercel
Copy link

vercel bot commented May 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2024 7:56pm

@MJez29
Copy link
Contributor Author

MJez29 commented May 12, 2023

Looking at the errors does it make sense to create

export type PromiseExecutor = ...
export type AsyncIterableIteratorExecutor = ...
export type Executor = PromiseExecutor | AsyncIterableIteratorExecutor

and by default generate a PromiseExecutor?

@AgentEnder AgentEnder force-pushed the mjez29/update-executor-generator branch from e9acd21 to 00c5715 Compare June 4, 2024 14:42
@AgentEnder AgentEnder requested a review from a team as a code owner June 4, 2024 14:42
@AgentEnder AgentEnder force-pushed the mjez29/update-executor-generator branch 2 times, most recently from 7f6178f to d7fc1e3 Compare June 4, 2024 18:47
@AgentEnder AgentEnder requested review from a team as code owners June 4, 2024 18:47
@AgentEnder AgentEnder requested a review from jaysoo June 4, 2024 18:47
@AgentEnder AgentEnder merged commit 6d2e7cd into nrwl:master Jun 4, 2024
6 checks passed
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2024
@MJez29 MJez29 deleted the mjez29/update-executor-generator branch June 20, 2024 12:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants