-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
153 lines (146 loc) · 3.9 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
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
const inquirer = require('inquirer');
const fs = require('fs');
const generateMarkdown = require('./utils/generateMarkdown');
const path = require('path');
const questions =
[
{
type: 'input',
name: 'title',
message: 'What is the title of your repository?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add a title for your repository.');
}
}
},
{
type: 'input',
name: 'description',
message: 'Please describe your application.',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add a description of your application.');
}
}
},
{
type: 'input',
name: 'install',
message: 'What are the instructions for installation?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add installation instructions.');
}
}
},
{
type: 'input',
name: 'usage',
message: 'What information is there for the usage of your application?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add information for usage.');
}
}
},
{
type: 'input',
name: 'guidelines',
message: 'What are the contribution guidelines?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add contribution guidelines.');
}
}
},
{
type: 'input',
name: 'test',
message: 'What are the instructions for testing this application?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add testing instructions.');
}
}
},
{
type: 'checkbox',
name: 'license',
message: 'Please choose a license for this application.',
choices: ['MIT', 'Mozilla', 'IBM', 'Apache', 'BSD 3-Clause', 'Eclipse', 'Other', 'None'],
validate: function (response) {
if (response.checked = true) {
return true;
console.log(response.value)
} else {
return console.log( 'Please choose a license.');
}
}
},
{
type: 'input',
name: 'github',
message: 'What is your Github username?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add your Github username.');
}
}
},
{
type: 'input',
name: 'email',
message: 'What is your email address?',
validate: function (response) {
if (response.includes("@")===true) {
return true;
} else {
return console.log( 'Please add your email.');
}
}
},
{
type: 'input',
name: 'links',
message: 'What links will you be using for your appliction?',
validate: function (response) {
if (response.length > 1) {
return true;
} else {
return console.log( 'Please add links to your application.');
}
}
},
];
function writeToFile(fileName, data) {
return fs.writeFileSync(path.join(process.cwd(), fileName), data);
}
// TODO: Create a function to write README file
function init() {
inquirer.prompt(questions)
.then((responses) => {
try {
writeToFile('README.md', generateMarkdown({ ...responses }));
console.log('You have completed you README.md!');
}catch (error) {
console.log(error)
}
});
}
// Function call to initialize app
init();