-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
84 lines (80 loc) · 2.36 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
//packages needed for this application
const fs = require("fs");
const path = require("path");
const inquirer = require("inquirer");
const generateMarkdown = require("./utils/generateMarkdown");
//array of questions for user input
const questions = [
{
type: "input",
name: "projTitle",
message: "Please enter a title for your project: ",
},
{
type: "input",
name: "projDescr",
message: "Please enter a short description of your project: ",
},
{
type: "list",
name: "projLicns",
message: "Please select a usage license for your project: ",
choices: ["MIT", "APACHE 2.0", "GPL 3.0", "BSD 3", "None"],
},
{
type: "input",
name: "projInstall",
message:
"Please enter a command that will be used to install the dependencies for your project (unless a custom value is necessary, it is recommended to leave the default alone and just hit enter here): ",
default: "npm i",
},
{
type: "input",
name: "projUsage",
message:
"Please enter a command that will be used to start the project (unless a custom value is necessary, it is recommended to leave the default alone and just hit enter here): ",
default: "npm start",
},
{
type: "list",
name: "projRepoLink",
message:
"Would you like to insert a placeholder for a GitHub repo link?",
choices: ["YES", "NO"],
},
{
type: "list",
name: "projDemoImage",
message:
"Would you like to insert a placeholder for a screenshot or other image file?",
choices: ["YES", "NO"],
},
{
type: "input",
name: "projContr",
message:
"Please enter any information the user needs in order to contribute to this porject: ",
},
{
type: "input",
name: "projTest",
message:
"Please enter a command that will be used to run the test scripts for your project (unless a custom value is necessary, it is recommended to leave the default alone and just hit enter here): ",
default: "npm test",
},
];
// function to write README file
function writeToFile(fileName, data) {
return fs.writeFileSync(path.join(process.cwd(), fileName), data);
}
// function to initialize app
function init() {
inquirer.prompt(questions).then((inquirerResponses) => {
console.log(
"The README.md file has now been generated in the same directory level as the project index file. Enjoy!"
);
writeToFile("README.md", generateMarkdown({ ...inquirerResponses }));
});
}
// function call to initialize app
init();