-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
110 lines (102 loc) · 2.66 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
'use strict';
const BaseGenerator = require('../../utils/BaseGenerator');
const chalk = require('chalk');
const yosay = require('yosay');
module.exports = class extends BaseGenerator {
prompting() {
// Have Yeoman greet the user.
this.log(yosay('Welcome to ' + chalk.red('Hapi Swagger ES6') + ' generator!'));
const { author, email = this.git.email() } = this._getNPMConfig();
const prompts = [
// Server
{
type: `input`,
name: 'service.name',
message: `Server Name`,
default: this._hyphenate(this.appname)
},
{
type: `input`,
name: 'service.description',
message: `Description (what does this server do)`,
default: 'A modern hapijs backend'
},
{
type: `input`,
name: 'service.port',
message: `Default port of the server`,
default: 3000
},
// Author
{
type: `input`,
name: 'author.fullName',
message: `Author (also used in license)`,
default: author.trim(),
store: true
},
{
type: `input`,
name: 'author.name',
message: `Author short name`,
default: this._hyphenate(author.trim()),
store: true
},
{
type: `input`,
name: `author.email`,
message: `Author Email`,
default: email.trim(),
store: true
},
{
type: `input`,
name: `author.github`,
message: `Github Username`,
store: true
},
// Docker
{
type: `confirm`,
name: `useDocker`,
default: true,
message: `Do want to use docker ?`
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
default() {
const { fullName: name, email } = this.props.author;
this.composeWith(require.resolve('generator-license'), {
name,
email,
licensePrompt: 'Which license do you want to use?',
defaultLicense: 'MIT'
});
}
writing() {
console.log(this.prompt === require('inquirer').prompt);
// Folders
this._copyFile('lib');
this._copyFile('test');
this._copyFile('config');
// Root files
this._copyFile('.gitignore');
this._copyFile('.eslintignore');
this._copyFile('.eslintrc');
// Docker
if (this.props.useDocker) {
this._copyFile('docker-compose.yml');
this._copyFile('Dockerfile');
}
this._copyFile('README.md');
// Special files
this._copyFile({ from: '__package.json', to: 'package.json' });
}
install() {
/* This.installDependencies(); */
}
};