Skip to content

Conversation

@ricardo-devis-agullo
Copy link
Collaborator

@ricardo-devis-agullo ricardo-devis-agullo commented Aug 26, 2025

Enhanced Configuration Management and Fallback Client Support

Overview

This PR introduces a comprehensive refactoring of OpenComponents' configuration management system and adds support for fallback client functionality. The changes improve the developer experience by providing better configuration structure, enhanced fallback capabilities, and cleaner code organization.

Key Changes

1. Centralized Configuration Management (src/cli/domain/ocConfig.ts)

  • New centralized configuration module that provides type-safe access to OpenComponents configuration
  • Structured configuration schema with proper TypeScript interfaces for better type safety
  • Backward compatibility maintained through deprecated mocks configuration that maps to the new development.plugins structure
  • Unified configuration parsing that merges legacy and new configuration formats seamlessly

2. Enhanced Development Configuration Structure

The configuration now follows a more logical structure:

{
  "registries": ["https://registry.example.com"],
  "development": {
    "plugins": {
      "static": { "pluginName": "staticValue" },
      "dynamic": { "pluginName": "./path/to/plugin.js" }
    },
    "fallback": {
      "url": "https://fallback-registry.example.com",
      "client": true
    }
  }
}

3. Fallback Client Support

  • Automatic fallback detection from configuration when fallbackRegistryUrl is not explicitly provided
  • Configurable client source allowing developers to use a fallback registry's client for component previews
  • Enhanced preview functionality that respects fallback client configuration

4. Improved Plugin Mocking System

  • Type-safe plugin mocking with proper TypeScript support
  • Simplified mock registration through the new configuration structure
  • Better error handling and validation for plugin configurations

5. Code Quality Improvements

  • Removed unused imports and cleaned up type definitions
  • Enhanced logging with component compilation progress indicators
  • Better error handling throughout the configuration management system
  • Consistent configuration access patterns across all modules

Technical Details

Configuration Migration

The system automatically migrates from the legacy mocks structure to the new development.plugins structure:

// Legacy format (still supported)
{
  "mocks": {
    "plugins": {
      "static": { "auth": "mock-token" },
      "dynamic": { "database": "./mocks/db.js" }
    }
  }
}

// New format (recommended)
{
  "development": {
    "plugins": {
      "static": { "auth": "mock-token" },
      "dynamic": { "database": "./mocks/db.js" }
    }
  }
}

Fallback Client Integration

When development.fallback.client is enabled, the preview system will:

  1. Use the fallback registry's client script instead of the local one
  2. Maintain proper component isolation and functionality
  3. Provide seamless fallback experience for missing components

Migration Guide

For existing configurations, no manual migration is required. The system automatically handles backward compatibility. However, it's recommended to update configurations to use the new development structure for better maintainability.

Testing

  • All existing functionality has been preserved with backward compatibility
  • New fallback client functionality has been tested with various registry configurations
  • Configuration parsing and migration logic has been thoroughly tested

This refactoring provides a solid foundation for future enhancements while maintaining full backward compatibility with existing OpenComponents deployments.

@ricardo-devis-agullo ricardo-devis-agullo merged commit 00e9275 into master Aug 26, 2025
3 checks passed
@ricardo-devis-agullo ricardo-devis-agullo deleted the fallback-client branch August 26, 2025 21:19
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