<commit_before>/* eslint-env es6 */
/* eslint-disable global-require, no-process-env */
/* eslint quote-props: ["error", "as-needed"] */
/* global module, process, require */

/*!
 * Figuration
 * Copyright 2013-2020 CAST, Inc.
 * Licensed under MIT (https://github.com/cast-org/figuration/blob/master/LICENSE)
 */

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

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

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

    var saucekey = null;
    if (typeof process.env.SAUCE_ACCESS_KEY !== 'undefined') {
        saucekey = process.env.SAUCE_ACCESS_KEY;
    }

    var autoprefixer = require('autoprefixer');
    var flexbugs = require('postcss-flexbugs-fixes');
    var calc = require('postcss-calc');
    var sass = require('node-sass');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        banner: '/*!\n' +
                ' * Figuration (v<%= pkg.version %>)\n' +
                ' * <%= pkg.homepage %>\n' +
                ' * Copyright 2013-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
                ' * Licensed under MIT (https://github.com/cast-org/figuration/blob/master/LICENSE)\n' +
                ' * -----\n' +
                ' * Portions Copyright 2011-<%= grunt.template.today("yyyy") %>  the Bootstrap Authors and Twitter, Inc.\n' +
                ' * Used under MIT License (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n' +
                ' */\n',
        jqueryCheck: 'if (typeof jQuery === \'undefined\') {\n' +
                     '  throw new Error(\'CAST Figuration\\\'s JavaScript requires jQuery\');\n' +
                     '}\n',
        jqueryVersionCheck: '(function($) {\n' +
                            '  var version = $.fn.jquery.split(\' \')[0].split(\'.\');\n' +
                            '  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] >= 4)) {\n' +
                            '    throw new Error(\'CAST Figuration\\\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0\');\n' +
                            '  }\n' +
                            '})(jQuery);\n\n',

        // File definitions
        // ==========
        jsCore: [
            'js/util.js',
            'js/drag.js',
            'js/collapse.js',
            'js/dropdown.js',
            'js/tab.js',
            'js/affix.js',
            'js/tooltip.js',
            'js/popover.js',
            'js/modal.js',
            'js/accordion.js',
            'js/tab-responsive.js',
            'js/slideshow.js',
            'js/scrollspy.js',
            'js/alert.js',
            'js/lazy.js',
            'js/slider.js',
            'js/img-compare.js',
            'js/equalize.js',
            'js/player.js',
            'js/common.js'
        ],

        jsDocs: [
            'site/assets/<%= pkg.versionShort %>/js/vendor/anchor.min.js',
            'site/assets/<%= pkg.versionShort %>/js/vendor/clipboard.min.js',
            'site/assets/<%= pkg.versionShort %>/js/vendor/holder.min.js',
            'site/assets/<%= pkg.versionShort %>/js/src/docs.js'
        ],

        // Task configs
        // ==========
        clean: {
            dist: 'dist',
            docs: 'site/<%= pkg.versionShort %>/dist',
            docscss: 'site/assets/<%= pkg.versionShort %>/css'
        },

        eslint: {
            options: {
                config: '.eslintrc.json',
                reportUnusedDisableDirectives: 'true'
            },
            grunt: {
                options: {
                    config: 'grunt/.eslintrc.json'
                },
                src: ['Gruntfile.js', 'grunt/*.js']
            },
            build: {
                options: {
                    config: 'build/.eslintrc.json'
                },
                src: 'build/*.js'
            },
            core: {
                src: '<%= jsCore %>'
            },
            test: {
                options: {
                    config: 'test/js/unit/.eslintrc.json'
                },
                src: 'test/js/unit/*.js'
            },
            docs : {
                src: ['site/assets/<%= pkg.versionShort %>/js/src/*.js', 'site/assets/<%= pkg.versionShort %>/js/*.js', '!site/assets/<%= pkg.versionShort %>/js/*.min.js']
            }
        },

        concat: {
            options: {
                banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>',
                stripBanners: false
            },
            core: {
                src: '<%= jsCore %>',
                dest: 'dist/js/<%= pkg.name %>.js'
            }
        },

        uglify: {
            options: {
                mangle: true,
                output: {
                    comments: /^!|@preserve|@license|@cc_on/i
                }
            },
            core: {
                src: '<%= concat.core.dest %>',
                dest: 'dist/js/<%= pkg.name %>.min.js'
            },
            docs: {
                src: '<%= jsDocs %>',
                dest: 'site/assets/<%= pkg.versionShort %>/js/docs.min.js'
            }
        },

        copy: {
            docs: {
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: 'site/<%= pkg.versionShort %>/dist/'
            }
        },

        stylelint: {
            options: {
                configFile: '.stylelintrc'
            },
            core: {
                src: ['scss/**/*.scss']
            },
            docs: {
                src: ['site/assets/<%= pkg.versionShort %>/scss/*.scss']
            }
        },

        sass: {
            options: {
                implementation: sass,
                includePaths: ['scss'],
                precision: 6,
                sourceComments: false,
                sourceMap: true,
                outputStyle: 'expanded'
            },
            core: {
                files: {
                    'dist/css/<%= pkg.name %>.css': 'scss/<%= pkg.name %>.scss'
                }
            },
            docs: {
                files: {
                    'site/assets/<%= pkg.versionShort %>/css/docs.css': 'site/assets/<%= pkg.versionShort %>/scss/docs.scss'
                }
            }
        },

        postcss: {
            core: {
                options: {
                    map: true,
                    processors: [flexbugs, calc, autoprefixer]
                },
                src: ['dist/css/*.css', '!dist/css/*.min.css']
            },
            docs: {
                options: {
                    processors: [flexbugs, calc, autoprefixer]
                },
                src: ['site/assets/<%= pkg.versionShort %>/css/*.css', '!site/assets/<%= pkg.versionShort %>/css/*.min.css']
            }
        },

        rtlcss: {
            core: {
                options: {
                    map: {
                        inline: false
                    },
                    opts: {
                        clean: true
                    }
                },
                expand: true,
                cwd: 'dist/css',
                src: ['*.css', '!*.min.css', '!*-rtl.css'],
                dest: 'dist/css',
                ext: '-rtl.css'
            },
            docs: {
                options: {
                    map: {
                        inline: false
                    },
                    opts: {
                        clean: true
                    }
                },
                expand: true,
                cwd: 'site/assets/<%= pkg.versionShort %>/css',
                src: ['*.css', '!*.min.css', '!*-rtl.css'],
                dest: 'site/assets/<%= pkg.versionShort %>/css',
                ext: '-rtl.css'
            }
        },

        cssmin: {
            options: {
                report: 'gzip',
                specialComments: '*',
                sourceMap: true,
                advanced: false
            },
            core: {
                files: [
                    {
                        expand: true,
                        cwd: 'dist/css',
                        src: ['*.css', '!*.min.css'],
                        dest: 'dist/css',
                        ext: '.min.css'
                    }
                ]
            },
            docs: {
                files: [
                    {
                        expand: true,
                        cwd: 'site/assets/<%= pkg.versionShort %>/css',
                        src: ['*.css', '!*.min.css'],
                        dest: 'site/assets/<%= pkg.versionShort %>/css',
                        ext: '.min.css'
                    }
                ]
            }
        },

        htmllint: {
            options: {
                ignore: [
                    'Consider using the "h1" element as a top-level heading only (all "h1" elements are treated as top-level headings by many screen readers and other tools).',
                    'Element "legend" not allowed as child of element "div" in this context. (Suppressing further errors from this subtree.)',
                    'Element "img" is missing required attribute "src".',
                    'The "color" input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.',
                    'The "datetime-local" input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.'
                ]
            },
            docs: {
                src: ['_siteout/**/*.html']
            },
            test: {
                src: ['test/visual/*.html']
            }
        },

        watch: {
            src: {
                files: '<%= eslint.core.src %>',
                tasks: ['eslint:core', 'concat']
            },
            sass: {
                files: 'scss/**/*.scss',
                tasks: ['dist-css', 'docs-dist-css']
            },
            docs: {
                files: 'site/assets/<%= pkg.versionShort %>/scss/**/*.scss',
                tasks: ['docs-dist-css', 'docs']
            }
        },

        run: {
            npmCssLintVarsCore: {
                exec: 'npm run css-lint-vars-core'
            },
            npmCssLintVarsDocs: {
                exec: 'npm run css-lint-vars-docs'
            },
            npmJsTestKarma: {
                exec: 'npm run js-test-karma'
            },
            npmJsTestCloud: {
                exec: 'npm run js-test-cloud'
            },
            npmDocsBuild: {
                exec: 'npm run docs-build'
            },
            npmDocsServe: {
                exec: 'npm run docs-serve'
            },
            npmLinkinator: {
                exec: 'npm run linkinator'
            }
        }
    });

    // Tasks
    // ==========
    // Load required plugins for tasks
    require('load-grunt-tasks')(grunt, {
        scope: 'devDependencies'
    });
    require('time-grunt')(grunt);

    // Default
    grunt.registerTask('default', ['clean:dist', 'test', 'docs-test-html']);

    // Test
    grunt.registerTask('test', ['dist-css', 'dist-js', 'test-css', 'test-js', 'docs-test']);
    grunt.registerTask('test-css', ['stylelint:core', 'run:npmCssLintVarsCore']);
    grunt.registerTask('test-html', ['htmllint:test']);

    // Test - JS subtasks
    var jsTestTasks = ['eslint:core', 'eslint:test', 'eslint:grunt', 'eslint:build'];
    if (saucekey !== null && process.env.TEST_SAUCE === 'true') {
        jsTestTasks.push('run:npmJsTestCloud');
    } else {
        jsTestTasks.push('run:npmJsTestKarma');
    }
    grunt.registerTask('test-js', jsTestTasks);

    // CSS distribution
    grunt.registerTask('dist-css', ['sass:core', 'postcss:core', 'rtlcss:core', 'cssmin:core']);

    // JS distribution
    grunt.registerTask('dist-js', ['concat', 'uglify:core']);

    // Full distribution
    grunt.registerTask('dist', ['clean:dist', 'dist-css', 'dist-js']);

    // Docs tasks
    grunt.registerTask('docs-test-html', ['run:npmDocsBuild', 'htmllint:docs', 'run:npmLinkinator']);
    grunt.registerTask('docs-test-css', ['stylelint:docs', 'run:npmCssLintVarsDocs']);
    grunt.registerTask('docs-dist-css', ['sass:docs', 'postcss:docs', 'rtlcss:docs', 'cssmin:docs']);
    grunt.registerTask('docs-test-js', ['eslint:docs']);
    grunt.registerTask('docs-dist-js', ['uglify:docs']);
    grunt.registerTask('docs-test', ['docs-test-css', 'docs-test-js', 'docs-test-html']);
    grunt.registerTask('docs-dist', ['docs-dist-css', 'docs-dist-js']);
    grunt.registerTask('docs', ['run:npmDocsServe']);
};
<commit_msg>Build: Add docs-dist  to test and dist tasks<commit_after>/* eslint-env es6 */
/* eslint-disable global-require, no-process-env */
/* eslint quote-props: ["error", "as-needed"] */
/* global module, process, require */

