<commit_before>/* eslint-disable no-console */

var start = Date.now();

// ///////////////////////// //
//          IMPORTS          //
// ///////////////////////// //

var fs = require('fs-extra');
var path = require('path');
var exec = require('child_process').execSync;
var NwBuilder = require('nw-builder');
var rcedit = require('rcedit');
var zip = require('7zip-bin');


// ///////////////////////// //
//          SETTINGS         //
// ///////////////////////// //

var year = '2017';
var company = 'Open Indy Brigade';
var description = 'Find accessibility issues in webpages.';

var platform = process.platform;
if (process.platform === 'linux' && process.arch === 'ia32') {
    platform = 'linux32';
} else if (process.platform === 'linux' && process.arch === 'x64') {
    platform = 'linux64';
} else if (process.platform === 'darwin') {
    platform = 'osx64';
}

var nwBuildSettings = {
    version: '0.14.7',
    flavor: 'normal',
    appName: 'Koa11y',
    appVersion: '3.0.0',
    files: [
        './_fonts/**/*',
        './_img/**/*',
        './_markup/**/*',
        './_scripts/**/*',
        './_style/style.css',
        './_style/ven.bootstrap.css',
        './_style/ven.bootstrap/bootstrap.css',
        './_style/ven.bootswatch/flatly.min.css',
        './index.htm',
        './package.json',
        './LICENSE'
    ],
    winIco: './_img/fav.ico',
    platforms: [ platform ],
    zip: false
};

var junk = [
    'd3dcompiler_47.dll',
    'dbghelp.dll',
    'libEGL.dll',
    'libexif.dll',
    'libGLESv2.dll',
    'nw_200_percent.pak',
    'snapshot_blob.bin',
    'package.nw/node_modules/vue/src/',
    'package.nw/node_modules/vue/types/',
    'package.nw/node_modules/vue/dist/vue.common.js',
    'package.nw/node_modules/vue/dist/vue.esm.js',
    'package.nw/node_modules/vue/dist/vue.js',
    'package.nw/node_modules/vue/dist/vue.runtime.common.js',
    'package.nw/node_modules/vue/dist/vue.runtime.esm.js',
    'package.nw/node_modules/vue/dist/vue.runtime.js',
    'package.nw/node_modules/vue/dist/vue.runtime.min.js',
    'package.nw/node_modules/performance-now/src/',
    'package.nw/node_modules/performance-now/test/',
    'package.nw/node_modules/ajv/dist/ajv.min.js.map',
    'package.nw/node_modules/ajv/scripts/',
    'package.nw/node_modules/ajv/lib/ajv.d.ts',
    'package.nw/node_modules/ajv/dist/',
    'package.nw/node_modules/truffler/example/',
    'package.nw/node_modules/truffler/test/',
    'package.nw/node_modules/hawk/example/',
    'package.nw/node_modules/hawk/test/',
    'package.nw/node_modules/hawk/images/',
    'package.nw/node_modules/pa11y/example/',
    'package.nw/node_modules/pa11y/test/',
    'package.nw/node_modules/es6-promise/es6-promise.d.ts'
];


// ///////////////////////// //
//         FUNCTIONS         //
// ///////////////////////// //

function updateExe (done) {
    var extension = '';
    if (platform === 'win32') {
        extension = '.exe';
    }
    var executable = './build/' + nwBuildSettings.appName + '/' + platform + '/' + nwBuildSettings.appName + extension;

    var options = {
        'version-string': {
            'CompanyName': company,
            'FileDescription': description,
            'LegalCopyright': 'Copyright ' + year + '. ' + company,
            'ProductName': nwBuildSettings.appName
        },
        'file-version': nwBuildSettings.appVersion,
        'product-version': nwBuildSettings.appVersion
    };

    if (platform === 'win32') {
        rcedit(executable, options, function (a, b, c) {
            if (a) {
                console.log(a);
            }
            if (b) {
                console.log(b);
            }
            if (c) {
                console.log(c);
            }
            if (typeof(done) === 'function') {
                done();
            }
        });
    } else if (platform === 'linux64' || platform === 'linux32') {
        exec('chmod +x ' + executable);

        var fileName = 'Koa11y.desktop';
        var fileData =
            '[Desktop Entry]\n' +
            'Type=Application\n' +
            'Terminal=true\n' +
            'Name=Run ' + nwBuildSettings.appName + '\n' +
            'Icon=utilities-terminal\n' +
            'Exec=gnome-terminal -e "bash -c \'./' + nwBuildSettings.appName + ';$SHELL\'"\n' +
            'Categories=Application;';
        var filePath = './build/' + nwBuildSettings.appName + '/' + platform + '/' + fileName;
        fs.writeFileSync(filePath, fileData);

        // TODO: On Linux auto-make the exe runnable, or a runnable .desktop file

        exec('chmod +x ' + filePath);
        done();
    } else if (process.platform === 'darwin') {
        // TODO: Copy files from image folder into app contents (.icns)
        done();
    } else {
        done();
    }
}

