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

Error while scaffolding #98

Closed amalsharief closed 1 year ago

amalsharief commented 1 year ago

Hi, thank you for your effort,

While I am running Craftsman, I countered this error in the scaffolding stage :

Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll An exception of type 'System.IO.IOException' occurred in System.Private.CoreLib.dll but was not handled in user code The process cannot access the file because it is being used by another process.

In this file

D:\craftsman\craftsman\Craftsman\Builders\Features\AddUserFeatureOverrideModifier.cs

at : line 117 115 // delete the old file and set the name of the new one to the original name 116 File.Delete(classPath.FullClassPath); 117 File.Move(tempPath, classPath.FullClassPath);

tempPath value : d:\hr\SingleEntity\SingleEntityManagement\src\SingleEntityManagement\Domain\Users\Features\AddUser.cstemp classPath.FullClassPat value : d:\hr\SingleEntity\SingleEntityManagement\src\SingleEntityManagement\Domain\Users\Features\AddUser.cs

Am I doing something wrong yaml file attached

Thank you in advance

SingleEntity.yaml.txt

pdevito3 commented 1 year ago

What version of Craftsman are you using? AddUserFeatureOverrideModifier is part of the upcoming release, so I'm assuming you're running this on latest in develop? I can try and take a look later today

amalsharief commented 1 year ago

Yes you are right the dev branch

Thank you

On Thu, 15 Sep 2022 at 4:44 PM Paul DeVito @.***> wrote:

What version of Craftsman are you using? AddUserFeatureOverrideModifier is part of the upcoming release, so I'm assuming you're running this on latest in develop? I can try and take a look later today

— Reply to this email directly, view it on GitHub https://github.com/pdevito3/craftsman/issues/98#issuecomment-1248203065, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGPZ4SXDSDZR526A7UZOK3V6MY3DANCNFSM6AAAAAAQNHOKRI . You are receiving this because you authored the thread.Message ID: @.***>

pdevito3 commented 1 year ago

Your Entities data has an extra indent. The below should work!

Fwiw, hoping to move to a more type/format friendly setup for this at some point. There's JSON formatter logic that could be used to help yaml files like this, but need to do a rewrite of Craftsman at some point too, so might make a more lib friendly setup with C# support as well. Sorry for the hassle!

DomainName: SingleEntity
BoundedContexts:
  - ProjectName: SingleEntityManagement
    Port: 5005
    DbContext:
      ContextName: SingleEntityDbContext
      DatabaseName: SingleEntityDb
      Provider: postgres
    Entities:
    - Name: SingleEntity
      Plural: SingleEntities
      Features:
        - Type: AddRecord
        - Type: GetRecord
        - Type: GetList
        - Type: UpdateRecord
        - Type: DeleteRecord
      Properties:
        - Name: Name
          Type: string
          CanFilter: true
          CanSort: true
    SwaggerConfig:
      Title: SingleEntity Management
      Description: SingleEntity desc
      ApiContact:
        Name: SingleEntity
        Email: devsupport@singleentity.com
        Url: 'https://www.singleentity.com'
    Environment:
      AuthSettings:
        Authority: 'http://localhost:3255/auth/realms/DevRealm'
        Audience: singlentity
        AuthorizationUrl: >-
          http://localhost:3255/auth/realms/DevRealm/protocol/openid-connect/auth
        TokenUrl: >-
          http://localhost:3255/auth/realms/DevRealm/protocol/openid-connect/token
        ClientId: singlentity.swagger
        ClientSecret: 974d6f71-d41b-4601-9a7a-a33081f80687
AuthServer:
  Name: KeycloakPulumi
  RealmName: DevRealm
  Port: 3255
  Clients:
    - Id: singlentity.postman.machine
      Name: SinglEntity Postman Machine
      Secret: 974d6f71-d41b-4601-9a7a-a33081f84682
      GrantType: ClientCredentials
      BaseUrl: 'https://oauth.pstmn.io/'
      Scopes:
        - singlentity
    - Id: singlentity.postman.code
      Name: SinglEntity Postman Code
      Secret: 974d6f71-d41b-4601-9a7a-a33081f84680
      GrantType: Code
      BaseUrl: 'https://oauth.pstmn.io/'
      Scopes:
        - singlentity
    - Id: singlentity.swagger
      Name: SinglEntity Swagger
      Secret: 974d6f71-d41b-4601-9a7a-a33081f80687
      GrantType: Code
      BaseUrl: 'https://localhost:5375/'
      Scopes:
        - singlentity
    - Id: singlentity.bff
      Name: SinglEntity BFF
      Secret: 974d6f71-d41b-4601-9a7a-a33081f80688
      BaseUrl: 'https://localhost:4378/'
      GrantType: Code
      RedirectUris:
        - 'https://localhost:4378/signin-oidc'
      AllowedCorsOrigins:
        - 'https://localhost:5375'
        - 'https://localhost:4378'
      Scopes:
        - singlentity
amalsharief commented 1 year ago

I have just copied the above yaml, but same result,

PS D:\craftsman\craftsman\Craftsman\bin\Debug\net6.0> .\Craftsman.exe new domain .\SingleEntity.yaml Your template file was parsed successfully. Error: The process cannot access the file because it is being used by another process. PS D:\craftsman\craftsman\Craftsman\bin\Debug\net6.0>

pdevito3 commented 1 year ago

It might be how you're running it. That error isn't from Craftsman, it's the runtime.

Try saving the file in Documents or somewhere outside. I'd recommend using dotnet run as well or the IDE with launch settings for running locally. For example:

  1. save file in /Users/amalsharief/Documents (or somewhere else more external)
  2. cd to Craftsman (e.g. cd /Users/amalsharief/repos/Craftsman/Craftsman
  3. use dotnet run: dotnet run new domain /Users/amalsharief/Documents/SingleEntity.yaml
  4. when running locally, it will prompt you what directory you want to add it to, for example: /Users/amalsharief/repos/examples