-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Is your feature request related to a problem? Please describe.
Currently, the Fusion Framework CLI has a fixed set of commands (app, portal, auth, create, disco, ai) that are hardcoded in the CLI package. This limits extensibility and makes it difficult for teams or third-party developers to add custom commands or extend CLI functionality without modifying the core CLI package.
Describe the solution you'd like
Implement a plugin system for the CLI that allows:
-
Plugin Discovery & Loading
- Support for plugins installed as npm packages (e.g.,
@equinor/fusion-framework-cli-plugin-*) - Support for local plugins (e.g.,
.fusion/plugins/directory) - Plugin discovery via
package.jsondependencies or configuration file - Plugin versioning and compatibility checks
- Support for plugins installed as npm packages (e.g.,
-
Plugin API
- Standard interface for plugins to register commands with Commander.js
- Access to CLI utilities (logger, spinner, etc.)
- Lifecycle hooks (before/after command execution)
- Configuration support (plugin-specific config in
.fusion/config.jsonor similar)
-
Plugin Structure
interface CliPlugin { name: string; version: string; description?: string; register(program: Command, context: CliContext): void | Promise<void>; // Optional lifecycle hooks beforeCommand?(command: string, args: string[]): void | Promise<void>; afterCommand?(command: string, args: string[]): void | Promise<void>; }
-
Integration Points
- Load plugins during CLI initialization (in
src/cli/main.ts) - Register plugin commands alongside built-in commands
- Support for plugin-specific help text and documentation
- Plugin error handling and isolation
- Load plugins during CLI initialization (in
-
Developer Experience
- Clear documentation on creating plugins
- Example plugin template/boilerplate
- Plugin validation and error messages
- Support for plugin development mode (hot reload during development)
Describe alternatives you've considered
- Monorepo-only extensions: Only allow extending CLI within the monorepo - this doesn't help external developers
- Forking the CLI: Not maintainable and creates fragmentation
- Wrapper scripts: Workaround but doesn't integrate with CLI help, error handling, or utilities
- Configuration-based commands: Limited flexibility compared to full plugin system
Additional context
Current CLI Structure:
The CLI uses Commander.js and currently registers commands in src/cli/commands/index.ts:
app- Application lifecycle commandsportal- Portal template commandsauth- Authentication commandscreate- Project scaffoldingdisco- Service discoveryai- AI/LLM integration commands
Inspiration from Framework:
The Fusion Framework already has plugin patterns (e.g., feature flags with addPlugin()), which could serve as a reference for the CLI plugin architecture.
Use Cases:
- Teams adding custom deployment commands specific to their infrastructure
- Third-party tools integrating with Fusion Framework (e.g., testing frameworks, code generators)
- Internal tools extending CLI functionality without modifying core package
- Custom build pipelines or CI/CD integrations
Implementation Considerations:
- Plugin security and sandboxing (if needed)
- Plugin dependency management
- Backward compatibility with existing commands
- Performance impact of plugin loading
- Plugin discovery performance (especially with many plugins)
Related:
- Similar to how Vite, ESLint, and other tools support plugins
- Could enable ecosystem growth around Fusion Framework CLI