-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
112 lines (102 loc) · 3.2 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
const inquirer = require('inquirer');
const promptUser = () => {
return inquirer.prompt([{
type: 'input',
name: 'name',
message: 'What is your name? (Required)',
validate: nameInput => {
if (nameInput) {
return true;
} else {
console.log('Please enter your name.');
return false;
}
}
}, {
type: 'input',
name: 'Github username',
message: 'Enter your GitHub Username'
}, {
type: 'confirm',
name: 'confirmAbout',
message: 'Would you like to enter some information about yourself for an "About" section?',
default: true
}, {
type: 'input',
name: 'about',
message: 'Provide some information about yourself:',
when: ({
confirmAbout
}) => {
if (confirmAbout) {
return true;
} else {
return false;
}
}
}]);
};
const promptProject = portfolioData => {
console.log(`
=================
Add a New Project
=================
`);
// If there's no 'projects' array property, create one
if (!portfolioData.projects) {
portfolioData.projects = [];
}
return inquirer.prompt.then(projectData => {
portfolioData.projects.push(projectData);
if (projectData.confirmAddProject) {
return promptProject(portfolioData);
} else {
return portfolioData;
}
})
([{
type: 'input',
name: 'Project name',
message: 'What is the name of your project?'
},
{
type: 'input',
name: 'Project description',
message: 'Provide a description of the project (Required)'
},
{
type: 'checkbox',
name: 'languages',
message: 'What did you build this project with? (Check all that apply)',
choices: ['JavaScript', 'HTML', 'CSS', 'ES6', 'jQuery', 'Bootstrap', 'Node']
},
{
type: 'input',
name: 'Project Github link',
message: 'Enter the GitHub link to your project. (Required)'
},
{
type: 'confirm',
name: 'feature',
message: 'Would you like to feature this project?',
default: false
},
{
type: 'confirm',
name: 'confirmAddProject',
message: 'Would you like to enter another project?',
default: false
}
]);
};
promptUser()
.then(answers => console.log(answers))
.then(promptProject)
.then(projectAnswers => console.log(projectAnswers));
// const fs = require('fs');
// const generatePage = require('./src/page-template.js');
// const pageHTML = generatePage(name, github);
// fs.writeFile('./index.html', generatePage(name, github), err => {
// if (err) throw new Error(err);
// console.log('Portfolio complete! Check out index.html to see the output!');
// });