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

[refactor] Better integrate new internal plugins #108

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

yoannmoinet
Copy link
Member

@yoannmoinet yoannmoinet commented Nov 12, 2024

What and why?

Now that we consider internal plugins almost the same as external plugins,
we need to better integrate how we create and verify them.

How?

  • Integrate their creation process in yarn cli create-plugin.
  • Integrate their verification in yarn cli integrity.
  • Update/simplify types.

Note

I will remove Check integrity of our files from the expected checks once this PR is merged.

@yoannmoinet yoannmoinet changed the title [DX] New internal plugins [refactor] New internal plugins Nov 12, 2024
@yoannmoinet yoannmoinet force-pushed the yoann/new-internal-plugins branch 2 times, most recently from 9757247 to 82ed7f6 Compare November 14, 2024 14:34
Base automatically changed from yoann/re-org-files to master November 14, 2024 16:24
@yoannmoinet yoannmoinet changed the title [refactor] New internal plugins [refactor] Better integrate new internal plugins Nov 14, 2024
@yoannmoinet yoannmoinet marked this pull request as ready for review November 14, 2024 16:58
Copy link
Member

@elbywan elbywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

bundler: {
name: `[${yellow('Discouraged')}] Bundler Specific Plugin`,
descriptions: [
'Create a plugin that will be customer facing.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit: it feels weird to me to have different wording for the same thing ('Create a customer facing plugin.' / 'Create a plugin that will be customer facing.')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 100%, I'll update.

@@ -172,7 +244,7 @@ const verifyCodeowners = (plugins: Workspace[]) => {

export const updateFiles = async (plugins: Workspace[]) => {
const errors: string[] = [];
await updateFactory(plugins);
errors.push(...(await updateFactory(plugins)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason that prevents doing this as a one liner?

const errors: string[] = await updateFactory(plugins);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely no reason at all, apart from some refactoring residue.
I'll update.

const paramsString = pluginExports[getFunction]
.toString()
// Find the list of arguments.
.match(/^\(([^)]+)\)/)[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pluginExports[getFunction]always well formatted? If the argument list contains destructuring patterns or extra spacing / new lines it could mess up the regex matching and the subsequent split.

Copy link
Member Author

@yoannmoinet yoannmoinet Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed this is flimsy and hacky.
It's basically a poor-man's dependency injection, doing best-effort.

This is "mostly" safe for a few reasons:

  • the code it parses is coming from a wizard that templates this part.
  • the code is expected to be linted/prettiered, but true that someone could disable this specific line.
  • the result is verified against a list of available params, so if I don't find one, it raises the error.
  • this would only happen on the DD dev side when creating/updating an internal plugin, and would never be able to reach production as it would most likely fail either in the tests, the linting or the typechecking.

I will improve the RegEx to cover more ground than what it does right now.
And keep an eye out in case we hit edge cases in the future.

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

Successfully merging this pull request may close these issues.

2 participants