-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
239 lines (235 loc) · 5.57 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
const fs = require("fs");
const path = require("path");
const inquirer = require("inquirer");
const util = require("util");
const generateMarkdown = require("./utils/generateMarkdown");
// array of questions for user
const questions = () =>
inquirer.prompt([
{
type: "input",
name: "title",
message: "What is the title to this project?\n >> ",
},
{
type: "input",
name: "repoUrl",
message: "Add your repository complete link here,\n Example: 'https://github.com/<USERNAME>/<REPONAME>':\n >> ",
validate(answer) {
if (answer === ""){
return "You must add the repository URL.";
}
return true;
}
},
{
type: "confirm",
name: "licenseConf",
message: "Do you have a LICENSE file on the root of this repo?\n >> "
},
{
type: "list",
name: "license",
message: "How your LICENSE file looks like?",
choices: [
"LICENSE",
"LICENSE.txt",
"License.txt",
"LICENSE.md",
"License.md",
],
when(answers){
return answers.licenseConf;
}
},
{
type: "confirm",
name: "linkedin",
message: "Do you want add your LinkedIn at this file?\n >> ",
},
{
type: "input",
name: "linkedinUrl",
message: "Add your LinkedIn profile url.\n Example: https://www.linkedin.com/in/<USERNAME>/\n >> ",
when(answers) {
return answers.linkedin;
}
},
{
type: "confirm",
name: "logo",
message: "Have your project a logo?\n >> ",
},
{
type: "input",
name: "logoPath",
message: "Add your logo path.\n Example: images/logo.png\n >> ",
when(answers){
return answers.logo;
},
},
{
type: "input",
name: "shortDescription",
message: "Add a short description of your project.\n >>"
},
{
type: "confirm",
name: "screen",
message: "Have your project a screen shot?\n >> ",
},
{
type: "input",
name: "screenPath",
message: "Add your screen shot path.\n Example: images/screenshot.png\n >> ",
when(answers){
return answers.screen;
},
},
{
type: "editor",
name: "about",
message: "Write what your project is about:\n >> ",
waitUserInput: true,
},
{
type: "checkbox",
name: "builtWith",
message: "Select which tecnology did you use on this project:",
choices: [
new inquirer.Separator(" = Program Languages = "),
{
name: "JavaScript",
},
{
name: "Python",
},
{
name: "Ruby",
},
{
name: "Go",
},
{
name: "Rust",
},
{
name: "C",
},
{
name: "C++",
},
{
name: "Java",
},
new inquirer.Separator(" = Frameworks = "),
{
name: "React",
},
{
name: "jQuery",
},
{
name: "Bootstrap",
},
{
name: "Django",
},
{
name: "RubyonRails",
},
{
name: "None",
},
],
validate(answer) {
if (answer.length < 1){
return "You must choose at least one topping.";
}
return true;
}
},
{
type: "confirm",
name: "prereqConf",
message: "Do you want to add the Prerequisites section to your Readme?\n >> ",
},
{
type: "editor",
name: "prereq",
message: "Write the Prerequisites necessary for this application.\n You can write it using Markdown syntax.\n >> ",
waitUserInput: true,
when(answers){
return answers.prereqConf;
},
},
{
type: "confirm",
name: "installConf",
message: "Do you want to add the Installation steps to your app on Readme?\n >> ",
},
{
type: "editor",
name: "install",
message: "Write the Installation steps.\n You can write it using Markdown syntax.\n >> ",
waitUserInput: true,
when(answers){
return answers.installConf;
},
},
{
type: "confirm",
name: "contri",
message: "Do you want to add contributing steps to this document?\n >> ",
},
{
type: "confirm",
name: "contact",
message: "Do you want to add your email contact at this document?\n >> "
},
{
type: "input",
name: "name",
message: "Add your name:\n >> ",
when(answers){
return answers.contact;
}
},
{
type: "input",
name: "email",
message: "Add your email:\n >> ",
when(answers){
return answers.contact;
}
},
{
type: "confirm",
name: "videoConf",
message: "Your project have a YouTube video?\n >> "
},
{
type: "input",
name: "video",
message: "Add the video link here.\n Format: https://www.youtube.com/watch?v=AXmt05ZcT7k\n >> ",
when(answers){
return answers.videoConf;
}
},
]);
// function to write README file
const writeToFile = (fileName, quest) => {
const write = util.promisify(fs.writeFile);
quest()
.then((data) => write(fileName, generateMarkdown(data)))
.then(() =>
console.log(
"Successfully you have a amazing Readme file to add to your repo."
)
)
.catch((err) => console.error(err));
};
// function to initialize program
const init = () => writeToFile("README.md", questions);
// function call to initialize program
init();