pdevito3 / craftsman

A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
https://wrapt.dev
MIT License
1.12k stars 65 forks source link

BasePaginationParameters.cs already exists (when scaffolding multiple bounded contexts) #124

Closed AlexanderNZ closed 12 months ago

AlexanderNZ commented 1 year ago

Hey, can I say before reporting this that I'm really enjoying the project!

I'm trying to scaffold out one solution with two bounded contexts and am experimenting with relationships, entities and so on.

Steps to reproduce

Given a project definition:

# Uses Wrapt (https://wrapt.dev/) for scaffolding

DomainName: poc
BoundedContexts:
    - ProjectName: HumanContext
      Port: 8081
      DbContext:
        ContextName: HumanDbContext
        DatabaseName: HumanReadModel
        Provider: postgres
        NamingConvention: CamelCase
      Entities:
        - Name: Human
          Features:
            - Type: AddRecord
            - Type: GetRecord
            - Type: GetList
            - Type: UpdateRecord
            - Type: DeleteRecord
          Properties:
          - Name: firstName
            Type: string
            IsRequired: true
          - Name: lastName
            Type: string
            IsRequired: true
          - Name: irdNumber
            Type: int
            IsRequired: false
          - Name: activeContracts
            Relationship: 1tomany
            ForeignEntityName: Contract
            ForeignEntityPlural: Contracts
        - Name: Contract
          Features:
            - Type: AddRecord
            - Type: GetRecord
            - Type: GetList
            - Type: UpdateRecord
            - Type: DeleteRecord
          Properties:
          - Name: jobTitle
            Type: string
            IsRequired: true
          - Name: hourlyRate
            Type: int
            IsRequired: true
          - Name: contractedHoursPerUnitTime
            Type: int
            IsRequired: false
          - Name: unitTime
            SmartNames:
                - week
                - month
                - year
          - Name: parentCompany
            Type: guid
            IsRequired: true

    - ProjectName: CompanyContext
      Port: 8082
      DbContext:
        ContextName: CompanyDbContext
        DatabaseName: CompanyReadModel
        Provider: postgres
        NamingConvention: CamelCase
      Entities:
        - Name: Company
          Features:
            - Type: AddRecord
            - Type: GetRecord
            - Type: GetList
            - Type: UpdateRecord
            - Type: DeleteRecord
          Properties:
            - Name: name
              Type: string
              IsRequired: true
            - Name: contactEmailAddress
              Type: string
              IsRequired: true
            - Name: activeContracts
              Relationship: 1tomany
              ForeignEntityName: Contract
            - Name: positions
              Relationship: 1tomany
              ForeignEntityName: Position
        - Name: Position
          Features:
            - Type: AddRecord
            - Type: GetRecord
            - Type: GetList
            - Type: UpdateRecord
            - Type: DeleteRecord
          Properties:
            - Name: fulfillingContracts
              Relationship: 1tomany
              ForeignEntityName: Contract
              IsRequired: true
        - Name: Contract
          Features:
            - Type: AddRecord
            - Type: GetRecord
            - Type: GetList
            - Type: UpdateRecord
            - Type: DeleteRecord
          Properties:
            - Name: humanContextContractId
              Type: string
              IsRequired: true      

I expect to get two projects generated successfully (when I comment out one or the other, this works!).

When I run craftsman new domain POC-Service-Template.yml I see:

Your template file was parsed successfully.
File scaffolding for HumanContext was successful.
Error: The file `$PROJECT_DIRECTORY/SharedKernel/Dtos/BasePaginationParameters.cs` already exists.

Further technical details

Craftsman version: 0.22.1 Mac Ventura 13.5.1

pdevito3 commented 1 year ago

Nice find. Appreciate you finding bugs to squash!