<commit_before>'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

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

    grunt.initConfig({
        serlo: config,
        watch: {
            compass: {
                files: ['<%= serlo.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= serlo.app %>/styles/{,*/}*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            jsLang: {
                files: ['<%= serlo.app %>/lang/*'],
                tasks: ['i18n']
            },
            scripts: {
                files: ['<%= serlo.app %>/scripts/{,*/}*.js'],
                tasks: ['jshint', 'copy:requirejs', 'requirejs:production']
            },
            images: {
                files: ['<%= serlo.app %>/images/{,*/}*.{png,jpg,jpeg}'],
                tasks: ['imagemin']
            },
            fonts: {
                files: ['<%= serlo.app %>/styles/fonts/*'],
                tasks: ['copy:dist']
            },
            editorScripts: {
                files: ['<%= serlo.app %>/editor/scripts/{,*/}*.js'],
                tasks: ['jshint', 'copy:requirejs', 'requirejs:editor']
            },
            editorCompass: {
                files: ['<%= serlo.app %>/editor/styles/{,*/}*.{scss,sass}'],
                tasks: ['jshint', 'compass:editor', 'autoprefixer']
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '<%= serlo.dist %>/*',
                        '!<%= serlo.dist %>/.git*'
                    ]
                }]
            },
            server: '<%= serlo.dist %>'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                ignores: [
                    '<%= serlo.app %>/scripts/thirdparty/{,*/}*.js',
                    '<%= serlo.app %>/scripts/modules/serlo_i18n.js',
                    '<%= serlo.app %>/scripts/libs/polyfills.js',
                    '<%= serlo.app %>/scripts/libs/markdown.js',
                    '<%= serlo.app %>/scripts/codemirror/codemirror.js'
                ]
            },
            all: [
                '<%= serlo.app %>/scripts/{,*/}*.js',
                '<%= serlo.app %>/editor/scripts/{,*/}*.js'
            ]
        },
        compass: {
            options: {
                sassDir: '<%= serlo.app %>/styles',
                cssDir: '<%= serlo.dist %>/styles',
                generatedImagesDir: '<%= serlo.dist %>/images/generated',
                imagesDir: '<%= serlo.app %>/images',
                javascriptsDir: '<%= serlo.app %>/scripts',
                fontsDir: '<%= serlo.app %>/styles/fonts',
                importPath: '<%= serlo.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= serlo.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= serlo.dist %>/styles/',
                    src: '{,*/}*.css',
                    dest: '<%= serlo.dist %>/styles/'
                }]
            }
        },
        'bower-install': {
            app: {
                html: '<%= serlo.app %>/index.html',
                ignorePath: '<%= serlo.app %>/'
            }
        },
        uglify: {
            dist: {
                options: {
                    banner: '/**\n' +
                            ' * \n' +
                            ' * Athene2 - Advanced Learning Resources Manager \n' +
                            ' *\n' +
                            ' * @license LGPL-3.0\n' +
                            ' * @license http://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0\n' +
                            ' * @link https://github.com/serlo-org/athene2 for the canonical source repository\n' +
                            ' * @copyright Copyright (c) 2013 Gesellschaft für freie Bildung e.V. (http://www.open-education.eu/)\n' +
                            ' */\n',
                    output: {
                        beautify: false
                    },
                    compress: {
                        sequences: true,
                        global_defs: {
                            DEBUG: true
                        }
                    },
                    warnings: true,
                    mangle: true
                },
                // files: {
                //     '<%= serlo.dist %>/scripts/main.js': '<%= serlo.dist %>/scripts/main.js'
                // }
                files: [{
                    '<%= serlo.dist %>/scripts/editor.js' : '<%= serlo.dist %>/scripts/editor.js',
                    '<%= serlo.dist %>/bower_components/requirejs/require.js': '<%= serlo.dist %>/bower_components/requirejs/require.js'
                }]
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= serlo.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= serlo.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= serlo.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= serlo.dist %>/images'
                }]
            }
        },
        cssmin: {
            minify: {
                expand: true,
                cwd: '<%= serlo.dist %>/styles/',
                src: ['*.css', '!*.min.css'],
                dest: '<%= serlo.dist %>/styles/',
                ext: '.css'
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= serlo.app %>',
                    dest: '<%= serlo.dist %>',
                    src: [
                        '.htaccess',
                        'styles/fonts/{,*/}*.*',
                        'bower_components/jquery/jquery.min.map'
                    ]
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= serlo.app %>/styles',
                dest: '<%= serlo.dist %>/styles/',
                src: '{,*/}*.css'
            },
            requirejs: {
                expand: true,
                dot: true,
                cwd: '<%= serlo.app %>/bower_components/requirejs',
                dest: '<%= serlo.dist %>/bower_components/requirejs',
                src: 'require.js'
            },
            modernizr: {
                expand: true,
                dot: true,
                cwd: '<%= serlo.app %>/bower_components/modernizr',
                dest: '<%= serlo.dist %>/bower_components/modernizr',
                src: 'modernizr.js'
            }
        },
        i18n: {
            src: ['<%= serlo.app %>/lang/*.json'],
            dest: '<%= serlo.app %>/scripts/modules/serlo_i18n.js'
        },
        modernizr: {
            devFile: '<%= serlo.app %>/bower_components/modernizr/modernizr.js',
            outputFile: '<%= serlo.dist %>/bower_components/modernizr/modernizr.js',
            files: [
                '<%= serlo.dist %>/scripts/{,*/}*.js',
                '<%= serlo.dist %>/styles/{,*/}*.css',
                '!<%= serlo.dist %>/scripts/vendor/*'
            ],
            uglify: true
        },
        concurrent: {
            server: [
                'compass',
                'copy:styles',
                'copy:requirejs'
            ],
            test: [
                'copy:styles',
                'copy:requirejs'
            ],
            dist: [
                'compass',
                'copy:styles',
                'copy:requirejs',
                'svgmin'
            ]
        },
        requirejs: {
            production: {
                options: {
                    baseUrl: "<%= serlo.app %>/scripts",
                    mainConfigFile: "source/scripts/main.js",
                    out: "<%= serlo.dist %>/scripts/editor.js",
                    preserveLicenseComments: false,
                    optimize: 'none'
                }
            },
            testing: {
                options: {
                    name: 'ATHENE2-TEST',
                    baseUrl: "<%= serlo.app %>/tests/modules",
                    mainConfigFile: "source/tests/modules/specRunner.js",
                    out: "<%= serlo.dist %>/scripts/editor.js",
                    preserveLicenseComments: false,
                    optimize: 'none'
                }
            }
        },
        "language-update": {
            src: [
                '<%= serlo.app %>/scripts/{,*/}*.js'
            ],
            langSrc: [
                '<%= serlo.app %>/lang/*.json'
            ],
            dest: '<%= serlo.app %>/lang-processed'
        },
        concat: {
            test: {
                src: [
                    '<%= serlo.app %>/bower_components/jasmine/lib/jasmine-core/jasmine.css',
                    '<%= serlo.dist %>/styles/main.css'
                ],
                dest: '<%= serlo.dist %>/styles/main.css'
            }
        }
    });

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

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'copy:requirejs',
            'i18n',
            'requirejs:production',
            'copy:dist',
            'copy:modernizr',
            'watch'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'concurrent:dist',
        'autoprefixer',
        'copy:dist',
        'i18n',
        'cssmin',
        'imagemin',
        'requirejs:production',
        'modernizr'
        // 'uglify'
    ]);

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

    grunt.registerTask('i18n', 'Creates an AMD module based on language files', function () {
        var data = grunt.config('i18n'),
            files = grunt.file.expand(data.src),
            output = '/**\n * Dont edit this file!\n' +
                    ' * This module generates itself from lang.js files!\n' +
                    ' * Instead edit the language files in /lang/\n' +
                    ' **/\n\n' +
                    '/*global define*/\n' +
                    'define(function () {\n' +
                    '"use strict";\n' +
                    'var i18n = {};\n';

        files.forEach(function (f) {
            var contents = grunt.file.read(f),
                langName = f.split('/').pop().replace('.json', '');

            output += '\ni18n.' + langName + ' = ' + contents + ';\n';
        });

        output += '\nreturn i18n;\n' +
                '});';

        grunt.file.write(data.dest, output);
    });

    grunt.registerMultiTask('language-update', 'Fetches translation strings from source files', function () {
        var data = grunt.config('language-update'),
            files = grunt.file.expand(data.src),
            languages = grunt.file.expand(data.langSrc),
            searchFunction = new RegExp(/(\(|^|[\s\n])t\(["']([^")]|[^')])*\)/g),
            filterString = new RegExp(/(["]([^"])*["])|([']([^'])*['])/),
            strings = [];

        files.forEach(function (f) {
            var contents = grunt.file.read(f);

            contents.replace(searchFunction, function (match) {
                match.replace(filterString, function (string) {
                    // string = string.split('');
                    // string.pop().shift();
                    string = string.substr(1);
                    string = string.substring(0, string.length - 1);

                    if (strings.indexOf(string) < 0) {
                        strings.push(string);
                    }
                });
            });
            // grunt.file.write(p, header + sep + contents + sep + footer);
            // grunt.log.writeln('File "' + p + '" created.');
        });

        languages.forEach(function (lang) {
            var contents = grunt.file.readJSON(lang);

            strings.forEach(function (string) {
                if (!contents[string]) {
                    contents[string] = "";
                }
            });

            contents = JSON.stringify(contents);

            contents = contents.replace(/\{/g, "{\n    ");
            contents = contents.replace(/","/g, "\",\n    \"");
            contents = contents.replace(/":"/g, "\" : \"");
            contents = contents.replace(/\}/g, "\n}");

            grunt.file.write(lang, contents);
        });
  });
};
<commit_msg>enable uglifying<commit_after>'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

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

    grunt.initConfig({
        serlo: config,
        watch: {
            compass: {
                files: ['<%= serlo.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= serlo.app %>/styles/{,*/}*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            jsLang: {
                files: ['<%= serlo.app %>/lang/*'],
                tasks: ['i18n']
            },
            scripts: {
                files: ['<%= serlo.app %>/scripts/{,*/}*.js'],
                tasks: ['jshint', 'copy:requirejs', 'requirejs:production']
            },
            images: {
                files: ['<%= serlo.app %>/images/{,*/}*.{png,jpg,jpeg}'],
                tasks: ['imagemin']
            },
            fonts: {
                files: ['<%= serlo.app %>/styles/fonts/*'],
                tasks: ['copy:dist']
            },
            editorScripts: {
                files: ['<%= serlo.app %>/editor/scripts/{,*/}*.js'],
                tasks: ['jshint', 'copy:requirejs', 'requirejs:editor']
            },
            editorCompass: {
                files: ['<%= serlo.app %>/editor/styles/{,*/}*.{scss,sass}'],
                tasks: ['jshint', 'compass:editor', 'autoprefixer']
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '<%= serlo.dist %>/*',
                        '!<%= serlo.dist %>/.git*'
                    ]
                }]
            },
            server: '<%= serlo.dist %>'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                ignores: [
                    '<%= serlo.app %>/scripts/thirdparty/{,*/}*.js',
                    '<%= serlo.app %>/scripts/modules/serlo_i18n.js',
                    '<%= serlo.app %>/scripts/libs/polyfills.js',
                    '<%= serlo.app %>/scripts/libs/markdown.js',
                    '<%= serlo.app %>/scripts/codemirror/codemirror.js'
                ]
            },
            all: [
                '<%= serlo.app %>/scripts/{,*/}*.js',
                '<%= serlo.app %>/editor/scripts/{,*/}*.js'
            ]
        },
        compass: {
            options: {
                sassDir: '<%= serlo.app %>/styles',
                cssDir: '<%= serlo.dist %>/styles',
                generatedImagesDir: '<%= serlo.dist %>/images/generated',
                imagesDir: '<%= serlo.app %>/images',
                javascriptsDir: '<%= serlo.app %>/scripts',
                fontsDir: '<%= serlo.app %>/styles/fonts',
                importPath: '<%= serlo.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= serlo.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= serlo.dist %>/styles/',
                    src: '{,*/}*.css',
                    dest: '<%= serlo.dist %>/styles/'
                }]
            }
        },
        'bower-install': {
            app: {
                html: '<%= serlo.app %>/index.html',
                ignorePath: '<%= serlo.app %>/'
            }
        },
        uglify: {
            dist: {
                options: {
                    banner: '/**\n' +
                            ' * \n' +
                            ' * Athene2 - Advanced Learning Resources Manager \n' +
                            ' *\n' +
                            ' * @license LGPL-3.0\n' +
                            ' * @license http://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0\n' +
                            ' * @link https://github.com/serlo-org/athene2 for the canonical source repository\n' +
                            ' * @copyright Copyright (c) 2013 Gesellschaft für freie Bildung e.V. (http://www.open-education.eu/)\n' +
                            ' */\n',
                    output: {
                        beautify: false
                    },
                    compress: {
                        sequences: true,
                        global_defs: {
                            DEBUG: true
                        }
                    },
                    warnings: true,
                    mangle: true
                },
                // files: {
                //     '<%= serlo.dist %>/scripts/main.js': '<%= serlo.dist %>/scripts/main.js'
                // }
                files: [{
                    '<%= serlo.dist %>/scripts/editor.js' : '<%= serlo.dist %>/scripts/editor.js',
                    '<%= serlo.dist %>/bower_components/requirejs/require.js': '<%= serlo.dist %>/bower_components/requirejs/require.js'
                }]
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= serlo.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= serlo.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= serlo.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= serlo.dist %>/images'
                }]
            }
        },
        cssmin: {
            minify: {
                expand: true,
                cwd: '<%= serlo.dist %>/styles/',
                src: ['*.css', '!*.min.css'],
                dest: '<%= serlo.dist %>/styles/',
                ext: '.css'
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= serlo.app %>',
                    dest: '<%= serlo.dist %>',
                    src: [
                        '.htaccess',
                        'styles/fonts/{,*/}*.*',
                        'bower_components/jquery/jquery.min.map'
                    ]
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= serlo.app %>/styles',
                dest: '<%= serlo.dist %>/styles/',
                src: '{,*/}*.css'
            },
            requirejs: {
                expand: true,
                dot: true,
                cwd: '<%= serlo.app %>/bower_components/requirejs',
                dest: '<%= serlo.dist %>/bower_components/requirejs',
                src: 'require.js'
            },
            modernizr: {
                expand: true,
                dot: true,
                cwd: '<%= serlo.app %>/bower_components/modernizr',
                dest: '<%= serlo.dist %>/bower_components/modernizr',
                src: 'modernizr.js'
            }
        },
        i18n: {
            src: ['<%= serlo.app %>/lang/*.json'],
            dest: '<%= serlo.app %>/scripts/modules/serlo_i18n.js'
        },
        modernizr: {
            devFile: '<%= serlo.app %>/bower_components/modernizr/modernizr.js',
            outputFile: '<%= serlo.dist %>/bower_components/modernizr/modernizr.js',
            files: [
                '<%= serlo.dist %>/scripts/{,*/}*.js',
                '<%= serlo.dist %>/styles/{,*/}*.css',
                '!<%= serlo.dist %>/scripts/vendor/*'
            ],
            uglify: true
        },
        concurrent: {
            server: [
                'compass',
                'copy:styles',
                'copy:requirejs'
            ],
            test: [
                'copy:styles',
                'copy:requirejs'
            ],
            dist: [
                'compass',
                'copy:styles',
                'copy:requirejs',
                'svgmin'
            ]
        },
        requirejs: {
            production: {
                options: {
                    baseUrl: "<%= serlo.app %>/scripts",
                    mainConfigFile: "source/scripts/main.js",
                    out: "<%= serlo.dist %>/scripts/editor.js",
                    preserveLicenseComments: false,
                    optimize: 'none'
                }
            },
            testing: {
                options: {
                    name: 'ATHENE2-TEST',
                    baseUrl: "<%= serlo.app %>/tests/modules",
                    mainConfigFile: "source/tests/modules/specRunner.js",
                    out: "<%= serlo.dist %>/scripts/editor.js",
                    preserveLicenseComments: false,
                    optimize: 'none'
                }
            }
        },
        "language-update": {
            src: [
                '<%= serlo.app %>/scripts/{,*/}*.js'
            ],
            langSrc: [
                '<%= serlo.app %>/lang/*.json'
            ],
            dest: '<%= serlo.app %>/lang-processed'
        },
        concat: {
            test: {
                src: [
                    '<%= serlo.app %>/bower_components/jasmine/lib/jasmine-core/jasmine.css',
                    '<%= serlo.dist %>/styles/main.css'
                ],
                dest: '<%= serlo.dist %>/styles/main.css'
            }
        }
    });

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

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'copy:requirejs',
            'i18n',
            'requirejs:production',
            'copy:dist',
            'copy:modernizr',
            'watch'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'concurrent:dist',
        'autoprefixer',
        'copy:dist',
        'i18n',
        'cssmin',
        'imagemin',
        'requirejs:production',
        'modernizr',
        'uglify'
    ]);

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

    grunt.registerTask('i18n', 'Creates an AMD module based on language files', function () {
        var data = grunt.config('i18n'),
            files = grunt.file.expand(data.src),
            output = '/**\n * Dont edit this file!\n' +
                    ' * This module generates itself from lang.js files!\n' +
                    ' * Instead edit the language files in /lang/\n' +
                    ' **/\n\n' +
                    '/*global define*/\n' +
                    'define(function () {\n' +
                    '"use strict";\n' +
                    'var i18n = {};\n';

        files.forEach(function (f) {
            var contents = grunt.file.read(f),
                langName = f.split('/').pop().replace('.json', '');

            output += '\ni18n.' + langName + ' = ' + contents + ';\n';
        });

        output += '\nreturn i18n;\n' +
                '});';

        grunt.file.write(data.dest, output);
    });

    grunt.registerMultiTask('language-update', 'Fetches translation strings from source files', function () {
        var data = grunt.config('language-update'),
            files = grunt.file.expand(data.src),
            languages = grunt.file.expand(data.langSrc),
            searchFunction = new RegExp(/(\(|^|[\s\n])t\(["']([^")]|[^')])*\)/g),
            filterString = new RegExp(/(["]([^"])*["])|([']([^'])*['])/),
            strings = [];

        files.forEach(function (f) {
            var contents = grunt.file.read(f);

            contents.replace(searchFunction, function (match) {
                match.replace(filterString, function (string) {
                    // string = string.split('');
                    // string.pop().shift();
                    string = string.substr(1);
                    string = string.substring(0, string.length - 1);

                    if (strings.indexOf(string) < 0) {
                        strings.push(string);
                    }
                });
            });
            // grunt.file.write(p, header + sep + contents + sep + footer);
            // grunt.log.writeln('File "' + p + '" created.');
        });

        languages.forEach(function (lang) {
            var contents = grunt.file.readJSON(lang);

            strings.forEach(function (string) {
                if (!contents[string]) {
                    contents[string] = "";
                }
            });

            contents = JSON.stringify(contents);

            contents = contents.replace(/\{/g, "{\n    ");
            contents = contents.replace(/","/g, "\",\n    \"");
            contents = contents.replace(/":"/g, "\" : \"");
            contents = contents.replace(/\}/g, "\n}");

            grunt.file.write(lang, contents);
        });
  });
};
<|endoftext|>


<commit_before>/**
 * Copyright 2013 Kitware Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

module.exports = function (grunt) {
  var fs = require('fs');
  var path = require('path');
  var DEBUG = false;

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      dist: {
        src: ['src/*.js'],
        dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js'
      }
    },
    uglify: {
      options: {
        beautify: false
      },
      dist: {
        src: ['src/*.js'],
        dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.min.js'
      }
    },
    jshint: {
      all: ['Gruntfile.js', 'src/*.js']
    },
    clean: ["dist"],
    copy: {
      pkg: {
        src: 'package.json',
        dest: 'dist/package.json'
      },
      readme: {
        src: 'README.md',
        dest: 'dist/README.md'
      }
    },
    shell: {
      dist: {
        command: 'npm publish dist',
        options: {
          stdout: true
        }
      }
    },
    release: {
      options: {
        npm: false,
        folder: 'dist'
      }
    }
  });

  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-release');

  grunt.registerTask('default', ['clean', 'concat', 'uglify', 'copy']);
  grunt.registerTask('dist', ['release', 'default', 'shell:dist']);
};
<commit_msg>Removed unused file<commit_after><|endoftext|>


<commit_before>/*!
 * Bootstrap's Gruntfile
 * http://getbootstrap.com
 * Copyright 2013-2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */

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

    // Force use of Unix newlines
    grunt.util.linefeed = '\n';

    RegExp.quote = function(string) {
        return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
    };

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

    // Project configuration.
    grunt.initConfig({

        jshint: {
            options: {
                jshintrc: 'js/.jshintrc'
            },
            src: {
                src: 'js/**/*.js'
            },
            test: {
                src: 'js/tests/unit/**/*.js'
            },
            assets: {
                src: 'docs/assets/js/_src/**/*.js'
            }
        },

        jscs: {
            options: {
                config: 'js/.jscsrc'
            },
            src: {
                src: '<%= jshint.src.src %>'
            },
            test: {
                src: '<%= jshint.test.src %>'
            },
            assets: {
                options: {
                    requireCamelCaseOrUpperCaseIdentifiers: null
                },
                src: '<%= jshint.assets.src %>'
            }
        },

        watch: {
            options: {
                livereload: true,
            },
            js: {
                files: [
                    '<%= jshint.src.src %>',
                    'js/templates/**/*.hbs',
                    'docs/assets/js/_src/**/*.js'
                ],
                tasks: ['jshint:src']
            },
            test: {
                files: '<%= jshint.test.src %>',
                tasks: ['jshint:test']
            }
        },

        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: false,
                browsers: ['Chrome', 'PhantomJS']
            },
            ci: {
                configFile: 'karma.conf.js',
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },

        sed: {
            versionNumber: {
                pattern: ( function() {
                    var old = grunt.option('oldver');
                    return old ? RegExp.quote(old) : old;
                } )(),
                replacement: grunt.option('newver'),
                recursive: true
            }
        }
    });

    // These plugins provide necessary tasks.
    require('load-grunt-tasks')(grunt, {
        scope: 'devDependencies'
    });
    grunt.registerTask('test', ['karma']);
    // Default task.
    grunt.registerTask('default', ['test']);

    grunt.registerTask('dev', ['watch']);

    // Version numbering task.
    // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
    // This can be overzealous, so its changes should always be manually reviewed!
    grunt.registerTask('change-version-number', 'sed');
};<commit_msg>fixed grunt commands<commit_after>/*!
 * Bootstrap's Gruntfile
 * http://getbootstrap.com
 * Copyright 2013-2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */

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

    // Force use of Unix newlines
    grunt.util.linefeed = '\n';

    RegExp.quote = function(string) {
        return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
    };

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

    // Project configuration.
    grunt.initConfig({

        jshint: {
            options: {
                jshintrc: 'js/.jshintrc'
            },
            src: {
                src: 'js/**/*.js'
            },
            test: {
                src: 'js/tests/unit/**/*.js'
            },
            assets: {
                src: 'docs/assets/js/_src/**/*.js'
            }
        },

        jscs: {
            options: {
                config: 'js/.jscsrc'
            },
            src: {
                src: '<%= jshint.src.src %>'
            },
            test: {
                src: '<%= jshint.test.src %>'
            },
            assets: {
                options: {
                    requireCamelCaseOrUpperCaseIdentifiers: null
                },
                src: '<%= jshint.assets.src %>'
            }
        },

        watch: {
            options: {
                livereload: true,
            },
            js: {
                files: [
                    '<%= jshint.src.src %>',
                    'js/templates/**/*.hbs',
                    'docs/assets/js/_src/**/*.js'
                ],
                tasks: ['jshint:src']
            },
            test: {
                files: '<%= jshint.test.src %>',
                tasks: ['jshint:test']
            }
        },

        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: false,
                browsers: ['Chrome', 'PhantomJS']
            },
            ci: {
                configFile: 'karma.conf.js',
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },

        sed: {
            versionNumber: {
                pattern: ( function() {
                    var old = grunt.option('oldver');
                    return old ? RegExp.quote(old) : old;
                } )(),
                replacement: grunt.option('newver'),
                recursive: true
            }
        }
    });

    // These plugins provide necessary tasks.
    require('load-grunt-tasks')(grunt, {
        scope: 'devDependencies'
    });
    grunt.registerTask('test:unit', ['karma:unit']);
    grunt.registerTask('test:ci', ['karma:ci']);
    // Default task.
    grunt.registerTask('default', ['test']);

    grunt.registerTask('dev', ['watch']);

    // Version numbering task.
    // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
    // This can be overzealous, so its changes should always be manually reviewed!
    grunt.registerTask('change-version-number', 'sed');
};<|endoftext|>


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

	process.env.NODE_ENV = grunt.option('dist') ? 'production' : 'development';

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Read project configuration

	var  path = require('path')
		,configr = require('./lib/configure')
		,cfg ,modulesPattern, buildBaseDirName, buildPath, buildPathJs, buildPathCss, buildPathSpriteSheets
		,isDistBuild = grunt.option('dist') || false // based on this value we will execute a dev or dist build
	;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Get project configuration

	// Override project config, if command line options contain config options (for testing)
	cfg = grunt.option('config-path') && grunt.option('config-files')
		? configr.merge(grunt.option('config-path'), grunt.option('config-files').split(','))
		: configr.get()
	;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Create vars from config

	modulesPattern = path.join(cfg.sources.modulesBaseDir, cfg.moduleDirName.replace('{{name}}', '*'));
	buildBaseDirName = isDistBuild ? cfg.build.baseDirNameDist : cfg.build.baseDirNameDev;
	buildPath             = path.join(cfg.buildBasePath, buildBaseDirName);                       // buildBaseDirName can be empty
	buildPathJs           = path.join(cfg.buildBasePath, buildBaseDirName, cfg.build.js.dirName); // cfg.build.js.dirName can be empty
	buildPathCss          = path.join(cfg.buildBasePath, buildBaseDirName, cfg.build.css.dirName); // cfg.build.css.dirName can be empty
	buildPathSpriteSheets = path.join(cfg.buildBasePath, buildBaseDirName, cfg.build.spriteSheets.dirName); // cfg.build.css.dirName can be empty

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define grunt config

	grunt.initConfig({

		pkg                         : require('./package.json')

		,staticBaseUriCss           : cfg.staticBaseUri
		,staticBaseUri              : (cfg.staticBaseUri || '') + '/'

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Sources base paths

		,tcInline                   : cfg.sources.inline
		,tcBase                     : cfg.sources.base
		,spritesPath                : '<%=tcBase%>/css/sprites'
		,tcModules                  : modulesPattern
		,tcApplication              : cfg.sources.application
		,staticDir                  : cfg.staticPath

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Output destinations

		//,baseDirName                : cfg.build.baseDirName

		,buildPath                  : buildPath             // dynamic, depends on build mode (development/production)
		//,buildBaseDirName           : buildBaseDirName          // dynamic, depends on build mode (development/production)
		,tmpPath                    : '<%=buildPath%>/tmp'

		,destJs                     : buildPathJs
		,destCss                    : buildPathCss
		,destSpritesImg             : buildPathSpriteSheets
		,destSpritesCss             : '<%=spritesPath%>'        // technically this should go in tmp, but we want the generated classes in our base css for easy lookup.

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Directory names

		,skinsDirName               : cfg.skinsDirName

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Define source file patterns

		,sources: {
			inline_css: [
				 '<%=tcInline%>/css/lib/*.{less,css}'
				,'<%=tcInline%>/css/*.less'
			]
			,external_css: [
				 '<%=tcBase%>/css/sprites/*.less'
				,'<%=tcBase%>/css/lib/*.{less,css}'
				,'<%=tcBase%>/css/*.less'
				,'<%=tcModules%>/*.less'
				,'<%=tcModules%>/<%=skinsDirName%>/*.less'
				,'<%=tcApplication%>/css/*.less'
			]
			,inline_js: [
				 '<%=tcInline%>/js/lib/*.js'
				,'<%=tcInline%>/js/*.js'
			]
			,external_js: [
				 '<%=tcBase%>/js/lib/*.js'
				,'<%=tcBase%>/js/*.js'
				,'<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,module_test_js: [
				 '<%=staticDir%>/lib/test/test.js'
				,'<%=tcModules%>/test/*.js'
			]
			,jshint_inline: [
				 '<%=tcInline%>/js/*.js'
			]
			,jshint_external: [
				 '<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,jshint_module_test: [
				'<%=tcModules%>/test/*.js'
			]
			,sprites_watch: [
				 '<%=spritesPath%>/**/*.{png|jpg|conf}'
				,'<%=tcModules%>/sprites/*.{png|jpg|conf}'
			]
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Configure Grunt plugins

		,glue: {
			// see: https://github.com/MarcDiethelm/grunt-glue-nu
			options: {
				 css                : '<%=destSpritesCss%>'
				,less               : true
				,url                : '<%=staticBaseUri%><%=buildBaseDirName%>'
				,namespace          : ''
				,'sprite-namespace' : ''
				,retina             : true
			}
			,sprites: {
				options: {
					'sprite-namespace' : 's' // styled inline-block in sprites-helper.less
				}
				,src                : [
					 '<%=spritesPath%>/icons'
					,'<%=tcModules%>/sprites'
				]
				,dest               : '<%=buildPath%>'
			}
		}

		,less_imports: {
			inline: {
				 src                : '<%=sources.inline_css%>'
				,dest               : '<%=tmpPath%>/inline-@import.less'
			},
			external: {
				options: {}
				,src                : '<%=sources.external_css%>'
				,dest               : '<%=tmpPath%>/external-@import.less'
			}
		}

		,concat: {
			inline_scripts: {
				options: {
					banner          : '/*! Inline script dependencies for page bootstrapping */\n'
				}
				,src                : '<%=sources.inline_js%>'
				,dest               : '<%=destJs%>/inline.js'
			}
			,external_scripts: {
				 src                : '<%=sources.external_js%>'
				,dest               : '<%=destJs%>/external.js'
			}
			,module_tests: {
				 src                : '<%=sources.module_test_js%>'
				,dest               : '<%=destJs%>/test.js'
			}
		}

		,uglify: {
			inline: {
				options: {
					preserveComments: 'some'
				}
				,src                : '<%=destJs%>/inline.js'
				,dest               : '<%=destJs%>/inline.min.js'
			},
			external: {
				 src                : '<%=destJs%>/external.js'
				,dest               : '<%=destJs%>/external.min.js'
			}
		}

		,less: {
			inline: {
				options: {
					// cssmin will not create file if the output is empty. a special comment fixes this.
					 banner         : '/*! Inline style dependencies for page bootstrapping */'
					,imports: {
						reference   : ['<%=tcInline%>/css/lib/reference/*.less']
					}
				}
				,src                : '<%=tmpPath%>/inline-@import.less'
				,dest               : '<%=destCss%>/inline.css'
			}
			,external: {
				options: {
					 banner         : "@static-base: '<%=staticBaseUriCss%>';"
					,imports: {
						//reference   : ['<%=tcBase%>/css/lib/reference/*.less']
						reference   : [path.relative(process.cwd(), cfg.sources.base +'/css/lib/reference')+'/*.less']
					}
				}
				,src                : '<%=tmpPath%>/external-@import.less'
				,dest               : '<%=destCss%>/external.css'
			}
		}

		,cssmin: {
			inline: {
				 src                : '<%=destCss%>/inline.css'
				,dest               : '<%=destCss%>/inline.min.css'
			},
			external: {
				 src                : '<%=destCss%>/external.css'
				,dest               : '<%=destCss%>/external.min.css'
			}
		}

		// After dist build remove all non-minified files.
		,clean: {
			dist: {
				options: {
					force: true
				}
				,src: [
					 '<%=tmpPath%>'
					,'<%=destCss%>/inline.css'
					,'<%=destCss%>/external.css'
					,'<%=destJs%>/inline.js'
					,'<%=destJs%>/external.js'
				]
			}
		}

		,jshint: {
			options: {
				// report but don't fail
				force               : true
				// enforce
				,latedef            : true
				,undef              : true
				//relax
				,laxcomma           : true
				,smarttabs          : true
				,expr               : true
				,asi                : true
				,loopfunc           : true
				,nonew              : true
				// environment
				,browser            : true
				,jquery             : true
				,globals: {
					$               : true
					,Tc             : true
					,xtc            : true
					,console        : true
					// Lawg
					,log            : true
					,dir            : true
					,info           : true
					,debug          : true
					,warn           : true
					,error          : true
					,table          : true
					// QUnit ಠ_ಠ
					,asyncTest      : true
					,deepEqual      : true
					,equal          : true
					,expect         : true
					,module         : true
					,notDeepEqual   : true
					,notEqual       : true
					,notStrictEqual : true
					,ok             : true
					,QUnit          : true
					,raises         : true
					,start          : true
					,stop           : true
					,strictEqual    : true
					,test           : true
				}
			}
			,inline                 : ['<%=sources.jshint_inline%>']
			,external               : ['<%=sources.jshint_external%>']
			,module_tests           : ['<%=sources.jshint_module_test%>']
		}

		,watch: {
			options: {
				//cwd                 : '../..',
				spawn                 : false
			}
			,sprites: {
				 files              : ['<%=sources.sprites_watch%>']
				,tasks              : ['build-sprites', 'build-external-css']
			},
			inline_styles: {
				 files              : ['<%=sources.inline_css%>', '<%=tcInline%>/css/lib/reference.less']
				,tasks              : ['build-inline-css']
			},
			external_styles: {
				 files              : ['<%=sources.external_css%>', '<%=tcBase%>/css/lib/reference.less']
				,tasks              : ['build-external-css']
			}
			,inline_scripts: {
				 files              : ['<%=sources.inline_js%>']
				,tasks              : ['build-inline-js']
			}
			,external_scripts: {
				 files              : ['<%=sources.external_js%>']
				,tasks              : ['build-external-js']
			}
			,module_tests: {
				 files              : ['<%=sources.module_test_js%>']
				,tasks              : ['build-module-tests']
			}
			,gruntfile: {
				 files              : ['Gruntfile.js']
				,tasks              : 'default'
			}
		}

		,log: {
			options: {
				 bold: true
				,color: 'green'
			}
			,devCssDone: {
				msg: 'Dev CSS complete'
			}
			,devJsDone: {
				msg: 'Dev JS complete'
			}
		}
	});

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define build tasks                            // use actual task name (first part before colon)!

	grunt.registerTask('build-sprites',              ['glue']);
	grunt.registerTask('build-external-js',          ['concat:external_scripts', 'jshint:external']);
	grunt.registerTask('build-inline-js',            ['concat:inline_scripts', 'log:devJsDone', 'jshint:inline']);
	grunt.registerTask('build-external-css',         ['less_imports:external', 'less:external']);
	grunt.registerTask('build-inline-css',           ['less_imports:inline', 'less:inline', 'log:devCssDone']);
	grunt.registerTask('build-module-tests',         ['concat:module_tests' , 'jshint:module_tests']);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define the build pipes

	var devBuild = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'
		,'watch'
	];

	var distBuild = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'

		,'uglify:inline'
		,'uglify:external'
		,'cssmin:inline'
		,'cssmin:external'
		,'clean:dist'
	];

	var task = isDistBuild ? distBuild : devBuild;

	// If sprites building is not enabled in the app config, remove it.
	!cfg.enableSpritesBuilding && task.shift();
	grunt.registerTask('default', task);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Load grunt plugins

	grunt.loadNpmTasks('grunt-glue-nu');
	grunt.loadNpmTasks('grunt-less-imports');
	grunt.loadNpmTasks('assemble-less');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-clean');

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Ad-hoc plugin

	grunt.registerMultiTask('log', 'a console logging task', function() {
		var options = this.options()
		   ,color = options.color || false
		;

		if (options.bold) {
			grunt.log.subhead(this.data.msg[color]);
		}
		else {
			grunt.log.writeln(this.data.msg[color]);
		}
	});

};
<commit_msg>Fix sprites url and watcher<commit_after>module.exports = function(grunt) {

	process.env.NODE_ENV = grunt.option('dist') ? 'production' : 'development';

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Read project configuration

	var  path = require('path')
		,configr = require('./lib/configure')
		,cfg ,modulesPattern, buildBaseDirName, buildPath, buildPathJs, buildPathCss, buildPathSpriteSheets
		,isDistBuild = grunt.option('dist') || false // based on this value we will execute a dev or dist build
	;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Get project configuration

	// Override project config, if command line options contain config options (for testing)
	cfg = grunt.option('config-path') && grunt.option('config-files')
		? configr.merge(grunt.option('config-path'), grunt.option('config-files').split(','))
		: configr.get()
	;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Create vars from config

	modulesPattern = path.join(cfg.sources.modulesBaseDir, cfg.moduleDirName.replace('{{name}}', '*'));
	buildBaseDirName = isDistBuild ? cfg.build.baseDirNameDist : cfg.build.baseDirNameDev;
	buildPath             = path.join(cfg.buildBasePath, buildBaseDirName);                       // buildBaseDirName can be empty
	buildPathJs           = path.join(cfg.buildBasePath, buildBaseDirName, cfg.build.js.dirName); // cfg.build.js.dirName can be empty
	buildPathCss          = path.join(cfg.buildBasePath, buildBaseDirName, cfg.build.css.dirName); // cfg.build.css.dirName can be empty
	buildPathSpriteSheets = path.join(cfg.buildBasePath, buildBaseDirName, cfg.build.spriteSheets.dirName); // cfg.build.css.dirName can be empty

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define grunt config

	grunt.initConfig({

		pkg                         : require('./package.json')

		,staticBaseUriCss           : cfg.staticBaseUri
		,staticBaseUri              : (cfg.staticBaseUri || '') + '/'

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Sources base paths

		,tcInline                   : cfg.sources.inline
		,tcBase                     : cfg.sources.base
		,spritesPath                : '<%=tcBase%>/css/sprites'
		,tcModules                  : modulesPattern
		,tcApplication              : cfg.sources.application
		,staticDir                  : cfg.staticPath

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Output destinations

		//,baseDirName                : cfg.build.baseDirName

		,buildPath                  : buildPath             // dynamic, depends on build mode (development/production)
		,buildBaseDirName           : buildBaseDirName          // dynamic, depends on build mode (development/production)
		,tmpPath                    : '<%=buildPath%>/tmp'

		,destJs                     : buildPathJs
		,destCss                    : buildPathCss
		,destSpritesImg             : buildPathSpriteSheets
		,destSpritesCss             : '<%=spritesPath%>'        // technically this should go in tmp, but we want the generated classes in our base css for easy lookup.

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Directory names

		,skinsDirName               : cfg.skinsDirName

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Define source file patterns

		,sources: {
			inline_css: [
				 '<%=tcInline%>/css/lib/*.{less,css}'
				,'<%=tcInline%>/css/*.less'
			]
			,external_css: [
				 '<%=tcBase%>/css/sprites/*.less'
				,'<%=tcBase%>/css/lib/*.{less,css}'
				,'<%=tcBase%>/css/*.less'
				,'<%=tcModules%>/*.less'
				,'<%=tcModules%>/<%=skinsDirName%>/*.less'
				,'<%=tcApplication%>/css/*.less'
			]
			,inline_js: [
				 '<%=tcInline%>/js/lib/*.js'
				,'<%=tcInline%>/js/*.js'
			]
			,external_js: [
				 '<%=tcBase%>/js/lib/*.js'
				,'<%=tcBase%>/js/*.js'
				,'<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,module_test_js: [
				 '<%=staticDir%>/lib/test/test.js'
				,'<%=tcModules%>/test/*.js'
			]
			,jshint_inline: [
				 '<%=tcInline%>/js/*.js'
			]
			,jshint_external: [
				 '<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,jshint_module_test: [
				'<%=tcModules%>/test/*.js'
			]
			,sprites_watch: [
				 '<%=spritesPath%>/**/*.{png,jpg,conf}'
				,'<%=tcModules%>/sprites/*.{png,jpg,conf}'
			]
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Configure Grunt plugins

		,glue: {
			// see: https://github.com/MarcDiethelm/grunt-glue-nu
			options: {
				 css                : '<%=destSpritesCss%>'
				,less               : true
				,url                : '<%=staticBaseUri%><%=buildBaseDirName%>/'
				,namespace          : ''
				,'sprite-namespace' : ''
				,retina             : true
			}
			,sprites: {
				options: {
					'sprite-namespace' : 's' // styled inline-block in sprites-helper.less
				}
				,src                : [
					 '<%=spritesPath%>/icons'
					,'<%=tcModules%>/sprites'
				]
				,dest               : '<%=buildPath%>'
			}
		}

		,less_imports: {
			inline: {
				 src                : '<%=sources.inline_css%>'
				,dest               : '<%=tmpPath%>/inline-@import.less'
			},
			external: {
				options: {}
				,src                : '<%=sources.external_css%>'
				,dest               : '<%=tmpPath%>/external-@import.less'
			}
		}

		,concat: {
			inline_scripts: {
				options: {
					banner          : '/*! Inline script dependencies for page bootstrapping */\n'
				}
				,src                : '<%=sources.inline_js%>'
				,dest               : '<%=destJs%>/inline.js'
			}
			,external_scripts: {
				 src                : '<%=sources.external_js%>'
				,dest               : '<%=destJs%>/external.js'
			}
			,module_tests: {
				 src                : '<%=sources.module_test_js%>'
				,dest               : '<%=destJs%>/test.js'
			}
		}

		,uglify: {
			inline: {
				options: {
					preserveComments: 'some'
				}
				,src                : '<%=destJs%>/inline.js'
				,dest               : '<%=destJs%>/inline.min.js'
			},
			external: {
				 src                : '<%=destJs%>/external.js'
				,dest               : '<%=destJs%>/external.min.js'
			}
		}

		,less: {
			inline: {
				options: {
					// cssmin will not create file if the output is empty. a special comment fixes this.
					 banner         : '/*! Inline style dependencies for page bootstrapping */'
					,imports: {
						reference   : ['<%=tcInline%>/css/lib/reference/*.less']
					}
				}
				,src                : '<%=tmpPath%>/inline-@import.less'
				,dest               : '<%=destCss%>/inline.css'
			}
			,external: {
				options: {
					 banner         : "@static-base: '<%=staticBaseUriCss%>';"
					,imports: {
						//reference   : ['<%=tcBase%>/css/lib/reference/*.less']
						reference   : [path.relative(process.cwd(), cfg.sources.base +'/css/lib/reference')+'/*.less']
					}
				}
				,src                : '<%=tmpPath%>/external-@import.less'
				,dest               : '<%=destCss%>/external.css'
			}
		}

		,cssmin: {
			inline: {
				 src                : '<%=destCss%>/inline.css'
				,dest               : '<%=destCss%>/inline.min.css'
			},
			external: {
				 src                : '<%=destCss%>/external.css'
				,dest               : '<%=destCss%>/external.min.css'
			}
		}

		// After dist build remove all non-minified files.
		,clean: {
			dist: {
				options: {
					force: true
				}
				,src: [
					 '<%=tmpPath%>'
					,'<%=destCss%>/inline.css'
					,'<%=destCss%>/external.css'
					,'<%=destJs%>/inline.js'
					,'<%=destJs%>/external.js'
				]
			}
		}

		,jshint: {
			options: {
				// report but don't fail
				force               : true
				// enforce
				,latedef            : true
				,undef              : true
				//relax
				,laxcomma           : true
				,smarttabs          : true
				,expr               : true
				,asi                : true
				,loopfunc           : true
				,nonew              : true
				// environment
				,browser            : true
				,jquery             : true
				,globals: {
					$               : true
					,Tc             : true
					,xtc            : true
					,console        : true
					// Lawg
					,log            : true
					,dir            : true
					,info           : true
					,debug          : true
					,warn           : true
					,error          : true
					,table          : true
					// QUnit ಠ_ಠ
					,asyncTest      : true
					,deepEqual      : true
					,equal          : true
					,expect         : true
					,module         : true
					,notDeepEqual   : true
					,notEqual       : true
					,notStrictEqual : true
					,ok             : true
					,QUnit          : true
					,raises         : true
					,start          : true
					,stop           : true
					,strictEqual    : true
					,test           : true
				}
			}
			,inline                 : ['<%=sources.jshint_inline%>']
			,external               : ['<%=sources.jshint_external%>']
			,module_tests           : ['<%=sources.jshint_module_test%>']
		}

		,watch: {
			options: {
				//cwd                 : '../..',
				spawn                 : false
			}
			,sprites: {
				 files              : ['<%=sources.sprites_watch%>']
				,tasks              : ['build-sprites', 'build-external-css']
			},
			inline_styles: {
				 files              : ['<%=sources.inline_css%>', '<%=tcInline%>/css/lib/reference.less']
				,tasks              : ['build-inline-css']
			},
			external_styles: {
				 files              : ['<%=sources.external_css%>', '<%=tcBase%>/css/lib/reference.less']
				,tasks              : ['build-external-css']
			}
			,inline_scripts: {
				 files              : ['<%=sources.inline_js%>']
				,tasks              : ['build-inline-js']
			}
			,external_scripts: {
				 files              : ['<%=sources.external_js%>']
				,tasks              : ['build-external-js']
			}
			,module_tests: {
				 files              : ['<%=sources.module_test_js%>']
				,tasks              : ['build-module-tests']
			}
			,gruntfile: {
				 files              : ['Gruntfile.js']
				,tasks              : 'default'
			}
		}

		,log: {
			options: {
				 bold: true
				,color: 'green'
			}
			,devCssDone: {
				msg: 'Dev CSS complete'
			}
			,devJsDone: {
				msg: 'Dev JS complete'
			}
		}
	});

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define build tasks                            // use actual task name (first part before colon)!

	grunt.registerTask('build-sprites',              ['glue']);
	grunt.registerTask('build-external-js',          ['concat:external_scripts', 'jshint:external']);
	grunt.registerTask('build-inline-js',            ['concat:inline_scripts', 'log:devJsDone', 'jshint:inline']);
	grunt.registerTask('build-external-css',         ['less_imports:external', 'less:external']);
	grunt.registerTask('build-inline-css',           ['less_imports:inline', 'less:inline', 'log:devCssDone']);
	grunt.registerTask('build-module-tests',         ['concat:module_tests' , 'jshint:module_tests']);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define the build pipes

	var devBuild = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'
		,'watch'
	];

	var distBuild = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'

		,'uglify:inline'
		,'uglify:external'
		,'cssmin:inline'
		,'cssmin:external'
		,'clean:dist'
	];

	var task = isDistBuild ? distBuild : devBuild;

	// If sprites building is not enabled in the app config, remove it.
	!cfg.enableSpritesBuilding && task.shift();
	grunt.registerTask('default', task);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Load grunt plugins

	grunt.loadNpmTasks('grunt-glue-nu');
	grunt.loadNpmTasks('grunt-less-imports');
	grunt.loadNpmTasks('assemble-less');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-clean');

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Ad-hoc plugin

	grunt.registerMultiTask('log', 'a console logging task', function() {
		var options = this.options()
		   ,color = options.color || false
		;

		if (options.bold) {
			grunt.log.subhead(this.data.msg[color]);
		}
		else {
			grunt.log.writeln(this.data.msg[color]);
		}
	});

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    clean: {
      files: ['dist']
    },
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.js': ['tracekit/tracekit.js', 'src/<%= pkg.name %>.tracekit.jquery.js', 'src/<%= pkg.name %>.js'],
          'dist/<%= pkg.name %>.vanilla.js': ['tracekit/tracekit.js', 'src/<%= pkg.name %>.js']
        }
      },
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js'],
          'dist/<%= pkg.name %>.vanilla.min.js': ['dist/<%= pkg.name %>.vanilla.js']
        }
      },
    },
    jshint: {
      gruntfile: {
        options: {
          jshintrc: '.jshintrc'
        },
        src: 'Gruntfile.js'
      },
      src: {
        options: {
          jshintrc: 'src/.jshintrc'
        },
        src: ['src/**/*.js']
      },
    },
    jasmine : {
      src : 'src/**/*.js',
      options : {
        specs : 'spec/**/*.js',
        vendor : ['tracekit/tracekit.js'],
        template : require('grunt-template-jasmine-istanbul'),
        templateOptions: {
          coverage: 'reports/coverage.json',
          report: 'reports/coverage'
        }
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      src: {
        files: '<%= jshint.src.src %>',
        tasks: ['jshint:src', 'jasmine']
      },
    },
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jasmine');

  // Default task.
  grunt.registerTask('default', ['jshint', 'jasmine', 'clean', 'concat', 'uglify']);

};
<commit_msg>package name changed so hard code old name<commit_after>'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    clean: {
      files: ['dist']
    },
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        files: {
          'dist/raygun.js': ['tracekit/tracekit.js', 'src/raygun.tracekit.jquery.js', 'src/raygun.js'],
          'dist/raygun.vanilla.js': ['tracekit/tracekit.js', 'src/raygun.js']
        }
      },
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        files: {
          'dist/raygun.min.js': ['dist/raygun.js'],
          'dist/raygun.vanilla.min.js': ['dist/raygun.vanilla.js']
        }
      },
    },
    jshint: {
      gruntfile: {
        options: {
          jshintrc: '.jshintrc'
        },
        src: 'Gruntfile.js'
      },
      src: {
        options: {
          jshintrc: 'src/.jshintrc'
        },
        src: ['src/**/*.js']
      },
    },
    jasmine : {
      src : 'src/**/*.js',
      options : {
        specs : 'spec/**/*.js',
        vendor : ['tracekit/tracekit.js'],
        template : require('grunt-template-jasmine-istanbul'),
        templateOptions: {
          coverage: 'reports/coverage.json',
          report: 'reports/coverage'
        }
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      src: {
        files: '<%= jshint.src.src %>',
        tasks: ['jshint:src', 'jasmine']
      },
    },
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jasmine');

  // Default task.
  grunt.registerTask('default', ['jshint', 'jasmine', 'clean', 'concat', 'uglify']);

};
<|endoftext|>


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

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-processhtml');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.initConfig({

        jshint: {
            files: [
                'Gruntfile.js',
                'src/scripts/**/*.js',
                'demo/**/*.js'
            ],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        clean: {
            dist: ['dist']
        },

        sass: {
            build: {
                files: {
                    'src/styles/ng-notify.css': 'src/styles/ng-notify.sass'
                }
            }
        },

        cssmin: {
            build: {
                files: {
                    'dist/ng-notify.min.css': 'src/styles/ng-notify.css'
                }
            },

            demo: {
                files: {
                    'dist/demo/demo.min.css': [
                        'src/styles/ng-notify.css',
                        'demo/demo.css'
                    ]
                }
            }
        },

        processhtml: {
            build: {
                files: {
                    'dist/demo/index.html': 'demo/index.html'
                }
            }
        },

        htmlmin: {
            options: {
                removeComments: true,
                collapseWhitespace: true
            },
            index: {
                files: {
                    'dist/demo/index.html': 'dist/demo/index.html'
                }
            }
        },

        uglify: {
            build: {
                files: {
                    'dist/ng-notify.min.js': 'src/**/*.js'
                }
            },
            demo: {
                files: {
                    'dist/demo/demo.min.js': [
                        'bower_components/angular/angular.js',
                        'src/scripts/ng-notify.js',
                        'demo/demo.js'
                    ]
                }
            }
        },

        watch: {
            scripts: {
                files: ['src/**/*', 'demo/**/*'],
                tasks: ['build']
            }
        }

    });

    /* Build process...

    - Lint JS
    - Clean old build
    - Process styles
    - Process scripts
    - Process demo */

    grunt.registerTask('build', [
        'jshint',
        'clean',
        'sass',
        'cssmin:build',
        'uglify:build',
        'demo'
    ]);

    grunt.registerTask('demo', [
        'processhtml',
        'htmlmin',
        'cssmin:demo',
        'uglify:demo'
    ]);

    grunt.registerTask('default', ['build']);
    grunt.registerTask('dev', ['build', 'watch']);

};
<commit_msg>Configured gh-pages to auto build.<commit_after>module.exports = function(grunt) {
    'use strict';

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-processhtml');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.initConfig({

        jshint: {
            files: [
                'Gruntfile.js',
                'src/scripts/**/*.js',
                'demo/**/*.js'
            ],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        clean: {
            dist: ['dist']
        },

        sass: {
            build: {
                files: {
                    'src/styles/ng-notify.css': 'src/styles/ng-notify.sass'
                }
            }
        },

        cssmin: {
            build: {
                files: {
                    'dist/ng-notify.min.css': 'src/styles/ng-notify.css'
                }
            },

            demo: {
                files: {
                    '_gh-pages/demo.min.css': [
                        'src/styles/ng-notify.css',
                        'demo/demo.css'
                    ]
                }
            }
        },

        processhtml: {
            build: {
                files: {
                    '_gh-pages/index.html': 'demo/index.html'
                }
            }
        },

        htmlmin: {
            options: {
                removeComments: true,
                collapseWhitespace: true
            },
            index: {
                files: {
                    '_gh-pages/index.html': '_gh-pages/index.html'
                }
            }
        },

        uglify: {
            build: {
                files: {
                    'dist/ng-notify.min.js': 'src/**/*.js'
                }
            },
            demo: {
                files: {
                    '_gh-pages/demo.min.js': [
                        'bower_components/angular/angular.js',
                        'src/scripts/ng-notify.js',
                        'demo/demo.js'
                    ]
                }
            }
        },

        watch: {
            scripts: {
                files: ['src/**/*', 'demo/**/*'],
                tasks: ['build']
            }
        }

    });

    /* Build process...

    - Lint JS
    - Clean old build
    - Process styles
    - Process scripts
    - Process demo */

    grunt.registerTask('build', [
        'jshint',
        'clean',
        'sass',
        'cssmin:build',
        'uglify:build',
        'demo'
    ]);

    grunt.registerTask('demo', [
        'processhtml',
        'htmlmin',
        'cssmin:demo',
        'uglify:demo'
    ]);

    grunt.registerTask('default', ['build']);
    grunt.registerTask('dev', ['build', 'watch']);

};
<|endoftext|>


