{"size": 2191, "ext": "js", "max_stars_repo_path": "lib/messageChecks.js", "max_stars_repo_name": "aymen-mouelhi/fixme-to-issue", "max_stars_repo_stars_event_min_datetime": "2017-03-25T16:58:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-27T00:29:04.000Z", "max_issues_repo_path": "lib/messageChecks.js", "max_issues_repo_name": "aymen-mouelhi/fixme-to-issue", "max_issues_repo_issues_event_min_datetime": "2017-03-19T00:49:03.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-26T10:08:01.000Z", "max_forks_repo_path": "lib/messageChecks.js", "max_forks_repo_name": "aymen-mouelhi/fixme-to-issue", "max_forks_repo_forks_event_min_datetime": "2017-11-07T09:30:30.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-14T19:46:51.000Z"}
{"max_stars_count": 8, "max_issues_count": 29, "max_forks_count": 3, "avg_line_length": 30.4305555556, "max_line_length": 123, "alphanum_fraction": 0.4125969877}
const chalk = require('chalk');
var annotations = {};

function getChalkColorer(color){
  if(color.indexOf('.') > 0){
    var c = color.split('.');
    return chalk[c[0]][c[1]];
  }else{
    return chalk[color];
  }
}

try {
    // TODO: Add option to add default label saying issue is created by bot [Issue #107]
    var options = JSON.parse(require('fs').readFileSync(require('path').resolve(__dirname, '../.fixme-to-issue'), 'utf8'));

    if (options.annotations) {
        options.annotations.forEach(function(annotation) {
          var regex = new RegExp("[\/\/][\/\\*]\\s*"+ annotation.name +"\\s*(?:\\(([^:]*)\\))*\\s*:?\\s*(.*)", "i");
          annotations[annotation.name.toLowerCase()] = {
            regex: regex,
            label: annotation.name,
            colorer: getChalkColorer(annotation.color),
            githubLabel: annotation.label
          }
        });
    }
} catch (e) {
    console.log(`${e}`);
} finally {
    annotations = annotations || {
        note: {
            regex: /[\/\/][\/\*]\s*NOTE\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ✐ NOTE',
            colorer: chalk.green
        },
        optimize: {
            regex: /[\/\/][\/\*]\s*OPTIMIZE\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ↻ OPTIMIZE',
            colorer: chalk.blue
        },
        todo: {
            regex: /[\/\/][\/\*]\s*TODO\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ✓ TODO',
            colorer: chalk.magenta
        },
        hack: {
            regex: /[\/\/][\/\*]\s*HACK\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ✄ HACK',
            colorer: chalk.yellow
        },
        xxx: {
            regex: /[\/\/][\/\*]\s*XXX\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ✗ XXX',
            colorer: chalk.black.bgYellow
        },
        fixme: {
            regex: /[\/\/][\/\*]\s*FIXME\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ☠ FIXME',
            colorer: chalk.red
        },
        bug: {
            regex: /[\/\/][\/\*]\s*BUG\s*(?:\(([^:]*)\))*\s*:?\s*(.*)/i,
            label: ' ☢ BUG',
            colorer: chalk.white.bgRed
        }
    };
}


module.exports = annotations;
