// TODO: Include packages needed for this application
const inquirer = require('inquirer');
const fs = require('fs');
const generateMarkdown = require('./utils/generateMarkdown')

// TODO: Create an array of questions for user input
const questions = [
    {
        type: 'input',
        message: 'What is yoru GitHub username?',
        name: 'github',
    },
    {
        type: 'input',
        message: 'What is your email address?',
        name: 'email',
    },
    {
        type: 'input',
        message: 'What is your project\'s name?',
        name: 'projectName',
    },
    {
        type: 'input',
        message: 'Please write a short description of your project',
        name: 'projectDesc',
    },
    {
        type: 'list',
        message: 'What kind of license should your project have? (Use arrow keys below)',
        name: 'license',
        choices: ['MIT', 'APACHE 2.0', 'GPL 3.0', 'BSD 3', 'NONE'],
    },
    {
        type: 'input',
        message: 'What command should be run to install dependencies?',
        name: 'dependencies',
    },
    {
        type: 'input',
        message: 'What command should be run to run tests?',
        name: 'tests',
    },
    {
        type: 'input',
        message: 'What does the user need to know about using the repo? (to skip press enter)',
        name: 'repoNeedToKnow',
    },
    {
        type: 'input',
        message: 'What does the user need to know about contributing to the repo? (to skip press enter)',
        name: 'repoContribute',
    },
];



// TODO: Create a function to write README file
function writeToFile(fileName, data) {
    fs.writeFile(fileName, data, (err) =>
    err ? console.log("There was an error. Please review and try, again.") : console.log("\nGenerating README.md...")
)};

// TODO: Create a function to initialize app
function init() {
    inquirer.prompt(questions)
        .then((answers) => {
            // console.log(answers);
            const data = generateMarkdown.generateMarkdown(answers);
            let fileName = 'README.md'
            writeToFile(fileName, data);
        })
    };

// Function call to initialize app
init();
