<commit_before>/*
 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */
/*global module, require*/
module.exports = function (grunt) {
    'use strict';

    // load dependencies
    require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-targethtml', 'grunt-usemin', 'grunt-cleanempty']});
    grunt.loadTasks('tasks');

    // Project configuration.
    grunt.initConfig({
        pkg  : grunt.file.readJSON("package.json"),
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        'dist',
                        'src/.index.html',
                        'src/styles/brackets.css'
                    ]
                }]
            }
        },
        copy: {
            dist: {
                files: [
                    {
                        'dist/index.html': 'src/.index.html'
                    },
                    /* static files */
                    {
                        expand: true,
                        dest: 'dist/',
                        cwd: 'src/',
                        src: [
                            'nls/{,*/}*.js',
                            'xorigin.js',
                            'dependencies.js',
                            'thirdparty/requirejs/require.js',
                            'LiveDevelopment/launch.html',
                            'LiveDevelopment/MultiBrowserImpl/transports/**',
                            'LiveDevelopment/MultiBrowserImpl/launchers/**'
                        ]
                    },
                    /* extensions and CodeMirror modes */
                    {
                        expand: true,
                        dest: 'dist/',
                        cwd: 'src/',
                        src: [
                            'extensions/default/**/*',
                            '!extensibility/node/spec/**',
                            '!extensibility/node/node_modules/**/{test,tst}/**/*',
                            '!extensibility/node/node_modules/**/examples/**/*',
                            '!filesystem/impls/appshell/**/*',
                            '!extensions/default/*/unittest-files/**/*',
                            '!extensions/default/*/unittests.js',
                            '!extensions/default/{*/thirdparty,**/node_modules}/**/test/**/*',
                            '!extensions/default/{*/thirdparty,**/node_modules}/**/doc/**/*',
                            '!extensions/default/{*/thirdparty,**/node_modules}/**/examples/**/*',
                            '!extensions/default/*/thirdparty/**/*.htm{,l}',
                            'extensions/dev/*',
                            'extensions/samples/**/*',
                            'thirdparty/CodeMirror2/addon/{,*/}*',
                            'thirdparty/CodeMirror2/keymap/{,*/}*',
                            'thirdparty/CodeMirror2/lib/{,*/}*',
                            'thirdparty/CodeMirror2/mode/{,*/}*',
                            '!thirdparty/CodeMirror2/mode/**/*.html',
                            '!thirdparty/CodeMirror2/**/*test.js',
                            'thirdparty/CodeMirror2/theme/{,*/}*',
                            'thirdparty/i18n/*.js',
                            'thirdparty/text/*.js'
                        ]
                    },
                    /* styles, fonts and images */
                    {
                        expand: true,
                        dest: 'dist/styles',
                        cwd: 'src/styles',
                        src: ['jsTreeTheme.css', 'fonts/{,*/}*.*', 'images/*', 'brackets.min.css*']
                    }
                ]
            }
        },
        cleanempty: {
            options: {
                force: true,
                files: false
            },
            src: ['dist/**/*'],
        },
        less: {
            dist: {
                files: {
                    "src/styles/brackets.min.css": "src/styles/brackets.less"
                },
                options: {
                    compress: true
                }
            }
        },
        requirejs: {
            dist: {
                // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
                options: {
                    // `name` and `out` is set by grunt-usemin
                    baseUrl: 'src',
                    optimize: 'uglify2',
                    // brackets.js should not be loaded until after polyfills defined in "utils/Compatibility"
                    // so explicitly include it in main.js
                    include: ["utils/Compatibility", "brackets"],
                    // required to support SourceMaps
                    // http://requirejs.org/docs/errors.html#sourcemapcomments
                    preserveLicenseComments: false,
                    useStrict: true,
                    // Disable closure, we want define/require to be globals
                    wrap: false,
                    exclude: ["text!config.json"],
                    uglify2: {} // https://github.com/mishoo/UglifyJS2
                }
            }
        },
        targethtml: {
            dist: {
                files: {
                    'src/.index.html': 'src/index.html'
                }
            }
        },
        useminPrepare: {
            options: {
                dest: 'dist'
            },
            html: 'src/.index.html'
        },
        usemin: {
            options: {
                dirs: ['dist']
            },
            html: ['dist/{,*/}*.html']
        },
        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: 'src',
                    src: '*.html',
                    dest: 'dist'
                }]
            }
        },
        meta : {
            src   : [
                'src/**/*.js',
                '!src/thirdparty/**',
                '!src/widgets/bootstrap-*.js',
                '!src/extensions/**/unittest-files/**/*.js',
                '!src/extensions/**/thirdparty/**/*.js',
                '!src/extensions/dev/**',
                '!src/extensions/disabled/**',
                '!**/node_modules/**/*.js',
                '!src/**/*-min.js',
                '!src/**/*.min.js'
            ],
            test : [
                'test/**/*.js',
                '!test/perf/*-files/**/*.js',
                '!test/spec/*-files/**/*.js',
                '!test/spec/*-known-goods/**/*.js',
                '!test/spec/FindReplace-test-files-*/**/*.js',
                '!test/smokes/**',
                '!test/temp/**',
                '!test/thirdparty/**',
                '!test/**/node_modules/**/*.js'
            ],
            grunt: [
                'Gruntfile.js',
                'tasks/**/*.js'
            ],
            /* specs that can run in phantom.js */
            specs : [
                'test/spec/CommandManager-test.js',
                //'test/spec/LanguageManager-test.js',
                //'test/spec/PreferencesManager-test.js',
                'test/spec/ViewUtils-test.js'
            ]
        },
        watch: {
            all : {
                files: ['**/*', '!**/node_modules/**'],
                tasks: ['jshint']
            },
            grunt : {
                files: ['<%= meta.grunt %>', 'tasks/**/*'],
                tasks: ['jshint:grunt']
            },
            src : {
                files: ['<%= meta.src %>', 'src/**/*'],
                tasks: ['jshint:src']
            },
            test : {
                files: ['<%= meta.test %>', 'test/**/*'],
                tasks: ['jshint:test']
            }
        },
        /* FIXME (jasonsanjose): how to handle extension tests */
        jasmine : {
            src : 'undefined.js', /* trick the default runner to run without importing src files */
            options : {
                junit : {
                    path: 'test/results',
                    consolidate: true
                },
                specs : '<%= meta.specs %>',
                /* Keep in sync with test/SpecRunner.html dependencies */
                vendor : [
                    'test/polyfills.js', /* For reference to why this polyfill is needed see Issue #7951. The need for this should go away once the version of phantomjs gets upgraded to 2.0 */
                    'src/thirdparty/jquery-2.1.3.min.js',
                    'src/thirdparty/CodeMirror2/lib/codemirror.js',
                    'src/thirdparty/CodeMirror2/lib/util/dialog.js',
                    'src/thirdparty/CodeMirror2/lib/util/searchcursor.js',
                    'src/thirdparty/CodeMirror2/addon/edit/closetag.js',
                    'src/thirdparty/CodeMirror2/addon/selection/active-line.js',
                    'src/thirdparty/mustache/mustache.js',
                    'src/thirdparty/path-utils/path-utils.min',
                    'src/thirdparty/less-1.7.5.min.js'
                ],
                helpers : [
                    'test/spec/PhantomHelper.js'
                ],
                template : require('grunt-template-jasmine-requirejs'),
                templateOptions: {
                    requireConfig : {
                        baseUrl: 'src',
                        paths: {
                            'test' : '../test',
                            'perf' : '../test/perf',
                            'spec' : '../test/spec',
                            'text' : 'thirdparty/text/text',
                            'i18n' : 'thirdparty/i18n/i18n'
                        }
                    }
                }
            }
        },
        'jasmine_node': {
            projectRoot: 'src/extensibility/node/spec/'
        },
        jshint: {
            all: [
                '<%= meta.grunt %>',
                '<%= meta.src %>',
                '<%= meta.test %>',
                //This code is third party, thus we should not touch it
                '!src/extensions/default/HTMLHinter/slowparse/**',
                //This javascript file has many third party methods, so skip it.
                '!src/extensions/default/HTMLHinter/tooltipsy.source.js',
                //Many Files are third party, thus we skip it
                '!src/extensions/default/brackets-browser-livedev/nohost/**',
                //This is a file we wrote, so we should lint it
                'src/extensions/default/brackets-browser-livedev/nohost/src/NoHostServer.js'
            ],
            grunt:  '<%= meta.grunt %>',
            src:    [
                '<%= meta.src %>',
                //This code is third party, thus we should not touch it
                '!src/extensions/default/HTMLHinter/slowparse/**',
                //This javascript file has many third party methods, so skip it.
                '!src/extensions/default/HTMLHinter/tooltipsy.source.js',
                //Many Files are third party, thus we skip it
                '!src/extensions/default/brackets-browser-livedev/nohost/**',
                //This is a file we wrote, so we should lint it
                'src/extensions/default/brackets-browser-livedev/nohost/src/NoHostServer.js'
            ],
            test:   '<%= meta.test %>',
            /* use strict options to mimic JSLINT until we migrate to JSHINT in Brackets */
            options: {
                jshintrc: '.jshintrc'
            }
        },
        shell: {
            repo: grunt.option("shell-repo") || "../brackets-shell",
            mac: "<%= shell.repo %>/installer/mac/staging/<%= pkg.name %>.app",
            win: "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe",
            linux: "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets"
        }
    });

    // task: install
    grunt.registerTask('install', ['write-config', 'less']);

    // task: test
    grunt.registerTask('test', ['jshint:all', 'jasmine']);
