-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
169 lines (159 loc) · 5.31 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
// TODO: Include packages needed for this application
const fs = require('fs');
const inquirer = require("inquirer")
const generateReadme = require("./utils/generateMarkdown.js")
// TODO: Create an array of questions for user input
const promptUser = () => {
return inquirer.prompt([{
type: 'input',
name: 'title',
message: 'What do you want to call this app?',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an app name.');
return false;
}
}
},
{
type: 'input',
name: 'description',
message: 'Enter a description of this app.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an app description.');
return false;
}
}
}, {
type: 'input',
name: 'installation',
message: 'Enter instructions on how to install the app.',
default: 'npm install'
}, {
type: 'input',
name: 'usage',
message: 'Provide information for how to use this app.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter instructions');
return false;
}
}
},
{
type: 'input',
name: 'contribution',
message: 'Who contributed to developing this app?',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an any contributors, or type "None".');
return false;
}
}
},
{
type: 'input',
name: 'tutorials',
message: 'Did you follow any tutorials? Include links or names here.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an any contributors, or type "None".');
return false;
}
}
},
{
type: 'input',
name: 'features',
message: 'If your project has a lot of features, list them here.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an any contributors, or type "None".');
return false;
}
}
},
{
type: 'input',
name: 'tests',
message: 'Provide examples of tests here.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an app name.');
return false;
}
}
},
{
type: 'input',
name: 'github',
message: 'What is your GitHub username? For users to see your other works.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter a username.');
return false;
}
}
},
{
type: 'input',
name: 'email',
message: 'What is your e-mail? For users to contact you with questions or if they would like to contribute.',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter an e-mail.');
return false;
}
}
},
])
// .then(answers => {
// var X = generateReadme(answers)
// console.log(X);
// console.log(answers);
// })
// .catch(('generating the readme did not work') => {
// console.log('generating the readme did not work');
// });
};
// TODO: Create a function to write README file
// TODO: Create a function to initialize app
// Function call to initialize app
// promptUser()
// .then(answers => console.log(answers))
// .then(answers => {
// const readME = generateReadme(answers);
// fs.writeFile('dist/readme.md', readME, err => {
// if (err) throw new Error(err);
// console.log('Page created! Look at your new Readme.md in this directory to see it.')
// });
// });
promptUser()
// .then looks for user input - "answers" is just to represent that data below. It is not a defined variable above
.then(answers => {
console.log(answers)
const readME = generateReadme(answers)
fs.writeFile('dist/readme.md', readME, err => {
if (err) throw new Error(err);
console.log('Page created! Look at your new Readme.md in this directory to see it.')
});
});