<commit_before>'use strict';

var themeName = 'Theme Name',
    themeUri = 'http://themeuri.com',
    author = 'Author Name',
    authorUri = 'http://yourdomain.com',
    themeSlug = 'tip-theme',
    sanitizedSlug = themeSlug.replace(/[^a-z0-9_]+/ig,'_');

module.exports = function(grunt) {
  grunt.initConfig({
    themeName: themeName,
    themeUri: themeUri,
    author: author,
    authorUri: authorUri,
    sanitizedSlug: sanitizedSlug,
    pkg: grunt.file.readJSON('package.json'),

    shell: {
      target: {
        command: 'git clone https://github.com/Automattic/_s.git'
      }
    },
    replace: {
      slug: {
        options: {
          usePrefix: false,
          patterns: [
            {
              match: '\'_s\'',
              replacement: '\'<%= sanitizedSlug %>\''
            },
            {
              match: 'tip_theme_',
              replacement: '<%= sanitizedSlug %>_'
            },
            {
              match: ' tip_theme',
              replacement: ' <%= sanitizedSlug %>'
            },
            {
              match: 'tip_theme-',
              replacement: '<%= sanitizedSlug %>-'
            }
          ]
        },
        files: [
          {
            expand: true,
            cwd: '.',
            src: [
              '*.*',
              '{inc,js,languages,layouts}/**/*.*'
            ],
            dest: '.'
          }
        ]
      },
      scss: {
        options: {
          usePrefix: false,
          patterns: [
            {
              match: 'Theme Name: tip_theme',
              replacement: 'Theme Name: <%= themeName %>'
            },
            {
              match: 'Theme URI: http://underscores.me/',
              replacement: 'Theme URI: <%= themeUri %>'
            },
            {
              match: 'Author: Automattic',
              replacement: 'Author: <%= author %>'
            },
            {
              match: 'Author URI: http://automattic.com/',
              replacement: 'Author URI: <%= authorUri %>'
            },
            {
              match: 'Text Domain: tip_theme',
              replacement: 'Text Domain: <%= sanitizedSlug %>'
            },
            {
              match: '@import "normalize";',
              replacement: '@import "normalize";\n@import "../bower_components/susy/sass/susy";\n@import "../bower_components/breakpoint-sass/stylesheets/breakpoint";'
            }
          ]
        },
        files: [
          {
            expand: true,
            cwd: '.',
            src: ['style.*', 'sass/style.*']
          }
        ]
      },
      footer: {
        options: {
          usePrefix: false,
          patterns: [
            {
              match: 'Automattic',
              replacement: '<%= author %>'
            },
            {
              match: 'http://automattic.com/',
              replacement: '<%= authorUri %>'
            }
          ]
        },
        files: [
          {
            expand: true,
            cwd: '.',
            src: 'footer.php'
          }
        ]
      }
    },

    sass: {
      dev: {
        options: {
          sourceMap: true,
          outputStyle: 'expanded',
          require: 'susy'
        },
        files: [
          {
            expand: true, // Recursive
            cwd: "sass", // The startup directory
            src: ["**/style.scss"], // Source files
            dest: ".", // Destination
            ext: ".css" // File extension
          }
        ]
      },
      dist: {
        options: {
          sourceMap: false,
          outputStyle: 'compressed',
          require: 'susy'
        },
        files: [
          {
            expand: true, // Recursive
            cwd: "sass", // The startup directory
            src: ["**/style.scss"], // Source files
            dest: ".", // Destination
            ext: ".css" // File extension
          }
        ]
      }
    },

    autoprefixer: {
      options: {
        browsers: [
          'last 3 versions'
        ],
        map: true // Update source map (creates one if it can't find an existing map)
      },
      dist: {
        files: [
          {
            expand: true, // Recursive
            cwd: ".", // The startup directory
            src: ["*.css"], // Source files
            dest: ".", // Destination
            ext: ".css" // File extension
          }
        ]
      }
    },

    csscomb: {
      options: {
        config: 'csscomb.json'
      },
      server: {
        files: {
          'deploy/style.css': ['deploy/style.css'],
        }
      },
    },

    cssmin: {
      server: {
        files: [{
          expand: true,
          cwd: 'deploy',
          src: 'style.css',
          dest: 'deploy',
          ext: '.css'
        }]
      }
    },

    jshint: {
      options: {
        node: true,
        reporter: require('jshint-stylish')
      },
      all: ['js/**/*.js'],
    },

    watch: {
      options: {
        livereload: true
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      scss: {
        files: '**/*.scss',
        tasks: ['sass:dev', 'autoprefixer']
      },
      jshint: {
        files: 'js/**/*.js',
        tasks: ['jshint']
      },
      livereload: {
        files: [
          '{,*/}*.html',
          '{,*/}*.php',
          'js/{,*/}*.js',
          'css/{,*/}*.css',
          'images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      },
    },

    clean: {
      pre: ['tip_theme'],
      post: ['deploy']

    },

    copy: {
      pre: {
        files: [
          {
            expand: true,
            cwd: 'tip_theme',
            src: [
              '**/*.*',
              '!.{*}',
              '!CONTRIBUTING.*',
              '!codesniffer.*',
              '!wpcom.*'
            ],
            dest: '.'
          }
        ]
      },
      post: {
        files: [
          {
            expand: true,
            src: [
              '**/*.*',
              '!**/*.map',
              '!sass/**/*.*',
              '!node_modules/**/*.*',
              '!bower_components/**/*.*',
              '!{package,bower,csscomb}.json',
              '!Gruntfile.js'
            ],
            dest: 'deploy/'+(__dirname.split('/').pop())
          }
        ]
      }
    },

    imageoptim: {
      options: {
        imageAlpha: true
      },
      src: ['deploy/**/*.{jpg,jpeg,png,gif}']
    },

    svgmin: {
      files: [
        {
          cwd: 'deploy',
          src: '**/*.svg',
          dest: 'deploy'
        }
      ]
    },

    uglify: {
      dist: {
        files: [
          {
            expand: true,
            cwd: 'deploy/js',
            dest: 'deploy/js',
            src: '*.js'
          }
        ]
      }
    },

    compress: {
      main: {
        options: {
          archive: 'deploy/'+(__dirname.split('/').pop())+'.zip'
        },
        files: [
          {
            expand: true,
            cwd: 'deploy/'+(__dirname.split('/').pop()),
            src: '**/*.*'
          }
        ]
      }
    }
  });

  // Load these required NPM tasks:
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-csscomb');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-replace');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-phplint');
  grunt.loadNpmTasks('grunt-imageoptim');
  grunt.loadNpmTasks('grunt-svgmin');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-shell');

  grunt.registerTask('serve', function (target) {
    grunt.task.run([
      'watch'
    ]);
  });

  grunt.registerTask('init', [
    'shell',
    'copy:pre',
    'clean:pre',
    'replace:slug',
    'replace:scss'
  ]);
  grunt.registerTask('default', ['serve']);
  grunt.registerTask('build', [
    'sass:dist',
    'autoprefixer',
    'clean:post',
    'copy:post',
    'uglify',
    'csscomb',
    'cssmin',
    'imageoptim'
  ]);

};<commit_msg>add compress to build task<commit_after>'use strict';

var themeName = 'Theme Name',
    themeUri = 'http://themeuri.com',
    author = 'Author Name',
    authorUri = 'http://yourdomain.com',
    themeSlug = 'tip-theme',
    sanitizedSlug = themeSlug.replace(/[^a-z0-9_]+/ig,'_');

module.exports = function(grunt) {
  grunt.initConfig({
    themeName: themeName,
    themeUri: themeUri,
    author: author,
    authorUri: authorUri,
    sanitizedSlug: sanitizedSlug,
    themeDir: (__dirname.split('/').pop()),
    pkg: grunt.file.readJSON('package.json'),

    shell: {
      target: {
        command: 'git clone https://github.com/Automattic/_s.git'
      }
    },

    replace: {
      slug: {
        options: {
          usePrefix: false,
          patterns: [
            {
              match: '\'_s\'',
              replacement: '\'<%= sanitizedSlug %>\''
            },
            {
              match: '_s_',
              replacement: '<%= sanitizedSlug %>_'
            },
            {
              match: ' _s',
              replacement: ' <%= sanitizedSlug %>'
            },
            {
              match: '_s-',
              replacement: '<%= sanitizedSlug %>-'
            }
          ]
        },
        files: [
          {
            expand: true,
            cwd: '.',
            src: [
              '*.{php,md,css}',
              '{inc,js,languages,layouts}/**/*.*'
            ],
            dest: '.'
          }
        ]
      },

      scss: {
        options: {
          usePrefix: false,
          patterns: [
            {
              match: 'Theme Name: _s',
              replacement: 'Theme Name: <%= themeName %>'
            },
            {
              match: 'Theme URI: http://underscores.me/',
              replacement: 'Theme URI: <%= themeUri %>'
            },
            {
              match: 'Author: Automattic',
              replacement: 'Author: <%= author %>'
            },
            {
              match: 'Author URI: http://automattic.com/',
              replacement: 'Author URI: <%= authorUri %>'
            },
            {
              match: 'Text Domain: _s',
              replacement: 'Text Domain: <%= sanitizedSlug %>'
            },
            {
              match: '@import "normalize";',
              replacement: '@import "normalize";\n@import "../bower_components/susy/sass/susy";\n@import "../bower_components/breakpoint-sass/stylesheets/breakpoint";'
            }
          ]
        },
        files: [
          {
            expand: true,
            cwd: '.',
            src: ['style.*', 'sass/style.*']
          }
        ]
      },

      footer: {
        options: {
          usePrefix: false,
          patterns: [
            {
              match: 'Automattic',
              replacement: '<%= author %>'
            },
            {
              match: 'http://automattic.com/',
              replacement: '<%= authorUri %>'
            }
          ]
        },
        files: [
          {
            expand: true,
            cwd: '.',
            src: 'footer.php'
          }
        ]
      }
    },

    sass: {
      dev: {
        options: {
          sourceMap: true,
          outputStyle: 'expanded',
          require: 'susy'
        },
        files: [
          {
            expand: true,
            cwd: 'sass',
            src: ['**/style.scss'],
            dest: '.',
            ext: '.css'
          }
        ]
      },
      dist: {
        options: {
          sourceMap: false,
          outputStyle: 'compressed',
          require: 'susy'
        },
        files: [
          {
            expand: true,
            cwd: 'sass',
            src: ['**/style.scss'],
            dest: '.',
            ext: '.css'
          }
        ]
      }
    },

    autoprefixer: {
      options: {
        browsers: [
          'last 3 versions'
        ],
        map: true
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '.',
            src: ['*.css'],
            dest: '.',
            ext: '.css'
          }
        ]
      }
    },

    csscomb: {
      options: {
        config: 'csscomb.json'
      },
      server: {
        files: {
          'deploy/style.css': ['deploy/style.css'],
        }
      },
    },

    cssmin: {
      server: {
        files: [{
          expand: true,
          cwd: 'deploy',
          src: 'style.css',
          dest: 'deploy',
          ext: '.css'
        }]
      }
    },

    jshint: {
      options: {
        node: true,
        reporter: require('jshint-stylish')
      },
      all: ['js/**/*.js'],
    },

    watch: {
      options: {
        livereload: true
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      scss: {
        files: '**/*.scss',
        tasks: ['sass:dev', 'autoprefixer']
      },
      jshint: {
        files: 'js/**/*.js',
        tasks: ['jshint']
      },
      livereload: {
        files: [
          '{,*/}*.html',
          '{,*/}*.php',
          'js/{,*/}*.js',
          'css/{,*/}*.css',
          'images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      },
    },

    clean: {
      pre: ['_s'],
      post: ['deploy']

    },

    copy: {
      pre: {
        files: [
          {
            expand: true,
            cwd: '_s',
            src: [
              '**/*.*',
              '!.{*}',
              '!CONTRIBUTING.*',
              '!codesniffer.*',
              '!wpcom.*'
            ],
            dest: '.'
          }
        ]
      },
      post: {
        files: [
          {
            expand: true,
            src: [
              '**/*.*',
              '!**/*.map',
              '!sass/**/*.*',
              '!node_modules/**/*.*',
              '!bower_components/**/*.*',
              '!{package,bower,csscomb}.json',
              '!Gruntfile.js'
            ],
            dest: 'deploy/<%= themeDir %>'
          }
        ]
      }
    },

    imageoptim: {
      options: {
        imageAlpha: true
      },
      src: ['deploy/**/*.{jpg,jpeg,png,gif}']
    },

    svgmin: {
      files: [
        {
          cwd: 'deploy',
          src: '**/*.svg',
          dest: 'deploy'
        }
      ]
    },

    uglify: {
      dist: {
        files: [
          {
            expand: true,
            cwd: 'deploy/js',
            dest: 'deploy/js',
            src: '*.js'
          }
        ]
      }
    },

    compress: {
      main: {
        options: {
          archive: 'deploy/<%= themeDir %>.zip'
        },
        files: [
          {
            expand: true,
            cwd: 'deploy/<%= themeDir %>',
            src: '**/*.*'
          }
        ]
      }
    }
  });

  // Load these required NPM tasks:
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-csscomb');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-replace');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-phplint');
  grunt.loadNpmTasks('grunt-imageoptim');
  grunt.loadNpmTasks('grunt-svgmin');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-shell');

  grunt.registerTask('serve', function (target) {
    grunt.task.run(['watch']);
  });

  grunt.registerTask('init', [
    'shell',
    'copy:pre',
    'clean:pre',
    'replace:slug',
    'replace:scss'
  ]);
  grunt.registerTask('default', ['serve']);
  grunt.registerTask('build', [
    'sass:dist',
    'autoprefixer',
    'clean:post',
    'copy:post',
    'uglify',
    'csscomb',
    'cssmin',
    'imageoptim',
    'compress'
  ]);
};<|endoftext|>