//    grunt.registerTask('test', ['jshint:all', 'jasmine', 'jasmine_node']);

    // task: set-release
    // Update version number in package.json and rewrite src/config.json
    grunt.registerTask('set-release', ['update-release-number', 'write-config']);

    // task: build
    grunt.registerTask('build', [
        'jshint:src',
        'jasmine',
        'clean',
        'less',
        'targethtml',
        'useminPrepare',
        'htmlmin',
        'requirejs',
        'concat',
        /*'cssmin',*/
        /*'uglify',*/
        'copy',
        'cleanempty',
        'usemin',
        'build-config'
    ]);

    // Default task.
    grunt.registerTask('default', ['test']);
};
<commit_msg>Updated Comments<commit_after>/*
 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */
/*global module, require*/
module.exports = function (grunt) {
    'use strict';

    // load dependencies
    require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-targethtml', 'grunt-usemin', 'grunt-cleanempty']});
    grunt.loadTasks('tasks');

    // Project configuration.
    grunt.initConfig({
        pkg  : grunt.file.readJSON("package.json"),
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        'dist',
                        'src/.index.html',
                        'src/styles/brackets.css'
                    ]
                }]
            }
        },
        copy: {
            dist: {
                files: [
                    {
                        'dist/index.html': 'src/.index.html'
                    },
                    /* static files */
                    {
                        expand: true,
                        dest: 'dist/',
                        cwd: 'src/',
                        src: [
                            'nls/{,*/}*.js',
                            'xorigin.js',
                            'dependencies.js',
                            'thirdparty/requirejs/require.js',
                            'LiveDevelopment/launch.html',
                            'LiveDevelopment/MultiBrowserImpl/transports/**',
                            'LiveDevelopment/MultiBrowserImpl/launchers/**'
                        ]
                    },
                    /* extensions and CodeMirror modes */
                    {
                        expand: true,
                        dest: 'dist/',
                        cwd: 'src/',
                        src: [
                            'extensions/default/**/*',
                            '!extensibility/node/spec/**',
                            '!extensibility/node/node_modules/**/{test,tst}/**/*',
                            '!extensibility/node/node_modules/**/examples/**/*',
                            '!filesystem/impls/appshell/**/*',
                            '!extensions/default/*/unittest-files/**/*',
                            '!extensions/default/*/unittests.js',
                            '!extensions/default/{*/thirdparty,**/node_modules}/**/test/**/*',
                            '!extensions/default/{*/thirdparty,**/node_modules}/**/doc/**/*',
                            '!extensions/default/{*/thirdparty,**/node_modules}/**/examples/**/*',
                            '!extensions/default/*/thirdparty/**/*.htm{,l}',
                            'extensions/dev/*',
                            'extensions/samples/**/*',
                            'thirdparty/CodeMirror2/addon/{,*/}*',
                            'thirdparty/CodeMirror2/keymap/{,*/}*',
                            'thirdparty/CodeMirror2/lib/{,*/}*',
                            'thirdparty/CodeMirror2/mode/{,*/}*',
                            '!thirdparty/CodeMirror2/mode/**/*.html',
                            '!thirdparty/CodeMirror2/**/*test.js',
                            'thirdparty/CodeMirror2/theme/{,*/}*',
                            'thirdparty/i18n/*.js',
                            'thirdparty/text/*.js'
                        ]
                    },
                    /* styles, fonts and images */
                    {
                        expand: true,
                        dest: 'dist/styles',
                        cwd: 'src/styles',
                        src: ['jsTreeTheme.css', 'fonts/{,*/}*.*', 'images/*', 'brackets.min.css*']
                    }
                ]
            }
        },
        cleanempty: {
            options: {
                force: true,
                files: false
            },
            src: ['dist/**/*'],
        },
        less: {
            dist: {
                files: {
                    "src/styles/brackets.min.css": "src/styles/brackets.less"
                },
                options: {
                    compress: true
                }
            }
        },
        requirejs: {
            dist: {
                // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
                options: {
                    // `name` and `out` is set by grunt-usemin
                    baseUrl: 'src',
                    optimize: 'uglify2',
                    // brackets.js should not be loaded until after polyfills defined in "utils/Compatibility"
                    // so explicitly include it in main.js
                    include: ["utils/Compatibility", "brackets"],
                    // required to support SourceMaps
                    // http://requirejs.org/docs/errors.html#sourcemapcomments
                    preserveLicenseComments: false,
                    useStrict: true,
                    // Disable closure, we want define/require to be globals
                    wrap: false,
                    exclude: ["text!config.json"],
                    uglify2: {} // https://github.com/mishoo/UglifyJS2
                }
            }
        },
        targethtml: {
            dist: {
                files: {
                    'src/.index.html': 'src/index.html'
                }
            }
        },
        useminPrepare: {
            options: {
                dest: 'dist'
            },
            html: 'src/.index.html'
        },
        usemin: {
            options: {
                dirs: ['dist']
            },
            html: ['dist/{,*/}*.html']
        },
        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: 'src',
                    src: '*.html',
                    dest: 'dist'
                }]
            }
        },
        meta : {
            src   : [
                'src/**/*.js',
                '!src/thirdparty/**',
                '!src/widgets/bootstrap-*.js',
                '!src/extensions/**/unittest-files/**/*.js',
                '!src/extensions/**/thirdparty/**/*.js',
                '!src/extensions/dev/**',
                '!src/extensions/disabled/**',
                '!**/node_modules/**/*.js',
                '!src/**/*-min.js',
                '!src/**/*.min.js'
            ],
            test : [
                'test/**/*.js',
                '!test/perf/*-files/**/*.js',
                '!test/spec/*-files/**/*.js',
                '!test/spec/*-known-goods/**/*.js',
                '!test/spec/FindReplace-test-files-*/**/*.js',
                '!test/smokes/**',
                '!test/temp/**',
                '!test/thirdparty/**',
                '!test/**/node_modules/**/*.js'
            ],
            grunt: [
                'Gruntfile.js',
                'tasks/**/*.js'
            ],
            /* specs that can run in phantom.js */
            specs : [
                'test/spec/CommandManager-test.js',
                //'test/spec/LanguageManager-test.js',
                //'test/spec/PreferencesManager-test.js',
                'test/spec/ViewUtils-test.js'
            ]
        },
        watch: {
            all : {
                files: ['**/*', '!**/node_modules/**'],
                tasks: ['jshint']
            },
            grunt : {
                files: ['<%= meta.grunt %>', 'tasks/**/*'],
                tasks: ['jshint:grunt']
            },
            src : {
                files: ['<%= meta.src %>', 'src/**/*'],
                tasks: ['jshint:src']
            },
            test : {
                files: ['<%= meta.test %>', 'test/**/*'],
                tasks: ['jshint:test']
            }
        },
        /* FIXME (jasonsanjose): how to handle extension tests */
        jasmine : {
            src : 'undefined.js', /* trick the default runner to run without importing src files */
            options : {
                junit : {
                    path: 'test/results',
                    consolidate: true
                },
                specs : '<%= meta.specs %>',
                /* Keep in sync with test/SpecRunner.html dependencies */
                vendor : [
                    'test/polyfills.js', /* For reference to why this polyfill is needed see Issue #7951. The need for this should go away once the version of phantomjs gets upgraded to 2.0 */
                    'src/thirdparty/jquery-2.1.3.min.js',
                    'src/thirdparty/CodeMirror2/lib/codemirror.js',
                    'src/thirdparty/CodeMirror2/lib/util/dialog.js',
                    'src/thirdparty/CodeMirror2/lib/util/searchcursor.js',
                    'src/thirdparty/CodeMirror2/addon/edit/closetag.js',
                    'src/thirdparty/CodeMirror2/addon/selection/active-line.js',
                    'src/thirdparty/mustache/mustache.js',
                    'src/thirdparty/path-utils/path-utils.min',
                    'src/thirdparty/less-1.7.5.min.js'
                ],
                helpers : [
                    'test/spec/PhantomHelper.js'
                ],
                template : require('grunt-template-jasmine-requirejs'),
                templateOptions: {
                    requireConfig : {
                        baseUrl: 'src',
                        paths: {
                            'test' : '../test',
                            'perf' : '../test/perf',
                            'spec' : '../test/spec',
                            'text' : 'thirdparty/text/text',
                            'i18n' : 'thirdparty/i18n/i18n'
                        }
                    }
                }
            }
        },
        'jasmine_node': {
            projectRoot: 'src/extensibility/node/spec/'
        },
        jshint: {
            all: [
                '<%= meta.grunt %>',
                '<%= meta.src %>',
                '<%= meta.test %>',
                // These modules include lots of third-party code, so we skip them
                '!src/extensions/default/HTMLHinter/slowparse/**',
                '!src/extensions/default/HTMLHinter/tooltipsy.source.js',
                '!src/extensions/default/brackets-browser-livedev/nohost/**',
                //With Previous skip statement, this file was ignored, so we specify it directly for jshinting
                'src/extensions/default/brackets-browser-livedev/nohost/src/NoHostServer.js'
            ],
            grunt:  '<%= meta.grunt %>',
            src:    [
                '<%= meta.src %>',
                // These modules include lots of third-party code, so we skip them
                '!src/extensions/default/HTMLHinter/slowparse/**',
                '!src/extensions/default/HTMLHinter/tooltipsy.source.js',
                '!src/extensions/default/brackets-browser-livedev/nohost/**',
                //With Previous skip statement, this file was ignored, so we specify it directly for jshinting
                'src/extensions/default/brackets-browser-livedev/nohost/src/NoHostServer.js'
            ],
            test:   '<%= meta.test %>',
            /* use strict options to mimic JSLINT until we migrate to JSHINT in Brackets */
            options: {
                jshintrc: '.jshintrc'
            }
        },
        shell: {
            repo: grunt.option("shell-repo") || "../brackets-shell",
            mac: "<%= shell.repo %>/installer/mac/staging/<%= pkg.name %>.app",
            win: "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe",
            linux: "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets"
        }
    });

    // task: install
    grunt.registerTask('install', ['write-config', 'less']);

    // task: test
    grunt.registerTask('test', ['jshint:all', 'jasmine']);
