generator-jhipster 7.9.2 → 7.9.3

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 (214) hide show
  1. package/cli/environment-builder.js +15 -1
  2. package/generators/app/index.js +12 -1
  3. package/generators/bootstrap/index.js +33 -1
  4. package/generators/ci-cd/templates/circle.yml.ejs +3 -13
  5. package/generators/client/files-angular.js +1 -1
  6. package/generators/client/files-react.js +5 -2
  7. package/generators/client/files-vue.js +3 -2
  8. package/generators/client/templates/angular/jest.conf.js.ejs +6 -3
  9. package/generators/client/templates/angular/package.json +18 -18
  10. package/generators/client/templates/angular/package.json.ejs +3 -7
  11. package/generators/client/templates/angular/src/main/webapp/app/admin/admin-routing.module.ts.ejs +1 -1
  12. package/generators/client/templates/angular/src/main/webapp/app/admin/health/health.model.ts.ejs +1 -1
  13. package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/update/user-management-update.component.ts.ejs +17 -15
  14. package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management.model.ts.ejs +2 -2
  15. package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management.route.ts.ejs +4 -4
  16. package/generators/client/templates/angular/src/main/webapp/app/core/request/request-util.ts.ejs +4 -2
  17. package/generators/client/templates/angular/src/main/webapp/app/core/util/data-util.service.ts.ejs +1 -1
  18. package/generators/client/templates/angular/src/main/webapp/app/core/util/parse-links.service.ts.ejs +1 -1
  19. package/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.html.ejs +1 -1
  20. package/generators/client/templates/angular/src/main/webapp/app/shared/filter/filter.component.html.ejs +8 -6
  21. package/generators/client/templates/angular/src/main/webapp/app/shared/filter/filter.component.ts.ejs +6 -11
  22. package/generators/client/templates/angular/src/main/webapp/app/shared/filter/filter.model.spec.ts.ejs +227 -25
  23. package/generators/client/templates/angular/src/main/webapp/app/shared/filter/filter.model.ts.ejs +104 -43
  24. package/generators/client/templates/angular/src/main/webapp/content/scss/global.scss.ejs +8 -0
  25. package/generators/client/templates/angular/tsconfig.json.ejs +0 -1
  26. package/generators/client/templates/angular/tsconfig.spec.json.ejs +2 -3
  27. package/generators/client/templates/angular/webpack/webpack.microfrontend.js.ejs +0 -3
  28. package/generators/client/templates/common/package.json +4 -4
  29. package/generators/client/templates/common/src/main/webapp/swagger-ui/index.html.ejs +1 -1
  30. package/generators/client/templates/react/jest.conf.js.ejs +2 -2
  31. package/generators/client/templates/react/package.json +23 -23
  32. package/generators/client/templates/react/package.json.ejs +3 -7
  33. package/generators/client/templates/react/src/main/webapp/app/config/store.ts.ejs +0 -6
  34. package/generators/client/templates/react/src/main/webapp/app/modules/administration/administration.reducer.spec.ts.ejs +7 -7
  35. package/generators/client/templates/react/src/main/webapp/app/modules/administration/administration.reducer.ts.ejs +6 -6
  36. package/generators/client/templates/react/src/main/webapp/app/modules/administration/index.tsx.ejs +2 -2
  37. package/generators/client/templates/react/src/main/webapp/app/shared/layout/menus/admin.tsx.ejs +1 -1
  38. package/generators/client/templates/react/src/main/webapp/app/shared/reducers/authentication.spec.ts.ejs +17 -8
  39. package/generators/client/templates/react/src/main/webapp/app/shared/reducers/authentication.ts.ejs +1 -1
  40. package/generators/client/templates/react/src/main/webapp/app/shared/reducers/locale.spec.ts.ejs +176 -19
  41. package/generators/client/templates/react/src/main/webapp/app/shared/reducers/locale.ts.ejs +46 -13
  42. package/generators/client/templates/react/webpack/webpack.microfrontend.js.jhi.react.ejs +1 -1
  43. package/generators/client/templates/vue/package.json +17 -17
  44. package/generators/client/templates/vue/package.json.ejs +3 -7
  45. package/generators/client/templates/vue/src/main/webapp/app/core/jhi-navbar/jhi-navbar.component.ts.ejs +2 -1
  46. package/generators/client/templates/vue/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue.ejs +1 -1
  47. package/generators/client/templates/vue/src/main/webapp/app/main.ts.ejs +2 -2
  48. package/generators/client/templates/vue/src/main/webapp/app/router/admin.ts.ejs +2 -2
  49. package/generators/client/templates/vue/src/test/javascript/e2e/modules/administration/administration.spec.ts.ejs +1 -1
  50. package/generators/client/templates/vue/src/test/javascript/e2e/page-objects/administration-page.ts.ejs +1 -1
  51. package/generators/client/templates/vue/src/test/javascript/e2e/page-objects/navbar-page.ts.ejs +2 -2
  52. package/generators/client/templates/vue/src/test/javascript/jest.conf.js.ejs +5 -6
  53. package/generators/client/templates/vue/src/test/javascript/spec/app/account/account.service.spec.ts.ejs +4 -0
  54. package/generators/client/templates/vue/src/test/javascript/spec/app/shared/alert/alert.service.spec.ts.ejs +106 -3
  55. package/generators/client/templates/vue/src/test/javascript/spec/app/shared/config/axios-interceptor.spec.ts.ejs +12 -0
  56. package/generators/client/templates/vue/src/test/javascript/spec/app/shared/config/formatter.spec.ts.ejs +6 -0
  57. package/generators/client/templates/vue/src/test/javascript/spec/app/shared/sort/sorts.spec.ts.ejs +10 -0
  58. package/generators/client/templates/vue/webpack/webpack.common.js.ejs +1 -1
  59. package/generators/client/templates/vue/webpack/webpack.dev.js.ejs +2 -2
  60. package/generators/common/files.js +5 -4
  61. package/generators/common/templates/package.json +1 -1
  62. package/generators/common/templates/sonar-project.properties.ejs +19 -11
  63. package/generators/cypress/index.js +1 -1
  64. package/generators/docker-compose/templates/README-DOCKER-COMPOSE.md.ejs +3 -3
  65. package/generators/docker-compose/templates/docker-compose.yml.ejs +1 -1
  66. package/generators/docker-compose/templates/realm-config/jhipster-realm.json.ejs +32 -14
  67. package/generators/entity/index.js +4 -3
  68. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/detail/entity-management-detail.component.html.ejs +1 -1
  69. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.html.ejs +18 -6
  70. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.spec.ts.ejs +1 -1
  71. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.ts.ejs +23 -19
  72. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/service/entity.service.spec.ts.ejs +3 -1
  73. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/service/entity.service.ts.ejs +1 -1
  74. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-form.service.ts.ejs +1 -1
  75. package/generators/entity-client/templates/vue/src/main/webapp/app/entities/entity.component.ts.ejs +2 -2
  76. package/generators/entity-server/templates/src/main/java/package/common/delete_template.ejs +7 -3
  77. package/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs +2 -2
  78. package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.ejs +15 -5
  79. package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.spring_data_persistable.ejs +8 -1
  80. package/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs +5 -0
  81. package/generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs +4 -4
  82. package/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs +6 -4
  83. package/generators/entity-server/templates/src/main/java/package/service/criteria/EntityCriteria.java.ejs +3 -26
  84. package/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs +1 -0
  85. package/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs +1 -1
  86. package/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs +33 -28
  87. package/generators/generate-blueprint/constants.mjs +46 -6
  88. package/generators/generate-blueprint/files.mjs +7 -5
  89. package/generators/generate-blueprint/generator.mjs +73 -19
  90. package/generators/generate-blueprint/templates/generators/generator/generator.spec.mjs.ejs +1 -1
  91. package/generators/generator-base-blueprint.js +23 -1
  92. package/generators/generator-base-entities.cjs +5 -1
  93. package/generators/generator-base.js +82 -15
  94. package/generators/generator-constants.js +17 -23
  95. package/generators/kubernetes/templates/deployment.yml.ejs +1 -1
  96. package/generators/kubernetes/templates/ingress.yml.ejs +1 -1
  97. package/generators/kubernetes/templates/istio/gateway.yml.ejs +1 -1
  98. package/generators/kubernetes/templates/kustomize/kustomization.yml.ejs +1 -1
  99. package/generators/kubernetes/templates/service.yml.ejs +1 -1
  100. package/generators/kubernetes-knative/templates/istio/gateway.yml.ejs +1 -1
  101. package/generators/kubernetes-knative/templates/service.yml.ejs +3 -3
  102. package/generators/languages/templates/src/main/webapp/i18n/al/health.json.ejs +1 -1
  103. package/generators/languages/templates/src/main/webapp/i18n/ar-ly/health.json.ejs +1 -1
  104. package/generators/languages/templates/src/main/webapp/i18n/bg/health.json.ejs +1 -1
  105. package/generators/languages/templates/src/main/webapp/i18n/bn/health.json.ejs +1 -1
  106. package/generators/languages/templates/src/main/webapp/i18n/by/health.json.ejs +1 -1
  107. package/generators/languages/templates/src/main/webapp/i18n/ca/health.json.ejs +1 -1
  108. package/generators/languages/templates/src/main/webapp/i18n/cs/health.json.ejs +1 -1
  109. package/generators/languages/templates/src/main/webapp/i18n/da/health.json.ejs +1 -1
  110. package/generators/languages/templates/src/main/webapp/i18n/de/health.json.ejs +1 -1
  111. package/generators/languages/templates/src/main/webapp/i18n/el/activate.json.ejs +1 -1
  112. package/generators/languages/templates/src/main/webapp/i18n/el/health.json.ejs +1 -1
  113. package/generators/languages/templates/src/main/webapp/i18n/el/password.json +1 -1
  114. package/generators/languages/templates/src/main/webapp/i18n/el/register.json +3 -3
  115. package/generators/languages/templates/src/main/webapp/i18n/el/tracker.json +1 -1
  116. package/generators/languages/templates/src/main/webapp/i18n/el/user-management.json +9 -9
  117. package/generators/languages/templates/src/main/webapp/i18n/en/health.json.ejs +1 -1
  118. package/generators/languages/templates/src/main/webapp/i18n/es/health.json.ejs +1 -1
  119. package/generators/languages/templates/src/main/webapp/i18n/et/health.json.ejs +1 -1
  120. package/generators/languages/templates/src/main/webapp/i18n/fa/health.json.ejs +1 -1
  121. package/generators/languages/templates/src/main/webapp/i18n/fi/health.json.ejs +1 -1
  122. package/generators/languages/templates/src/main/webapp/i18n/fr/health.json.ejs +1 -1
  123. package/generators/languages/templates/src/main/webapp/i18n/gl/health.json.ejs +1 -1
  124. package/generators/languages/templates/src/main/webapp/i18n/hi/health.json.ejs +1 -1
  125. package/generators/languages/templates/src/main/webapp/i18n/hr/health.json.ejs +1 -1
  126. package/generators/languages/templates/src/main/webapp/i18n/hu/health.json.ejs +1 -1
  127. package/generators/languages/templates/src/main/webapp/i18n/hy/health.json.ejs +1 -1
  128. package/generators/languages/templates/src/main/webapp/i18n/in/health.json.ejs +1 -1
  129. package/generators/languages/templates/src/main/webapp/i18n/it/health.json.ejs +1 -1
  130. package/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs +1 -1
  131. package/generators/languages/templates/src/main/webapp/i18n/ko/health.json.ejs +1 -1
  132. package/generators/languages/templates/src/main/webapp/i18n/mr/health.json.ejs +1 -1
  133. package/generators/languages/templates/src/main/webapp/i18n/my/health.json.ejs +1 -1
  134. package/generators/languages/templates/src/main/webapp/i18n/nl/health.json.ejs +1 -1
  135. package/generators/languages/templates/src/main/webapp/i18n/pa/health.json.ejs +1 -1
  136. package/generators/languages/templates/src/main/webapp/i18n/pl/health.json.ejs +1 -1
  137. package/generators/languages/templates/src/main/webapp/i18n/pt-br/health.json.ejs +1 -1
  138. package/generators/languages/templates/src/main/webapp/i18n/pt-pt/health.json.ejs +1 -1
  139. package/generators/languages/templates/src/main/webapp/i18n/ro/health.json.ejs +1 -1
  140. package/generators/languages/templates/src/main/webapp/i18n/ru/health.json.ejs +1 -1
  141. package/generators/languages/templates/src/main/webapp/i18n/si/health.json.ejs +1 -1
  142. package/generators/languages/templates/src/main/webapp/i18n/sk/health.json.ejs +1 -1
  143. package/generators/languages/templates/src/main/webapp/i18n/sr/health.json.ejs +1 -1
  144. package/generators/languages/templates/src/main/webapp/i18n/sv/health.json.ejs +1 -1
  145. package/generators/languages/templates/src/main/webapp/i18n/ta/health.json.ejs +1 -1
  146. package/generators/languages/templates/src/main/webapp/i18n/te/health.json.ejs +1 -1
  147. package/generators/languages/templates/src/main/webapp/i18n/th/health.json.ejs +1 -1
  148. package/generators/languages/templates/src/main/webapp/i18n/tr/health.json.ejs +1 -1
  149. package/generators/languages/templates/src/main/webapp/i18n/ua/health.json.ejs +1 -1
  150. package/generators/languages/templates/src/main/webapp/i18n/uz-Latn-uz/health.json.ejs +1 -1
  151. package/generators/languages/templates/src/main/webapp/i18n/vi/health.json.ejs +1 -1
  152. package/generators/languages/templates/src/main/webapp/i18n/zh-cn/health.json.ejs +1 -1
  153. package/generators/languages/templates/src/main/webapp/i18n/zh-tw/health.json.ejs +1 -1
  154. package/generators/openshift/templates/deployment.yml.ejs +2 -2
  155. package/generators/server/cleanup-elasticsearch.js +5 -0
  156. package/generators/server/files.js +17 -8
  157. package/generators/server/index.js +0 -2
  158. package/generators/server/templates/build.gradle.ejs +6 -14
  159. package/generators/server/templates/gradle/profile_dev.gradle.ejs +1 -1
  160. package/generators/server/templates/gradle/profile_prod.gradle.ejs +1 -1
  161. package/generators/server/templates/gradle.properties.ejs +6 -4
  162. package/generators/server/templates/npmw.cmd +31 -29
  163. package/generators/server/templates/package.json.ejs +2 -2
  164. package/generators/server/templates/pom.xml.ejs +12 -23
  165. package/generators/server/templates/sql/common/src/test/java/package/config/MsSqlTestContainer.java.ejs +2 -3
  166. package/generators/server/templates/src/main/docker/app.yml.ejs +7 -1
  167. package/generators/server/templates/src/main/docker/config/realm-config/jhipster-realm.json.ejs +32 -14
  168. package/generators/server/templates/src/main/docker/jhipster-control-center.yml.ejs +1 -1
  169. package/generators/server/templates/src/main/docker/prometheus/prometheus.yml.ejs +1 -1
  170. package/generators/server/templates/src/main/java/package/Application.java.ejs +11 -4
  171. package/generators/server/templates/src/main/java/package/config/CRLFLogConverter.java.ejs +57 -0
  172. package/generators/server/templates/src/main/java/package/config/EurekaWorkaroundConfiguration.java.ejs +49 -0
  173. package/generators/server/templates/src/main/java/package/config/LoggingConfiguration.java.ejs +4 -4
  174. package/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs +17 -18
  175. package/generators/server/templates/src/main/java/package/config/SecurityConfiguration_reactive.java.ejs +13 -5
  176. package/generators/server/templates/src/main/java/package/domain/AbstractAuditingEntity.java.ejs +5 -6
  177. package/generators/server/templates/src/main/java/package/domain/User.java.ejs +1 -1
  178. package/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs +1 -1
  179. package/generators/server/templates/src/main/java/package/security/oauth2/CustomClaimConverter.java.ejs +13 -6
  180. package/generators/server/templates/src/main/java/package/service/dto/AdminUserDTO.java.ejs +3 -1
  181. package/generators/server/templates/src/main/java/package/service/dto/PasswordChangeDTO.java.ejs +5 -1
  182. package/generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs +3 -1
  183. package/generators/server/templates/src/main/java/package/web/rest/UserResource.java.ejs +15 -42
  184. package/generators/server/templates/src/main/java/package/web/rest/errors/BadRequestAlertException.java.ejs +1 -0
  185. package/generators/server/templates/src/main/java/package/web/rest/errors/EmailAlreadyUsedException.java.ejs +1 -0
  186. package/generators/server/templates/src/main/java/package/web/rest/errors/InvalidPasswordException.java.ejs +1 -0
  187. package/generators/server/templates/src/main/java/package/web/rest/errors/LoginAlreadyUsedException.java.ejs +1 -0
  188. package/generators/server/templates/src/main/resources/config/application-dev.yml.ejs +1 -1
  189. package/generators/server/templates/src/main/resources/config/application-prod.yml.ejs +2 -2
  190. package/generators/server/templates/src/main/resources/config/application.yml.ejs +4 -2
  191. package/generators/server/templates/src/main/resources/config/liquibase/master.xml.ejs +3 -8
  192. package/generators/server/templates/src/main/resources/logback-spring.xml.ejs +5 -0
  193. package/generators/server/templates/src/test/java/package/config/{ElasticsearchReactiveTestConfiguration.java.ejs → ElasticsearchTestConfiguration.java.ejs} +3 -3
  194. package/generators/server/templates/src/test/java/package/config/ElasticsearchTestContainer.java.ejs +1 -0
  195. package/generators/server/templates/src/test/java/package/config/JHipsterBlockHoundIntegration.java.ejs +3 -0
  196. package/generators/server/templates/src/test/java/package/config/TestContainersSpringContextCustomizerFactory.java.ejs +2 -2
  197. package/generators/sql-constants.js +5 -2
  198. package/generators/utils.js +43 -3
  199. package/generators/workspaces/index.js +2 -1
  200. package/jdl/exporters/jdl-exporter.js +6 -1
  201. package/jdl/jhipster/application-options.js +2 -1
  202. package/jdl/jhipster/binary-options.js +2 -2
  203. package/jdl/jhipster/default-application-options.js +11 -8
  204. package/jdl/jhipster/entity-options.js +1 -0
  205. package/jdl/jhipster/search-engine-types.js +1 -0
  206. package/lib/constants/priorities.cjs +16 -0
  207. package/lib/constants/priorities.mjs +1 -0
  208. package/lib/index.js +2 -0
  209. package/lib/support/base.cjs +2 -1
  210. package/package.json +7 -6
  211. package/utils/blueprint.js +10 -0
  212. package/utils/field.js +3 -1
  213. package/generators/client/templates/react/src/main/webapp/app/config/translation-middleware.ts.ejs +0 -58
  214. package/generators/server/templates/.npmrc.ejs +0 -1
