{"size": 2749, "ext": "js", "max_stars_repo_path": "utils/generateMarkdown.js", "max_stars_repo_name": "ferwicker/readme-generator", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "utils/generateMarkdown.js", "max_issues_repo_name": "ferwicker/readme-generator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "utils/generateMarkdown.js", "max_forks_repo_name": "ferwicker/readme-generator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6456692913, "max_line_length": 96, "alphanum_fraction": 0.6515096399}
//License objects
const MIT = {
  badge: 'https://img.shields.io/badge/License-MIT-yellow.svg',
  link: 'https://opensource.org/licenses/MIT'
}

const Apache2 = {
  badge: 'https://img.shields.io/badge/License-Apache%202.0-blue.svg',
  link: 'https://opensource.org/licenses/Apache-2.0',
}

const CreativeCommons = {
  badge: 'https://img.shields.io/badge/License-CC0%201.0-lightgrey.svg',
  link: 'http://creativecommons.org/publicdomain/zero/1.0/',
}

const GPLv2 = {
  badge: 'https://img.shields.io/badge/License-GPL%20v2-blue.svg',
  link: 'https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html',
}

const GPLv3 = {
  badge: 'https://img.shields.io/badge/License-GPLv3-blue.svg',
  link: 'https://www.gnu.org/licenses/gpl-3.0',
}


const getLicenseInfo = ({badge, link}, license) => {
  return `## License
  [![License badge](${badge})](${link})

  This work is covered by ${license} license. For more information [see full license.](${link})`
}


function renderLicenseSection(license, name) {
  let licCode;

  switch (license){
    case 'MIT':
      licCode = MIT;
      break;
    case 'Apache 2.0':
      licCode = Apache2;
      break;
    case 'Creative Commons':
      licCode = CreativeCommons;
      break;
    case 'GPLv2':
      licCode = GPLv2;
      break;
    case 'GPLv3':
      licCode = GPLv3;
      break;
  }

  if (license === 'no license') {
    return `## License
    No license.`
  } else {
    return `${getLicenseInfo(licCode, license)}
  ${license} © ${name}`
  }
  
}

// generate screenshot if link provided
function screenshot (confirm, screenshot, title){
  if (confirm){
    return `![${title} screenshot](${screenshot})
    `;
  } else {
    return '';
  }
}


// Create a function to generate markdown for README
function generateMarkdown(data) {
  const licenseSection = renderLicenseSection(data.license, data.name);
  const screenshottext = screenshot(data.screenshotconfirm, data.screenshot, data.title);

  return `# ${data.title}

  ## Description
  ${data.description}

  [See deployed application.](${data.deployedLink})

  ## Table of Contents
  - [Features](#features)
  - [Installation](#installation)
  - [How to use](#how-to-use)
  - [Licence](#licence)
  - [Contributing](#contributing)
  - [Tests](#tests)
  - [Questions and Feedback](#questions-and-feedback)

  ## Features
  ${data.features}
  ${screenshottext}

  ## Installation
  ${data.installation}

  ## How to use
  ${data.howtouse}

  ${licenseSection}

  ## Contributing
  ${data.contributing}

  ## Tests
  ${data.tests}

  ## Questions and Feedback
  Got questions or feedback? You can contact me on:

  - [Github](https://github.com/${data.username})
  - [Email](mailto:${data.email})

`;
}

module.exports = generateMarkdown;
