<commit_before>var _ = require('lodash');
var assetRev = require('broccoli-asset-rev');
var autoPrefixer = require('broccoli-autoprefixer');
var cleanCss = require('broccoli-clean-css');
var compileCoffeeScript = require('broccoli-coffee');
var compileSass = require('broccoli-ruby-sass');
var concat = require('broccoli-concat');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
var sieveFiles = require('broccoli-funnel');
var uglifyJs = require('broccoli-uglify-js');
var esTranspiler = require('broccoli-babel-transpiler');

exports.getEnv = getEnv();

/**
 * Get environment name, first by looking at SYMFONY_ENV
 * and then falling back to BROCCOLI_ENV
 *
 * @returns string
 */
function getEnv () {
    var symfonyEnv = process.env.SYMFONY_ENV || 'dev';
    var env = process.env.BROCCOLI_ENV || symfonyEnv;
    switch (env) {
        case 'prod':
        case 'production':
        case 'staging':
            env = 'production';
            break;
        case 'dev':
        case 'development':
        case 'test':
            env = 'development';
            break;
        default:
            throw new Error('Environment "' + env + '" is not supported');
    }
    return env
}

// paths
var bowerRoot = 'vendor/bower';
var appCssFile = 'style/app.css';
var scoreBoardCssFile = 'style/scoreboard.css';
var scoreCardCssFile = 'style/scorecard.css';

var env = getEnv();
var buildType = process.env.SYMFONY__BUILD_TYPE || 'hosted';

var sassSources = mergeTrees([
    bowerRoot + '/bootstrap-sass-official/assets/stylesheets',
    bowerRoot + '/fontawesome/scss',
    'app/Resources/styles'
]);

var sassOptions = {
    unixNewlines: true,
    cacheLocation: 'var/cache/' + buildType + '/' + env + '/sass-cache',
    precision: 10
};


var appCss = autoPrefixer(
    compileSass(sassSources, 'app.scss', appCssFile, sassOptions)
);
var scoreBoardCss = autoPrefixer(
    compileSass(sassSources, 'scoreboard.scss', scoreBoardCssFile, sassOptions)
);
var scoreCardCss = autoPrefixer(
    compileSass(sassSources, 'scorecard.scss', scoreCardCssFile, sassOptions)
);

var bowerJsTree = sieveFiles(bowerRoot, {
    files: [
        'jquery/dist/jquery.js',
        'bootstrap-sass-official/assets/javascripts/bootstrap.js',
        'jquery-color/jquery.color.js',
        'jquery.countdown/dist/jquery.countdown.js',
        'modernizr/modernizr.js'
    ],
    destDir: 'js',
    getDestinationPath: function(relativePath) {
        return path.basename(relativePath);
    }
});
var jsTree = sieveFiles(__dirname + '/web/bundles/common/js', {
        include: ['*.js'],
        destDir: 'js'
    });
var coffeeTree = sieveFiles(__dirname + '/src/GameBundle/Resources/coffee', {
        include: ['*.coffee'],
        destDir: 'js'
    });

coffeeTree = compileCoffeeScript(coffeeTree, {bare: true});
var appJs = mergeTrees([bowerJsTree, jsTree, coffeeTree]);

appJs = concat(appJs, {
    inputFiles: [
        'js/jquery.js',
        'js/bootstrap.js',
        'js/jquery.color.js',
        'js/jquery.countdown.js',
        'js/jquery-ujs.js',
        'js/game.js',
        'js/common.js'
    ],
    outputFile: '/js/app.js'
});

//var scriptTree = esTranspiler(inputTree, options);
//
if ('production' == env) {
    appJs = uglifyJs(appJs, {
        compress: true
    });
    /* cleancss options to consider
        root - path to resolve absolute @import rules and rebase relative URLs
        relativeTo - path with which to resolve relative @import rules and URLs
        processImport - whether to process @import rules
        noRebase - whether to skip URLs rebasing
    */
    appCss = cleanCss(appCss);
    scoreBoardCss = cleanCss(scoreBoardCss);
    scoreCardCss = cleanCss(scoreCardCss);
}

var appFonts = sieveFiles(bowerRoot + '/fontawesome/fonts', {
    destDir: '/fonts'
});

