|
| 1 | +# Genocs CLI - Copilot Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +This is a .NET 9 CLI tool packaged as a global dotnet tool (`genocs`) that provides templates for Genocs microservice solutions. The tool generates project scaffolding for various frontend and backend architectures. |
| 5 | + |
| 6 | +## Architecture & Structure |
| 7 | + |
| 8 | +### Core Components |
| 9 | +- **Single executable**: `src/Program.cs` contains all CLI command logic in a top-level program pattern |
| 10 | +- **Template bootstrapping**: Commands call specific `Bootstrap*SolutionAsync()` methods that invoke `dotnet new` with Genocs templates |
| 11 | +- **Command pattern**: Simple string parsing with format `genocs <template-type> <command> <project-name>` |
| 12 | + |
| 13 | +### Supported Templates |
| 14 | +Available via commands like `genocs [template] new CompanyName.ProjectName`: |
| 15 | +- `angular` - Angular frontend projects |
| 16 | +- `react` - React frontend projects |
| 17 | +- `blazor-clean` - Clean Blazor applications |
| 18 | +- `blazor-wasm` - Blazor WebAssembly projects |
| 19 | +- `clean-webapi` - Clean Architecture Web APIs |
| 20 | +- `libra-webapi` - Libra Web API template |
| 21 | +- `micro-webapi` - Microservice Web API template |
| 22 | + |
| 23 | +### Project Naming Convention |
| 24 | +Uses `ToCapitalCase()` extension method (in `StringExtensions.cs`) to convert input like "company.project" to "Company.Project" format for proper C# namespace conventions. |
| 25 | + |
| 26 | +## Development Workflows |
| 27 | + |
| 28 | +### Building & Testing |
| 29 | +```bash |
| 30 | +# From repository root |
| 31 | +dotnet build |
| 32 | +dotnet run --project src/genocs.cli.csproj -- genocs -i |
| 33 | + |
| 34 | +# From src/ directory |
| 35 | +dotnet build genocs.cli.csproj |
| 36 | +dotnet run -f net9.0 genocs -i |
| 37 | +``` |
| 38 | + |
| 39 | +### Local Installation & Testing |
| 40 | +```bash |
| 41 | +# Pack for local installation |
| 42 | +dotnet pack --output nupkgs |
| 43 | +dotnet tool install --global --add-source ./nupkgs genocs.cli |
| 44 | + |
| 45 | +# Test template installation |
| 46 | +genocs install # or genocs i |
| 47 | +``` |
| 48 | + |
| 49 | +### Template Management |
| 50 | +- `genocs install|i` - Installs/updates Genocs templates from remote repositories |
| 51 | +- `genocs update|u` - Alias for install command |
| 52 | +- Templates are installed via `dotnet new install` commands in bootstrap methods |
| 53 | + |
| 54 | +## Build Configuration |
| 55 | + |
| 56 | +### Project Structure |
| 57 | +- **Single project solution**: Only `src/genocs.cli.csproj` with solution items folder |
| 58 | +- **Global build props**: `Directory.Build.props` enforces StyleCop, Roslynator analyzers, nullable reference types |
| 59 | +- **Tool packaging**: Configured as `<PackAsTool>true</PackAsTool>` with command name `genocs` |
| 60 | + |
| 61 | +### Code Quality |
| 62 | +- **StyleCop + Roslynator**: Enforced via `Directory.Build.props` with custom `stylecop.json` rules |
| 63 | +- **Nullable enabled**: All projects use `<Nullable>enable</Nullable>` |
| 64 | +- **Documentation**: `GenerateDocumentationFile` enabled for XML docs |
| 65 | +- **Global using**: `System.Guid` aliased as `DefaultIdType` |
| 66 | + |
| 67 | +## Key Patterns |
| 68 | + |
| 69 | +### Command Parsing |
| 70 | +Simple imperative parsing in `Program.cs`: |
| 71 | +```csharp |
| 72 | +string firstArg = args[0].Trim().ToLower(); |
| 73 | +if (firstArg == "install" || firstArg == "i" || firstArg == "update" || firstArg == "u") |
| 74 | +{ |
| 75 | + await InstallTemplates(); |
| 76 | + return; |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +### Error Handling |
| 81 | +Basic validation with console output: |
| 82 | +```csharp |
| 83 | +if (args.Length != 3) |
| 84 | +{ |
| 85 | + Console.WriteLine("Invalid command. Use something like: genocs angular new <CompanyName.ProjectName>"); |
| 86 | + return; |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +### Resource Management |
| 91 | +- `MainResource.resx` for embedded strings/resources |
| 92 | +- `Figgle` dependency for ASCII art rendering |
| 93 | +- `icon.png` and license files embedded in NuGet package |
| 94 | + |
| 95 | +## CI/CD Pipeline |
| 96 | +- **GitHub Actions**: `build_and_test.yml` runs on .NET 9 with restore, build, test, pack |
| 97 | +- **NuGet publishing**: Separate workflow for package deployment |
| 98 | +- **Version management**: `PackageVersion` in csproj, uses SemVer |
| 99 | + |
| 100 | +## Dependencies & External Integration |
| 101 | +- **Figgle**: ASCII art rendering for CLI branding |
| 102 | +- **Genocs Templates**: External template repositories installed via `dotnet new install` |
| 103 | +- **NuGet**: Published as global tool with command name `genocs` |
0 commit comments