<commit_before>// Generated on 2014-01-03 using generator-webapp 0.4.6
'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) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

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

    var modRewrite = require('connect-modrewrite');

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: {
            // Configurable paths
            app: 'app',
            dist: 'dist'
        },

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            js: {
                files: ['<%= yeoman.app %>/scripts/**/*.js'],
                tasks: ['browserify'],
                options: {
                    livereload: true
                }
            },
            jstest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['test:watch']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{gif,jpeg,jpg,png,svg,webp}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: '0.0.0.0',
                middleware: function(connect, options, middlewares) {
                    // Rewrite everything that does not contain a '.' to
                    // support pushState
                    middlewares.unshift(modRewrite(['^[^\\.]*$ /index.html [L]']));
                    return middlewares;
                }
            },
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= yeoman.app %>',
                        '.',
                        'api/app'
                    ]
                }
            },
            test: {
                options: {
                    port: 9001,
                    base: [
                        '.tmp',
                        'test',
                        '<%= yeoman.app %>',
                        'api/app'
                    ]
                }
            },
            dist: {
                options: {
                    open: true,
                    base: [
                        '<%= yeoman.dist %>',
                        'api/app'
                    ],
                    livereload: false
                }
            }
        },

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

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/**/*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },

        // Mocha testing framework configuration options
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html']
                }
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                sourcemap: true,
                bundleExec: true,
                relativeAssets: false,
                assetCacheBuster: false
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: false
                }
            }
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                // Commented out to use more extensive autoprefixer defaults
                // browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        browserify: {
            all: {
                files: {
                    '.tmp/scripts/main.js': '<%= yeoman.app %>/scripts/main.js'
                }
            }
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '!<%= yeoman.dist %>/styles/slate.min.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{gif,jpeg,jpg,png,webp}',
//                        '<%= yeoman.dist %>/styles/fonts/{,*/}*.*'
                    ]
                }
            }
        },

        // 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: '<%= yeoman.dist %>'
            },
            html: '.tmp/index.html'
        },

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

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{gif,jpeg,jpg,png}',
                    dest: '<%= yeoman.dist %>/images'
                }, {
                  expand: true,
                  cwd: '<%= yeoman.app %>/bower_components/select2',
                  src: '*.{gif,png}',
                  dest: '<%= yeoman.dist %>/styles'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        htmlmin: {
            dist: {
                options: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeCommentsFromCDATA: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: '{,*/}*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        cssmin: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/styles/exports.css': [
                        '.tmp/styles/exports.css'
                    ]
                }
            }
        },
        // uglify: {
        //     dist: {
        //         files: {
        //             '<%= yeoman.dist %>/scripts/scripts.js': [
        //                 '<%= yeoman.dist %>/scripts/scripts.js'
        //             ]
        //         }
        //     }
        // },
        // concat: {
        //     dist: {}
        // },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{config,php}',
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'bower_components/zeroclipboard/dist/ZeroClipboard.swf',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'scripts/disqus-count.js',
                        'styles/slate.min.css',
                        'styles/*.{gif,png}',
                        'styles/fonts/{,*/}*.*',
                        'vendor/knplabs/knp-snappy/src/**/*.php',
                        'bower_components/font-awesome/fonts/*.*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp',
                    dest: '<%= yeoman.dist %>',
                    src: 'index.html'
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            },
            tmp: {
                expand: true,
                cwd: '<%= yeoman.app %>',
                dest: '.tmp',
                src: [
                    'bower_components/qtip2/jquery.qtip.css',
                    'bower_components/select2/select2.css',
                    'index.html'
                ]
            }
        },

        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [
                'browserify',
                'compass:server',
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'browserify',
                'compass',
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        },
        rsync: {
            options: {
                args: ['-cruv']
            },
            'nusmods.com': {
                options: {
                    src: '<%= yeoman.dist %>/*',
                    dest: '~/nusmods.com'
                }
            }
        }
    });

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

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', function () {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve']);
    });

    grunt.registerTask('test', function(target) {
        if (target !== 'watch') {
            grunt.task.run([
                'clean:server',
                'concurrent:test',
                'autoprefixer'
            ]);
        }

        grunt.task.run([
            'connect:test',
            'mocha'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'copy:tmp',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'cssmin',
        'uglify',
        'copy:dist',
        'rev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        // 'newer:jshint',
        // 'test',
        'build'
    ]);
};
<commit_msg>Fix browserify not recompiling when hbs template changes<commit_after>// Generated on 2014-01-03 using generator-webapp 0.4.6
'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) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

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

    var modRewrite = require('connect-modrewrite');

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: {
            // Configurable paths
            app: 'app',
            dist: 'dist'
        },

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            js: {
                files: ['<%= yeoman.app %>/scripts/**/*.{js,hbs}'],
                tasks: ['browserify'],
                options: {
                    livereload: true
                }
            },
            jstest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['test:watch']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{gif,jpeg,jpg,png,svg,webp}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: '0.0.0.0',
                middleware: function(connect, options, middlewares) {
                    // Rewrite everything that does not contain a '.' to
                    // support pushState
                    middlewares.unshift(modRewrite(['^[^\\.]*$ /index.html [L]']));
                    return middlewares;
                }
            },
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= yeoman.app %>',
                        '.',
                        'api/app'
                    ]
                }
            },
            test: {
                options: {
                    port: 9001,
                    base: [
                        '.tmp',
                        'test',
                        '<%= yeoman.app %>',
                        'api/app'
                    ]
                }
            },
            dist: {
                options: {
                    open: true,
                    base: [
                        '<%= yeoman.dist %>',
                        'api/app'
                    ],
                    livereload: false
                }
            }
        },

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

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/**/*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },

        // Mocha testing framework configuration options
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html']
                }
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                sourcemap: true,
                bundleExec: true,
                relativeAssets: false,
                assetCacheBuster: false
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: false
                }
            }
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                // Commented out to use more extensive autoprefixer defaults
                // browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        browserify: {
            all: {
                files: {
                    '.tmp/scripts/main.js': '<%= yeoman.app %>/scripts/main.js'
                }
            }
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '!<%= yeoman.dist %>/styles/slate.min.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{gif,jpeg,jpg,png,webp}',
//                        '<%= yeoman.dist %>/styles/fonts/{,*/}*.*'
                    ]
                }
            }
        },

        // 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: '<%= yeoman.dist %>'
            },
            html: '.tmp/index.html'
        },

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

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{gif,jpeg,jpg,png}',
                    dest: '<%= yeoman.dist %>/images'
                }, {
                  expand: true,
                  cwd: '<%= yeoman.app %>/bower_components/select2',
                  src: '*.{gif,png}',
                  dest: '<%= yeoman.dist %>/styles'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        htmlmin: {
            dist: {
                options: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeCommentsFromCDATA: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: '{,*/}*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        cssmin: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/styles/exports.css': [
                        '.tmp/styles/exports.css'
                    ]
                }
            }
        },
        // uglify: {
        //     dist: {
        //         files: {
        //             '<%= yeoman.dist %>/scripts/scripts.js': [
        //                 '<%= yeoman.dist %>/scripts/scripts.js'
        //             ]
        //         }
        //     }
        // },
        // concat: {
        //     dist: {}
        // },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{config,php}',
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'bower_components/zeroclipboard/dist/ZeroClipboard.swf',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'scripts/disqus-count.js',
                        'styles/slate.min.css',
                        'styles/*.{gif,png}',
                        'styles/fonts/{,*/}*.*',
                        'vendor/knplabs/knp-snappy/src/**/*.php',
                        'bower_components/font-awesome/fonts/*.*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp',
                    dest: '<%= yeoman.dist %>',
                    src: 'index.html'
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            },
            tmp: {
                expand: true,
                cwd: '<%= yeoman.app %>',
                dest: '.tmp',
                src: [
                    'bower_components/qtip2/jquery.qtip.css',
                    'bower_components/select2/select2.css',
                    'index.html'
                ]
            }
        },

        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [
                'browserify',
                'compass:server',
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'browserify',
                'compass',
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        },
        rsync: {
            options: {
                args: ['-cruv']
            },
            'nusmods.com': {
                options: {
                    src: '<%= yeoman.dist %>/*',
                    dest: '~/nusmods.com'
                }
            }
        }
    });

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

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', function () {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve']);
    });

    grunt.registerTask('test', function(target) {
        if (target !== 'watch') {
            grunt.task.run([
                'clean:server',
                'concurrent:test',
                'autoprefixer'
            ]);
        }

        grunt.task.run([
            'connect:test',
            'mocha'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'copy:tmp',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'cssmin',
        'uglify',
        'copy:dist',
        'rev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        // 'newer:jshint',
        // 'test',
        'build'
    ]);
};
<|endoftext|>


<commit_before>export function cssSupports (property, value) {
  if (CSS) {
    return CSS.supports(property, value)
  }

  return toCamelCase(property) in document.body.style
}

export function toCamelCase (cssProperty) {
  cssProperty = cssProperty
    .split('-')
    .filter(word => !!word)
    .map(word => word[0].toUpperCase() + word.substr(1))
    .join('')

  return cssProperty[0].toLowerCase() + cssProperty.substr(1)
}
<commit_msg>fix: Modify css support check to work better with SSR<commit_after>export function cssSupports (property, value) {
  if (typeof CSS !== 'undefined') {
    return CSS.supports(property, value)
  }

  if (typeof document === 'undefined') {
    return false;
  }

  return toCamelCase(property) in document.body.style
}

export function toCamelCase (cssProperty) {
  cssProperty = cssProperty
    .split('-')
    .filter(word => !!word)
    .map(word => word[0].toUpperCase() + word.substr(1))
    .join('')

  return cssProperty[0].toLowerCase() + cssProperty.substr(1)
}
<|endoftext|>


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

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

    // Compiles our Sass
    sass: {
      options: {
        precision: 6,
        sourceComments: false,
        outputStyle: 'compressed'
      },
      dist: {
        files: {
          'css/primer.css': 'scss/primer.scss'
        }
      }
    },

    // Handle vendor prefixing
    postcss: {
      options: {
        processors: [
          require('autoprefixer-core')({ browsers: 'last 2 versions' }),
        ]
      },
      dist: {
        src: 'css/*.css'
      },
      docs: {
        src: '_site/*.css'
      }
    },

    // Runs CSS reporting
    parker: {
      options: {
        metrics: [
          'TotalStylesheets',
          'TotalStylesheetSize',
          'TotalRules',
          'TotalSelectors',
          'TotalIdentifiers',
          'TotalDeclarations',
          'SelectorsPerRule',
          'IdentifiersPerSelector',
          'SpecificityPerSelector',
          'TopSelectorSpecificity',
          'TopSelectorSpecificitySelector',
          'TotalIdSelectors',
          'TotalUniqueColours',
          'TotalImportantKeywords',
          'TotalMediaQueries'
        ],
        file: "css/.primer-stats.md",
        usePackage: true
      },
      src: [
        'css/*.css'
      ],
    },

    // Build tooling

    watch: {
      sass: {
        files: ['scss/**/*.scss', 'docs/docs.scss'],
        tasks: ['sass', 'postcss', 'parker']
      }
    },

    jekyll: {
      options: {
        src: 'docs',
        dest: '_site',
        config: '_config.yml'
      }
    },

    buildcontrol: {
      options: {
        dir: '_site',
        commit: true,
        push: true,
        message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
      },
      pages: {
        options: {
          remote: 'git@github.com:primer/primer.git',
          branch: 'gh-pages'
        }
      }
    }
  });

  // Load dependencies
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-build-control');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-jekyll');
  grunt.loadNpmTasks('grunt-parker');
  grunt.loadNpmTasks('grunt-sass');

  // Generate and format the CSS
  grunt.registerTask('default', ['sass', 'jekyll', 'postcss', 'parker']);

  // Publish to GitHub
  grunt.registerTask('publish', ['jekyll', 'postcss:docs', 'buildcontrol:pages']);
};
<commit_msg>shoutout to @jonrohan, my guardian angel<commit_after>module.exports = function(grunt) {

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

    // Compiles our Sass
    sass: {
      options: {
        precision: 6,
        sourceComments: false,
        outputStyle: 'compressed'
      },
      dist: {
        files: {
          'css/primer.css': 'scss/primer.scss'
        }
      }
    },

    // Handle vendor prefixing
    postcss: {
      options: {
        processors: [
          require('autoprefixer-core')({ browsers: ['last 2 versions', 'ie 8', 'ie 9'] }),
        ]
      },
      dist: {
        src: 'css/*.css'
      },
      docs: {
        src: '_site/*.css'
      }
    },

    // Runs CSS reporting
    parker: {
      options: {
        metrics: [
          'TotalStylesheets',
          'TotalStylesheetSize',
          'TotalRules',
          'TotalSelectors',
          'TotalIdentifiers',
          'TotalDeclarations',
          'SelectorsPerRule',
          'IdentifiersPerSelector',
          'SpecificityPerSelector',
          'TopSelectorSpecificity',
          'TopSelectorSpecificitySelector',
          'TotalIdSelectors',
          'TotalUniqueColours',
          'TotalImportantKeywords',
          'TotalMediaQueries'
        ],
        file: "css/.primer-stats.md",
        usePackage: true
      },
      src: [
        'css/*.css'
      ],
    },

    // Build tooling

    watch: {
      sass: {
        files: ['scss/**/*.scss', 'docs/docs.scss'],
        tasks: ['sass', 'postcss', 'parker']
      }
    },

    jekyll: {
      options: {
        src: 'docs',
        dest: '_site',
        config: '_config.yml'
      }
    },

    buildcontrol: {
      options: {
        dir: '_site',
        commit: true,
        push: true,
        message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
      },
      pages: {
        options: {
          remote: 'git@github.com:primer/primer.git',
          branch: 'gh-pages'
        }
      }
    }
  });

  // Load dependencies
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-build-control');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-jekyll');
  grunt.loadNpmTasks('grunt-parker');
  grunt.loadNpmTasks('grunt-sass');

  // Generate and format the CSS
  grunt.registerTask('default', ['sass', 'jekyll', 'postcss', 'parker']);

  // Publish to GitHub
  grunt.registerTask('publish', ['jekyll', 'postcss:docs', 'buildcontrol:pages']);
};
<|endoftext|>


