-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
206 lines (174 loc) · 5.54 KB
/
app.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
const fs = require("fs")
const inquirer = require("inquirer")
const path = require("path")
// Require class Files
const Manager = require("./lib/Manager")
const Engineer = require("./lib/Engineer")
const Intern = require("./lib/Intern")
const OUTPUT_DIR = path.resolve(__dirname, "output");
const outputPath = path.join(OUTPUT_DIR, "team.html");
const render = require("./lib/htmlRenderer");
const Choice = require("inquirer/lib/objects/choice")
const employee = []
inquirer.prompt([
{
type: "input",
name: "name",
message: "What is the Manager's name?"
},
{
type: "input",
name: "id",
message: "What is the Manager's ID?"
},
{
type: "input",
name: "email",
message: "What is the Manager's email?"
},
{
type: "input",
name: "officeNo",
message: "What is the Manager's office number?"
},
{
type: "rawlist",
name: "role",
message: "Which type of team member would you like to add?",
choices: ["Engineer", "Intern", "I don't want to add any more team members"]
}
]).then(function (res) {
employee.push(new Manager(res.name, res.id, res.email, res.officeNo))
if (res.role === "Engineer") {
return promptEngineer()
} else if (res.role === "Intern") {
return promptIntern()
} else {
fs.writeFile(outputPath, render(employee), function (err) {
if (err) throw err
})
console.log("Generating HTML file with this info...")
}
})
function promptEngineer() {
inquirer.prompt([
{
type: "input",
name: "name",
message: "What is the Engineer's name?"
},
{
type: "input",
name: "id",
message: "What is the Engineer's ID?"
},
{
type: "input",
name: "email",
message: "What is the Engineer's email?"
},
{
type: "input",
name: "github",
message: "What is the Engineer's GitHub Username?"
},
{
type: "rawlist",
name: "role",
message: "Which type of team member would you like to add?",
choices: ["Engineer", "Intern", "I don't want to add any more team members"]
}
]).then((res) => {
employee.push(new Engineer(res.name, res.id, res.email, res.github))
if (res.role === "Engineer") {
return promptEngineer()
} else if (res.role === "Intern") {
return promptIntern()
} else {
fs.writeFile(outputPath, render(employee), (err) => {
if (err) throw err
})
console.log("Generating HTML file with this info...")
}
})
}
function promptIntern() {
inquirer.prompt([
{
type: "input",
name: "name",
message: "What is the Intern's name?"
},
{
type: "input",
name: "id",
message: "What is the Intern's ID?"
},
{
type: "input",
name: "email",
message: "What is the Intern's email?"
},
{
type: "input",
name: "school",
message: "What is the Intern's school?"
},
{
type: "rawlist",
name: "role",
message: "Which type of team member would you like to add?",
choices: ["Engineer", "Intern", "I don't want to add any more team members"]
}
]).then((res) => {
employee.push(new Intern(res.name, res.id, res.email, res.school))
if (res.role === "Engineer") {
return promptEngineer()
} else if (res.role === "Intern") {
return promptIntern()
} else {
fs.writeFile(outputPath, render(employee), (err) => {
if (err) throw err
})
console.log("Generating HTML file with this info...")
}
})
}
// function (res) {
// const engineer = `<!DOCTYPE html>
// <html lang="en">
// <head>
// <meta charset="UTF-8">
// <meta name="viewport" content="width=device-width, initial-scale=1.0">
// <!-- Bootstrap CDN -->
// <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
// <!-- jQuery CDN -->
// <script src="https://code.jquery.com/jquery-3.5.1.min.js"
// integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
// <title>Intern Info</title>
// </head>
// <body>
// <!-- Start Bootstrap Body-->
// <!-- <div class="jumbotron jumbotron-fluid"> -->
// <!-- <div class="container bg-white pb-5"> -->
// <!-- <h1 class="p-5 bg-danger text-center text-white">My Team</h1> -->
// <!-- Start Row-->
// <div class="row row ml-5 mr-5 mt-5">
// <!-- Start Card Layout-->
// <div class="col-4">
// <div class="border shadow p-3 mb-5 rounded bg-light" style="width: 18rem;">
// <div class="card-header bg-danger text-white">
// <h2 class="font-weight-normal">${res.name}</h2>
// <h3 class="font-weight-normal">${res.title}</h3>
// </div>
// <ul class="list-group list-group-flush border mt-4 mb-4">
// <li class="list-group-item">${res.id}</li>
// <li class="list-group-item">${res.email}</li>
// <li class="list-group-item">${res.gitHubUser}</li>
// </ul>
// </div>
// </div>
// </div>
// </body>
// </html>`
// }