-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
command.js
149 lines (146 loc) · 6.07 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
import chalk from 'chalk';
import { GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL } from 'generator-jhipster/generators';
import { command as serverCommand } from 'generator-jhipster/generators/server';
import { command as springBootCommand } from 'generator-jhipster/generators/spring-boot';
const { applicationType } = serverCommand.configs;
const { defaultPackaging } = springBootCommand.configs;
/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
const command = {
options: {},
configs: {
applicationType,
defaultPackaging,
serverPort: {
prompt: gen => ({
when: answers =>
['gateway', 'microservice'].includes(answers.applicationType ?? gen.jhipsterConfigWithDefaults.applicationType),
type: 'input',
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: answers =>
(answers.applicationType ?? gen.jhipsterConfigWithDefaults.applicationType) === 'microservice' ? 8081 : 8080,
}),
scope: 'storage',
},
packageName: {
prompt: {
type: 'input',
validate: input =>
/^([a-z_]{1}[a-z0-9_]*(\.[a-z_]{1}[a-z0-9_]*)*)$/.test(input)
? true
: 'The package name you have provided is not a valid Java package name.',
message: 'What is your default Java package name?',
default: 'com.mycompany.myapp',
},
scope: 'storage',
},
authenticationType: {
description: 'Provide authentication type for the application when skipping server side generation',
cli: {
name: 'auth',
type: String,
},
prompt: {
type: 'list',
message: `Which ${chalk.yellow('*type*')} of authentication would you like to use?`,
},
choices: [
{ value: 'jwt', name: 'JWT authentication (stateless, with a token)' },
{ value: 'oauth2', name: 'OAuth 2.0 / OIDC Authentication (stateful, generated with Keycloak)' },
],
scope: 'storage',
},
buildTool: {
description: 'Provide build tool for the application when skipping server side generation',
cli: {
name: 'build',
type: String,
},
prompt: {
type: 'list',
message: 'Would you like to use Maven or Gradle for building the backend?',
},
choices: [
{ value: 'maven', name: 'Maven' },
{ value: 'gradle', name: 'Gradle' },
],
scope: 'storage',
},
databaseType: {
prompt: {
type: 'list',
message: `Which ${chalk.yellow('*type*')} of database would you like to use?`,
default: 'sql',
},
choices: [
{ value: 'sql', name: 'SQL (SQL databases)' },
{ value: 'mongodb', name: 'MongoDB' },
],
scope: 'storage',
},
prodDatabaseType: {
prompt: gen => ({
when: answers => (answers.databaseType ?? gen.jhipsterConfigWithDefaults.databaseType) === 'sql',
type: 'list',
message: `Which ${chalk.yellow('*production*')} database would you like to use?`,
}),
choices: [
{ value: 'postgresql', name: 'PostgreSQL' },
{ value: 'mysql', name: 'MySQL' },
{ value: 'mariadb', name: 'MariaDB' },
{ value: 'oracle', name: 'Oracle' },
{ value: 'mssql', name: 'Microsoft SQL Server' },
],
scope: 'storage',
},
devDatabaseType: {
prompt: gen => ({
when: answers => (answers.databaseType ?? gen.jhipsterConfigWithDefaults.databaseType) === 'sql',
type: 'list',
message: `Which ${chalk.yellow('*development*')} database would you like to use?`,
}),
choices: [
{ value: null, name: 'Same as production' },
{ value: 'h2Disk', name: 'H2 with disk-based persistence' },
{ value: 'h2Memory', name: 'H2 with in-memory persistence' },
],
scope: 'storage',
},
cacheProvider: {
description: 'Cache provider',
cli: {
type: String,
},
prompt: {
type: 'list',
message: 'Do you want to use the Quarkus cache abstraction?',
},
choices: [
{ value: 'caffeine', name: 'Yes, with the Caffeine implementation (local cache, for a single node)' },
{ value: 'redis', name: 'Yes, with the Redis implementation - Warning, this will disable the Hibernate 2nd level cache!' },
{ value: 'no', name: 'No' },
],
scope: 'storage',
},
enableHibernateCache: {
description: 'Enable hibernate cache',
cli: {
type: Boolean,
},
prompt: gen => ({
when: answers =>
(answers.databaseType ?? gen.jhipsterConfigWithDefaults.databaseType) === 'sql' &&
!['redis'].includes(answers.cacheProvider ?? gen.jhipsterConfigWithDefaults.cacheProvider),
type: 'confirm',
message: 'Do you want to use Hibernate 2nd level cache?',
default: true,
}),
scope: 'storage',
},
},
import: [GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL],
};
export default command;