@mshima/generator-jhipster-nodejs 0.0.0-stage → 0.0.1

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 (209) hide show
  1. package/LICENSE.txt +204 -0
  2. package/README.md +243 -2
  3. package/build-info.json +3 -0
  4. package/cli/cli-customizations.cjs +9 -0
  5. package/cli/cli.cjs +40 -0
  6. package/cli/logo.js +31 -0
  7. package/cli/version.cjs +12 -0
  8. package/generators/ci-cd/USAGE +5 -0
  9. package/generators/ci-cd/command.js +5 -0
  10. package/generators/ci-cd/generator.js +158 -0
  11. package/generators/ci-cd/index.js +2 -0
  12. package/generators/ci-cd/templates/.gitlab-ci.yml.ejs +137 -0
  13. package/generators/ci-cd/templates/azure-pipelines.yml.ejs +68 -0
  14. package/generators/ci-cd/templates/circle.yml.ejs +59 -0
  15. package/generators/ci-cd/templates/docker-registry.yml.ejs +58 -0
  16. package/generators/ci-cd/templates/github-ci.yml.ejs +90 -0
  17. package/generators/ci-cd/templates/jenkins/Jenkinsfile.ejs +104 -0
  18. package/generators/ci-cd/templates/jenkins/idea.gdsl +90 -0
  19. package/generators/ci-cd/templates/jenkins/jenkins.yml.ejs +33 -0
  20. package/generators/ci-cd/templates/travis.yml.ejs +75 -0
  21. package/generators/client/command.js +5 -0
  22. package/generators/client/generator.js +21 -0
  23. package/generators/client/generators/bootstrap/command.js +5 -0
  24. package/generators/client/generators/bootstrap/generator.js +28 -0
  25. package/generators/client/generators/bootstrap/index.js +2 -0
  26. package/generators/client/index.js +2 -0
  27. package/generators/common/generators/bootstrap/command.js +5 -0
  28. package/generators/common/generators/bootstrap/generator.js +37 -0
  29. package/generators/common/generators/bootstrap/index.js +2 -0
  30. package/generators/docker/command.js +5 -0
  31. package/generators/docker/generator.js +16 -0
  32. package/generators/docker/generators/bootstrap/command.js +5 -0
  33. package/generators/docker/generators/bootstrap/generator.js +56 -0
  34. package/generators/docker/generators/bootstrap/index.js +2 -0
  35. package/generators/docker/index.js +2 -0
  36. package/generators/docker/templates/docker/app.yml.ejs +25 -0
  37. package/generators/generator-nodejs-constants.js +32 -0
  38. package/generators/languages/command.js +5 -0
  39. package/generators/languages/generator.js +22 -0
  40. package/generators/languages/index.js +2 -0
  41. package/generators/languages/templates/src/main/webapp/i18n/en/home.json +19 -0
  42. package/generators/languages/templates/src/main/webapp/i18n/es/home.json +19 -0
  43. package/generators/languages/templates/src/main/webapp/i18n/it/home.json +19 -0
  44. package/generators/node-server/command.js +96 -0
  45. package/generators/node-server/entity-files.js +41 -0
  46. package/generators/node-server/files.js +254 -0
  47. package/generators/node-server/generator.js +702 -0
  48. package/generators/node-server/generators/bootstrap/command.js +5 -0
  49. package/generators/node-server/generators/bootstrap/generator.js +83 -0
  50. package/generators/node-server/generators/bootstrap/index.js +2 -0
  51. package/generators/node-server/index.js +2 -0
  52. package/generators/node-server/resources/package.json +76 -0
  53. package/generators/node-server/support/api-fake-data.js +54 -0
  54. package/generators/node-server/support/columns.js +73 -0
  55. package/generators/node-server/support/database.js +24 -0
  56. package/generators/node-server/support/entity-authorities.js +32 -0
  57. package/generators/node-server/support/entity-paths.js +13 -0
  58. package/generators/node-server/support/enums.js +11 -0
  59. package/generators/node-server/support/index.js +9 -0
  60. package/generators/node-server/support/mail-templates.js +82 -0
  61. package/generators/node-server/support/migrations.js +197 -0
  62. package/generators/node-server/support/validators.js +25 -0
  63. package/generators/node-server/templates/.dockerignore.ejs +16 -0
  64. package/generators/node-server/templates/.gitignore.jhi.nodejs.ejs +24 -0
  65. package/generators/node-server/templates/Dockerfile.ejs +54 -0
  66. package/generators/node-server/templates/README.md.jhi.nodejs.ejs +220 -0
  67. package/generators/node-server/templates/package.json.ejs +84 -0
  68. package/generators/node-server/templates/server/README.md.ejs +269 -0
  69. package/generators/node-server/templates/server/e2e/_entityFileName_.database.e2e-spec.ts.ejs +192 -0
  70. package/generators/node-server/templates/server/e2e/_entityFileName_.e2e-spec.ts.ejs +402 -0
  71. package/generators/node-server/templates/server/e2e/account.e2e-spec.ts.ejs +349 -0
  72. package/generators/node-server/templates/server/e2e/app.e2e-spec.ts.ejs +188 -0
  73. package/generators/node-server/templates/server/e2e/authority.e2e-spec.ts.ejs +50 -0
  74. package/generators/node-server/templates/server/e2e/cors.e2e-spec.ts.ejs +110 -0
  75. package/generators/node-server/templates/server/e2e/management.e2e-spec.ts.ejs +180 -0
  76. package/generators/node-server/templates/server/e2e/oauth2-bearer.e2e-spec.ts.ejs +71 -0
  77. package/generators/node-server/templates/server/e2e/session.e2e-spec.ts.ejs +219 -0
  78. package/generators/node-server/templates/server/e2e/setup.test.js.ejs +1 -0
  79. package/generators/node-server/templates/server/e2e/user.e2e-spec.ts.ejs +318 -0
  80. package/generators/node-server/templates/server/env.ejs +1 -0
  81. package/generators/node-server/templates/server/eslint.config.mjs.ejs +48 -0
  82. package/generators/node-server/templates/server/nest-cli.json.ejs +11 -0
  83. package/generators/node-server/templates/server/ormconfig.ts.ejs +35 -0
  84. package/generators/node-server/templates/server/package.json.ejs +143 -0
  85. package/generators/node-server/templates/server/sonar-project.properties.ejs +10 -0
  86. package/generators/node-server/templates/server/src/app.config.spec.ts.ejs +13 -0
  87. package/generators/node-server/templates/server/src/app.config.ts.ejs +179 -0
  88. package/generators/node-server/templates/server/src/app.module.ts.ejs +80 -0
  89. package/generators/node-server/templates/server/src/application-config.ts.ejs +153 -0
  90. package/generators/node-server/templates/server/src/auth/account.controller.ts.ejs +183 -0
  91. package/generators/node-server/templates/server/src/auth/auth.module.ts.ejs +104 -0
  92. package/generators/node-server/templates/server/src/auth/auth.service.ts.ejs +294 -0
  93. package/generators/node-server/templates/server/src/auth/csrf.middleware.spec.ts.ejs +65 -0
  94. package/generators/node-server/templates/server/src/auth/csrf.middleware.ts.ejs +76 -0
  95. package/generators/node-server/templates/server/src/auth/decorators/auth-user.decorator.ts.ejs +8 -0
  96. package/generators/node-server/templates/server/src/auth/decorators/roles.decorator.ts.ejs +4 -0
  97. package/generators/node-server/templates/server/src/auth/dto/key-and-password.dto.ts.ejs +17 -0
  98. package/generators/node-server/templates/server/src/auth/dto/password-change.dto.ts.ejs +17 -0
  99. package/generators/node-server/templates/server/src/auth/dto/user-login.dto.ts.ejs +21 -0
  100. package/generators/node-server/templates/server/src/auth/guards/auth.guard.ts.ejs +50 -0
  101. package/generators/node-server/templates/server/src/auth/guards/oauth2-login.guard.ts.ejs +6 -0
  102. package/generators/node-server/templates/server/src/auth/guards/roles.guard.ts.ejs +25 -0
  103. package/generators/node-server/templates/server/src/auth/index.ts.ejs +8 -0
  104. package/generators/node-server/templates/server/src/auth/jwt.config.spec.ts.ejs +22 -0
  105. package/generators/node-server/templates/server/src/auth/jwt.config.ts.ejs +29 -0
  106. package/generators/node-server/templates/server/src/auth/oauth2.authorities.spec.ts.ejs +24 -0
  107. package/generators/node-server/templates/server/src/auth/oauth2.authorities.ts.ejs +33 -0
  108. package/generators/node-server/templates/server/src/auth/oauth2.config.ts.ejs +51 -0
  109. package/generators/node-server/templates/server/src/auth/passport.jwt.strategy.ts.ejs +45 -0
  110. package/generators/node-server/templates/server/src/auth/passport.oauth2-bearer.strategy.ts.ejs +32 -0
  111. package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.spec.ts.ejs +27 -0
  112. package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.ts.ejs +44 -0
  113. package/generators/node-server/templates/server/src/auth/password-util.ts.ejs +10 -0
  114. package/generators/node-server/templates/server/src/auth/password.service.ts.ejs +34 -0
  115. package/generators/node-server/templates/server/src/auth/payload.interface.ts.ejs +14 -0
  116. package/generators/node-server/templates/server/src/auth/role-type.ts.ejs +7 -0
  117. package/generators/node-server/templates/server/src/auth/session-user.middleware.ts.ejs +33 -0
  118. package/generators/node-server/templates/server/src/auth/session.entity.ts.ejs +36 -0
  119. package/generators/node-server/templates/server/src/auth/session.store.spec.ts.ejs +99 -0
  120. package/generators/node-server/templates/server/src/auth/session.store.ts.ejs +116 -0
  121. package/generators/node-server/templates/server/src/auth/user.jwt.controller.ts.ejs +26 -0
  122. package/generators/node-server/templates/server/src/auth/user.oauth2.controller.ts.ejs +78 -0
  123. package/generators/node-server/templates/server/src/auth/user.session.controller.ts.ejs +103 -0
  124. package/generators/node-server/templates/server/src/common/common.module.ts.ejs +19 -0
  125. package/generators/node-server/templates/server/src/common/database/base.entity.ts.ejs +13 -0
  126. package/generators/node-server/templates/server/src/common/database/column-transformers.spec.ts.ejs +46 -0
  127. package/generators/node-server/templates/server/src/common/database/column-transformers.ts.ejs +69 -0
  128. package/generators/node-server/templates/server/src/common/database/column-types.spec.ts.ejs +21 -0
  129. package/generators/node-server/templates/server/src/common/database/column-types.ts.ejs +29 -0
  130. package/generators/node-server/templates/server/src/common/database/pagination.entity.spec.ts.ejs +66 -0
  131. package/generators/node-server/templates/server/src/common/database/pagination.entity.ts.ejs +108 -0
  132. package/generators/node-server/templates/server/src/common/dto/base.dto.ts.ejs +19 -0
  133. package/generators/node-server/templates/server/src/common/errors/error-constants.ts.ejs +10 -0
  134. package/generators/node-server/templates/server/src/common/errors/problem-details.filter.ts.ejs +63 -0
  135. package/generators/node-server/templates/server/src/common/errors/problem.exception.ts.ejs +92 -0
  136. package/generators/node-server/templates/server/src/common/field_validators.ejs +77 -0
  137. package/generators/node-server/templates/server/src/common/header-util.ts.ejs +105 -0
  138. package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.spec.ts.ejs +93 -0
  139. package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.ts.ejs +48 -0
  140. package/generators/node-server/templates/server/src/common/logging.spec.ts.ejs +83 -0
  141. package/generators/node-server/templates/server/src/common/logging.ts.ejs +129 -0
  142. package/generators/node-server/templates/server/src/common/metrics.spec.ts.ejs +43 -0
  143. package/generators/node-server/templates/server/src/common/metrics.ts.ejs +198 -0
  144. package/generators/node-server/templates/server/src/common/request.ts.ejs +8 -0
  145. package/generators/node-server/templates/server/src/common/sortable-properties.ts.ejs +43 -0
  146. package/generators/node-server/templates/server/src/common/updatable-properties.ts.ejs +14 -0
  147. package/generators/node-server/templates/server/src/config/application-dev.yml.ejs +118 -0
  148. package/generators/node-server/templates/server/src/config/application-prod.yml.ejs +97 -0
  149. package/generators/node-server/templates/server/src/config/application-secret-samples.yml.ejs +42 -0
  150. package/generators/node-server/templates/server/src/config/application-test.yml.ejs +68 -0
  151. package/generators/node-server/templates/server/src/config/application-tls-samples.yml.ejs +15 -0
  152. package/generators/node-server/templates/server/src/config/application-tls.yml.ejs +15 -0
  153. package/generators/node-server/templates/server/src/config/application.yml.ejs +149 -0
  154. package/generators/node-server/templates/server/src/config.spec.ts.ejs +81 -0
  155. package/generators/node-server/templates/server/src/config.ts.ejs +255 -0
  156. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.controller.ts.ejs +178 -0
  157. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.entity.ts.ejs +110 -0
  158. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.mapper.ts.ejs +37 -0
  159. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.module.ts.ejs +14 -0
  160. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.service.ts.ejs +123 -0
  161. package/generators/node-server/templates/server/src/entities/_entityFileName_/dto/_entityFileName_.dto.ts.ejs +99 -0
  162. package/generators/node-server/templates/server/src/mail/mail.module.ts.ejs +49 -0
  163. package/generators/node-server/templates/server/src/mail/mail.service.spec.ts.ejs +105 -0
  164. package/generators/node-server/templates/server/src/mail/mail.service.ts.ejs +120 -0
  165. package/generators/node-server/templates/server/src/main.ts.ejs +114 -0
  166. package/generators/node-server/templates/server/src/management/api-docs.controller.ts.ejs +27 -0
  167. package/generators/node-server/templates/server/src/management/api-docs.service.ts.ejs +8 -0
  168. package/generators/node-server/templates/server/src/management/configuration.controller.ts.ejs +80 -0
  169. package/generators/node-server/templates/server/src/management/health.controller.spec.ts.ejs +79 -0
  170. package/generators/node-server/templates/server/src/management/health.controller.ts.ejs +87 -0
  171. package/generators/node-server/templates/server/src/management/health.module.ts.ejs +9 -0
  172. package/generators/node-server/templates/server/src/management/loggers.controller.ts.ejs +40 -0
  173. package/generators/node-server/templates/server/src/management/management.controller.spec.ts.ejs +26 -0
  174. package/generators/node-server/templates/server/src/management/management.controller.ts.ejs +34 -0
  175. package/generators/node-server/templates/server/src/management/management.module.ts.ejs +21 -0
  176. package/generators/node-server/templates/server/src/management/metrics.controller.ts.ejs +85 -0
  177. package/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs +64 -0
  178. package/generators/node-server/templates/server/src/migrations/1570200270082-CreateSessions.ts.ejs +26 -0
  179. package/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs +74 -0
  180. package/generators/node-server/templates/server/src/migrations/_entityConstraintsMigration_.ts.ejs +40 -0
  181. package/generators/node-server/templates/server/src/migrations/_entityMigration_.ts.ejs +26 -0
  182. package/generators/node-server/templates/server/src/migrations/support/schema.ts.ejs +202 -0
  183. package/generators/node-server/templates/server/src/orm.config.ts.ejs +147 -0
  184. package/generators/node-server/templates/server/src/registry/consul.service.ts.ejs +70 -0
  185. package/generators/node-server/templates/server/src/registry/eureka.service.ts.ejs +129 -0
  186. package/generators/node-server/templates/server/src/swagger.ts.ejs +24 -0
  187. package/generators/node-server/templates/server/src/tls.ts.ejs +27 -0
  188. package/generators/node-server/templates/server/src/users/authority.controller.ts.ejs +85 -0
  189. package/generators/node-server/templates/server/src/users/authority.entity.ts.ejs +22 -0
  190. package/generators/node-server/templates/server/src/users/dto/authority.dto.ts.ejs +10 -0
  191. package/generators/node-server/templates/server/src/users/dto/user.dto.ts.ejs +116 -0
  192. package/generators/node-server/templates/server/src/users/public.user.controller.ts.ejs +51 -0
  193. package/generators/node-server/templates/server/src/users/user.controller.ts.ejs +191 -0
  194. package/generators/node-server/templates/server/src/users/user.entity.ts.ejs +63 -0
  195. package/generators/node-server/templates/server/src/users/user.mapper.ts.ejs +26 -0
  196. package/generators/node-server/templates/server/src/users/user.module.ts.ejs +19 -0
  197. package/generators/node-server/templates/server/src/users/user.service.ts.ejs +156 -0
  198. package/generators/node-server/templates/server/tsconfig.build.json.ejs +9 -0
  199. package/generators/node-server/templates/server/tsconfig.json.ejs +23 -0
  200. package/generators/node-server/templates/server/typeorm-migration.ts.ejs +18 -0
  201. package/generators/node-server/templates/server/vitest.config.e2e.ts.ejs +16 -0
  202. package/generators/node-server/templates/server/vitest.config.ts.ejs +16 -0
  203. package/generators/server/command.js +7 -0
  204. package/generators/server/generator.js +20 -0
  205. package/generators/server/generators/bootstrap/command.js +5 -0
  206. package/generators/server/generators/bootstrap/generator.js +15 -0
  207. package/generators/server/generators/bootstrap/index.js +2 -0
  208. package/generators/server/index.js +2 -0
  209. package/package.json +75 -4
