-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.js
113 lines (98 loc) · 4.63 KB
/
index.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
/**
* Copyright 2013-2020 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable consistent-return */
const chalk = require('chalk');
const ServerGenerator = require('generator-jhipster/generators/server');
const constants = require('generator-jhipster/generators/generator-constants');
const writeFiles = require('./files').writeFiles;
const prompts = require('./prompts');
module.exports = class extends ServerGenerator {
constructor(args, opts) {
super(args, Object.assign({ fromBlueprint: true }, opts)); // fromBlueprint variable is important
const jhContext = (this.jhipsterContext = this.options.jhipsterContext);
if (!jhContext) {
this.error(`This is a JHipster blueprint and should be used only like ${chalk.yellow('jhipster --blueprint micronaut')}`);
}
this.configOptions = jhContext.configOptions || {};
// Add custom options for the CLI here, For example
// this.option('skip-ktlint-format', {
// desc: 'Indicates to skip formatting using ktlint',
// type: Boolean,
// defaults: false
// });
// This sets up options for this sub generator and is being reused from JHipster
jhContext.setupServerOptions(this, jhContext);
}
get initializing() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._initializing();
}
get prompting() {
// Here we are not overriding this phase and hence its being handled by JHipster
// return super._prompting();
return {
askForModuleName: prompts.askForModuleName,
askForServerSideOpts: prompts.askForServerSideOpts,
askForOptionalItems: prompts.askForOptionalItems,
askFori18n: prompts.askFori18n,
setSharedConfigOptions() {
this.configOptions.packageName = this.packageName;
this.configOptions.cacheProvider = this.cacheProvider;
this.configOptions.enableHibernateCache = this.enableHibernateCache;
this.configOptions.websocket = this.websocket;
this.configOptions.databaseType = this.databaseType;
this.configOptions.devDatabaseType = this.devDatabaseType;
this.configOptions.prodDatabaseType = this.prodDatabaseType;
this.configOptions.searchEngine = this.searchEngine;
this.configOptions.messageBroker = this.messageBroker;
this.configOptions.serviceDiscoveryType = this.serviceDiscoveryType;
this.configOptions.buildTool = this.buildTool;
this.configOptions.enableSwaggerCodegen = this.enableSwaggerCodegen;
this.configOptions.authenticationType = this.authenticationType;
const uaaBaseName = this.uaaBaseName;
if (uaaBaseName) {
this.configOptions.uaaBaseName = this.uaaBaseName;
}
this.configOptions.serverPort = this.serverPort;
// Make dist dir available in templates
this.BUILD_DIR = this.getBuildDirectoryForBuildTool(this.buildTool);
this.CLIENT_DIST_DIR = this.getResourceBuildDirectoryForBuildTool(this.configOptions.buildTool) + constants.CLIENT_DIST_DIR;
}
};
}
get configuring() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._configuring();
}
get default() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._default();
}
get writing() {
// Overriding the JHipster file generation with the custom one.
return writeFiles();
}
/* get install() {
Add any necessary installation steps here.
} */
get end() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._end();
}
};