var appAssets = mergeTrees([appCss, scoreBoardCss, scoreCardCss, appJs, appFonts]);
/*if ('production' == env) {
    appAssets = assetRev(appAssets, {
        extensions: ['js', 'css', 'png', 'jpg', 'gif'],
        //exclude: ['fonts/169929'],
        // prepend: 'https://example.com/',<commit_msg>fix some indents in Brocfile.js<commit_after>var _ = require('lodash');
var assetRev = require('broccoli-asset-rev');
var autoPrefixer = require('broccoli-autoprefixer');
var cleanCss = require('broccoli-clean-css');
var compileCoffeeScript = require('broccoli-coffee');
var compileSass = require('broccoli-ruby-sass');
var concat = require('broccoli-concat');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
var sieveFiles = require('broccoli-funnel');
var uglifyJs = require('broccoli-uglify-js');
var esTranspiler = require('broccoli-babel-transpiler');

exports.getEnv = getEnv();

/**
 * Get environment name, first by looking at SYMFONY_ENV
 * and then falling back to BROCCOLI_ENV
 *
 * @returns string
 */
function getEnv () {
    var symfonyEnv = process.env.SYMFONY_ENV || 'dev';
    var env = process.env.BROCCOLI_ENV || symfonyEnv;
    switch (env) {
        case 'prod':
        case 'production':
        case 'staging':
            env = 'production';
            break;
        case 'dev':
        case 'development':
        case 'test':
            env = 'development';
            break;
        default:
            throw new Error('Environment "' + env + '" is not supported');
    }
    return env
}

// paths
var bowerRoot = 'vendor/bower';
var appCssFile = 'style/app.css';
var scoreBoardCssFile = 'style/scoreboard.css';
var scoreCardCssFile = 'style/scorecard.css';

var env = getEnv();
var buildType = process.env.SYMFONY__BUILD_TYPE || 'hosted';

var sassSources = mergeTrees([
    bowerRoot + '/bootstrap-sass-official/assets/stylesheets',
    bowerRoot + '/fontawesome/scss',
    'app/Resources/styles'
]);

var sassOptions = {
    unixNewlines: true,
    cacheLocation: 'var/cache/' + buildType + '/' + env + '/sass-cache',
    precision: 10
};


var appCss = autoPrefixer(
    compileSass(sassSources, 'app.scss', appCssFile, sassOptions)
);
var scoreBoardCss = autoPrefixer(
    compileSass(sassSources, 'scoreboard.scss', scoreBoardCssFile, sassOptions)
);
var scoreCardCss = autoPrefixer(
    compileSass(sassSources, 'scorecard.scss', scoreCardCssFile, sassOptions)
);

var bowerJsTree = sieveFiles(bowerRoot, {
    files: [
        'jquery/dist/jquery.js',
        'bootstrap-sass-official/assets/javascripts/bootstrap.js',
        'jquery-color/jquery.color.js',
        'jquery.countdown/dist/jquery.countdown.js',
        'modernizr/modernizr.js'
    ],
    destDir: 'js',
    getDestinationPath: function(relativePath) {
        return path.basename(relativePath);
    }
});
var jsTree = sieveFiles(__dirname + '/web/bundles/common/js', {
    include: ['*.js'],
    destDir: 'js'
});

var coffeeTree = sieveFiles(__dirname + '/src/GameBundle/Resources/coffee', {
    include: ['*.coffee'],
    destDir: 'js'
});
coffeeTree = compileCoffeeScript(coffeeTree, {bare: true});
var appJs = mergeTrees([bowerJsTree, jsTree, coffeeTree]);

appJs = concat(appJs, {
    inputFiles: [
        'js/jquery.js',
        'js/bootstrap.js',
        'js/jquery.color.js',
        'js/jquery.countdown.js',
        'js/jquery-ujs.js',
        'js/game.js',
        'js/common.js'
    ],
    outputFile: '/js/app.js'
});

if ('production' == env) {
    appJs = uglifyJs(appJs, {
        compress: true
    });
    /* cleancss options to consider
        root - path to resolve absolute @import rules and rebase relative URLs
        relativeTo - path with which to resolve relative @import rules and URLs
        processImport - whether to process @import rules
        noRebase - whether to skip URLs rebasing
    */
    appCss = cleanCss(appCss);
    scoreBoardCss = cleanCss(scoreBoardCss);
    scoreCardCss = cleanCss(scoreCardCss);
}

var appFonts = sieveFiles(bowerRoot + '/fontawesome/fonts', {
    destDir: '/fonts'
});

var appAssets = mergeTrees([appCss, scoreBoardCss, scoreCardCss, appJs, appFonts]);
/*if ('production' == env) {
    appAssets = assetRev(appAssets, {
        extensions: ['js', 'css', 'png', 'jpg', 'gif'],
        //exclude: ['fonts/169929'],
        // prepend: 'https://example.com/',
{'fraction_non_alphanumeric': 0.1439375457428641, 'fraction_numerical': 0.0019516955354964625, 'mean_word_length': 3.2046153846153844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '44022', 'n_tokens_mistral': 2772, 'n_tokens_neox': 2693, 'n_words': 575}