Skip to content

feat(core): integrate auto-installer with plugin loader for seamless plugin installation#67

Merged
michaelbe812 merged 3 commits intomainfrom
feat/issue-66-auto-installer-integration
Sep 17, 2025
Merged

feat(core): integrate auto-installer with plugin loader for seamless plugin installation#67
michaelbe812 merged 3 commits intomainfrom
feat/issue-66-auto-installer-integration

Conversation

@michaelbe812
Copy link
Copy Markdown
Contributor

Summary

  • Integrates auto-installer with plugin loader for automatic plugin package installation
  • Provides seamless UX when plugin packages are missing

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:

  • The package is a known @nx-plugin-openapi/* plugin
  • Not running in a CI environment
  • The package is genuinely missing (not other errors)

Changes

  • Modified plugin-loader.ts to add auto-installation logic after fallback paths are tried
  • Added comprehensive tests for auto-installation scenarios
  • Handle installation failures gracefully with proper logging

Benefits

  1. Seamless UX: Users don't need to manually install plugin packages
  2. Maintains existing behavior: Fallback paths and error handling remain unchanged
  3. Safe: Only attempts installation for known plugin packages in development environments
  4. Leverages existing infrastructure: Uses the already-implemented auto-installer module

Testing

  • All existing tests pass
  • New tests added for auto-installation scenarios
  • Linting passes
  • Tested with missing packages, CI environments, and installation failures

Fixes #66

…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
Copy link
Copy Markdown
Contributor Author

@michaelbe812 michaelbe812 left a comment

Choose a reason for hiding this comment

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

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)

  1. Avoid repeated install attempts on failure: track failed auto-installs per package during process lifetime to prevent repeated attempts.
  2. Add a test for createPlugin() after installation to exercise all export patterns, mirroring the default-export case.
  3. Consider passing cwd/root into installPackages so installing occurs at workspace root when loadPlugin is invoked with opts.root.
  4. 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 });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@michaelbe812 michaelbe812 merged commit ec7d3d2 into main Sep 17, 2025
2 checks passed
@michaelbe812 michaelbe812 deleted the feat/issue-66-auto-installer-integration branch September 17, 2025 04:47
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.

Integrate auto-installer with plugin loader for seamless plugin installation

1 participant