-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.js
61 lines (47 loc) · 1.99 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
// Imports
import { generateMarkdown } from './src/generateMarkdown.js';
import { promptUser } from './src/promptUser.js';
import { promptDescription } from './src/promptDescription.js'
import { promptUserStory } from './src/promptUserStory.js';
import { promptResourcesUsed } from './src/promptResourcesUsed.js';
import { promptUsage } from './src/promptUsage.js';
import { promptContributors } from './src/promptContributors.js'
import { promptContactInfo } from './src/promptContactInfo.js';
// utils imports
import { writeToFile } from './utils/writeFile.js';
import { clearDistDirectory } from './utils/clearDistDirectory.js';
const initializeApp = async () => {
try {
// Clear /dist directory when user initializes the app
clearDistDirectory();
// Let userResponse be what promptUser collects
let userResponse = await promptUser();
// Run promptDescription if userResponse is true
if (userResponse.confirmDescription) {
userResponse = await promptDescription(userResponse);
}
if (userResponse.confirmUserStory) {
userResponse = await promptUserStory(userResponse);
}
if (userResponse.confirmResourcesUsed) {
userResponse = await promptResourcesUsed(userResponse);
}
if (userResponse.confirmUsage) {
userResponse = await promptUsage(userResponse);
}
if (userResponse.confirmContributors) {
userResponse = await promptContributors(userResponse);
}
if (userResponse.confirmContactInfo) {
userResponse = await promptContactInfo(userResponse);
}
// Generate the README using userResponse data
const fileContent = generateMarkdown(userResponse);
// Write userResponse to the file
await writeToFile(fileContent);
console.log('README File successfully generated.');
} catch (error) {
console.error('An error occured:', error.message);
}
}
initializeApp();