generator-codedesignplus 0.0.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENCE.md +13 -0
- package/README.md +454 -0
- package/generators/app/index.mjs +22 -0
- package/generators/microservice/core/aggregate.mjs +25 -0
- package/generators/microservice/core/appsettings.mjs +73 -0
- package/generators/microservice/core/asyncWorker.mjs +87 -0
- package/generators/microservice/core/command.mjs +54 -0
- package/generators/microservice/core/consumer.mjs +73 -0
- package/generators/microservice/core/controller.mjs +25 -0
- package/generators/microservice/core/core.mjs +98 -0
- package/generators/microservice/core/dataTransferObject.mjs +31 -0
- package/generators/microservice/core/domainEvent.mjs +36 -0
- package/generators/microservice/core/dotnet.mjs +56 -0
- package/generators/microservice/core/entity.mjs +29 -0
- package/generators/microservice/core/errors.mjs +37 -0
- package/generators/microservice/core/grpc.mjs +97 -0
- package/generators/microservice/core/microservice.mjs +212 -0
- package/generators/microservice/core/proto.mjs +61 -0
- package/generators/microservice/core/query.mjs +59 -0
- package/generators/microservice/core/repository.mjs +41 -0
- package/generators/microservice/core/utils.mjs +196 -0
- package/generators/microservice/core/valueObject.mjs +29 -0
- package/generators/microservice/core/xml.mjs +48 -0
- package/generators/microservice/index.mjs +38 -0
- package/generators/microservice/templates/aggregate/ItemAggregate.cs +9 -0
- package/generators/microservice/templates/command/ItemCommand.cs +12 -0
- package/generators/microservice/templates/command/ItemCommandHandler.cs +9 -0
- package/generators/microservice/templates/consumer/ItemHandler.cs +14 -0
- package/generators/microservice/templates/controller/ItemController.cs +8 -0
- package/generators/microservice/templates/data-transfer-object/ItemDto.cs +6 -0
- package/generators/microservice/templates/domain-event/ItemDomainEvent.cs +15 -0
- package/generators/microservice/templates/entity/ItemEntity.cs +6 -0
- package/generators/microservice/templates/errors/Error.cs +6 -0
- package/generators/microservice/templates/grpc/ItemService.cs +6 -0
- package/generators/microservice/templates/grpc/grpc.proto +22 -0
- package/generators/microservice/templates/microservice/.dockerignore +30 -0
- package/generators/microservice/templates/microservice/CodeDesignPlus.Net.Microservice.sln +155 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/CodeDesignPlus.Net.Microservice.Application.csproj +20 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Errors.cs +10 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/AddProductToOrder/AddProductToOrderCommand.cs +17 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/AddProductToOrder/AddProductToOrderCommandHandler.cs +27 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CancelOrder/CancelOrderCommand.cs +13 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CancelOrder/CancelOrderCommandHandler.cs +24 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CompleteOrder/CompleteOrderCommand.cs +11 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CompleteOrder/CompleteOrderCommandHandler.cs +25 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CreateOrder/CreateOrderCommand.cs +32 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CreateOrder/CreateOrderCommandHandler.cs +24 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/RemoveProduct/RemoveProductCommand.cs +12 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/RemoveProduct/RemoveProductCommandHandler.cs +22 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommand.cs +14 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommandHandler.cs +24 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/AddressDto.cs +11 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/ClientDto.cs +9 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/OrderDto.cs +18 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/ProductDto.cs +10 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/FindOrderById/FindOrderByIdQuery.cs +4 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/FindOrderById/FindOrderByIdQueryHandler.cs +23 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/GetAllOrders/GetAllOrdersQuery.cs +3 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/GetAllOrders/GetAllOrdersQueryHandler.cs +18 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Setup/MapsterConfig.cs +26 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Startup.cs +15 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Usings.cs +18 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/CodeDesignPlus.Net.Microservice.Domain.csproj +11 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/AddProductToOrderParams.cs +15 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/CancelOrderParams.cs +13 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/CompleteOrderParams.cs +12 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/RemoveProductFromOrderParams.cs +11 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/UpdateQuantityProductParams.cs +12 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/OrderCancelledDomainEvent.cs +21 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/OrderCompletedDomainEvent.cs +18 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/OrderCreatedDomainEvent.cs +44 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/ProductAddedToOrderDomainEvent.cs +20 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/ProductQuantityUpdatedDomainEvent.cs +20 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/ProductRemovedFromOrderDomainEvent.cs +18 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Entities/ProductEntity.cs +10 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Enums/OrderStatus.cs +10 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Errors.cs +28 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/OrderAggregate.cs +124 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Repositories/IOrderRepository.cs +14 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Startup.cs +12 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Usings.cs +11 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/ValueObjects/AddressValueObject.cs +30 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/ValueObjects/ClientValueObject.cs +27 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/CodeDesignPlus.Net.Microservice.Infrastructure.csproj +13 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Errors.cs +6 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Repositories/OrderRepository.cs +109 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Startup.cs +10 -0
- package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Usings.cs +15 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/CodeDesignPlus.Net.Microservice.AsyncWorker.csproj +31 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Program.cs +41 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Properties/launchSettings.json +15 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Usings.cs +10 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/appsettings.Development.json +2 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/appsettings.json +129 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/CodeDesignPlus.Net.Microservice.Rest.csproj +36 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/CodeDesignPlus.Net.Microservice.Rest.csproj.user +11 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Controllers/OrderController.cs +138 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Core/Mapster/MapsterConfig.cs +12 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Dockerfile +37 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Program.cs +52 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Properties/launchSettings.json +26 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Usings.cs +22 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/appsettings.Development.json +3 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/appsettings.json +86 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/CodeDesignPlus.Net.Microservice.gRpc.csproj +35 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/CodeDesignPlus.Net.Microservice.gRpc.csproj.user +9 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Core/Mapster/MapsterConfig.cs +13 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Program.cs +61 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Properties/launchSettings.json +23 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Protos/orders.proto +66 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Services/OrderService.cs +29 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Usings.cs +12 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/appsettings.Development.json +3 -0
- package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/appsettings.json +92 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/CodeDesignPlus.Net.Microservice.AsyncWorker.Test.csproj +35 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Properties/launchSettings.json +12 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Usings.cs +8 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/CodeDesignPlus.Net.Microservice.Rest.Test.csproj +36 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Controllers/OrderControllerTest.cs +337 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Properties/launchSettings.json +12 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Usings.cs +8 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/CodeDesignPlus.Net.Microservice.gRpc.Test.csproj +46 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Protos/orders.proto +65 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/OrdersServiceTest.cs +64 -0
- package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Usings.cs +7 -0
- package/generators/microservice/templates/microservice/tests/load/load-rest.js +63 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/CodeDesignPlus.Net.Microservice.Application.Test.csproj +34 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/AddProductToOrder/AddProductToOrderCommandHandlerTest.cs +98 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/AddProductToOrder/AddProductToOrderCommandTest.cs +84 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CancelOrder/CancelOrderCommandHandlerTest.cs +74 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CancelOrder/CancelOrderCommandTest.cs +43 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CompleteOrder/CompleteOrderCommandHandlerTest.cs +74 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CompleteOrder/CompleteOrderCommandTest.cs +32 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CreateOrder/CreateOrderCommandHandlerTest.cs +100 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CreateOrder/CreateOrderCommandTest.cs +122 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/RemoveProduct/RemoveProductCommandHandlerTest.cs +71 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/RemoveProduct/RemoveProductCommandTest.cs +33 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommandHandlerTest.cs +82 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommandTest.cs +51 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Queries/FindOrderById/FindOrderByIdQueryHandlerTest.cs +70 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Queries/GetAllOrders/GetAllOrdersQueryHandlerTest.cs +80 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Setup/MapsterConfigTest.cs +20 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Usings.cs +18 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/CodeDesignPlus.Net.Microservice.AsyncWorker.Test.csproj +38 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Usings.cs +9 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/CodeDesignPlus.Net.Microservice.Default.Test.csproj +35 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Usings.cs +6 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/AggregateTest.cs +37 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/CommandsTests.cs +29 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/DataTransferObjectTest.cs +47 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/DomainEventTest.cs +42 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/EntityTest.cs +25 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/ErrorsTest.cs +55 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/QueryTests.cs +29 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/StartupTest.cs +43 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/CodeDesignPlus.Net.Microservice.Domain.Test.csproj +38 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/DomainEvents/OrderCancelledDomainEventTest.cs +46 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/OrderAggregateTest.cs +518 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/Usings.cs +7 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/CodeDesignPlus.Net.Microservice.Infrastructure.Test.csproj +34 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/Repositories/OrderRepositoryTest.cs +259 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/Usings.cs +14 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/CodeDesignPlus.Net.Microservice.Rest.Test.csproj +40 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Controllers/OrderControllerTest.cs +189 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Core/Mapster/MapsterConfigTest.cs +19 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Usings.cs +14 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/CodeDesignPlus.Net.Microservice.gRpc.Test.csproj +39 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Core/Mapster/MapsterConfigTest.cs +19 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/OrderServiceTest.cs +72 -0
- package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Usings.cs +15 -0
- package/generators/microservice/templates/microservice/tools/convert-crlf-to-lf.sh +6 -0
- package/generators/microservice/templates/microservice/tools/sonarqube/sonar.ps1 +18 -0
- package/generators/microservice/templates/microservice/tools/sonarqube/sonar.sh +18 -0
- package/generators/microservice/templates/microservice/tools/update-packages/update-packages.ps1 +10 -0
- package/generators/microservice/templates/microservice/tools/update-packages/update-packages.sh +11 -0
- package/generators/microservice/templates/microservice/tools/upgrade-dotnet/upgrade-assistant.ps1 +10 -0
- package/generators/microservice/templates/microservice/tools/upgrade-dotnet/upgrade-assistant.sh +11 -0
- package/generators/microservice/templates/microservice/tools/vault/config-vault.ps1 +178 -0
- package/generators/microservice/templates/microservice/tools/vault/config-vault.sh +152 -0
- package/generators/microservice/templates/others/MapsterConfig.cs +9 -0
- package/generators/microservice/templates/query/ItemQuery.cs +4 -0
- package/generators/microservice/templates/query/ItemQueryHandler.cs +9 -0
- package/generators/microservice/templates/repository/IItemRepository.cs +6 -0
- package/generators/microservice/templates/repository/ItemRepository.cs +7 -0
- package/generators/microservice/templates/value-object/ItemValueObject.cs +23 -0
- package/generators/microservice/types/aggregate.mjs +19 -0
- package/generators/microservice/types/appsettings.mjs +26 -0
- package/generators/microservice/types/base.mjs +24 -0
- package/generators/microservice/types/command.mjs +38 -0
- package/generators/microservice/types/consumer.mjs +21 -0
- package/generators/microservice/types/controller.mjs +20 -0
- package/generators/microservice/types/dataTransferObject.mjs +19 -0
- package/generators/microservice/types/domainEvents.mjs +22 -0
- package/generators/microservice/types/entity.mjs +21 -0
- package/generators/microservice/types/index.mjs +25 -0
- package/generators/microservice/types/proto.mjs +19 -0
- package/generators/microservice/types/query.mjs +38 -0
- package/generators/microservice/types/repository.mjs +21 -0
- package/generators/microservice/types/valueObject.mjs +23 -0
- package/package.json +70 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { glob } from 'glob';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import ErrorsGenerator from './errors.mjs';
|
|
4
|
+
import AppSettingsGenerator from './appsettings.mjs';
|
|
5
|
+
import AggregateGenerator from './aggregate.mjs';
|
|
6
|
+
import CommandGenerator from './command.mjs';
|
|
7
|
+
import QueryGenerator from './query.mjs';
|
|
8
|
+
import ControllerGenerator from './controller.mjs';
|
|
9
|
+
import DtoGenerator from './dataTransferObject.mjs';
|
|
10
|
+
import ValueObjectGenerator from './valueObject.mjs';
|
|
11
|
+
import DomainEventGenerator from './domainEvent.mjs';
|
|
12
|
+
import EntityGenerator from './entity.mjs';
|
|
13
|
+
import RepositoryGenerator from './repository.mjs';
|
|
14
|
+
import ProtoGenerator from './proto.mjs';
|
|
15
|
+
import ConsumerGenerator from './consumer.mjs';
|
|
16
|
+
|
|
17
|
+
import fs from 'fs/promises';
|
|
18
|
+
import { toPascalCase } from '../types/base.mjs';
|
|
19
|
+
|
|
20
|
+
export default class MicroserviceGenerator {
|
|
21
|
+
|
|
22
|
+
constructor(utils, generator) {
|
|
23
|
+
this._utils = utils;
|
|
24
|
+
this._generator = generator;
|
|
25
|
+
this._errorGenerator = new ErrorsGenerator(utils, generator);
|
|
26
|
+
this._appsettings = new AppSettingsGenerator(utils, generator);
|
|
27
|
+
this._consumerGenerator = new ConsumerGenerator(utils, generator);
|
|
28
|
+
this._protoGenerator = new ProtoGenerator(utils, generator);
|
|
29
|
+
this.name = 'microservice';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getArguments() {
|
|
33
|
+
this._generator.option('is-crud', { type: Boolean, alias: 'ic', required: false, description: 'Indicates that the microservice will be a CRUD, generating the basic structure for data management operations.' });
|
|
34
|
+
this._generator.option('enable-grpc', { type: Boolean, alias: 'eg', required: true, description: 'Enables the gRPC API for the microservice, which offers a high-performance communication protocol.' });
|
|
35
|
+
this._generator.option('enable-async-worker', { type: Boolean, alias: 'eaw', required: true, description: 'Enables an asynchronous worker for handling background tasks and events, improving scalability.' });
|
|
36
|
+
this._generator.option('aggregate', { type: String, alias: 'a', required: true, description: 'The name of the microservice\'s root aggregate, essential for domain organization.' });
|
|
37
|
+
|
|
38
|
+
this._appsettings.getArguments();
|
|
39
|
+
|
|
40
|
+
if (this._generator.options.enableAsyncWorker)
|
|
41
|
+
this._consumerGenerator.getArguments();
|
|
42
|
+
|
|
43
|
+
const aggregate = toPascalCase(this._generator.options.aggregate);
|
|
44
|
+
|
|
45
|
+
this._generator.options = {
|
|
46
|
+
...this._generator.options,
|
|
47
|
+
aggregate: aggregate,
|
|
48
|
+
domainEvents: `${aggregate}Created, ${aggregate}Updated, ${aggregate}Deleted`,
|
|
49
|
+
commands: `Create${aggregate}, Update${aggregate}, Delete${aggregate}`,
|
|
50
|
+
queries: `Get${aggregate}ById, GetAll${aggregate}`,
|
|
51
|
+
}
|
|
52
|
+
if (!this._generator.options.isCrud) {
|
|
53
|
+
this._generator.option('domainEvents', { type: String, alias: 'de', required: true, description: 'Comma-separated list of domain events, fundamental in asynchronous communication between microservices.' });
|
|
54
|
+
this._generator.option('entities', { type: String, alias: 'e', required: true, description: 'Comma-separated list of entities.' });
|
|
55
|
+
this._generator.option('commands', { type: String, alias: 'cs', required: false, description: 'Comma-separated list of commands representing actions from the user or system.' });
|
|
56
|
+
this._generator.option('queries', { type: String, alias: 'q', required: false, description: 'Comma-separated list of queries, representing requests for information from the system.' });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this._generator.options = {
|
|
60
|
+
...this._generator.options,
|
|
61
|
+
repository: aggregate,
|
|
62
|
+
controller: aggregate,
|
|
63
|
+
dataTransferObject: aggregate,
|
|
64
|
+
protoName: aggregate
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async generate(options) {
|
|
69
|
+
const namespace = `${options.organization}.Net.Microservice.${options.microservice}`;
|
|
70
|
+
|
|
71
|
+
const template = this._generator.templatePath('microservice');
|
|
72
|
+
|
|
73
|
+
const destination = path.join(this._generator.destinationRoot(), namespace);
|
|
74
|
+
|
|
75
|
+
const ignores = this._getIgnores();
|
|
76
|
+
|
|
77
|
+
const files = glob.sync('**', { dot: true, nodir: true, cwd: template, ignore: ignores });
|
|
78
|
+
|
|
79
|
+
await this._utils.generateFiles(options, namespace, template, destination, files);
|
|
80
|
+
|
|
81
|
+
this._generator.destinationRoot(destination);
|
|
82
|
+
|
|
83
|
+
await this._errorGenerator.generate(options);
|
|
84
|
+
|
|
85
|
+
await this._appsettings.generate(options);
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
const generatorsMap = {
|
|
89
|
+
'Aggregate': AggregateGenerator,
|
|
90
|
+
'Domain Event': DomainEventGenerator,
|
|
91
|
+
'Entity': EntityGenerator,
|
|
92
|
+
'Value Object': ValueObjectGenerator,
|
|
93
|
+
'Repository': RepositoryGenerator,
|
|
94
|
+
'Data Transfer Object': DtoGenerator,
|
|
95
|
+
'Command': CommandGenerator,
|
|
96
|
+
'Query': QueryGenerator,
|
|
97
|
+
'Controller': ControllerGenerator,
|
|
98
|
+
'Proto': ProtoGenerator,
|
|
99
|
+
'Consumer': ConsumerGenerator
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
for (const key in generatorsMap) {
|
|
103
|
+
const generator = new generatorsMap[key](this._utils, this._generator);
|
|
104
|
+
|
|
105
|
+
await generator.generate(options);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
await this._createMetadataFile(destination, options);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async _createMetadataFile(destination, options) {
|
|
112
|
+
await this._generator.fs.writeJSON(`${destination}/archetype.json`, {
|
|
113
|
+
"microservice": options.microservice,
|
|
114
|
+
"description": "Custom Microservice",
|
|
115
|
+
"version": "1.0.0",
|
|
116
|
+
"organization": options.organization,
|
|
117
|
+
"aggregate": options.aggregate.name,
|
|
118
|
+
"vault": options.appSettings.vault,
|
|
119
|
+
"contactName": options.appSettings.contact.name,
|
|
120
|
+
"contactEmail": options.appSettings.contact.email
|
|
121
|
+
}, { spaces: 2 });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_getIgnores() {
|
|
125
|
+
const ignores = ['**/bin/**', '**/obj/**'];
|
|
126
|
+
|
|
127
|
+
const items = {
|
|
128
|
+
domain_application: [
|
|
129
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Errors.cs',
|
|
130
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/AddProductToOrder/**',
|
|
131
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CancelOrder/**',
|
|
132
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CompleteOrder/**',
|
|
133
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CreateOrder/**',
|
|
134
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/RemoveProduct/**',
|
|
135
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/UpdateQuantityProduct/**',
|
|
136
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/AddProductToOrder/**',
|
|
137
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/FindOrderById/**',
|
|
138
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/GetAllOrders/**',
|
|
139
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/*.cs',
|
|
140
|
+
],
|
|
141
|
+
domain_domain: [
|
|
142
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/Errors.cs',
|
|
143
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/*.cs',
|
|
144
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/*.cs',
|
|
145
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/Entities/*.cs',
|
|
146
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/Enums/*.cs',
|
|
147
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/Repositories/*.cs',
|
|
148
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/ValueObjects/*.cs',
|
|
149
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Domain/OrderAggregate.cs',
|
|
150
|
+
],
|
|
151
|
+
domain_infrastructure: [
|
|
152
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Repositories/OrderRepository.cs',
|
|
153
|
+
'src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Errors.cs'
|
|
154
|
+
],
|
|
155
|
+
entryPoints_asyncWorker: [
|
|
156
|
+
'src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Consumers/**'
|
|
157
|
+
],
|
|
158
|
+
entryPoints_gRpc: [
|
|
159
|
+
'src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Protos/*.proto',
|
|
160
|
+
'src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Services/*.cs'
|
|
161
|
+
],
|
|
162
|
+
entryPoints_Rest: [
|
|
163
|
+
'src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Controllers/**'
|
|
164
|
+
],
|
|
165
|
+
integrationTest_asyncWorker: [
|
|
166
|
+
'tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Consumers/**'
|
|
167
|
+
],
|
|
168
|
+
integrationTest_gRpc: [
|
|
169
|
+
'tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Protos/**',
|
|
170
|
+
'tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/**'
|
|
171
|
+
],
|
|
172
|
+
integrationTest_rest: [
|
|
173
|
+
'tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Controllers/**'
|
|
174
|
+
],
|
|
175
|
+
unitTest_application: [
|
|
176
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/AddProductToOrder/**',
|
|
177
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CancelOrder/**',
|
|
178
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CompleteOrder/**',
|
|
179
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CreateOrder/**',
|
|
180
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/RemoveProduct/**',
|
|
181
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/UpdateQuantityProduct/**',
|
|
182
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Queries/FindOrderById/**',
|
|
183
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Queries/GetAllOrders/**',
|
|
184
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/DataTransferObjects/ClientDto.cs',
|
|
185
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/DataTransferObjects/OrderDto.cs',
|
|
186
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/DataTransferObjects/ProductDto.cs',
|
|
187
|
+
],
|
|
188
|
+
unitTest_domain: [
|
|
189
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/DomainEvents/*.cs',
|
|
190
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/OrderAggregateTest.cs',
|
|
191
|
+
],
|
|
192
|
+
unitTest_infrastructure: [
|
|
193
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/Repositories/*.cs',
|
|
194
|
+
],
|
|
195
|
+
unitTest_asyncWorker: [
|
|
196
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Consumers/*.cs',
|
|
197
|
+
],
|
|
198
|
+
unitTest_gRpc: [
|
|
199
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/*.cs',
|
|
200
|
+
],
|
|
201
|
+
unitTest_rest: [
|
|
202
|
+
'tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Controllers/*.cs',
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
for (const key in items) {
|
|
207
|
+
ignores.push(...items[key]);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return ignores;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import Xml from './xml.mjs';
|
|
3
|
+
|
|
4
|
+
export default class ProtoGenerator {
|
|
5
|
+
|
|
6
|
+
constructor(utils, generator) {
|
|
7
|
+
this._utils = utils;
|
|
8
|
+
this._generator = generator;
|
|
9
|
+
this.name = 'proto';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async generate(options) {
|
|
13
|
+
if (options.enableGrpc) {
|
|
14
|
+
const solution = `${options.solution}.gRpc`;
|
|
15
|
+
|
|
16
|
+
await this._generator.fs.copyTplAsync(
|
|
17
|
+
this._generator.templatePath('grpc/grpc.proto'),
|
|
18
|
+
this._generator.destinationPath(path.join(options.paths.src.grpc, 'Protos', options.proto.file)),
|
|
19
|
+
{
|
|
20
|
+
ns: solution,
|
|
21
|
+
name: options.proto.fullname
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
await this._generator.fs.copyTplAsync(
|
|
26
|
+
this._generator.templatePath('grpc/grpc.proto'),
|
|
27
|
+
this._generator.destinationPath(path.join(options.paths.integrationTests.grpc, 'Protos', options.proto.file)),
|
|
28
|
+
{
|
|
29
|
+
ns: `${solution}.Test`,
|
|
30
|
+
name: options.proto.fullname
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
await this._generator.fs.copyTplAsync(
|
|
35
|
+
this._generator.templatePath('grpc/ItemService.cs'),
|
|
36
|
+
this._generator.destinationPath(path.join(options.paths.src.grpc, 'Services', `${options.proto.name}Service.cs`)),
|
|
37
|
+
{
|
|
38
|
+
ns: `${solution}.Services`,
|
|
39
|
+
name: options.proto.name
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const grpcProject = new Xml(`${this._generator.destinationPath()}/${options.paths.src.grpc}/${solution}.csproj`);
|
|
44
|
+
|
|
45
|
+
await grpcProject.addProtobuf(`Protos\\${options.proto.file}`);
|
|
46
|
+
|
|
47
|
+
const grpcTestProject = new Xml(`${this._generator.destinationPath()}/${options.paths.integrationTests.grpc}/${solution}.Test.csproj`);
|
|
48
|
+
|
|
49
|
+
await grpcTestProject.addProtobuf(`Protos\\${options.proto.file}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getArguments() {
|
|
54
|
+
this._generator.option('proto-name', { type: String, alias: 'p', required: true, description: 'The base name of the .proto file.' });
|
|
55
|
+
|
|
56
|
+
this._generator.options = {
|
|
57
|
+
...this._generator.options,
|
|
58
|
+
enableGrpc: this._generator.options.protoName !== undefined && this._generator.options.protoName !== null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import DtoGenerator from './dataTransferObject.mjs';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
|
|
5
|
+
export default class QueryGenerator {
|
|
6
|
+
|
|
7
|
+
constructor(utils, generator) {
|
|
8
|
+
this._utils = utils;
|
|
9
|
+
this._generator = generator;
|
|
10
|
+
this.name = 'query';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async generate(options) {
|
|
14
|
+
|
|
15
|
+
await new DtoGenerator(this._utils, this._generator).generate(options);
|
|
16
|
+
|
|
17
|
+
for (const key in options.queries) {
|
|
18
|
+
const handler = options.queries[key];
|
|
19
|
+
const query = handler.query;
|
|
20
|
+
|
|
21
|
+
const ns = `${options.solution}.Application.${options.aggregate.name}.Queries.${query.name}`;
|
|
22
|
+
|
|
23
|
+
await this._generator.fs.copyTplAsync(
|
|
24
|
+
this._generator.templatePath('query/ItemQuery.cs'),
|
|
25
|
+
this._generator.destinationPath(path.join(options.paths.src.application, options.aggregate.name, `Queries`, query.name, query.file)),
|
|
26
|
+
{
|
|
27
|
+
ns: ns,
|
|
28
|
+
name: query.fullname,
|
|
29
|
+
dto: options.dataTransferObject.fullname
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
await this._generator.fs.copyTplAsync(
|
|
34
|
+
this._generator.templatePath('query/ItemQueryHandler.cs'),
|
|
35
|
+
this._generator.destinationPath(path.join(options.paths.src.application, options.aggregate.name, `Queries`, query.name, handler.file)),
|
|
36
|
+
{
|
|
37
|
+
ns: ns,
|
|
38
|
+
name: query.fullname,
|
|
39
|
+
handler: handler.fullname,
|
|
40
|
+
dto: options.dataTransferObject.fullname,
|
|
41
|
+
repository: options.repository.interface
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
this._utils.addUsing(options.paths.src.rest, ns);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getArguments() {
|
|
50
|
+
this._generator.option('aggregate', { type: String, alias: 'a', required: true, description: 'The name of the microservice\'s root aggregate, essential for domain organization.' });
|
|
51
|
+
this._generator.option('repository', { type: String, alias: 'r', required: true, description: 'The name of the aggregate for which the repository is created or queried.' });
|
|
52
|
+
this._generator.option('queries', { type: String, alias: 'q', required: true, description: 'Comma-separated list of queries, representing requests for information from the system.' });
|
|
53
|
+
|
|
54
|
+
this._generator.options = {
|
|
55
|
+
...this._generator.options,
|
|
56
|
+
dataTransferObject: this._generator.options.aggregate
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export default class RepositoryGenerator {
|
|
3
|
+
|
|
4
|
+
constructor(utils, generator) {
|
|
5
|
+
this._utils = utils;
|
|
6
|
+
this._generator = generator;
|
|
7
|
+
this.name = 'repository';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async generate(options) {
|
|
11
|
+
|
|
12
|
+
if (!options.repository)
|
|
13
|
+
return;
|
|
14
|
+
|
|
15
|
+
//Create Interface Repository
|
|
16
|
+
await this._generator.fs.copyTplAsync(
|
|
17
|
+
this._generator.templatePath(`repository/IItemRepository.cs`),
|
|
18
|
+
this._generator.destinationPath(path.join(options.paths.src.domain, `Repositories`, options.repository.fileInterface)),
|
|
19
|
+
{
|
|
20
|
+
ns: `${options.solution}.Domain.Repositories`,
|
|
21
|
+
name: options.repository.interface,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
//Create Implementation
|
|
26
|
+
await this._generator.fs.copyTplAsync(
|
|
27
|
+
this._generator.templatePath(`repository/ItemRepository.cs`),
|
|
28
|
+
this._generator.destinationPath(path.join(options.paths.src.infrastructure, `Repositories`, options.repository.file)),
|
|
29
|
+
{
|
|
30
|
+
ns: `${options.solution}.Infrastructure.Repositories`,
|
|
31
|
+
name: options.repository.fullname,
|
|
32
|
+
interface: options.repository.interface
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
getArguments() {
|
|
39
|
+
this._generator.option('repository', { type: String, alias: 'r', required: true, description: 'The name of the aggregate for which the repository is created or queried.' });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { findUp } from 'find-up';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import {
|
|
5
|
+
AggregateModel,
|
|
6
|
+
CommandHandlerModel,
|
|
7
|
+
ControllerModel,
|
|
8
|
+
DataTransferObjectModel,
|
|
9
|
+
DomainEventModel,
|
|
10
|
+
EntityModel,
|
|
11
|
+
ProtoModel,
|
|
12
|
+
QueryHandlerModel,
|
|
13
|
+
RepositoryModel,
|
|
14
|
+
ValueObjectModel,
|
|
15
|
+
ConsumerModel
|
|
16
|
+
} from '../types/index.mjs';
|
|
17
|
+
import { AppSettingsModel } from '../types/appsettings.mjs';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export default class Utils {
|
|
22
|
+
constructor(generator) {
|
|
23
|
+
this._generator = generator;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async setPathBase() {
|
|
27
|
+
const filePath = await findUp('archetype.json');
|
|
28
|
+
|
|
29
|
+
if (!filePath) {
|
|
30
|
+
return this._generator.destinationRoot();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const pathBaseDir = path.dirname(filePath);
|
|
34
|
+
|
|
35
|
+
this._generator.destinationRoot(pathBaseDir);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async readArchetypeMetadata() {
|
|
39
|
+
const archetypeFile = await findUp('archetype.json');
|
|
40
|
+
|
|
41
|
+
if (!archetypeFile)
|
|
42
|
+
throw new Error('No se encontró el archivo archetype.json');
|
|
43
|
+
|
|
44
|
+
return await this._generator.fs.readJSON(archetypeFile);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getOptions(answers) {
|
|
48
|
+
const archetypeValues = this._generator.fs.readJSON(`${path.join(this._generator.destinationRoot())}/archetype.json`);
|
|
49
|
+
|
|
50
|
+
answers = {
|
|
51
|
+
...answers,
|
|
52
|
+
organization: archetypeValues.organization,
|
|
53
|
+
microservice: archetypeValues.microservice,
|
|
54
|
+
description: archetypeValues.description,
|
|
55
|
+
organization: archetypeValues.organization,
|
|
56
|
+
aggregate: answers.aggregate ?? archetypeValues.aggregate,
|
|
57
|
+
vault: archetypeValues.vault,
|
|
58
|
+
contactName: archetypeValues.contactName,
|
|
59
|
+
contactEmail: archetypeValues.contactEmail
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const organization = this.toPascalCase(answers.organization);
|
|
63
|
+
const microservice = this.toPascalCase(answers.microservice);
|
|
64
|
+
|
|
65
|
+
const solution = `${organization}.Net.Microservice.${microservice}`;
|
|
66
|
+
|
|
67
|
+
let options = {
|
|
68
|
+
"organization": organization,
|
|
69
|
+
"microservice": microservice,
|
|
70
|
+
"solution": solution,
|
|
71
|
+
"paths": {
|
|
72
|
+
"src": {
|
|
73
|
+
"domain": path.join('src', 'domain', `${solution}.Domain`),
|
|
74
|
+
"application": path.join('src', 'domain', `${solution}.Application`),
|
|
75
|
+
"infrastructure": path.join('src', 'domain', `${solution}.Infrastructure`),
|
|
76
|
+
"rest": path.join('src', 'entrypoints', `${solution}.Rest`),
|
|
77
|
+
"grpc": path.join('src', 'entrypoints', `${solution}.gRpc`),
|
|
78
|
+
"asyncWorker": path.join('src', 'entrypoints', `${solution}.AsyncWorker`)
|
|
79
|
+
},
|
|
80
|
+
"tests": {
|
|
81
|
+
"domain": path.join('tests', 'unit', `${solution}.Domain.Test`),
|
|
82
|
+
"application": path.join('tests', 'unit', `${solution}.Application.Test`),
|
|
83
|
+
"infrastructure": path.join('tests', 'unit', `${solution}.Infrastructure.Test`),
|
|
84
|
+
"rest": path.join('tests', 'unit', `${solution}.Rest.Test`),
|
|
85
|
+
"grpc": path.join('tests', 'unit', `${solution}.gRpc.Test`),
|
|
86
|
+
"asyncWorker": path.join('tests', 'unit', `${solution}.AsyncWorker.Test`)
|
|
87
|
+
},
|
|
88
|
+
"integrationTests": {
|
|
89
|
+
"rest": path.join('tests', 'integration', `${solution}.Rest.Test`),
|
|
90
|
+
"grpc": path.join('tests', 'integration', `${solution}.gRpc.Test`),
|
|
91
|
+
"asyncWorker": path.join('tests', 'integration', `${solution}.AsyncWorker.Test`)
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"aggregate": AggregateModel.from(answers.aggregate),
|
|
95
|
+
"domainEvents": DomainEventModel.from(answers.domainEvents),
|
|
96
|
+
"entities": EntityModel.from(answers.entities),
|
|
97
|
+
"valueObjects": ValueObjectModel.from(answers.valueObjects),
|
|
98
|
+
"commands": CommandHandlerModel.from(answers.commands),
|
|
99
|
+
"queries": QueryHandlerModel.from(answers.queries),
|
|
100
|
+
"enableGrpc": answers.enableGrpc,
|
|
101
|
+
"enableAsyncWorker": answers.enableAsyncWorker,
|
|
102
|
+
"consumer": answers.enableAsyncWorker ? ConsumerModel.from(answers.consumer) : answers.consumer,
|
|
103
|
+
"repository": RepositoryModel.from(answers.repository),
|
|
104
|
+
"dataTransferObject": DataTransferObjectModel.from(answers.dataTransferObject),
|
|
105
|
+
"controller": ControllerModel.from(answers.controller),
|
|
106
|
+
"proto": ProtoModel.from(answers.protoName),
|
|
107
|
+
"appSettings": AppSettingsModel.from(answers)
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return options;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async addUsing(src, ns) {
|
|
114
|
+
|
|
115
|
+
const filePath = path.join(this._generator.destinationRoot(), src, 'Usings.cs');
|
|
116
|
+
|
|
117
|
+
let content = this._generator.fs.read(filePath);
|
|
118
|
+
|
|
119
|
+
const lineToAdd = `global using ${ns};`;
|
|
120
|
+
|
|
121
|
+
if (!content.includes(lineToAdd)) {
|
|
122
|
+
content += `\n${lineToAdd}`;
|
|
123
|
+
this._generator.fs.write(filePath, content, { flag: 'w', mode: 0o666 });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async getClassName(path) {
|
|
128
|
+
const content = this._generator.fs.read(path);
|
|
129
|
+
|
|
130
|
+
const classNameMatch = content.match(/public class (\w+)/);
|
|
131
|
+
const className = classNameMatch[1];
|
|
132
|
+
|
|
133
|
+
return className;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
toPascalCase = (str) =>
|
|
137
|
+
str
|
|
138
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
|
139
|
+
.map((x) => x.charAt(0).toUpperCase() + x.slice(1).toLowerCase())
|
|
140
|
+
.join("");
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
_getTransformations(options, namespace) {
|
|
144
|
+
let transformations = [
|
|
145
|
+
[/CodeDesignPlus\.Net\.Microservice(?!\.Commons)/g, namespace],
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
if (options.entities.length === 0)
|
|
149
|
+
transformations = [[/global using CodeDesignPlus\.Net\.Microservice\.Domain\.Entities;/g, ''], ...transformations];
|
|
150
|
+
|
|
151
|
+
if (options.domainEvents.length === 0)
|
|
152
|
+
transformations = [[/global using CodeDesignPlus\.Net\.Microservice\.Domain\.DomainEvents;/g, ''], ...transformations];
|
|
153
|
+
|
|
154
|
+
return [
|
|
155
|
+
[/public static void Configure\(\)\s*{\s*([^}]*)}/g, 'public static void Configure() { }'],
|
|
156
|
+
[/<Protobuf Include="Protos\\org.proto" GrpcServices="Server" \/>/g, ''],
|
|
157
|
+
[/Protos\\orders.proto/g, `Protos\\${options.proto?.file}`],
|
|
158
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Domain\.Enums;/g, ''],
|
|
159
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Domain\.DataTransferObjects;/g, ''],
|
|
160
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Domain\.ValueObjects;/g, ''],
|
|
161
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.AsyncWorker\.Consumers;/g, ''],
|
|
162
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Commands\.AddProductToOrder;/g, ''],
|
|
163
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Commands\.CancelOrder;/g, ''],
|
|
164
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Commands\.CompleteOrder;/g, ''],
|
|
165
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Commands\.CreateOrder;/g, ''],
|
|
166
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Commands\.RemoveProduct;/g, ''],
|
|
167
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Commands\.UpdateQuantityProduct;/g, ''],
|
|
168
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Queries\.FindOrderById;/g, ''],
|
|
169
|
+
[/global using CodeDesignPlus\.Net\.Microservice\.Application\.Order\.Queries\.GetAllOrders;/g, ''],
|
|
170
|
+
[/app\.MapGrpcService<OrdersService>\(\)/g, `app.MapGrpcService<${options.proto?.name}Service>()`],
|
|
171
|
+
[/Order/g, options.aggregate.name],
|
|
172
|
+
...transformations
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async generateFiles(options, namespace, template, destination, files) {
|
|
177
|
+
const transformations = this._getTransformations(options, namespace);
|
|
178
|
+
|
|
179
|
+
for (const i in files) {
|
|
180
|
+
const file = files[i];
|
|
181
|
+
const src = path.resolve(template, file);
|
|
182
|
+
const dest = path.resolve(destination, file
|
|
183
|
+
.replace(/CodeDesignPlus\.Net\.Microservice/g, namespace)
|
|
184
|
+
.replace(/Order/g, options.microservice)
|
|
185
|
+
.replace(/orders.proto/g, options.proto?.file)
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const content = await fs.readFile(src, { encoding: 'utf-8' });
|
|
189
|
+
|
|
190
|
+
let transformedContent = transformations.reduce((acc, [regex, replacement]) => acc.replace(regex, replacement), content);
|
|
191
|
+
|
|
192
|
+
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
193
|
+
await fs.writeFile(dest, transformedContent, { encoding: 'utf-8' });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
export default class ValueObjectGenerator {
|
|
4
|
+
|
|
5
|
+
constructor(utils, generator) {
|
|
6
|
+
this._utils = utils;
|
|
7
|
+
this._generator = generator;
|
|
8
|
+
this.name = 'valueObject';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async generate(options) {
|
|
12
|
+
for (const key in options.valueObjects) {
|
|
13
|
+
const valueObject = options.valueObjects[key];
|
|
14
|
+
|
|
15
|
+
await this._generator.fs.copyTplAsync(
|
|
16
|
+
this._generator.templatePath('value-object/ItemValueObject.cs'),
|
|
17
|
+
this._generator.destinationPath(path.join(options.paths.src.domain, `ValueObjects`, valueObject.file)),
|
|
18
|
+
{
|
|
19
|
+
ns: `${options.solution}.Domain.ValueObjects`,
|
|
20
|
+
name: valueObject.fullname
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getArguments() {
|
|
27
|
+
this._generator.option('valueObjects', { type: String, alias: 'vo', required: true, description: 'Comma-separated list of value object names.' });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { Parser, Builder } from 'xml2js';
|
|
3
|
+
|
|
4
|
+
export default class Xml {
|
|
5
|
+
constructor(filePath) {
|
|
6
|
+
this.filePath = filePath;
|
|
7
|
+
this.parser = new Parser();
|
|
8
|
+
this.builder = new Builder();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async _parseFile() {
|
|
12
|
+
const content = readFileSync(this.filePath, 'utf8');
|
|
13
|
+
this.ast = await this.parser.parseStringPromise(content);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_writeFile() {
|
|
17
|
+
const xml = this.builder.buildObject(this.ast);
|
|
18
|
+
writeFileSync(this.filePath, xml, 'utf8');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async addProtobuf(protoPath, grpcServices = "Server") {
|
|
22
|
+
await this._parseFile();
|
|
23
|
+
|
|
24
|
+
const protoEntry = {
|
|
25
|
+
Protobuf: {
|
|
26
|
+
$: {
|
|
27
|
+
Include: protoPath,
|
|
28
|
+
GrpcServices: grpcServices
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let itemGroup = this.ast.Project.ItemGroup.find(group => group.$ && group.$.Label === "Protos");
|
|
34
|
+
|
|
35
|
+
if (itemGroup) {
|
|
36
|
+
itemGroup.Protobuf = itemGroup.Protobuf || [];
|
|
37
|
+
itemGroup.Protobuf.push(protoEntry.Protobuf);
|
|
38
|
+
} else {
|
|
39
|
+
itemGroup = {
|
|
40
|
+
$: { Label: "Protos" },
|
|
41
|
+
Protobuf: [protoEntry.Protobuf]
|
|
42
|
+
};
|
|
43
|
+
this.ast.Project.ItemGroup.push(itemGroup);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this._writeFile();
|
|
47
|
+
}
|
|
48
|
+
}
|