feat(core): integrate auto-installer with plugin loader for seamless plugin installation#67
Merged
michaelbe812 merged 3 commits intomainfrom Sep 17, 2025
Merged
Conversation
…plugin installation - Add auto-installation logic to plugin loader when packages are missing - Auto-install only for @nx-plugin-openapi/* packages in development - Skip auto-installation in CI environments - Handle installation failures gracefully with proper logging - Add comprehensive tests for auto-installation scenarios Fixes #66
michaelbe812
commented
Sep 16, 2025
Contributor
Author
michaelbe812
left a comment
There was a problem hiding this comment.
Review summary
- Integration of auto-installer into plugin loader looks solid and scoped.
- Tests cover happy path, CI skip, non-scope packages, failure handling, and built-in mapping.
- Ran Nx tests across workspace locally; all suites passed. No regressions observed.
Suggestions (non-blocking)
- Avoid repeated install attempts on failure: track failed auto-installs per package during process lifetime to prevent repeated attempts.
- Add a test for createPlugin() after installation to exercise all export patterns, mirroring the default-export case.
- Consider passing cwd/root into installPackages so installing occurs at workspace root when loadPlugin is invoked with opts.root.
- Optional environment opt-out (e.g., NX_PLUGIN_OPENAPI_AUTO_INSTALL=false) for advanced users.
LGTM from a functionality standpoint. I can’t formally approve my own PR; please have another maintainer approve.
| if (shouldTryAutoInstall(e, pkg)) { | ||
| logger.info(`Attempting to auto-install missing plugin: ${pkg}`); | ||
| try { | ||
| installPackages([pkg], { dev: true }); |
Contributor
There was a problem hiding this comment.
The installPackages() function appears to be asynchronous but is being called synchronously. This could lead to the retry import executing before the installation completes. Consider adding await:
await installPackages([pkg], { dev: true });This ensures the installation fully completes before attempting to import the newly installed package.
Suggested change
| installPackages([pkg], { dev: true }); | |
| await installPackages([pkg], { dev: true }); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem Statement
Currently, when users try to use a plugin but the corresponding npm package is not installed, the plugin loader throws a PluginNotFoundError. This creates a poor user experience as users must manually install plugin packages before using them.
Solution
Integrated the existing auto-installer infrastructure with the plugin loader to automatically install missing plugin packages when:
Changes
Benefits
Testing
Fixes #66