<commit_before>module.exports = function(grunt) {

    'use strict';

    grunt.initConfig({

        pkg:     grunt.file.readJSON('package.json'),
        pulsar:  grunt.file.readJSON('pulsar.json'),

        browserify: {
            dev: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            lexicon: {
                files: {
                    'dist/js/lexicon-bundle.js': ['js/lexicon/lexicon-index.js']
                },
                options: {
                    browserifyOptions: {
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            dist: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar'
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        'uglifyify'
                    ]
                }
            },
            browserTests: {
                files: {
                    'dist/js/bundle.js': ['js/index.js'],
                    'dist/js/browser.test.js': ['tests/harness/browser.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        ['require-globify']
                    ]
                }
            }
        },

        phpunit: {
            classes: {
                dir: 'tests/unit/'
            },
            options: {
                bin: 'php -d memory_limit=-1 ./vendor/bin/phpunit',
                bootstrap: 'tests/unit/bootstrap.php',
                colors: true
            }
        },

        sass: {
            dev: {
                options: {
                    outputStyle: 'nested',
                    sourceMap: true
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            },
            dist_modern: {
                options: {
                    outputStyle: 'compressed'
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'dist/css/',
                    expand: true,
                    flatten: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    ['pulsar.scss']
                }]
            },
            dist_ie: {
                options: {
                    outputStyle: 'nested'
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'dist/css/',
                    expand: true,
                    flatten: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    'pulsar-ie*.scss'
                }]
            },
            lexicon: {
                options: {
                    outputStyle: 'nested',
                    sourceMap: true
                },
                files: [{
                    cwd: 'stylesheets/lexicon/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            }
        },

        replace: {
            projector: {
                src: ['stylesheets/pulsar.scss'],
                dest: 'stylesheets/pulsar-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            },
            projector_ie9: {
                src: ['stylesheets/pulsar-ie9.scss'],
                dest: 'stylesheets/pulsar-ie9-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            },
            projector_ie8: {
                src: ['stylesheets/pulsar-ie8.scss'],
                dest: 'stylesheets/pulsar-ie8-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            },
            projector_ie7: {
                src: ['stylesheets/pulsar-ie7.scss'],
                dest: 'stylesheets/pulsar-ie7-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            }
        },

        autoprefixer: {
            dev: {
                options: {
                    browsers: ['last 2 version', 'ie 7', 'ie 8', 'ie 9']
                },
                expand: true,
                src:    'css/*.css'
            }
        },

        scsslint: {
            allFiles: [
                'stylesheets/**/*.scss',
            ],
            options: {
                config: '.scss-lint.yml',
                colorizeOutput: true
            },
        },

        watch: {
            css: {
                files: ['stylesheets/**/*.scss'],
                tasks: ['sass:dev', 'sass:lexicon', 'autoprefixer', 'bless:css']
            },
            scsslint: {
                files: 'stylesheets/**/*.scss',
                tasks: ['scsslint']
            },
            lexicon: {
                files: ['js/lexicon/**/*.js'],
                tasks: ['browserify:lexicon']
            },
            js: {
                files: ['js/**/*.js', 'package.json', '!js/lexicon/**/*'],
                tasks: ['browserify:dev']
            },
            tests: {
                files: ['tests/**/*.js'],
                tasks: ['browserify:browserTests']
            }
        },

        jshint: {
            options: {
            jshintrc: '.jshintrc'
            },
            all: ['js/**/*.js']
        },

        mocha: {
            test: {
                src: ['tests/**/*.html'],
                options: {
                    reporter: 'Nyan',
                    run: true
                }
            },
        },

        uglify: {
            concat: {
                options: {
                    banner: '<%= pkg.banner %>',
                    beautify: true
                },
                files: {
                    'dist/js/<%= pkg.name %>.js': ['js/**/*.js']
                }
                },
                minify: {
                options: {
                    banner: '<%= pkg.banner %>',
                    compress: true,
                    report: 'min'
                },
                files: {
                    'dist/js/<%= pkg.name %>.min.js': ['js/**/*.js']
                }
            }
        },

        asciify: {
            banner:{
            text: '<%= pkg.name %>',
            options: {
                font: 'univers',
                log: true
            }
            },
        },

        copy: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '',
                    src: [
                        'fonts/**/*',
                        'images/**/*',
                        'libs/**/*',
                        'views/pulsar/**/*',
                        'src/**/*'
                    ],
                    dest: 'dist/'
                }]
            },
            docs: {
                files: [{
                    cwd: '',
                    expand: true,
                    flatten: true,
                    src: [
                        'dist/js/bundle.js'
                    ],
                    dest: 'docs/assets/'
                }]
            }
        },

        clean: {
            dist: ['dist'],
            favicons: ['views/pulsar/components/favicons-*.html'],
            smoketest: ['tmp/failures/*']
        },

        bump: {
            options: {
                updateConfigs: ['pkg'],
                files: ['pulsar.json', 'package.json', 'composer.json', 'bower.json', 'VERSION'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['-a'],
                createTag: true,
                tagName: '%VERSION%',
                push: true,
                pushTo: 'origin'
            }
        },

        exec: {
            phantomcss: {
                cmd: 'phantomjs tests/css/testsuite.js'
            },
            updateComposer: {
                cmd: 'sudo php composer.phar update'
            },
            updateBrew: {
                cmd: 'brew update && brew upgrade'
            },
            updateBower: {
                cmd: 'bower update'
            },
            updateGems: {
                cmd: 'sudo gem update'
            },
            updateNpm: {
                cmd: 'sudo npm install'
            },
            wraithUpdate: {
                cmd: 'php tests/css/updateWraith.php'
            },
            wraithHistory: {
                cmd: 'wraith history wraith.yml'
            },
            wraithLatest: {
                cmd: 'wraith latest wraith.yml'
            },
            fixProximaNova: {
                cmd: 'git update-index --skip-worktree fonts/_config.fonts.scss'
            }
        },

        realFavicon: {
            options: {
                settings: {
                    scalingAlgorithm: 'Mitchell',
                    errorOnImageTooSmall: false
                }
            },
            cms: {
                src: 'images/favicons/src/favicon-cms.svg',
                dest: 'images/favicons/cms',
                options: {
                    iconsPath: '/jadu/bundles/pulsar/images/favicons/cms/',
                    html: [ 'views/pulsar/components/favicons-cms.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#15a6d1',
                            onConflict: 'override'
                        }
                    }
                }
            },
            xfp: {
                src: 'images/favicons/src/favicon-xfp.svg',
                dest: 'images/favicons/xfp',
                options: {
                    iconsPath: '/images/favicons/xfp/',
                    html: [ 'views/pulsar/components/favicons-xfp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#80BA27',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cxm: {
                src: 'images/favicons/src/favicon-cxm.svg',
                dest: 'images/favicons/cxm',
                options: {
                    iconsPath: '/images/favicons/cxm/',
                    html: [ 'views/pulsar/components/favicons-cxm.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#54B9A9',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cp: {
                src: 'images/favicons/src/favicon-cp.svg',
                dest: 'images/favicons/cp',
                options: {
                    iconsPath: '/images/favicons/cp/',
                    html: [ 'views/pulsar/components/favicons-cp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#DC5172',
                            onConflict: 'override'
                        }
                    }
                }
            }
        },

        bless: {
            css: {
                options: {
                    cacheBuster: true,
                    compress: true,
                    logCount: true
                },
                files: {
                    'css/pulsar-ie7.min.css': 'css/pulsar-ie7.css',
                    'css/pulsar-ie8.min.css': 'css/pulsar-ie8.css',
                    'css/pulsar-ie9.min.css': 'css/pulsar-ie9.css',
                    'css/pulsar-ie7-theme-projector.min.css': 'css/pulsar-ie7-theme-projector.css',
                    'css/pulsar-ie8-theme-projector.min.css': 'css/pulsar-ie8-theme-projector.css',
                    'css/pulsar-ie9-theme-projector.min.css': 'css/pulsar-ie9-theme-projector.css'
                }
            }
        },

        compress: {
            dist: {
                options: {
                    archive: 'pulsar.zip'
                },
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['**/*']
                }]
            }
        },

        browserSync: {
            files: [
                'css/*',
                'dist/**/*',
                'images/**/*',
                'views/**/*'
            ],
            options: {
                proxy: 'http://localhost:3000/app/app.php/lexicon',
                reloadOnRestart: true,
                watchTask: true
            }
	    },

        casperjs: {
            options: {
                async: {
                    parallel: false
                },
                silent: false
            },
            files: ['../pulsar/tests/js/casper.js']
        },

        validation: {
            options: {
                reset: grunt.option('reset') || false,
                stoponerror: false,
                maxTry: 3,
                relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], // ignores these errors
                generateReport: true,
                errorHTMLRootDir: "tests/validation/error_reports",
                useTimeStamp: true,
                errorTemplate: "tests/validation/w3c_validation_error_Template.html"
            },
            files: {
                src: ['../pulsar/tests/validation/html_output/*.html']
            }
        },

	    'gh-pages': {
            options: {
                base: 'docs/_site',
                repo: 'https://github.com/jadu/pulsar.git'
            },
            src: ['**']
        }

    });

    grunt.config.set('leadingIndent.indentation', 'spaces');

    grunt.config.set('leadingIndent.files', {
        src : [
            'docs/**/*.md',
            'docs/**/*.php',
            'css/**/*',
            'js/**/*',
            'src/**/*',
            'stylesheets/**/*',
            'tests/**/*',
            'views/**/*'
        ]
    });

    grunt.registerTask('default', [
        'copy',
        'scsslint',
        'replace',
        'sass:dev',
        'sass:lexicon',
        'autoprefixer',
        'bless',
        'browserify:dev',
        'browserify:lexicon',
        'browserSync',
        'watch'
    ]);

    grunt.registerTask('post-merge', [
        'exec:fixProximaNova',
        'replace',
        'sass:dev',
        'browserify'
    ]);

    grunt.registerTask('build', [
        'scsslint',
        'replace',
        'sass:dist_modern',
        'sass:dist_ie',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'realFavicon',
        'compress'
    ]);

    grunt.registerTask('deploy', [
        'replace',
        'sass:dist_modern',
        'sass:dist_ie',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'compress'
    ]);

    grunt.registerTask('favicons', [
        'clean:favicons',
        'realFavicon'
    ]);

    grunt.registerTask('wraith', [
        'exec:wraithLatest'
    ]);

    grunt.registerTask('wraith-update', [
        'exec:wraithUpdate',
        'exec:wraithHistory'
    ]);

    grunt.registerTask('update', [
        'exec:updateComposer',
        'exec:updateBrew',
        'exec:updateBower',
        'exec:updateGems',
        'exec:updateNpm'
    ]);

    grunt.registerTask('validate', [
        'casperjs',
        'validation'
    ]);

    grunt.registerTask('javascript:tests', [
        'browserify:browserTests',
    ]);

    grunt.registerTask('javascript:tests:watch', [
        'browserify:browserTests',
        'watch:tests'
    ]);

    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

};
<commit_msg>Revert "Make sure browsersync loads correct page"<commit_after>module.exports = function(grunt) {

    'use strict';

    grunt.initConfig({

        pkg:     grunt.file.readJSON('package.json'),
        pulsar:  grunt.file.readJSON('pulsar.json'),

        browserify: {
            dev: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            lexicon: {
                files: {
                    'dist/js/lexicon-bundle.js': ['js/lexicon/lexicon-index.js']
                },
                options: {
                    browserifyOptions: {
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            dist: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar'
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        'uglifyify'
                    ]
                }
            },
            browserTests: {
                files: {
                    'dist/js/bundle.js': ['js/index.js'],
                    'dist/js/browser.test.js': ['tests/harness/browser.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        ['require-globify']
                    ]
                }
            }
        },

        phpunit: {
            classes: {
                dir: 'tests/unit/'
            },
            options: {
                bin: 'php -d memory_limit=-1 ./vendor/bin/phpunit',
                bootstrap: 'tests/unit/bootstrap.php',
                colors: true
            }
        },

        sass: {
            dev: {
                options: {
                    outputStyle: 'nested',
                    sourceMap: true
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            },
            dist_modern: {
                options: {
                    outputStyle: 'compressed'
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'dist/css/',
                    expand: true,
                    flatten: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    ['pulsar.scss']
                }]
            },
            dist_ie: {
                options: {
                    outputStyle: 'nested'
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'dist/css/',
                    expand: true,
                    flatten: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    'pulsar-ie*.scss'
                }]
            },
            lexicon: {
                options: {
                    outputStyle: 'nested',
                    sourceMap: true
                },
                files: [{
                    cwd: 'stylesheets/lexicon/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            }
        },

        replace: {
            projector: {
                src: ['stylesheets/pulsar.scss'],
                dest: 'stylesheets/pulsar-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            },
            projector_ie9: {
                src: ['stylesheets/pulsar-ie9.scss'],
                dest: 'stylesheets/pulsar-ie9-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            },
            projector_ie8: {
                src: ['stylesheets/pulsar-ie8.scss'],
                dest: 'stylesheets/pulsar-ie8-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            },
            projector_ie7: {
                src: ['stylesheets/pulsar-ie7.scss'],
                dest: 'stylesheets/pulsar-ie7-theme-projector.scss',
                replacements: [{
                    from: 'palette.base',
                    to: 'palette.projector'
                }]
            }
        },

        autoprefixer: {
            dev: {
                options: {
                    browsers: ['last 2 version', 'ie 7', 'ie 8', 'ie 9']
                },
                expand: true,
                src:    'css/*.css'
            }
        },

        scsslint: {
            allFiles: [
                'stylesheets/**/*.scss',
            ],
            options: {
                config: '.scss-lint.yml',
                colorizeOutput: true
            },
        },

        watch: {
            css: {
                files: ['stylesheets/**/*.scss'],
                tasks: ['sass:dev', 'sass:lexicon', 'autoprefixer', 'bless:css']
            },
            scsslint: {
                files: 'stylesheets/**/*.scss',
                tasks: ['scsslint']
            },
            lexicon: {
                files: ['js/lexicon/**/*.js'],
                tasks: ['browserify:lexicon']
            },
            js: {
                files: ['js/**/*.js', 'package.json', '!js/lexicon/**/*'],
                tasks: ['browserify:dev']
            },
            tests: {
                files: ['tests/**/*.js'],
                tasks: ['browserify:browserTests']
            }
        },

        jshint: {
            options: {
            jshintrc: '.jshintrc'
            },
            all: ['js/**/*.js']
        },

        mocha: {
            test: {
                src: ['tests/**/*.html'],
                options: {
                    reporter: 'Nyan',
                    run: true
                }
            },
        },

        uglify: {
            concat: {
                options: {
                    banner: '<%= pkg.banner %>',
                    beautify: true
                },
                files: {
                    'dist/js/<%= pkg.name %>.js': ['js/**/*.js']
                }
                },
                minify: {
                options: {
                    banner: '<%= pkg.banner %>',
                    compress: true,
                    report: 'min'
                },
                files: {
                    'dist/js/<%= pkg.name %>.min.js': ['js/**/*.js']
                }
            }
        },

        asciify: {
            banner:{
            text: '<%= pkg.name %>',
            options: {
                font: 'univers',
                log: true
            }
            },
        },

        copy: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '',
                    src: [
                        'fonts/**/*',
                        'images/**/*',
                        'libs/**/*',
                        'views/pulsar/**/*',
                        'src/**/*'
                    ],
                    dest: 'dist/'
                }]
            },
            docs: {
                files: [{
                    cwd: '',
                    expand: true,
                    flatten: true,
                    src: [
                        'dist/js/bundle.js'
                    ],
                    dest: 'docs/assets/'
                }]
            }
        },

        clean: {
            dist: ['dist'],
            favicons: ['views/pulsar/components/favicons-*.html'],
            smoketest: ['tmp/failures/*']
        },

        bump: {
            options: {
                updateConfigs: ['pkg'],
                files: ['pulsar.json', 'package.json', 'composer.json', 'bower.json', 'VERSION'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['-a'],
                createTag: true,
                tagName: '%VERSION%',
                push: true,
                pushTo: 'origin'
            }
        },

        exec: {
            phantomcss: {
                cmd: 'phantomjs tests/css/testsuite.js'
            },
            updateComposer: {
                cmd: 'sudo php composer.phar update'
            },
            updateBrew: {
                cmd: 'brew update && brew upgrade'
            },
            updateBower: {
                cmd: 'bower update'
            },
            updateGems: {
                cmd: 'sudo gem update'
            },
            updateNpm: {
                cmd: 'sudo npm install'
            },
            wraithUpdate: {
                cmd: 'php tests/css/updateWraith.php'
            },
            wraithHistory: {
                cmd: 'wraith history wraith.yml'
            },
            wraithLatest: {
                cmd: 'wraith latest wraith.yml'
            },
            fixProximaNova: {
                cmd: 'git update-index --skip-worktree fonts/_config.fonts.scss'
            }
        },

        realFavicon: {
            options: {
                settings: {
                    scalingAlgorithm: 'Mitchell',
                    errorOnImageTooSmall: false
                }
            },
            cms: {
                src: 'images/favicons/src/favicon-cms.svg',
                dest: 'images/favicons/cms',
                options: {
                    iconsPath: '/jadu/bundles/pulsar/images/favicons/cms/',
                    html: [ 'views/pulsar/components/favicons-cms.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#15a6d1',
                            onConflict: 'override'
                        }
                    }
                }
            },
            xfp: {
                src: 'images/favicons/src/favicon-xfp.svg',
                dest: 'images/favicons/xfp',
                options: {
                    iconsPath: '/images/favicons/xfp/',
                    html: [ 'views/pulsar/components/favicons-xfp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#80BA27',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cxm: {
                src: 'images/favicons/src/favicon-cxm.svg',
                dest: 'images/favicons/cxm',
                options: {
                    iconsPath: '/images/favicons/cxm/',
                    html: [ 'views/pulsar/components/favicons-cxm.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#54B9A9',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cp: {
                src: 'images/favicons/src/favicon-cp.svg',
                dest: 'images/favicons/cp',
                options: {
                    iconsPath: '/images/favicons/cp/',
                    html: [ 'views/pulsar/components/favicons-cp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#DC5172',
                            onConflict: 'override'
                        }
                    }
                }
            }
        },

        bless: {
            css: {
                options: {
                    cacheBuster: true,
                    compress: true,
                    logCount: true
                },
                files: {
                    'css/pulsar-ie7.min.css': 'css/pulsar-ie7.css',
                    'css/pulsar-ie8.min.css': 'css/pulsar-ie8.css',
                    'css/pulsar-ie9.min.css': 'css/pulsar-ie9.css',
                    'css/pulsar-ie7-theme-projector.min.css': 'css/pulsar-ie7-theme-projector.css',
                    'css/pulsar-ie8-theme-projector.min.css': 'css/pulsar-ie8-theme-projector.css',
                    'css/pulsar-ie9-theme-projector.min.css': 'css/pulsar-ie9-theme-projector.css'
                }
            }
        },

        compress: {
            dist: {
                options: {
                    archive: 'pulsar.zip'
                },
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['**/*']
                }]
            }
        },

        browserSync: {
            files: [
                'css/*',
                'dist/**/*',
                'images/**/*',
                'views/**/*'
            ],
            options: {
                proxy: 'http://192.168.13.37/index.php',
                reloadOnRestart: true,
                watchTask: true
            }
	    },

        casperjs: {
            options: {
                async: {
                    parallel: false
                },
                silent: false
            },
            files: ['../pulsar/tests/js/casper.js']
        },

        validation: {
            options: {
                reset: grunt.option('reset') || false,
                stoponerror: false,
                maxTry: 3,
                relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], // ignores these errors
                generateReport: true,
                errorHTMLRootDir: "tests/validation/error_reports",
                useTimeStamp: true,
                errorTemplate: "tests/validation/w3c_validation_error_Template.html"
            },
            files: {
                src: ['../pulsar/tests/validation/html_output/*.html']
            }
        },

	    'gh-pages': {
            options: {
                base: 'docs/_site',
                repo: 'https://github.com/jadu/pulsar.git'
            },
            src: ['**']
        }

    });

    grunt.config.set('leadingIndent.indentation', 'spaces');

    grunt.config.set('leadingIndent.files', {
        src : [
            'docs/**/*.md',
            'docs/**/*.php',
            'css/**/*',
            'js/**/*',
            'src/**/*',
            'stylesheets/**/*',
            'tests/**/*',
            'views/**/*'
        ]
    });

    grunt.registerTask('default', [
        'copy',
        'scsslint',
        'replace',
        'sass:dev',
        'sass:lexicon',
        'autoprefixer',
        'bless',
        'browserify:dev',
        'browserify:lexicon',
        'browserSync',
        'watch'
    ]);

    grunt.registerTask('post-merge', [
        'exec:fixProximaNova',
        'replace',
        'sass:dev',
        'browserify'
    ]);

    grunt.registerTask('build', [
        'scsslint',
        'replace',
        'sass:dist_modern',
        'sass:dist_ie',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'realFavicon',
        'compress'
    ]);

    grunt.registerTask('deploy', [
        'replace',
        'sass:dist_modern',
        'sass:dist_ie',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'compress'
    ]);

    grunt.registerTask('favicons', [
        'clean:favicons',
        'realFavicon'
    ]);

    grunt.registerTask('wraith', [
        'exec:wraithLatest'
    ]);

    grunt.registerTask('wraith-update', [
        'exec:wraithUpdate',
        'exec:wraithHistory'
    ]);

    grunt.registerTask('update', [
        'exec:updateComposer',
        'exec:updateBrew',
        'exec:updateBower',
        'exec:updateGems',
        'exec:updateNpm'
    ]);

    grunt.registerTask('validate', [
        'casperjs',
        'validation'
    ]);

    grunt.registerTask('javascript:tests', [
        'browserify:browserTests',
    ]);

    grunt.registerTask('javascript:tests:watch', [
        'browserify:browserTests',
        'watch:tests'
    ]);

    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

};
<|endoftext|>


<commit_before>module.exports = function (grunt) {

    "use strict";

    // Execute QUnit unit tests
    grunt.loadNpmTasks('grunt-contrib-qunit');

    // Minify files with Google Closure Compiler
    grunt.loadNpmTasks('grunt-closure-compiler');

    grunt.initConfig({
        'closure-compiler': {
            frontend: {
                js: 'maoli.js',
                jsOutputFile: 'maoli.min.js',
                createSourceMap: 'maoli.min.map',
                sourceMapFormat: 'V3',
                maxBuffer: 500,
                options: {
                    compilation_level: 'SIMPLE_OPTIMIZATIONS',
                    language_in: 'ECMASCRIPT5_STRICT'
                }
            }
        },

        qunit: {
            source: ["test/test.html"],
            minified: ["test/test-min.html"]
        }
    });

    grunt.registerTask("default", "closure-compiler");
}<commit_msg>Playing with Travis-CI.<commit_after>module.exports = function (grunt) {

    "use strict";

    // Execute QUnit unit tests
    grunt.loadNpmTasks('grunt-contrib-qunit');

    // Minify files with Google Closure Compiler
    grunt.loadNpmTasks('grunt-closure-compiler');

    grunt.initConfig({
        'closure-compiler': {
            frontend: {
                closurePath: '.',
                js: 'maoli.js',
                jsOutputFile: 'maoli.min.js',
                createSourceMap: 'maoli.min.map',
                sourceMapFormat: 'V3',
                maxBuffer: 500,
                options: {
                    compilation_level: 'SIMPLE_OPTIMIZATIONS',
                    language_in: 'ECMASCRIPT5_STRICT'
                }
            }
        },

        qunit: {
            source: ["test/test.html"],
            minified: ["test/test-min.html"]
        }
    });

    grunt.registerTask("default", "closure-compiler");
}<|endoftext|>


<commit_before>module.exports = function (grunt) {
    // Loading external tasks
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-compass');
    grunt.loadNpmTasks('grunt-karma');

    // Project configuration.
    grunt.initConfig({
        dist: 'build',
        pkg: grunt.file.readJSON('package.json'),
        watch: {
            compass: {
                files: [ 'static/scss/*.scss' ],
                tasks: [ 'compass:dev' ]
            },
            karma: {
                files: ['static/js/*.js', 'test/unit/*.js'],
                tasks: ['karma:unitBackground:run'] //NOTE the :run flag
            }
        },
        karma: {
            options: {
                configFile: 'config/karma.conf.js',
                browsers: ['Chrome']
            },

            unit: {
                singleRun: true
            },

            unitBackground: {
                background: true
            }
        },
        uglify: {
            build: {
                files: [
                    {
                        'static/js/<%= dist %>/tmp/external.min.js': [
                            'static/lib/ui-utils-custom/ui-utils.js',
                            'static/lib/bootstrap-tour/bootstrap-tour.js',
                            'static/lib/bootstrap-switch/bootstrapSwitch.js',
                            'static/lib/bootstrap-tour/deps/jquery.cookie.js',
                            'static/lib/linkedlist/linkedlist.js',
                            'static/lib/angular-segmentio/angular-segmentio.js'
                        ]
                    },
                    {
                        'static/js/<%= dist %>/tmp/app.min.js': [
                            'static/js/app.js',
                            'static/js/controllers.js',
                            'static/js/directives.js',
                            'static/js/filters.js',
                            'static/js/services.js'
                        ]
                    }
                ]
            }
        },
        concat: {
            options: {
                stripBanners: true,
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
                    '<%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            js: {
                src: ['static/lib/ace/ace.min.js',
                    'static/lib/angular-ui-custom/angular-ui.min.js',
                    'static/lib/angular-ui-bootstrap-custom/ui-bootstrap-custom-tpls-0.3.0.min.js',
                    'static/lib/modernizr-custom/modernizr.min.js', 'static/lib/detectizr/detectizr.min.js',
                    'static/lib/popcorn/popcorn-complete.min.js',
                    'static/lib/angularSmoothscroll/dist/scripts/b8aa6767.scripts.js',
                    'static/js/<%= dist %>/tmp/external.min.js', 'static/js/<%= dist %>/tmp/app.min.js'],
                dest: 'static/js/<%= dist %>/<%= pkg.name %>.min.js'
            },
            css: {
                src: ['static/lib/bootstrap-switch/bootstrapSwitch.css', 'static/css/styles.css', 'static/css/app.css', 'static/css/home.css'],
                dest: 'static/css/<%= dist %>/tmp/concat.css'
            }
        },
        cssmin: {
            combine: {
                files: {
                    'static/css/<%= dist %>/<%= pkg.name %>.min.css': ['<%= concat.css.dest %>']
                }
            }
        },

        clean: {
            build: {
                src: ['static/css/<%= dist %>/*', 'static/js/<%= dist %>/*'],
                filter: 'isFile'
            },
            tmp: {
                src: ['static/css/<%= dist %>/tmp/*', 'static/js/<%= dist %>/tmp/*'],
                filter: 'isFile'
            }
        },
        compass: {
            dev: {
                src: 'static/scss',
                dest: 'static/css',
                linecomments: true,
                forcecompile: true,
                debugsass: true
            },
            prod: {
                src: 'static/scss',
                dest: 'static/css',
                outputstyle: 'compressed',
                linecomments: false,
                forcecompile: true,
                debugsass: false
            }
        }
    });

    // Default task.
    grunt.registerTask('prod', ['clean:build','uglify', 'compass:prod', 'concat', 'cssmin', 'clean:tmp']);
    grunt.registerTask('default', ['prod']);

};<commit_msg>Update angular-smoothscroll<commit_after>module.exports = function (grunt) {
    // Loading external tasks
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-compass');
    grunt.loadNpmTasks('grunt-karma');

    // Project configuration.
    grunt.initConfig({
        dist: 'build',
        pkg: grunt.file.readJSON('package.json'),
        watch: {
            compass: {
                files: [ 'static/scss/*.scss' ],
                tasks: [ 'compass:dev' ]
            },
            karma: {
                files: ['static/js/*.js', 'test/unit/*.js'],
                tasks: ['karma:unitBackground:run'] //NOTE the :run flag
            }
        },
        karma: {
            options: {
                configFile: 'config/karma.conf.js',
                browsers: ['Chrome']
            },

            unit: {
                singleRun: true
            },

            unitBackground: {
                background: true
            }
        },
        uglify: {
            build: {
                files: [
                    {
                        'static/js/<%= dist %>/tmp/external.min.js': [
                            'static/lib/ui-utils-custom/ui-utils.js',
                            'static/lib/bootstrap-tour/bootstrap-tour.js',
                            'static/lib/bootstrap-switch/bootstrapSwitch.js',
                            'static/lib/bootstrap-tour/deps/jquery.cookie.js',
                            'static/lib/linkedlist/linkedlist.js',
                            'static/lib/angular-segmentio/angular-segmentio.js'
                        ]
                    },
                    {
                        'static/js/<%= dist %>/tmp/app.min.js': [
                            'static/js/app.js',
                            'static/js/controllers.js',
                            'static/js/directives.js',
                            'static/js/filters.js',
                            'static/js/services.js'
                        ]
                    }
                ]
            }
        },
        concat: {
            options: {
                stripBanners: true,
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
                    '<%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            js: {
                src: ['static/lib/ace/ace.min.js',
                    'static/lib/angular-ui-custom/angular-ui.min.js',
                    'static/lib/angular-ui-bootstrap-custom/ui-bootstrap-custom-tpls-0.3.0.min.js',
                    'static/lib/modernizr-custom/modernizr.min.js', 'static/lib/detectizr/detectizr.min.js',
                    'static/lib/popcorn/popcorn-complete.min.js',
                    'static/lib/angular-smoothscroll/dist/scripts/2d8e3100.scripts.js',
                    'static/js/<%= dist %>/tmp/external.min.js', 'static/js/<%= dist %>/tmp/app.min.js'],
                dest: 'static/js/<%= dist %>/<%= pkg.name %>.min.js'
            },
            css: {
                src: ['static/lib/bootstrap-switch/bootstrapSwitch.css', 'static/css/styles.css', 'static/css/app.css', 'static/css/home.css'],
                dest: 'static/css/<%= dist %>/tmp/concat.css'
            }
        },
        cssmin: {
            combine: {
                files: {
                    'static/css/<%= dist %>/<%= pkg.name %>.min.css': ['<%= concat.css.dest %>']
                }
            }
        },

        clean: {
            build: {
                src: ['static/css/<%= dist %>/*', 'static/js/<%= dist %>/*'],
                filter: 'isFile'
            },
            tmp: {
                src: ['static/css/<%= dist %>/tmp/*', 'static/js/<%= dist %>/tmp/*'],
                filter: 'isFile'
            }
        },
        compass: {
            dev: {
                src: 'static/scss',
                dest: 'static/css',
                linecomments: true,
                forcecompile: true,
                debugsass: true
            },
            prod: {
                src: 'static/scss',
                dest: 'static/css',
                outputstyle: 'compressed',
                linecomments: false,
                forcecompile: true,
                debugsass: false
            }
        }
    });

    // Default task.
    grunt.registerTask('prod', ['clean:build','uglify', 'compass:prod', 'concat', 'cssmin', 'clean:tmp']);
    grunt.registerTask('default', ['prod']);

};<|endoftext|>


<commit_before>"use strict";

module.exports = function( grunt ) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        clean: {
            test: ['dist/**/*.js']
        },

        concat: {
            alone: {
                dest: 'dist/neuron-noes5.js',
                src: [
                    'lib/intro.js',

                    // Neuron core
                    // 'lib/ecma5.js',

                    // 'lib/seed.js',
                    'lib/util.js',

                    'lib/module-manager.js',
                    // 'lib/event.js',
                    'lib/asset.js',

                    // Neuron peripheral
                    'lib/config.js',
                    'lib/analysis.js',

                    // Exports
                    'lib/exports.js',
                    'lib/load.js',
                    'lib/outro.js',
                ]
            },

            active: {
                dest: 'dist/neuron.js',
                src: [
                    'lib/intro.js',

                    // Neuron core
                    'lib/ecma5.js',

                    // 'lib/seed.js',
                    'lib/util.js',

                    'lib/module-manager.js',
                    // 'lib/event.js',
                    'lib/asset.js',

                    // Neuron peripheral
                    'lib/config.js',
                    'lib/analysis.js',

                    // Exports
                    'lib/exports.js',
                    'lib/load.js',
                    'lib/outro.js',
                ]
            },

            // passive_timeout: {
            //     dest: 'dist/neuron-with-passive-config.js',
            //     src: [
            //         'lib/intro.js',
            //         'lib/ecma5.js',

            //         'lib/seed.js',
            //         'lib/lang.js',

            //         'lib/event.js',
            //         'lib/module-manager.js',
            //         // 'lib/biz.js',
            //         'lib/loader/config-passive-timeout.js',
            //         'lib/outro.js'
            //     ]
            // },
        },

        jshint: {
            dist: {
                src: [ 'dist/*.js' ],
                options: require('./grunt/jshint/dist-rc')
            },

            grunt: {
                src: [ 'Gruntfile.js' ],
                options: require('./grunt/jshint/grunt-rc')
            }
        },

        mocha: {
            test: {
                options: {
                    run: true,
                    timeout:5000,
                    // log: true,
                    logErrors: true,
                    reporter: 'Spec'
                },
                src: ['test/*.html', 'test/folder/*.html'],
            }
        },
        // uglify: {
        //     all: {
        //         files: {
        //             "dist/neuron.min.js": [ "dist/neuron.js" ]
        //         },
        //         options: {
        //             // Keep our hard-coded banner
        //             preserveComments: "some",
        //             // sourceMap: "dist/neuron.min.map",
        //             // sourceMappingURL: "neuron.min.map",
        //             report: "gzip",
        //             beautify: {
        //                 ascii_only: true
        //             },
        //             compress: {
        //                 hoist_funs: false,
        //                 join_vars: false,
        //                 loops: false,
        //                 unused: false
        //             },
        //             mangle: {
        //                 // saves some bytes when gzipped
        //                 except: [ "undefined" ]
        //             }
        //         }
        //     }
        // }
    });

    grunt.registerMultiTask(
        'concat',
        'build files',
        function() {
            var version = grunt.config( 'pkg.cortex.version' );
            var data = this.data;
            var src = data.src;
            var dest = data.dest;
            var compiled;

            if ( process.env.COMMIT ) {
                version += '' + process.env.COMMIT;
            }

            compiled = src.reduce(function(compiled, filepath) {
                return compiled + grunt.file.read( filepath ) + '\n\n';

            }, '');

            // Embed Version
            // Embed Date
            compiled = compiled
                .replace( /@VERSION/g, version )
                .replace( /@DATE/g, function () {
                    // YYYY-MM-DD
                    return ( new Date() ).toISOString().replace( /T.*/, '' );
                });

            // Write concatenated source to file
            grunt.file.write( dest, compiled );

            // Fail task if errors were logged.
            if ( this.errorCount ) {
                return false;
            }

            // Otherwise, print a success message.
            grunt.log.writeln( 'File ' + dest + ' created.' );
        }

    );

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    // grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-mocha');

    grunt.registerTask('build', [
        'clean',
        'concat',
    ]);

    grunt.registerTask('default', [
        'build',
        'jshint',
        'mocha',
        // 'uglify'
    ]);
};<commit_msg>removes grunt; #124<commit_after><|endoftext|>


<commit_before>/*jshint -W098 */

module.exports = function (grunt) {
	'use strict';

	var path = require('path');
	var util = require('util');

	var isTravis = (process.env.TRAVIS === 'true');
	var isVagrant = (process.env.PWD === '/vagrant');
	if (isVagrant) {
		grunt.log.writeln('-> ' + 'vagrant detected'.cyan);
	}
	var cpuCores = require('os').cpus().length;
	//grunt.log.writeln(util.inspect(process.env));

	var gtx = require('gruntfile-gtx').wrap(grunt);
	gtx.loadAuto();
	gtx.loadNpm([
		'mocha-unfunk-reporter'
	]);

	//defaults and one-off tasks
	gtx.config({
		pkg: gtx.readJSON('package.json'),
		jshint: {
			options: gtx.readJSON('.jshintrc', {
				reporter: './node_modules/jshint-path-reporter'
			}),
			support: ['Gruntfile.js', 'test/*.js', 'lib/**/*.js'],
			fixtures: ['test/**/fixtures/**/*.js']
		},
		tslint: {
			options: {
				configuration: gtx.readJSON('tslint.json'),
				formatter: 'tslint-path-formatter'
			},
			source: ['src/**/*.ts', '!src/test', '!src/spec'],
			helper: ['test/*.ts'],
			testing: [
				'src/test/**/*.ts',
				'src/spec/**/*.ts'
			]
		},
		todos: {
			options: {
				reporter: 'path',
				verbose: false,
				priorities: {
					low: /(NOTE|TODO)/,
					med: /(FIXME)/,
					high: /(BROKEN)/
				}
			},
			all: {
				options: {},
				src: ['src/**/*.ts', 'test/**/src/**/*.ts']
			}
		},
		clean: {
			tmp: ['tmp/**/*', 'test/tmp/**/*'],
			dump: ['test/modules/**/dump'],
			test: ['test/*/spec/build/**/*'],
			build: ['build/**', 'build/**/*.js', 'build/**/*.d.ts', 'build/**/*.js.map']
		},
		copy: {
			cli: {
				files: [
				// includes files within path
					{expand: true, cwd: 'src', src: ['cli.js', '.gitattributes'], dest: 'build', filter: 'isFile'}
				]
			}
		},
		'regex-replace': {
			cli: {
				src: ['build/cli.js'],
				actions: [
					{
						name: 'eol',
						search: '\\r\\n',
						replace: '\n',
						flags: 'g'
					}
				]
			},
			build: {
				src: ['build/**/*.js'],
				actions: [
					{
						name: 'map',
						search: '\r?\n?\\\/\\\/# sourceMappingURL=.*',
						replace: '',
						flags: 'g'
					}
				]
			}
		},
		tv4: {
			packjson: {
				options: {
					root: function() {
						return require('package.json-schema').get();
					}
				},
				src: ['package.json']
			},
			tsd: {
				options: {
					multi: true,
					root: 'schema/tsd-v4.json'
				},
				src: ['tsd.json']
			},
			schemas: {
				options: {
					multi: true,
					root: 'http://json-schema.org/draft-04/schema#'
				},
				src: ['schema/*.json']
			}
		},
		mochaTest: {
			options: {
				reporter: 'mocha-unfunk-reporter',
				timeout: 3000
			},
			integrity: ['test/integrity.js'],
			// some extra js tests
			spec: ['test/spec/*.js']
		},
		typson: {
			options: {

			},
			http: {
				src: [
					'./src/http/types.ts'
				]
			}
		},
		mocha_unfunk: {
			dev: {
				options: {
					reportPending: true,
					stackFilter: true
				}
			}
		},
		ts_clean: {
			build: {
				src: ['build/**/*'],
				dot: true
			}
		},
		ts: {
			options: {
				module: 'commonjs',
				fast: 'never',
				target: 'es5',
				declaration: true,
				sourcemap: true,
				removeComments: true,
				noImplicitAny: false
			},
			api: {
				src: ['src/**/*.ts', '!src/test/**/*.ts', '!src/spec/**/*.ts', '!src/**/_ref.d.ts'],
				outDir: 'build/'
			},
			test: {
				src: ['src/test.ts'],
				outDir: 'build/'
			},
			/*blobSha: {
				src: ['src/util/blobSha.ts'],
				out: 'util/blobSha.js'
			},*/
			/*capture_task: {
				src: ['tasks/capture_cli.ts'],
				out: 'tasks/capture_cli.js'
			},*/
			//use this non-checked-in file to test small snippets of dev code
			dev: {
				src: ['src/dev.ts'],
				out: 'tmp/dev.js'
			},
			scratch: {
				options: {
					baseDir: './src'
				},
				src: ['src/dt/dt.ts'],
				outDir: 'tmp/'
			}
		},
		shell: {
			options: {
				failOnError: true,
				stdout: true
			},
			demo_help: {
				command: [
					'node', './build/cli.js',
					'-h',
					'--capture',
					'--style', 'ansi'
				].join(' '),
				options: {
				}
			},
			demo_html: {
				command: [
					'node', './build/cli.js',
					'-h',
					'--style', 'html'
				].join(' '),
				options: {
				}
			},
			scratch: {
				command: [
					'node', './tmp/dt/dt',
					'--stack'
				].join(' '),
				options: {
				}
			}
		}
	});

	// module tester macro
	gtx.define('moduleTest', function (macro, id) {
		var srcPath = 'src/spec/' + id + '/';

		var basePath = 'test/spec/' + id + '/';
		var tmpPath = basePath + 'tmp/';
		var outPath = basePath + 'build/';

		macro.add('clean', [tmpPath, outPath]);
		macro.add('ts', {
			options: {
				module: 'commonjs',
				target: 'es5',
				declaration: false,
				sourcemap: true,
				noImplicitAny: false
			},
			src: [srcPath + '**/*.ts'],
			outDir: outPath
		});
		macro.add('tslint', {
			src: [srcPath + '** /*.ts']
		});
		if (macro.getParam('http', 0) > 0) {
			macro.add('connect', {
				options: {
					port: macro.getParam('http'),
					base: basePath + 'www/'
				}
			});
		}
		macro.run('mocha_unfunk:dev');
		macro.add('mochaTest', {
			options: {
				timeout: macro.getParam('timeout', 3000)
			},
			src: [outPath + 'spec/**/*.js']
		});
		macro.tag('module');

		//TODO implement new gruntfile-gtx once() feature (run-once dependencies, like tslint:source or tslint:helper)
	}, {
		concurrent: 1 //cpuCores
	});

	var longTimer = (isVagrant ? 250000 : 10000);

	// modules
	gtx.create('xm', 'moduleTest', null, 'lib');
	gtx.create('git', 'moduleTest', {timeout: longTimer}, 'lib');
	gtx.create('tsd', 'moduleTest', {timeout: longTimer}, 'lib,core');
	gtx.create('core,api,cli', 'moduleTest', {timeout: longTimer}, 'core');
	gtx.create('http', 'moduleTest', {
		timeout: longTimer,
		http: 9090
	}, 'lib');

	gtx.alias('pre_publish', [
		/*'tv4:schemas',*/
		'tv4:tsd',
		'tv4:packjson',
		'rebuild',
		'regex-replace:build',
		'regex-replace:cli',
		'ts_clean:build',
		// 'gtx:cli',
		// 'gtx:api',
		'mochaTest:integrity',
		'demo:help'
	]);

	// assemble!
	gtx.alias('prep', [
		'clean:tmp',
		'clean:test',
		'jshint:support',
		'jshint:fixtures',
		'mocha_unfunk:dev'
	]);
	gtx.alias('rebuild', [
		'clean:build',
		'prep',
		'ts:api',
		'copy:cli',
		'regex-replace:cli',
		'tslint:source',
		// 'export_declaration:api'
	]);
	gtx.alias('build', [
		'rebuild'
	]);
	gtx.alias('test', [
		'build',
		'tslint:testing',
		'gtx-type:moduleTest',
		'mochaTest:spec'
	]);
	gtx.alias('default', [
		'test'
	]);
	gtx.alias('demo:help', [
		'shell:demo_help'
	]);

	gtx.alias('dev', [
		'clean:build',
		'prep',
		'typson:http',
		//'ts:scratch',
		//'shell:scratch'
	]);

	gtx.alias('specjs', ['mochaTest:spec']);
	gtx.alias('scratch', ['clean:tmp', 'ts:scratch']);

	gtx.alias('debugger', ['gtx:api']);

	// additional editor toolbar mappings
	gtx.alias('edit_01', 'gtx:tsd');
	gtx.alias('edit_02', 'gtx:api');
	gtx.alias('edit_03', 'build', 'gtx:cli');
	gtx.alias('edit_04', 'gtx:core');
	gtx.alias('edit_05', 'gtx:git');
	gtx.alias('edit_06', 'gtx:xm');
	gtx.alias('edit_07', 'gtx:http');
	gtx.alias('edit_08', 'scratch');

	// build and send to grunt.initConfig();
	gtx.finalise();
};
<commit_msg>dropped a rexgex replace target<commit_after>/*jshint -W098 */

module.exports = function (grunt) {
	'use strict';

	var path = require('path');
	var util = require('util');

	var isTravis = (process.env.TRAVIS === 'true');
	var isVagrant = (process.env.PWD === '/vagrant');
	if (isVagrant) {
		grunt.log.writeln('-> ' + 'vagrant detected'.cyan);
	}
	var cpuCores = require('os').cpus().length;
	//grunt.log.writeln(util.inspect(process.env));

	var gtx = require('gruntfile-gtx').wrap(grunt);
	gtx.loadAuto();
	gtx.loadNpm([
		'mocha-unfunk-reporter'
	]);

	//defaults and one-off tasks
	gtx.config({
		pkg: gtx.readJSON('package.json'),
		jshint: {
			options: gtx.readJSON('.jshintrc', {
				reporter: './node_modules/jshint-path-reporter'
			}),
			support: ['Gruntfile.js', 'test/*.js', 'lib/**/*.js'],
			fixtures: ['test/**/fixtures/**/*.js']
		},
		tslint: {
			options: {
				configuration: gtx.readJSON('tslint.json'),
				formatter: 'tslint-path-formatter'
			},
			source: ['src/**/*.ts', '!src/test', '!src/spec'],
			helper: ['test/*.ts'],
			testing: [
				'src/test/**/*.ts',
				'src/spec/**/*.ts'
			]
		},
		todos: {
			options: {
				reporter: 'path',
				verbose: false,
				priorities: {
					low: /(NOTE|TODO)/,
					med: /(FIXME)/,
					high: /(BROKEN)/
				}
			},
			all: {
				options: {},
				src: ['src/**/*.ts', 'test/**/src/**/*.ts']
			}
		},
		clean: {
			tmp: ['tmp/**/*', 'test/tmp/**/*'],
			dump: ['test/modules/**/dump'],
			test: ['test/*/spec/build/**/*'],
			build: ['build/**', 'build/**/*.js', 'build/**/*.d.ts', 'build/**/*.js.map']
		},
		copy: {
			cli: {
				files: [
				// includes files within path
					{expand: true, cwd: 'src', src: ['cli.js', '.gitattributes'], dest: 'build', filter: 'isFile'}
				]
			}
		},
		'regex-replace': {
			cli: {
				src: ['build/cli.js'],
				actions: [
					{
						name: 'eol',
						search: '\\r\\n',
						replace: '\n',
						flags: 'g'
					}
				]
			}
		},
		tv4: {
			packjson: {
				options: {
					root: function() {
						return require('package.json-schema').get();
					}
				},
				src: ['package.json']
			},
			tsd: {
				options: {
					multi: true,
					root: 'schema/tsd-v4.json'
				},
				src: ['tsd.json']
			},
			schemas: {
				options: {
					multi: true,
					root: 'http://json-schema.org/draft-04/schema#'
				},
				src: ['schema/*.json']
			}
		},
		mochaTest: {
			options: {
				reporter: 'mocha-unfunk-reporter',
				timeout: 3000
			},
			integrity: ['test/integrity.js'],
			// some extra js tests
			spec: ['test/spec/*.js']
		},
		typson: {
			options: {

			},
			http: {
				src: [
					'./src/http/types.ts'
				]
			}
		},
		mocha_unfunk: {
			dev: {
				options: {
					reportPending: true,
					stackFilter: true
				}
			}
		},
		ts_clean: {
			build: {
				src: ['build/**/*'],
				dot: true
			}
		},
		ts: {
			options: {
				module: 'commonjs',
				fast: 'never',
				target: 'es5',
				declaration: true,
				sourcemap: true,
				removeComments: true,
				noImplicitAny: false
			},
			api: {
				src: ['src/**/*.ts', '!src/test/**/*.ts', '!src/spec/**/*.ts', '!src/**/_ref.d.ts'],
				outDir: 'build/'
			},
			test: {
				src: ['src/test.ts'],
				outDir: 'build/'
			},
			/*blobSha: {
				src: ['src/util/blobSha.ts'],
				out: 'util/blobSha.js'
			},*/
			/*capture_task: {
				src: ['tasks/capture_cli.ts'],
				out: 'tasks/capture_cli.js'
			},*/
			//use this non-checked-in file to test small snippets of dev code
			dev: {
				src: ['src/dev.ts'],
				out: 'tmp/dev.js'
			},
			scratch: {
				options: {
					baseDir: './src'
				},
				src: ['src/dt/dt.ts'],
				outDir: 'tmp/'
			}
		},
		shell: {
			options: {
				failOnError: true,
				stdout: true
			},
			demo_help: {
				command: [
					'node', './build/cli.js',
					'-h',
					'--capture',
					'--style', 'ansi'
				].join(' '),
				options: {
				}
			},
			demo_html: {
				command: [
					'node', './build/cli.js',
					'-h',
					'--style', 'html'
				].join(' '),
				options: {
				}
			},
			scratch: {
				command: [
					'node', './tmp/dt/dt',
					'--stack'
				].join(' '),
				options: {
				}
			}
		}
	});

	// module tester macro
	gtx.define('moduleTest', function (macro, id) {
		var srcPath = 'src/spec/' + id + '/';

		var basePath = 'test/spec/' + id + '/';
		var tmpPath = basePath + 'tmp/';
		var outPath = basePath + 'build/';

		macro.add('clean', [tmpPath, outPath]);
		macro.add('ts', {
			options: {
				module: 'commonjs',
				target: 'es5',
				declaration: false,
				sourcemap: true,
				noImplicitAny: false
			},
			src: [srcPath + '**/*.ts'],
			outDir: outPath
		});
		macro.add('tslint', {
			src: [srcPath + '** /*.ts']
		});
		if (macro.getParam('http', 0) > 0) {
			macro.add('connect', {
				options: {
					port: macro.getParam('http'),
					base: basePath + 'www/'
				}
			});
		}
		macro.run('mocha_unfunk:dev');
		macro.add('mochaTest', {
			options: {
				timeout: macro.getParam('timeout', 3000)
			},
			src: [outPath + 'spec/**/*.js']
		});
		macro.tag('module');

		//TODO implement new gruntfile-gtx once() feature (run-once dependencies, like tslint:source or tslint:helper)
	}, {
		concurrent: 1 //cpuCores
	});

	var longTimer = (isVagrant ? 250000 : 10000);

	// modules
	gtx.create('xm', 'moduleTest', null, 'lib');
	gtx.create('git', 'moduleTest', {timeout: longTimer}, 'lib');
	gtx.create('tsd', 'moduleTest', {timeout: longTimer}, 'lib,core');
	gtx.create('core,api,cli', 'moduleTest', {timeout: longTimer}, 'core');
	gtx.create('http', 'moduleTest', {
		timeout: longTimer,
		http: 9090
	}, 'lib');

	gtx.alias('pre_publish', [
		/*'tv4:schemas',*/
		'tv4:tsd',
		'tv4:packjson',
		'rebuild',
		'regex-replace:cli',
		'ts_clean:build',
		'gtx:cli',
		// 'gtx:api',
		'mochaTest:integrity',
		'demo:help'
	]);

	// assemble!
	gtx.alias('prep', [
		'clean:tmp',
		'clean:test',
		'jshint:support',
		'jshint:fixtures',
		'mocha_unfunk:dev'
	]);
	gtx.alias('rebuild', [
		'clean:build',
		'prep',
		'ts:api',
		'copy:cli',
		'regex-replace:cli',
		'tslint:source',
		// 'export_declaration:api'
	]);
	gtx.alias('build', [
		'rebuild'
	]);
	gtx.alias('test', [
		'build',
		'tslint:testing',
		'gtx-type:moduleTest',
		'mochaTest:spec'
	]);
	gtx.alias('default', [
		'test'
	]);
	gtx.alias('demo:help', [
		'shell:demo_help'
	]);

	gtx.alias('dev', [
		'clean:build',
		'prep',
		'typson:http',
		//'ts:scratch',
		//'shell:scratch'
	]);

	gtx.alias('specjs', ['mochaTest:spec']);
	gtx.alias('scratch', ['clean:tmp', 'ts:scratch']);

	gtx.alias('debugger', ['gtx:api']);

	// additional editor toolbar mappings
	gtx.alias('edit_01', 'gtx:tsd');
	gtx.alias('edit_02', 'gtx:api');
	gtx.alias('edit_03', 'build', 'gtx:cli');
	gtx.alias('edit_04', 'gtx:core');
	gtx.alias('edit_05', 'gtx:git');
	gtx.alias('edit_06', 'gtx:xm');
	gtx.alias('edit_07', 'gtx:http');
	gtx.alias('edit_08', 'scratch');

	// build and send to grunt.initConfig();
	gtx.finalise();
};
<|endoftext|>


<commit_before>/* File: GruntFile.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), Boulevard Nicephore Niepce, 86360 CHASSENEUIL-DU-POITOU, France
 * (direction-innovation@cned.fr)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

'use strict';

var path = require('path');

module.exports = function(grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        app: '.',
        dist: 'dist',
        generated: 'generated'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            main: {
                files: ['app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff}'],
            },
            options: {
                livereload: true/*,
                port: 3000,
                key: grunt.file.read('../sslcert/key.pem'),
                cert: grunt.file.read('../sslcert/cert.pem')*/
            }
        },
        express: {
            options: {
                hostname: '0.0.0.0'
            },
            livereload: {
                options: {
                    server: path.resolve('./app.js'),
                    livereload: false,
                    serverreload: false,
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, yeomanConfig.app)],
                    spawn: false
                }
            },
            test: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')]
                }
            },
            dist: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: path.resolve(__dirname, yeomanConfig.dist)
                }
            },
            server: {
                options: {
                    port: 80
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '<%= yeoman.generated %>/*',
                        '!<%= yeoman.dist %>/.git*']
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: 'checkstyle',
                reporterOutput: 'generated/jshint/resultJSHint.xml'
            },
            all: {
                src: ['Gruntfile.js', 'app/scripts/**/*.js', 'api/**/*.js', 'test/spec/**/*.js']
            }
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/styles/fonts/*']
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            // By default, your `index.html` <!-- Usemin Block --> will take care of
            // minification. This option is pre-configured if you do not wish to use
            // Usemin blocks.
            // dist: {
            //   files: {
            //     '<%= yeoman.dist %>/styles/main.css': [
            //       '.tmp/styles/{,*/}*.css',
            //       '<%= yeoman.app %>/styles/{,*/}*.css'
            //     ]
            //   }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                     // https://github.com/yeoman/grunt-usemin/issues/44
                     //collapseWhitespace: true,
                     collapseBooleanAttributes: true,
                     removeAttributeQuotes: true,
                     removeRedundantAttributes: true,
                     useShortDoctype: true,
                     removeEmptyAttributes: true,
                     removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: ['*.html', 'views/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        'app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff}',
                        'app/bower_components/**/*.js',
                        'api/**/*',
                        'models/**/*',
                        'routes/**/*',
                        'custom_node_modules/**',
                        'app.js',
                        'Gruntfile.js',
                        'package.json',
                        'files/**/**/**',
                        'po/**']
                }, {
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: ['env/config.<%= [NODE_ENV] %>.json'],
                    rename: function(dest, src) {
                        return dest + '/env/config.json';
                    }
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*']
                }]
            }
        },
        concurrent: {
            dist: [
                'imagemin',
                'svgmin']
        },
        ngmin: {
            controllers: {
                expand: true,
                cwd: 'app',
                src: ['scripts/**/*.js'],
                dest: 'generated/'
            }
        },
        uglify: {
            build: {
                src: ' <%= yeoman.generated %>/scripts/**/*.js',
                dest: '<%= yeoman.dist %>/app/scripts/front.js'
            }
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        nggettext_extract: {
            pot: {
                files: {
                    'po/template.pot': ['app/views/**/*.html']
                }
            }
        },
        nggettext_compile: {
            all: {
                files: {
                    'app/scripts/translations.js': ['po/*.po']
                }
            }
        },
        /**
         * Specification de chaque configuration d'un ENV comme task
         */
        env: {
            dev: {
                src: 'env/config.json'
            },
            test: {
                src: 'env/config.test.json'
            },
            integ: {
                src: 'env/config.integ.json'
            },
            recette: {
                src: 'env/config.recette.json'
            },
            prod: {
                src: 'env/config.prod.json'
            }
        },
        /**
         *  Generation des fichiers avec
         *  des liens absoluts selon l'environnement
         */
        template: {
            'generate-from-tpl': {
                options: {
                    data: {
                        'URL_REQUEST': '<%= [URL_REQUEST] %>'
                    }
                },
                files: {
                    './app/index.html': ['./app/index.html.tpl'],
                    './app/scripts/app.js': ['./app/scripts/app.js.tpl'],
                    './app/scripts/services/config.js': ['./app/scripts/services/config.js.tpl']
                }
            },
            'replace-custom-node-modules': {
                files: {
                    './node_modules/passport-local/lib/passport-local/strategy.js': ['./custom_node_modules/passport-local/lib/passport-local/strategy.js']
                }
            }
        }

    });

    grunt.registerTask('build', [
        'clean:dist',
        'copy:dist',
        'useminPrepare',
        'ngmin',
        'uglify',
        'usemin']);

    grunt.registerTask('setEnv', function() {
        grunt.config('NODE_ENV', process.env.NODE_ENV);
        grunt.config('URL_REQUEST', process.env.URL_REQUEST);
        console.log('ENV = ' + process.env.NODE_ENV);
    });

    grunt.registerTask('build-dev', [
        'env:dev',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-integ', [
        'env:integ',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-recette', [
        'env:recette',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-prod', [
        'env:prod',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('server', function(target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'express:dist:keepalive']);
        }

        var env = grunt.file.readJSON('./env/config.json').NODE_ENV;
        if (env === 'dev') {
            grunt.task.run([
                'env:dev',
                'setEnv',
                'template:generate-from-tpl',
                'template:replace-custom-node-modules',
                'clean:server',
                'express:livereload',
                'watch:main']);
            //'concurrent:server',
        } else {
            grunt.task.run([
                'template:replace-custom-node-modules',
                'clean:server',
            //'concurrent:server',
            'express:livereload',
                'watch:main']);
        }
    });

    grunt.registerTask('test', [
        'env:test',
        'clean:server',
        'express:test',
        'jshint:all',
        'karma']);
};<commit_msg>Génération des fichier de l'environnement dans le task "TEST"<commit_after>/* File: GruntFile.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), Boulevard Nicephore Niepce, 86360 CHASSENEUIL-DU-POITOU, France
 * (direction-innovation@cned.fr)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