@@ -19,7 +19,7 @@
19
19
  package <%= entityAbsolutePackage %>.web.rest;
20
20
 
21
21
  <%_
22
-
22
+ const fieldsToTest = fields.filter(field => !field.id && !field.autoGenerate && !field.transient);
23
23
  let mapsIdEntity;
24
24
  let mapsIdEntityInstance;
25
25
  let mapsIdRepoInstance;
@@ -104,7 +104,7 @@ import org.assertj.core.util.IterableUtil;
104
104
  import org.apache.commons.collections4.IterableUtils;
105
105
  import java.util.concurrent.TimeUnit;
106
106
  <%_ } _%>
107
- <%_ if (databaseTypeSql && reactive) { _%>
107
+ <%_ if ((databaseTypeSql && reactive) || searchEngineElasticsearch) { _%>
108
108
  import org.junit.jupiter.api.AfterEach;
109
109
  <%_ } _%>
110
110
  import org.junit.jupiter.api.BeforeEach;
@@ -246,7 +246,7 @@ import <%= entityAbsolutePackage %>.domain.enumeration.<%= field.fieldType %>;
246
246
  @WithMockUser
247
247
  class <%= entityClass %>ResourceIT {
248
248
  <%_
249
- for (field of fields.filter(field => !field.id && !field.transient)) {
249
+ for (field of fieldsToTest) {
250
250
  const defaultValueName = 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase();
251
251
  const updatedValueName = 'UPDATED_' + field.fieldNameUnderscored.toUpperCase();
252
252
  const smallerValueName = 'SMALLER_' + field.fieldNameUnderscored.toUpperCase();
@@ -487,7 +487,7 @@ if (field.fieldTypeString || field.blobContentTypeText) {
487
487
  <%_ if (fluentMethods) { _%>
488
488
  <%= persistClass %> <%= persistInstance %> = new <%= persistClass %>()<%_ if (reactive && databaseTypeSql && primaryKey.typeUUID && !isUsingMapsId) { _%>
489
489
  .<%= primaryKey.name %>(UUID.randomUUID())
490
- <%_ } _%><% for (field of fields.filter(field => !field.id && !field.transient)) { %>
490
+ <%_ } _%><% for (field of fieldsToTest) { %>
491
491
  .<%= field.fieldName %>(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>)<% if (field.fieldTypeBinary && !field.blobContentTypeText) { %>
492
492
  .<%= field.fieldName %>ContentType(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE)<% } %><% } %>;
493
493
  <%_ } else { _%>
@@ -495,7 +495,7 @@ if (field.fieldTypeString || field.blobContentTypeText) {
495
495
  <%_ if (reactive && databaseTypeSql && primaryKey.typeUUID && !isUsingMapsId) { _%>
496
496
  <%= persistInstance %>.set<%= primaryKey.fields[0].fieldInJavaBeanMethod %>(UUID.randomUUID());
497
497
  <%_ } _%>
498
- <%_ for (field of fields.filter(field => !field.id && !field.transient)) { _%>
498
+ <%_ for (field of fieldsToTest) { _%>
499
499
  <%= persistInstance %>.set<%= field.fieldInJavaBeanMethod %>(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>);
500
500
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
501
501
  <%= persistInstance %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE);
@@ -584,6 +584,14 @@ _%>
584
584
  deleteEntities(em);
585
585
  }
586
586
 
587
+ <%_ } _%>
588
+ <%_ if (searchEngineElasticsearch) { _%>
589
+ @AfterEach
590
+ public void cleanupElasticSearchRepository() {
591
+ <%= entityInstance %>SearchRepository.deleteAll()<%= callBlock %>;
592
+ assertThat(<%= entityInstance %>SearchRepository.count()<%= callBlock %>).isEqualTo(0);
593
+ }
594
+
587
595
  <%_ } _%>
588
596
  <%_ if (reactive && testsNeedCsrf) { _%>
589
597
  @BeforeEach
@@ -598,9 +606,6 @@ _%>
598
606
  <%= entityInstance %>Repository.deleteAll()<%= callBlock %>;
599
607
  <%_ } else if (databaseTypeSql && reactive) { _%>
600
608
  deleteEntities(em);
601
- <%_ } _%>
602
- <%_ if (searchEngineElasticsearch) { _%>
603
- <%= entityInstance %>SearchRepository.deleteAll()<%= callBlock %>;
604
609
  <%_ } _%>
605
610
  <%= persistInstance %> = createEntity(<% if (databaseTypeSql) { %>em<% } %>);
606
611
  }
@@ -649,7 +654,7 @@ _%>
649
654
  });
650
655
  <%_ } _%>
651
656
  <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1);
652
- <%_ for (const field of fields.filter(field => !field.id && !field.transient)) {
657
+ <%_ for (const field of fieldsToTest) {
653
658
  if (field.fieldTypeZonedDateTime) { _%>
654
659
  assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>);
655
660
  <%_ } else if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
@@ -785,7 +790,7 @@ _%>
785
790
  <%_ } _%>
786
791
  }
