-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
139 lines (105 loc) · 3.58 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
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
const inquirer = require("inquirer");
const fs = require("fs");
const axios = require('axios');
const generateMarkdown = require("./utils/generateMarkdown.js");
// create object with responses to pass into generateMarkdown
const responsesAll = {};
// create array with github and readme questions
const questionsGit = [
{
type: "input",
message: "What is your Github username?",
name: "gitUser"
},
{
type: "password",
message: "Enter your password:",
name: "gitPass"
},
{
type: "input",
message: "What is the name of your Github repository?",
name: "repoName"
},
{
type: "input",
message: "Enter a project description:",
name: "projDesc"
},
{
type: "input",
message: "Which tech frameworks were used:",
name: "projTech"
},
{
type: "input",
message: "Enter any installation instructions:",
name: "projInstall"
},
{
type: "input",
message: "Describe the application's functionality:",
name: "projUsage"
},
{
type: "list",
message: "Enter the license:",
choices: ["MIT", "Apache", "GPL"],
name: "projLicense"
},
{
type: "input",
message: "Enter any other contributing authors:",
name: "projAuth"
},
{
type: "input",
message: "Explain how to run the automated tests for this system:",
name: "projTests"
},
];
inquirer
.prompt(questionsGit)
.then(function(questionResponse) {
console.log('Done');
console.log('Github user: ', questionResponse.gitUser);
// console.log("questionResponse: ", questionResponse);
const queryURL = () => {
var queryURL = "https://api.github.com/repos/" + questionResponse.gitUser + "/" + questionResponse.repoName;
// return axios.get for queryURL response
return axios.get(queryURL)
};
const queryURLUser = () => {
var queryURLUser = "https://api.github.com/users/" + questionResponse.gitUser;
// return axios.get for queryURLUser response
return axios.get(queryURLUser);
};
axios.all([queryURL(), queryURLUser()])
.then(axios.spread(function (queryResponse, queryResponseUser) {
responsesAll.gitUser = questionResponse.gitUser;
// repo name ex: Hooking-Up-in-Your-Hood
responsesAll.repoName = questionResponse.repoName;
responsesAll.projDesc = questionResponse.projDesc;
responsesAll.projTech = questionResponse.projTech;
responsesAll.projInstall = questionResponse.projInstall;
responsesAll.projUsage = questionResponse.projUsage;
responsesAll.projLicense = questionResponse.projLicense;
responsesAll.projAuth = questionResponse.projAuth;
responsesAll.projTests = questionResponse.projTests;
// format for project clone URL:
// https://github.com/[username]/[repo-name].git
responsesAll.projCloneURL = "https://github.com/" + questionResponse.gitUser + "/" + queryResponse.data.name + ".git";
// format for project pull URL:
// https://github.com/[username]/[repo-name]/compare
responsesAll.projPullURL = "https://github.com/" + questionResponse.gitUser + "/" + queryResponse.data.name + "/compare";
console.log("responsesAll.gitUser: ", responsesAll.gitUser);
console.log("responsesAll.repoName: ", responsesAll.repoName);
console.log("responsesAll.projCloneURL: ", responsesAll.projCloneURL);
console.log("responsesAll.projPullURL: ", responsesAll.projPullURL);
const writeToFile = (responsesAll, data) => {
fs.writeFile("README_template.md", generateMarkdown(responsesAll, data))
};
// writeToFile(queryResponse, queryResponseUser, responsesAll);
writeToFile(responsesAll);
}));
});