fix(plugins): implement dynamic plugin loading and unloading#6
Merged
Conversation
- Add plugin-loader.ts module for dynamic command loading - Load installed plugins on CLI startup - Execute plugin commands when matched - Clear plugin cache when unloading to prevent stale commands - Add tests for plugin loader functionality - Add integration test for plugin lifecycle (load/unload) Fixes issue where plugin commands remained available after unloading. Plugin commands are now properly loaded from node_modules at runtime and removed from memory when unloaded.
- Remove test.skip from plugin lifecycle integration test - Make test idempotent with proper before/after cleanup - Fix plugin command routing - check plugins BEFORE verb-only check - Add file:// protocol and cache-busting for dynamic imports - Improve test to capture both stdout and stderr The key bug was that plugin commands were checked after the verb-only check, so single-word plugin commands would trigger showVerbResources instead of executing. Now plugin commands are checked first. Test now runs successfully in both local and CI/CD environments.
- Add debug() method to Logger class with timestamp and JSON support - Enable debug mode via DEBUG=1 or C8CTL_DEBUG=1 env vars - Refactor getter/setter methods to modern TS property syntax - mode property (was getMode/setMode methods) - debugEnabled property for toggling debug output - Update plugin-loader to use logger.debug() instead of console.log - Add comprehensive debug mode tests - Document debug mode in README Debug output goes to stderr to avoid interfering with command output. Modern TS syntax reduces boilerplate and improves readability.
|
This has been released in 1.0.0. |
Collaborator
Author
|
ping back to https://github.com/camunda/product-hub/issues/2638 |
|
This has been released in 2.0.0. |
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.
Problem
After loading and unloading a plugin, the command was still available even though the plugin was unloaded. This was because there was no actual runtime plugin loading mechanism - the CLI only wrapped
npm installandnpm uninstallbut never actually loaded or executed plugin commands.Solution
plugin-loader.tsmodule for dynamic command loadingChanges
src/plugin-loader.ts- New module for managing plugin lifecyclesrc/index.ts- Load plugins at startup, route plugin commandssrc/commands/plugins.ts- Made async, clear cache on unloadtests/unit/plugin-loader.test.ts- Unit tests for plugin loadertests/integration/plugin-lifecycle.test.ts- Integration test (skipped by default)Testing
Fixes the issue where plugin commands remained available after unloading.