//    grunt.registerTask('test', ['jshint:all', 'jasmine', 'jasmine_node']);

    // task: set-release
    // Update version number in package.json and rewrite src/config.json
    grunt.registerTask('set-release', ['update-release-number', 'write-config']);

    // task: build
    grunt.registerTask('build', [
        'jshint:src',
        'jasmine',
        'clean',
        'less',
        'targethtml',
        'useminPrepare',
        'htmlmin',
        'requirejs',
        'concat',
        /*'cssmin',*/
        /*'uglify',*/
        'copy',
        'cleanempty',
        'usemin',
        'build-config'
    ]);

    // Default task.
    grunt.registerTask('default', ['test']);
};
<|endoftext|>


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

    grunt.initConfig({

        clean: {
            options: {
                force: true
            },

            pre_dist: {
                src: ['dist/']
            },

            dist: {
                src: [
                    'dist/css/**/*.css',
                    '!dist/css/main.css',
                    'dist/css/**/*.map',
                    'dist/sass/',
                    'dist/.sass-cache/'
                ]
            }
        },

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

        requirejs: {
            compile: {
                options: {
                    appDir: './src',
                    baseUrl: './src/js',
                    dir: 'dist',
                    modules: [
                        {
                            name: 'main'
                        }
                    ],
                    fileExclusionRegExp: /^(r|build|node_modules|Gruntfile)(\.js)?$/,
                    optimizeCss: 'none',
                    removeCombined: true,
                    mainConfigFile: './src/js/main.js',
                    waitSeconds: 30
                }
            }
        },

        compass: {
            dist: {
                options: {
                    sassDir: 'src/sass',
                    cssDir: 'src/css',
                    imagesDir: 'src/images',
                    fontsDir: 'src/fonts',
                    outputStyle: 'compressed',
                    relativeAssets: true,
                    noLineComments: true,
                    environment: 'production',
                    sourcemap: true
                }
            },

            dev: {
                options: {
                    sassDir: 'src/sass',
                    cssDir: 'src/css',
                    imagesDir: 'src/images',
                    fontsDir: 'src/fonts',
                    relativeAssets: true,
                    environment: 'development',
                    sourcemap: true
                }
            }
        },

        cssmin: {
            dist: {
                files: {
                    'dist/css/main.css': ['css/main.css']
                }
            }
        },

        concat: {
            css: {
                src: [
				    'src/css/styles.css',
                    '!src/css/main.css'
                ],
                dest: 'css/main.css'
            }
        },

        watch: {
            css: {
                files: ['src/sass/**/*.scss', 'src/sass/**/*.sass'],
                tasks: ['compass:dev', 'concat:css']
            }
        }
    });

    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    grunt.registerTask('default', ['compass:dev', 'concat:css']);

    grunt.registerTask('hint', ['compass:dev', 'jshint', 'inlinelint']);

    grunt.registerTask('minify',
        [
            'clean:pre_dist', 'compass:dist', 'concat:css', 'requirejs', 'cssmin:dist', 'clean:dist'
        ]);
};
<commit_msg>Fix task name<commit_after>module.exports = function(grunt) {
    'use strict';

    grunt.initConfig({

        clean: {
            options: {
                force: true
            },

            pre_dist: {
                src: ['dist/']
            },

            dist: {
                src: [
                    'dist/css/**/*.css',
                    '!dist/css/main.css',
                    'dist/css/**/*.map',
                    'dist/sass/',
                    'dist/.sass-cache/'
                ]
            }
        },

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

        requirejs: {
            compile: {
                options: {
                    appDir: './src',
                    baseUrl: './src/js',
                    dir: 'dist',
                    modules: [
                        {
                            name: 'main'
                        }
                    ],
                    fileExclusionRegExp: /^(r|build|node_modules|Gruntfile)(\.js)?$/,
                    optimizeCss: 'none',
                    removeCombined: true,
                    mainConfigFile: './src/js/main.js',
                    waitSeconds: 30
                }
            }
        },

        compass: {
            dist: {
                options: {
                    sassDir: 'src/sass',
                    cssDir: 'src/css',
                    imagesDir: 'src/images',
                    fontsDir: 'src/fonts',
                    outputStyle: 'compressed',
                    relativeAssets: true,
                    noLineComments: true,
                    environment: 'production',
                    sourcemap: true
                }
            },

            dev: {
                options: {
                    sassDir: 'src/sass',
                    cssDir: 'src/css',
                    imagesDir: 'src/images',
                    fontsDir: 'src/fonts',
                    relativeAssets: true,
                    environment: 'development',
                    sourcemap: true
                }
            }
        },

        cssmin: {
            dist: {
                files: {
                    'dist/css/main.css': ['css/main.css']
                }
            }
        },

        concat: {
            css: {
                src: [
				    'src/css/styles.css',
                    '!src/css/main.css'
                ],
                dest: 'css/main.css'
            }
        },

        watch: {
            css: {
                files: ['src/sass/**/*.scss', 'src/sass/**/*.sass'],
                tasks: ['compass:dev', 'concat:css']
            }
        }
    });

    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    grunt.registerTask('default', ['compass:dev', 'concat:css']);

    grunt.registerTask('hint', ['compass:dev', 'jshint', 'inlinelint']);

    grunt.registerTask('build',
        [
            'clean:pre_dist', 'compass:dist', 'concat:css', 'requirejs', 'cssmin:dist', 'clean:dist'
        ]);
};
<|endoftext|>