'use strict';

var path = require('path');

module.exports = function(grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        app: '.',
        dist: 'dist',
        generated: 'generated'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            main: {
                files: ['app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff}'],
            },
            options: {
                livereload: true
                /*,
                port: 3000,
                key: grunt.file.read('../sslcert/key.pem'),
                cert: grunt.file.read('../sslcert/cert.pem')*/
            }
        },
        express: {
            options: {
                hostname: '0.0.0.0'
            },
            livereload: {
                options: {
                    server: path.resolve('./app.js'),
                    livereload: false,
                    serverreload: false,
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, yeomanConfig.app)],
                    spawn: false
                }
            },
            test: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')]
                }
            },
            dist: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: path.resolve(__dirname, yeomanConfig.dist)
                }
            },
            server: {
                options: {
                    port: 80
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '<%= yeoman.generated %>/*',
                        '!<%= yeoman.dist %>/.git*']
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: 'checkstyle',
                reporterOutput: 'generated/jshint/resultJSHint.xml'
            },
            all: {
                src: ['Gruntfile.js', 'app/scripts/**/*.js', 'api/**/*.js', 'test/spec/**/*.js']
            }
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/styles/fonts/*']
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            // By default, your `index.html` <!-- Usemin Block --> will take care of
            // minification. This option is pre-configured if you do not wish to use
            // Usemin blocks.
            // dist: {
            //   files: {
            //     '<%= yeoman.dist %>/styles/main.css': [
            //       '.tmp/styles/{,*/}*.css',
            //       '<%= yeoman.app %>/styles/{,*/}*.css'
            //     ]
            //   }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                     // https://github.com/yeoman/grunt-usemin/issues/44
                     //collapseWhitespace: true,
                     collapseBooleanAttributes: true,
                     removeAttributeQuotes: true,
                     removeRedundantAttributes: true,
                     useShortDoctype: true,
                     removeEmptyAttributes: true,
                     removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: ['*.html', 'views/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        'app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff}',
                        'app/bower_components/**/*.js',
                        'api/**/*',
                        'models/**/*',
                        'routes/**/*',
                        'custom_node_modules/**',
                        'app.js',
                        'Gruntfile.js',
                        'package.json',
                        'files/**/**/**',
                        'po/**']
                }, {
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: ['env/config.<%= [NODE_ENV] %>.json'],
                    rename: function(dest, src) {
                        return dest + '/env/config.json';
                    }
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*']
                }]
            }
        },
        concurrent: {
            dist: [
                'imagemin',
                'svgmin']
        },
        ngmin: {
            controllers: {
                expand: true,
                cwd: 'app',
                src: ['scripts/**/*.js'],
                dest: 'generated/'
            }
        },
        uglify: {
            build: {
                src: ' <%= yeoman.generated %>/scripts/**/*.js',
                dest: '<%= yeoman.dist %>/app/scripts/front.js'
            }
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        nggettext_extract: {
            pot: {
                files: {
                    'po/template.pot': ['app/views/**/*.html']
                }
            }
        },
        nggettext_compile: {
            all: {
                files: {
                    'app/scripts/translations.js': ['po/*.po']
                }
            }
        },
        /**
         * Specification de chaque configuration d'un ENV comme task
         */
        env: {
            dev: {
                src: 'env/config.json'
            },
            test: {
                src: 'env/config.test.json'
            },
            integ: {
                src: 'env/config.integ.json'
            },
            recette: {
                src: 'env/config.recette.json'
            },
            prod: {
                src: 'env/config.prod.json'
            }
        },
        /**
         *  Generation des fichiers avec
         *  des liens absoluts selon l'environnement
         */
        template: {
            'generate-from-tpl': {
                options: {
                    data: {
                        'URL_REQUEST': '<%= [URL_REQUEST] %>'
                    }
                },
                files: {
                    './app/index.html': ['./app/index.html.tpl'],
                    './app/scripts/app.js': ['./app/scripts/app.js.tpl'],
                    './app/scripts/services/config.js': ['./app/scripts/services/config.js.tpl']
                }
            },
            'replace-custom-node-modules': {
                files: {
                    './node_modules/passport-local/lib/passport-local/strategy.js': ['./custom_node_modules/passport-local/lib/passport-local/strategy.js']
                }
            }
        }

    });

    grunt.registerTask('build', [
        'clean:dist',
        'copy:dist',
        'useminPrepare',
        'ngmin',
        'uglify',
        'usemin']);

    grunt.registerTask('setEnv', function() {
        grunt.config('NODE_ENV', process.env.NODE_ENV);
        grunt.config('URL_REQUEST', process.env.URL_REQUEST);
        console.log('ENV = ' + process.env.NODE_ENV);
    });

    grunt.registerTask('build-dev', [
        'env:dev',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-integ', [
        'env:integ',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-recette', [
        'env:recette',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-prod', [
        'env:prod',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('server', function(target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'express:dist:keepalive']);
        }

        var env = grunt.file.readJSON('./env/config.json').NODE_ENV;
        if (env === 'dev') {
            grunt.task.run([
                'env:dev',
                'setEnv',
                'template:generate-from-tpl',
                'template:replace-custom-node-modules',
                'clean:server',
                'express:livereload',
                'watch:main']);
            //'concurrent:server',
        } else {
            grunt.task.run([
                'template:replace-custom-node-modules',
                'clean:server',
            //'concurrent:server',
            'express:livereload',
                'watch:main']);
        }
    });

    grunt.registerTask('test', [
        'env:dev',
        'setEnv',
        'template:generate-from-tpl',
        'env:test',
        'clean:server',
        'express:test',
        'jshint:all',
        'karma']);
};<|endoftext|>