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
package/LICENCE.md ADDED
@@ -0,0 +1,13 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2023 CodeDesignPlus
6
+
7
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
8
+
9
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10
+
11
+ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.
12
+
13
+ As an additional permission under GNU LGPL version 3 section 7, you may distribute non-source (e.g., minimized or compacted) forms of that code without the copy of the GNU LGPL, but you must make the corresponding source code available under the GNU LGPL as provided above.
package/README.md ADDED
@@ -0,0 +1,454 @@
1
+ # 👋 Your Sidekick for CodeDesignPlus.Net Microservices! 🚀
2
+
3
+ Hey there, developer! 👋 Tired of starting your microservices from scratch? Worry no more! The `generator-codedesignplus` is here to simplify and standardize the creation of your microservices based on the `CodeDesignPlus.Net.Microservice` archetype. Imagine having a tool that guides you step by step, generating the structure and key components of your microservice—all ready for you to focus on the business logic! 🤩
4
+
5
+ ## What's the Buzz About CodeDesignPlus.Net.Microservice? 🤔
6
+
7
+ `CodeDesignPlus.Net.Microservice` is like your "starter kit" for building modern .NET microservices. It's a starting point that promotes separation of responsibilities, maintainability, and scalability. Forget tedious configurations, as it includes a well-defined project structure, default settings, and utility libraries. In short, it's the solid foundation you need to develop robust microservices quickly and efficiently. 😎
8
+
9
+ ## A Journey into the World of Domain-Driven Design (DDD) 🗺️
10
+
11
+ Before you start using the generator, it's important to know some key concepts of DDD:
12
+
13
+ * **Domain:** It's the "world" of your software, the area of knowledge it operates on. Think of the domain as your business context with its own rules. For example, in an e-commerce platform, the domain might be "order management" or "product administration."
14
+ * **Aggregate:** A cluster of entities treated as a unit, with a root entity acting as the "entry point." Aggregates are responsible for maintaining consistency within their boundaries. An order with its order lines is a good example.
15
+ * **Entity:** An object with its own identity, persisting over time and having a defined lifecycle. Each entity has a unique identifier. A user with their name, email, and other details is an entity.
16
+ * **Value Object:** An object without its own identity, defined by its attributes. They are immutable and compared by value. An address or a currency are perfect examples.
17
+ * **Domain Event:** A notification of something that has happened in the domain. They are immutable and represent historical facts. Examples include "OrderCreated" or "UserRegistered."
18
+ * **Repository:** A mechanism that "hides" access to persistent data. It provides an interface for your application to interact with the database without worrying about technical details.
19
+ * **Command:** An intention to perform an action that changes the system's state. These are the orders you give, such as "CreateOrder" or "UpdateUser."
20
+ * **Query:** A request to get information from the system without modifying anything. For example, "GetUserById" or "FindProductsByName."
21
+
22
+ ## Configuration Flags: Customize Your Microservice! 🛠️
23
+
24
+ | Flag | Description |
25
+ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
26
+ | `--organization` | The name of your organization—the base of your namespace! |
27
+ | `--microservice` | The name of your microservice—the heart of your project! |
28
+ | `--description` | A detailed description—so everyone understands its purpose! |
29
+ | `--contact-name` | The name of the contact person—the one who always has the answers! |
30
+ | `--contact-email` | The contact email—the way to communicate with the responsible person! |
31
+ | `--vault` | The name of the vault for managing secrets—your microservice's safe! |
32
+ | `--is-crud` | Indicates whether your microservice will be a CRUD—the easy path for data management! |
33
+ | `--aggregate` | The name of the root aggregate—the foundation of your domain! |
34
+ | `--enable-grpc` | Enables the gRPC API—communication at the speed of light! |
35
+ | `--enable-async-worker` | Enables an asynchronous worker—for background tasks without stress! |
36
+ | `--consumer-name` | The name of the event consumer—the one who always keeps track of everything! |
37
+ | `--consumer-aggregate` | The aggregate the consumer belongs to—context is key! |
38
+ | `--consumer-action` | The action to be performed by the consumer upon receiving an event—respond to the action! |
39
+ | `--domain-events` | A comma-separated list of domain events—your microservice's communication! |
40
+ | `--entities` | A comma-separated list of entities—objects with identity! |
41
+ | `--commands` | A comma-separated list of commands—actions that change the system! |
42
+ | `--queries` | A comma-separated list of queries—requests that fetch information! |
43
+ | `--repository` | The name of the aggregate for which the repository is created or consulted—access to your data! |
44
+ | `--controller` | The name of the controller—the entry point to your microservice! |
45
+ | `--proto-name` | The base name of the `.proto` file—the definition of your gRPC API! |
46
+ | `--valueObjects` | A comma-separated list of value object names—objects without identity! |
47
+ | `--dataTransferObject` | A comma-separated list of DTO names—the shape of the data as it travels! |
48
+
49
+ ## Available Commands: Your Guide in Development! 🚀
50
+
51
+ | Command | Description | Main Options |
52
+ | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
53
+ | `yo codedesignplus:microservice microservice` | Creates the base structure of a new microservice. Choose between a CRUD or custom pattern. | `--organization`, `--microservice`, `--description`, `--contact-name`, `--contact-email`, `--vault`, `--is-crud`, `--aggregate`, `--enable-grpc`, `--enable-async-worker`, `--consumer-name`, `--consumer-aggregate`, `--consumer-action`, `--domain-events`, `--entities`, `--commands`, `--queries` |
54
+ | `yo codedesignplus:microservice aggregate` | Creates a new aggregate within an existing microservice. | `--organization`, `--microservice`, `--aggregate` |
55
+ | `yo codedesignplus:microservice entity` | Creates one or more entities. | `--organization`, `--microservice`, `--entities` |
56
+ | `yo codedesignplus:microservice valueObject` | Creates one or more value objects. | `--organization`, `--microservice`, `--valueObjects` |
57
+ | `yo codedesignplus:microservice domainEvent`| Creates one or more domain events associated with an aggregate. | `--organization`, `--microservice`, `--aggregate`, `--domainEvents` |
58
+ | `yo codedesignplus:microservice repository` | Creates a repository for a specific aggregate. | `--organization`, `--microservice`, `--repository` |
59
+ | `yo codedesignplus:microservice controller` | Creates a controller to handle incoming requests. | `--organization`, `--microservice`, `--controller` |
60
+ | `yo codedesignplus:microservice proto` | Creates a `.proto` file for a gRPC service. | `--organization`, `--microservice`, `--proto-name` |
61
+ | `yo codedesignplus:microservice consumer` | Creates a consumer that reacts to domain events. | `--organization`, `--microservice`, `--consumer-name`, `--consumer-aggregate`, `--consumer-action` |
62
+ | `yo codedesignplus:microservice query` | Creates one or more queries to retrieve data without modifying the state. | `--organization`, `--microservice`, `--aggregate`, `--repository`, `--queries` |
63
+ | `yo codedesignplus:microservice command` | Creates one or more commands to perform actions that change the system state. | `--organization`, `--microservice`, `--aggregate`, `--repository`, `--commands` |
64
+ | `yo codedesignplus:microservice dto` | Creates one or more Data Transfer Objects (DTOs) to transfer data. | `--organization`, `--microservice`, `--aggregate`, `--dataTransferObject` |
65
+ | `yo codedesignplus:microservice grpc` | Creates a gRPC project. | `--organization`, `--microservice` |
66
+ | `yo codedesignplus:microservice asyncWorker`| Creates an async worker project. | `--organization`, `--microservice` |
67
+
68
+ ### 1. Creating a Microservice: The Beginning of It All!
69
+
70
+ `yo codedesignplus:microservice microservice`
71
+
72
+ This is the starting point for your new microservice. You can choose between a **CRUD** or **Custom** microservice, each with its own magic and design patterns.
73
+
74
+ #### CRUD Microservice: Straight to the Point!
75
+
76
+ A CRUD microservice focuses on managing data: create, read, update, and delete. It's ideal for scenarios where data persistence is the main concern.
77
+
78
+ ```bash
79
+ yo codedesignplus:microservice microservice \
80
+ --organization acme \
81
+ --microservice users \
82
+ --description "Microservice to manage platform users." \
83
+ --contact-name "Jane Doe" \
84
+ --contact-email "jane.doe@example.com" \
85
+ --vault vault-acme \
86
+ --is-crud \
87
+ --aggregate user \
88
+ --enable-grpc \
89
+ --enable-async-worker \
90
+ --consumer-name userRegistered \
91
+ --consumer-aggregate user \
92
+ --consumer-action send-welcome-email
93
+ ```
94
+
95
+ **Note:** The REST entrypoint is created by default when creating a microservice.
96
+
97
+ #### Custom Microservice: Maximum Flexibility!
98
+
99
+ A custom microservice is for complex business logic and events, not just CRUD operations. It's perfect if the workflow is more important than data storage.
100
+
101
+ ```bash
102
+ yo codedesignplus:microservice microservice \
103
+ --organization acme \
104
+ --microservice inventory \
105
+ --description "Microservice to manage product inventory." \
106
+ --contact-name "John Smith" \
107
+ --contact-email "john.smith@example.com" \
108
+ --vault vault-acme \
109
+ --aggregate product \
110
+ --enable-grpc \
111
+ --enable-async-worker \
112
+ --consumer-name orderCreated \
113
+ --consumer-aggregate order \
114
+ --consumer-action update-stock \
115
+ --domain-events "ProductCreated,ProductUpdated,ProductRemoved" \
116
+ --entities Product,Category \
117
+ --commands CreateProduct,UpdateProduct,RemoveProduct \
118
+ --queries FindProductById,FindProductsByCategory
119
+ ```
120
+
121
+ **Note:** The flags `--organization`, `--microservice`, `--description`, `--contact-name`, `--contact-email`, and `--vault` are optional after the initial creation, as they are stored in `archetype.json`.
122
+
123
+ ### 2. Creating an Aggregate: Organizing Your Domain!
124
+
125
+ `yo codedesignplus:microservice aggregate`
126
+
127
+ Creates a new aggregate in your microservice. Aggregates are key in DDD—they maintain the consistency of your entities!
128
+
129
+ ```bash
130
+ yo codedesignplus:microservice aggregate \
131
+ --organization acme \
132
+ --microservice users \
133
+ --aggregate UserProfile
134
+ ```
135
+
136
+ ### 3. Creating an Entity: Giving Identity to Your Objects!
137
+
138
+ `yo codedesignplus:microservice entity`
139
+
140
+ Creates one or more entities. These are objects with identity that can change state!
141
+
142
+ ```bash
143
+ yo codedesignplus:microservice entity \
144
+ --organization acme \
145
+ --microservice inventory \
146
+ --entities Product,Category
147
+ ```
148
+
149
+ ### 4. Creating a Value Object: Objects Without Identity!
150
+
151
+ `yo codedesignplus:microservice valueObject`
152
+
153
+ Creates one or more value objects. They are immutable and defined by their attributes!
154
+
155
+ ```bash
156
+ yo codedesignplus:microservice valueObject \
157
+ --organization acme \
158
+ --microservice users \
159
+ --valueObjects Email,Address
160
+ ```
161
+
162
+ ### 5. Creating a Domain Event: Communicating What Happens!
163
+
164
+ `yo codedesignplus:microservice domainEvent`
165
+
166
+ Creates one or more domain events. These are representations of something that happened in your domain!
167
+
168
+ ```bash
169
+ yo codedesignplus:microservice domainEvent \
170
+ --organization acme \
171
+ --microservice orders \
172
+ --aggregate Order \
173
+ --domainEvents OrderCreated,OrderShipped
174
+ ```
175
+
176
+ ### 6. Creating a Repository: Access to Your Data!
177
+
178
+ `yo codedesignplus:microservice repository`
179
+
180
+ Creates a repository for a specific aggregate. It's the interface to access persistent data!
181
+
182
+ ```bash
183
+ yo codedesignplus:microservice repository \
184
+ --organization acme \
185
+ --microservice products \
186
+ --repository Product
187
+ ```
188
+
189
+ ### 7. Creating a Controller: Managing Requests!
190
+
191
+ `yo codedesignplus:microservice controller`
192
+
193
+ Creates a controller to manage incoming requests (HTTP or gRPC).
194
+
195
+ ```bash
196
+ yo codedesignplus:microservice controller \
197
+ --organization acme \
198
+ --microservice users \
199
+ --controller UserProfileController
200
+ ```
201
+
202
+ ### 8. Creating a Proto: Defining Your gRPC API!
203
+
204
+ `yo codedesignplus:microservice proto`
205
+
206
+ Creates a `.proto` file for a gRPC service. It defines the messages and services for communication!
207
+
208
+ ```bash
209
+ yo codedesignplus:microservice proto \
210
+ --organization acme \
211
+ --microservice products \
212
+ --proto-name ProductService
213
+ ```
214
+
215
+ ### 9. Creating an Event Consumer: Reacting to Changes!
216
+
217
+ `yo codedesignplus:microservice consumer`
218
+
219
+ Creates a consumer that reacts to events published by other microservices.
220
+
221
+ ```bash
222
+ yo codedesignplus:microservice consumer \
223
+ --organization acme \
224
+ --microservice notifications \
225
+ --consumer-name OrderCreated \
226
+ --consumer-aggregate Order \
227
+ --consumer-action send-order-confirmation
228
+ ```
229
+
230
+ ### 10. Creating a Query: Getting Information Without Changing Anything!
231
+
232
+ `yo codedesignplus:microservice query`
233
+
234
+ Creates one or more queries to get information from the system without modifying its state!
235
+
236
+ ```bash
237
+ yo codedesignplus:microservice query \
238
+ --organization acme \
239
+ --microservice products \
240
+ --aggregate Product \
241
+ --repository Product \
242
+ --queries FindProductById,FindProductsByName
243
+ ```
244
+
245
+ ### 11. Creating a Command: Changing the System State!
246
+
247
+ `yo codedesignplus:microservice command`
248
+
249
+ Creates one or more commands to perform actions that change the system's state.
250
+
251
+ ```bash
252
+ yo codedesignplus:microservice command \
253
+ --organization acme \
254
+ --microservice orders \
255
+ --aggregate Order \
256
+ --repository Order \
257
+ --commands CreateOrder,CancelOrder
258
+ ```
259
+
260
+ ### 12. Creating Data Transfer Objects (DTOs): The Traveling Data!
261
+
262
+ `yo codedesignplus:microservice dto`
263
+
264
+ Creates one or more DTOs to transfer data between layers or microservices.
265
+
266
+ ```bash
267
+ yo codedesignplus:microservice dto \
268
+ --organization acme \
269
+ --microservice orders \
270
+ --aggregate Order \
271
+ --dataTransferObject OrderDto,OrderSummaryDto
272
+ ```
273
+
274
+ ### 13. Creating a gRPC Project: Adding Fast Communication!
275
+
276
+ `yo codedesignplus:microservice grpc`
277
+
278
+ Creates a gRPC project within your microservice if you didn't do it initially!
279
+
280
+ ```bash
281
+ yo codedesignplus:microservice grpc \
282
+ --organization acme \
283
+ --microservice products
284
+ ```
285
+
286
+ ### 14. Creating an Async Worker Project: Background Tasks!
287
+
288
+ `yo codedesignplus:microservice asyncWorker`
289
+
290
+ Creates an asynchronous worker project within your microservice for tasks that don't need to wait!
291
+
292
+ ```bash
293
+ yo codedesignplus:microservice asyncWorker \
294
+ --organization acme \
295
+ --microservice notifications
296
+ ```
297
+
298
+ ## Internal Structure of the Generator and Contributions 🤝
299
+
300
+ ### How Does This Generator Work Internally? 🤔
301
+
302
+ The `generator-codedesignplus` is built using Yeoman, a tool for creating code generators. Here's a summary of its structure:
303
+
304
+ 1. **Entry Point (`index.mjs`):**
305
+ * The "brain" of the generator.
306
+ * Imports the `Core`, `Utils`, and `DotNet` classes from their respective files.
307
+ * Retrieves command-line arguments (template, organization, microservice, etc.).
308
+ * Executes methods to generate files, depending on the resource (aggregate, command, entity, etc.).
309
+
310
+ 2. **`Core` Class (`core/core.mjs`):**
311
+ * Manages arguments, options, and initial questions.
312
+ * Maps generators to resources (aggregate, command, entity, etc.).
313
+ * Displays help in the console.
314
+ * Decides which generator to use, based on the template option.
315
+
316
+ 3. **`Utils` Class (`core/utils.mjs`):**
317
+ * Utility functions for the generator.
318
+ * Reads and writes configuration information (`archetype.json`).
319
+ * Transforms files (replaces names, namespaces, etc.).
320
+ * Manages namespaces, adds `usings`, and generates files with `generateFiles`.
321
+
322
+ 4. **`DotNet` Class (`core/dotnet.mjs`):**
323
+ * Logic to perform operations related to .NET.
324
+ * Removes projects from a microservice (executed when creating the microservice).
325
+
326
+ 5. **Specific Generators (`core/*.mjs`):**
327
+ * Generators for components (e.g., `aggregate.mjs`, `command.mjs`).
328
+ * Define specific arguments and options.
329
+ * Implement logic to generate files (using templates and `Utils`).
330
+
331
+ 6. **Templates (`templates/`):**
332
+ * Base files for generating code.
333
+ * Placeholders (e.g., `CodeDesignPlus.Net.Microservice`, `Order`) are dynamically replaced.
334
+ * The structure reflects a .NET project with the `CodeDesignPlus.Net.Microservice` archetype.
335
+
336
+ 7. **Types (`types/`):**
337
+ * Definitions of classes/interfaces for data type management within the generator.
338
+
339
+ 8. **`package.json`:**
340
+ * Project dependencies, development scripts, and package information.
341
+ * Includes `yeoman-generator`, `find-up`, etc.
342
+
343
+ ### How to Contribute to Development? 🤝
344
+
345
+ We love collaboration! If you want to contribute, follow these steps:
346
+
347
+ 1. **Clone the repository:**
348
+
349
+ ```bash
350
+ git clone https://github.com/codedesignplus/generator-codedesignplus.git
351
+ cd generator-codedesignplus
352
+ ```
353
+
354
+ 2. **Install the dependencies:**
355
+
356
+ ```bash
357
+ npm install
358
+ ```
359
+
360
+ 3. **Make your changes:**
361
+ * Create a separate branch.
362
+ * Modify files in `generators`, `templates`, and `types`.
363
+ * Understand the logic (`index.mjs`, `core/core.mjs`, `core/utils.mjs`).
364
+ * If you add templates, update the generators' logic.
365
+
366
+ 4. **Run tests:**
367
+ * Run tests with `npm test`.
368
+ * Create or modify tests as needed.
369
+
370
+ 5. **Ensure your code follows project style:**
371
+ * Execute `npm run lint`, `npm run format` or `npm run prettier`
372
+
373
+ 6. **Create a Pull Request:**
374
+ * Upload your changes to your fork.
375
+ * Create a pull request to the `main` branch.
376
+ * Describe your changes clearly.
377
+
378
+ ### Detailed File Structure 📁
379
+
380
+ Here's a summary of the generator's file structure:
381
+
382
+ ```
383
+ generator-codedesignplus/
384
+ ├── generators/ # Generator logic
385
+ │ ├── core/ # Central logic
386
+ │ │ ├── aggregate.mjs # Aggregate generator
387
+ │ │ ├── appsettings.mjs # Appsettings generator
388
+ │ │ ├── asyncWorker.mjs # Async Worker generator
389
+ │ │ ├── command.mjs # Command generator
390
+ │ │ ├── consumer.mjs # Consumer generator
391
+ │ │ ├── controller.mjs # Controller generator
392
+ │ │ ├── core.mjs # Core class
393
+ │ │ ├── dataTransferObject.mjs # DTO generator
394
+ │ │ ├── domainEvent.mjs # Domain event generator
395
+ │ │ ├── dotnet.mjs # Utilities for .Net
396
+ │ │ ├── entity.mjs # Entity generator
397
+ │ │ ├── errors.mjs # Errors generator
398
+ │ │ ├── grpc.mjs # gRPC generator
399
+ │ │ ├── microservice.mjs # Microservice generator
400
+ │ │ ├── proto.mjs # .proto file generator
401
+ │ │ ├── query.mjs # Query generator
402
+ │ │ ├── repository.mjs # Repository generator
403
+ │ │ ├── utils.mjs # Utilities class
404
+ │ │ ├── valueObject.mjs # Value object generator
405
+ │ │ └── xml.mjs # XML Utilities
406
+ │ ├── index.mjs # Entry point
407
+ │ ├── templates/ # File templates
408
+ │ │ ├── aggregate/ # Aggregate templates
409
+ │ │ ├── command/ # Command templates
410
+ │ │ ├── consumer/ # Consumer templates
411
+ │ │ ├── controller/ # Controller templates
412
+ │ │ ├── data-transfer-object/ # DTO templates
413
+ │ │ ├── domain-event/ # Domain event templates
414
+ │ │ ├── entity/ # Entity templates
415
+ │ │ ├── errors/ # Errors templates
416
+ │ │ ├── grpc/ # gRPC templates
417
+ │ │ ├── microservice/ # Microservice templates
418
+ │ │ ├── others/ # Other templates
419
+ │ │ ├── query/ # Query templates
420
+ │ │ ├── repository/ # Repository templates
421
+ │ │ └── value-object/ # Value object templates
422
+ │ └── types/ # Type definitions
423
+ │ ├── aggregate.mjs
424
+ │ ├── appsettings.mjs
425
+ │ ├── base.mjs
426
+ │ ├── command.mjs
427
+ │ ├── consumer.mjs
428
+ │ ├── controller.mjs
429
+ │ ├── dataTransferObject.mjs
430
+ │ ├── domainEvents.mjs
431
+ │ ├── entity.mjs
432
+ │ ├── index.mjs
433
+ │ ├── proto.mjs
434
+ │ ├── query.mjs
435
+ │ ├── repository.mjs
436
+ │ └── valueObject.mjs
437
+ ├── package.json # Project configuration
438
+ └── README.md # This file
439
+ ```
440
+
441
+ ## Usage 🚀
442
+
443
+ 1. **Install Yeoman and the generator:**
444
+
445
+ ```bash
446
+ npm install -g yo
447
+ npm install -g generator-codedesignplus
448
+ ```
449
+
450
+ 2. **Run the commands:**
451
+
452
+ Go to the folder where you want to generate the microservice and run one of the `yo codedesignplus:microservice` commands shown above.
453
+
454
+ And that's it! We hope this generator is a great help to you on your journey as a microservice developer. If you have any questions, don't hesitate to contact us or create an issue in the repository! 😊
@@ -0,0 +1,22 @@
1
+ import Generator from 'yeoman-generator';
2
+
3
+ export default class extends Generator {
4
+
5
+ async prompting() {
6
+ const answers = await this.prompt([{
7
+ type: 'input',
8
+ name: 'name',
9
+ message: 'Your project name',
10
+ default: this.appname // Default to current folder name
11
+ }]);
12
+ this.log('app name', answers.name);
13
+ }
14
+
15
+ writing() {
16
+ this.fs.copyTpl(
17
+ this.templatePath('index.html'),
18
+ this.destinationPath('index.html'),
19
+ { title: 'Templating with Yeoman' }
20
+ );
21
+ }
22
+ };
@@ -0,0 +1,25 @@
1
+ import path from 'path';
2
+
3
+ export default class AggregateGenerator {
4
+
5
+ constructor(utils, generator) {
6
+ this._utils = utils;
7
+ this._generator = generator;
8
+ this.name = 'aggregate';
9
+ }
10
+
11
+ async generate(options) {
12
+ await this._generator.fs.copyTplAsync(
13
+ this._generator.templatePath('aggregate/ItemAggregate.cs'),
14
+ this._generator.destinationPath(path.join(options.paths.src.domain, options.aggregate.file)),
15
+ {
16
+ ns: `${options.solution}.Domain`,
17
+ name: options.aggregate.fullname
18
+ }
19
+ );
20
+ }
21
+
22
+ getArguments() {
23
+ this._generator.option('aggregate', { type: String, alias: 'a', required: true, description: 'The name of the aggregate to create' });
24
+ }
25
+ }
@@ -0,0 +1,73 @@
1
+ import path from 'path';
2
+
3
+ export default class AppSettingsGenerator {
4
+
5
+ constructor(utils, generator) {
6
+ this._utils = utils;
7
+ this._generator = generator;
8
+ this.name = 'appsettings';
9
+ }
10
+
11
+ async generate(options, sources = []) {
12
+
13
+ if(sources.length === 0) {
14
+ sources = [
15
+ options.paths.src.rest,
16
+ options.paths.src.grpc,
17
+ options.paths.src.asyncWorker
18
+ ];
19
+ }
20
+
21
+ const destination = this._generator.destinationPath();
22
+
23
+ sources.forEach(source => {
24
+
25
+ const appSettingsFile = path.join(destination, source, 'appsettings.json');
26
+
27
+ const json = this._generator.fs.readJSON(appSettingsFile, {});
28
+
29
+ json.Core.AppName = options.appSettings.appName;
30
+ json.Core.Description = options.appSettings.description;
31
+ json.Core.Business = options.appSettings.business;
32
+ json.Core.Contact.Name = options.appSettings.contact.name;
33
+ json.Core.Contact.Email = options.appSettings.contact.email;
34
+ json.Vault.Solution = options.appSettings.vault;
35
+ json.Vault.AppName = options.appSettings.appName;
36
+ json.Mongo.Database = options.appSettings.database;
37
+
38
+ this._generator.fs.writeJSON(appSettingsFile, json);
39
+ });
40
+
41
+ try {
42
+ this.updateConfigVault(path.join('tools', 'vault','config-vault.ps1'), options);
43
+ this.updateConfigVault(path.join('tools', 'vault','config-vault.sh'), options);
44
+ } catch (error) {
45
+ console.log('The vault configuration could not be updated.');
46
+ console.log(error);
47
+ }
48
+ }
49
+
50
+ updateConfigVault(file, options) {
51
+ const configFile = this._generator.destinationPath(file);
52
+
53
+ let config = this._generator.fs.read(configFile);
54
+
55
+ const vault = options.appSettings.vault.toLowerCase();
56
+
57
+ config = config.replace(/\bvault-keyvalue\b/g, `${vault}-keyvalue`);
58
+ config = config.replace(/\bvault-database\b/g, `${vault}-database`);
59
+ config = config.replace(/\bvault-rabbitmq\b/g, `${vault}-rabbitmq`);
60
+ config = config.replace(/\bvault-transit\b/g, `${vault}-transit`);
61
+ config = config.replace(/\bvault-approle\b/g, `${vault}-approle`);
62
+ config = config.replace(/ms-archetype/g, options.appSettings.appName);
63
+
64
+ this._generator.fs.write(configFile, config);
65
+ }
66
+
67
+ getArguments() {
68
+ this._generator.option('description', { type: String, alias: 'd', required: true, description: 'A detailed description of the microservice providing clear context about its purpose.' });
69
+ this._generator.option('contact-name', { type: String, alias: 'cn', required: true, description: 'Name of the contact person responsible for the microservice.' });
70
+ this._generator.option('contact-email', { type: String, alias: 'ce', required: true, description: 'Email of the contact person responsible.' });
71
+ this._generator.option('vault', { type: String, alias: 'v', required: true, description: 'The name of the vault for managing secrets and configurations.' });
72
+ }
73
+ }