/*!
 * Figuration
 * Copyright 2013-2020 CAST, Inc.
 * Licensed under MIT (https://github.com/cast-org/figuration/blob/master/LICENSE)
 */

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

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

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

    var saucekey = null;
    if (typeof process.env.SAUCE_ACCESS_KEY !== 'undefined') {
        saucekey = process.env.SAUCE_ACCESS_KEY;
    }

    var autoprefixer = require('autoprefixer');
    var flexbugs = require('postcss-flexbugs-fixes');
    var calc = require('postcss-calc');
    var sass = require('node-sass');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        banner: '/*!\n' +
                ' * Figuration (v<%= pkg.version %>)\n' +
                ' * <%= pkg.homepage %>\n' +
                ' * Copyright 2013-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
                ' * Licensed under MIT (https://github.com/cast-org/figuration/blob/master/LICENSE)\n' +
                ' * -----\n' +
                ' * Portions Copyright 2011-<%= grunt.template.today("yyyy") %>  the Bootstrap Authors and Twitter, Inc.\n' +
                ' * Used under MIT License (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n' +
                ' */\n',
        jqueryCheck: 'if (typeof jQuery === \'undefined\') {\n' +
                     '  throw new Error(\'CAST Figuration\\\'s JavaScript requires jQuery\');\n' +
                     '}\n',
        jqueryVersionCheck: '(function($) {\n' +
                            '  var version = $.fn.jquery.split(\' \')[0].split(\'.\');\n' +
                            '  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] >= 4)) {\n' +
                            '    throw new Error(\'CAST Figuration\\\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0\');\n' +
                            '  }\n' +
                            '})(jQuery);\n\n',

        // File definitions
        // ==========
        jsCore: [
            'js/util.js',
            'js/drag.js',
            'js/collapse.js',
            'js/dropdown.js',
            'js/tab.js',
            'js/affix.js',
            'js/tooltip.js',
            'js/popover.js',
            'js/modal.js',
            'js/accordion.js',
            'js/tab-responsive.js',
            'js/slideshow.js',
            'js/scrollspy.js',
            'js/alert.js',
            'js/lazy.js',
            'js/slider.js',
            'js/img-compare.js',
            'js/equalize.js',
            'js/player.js',
            'js/common.js'
        ],

        jsDocs: [
            'site/assets/<%= pkg.versionShort %>/js/vendor/anchor.min.js',
            'site/assets/<%= pkg.versionShort %>/js/vendor/clipboard.min.js',
            'site/assets/<%= pkg.versionShort %>/js/vendor/holder.min.js',
            'site/assets/<%= pkg.versionShort %>/js/src/docs.js'
        ],

        // Task configs
        // ==========
        clean: {
            dist: 'dist',
            docs: 'site/<%= pkg.versionShort %>/dist',
            docscss: 'site/assets/<%= pkg.versionShort %>/css'
        },

        eslint: {
            options: {
                config: '.eslintrc.json',
                reportUnusedDisableDirectives: 'true'
            },
            grunt: {
                options: {
                    config: 'grunt/.eslintrc.json'
                },
                src: ['Gruntfile.js', 'grunt/*.js']
            },
            build: {
                options: {
                    config: 'build/.eslintrc.json'
                },
                src: 'build/*.js'
            },
            core: {
                src: '<%= jsCore %>'
            },
            test: {
                options: {
                    config: 'test/js/unit/.eslintrc.json'
                },
                src: 'test/js/unit/*.js'
            },
            docs : {
                src: ['site/assets/<%= pkg.versionShort %>/js/src/*.js', 'site/assets/<%= pkg.versionShort %>/js/*.js', '!site/assets/<%= pkg.versionShort %>/js/*.min.js']
            }
        },

        concat: {
            options: {
                banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>',
                stripBanners: false
            },
            core: {
                src: '<%= jsCore %>',
                dest: 'dist/js/<%= pkg.name %>.js'
            }
        },

        uglify: {
            options: {
                mangle: true,
                output: {
                    comments: /^!|@preserve|@license|@cc_on/i
                }
            },
            core: {
                src: '<%= concat.core.dest %>',
                dest: 'dist/js/<%= pkg.name %>.min.js'
            },
            docs: {
                src: '<%= jsDocs %>',
                dest: 'site/assets/<%= pkg.versionShort %>/js/docs.min.js'
            }
        },

        copy: {
            docs: {
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: 'site/<%= pkg.versionShort %>/dist/'
            }
        },

        stylelint: {
            options: {
                configFile: '.stylelintrc'
            },
            core: {
                src: ['scss/**/*.scss']
            },
            docs: {
                src: ['site/assets/<%= pkg.versionShort %>/scss/*.scss']
            }
        },

        sass: {
            options: {
                implementation: sass,
                includePaths: ['scss'],
                precision: 6,
                sourceComments: false,
                sourceMap: true,
                outputStyle: 'expanded'
            },
            core: {
                files: {
                    'dist/css/<%= pkg.name %>.css': 'scss/<%= pkg.name %>.scss'
                }
            },
            docs: {
                files: {
                    'site/assets/<%= pkg.versionShort %>/css/docs.css': 'site/assets/<%= pkg.versionShort %>/scss/docs.scss'
                }
            }
        },

        postcss: {
            core: {
                options: {
                    map: true,
                    processors: [flexbugs, calc, autoprefixer]
                },
                src: ['dist/css/*.css', '!dist/css/*.min.css']
            },
            docs: {
                options: {
                    processors: [flexbugs, calc, autoprefixer]
                },
                src: ['site/assets/<%= pkg.versionShort %>/css/*.css', '!site/assets/<%= pkg.versionShort %>/css/*.min.css']
            }
        },

        rtlcss: {
            core: {
                options: {
                    map: {
                        inline: false
                    },
                    opts: {
                        clean: true
                    }
                },
                expand: true,
                cwd: 'dist/css',
                src: ['*.css', '!*.min.css', '!*-rtl.css'],
                dest: 'dist/css',
                ext: '-rtl.css'
            },
            docs: {
                options: {
                    map: {
                        inline: false
                    },
                    opts: {
                        clean: true
                    }
                },
                expand: true,
                cwd: 'site/assets/<%= pkg.versionShort %>/css',
                src: ['*.css', '!*.min.css', '!*-rtl.css'],
                dest: 'site/assets/<%= pkg.versionShort %>/css',
                ext: '-rtl.css'
            }
        },

        cssmin: {
            options: {
                report: 'gzip',
                specialComments: '*',
                sourceMap: true,
                advanced: false
            },
            core: {
                files: [
                    {
                        expand: true,
                        cwd: 'dist/css',
                        src: ['*.css', '!*.min.css'],
                        dest: 'dist/css',
                        ext: '.min.css'
                    }
                ]
            },
            docs: {
                files: [
                    {
                        expand: true,
                        cwd: 'site/assets/<%= pkg.versionShort %>/css',
                        src: ['*.css', '!*.min.css'],
                        dest: 'site/assets/<%= pkg.versionShort %>/css',
                        ext: '.min.css'
                    }
                ]
            }
        },

        htmllint: {
            options: {
                ignore: [
                    'Consider using the "h1" element as a top-level heading only (all "h1" elements are treated as top-level headings by many screen readers and other tools).',
                    'Element "legend" not allowed as child of element "div" in this context. (Suppressing further errors from this subtree.)',
                    'Element "img" is missing required attribute "src".',
                    'The "color" input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.',
                    'The "datetime-local" input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.'
                ]
            },
            docs: {
                src: ['_siteout/**/*.html']
            },
            test: {
                src: ['test/visual/*.html']
            }
        },

        watch: {
            src: {
                files: '<%= eslint.core.src %>',
                tasks: ['eslint:core', 'concat']
            },
            sass: {
                files: 'scss/**/*.scss',
                tasks: ['dist-css', 'docs-dist-css']
            },
            docs: {
                files: 'site/assets/<%= pkg.versionShort %>/scss/**/*.scss',
                tasks: ['docs-dist-css', 'docs']
            }
        },

        run: {
            npmCssLintVarsCore: {
                exec: 'npm run css-lint-vars-core'
            },
            npmCssLintVarsDocs: {
                exec: 'npm run css-lint-vars-docs'
            },
            npmJsTestKarma: {
                exec: 'npm run js-test-karma'
            },
            npmJsTestCloud: {
                exec: 'npm run js-test-cloud'
            },
            npmDocsBuild: {
                exec: 'npm run docs-build'
            },
            npmDocsServe: {
                exec: 'npm run docs-serve'
            },
            npmLinkinator: {
                exec: 'npm run linkinator'
            }
        }
    });

    // Tasks
    // ==========
    // Load required plugins for tasks
    require('load-grunt-tasks')(grunt, {
        scope: 'devDependencies'
    });
    require('time-grunt')(grunt);

    // Default
    grunt.registerTask('default', ['clean:dist', 'test', 'docs-test-html']);

    // Test
    grunt.registerTask('test', ['dist-css', 'dist-js', 'docs-dist', 'test-css', 'test-js', 'docs-test']);
    grunt.registerTask('test-css', ['stylelint:core', 'run:npmCssLintVarsCore']);
    grunt.registerTask('test-html', ['htmllint:test']);

    // Test - JS subtasks
    var jsTestTasks = ['eslint:core', 'eslint:test', 'eslint:grunt', 'eslint:build'];
    if (saucekey !== null && process.env.TEST_SAUCE === 'true') {
        jsTestTasks.push('run:npmJsTestCloud');
    } else {
        jsTestTasks.push('run:npmJsTestKarma');
    }
    grunt.registerTask('test-js', jsTestTasks);

    // CSS distribution
    grunt.registerTask('dist-css', ['sass:core', 'postcss:core', 'rtlcss:core', 'cssmin:core']);

    // JS distribution
    grunt.registerTask('dist-js', ['concat', 'uglify:core']);

    // Full distribution
    grunt.registerTask('dist', ['clean:dist', 'dist-css', 'dist-js', 'docs-dist']);

    // Docs tasks
    grunt.registerTask('docs-test-html', ['run:npmDocsBuild', 'htmllint:docs', 'run:npmLinkinator']);
    grunt.registerTask('docs-test-css', ['stylelint:docs', 'run:npmCssLintVarsDocs']);
    grunt.registerTask('docs-dist-css', ['sass:docs', 'postcss:docs', 'rtlcss:docs', 'cssmin:docs']);
    grunt.registerTask('docs-test-js', ['eslint:docs']);
    grunt.registerTask('docs-dist-js', ['uglify:docs']);
    grunt.registerTask('docs-test', ['docs-test-css', 'docs-test-js', 'docs-test-html']);
    grunt.registerTask('docs-dist', ['docs-dist-css', 'docs-dist-js']);
    grunt.registerTask('docs', ['run:npmDocsServe']);
};
<|endoftext|>