787
792
  <%_ } _%>
788
- <%_ for (field of fields.filter(field => !field.id && !field.transient)) { _%>
793
+ <%_ for (field of fieldsToTest) { _%>
789
794
  <%_ if (field.fieldValidate) {
790
795
  let required = false;
791
796
  if (!field.fieldTypeBytes && field.fieldValidate && field.fieldValidationRequired) {
@@ -863,7 +868,7 @@ _%>
863
868
  assertThat(<%= entityInstance %>List).isNotNull();
864
869
  assertThat(<%= entityInstance %>List).hasSize(1);
865
870
  <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(0);
866
- <%_ for (const field of fields.filter(field => !field.id && !field.transient)) {
871
+ <%_ for (const field of fieldsToTest) {
867
872
  if (field.fieldTypeZonedDateTime) { _%>
868
873
  assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>);
869
874
  <%_ } else if ((field.fieldTypeBinary) && !field.blobContentTypeText) { _%>
@@ -902,7 +907,7 @@ _%>
902
907
  .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
903
908
  <%_ } _%>
904
909
  <%_ if (databaseTypeSql || databaseTypeMongodb || databaseTypeCouchbase || databaseTypeCassandra) { _%>
905
- <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= idValue %>))<%= !reactive ? ')' : '' %><%_ } _%><% for (field of fields.filter(field => !field.id && !field.transient)) { %>
910
+ <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= idValue %>))<%= !reactive ? ')' : '' %><%_ } _%><% for (field of fieldsToTest) { %>
906
911
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
907
912
  <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.[*].<%= field.fieldName %>ContentType").value(hasItem(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE))<%= !reactive ? ')' : '' %>
908
913
  <%_ } _%>
@@ -989,7 +994,7 @@ _%>
989
994
  .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
990
995
  <%_ } _%>
