<commit_before>var fs = require('fs');
var path = require('path');
var readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

console.log('> This script will overwrite any present \'config.json\' with the default values');
console.log('  and may also revert any changes you made to the default data files.');

rl.question('> Do you want to continue? (yes/no):', function(answer) {
    if (answer !== 'yes') {
        console.log('> Aborted! The program will now terminate.');
        rl.close();
        process.exit();
    }
    rl.close();
    
    var version;
    try {
        version = fs.readFileSync('./.version', 'utf8');;
    } catch(err) {
        console.log("Could not read version file. Program will now terminate...");
        process.exit();
    }
    
    /**
     * Configuration File
     */
    console.log('> Creating config file...');
    var config = {
        "version" : version,
        "port" : "63357",
        "dataPath" : "exampleData",
        "sessionSeed" : "secret",
        "hashAlgorithm" : "sha512",
        "hashEncoding" : "utf-8"
    };
    var configRaw = JSON.stringify(config, null, 4);
    fs.writeFileSync(path.join(__dirname, 'config.json'), configRaw, 'utf8');
    var _dataPath = path.join(__dirname, config.dataPath);
    //fs.accessSync(_dataPath, fs.F_OK | fs.R_OK);
    if (fs.existsSync(_dataPath) == false)
        fs.mkdirSync(_dataPath);
    var _hashAlgorithm = config.hashAlgorithm;
    var _hashEncoding = config.hashEncoding;
    
    /**
     * Accounts
     */
     console.log('> Creating accounts...');
    var crypto = require('crypto');
    var hash1 = crypto.createHash(_hashAlgorithm);
    hash1.update('password1', _hashEncoding);
    var pwd1 = hash1.digest('hex').toString(_hashEncoding);
    var hash2 = crypto.createHash(_hashAlgorithm);
    hash2.update('password2', _hashEncoding);
    var pwd2 = hash2.digest('hex').toString(_hashEncoding);
    var hash3 = crypto.createHash(_hashAlgorithm);
    hash3.update('password3', _hashEncoding);
    var pwd3 = hash3.digest('hex').toString(_hashEncoding);
    
    var accountData = [
        { "username" : "inhabitant_1", 'password' : <PASSWORD> },
        { "username" : "inhabitant_2", 'password' : <PASSWORD> },
        { "username" : "inhabitant_3", 'password' : <PASSWORD> }
    ];
    var accountDataRaw = JSON.stringify(accountData, null, 4);
    fs.writeFileSync(path.join(_dataPath, 'accounts.json'), accountDataRaw, 'utf8');
    
    /**
     * Shopping List
     */
    console.log('> Creating shoppingList file...');
    var shoppingListData = [
        {
            "id": 0,
            "name": "Brot",
            "amount": "2",
            "isClaimed": false
        },
        {
            "id": 1,
            "name": "Met",
            "amount": "4",
            "isClaimed": false
        },
        {
            "id": 2,
            "name": "Kekse ",
            "amount": "3",
            "isClaimed": false
        }
    ];
    var shoppingListDataRaw = JSON.stringify(shoppingListData, null, 4);
    fs.writeFileSync(path.join(_dataPath, 'shoppingList.json'), shoppingListDataRaw, 'utf8');
    
    /**
     * Calendar
     */
    console.log('> Creating calendar file...');<commit_msg>Added creating of settlements file<commit_after>var fs = require('fs');
var path = require('path');
var readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

console.log('> This script will overwrite any present \'config.json\' with the default values');
console.log('  and may also revert any changes you made to the default data files.');

rl.question('> Do you want to continue? (yes/no):', function(answer) {
    if (answer !== 'yes') {
        console.log('> Aborted! The program will now terminate.');
        rl.close();
        process.exit();
    }
    rl.close();
    
    var version;
    try {
        version = fs.readFileSync('./.version', 'utf8');;
    } catch(err) {
        console.log("Could not read version file. Program will now terminate...");
        process.exit();
    }
    
    /**
     * Configuration File
     */
    console.log('> Creating config file...');
    var config = {
        "version" : version,
        "port" : "63357",
        "dataPath" : "exampleData",
        "sessionSeed" : "secret",
        "hashAlgorithm" : "sha512",
        "hashEncoding" : "utf-8"
    };
    var configRaw = JSON.stringify(config, null, 4);
    fs.writeFileSync(path.join(__dirname, 'config.json'), configRaw, 'utf8');
    var _dataPath = path.join(__dirname, config.dataPath);
    //fs.accessSync(_dataPath, fs.F_OK | fs.R_OK);
    if (fs.existsSync(_dataPath) == false)
        fs.mkdirSync(_dataPath);
    var _hashAlgorithm = config.hashAlgorithm;
    var _hashEncoding = config.hashEncoding;
    
    /**
     * Accounts
     */
     console.log('> Creating accounts...');
    var crypto = require('crypto');
    var hash1 = crypto.createHash(_hashAlgorithm);
    hash1.update('password1', _hashEncoding);
    var pwd1 = hash1.digest('hex').toString(_hashEncoding);
    var hash2 = crypto.createHash(_hashAlgorithm);
    hash2.update('password2', _hashEncoding);
    var pwd2 = hash2.digest('hex').toString(_hashEncoding);
    var hash3 = crypto.createHash(_hashAlgorithm);
    hash3.update('password3', _hashEncoding);
    var pwd3 = hash3.digest('hex').toString(_hashEncoding);
    
    var accountData = [
        { "username" : "inhabitant_1", 'password' : <PASSWORD> },
        { "username" : "inhabitant_2", 'password' : <PASSWORD> },
        { "username" : "inhabitant_3", 'password' : <PASSWORD> }
    ];
    var accountDataRaw = JSON.stringify(accountData, null, 4);
    fs.writeFileSync(path.join(_dataPath, 'accounts.json'), accountDataRaw, 'utf8');
    
    /**
     * Shopping List
     */
    console.log('> Creating shoppingList file...');
    var shoppingListData = [
        {
            "id": 0,
            "name": "Brot",
            "amount": "2",
            "isClaimed": false
        },
        {
            "id": 1,
            "name": "Met",
            "amount": "4",
            "isClaimed": false
        },
        {
            "id": 2,
            "name": "Kekse ",
            "amount": "3",
            "isClaimed": false
        }
    ];
    var shoppingListDataRaw = JSON.stringify(shoppingListData, null, 4);
    fs.writeFileSync(path.join(_dataPath, 'shoppingList.json'), shoppingListDataRaw, 'utf8');

    /**
     * Settlements
     */
    console.log('> Creating Settlements file...');
    var settlementsData = [

    ];
    var settlementsDataRaw = JSON.stringify(settlementsData, null, 4);
    fs.writeFileSync(path.join(_dataPath, 'settlements.json'), settlementsDataRaw, 'utf8');
    
    /**
     * Calendar
     */
    console.log('> Creating calendar file...');
{'fraction_non_alphanumeric': 0.15609192079780315, 'fraction_numerical': 0.011851423616129498, 'mean_word_length': 2.4808853118712273, 'pattern_counts': {'":': 24, '<': 9, '<?xml version=': 0, '>': 24, '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': '6782306', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2100, 'n_words': 471}