<commit_before>'use strict';

var spawn = require('child_process').spawn;
var tests = require('./tests');
var excludeLibrariesPattern = '!node_modules/**';

module.exports = function(grunt) {
  grunt.initConfig({
    jshint: {
      files: ['**/*.js', excludeLibrariesPattern],
      options: {
        bitwise: true,
        camelcase: true,
        devel: true,
        eqeqeq: true,
        eqnull: true,
        globalstrict: true,
        immed: true,
        indent: 2,
        newcap: true,
        noarg: true,
        node: true,
        quotmark: 'single',
        sub: true,
        trailing: true,
        undef: true
      },
    },

    // TODO: get sensitive defaults, if these (taken from grunt-complexity
    // README) aren't
    complexity: {
      generic: {
        src: ['**/*.js', excludeLibrariesPattern, '!Gruntfile.js'],
        options: {
          breakOnErrors: true,
          errorsOnly: false, // show only maintainability errors
          cyclomatic: [3, 7, 12],
          halstead: [8, 13, 20],
          maintainability: 100
        }
      }
    },

    connect: {
      server: {
        options: {
          port: 8000,
          base: 'tests/webroot'
        },
      },
    },
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-complexity');
  grunt.loadNpmTasks('grunt-contrib-connect');

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

  grunt.registerTask('testPasses', tests.testPasses);
  grunt.registerTask('testFails', tests.testFails);
  grunt.registerTask('selenium', function(grunt) {
    var done = this.async();
    // this is the same selenium wrapper than in README. It conveniently
    // includes the .jar file and exposes a command to start it
    var selenium = spawn('./node_modules/selenium-server/bin/selenium');
    selenium.stderr.once('data', function() {
      done(false);
    });
    selenium.stdout.once('data', function() {
      done();
    });
  });

  grunt.registerTask(
    'tests', ['connect:server', 'selenium', 'testPasses', 'testFails']
  );
};
<commit_msg>gruntfile refactor<commit_after>'use strict';

var spawn = require('child_process').spawn;
var tests = require('./tests');
var excludeLibrariesPattern = '!node_modules/**';
var allJSFilesPattern = '**/*.js';

module.exports = function(grunt) {
  grunt.initConfig({
    jshint: {
      files: [allJSFilesPattern, excludeLibrariesPattern],
      options: {
        bitwise: true,
        camelcase: true,
        devel: true,
        eqeqeq: true,
        eqnull: true,
        globalstrict: true,
        immed: true,
        indent: 2,
        newcap: true,
        noarg: true,
        node: true,
        quotmark: 'single',
        sub: true,
        trailing: true,
        undef: true
      },
    },

    // TODO: get sensitive defaults, if these (taken from grunt-complexity
    // README) aren't
    complexity: {
      generic: {
        src: [allJSFilesPattern, excludeLibrariesPattern, '!Gruntfile.js'],
        options: {
          breakOnErrors: true,
          errorsOnly: false, // show only maintainability errors
          cyclomatic: [3, 7, 12],
          halstead: [8, 13, 20],
          maintainability: 100
        }
      }
    },

    connect: {
      server: {
        options: {
          port: 8000,
          base: 'tests/webroot'
        },
      },
    },
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-complexity');
  grunt.loadNpmTasks('grunt-contrib-connect');

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

  grunt.registerTask('testPasses', tests.testPasses);
  grunt.registerTask('testFails', tests.testFails);
  grunt.registerTask('selenium', function(grunt) {
    var done = this.async();
    // this is the same selenium wrapper than in README. It conveniently
    // includes the .jar file and exposes a command to start it
    var selenium = spawn('./node_modules/selenium-server/bin/selenium');
    selenium.stderr.once('data', function() {
      done(false);
    });
    selenium.stdout.once('data', function() {
      done();
    });
  });

  grunt.registerTask(
    'tests', ['connect:server', 'selenium', 'testPasses', 'testFails']
  );
};
<|endoftext|>


<commit_before>/*!
* Tree Gruntfile
* @author Ilia Kolev
*/

'use strict';

/**
* Grunt module
*/
module.exports = function (grunt) {

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

    /**
     * Displays the elapsed execution time of grunt tasks
     */
    require('time-grunt')(grunt);

    /**
     * Project configuration
     */
    grunt.initConfig({

        /**
         * Store your Package file so you can reference its specific data whenever necessary
         */
        pkg: grunt.file.readJSON('package.json'),

        /**
         * JSHint
         * https://github.com/gruntjs/grunt-contrib-jshint
         * Manage the options inside .jshintrc file
         */
        jshint: {
            files: [
                'www/assets/js/*.js',
                'Gruntfile.js'
            ],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        /**
        * CSSO
        * Minify CSS files
        * https://github.com/t32k/grunt-csso
        */
        csso: {
            dist: {
                files: {
                    'www/assets/css/screen.css': ['www/assets/css/screen.css']
                }
            }
        },

        /**
         * Compile Sass to CSS using Compass
         * https://github.com/gruntjs/grunt-contrib-jshint
         */
        compass: {
            dist: {
                options: {
                    config: 'config.rb'
                }
            }
        },

        /**
         * Autoprefixer
         * Adds vendor prefixes automatically
         * https://github.com/nDmitry/grunt-autoprefixer
         */
        autoprefixer: {
            dist: {
                options: {
                    browsers: [
                        'last 2 version',
                        'safari 6',
                        'ie 9',
                        'opera 12.1',
                        'ios 6',
                        'android 4'
                    ]
                },
                src: 'www/assets/css/screen.css'
            }
        },

        /**
         * Runs tasks against changed watched files
         * https://github.com/gruntjs/grunt-contrib-watch
         */
        watch: {
            jshint: {
                files: '<%= jshint.files %>',
                tasks: 'jshint'
            },
            sass: {
                files: 'www/assets/sass/{,*/}*.{scss,sass}',
                tasks: ['compass:dist', 'autoprefixer:dist', 'csso:dist'],
            },
        },
    });

    /**
     * Default task
     * Run `grunt` on the command line
     */
    grunt.registerTask('default', [
        'autoprefixer:dist',
        'jshint',
        'csso:dist',
        'compass:dist',
        'watch'
    ]);
};
<commit_msg>update Gruntfile<commit_after>/*!
* Tree Gruntfile
* @author Ilia Kolev
*/

'use strict';

/**
* Grunt module
*/
module.exports = function (grunt) {

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

    /**
     * Displays the elapsed execution time of grunt tasks
     */
    require('time-grunt')(grunt);

    /**
     * Project configuration
     */
    grunt.initConfig({

        /**
         * Store your Package file so you can reference its specific data whenever necessary
         */
        pkg: grunt.file.readJSON('package.json'),

        /**
         * Set project info
         */
        project: {
            www: 'www',
            js: [
                '<%= project.www %>/assets/js/vendor/*.js',
                '<%= project.www %>/assets/js/src/*.js'
            ]
        },

        /**
         * JSHint
         * https://github.com/gruntjs/grunt-contrib-jshint
         * Manage the options inside .jshintrc file
         */
        jshint: {
            files: [
                'www/assets/js/vendor/*.js',
                'www/assets/js/src/*js',
                'Gruntfile.js'
            ],
            options: {
                jshintrc: '.jshintrc',
                ignores: [
                    'www/assets/js/scripts.min.js',
                    'www/assets/js/vendor/*.js'
                ]
            }
        },

        /**
         * Uglify (minify) JavaScript files
         * https://github.com/gruntjs/grunt-contrib-uglify
         * Compresses and minifies all JavaScript files into one
         */
        uglify: {
            dev: {
                options: {
                    mangle: false,
                    compress: false,
                    preserveComments: 'all',
                    beautify: true
                },
                files: {
                    'www/assets/js/scripts.min.js': '<%= project.js %>'
                }
            },
            dist: {
                options: {
                    mangle: true,
                    compress: true
                },
                files: {
                    'www/assets/js/scripts.min.js': '<%= project.js %>'
                }
            }
        },

        /**
         * CSSO
         * Minify CSS files
         * https://github.com/t32k/grunt-csso
         */
        csso: {
            dist: {
                files: {
                    'www/assets/css/screen.css': ['www/assets/css/screen.css']
                }
            }
        },

        /**
         * Compile Sass to CSS using Compass
         * https://github.com/gruntjs/grunt-contrib-jshint
         */
        compass: {
            dist: {
                options: {
                    config: 'config.rb'
                }
            }
        },

        /**
         * Autoprefixer
         * Adds vendor prefixes automatically
         * https://github.com/nDmitry/grunt-autoprefixer
         */
        autoprefixer: {
            dist: {
                options: {
                    browsers: [
                        'last 2 version',
                        'safari 6',
                        'ie 9',
                        'opera 12.1',
                        'ios 6',
                        'android 4'
                    ]
                },
                src: 'www/assets/css/screen.css'
            }
        },

        /**
         * Runs tasks against changed watched files
         * https://github.com/gruntjs/grunt-contrib-watch
         */
        watch: {
            js: {
                files: '<%= jshint.files %>',
                tasks: ['jshint', 'uglify:dev']
            },
            sass: {
                files: 'www/assets/sass/{,*/}*.{scss,sass}',
                tasks: ['compass:dist', 'autoprefixer:dist', 'csso:dist'],
            },
        },
    });

    /**
     * Default task
     * Run `grunt` on the command line
     */
    grunt.registerTask('default', [
        'compass:dist',
        'autoprefixer:dist',
        'csso:dist',
        'jshint',
        'uglify:dev',
        'watch'
    ]);

    /**
     * Build task
     * Run `grunt build` on the command line
     * Then compress all JS/CSS files
     */
    grunt.registerTask('build', [
        'compass:dist',
        'autoprefixer:dist',
        'csso:dist',
        'jshint',
        'uglify:dist'
    ]);
};
<|endoftext|>


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

    grunt.initConfig({
        clean: ['_site'],
        concat: {
            app: {
                src: ['src/js/app.js', 'src/js/foo.js'],
                dest: '_site/js/app.js',
            }
        },
        connect: {
            server: {
                options: {
                    host: 'localhost',
                    port: 9000,
                    base: '_site',
                    open: true,
                    middleware: function(connect, options, defaultMiddleware) {
                        return [
                            require('grunt-connect-proxy/lib/utils').proxyRequest
                        ].concat(defaultMiddleware);
                    }
                },
                'proxies': [
                    {
                        context: '/es',
                        host: 'docker',
                        port: 9200,
                        rewrite: {
                            '^/es': '/'
                        }
                    }
                ]
            }
        },
        copy: {
            main: {
                files: [
                    { expand: true, cwd: 'src', src: ['index.html'], dest: '_site' }
                ]
            },
            libs: {
                files: [
                    { expand: true, cwd: 'bower_components', src: ['**/*.min.js'], dest: '_site/js', flatten: true },
                    { expand: true, cwd: 'bower_components/ace-builds/src-min', src: ['**'], dest: '_site/js/ace' },
                    { expand: true, cwd: 'bower_components/bootstrap/dist/css', src: ['*.min.css'], dest: '_site/css' },
                    { expand: true, cwd: 'bower_components/bootstrap/dist/fonts', src: ['*'], dest: '_site/fonts' }
                ]
            }
        },
        less : {
            app : {
                options: {
                    compress: true,
                    yuicompress: true
                },
                files: {
                    '_site/css/app.min.css' : 'src/less/app.less'
                }
            }
        },
        uglify: {
            prod: {
                files: {
                    '_site/js/app.min.js': ['src/js/app.js', 'src/js/editors.js']
                }
            },
            dev: {
                files: {
                    '_site/js/app.min.js': ['src/js/app.js', 'src/js/editors.js']
                },
                options: {
                    beautify: true,
                    mangle: false
                }
            }
        },
        watch: {
            main: {
                files: ['src/index.html'],
                tasks: ['copy:main'],
                options: {
                    spawn: false
                }
            },
            js: {
                files: ['src/js/*.js'],
                tasks: ['uglify'],
                options: {
                    spawn: false
                }
            },
            less: {
                files: ['src/less/*.less'],
                tasks: ['less'],
                options: {
                    spawn: false
                }
            }
        },
        http: {
            clean: {
                options: {
                    url: 'http://docker:9200/test',
                    method: 'DELETE',
                    ignoreErrors: true
                }
            },
            insert: {
                options: {
                    url: 'http://docker:9200/test/user',
                    method: 'POST',
                    json: true,
                    body: '<%= testdata.dataset %>'
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-connect-proxy');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-http');

    grunt.registerTask('default', ['clean', 'copy', 'uglify:prod', 'less']);
    grunt.registerTask('dev', ['clean', 'copy', 'uglify:dev', 'less', 'configureProxies:server', 'connect', 'watch']);
    grunt.registerTask('testdata', 'reads testdata.json and posts the content to elasticsearch', function() {
        grunt.task.run('http:clean');
        var data = grunt.file.readJSON('test/testdata.json');
        for (var i = 0; i < data.length; i++) {
            grunt.config.set('testdata.dataset', data[0]);
            grunt.task.run('http:insert');
        }
    });

};<commit_msg>using bulk api for testdata<commit_after>module.exports = function(grunt) {

    grunt.initConfig({
        clean: ['_site'],
        concat: {
            app: {
                src: ['src/js/app.js', 'src/js/foo.js'],
                dest: '_site/js/app.js',
            }
        },
        connect: {
            server: {
                options: {
                    host: 'localhost',
                    port: 9000,
                    base: '_site',
                    open: true,
                    middleware: function(connect, options, defaultMiddleware) {
                        return [
                            require('grunt-connect-proxy/lib/utils').proxyRequest
                        ].concat(defaultMiddleware);
                    }
                },
                'proxies': [
                    {
                        context: '/es',
                        host: 'docker',
                        port: 9200,
                        rewrite: {
                            '^/es': '/'
                        }
                    }
                ]
            }
        },
        copy: {
            main: {
                files: [
                    { expand: true, cwd: 'src', src: ['index.html'], dest: '_site' }
                ]
            },
            libs: {
                files: [
                    { expand: true, cwd: 'bower_components', src: ['**/*.min.js'], dest: '_site/js', flatten: true },
                    { expand: true, cwd: 'bower_components/ace-builds/src-min', src: ['**'], dest: '_site/js/ace' },
                    { expand: true, cwd: 'bower_components/bootstrap/dist/css', src: ['*.min.css'], dest: '_site/css' },
                    { expand: true, cwd: 'bower_components/bootstrap/dist/fonts', src: ['*'], dest: '_site/fonts' }
                ]
            }
        },
        less : {
            app : {
                options: {
                    compress: true,
                    yuicompress: true
                },
                files: {
                    '_site/css/app.min.css' : 'src/less/app.less'
                }
            }
        },
        uglify: {
            prod: {
                files: {
                    '_site/js/app.min.js': ['src/js/app.js', 'src/js/editors.js']
                }
            },
            dev: {
                files: {
                    '_site/js/app.min.js': ['src/js/app.js', 'src/js/editors.js']
                },
                options: {
                    beautify: true,
                    mangle: false
                }
            }
        },
        watch: {
            main: {
                files: ['src/index.html'],
                tasks: ['copy:main'],
                options: {
                    spawn: false
                }
            },
            js: {
                files: ['src/js/*.js'],
                tasks: ['uglify'],
                options: {
                    spawn: false
                }
            },
            less: {
                files: ['src/less/*.less'],
                tasks: ['less'],
                options: {
                    spawn: false
                }
            }
        },
        http: {
            clean: {
                options: {
                    url: 'http://docker:9200/test',
                    method: 'DELETE',
                    ignoreErrors: true
                }
            },
            insert: {
                options: {
                    url: 'http://docker:9200/_bulk',
                    method: 'POST',
                    json: true,
                    body: '<%= testdata.bulk %>'
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-connect-proxy');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-http');

    grunt.registerTask('default', ['clean', 'copy', 'uglify:prod', 'less']);
    grunt.registerTask('dev', ['clean', 'copy', 'uglify:dev', 'less', 'configureProxies:server', 'connect', 'watch']);
    grunt.registerTask('testdata', 'reads testdata.json and posts the content to elasticsearch', function() {
        grunt.task.run('http:clean');
        var data = grunt.file.readJSON('test/testdata.json');
        var bulk = '';
        for (var i = 0; i < data.length; i++) {
            bulk += JSON.stringify({ "index" : { "_index" : "test", "_type" : "person" } }) + '\n';
            bulk += JSON.stringify(data[i]) + '\n';
        }
        grunt.config.set('testdata.bulk', bulk);
        grunt.task.run('http:insert');
    });

};<|endoftext|>


<commit_before>#!/usr/bin/env node

/*!
 * iamprabhat®
 * From the Desk of Prabhat Kumar — CEO, Founder & Scientist.
 * ___________________________________________________________________________
 *
 * Grunt, http://gruntjs.com/ — The JavaScript Task Runner.
 * ___________________________________________________________________________
 *
 * Architecture and Code Handcrafted by Prabhat Kumar.
 * Architectuur en Code handgemaakt door Prabhat Kumar.
 * @author    : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Prabhat Kumar [http://prabhatkumar.org/].
 * ___________________________________________________________________________
 *
 * @date      : 18-Nov-2016
 * @license   : Apache, version 2.0
 * @require   : Node.js®
 * @require   : NPM
 * @require   : grunt-cli
 * @build     : SEED™ — Umeå
 *              └────── A Sequømics Product — http://sequomics.com/.
 * ___________________________________________________________________________
 *
 * --/The Heart of Build System/-- of "iamprabhat®".
 * ___________________________________________________________________________
 */

// Invoking strict mode.
///@purpose: Strict mode applies to entire scripts or to individual functions.
"use strict";

// To load required Node module.
///-----------------------------
var os          = require('os');
var fs          = require('fs');
var path        = require('path');

// To load required NPM modules.
///-----------------------------
var chalk       = require('chalk');
var inquirer    = require('inquirer');
var semver      = require('semver');

// Default color defined.
///----------------------
var noop        = chalk.red;
var yeep        = chalk.green;
var okay        = chalk.blue;
var boop        = chalk.gray;

///-------------------
// An object literals.
///-------------------
var build = {
  // Nonidentifier property names are quoted.
  "system"    : "SEED™",
  "name"      : "Umeå",
  "year"      : "2015",
  "audience"  : "for all scientist."
};

///-------------------------
// A smart license function.
///------- Apache ----------
var license = [
'/*!                                                                                ',
' * iamprabhat® — %(version)s                                                                         ',
' * From the Desk of Prabhat Kumar — CEO, Founder & Scientist.                                        ',
' * ---------------------------------------------------------------------------                       ',
' * Copyright © 2008 - ' + new Date().getFullYear() + ', Prabhat Kumar, All rights reserved.          ',
' * ---------------------------------------------------------------------------                       ',
' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Research, All rights reserved.     ',
' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.  ',
' * ---------------------------------------------------------------------------                       ',
' * HomePage: http://prabhatkumar.org/ or https://iamprabhatkumar.wordpress.com                       ',
' * ---------------------------------------------------------------------------                       ',
' * Available via the Apache, version 2.0. [http://www.apache.org/licenses/]                          ',
' * See: https://github.com/iamprabhat/iamprabhat — for details.                                      ',
' * ---------------------------------------------------------------------------                       ',
' */                                                                                ',
'\n',
'/*!                                                                                ',
' * Build System — ' + build.system + ':' + build.name + ' — ' + '%(version)s' + ' — '+ build.audience ,
' * ---------------------------------------------------------------------------                       ',
' * Copyright © 2015 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.  ',
' * Available via the Apache, version 2.0. [http://www.apache.org/licenses/]                          ',
' * ---------------------------------------------------------------------------                       ',
' * See: http://seed.sequomics.com/ — for details.                                                    ',
' * ---------------------------------------------------------------------------                       ',
' */                                                                                ',
'\n',
].map(function(s) {
  return s.replace(/\s+$/, '');
}).join("\n");

///--------------------------
// A citation of iamprabhat®.
///--------------------------
var cite = JSON.parse(fs.readFileSync('./citation.json', {
  encoding: "utf8"
}));

// To get asset(s) information.
///----------------------------
var bkg  = JSON.parse(fs.readFileSync('./bower.json', {
  encoding: "utf8"
}));

var pkg  = JSON.parse(fs.readFileSync('./package.json', {
  encoding: "utf8"
}));

// To get credential(s) information.
///---------------------------------
var ftp  = JSON.parse(fs.readFileSync('./secret.json', {
  encoding: "utf8"
}));

// Global variables.
//=~~~~~~~~~~~~~~~~~
var rootPath    = './';
var appsPath    = './app/';
var docsPath    = './docs/';
var libsPath    = './libs/';
// A destination directory.
var buildPath   = './build/';

var message     = "SEED™ — Supported under Mac OS X and Linux only!";

// To get 'version', i.e. required to work on SEED™: Grunt based build system.
var version     = pkg.version;

// ----------------------------------------------------------------------------------------------------------
var banner      =
    '/*!\n' +
    ' * ————————————\n' +
    ' * iamprabhat®: v' + version + '\n' +
    ' * ————————————\n' +
    ' * From the Desk of Prabhat Kumar — CEO, Founder & Scientist.\n' +
    ' * Copyright © 2008 - ' + new Date().getFullYear() + ', Prabhat Kumar, All rights reserved.\n' +
    ' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.\n' +
    ' * Released under the Apache License (http://www.apache.org/licenses/).\n' +
    ' */';

// An object with no properties.
var replaceHandlers = {};

// A function to register `ReplaceHandler`.
///----------------------------------------
function registerReplaceHandler(keyword, handler) {
  replaceHandlers[keyword] = handler;
}

/*!
 * Replace %(id)s in strings with values in objects(s).
 * ----------------------------------------------------
 * Given a string like `"Hello %(name)s from %(user.country)s"`
 * and an object like `{name:"Prabhat", user:{country:"India"}}` would,
 * return `"Hello Prabhat from India"`.
 * ----------------------------------------------------
 * @param {string} str string to do replacements in,
 * @param {Object|Object[]} params one or more objects.
 * @returns {string} string with replaced parts.
 */
var replaceParams = (function() {

  var replaceParamsRE = /%\(([^\)]+)\)s/g;

  return function(str, params) {
    if (!params.length) {
      params = [params];
    }
    return str.replace(replaceParamsRE, function(match, key) {
      var colonNdx = key.indexOf(":");
      if (colonNdx >= 0) {
        try {
          var hanson = null;
          var args = hanson.parse("{" + key + "}");
          var handlerName = Object.keys(args)[0];
          var handler = replaceHandlers[handlerName];
          if (handler) {
            return handler(args[handlerName]);
          }
          console.error(noop("SEED™: Unknown substition handler: " + handlerName));
        } catch(e) {
          console.error(noop(e));
          console.error(noop("SEED™: Bad substitution: %(" + key + ")s"));
        }
      } else {
        // handle normal substitutions.
        var keys = key.split('.');
        for (var ii = 0; ii < params.length; ++ii) {
          var obj = params[ii];
          for (var jj = 0; jj < keys.length; ++jj) {
            key = keys[jj];
            obj = obj[key];
            if (obj === undefined) {
              break;
            }
          }
          if (obj !== undefined) {
            return obj;
          }
        }
      }
      console.error(noop("SEED™: Unknown key: " + key));
      return "%(" + key + ")s";
    });
  };
}());

// A function to register `hackForCommonJSAndBrowserify`.
///------------------------------------------------------
function hackForCommonJSAndBrowserify(text, sourceMapText) {
  var dirname = path.dirname(this.outPath);
  if (!fs.existsSync(dirname)) {
    fs.mkdirSync(dirname);
  }
  text = text.replace(/require/g, 'notrequirebecasebrowserifymessesup');
  fs.writeFileSync(this.outPath, text, {
    encoding: "utf-8"
  });
}

// A function to register `dateFormat`.
///------------------------------------
function dateFormat(date, format) {
  if (format === undefined) {
    format = date;
    date = new Date();
  }
  var map = {
    "M": date.getMonth() + 1,
    "d": date.getDate(),
    "h": date.getHours(),
    "m": date.getMinutes(),
    "s": date.getSeconds(),
    "q": Math.floor((date.getMonth() + 3) / 3),
    "S": date.getMilliseconds()
  };
  format = format.replace(/([yMdhmsqS])(\1)*/g, function(all, t){
    var v = map[t];
    if (v !== undefined) {
      if (all.length > 1) {
        v = '0' + v;
        v = v.substr(v.length-2);
      }
      return v;
    } else if (t === 'y') {
      return (date.getFullYear() + '').substr(4 - all.length);
    }
    return all;
  });
  return format;
}

// ----------------------------------------------------------------------------------------------------------
// All Grunt Operations Defined... |--------------------------------------------| 21/Nov/2016 | SEED™ — Umeå.
// ----------------------------------------------------------------------------------------------------------

module.exports = function(grunt) {

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

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

  // Date objects.
  var today    = new Date();
  var timems   = Date.now();

  // Advanced Grunt API.
  /// -->> A mode defaults to `0777`.
  var mode     = '0777';
  /// -->> A file globbing pattern.
  var pattern  = '**/*.js';
  // Exclude: remove from consideration.
  // grunt.file.expand([options, ] patterns)
  var excludes = grunt.file.expand([
    '!/libs/assembly/assembly.js',
    '!/libs/assembly/convert.js'
  ]);
  // Includes: make part of a whole or set.
  // grunt.file.expand([options, ] patterns)
  var includes = grunt.file.expand([
    __dirname + '/core/source/script/' + pattern,
    __dirname + '/core/source/engine/' + pattern
  ]);
<commit_msg>Initial commit<commit_after>#!/usr/bin/env node

/*!
 * iamprabhat®
 * From the Desk of Prabhat Kumar — CEO, Founder & Scientist.
 * ___________________________________________________________________________
 *
 * Grunt, http://gruntjs.com/ — The JavaScript Task Runner.
 * ___________________________________________________________________________
 *
 * Architecture and Code Handcrafted by Prabhat Kumar.
 * Architectuur en Code handgemaakt door Prabhat Kumar.
 * @author    : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Prabhat Kumar [http://prabhatkumar.org/].
 * ___________________________________________________________________________
 *
 * @date      : 18-Nov-2016
 * @license   : Apache, version 2.0
 * @require   : Node.js®
 * @require   : NPM
 * @require   : grunt-cli
 * @build     : SEED™ — Umeå
 *              └────── A Sequømics Product — http://sequomics.com/.
 * ___________________________________________________________________________
 *
 * --/The Heart of Build System/-- of "iamprabhat®".
 * ___________________________________________________________________________
 */

// Invoking strict mode.
///@purpose: Strict mode applies to entire scripts or to individual functions.
"use strict";

// To load required Node module.
///-----------------------------
var os          = require('os');
var fs          = require('fs');
var path        = require('path');

// To load required NPM modules.
///-----------------------------
var chalk       = require('chalk');
var inquirer    = require('inquirer');
var semver      = require('semver');

// Default color defined.
///----------------------
var noop        = chalk.red;
var yeep        = chalk.green;
var okay        = chalk.blue;
var boop        = chalk.gray;

///-------------------
// An object literals.
///-------------------
var build = {
  // Nonidentifier property names are quoted.
  "system"    : "SEED™",
  "name"      : "Umeå",
  "year"      : "2015",
  "audience"  : "for all scientist."
};

///-------------------------
// A smart license function.
///------- Apache ----------
var license = [
'/*!                                                                                ',
' * iamprabhat® — %(version)s                                                                         ',
' * From the Desk of Prabhat Kumar — CEO, Founder & Scientist.                                        ',
' * ---------------------------------------------------------------------------                       ',
' * Copyright © 2008 - ' + new Date().getFullYear() + ', Prabhat Kumar, All rights reserved.          ',
' * ---------------------------------------------------------------------------                       ',
' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Research, All rights reserved.     ',
' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.  ',
' * ---------------------------------------------------------------------------                       ',
' * HomePage: http://prabhatkumar.org/ or https://iamprabhatkumar.wordpress.com                       ',
' * ---------------------------------------------------------------------------                       ',
' * Available via the Apache, version 2.0. [http://www.apache.org/licenses/]                          ',
' * See: https://github.com/iamprabhat/iamprabhat — for details.                                      ',
' * ---------------------------------------------------------------------------                       ',
' */                                                                                ',
'\n',
'/*!                                                                                ',
' * Build System — ' + build.system + ':' + build.name + ' — ' + '%(version)s' + ' — '+ build.audience ,
' * ---------------------------------------------------------------------------                       ',
' * Copyright © 2015 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.  ',
' * Available via the Apache, version 2.0. [http://www.apache.org/licenses/]                          ',
' * ---------------------------------------------------------------------------                       ',
' * See: http://seed.sequomics.com/ — for details.                                                    ',
' * ---------------------------------------------------------------------------                       ',
' */                                                                                ',
'\n',
].map(function(s) {
  return s.replace(/\s+$/, '');
}).join("\n");

///--------------------------
// A citation of iamprabhat®.
///--------------------------
var cite = JSON.parse(fs.readFileSync('./citation.json', {
  encoding: "utf8"
}));

// To get asset(s) information.
///----------------------------
var bkg  = JSON.parse(fs.readFileSync('./bower.json', {
  encoding: "utf8"
}));

var pkg  = JSON.parse(fs.readFileSync('./package.json', {
  encoding: "utf8"
}));

// To get credential(s) information.
///---------------------------------
var ftp  = JSON.parse(fs.readFileSync('./secret.json', {
  encoding: "utf8"
}));

// Global variables.
//=~~~~~~~~~~~~~~~~~
var rootPath    = './';
var appsPath    = './app/';
var docsPath    = './docs/';
var libsPath    = './libs/';
// A destination directory.
var buildPath   = './build/';

var message     = "SEED™ — Supported under Mac OS X and Linux only!";

// To get 'version', i.e. required to work on SEED™: Grunt based build system.
var version     = pkg.version;

// ----------------------------------------------------------------------------------------------------------
var banner      =
    '/*!\n' +
    ' * ————————————\n' +
    ' * iamprabhat®: v' + version + '\n' +
    ' * ————————————\n' +
    ' * From the Desk of Prabhat Kumar — CEO, Founder & Scientist.\n' +
    ' * Copyright © 2008 - ' + new Date().getFullYear() + ', Prabhat Kumar, All rights reserved.\n' +
    ' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.\n' +
    ' * Released under the Apache License (http://www.apache.org/licenses/).\n' +
    ' */';

// An object with no properties.
var replaceHandlers = {};

// A function to register `ReplaceHandler`.
///----------------------------------------
function registerReplaceHandler(keyword, handler) {
  replaceHandlers[keyword] = handler;
}

/*!
 * Replace %(id)s in strings with values in objects(s).
 * ----------------------------------------------------
 * Given a string like `"Hello %(name)s from %(user.country)s"`
 * and an object like `{name:"Prabhat", user:{country:"India"}}` would,
 * return `"Hello Prabhat from India"`.
 * ----------------------------------------------------
 * @param {string} str string to do replacements in,
 * @param {Object|Object[]} params one or more objects.
 * @returns {string} string with replaced parts.
 */
var replaceParams = (function() {

  var replaceParamsRE = /%\(([^\)]+)\)s/g;

  return function(str, params) {
    if (!params.length) {
      params = [params];
    }
    return str.replace(replaceParamsRE, function(match, key) {
      var colonNdx = key.indexOf(":");
      if (colonNdx >= 0) {
        try {
          var hanson = null;
          var args = hanson.parse("{" + key + "}");
          var handlerName = Object.keys(args)[0];
          var handler = replaceHandlers[handlerName];
          if (handler) {
            return handler(args[handlerName]);
          }
          console.error(noop("SEED™: Unknown substition handler: " + handlerName));
        } catch(e) {
          console.error(noop(e));
          console.error(noop("SEED™: Bad substitution: %(" + key + ")s"));
        }
      } else {
        // handle normal substitutions.
        var keys = key.split('.');
        for (var ii = 0; ii < params.length; ++ii) {
          var obj = params[ii];
          for (var jj = 0; jj < keys.length; ++jj) {
            key = keys[jj];
            obj = obj[key];
            if (obj === undefined) {
              break;
            }
          }
          if (obj !== undefined) {
            return obj;
          }
        }
      }
      console.error(noop("SEED™: Unknown key: " + key));
      return "%(" + key + ")s";
    });
  };
}());

// A function to register `hackForCommonJSAndBrowserify`.
///------------------------------------------------------
function hackForCommonJSAndBrowserify(text, sourceMapText) {
  var dirname = path.dirname(this.outPath);
  if (!fs.existsSync(dirname)) {
    fs.mkdirSync(dirname);
  }
  text = text.replace(/require/g, 'notrequirebecasebrowserifymessesup');
  fs.writeFileSync(this.outPath, text, {
    encoding: "utf-8"
  });
}

// A function to register `dateFormat`.
///------------------------------------
function dateFormat(date, format) {
  if (format === undefined) {
    format = date;
    date = new Date();
  }
  var map = {
    "M": date.getMonth() + 1,
    "d": date.getDate(),
    "h": date.getHours(),
    "m": date.getMinutes(),
    "s": date.getSeconds(),
    "q": Math.floor((date.getMonth() + 3) / 3),
    "S": date.getMilliseconds()
  };
  format = format.replace(/([yMdhmsqS])(\1)*/g, function(all, t){
    var v = map[t];
    if (v !== undefined) {
      if (all.length > 1) {
        v = '0' + v;
        v = v.substr(v.length-2);
      }
      return v;
    } else if (t === 'y') {
      return (date.getFullYear() + '').substr(4 - all.length);
    }
    return all;
  });
  return format;
}

// ----------------------------------------------------------------------------------------------------------
// All Grunt Operations Defined... |--------------------------------------------| 21/Nov/2016 | SEED™ — Umeå.
// ----------------------------------------------------------------------------------------------------------

module.exports = function(grunt) {

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

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

  // Date objects.
  var today    = new Date();
  var timems   = Date.now();

  // Advanced Grunt API.
  /// -->> A mode defaults to `0777`.
  var mode     = '0777';
  /// -->> A file globbing pattern.
  var pattern  = '**/*.js';
  // Exclude: remove from consideration.
  // grunt.file.expand([options, ] patterns)
  var excludes = grunt.file.expand([
    '!/libs/assembly/assembly.js',
    '!/libs/assembly/convert.js'
  ]);
  // Includes: make part of a whole or set.
  // grunt.file.expand([options, ] patterns)
  var includes = grunt.file.expand([
    __dirname + '/core/source/script/' + pattern,
    __dirname + '/core/source/engine/' + pattern
  ]);
  // To write process log(s).
  var contents = null;
<|endoftext|>


<commit_before>module.exports = function(grunt) {
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		preprocess : {
			html : {
				src : 'templates/main.tumblr',
				dest : 'theme.tumblr'
			}
		}
	});

	grunt.loadNpmTasks('grunt-preprocess');
	grunt.registerTask('default', ['preprocess']);
}
<commit_msg>concatting all the tumblr files into one before running preprocess<commit_after>module.exports = function(grunt) {
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		concat: {
			dist: {
				src: [
					'templates/_header.tumblr',
//					'_blockAnswer.tumblr',
//					'_blockAudio.tumblr',
//					'_blockChat.tumblr',
//					'_blockLink.tumblr',
//					'_blockPhoto.tumblr',
//					'_blockPhotoset.tumblr',
//					'_blockPosts.tumblr',
//					'_blockQuote.tumblr',
//					'_blockText.tumblr',
//					'_blockVideo.tumblr',
					'templates/_footer.tumblr'
				],
				dest: "build/unprocessed.template.tumblr"
			}
		},
		preprocess : {
			html : {
				src : 'build/unprocessed.template.tumblr',
				dest : 'theme.tumblr'
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-preprocess');
	grunt.registerTask('default', ['concat', 'preprocess']);
}
<|endoftext|>


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

  // task configurations
  var config = {
    // meta data from package.json
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today(\'yyyy-mm-dd\') %>\n' +
      '<%= pkg.homepage ? \'* \' + pkg.homepage + \'\\n\' : \'\' %>' +
      '* Copyright (c) <%= grunt.template.today(\'yyyy\') %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, \'type\').join(\', \') %> */\n',
    // files that our tasks will use
    files: {
      html: {
        src: 'index.html'
      },
      js: {
        vendor: [
          'bower_components/mithril/mithril.min.js'
        ],
        app: {
          main: 'js/app.js',
          compiled: 'generated/js/app.min.js'
        }
      },
      sass: {
        src: [
            'sass/**/*.{scss,sass}',
            'sass/_partials/**/*.{scss,sass}'
        ]
      },
    },
    // our tasks
    browserify: {
      app: {
        files: {
          'generated/js/app.min.js': ['js/app.js'],
        }
      },
      options: {
        debug: true
      }
    },
    concat: {
      app: {
        dest: 'generated/js/vendor.min.js',
        src: ['<%= files.js.vendor %>']
      }
    },
    sass: {
        dev: {
          options: {
            sourceMap: true,
            includePaths: ['bower_components/susy/sass']
          },
          dest: 'generated/css/styles.css',
          src: '<%= files.sass.src %>'
        },
        dist: {
          options: {
            outputStyle: 'compressed',
            includePaths: ['bower_components/susy/sass']
          },
          dest: 'dist/css/styles.css',
          src: '<%= files.sass.src %>'
        }
    },
    copy: {
      html: {
        files: {
          'generated/index.html': '<%= files.html.src %>',
          'dist/index.html': '<%= files.html.src %>'
        }
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.app.dest %>',
        dest: 'dist/js/vendor.min.js'
      }
    },
    server: {
        base: (process.env.SERVER_BASE || 'generated'),
        web: {
            port: 8000
        }
    },
    open: {
        dev: {
            path: 'http://localhost:<%= server.web.port %>'
        }
    },
    watch: {
        options: {
            livereload: true
        },
        html: {
            files: ['<%= files.html.src %>'],
            tasks: ['copy']
        },
        js: {
            files: ['<%= files.js.vendor %>'],
            tasks: ['concat']
        },
        app: {
            files: ['<%= files.js.app.main =>'],
            tasks: ['browserify', 'concat']
        },
        sass: {
            files: ['<%= files.sass.src %>'],
            tasks: ['sass:dev']
        }
    },
    // one-off task 'grunt clean', which clears our generated files and build files.
    clean: {
        workspaces: ['dist', 'generated']
    }
  };

  // initializing task configuration
  grunt.initConfig(config);

  // loading local tasks
  grunt.loadTasks('tasks');

  // loading external tasks (aka: plugins)
  require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);

  // creating workflows
  grunt.registerTask('default', ['copy', 'sass:dev', 'browserify', 'concat', 'server', 'open', 'watch']);
  grunt.registerTask('build', ['copy', 'sass:dist', 'browserify', 'concat', 'uglify']);
  grunt.registerTask('prodsim', ['build', 'server', 'open', 'watch']);

};
<commit_msg>Use string interpolation to DRY file locations<commit_after>module.exports = function(grunt) {
  'use strict';

  // task configurations
  var config = {
    // meta data from package.json
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today(\'yyyy-mm-dd\') %>\n' +
      '<%= pkg.homepage ? \'* \' + pkg.homepage + \'\\n\' : \'\' %>' +
      '* Copyright (c) <%= grunt.template.today(\'yyyy\') %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, \'type\').join(\', \') %> */\n',
    // files that our tasks will use
    files: {
      html: {
        src: 'index.html'
      },
      js: {
        vendor: [
          'bower_components/mithril/mithril.min.js'
        ],
        app: {
          main: 'js/app.js',
          compiled: 'generated/js/app.min.js'
        }
      },
      sass: {
        src: [
            'sass/**/*.{scss,sass}',
            'sass/_partials/**/*.{scss,sass}'
        ]
      },
    },
    // our tasks
    browserify: {
      app: {
        files: {
            '<%= files.js.app.compiled %>': '<%= files.js.app.main %>'
        }
      },
      options: {
        debug: true
      }
    },
    concat: {
      app: {
        dest: 'generated/js/vendor.min.js',
        src: ['<%= files.js.vendor %>']
      }
    },
    sass: {
        dev: {
          options: {
            sourceMap: true,
            includePaths: ['bower_components/susy/sass']
          },
          dest: 'generated/css/styles.css',
          src: '<%= files.sass.src %>'
        },
        dist: {
          options: {
            outputStyle: 'compressed',
            includePaths: ['bower_components/susy/sass']
          },
          dest: 'dist/css/styles.css',
          src: '<%= files.sass.src %>'
        }
    },
    copy: {
      html: {
        files: {
          'generated/index.html': '<%= files.html.src %>',
          'dist/index.html': '<%= files.html.src %>'
        }
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.app.dest %>',
        dest: 'dist/js/vendor.min.js'
      }
    },
    server: {
        base: (process.env.SERVER_BASE || 'generated'),
        web: {
            port: 8000
        }
    },
    open: {
        dev: {
            path: 'http://localhost:<%= server.web.port %>'
        }
    },
    watch: {
        options: {
            livereload: true
        },
        html: {
            files: ['<%= files.html.src %>'],
            tasks: ['copy']
        },
        js: {
            files: ['<%= files.js.vendor %>'],
            tasks: ['concat']
        },
        app: {
            files: ['<%= files.js.app.main =>'],
            tasks: ['browserify', 'concat']
        },
        sass: {
            files: ['<%= files.sass.src %>'],
            tasks: ['sass:dev']
        }
    },
    // one-off task 'grunt clean', which clears our generated files and build files.
    clean: {
        workspaces: ['dist', 'generated']
    }
  };

  // initializing task configuration
  grunt.initConfig(config);

  // loading local tasks
  grunt.loadTasks('tasks');

  // loading external tasks (aka: plugins)
  require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);

  // creating workflows
  grunt.registerTask('default', ['copy', 'sass:dev', 'browserify', 'concat', 'server', 'open', 'watch']);
  grunt.registerTask('build', ['copy', 'sass:dist', 'browserify', 'concat', 'uglify']);
  grunt.registerTask('prodsim', ['build', 'server', 'open', 'watch']);

};
<|endoftext|>


<commit_before>//require('load-grunt-tasks')(grunt);

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);

    // Project configuration.
    grunt.initConfig({
        stylus: {
          compile: {
              options: {
                  paths: ["node_modules/axis/",
                          "node_modules/jeet/stylus/",
                          "node_modules/rupture/",
                  ],
                  urlfunc: "embedurl",
              },
              files: {
                  "static/css/s.css": "styl/s.styl"
              }
          }
        },
         shell: { //me with ascidoctor.js
             build: {
                 command: function () {
                     comm = "hugo"
                     return comm
                 },
             },
             update: {
                 command: function () {
                     comm = "npm update caniuse-db"
                     return comm
                 }
             },
         },
        autoprefixer: {
             single_file: {
                 options: {
                     browsers: ["> 1%", "ie10", "ie11"]
                 },
                 src: 'static/css/s.css',
                 dest: 'static/css/s.css'
             },
        },
        cssmin: {
            options: {
                report: 'min'
            },
            main: {
                expand: true,
                cwd: 'public/',
                src: '**/*.css',
                dest: 'public/'
            }
        },
        //WARNING: never put this in a git repo dir...
        aws: grunt.file.readJSON("../grunt-aws-SECRET.json"),
        aws_s3: {
             options: {
                    accessKeyId: "<%= aws.secret %>",
                    secretAccessKey: '<%= aws.key %>',
                    bucket: "<%= aws.bucket %>",
                    region: "us-east-1",
                    access: "public-read",
                    progress: "progressBar",
                    streams: true,
                    debug: false,
                    uploadConcurrency: 30,
                },

            production: {
                options: {
                    streams: true,
                    debug: false,
                    differential: true,
                params: {
                        "CacheControl": "max-age=63072000, public",
                        "Expires": new Date(Date.now() + 6.31139e10),//.toUTCString(),
                }
                },

                files: [
                    { expand: true, dest: '.', cwd: 'public/', src: ['**/*',"!**/*.html","!**/*.css"], action: 'upload', differential: true },
                    { dest: '/', cwd: 'public/', action: 'delete', differential: true }
                ]
            },
            gzipd: {
                options: {
                    streams: true,
                    debug: false,
                    differential: true,
                params: {
                    "CacheControl": "max-age=63072000, public",
                    "Expires": new Date(Date.now() + 6.31139e10),
                    "ContentEncoding": "gzip"
                }
                },
                files: [ {expand: true, dest: ".", cwd: "preflight/", src: ["**/*.html", "**/*.css"], action:"upload", differential:true}]
            },
            production_index: {
                options: {
                    streams: true,
                    debug: false,
                    differential: false,
                params: {
                    "CacheControl": "max-age=3600, public",
                    "Expires": new Date(Date.now() + 3600),
                    "ContentEncoding": "gzip"
                }
                },
                files: [
                    { expand: true, dest: '.', cwd: 'preflight/', src: ['index.html'], action: 'upload', differential: false}
                ]
            }
        },
        compress: {
            main: {
                options: { mode: 'gzip', pretty: true, level: 9},
                expand: true,
                cwd: "public/",
                src: ["**/*.html", "**/*.css"],
                dest: "preflight/",
            },
        },
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                expand: true,
                cwd: 'public',
                src: ['**/*.html'],
                dest: 'public/'
            }
        },
        concat: {
          css: {
              src: ['static/css/s.css', "node_modules/grunt-highlight/node_modules/highlight.js/styles/tomorrow.css"],
              dest: 'static/css/s.css'
          },
      },
  highlight: {
    task: {
      options: {},
        expand: true,
        cwd: 'public',
        src: ["**/*.html"],
        dest: "public/"
    }
  },
  cacheBust: {
    options: {
        encoding: 'utf8',
        algorithm: 'sha1',
        length: 16,
        baseDir: "public/"

    },
      assets: {
          expand: true,
          cwd: "public",
          src: ["**/*.html"],
          dest: "public/"
    }
  },
        availabletasks: {
            tasks: {}
      },
        prompt: {
            target: {
                options: {
                    questions: [
                        {
                            config: 'config.invalidateTarget',
                            type: 'list', // list, checkbox, confirm, input, password
                            message: 'What do you want to invalidate?',
                            default: 'index', // default value if nothing is entered
                            choices: ["index", "all", "html", "none"],
                        }
                    ]
                }
            },
        },
        invalidate_cloudfront: {
          options: {
              key: "<%= aws.secret %>",
              secret: "<%= aws.key %>",
              distribution: 'E9J6BU91BD488'
            },
            all: {
                files: [{
                    expand: true,
                    cwd: 'public/',
                    src: ['**/*'],
                    filter: 'isFile',
                    dest: ''
                }]
            },
          index: {
              files: [
                  {
                      expand: true,
                      cwd: "preflight/",
                      src: ["/index.html", "index.html/", "index.html"],
                      dest: ''
                  }
              ]
          },
          html: {
              files: [
                  {
                      expand: true,
                      cwd: "preflight/",
                      src: ["why-we--docker/", "index.html", "why-we--docker", "why-we--docker/index.html" ],
                      dest: ''
                  }
              ]
          }
        },
      clean: {
          build: ["public/*", "preflight/*"],
      },
  });

    require('matchdep').filter('grunt-*').forEach(grunt.loadNpmTasks);
    grunt.registerTask('cl', ['clean:build','shell:update']);
    grunt.registerTask("css", ["stylus","concat", "cssmin"]);
    grunt.registerTask("push_production", ["aws_s3:production", "aws_s3:gzipd"]);
    grunt.registerTask("kill_html", ["invalidate_cloudfront:html"]);
    grunt.registerTask("hugo", ["shell:build"]);
    grunt.registerTask('printConfig', function() {
        grunt.log.writeln(JSON.stringify(grunt.config(), null, 2));
    })
    var target1 = grunt.option("invalidate") || "index";
    grunt.registerTask("kill_cdn", ["invalidate_cloudfront:" + target1])
    grunt.registerTask('dev', ['clean:build',
                               'css',
                               'shell:build',
                              ]);
    grunt.registerTask("pub", ['clean:build',
                               "css",
                               "shell:update",
                               "autoprefixer",
                               "hugo",
           //                    "cacheBust",
                               "htmlmin",
                               "compress",//minify and compress because overkill is a thing!
                               'push_production',
//                               'kill_cdn'
                              ]);
};
<commit_msg>tweaks to blog post, no idea when these happened<commit_after>//require('load-grunt-tasks')(grunt);

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);

    // Project configuration.
    grunt.initConfig({
        stylus: {
          compile: {
              options: {
                  paths: ["node_modules/axis/",
                          "node_modules/jeet/stylus/",
                          "node_modules/rupture/",
                  ],
                  urlfunc: "embedurl",
              },
              files: {
                  "static/css/s.css": "styl/s.styl"
              }
          }
        },
         shell: { //me with ascidoctor.js
             build: {
                 command: function () {
                     comm = "hugo"
                     return comm
                 },
             },
             update: {
                 command: function () {
                     comm = "npm update caniuse-db"
                     return comm
                 }
             },
         },
        autoprefixer: {
             single_file: {
                 options: {
                     browsers: ["> 1%", "ie10", "ie11"]
                 },
                 src: 'static/css/s.css',
                 dest: 'static/css/s.css'
             },
        },
        cssmin: {
            options: {
                report: 'min'
            },
            main: {
                expand: true,
                cwd: 'public/',
                src: '**/*.css',
                dest: 'public/'
            }
        },
        //WARNING: never put this in a git repo dir...
        aws: grunt.file.readJSON("../grunt-aws-SECRET.json"),
        aws_s3: {
             options: {
                    accessKeyId: "<%= aws.secret %>",
                    secretAccessKey: '<%= aws.key %>',
                    bucket: "<%= aws.bucket %>",
                    region: "us-east-1",
                    access: "public-read",
                    progress: "progressBar",
                    streams: true,
                    debug: false,
                    uploadConcurrency: 30,
                },

            production: {
                options: {
                    streams: true,
                    debug: false,
                    differential: true,
                params: {
                        "CacheControl": "max-age=63072000, public",
                        "Expires": new Date(Date.now() + 6.31139e10),//.toUTCString(),
                }
                },

                files: [
                    { expand: true, dest: '.', cwd: 'public/', src: ['**/*',"!**/*.html","!**/*.css"], action: 'upload', differential: true },
                    { dest: '/', cwd: 'public/', action: 'delete', differential: true }
                ]
            },
            gzipd: {
                options: {
                    streams: true,
                    debug: false,
                    differential: true,
                params: {
                    "CacheControl": "max-age=63072000, public",
                    "Expires": new Date(Date.now() + 6.31139e10),
                    "ContentEncoding": "gzip"
                }
                },
                files: [ {expand: true, dest: ".", cwd: "preflight/", src: ["**/*.html", "**/*.css"], action:"upload", differential:true}]
            },
            production_index: {
                options: {
                    streams: true,
                    debug: false,
                    differential: false,
                params: {
                    "CacheControl": "max-age=3600, public",
                    "Expires": new Date(Date.now() + 3600),
                    "ContentEncoding": "gzip"
                }
                },
                files: [
                    { expand: true, dest: '.', cwd: 'preflight/', src: ['index.html'], action: 'upload', differential: false}
                ]
            }
        },
        cloudfront: {
            options: {
                accessKeyId: "<%= aws.secret %>",
                secretAccessKey: "<%= aws.key %>",
                distributionId: 'E9J6BU91BD488',
                invalidations: ["/*"],
            },
            all: {},
         },
        compress: {
            main: {
                options: { mode: 'gzip', pretty: true, level: 9},
                expand: true,
                cwd: "public/",
                src: ["**/*.html", "**/*.css"],
                dest: "preflight/",
            },
        },
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                expand: true,
                cwd: 'public',
                src: ['**/*.html'],
                dest: 'public/'
            }
        },
        concat: {
          css: {
              src: ['static/css/s.css', "node_modules/grunt-highlight/node_modules/highlight.js/styles/tomorrow.css"],
              dest: 'static/css/s.css'
          },
      },
  highlight: {
    task: {
      options: {},
        expand: true,
        cwd: 'public',
        src: ["**/*.html"],
        dest: "public/"
    }
  },
        clean: {
            build: ["public/*", "preflight/*"],
        },
  });

    require('matchdep').filter('grunt-*').forEach(grunt.loadNpmTasks);
    grunt.registerTask('cl', ['clean:build','shell:update']);
    grunt.registerTask("css", ["stylus","concat", "cssmin"]);
    grunt.registerTask("push_production", ["aws_s3:production", "aws_s3:gzipd"]);
    grunt.registerTask("hugo", ["shell:build"]);
    grunt.registerTask("kill", ["cloudfront:all"]);
    grunt.registerTask('dev', ['clean:build',
                               'css',
                               'shell:build',
                              ]);
    grunt.registerTask("pub", ['clean:build',
                               "css",
                               "shell:update",
                               "autoprefixer",
                               "hugo",
                               "htmlmin",
                               "compress",//minify and compress because overkill is a thing!
                               'push_production',
                              ]);
        };
<|endoftext|>


<commit_before>module.exports = function (grunt) {
    'use strict';
    grunt.initConfig({
        stylus: {
            complie: {
                options: {
                    linenos: false,
                    compress: true,
                    banner: '\/* Zhengzheng ZHANG [tychio@yeahmobi.com]\n * 2013.9.6\n *\/'
                },
                files: {
                    'country.css': 'country.styl'
                }
            }
        },
        watch: {
            css: {
                files: 'country.css',
                tasks: 'stylus'
            }
        }
    });

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

    grunt.registerTask('default', ['stylus', 'watch']);
};<commit_msg>fix watch config in grunt<commit_after>module.exports = function (grunt) {
    'use strict';
    grunt.initConfig({
        stylus: {
            complie: {
                options: {
                    linenos: false,
                    compress: true,
                    banner: '\/* Zhengzheng ZHANG [tychio@yeahmobi.com]\n * 2013.9.6\n *\/'
                },
                files: {
                    'country.css': 'country.styl'
                }
            }
        },
        watch: {
            css: {
                files: 'country.styl',
                tasks: 'stylus'
            }
        }
    });

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

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


<commit_before>'use strict';

module.exports = function (grunt) {
    require('grunt-commons')(grunt, {
        name: 'ko-grid-links',
        main: 'links',
        internalMain: 'links',

        shims: {
            'ko-grid': 'window.ko.bindingHandlers[\'grid\']'
        }
    }).initialize({});
};
<commit_msg>Added missing shim.<commit_after>'use strict';

module.exports = function (grunt) {
    require('grunt-commons')(grunt, {
        name: 'ko-grid-links',
        main: 'links',
        internalMain: 'links',

        shims: {
            knockout: 'window.ko',
            'ko-grid': 'window.ko.bindingHandlers[\'grid\']'
        }
    }).initialize({});
};
<|endoftext|>