{"size": 2012, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "Mleuer/Good-README-Generator", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "Mleuer/Good-README-Generator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "Mleuer/Good-README-Generator", "max_forks_repo_forks_event_min_datetime": "2020-07-11T21:01:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-11T21:01:19.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 26.1298701299, "max_line_length": 135, "alphanum_fraction": 0.5849900596}
const api = require("./utils/api.js");
const inquirer = require("inquirer");
const generateMarkdown = require("./utils/generateMarkdown");
const fs = require('fs');
require('dotenv').config();






const questions = [
    {
        type: "input",
        name: "githubUsername",
        message: "What is your Github username?"
    },
    {
        type: "input",
        name: "projectTitle",
        message: "What is the title of your project?"
    },
    {
        type: "input",
        name: "badgeLabel",
        message: "What would you like your badge to say?"
    },
    {
        type: "input",
        name: "projectDescription",
        message: "Please describe your project."
    },
    {
        type: "input",
        name: "installation",
        message: "What are the steps required to install your project?"
    },
    {
        type: "input",
        name: "usage",
        message: "Provide instructions and examples for use."
    },
    {
        type: "rawlist",
        name: "license",
        message: "Choose your license",
        choices: ["ISC License (People can do anything with your code with proper attribution)", "MIT License (Simple and Permissive)"]
    },
    {
        type: "input",
        name: "contributors",
        message: "Comma separated list of Github profiles of contributors"
    },
    {
        type: "checkbox",
        name: "tableOfContents",
        message: "Which of the following would you like included in the Table of Contents?",
        choices: ["Installation", "Usage", "License", "Contributing", "Tests", "Questions"]
    }
];

function writeToFile(fileName, data) {
    fs.writeFile(fileName, data, (err) => {
        if (err) throw err;
        console.log('The file has been saved!');
    });
}

async function init() {
    const answers = await inquirer.prompt(questions);
    const user = await api.getUser(answers.githubUsername);
    const markDown = generateMarkdown(user, answers);
    writeToFile("README.md", markDown);
}

init();