<commit_before>/**
 * ng-scaffold
 * Grunt task runner configuration.
 */

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

    // load all required Grunt plugins listed in package.json
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // display the elapsed execution time of all tasks
    require('time-grunt')(grunt);

   /**
    * Register custom tasks.
    */
    // Create build
    grunt.registerTask('build', [
        'clean:dist',
        'clean:release',
        'copy:build',
        'modernizr',
        'concat',
        'recess',
        'uglify'
    ]);

    // Development build
    // with linting,
    // but no tests
    grunt.registerTask('dev', [
        'jshint:dev',
        'plato:dev',
        'build',
        'jshint:afterconcat',
    ]);

    // Run and autowatch development build
    // on lokal serverlivereload
    // (linting included, no tests)
    grunt.registerTask('dev-server', [
        'dev',
        'connect:dev',
        'watch:dev'
    ]);

    // Run and autowatch unit tests
    // on development build
    // with Karma
    // (linting included)
    grunt.registerTask('dev-test', [
        'dev',
        'watch:test'
    ]);

    // Release build
    // with linting and
    // running all tests
    grunt.registerTask('release', 'Release build', function () {
        grunt.task.run(
            'jshint:release',
            'build',
            'karma:unit',
            'jshint:afterconcat',
            'clean:unmin',
            'copy:release',
            'clean:dist',
            'connect:testRelease',
            'karma:e2e'
        );

        // set suffix for minified files to '.min'
        grunt.config.set('meta.minSuffix', '.min');
    });

    // Start and open release server
    // (no build, no linting, no tests)
    grunt.registerTask('release-server', [
        'connect:release'
    ]);

    // Run unit and e2e tests
    // on build
    // with Karma
    // (no linting, no autowatch)
    grunt.registerTask('test', [
        'build',
        'karma:unit',
        'connect:testDev',
        'karma:e2e'
    ]);

   /**
    * Configure tasks.
    */
    grunt.initConfig({
        // get npm config
        pkg: grunt.file.readJSON('package.json'),

        // define meta data
        meta: {
            // This is a file suffix for minified sources like jquery.min.js;
            // the default value is an empty string;
            // this suffix is set to '.min' inside the release task;
            // it's used as a template variable inside index.html;
            // based on this variable the minified sources for the release task,
            // or the unminified files for the build and development tasks are loaded.
            //
            minSuffix: '',
            // doc block for the concatinated and compiled files
            banner:
                '/**\n' +
                ' * <%= pkg.name %> v<%= pkg.version %>\n' +
                ' * <%= pkg.homepage %>\n' +
                ' *\n' +
                ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
                ' * Released under the <%= pkg.licenses[0].type %> license\n' +
                ' * <%= pkg.licenses[0].url %>\n' +
                ' *\n' +
                ' * Date: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
                ' */\n',

            // strict mode string
            strict: '\'use strict\';\n\n'
        },

        /**
         * dev + release tasks: jshint, palato, karma
         */
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                ignores: ['dist/lib/*', 'dist/src/**/*.min.js']
            },
            dev: [
                'src/**/*.js',
                'test/**/*.spec.js',
                'test/**/*.scenario.js',
                'test/**/*.conf.js',
                'Gruntfile.js'
            ],
            release: [
                'src/**/*.js',
            ],
            afterconcat: [
                'dist/src/**/*.js'
            ]
        },

        plato: {
            dev: {
                options: {
                    jshint: grunt.file.readJSON('.jshintrc')
                },
                files: {
                    'reports': [
                        'src/**/*.js',
                        'test/unit/**/*.js',
                        'test/e2e/**/*.js'
                    ],
                }
            },
        },

        karma: {
            unit: {
                configFile: 'test/config/karma.unit.conf.js',
                autoWatch: false,
                singleRun: true
            },
            e2e: {
                configFile: 'test/config/karma.e2e.conf.js',
                autoWatch: false,
                singleRun: true
            },
            dev: {
                configFile: 'test/config/karma.unit.conf.js',
                browsers: ['PhantomJS'], // Only PhantomJS!
                autoWatch: false,
                singleRun: true
            },
            watch: {
                configFile: 'test/config/karma.unit.conf.js',
                browsers: ['PhantomJS'], // Only PhantomJS!
                autoWatch: true,
                singleRun: false
            }
        },

        /**
         * dev tasks: watch, connect, open
         */
        watch: {
            dev: {
                options: {
                    livereload: true,
                    spawn: false
                },
                files: [
                    'src/index.html',
                    'src/app/**/*.tpl.html',
                    'src/common/**/*.tpl.html',
                    'src/less/*.less',
                    'src/**/*.js',
                    'Gruntfile.js',
                    'bower.json'
                ],
                tasks: [
                    'dev'
                ]
            },
            test: {
                options: {
                    spawn: false
                },
                files: [
                    'src/**/*.js',
                    'test/**/*.spec.js',
                    'test/**/*unit.conf.js'
                ],
                tasks: [
                    'dev',
                    'karma:dev'
                ]
            }
        },

        connect: {
            options: {
                hostname: 'localhost',
                port: 8080
            },
            dev: {
                options: {
                    base: 'dist/',
                    open: true,
                    middleware: function (connect, options) {
                        return [
                            require('connect-livereload')(),
                            connect.static(options.base)
                        ];
                    }
                }
            },
            release: {
                options: {
                    base: 'release/',
                    keepalive: true,
                    open: true,
                    middleware: function (connect, options) {
                        return [
                            connect.static(options.base)
                        ];
                    }
                }
            },
            testDev: {
                options: {
                    base: 'dist/',
                    middleware: function (connect, options) {
                        return [
                            connect.static(options.base)
                        ];
                    }
                }
            },
            testRelease: {
                options: {
                    base: 'release/',
                    middleware: function (connect, options) {
                        return [
                            connect.static(options.base)
                        ];
                    }
                }
            }
        },

        open: {
            dev: {
                path: 'http://localhost:8888/'
            },
            release: {
                path: 'http://localhost:8080/'
            }
        },

        /**
         * build tasks: clean, copy, modernizr, concat, recess, uglify
         */
        clean: {
            // delete dist folder
            dist: ['dist'],
            // delete release folder
            release: ['release'],
            // delete all unminified sources from dist/
            unmin: [
                'dist/src/app.js',
                'dist/lib/angular.js',
                'dist/lib/angular-route.js',
                'dist/lib/bootstrap.js',
                'dist/lib/jquery.js',
                'dist/lib/modernizr.js'
            ]
        },

        copy: {
            build: {
                files: [{
                    // copy index.html, robots.txt, license.txt
                    cwd: 'src',
                    src : ['*.txt'],
                    dest: 'dist',
                    expand: true
                }, {
                    // copy angular templates
                    src: [
                        'src/app/**/*.tpl.html',
                        'src/common/**/*.tpl.html'
                    ],
                    dest: 'dist/src/tpl/',
                    expand: true,
                    flatten: true
                }, {
                    // copy content of asset dir
                    cwd: 'src/asset',
                    src : '**',
                    dest: 'dist',
                    expand: true,
                }, {
                    // copy vendor: Bootstrap (fonts)
                    cwd: 'vendor/bootstrap/',
                    src : 'fonts/*',
                    dest: 'dist',
                    expand: true
                }, {
                    // copy vendor: Bootstrap (css)
                    cwd: 'vendor/bootstrap/dist/css',
                    src : ['bootstrap.css', 'bootstrap.min.css'],
                    dest: 'dist/css',
                    expand: true
                }, {
                    // copy vendor: Bootstrap (js)
                    cwd: 'vendor/bootstrap/dist/js',
                    src : ['*.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: Angular
                    cwd: 'vendor/angular/',
                    src : ['angular.js', 'angular.min.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: Angular-Route
                    cwd: 'vendor/angular-route/',
                    src : ['angular-route.js', 'angular-route.min.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: jQuery
                    cwd: 'vendor/jquery/',
                    src : ['jquery.js', 'jquery.min.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: Modernizr
                    src: 'vendor/modernizr/index.js',
                    dest: 'dist/lib/modernizr.js'
                }]
            },
            release: {
                files: [{
                    // copy contents of dist/ to release
                    cwd: 'dist',
                    src : ['**'],
                    dest: 'release',
                    expand: true
                }]
            }
        },

        modernizr: {
            // generate a uglified version of modernizr.js
            'devFile' : 'vendor/modernizr/index.js',
            'outputFile' : 'dist/lib/modernizr.min.js',
            'uglify' : true,
            'tests' : [],
            'parseFiles' : false,
            'matchCommunityTests' : false,
            'customTests' : [],
            // based on default settings on http://modernizr.com/download/
            'extra' : {
                'cssclasses' : true,
                'shiv' : true,
                'printshiv' : true,
                'load' : false,
                'mq' : false
            },
            // based on default settings on http://modernizr.com/download/
            'extensibility' : {
                'addtest' : false,
                'prefixed' : false,
                'teststyles' : false,
                'testprops' : false,
                'testallprops' : false,
                'hasevents' : false,
                'prefixes' : false,
                'domprefixes' : false
            }
        },

        concat: {
            // concat all src/app js files and compiled templates
            index: {
                options: {
                    process: true
                },
                files: {
                    'dist/index.html': ['src/index.html'],
                }
            },
            build: {
                options: {
                    nonull: true,
                    separator: '\n\n',
                    stripBanners: true,
                    // add doc block (banner) and 'use strict' statement
                    banner: '<%= meta.banner %>' + '<%= meta.strict %>',
                    // replace all 'use strict' statements
                    process: function (src) {
                        return  src.replace(
                            /(^|\n)([ \t]*)('use strict'|"use strict");?\s*/g,
                            '$1$2'
                        );
                    },
                },
                files: {
                    'dist/src/app.js': ['src/**/*.js'],
                }
            }
        },

        recess: {
            options: {
                noIDs: false,
                noJSPrefix: false,
                noOverqualifying: false
            },
            compile: {
                // lint and compile less files
                files: {
                    'dist/css/app.css': ['src/less/*.less']
                },
                options: {
                    compile: true
                }
            },
            compress: {
                // lint, compile and compress less files
                files: {
                    'dist/css/app.min.css': ['dist/css/app.css']
                },
                options: {
                    compress: true
                }
            }
        },

        uglify: {
            options: {
                mangle: true,
                report: 'min',
                wrap: 'global',
                exportAll: true,
                compress: {
                    dead_code: false,
                    unused: false,
                }
            },
            // app.js
            app: {
                options: {
                    banner: '<%= meta.banner %>'
                },
                files: {
                    'dist/src/app.min.js': ['dist/src/app.js']
                }
            }
        },
    });
};
<commit_msg>Fixed bug; failed to copy bootstrap fonts to dist folder.<commit_after>/**
 * ng-scaffold
 * Grunt task runner configuration.
 */

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

    // load all required Grunt plugins listed in package.json
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // display the elapsed execution time of all tasks
    require('time-grunt')(grunt);

   /**
    * Register custom tasks.
    */
    // Create build
    grunt.registerTask('build', [
        'clean:dist',
        'clean:release',
        'copy:build',
        'modernizr',
        'concat',
        'recess',
        'uglify'
    ]);

    // Development build
    // with linting,
    // but no tests
    grunt.registerTask('dev', [
        'jshint:dev',
        'plato:dev',
        'build',
        'jshint:afterconcat',
    ]);

    // Run and autowatch development build
    // on lokal serverlivereload
    // (linting included, no tests)
    grunt.registerTask('dev-server', [
        'dev',
        'connect:dev',
        'watch:dev'
    ]);

    // Run and autowatch unit tests
    // on development build
    // with Karma
    // (linting included)
    grunt.registerTask('dev-test', [
        'dev',
        'watch:test'
    ]);

    // Release build
    // with linting and
    // running all tests
    grunt.registerTask('release', 'Release build', function () {
        grunt.task.run(
            'jshint:release',
            'build',
            'karma:unit',
            'jshint:afterconcat',
            'clean:unmin',
            'copy:release',
            'clean:dist',
            'connect:testRelease',
            'karma:e2e'
        );

        // set suffix for minified files to '.min'
        grunt.config.set('meta.minSuffix', '.min');
    });

    // Start and open release server
    // (no build, no linting, no tests)
    grunt.registerTask('release-server', [
        'connect:release'
    ]);

    // Run unit and e2e tests
    // on build
    // with Karma
    // (no linting, no autowatch)
    grunt.registerTask('test', [
        'build',
        'karma:unit',
        'connect:testDev',
        'karma:e2e'
    ]);

   /**
    * Configure tasks.
    */
    grunt.initConfig({
        // get npm config
        pkg: grunt.file.readJSON('package.json'),

        // define meta data
        meta: {
            // This is a file suffix for minified sources like jquery.min.js;
            // the default value is an empty string;
            // this suffix is set to '.min' inside the release task;
            // it's used as a template variable inside index.html;
            // based on this variable the minified sources for the release task,
            // or the unminified files for the build and development tasks are loaded.
            //
            minSuffix: '',
            // doc block for the concatinated and compiled files
            banner:
                '/**\n' +
                ' * <%= pkg.name %> v<%= pkg.version %>\n' +
                ' * <%= pkg.homepage %>\n' +
                ' *\n' +
                ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
                ' * Released under the <%= pkg.licenses[0].type %> license\n' +
                ' * <%= pkg.licenses[0].url %>\n' +
                ' *\n' +
                ' * Date: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
                ' */\n',

            // strict mode string
            strict: '\'use strict\';\n\n'
        },

        /**
         * dev + release tasks: jshint, palato, karma
         */
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                ignores: ['dist/lib/*', 'dist/src/**/*.min.js']
            },
            dev: [
                'src/**/*.js',
                'test/**/*.spec.js',
                'test/**/*.scenario.js',
                'test/**/*.conf.js',
                'Gruntfile.js'
            ],
            release: [
                'src/**/*.js',
            ],
            afterconcat: [
                'dist/src/**/*.js'
            ]
        },

        plato: {
            dev: {
                options: {
                    jshint: grunt.file.readJSON('.jshintrc')
                },
                files: {
                    'reports': [
                        'src/**/*.js',
                        'test/unit/**/*.js',
                        'test/e2e/**/*.js'
                    ],
                }
            },
        },

        karma: {
            unit: {
                configFile: 'test/config/karma.unit.conf.js',
                autoWatch: false,
                singleRun: true
            },
            e2e: {
                configFile: 'test/config/karma.e2e.conf.js',
                autoWatch: false,
                singleRun: true
            },
            dev: {
                configFile: 'test/config/karma.unit.conf.js',
                browsers: ['PhantomJS'], // Only PhantomJS!
                autoWatch: false,
                singleRun: true
            },
            watch: {
                configFile: 'test/config/karma.unit.conf.js',
                browsers: ['PhantomJS'], // Only PhantomJS!
                autoWatch: true,
                singleRun: false
            }
        },

        /**
         * dev tasks: watch, connect, open
         */
        watch: {
            dev: {
                options: {
                    livereload: true,
                    spawn: false
                },
                files: [
                    'src/index.html',
                    'src/app/**/*.tpl.html',
                    'src/common/**/*.tpl.html',
                    'src/less/*.less',
                    'src/**/*.js',
                    'Gruntfile.js',
                    'bower.json'
                ],
                tasks: [
                    'dev'
                ]
            },
            test: {
                options: {
                    spawn: false
                },
                files: [
                    'src/**/*.js',
                    'test/**/*.spec.js',
                    'test/**/*unit.conf.js'
                ],
                tasks: [
                    'dev',
                    'karma:dev'
                ]
            }
        },

        connect: {
            options: {
                hostname: 'localhost',
                port: 8080
            },
            dev: {
                options: {
                    base: 'dist/',
                    open: true,
                    middleware: function (connect, options) {
                        return [
                            require('connect-livereload')(),
                            connect.static(options.base)
                        ];
                    }
                }
            },
            release: {
                options: {
                    base: 'release/',
                    keepalive: true,
                    open: true,
                    middleware: function (connect, options) {
                        return [
                            connect.static(options.base)
                        ];
                    }
                }
            },
            testDev: {
                options: {
                    base: 'dist/',
                    middleware: function (connect, options) {
                        return [
                            connect.static(options.base)
                        ];
                    }
                }
            },
            testRelease: {
                options: {
                    base: 'release/',
                    middleware: function (connect, options) {
                        return [
                            connect.static(options.base)
                        ];
                    }
                }
            }
        },

        open: {
            dev: {
                path: 'http://localhost:8888/'
            },
            release: {
                path: 'http://localhost:8080/'
            }
        },

        /**
         * build tasks: clean, copy, modernizr, concat, recess, uglify
         */
        clean: {
            // delete dist folder
            dist: ['dist'],
            // delete release folder
            release: ['release'],
            // delete all unminified sources from dist/
            unmin: [
                'dist/src/app.js',
                'dist/lib/angular.js',
                'dist/lib/angular-route.js',
                'dist/lib/bootstrap.js',
                'dist/lib/jquery.js',
                'dist/lib/modernizr.js'
            ]
        },

        copy: {
            build: {
                files: [{
                    // copy index.html, robots.txt, license.txt
                    cwd: 'src',
                    src : ['*.txt'],
                    dest: 'dist',
                    expand: true
                }, {
                    // copy angular templates
                    src: [
                        'src/app/**/*.tpl.html',
                        'src/common/**/*.tpl.html'
                    ],
                    dest: 'dist/src/tpl/',
                    expand: true,
                    flatten: true
                }, {
                    // copy content of asset dir
                    cwd: 'src/asset',
                    src : '**',
                    dest: 'dist',
                    expand: true,
                }, {
                    // copy vendor: Bootstrap (fonts)
                    cwd: 'vendor/bootstrap/dist/fonts',
                    src : ['*'],
                    dest: 'dist/fonts',
                    expand: true
                }, {
                    // copy vendor: Bootstrap (css)
                    cwd: 'vendor/bootstrap/dist/css',
                    src : ['bootstrap.css', 'bootstrap.min.css'],
                    dest: 'dist/css',
                    expand: true
                }, {
                    // copy vendor: Bootstrap (js)
                    cwd: 'vendor/bootstrap/dist/js',
                    src : ['*.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: Angular
                    cwd: 'vendor/angular/',
                    src : ['angular.js', 'angular.min.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: Angular-Route
                    cwd: 'vendor/angular-route/',
                    src : ['angular-route.js', 'angular-route.min.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: jQuery
                    cwd: 'vendor/jquery/',
                    src : ['jquery.js', 'jquery.min.js'],
                    dest: 'dist/lib',
                    expand: true
                }, {
                    // copy vendor: Modernizr
                    src: 'vendor/modernizr/index.js',
                    dest: 'dist/lib/modernizr.js'
                }]
            },
            release: {
                files: [{
                    // copy contents of dist/ to release
                    cwd: 'dist',
                    src : ['**'],
                    dest: 'release',
                    expand: true
                }]
            }
        },

        modernizr: {
            // generate a uglified version of modernizr.js
            'devFile' : 'vendor/modernizr/index.js',
            'outputFile' : 'dist/lib/modernizr.min.js',
            'uglify' : true,
            'tests' : [],
            'parseFiles' : false,
            'matchCommunityTests' : false,
            'customTests' : [],
            // based on default settings on http://modernizr.com/download/
            'extra' : {
                'cssclasses' : true,
                'shiv' : true,
                'printshiv' : true,
                'load' : false,
                'mq' : false
            },
            // based on default settings on http://modernizr.com/download/
            'extensibility' : {
                'addtest' : false,
                'prefixed' : false,
                'teststyles' : false,
                'testprops' : false,
                'testallprops' : false,
                'hasevents' : false,
                'prefixes' : false,
                'domprefixes' : false
            }
        },

        concat: {
            // concat all src/app js files and compiled templates
            index: {
                options: {
                    process: true
                },
                files: {
                    'dist/index.html': ['src/index.html'],
                }
            },
            build: {
                options: {
                    nonull: true,
                    separator: '\n\n',
                    stripBanners: true,
                    // add doc block (banner) and 'use strict' statement
                    banner: '<%= meta.banner %>' + '<%= meta.strict %>',
                    // replace all 'use strict' statements
                    process: function (src) {
                        return  src.replace(
                            /(^|\n)([ \t]*)('use strict'|"use strict");?\s*/g,
                            '$1$2'
                        );
                    },
                },
                files: {
                    'dist/src/app.js': ['src/**/*.js'],
                }
            }
        },

        recess: {
            options: {
                noIDs: false,
                noJSPrefix: false,
                noOverqualifying: false
            },
            compile: {
                // lint and compile less files
                files: {
                    'dist/css/app.css': ['src/less/*.less']
                },
                options: {
                    compile: true
                }
            },
            compress: {
                // lint, compile and compress less files
                files: {
                    'dist/css/app.min.css': ['dist/css/app.css']
                },
                options: {
                    compress: true
                }
            }
        },

        uglify: {
            options: {
                mangle: true,
                report: 'min',
                wrap: 'global',
                exportAll: true,
                compress: {
                    dead_code: false,
                    unused: false,
                }
            },
            // app.js
            app: {
                options: {
                    banner: '<%= meta.banner %>'
                },
                files: {
                    'dist/src/app.min.js': ['dist/src/app.js']
                }
            }
        },
    });
};
<|endoftext|>


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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        process: true
      },
      dist: {
        src: ['src/header.js', 'src/stacktrace.js', 'src/notifier.js', 'src/footer.js'],
        dest: 'tmp/concat-dist.js'
      }
    },
    browserify: {
      legacy: {
        src: ['<%= concat.dist.dest %>'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    jshint: {
      files: ['gruntfile.js', 'src/notifier.js', 'src/stacktrace.js', 'test/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          jQuery: true,
          console: true,
          module: true,
          document: true
        }
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'test/**/*.coffee'],
      tasks: ['test']
    },
    mochacli: {
      all: ['test/**/*.coffee'],
      options: {
        // require: ['should'],
        compilers: [ 'coffee:coffee-script' ],
        files: 'test/**/*.coffee',
        bail: true,
        reporter: 'spec'
      }
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-mocha-cli');

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

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

};
<commit_msg>Watch and lint formatters<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        process: true
      },
      dist: {
        src: ['src/header.js', 'src/stacktrace.js', 'src/notifier.js', 'src/footer.js'],
        dest: 'tmp/concat-dist.js'
      }
    },
    browserify: {
      legacy: {
        src: ['<%= concat.dist.dest %>'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    jshint: {
      files: ['gruntfile.js', 'src/notifier.js', 'src/stacktrace.js', 'src/formatters/**/*.js', 'test/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          jQuery: true,
          console: true,
          module: true,
          document: true
        }
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'test/**/*.coffee'],
      tasks: ['test']
    },
    mochacli: {
      all: ['test/**/*.coffee'],
      options: {
        // require: ['should'],
        compilers: [ 'coffee:coffee-script' ],
        files: 'test/**/*.coffee',
        bail: true,
        reporter: 'spec'
      }
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-mocha-cli');

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

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

};
<|endoftext|>


<commit_before>var path = require('path');

module.exports = function (grunt) {
  // load all grunt tasks matching the `grunt-*` pattern
  require('load-grunt-tasks')(grunt);

  var appconf = {
    dist: {
      public: "./public/dist/scripts",
      admin: "./public/dist/scripts/admin"
    }
  };

  grunt.initConfig({
    anyandgo: appconf,
	jshint: {
      options: {
        reporter: require('jshint-stylish'),
        // https://gist.github.com/haschek/2595796
        jshintrc: './.jshintrc'
      },
	  all: ['Grunfile.js', 'routes/*.js',
      "models/*js", "forms/*js", 'test/**/*.js']
    },
    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/unit/**/*.js']
      }
    },
    watch: {
      scripts: {
        options: { livereload: 35729 },
        files: ['./app.js', './Gruntfile.js', './bin/www',
        './models/*.js', './routes/*.js', './forms/*.js'],
        tasks: ['jshint','mochaTest','docco'],
        options: {
            debounceDelay: 750
        }
      },
      tests: {
        options: { livereload: 35729 },
        files: ['./test/**/*.js'],
        tasks: ['mochaTest', 'docco']
      },
      public: {
        files: ['./public/**/*', './views/**/*.jade', './views/**/*.styl'],
        options: {
            debounceDelay: 750,
            livereload: 35729
        },
        task: ['']
      },
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      }
    },
    nodemon: {
      dev: {
            script: './bin/www',
            options: {
                ignore: ['node_modules/**', 'public/js/**/*'],
                callback: function (nodemon) {
                    // opens browser on initial server start
                    nodemon.on('config:update', function () {
                      // Delay before server listens on port
                      setTimeout(function() {
                        require('open')('http://localhost:3000/');
                      }, 3000);
                    });
                }
            }
      }
    },
    docco: {
      debug: {
        src: ['test/**/*.js','models/*.js','routes/*.js'],
        options: {
          output: 'docs/'
        }
      }
    },
    wiredep: {
      target: {
        src: ['views/layout-admin.jade'],
        ignorePath: '../public'
      },
      options: {
        overrides: {
          "directory": "./bower_components/"
        }
      }
    },
    concurrent: {
      dev: {
        tasks: ['nodemon', 'watch'],
        options: {
          logConcurrentOutput: true,
          limit: 5
        }
      },
      test: ['mochaTest']
    },
    clean: {
      public: './public/dist/{,*/}*',
      temporal: '.tmp'
    },
    useminPrepare: {
        html: 'views/**/*.jade',
        options: {
            dest: './public/dist/',
            flow: {
                html: {
                    steps: {
                        js: ['concat', 'uglifyjs'],
                        css: ['cssmin']
                    },
                    post: {
                        js: [{
                          name: 'uglify',
                          createConfig: function (context, block) {
                            var generated = context.options.generated;
                            generated.options = {
                              mangle: false
                              /*
                              http://mathieuhicauber-java.blogspot.com.ar/2013/12/grunt-uglify-task-breaks-angular-app.html
                              http://stackoverflow.com/questions/21688681/unknown-provider-aprovider-a-how-do-i-find-the-original-provider
                              http://stackoverflow.com/a/20945907/467034
                              */
                            };
                          }
                        }]
                    }
                }
            }
        }
    }
  });

  grunt.registerTask('buildprod', [
    'clean:public',
    //copy styles to .tmp
    'useminPrepare',
    //generates new task configs: concat, uglify
    'concat',
    'uglify',
    'cssmin'
  ]);

  grunt.task.registerTask('create', 'Create mongoose model + test', function(arg1, arg2) {
      grunt.log.debug(arg1, arg2);
      switch(arg1){
        case 'model':
            if(typeof arg2 !== 'undefined') {
              // create model
              var filemodel = grunt.template.process(grunt.file.read('./templates/mongoose-model.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './models/'+arg2.toLowerCase()+'.js';
              grunt.file.write(filename, filemodel);

              // create test
              var filetest = grunt.template.process(grunt.file.read('./templates/mongoose-model-tests.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenametest = './test/unit/models/'+arg2.toLowerCase()+'-tests.js';
              grunt.file.write(filenametest, filetest);

              // append model to ./routes/main.js
              var appendm = grunt.template.process(grunt.file.read('./templates/append-model-routes-main.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              var regexpm = new RegExp(".*"+appendm.replace("(", "\\(").replace(")","\\)")+".*");
              if(!mainroutes.match(regexpm)){
                  grunt.file.write(filename,
                      mainroutes.replace("/* models:end */",appendm+"  /* models:end */"));
              }

              // register model in ./routes/main.js
              var appendm = grunt.template.process(grunt.file.read('./templates/append-model-registration.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              var regexpm = new RegExp(".*"+appendm.replace("(", "\\(").replace(")","\\)")+".*");
              if(!mainroutes.match(regexpm)){
                  grunt.file.write(filename,
                      mainroutes.replace("/* models:registration:end */",appendm));
              }

            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'page':
            if(typeof arg2 !== 'undefined') {
              // create model
              var filepage = grunt.template.process(grunt.file.read('./templates/view-page.jade.tpl'), {
                    data: {
                        'pagename': arg2
                    }
              });
              var filename = './views/'+arg2.toLowerCase()+'.jade';
              grunt.file.write(filename, filepage);

              // append page route to ./routes/main.js
              var appendp = grunt.template.process(grunt.file.read('./templates/append-page-routes-main.tpl'), {
                    data: {
                        'pagename': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("/* page:public:end */",appendp+"/* page:public:end */"));

              // append page link to ./views/partials/site-menu.jade
              var appendm = grunt.template.process(grunt.file.read('./templates/append-site-menu-item.tpl'), {
                    data: {
                        'pagename': arg2
                    }
              });
              var filename = './views/partials/site-menu.jade';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("// public:page:menu:end",appendm));
            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'crud':
            if(typeof arg2 !== 'undefined') {
              // create Front-end files
              var feFilesRoot = {
                "templates" : "./templates/crud/admin/controllers/",
                "destination" : "./public/scripts/admin/controllers/"
              };
              var feFiles = {
                  "model-edit-js.tpl" : "<%=modelname%>-edit.js",
                  "model-new-js.tpl" : "<%=modelname%>-new.js",
                  "model-js.tpl" : "<%=modelname%>.js",
                  "../views/model-html.tpl" : "../views/<%=modelname%>.html"
              };

              for(var i in feFiles){
                  var filefetemp = feFilesRoot.templates+i;
                  var filefe = grunt.template.process(grunt.file.read(filefetemp), {
                        data: {
                            'modelname': arg2
                        }
                  });
                  var filenamefe = feFilesRoot.destination+feFiles[i].replace("<%=modelname%>",arg2.toLowerCase());
                  grunt.file.write(filenamefe, filefe);
              }
              // append Front-end files
              var appendfe = grunt.template.process(grunt.file.read('./templates/crud/admin-crud-scripts-append.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenamefe = './views/admin-panel.jade';
              var mainfe = grunt.file.read(filenamefe);
              grunt.file.write(filenamefe, mainfe.replace("//admin:crud:scripts:end",appendfe));
              // append CRUD menu into admin
              var appendcmenu = grunt.template.process(grunt.file.read('./templates/crud/admin-crud-menu-append.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenamecmenu = './views/partials/admin-menu.jade';
              var maincmenu = grunt.file.read(filenamecmenu);
              grunt.file.write(filenamecmenu, maincmenu.replace("//admin:crud:menu:end",appendcmenu));
              // append routes to ./public/scripts/admin/app.js
              var appendcroute = grunt.template.process(grunt.file.read('./templates/crud/admin/app-route-append.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenamecroute = './public/scripts/admin/app.js';
              var maincroute = grunt.file.read(filenamecroute);
              grunt.file.write(filenamecroute, maincroute.replace(".otherwise({",appendcroute));

              // create tests

              /*
              var appendp = grunt.template.process(grunt.file.read('./templates/append-model-rest-main.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              */
              //grunt.file.write(filename, mainroutes.replace("/* rest:public:end */",appendp));

              /*
              // create test
              var filetest = grunt.template.process(grunt.file.read('./templates/mongoose-model-rest-tests.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenametest = './test/rest/models/'+arg2.toLowerCase()+'s-rest-tests.js';
              grunt.file.write(filenametest, filetest);
              */
            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'rest':
            if(typeof arg2 !== 'undefined') {
              // append rest to ./routes/main.js
              var appendp = grunt.template.process(grunt.file.read('./templates/append-model-rest-main.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("/* rest:public:end */",appendp));

              // create test
              var filetest = grunt.template.process(grunt.file.read('./templates/mongoose-model-rest-tests.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenametest = './test/rest/models/'+arg2.toLowerCase()+'s-rest-tests.js';
              grunt.file.write(filenametest, filetest);
            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'locale':
            if(typeof arg2 !== 'undefined') {
              // append locale to ./apps.js
              var appendp = "'"+arg2.toLowerCase()+"',\n      //global:translation:end"
              var filename = './app.js';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("//global:translation:end",appendp));

              // append page link to ./views/partials/site-menu.jade
              var appendm = "li\n";
                  appendm += "              a(href='#', langsupport='"+arg2.toLowerCase()+"') "+arg2.toLowerCase()+"\n";
                  appendm += "            //public:translation:menu:end";

              var filename = './views/partials/site-menu.jade';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("//public:translation:menu:end",appendm));

            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
      }
  });

  grunt.registerTask('default', ['jshint', 'concurrent']);
};
<commit_msg>Reduce the amount of watched files<commit_after>var path = require('path');

module.exports = function (grunt) {
  // load all grunt tasks matching the `grunt-*` pattern
  require('load-grunt-tasks')(grunt);

  var appconf = {
    dist: {
      public: "./public/dist/scripts",
      admin: "./public/dist/scripts/admin"
    }
  };

  grunt.initConfig({
    anyandgo: appconf,
	jshint: {
      options: {
        reporter: require('jshint-stylish'),
        // https://gist.github.com/haschek/2595796
        jshintrc: './.jshintrc'
      },
	  all: ['Grunfile.js', 'routes/*.js',
      "models/*js", "forms/*js", 'test/**/*.js']
    },
    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/unit/**/*.js']
      }
    },
    watch: {
      scripts: {
        options: { livereload: 35729 },
        files: ['./app.js', './Gruntfile.js', './bin/www',
        './models/*.js', './routes/*.js', './forms/*.js'],
        tasks: ['jshint','mochaTest','docco'],
        options: {
            debounceDelay: 750
        }
      },
      tests: {
        options: { livereload: 35729 },
        files: ['./test/**/*.js'],
        tasks: ['mochaTest', 'docco']
      },
      public: {
        files: ['./public/scripts/**/*', './public/css/**/*', './views/**/*.jade', './views/**/*.styl'],
        options: {
            debounceDelay: 750,
            livereload: 35729
        },
        task: ['']
      },
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      }
    },
    nodemon: {
      dev: {
            script: './bin/www',
            options: {
                ignore: ['node_modules/**', 'public/js/**/*'],
                callback: function (nodemon) {
                    // opens browser on initial server start
                    nodemon.on('config:update', function () {
                      // Delay before server listens on port
                      setTimeout(function() {
                        require('open')('http://localhost:3000/');
                      }, 3000);
                    });
                }
            }
      }
    },
    docco: {
      debug: {
        src: ['test/**/*.js','models/*.js','routes/*.js'],
        options: {
          output: 'docs/'
        }
      }
    },
    wiredep: {
      target: {
        src: ['views/layout-admin.jade'],
        ignorePath: '../public'
      },
      options: {
        overrides: {
          "directory": "./bower_components/"
        }
      }
    },
    concurrent: {
      dev: {
        tasks: ['nodemon', 'watch'],
        options: {
          logConcurrentOutput: true,
          limit: 5
        }
      },
      test: ['mochaTest']
    },
    clean: {
      public: './public/dist/{,*/}*',
      temporal: '.tmp'
    },
    useminPrepare: {
        html: 'views/**/*.jade',
        options: {
            dest: './public/dist/',
            flow: {
                html: {
                    steps: {
                        js: ['concat', 'uglifyjs'],
                        css: ['cssmin']
                    },
                    post: {
                        js: [{
                          name: 'uglify',
                          createConfig: function (context, block) {
                            var generated = context.options.generated;
                            generated.options = {
                              mangle: false
                              /*
                              http://mathieuhicauber-java.blogspot.com.ar/2013/12/grunt-uglify-task-breaks-angular-app.html
                              http://stackoverflow.com/questions/21688681/unknown-provider-aprovider-a-how-do-i-find-the-original-provider
                              http://stackoverflow.com/a/20945907/467034
                              */
                            };
                          }
                        }]
                    }
                }
            }
        }
    }
  });

  grunt.registerTask('buildprod', [
    'clean:public',
    //copy styles to .tmp
    'useminPrepare',
    //generates new task configs: concat, uglify
    'concat',
    'uglify',
    'cssmin'
  ]);

  grunt.task.registerTask('create', 'Create mongoose model + test', function(arg1, arg2) {
      grunt.log.debug(arg1, arg2);
      switch(arg1){
        case 'model':
            if(typeof arg2 !== 'undefined') {
              // create model
              var filemodel = grunt.template.process(grunt.file.read('./templates/mongoose-model.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './models/'+arg2.toLowerCase()+'.js';
              grunt.file.write(filename, filemodel);

              // create test
              var filetest = grunt.template.process(grunt.file.read('./templates/mongoose-model-tests.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenametest = './test/unit/models/'+arg2.toLowerCase()+'-tests.js';
              grunt.file.write(filenametest, filetest);

              // append model to ./routes/main.js
              var appendm = grunt.template.process(grunt.file.read('./templates/append-model-routes-main.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              var regexpm = new RegExp(".*"+appendm.replace("(", "\\(").replace(")","\\)")+".*");
              if(!mainroutes.match(regexpm)){
                  grunt.file.write(filename,
                      mainroutes.replace("/* models:end */",appendm+"  /* models:end */"));
              }

              // register model in ./routes/main.js
              var appendm = grunt.template.process(grunt.file.read('./templates/append-model-registration.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              var regexpm = new RegExp(".*"+appendm.replace("(", "\\(").replace(")","\\)")+".*");
              if(!mainroutes.match(regexpm)){
                  grunt.file.write(filename,
                      mainroutes.replace("/* models:registration:end */",appendm));
              }

            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'page':
            if(typeof arg2 !== 'undefined') {
              // create model
              var filepage = grunt.template.process(grunt.file.read('./templates/view-page.jade.tpl'), {
                    data: {
                        'pagename': arg2
                    }
              });
              var filename = './views/'+arg2.toLowerCase()+'.jade';
              grunt.file.write(filename, filepage);

              // append page route to ./routes/main.js
              var appendp = grunt.template.process(grunt.file.read('./templates/append-page-routes-main.tpl'), {
                    data: {
                        'pagename': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("/* page:public:end */",appendp+"/* page:public:end */"));

              // append page link to ./views/partials/site-menu.jade
              var appendm = grunt.template.process(grunt.file.read('./templates/append-site-menu-item.tpl'), {
                    data: {
                        'pagename': arg2
                    }
              });
              var filename = './views/partials/site-menu.jade';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("// public:page:menu:end",appendm));
            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'crud':
            if(typeof arg2 !== 'undefined') {
              // create Front-end files
              var feFilesRoot = {
                "templates" : "./templates/crud/admin/controllers/",
                "destination" : "./public/scripts/admin/controllers/"
              };
              var feFiles = {
                  "model-edit-js.tpl" : "<%=modelname%>-edit.js",
                  "model-new-js.tpl" : "<%=modelname%>-new.js",
                  "model-js.tpl" : "<%=modelname%>.js",
                  "../views/model-html.tpl" : "../views/<%=modelname%>.html"
              };

              for(var i in feFiles){
                  var filefetemp = feFilesRoot.templates+i;
                  var filefe = grunt.template.process(grunt.file.read(filefetemp), {
                        data: {
                            'modelname': arg2
                        }
                  });
                  var filenamefe = feFilesRoot.destination+feFiles[i].replace("<%=modelname%>",arg2.toLowerCase());
                  grunt.file.write(filenamefe, filefe);
              }
              // append Front-end files
              var appendfe = grunt.template.process(grunt.file.read('./templates/crud/admin-crud-scripts-append.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenamefe = './views/admin-panel.jade';
              var mainfe = grunt.file.read(filenamefe);
              grunt.file.write(filenamefe, mainfe.replace("//admin:crud:scripts:end",appendfe));
              // append CRUD menu into admin
              var appendcmenu = grunt.template.process(grunt.file.read('./templates/crud/admin-crud-menu-append.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenamecmenu = './views/partials/admin-menu.jade';
              var maincmenu = grunt.file.read(filenamecmenu);
              grunt.file.write(filenamecmenu, maincmenu.replace("//admin:crud:menu:end",appendcmenu));
              // append routes to ./public/scripts/admin/app.js
              var appendcroute = grunt.template.process(grunt.file.read('./templates/crud/admin/app-route-append.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenamecroute = './public/scripts/admin/app.js';
              var maincroute = grunt.file.read(filenamecroute);
              grunt.file.write(filenamecroute, maincroute.replace(".otherwise({",appendcroute));

              // create tests

              /*
              var appendp = grunt.template.process(grunt.file.read('./templates/append-model-rest-main.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              */
              //grunt.file.write(filename, mainroutes.replace("/* rest:public:end */",appendp));

              /*
              // create test
              var filetest = grunt.template.process(grunt.file.read('./templates/mongoose-model-rest-tests.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenametest = './test/rest/models/'+arg2.toLowerCase()+'s-rest-tests.js';
              grunt.file.write(filenametest, filetest);
              */
            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'rest':
            if(typeof arg2 !== 'undefined') {
              // append rest to ./routes/main.js
              var appendp = grunt.template.process(grunt.file.read('./templates/append-model-rest-main.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filename = './routes/main.js';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("/* rest:public:end */",appendp));

              // create test
              var filetest = grunt.template.process(grunt.file.read('./templates/mongoose-model-rest-tests.js.tpl'), {
                    data: {
                        'modelname': arg2
                    }
              });
              var filenametest = './test/rest/models/'+arg2.toLowerCase()+'s-rest-tests.js';
              grunt.file.write(filenametest, filetest);
            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
        case 'locale':
            if(typeof arg2 !== 'undefined') {
              // append locale to ./apps.js
              var appendp = "'"+arg2.toLowerCase()+"',\n      //global:translation:end"
              var filename = './app.js';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("//global:translation:end",appendp));

              // append page link to ./views/partials/site-menu.jade
              var appendm = "li\n";
                  appendm += "              a(href='#', langsupport='"+arg2.toLowerCase()+"') "+arg2.toLowerCase()+"\n";
                  appendm += "            //public:translation:menu:end";

              var filename = './views/partials/site-menu.jade';
              var mainroutes = grunt.file.read(filename);
              grunt.file.write(filename, mainroutes.replace("//public:translation:menu:end",appendm));

            } else {
                grunt.log.warn('Parameter name missing for '+arg1+' task');
            }
        break;
      }
  });

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