<commit_before>'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
    console.log(require('path').resolve(dir));
    return connect.static(require('path').resolve(dir));
};

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

    // configurable paths
    var yeomanConfig = {
        name: 'gmods',
        src: 'src',
        dist: 'dist',
        example:'example'
    };

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

    grunt.initConfig({
        yeoman: yeomanConfig,
        livereload:{
            port: 35799
        },
        watch: {
            livereload: {
                files: [
                    '<%= yeoman.src %>/{,*/}*.html',
                    '{.tmp,<%= yeoman.src %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.src %>}/scripts/{,*/}*.js',
                    '<%= yeoman.src %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ],
                tasks: ['livereload']
            }
        },
        connect: {
            options: {
                port: 9339,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.src),
                            mountFolder(connect, yeomanConfig.example)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test'),
                            mountFolder(connect, yeomanConfig.example)
                        ];
                    }
                }
            },
            dev:{
                options: {}
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.src %>/{,*/}*.js'
            ]
        },
        karma: {
            options: {
                configFile: 'karma.conf.js',
                runnerPort: 9119,
                browsers: ['Chrome', 'Firefox']
            },
            unit: {
                reporters: 'dots'
            },
            continuous: {
                singleRun: true,
                browsers: ['PhantomJS']
            },
            ci: {
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },
        concat: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= yeoman.name %>.js': [
                        '.tmp/{,*/}*.js',
                        '<%= yeoman.src %>/{,*/}*.js'
                    ]
                }
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= yeoman.name %>.min.js': [
                        '<%= yeoman.dist %>/<%= yeoman.name %>.js'
                    ]
                }
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.src %>',
                    dest: '<%= yeoman.dist %>',
                    src: []
                }]
            }
        },
        //https://github.com/vojtajina/grunt-bump
        bump: {
            options: {
                files: ['package.json', 'bower.json', 'component.json'],
                updateConfigs: [],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['package.json', 'bower.json', 'component.json'], // '-a' for all files
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: 'upstream',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
            }
        }
    });

    grunt.renameTask('regarde', 'watch');

    grunt.registerTask('server', [
        'clean:server',
        'livereload-start',
        'connect:livereload',
        'open',
        'watch'
    ]);

    grunt.registerTask('test', [
        'clean:server',
        'connect:test',
        'karma:ci'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'jshint',
        'test',
        'concat',
        'copy',
        'uglify',
    ]);

    grunt.registerTask('default', ['build']);
};
<commit_msg>Gruntfile: Refactored to serve app folder.<commit_after>'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
    console.log(require('path').resolve(dir));
    return connect.static(require('path').resolve(dir));
};

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

    // configurable paths
    var config = {
        name: 'gmods',
        lib:'lib',
        src: 'src',
        dist: 'dist',
        app:'app'
    };

    try {
        config.src = require('./component.json').appPath || config.src;
    } catch (e) {}

    grunt.initConfig({
        config: config,
        livereload:{
            port: 35799
        },
        watch: {
            livereload: {
                files: [
                    '<%= config.app %>/{,*/}*.html',
                    '{.tmp,<%= config.app %>}/{,*/}*.css',
                    '{.tmp,<%= config.app %>,<%= config.src %>}/{,*/}*.js',
                    '<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ],
                tasks: ['livereload']
            }
        },
        connect: {
            options: {
                port: 9339,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, config.lib),
                            mountFolder(connect, config.src),
                            mountFolder(connect, config.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test'),
                            mountFolder(connect, config.src)
                        ];
                    }
                }
            },
            dev:{
                options: {}
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= config.dist %>/*',
                        '!<%= config.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= config.src %>/{,*/}*.js'
            ]
        },
        karma: {
            options: {
                configFile: 'karma.conf.js',
                runnerPort: 9119,
                browsers: ['Chrome', 'Firefox']
            },
            unit: {
                reporters: 'dots'
            },
            continuous: {
                singleRun: true,
                browsers: ['PhantomJS']
            },
            ci: {
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },
        concat: {
            dist: {
                files: {
                    '<%= config.dist %>/<%= config.name %>.js': [
                        '.tmp/{,*/}*.js',
                        '<%= config.src %>/{,*/}*.js'
                    ]
                }
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= config.dist %>/<%= config.name %>.min.js': [
                        '<%= config.dist %>/<%= config.name %>.js'
                    ]
                }
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= config.src %>',
                    dest: '<%= config.dist %>',
                    src: []
                }]
            }
        },
        //https://github.com/vojtajina/grunt-bump
        bump: {
            options: {
                files: ['package.json', 'bower.json', 'component.json'],
                updateConfigs: [],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['package.json', 'bower.json', 'component.json'], // '-a' for all files
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: 'upstream',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
            }
        }
    });

    grunt.renameTask('regarde', 'watch');

    grunt.registerTask('server', [
        'clean:server',
        'livereload-start',
        'connect:livereload',
        'open',
        'watch'
    ]);

    grunt.registerTask('test', [
        'clean:server',
        'connect:test',
        'karma:ci'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'jshint',
        'test',
        'concat',
        'copy',
        'uglify',
    ]);

    grunt.registerTask('default', ['build']);
};
<|endoftext|>


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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      files: ['js/app/**/*.js', 'js/shims/**/*.js'],
      options: {
        globals: {
          console: true,
          module: true,
          require: true
        },
        undef: true
      }
    },
    watch: {
      files: ['Gruntfile.js', '<%= jshint.files %>'],
      tasks: ['jshint', 'browserify']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('browserify', 'Browserify and concatenate app sources', function() {

    var browserify  = require('browserify'),
        shim        = require('browserify-shim'),
        entryPoints = [ './js/app/index.js',
                        './js/app/fixture.js' ],
        moduleList  = [ './js/app/models/*.js' ];

    var addEntryPoint = function(r, entryPoint) {
      return r.require(require.resolve(entryPoint), { entry: true })
    };

    var output = shim(browserify(), {
      jquery: { path: './js/vendor/jquery.min.js', exports: '$' }
    })
      .require('underscore', {expose: "underscore"})
      .require('backbone', {expose: "backbone"})
      .require(require.resolve('./js/shims/parse.js'), {expose: "parse"})
      .require(require.resolve('./js/shims/google-maps.js'), {expose: "google-maps"});

    entryPoints.forEach(function(entryPoint) {
      output = addEntryPoint(output, entryPoint);
    });

    moduleList.forEach(function(modules) {
      require('glob')(modules, function(er, files) {
        files.forEach(function(file) {
          var name = file
            .replace("./js/app/","")
            .replace(/\.js$/,"");
          output = output.require(require.resolve(file),
                                  {expose: name});
        });
      });

    });

    output.bundle(function (err, src) {
      if (err) return console.error(err);

      require('fs').writeFileSync("./js/static/output.js", src);
    });

  });

  grunt.registerTask('default', ['jshint', 'browserify']);

};
<commit_msg>jshint options: allow 'debugger'<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      files: ['js/app/**/*.js', 'js/shims/**/*.js'],
      options: {
        globals: {
          console: true,
          module: true,
          require: true
        },
        undef: true,
        debug: true
      }
    },
    watch: {
      files: ['Gruntfile.js', '<%= jshint.files %>'],
      tasks: ['jshint', 'browserify']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('browserify', 'Browserify and concatenate app sources', function() {

    var browserify  = require('browserify'),
        shim        = require('browserify-shim'),
        entryPoints = [ './js/app/index.js',
                        './js/app/fixture.js' ],
        moduleList  = [ './js/app/models/*.js' ];

    var addEntryPoint = function(r, entryPoint) {
      return r.require(require.resolve(entryPoint), { entry: true })
    };

    var output = shim(browserify(), {
      jquery: { path: './js/vendor/jquery.min.js', exports: '$' }
    })
      .require('underscore', {expose: "underscore"})
      .require('backbone', {expose: "backbone"})
      .require(require.resolve('./js/shims/parse.js'), {expose: "parse"})
      .require(require.resolve('./js/shims/google-maps.js'), {expose: "google-maps"});

    entryPoints.forEach(function(entryPoint) {
      output = addEntryPoint(output, entryPoint);
    });

    moduleList.forEach(function(modules) {
      require('glob')(modules, function(er, files) {
        files.forEach(function(file) {
          var name = file
            .replace("./js/app/","")
            .replace(/\.js$/,"");
          output = output.require(require.resolve(file),
                                  {expose: name});
        });
      });

    });

    output.bundle(function (err, src) {
      if (err) return console.error(err);

      require('fs').writeFileSync("./js/static/output.js", src);
    });

  });

  grunt.registerTask('default', ['jshint', 'browserify']);

};
<|endoftext|>


<commit_before>"use strict";

module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    interval: 200,
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: false,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        node: true,
        es5: true,
        strict: true,
        globalstrict: true
      },
      files: {
        src: ['Gruntfile.js', 'package.json', 'lib/**/**/*.js', '!lib/themes/**']
      }
    },
    watch: {
      files: ['<%= jshint.files.src %>'],
      tasks: ['default']
    }
  });

  // npm tasks
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Default task.
  grunt.registerTask('default', ['jshint']);
};
<commit_msg>Specified grunt jshint src. To try to include everything makes it ridicously slow...<commit_after>"use strict";

module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    interval: 200,
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: false,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        node: true,
        es5: true,
        strict: true,
        globalstrict: true
      },
      files: {
        src: ['Gruntfile.js', 'package.json', 'lib/*.js', 'lib/controllers/**/*.js', 'lib/models/**/*.js', 'lib/utils/**/*.js']
      }
    },
    watch: {
      files: ['<%= jshint.files.src %>'],
      tasks: ['default']
    }
  });

  // npm tasks
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Default task.
  grunt.registerTask('default', ['jshint']);
};
<|endoftext|>


<commit_before>'use strict';

var sass = require('node-sass');

