-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
199 lines (153 loc) · 5.42 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
const inquirer = require('inquirer');
const fs = require("fs");
const util = require("util");
const { captureRejectionSymbol } = require("events");
const { fileURLToPath } = require('url');
const writeFileAsync = util.promisify(fs.writeFile);
// const mitURL = "https://opensource.org/licenses/MIT)";
// const gnuURL = "https://www.gnu.org/licenses/gpl-3.0";
const outline = [
{ // add title
type: "input",
name: "title",
message: "What is the name of your project?"
},
{ // add description
type: "input",
name: "description",
default: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
message: "Enter description of application."
},
{ // add default table of contents
type: "checkbox",
name: "tableOfContents",
message: "Select all to add Table of Contents",
default: ["Installation", "Usage", "Contributing", "Tests", "Questions", "License"],
choices: [
"Installation",
"Usage",
"Contributing",
"Tests",
"Questions",
"License",
],
},
{ // add installation instruction step 1
type: "input",
name: "installStep1",
message: "Installation Instructions (Step 1):"
},
{ // add installation instruction step 2
type: "input",
name: "installStep2",
message: "Installation Instructions (Step 2):"
},
{ // add installation instruction step 3
type: "input",
name: "installStep3",
message: "Installation Instructions (Step 3):"
},
{ // add usage information step 1
type: "input",
name: "usageStep1",
message: "Operating Instructions (Step 1)"
},
{ // add usage information step 2
type: "input",
name: "usageStep2",
message: "Operating Instructions (Step 2)"
},
{ // add usage information step 3
type: "input",
name: "usageStep3",
message: "Operating Instructions (Step 3)"
},
{ // add usage information
type: "input",
name: "screenshot",
default: "screenshot-img",
message: "Add screenshot placeholder (ex. img-name)"
},
{ // add GitHub username to questions section
type: "input",
name: "userName",
message: "Enter your GitHub username"
},
{ // add email address to questions section
type: "input",
name: "userEmail",
message: "Enter your email address"
},
{ // select a license
type: "list",
name: "license",
message: "Select a license",
choices: [
"MIT",
"GPLv3",
"MPL%202.0"
]
},
]
const promptUser = () => {
return inquirer.prompt(outline);
};
// var license = answers.license[i]
// const license = {
// "MIT": answers.license[0],
// "GNU-GPLv3": answers.license[1],
// "Mozilla": answers.license[2]
// };
// for (i = 0; i < answers.tableOfContents.length; i++) {
// return answers.tableOfContents[i];
// }
const generateREADME = (answers) => {
return `# ${answers.title} ![License: ${answers.license}](https://img.shields.io/badge/License-${answers.license}-yellow.svg)
## Description
${answers.description}
## Table of Contents
* [${answers.tableOfContents[0]}](#${answers.tableOfContents[0]})
* [${answers.tableOfContents[1]}](#${answers.tableOfContents[1]})
* [${answers.tableOfContents[2]}](#${answers.tableOfContents[2]})
* [${answers.tableOfContents[3]}](#${answers.tableOfContents[3]})
* [${answers.tableOfContents[4]}](#${answers.tableOfContents[4]})
* [${answers.tableOfContents[5]}](#${answers.tableOfContents[5]})
## Installation
Steps required to install application:
1. ${answers.installStep1}
2. ${answers.installStep2}
3. ${answers.installStep1}
## Usage
Operating instructions and examples for use.
1. ${answers.usageStep1}
![${answers.screenshot} alt](https://via.placeholder.com/150)
2. ${answers.usageStep2}
![${answers.screenshot} alt](https://via.placeholder.com/150)
3. ${answers.usageStep3}
![${answers.screenshot} alt](https://via.placeholder.com/150)
## Contributing
*If you would like other developers to contribute to your application add guidelines for how to do so.*
## Tests
*Tests for application. Examples on how to run them.*
## Questions
Link to my [GitHub Profile](https://github.com/${answers.userName})
You can reach me at ${answers.userEmail} if you have any additional questions.
## License
[${answers.license} License](${answers.license}License.txt)
---
© 2020 Trilogy Education Services, LLC, a 2U, Inc. brand. Confidential and Proprietary. All Rights Reserved.
`
}
const init = async () => {
try {
const addedText = await promptUser();
// console.log(addedText);
const readme = generateREADME(addedText);
// console.log(readme);
await writeFileAsync("New_README.md", readme);
console.log("Successfully wrote README.md");
} catch (error) {
console.log(error);
}
}
init();