-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
command.js
196 lines (190 loc) · 6.56 KB
/
command.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import chalk from 'chalk';
import { command as springBootCommand } from 'generator-jhipster/generators/spring-boot';
const { syncUserWithIdp, defaultPackaging } = springBootCommand.configs;
const prodDatabaseTypeChoices = [
{ value: 'postgresql', name: 'PostgreSQL' },
{ value: 'mysql', name: 'MySQL' },
{ value: 'mariadb', name: 'MariaDB' },
{ value: 'oracle', name: 'Oracle (Please follow our documentation to use the Oracle proprietary driver)' },
{ value: 'mssql', name: 'Microsoft SQL Server' },
];
const authenticationTypeChoices = [
{ value: 'jwt', name: 'JWT authentication (stateless, with a token)' },
{ value: 'oauth2', name: 'OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak)' },
{ value: 'session', name: 'HTTP Session Authentication (stateful)' },
];
export const serverTestFrameworkChoices = [
{ name: 'Gatling', value: 'gatling' },
{ name: 'Cucumber', value: 'cucumber' },
];
/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
const command = {
options: {},
configs: {
serverPort: {
description: 'Server port',
cli: {
type: Number,
},
prompt: gen => ({
when: () => ['gateway', 'microservice'].includes(gen.jhipsterConfigWithDefaults.applicationType),
validate: input => (/^([0-9]*)$/.test(input) ? true : 'This is not a valid port number.'),
message:
'As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts.',
default: gen.jhipsterConfigWithDefaults.serverPort,
}),
},
serviceDiscoveryType: {
description: 'Service discovery',
cli: {
type: String,
},
prompt: gen => ({
when: () => ['gateway', 'microservice'].includes(gen.jhipsterConfigWithDefaults.applicationType),
type: 'list',
message: 'Which service discovery server do you want to use?',
default: 'consul',
}),
choices: [
{ name: 'Consul (recommended)', value: 'consul' },
{ name: 'JHipster Registry (legacy, uses Eureka, provides Spring Cloud Config support)', value: 'eureka' },
{ name: 'No service discovery', value: 'no' },
],
},
authenticationType: {
description: 'Authentication type',
cli: {
type: String,
},
prompt: gen => ({
type: 'list',
name: 'authenticationType',
message: `Which ${chalk.yellow('*type*')} of authentication would you like to use?`,
choices: () =>
gen.jhipsterConfigWithDefaults.applicationType === 'monolith' ? authenticationTypeChoices : authenticationTypeChoices.slice(0, 1),
default: 'jwt',
}),
choices: authenticationTypeChoices,
},
syncUserWithIdp,
prodDatabaseType: {
description: 'Production database',
cli: {
type: String,
},
prompt: gen => ({
when: () => gen.jhipsterConfigWithDefaults.databaseType === 'sql',
type: 'list',
message: `Which ${chalk.yellow('*production*')} database would you like to use?`,
}),
choices: prodDatabaseTypeChoices,
default: 'postgresql',
},
devDatabaseType: {
description: 'Development database',
cli: {
type: String,
},
prompt: {
type: 'list',
message: `Which ${chalk.yellow('*development*')} database would you like to use?`,
choices: answers => [
...prodDatabaseTypeChoices.filter(it => it.value === answers.prodDatabaseType),
{ value: 'h2Disk', name: 'H2 with disk-based persistence' },
{ value: 'h2Memory', name: 'H2 with in-memory persistence' },
],
default: 'h2Disk',
},
},
cacheProvider: {
description: 'Cache provider',
cli: {
type: String,
},
prompt: gen => ({
type: 'list',
message: 'Which cache do you want to use?',
default: () => gen.jhipsterConfigWithDefaults.cacheProvider,
}),
choices: [
{ value: 'ehcache', name: 'Ehcache (local cache, for a single node)' },
{ value: 'caffeine', name: 'Caffeine (local cache, for a single node)' },
{ value: 'hazelcast', name: 'Hazelcast (distributed cache, for multiple nodes, supports rate-limiting for gateway applications)' },
{ value: 'infinispan', name: 'Infinispan (hybrid cache, for multiple nodes)' },
{
value: 'memcached',
name: 'Memcached (distributed cache) - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!',
},
{ value: 'redis', name: 'Redis (distributed cache)' },
{ value: 'no', name: 'No cache - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!' },
],
},
enableHibernateCache: {
description: 'Hibernate 2nd level cache',
cli: {
type: Boolean,
},
prompt: gen => ({
when: answers =>
['ehcache', 'caffeine', 'hazelcast', 'redis'].includes(answers.cacheProvider ?? gen.jhipsterConfigWithDefaults.cacheProvider),
type: 'confirm',
message: 'Do you want to use Hibernate 2nd level cache?',
default: gen.jhipsterConfigWithDefaults.enableHibernateCache,
}),
},
serverTestFrameworks: {
description: 'Server test frameworks',
cli: {
type: Array,
},
prompt: {
type: 'checkbox',
message: 'Besides Junit, which testing frameworks would you like to use?',
},
choices: serverTestFrameworkChoices,
},
messageBroker: {
description: 'Message broker',
cli: {
type: String,
},
prompt: {
type: 'list',
message: 'Which message broker would you like to use?',
},
choices: [
{ value: 'no', name: 'No message broker' },
{ value: 'kafka', name: 'Apache Kafka as asynchronous messages broker' },
],
},
searchEngine: {
description: 'Search engine',
cli: {
type: String,
},
prompt: {
type: 'list',
message: 'Which search engine would you like to use?',
},
choices: [
{ value: 'no', name: 'No search engine' },
{ value: 'elasticsearch', name: 'Elasticsearch' },
],
},
enableSwaggerCodegen: {
description: 'API first development using OpenAPI-generator',
cli: {
type: Boolean,
},
prompt: {
type: 'confirm',
message: 'API first development using OpenAPI-generator',
},
default: false,
},
defaultPackaging,
},
};
export default command;