-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
177 lines (150 loc) · 6.99 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
const Manager = require("./lib/Manager");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
const inquirer = require("inquirer");
const path = require("path");
const fs = require("fs");
const OUTPUT_DIR = path.resolve(__dirname, "output");
const outputPath = path.join(OUTPUT_DIR, "team.html");
const render = require("./lib/htmlRenderer");
// Use inquirer to gather information about the development team members, and to create objects for each team member using classes
const employees = [];
createTeam();
function createTeam() {
// Inquirer Prompt #1
console.log("Please build your team")
inquirer.prompt([
// Questions about the manager
{
type: "input",
message: " \n \n What is your manager's name? \n \n ",
name: "name",
default: "Manager's Name"
},
{
type: "input",
message: " \n \n What is your manager's id? \n \n ",
name: "id",
default: "Manager's ID Number"
},
{
type: "input",
message: " \n \n What is your manager's email? \n \n ",
name: "email",
default: "manager@email.com"
},
{
type: "input",
message: " \n \n What is your manager's office number? \n \n ",
name: "officeNumber",
default: "Manager's Office Number"
}
])
.then(function (managerAnswers) {
const manager = new Manager(managerAnswers.name, managerAnswers.id, managerAnswers.email, managerAnswers.officeNumber);
employees.push(manager);
// Recursion
// Inquirer Prompt #2
teamPrompt()
function teamPrompt() {
inquirer.prompt([
// Select your team member
{
type: "list",
message: " \n \n Which type of team member would you like to add? \n \n ",
name: "employee",
choices: [
"Engineer",
"Intern",
"No more team members"
]
}
])
.then(function (typeAnswers) {
if (typeAnswers.employee === "Engineer") {
// Inquirer Prompt #3
engineerPrompt()
function engineerPrompt() {
inquirer.prompt([{
// Questions about the engineer
type: "input",
message: " \n \n What is your engineer's name? \n \n ",
name: "name",
default: "Engineer's Name"
},
{
type: "input",
message: " \n \n What is your engineer's id? \n \n ",
name: "id",
default: "Engineer's ID Number"
},
{
type: "input",
message: " \n \n What is your engineer's email? \n \n ",
name: "email",
default: "engineer@email.com"
},
{
type: "input",
message: " \n \n What is your engineer's Github? \n \n ",
name: "github",
default: "Engineer's GitHub username"
}
])
.then(function (engineerAnswers) {
const engineer = new Engineer(engineerAnswers.name, engineerAnswers.id, engineerAnswers.email, engineerAnswers.github);
employees.push(engineer);
teamPrompt();
})
}
} else if (typeAnswers.employee === "Intern") {
// Inquirer Prompt #4
internPrompt()
function internPrompt() {
inquirer.prompt([
// Questions about the intern
{
type: "input",
message: " \n \n What is your intern's name? \n \n ",
name: "name",
default: "Intern's Name"
},
{
type: "input",
message: " \n \n What is your intern's id? \n \n ",
name: "id",
default: "Intern's ID Number"
},
{
type: "input",
message: " \n \n What is your intern's email? \n \n ",
name: "email",
default: "intern@email.com"
},
{
type: "input",
message: " \n \n What is your intern's school? \n \n ",
name: "school",
default: "Intern's School"
}
])
.then(function (internAnswers) {
const intern = new Intern(internAnswers.name, internAnswers.id, internAnswers.email, internAnswers.school);
employees.push(intern);
teamPrompt();
})
}
} else {
//Exit the inquirer
const html = render(employees);
fs.writeFile(outputPath, html, function (err) {
if (err) {
return console.log(err);
};
});
console.log("Team successfully created!");
}
})
}
})
}