-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
94 lines (90 loc) · 2.99 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
// packages needed for this application
const inquirer = require('inquirer');
const fs = require('fs');
const generateMarkdown = require('./Develop/utils/generateMarkdown.js');
// array of questions for user input
const questions = // promopt questions for user's readme
[
{
type: 'input',
name: 'title',
message: 'What is the title of your project?',
validate: projectNameInput => {
if (projectNameInput) {
return true;
} else if (!projectNameInput){
console.log("Please enter your project name!")
return false;
}
}
},
{
type: 'input',
name: 'description',
message: 'Please provide a description of your project:',
validate: descriptionInput => {
if (descriptionInput) {
return true;
} else {
console.log('Descriptions are necessary for a quality readme, please provide one!')
return false;
}
}
},
{
type: 'input',
name: 'installation',
message: 'Please provide step-by-step instructions on how to get the development environment running:'
},
{
type: 'input',
name: 'usage',
message: 'Please provide instructions for use. '
},
{
type: 'input',
name: 'test',
message: 'Provide examples on how to run tests of your application, is there are any:'
},
{
type: 'input',
name: 'contributors',
message: 'List all collaborators (if any) with links to their Github. \n If you used any third-party assets that require attribution, list links to their primary web presence.'
},
{
type: 'list',
name: 'license',
message: 'Please choose an appropriate license for this project: \n if you need help choosing a license, please refer to: (https://choosealicense.com/) ',
choices: ["MIT", "Apache", "ISC", "Mozilla", "GNU GPL v3", "Eclipse"]
},
{
type: 'input',
name: 'github',
message: 'Please provide your github username for additional questions regarding your project:'
},
{
type: 'input',
name: 'email',
message: 'Please provide an email for additional questions regarding your project:'
}
];
//function to write README file
function writeToFile(fileName, data) {
fs.writeFile(fileName, data, err => err ?
console.log(err) : console.log('Readme Generated!'));
}
//function to initialize app
function init() {
inquirer
.prompt(questions)
.then(answers => {
//do stuff with answers
console.log(answers)
// generateMarkdown(answers);
// after all answers are collected, write to file
// builds a string that uses answers to generate markdown
writeToFile('./Develop/README.md', generateMarkdown(answers))
});
}
// Function call to initialize app
init();