991
996
  <%_ if (databaseTypeSql || databaseTypeMongodb || databaseTypeCouchbase || databaseTypeCassandra) { _%>
992
- <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.<%= primaryKey.name %>").value(<%= reactive ? 'is(' : '' %><%= idValue %>))<%_ } _%><% for (field of fields.filter(field => !field.id && !field.transient)) { %>
997
+ <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.<%= primaryKey.name %>").value(<%= reactive ? 'is(' : '' %><%= idValue %>))<%_ } _%><% for (field of fieldsToTest) { %>
993
998
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
994
999
  <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.<%= field.fieldName %>ContentType").value(<%= reactive ? 'is(' : '' %><%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE))
995
1000
  <%_ } _%>
@@ -1028,7 +1033,7 @@ _%>
1028
1033
  <%_ } _%>
1029
1034
  }
1030
1035
 
1031
- <%_ fields.filter(field => !field.id && !field.transient).forEach((searchBy) => { /* we can't filter by all the fields. */_%>
1036
+ <%_ fieldsToTest.forEach((searchBy) => { /* we can't filter by all the fields. */_%>
1032
1037
  <%_ if (isFilterableType(searchBy.fieldType)) { _%>
1033
1038
 
1034
1039
  @Test<%= transactionalAnnotation %>
@@ -1219,7 +1224,7 @@ _%>
1219
1224
  .expectStatus().isOk()
1220
1225
  .expectHeader().contentType(MediaType.APPLICATION_JSON)
1221
1226
  .expectBody()
1222
- .jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= idValue %>))<% for (field of fields.filter(field => !field.id && !field.transient)) { %>
1227
+ .jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= idValue %>))<% for (field of fieldsToTest) { %>
1223
1228
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
1224
1229
  .jsonPath("$.[*].<%= field.fieldName %>ContentType").value(hasItem(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE))
1225
1230
  <%_ } _%>
@@ -1255,7 +1260,7 @@ _%>
1255
1260
  'UUID' : '.toString()'
1256
1261
  }[primaryKey.type] || '';
1257
1262
  _%>
1258
- .andExpect(jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()<%= primaryKeyConversion %>)))<% fields.filter(field => !field.id && !field.transient).forEach((field) => { %>
1263
+ .andExpect(jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()<%= primaryKeyConversion %>)))<% fieldsToTest.forEach((field) => { %>
1259
1264
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
1260
1265
  .andExpect(jsonPath("$.[*].<%= field.fieldName %>ContentType").value(hasItem(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE)))
1261
1266
  <%_ } _%>
@@ -1336,7 +1341,7 @@ _%>
1336
1341
  <%_ if (!readOnly) { _%>
1337
1342
 
1338
1343
  @Test<%= transactionalAnnotation %>
1339
- void putNew<%= entityClass %>() throws Exception {
1344
+ void putExisting<%= entityClass %>() throws Exception {
1340
1345
  // Initialize the database
1341
1346
  <%_ if (!primaryKey.derived) { _%>
1342
1347
  <%_ for (field of primaryKey.fields.filter(f => !f.autoGenerateByRepository)) { _%>
@@ -1357,12 +1362,12 @@ _%>
1357
1362
  // Disconnect from session so that the updates on updated<%= persistClass %> are not directly saved in db
1358
1363
  em.detach(updated<%= persistClass %>);
1359
1364
  <%_ } _%>
1360
- <%_ if (fluentMethods && fields.filter(field => !field.id && !field.transient).length > 0) { _%>
1361
- updated<%= persistClass %><% for (field of fields.filter(field => !field.id && !field.transient)) { %>
1365
+ <%_ if (fluentMethods && fieldsToTest.length > 0) { _%>
1366
+ updated<%= persistClass %><% for (field of fieldsToTest) { %>
1362
1367
  .<%= field.fieldName %>(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>)<% if (field.fieldTypeBinary && !field.blobContentTypeText) { %>
1363
1368
  .<%= field.fieldName %>ContentType(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE)<% } %><% } %>;
1364
1369
  <%_ } else { _%>
1365
- <%_ for (field of fields.filter(field => !field.id && !field.transient)) { _%>
1370
+ <%_ for (field of fieldsToTest) { _%>
1366
1371
  updated<%= persistClass %>.set<%= field.fieldInJavaBeanMethod %>(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>);
1367
1372
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
1368
1373
  updated<%= persistClass %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE);
@@ -1393,7 +1398,7 @@ _%>
1393
1398
  List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>;
1394
1399
  assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate);
1395
1400
  <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1);
1396
- <%_ for (const field of fields.filter(field => !field.id && !field.transient)) { _%>
1401
+ <%_ for (const field of fieldsToTest) { _%>
1397
1402
  <%_ if (field.fieldTypeZonedDateTime) { _%>
1398
1403
  assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>);
1399
1404
  <%_ } else if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
@@ -1411,7 +1416,7 @@ _%>
1411
1416
  assertThat(searchDatabaseSizeAfter).isEqualTo(searchDatabaseSizeBefore);
1412
1417
  List<<%= persistClass %>> <%= entityInstance %>SearchList = IterableUtils.toList(<%= entityInstance %>SearchRepository.findAll()<%= callListBlock %>);
1413
1418
  <%= persistClass %> test<%= entityClass %>Search = <%= entityInstance %>SearchList.get(searchDatabaseSizeAfter - 1);
1414
- <%_ for (const field of fields.filter(field => !field.id && !field.transient)) { _%>
1419
+ <%_ for (const field of fieldsToTest) { _%>
1415
1420
  <%_ if (field.fieldTypeZonedDateTime) { _%>
1416
1421
  assertThat(test<%= entityClass %>Search.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>);
1417
1422
  <%_ } else if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
@@ -1545,7 +1550,7 @@ _%>
1545
1550
  <%_ } _%>
1546
1551
  }
1547
1552
 
1548
- <%
1553
+ <%_
1549
1554
  const prepareFieldForPatchTest = (field, includeCb) => {
1550
1555
  const includeField = includeCb();
1551
1556
  const fieldNameUnderscoreUppercased = field.fieldNameUnderscored.toUpperCase();
@@ -1553,7 +1558,7 @@ _%>
1553
1558
  const testWithConstant = includeField ? `UPDATED_${fieldNameUnderscoreUppercased}` : `DEFAULT_${fieldNameUnderscoreUppercased}`;
1554
1559
  return { includeField, updateWithValue, testWithConstant, ...field};
1555
1560
  };
1556
- %>
1561
+ _%>
1557
1562
  @Test<%= transactionalAnnotation %>
1558
1563
  void partialUpdate<%= entityClass %>WithPatch() throws Exception {
1559
1564
  // Initialize the database
@@ -1564,7 +1569,7 @@ _%>
1564
1569
  <%_ } _%>
1565
1570
  <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;
1566
1571
 
1567
- <% const fieldsToIncludeInPartialPatchTest = fields.filter(field => !field.id && !field.transient).map(field => prepareFieldForPatchTest(field, () => faker.datatype.boolean())); %>
1572
+ <%_ const fieldsToIncludeInPartialPatchTest = fieldsToTest.map(field => prepareFieldForPatchTest(field, () => faker.datatype.boolean())); _%>
1568
1573
  <%- include('/partials/it_patch_update.partial.java.ejs', {fields: fieldsToIncludeInPartialPatchTest, saveMethod, asEntity, callBlock, callListBlock}); -%>
1569
1574
  }
1570
1575
 
@@ -1578,7 +1583,7 @@ _%>
1578
1583
  <%_ } _%>
1579
1584
  <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;
1580
1585
 
1581
- <% const fieldsToIncludeInFullPatchTest = fields.filter(field => !field.id && !field.transient).map(field => prepareFieldForPatchTest(field, () => true)); %>
1586
+ <% const fieldsToIncludeInFullPatchTest = fieldsToTest.map(field => prepareFieldForPatchTest(field, () => true)); %>
1582
1587
  <%- include('/partials/it_patch_update.partial.java.ejs', {fields: fieldsToIncludeInFullPatchTest, saveMethod, asEntity, callBlock, callListBlock}); -%>
1583
1588
  }
1584
1589
 
@@ -1714,7 +1719,7 @@ _%>
1714
1719
  <%= entityInstance %>SearchRepository.save(<%= persistInstance %>)<%= callBlock %>;
1715
1720
  <%_ } _%>
1716
1721
 
1717
- int databaseSizeBeforeDelete = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size();
1722
+ int databaseSizeBeforeDelete = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size();
1718
1723
  <%_ if (searchEngineElasticsearch) { _%>
1719
1724
  int searchDatabaseSizeBefore = IterableUtil.sizeOf(<%= entityInstance %>SearchRepository.findAll()<%= callListBlock %>);
1720
1725
  assertThat(searchDatabaseSizeBefore).isEqualTo(databaseSizeBeforeDelete);
@@ -1779,7 +1784,7 @@ _%>
1779
1784
  .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
1780
1785
  <%_ } _%>
1781
1786
  <%_ if (databaseTypeSql || databaseTypeMongodb || databaseTypeCouchbase || databaseTypeCassandra) { _%>
1782
- <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= idValue %>))<%= !reactive ? ')' : '' %><%_ } _%><% for (field of fields.filter(field => !field.id && !field.transient)) { %>
1787
+ <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= idValue %>))<%= !reactive ? ')' : '' %><%_ } _%><% for (field of fieldsToTest) { %>
1783
1788
  <%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
1784
1789
  <%= !reactive ? '.andExpect(' : '.' %>jsonPath("$.[*].<%= field.fieldName %>ContentType").value(hasItem(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE))<%= !reactive ? ')' : '' %>
1785
1790
  <%_ } _%>
