-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
184 lines (174 loc) · 4.25 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
const inquirer = require("inquirer");
const fs = require("fs");
const generateTeam = require("./src/page-template.js");
const Manager = require("./lib/Manager");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
const teamMembers = [];
// inquirer questions here
// first question function is add manager
function addManager() {
console.log(`
=======================
Team Profile Generator!
=======================
`);
return inquirer
.prompt([
{
type: "input",
name: "managerName",
message: "To begin, please enter the name of the Team Manager:",
},
{
type: "input",
name: "managerID",
message: "Enter the employee ID for this manager:",
},
{
type: "input",
name: "managerEmail",
message: "Enter the email for this manager: ",
},
{
type: "input",
name: "managerOfficeNum",
message: "Enter the office number for this manager: ",
},
])
.then((answers) => {
const manager = new Manager(
answers.managerName,
answers.managerID,
answers.managerEmail,
answers.managerOfficeNum
);
teamMembers.push(manager);
console.log(teamMembers);
addNewMember();
});
}
// then addNewMember will handle engineer OR intern OR finish adding members
// use conditionals to determine which was chosen
// type: checkbox
function addEngineer() {
console.log(`
================
Add New Engineer
================
`);
return inquirer
.prompt([
{
type: "input",
name: "engineerName",
message: "Please enter the name of the engineer",
},
{
type: "input",
name: "engineerID",
message: "Please enter the employee ID number",
},
{
type: "input",
name: "engineerEmail",
message: "Enter their email",
},
{
type: "input",
name: "github",
message: "Enter their GitHub username",
},
])
.then((answers) => {
const engineer = new Engineer(
answers.engineerName,
answers.engineerID,
answers.engineerEmail,
answers.github
);
teamMembers.push(engineer);
addNewMember();
});
}
function addIntern() {
console.log(`
==============
Add New Intern
==============
`);
return inquirer
.prompt([
{
type: "input",
name: "internName",
message: "Enter the name of the intern",
},
{
type: "input",
name: "internID",
message: "Enter the employee ID",
},
{
type: "input",
name: "internEmail",
message: "Enter the email of this intern",
},
{
type: "input",
name: "school",
message: "Enter the school this intern is attending",
},
])
.then((answers) => {
const intern = new Intern(
answers.internName,
answers.internID,
answers.internEmail,
answers.school
);
teamMembers.push(intern);
addNewMember();
});
}
// IF finish: deploy => copyFile & writeFile
// ~ notate semantics for parameters
// take ~(data) => generatePage(data)
// then ~(pagehtml) => writeFile(pageHtml)
// then (writeFileResponse) => copyFile()
function addNewMember() {
return inquirer
.prompt([
{
type: "list",
name: "memberType",
message:
"Please select a role to add a new team member, otherwise select finish. ",
choices: ["Engineer", "Intern", "Finish building team"],
},
])
.then((choice) => {
console.log(choice.memberType);
if (choice.memberType === "Engineer") {
addEngineer();
}
if (choice.memberType === "Intern") {
addIntern();
}
if (choice.memberType === "Finish building team") {
console.log(teamMembers);
return finishTeam("./dist/index.html", generateTeam(teamMembers));
}
});
}
function finishTeam(fileName, data) {
console.log(teamMembers);
fs.writeFile(fileName, data, (err) => {
if (err) {
throw err;
} else {
console.log("File written. It lives in the ``/dist`` folder!");
}
});
}
addManager();