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.
Files changed (200) hide show
  1. package/LICENCE.md +13 -0
  2. package/README.md +454 -0
  3. package/generators/app/index.mjs +22 -0
  4. package/generators/microservice/core/aggregate.mjs +25 -0
  5. package/generators/microservice/core/appsettings.mjs +73 -0
  6. package/generators/microservice/core/asyncWorker.mjs +87 -0
  7. package/generators/microservice/core/command.mjs +54 -0
  8. package/generators/microservice/core/consumer.mjs +73 -0
  9. package/generators/microservice/core/controller.mjs +25 -0
  10. package/generators/microservice/core/core.mjs +98 -0
  11. package/generators/microservice/core/dataTransferObject.mjs +31 -0
  12. package/generators/microservice/core/domainEvent.mjs +36 -0
  13. package/generators/microservice/core/dotnet.mjs +56 -0
  14. package/generators/microservice/core/entity.mjs +29 -0
  15. package/generators/microservice/core/errors.mjs +37 -0
  16. package/generators/microservice/core/grpc.mjs +97 -0
  17. package/generators/microservice/core/microservice.mjs +212 -0
  18. package/generators/microservice/core/proto.mjs +61 -0
  19. package/generators/microservice/core/query.mjs +59 -0
  20. package/generators/microservice/core/repository.mjs +41 -0
  21. package/generators/microservice/core/utils.mjs +196 -0
  22. package/generators/microservice/core/valueObject.mjs +29 -0
  23. package/generators/microservice/core/xml.mjs +48 -0
  24. package/generators/microservice/index.mjs +38 -0
  25. package/generators/microservice/templates/aggregate/ItemAggregate.cs +9 -0
  26. package/generators/microservice/templates/command/ItemCommand.cs +12 -0
  27. package/generators/microservice/templates/command/ItemCommandHandler.cs +9 -0
  28. package/generators/microservice/templates/consumer/ItemHandler.cs +14 -0
  29. package/generators/microservice/templates/controller/ItemController.cs +8 -0
  30. package/generators/microservice/templates/data-transfer-object/ItemDto.cs +6 -0
  31. package/generators/microservice/templates/domain-event/ItemDomainEvent.cs +15 -0
  32. package/generators/microservice/templates/entity/ItemEntity.cs +6 -0
  33. package/generators/microservice/templates/errors/Error.cs +6 -0
  34. package/generators/microservice/templates/grpc/ItemService.cs +6 -0
  35. package/generators/microservice/templates/grpc/grpc.proto +22 -0
  36. package/generators/microservice/templates/microservice/.dockerignore +30 -0
  37. package/generators/microservice/templates/microservice/CodeDesignPlus.Net.Microservice.sln +155 -0
  38. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/CodeDesignPlus.Net.Microservice.Application.csproj +20 -0
  39. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Errors.cs +10 -0
  40. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/AddProductToOrder/AddProductToOrderCommand.cs +17 -0
  41. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/AddProductToOrder/AddProductToOrderCommandHandler.cs +27 -0
  42. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CancelOrder/CancelOrderCommand.cs +13 -0
  43. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CancelOrder/CancelOrderCommandHandler.cs +24 -0
  44. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CompleteOrder/CompleteOrderCommand.cs +11 -0
  45. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CompleteOrder/CompleteOrderCommandHandler.cs +25 -0
  46. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CreateOrder/CreateOrderCommand.cs +32 -0
  47. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/CreateOrder/CreateOrderCommandHandler.cs +24 -0
  48. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/RemoveProduct/RemoveProductCommand.cs +12 -0
  49. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/RemoveProduct/RemoveProductCommandHandler.cs +22 -0
  50. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommand.cs +14 -0
  51. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommandHandler.cs +24 -0
  52. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/AddressDto.cs +11 -0
  53. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/ClientDto.cs +9 -0
  54. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/OrderDto.cs +18 -0
  55. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/DataTransferObjects/ProductDto.cs +10 -0
  56. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/FindOrderById/FindOrderByIdQuery.cs +4 -0
  57. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/FindOrderById/FindOrderByIdQueryHandler.cs +23 -0
  58. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/GetAllOrders/GetAllOrdersQuery.cs +3 -0
  59. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Order/Queries/GetAllOrders/GetAllOrdersQueryHandler.cs +18 -0
  60. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Setup/MapsterConfig.cs +26 -0
  61. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Startup.cs +15 -0
  62. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Application/Usings.cs +18 -0
  63. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/CodeDesignPlus.Net.Microservice.Domain.csproj +11 -0
  64. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/AddProductToOrderParams.cs +15 -0
  65. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/CancelOrderParams.cs +13 -0
  66. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/CompleteOrderParams.cs +12 -0
  67. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/RemoveProductFromOrderParams.cs +11 -0
  68. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DataTransferObjects/UpdateQuantityProductParams.cs +12 -0
  69. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/OrderCancelledDomainEvent.cs +21 -0
  70. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/OrderCompletedDomainEvent.cs +18 -0
  71. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/OrderCreatedDomainEvent.cs +44 -0
  72. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/ProductAddedToOrderDomainEvent.cs +20 -0
  73. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/ProductQuantityUpdatedDomainEvent.cs +20 -0
  74. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/DomainEvents/ProductRemovedFromOrderDomainEvent.cs +18 -0
  75. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Entities/ProductEntity.cs +10 -0
  76. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Enums/OrderStatus.cs +10 -0
  77. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Errors.cs +28 -0
  78. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/OrderAggregate.cs +124 -0
  79. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Repositories/IOrderRepository.cs +14 -0
  80. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Startup.cs +12 -0
  81. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/Usings.cs +11 -0
  82. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/ValueObjects/AddressValueObject.cs +30 -0
  83. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Domain/ValueObjects/ClientValueObject.cs +27 -0
  84. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/CodeDesignPlus.Net.Microservice.Infrastructure.csproj +13 -0
  85. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Errors.cs +6 -0
  86. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Repositories/OrderRepository.cs +109 -0
  87. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Startup.cs +10 -0
  88. package/generators/microservice/templates/microservice/src/domain/CodeDesignPlus.Net.Microservice.Infrastructure/Usings.cs +15 -0
  89. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/CodeDesignPlus.Net.Microservice.AsyncWorker.csproj +31 -0
  90. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Program.cs +41 -0
  91. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Properties/launchSettings.json +15 -0
  92. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Usings.cs +10 -0
  93. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/appsettings.Development.json +2 -0
  94. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/appsettings.json +129 -0
  95. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/CodeDesignPlus.Net.Microservice.Rest.csproj +36 -0
  96. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/CodeDesignPlus.Net.Microservice.Rest.csproj.user +11 -0
  97. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Controllers/OrderController.cs +138 -0
  98. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Core/Mapster/MapsterConfig.cs +12 -0
  99. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Dockerfile +37 -0
  100. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Program.cs +52 -0
  101. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Properties/launchSettings.json +26 -0
  102. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/Usings.cs +22 -0
  103. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/appsettings.Development.json +3 -0
  104. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.Rest/appsettings.json +86 -0
  105. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/CodeDesignPlus.Net.Microservice.gRpc.csproj +35 -0
  106. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/CodeDesignPlus.Net.Microservice.gRpc.csproj.user +9 -0
  107. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Core/Mapster/MapsterConfig.cs +13 -0
  108. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Program.cs +61 -0
  109. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Properties/launchSettings.json +23 -0
  110. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Protos/orders.proto +66 -0
  111. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Services/OrderService.cs +29 -0
  112. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Usings.cs +12 -0
  113. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/appsettings.Development.json +3 -0
  114. package/generators/microservice/templates/microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/appsettings.json +92 -0
  115. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/CodeDesignPlus.Net.Microservice.AsyncWorker.Test.csproj +35 -0
  116. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Properties/launchSettings.json +12 -0
  117. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Usings.cs +8 -0
  118. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/CodeDesignPlus.Net.Microservice.Rest.Test.csproj +36 -0
  119. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Controllers/OrderControllerTest.cs +337 -0
  120. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Properties/launchSettings.json +12 -0
  121. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.Rest.Test/Usings.cs +8 -0
  122. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/CodeDesignPlus.Net.Microservice.gRpc.Test.csproj +46 -0
  123. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Protos/orders.proto +65 -0
  124. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/OrdersServiceTest.cs +64 -0
  125. package/generators/microservice/templates/microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Usings.cs +7 -0
  126. package/generators/microservice/templates/microservice/tests/load/load-rest.js +63 -0
  127. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/CodeDesignPlus.Net.Microservice.Application.Test.csproj +34 -0
  128. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/AddProductToOrder/AddProductToOrderCommandHandlerTest.cs +98 -0
  129. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/AddProductToOrder/AddProductToOrderCommandTest.cs +84 -0
  130. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CancelOrder/CancelOrderCommandHandlerTest.cs +74 -0
  131. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CancelOrder/CancelOrderCommandTest.cs +43 -0
  132. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CompleteOrder/CompleteOrderCommandHandlerTest.cs +74 -0
  133. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CompleteOrder/CompleteOrderCommandTest.cs +32 -0
  134. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CreateOrder/CreateOrderCommandHandlerTest.cs +100 -0
  135. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/CreateOrder/CreateOrderCommandTest.cs +122 -0
  136. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/RemoveProduct/RemoveProductCommandHandlerTest.cs +71 -0
  137. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/RemoveProduct/RemoveProductCommandTest.cs +33 -0
  138. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommandHandlerTest.cs +82 -0
  139. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Commands/UpdateQuantityProduct/UpdateQuantityProductCommandTest.cs +51 -0
  140. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Queries/FindOrderById/FindOrderByIdQueryHandlerTest.cs +70 -0
  141. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Order/Queries/GetAllOrders/GetAllOrdersQueryHandlerTest.cs +80 -0
  142. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Setup/MapsterConfigTest.cs +20 -0
  143. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Application.Test/Usings.cs +18 -0
  144. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/CodeDesignPlus.Net.Microservice.AsyncWorker.Test.csproj +38 -0
  145. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Usings.cs +9 -0
  146. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/CodeDesignPlus.Net.Microservice.Default.Test.csproj +35 -0
  147. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Usings.cs +6 -0
  148. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/AggregateTest.cs +37 -0
  149. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/CommandsTests.cs +29 -0
  150. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/DataTransferObjectTest.cs +47 -0
  151. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/DomainEventTest.cs +42 -0
  152. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/EntityTest.cs +25 -0
  153. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/ErrorsTest.cs +55 -0
  154. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/QueryTests.cs +29 -0
  155. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Default.Test/Validations/StartupTest.cs +43 -0
  156. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/CodeDesignPlus.Net.Microservice.Domain.Test.csproj +38 -0
  157. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/DomainEvents/OrderCancelledDomainEventTest.cs +46 -0
  158. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/OrderAggregateTest.cs +518 -0
  159. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Domain.Test/Usings.cs +7 -0
  160. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/CodeDesignPlus.Net.Microservice.Infrastructure.Test.csproj +34 -0
  161. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/Repositories/OrderRepositoryTest.cs +259 -0
  162. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Infrastructure.Test/Usings.cs +14 -0
  163. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/CodeDesignPlus.Net.Microservice.Rest.Test.csproj +40 -0
  164. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Controllers/OrderControllerTest.cs +189 -0
  165. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Core/Mapster/MapsterConfigTest.cs +19 -0
  166. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.Rest.Test/Usings.cs +14 -0
  167. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/CodeDesignPlus.Net.Microservice.gRpc.Test.csproj +39 -0
  168. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Core/Mapster/MapsterConfigTest.cs +19 -0
  169. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/OrderServiceTest.cs +72 -0
  170. package/generators/microservice/templates/microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Usings.cs +15 -0
  171. package/generators/microservice/templates/microservice/tools/convert-crlf-to-lf.sh +6 -0
  172. package/generators/microservice/templates/microservice/tools/sonarqube/sonar.ps1 +18 -0
  173. package/generators/microservice/templates/microservice/tools/sonarqube/sonar.sh +18 -0
  174. package/generators/microservice/templates/microservice/tools/update-packages/update-packages.ps1 +10 -0
  175. package/generators/microservice/templates/microservice/tools/update-packages/update-packages.sh +11 -0
  176. package/generators/microservice/templates/microservice/tools/upgrade-dotnet/upgrade-assistant.ps1 +10 -0
  177. package/generators/microservice/templates/microservice/tools/upgrade-dotnet/upgrade-assistant.sh +11 -0
  178. package/generators/microservice/templates/microservice/tools/vault/config-vault.ps1 +178 -0
  179. package/generators/microservice/templates/microservice/tools/vault/config-vault.sh +152 -0
  180. package/generators/microservice/templates/others/MapsterConfig.cs +9 -0
  181. package/generators/microservice/templates/query/ItemQuery.cs +4 -0
  182. package/generators/microservice/templates/query/ItemQueryHandler.cs +9 -0
  183. package/generators/microservice/templates/repository/IItemRepository.cs +6 -0
  184. package/generators/microservice/templates/repository/ItemRepository.cs +7 -0
  185. package/generators/microservice/templates/value-object/ItemValueObject.cs +23 -0
  186. package/generators/microservice/types/aggregate.mjs +19 -0
  187. package/generators/microservice/types/appsettings.mjs +26 -0
  188. package/generators/microservice/types/base.mjs +24 -0
  189. package/generators/microservice/types/command.mjs +38 -0
  190. package/generators/microservice/types/consumer.mjs +21 -0
  191. package/generators/microservice/types/controller.mjs +20 -0
  192. package/generators/microservice/types/dataTransferObject.mjs +19 -0
  193. package/generators/microservice/types/domainEvents.mjs +22 -0
  194. package/generators/microservice/types/entity.mjs +21 -0
  195. package/generators/microservice/types/index.mjs +25 -0
  196. package/generators/microservice/types/proto.mjs +19 -0
  197. package/generators/microservice/types/query.mjs +38 -0
  198. package/generators/microservice/types/repository.mjs +21 -0
  199. package/generators/microservice/types/valueObject.mjs +23 -0
  200. package/package.json +70 -0