function copyManifest () {
    var manifest = fs.readJsonSync('./package.json');
    manifest.devDependencies = {};
    var output = JSON.stringify(manifest, null, 2);
    var buildPackagePath = './build/' + nwBuildSettings.appName + '/' + platform + '/package.json';
    if (process.platform === 'darwin') {
        buildPackagePath = path.join('.', 'build', nwBuildSettings.appName, platform, nwBuildSettings.appName + '.app', 'Contents', 'Resources', 'app.nw', 'package.json');
    }
    fs.writeFileSync(buildPackagePath, output);
}

function changeDirectoryToBuildFolder () {
    var buildFolder = path.join(process.cwd(), 'build', nwBuildSettings.appName, platform);
    if (process.platform === 'darwin') {
        buildFolder = path.join(process.cwd(), 'build', nwBuildSettings.appName, platform, nwBuildSettings.appName + '.app', 'Contents', 'Resources', 'app.nw');
    }
    process.chdir(buildFolder);
}

function npmInstallBuildFolder () {
    exec('npm install');
}
<commit_msg>Finish icons for OSX build script<commit_after>/* eslint-disable no-console */

var start = Date.now();

// ///////////////////////// //
//          IMPORTS          //
// ///////////////////////// //

var fs = require('fs-extra');
var path = require('path');
var exec = require('child_process').execSync;
var NwBuilder = require('nw-builder');
var rcedit = require('rcedit');
var zip = require('7zip-bin');


// ///////////////////////// //
//          SETTINGS         //
// ///////////////////////// //

var year = '2017';
var company = 'Open Indy Brigade';
var description = 'Find accessibility issues in webpages.';

var platform = process.platform;
if (process.platform === 'linux' && process.arch === 'ia32') {
    platform = 'linux32';
} else if (process.platform === 'linux' && process.arch === 'x64') {
    platform = 'linux64';
} else if (process.platform === 'darwin') {
    platform = 'osx64';
}

var nwBuildSettings = {
    version: '0.14.7',
    flavor: 'normal',
    appName: 'Koa11y',
    appVersion: '3.0.0',
    files: [
        './_fonts/**/*',
        './_img/**/*',
        './_markup/**/*',
        './_scripts/**/*',
        './_style/style.css',
        './_style/ven.bootstrap.css',
        './_style/ven.bootstrap/bootstrap.css',
        './_style/ven.bootswatch/flatly.min.css',
        './index.htm',
        './package.json',
        './LICENSE'
    ],
    winIco: './_img/fav.ico',
    platforms: [ platform ],
    zip: false
};

var junk = [
    'd3dcompiler_47.dll',
    'dbghelp.dll',
    'libEGL.dll',
    'libexif.dll',
    'libGLESv2.dll',
    'nw_200_percent.pak',
    'snapshot_blob.bin',
    'package.nw/node_modules/vue/src/',
    'package.nw/node_modules/vue/types/',
    'package.nw/node_modules/vue/dist/vue.common.js',
    'package.nw/node_modules/vue/dist/vue.esm.js',
    'package.nw/node_modules/vue/dist/vue.js',
    'package.nw/node_modules/vue/dist/vue.runtime.common.js',
    'package.nw/node_modules/vue/dist/vue.runtime.esm.js',
    'package.nw/node_modules/vue/dist/vue.runtime.js',
    'package.nw/node_modules/vue/dist/vue.runtime.min.js',
    'package.nw/node_modules/performance-now/src/',
    'package.nw/node_modules/performance-now/test/',
    'package.nw/node_modules/ajv/dist/ajv.min.js.map',
    'package.nw/node_modules/ajv/scripts/',
    'package.nw/node_modules/ajv/lib/ajv.d.ts',
    'package.nw/node_modules/ajv/dist/',
    'package.nw/node_modules/truffler/example/',
    'package.nw/node_modules/truffler/test/',
    'package.nw/node_modules/hawk/example/',
    'package.nw/node_modules/hawk/test/',
    'package.nw/node_modules/hawk/images/',
    'package.nw/node_modules/pa11y/example/',
    'package.nw/node_modules/pa11y/test/',
    'package.nw/node_modules/es6-promise/es6-promise.d.ts'
];


