-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
70 lines (57 loc) · 1.67 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
'use strict';
const Generator = require('yeoman-generator');
const app = require('../../lib/generators/app');
const optionOrPrompt = require('../../lib/utils').yeomanOptionOrPrompt;
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);
// This method adds support for a `--use-cli-defaults` flag
this.option('useDefaults', {
name: 'use-cli-defaults',
description: 'Use default values if not provided (will not prompt)',
hide: false
});
// This method adds support for a `--run-gradle-build` flag
this.option('runGradleBuild', {
name: 'run-gradle-build',
description: 'Run build gradle on generated project',
hide: false
});
app.prompts.forEach(prompt =>
this.option(prompt.name, {
name: prompt.cliName,
description: prompt.message,
type: String,
default: (this.options.useCliDefaults || this.options.help) ? prompt.default : undefined,
hide: false
})
);
this._optionOrPrompt = optionOrPrompt;
}
initializing() {
this.props = {};
}
helloMsg() {
this.log('Yeoman spring boot mvc application generator from swagger api specification');
}
prompting() {
const self = this;
const done = self.async();
return this._optionOrPrompt(app.prompts).then(function responses(props) {
app.onResponses(self, props, done);
});
}
writing() {
app.write(this);
}
routing() {
app.routing(this);
}
end() {
if (this.options.runGradleBuild) {
this.spawnCommand('./gradlew', ['build']);
} else {
this.log('Skipping run gradle build (no --runGradleBuild flag set)');
}
}
};