module.exports = function (grunt) {

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  require('dotenv').config();

  // Automatically load required grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    s3: 'grunt-aws',
    cloudfront: 'grunt-aws',
    replace: 'grunt-text-replace'
  });

  // configurable paths
  var config = {
    app: 'app',
    dist: 'dist'
  };

  grunt.initConfig({

    // Project settings
    config: config,
    package: grunt.file.readJSON('package.json'),

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      assemble: {
        files: [
          '<%= config.app %>/data/{,*/}*.{yml,json}',
          '<%= config.app %>/{layouts,pages,partials}/{,**/}*.{hbs,md}'
        ],
        tasks: ['assemble']
      },
      js: {
        files: [
          '<%= config.app %>/scripts/{,*/}*.js'
        ],
        tasks: [
          'browserify',
          'eslint'
        ]
      },
      sass: {
        files: ['<%= config.app %>/styles/{,*/}*.scss'],
        tasks: [
          'sass:server',
          'postcss:server'
        ]
      },
      webfont: {
        files: [
          '<%= config.app %>/media/icons/*.svg'
        ],
        tasks: ['webfont']
      },
    },

    browserSync: {
      options: {
        port: 0,
        notify: false,
        background: true,
        timestamps: false
      },
      livereload: {
        options: {
          files: [
            '.tmp/{,*/}*.html',
            '.tmp/styles/{,*/}*.css',
            '.tmp/scripts/main.js',
            '<%= config.app %>/media/{,**/}*',
            '!<%= config.app %>/media/icons/*'
          ],
          server: {
            baseDir: ['.tmp', config.app],
            routes: {
              '/node_modules': './node_modules',
              '/app/styles': './app/styles'
            }
          }
        }
      },
      dist: {
        options: {
          background: false,
          server: '<%= config.dist %>',
          snippetOptions: {
            rule: {
              // disable auto-injection
              match: /^$/
            }
          }
        }
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '.sass-cache',
            '<%= config.dist %>/*',
            '!<%= config.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Generate pages
    assemble: {
      options: {
        root: '.tmp',
        layout: 'default',
        layoutext: '.hbs',
        layoutdir: '<%= config.app %>/layouts',
        assets: '<%= config.app %>',
        data: '<%= config.app %>/data/*.{json,yml}',
        partials: '<%= config.app %>/partials/{,*/}*.hbs',
        helpers: ['<%= config.app %>/helpers/*.js'],
        plugins: [
          'grunt-assemble-contextual'
        ],
        contextual: {
          dest: '.tmp'
        },
        marked: {
          breaks: true
        }
      },
      pages: {
        options: {
          plugins: [
            'grunt-assemble-permalinks',
            'grunt-assemble-sitemap'
          ],
          sitemap: {
            relativedest: '.tmp',
            robot: false
          },
          permalinks: {
            preset: 'pretty'
          }
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            '{,**/}*.{hbs,md}',
            '!error.hbs'
          ]
        }]
      },
      special: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            'error.hbs'
          ]
        }]
      }
    },

    // Compile Sass
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
        includePaths: [
          '<%= config.app %>',
          'node_modules'
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: ['styles/{,*/}*.scss'],
          dest: '.tmp',
          ext: '.css'
        }]
      }
    },

    // Converts ES6 to ES5 for browser compatibility
    browserify: {
      options: {
        transform: [
          ['babelify', {
            'presets': ['@babel/preset-env']
          }]
        ]
      },
      server: {
        src: '<%= config.app %>/scripts/main.js',
        dest: '.tmp/scripts/main.js',
      }
    },

    // Process CSS
    postcss: {
      options: {
        map: {
          inline: false
        },
        processors: [
          require('postcss-flexbugs-fixes'),
          require('autoprefixer')({
            browsers: [
              'last 1 major version',
              '>= 1%',
              'Chrome >= 45',
              'Firefox >= 38',
              'Edge >= 12',
              'Explorer >= 10',
              'iOS >= 9',
              'Safari >= 9',
              'Android >= 4.4',
              'Opera >= 30'
            ]
          })
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      },
      dist: {
        options: {
          processors: [
            require('postcss-flexbugs-fixes'),
            require('autoprefixer'),
            require('postcss-uncss')({
              htmlroot: '.tmp',
              html: [
                '.tmp/{,*/}*.html'
              ],
              ignore: [
                '.arrow',
                '.show',
                '.hide',
                '.fade',
                /\.(bs-)?popover/,
                /\.(bs-)?tooltip/
              ]
            })
          ]
        },
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      }
    },

    // Generate custom icon font
    webfont: {
      icons: {
        src: '<%= config.app %>/media/icons/*.svg',
        dest: '.tmp/media/fonts',
        destCss: '.tmp/',
        options: {
          engine: 'node',
          hashes: false,
          stylesheet: 'css',
          relativeFontPath: '/media/fonts',
          templateOptions: {
            classPrefix: 'icon-',
          }
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      options: {
        dest: '<%= config.dist %>'
      },
      html: '.tmp/index.html'
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      options: {
        assetsDirs: ['<%= config.dist %>']
      },
      html: ['<%= config.dist %>/{,**/}*.html'],
      css: ['<%= config.dist %>/{,*/}*.css']
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/media',
          src: '{,**/}*.{png,jpg,jpeg}',
          dest: '<%= config.dist %>/media'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/media',
          src: '{,**/}*.svg',
          dest: '<%= config.dist %>/media'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          conservativeCollapse: true,
          removeAttributeQuotes: true,
          removeCommentsFromCDATA: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true,
          removeRedundantAttributes: false,
          useShortDoctype: true,
          processScripts: ['application/ld+json']
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>',
          src: '{,**/}*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

    // Put files not handled in other tasks here
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '.htaccess',
            '*.txt',
            'media/{,**/}*.{webp,gif,ico}',
            'media/fonts/*'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          flatten: true,
          src: [
            'media/favicon.ico'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            'media/fonts/*',
            'robots.txt',
            'sitemap.xml'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            '{,**/}*.html',
            '!icons.html'
          ]
        }]
      }
    },

    // Inline Critical CSS
    critical: {
      options: {
        base: '<%= config.dist %>',
        minify: true,
        width: 1440,
        height: 900
      },
      home: {
        src: '<%= config.dist %>/index.html',
        dest: '<%= config.dist %>/index.html'
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      options: {
        configFile: '.eslintrc.json'
      },
      target: [
        '<%= config.app %>/scripts/{,*/}*.js'
      ]
    },

    // Pick an unused port for livereload
    portPick: {
      browserSync: {
        options: {
          port: 9000
        },
        targets: ['browserSync.options.port']
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= config.dist %>/scripts/{,*/}*.js',
          '<%= config.dist %>/styles/{,*/}*.css',
          '<%= config.dist %>/media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}'
        ]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      server: [
        'webfont',
        'sass',
        'browserify'
      ],
      dist: [
        'webfont',
        'sass',
        'browserify',
        'imagemin',
        'svgmin'
      ]
    },

    // Deploy to AWS S3
    s3: {
      options: {
        signatureVersion: 'v4',
        bucket: '<%= process.env.S3_BUCKET %>',
        gzip: false,
        headers: {
          CacheControl: 'public, no-cache, no-transform, s-maxage=31536000'
        }
      },
      // Define file location for all environments
      default: {
        src: [
          '{,**/}*.html',
          '{,*/}favicon.ico',
          'robots.txt',
          'sitemap.xml'
        ]
      },
      defaultAssets: {
        src: [
          'scripts/{,*/}*.js',
          'styles/{,*/}*.css',
          'media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}'
        ]
      },
      dist: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=60, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.default.src %>'
      },
      distAssets: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=31536000, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.defaultAssets.src %>'
      }
    },

    // Invalidate Cloudfront
    cloudfront: {
      options: {
        distributionId: '<%= process.env.CLOUDFRONT_ID %>'
      },
      production: {
        options: {
          invalidations: [
            '/*'
          ]
        }
      }
    },

    // Increment version number, create and push tag
    bump: {
      options: {
        files: ['package.json'],
        commitFiles: '<%= bump.options.files %>',
        pushTo: 'origin'
      }
    },

    // Text replacements
    replace: {
      openGraphTag: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<meta property=og:(image|url) content="?(\/[^"?>]+)"?/g,
          to: '<meta property=og:$1 content=<%= package.homepage %>$2'
        }]
      },
      relCanonical: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<link rel=canonical href="?(\/[^"?>]+)"?/g,
          to: '<link rel=canonical href=<%= package.homepage %>$1'
        }]
      },
      sitemap: {
        src: [
          '<%= config.dist %>/sitemap.xml',
        ],
        overwrite: true,
        replacements: [
          {
            from: 'index.html',
            to: ''
          }, {
            from: /\s+<changefreq>[a-z]+<\/changefreq>/g,
            to: ''
          }, {
            from: /\s+<priority>[0-9\.]+<\/priority>/g,
            to: ''
          }

        ]
      }
    },

  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'portPick:browserSync', 'browserSync:dist']);
    }

    grunt.task.run([
      'clean:server',
      'assemble',
      'portPick',
      'concurrent:server',
      'postcss:server',
      'browserSync:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('purge', [
    'cloudfront'
  ]);

  grunt.registerTask('test', [
    'eslint'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'assemble',
    'useminPrepare',
    'concurrent:dist',
    'postcss:dist',
    'concat',
    'cssmin',
    'uglify',
    'copy:dist',
    'filerev',
    'usemin',
    'htmlmin',
    'critical'
  ]);

  grunt.registerTask('deploy', [
    'build',
    'replace',
    's3:dist',
    's3:distAssets',
    'purge'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);
};
<commit_msg>Fix replace task<commit_after>'use strict';

var sass = require('node-sass');

