Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ src/plugins/*/dist/
# Plugins copied to Host wwwroot during build
src/dotnet/Host/wwwroot/plugins/

# Shell UI build outputs
src/dotnet/Host/wwwroot/assets/
src/dotnet/Host/wwwroot/index.html

# -------------------------
# Environment & Config
# -------------------------
Expand Down
314 changes: 314 additions & 0 deletions IMPLEMENTATION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
# Enterprise Reporting and CLI Implementation Summary

## Overview

This implementation adds comprehensive enterprise-ready reporting and monitoring capabilities to the DataverseDevKit Solution Layer Analyzer, including a command-line interface (CLI) for automation and CI/CD integration.

## What Was Implemented

### 1. Backend Models and Database Schema

#### New Models
- **Report**: Represents a saved report configuration with query, severity, recommended actions
- **ReportGroup**: Organizes reports into logical groups
- **AnalyzerConfig**: Global configuration for analyzer including source/target solutions and reports
- **ReportSeverity**: Enum for severity levels (Information, Warning, Critical)
- **ReportVerbosity**: Enum for output detail levels (Basic, Medium, Verbose)
- **ReportOutputFormat**: Enum for output formats (YAML, JSON, CSV)

#### Database Changes
- Added `Reports` table with columns for name, description, group, severity, action, query, display order
- Added `ReportGroups` table for organizing reports
- Configured Entity Framework relationships and indexes
- Support for automatic schema migration via EF Core

### 2. Report Management Service

Created `ReportService` with comprehensive CRUD operations:
- **Save/Update/Delete Reports**: Full lifecycle management
- **Duplicate Reports**: Clone existing reports with modifications
- **Reorder Reports**: Change display order and grouping
- **Execute Reports**: Run saved queries and return results
- **Group Management**: Create, update, delete, and reorder report groups
- **Export/Import Configuration**: YAML-based config persistence

#### Serialization Support
- **YAML**: Using YamlDotNet for human-readable configs
- **JSON**: For machine-readable integration
- **CSV**: Custom CSV helper for Excel processing

The CSV output is optimized for different verbosity levels:
- Basic: One row per component
- Medium: One row per layer with changed attributes list
- Verbose: One row per attribute change with old/new values

### 3. Plugin Command Extensions

Added 14 new commands to the Solution Layer Analyzer plugin:

#### Report Commands
- `saveReport`: Save a query/filter as a report
- `updateReport`: Modify an existing report
- `deleteReport`: Remove a report
- `duplicateReport`: Clone a report
- `listReports`: Get all reports organized by groups
- `executeReport`: Run a saved report
- `reorderReports`: Change report ordering and grouping

#### Group Commands
- `createReportGroup`: Create a new group
- `updateReportGroup`: Modify a group
- `deleteReportGroup`: Remove a group
- `reorderReportGroups`: Change group ordering

#### Config Commands
- `exportConfig`: Export configuration to YAML
- `importConfig`: Import configuration from YAML
- `generateReportOutput`: Generate detailed reports in YAML/JSON/CSV

### 4. CLI Application

Created a complete .NET Console application (`DataverseDevKit.SolutionAnalyzer.CLI`) with:

#### Features
- **System.CommandLine**: Modern command-line parsing
- **File Logging**: Dedicated log files per execution
- **Console Logging**: Real-time feedback with success/error indicators
- **YAML Configuration**: Human-readable config files
- **Multiple Output Formats**: YAML, JSON, CSV
- **Flexible Verbosity**: Control detail level for both CLI and reports

#### Commands
- `index`: Build solution component index
- `run`: Execute all configured reports
- `export`: Export current configuration
- `import`: Import configuration from file

#### Authentication Support (Structure Ready)
- Connection string
- Interactive OAuth (placeholder)
- Service principal with client credentials (placeholder)

## Configuration File Structure

The YAML configuration file structure:

```yaml
sourceSolutions:
- CoreSolution
targetSolutions:
- Project1
- Project2
componentTypes: # Optional
- 1 # Entity
- 24 # SystemForm
reportGroups:
- name: Group Name
displayOrder: 1
reports:
- name: Report Name
description: Description
severity: Information|Warning|Critical
recommendedAction: Action to take
displayOrder: 1
queryJson: '{ filter query JSON }'
ungroupedReports:
- name: Standalone Report
# same structure as above
```

## Example Report Scenarios

The implementation supports the scenarios described in the requirements:

### 1. Empty Layers Detection
```yaml
name: Empty Layers that can be removed
severity: Information
action: Remove empty layer
```
Identifies layers with no actual changes that can be safely removed.

### 2. Consolidation Opportunities
```yaml
name: Form or View layers that may need consolidation
severity: Warning
action: Consider moving to Core solution
```
Finds customizations that should potentially move to the core solution.

### 3. Critical Conflicts
```yaml
name: Form or View conflicts between projects
severity: Critical
action: Immediate action required
```
Detects conflicting customizations across multiple projects.

### 4. Shared Concerns
```yaml
name: Non-UI component conflicts
severity: Critical
action: Review potential layer on shared concerns
```
Identifies conflicts in entities, attributes, and other shared components.

## Output Examples

### YAML Output (Medium Verbosity)
```yaml
generatedAt: 2026-02-01T00:00:00Z
connectionId: env-12345
verbosity: Medium
reports:
- name: Empty Layers
group: Project 1
severity: Information
totalMatches: 5
components:
- componentId: guid
componentType: 24
logicalName: contact_form
layers:
- solutionName: Project1
ordinal: 1
changedAttributes:
- formXml
- displayName
```

### CSV Output (Basic Verbosity)
```
Report Name,Group,Severity,Recommended Action,Component ID,Component Type,Logical Name,Display Name,Solutions,Make Portal URL
Empty Layers,Project 1,Information,Remove empty layer,guid,24,contact_form,Contact Form,CoreSolution; Project1,https://make.powerapps.com/...
```

## File Structure

```
src/
├── cli/
│ └── solution-analyzer/
│ ├── DataverseDevKit.SolutionAnalyzer.CLI/
│ │ ├── Program.cs
│ │ ├── SolutionAnalyzerCli.cs
│ │ ├── FileLogger.cs
│ │ └── DataverseDevKit.SolutionAnalyzer.CLI.csproj
│ ├── README.md
│ └── example-config.yaml
└── plugins/
└── solution-layer-analyzer/
└── src/
├── Models/
│ ├── Report.cs
│ ├── ReportGroup.cs
│ ├── ReportSeverity.cs
│ └── AnalyzerConfig.cs
├── Services/
│ ├── ReportService.cs
│ └── CsvHelper.cs
├── DTOs/
│ └── ReportDtos.cs
├── Data/
│ └── AnalyzerDbContext.cs (updated)
└── SolutionLayerAnalyzerPlugin.cs (updated)
```

## Usage Examples

### Index Solutions
```bash
ddk-solution-analyzer index \
--config analyzer-config.yaml \
--environment-url https://yourorg.crm.dynamics.com \
--output ./reports
```

### Run All Reports
```bash
ddk-solution-analyzer run \
--config analyzer-config.yaml \
--environment-url https://yourorg.crm.dynamics.com \
--format csv \
--report-verbosity medium \
--output ./reports
```

### CI/CD Integration
```bash
#!/bin/bash
ddk-solution-analyzer run \
--config solution-analysis.yaml \
--client-id $AZURE_CLIENT_ID \
--client-secret $AZURE_CLIENT_SECRET \
--tenant-id $AZURE_TENANT_ID \
--environment-url $DATAVERSE_URL \
--format json \
--verbosity minimal \
--output ./build/reports
```

## Next Steps

To complete the implementation, the following items remain:

### Authentication Integration
- Implement interactive OAuth flow in CLI
- Implement service principal authentication
- Integrate with Dataverse service client factory

### Plugin Host Integration
- Wire up CLI to directly call plugin methods
- Setup plugin context and service providers
- Handle plugin lifecycle (initialize, execute, dispose)

### Frontend UI (Phase 5)
- Create Reports tab in web UI
- Implement "Save as Report" from analysis view
- Add report editor and management UI
- Drag-and-drop reordering
- Import/export UI

### Testing (Phase 6)
- Unit tests for report models
- Unit tests for ReportService
- Integration tests for CLI
- End-to-end tests

## Benefits

### For Development Teams
- **Early Detection**: Catch layer conflicts and issues early in development
- **Automated Monitoring**: Run reports in CI/CD pipelines
- **Clear Guidelines**: Severity levels and recommended actions guide developers

### For Enterprise Organizations
- **Standardization**: Enforce organizational layering standards
- **Audit Trail**: File logs and report history
- **Excel Integration**: CSV export for analysis and reporting
- **Flexibility**: YAML configs easy to version control and share

### For DevOps
- **Automation**: CLI tool integrates into existing pipelines
- **Multiple Formats**: JSON for tools, CSV for humans, YAML for config
- **Configurable**: Adjust verbosity and formats per use case
- **Scalable**: Process multiple environments with same config

## Technical Highlights

1. **Clean Architecture**: Separation of concerns between models, services, and presentation
2. **Entity Framework Core**: Modern ORM with SQLite for local persistence
3. **YAML Configuration**: Human-readable, version-control friendly
4. **Multiple Serializers**: YamlDotNet, System.Text.Json, custom CSV
5. **Extensible**: Easy to add new commands, output formats, or report types
6. **Type-Safe**: Strong typing throughout with nullable reference types
7. **Async/Await**: Modern async patterns for better performance
8. **Logging**: Structured logging with Microsoft.Extensions.Logging

## Conclusion

This implementation provides a solid foundation for enterprise-grade solution layer analysis and monitoring. The combination of a powerful plugin backend with a flexible CLI tool enables both interactive usage and automation scenarios.

The YAML-based configuration makes it easy to define, share, and version control reporting rules, while the multiple output formats ensure compatibility with various tools and workflows.

The modular design allows for easy extension and customization to meet specific organizational needs.
Binary file added msbuild.binlog
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev:sdk": "pnpm --filter @ddk/host-sdk dev",
"build": "pnpm -r build",
"build:shell": "pnpm --filter @ddk/shell build",
"build:shell:pre": "pnpm --filter @ddk/sdk build",
"build:plugins": "pnpm --filter \"@ddk/plugin-*\" build",
"type-check": "pnpm -r type-check",
"lint": "pnpm -r lint",
Expand Down
Loading