@@ -0,0 +1,197 @@
1
+ import { bigDecimalPrecision } from './columns.js';
2
+ import { serverEnumInfo } from './enums.js';
3
+
4
+ /**
5
+ * The migrations of the SQL databases, like the Liquibase changelogs of JHipster Spring Boot: the tables of the built-in
6
+ * users (CreateTables), then for each entity the migration adding its table and the one adding its constraints (its
7
+ * foreign keys and its join tables). The tables and the columns are the ones TypeORM maps the entities to, with their
8
+ * names, so a database created by a former version of the application (its schema synchronized from the entities) keeps
9
+ * its schema.
10
+ *
11
+ * TypeORM runs the migrations in the order of the timestamp of the last 13 digits of their class name: the sections of
12
+ * the master.xml of Liquibase are ranges of timestamps. The changelogs of the tables are the migrations of the tables at
13
+ * the timestamp of the changelogDate of their entity, the changelogs of the constraints the ones of the constraints at
14
+ * that timestamp plus CONSTRAINTS_TIMESTAMP_OFFSET, and the changelogs of the developers, at the end of master.xml, the
15
+ * migrations the typeorm:migration scripts create at their time plus MIGRATION_TIMESTAMP_OFFSET.
16
+ */
17
+
18
+ /**
19
+ * The offset of the timestamps of the constraints migrations, after the ones of every table: the timestamp of the
20
+ * constraints of an entity is the one of its table plus 3000000000000 (4702121677000 for 1702121677000), so its name, like
21
+ * the constraints changelog of Liquibase named by the changelogDate of the entity, never changes, whatever the entities it
22
+ * references. The tables of the entities created up to 95 years after the first one stay before every constraints migration.
23
+ */
24
+ export const CONSTRAINTS_TIMESTAMP_OFFSET = 3 * 10 ** 12;
25
+
26
+ /**
27
+ * The offset of the timestamps of the migrations of the developers, created by the typeorm:migration scripts: their time
28
+ * plus 6000000000000, after the constraints migrations of every entity created before, like the changelogs added at the
29
+ * end of the master.xml of Liquibase; within 13 digits until 2096.
30
+ */
31
+ export const MIGRATION_TIMESTAMP_OFFSET = 6 * 10 ** 12;
32
+
33
+ /** The JavaScript timestamp (milliseconds, UTC) of the changelogDate of an entity, the date JHipster parses it to. */
34
+ const entityTimestamp = entity => entity.changelogDateForRecent.getTime();
35
+
36
+ /** The TypeScript of the type of a column whose @Column decorator has none: the TypeScript type of its property. */
37
+ const typeOfFieldType = {
38
+ string: 'String',
39
+ number: 'Number',
40
+ boolean: 'Boolean',
41
+ Date: 'Date',
42
+ };
43
+
44
+ /** A string literal of TypeScript. */
45
+ const literal = value => `'${String(value).replaceAll('\\', '\\\\').replaceAll("'", "\\'")}'`;
46
+
47
+ /** The migration column of the primary key of an entity, like its @PrimaryGeneratedColumn. */
48
+ export const primaryKeyColumn = entity => ({
49
+ name: entity.primaryKey.name,
50
+ type: entity.primaryKey.typeUUID ? literal('uuid') : 'Number',
51
+ primary: true,
52
+ generated: entity.primaryKey.typeUUID ? 'uuid' : 'increment',
53
+ });
54
+
55
+ /** The migration column referencing the primary key of an entity: a join column, or a column of a join table. */
56
+ const referenceColumn = (name, entity) => ({
57
+ name,
58
+ type: entity.primaryKey.typeUUID ? literal('uuid') : 'Number',
59
+ });
60
+
61
+ /** The migration columns of a field, like the @Column decorators of the entity: its column, and the content type of a blob. */
62
+ export const fieldColumns = field => {
63
+ const { fieldValidationRequired: required, fieldValidationUnique: unique, fieldValidationMaxlength: maxlength } = field;
64
+ const nullable = !required;
65
+ const type = field.nodejsColumnType ? literal(field.nodejsColumnType) : (typeOfFieldType[field.nodejsFieldType] ?? 'String');
66
+ const column = { name: field.fieldNameAsDatabaseColumn, type, nullable, unique };
67
+ if (field.fieldIsEnum) {
68
+ // The values of the TypeScript enum of the field, the ones of the enum column of the databases having one (MySQL).
69
+ column.enum = `[${serverEnumInfo(field)
70
+ .enumValues.map(({ value }) => literal(value))
71
+ .join(', ')}]`;
72
+ } else if (field.fieldType === 'BigDecimal') {
73
+ Object.assign(column, bigDecimalPrecision);
74
+ } else if (!['Instant', 'ZonedDateTime', 'LocalDate'].includes(field.fieldType) && maxlength) {
75
+ column.length = field.fieldValidateRulesMaxlength;
76
+ }
77
+ const columns = [column];
78
+ if (['byte[]', 'ByteBuffer'].includes(field.fieldType) && field.fieldTypeBlobContent !== 'text') {
79
+ columns.push({ name: `${field.fieldNameAsDatabaseColumn}_content_type`, type: 'String', nullable });
80
+ }
81
+ return columns;
82
+ };
83
+
84
+ /**
85
+ * The camelCase of the default naming strategy of TypeORM, the names it gives the join columns and the columns of the join
86
+ * tables: unlike the one of lodash, it keeps the case of the letters it does not join (mainURL_id is mainURLId).
87
+ */
88
+ export const typeormCamelCase = text =>
89
+ text.replaceAll(/^([A-Z])|[\s\-_](\w)/g, (_match, first, next) => (next ? next.toUpperCase() : first.toLowerCase()));
90
+
91
+ /** The join column of a relationship, named like TypeORM names it (the relationship and the primary key of the other entity). */
92
+ const joinColumnName = relationship =>
93
+ typeormCamelCase(`${relationship.relationshipFieldName}_${relationship.otherEntity.primaryKey.name}`);
94
+
95
+ /**
96
+ * The relationships of an entity with a join column, the persistableRelationships of JHipster but the many-to-many ones:
97
+ * the many-to-one ones, and the one-to-one ones on their owner side.
98
+ */
99
+ const joinColumnRelationships = entity => entity.persistableRelationships.filter(relationship => !relationship.relationshipManyToMany);
100
+
101
+ /**
102
+ * The names of the columns of a join table, like TypeORM names the ones of a @JoinTable: the same names, like the ones of a
103
+ * many-to-many relationship of an entity with itself named like its table, suffixed by _1 and _2.
104
+ */
105
+ const junctionColumnNames = (joinColumnName, inverseJoinColumnName) =>
106
+ joinColumnName === inverseJoinColumnName
107
+ ? [`${joinColumnName}_1`, `${inverseJoinColumnName}_2`]
108
+ : [joinColumnName, inverseJoinColumnName];
109
+
110
+ /** The relationships of an entity with a join table, the many-to-many ones on their owner side (shouldWriteJoinTable of JHipster). */
111
+ const joinTableRelationships = entity => entity.relationships.filter(relationship => relationship.shouldWriteJoinTable);
112
+
113
+ /**
114
+ * The join table of a many-to-many relationship on its owner side, the one of its @JoinTable and of its constraints
115
+ * migration: the joinTable of JHipster, its columns named by the table of the entity and the relationship.
116
+ */
117
+ export const joinTable = (entity, relationship) => {
118
+ const [joinColumnName, inverseJoinColumnName] = junctionColumnNames(`${entity.entityTableName}_id`, `${relationship.columnName}_id`);
119
+ return {
120
+ name: relationship.joinTable.name,
121
+ joinColumn: {
122
+ ...referenceColumn(joinColumnName, entity),
123
+ referencedTableName: entity.entityTableName,
124
+ referencedColumnName: entity.primaryKey.name,
125
+ },
126
+ inverseJoinColumn: {
127
+ ...referenceColumn(inverseJoinColumnName, relationship.otherEntity),
128
+ referencedTableName: relationship.otherEntity.entityTableName,
129
+ referencedColumnName: relationship.otherEntity.primaryKey.name,
130
+ },
131
+ };
132
+ };
133
+
134
+ /** The migration adding the table of an entity, its name, its class and its columns. */
135
+ export const entityMigration = entity => {
136
+ const timestamp = entityTimestamp(entity);
137
+ const relationships = joinColumnRelationships(entity);
138
+ return {
139
+ timestamp,
140
+ className: `AddedEntity${entity.entityClass}${timestamp}`,
141
+ fileName: `${timestamp}-AddedEntity${entity.entityClass}`,
142
+ tableName: entity.entityTableName,
143
+ columns: [
144
+ primaryKeyColumn(entity),
145
+ ...entity.fields.filter(field => !field.id).flatMap(fieldColumns),
146
+ ...relationships.map(relationship => ({
147
+ ...referenceColumn(joinColumnName(relationship), relationship.otherEntity),
148
+ nullable: true,
149
+ })),
150
+ ],
151
+ relationUniques: relationships
152
+ .filter(relationship => relationship.relationshipOneToOne)
153
+ .map(relationship => joinColumnName(relationship)),
154
+ };
155
+ };
156
+
157
+ /**
158
+ * The migration adding the constraints of an entity, its foreign keys and its join tables, when it has some: run after the
159
+ * migrations of every table, like the constraints changelogs of JHipster run after every table.
160
+ */
161
+ export const constraintsMigration = entity => {
162
+ const joinColumns = joinColumnRelationships(entity);
163
+ const joinTables = joinTableRelationships(entity);
164
+ if (joinColumns.length === 0 && joinTables.length === 0) return undefined;
165
+ const timestamp = entityTimestamp(entity) + CONSTRAINTS_TIMESTAMP_OFFSET;
166
+ return {
167
+ timestamp,
168
+ className: `AddedEntityConstraints${entity.entityClass}${timestamp}`,
169
+ fileName: `${timestamp}-AddedEntityConstraints${entity.entityClass}`,
170
+ tableName: entity.entityTableName,
171
+ foreignKeys: joinColumns.map(relationship => ({
172
+ columnName: joinColumnName(relationship),
173
+ referencedTableName: relationship.otherEntity.entityTableName,
174
+ referencedColumnName: relationship.otherEntity.primaryKey.name,
175
+ })),
176
+ joinTables: joinTables.map(relationship => joinTable(entity, relationship)),
177
+ };
178
+ };
179
+
180
+ /**
181
+ * The join table of the authorities of the built-in users, named like TypeORM names the junction table of the @JoinTable()
182
+ * of User.authorities: the tables and the property, its columns the tables and their primary keys.
183
+ */
184
+ export const userAuthorityJoinTable = ({ user, authority }) => ({
185
+ name: `${user.entityTableName}_authorities_${authority.entityTableName}`,
186
+ joinColumn: {
187
+ ...referenceColumn(typeormCamelCase(`${user.entityTableName}_${user.primaryKey.name}`), user),
188
+ referencedTableName: user.entityTableName,
189
+ referencedColumnName: user.primaryKey.name,
190
+ },
191
+ inverseJoinColumn: {
192
+ name: typeormCamelCase(`${authority.entityTableName}_name`),
193
+ type: 'String',
194
+ referencedTableName: authority.entityTableName,
195
+ referencedColumnName: 'name',
196
+ },
197
+ });
@@ -0,0 +1,25 @@
1
+ /** An ISO-8601 duration, like Duration.parse of Java: the pattern of parseDuration (src/common/database/column-transformers.ts). */
2
+ const ISO_DURATION = String.raw`/^([-+]?)P(?:([-+]?\d+)D)?(?:T(?:([-+]?\d+)H)?(?:([-+]?\d+)M)?(?:([-+]?)(\d+)(?:[.,](\d{0,9}))?S)?)?$/i`;
3
+
4
+ /**
5
+ * The class-validator decorators of the type of each field type, like the JSON deserialization of JHipster Spring Boot refuses
6
+ * a value of another type (400), instead of the error of the database or of a column transformer (500): a number, a
7
+ * boolean, a UUID, an ISO-8601 instant, a yyyy-MM-dd date, a HH:mm:ss time or an ISO-8601 duration.
8
+ */
9
+ const typeValidators = {
10
+ Integer: ['@IsInt()'],
11
+ Long: ['@IsInt()'],
12
+ Float: ['@IsNumber()'],
13
+ Double: ['@IsNumber()'],
14
+ BigDecimal: ['@IsNumber()'],
15
+ Boolean: ['@IsBoolean()'],
16
+ UUID: ['@IsUUID()'],
17
+ Instant: ['@IsISO8601()'],
18
+ ZonedDateTime: ['@IsISO8601()'],
19
+ LocalDate: [String.raw`@Matches(/^\d{4}-\d{2}-\d{2}$/)`, '@IsISO8601({ strict: true })'],
20
+ LocalTime: [String.raw`@Matches(/^\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/)`],
21
+ Duration: [`@Matches(${ISO_DURATION})`],
22
+ };
23
+
24
+ /** The class-validator decorators of the type of a field: none for a text, a blob or an enum (@IsEnum). */
25
+ export const fieldTypeValidators = field => (field.fieldIsEnum ? [] : (typeValidators[field.fieldType] ?? []));
@@ -0,0 +1,16 @@
1
+ .git
2
+ Dockerfile
3
+ .dockerignore
4
+ node_modules
5
+ yarn.lock
6
+
7
+ <%= nodeServerRootDir %>node_modules
8
+ <%= nodeServerRootDir %>dist
9
+ <%= nodeServerRootDir %>.env
10
+ <%= nodeServerRootDir %>yarn.lock
11
+
12
+ <%= clientRootDir %>node_modules
13
+ <%= clientRootDir %>yarn.lock
14
+
15
+ <%= temporaryDir %>
16
+ target
@@ -0,0 +1,24 @@
1
+ <%#
2
+ Copyright 2013-2023 the original author or authors from the JHipster project.
3
+
4
+ This file is part of the JHipster project, see https://www.jhipster.tech/
5
+ for more information.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -%>
19
+ <&_ if (!fragment.section) { -&>
20
+ # Generated by jhipster-nodejs:node-server
21
+ <%- nodeServerRootDir %>dist/
22
+ # Local settings of the server, like secrets (the development profile is in .env.dev)
23
+ <%- nodeServerRootDir %>.env
24
+ <&_ } -&>
@@ -0,0 +1,54 @@
1
+ <%_
2
+ const serverDir = nodeServerRootDir.replace(/\/$/, '');
3
+ const clientDir = clientRootDir.replace(/\/$/, '');
4
+ _%>
5
+ # Build stage: installs every dependency and builds the application.
6
+ FROM node:<%- nodeVersion %>-alpine AS build
7
+
8
+ WORKDIR /usr/src/app
9
+
10
+ # The package-lock.json of the application, missing in a workspace of applications (its lock is the one of the workspace).
11
+ COPY package*.json ./
12
+ COPY <%- nodeServerRootDir %>package.json <%- nodeServerRootDir %>
13
+ <%_ if (clientFrameworkAny) { _%>
14
+ COPY <%- clientRootDir %>package.json <%- clientRootDir %>
15
+ <%_ } _%>
16
+ # The install scripts (native bindings of the development database, husky, Cypress) are not needed to build. npm install
17
+ # installs the versions of the package-lock.json, or resolves them and writes one, the runtime stage installs from it.
18
+ RUN npm install --ignore-scripts
19
+
20
+ COPY . .
21
+ RUN npm run build --workspace <%- serverDir %>
22
+ <%_ if (clientFrameworkAny) { _%>
23
+ # The client is built into <%- nodeServerRootDir %>dist/static, served by the server.
24
+ RUN npm run build --workspace <%- clientDir %>
25
+ <%_ } _%>
26
+
27
+ # Runtime stage: the production dependencies of the server and its build only.
28
+ FROM node:<%- nodeVersion %>-alpine
29
+
30
+ WORKDIR /usr/src/app
31
+
32
+ ENV NODE_ENV=production
33
+ ENV BACKEND_ENV=prod
34
+ ENV NODE_SERVER_PORT=<%- serverPort %>
35
+
36
+ COPY package.json ./
37
+ COPY --from=build /usr/src/app/package-lock.json ./
38
+ COPY <%- nodeServerRootDir %>package.json <%- nodeServerRootDir %>
39
+ <%_ if (clientFrameworkAny) { _%>
40
+ COPY <%- clientRootDir %>package.json <%- clientRootDir %>
41
+ <%_ } _%>
42
+ RUN npm ci --omit=dev --ignore-scripts --workspace <%- serverDir %> && npm cache clean --force
43
+
44
+ COPY --from=build /usr/src/app/<%- nodeServerRootDir %>dist <%- nodeServerRootDir %>dist
45
+
46
+ USER node
47
+ WORKDIR /usr/src/app/<%- serverDir %>
48
+
49
+ EXPOSE <%- serverPort %>
50
+
51
+ HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
52
+ CMD ["node", "-e", "fetch(`http://localhost:${process.env.NODE_SERVER_PORT}/management/health`).then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
53
+
54
+ CMD ["node", "dist/main.js"]
@@ -0,0 +1,220 @@
1
+ <%#
2
+ Copyright 2019-2023 the original author or authors from the JHipster project
3
+
4
+ This file is part of the JHipster project, see https://www.jhipster.tech/
5
+ for more information.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -%>
19
+ <%#
20
+ This is a fragment file, it will be merged into to root template if available.
21
+ EJS fragments will process % delimiter tags in template and & delimiter tags in the merge process.
22
+ -%>
23
+ <&_ if (fragment.introSection) { -&>
24
+ This application was generated using the [NodeJS blueprint](https://github.com/jhipster/generator-jhipster-nodejs) of JHipster <%= jhipsterVersion %>, you can find documentation and help at [<%= documentationArchiveUrl %>](<%= documentationArchiveUrl %>). For any questions you can refer to the stream lead: [Angelo Manganiello](https://github.com/amanganiello90).
25
+ <%_ if (applicationTypeGateway || applicationTypeMicroservice) { _%>
26
+
27
+ This is a "<%= applicationType %>" application intended to be part of a microservice architecture, please refer to the [Doing microservices with JHipster][] page of the documentation for more information.
28
+ <%_ if (serviceDiscoveryEureka) { _%>
29
+ This application is configured for Service Discovery and Configuration with the JHipster-Registry, enabled with `EUREKA_CLIENT_ENABLED=true` (at `eureka.client.service-url.defaultZone`, [http://localhost:8761](http://localhost:8761) by default). Enabled, it refuses to start if it is not able to load its configuration from the JHipster-Registry, then registers once it listens and deregisters when it stops. For more information, read our documentation on [Service Discovery and Configuration with the JHipster-Registry][].
30
+ <%_ } _%>
31
+ <%_ if (serviceDiscoveryConsul) { _%>
32
+ This application is configured for Service Discovery with Consul, enabled with `CLOUD_CONSUL_ENABLED=true` (at `CLOUD_CONSUL_HOST` and `CLOUD_CONSUL_PORT`, [http://localhost:8500](http://localhost:8500) by default). Enabled, it registers once it listens, with the health check of `/management/health`, and deregisters when it stops; a failed registration is logged. For more information, read our documentation on [Service Discovery and Configuration with Consul][].
33
+ <%_ } _%>
34
+ <%_ } _%>
35
+
36
+ <&_ } -&>
37
+
38
+ <&_ if (fragment.structureSection) { -&>
39
+ Node is required for generation and recommended for development. `package.json` is always generated for a better development experience with prettier, commit hooks, scripts and so on.
40
+
41
+ In the project root, JHipster generates configuration files for tools like git, prettier, husky, and others that are well known and you can find references in the web.
42
+
43
+ - `.yo-rc.json` - Yeoman configuration file
44
+ JHipster configuration is stored in this file at `generator-jhipster` key. You may find `generator-jhipster-*` for specific blueprints configuration.
45
+ - `.yo-resolve` (optional) - Yeoman conflict resolver
46
+ Allows to use a specific action when conflicts are found skipping prompts for files that matches a pattern. Each line should match `[pattern] [action]` with pattern been a [Minimatch](https://github.com/isaacs/minimatch#minimatch) pattern and action been one of skip (default if ommited) or force. Lines starting with `#` are considered comments and are ignored.
47
+ - `.jhipster/*.json` - JHipster entity configuration files
48
+ - `/<%- dockerServicesDir %>` - Docker configurations for the application and services that the application depends on
49
+ - `/<%- clientRootDir %>` - Web application.
50
+ - `/server/` - NodeJS server application.
51
+
52
+ <&_ } -&>
53
+
54
+ <&_ if (fragment.developmentSection) { -&>
55
+
56
+ <%_ if (authenticationTypeOauth2) { _%>
57
+ ### OAuth 2.0 / OpenID Connect
58
+
59
+ Congratulations! You've selected an excellent way to secure your NHipster application. If you're not sure what OAuth and OpenID Connect (OIDC) are, please see [What the Heck is OAuth?](https://developer.okta.com/blog/2017/06/21/what-the-heck-is-oauth)
60
+
61
+ To log in to your app, you'll need to have [Keycloak](https://keycloak.org) up and running. The JHipster Team has created a Docker container for you that has the default users and roles. Start Keycloak using the following command.
62
+
63
+ ```
64
+ docker compose -f <%- dockerServicesDir %>keycloak.yml up
65
+ ```
66
+
67
+ ### Okta
68
+
69
+ If you'd like to use Okta instead of Keycloak, it's pretty quick using the [Okta CLI](https://cli.okta.com/). After you've installed it, run:
70
+
71
+ ```shell
72
+ okta register
73
+ ```
74
+
75
+ Then, in your JHipster app's directory, run `okta apps create` and select **JHipster**. This will set up an Okta app for you, create `ROLE_ADMIN` and `ROLE_USER` groups, create a `.okta.env` file with your Okta settings, and configure a `groups` claim in your ID token.
76
+
77
+ Run `source .okta.env` and start your app with `npm start`. You should be able to sign in with the credentials you registered with.
78
+
79
+ If you're on Windows, you should install [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10) so the `source` command will work.
80
+
81
+ If you'd like to configure things manually through the Okta developer console, see the instructions below.
82
+
83
+ First, you'll need to create a free developer account at <https://developer.okta.com/signup/>. After doing so, you'll get your own Okta domain, that has a name like `https://dev-123456.okta.com`.
84
+
85
+ Modify `<%= nodeServerRootDir %>src/config/application.yml` to use your Okta settings.
86
+
87
+ ```yaml
88
+ ...
89
+ security:
90
+ oauth2:
91
+ client:
92
+ provider:
93
+ oidc:
94
+ issuer-uri: https://{yourOktaDomain}/oauth2/default
95
+ registration:
96
+ oidc:
97
+ client-id: {clientId}
98
+ client-secret: {clientSecret}
99
+ ```
100
+
101
+ Create an OIDC App in Okta to get a `{clientId}` and `{clientSecret}`. To do this, log in to your Okta Developer account and navigate to **Applications** > **Add Application**. Click **Web** and click the **Next** button. Give the app a name you’ll remember, specify `http://localhost:<%- serverPort %>` as a Base URI, and `http://localhost:<%- serverPort %>/login/oauth2/code/oidc` as a Login Redirect URI. Click **Done**, then Edit and add `http://localhost:<%- serverPort %>` as a Logout redirect URI. Copy and paste the client ID and secret into your `application.yml` file.
102
+
103
+ Create a `ROLE_ADMIN` and `ROLE_USER` group and add users into them. Modify e2e tests to use this account when running integration tests. You'll need to change credentials in `<%= clientTestDir %>e2e/account/account.spec.ts` and `<%= clientTestDir %>e2e/admin/administration.spec.ts`.
104
+
105
+ Navigate to **API** > **Authorization Servers**, click the **Authorization Servers** tab and edit the default one. Click the **Claims** tab and **Add Claim**. Name it "groups", and include it in the ID Token. Set the value type to "Groups" and set the filter to be a Regex of `.*`.
106
+
107
+ After making these changes, you should be good to go! If you have any issues, please post them to [Stack Overflow](https://stackoverflow.com/questions/tagged/jhipster). Make sure to tag your question with "jhipster" and "okta".
108
+
109
+ <%_ } else if (authenticationTypeJwt) { _%>
110
+
111
+ ### JWT authentication and authorization
112
+
113
+ Congratulations! You've selected an excellent way to secure your NHipster application. If you're not sure what JSON Web Token (JWT) is, please see [What the Heck is JWT?](https://jwt.io/introduction/)
114
+
115
+ Your app uses, to get and use the token, the `<%= nodeServerRootDir %>src/config/application.yml` settings:
116
+
117
+ ```yaml
118
+ ...
119
+ security:
120
+ authentication:
121
+ jwt:
122
+ # This token must be encoded using Base64 and be at least 512 bits long, like the HS512 key of JHipster Spring Boot (you can type `openssl rand -base64 64` on your command line to generate one)
123
+ base64-secret: {yourSecret}
124
+ # Token is valid 24 hours
125
+ token-validity-in-seconds: 86400
126
+ token-validity-in-seconds-for-remember-me: 2592000
127
+ ```
128
+
129
+ You can use the default secret created from the app, or change it.
130
+ <%_ if (generateBuiltInUserEntity) { _%>
131
+ So to get a token, you have to pass a POST request on the _api/authenticate_ url with **UserLoginDTO** as body.
132
+ For this you can use the client login page (if you have generated it), or a client like curl.
133
+ <%_ } else { _%>
134
+ This application has no users of its own: it validates the tokens issued by the application sharing this secret (like the gateway), and the user of a request is the one of its token.
135
+ <%_ } _%>
136
+ <%_ } else if (authenticationTypeSession) { _%>
137
+
138
+ ### Session authentication
139
+
140
+ Like JHipster Spring Boot with HTTP sessions, the client logs in by posting the `username`, `password` and `remember-me`
141
+ form to `api/authentication`, and logs out by posting to `api/logout`. The sessions are kept in the database of the
142
+ application (the `<%- jhiTablePrefix %>_session` table or collection): they outlive a restart and are shared by the instances of a
143
+ cluster. A session ends after 30 minutes without requests, 31 days with remember-me, and the account page lists the
144
+ sessions of the user, any of which it can end. Its unsafe requests, the login included, send the token of the
145
+ `XSRF-TOKEN` cookie as the `X-XSRF-TOKEN` header, as the JHipster clients do. The secret of the sessions is
146
+ `jhipster.security.session.secret`, set it in production with the `JHIPSTER_SECURITY_SESSION_SECRET` environment variable.
147
+ <%_ } _%>
148
+ <%_ if (generateUserManagement) { _%>
149
+
150
+ ### Account mails
151
+
152
+ Like JHipster Spring Boot, the server sends the account mails with [@nestjs-modules/mailer][] (Nodemailer): the activation mail of a registered user (who signs in once activated, with the link of the mail), the creation mail of a user created by an administrator and the password reset mail. Their HTML is the [Handlebars][] templates of `<%= nodeServerRootDir %>src/templates/mail/` (like the Thymeleaf templates of `templates/mail`; they interpolate values, escaped, and call the `message` helper of the server, they run no code), their texts the messages of `<%= nodeServerRootDir %>src/i18n/messages*.properties` in the language of the user, and their links open the client at `jhipster.mail.base-url`.
153
+
154
+ The SMTP server is set by the `mail` settings of `<%= nodeServerRootDir %>src/config/application-dev.yml` and `application-prod.yml` (`localhost:25` by default), or by environment variables like `MAIL_HOST`, `MAIL_PORT`, `MAIL_USERNAME` and `MAIL_PASSWORD`. A mail that cannot be sent is logged as a warning, without failing the request.
155
+ <%_ } _%>
156
+
157
+ ### Using NestJS CLI
158
+
159
+ You can also use [NestJS CLI][] to generate some custom server code.
160
+
161
+ For example, the following command:
162
+
163
+ nest generate module my-module
164
+
165
+ will generate the file:
166
+
167
+ create <%= nodeServerRootDir %>src/my-component/my-component.module.ts
168
+
169
+
170
+ ### Building and running
171
+
172
+ #### Running
173
+
174
+ ```bash
175
+ <%= nodePackageManager %> run app:start
176
+ ```
177
+
178
+ #### Building
179
+
180
+ ```bash
181
+ <%= nodePackageManager %> run build:app
182
+ ```
183
+
184
+ The build folder with all compiled sources will be **<%= nodeServerRootDir %>dist**.
185
+
186
+ > For more explanation about full stack server/client build refer to [<%= nodeServerRootDir %>README.md](<%= nodeServerRootDir %>README.md)
187
+
188
+ <&_ } -&>
189
+
190
+ <&_ if (fragment.othersSection) { -&>
191
+
192
+ ### Code quality using Sonar
193
+
194
+ Sonar is used to analyse code quality. You can start a local Sonar server (accessible on http://localhost:9001) with:
195
+
196
+ ```
197
+ docker compose -f <%- dockerServicesDir %>sonar.yml up -d
198
+ ```
199
+
200
+ Note: we have turned off forced authentication redirect for UI in [<%- dockerServicesDir %>sonar.yml](<%- dockerServicesDir %>sonar.yml) for out of the box experience while trying out SonarQube, for real use cases turn it back on.
201
+
202
+ You can run a Sonar analysis with using the [sonar-scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner).
203
+ Then, run a Sonar analysis in the <%= nodeServerRootDir %> folder:
204
+
205
+ ```sh
206
+ npm run sonar:scanner
207
+ ```
208
+
209
+ For more information, refer to the [Code quality page][].
210
+
211
+ <&_ } -&>
212
+
213
+ <&_ if (fragment.referenceSection) { -&>
214
+ [Node.js]: https://nodejs.org/
215
+ [Vitest]: https://vitest.dev/
216
+ [NestJS]: https://nestjs.com/
217
+ [NestJS CLI]: https://docs.nestjs.com/cli/usages
218
+ [@nestjs-modules/mailer]: https://nest-modules.github.io/mailer/
219
+ [Handlebars]: https://handlebarsjs.com/
220
+ <&_ } -&>
@@ -0,0 +1,84 @@
1
+ <%#
2
+ Copyright 2019-2023 the original author or authors from the JHipster project.
3
+
4
+ This file is part of the JHipster project, see https://www.jhipster.tech/
5
+ for more information.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -%>
19
+ {
20
+ "name": "<%= dasherizedBaseName %>",
21
+ "version": "0.0.0",
22
+ "description": "Description for <%= baseName %>",
23
+ "private": true,
24
+ "license": "UNLICENSED",
25
+ "cacheDirectories": [
26
+ "node_modules"
27
+ ],
28
+ "devDependencies": {
29
+ "@eslint/js": "<%- nodeServerDependencies['@eslint/js'] %>",
30
+ "concurrently": "<%= nodeDependencies['concurrently'] %>",
31
+ "eslint": "<%- nodeServerDependencies['eslint'] %>",
32
+ "eslint-config-prettier": "<%- nodeServerDependencies['eslint-config-prettier'] %>",
33
+ "globals": "<%- nodeServerDependencies['globals'] %>",
34
+ "prettier": "<%= nodeDependencies['prettier'] %>",
35
+ "prettier-plugin-packagejson": "<%= nodeDependencies['prettier-plugin-packagejson'] %>",
36
+ "typescript-eslint": "<%- nodeServerDependencies['typescript-eslint'] %>"<% if (clientFrameworkAny) { %>,
37
+ "wait-on": "<%= nodeDependencies['wait-on'] %>"<% } %>
38
+ },
39
+ "engines": {
40
+ "node": ">=<%= nodeVersion %>"
41
+ },
42
+ <%_ if (clientFrameworkAny) { _%>
43
+ "config": {
44
+ "backend_port": <%= serverPort %>
45
+ },
46
+ <%_ } _%>
47
+ "workspaces": [
48
+ "server"
49
+ ],
50
+ "scripts": {
51
+ "backend:start": "<%= clientPackageManager %> run start:server",
52
+ <%_ if (clientFrameworkAny) { _%>
53
+ "app:start": "<%= clientPackageManager %> run build && BACKEND_ENV=dev <%= clientPackageManager %> run start:prod -w server",
54
+ "ci:e2e:package": "<%= clientPackageManager %> run build",
55
+ <%_ if ((testFrameworks ?? []).some(testFramework => ['cypress', 'playwright'].includes(testFramework))) { _%>
56
+ "e2e": "<%= clientPackageManager %> run e2e -w client",
57
+ <%_ } _%>
58
+ "ci:e2e:server:start": "BACKEND_ENV=test <%= clientPackageManager %> run start:prod -w server",
59
+ "build": "<%= clientPackageManager %> run build -w server && <%= clientPackageManager %> run build -w client",
60
+ <%_ } else { _%>
61
+ "build": "<%= clientPackageManager %> run build -w server",
62
+ <%_ } _%>
63
+ "build:app": "<%= clientPackageManager %> run build -w server",
64
+ "ci:docker:build": "<%= clientPackageManager %> run docker:build",
65
+ "docker:build": "docker build -t <%= baseName.toLowerCase() %> .",
66
+ "lint": "<%= clientPackageManager %> run lint --workspaces",
67
+ "lint:fix": "<%= clientPackageManager %> run lint:fix --workspaces",
68
+ "prettier:check": "prettier --check \"{,src/**/}*.{<%= prettierExtensions %>}\"",
69
+ "prettier:format": "prettier --write \"{,src/**/}*.{<%= prettierExtensions %>}\"",
70
+ <%_ if (clientFrameworkAny) { _%>
71
+ "start": "concurrently -k -s first -n application,client -c red,green npm:start:server npm:start:client",
72
+ <%_ } else { _%>
73
+ "start": "<%= clientPackageManager %> run start:server",
74
+ <%_ } _%>
75
+ "start:server": "<%= clientPackageManager %> run start -w server",
76
+ <%_ if (clientFrameworkAny) { _%>
77
+ "start:client": "<%= clientPackageManager %> run start -w client",
78
+ "test:client": "<%= clientPackageManager %> test -w client",
79
+ <%_ } _%>
80
+ "test:server": "<%= clientPackageManager %> test -w server",
81
+ "test:server:e2e": "<%= clientPackageManager %> run test:e2e -w server",
82
+ "test": "<%= clientPackageManager %> test --workspaces"
83
+ }
84
+ }