module.exports = function (grunt) {

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  require('dotenv').config();

  // Automatically load required grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    s3: 'grunt-aws',
    cloudfront: 'grunt-aws',
    replace: 'grunt-text-replace'
  });

  // configurable paths
  var config = {
    app: 'app',
    dist: 'dist'
  };

  grunt.initConfig({

    // Project settings
    config: config,
    package: grunt.file.readJSON('package.json'),

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      assemble: {
        files: [
          '<%= config.app %>/data/{,*/}*.{yml,json}',
          '<%= config.app %>/{layouts,pages,partials}/{,**/}*.{hbs,md}'
        ],
        tasks: ['assemble']
      },
      js: {
        files: [
          '<%= config.app %>/scripts/{,*/}*.js'
        ],
        tasks: [
          'browserify',
          'eslint'
        ]
      },
      sass: {
        files: ['<%= config.app %>/styles/{,*/}*.scss'],
        tasks: [
          'sass:server',
          'postcss:server'
        ]
      },
      webfont: {
        files: [
          '<%= config.app %>/media/icons/*.svg'
        ],
        tasks: ['webfont']
      },
    },

    browserSync: {
      options: {
        port: 0,
        notify: false,
        background: true,
        timestamps: false
      },
      livereload: {
        options: {
          files: [
            '.tmp/{,*/}*.html',
            '.tmp/styles/{,*/}*.css',
            '.tmp/scripts/main.js',
            '<%= config.app %>/media/{,**/}*',
            '!<%= config.app %>/media/icons/*'
          ],
          server: {
            baseDir: ['.tmp', config.app],
            routes: {
              '/node_modules': './node_modules',
              '/app/styles': './app/styles'
            }
          }
        }
      },
      dist: {
        options: {
          background: false,
          server: '<%= config.dist %>',
          snippetOptions: {
            rule: {
              // disable auto-injection
              match: /^$/
            }
          }
        }
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '.sass-cache',
            '<%= config.dist %>/*',
            '!<%= config.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Generate pages
    assemble: {
      options: {
        root: '.tmp',
        layout: 'default',
        layoutext: '.hbs',
        layoutdir: '<%= config.app %>/layouts',
        assets: '<%= config.app %>',
        data: '<%= config.app %>/data/*.{json,yml}',
        partials: '<%= config.app %>/partials/{,*/}*.hbs',
        helpers: ['<%= config.app %>/helpers/*.js'],
        plugins: [
          'grunt-assemble-contextual'
        ],
        contextual: {
          dest: '.tmp'
        },
        marked: {
          breaks: true
        }
      },
      pages: {
        options: {
          plugins: [
            'grunt-assemble-permalinks',
            'grunt-assemble-sitemap'
          ],
          sitemap: {
            relativedest: '.tmp',
            robot: false
          },
          permalinks: {
            preset: 'pretty'
          }
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            '{,**/}*.{hbs,md}',
            '!error.hbs'
          ]
        }]
      },
      special: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            'error.hbs'
          ]
        }]
      }
    },

    // Compile Sass
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
        includePaths: [
          '<%= config.app %>',
          'node_modules'
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: ['styles/{,*/}*.scss'],
          dest: '.tmp',
          ext: '.css'
        }]
      }
    },

    // Converts ES6 to ES5 for browser compatibility
    browserify: {
      options: {
        transform: [
          ['babelify', {
            'presets': ['@babel/preset-env']
          }]
        ]
      },
      server: {
        src: '<%= config.app %>/scripts/main.js',
        dest: '.tmp/scripts/main.js',
      }
    },

    // Process CSS
    postcss: {
      options: {
        map: {
          inline: false
        },
        processors: [
          require('postcss-flexbugs-fixes'),
          require('autoprefixer')({
            browsers: [
              'last 1 major version',
              '>= 1%',
              'Chrome >= 45',
              'Firefox >= 38',
              'Edge >= 12',
              'Explorer >= 10',
              'iOS >= 9',
              'Safari >= 9',
              'Android >= 4.4',
              'Opera >= 30'
            ]
          })
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      },
      dist: {
        options: {
          processors: [
            require('postcss-flexbugs-fixes'),
            require('autoprefixer'),
            require('postcss-uncss')({
              htmlroot: '.tmp',
              html: [
                '.tmp/{,*/}*.html'
              ],
              ignore: [
                '.arrow',
                '.show',
                '.hide',
                '.fade',
                /\.(bs-)?popover/,
                /\.(bs-)?tooltip/
              ]
            })
          ]
        },
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      }
    },

    // Generate custom icon font
    webfont: {
      icons: {
        src: '<%= config.app %>/media/icons/*.svg',
        dest: '.tmp/media/fonts',
        destCss: '.tmp/',
        options: {
          engine: 'node',
          hashes: false,
          stylesheet: 'css',
          relativeFontPath: '/media/fonts',
          templateOptions: {
            classPrefix: 'icon-',
          }
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      options: {
        dest: '<%= config.dist %>'
      },
      html: '.tmp/index.html'
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      options: {
        assetsDirs: ['<%= config.dist %>']
      },
      html: ['<%= config.dist %>/{,**/}*.html'],
      css: ['<%= config.dist %>/{,*/}*.css']
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/media',
          src: '{,**/}*.{png,jpg,jpeg}',
          dest: '<%= config.dist %>/media'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/media',
          src: '{,**/}*.svg',
          dest: '<%= config.dist %>/media'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          conservativeCollapse: true,
          removeAttributeQuotes: true,
          removeCommentsFromCDATA: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true,
          removeRedundantAttributes: false,
          useShortDoctype: true,
          processScripts: ['application/ld+json']
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>',
          src: '{,**/}*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

    // Put files not handled in other tasks here
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '.htaccess',
            '*.txt',
            'media/{,**/}*.{webp,gif,ico}',
            'media/fonts/*'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          flatten: true,
          src: [
            'media/favicon.ico'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            'media/fonts/*',
            'robots.txt',
            'sitemap.xml'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            '{,**/}*.html',
            '!icons.html'
          ]
        }]
      }
    },

    // Inline Critical CSS
    critical: {
      options: {
        base: '<%= config.dist %>',
        minify: true,
        width: 1440,
        height: 900
      },
      home: {
        src: '<%= config.dist %>/index.html',
        dest: '<%= config.dist %>/index.html'
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      options: {
        configFile: '.eslintrc.json'
      },
      target: [
        '<%= config.app %>/scripts/{,*/}*.js'
      ]
    },

    // Pick an unused port for livereload
    portPick: {
      browserSync: {
        options: {
          port: 9000
        },
        targets: ['browserSync.options.port']
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= config.dist %>/scripts/{,*/}*.js',
          '<%= config.dist %>/styles/{,*/}*.css',
          '<%= config.dist %>/media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}'
        ]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      server: [
        'webfont',
        'sass',
        'browserify'
      ],
      dist: [
        'webfont',
        'sass',
        'browserify',
        'imagemin',
        'svgmin'
      ]
    },

    // Deploy to AWS S3
    s3: {
      options: {
        signatureVersion: 'v4',
        bucket: '<%= process.env.S3_BUCKET %>',
        gzip: false,
        headers: {
          CacheControl: 'public, no-cache, no-transform, s-maxage=31536000'
        }
      },
      // Define file location for all environments
      default: {
        src: [
          '{,**/}*.html',
          '{,*/}favicon.ico',
          'robots.txt',
          'sitemap.xml'
        ]
      },
      defaultAssets: {
        src: [
          'scripts/{,*/}*.js',
          'styles/{,*/}*.css',
          'media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}'
        ]
      },
      dist: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=60, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.default.src %>'
      },
      distAssets: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=31536000, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.defaultAssets.src %>'
      }
    },

    // Invalidate Cloudfront
    cloudfront: {
      options: {
        distributionId: '<%= process.env.CLOUDFRONT_ID %>'
      },
      production: {
        options: {
          invalidations: [
            '/*'
          ]
        }
      }
    },

    // Increment version number, create and push tag
    bump: {
      options: {
        files: ['package.json'],
        commitFiles: '<%= bump.options.files %>',
        pushTo: 'origin'
      }
    },

    // Text replacements
    replace: {
      openGraphTag: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<meta property="og:(image|url)" content="?([^"]+)"?/g,
          to: '<meta property="og:$1" content="<%= package.homepage %>$2"'
        }]
      },
      relCanonical: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<link rel="canonical" href="?([^"]+)"?/g,
          to: '<link rel="canonical" href="<%= package.homepage %>$1"'
        }]
      },
      sitemap: {
        src: [
          '<%= config.dist %>/sitemap.xml',
        ],
        overwrite: true,
        replacements: [
          {
            from: 'index.html',
            to: ''
          }, {
            from: /\s+<changefreq>[a-z]+<\/changefreq>/g,
            to: ''
          }, {
            from: /\s+<priority>[0-9\.]+<\/priority>/g,
            to: ''
          }

        ]
      }
    },

  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'portPick:browserSync', 'browserSync:dist']);
    }

    grunt.task.run([
      'clean:server',
      'assemble',
      'portPick',
      'concurrent:server',
      'postcss:server',
      'browserSync:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('purge', [
    'cloudfront'
  ]);

  grunt.registerTask('test', [
    'eslint'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'assemble',
    'useminPrepare',
    'concurrent:dist',
    'postcss:dist',
    'concat',
    'cssmin',
    'uglify',
    'copy:dist',
    'filerev',
    'usemin',
    'replace',
    'htmlmin',
    'critical'
  ]);

  grunt.registerTask('deploy', [
    'build',
    's3:dist',
    's3:distAssets',
    'purge'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
	_ = require('lodash');

	var version = "0.1.23"

	var inputFolder = "./docs"
	var tempFolder = "./temp"
	var archiveFolder = "./archive"
	var outputFolder = "../mithril"

	var guideLayout = "guide"
	var guide = [
		"auto-redrawing",
		"benchmarks",
		"community",
		"compiling-templates",
		"comparison",
		"components",
		"getting-started",
		"installation",
		"integration",
		"practices",
		"refactoring",
		"routing",
		"tools",
		"web-services",
	]
	var apiLayout = "api"
	var api = [
		"change-log",
		"roadmap",
		"how-to-read-signatures",
		"mithril",
		"mithril.computation",
		"mithril.deferred",
		"mithril.module",
		"mithril.prop",
		"mithril.redraw",
		"mithril.render",
		"mithril.deps",
		"mithril.request",
		"mithril.route",
		"mithril.sync",
		"mithril.trust",
		"mithril.withAttr",
		"mithril.xhr"
	]

	var md2htmlTasks = {}
	var makeTasks = function(layout, pages) {
		pages.map(function(name) {
			md2htmlTasks[name] = {
				options: {layout: inputFolder + "/layout/" + layout + ".html"},
				files: [{src: [inputFolder + "/" + name + ".md"], dest: tempFolder + "/" + name + ".html"}]
			}
		})
	}
	makeTasks("guide", guide)
	makeTasks("api", api)

	var sauceBrowsers =[
		{ browserName: 'firefox', version: '19', platform: 'XP' },
		{ browserName: "internet explorer", platform: "XP", version: "6"},
		{ browserName: "safari", platform: "OS X 10.9", version: "7"},
		{ browserName: "iPad", platform: "OS X 10.9", version: "7.1"},
		{ browserName: "opera", platform: "Linux", version: "12"},
		{ browserName: "chrome", platform: "XP", version: "26"},
		{ browserName: "chrome", platform: "Windows 8", version: "26"},
	];

	var sauceOnTestComplete = function(result, callback) {
		var request = require('request');

		var user = process.env.SAUCE_USERNAME;
		var pass = process.env.SAUCE_ACCESS_KEY;

		request.put({
			url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
			auth: { user: user, pass: pass },
			json: { passed: result.passed }
		}, function (error, response, body) {
			if (error) {
				callback(error);
			} else if (response.statusCode !== 200) {
				callback(new Error('Unexpected response status: '
					+ response.statusCode + "\n "));
			} else {
				callback(null, result.passed);
			}
		});
	};

	var sauceBaseOptions = {
		username: process.env.SAUCE_USERNAME,
		key: process.env.SAUCE_ACCESS_KEY,
		testname: "Mithril Tests " + new Date().toJSON(),
		browsers: sauceBrowsers,
		sauceConfig: {
			"record-video": false,
			"record-screenshots": false,
		},
		build: process.env.TRAVIS_JOB_ID,
		onTestComplete: sauceOnTestComplete,
		tunnelTimeout: 5,
	};
	var sauceCustomOptions = {
		testname: "Mithril Custom Tests "+ new Date().toJSON(),
		urls: ["http://127.0.0.1:8000/tests/index.html"],
	};
	_.assign(sauceCustomOptions, sauceBaseOptions);
	var sauceQunitOptions = {
		testname: "qUnit Tests "+ new Date().toJSON(),
		urls: ["http://127.0.0.1:8000/tests/e2e/test.html"],
	};
	_.assign(sauceQunitOptions, sauceBaseOptions);

	var currentVersionArchiveFolder = archiveFolder + "/v" + version
	grunt.initConfig({
		md2html: md2htmlTasks,
		uglify: {
			options: {banner: "/*\nMithril v" + version + "\nhttp://github.com/lhorie/mithril.js\n(c) Leo Horie\nLicense: MIT\n*/", sourceMap: true},
			mithril: {src: "mithril.js", dest: "mithril.min.js"}
		},
		concat: {
			test: {src: ["mithril.js", "./tests/test.js", "./tests/mock.js", "./tests/mithril-tests.js"], dest: currentVersionArchiveFolder + "/mithril-tests.js"}
		},
		zip: {
			distribution: {
				cwd: currentVersionArchiveFolder + "/",
				src: [currentVersionArchiveFolder + "/mithril.min.js", currentVersionArchiveFolder + "/mithril.min.map", currentVersionArchiveFolder + "/mithril.js"],
				dest: currentVersionArchiveFolder + "/mithril.min.zip"
			}
		},
		replace: {
			options: {force: true, patterns: [{match: /\.md/g, replacement: ".html"}, {match: /\$version/g, replacement: version}]},
			links: {expand: true, flatten: true, src: [tempFolder + "/**/*.html"], dest: currentVersionArchiveFolder + "/"},
			index: {src: inputFolder + "/layout/index.html", dest: currentVersionArchiveFolder + "/index.html"},
			commonjs: {expand: true, flatten: true, src: [inputFolder + "/layout/*.json"], dest: currentVersionArchiveFolder},
			cdnjs: {src: "deploy/cdnjs-package.json", dest: "../cdnjs/ajax/libs/mithril/package.json"}
		},
		copy: {
			style: {src: inputFolder + "/layout/style.css", dest: currentVersionArchiveFolder + "/style.css"},
			pages: {src: inputFolder + "/layout/pages.json", dest: currentVersionArchiveFolder + "/pages.json"},
			lib: {expand: true, cwd: inputFolder + "/layout/lib/", src: "./**", dest: currentVersionArchiveFolder + "/lib/"},
			tools: {expand: true, cwd: inputFolder + "/layout/tools/", src: "./**", dest: currentVersionArchiveFolder + "/tools/"},
			comparisons: {expand: true, cwd: inputFolder + "/layout/comparisons/", src: "./**", dest: currentVersionArchiveFolder + "/comparisons/"},
			unminified: {src: "mithril.js", dest: currentVersionArchiveFolder + "/mithril.js"},
			minified: {src: "mithril.min.js", dest: currentVersionArchiveFolder + "/mithril.min.js"},
			map: {src: "mithril.min.map", dest: currentVersionArchiveFolder + "/mithril.min.map"},
			typescript: {src: "mithril.d.ts", dest: currentVersionArchiveFolder + "/mithril.d.ts"},
			publish: {expand: true, cwd: currentVersionArchiveFolder, src: "./**", dest: outputFolder},
			archive: {expand: true, cwd: currentVersionArchiveFolder, src: "./**", dest: outputFolder + "/archive/v" + version},
			cdnjs1: {src: currentVersionArchiveFolder + "/mithril.js", dest: "../cdnjs/ajax/libs/mithril/" + version + "/mithril.js"},
			cdnjs2: {src: currentVersionArchiveFolder + "/mithril.min.js", dest: "../cdnjs/ajax/libs/mithril/" + version + "/mithril.min.js"},
			cdnjs3: {src: currentVersionArchiveFolder + "/mithril.min.map", dest: "../cdnjs/ajax/libs/mithril/" + version + "/mithril.min.map"},
			jsdelivr1: {src: currentVersionArchiveFolder + "/mithril.js", dest: "../jsdelivr/files/mithril/" + version + "/mithril.js"},
			jsdelivr2: {src: currentVersionArchiveFolder + "/mithril.min.js", dest: "../jsdelivr/files/mithril/" + version + "/mithril.min.js"},
			jsdelivr3: {src: currentVersionArchiveFolder + "/mithril.min.map", dest: "../jsdelivr/files/mithril/" + version + "/mithril.min.map"}
		},
		execute: {
			tests: {src: [currentVersionArchiveFolder + "/mithril-tests.js"]}
		},
		qunit: {
			all: ['tests/e2e/**/*.html']
		},
		"saucelabs-custom": {
			all:{
				options: sauceCustomOptions
			}
		},
		"saucelabs-qunit": {
			all:{
				options: sauceQunitOptions
			}
		},
		watch: {},

		connect: {
			server: {
				options: {
					port: 8000,
					base: '.'
				}
			}
		},
		clean: {
			options: {force: true},
			generated: [tempFolder]
		}
	});

	grunt.loadNpmTasks("grunt-contrib-clean");
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks("grunt-contrib-copy");
	grunt.loadNpmTasks("grunt-contrib-uglify");
	grunt.loadNpmTasks('grunt-execute');
	grunt.loadNpmTasks("grunt-md2html");
	grunt.loadNpmTasks("grunt-replace");
	grunt.loadNpmTasks('grunt-zip');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-connect');
	grunt.loadNpmTasks('grunt-saucelabs');

	grunt.registerTask("build", ["test", "uglify", "zip", "md2html", "replace", "copy", "clean"]);
	grunt.registerTask("testall", ["test", "teste2e"]);
	grunt.registerTask("test", ["concat", "execute"]);
	grunt.registerTask('teste2e', ['connect', 'qunit']);
	grunt.registerTask("default", ["build"]);

	grunt.registerTask("sauce-qunit", ["connect", "saucelabs-qunit"]);
	grunt.registerTask("sauce-custom", ["connect", "saucelabs-custom"]);
	grunt.registerTask("sauce-all", ["connect", "saucelabs-qunit", "saucelabs-custom"]);
};
<commit_msg>change test port<commit_after>module.exports = function(grunt) {
	_ = require('lodash');

	var version = "0.1.23"

	var inputFolder = "./docs"
	var tempFolder = "./temp"
	var archiveFolder = "./archive"
	var outputFolder = "../mithril"

	var guideLayout = "guide"
	var guide = [
		"auto-redrawing",
		"benchmarks",
		"community",
		"compiling-templates",
		"comparison",
		"components",
		"getting-started",
		"installation",
		"integration",
		"practices",
		"refactoring",
		"routing",
		"tools",
		"web-services",
	]
	var apiLayout = "api"
	var api = [
		"change-log",
		"roadmap",
		"how-to-read-signatures",
		"mithril",
		"mithril.computation",
		"mithril.deferred",
		"mithril.module",
		"mithril.prop",
		"mithril.redraw",
		"mithril.render",
		"mithril.deps",
		"mithril.request",
		"mithril.route",
		"mithril.sync",
		"mithril.trust",
		"mithril.withAttr",
		"mithril.xhr"
	]

	var md2htmlTasks = {}
	var makeTasks = function(layout, pages) {
		pages.map(function(name) {
			md2htmlTasks[name] = {
				options: {layout: inputFolder + "/layout/" + layout + ".html"},
				files: [{src: [inputFolder + "/" + name + ".md"], dest: tempFolder + "/" + name + ".html"}]
			}
		})
	}
	makeTasks("guide", guide)
	makeTasks("api", api)

	var sauceBrowsers =[
		{ browserName: 'firefox', version: '19', platform: 'XP' },
		{ browserName: "internet explorer", platform: "XP", version: "6"},
		{ browserName: "safari", platform: "OS X 10.9", version: "7"},
		{ browserName: "iPad", platform: "OS X 10.9", version: "7.1"},
		{ browserName: "opera", platform: "Linux", version: "12"},
		{ browserName: "chrome", platform: "XP", version: "26"},
		{ browserName: "chrome", platform: "Windows 8", version: "26"},
	];

	var sauceOnTestComplete = function(result, callback) {
		var request = require('request');

		var user = process.env.SAUCE_USERNAME;
		var pass = process.env.SAUCE_ACCESS_KEY;

		request.put({
			url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
			auth: { user: user, pass: pass },
			json: { passed: result.passed }
		}, function (error, response, body) {
			if (error) {
				callback(error);
			} else if (response.statusCode !== 200) {
				callback(new Error('Unexpected response status: '
					+ response.statusCode + "\n "));
			} else {
				callback(null, result.passed);
			}
		});
	};

	var sauceBaseOptions = {
		username: process.env.SAUCE_USERNAME,
		key: process.env.SAUCE_ACCESS_KEY,
		testname: "Mithril Tests " + new Date().toJSON(),
		browsers: sauceBrowsers,
		sauceConfig: {
			"record-video": false,
			"record-screenshots": false,
		},
		build: process.env.TRAVIS_JOB_ID,
		onTestComplete: sauceOnTestComplete,
		tunnelTimeout: 5,
	};
	var sauceCustomOptions = {
		testname: "Mithril Custom Tests "+ new Date().toJSON(),
		urls: ["http://127.0.0.1:8000/tests/index.html"],
	};
	_.assign(sauceCustomOptions, sauceBaseOptions);
	var sauceQunitOptions = {
		testname: "qUnit Tests "+ new Date().toJSON(),
		urls: ["http://127.0.0.1:8000/tests/e2e/test.html"],
	};
	_.assign(sauceQunitOptions, sauceBaseOptions);

	var currentVersionArchiveFolder = archiveFolder + "/v" + version
	grunt.initConfig({
		md2html: md2htmlTasks,
		uglify: {
			options: {banner: "/*\nMithril v" + version + "\nhttp://github.com/lhorie/mithril.js\n(c) Leo Horie\nLicense: MIT\n*/", sourceMap: true},
			mithril: {src: "mithril.js", dest: "mithril.min.js"}
		},
		concat: {
			test: {src: ["mithril.js", "./tests/test.js", "./tests/mock.js", "./tests/mithril-tests.js"], dest: currentVersionArchiveFolder + "/mithril-tests.js"}
		},
		zip: {
			distribution: {
				cwd: currentVersionArchiveFolder + "/",
				src: [currentVersionArchiveFolder + "/mithril.min.js", currentVersionArchiveFolder + "/mithril.min.map", currentVersionArchiveFolder + "/mithril.js"],
				dest: currentVersionArchiveFolder + "/mithril.min.zip"
			}
		},
		replace: {
			options: {force: true, patterns: [{match: /\.md/g, replacement: ".html"}, {match: /\$version/g, replacement: version}]},
			links: {expand: true, flatten: true, src: [tempFolder + "/**/*.html"], dest: currentVersionArchiveFolder + "/"},
			index: {src: inputFolder + "/layout/index.html", dest: currentVersionArchiveFolder + "/index.html"},
			commonjs: {expand: true, flatten: true, src: [inputFolder + "/layout/*.json"], dest: currentVersionArchiveFolder},
			cdnjs: {src: "deploy/cdnjs-package.json", dest: "../cdnjs/ajax/libs/mithril/package.json"}
		},
		copy: {
			style: {src: inputFolder + "/layout/style.css", dest: currentVersionArchiveFolder + "/style.css"},
			pages: {src: inputFolder + "/layout/pages.json", dest: currentVersionArchiveFolder + "/pages.json"},
			lib: {expand: true, cwd: inputFolder + "/layout/lib/", src: "./**", dest: currentVersionArchiveFolder + "/lib/"},
			tools: {expand: true, cwd: inputFolder + "/layout/tools/", src: "./**", dest: currentVersionArchiveFolder + "/tools/"},
			comparisons: {expand: true, cwd: inputFolder + "/layout/comparisons/", src: "./**", dest: currentVersionArchiveFolder + "/comparisons/"},
			unminified: {src: "mithril.js", dest: currentVersionArchiveFolder + "/mithril.js"},
			minified: {src: "mithril.min.js", dest: currentVersionArchiveFolder + "/mithril.min.js"},
			map: {src: "mithril.min.map", dest: currentVersionArchiveFolder + "/mithril.min.map"},
			typescript: {src: "mithril.d.ts", dest: currentVersionArchiveFolder + "/mithril.d.ts"},
			publish: {expand: true, cwd: currentVersionArchiveFolder, src: "./**", dest: outputFolder},
			archive: {expand: true, cwd: currentVersionArchiveFolder, src: "./**", dest: outputFolder + "/archive/v" + version},
			cdnjs1: {src: currentVersionArchiveFolder + "/mithril.js", dest: "../cdnjs/ajax/libs/mithril/" + version + "/mithril.js"},
			cdnjs2: {src: currentVersionArchiveFolder + "/mithril.min.js", dest: "../cdnjs/ajax/libs/mithril/" + version + "/mithril.min.js"},
			cdnjs3: {src: currentVersionArchiveFolder + "/mithril.min.map", dest: "../cdnjs/ajax/libs/mithril/" + version + "/mithril.min.map"},
			jsdelivr1: {src: currentVersionArchiveFolder + "/mithril.js", dest: "../jsdelivr/files/mithril/" + version + "/mithril.js"},
			jsdelivr2: {src: currentVersionArchiveFolder + "/mithril.min.js", dest: "../jsdelivr/files/mithril/" + version + "/mithril.min.js"},
			jsdelivr3: {src: currentVersionArchiveFolder + "/mithril.min.map", dest: "../jsdelivr/files/mithril/" + version + "/mithril.min.map"}
		},
		execute: {
			tests: {src: [currentVersionArchiveFolder + "/mithril-tests.js"]}
		},
		qunit: {
			all: ['tests/e2e/**/*.html']
		},
		"saucelabs-custom": {
			all:{
				options: sauceCustomOptions
			}
		},
		"saucelabs-qunit": {
			all:{
				options: sauceQunitOptions
			}
		},
		watch: {},

		connect: {
			server: {
				options: {
					port: 8888,
					base: '.'
				}
			}
		},
		clean: {
			options: {force: true},
			generated: [tempFolder]
		}
	});

	grunt.loadNpmTasks("grunt-contrib-clean");
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks("grunt-contrib-copy");
	grunt.loadNpmTasks("grunt-contrib-uglify");
	grunt.loadNpmTasks('grunt-execute');
	grunt.loadNpmTasks("grunt-md2html");
	grunt.loadNpmTasks("grunt-replace");
	grunt.loadNpmTasks('grunt-zip');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-connect');
	grunt.loadNpmTasks('grunt-saucelabs');

	grunt.registerTask("build", ["test", "uglify", "zip", "md2html", "replace", "copy", "clean"]);
	grunt.registerTask("testall", ["test", "teste2e"]);
	grunt.registerTask("test", ["concat", "execute"]);
	grunt.registerTask('teste2e', ['connect', 'qunit']);
	grunt.registerTask("default", ["build"]);

	grunt.registerTask("sauce-qunit", ["connect", "saucelabs-qunit"]);
	grunt.registerTask("sauce-custom", ["connect", "saucelabs-custom"]);
	grunt.registerTask("sauce-all", ["connect", "saucelabs-qunit", "saucelabs-custom"]);
};
<|endoftext|>