@@ -0,0 +1,87 @@
1
+ import path from 'path';
2
+ import AppSettingsGenerator from './appsettings.mjs';
3
+ import fsSync from 'fs';
4
+ import fs from 'fs/promises';
5
+ import { glob } from 'glob';
6
+
7
+ export default class AsyncWorkerGenerator {
8
+
9
+ constructor(utils, generator) {
10
+ this._appsettings = new AppSettingsGenerator(utils, generator);
11
+
12
+ this._utils = utils;
13
+ this._generator = generator;
14
+ this.name = 'grpc';
15
+ }
16
+
17
+ async generate(options) {
18
+ options = {
19
+ ...options
20
+ }
21
+
22
+ const destination = this._generator.destinationPath();
23
+
24
+ const asyncWorkerProjectPathDestination = path.join(destination, options.paths.src.asyncWorker);
25
+ const asyncWorkerTestProjectPathDestination = path.join(destination, options.paths.tests.asyncWorker);
26
+ const asyncWorkerIntegrationTestProjectPathDestination = path.join(destination, options.paths.integrationTests.asyncWorker);
27
+
28
+ const ignores = this._getIgnores();
29
+
30
+ if (!fsSync.existsSync(asyncWorkerProjectPathDestination)) {
31
+ const templateAsyncWorkerProject = this._generator.templatePath('microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker');
32
+
33
+ await this._generateFiles(templateAsyncWorkerProject, ignores, options, asyncWorkerProjectPathDestination);
34
+ }
35
+
36
+ if (!fsSync.existsSync(asyncWorkerTestProjectPathDestination)) {
37
+ const templateAsyncWorkerProject = this._generator.templatePath('microservice/tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test');
38
+
39
+ await this._generateFiles(templateAsyncWorkerProject, ignores, options, asyncWorkerTestProjectPathDestination);
40
+ }
41
+
42
+ if (!fsSync.existsSync(asyncWorkerIntegrationTestProjectPathDestination)) {
43
+ const templateAsyncWorkerProject = this._generator.templatePath('microservice/tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test');
44
+
45
+ await this._generateFiles(templateAsyncWorkerProject, ignores, options, asyncWorkerIntegrationTestProjectPathDestination);
46
+ }
47
+
48
+ await this._generator.spawnCommand('dotnet', ['sln', `${destination}/${options.solution}.sln`, 'add', `${asyncWorkerProjectPathDestination}`, '--solution-folder', 'src/entrypoints']);
49
+ await this._generator.spawnCommand('dotnet', ['sln', `${destination}/${options.solution}.sln`, 'add', `${asyncWorkerTestProjectPathDestination}`, '--solution-folder', 'tests/unit']);
50
+ await this._generator.spawnCommand('dotnet', ['sln', `${destination}/${options.solution}.sln`, 'add', `${asyncWorkerIntegrationTestProjectPathDestination}`, '--solution-folder', 'tests/integration']);
51
+ }
52
+
53
+ async _generateFiles(templateAsyncWorkerProject, ignores, options, asyncWorkerProjectPathDestination) {
54
+
55
+ const files = glob.sync('**', { dot: true, nodir: true, cwd: templateAsyncWorkerProject, ignore: ignores });
56
+
57
+ await this._utils.generateFiles(options, options.solution, templateAsyncWorkerProject, asyncWorkerProjectPathDestination, files);
58
+
59
+ await this._appsettings.generate(options, [options.paths.src.asyncWorker]);
60
+ }
61
+
62
+ getArguments() {
63
+
64
+ }
65
+
66
+ _getIgnores() {
67
+ const ignores = ['**/bin/**', '**/obj/**'];
68
+
69
+ const items = {
70
+ entryPoints_asyncWorker: [
71
+ 'src/entrypoints/CodeDesignPlus.Net.Microservice.AsyncWorker/Consumers/**'
72
+ ],
73
+ integrationTest_asyncWorker: [
74
+ 'tests/integration/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Consumers/**'
75
+ ],
76
+ unitTest_asyncWorker: [
77
+ 'tests/unit/CodeDesignPlus.Net.Microservice.AsyncWorker.Test/Consumers/*.cs',
78
+ ]
79
+ }
80
+
81
+ for (const key in items) {
82
+ ignores.push(...items[key]);
83
+ }
84
+
85
+ return ignores;
86
+ }
87
+ }
@@ -0,0 +1,54 @@
1
+ import { glob } from 'glob';
2
+ import path from 'path';
3
+ import RepositoryGenerator from './repository.mjs';
4
+
5
+ export default class CommandGenerator {
6
+
7
+ constructor(utils, generator) {
8
+ this._utils = utils;
9
+ this._generator = generator;
10
+ this.name = 'command';
11
+ this._repositoryGenerator = new RepositoryGenerator(this._utils, this._generator);
12
+ }
13
+
14
+ async generate(options) {
15
+
16
+ for (const key in options.commands) {
17
+ const handler = options.commands[key];
18
+ const command = handler.command;
19
+
20
+ const ns = `${options.solution}.Application.${options.aggregate.name}.Commands.${command.name}`;
21
+
22
+ await this._generator.fs.copyTplAsync(
23
+ this._generator.templatePath('command/ItemCommand.cs'),
24
+ this._generator.destinationPath(path.join(options.paths.src.application, options.aggregate.name, `Commands`, command.name, command.file)),
25
+ {
26
+ ns: ns,
27
+ name: command.fullname,
28
+
29
+ }
30
+ );
31
+
32
+ await this._generator.fs.copyTplAsync(
33
+ this._generator.templatePath('command/ItemCommandHandler.cs'),
34
+ this._generator.destinationPath(path.join(options.paths.src.application, options.aggregate.name, `Commands`, command.name, handler.file)),
35
+ {
36
+ ns: ns,
37
+ name: command.fullname,
38
+ handler: handler.fullname,
39
+ repository: options.repository.interface
40
+ }
41
+ );
42
+
43
+ this._utils.addUsing(options.paths.src.rest, ns);
44
+ }
45
+
46
+ // await this._repositoryGenerator.generate(options);
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('commands', { type: String, alias: 'cs', required: true, description: 'Comma-separated list of commands representing actions from the user or system.' });
53
+ }
54
+ }
@@ -0,0 +1,73 @@
1
+ import EntityGenerator from './entity.mjs';
2
+ import DomainEventGenerator from './domainEvent.mjs';
3
+ import AggregateGenerator from './aggregate.mjs';
4
+ import RepositoryGenerator from './repository.mjs';
5
+ import CommandGenerator from './command.mjs';
6
+ import { AggregateModel, DomainEventModel, RepositoryModel, CommandHandlerModel } from '../types/index.mjs';
7
+ import path from 'path';
8
+
9
+ export default class ConsumerGenerator {
10
+
11
+ constructor(utils, generator) {
12
+ this._utils = utils;
13
+ this._generator = generator;
14
+ this._entityGenerator = new EntityGenerator(this._utils, this._generator);
15
+ this._domainEventGenerator = new DomainEventGenerator(this._utils, this._generator);
16
+ this._aggregateGenerator = new AggregateGenerator(this._utils, this._generator);
17
+ this._repositoryGenerator = new RepositoryGenerator(this._utils, this._generator);
18
+ this._commandGenerator = new CommandGenerator(this._utils, this._generator);
19
+ this.name = 'consumer';
20
+ }
21
+
22
+ async generate(options) {
23
+
24
+ if (options.enableAsyncWorker) {
25
+
26
+ options = {
27
+ ...options,
28
+ aggregate: AggregateModel.from(options.consumer.aggregate),
29
+ domainEvents: DomainEventModel.from(options.consumer.domainEvent),
30
+ repository: RepositoryModel.from(options.consumer.aggregate),
31
+ commands: CommandHandlerModel.from(options.consumer.command),
32
+ isConsumer: true
33
+ }
34
+
35
+ await this._generator.fs.copyTplAsync(
36
+ this._generator.templatePath('consumer/ItemHandler.cs'),
37
+ this._generator.destinationPath(path.join(options.paths.src.asyncWorker, `Consumers`, options.consumer.file)),
38
+ {
39
+ ns: `${options.solution}.AsyncWorker.Consumers`,
40
+ name: options.consumer.fullname,
41
+ action: options.consumer.action,
42
+ aggregate: options.consumer.aggregate,
43
+ domainEvent: `${options.consumer.domainEvent}DomainEvent`,
44
+ solution: options.solution
45
+ }
46
+ );
47
+
48
+ await this._aggregateGenerator.generate(options);
49
+
50
+ await this._repositoryGenerator.generate(options);
51
+
52
+ await this._commandGenerator.generate(options);
53
+
54
+ await this._domainEventGenerator.generate(options);
55
+ }
56
+ }
57
+
58
+ getArguments() {
59
+ this._generator.option('consumer-name', { type: String, required: true, description: 'Name of the event consumer, specifying the type of event it consumes.' });
60
+ this._generator.option('consumer-aggregate', { type: String, required: true, description: 'Aggregate to which the consumer belongs, defining the context of the event.' });
61
+ this._generator.option('consumer-action', { type: String, required: true, description: 'Action to be performed in the consumer when it receives an event.' });
62
+
63
+ this._generator.options = {
64
+ ...this._generator.options,
65
+ consumer: {
66
+ aggregate: this._generator.options['consumerAggregate'],
67
+ consumer: this._generator.options['consumerName'],
68
+ action: this._generator.options['consumerAction'],
69
+ },
70
+ enableAsyncWorker: this._generator.options.consumerName !== undefined && this._generator.options.consumerName !== null
71
+ };
72
+ }
73
+ }
@@ -0,0 +1,25 @@
1
+ import path from 'path';
2
+ export default class ControllerGenerator {
3
+
4
+ constructor(utils, generator) {
5
+ this._utils = utils;
6
+ this._generator = generator;
7
+ this.name = 'controller';
8
+ }
9
+
10
+ async generate(options) {
11
+
12
+ await this._generator.fs.copyTplAsync(
13
+ this._generator.templatePath('controller/ItemController.cs'),
14
+ this._generator.destinationPath(path.join(options.paths.src.rest, `Controllers`, options.controller.file)),
15
+ {
16
+ ns: `${options.solution}.Rest.Controllers`,
17
+ name: options.controller.fullname
18
+ }
19
+ );
20
+ }
21
+
22
+ getArguments() {
23
+ this._generator.option('controller', { type: String, alias: 'cr', required: true, description: 'The name of the controller to create.' });
24
+ }
25
+ }
@@ -0,0 +1,98 @@
1
+ import AggregateGenerator from './aggregate.mjs';
2
+ import CommandGenerator from './command.mjs';
3
+ import QueryGenerator from './query.mjs';
4
+ import ConsumerGenerator from './consumer.mjs';
5
+ import ControllerGenerator from './controller.mjs';
6
+ import DtoGenerator from './dataTransferObject.mjs';
7
+ import DomainEventGenerator from './domainEvent.mjs';
8
+ import EntityGenerator from './entity.mjs';
9
+ import RepositoryGenerator from './repository.mjs';
10
+ import MicroserviceGenerator from './microservice.mjs';
11
+ import ValueObjectGenerator from './valueObject.mjs';
12
+ import AsyncWorkerGenerator from './asyncWorker.mjs';
13
+ import GrpcGenerator from './grpc.mjs';
14
+ import ProtoGenerator from './proto.mjs';
15
+ import figlet from 'figlet';
16
+ import boxen from 'boxen';
17
+
18
+ export default class Core {
19
+
20
+ constructor(utils, generator) {
21
+ this._utils = utils;
22
+ this._generator = generator;
23
+ }
24
+
25
+ arguments() {
26
+ console.log(figlet.textSync('CodeDesignPlus'));
27
+
28
+ if (this._generator.options.help)
29
+ console.log(boxen(
30
+ 'Welcome to the CodeDesignPlus Microservice Archetype Generator (v1.0)\n\n' +
31
+ 'This generator helps developers quickly create resources for microservices following best practices in the CodeDesignPlus architecture.\n\n' +
32
+ 'Available Commands:\n\n' +
33
+ ' - yo codedesignplus:microservice microservice | Creates the base structure for a new microservice, choosing between CRUD or custom patterns.\n' +
34
+ ' - yo codedesignplus:microservice aggregate | Creates a new aggregate within an existing microservice.\n' +
35
+ ' - yo codedesignplus:microservice entity | Creates one or more entities.\n' +
36
+ ' - yo codedesignplus:microservice valueObject | Creates one or more value objects.\n' +
37
+ ' - yo codedesignplus:microservice domainEvent | Creates one or more domain events associated with an aggregate.\n' +
38
+ ' - yo codedesignplus:microservice repository | Creates a repository for a specific aggregate.\n' +
39
+ ' - yo codedesignplus:microservice controller | Creates a controller to handle incoming requests.\n' +
40
+ ' - yo codedesignplus:microservice proto | Creates a .proto file for a gRPC service.\n' +
41
+ ' - yo codedesignplus:microservice consumer | Creates a consumer that reacts to domain events.\n' +
42
+ ' - yo codedesignplus:microservice query | Creates one or more queries to retrieve data.\n' +
43
+ ' - yo codedesignplus:microservice command | Creates one or more commands to perform actions that change the system state.\n' +
44
+ ' - yo codedesignplus:microservice dto | Creates one or more Data Transfer Objects (DTOs) to transfer data.\n\n' +
45
+ ' - yo codedesignplus:microservice grpc | Creates a gRPC project.\n' +
46
+ ' - yo codedesignplus:microservice asyncWorker | Creates an async worker project.\n\n' +
47
+ 'Usage:\n\n' +
48
+ 'To use a command, run `yo codedesignplus:microservice <command> --option1 <value> --option2 <value>`.\n\n' +
49
+ 'For more details on each command and its options, use the `--help` flag after the specific command (e.g., `yo codedesignplus:microservice microservice --help`).\n\n',
50
+
51
+ { padding: 1, margin: 1, borderStyle: 'round' }
52
+ ));
53
+
54
+ this._generator.argument('template', {
55
+ type: String,
56
+ alias: 't',
57
+ description: 'The type of component to generate.',
58
+ required: true
59
+ });
60
+
61
+ if (this._generator.options.template) {
62
+ const generatorsMap = {
63
+ 'aggregate': AggregateGenerator,
64
+ 'command': CommandGenerator,
65
+ 'consumer': ConsumerGenerator,
66
+ 'controller': ControllerGenerator,
67
+ 'dto': DtoGenerator,
68
+ 'domainEvent': DomainEventGenerator,
69
+ 'entity': EntityGenerator,
70
+ 'microservice': MicroserviceGenerator,
71
+ 'proto': ProtoGenerator,
72
+ 'query': QueryGenerator,
73
+ 'repository': RepositoryGenerator,
74
+ 'valueObject': ValueObjectGenerator,
75
+ 'grpc': GrpcGenerator,
76
+ 'asyncWorker': AsyncWorkerGenerator
77
+ };
78
+
79
+ this._generator.option('organization', { type: String, alias: 'o', required: true, description: 'The organization or company name used in the microservice\'s namespace' });
80
+ this._generator.option('microservice', { type: String, alias: 'm', required: true, description: 'The name of the microservice, used in the namespace' });
81
+
82
+ const generatorClass = generatorsMap[this._generator.options.template];
83
+
84
+ if (!generatorClass)
85
+ throw new Error(`The resource ${this._generator.options.template} is not supported`);
86
+
87
+ const generatorInstance = new generatorClass(this._utils, this._generator);
88
+
89
+ generatorInstance.getArguments();
90
+
91
+ return [generatorInstance, {
92
+ ...this._generator.options,
93
+ }];
94
+ }
95
+
96
+ return [null, null];
97
+ }
98
+ }
@@ -0,0 +1,31 @@
1
+ import path from 'path';
2
+ import { glob } from 'glob';
3
+
4
+ export default class DtoGenerator {
5
+
6
+ constructor(utils, generator) {
7
+ this._utils = utils;
8
+ this._generator = generator;
9
+ this.name = 'dataTransferObject';
10
+ }
11
+
12
+ async generate(options) {
13
+
14
+ const ns = `${options.solution}.Application.${options.aggregate.name}.DataTransferObjects`;
15
+ await this._generator.fs.copyTplAsync(
16
+ this._generator.templatePath('data-transfer-object/ItemDto.cs'),
17
+ this._generator.destinationPath(path.join(options.paths.src.application, options.aggregate.name, `DataTransferObjects`, options.dataTransferObject.file)),
18
+ {
19
+ ns: ns,
20
+ name: options.dataTransferObject.fullname
21
+ }
22
+ );
23
+
24
+ this._utils.addUsing(options.paths.src.application, ns);
25
+ }
26
+
27
+ getArguments() {
28
+ this._generator.option('aggregate', { type: String, alias: 'a', required: true, description: 'The name of the microservice\'s root aggregate, essential for domain organization.' });
29
+ this._generator.option('dataTransferObject', { type: String, alias: 'dto', required: true, description: 'A comma-separated list of Data Transfer Object names to be generated.' });
30
+ }
31
+ }
@@ -0,0 +1,36 @@
1
+ import { glob } from 'glob';
2
+ import path from 'path';
3
+
4
+ export default class DomainEventGenerator {
5
+
6
+ constructor(utils, generator) {
7
+ this._utils = utils;
8
+ this._generator = generator;
9
+ this.name = 'domainEvent';
10
+ }
11
+
12
+ async generate(options) {
13
+
14
+ const to = options.isConsumer ? options.paths.src.asyncWorker : options.paths.src.domain;
15
+ const ns = options.isConsumer ? `${options.solution}.AsyncWorker.DomainEvents` : `${options.solution}.Domain.DomainEvents`;
16
+
17
+ for (const key in options.domainEvents) {
18
+ const domainEvent = options.domainEvents[key];
19
+
20
+ await this._generator.fs.copyTplAsync(
21
+ this._generator.templatePath('domain-event/ItemDomainEvent.cs'),
22
+ this._generator.destinationPath(path.join(to, `DomainEvents`, domainEvent.file)),
23
+ {
24
+ ns: ns,
25
+ name: domainEvent.fullname,
26
+ entity: options.aggregate.fullname
27
+ }
28
+ );
29
+ }
30
+ }
31
+
32
+ getArguments() {
33
+ this._generator.option('aggregate', { type: String, alias: 'a', required: true, description: 'The name of the microservice\'s root aggregate, essential for domain organization.' });
34
+ this._generator.option('domainEvents', { type: String, alias: 'de', required: true, description: 'Comma-separated list of domain events, fundamental in asynchronous communication between microservices.' });
35
+ }
36
+ }
@@ -0,0 +1,56 @@
1
+ import { spawnSync } from 'child_process';
2
+ import path from 'path';
3
+ import fs from 'fs';
4
+
5
+ export default class DotNet {
6
+
7
+ constructor(generator) {
8
+ this._generator = generator;
9
+ }
10
+
11
+ removeProjects(options) {
12
+ this._generator.on('end', () => {
13
+
14
+ if (!options.enableGrpc)
15
+ this._removeProject('gRpc');
16
+
17
+ if (!options.enableAsyncWorker)
18
+ this._removeProject('AsyncWorker');
19
+
20
+ });
21
+ }
22
+
23
+ _removeProject(name) {
24
+ const cwd = this._generator.destinationRoot();
25
+
26
+ const results = spawnSync("dotnet", ["sln", "list"], { cwd: cwd });
27
+
28
+ if (results.error)
29
+ return;
30
+
31
+ if (results.status !== 0)
32
+ return;
33
+
34
+ const solutionProjects = results.stdout.toString().trim().split('\n').slice(1).map(project => project.replace('\r', ''));
35
+ const projects = solutionProjects.filter(project => project.includes(name));
36
+
37
+ for (const project of projects) {
38
+ const removeResult = spawnSync("dotnet", ["sln", "remove", project], { cwd: cwd });
39
+
40
+ if (removeResult.error)
41
+ return;
42
+
43
+ if (removeResult.status !== 0)
44
+ return;
45
+
46
+ const projectPath = path.join(this._generator.destinationRoot(), path.dirname(project));
47
+
48
+ if (fs.existsSync(projectPath))
49
+ fs.rm(projectPath, { recursive: true }, (err) => {
50
+ if (err)
51
+ console.error(err);
52
+ });
53
+ }
54
+ }
55
+
56
+ }
@@ -0,0 +1,29 @@
1
+ import path from 'path';
2
+ export default class EntityGenerator {
3
+
4
+ constructor(utils, generator) {
5
+ this._utils = utils;
6
+ this._generator = generator;
7
+ this.name = 'entity';
8
+ }
9
+
10
+ async generate(options) {
11
+ for (const key in options.entities) {
12
+ const entity = options.entities[key];
13
+
14
+ await this._generator.fs.copyTplAsync(
15
+ this._generator.templatePath('entity/ItemEntity.cs'),
16
+ this._generator.destinationPath(path.join(options.paths.src.domain, `Entities`, entity.file)),
17
+ {
18
+ ns: `${options.solution}.Domain.Entities`,
19
+ name: entity.fullname
20
+ }
21
+ );
22
+ }
23
+ }
24
+
25
+
26
+ getArguments() {
27
+ this._generator.option('entities', { type: String, alias: 'e', required: true, description: 'Comma-separated list of entities.' });
28
+ }
29
+ }
@@ -0,0 +1,37 @@
1
+ export default class ErrorsGenerator {
2
+
3
+ constructor(utils, generator) {
4
+ this._utils = utils;
5
+ this._generator = generator;
6
+ }
7
+
8
+ async generate(options) {
9
+ const layers = {
10
+ 'Domain': {
11
+ "code": '100',
12
+ "destination": options.paths.src.domain
13
+ },
14
+ 'Application': {
15
+ "code": '200',
16
+ "destination": options.paths.src.application
17
+ },
18
+ 'Infrastructure': {
19
+ "code": '300',
20
+ "destination": options.paths.src.infrastructure
21
+ }
22
+ };
23
+
24
+ for (const layer in layers) {
25
+ const { code, destination } = layers[layer];
26
+
27
+ this._generator.fs.copyTplAsync(
28
+ this._generator.templatePath('errors/Error.cs'),
29
+ this._generator.destinationPath(`${destination}/Errors.cs`),
30
+ {
31
+ ns: `${options.solution}.${layer}`,
32
+ code: `${code} : UnknownError`,
33
+ }
34
+ );
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,97 @@
1
+ import path from 'path';
2
+ import AppSettingsGenerator from './appsettings.mjs';
3
+ import ProtoGenerator from './proto.mjs';
4
+ import fsSync from 'fs';
5
+ import { glob } from 'glob';
6
+ import { ProtoModel } from '../types/index.mjs';
7
+
8
+ export default class GrpcGenerator {
9
+
10
+ constructor(utils, generator) {
11
+ this._appsettings = new AppSettingsGenerator(utils, generator);
12
+ this._protoGenerator = new ProtoGenerator(utils, generator);
13
+
14
+ this._utils = utils;
15
+ this._generator = generator;
16
+ this.name = 'grpc';
17
+ }
18
+
19
+ async generate(options) {
20
+ options = {
21
+ ...options,
22
+ proto: ProtoModel.from(options.aggregate.name)
23
+ }
24
+
25
+ const destination = this._generator.destinationPath();
26
+
27
+ const grpcProjectPathDestination = path.join(destination, options.paths.src.grpc);
28
+ const grpcTestProjectPathDestination = path.join(destination, options.paths.tests.grpc);
29
+ const grpcIntegrationTestProjectPathDestination = path.join(destination, options.paths.integrationTests.grpc);
30
+
31
+ const ignores = this._getIgnores();
32
+
33
+ if (!fsSync.existsSync(grpcProjectPathDestination)) {
34
+ const templateGrpcProject = this._generator.templatePath('microservice/src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc');
35
+
36
+ await this._generateFiles(templateGrpcProject, ignores, options, grpcProjectPathDestination);
37
+ }
38
+
39
+ if (!fsSync.existsSync(grpcTestProjectPathDestination)) {
40
+ const templateGrpcProject = this._generator.templatePath('microservice/tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test');
41
+
42
+ await this._generateFiles(templateGrpcProject, ignores, options, grpcTestProjectPathDestination);
43
+ }
44
+
45
+ if (!fsSync.existsSync(grpcIntegrationTestProjectPathDestination)) {
46
+ const templateGrpcProject = this._generator.templatePath('microservice/tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test');
47
+
48
+ await this._generateFiles(templateGrpcProject, ignores, options, grpcIntegrationTestProjectPathDestination);
49
+ }
50
+
51
+ this._protoGenerator.generate(options);
52
+
53
+ await this._generator.spawnCommand('dotnet', ['sln', `${destination}/${options.solution}.sln`, 'add', `${grpcProjectPathDestination}`, '--solution-folder', 'src/entrypoints']);
54
+ await this._generator.spawnCommand('dotnet', ['sln', `${destination}/${options.solution}.sln`, 'add', `${grpcTestProjectPathDestination}`, '--solution-folder', 'tests/unit']);
55
+ await this._generator.spawnCommand('dotnet', ['sln', `${destination}/${options.solution}.sln`, 'add', `${grpcIntegrationTestProjectPathDestination}`, '--solution-folder', 'tests/integration']);
56
+ }
57
+
58
+ async _generateFiles(templateGrpcProject, ignores, options, grpcProjectPathDestination) {
59
+
60
+ const files = glob.sync('**', { dot: true, nodir: true, cwd: templateGrpcProject, ignore: ignores });
61
+
62
+ await this._utils.generateFiles(options, options.solution, templateGrpcProject, grpcProjectPathDestination, files);
63
+
64
+ await this._appsettings.generate(options, [options.paths.src.grpc]);
65
+ }
66
+
67
+ getArguments() {
68
+ this._generator.options = {
69
+ ...this._generator.options,
70
+ enableGrpc: "true"
71
+ }
72
+ }
73
+
74
+ _getIgnores() {
75
+ const ignores = ['**/bin/**', '**/obj/**'];
76
+
77
+ const items = {
78
+ entryPoints_gRpc: [
79
+ 'src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Protos/*.proto',
80
+ 'src/entrypoints/CodeDesignPlus.Net.Microservice.gRpc/Services/*.cs'
81
+ ],
82
+ integrationTest_gRpc: [
83
+ 'tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Protos/**',
84
+ 'tests/integration/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/**'
85
+ ],
86
+ unitTest_gRpc: [
87
+ 'tests/unit/CodeDesignPlus.Net.Microservice.gRpc.Test/Services/*.cs',
88
+ ]
89
+ }
90
+
91
+ for (const key in items) {
92
+ ignores.push(...items[key]);
93
+ }
94
+
95
+ return ignores;
96
+ }
97
+ }