@@ -23,22 +23,36 @@ import { BASE_PRIORITY_NAMES, ENTITY_PRIORITY_NAMES } from '../../lib/constants/
23
23
 
24
24
  const prioritiesForSub = subGenerator => (subGenerator.startsWith('entit') ? ENTITY_PRIORITY_NAMES : BASE_PRIORITY_NAMES);
25
25
 
26
+ export const GENERATE_SNAPSHOTS = 'generateSnapshots';
27
+ export const LINK_JHIPSTER_DEPENDENCY = 'linkJhipsterDependency';
26
28
  export const GENERATORS = 'generators';
27
29
  export const SUB_GENERATORS = 'subGenerators';
28
30
  export const ADDITIONAL_SUB_GENERATORS = 'additionalSubGenerators';
29
31
  export const DYNAMIC = 'dynamic';
30
32
  export const JS = 'js';
33
+ export const LOCAL_BLUEPRINT_OPTION = 'localBlueprint';
34
+ export const CLI_OPTION = 'cli';
31
35
 
32
36
  export const SBS = 'sbs';
33
37
  export const COMMAND = 'command';
34
38
  export const PRIORITIES = 'priorities';
35
39
  export const ALL_GENERATORS = 'allGenerators';
40
+ export const ALL_PRIORITIES = 'allPriorities';
36
41
  export const WRITTEN = 'written';
