Skip to content

feat(cli): implement gen-crud command - #17

Merged
ahmet-cetinkaya merged 7 commits into
mainfrom
feat/014-gen-crud-command
Jun 15, 2026
Merged

ahmet-cetinkaya merged 7 commits into
mainfrom
feat/014-gen-crud-command

Conversation

@ahmet-cetinkaya

Copy link
Copy Markdown
Member

🚀 Motivation and Context

Implement the gen-crud command for the nfw CLI, enabling automatic generation of complete CRUD scaffolding (commands, queries, handlers, repository) for NFramework services. This is a core productivity feature that eliminates boilerplate and enforces architectural consistency across all services.

⚙️ Implementation Details

CLI Layer (Phase 2):

  • Interactive prompts for entity name, properties (type/nullable), feature namespace, and repository selection
  • Comprehensive input validation: entity/property naming rules, CLI type whitelist (string, int, long, decimal, double, float, bool, datetime, datetimeoffset, guid, byte[], short), required field enforcement
  • Confirmation summary display before generation

Schema & Type Mapping:

  • Added BigInteger variant to GeneralType enum (long / C# long / Rust i64) alongside existing Integer (int)
  • Fixed template type emission: to_csharp_type() is now called for C# template context (was using schema-level to_string() which emitted raw names like uuid instead of Guid)
  • Updated command handlers (add_entity, gen_crud) to use the correct type context

Bug Fixes (discovered during end-to-end smoke test):

  • Correct entity namespace in generated code: Domain.Features.{Feature}.Entities (was flat Domain.Entities)
  • CreateCommand.ToEntity() now passes Guid.NewGuid() as first constructor argument
  • Nullable out T? + null-forgiving operator in all command/query handlers

📋 Checklist for Reviewer

  • Tests passed locally (119 unit tests ✅; 3 doc-test linker errors are Nix environment issue)
  • Commit history is clean and descriptive (all conventional commits)
  • make format ✅ — markdown, Rust (clippy + fmt), shell all clean
  • make lint ✅ — all crates pass clippy
  • Documentation updated (gen-crud specification added in commit history)

🔗 Related

  • Depends on: core-persistence-dotnet Rail<T> migration (feat/railway-rail-pipeline)
  • Depends on: nfw-generators CRUD templates (feat/add-crud-support-dotnet)

- Fix list_presentation_layers to recognize {{ Name }} placeholder
  in workflow destination paths (blocked add persistence/mediator)
- Fix positional arg ID mismatch: registration used 'entity-name'
  but handler accessed 'name' (gen crud never received entity name)
- Fix check_entity_exists to use correct service path with
  .Core.Domain and feature-based layout support
- Fix error propagation: handle() silently swallowed errors via
  let _res pattern; now uses ? operator
- Fix handle() to use command.context instead of re-creating
  ServiceInfo with hardcoded generator ID
- Wire FileSystemEntitySchemaStore into DI for schema loading
general_type().to_string() emitted schema-level names (uuid, integer)
instead of C# types (Guid, long) into generator template parameters.
Now uses to_csharp_type() in both entity and CRUD command handlers.
Integer mapped to both int and long CLI types, always emitting long.
Now int → Integer (C# int, Rust i32), long → BigInteger (C# long, Rust i64).
@ahmet-cetinkaya ahmet-cetinkaya added the enhancement New feature or request label Jun 15, 2026
@ahmet-cetinkaya ahmet-cetinkaya self-assigned this Jun 15, 2026
@ahmet-cetinkaya
ahmet-cetinkaya marked this pull request as ready for review June 15, 2026 14:39
@ahmet-cetinkaya
ahmet-cetinkaya merged commit 9c4e3ba into main Jun 15, 2026
4 checks passed
@ahmet-cetinkaya
ahmet-cetinkaya deleted the feat/014-gen-crud-command branch June 15, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant