<commit_before>const GitHubApi = require('github');
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const frontMatter = require("front-matter");

const github = new GitHubApi({
    protocol: "https",
    host: "api.github.com",
    pathPrefix: "",
    timeout: 5000
})
const commentDataPath = path.join(__dirname, '../_data/commentrefs.yml');
const postDirectory = path.join(__dirname, '../_posts/');
const siteRoot = "http://skwi.fr";

function getFrontMatterForPost(postFilename) {
    return frontMatter(fs.readFileSync(path.join(postDirectory, postFilename), 'utf8')).attributes;
}
function getIssueIdForPost(postFilename) {
    let commentData = yaml.safeLoad(fs.readFileSync(commentDataPath, 'utf8'));
    return commentData[postFilename] !== undefined ? commentData[postFilename] : null;
}
function setIssueIdForPost(postFilename, issueId) {
    let commentData = yaml.safeLoad(fs.readFileSync(commentDataPath, 'utf8'));
    commentData[postFilename] = issueId;
    fs.writeFileSync(commentDataPath, yaml.safeDump(commentData), 'utf8');
}


fs.readdirSync(postDirectory, 'utf8').forEach(postFile => {
    let postInfo = getFrontMatterForPost(postFile);
    console.log(`\nChecking comments for post "${postInfo.title}" (${postFile})`);

    if (getIssueIdForPost(postFile) !== null) {
        console.log(`EXISTING !`);
        return;
    }
    console.log(`Comments not existing. Creating github issue.`);

    let issueData = {
        owner: 'skwi',
        repo: 'skwi.github.io',
        title: `Comments for post "${postInfo.title}" (${postFile})`,
        body: `Auto generated comment issue for post "${postInfo.title}" (${postFile})`
    };

    github.authenticate({
        type: "token",<commit_msg>Update issue message for comments<commit_after>const GitHubApi = require('github');
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const frontMatter = require("front-matter");

const github = new GitHubApi({
    protocol: "https",
    host: "api.github.com",
    pathPrefix: "",
    timeout: 5000
})
const commentDataPath = path.join(__dirname, '../_data/commentrefs.yml');
const postDirectory = path.join(__dirname, '../_posts/');
const siteRoot = "http://skwi.fr";

function getFrontMatterForPost(postFilename) {
    return frontMatter(fs.readFileSync(path.join(postDirectory, postFilename), 'utf8')).attributes;
}
function getIssueIdForPost(postFilename) {
    let commentData = yaml.safeLoad(fs.readFileSync(commentDataPath, 'utf8'));
    return commentData[postFilename] !== undefined ? commentData[postFilename] : null;
}
function setIssueIdForPost(postFilename, issueId) {
    let commentData = yaml.safeLoad(fs.readFileSync(commentDataPath, 'utf8'));
    commentData[postFilename] = issueId;
    fs.writeFileSync(commentDataPath, yaml.safeDump(commentData), 'utf8');
}


fs.readdirSync(postDirectory, 'utf8').forEach(postFile => {
    let postInfo = getFrontMatterForPost(postFile);
    console.log(`\nChecking comments for post "${postInfo.title}" (${postFile})`);

    if (getIssueIdForPost(postFile) !== null) {
        console.log(`EXISTING !`);
        return;
    }
    console.log(`Comments not existing. Creating github issue.`);

    let issueData = {
        owner: 'skwi',
        repo: 'skwi.github.io',
        title: `Commentaires pour "${postInfo.title}"`,
        body: `Ecrivez ci dessous vos commentaires pour l'article "${postInfo.title}", ils seront automatiquement affichés sur le blog.`
    };

    github.authenticate({
        type: "token",
{'fraction_non_alphanumeric': 0.14909090909090908, 'fraction_numerical': 0.005034965034965035, 'mean_word_length': 4.493087557603687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2624559', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1078, 'n_words': 232}