37
42
 
38
43
  /**
39
44
  * Options exposed to cli
40
45
  */
41
46
  export const options = () => ({
47
+ [GENERATE_SNAPSHOTS]: {
48
+ desc: 'Generate test snapshots',
49
+ type: Boolean,
50
+ },
51
+ [LINK_JHIPSTER_DEPENDENCY]: {
52
+ desc: 'Link JHipster dependency for testing',
53
+ type: Boolean,
54
+ hide: true,
55
+ },
42
56
  [SUB_GENERATORS]: {
43
57
  desc: 'Sub generators to generate',
44
58
  type: Array,
@@ -59,11 +73,25 @@ export const options = () => ({
59
73
  type: Boolean,
60
74
  scope: 'storage',
61
75
  },
76
+ [LOCAL_BLUEPRINT_OPTION]: {
77
+ desc: 'Generate a local blueprint',
78
+ type: Boolean,
79
+ scope: 'storage',
80
+ },
81
+ [CLI_OPTION]: {
82
+ desc: 'Generate a cli for the blueprint',
83
+ type: Boolean,
84
+ scope: 'storage',
85
+ },
62
86
  [ALL_GENERATORS]: {
63
- desc: 'Use js extension',
87
+ desc: 'Generate every sub generator',
64
88
  type: Boolean,
65
89
  scope: 'generator',
66
90
  },
91
+ [ALL_PRIORITIES]: {
92
+ desc: 'Generate every priority',
93
+ type: Boolean,
94
+ },
67
95
  });
68
96
 
69
97
  /**
@@ -74,10 +102,12 @@ export const requiredConfig = () => ({});
74
102
  /**
75
103
  * Default config that will be used for templates
76
104
  */
77
- export const defaultConfig = () => ({
105
+ export const defaultConfig = ({ config = {} } = {}) => ({
78
106
  ...requiredConfig,
79
107
  [DYNAMIC]: false,
80
108
  [JS]: false,
109
+ [LOCAL_BLUEPRINT_OPTION]: false,
110
+ [CLI_OPTION]: !config[LOCAL_BLUEPRINT_OPTION],
81
111
  [SUB_GENERATORS]: [],
82
112
  [ADDITIONAL_SUB_GENERATORS]: '',
83
113
  });
@@ -109,7 +139,14 @@ export const allGeneratorsConfig = () => ({
109
139
  });
110
140
 
111
141
  export const prompts = () => {
142
+ const { [LOCAL_BLUEPRINT_OPTION]: LOCAL_BLUEPRINT_OPTION_DEFAULT_VALUE, [CLI_OPTION]: CLI_OPTION_DEFAULT_VALUE } = defaultConfig();
112
143
  return [
144
+ {
145
+ type: 'confirm',
146
+ name: LOCAL_BLUEPRINT_OPTION,
147
+ message: 'Do you want to generate a local blueprint inside your application?',
148
+ default: LOCAL_BLUEPRINT_OPTION_DEFAULT_VALUE,
149
+ },
113
150
  {
114
151
  type: 'checkbox',
115
152
  name: SUB_GENERATORS,
@@ -130,24 +167,27 @@ export const prompts = () => {
130
167
  },
131
168
  },
132
169
  {
170
+ when: answers => !answers[LOCAL_BLUEPRINT_OPTION],
133
171
  type: 'confirm',
134
- name: 'cli',
172
+ name: CLI_OPTION,
135
173
  message: 'Add a cli?',
136
- default: true,
174
+ default: CLI_OPTION_DEFAULT_VALUE,
137
175
  },
138
176
  ];
139
177
  };
140
178
 
141
- export const subGeneratorPrompts = (subGenerator, additionalSubGenerator) => {
179
+ export const subGeneratorPrompts = ({ subGenerator, additionalSubGenerator, localBlueprint }) => {
180
+ const { [SBS]: SBS_DEFAULT_VALUE } = defaultSubGeneratorConfig();
142
181
  return [
143
182
  {
144
183
  type: 'confirm',
145
184
  name: SBS,
146
185
  when: !additionalSubGenerator,
147
186
  message: `Is ${chalk.yellow(subGenerator)} generator a side-by-side blueprint?`,
148
- default: true,
187
+ default: SBS_DEFAULT_VALUE,
149
188
  },
150
189
  {
190
+ when: !localBlueprint,
151
191
  type: 'confirm',
152
192
  name: COMMAND,
153
193
  message: `Is ${chalk.yellow(subGenerator)} generator a cli command?`,
@@ -16,10 +16,12 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
+ import { LOCAL_BLUEPRINT_OPTION } from './constants.mjs';
19
20
 
20
21
  export const files = {
21
22
  baseFiles: [
22
23
  {
24
+ condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION],
23
25
  templates: [
24
26
  '.github/workflows/generator.yml',
25
27
  '.eslintrc.json',
@@ -44,18 +46,18 @@ export const generatorFiles = {
44
46
  generator: [
45
47
  {
46
48
  path: 'generators/generator',
47
- to: ctx => `generators/${ctx.generator}`,
49
+ to: ctx => `${ctx.application.blueprintsPath}${ctx.generator}`,
48
50
  templates: [{ file: 'generator.mjs.jhi', renameTo: ctx => (ctx.js ? 'generator.js.jhi' : 'generator.mjs.jhi') }],
49
51
  },
50
52
  {
51
53
  path: 'generators/generator',
52
- to: ctx => `generators/${ctx.generator}`,
54
+ to: ctx => `${ctx.application.blueprintsPath}${ctx.generator}`,
53
55
  templates: [{ file: 'index.mjs', renameTo: ctx => (ctx.js ? 'index.js' : 'index.mjs') }],
54
56
  },
55
57
  {
56
58
  path: 'generators/generator',
57
- to: ctx => `generators/${ctx.generator}`,
58
- condition: ctx => !ctx.generator.startsWith('entity'),
59
+ to: ctx => `${ctx.application.blueprintsPath}${ctx.generator}`,
60
+ condition: ctx => !ctx.generator.startsWith('entity') && !ctx.application[LOCAL_BLUEPRINT_OPTION],
59
61
  templates: [
60
62
  {
61
63
  file: 'generator.spec.mjs',
@@ -65,7 +67,7 @@ export const generatorFiles = {
65
67
  },
66
68
  {
67
69
  path: 'generators/generator',
68
- to: ctx => `generators/${ctx.generator}`,
70
+ to: ctx => `${ctx.application.blueprintsPath}${ctx.generator}`,
69
71
  condition(ctx) {
70
72
  return (this.options.force || !ctx.written) && ctx.priorities.find(priority => priority.name === 'writing');
71
73
  },
@@ -31,9 +31,12 @@ import {
31
31
  PREPARING_PRIORITY,
32
32
  WRITING_PRIORITY,
33
33
  POST_WRITING_PRIORITY,
34
- INSTALL_PRIORITY,
34
+ POST_INSTALL_PRIORITY,
35
35
  END_PRIORITY,
36
+ COMPOSING_PRIORITY,
37
+ BASE_PRIORITY_NAMES,
36
38
  } from '../../lib/constants/priorities.mjs';
39
+
37
40
  import {
38
41
  options,
39
42
  requiredConfig,
@@ -42,19 +45,23 @@ import {
42
45
  allGeneratorsConfig,
43
46
  prompts,
44
47
  subGeneratorPrompts,
48
+ GENERATE_SNAPSHOTS,
49
+ LINK_JHIPSTER_DEPENDENCY,
45
50
  ALL_GENERATORS,
46
51
  GENERATORS,
47
52
  PRIORITIES,
48
53
  SUB_GENERATORS,
49
54
  ADDITIONAL_SUB_GENERATORS,
50
55
  WRITTEN,
56
+ LOCAL_BLUEPRINT_OPTION,
57
+ ALL_PRIORITIES,
51
58
  } from './constants.mjs';
52
59
 
53
60
  import GENERATOR_LIST from '../generator-list.js';
54
61
  import { files, generatorFiles } from './files.mjs';
55
62
 
56
63
  const { camelCase, upperFirst, snakeCase } = lodash;
57
- const { GENERATOR_INIT, GENERATOR_GENERATE_BLUEPRINT } = GENERATOR_LIST;
64
+ const { GENERATOR_PROJECT_NAME, GENERATOR_INIT, GENERATOR_GENERATE_BLUEPRINT } = GENERATOR_LIST;
58
65
 
59
66
  export default class extends BaseBlueprintGenerator {
60
67
  constructor(args, opts, features) {
@@ -73,22 +80,18 @@ export default class extends BaseBlueprintGenerator {
73
80
  this.config.set(allGeneratorsConfig());
74
81
  }
75
82
  if (this.options.defaults) {
76
- this.config.defaults(defaultConfig());
83
+ this.config.defaults(defaultConfig({ config: this.jhipsterConfig }));
77
84
  }
78
- this.config.defaults({
79
- [SKIP_COMMIT_HOOK]: true,
80
- });
81
85
  }
82
86
 
83
87
  /** @inheritdoc */
84
88
  async getPossibleDependencies() {
85
- return [GENERATOR_INIT];
89
+ return [GENERATOR_PROJECT_NAME, GENERATOR_INIT];
86
90
  }
87
91
 
88
92
  async _beforeQueue() {
89
93
  if (!this.fromBlueprint) {
90
- const configure = this.options.configure || !this.shouldComposeModular();
91
- await this.dependsOnJHipster(GENERATOR_INIT, [], { configure });
94
+ await this.dependsOnJHipster(GENERATOR_PROJECT_NAME);
92
95
  await this.composeWithBlueprints(GENERATOR_GENERATE_BLUEPRINT);
93
96
  }
94
97
  }
@@ -119,20 +122,30 @@ export default class extends BaseBlueprintGenerator {
119
122
  await this.prompt(prompts(this), this.config);
120
123
  },
121
124
  async eachSubGenerator() {
125
+ const { localBlueprint } = this.jhipsterConfig;
126
+ const { [ALL_PRIORITIES]: allPriorities } = this.options;
122
127
  const subGenerators = this.config.get(SUB_GENERATORS) || [];
123
128
  for (const subGenerator of subGenerators) {
124
129
  const subGeneratorStorage = this.getSubGeneratorStorage(subGenerator);
125
- await this.prompt(subGeneratorPrompts(subGenerator), subGeneratorStorage);
130
+ if (allPriorities) {
131
+ subGeneratorStorage.defaults({ [PRIORITIES]: BASE_PRIORITY_NAMES });
132
+ }
133
+ await this.prompt(subGeneratorPrompts({ subGenerator, localBlueprint, options: this.options }), subGeneratorStorage);
126
134
  }
127
135
  },
128
136
  async eachAdditionalSubGenerator() {
137
+ const { localBlueprint } = this.jhipsterConfig;
138
+ const { [ALL_PRIORITIES]: allPriorities } = this.options;
129
139
  const additionalSubGenerators = this.config.get(ADDITIONAL_SUB_GENERATORS) || '';
130
140
  for (const subGenerator of additionalSubGenerators
131
141
  .split(',')
132
142
  .map(sub => sub.trim())
133
143
  .filter(Boolean)) {
134
144
  const subGeneratorStorage = this.getSubGeneratorStorage(subGenerator);
135
- await this.prompt(subGeneratorPrompts(subGenerator, true), subGeneratorStorage);
145
+ if (allPriorities) {
146
+ subGeneratorStorage.defaults({ [PRIORITIES]: BASE_PRIORITY_NAMES });
147
+ }
148
+ await this.prompt(subGeneratorPrompts({ subGenerator, localBlueprint, additionalSubGenerator: true }), subGeneratorStorage);
136
149
  }
137
150
  },
138
151
  };
@@ -148,6 +161,13 @@ export default class extends BaseBlueprintGenerator {
148
161
  requiredConfig() {
149
162
  this.config.defaults(requiredConfig());
150
163
  },
164
+ conditionalConfig() {
165
+ if (!this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) {
166
+ this.config.defaults({
167
+ [SKIP_COMMIT_HOOK]: true,
168
+ });
169
+ }
170
+ },
151
171
  };
152
172
  }
153
173
 
@@ -156,6 +176,20 @@ export default class extends BaseBlueprintGenerator {
156
176
  return this.configuring;
157
177
  }
158
178
 
179
+ get composing() {
180
+ return {
181
+ async compose() {
182
+ const configure = this.options.configure || !this.shouldComposeModular() || this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION];
183
+ await this.composeWithJHipster(GENERATOR_INIT, [], { configure });
184
+ },
185
+ };
186
+ }
187
+
188
+ get [COMPOSING_PRIORITY]() {
189
+ if (this.delegateToBlueprint) return {};
190
+ return this.composing;
191
+ }
192
+
159
193
  get loading() {
160
194
  return {
161
195
  createContext() {
@@ -184,6 +218,9 @@ export default class extends BaseBlueprintGenerator {
184
218
  }
185
219
  }
186
220
  },
221
+ preparePath() {
222
+ this.application.blueprintsPath = this.application[LOCAL_BLUEPRINT_OPTION] ? '.blueprint/' : 'generators/';
223
+ },
187
224
  };
188
225
  }
189
226
 
@@ -240,8 +277,8 @@ export default class extends BaseBlueprintGenerator {
240
277
 
241
278
  get postWriting() {
242
279
  return {
243
- postWriting() {
244
- if (this.shouldSkipFiles()) return;
280
+ packageJson() {
281
+ if (this.shouldSkipFiles() || this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) return;
245
282
  const { packagejs } = this.application;
246
283
  this.packageJson.merge({
247
284
  name: `generator-jhipster-${this.jhipsterConfig.baseName}`,
@@ -284,7 +321,7 @@ export default class extends BaseBlueprintGenerator {
284
321
  });
285
322
  },
286
323
  addCliToPackageJson() {
287
- if (this.shouldSkipFiles() || !this.jhipsterConfig.cli) return;
324
+ if (this.shouldSkipFiles() || !this.jhipsterConfig.cli || this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) return;
288
325
  const { baseName, cliName = `jhipster-${baseName}` } = this.application;
289
326
  this.packageJson.merge({
290
327
  bin: {
@@ -294,7 +331,7 @@ export default class extends BaseBlueprintGenerator {
294
331
  });
295
332
  },
296
333
  addGeneratorJHipsterDependency() {
297
- if (this.shouldSkipFiles()) return;
334
+ if (this.shouldSkipFiles() || this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) return;
298
335
  const { packagejs } = this.application;
299
336
  if (this.jhipsterConfig.dynamic) {
300
337
  this.packageJson.merge({
@@ -321,30 +358,47 @@ export default class extends BaseBlueprintGenerator {
321
358
  return this.postWriting;
322
359
  }
323
360
 
324
- get install() {
361
+ get postInstall() {
325
362
  return {
326
363
  async addSnapshot() {
327
- if (this.options.skipInstall || this.options.skipGit || this.config.existed) return;
364
+ const { [LOCAL_BLUEPRINT_OPTION]: localBlueprint } = this.jhipsterConfig;
365
+ const {
366
+ skipInstall,
367
+ skipGit,
368
+ existed,
369
+ [GENERATE_SNAPSHOTS]: generateSnapshots = !localBlueprint && !skipInstall && !skipGit && !existed,
370
+ } = this.options;
371
+ if (!generateSnapshots) return;
372
+
328
373
  // Generate snapshots to add to git.
329
374
  this.log(`
330
375
  This is a new blueprint, executing '${chalk.yellow('npm run update-snapshot')}' to generate snapshots and commit to git.`);
331
376
  try {
377
+ if (this.options[LINK_JHIPSTER_DEPENDENCY]) {
378
+ await this.spawnCommand('npm', ['link', 'generator-jhipster']);
379
+ }
332
380
  await this.spawnCommand('npm', ['run', 'update-snapshot']);
333
381
  } catch (error) {
382
+ if (generateSnapshots !== undefined) {
383
+ // We are forcing to generate snapshots fail the generation.
384
+ throw error;
385
+ }
334
386
  this.log('Fail to generate snapshots');
335
387
  }
336
388
  },
337
389
  };
338
390
  }
339
391
 
340
- get [INSTALL_PRIORITY]() {
392
+ get [POST_INSTALL_PRIORITY]() {
341
393
  if (this.delegateToBlueprint) return {};
342
- return this.install;
394
+ return this.postInstall;
343
395
  }
344
396
 
345
397
  get end() {
346
398
  return {
347
399
  end() {
400
+ if (this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) return;
401
+
348
402
  this.log(`${chalk.bold.green('##### USAGE #####')}
349
403
  To begin to work:
350
404
  - launch: ${chalk.yellow.bold('npm install')}
@@ -16,7 +16,7 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- import expect from 'expect';
19
+ import { expect } from 'expect';
20
20
 
21
21
  import { helpers, lookups } from '#test-utils';
22
22