// ///////////////////////// //
//         FUNCTIONS         //
// ///////////////////////// //

function updateExe (done) {
    var extension = '';
    if (platform === 'win32') {
        extension = '.exe';
    }
    var executable = './build/' + nwBuildSettings.appName + '/' + platform + '/' + nwBuildSettings.appName + extension;

    var options = {
        'version-string': {
            'CompanyName': company,
            'FileDescription': description,
            'LegalCopyright': 'Copyright ' + year + '. ' + company,
            'ProductName': nwBuildSettings.appName
        },
        'file-version': nwBuildSettings.appVersion,
        'product-version': nwBuildSettings.appVersion
    };

    if (platform === 'win32') {
        rcedit(executable, options, function (a, b, c) {
            if (a) {
                console.log(a);
            }
            if (b) {
                console.log(b);
            }
            if (c) {
                console.log(c);
            }
            if (typeof(done) === 'function') {
                done();
            }
        });
    } else if (platform === 'linux64' || platform === 'linux32') {
        exec('chmod +x ' + executable);

        var fileName = 'Koa11y.desktop';
        var fileData =
            '[Desktop Entry]\n' +
            'Type=Application\n' +
            'Terminal=true\n' +
            'Name=Run ' + nwBuildSettings.appName + '\n' +
            'Icon=utilities-terminal\n' +
            'Exec=gnome-terminal -e "bash -c \'./' + nwBuildSettings.appName + ';$SHELL\'"\n' +
            'Categories=Application;';
        var filePath = './build/' + nwBuildSettings.appName + '/' + platform + '/' + fileName;
        fs.writeFileSync(filePath, fileData);

        // TODO: On Linux auto-make the exe runnable, or a runnable .desktop file

        exec('chmod +x ' + filePath);
        done();
    } else if (process.platform === 'darwin') {
        fs.copySync('./_img/app.icns', './build/' + nwBuildSettings.appName + '/osx64/' + nwBuildSettings.appName + '.app/Contents/Resources/app.icns');
        fs.copySync('./_img/document.icns', './build/' + nwBuildSettings.appName + '/osx64/' + nwBuildSettings.appName + '.app/Contents/Resources/document.icns');
        done();
    } else {
        done();
    }
}

function copyManifest () {
    var manifest = fs.readJsonSync('./package.json');
    manifest.devDependencies = {};
    manifest.name = nwBuildSettings.appName;
    var output = JSON.stringify(manifest, null, 2);
    var buildPackagePath = './build/' + nwBuildSettings.appName + '/' + platform + '/package.json';
    if (process.platform === 'darwin') {
        buildPackagePath = path.join('.', 'build', nwBuildSettings.appName, platform, nwBuildSettings.appName + '.app', 'Contents', 'Resources', 'app.nw', 'package.json');
    }
    fs.writeFileSync(buildPackagePath, output);
}

function changeDirectoryToBuildFolder () {
    var buildFolder = path.join(process.cwd(), 'build', nwBuildSettings.appName, platform);
    if (process.platform === 'darwin') {
        buildFolder = path.join(process.cwd(), 'build', nwBuildSettings.appName, platform, nwBuildSettings.appName + '.app', 'Contents', 'Resources', 'app.nw');
    }
    process.chdir(buildFolder);
}

function npmInstallBuildFolder () {
    exec('npm install');
}

{'fraction_non_alphanumeric': 0.1991750147318798, 'fraction_numerical': 0.008418217021634818, 'mean_word_length': 2.172229639519359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1822791', 'n_tokens_mistral': 3989, 'n_tokens_neox': 3825, 'n_words': 631}