<commit_before>"use strict";

module.exports = function( grunt ) {

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

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

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

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

            //         'lib/event.js',
            //         'lib/module-manager.js',
            //         // 'lib/biz.js',
            //         'lib/outro.js'
            //     ]
            // },

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

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

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

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

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

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

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

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

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

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

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

        mocha: {
            all: ['test/*.html'],
            options: {
                reporter: 'Spec',
                run: false,
                ignoreLeaks: false,
                timeout:5000
            }
        },

        uglify: {
            all: {
                files: {
                    "dist/neuron.min.js": [ "dist/neuron.js" ]
                },
                options: {
                    // Keep our hard-coded banner
                    preserveComments: "some",
                    // sourceMap: "dist/neuron.min.map",
                    // sourceMappingURL: "neuron.min.map",
                    report: "gzip",
                    beautify: {
                        ascii_only: true
                    },
                    compress: {
                        hoist_funs: false,
                        join_vars: false,
                        loops: false,
                        unused: false
                    },
                    mangle: {
                        // saves some bytes when gzipped
                        except: [ "undefined" ]
                    }
                }
            }
        }
    });

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

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

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

            }, '');

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

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

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

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

    );

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

    grunt.registerTask('default', ['clean', 'build', 'jshint', /* 'mocha' */, 'uglify']);

};<commit_msg>update Gruntfile<commit_after>"use strict";

module.exports = function( grunt ) {

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

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

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

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

            //         'lib/event.js',
            //         'lib/module-manager.js',
            //         // 'lib/biz.js',
            //         'lib/outro.js'
            //     ]
            // },

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

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

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

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

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

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

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

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

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

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

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

        mocha: {
            all: ['test/*.html'],
            options: {
                reporter: 'Spec',
                run: false,
                ignoreLeaks: false,
                timeout:5000
            }
        },

        uglify: {
            all: {
                files: {
                    "dist/neuron.min.js": [ "dist/neuron.js" ]
                },
                options: {
                    // Keep our hard-coded banner
                    preserveComments: "some",
                    // sourceMap: "dist/neuron.min.map",
                    // sourceMappingURL: "neuron.min.map",
                    report: "gzip",
                    beautify: {
                        ascii_only: true
                    },
                    compress: {
                        hoist_funs: false,
                        join_vars: false,
                        loops: false,
                        unused: false
                    },
                    mangle: {
                        // saves some bytes when gzipped
                        except: [ "undefined" ]
                    }
                }
            }
        }
    });

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

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

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

            }, '');

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

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

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

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

    );

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

    grunt.registerTask('default', ['clean', 'build', 'jshint', /* 'mocha' */, 'uglify']);

};<|endoftext|>


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

    var debug = typeof grunt.option('dev') !== "undefined";

    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.file.setBase('opentreemap');

    grunt.registerTask('check', ['jshint']);
    grunt.registerTask('js', debug ? ['browserify'] : ['browserify', 'uglify']);
    grunt.registerTask('css', debug ? ['sass', 'concat'] : ['sass', 'concat', 'cssmin']);
    grunt.registerTask('default', ['js', 'css']);

    /*
     * Reads the extra.json file which should be a dictionary
     * where the keys are the require.js alias and the values
     * are the path to a file, relative to `opentreemap`
     */
    function getAliases() {
        var aliases = ['treemap/js/src/map.js:map',
                       'treemap/js/src/user.js:user',
                       'treemap/js/src/mapManager.js:mapManager',
                       'treemap/js/src/plot.js:plot',
                       'treemap/js/src/searchBar.js:searchBar',
                       'treemap/js/src/buttonEnabler.js:buttonEnabler',
                       'treemap/js/src/csrf.js:csrf',
                       'treemap/js/src/photoReview.js:photoReview',
                       'treemap/js/src/baconUtils:BaconUtils',
                       'treemap/js/src/inlineEditForm:inlineEditForm',
                       'treemap/js/src/imageUploadPanel:imageUploadPanel',
                       'treemap/js/src/export.js:export',
                       'treemap/js/src/utility:utility'];

        var extras = require('./extra.json');
        for (var alias in extras) {
            var filepath = extras[alias];
            if (grunt.file.exists(filepath)) {
                aliases.push(filepath + ':' + alias);
            }
        }
        return aliases;
    }

    grunt.initConfig({
        browserify: {
            treemap: {
                src: [],
                dest: 'treemap/static/js/treemap.js',
                options: {
                    alias: getAliases(),
                    aliasMappings: {
                        cwd:'treemap/js/lib/',
                        src: ['*.js'],
                        dest: '',
                        ext: '',
                        flatten: true
                    },
                    noParse: grunt.file.expand('*/js/lib/*.js'),
                    shim: {
                        leafletgoogle: {
                            path: './treemap/js/shim/leaflet.google.js',
                            exports: null,
                            depends: { leaflet: 'L' }
                        },
                        leafletbing: {
                            path: './treemap/js/shim/leaflet.bing.js',
                            exports: null,
                            depends: { leaflet: 'L' }
                        },
                        utfgrid: {
                            path: './treemap/js/shim/leaflet.utfgrid.js',
                            exports: null,
                            depends: { leaflet: 'L' }
                        },
                        // BEGIN modules which add themselves to the jQuery object
                        typeahead: {
                            path: './treemap/js/shim/typeahead.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        bootstrap: {
                            path: './treemap/js/shim/bootstrap.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        jqueryFileUpload: {
                            path: './treemap/js/shim/jquery.fileupload.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        jqueryIframeTransport: {
                            path: './treemap/js/shim/jquery.iframe-transport.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        jqueryUiWidget: {
                            path: './treemap/js/shim/jquery.ui.widget.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        // END modules which add themselves to the jQuery object
                        jscolor: {
                            path: './treemap/js/shim/jscolor.js',
                            exports: null
                        },
                        // Bootstrap-datepicker puts itself onto the jQuery object
                        "bootstrap-datepicker": {
                            path: './treemap/js/shim/bootstrap-datepicker.js',
                            exports: null,
                            depends: { jquery: 'jQuery', bootstrap: 'bootstrap' }
                        }
                    },
                    debug: debug
                }
            }
        },
        jshint: {
            options: {
                jshintrc: "../.jshintrc"
            },
            treemap: ['../Gruntfile.js', '*/js/src/**/*.js']
        },
        uglify: {
            options: {
                mangle: {
                    except: ['require', 'google']
                }
            },
            treemap: {
                files: {
                    'treemap/static/js/treemap.min.js': ['treemap/static/js/treemap.js']
                }
            }
        },
        sass: {
            treemap: {
                options: {
                    includePaths: ['treemap/css/sass/']
                },
                files: {
                    'treemap/static/css/main.css': 'treemap/css/sass/main.scss'
                }
            }
        },
        concat: {
            treemap: {
                src: ['treemap/css/vendor/bootstrap.css',
                      'treemap/css/vendor/bootstrap-responsive.css',
                      'treemap/css/vendor/datepicker.css',
                      'treemap/css/vendor/fontello.css',
                      'treemap/css/vendor/leaflet.css'],
                dest: 'treemap/static/css/vendor.css'
            }
        },
        cssmin: {
            treemap: {
                files: {
                    'treemap/static/css/vendor.min.css': ['treemap/static/css/vendor.css'],
                    'treemap/static/css/main.min.css': ['treemap/static/css/main.css']
                }
            }
        }
    });
};
<commit_msg>Use file extensions in alias list.<commit_after>module.exports = function(grunt) {
    "use strict";

    var debug = typeof grunt.option('dev') !== "undefined";

    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.file.setBase('opentreemap');

    grunt.registerTask('check', ['jshint']);
    grunt.registerTask('js', debug ? ['browserify'] : ['browserify', 'uglify']);
    grunt.registerTask('css', debug ? ['sass', 'concat'] : ['sass', 'concat', 'cssmin']);
    grunt.registerTask('default', ['js', 'css']);

    /*
     * Reads the extra.json file which should be a dictionary
     * where the keys are the require.js alias and the values
     * are the path to a file, relative to `opentreemap`
     */
    function getAliases() {
        var aliases = ['treemap/js/src/map.js:map',
                       'treemap/js/src/user.js:user',
                       'treemap/js/src/mapManager.js:mapManager',
                       'treemap/js/src/plot.js:plot',
                       'treemap/js/src/searchBar.js:searchBar',
                       'treemap/js/src/buttonEnabler.js:buttonEnabler',
                       'treemap/js/src/csrf.js:csrf',
                       'treemap/js/src/photoReview.js:photoReview',
                       'treemap/js/src/baconUtils.js:BaconUtils',
                       'treemap/js/src/inlineEditForm.js:inlineEditForm',
                       'treemap/js/src/imageUploadPanel.js:imageUploadPanel',
                       'treemap/js/src/export.js:export',
                       'treemap/js/src/utility.js:utility'];

        var extras = require('./extra.json');
        for (var alias in extras) {
            var filepath = extras[alias];
            if (grunt.file.exists(filepath)) {
                aliases.push(filepath + ':' + alias);
            }
        }
        return aliases;
    }

    grunt.initConfig({
        browserify: {
            treemap: {
                src: [],
                dest: 'treemap/static/js/treemap.js',
                options: {
                    alias: getAliases(),
                    aliasMappings: {
                        cwd:'treemap/js/lib/',
                        src: ['*.js'],
                        dest: '',
                        ext: '',
                        flatten: true
                    },
                    noParse: grunt.file.expand('*/js/lib/*.js'),
                    shim: {
                        leafletgoogle: {
                            path: './treemap/js/shim/leaflet.google.js',
                            exports: null,
                            depends: { leaflet: 'L' }
                        },
                        leafletbing: {
                            path: './treemap/js/shim/leaflet.bing.js',
                            exports: null,
                            depends: { leaflet: 'L' }
                        },
                        utfgrid: {
                            path: './treemap/js/shim/leaflet.utfgrid.js',
                            exports: null,
                            depends: { leaflet: 'L' }
                        },
                        // BEGIN modules which add themselves to the jQuery object
                        typeahead: {
                            path: './treemap/js/shim/typeahead.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        bootstrap: {
                            path: './treemap/js/shim/bootstrap.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        jqueryFileUpload: {
                            path: './treemap/js/shim/jquery.fileupload.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        jqueryIframeTransport: {
                            path: './treemap/js/shim/jquery.iframe-transport.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        jqueryUiWidget: {
                            path: './treemap/js/shim/jquery.ui.widget.js',
                            exports: null,
                            depends: { jquery: 'jQuery' }
                        },
                        // END modules which add themselves to the jQuery object
                        jscolor: {
                            path: './treemap/js/shim/jscolor.js',
                            exports: null
                        },
                        // Bootstrap-datepicker puts itself onto the jQuery object
                        "bootstrap-datepicker": {
                            path: './treemap/js/shim/bootstrap-datepicker.js',
                            exports: null,
                            depends: { jquery: 'jQuery', bootstrap: 'bootstrap' }
                        }
                    },
                    debug: debug
                }
            }
        },
        jshint: {
            options: {
                jshintrc: "../.jshintrc"
            },
            treemap: ['../Gruntfile.js', '*/js/src/**/*.js']
        },
        uglify: {
            options: {
                mangle: {
                    except: ['require', 'google']
                }
            },
            treemap: {
                files: {
                    'treemap/static/js/treemap.min.js': ['treemap/static/js/treemap.js']
                }
            }
        },
        sass: {
            treemap: {
                options: {
                    includePaths: ['treemap/css/sass/']
                },
                files: {
                    'treemap/static/css/main.css': 'treemap/css/sass/main.scss'
                }
            }
        },
        concat: {
            treemap: {
                src: ['treemap/css/vendor/bootstrap.css',
                      'treemap/css/vendor/bootstrap-responsive.css',
                      'treemap/css/vendor/datepicker.css',
                      'treemap/css/vendor/fontello.css',
                      'treemap/css/vendor/leaflet.css'],
                dest: 'treemap/static/css/vendor.css'
            }
        },
        cssmin: {
            treemap: {
                files: {
                    'treemap/static/css/vendor.min.css': ['treemap/static/css/vendor.css'],
                    'treemap/static/css/main.min.css': ['treemap/static/css/main.css']
                }
            }
        }
    });
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    jshint: {
      files: [
        'app/**/*.js',
        'admin/**/*.js',
        'test/**/*.js',
        'shared/**/*.js',
        'server/**/*.js'
      ],
      options: {
        globals: {
          window: true,
          document: true,
          navigator: true,
          console: true,
          module: true,
          require: true,
          FastClick: true,
          $: true,
          Backbone: true,
          Parse: true,
          Handlebars: true,
          _: true,
          google: true,
          parseAppKey: true,
          parseJSKey: true
        },
        undef: true,
        debug: true,
        '-W030': true
      }
    },

    // A simple Grunt invoker for mocha tests
    simplemocha: {
      options: {
        timeout: 3000,
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'list'
      },

      all: {
        src: 'test/**/*.js'
      }
    },

    // run the 'default' task when any watched files change
    watch: {
      files: [
        'Gruntfile.js',
        'app/**/*',
        'admin/**/*',
        'shared/**/*',
        'server/**/*',
        'vendor/**/*',
        'test/**/*'
      ],
      tasks: ['default']
    },

    sass: {
      // generate app-specific css file
      app: {
        src: 'app/css/app.scss',
        dest: 'tmp/linksf.css'
      },

      admin: {
        src: 'admin/css/admin.scss',
        dest: 'tmp/linksf_admin.css'
      }
    },

    // Browserify
    browserify: {
      options: {
        // We want `.hbs` files to be `require`able. We use the hbsfy transform
        // to precompile Handlebars templates and let us require the compiled
        // JavaScript functions.
        transform: ['hbsfy']
      },
      app: {
        // The entry point where Browserify will begin searching the AST for `require` calls
        src: 'app/js/app.js',

        // The built file
        dest: 'tmp/app.js',

        options: {
          // We want alias mappings because we'd rather
          // `require('views/index_view')` than `require('./views/index_view.js')`
          //
          // There is a tradeoff for convenient here - all aliased files are exported
          // into the built app.js file, even if they're never explicitly
          // `require`d from the entry point tree.
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'app/js/lib',            src: '*.js',  dest: 'lib' },
            { cwd: 'app/js/models',         src: '*.js',  dest: 'models' },
            { cwd: 'app/js/collections',    src: '*.js',  dest: 'collections' },
            { cwd: 'app/js/routers',        src: '*.js',  dest: 'routers' },
            { cwd: 'app/js/templates',      src: '*.hbs', dest: 'templates' },
            { cwd: 'app/js/views',          src: '*.js',  dest: 'views' }
          ]
        }
      },
      // See browserify:app above
      admin: {
        src: 'admin/js/admin.js',
        dest: 'tmp/admin.js',
        options: {
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'admin/js/lib',          src: '*.js',  dest: 'lib' },
            { cwd: 'admin/js/models',       src: '*.js',  dest: 'models' },
            { cwd: 'admin/js/collections',  src: '*.js',  dest: 'collections' },
            { cwd: 'admin/js/routers',      src: '*.js',  dest: 'routers' },
            { cwd: 'admin/js/templates',    src: '*.hbs', dest: 'templates' },
            { cwd: 'admin/js/views',        src: '*.js',  dest: 'views' }
          ]
        }
      }
    },

    // Minify css files
    cssmin: {
      app: {
        src: 'tmp/linksf.css',
        dest: 'tmp/linksf.css'
      },
      admin: {
        src: 'tmp/linksf_admin.css',
        dest: 'tmp/linksf_admin.css'
      },
    },

    // Concatenate files together.
    concat: {
      // Not a target, just a variable that we can interpolate in elsewhere.
      shared_js: [
        'vendor/js/jquery-2.0.3.js',
        'vendor/js/jquery.serialize-object.js',
        'vendor/js/bootstrap-button.js',
        'vendor/js/underscore.js',
        'vendor/js/backbone-1.0.0.js',
        'vendor/js/parse-1.2.12.js'
      ],

      shared_js_minified: [
        'vendor/js/jquery-2.0.3.min.js',
        'vendor/js/jquery.serialize-object.min.js',
        'vendor/js/bootstrap-button.min.js',
        'vendor/js/underscore.min.js',
        'vendor/js/backbone-1.0.0.min.js',
        'vendor/js/parse-1.2.12.min.js'
      ],

      // App also uses the vendored fastclick library
      app: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/fastclick.js',
          'tmp/app.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Concat minified files
      app_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/fastclick.min.js',
          'tmp/app.min.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Admin uses backbone filters for authentication and autosize for text entry
      admin: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/backbone_filters.js',
          'vendor/js/jquery.autosize.js',
          'vendor/js/bootstrap.js',
          'tmp/admin.js'
        ],
        dest: 'tmp/linksf_admin.js'
      },

      admin_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/backbone_filters.min.js',
          'vendor/js/jquery.autosize.min.js',
          'vendor/js/bootstrap.min.js',
          'tmp/admin.min.js'
        ],
        dest: 'tmp/linksf_admin.js'
      }
    },

    uglify: {
      options: {
        mangle: false,
        preserveComments: false,
        report: 'min'
      },

      vendor: {
        files: {
          // These libraries are not distributed with minified versions, so we
          // minify them ourselves.
          'vendor/js/jquery.serialize-object.min.js': 'vendor/js/jquery.serialize-object.js',
          'vendor/js/backbone_filters.min.js': 'vendor/js/backbone_filters.js',
          'vendor/js/bootstrap-button.min.js': 'vendor/js/bootstrap-button.js'
        }
      },
      app: {files: {'tmp/app.min.js': 'tmp/app.js'}},
      admin: {files: {'tmp/admin.min.js': 'tmp/admin.js'}}
    },

    clean: {
      build: {
        src: 'build/*',
        filter: function(filepath) { return filepath !== 'build/.gitkeep'; }
      }
    },

    cachebuster: {
      dist: {
        files: {
          src: [
            'tmp/linksf.js',
            'tmp/linksf.css',
            'tmp/linksf_admin.js',
            'tmp/linksf_admin.css'
          ],
        },
        options: {
          complete: function(hashes) {
            // ugly but the only way to tag each file with a key
            var keyMap = {
                'tmp/linksf.js': 'linksf_js',
                'tmp/linksf.css': 'linksf_css',
                'tmp/linksf_admin.js': 'linksf_admin_js',
                'tmp/linksf_admin.css': 'linksf_admin_css'
               },
               context = {},
               Handlebars = require('handlebars'),
               template,
               output;

            context.parseAppKey = process.env.PARSE_APP_KEY || 'Y213cb9EqDqUka0d56iQ1ZEyCeqsi4TMIh5zGTtY';
            context.parseJSKey  = process.env.PARSE_JS_KEY || 'CJrY4twgkR8KluQEtgMrbtciyk9rIFkILLxCRZGq';

            Object.keys(hashes).forEach(function(key) {
              var matches = key.match(/^tmp\/(.*)(\..*)$/),
                  outputFile = 'build/' + matches[1] + '-' + hashes[key] + matches[2];

              grunt.file.copy(key, outputFile);
              context[keyMap[key]] = outputFile;
            });

            template = Handlebars.compile(grunt.file.read('app/index.html'));
            output = template(context);
            grunt.file.write('index.html', output);

            template = Handlebars.compile(grunt.file.read('admin/admin.html'));
            output = template(context);
            grunt.file.write('admin.html', output);
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-cachebuster');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');

  grunt.registerTask('build:development', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'browserify',
    'concat:app',
    'concat:admin',
    'cachebuster'
  ]);

  grunt.registerTask('build:production', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'cssmin',
    'browserify',
    'uglify',
    'concat:app_min',
    'concat:admin_min',
    'cachebuster'
  ]);

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

  grunt.registerTask('release', [
    'build:production'
  ]);
};
<commit_msg>add note about sass's responsibilities<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    jshint: {
      files: [
        'app/**/*.js',
        'admin/**/*.js',
        'test/**/*.js',
        'shared/**/*.js',
        'server/**/*.js'
      ],
      options: {
        globals: {
          window: true,
          document: true,
          navigator: true,
          console: true,
          module: true,
          require: true,
          FastClick: true,
          $: true,
          Backbone: true,
          Parse: true,
          Handlebars: true,
          _: true,
          google: true,
          parseAppKey: true,
          parseJSKey: true
        },
        undef: true,
        debug: true,
        '-W030': true
      }
    },

    // A simple Grunt invoker for mocha tests
    simplemocha: {
      options: {
        timeout: 3000,
        ignoreLeaks: false,
        ui: 'bdd',
        reporter: 'list'
      },

      all: {
        src: 'test/**/*.js'
      }
    },

    // run the 'default' task when any watched files change
    watch: {
      files: [
        'Gruntfile.js',
        'app/**/*',
        'admin/**/*',
        'shared/**/*',
        'server/**/*',
        'vendor/**/*',
        'test/**/*'
      ],
      tasks: ['default']
    },

    sass: {
      // generate app-specific css file
      // sass performs both the processing and concatenation steps for css
      app: {
        src: 'app/css/app.scss',
        dest: 'tmp/linksf.css'
      },

      admin: {
        src: 'admin/css/admin.scss',
        dest: 'tmp/linksf_admin.css'
      }
    },

    // Browserify
    browserify: {
      options: {
        // We want `.hbs` files to be `require`able. We use the hbsfy transform
        // to precompile Handlebars templates and let us require the compiled
        // JavaScript functions.
        transform: ['hbsfy']
      },
      app: {
        // The entry point where Browserify will begin searching the AST for `require` calls
        src: 'app/js/app.js',

        // The built file
        dest: 'tmp/app.js',

        options: {
          // We want alias mappings because we'd rather
          // `require('views/index_view')` than `require('./views/index_view.js')`
          //
          // There is a tradeoff for convenient here - all aliased files are exported
          // into the built app.js file, even if they're never explicitly
          // `require`d from the entry point tree.
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'app/js/lib',            src: '*.js',  dest: 'lib' },
            { cwd: 'app/js/models',         src: '*.js',  dest: 'models' },
            { cwd: 'app/js/collections',    src: '*.js',  dest: 'collections' },
            { cwd: 'app/js/routers',        src: '*.js',  dest: 'routers' },
            { cwd: 'app/js/templates',      src: '*.hbs', dest: 'templates' },
            { cwd: 'app/js/views',          src: '*.js',  dest: 'views' }
          ]
        }
      },
      // See browserify:app above
      admin: {
        src: 'admin/js/admin.js',
        dest: 'tmp/admin.js',
        options: {
          aliasMappings: [
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'shared/lib' },
            { cwd: 'shared/js/lib',         src: '*.js',  dest: 'cloud/lib' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'shared/models' },
            { cwd: 'shared/js/models',      src: '*.js',  dest: 'cloud/models' },
            { cwd: 'shared/js/collections', src: '*.js',  dest: 'shared/collections' },
            { cwd: 'shared/js/views',       src: '*.js',  dest: 'shared/views' },
            { cwd: 'shared/js/templates',   src: '*.hbs', dest: 'shared/templates' },
            { cwd: 'admin/js/lib',          src: '*.js',  dest: 'lib' },
            { cwd: 'admin/js/models',       src: '*.js',  dest: 'models' },
            { cwd: 'admin/js/collections',  src: '*.js',  dest: 'collections' },
            { cwd: 'admin/js/routers',      src: '*.js',  dest: 'routers' },
            { cwd: 'admin/js/templates',    src: '*.hbs', dest: 'templates' },
            { cwd: 'admin/js/views',        src: '*.js',  dest: 'views' }
          ]
        }
      }
    },

    // Minify css files
    cssmin: {
      app: {
        src: 'tmp/linksf.css',
        dest: 'tmp/linksf.css'
      },
      admin: {
        src: 'tmp/linksf_admin.css',
        dest: 'tmp/linksf_admin.css'
      },
    },

    // Concatenate files together.
    concat: {
      // Not a target, just a variable that we can interpolate in elsewhere.
      shared_js: [
        'vendor/js/jquery-2.0.3.js',
        'vendor/js/jquery.serialize-object.js',
        'vendor/js/bootstrap-button.js',
        'vendor/js/underscore.js',
        'vendor/js/backbone-1.0.0.js',
        'vendor/js/parse-1.2.12.js'
      ],

      shared_js_minified: [
        'vendor/js/jquery-2.0.3.min.js',
        'vendor/js/jquery.serialize-object.min.js',
        'vendor/js/bootstrap-button.min.js',
        'vendor/js/underscore.min.js',
        'vendor/js/backbone-1.0.0.min.js',
        'vendor/js/parse-1.2.12.min.js'
      ],

      // App also uses the vendored fastclick library
      app: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/fastclick.js',
          'tmp/app.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Concat minified files
      app_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/fastclick.min.js',
          'tmp/app.min.js'
        ],
        dest: 'tmp/linksf.js'
      },

      // Admin uses backbone filters for authentication and autosize for text entry
      admin: {
        src: [
          '<%= concat.shared_js %>',
          'vendor/js/backbone_filters.js',
          'vendor/js/jquery.autosize.js',
          'vendor/js/bootstrap.js',
          'tmp/admin.js'
        ],
        dest: 'tmp/linksf_admin.js'
      },

      admin_min: {
        src: [
          '<%= concat.shared_js_minified %>',
          'vendor/js/backbone_filters.min.js',
          'vendor/js/jquery.autosize.min.js',
          'vendor/js/bootstrap.min.js',
          'tmp/admin.min.js'
        ],
        dest: 'tmp/linksf_admin.js'
      }
    },

    uglify: {
      options: {
        mangle: false,
        preserveComments: false,
        report: 'min'
      },

      vendor: {
        files: {
          // These libraries are not distributed with minified versions, so we
          // minify them ourselves.
          'vendor/js/jquery.serialize-object.min.js': 'vendor/js/jquery.serialize-object.js',
          'vendor/js/backbone_filters.min.js': 'vendor/js/backbone_filters.js',
          'vendor/js/bootstrap-button.min.js': 'vendor/js/bootstrap-button.js'
        }
      },
      app: {files: {'tmp/app.min.js': 'tmp/app.js'}},
      admin: {files: {'tmp/admin.min.js': 'tmp/admin.js'}}
    },

    clean: {
      build: {
        src: 'build/*',
        filter: function(filepath) { return filepath !== 'build/.gitkeep'; }
      }
    },

    cachebuster: {
      dist: {
        files: {
          src: [
            'tmp/linksf.js',
            'tmp/linksf.css',
            'tmp/linksf_admin.js',
            'tmp/linksf_admin.css'
          ],
        },
        options: {
          complete: function(hashes) {
            // ugly but the only way to tag each file with a key
            var keyMap = {
                'tmp/linksf.js': 'linksf_js',
                'tmp/linksf.css': 'linksf_css',
                'tmp/linksf_admin.js': 'linksf_admin_js',
                'tmp/linksf_admin.css': 'linksf_admin_css'
               },
               context = {},
               Handlebars = require('handlebars'),
               template,
               output;

            context.parseAppKey = process.env.PARSE_APP_KEY || 'Y213cb9EqDqUka0d56iQ1ZEyCeqsi4TMIh5zGTtY';
            context.parseJSKey  = process.env.PARSE_JS_KEY || 'CJrY4twgkR8KluQEtgMrbtciyk9rIFkILLxCRZGq';

            Object.keys(hashes).forEach(function(key) {
              var matches = key.match(/^tmp\/(.*)(\..*)$/),
                  outputFile = 'build/' + matches[1] + '-' + hashes[key] + matches[2];

              grunt.file.copy(key, outputFile);
              context[keyMap[key]] = outputFile;
            });

            template = Handlebars.compile(grunt.file.read('app/index.html'));
            output = template(context);
            grunt.file.write('index.html', output);

            template = Handlebars.compile(grunt.file.read('admin/admin.html'));
            output = template(context);
            grunt.file.write('admin.html', output);
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-simple-mocha');
  grunt.loadNpmTasks('grunt-cachebuster');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');

  grunt.registerTask('build:development', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'browserify',
    'concat:app',
    'concat:admin',
    'cachebuster'
  ]);

  grunt.registerTask('build:production', [
    'clean',
    'jshint',
    'simplemocha',
    'sass',
    'cssmin',
    'browserify',
    'uglify',
    'concat:app_min',
    'concat:admin_min',
    'cachebuster'
  ]);

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

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


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

	var env = grunt.option('env') || 'staging';

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

		ngconstant: {
			// Options for all targets
			options: {
				name: 'env.config',
			},
			// Environment targets
			development: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'development',
						apiCadastaRoot: 'http://localhost:9000',
						apiCKANRoot: 'http://localhost:5000/api/3/action'
					}
				}
			},
			staging: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'staging',
						apiCadastaRoot: 'http://54.69.121.180:3000',
						apiCKANRoot: 'http://cadasta-staging.spatialdevmo.com/api/3/action'
					}
				}
			},
			local_staging: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'staging',
						apiCadastaRoot: 'http://54.69.121.180:3000',
						apiCKANRoot: 'http://localhost:5000/api/3/action'
					}
				}
			},
			demo: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'demo',
						apiCadastaRoot: 'http://54.69.121.180:3001',
						apiCKANRoot: 'http://cadasta-demo.spatialdevmo.com/api/3/action'
					}
				}
			},
			production: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'production',
						apiCadastaRoot: 'http://54.69.121.180:3000',
						apiCKANRoot: 'http://cadasta-staging.spatialdevmo.com/api/3/action'
					}
				}
			}
		},

		cachebreaker: {
			projectDashboard: {
				options: {
					match: ["project-dashboard-app.min.js", "project-dashboard-app.min.css"],
				},
				files: {
					src: ['ckanext/project/templates/project/read_base.html']
				}
			},

			organizationDashboard: {
				options: {
					match: ["organization-dashboard-app.min.js", "organization-dashboard-app.min.css"],
				},
				files: {
					src: ['ckanext/project/templates/organization/read_base.html']
				}
			}
		},

		uglify: {
			options: {
				mangle: false
			},
			projectDashboard: {
				options: {
					sourceMap: true,
					sourceMapName: function(){
						return 'ckanext/project/public/build/project-dashboard-app.min.map';
					}
				},
				files: {
					'ckanext/project/public/build/project-dashboard-app.min.js': [
						"ckanext/project/public/shared/src/app.config.js",
						"ckanext/project/public/shared/src/env.config.js",
						"ckanext/project/public/shared/src/modules/params-manager.js",
						"ckanext/project/public/project-dashboard/src/project-dashboard-app.js",
						"ckanext/project/public/project-dashboard/src/services/dataService.js",
						"ckanext/project/public/shared/src/services/userService.js",
						"ckanext/project/public/project-dashboard/src/services/mapUtilityService.js",
						"ckanext/project/public/shared/src/services/utilityService.js",
						"ckanext/project/public/project-dashboard/src/services/parcelService.js",
						"ckanext/project/public/project-dashboard/src/services/relationshipService.js",
						"ckanext/project/public/shared/src/services/onaService.js",
						"ckanext/project/public/project-dashboard/src/services/uploadResourceService.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-overview.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-parcels.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-parcel.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-map.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-relationship.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-relationships.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-resources.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-activity_list.js",
						"ckanext/project/public/project-dashboard/src/controllers/tabs.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-header.js",
						"ckanext/project/public/project-dashboard/src/controllers/breadcrumbs.js",
						"ckanext/project/public/project-dashboard/src/controllers/field-data.js",
						"ckanext/project/public/shared/src/directives/sticky-state.js",
						"ckanext/project/public/shared/src/other_scripts/custom_jquery.js",
						"ckanext/project/public/project-dashboard/src/other_scripts/custom_jquery.js"
					]
				}
			},
			organizationDashboard: {
				options: {
					sourceMap: true,
					sourceMapName: function(){
						return 'ckanext/project/public/build/organization-dashboard-app.min.map';
					}
				},
				files: {
					'ckanext/project/public/build/organization-dashboard-app.min.js': [
						"ckanext/project/public/shared/src/config.js",
						"ckanext/project/public/organization-dashboard/src/modules/params-manager.js",
						"ckanext/project/public/organization-dashboard/src/organization-dashboard-app.js",
						//"ckanext/project/public/shared/src/services/userService.js",
						"ckanext/project/public/organization-dashboard/src/services/dataService.js",
						"ckanext/project/public/organization-dashboard/src/controllers/tabs.js",
						"ckanext/project/public/organization-dashboard/src/controllers/organization-header.js",
						"ckanext/project/public/organization-dashboard/src/controllers/organization-overview.js",
						"ckanext/project/public/organization-dashboard/src/controllers/organization-members.js",
						"ckanext/project/public/organization-dashboard/src/controllers/breadcrumbs.js",
						"ckanext/project/public/organization-dashboard/src/directives/sticky-state.js",
						"ckanext/project/public/shared/src/other_scripts/custom_jquery.js",
						"ckanext/project/public/organization-dashboard/src/other_scripts/custom_jquery.js"

					]
				}
			}
		},

		cssmin: {
			options: {
				shorthandCompacting: false,
				roundingPrecision: -1
			},
			projectDashboard: {
				files: {
					'ckanext/project/public/build/project-dashboard-app.min.css': [
						"ckanext/project/public/shared/styles/style.css",
						"ckanext/project/public/shared/styles/breadcrumbs.css",
						"ckanext/project/public/shared/styles/ckanext_project.css",
						"ckanext/project/public/shared/styles/material-design-icons.css",
						"ckanext/project/public/shared/styles/tabs.css",
						"ckanext/project/public/project-dashboard/styles/parcels.css",
						"ckanext/project/public/project-dashboard/styles/project_overview.css",
						"ckanext/project/public/project-dashboard/styles/project-map-tab.css",
						"ckanext/project/public/project-dashboard/styles/activity_resources_tab.css"]
				}
			},
			organizationDashboard: {
				files: {
					'ckanext/project/public/build/organization-dashboard-app.min.css': [
						"ckanext/project/public/shared/styles/style.css",
						"ckanext/project/public/organization-dashboard/styles/org-overview.css",
						"ckanext/project/public/shared/styles/breadcrumbs.css",
						"ckanext/project/public/shared/styles/ckanext_project.css",
						"ckanext/project/public/shared/styles/material-design-icons.css",
						"ckanext/project/public/shared/styles/tabs.css"]
				}
			}
		},

		watch: {
			code: {
				files: [
					'ckanext/project/public/shared/src/**',
					'ckanext/project/public/shared/styles/**',
					'ckanext/project/public/organization-dashboard/src/**',
					'ckanext/project/public/organization-dashboard/styles/**',
					'ckanext/project/public/project-dashboard/src/**',
					'ckanext/project/public/project-dashboard/styles/**'
				],
				tasks: ['build'],
				options: {
					spawn: false,
				},
			},
		}

	});

	grunt.loadNpmTasks('grunt-ng-constant');
	grunt.loadNpmTasks('grunt-cache-breaker');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-watch');

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

	grunt.registerTask('build', ['ngconstant:' + env,'uglify:projectDashboard','uglify:organizationDashboard', 'cssmin:projectDashboard','cssmin:organizationDashboard', 'cachebreaker:projectDashboard', 'cachebreaker:organizationDashboard']);
};<commit_msg>Add proper grunt file includes<commit_after>module.exports = function(grunt) {

	var env = grunt.option('env') || 'staging';

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

		ngconstant: {
			// Options for all targets
			options: {
				name: 'env.config',
			},
			// Environment targets
			development: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'development',
						apiCadastaRoot: 'http://localhost:9000',
						apiCKANRoot: 'http://localhost:5000/api/3/action'
					}
				}
			},
			staging: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'staging',
						apiCadastaRoot: 'http://54.69.121.180:3000',
						apiCKANRoot: 'http://cadasta-staging.spatialdevmo.com/api/3/action'
					}
				}
			},
			local_staging: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'staging',
						apiCadastaRoot: 'http://54.69.121.180:3000',
						apiCKANRoot: 'http://localhost:5000/api/3/action'
					}
				}
			},
			demo: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'demo',
						apiCadastaRoot: 'http://54.69.121.180:3001',
						apiCKANRoot: 'http://cadasta-demo.spatialdevmo.com/api/3/action'
					}
				}
			},
			production: {
				options: {
					dest: 'ckanext/project/public/shared/src/env.config.js'
				},
				constants: {
					ENV: {
						name: 'production',
						apiCadastaRoot: 'http://54.69.121.180:3000',
						apiCKANRoot: 'http://cadasta-staging.spatialdevmo.com/api/3/action'
					}
				}
			}
		},

		cachebreaker: {
			projectDashboard: {
				options: {
					match: ["project-dashboard-app.min.js", "project-dashboard-app.min.css"],
				},
				files: {
					src: ['ckanext/project/templates/project/read_base.html']
				}
			},

			organizationDashboard: {
				options: {
					match: ["organization-dashboard-app.min.js", "organization-dashboard-app.min.css"],
				},
				files: {
					src: ['ckanext/project/templates/organization/read_base.html']
				}
			}
		},

		uglify: {
			options: {
				mangle: false
			},
			projectDashboard: {
				options: {
					sourceMap: true,
					sourceMapName: function(){
						return 'ckanext/project/public/build/project-dashboard-app.min.map';
					}
				},
				files: {
					'ckanext/project/public/build/project-dashboard-app.min.js': [
						"ckanext/project/public/shared/src/app.config.js",
						"ckanext/project/public/shared/src/env.config.js",
						"ckanext/project/public/shared/src/modules/params-manager.js",
						"ckanext/project/public/project-dashboard/src/project-dashboard-app.js",
						"ckanext/project/public/project-dashboard/src/services/dataService.js",
						"ckanext/project/public/shared/src/services/userService.js",
						"ckanext/project/public/project-dashboard/src/services/mapUtilityService.js",
						"ckanext/project/public/shared/src/services/utilityService.js",
						"ckanext/project/public/project-dashboard/src/services/parcelService.js",
						"ckanext/project/public/project-dashboard/src/services/relationshipService.js",
						"ckanext/project/public/shared/src/services/onaService.js",
						"ckanext/project/public/project-dashboard/src/services/uploadResourceService.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-overview.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-parcels.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-parcel.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-map.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-relationship.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-relationships.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-resources.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-activity_list.js",
						"ckanext/project/public/project-dashboard/src/controllers/tabs.js",
						"ckanext/project/public/project-dashboard/src/controllers/project-header.js",
						"ckanext/project/public/project-dashboard/src/controllers/breadcrumbs.js",
						"ckanext/project/public/project-dashboard/src/controllers/field-data.js",
						"ckanext/project/public/shared/src/directives/sticky-state.js",
						"ckanext/project/public/shared/src/other_scripts/custom_jquery.js",
						"ckanext/project/public/project-dashboard/src/other_scripts/custom_jquery.js"
					]
				}
			},
			organizationDashboard: {
				options: {
					sourceMap: true,
					sourceMapName: function(){
						return 'ckanext/project/public/build/organization-dashboard-app.min.map';
					}
				},
				files: {
					'ckanext/project/public/build/organization-dashboard-app.min.js': [
						"ckanext/project/public/shared/src/app.config.js",
						"ckanext/project/public/shared/src/env.config.js",
						"ckanext/project/public/organization-dashboard/src/modules/params-manager.js",
						"ckanext/project/public/organization-dashboard/src/organization-dashboard-app.js",
						//"ckanext/project/public/shared/src/services/userService.js",
						"ckanext/project/public/organization-dashboard/src/services/dataService.js",
						"ckanext/project/public/organization-dashboard/src/controllers/tabs.js",
						"ckanext/project/public/organization-dashboard/src/controllers/organization-header.js",
						"ckanext/project/public/organization-dashboard/src/controllers/organization-overview.js",
						"ckanext/project/public/organization-dashboard/src/controllers/organization-members.js",
						"ckanext/project/public/organization-dashboard/src/controllers/breadcrumbs.js",
						"ckanext/project/public/organization-dashboard/src/directives/sticky-state.js",
						"ckanext/project/public/shared/src/other_scripts/custom_jquery.js",
						"ckanext/project/public/organization-dashboard/src/other_scripts/custom_jquery.js"

					]
				}
			}
		},

		cssmin: {
			options: {
				shorthandCompacting: false,
				roundingPrecision: -1
			},
			projectDashboard: {
				files: {
					'ckanext/project/public/build/project-dashboard-app.min.css': [
						"ckanext/project/public/shared/styles/style.css",
						"ckanext/project/public/shared/styles/breadcrumbs.css",
						"ckanext/project/public/shared/styles/ckanext_project.css",
						"ckanext/project/public/shared/styles/material-design-icons.css",
						"ckanext/project/public/shared/styles/tabs.css",
						"ckanext/project/public/project-dashboard/styles/parcels.css",
						"ckanext/project/public/project-dashboard/styles/project_overview.css",
						"ckanext/project/public/project-dashboard/styles/project-map-tab.css",
						"ckanext/project/public/project-dashboard/styles/activity_resources_tab.css"]
				}
			},
			organizationDashboard: {
				files: {
					'ckanext/project/public/build/organization-dashboard-app.min.css': [
						"ckanext/project/public/shared/styles/style.css",
						"ckanext/project/public/organization-dashboard/styles/org-overview.css",
						"ckanext/project/public/shared/styles/breadcrumbs.css",
						"ckanext/project/public/shared/styles/ckanext_project.css",
						"ckanext/project/public/shared/styles/material-design-icons.css",
						"ckanext/project/public/shared/styles/tabs.css"]
				}
			}
		},

		watch: {
			code: {
				files: [
					'ckanext/project/public/shared/src/**',
					'ckanext/project/public/shared/styles/**',
					'ckanext/project/public/organization-dashboard/src/**',
					'ckanext/project/public/organization-dashboard/styles/**',
					'ckanext/project/public/project-dashboard/src/**',
					'ckanext/project/public/project-dashboard/styles/**'
				],
				tasks: ['build'],
				options: {
					spawn: false,
				},
			},
		}

	});

	grunt.loadNpmTasks('grunt-ng-constant');
	grunt.loadNpmTasks('grunt-cache-breaker');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-watch');

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

	grunt.registerTask('build', ['ngconstant:' + env,'uglify:projectDashboard','uglify:organizationDashboard', 'cssmin:projectDashboard','cssmin:organizationDashboard', 'cachebreaker:projectDashboard', 'cachebreaker:organizationDashboard']);
};<|endoftext|>


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

  var bower = grunt.file.readJSON('bower.json');
  var components = [];
  for (var i in bower.concat.app) {
    components.push('components/' + bower.concat.app[i] + '/**/*.js');
  }
  components.push('components/' + 'webaudiorecorder/lib/WebAudioRecorder.js');

  var libtextsecurecomponents = [];
  for (i in bower.concat.libtextsecure) {
    libtextsecurecomponents.push('components/' + bower.concat.libtextsecure[i] + '/**/*.js');
  }

  var importOnce = require("node-sass-import-once");
  grunt.loadNpmTasks("grunt-sass");

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      components: {
        src: components,
        dest: 'js/components.js',
      },
      libtextsecurecomponents: {
        src: libtextsecurecomponents,
        dest: 'libtextsecure/components.js',
      },
      test: {
        src: [
          'components/mocha/mocha.js',
          'components/chai/chai.js',
          'test/_test.js'
        ],
        dest: 'test/test.js',
      },
      //TODO: Move errors back down?
      libtextsecure: {
        options: {
          banner: ";(function() {\n",
          footer: "})();\n",
        },
        src: [
          'libtextsecure/errors.js',
          'libtextsecure/libsignal-protocol.js',
          'libtextsecure/protocol_wrapper.js',

          'libtextsecure/crypto.js',
          'libtextsecure/storage.js',
          'libtextsecure/storage/user.js',
          'libtextsecure/storage/groups.js',
          'libtextsecure/storage/unprocessed.js',
          'libtextsecure/protobufs.js',
          'libtextsecure/websocket-resources.js',
          'libtextsecure/helpers.js',
          'libtextsecure/stringview.js',
          'libtextsecure/event_target.js',
          'libtextsecure/api.js',
          'libtextsecure/account_manager.js',
          'libtextsecure/message_receiver.js',
          'libtextsecure/outgoing_message.js',
          'libtextsecure/sendmessage.js',
          'libtextsecure/sync_request.js',
          'libtextsecure/contacts_parser.js',
          'libtextsecure/ProvisioningCipher.js',
          'libtextsecure/task_with_timeout.js',
        ],
        dest: 'js/libtextsecure.js',
      },
      libtextsecuretest: {
        src: [
          'components/jquery/dist/jquery.js',
          'components/mock-socket/dist/mock-socket.js',
          'components/mocha/mocha.js',
          'components/chai/chai.js',
          'libtextsecure/test/_test.js'
        ],
        dest: 'libtextsecure/test/test.js',
      }
    },
    sass: {
      options: {
        sourceMap: true,
        importer: importOnce
      },
      dev: {
        files: {
          "stylesheets/manifest.css": "stylesheets/manifest.scss"
        }
      }
    },
    jshint: {
      files: [
        'Gruntfile.js',
        'js/**/*.js',
        '!js/libtextsecure.js',
        '!js/WebAudioRecorderMp3.js',
        '!js/Mp3LameEncoder.min.js',
        '!js/libsignal-protocol-worker.js',
        '!js/components.js',
        '!js/signal_protocol_store.js',
        '_locales/**/*'
      ],
      options: { jshintrc: '.jshintrc' },
    },
    dist: {
      src: [
        'manifest.json',
        'background.html',
        'index.html',
        'options.html',
        '_locales/**',
        'protos/*',
        'js/**',
        'stylesheets/*.css',
        '!js/register.js'
      ],
      res: [
        'audio/**',
        'images/**/*',
        'fonts/*',
      ]
    },
    copy: {
      res: {
        files: [{ expand: true, dest: 'dist/', src: ['<%= dist.res %>'] }],
      },
      src: {
        files: [{ expand: true, dest: 'dist/', src: ['<%= dist.src %>'] }],
        options: {
          process: function(content, srcpath) {
            if (srcpath.match('background.js')) {
              return content.replace(
                /textsecure-service-staging.whispersystems.org/g,
                'textsecure-service-ca.whispersystems.org');
            } else if (srcpath.match('expire.js')) {
              var gitinfo = grunt.config.get('gitinfo');
              var commited = gitinfo.local.branch.current.lastCommitTime;
              var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
              return content.replace(
                /var BUILD_EXPIRATION = 0/,
                "var BUILD_EXPIRATION = " + time
              );
            } else {
              return content;
            }
          }
        }
      }
    },
    jscs: {
      all: {
        src: [
        'Gruntfile',
        'js/**/*.js',
        '!js/libtextsecure.js',
        '!js/WebAudioRecorderMp3.js',
        '!js/Mp3LameEncoder.min.js',
        '!js/libsignal-protocol-worker.js',
        '!js/components.js',
        'test/**/*.js',
        '!test/blanket_mocha.js',
        '!test/test.js',
        ]
      }
    },
    watch: {
      sass: {
        files: ['./stylesheets/*.scss'],
        tasks: ['sass']
      },
      libtextsecure: {
        files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
        tasks: ['concat:libtextsecure']
      },
      dist: {
        files: ['<%= dist.src %>', '<%= dist.res %>'],
        tasks: ['copy_dist']
      },
      scripts: {
        files: ['<%= jshint.files %>', './js/**/*.js'],
        tasks: ['jshint']
      },
      style: {
        files: ['<%= jscs.all.src %>', './js/**/*.js'],
        tasks: ['jscs']
      },
    },
    connect: {
      server: {
        options: {
          base: '.',
          port: 9999
        }
      }
    },
    'saucelabs-mocha': {
      all: {
        options: {
          urls: [
            'http://127.0.0.1:9999/test/index.html',
            'http://127.0.0.1:9999/libtextsecure/test/index.html',
          ],
          build: process.env.TRAVIS_JOB_ID,
          browsers: [
            { browserName: 'chrome', version: '41' },
          ],
          testname: 'TextSecure-Browser Tests',
          'max-duration': 300,
          statusCheckAttempts: 200
        }
      }
    },
    exec: {
      'tx-pull': {
        cmd: 'tx pull'
      }
    },
    gitinfo: {} // to be populated by grunt gitinfo
  });

  Object.keys(grunt.config.get('pkg').devDependencies).forEach(function(key) {
    if (/^grunt(?!(-cli)?$)/.test(key)) {  // ignore grunt and grunt-cli
      grunt.loadNpmTasks(key);
    }
  });

  // Transifex does not understand placeholders, so this task patches all non-en
  // locales with missing placeholders
  grunt.registerTask('locale-patch', function(){
    var en = grunt.file.readJSON('_locales/en/messages.json');
    grunt.file.recurse('_locales', function(abspath, rootdir, subdir, filename){
      if (subdir === 'en' || filename !== 'messages.json'){
        return;
      }
      var messages = grunt.file.readJSON(abspath);

      for (var key in messages){
        if (en[key] !== undefined && messages[key] !== undefined){
          if (en[key].placeholders !== undefined && messages[key].placeholders === undefined){
            messages[key].placeholders = en[key].placeholders;
          }
        }
      }

      grunt.file.write(abspath, JSON.stringify(messages, null, 4) + '\n');
    });
  });

  grunt.registerTask('getExpireTime', function() {
      var gitinfo = grunt.config.get('gitinfo');
      var commited = gitinfo.local.branch.current.lastCommitTime;
      var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
      grunt.file.write('config/local-production.json',
        JSON.stringify({ buildExpiration: time }) + '\n');
  });

  grunt.registerTask('tx', ['exec:tx-pull', 'locale-patch']);
  grunt.registerTask('dev', ['default', 'connect', 'watch']);
  grunt.registerTask('test', ['jshint', 'jscs' ]);
  grunt.registerTask('copy_dist', ['gitinfo', 'copy']);
  grunt.registerTask('date', ['gitinfo', 'getExpireTime']);
  grunt.registerTask('default', ['concat', 'sass', 'date']);

};
<commit_msg>Add task to download releases from s3<commit_after>module.exports = function(grunt) {
  'use strict';

  var bower = grunt.file.readJSON('bower.json');
  var components = [];
  for (var i in bower.concat.app) {
    components.push('components/' + bower.concat.app[i] + '/**/*.js');
  }
  components.push('components/' + 'webaudiorecorder/lib/WebAudioRecorder.js');

  var libtextsecurecomponents = [];
  for (i in bower.concat.libtextsecure) {
    libtextsecurecomponents.push('components/' + bower.concat.libtextsecure[i] + '/**/*.js');
  }

  var importOnce = require("node-sass-import-once");
  grunt.loadNpmTasks("grunt-sass");

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      components: {
        src: components,
        dest: 'js/components.js',
      },
      libtextsecurecomponents: {
        src: libtextsecurecomponents,
        dest: 'libtextsecure/components.js',
      },
      test: {
        src: [
          'components/mocha/mocha.js',
          'components/chai/chai.js',
          'test/_test.js'
        ],
        dest: 'test/test.js',
      },
      //TODO: Move errors back down?
      libtextsecure: {
        options: {
          banner: ";(function() {\n",
          footer: "})();\n",
        },
        src: [
          'libtextsecure/errors.js',
          'libtextsecure/libsignal-protocol.js',
          'libtextsecure/protocol_wrapper.js',

          'libtextsecure/crypto.js',
          'libtextsecure/storage.js',
          'libtextsecure/storage/user.js',
          'libtextsecure/storage/groups.js',
          'libtextsecure/storage/unprocessed.js',
          'libtextsecure/protobufs.js',
          'libtextsecure/websocket-resources.js',
          'libtextsecure/helpers.js',
          'libtextsecure/stringview.js',
          'libtextsecure/event_target.js',
          'libtextsecure/api.js',
          'libtextsecure/account_manager.js',
          'libtextsecure/message_receiver.js',
          'libtextsecure/outgoing_message.js',
          'libtextsecure/sendmessage.js',
          'libtextsecure/sync_request.js',
          'libtextsecure/contacts_parser.js',
          'libtextsecure/ProvisioningCipher.js',
          'libtextsecure/task_with_timeout.js',
        ],
        dest: 'js/libtextsecure.js',
      },
      libtextsecuretest: {
        src: [
          'components/jquery/dist/jquery.js',
          'components/mock-socket/dist/mock-socket.js',
          'components/mocha/mocha.js',
          'components/chai/chai.js',
          'libtextsecure/test/_test.js'
        ],
        dest: 'libtextsecure/test/test.js',
      }
    },
    sass: {
      options: {
        sourceMap: true,
        importer: importOnce
      },
      dev: {
        files: {
          "stylesheets/manifest.css": "stylesheets/manifest.scss"
        }
      }
    },
    jshint: {
      files: [
        'Gruntfile.js',
        'js/**/*.js',
        '!js/libtextsecure.js',
        '!js/WebAudioRecorderMp3.js',
        '!js/Mp3LameEncoder.min.js',
        '!js/libsignal-protocol-worker.js',
        '!js/components.js',
        '!js/signal_protocol_store.js',
        '_locales/**/*'
      ],
      options: { jshintrc: '.jshintrc' },
    },
    dist: {
      src: [
        'manifest.json',
        'background.html',
        'index.html',
        'options.html',
        '_locales/**',
        'protos/*',
        'js/**',
        'stylesheets/*.css',
        '!js/register.js'
      ],
      res: [
        'audio/**',
        'images/**/*',
        'fonts/*',
      ]
    },
    copy: {
      res: {
        files: [{ expand: true, dest: 'dist/', src: ['<%= dist.res %>'] }],
      },
      src: {
        files: [{ expand: true, dest: 'dist/', src: ['<%= dist.src %>'] }],
        options: {
          process: function(content, srcpath) {
            if (srcpath.match('background.js')) {
              return content.replace(
                /textsecure-service-staging.whispersystems.org/g,
                'textsecure-service-ca.whispersystems.org');
            } else if (srcpath.match('expire.js')) {
              var gitinfo = grunt.config.get('gitinfo');
              var commited = gitinfo.local.branch.current.lastCommitTime;
              var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
              return content.replace(
                /var BUILD_EXPIRATION = 0/,
                "var BUILD_EXPIRATION = " + time
              );
            } else {
              return content;
            }
          }
        }
      }
    },
    jscs: {
      all: {
        src: [
        'Gruntfile',
        'js/**/*.js',
        '!js/libtextsecure.js',
        '!js/WebAudioRecorderMp3.js',
        '!js/Mp3LameEncoder.min.js',
        '!js/libsignal-protocol-worker.js',
        '!js/components.js',
        'test/**/*.js',
        '!test/blanket_mocha.js',
        '!test/test.js',
        ]
      }
    },
    watch: {
      sass: {
        files: ['./stylesheets/*.scss'],
        tasks: ['sass']
      },
      libtextsecure: {
        files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
        tasks: ['concat:libtextsecure']
      },
      dist: {
        files: ['<%= dist.src %>', '<%= dist.res %>'],
        tasks: ['copy_dist']
      },
      scripts: {
        files: ['<%= jshint.files %>', './js/**/*.js'],
        tasks: ['jshint']
      },
      style: {
        files: ['<%= jscs.all.src %>', './js/**/*.js'],
        tasks: ['jscs']
      },
    },
    connect: {
      server: {
        options: {
          base: '.',
          port: 9999
        }
      }
    },
    'saucelabs-mocha': {
      all: {
        options: {
          urls: [
            'http://127.0.0.1:9999/test/index.html',
            'http://127.0.0.1:9999/libtextsecure/test/index.html',
          ],
          build: process.env.TRAVIS_JOB_ID,
          browsers: [
            { browserName: 'chrome', version: '41' },
          ],
          testname: 'TextSecure-Browser Tests',
          'max-duration': 300,
          statusCheckAttempts: 200
        }
      }
    },
    exec: {
      'tx-pull': {
        cmd: 'tx pull'
      }
    },
    release: {
      mac: {
        archive: 'mac/Signal.app/Contents/Resources/app.asar',
      },
      mas: {
        archive: 'mas/Signal.app/Contents/Resources/app.asar',
      },
      linux: {
        archive: 'linux-unpacked/resources/app.asar',
      },
      win: {
        archive: 'win-unpacked/resources/app.asar',
      }
    },
    gitinfo: {} // to be populated by grunt gitinfo
  });

  Object.keys(grunt.config.get('pkg').devDependencies).forEach(function(key) {
    if (/^grunt(?!(-cli)?$)/.test(key)) {  // ignore grunt and grunt-cli
      grunt.loadNpmTasks(key);
    }
  });

  // Transifex does not understand placeholders, so this task patches all non-en
  // locales with missing placeholders
  grunt.registerTask('locale-patch', function(){
    var en = grunt.file.readJSON('_locales/en/messages.json');
    grunt.file.recurse('_locales', function(abspath, rootdir, subdir, filename){
      if (subdir === 'en' || filename !== 'messages.json'){
        return;
      }
      var messages = grunt.file.readJSON(abspath);

      for (var key in messages){
        if (en[key] !== undefined && messages[key] !== undefined){
          if (en[key].placeholders !== undefined && messages[key].placeholders === undefined){
            messages[key].placeholders = en[key].placeholders;
          }
        }
      }

      grunt.file.write(abspath, JSON.stringify(messages, null, 4) + '\n');
    });
  });

  grunt.registerTask('getExpireTime', function() {
      grunt.task.requires('gitinfo');
      var gitinfo = grunt.config.get('gitinfo');
      var commited = gitinfo.local.branch.current.lastCommitTime;
      var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
      grunt.file.write('config/local-production.json',
        JSON.stringify({ buildExpiration: time }) + '\n');
  });

  grunt.registerTask('clean-release', function() {
    require('rimraf').sync('release');
    require('mkdirp').sync('release');
  });

  grunt.registerTask('fetch-release', function() {
    grunt.task.requires('gitinfo');
    require('mkdirp').sync('release');
    var fs = require('fs');
    var done = this.async();
    var package_json = grunt.config.get('pkg');
    var gitinfo = grunt.config.get('gitinfo');
    var https = require('https');

    var urlBase = "https://s3-us-west-1.amazonaws.com/signal-desktop-builds";
    var keyBase = 'liliakai/textsecure-chrome';
    var sha = gitinfo.local.branch.current.SHA;
    var files = [
      'signal-desktop-' + package_json.version + '.zip',
      'Signal-' + package_json.version + '-win.zip'
    ];

    var extract = require('extract-zip');
    var download = function(url, dest, cb) {
        var file = fs.createWriteStream(dest);
        var request = https.get(url, function(response) {
          if (response.statusCode !== 200) {
            cb(response.statusCode);
          } else {
            response.pipe(file);
            file.on('finish', function() {
              file.close(function() {
                extract(dest, {dir: 'release'}, cb);
              });
            });
          }
        }).on('error', function(err) { // Handle errors
          fs.unlink(dest); // Delete the file async. (But we don't check the result)
          if (cb) cb(err.message);
        });
    };

    Promise.all(files.map(function(fileName) {
      var key = [ keyBase, sha, 'dist', fileName].join('/');
      var url = [urlBase, key].join('/');
      var dest = 'release/' + fileName;
      return new Promise(function(resolve) {
        console.log(url);
        download(url, dest, function(err) {
          if (err) {
            console.log('failed', dest, err);
            resolve(err);
          } else {
            console.log('done', dest);
            resolve();
          }
        });
      });
    })).then(function(results) {
      results.forEach(function(error) {
        if (error) {
          grunt.fail.warn('Failed to fetch some release artifacts');
        }
      });
      done();
    });
  });

  grunt.registerMultiTask('test-release', 'Test packaged releases', function() {
      var dir = grunt.option('dir') || 'dist';
      var environment = grunt.option('env') || 'production';
      var asar = require('asar');
      var config = this.data;
      var archive = [dir, config.archive].join('/');
      var files = [
        'config/default.json',
        'config/' + environment + '.json',
        'config/local-' + environment + '.json'
      ];

      console.log(this.target, archive);
      var releaseFiles = files.concat(config.files || []);
      releaseFiles.forEach(function(fileName) {
        console.log(fileName);
        try {
          asar.statFile(archive, fileName);
          return true;
        } catch (e) {
          console.log(e);
          throw new Error("Missing file " + fileName);
        }
      });

      // todo: verify package.json has `environment: <environment>`
  });

  grunt.registerTask('tx', ['exec:tx-pull', 'locale-patch']);
  grunt.registerTask('dev', ['default', 'connect', 'watch']);
  grunt.registerTask('test', ['jshint', 'jscs' ]);
  grunt.registerTask('copy_dist', ['gitinfo', 'copy']);
  grunt.registerTask('date', ['gitinfo', 'getExpireTime']);
  grunt.registerTask('prep-release', ['gitinfo', 'fetch-release', 'test-release']);
  grunt.registerTask('default', ['concat', 'sass', 'date']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt){
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
                mangle:true,
                sourceMap: false,
                sourceMapName: 'dest/srcmap.map'
            },
            release: {
                files: [{
                    expand:true,
                    cwd: 'src',
                    src: ['**/*.js','!**/*.min.js'],
                    ext: '.min.js',
                    dest: 'dest/'
                }]
            }
        },
        htmlmin: {
          main: {
            options: {
              collapseWhitespace: true,
              minifyCSS: true,
              minifyJS: true,
              removeComments: true,
            },
            files: [{
                expand:true,
                cwd: 'src',
                src: ['**/*.html'],
                dest: 'dest/'
            }]
          },
        },
        copy: {
            main: {
                files: [{
                    expand: true,
                    cwd:'src',
                    src: ['**/**','!**/*.html','!**/*.js','**/*.min.js','_locales/**'],
                    dest: 'dest/'
              }]
            }
        },
        compress: {
            main: {
                options: {
                    archive: 'bilibili_helper.zip'
                },
                files: [{
                    expand: true,
                    cwd: 'dest/',
                    src: ['**/*'],
                    dest: '/'
                 }]
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');

    grunt.registerTask('default', ['uglify:release','htmlmin:main','copy:main','compress:main']);
    grunt.registerTask('debug', ['uglify:release','copy:main']);
}
<commit_msg>add htmlmin for debug in grunt<commit_after>module.exports = function(grunt){
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
                mangle:true,
                sourceMap: false,
                sourceMapName: 'dest/srcmap.map'
            },
            release: {
                files: [{
                    expand:true,
                    cwd: 'src',
                    src: ['**/*.js','!**/*.min.js'],
                    ext: '.min.js',
                    dest: 'dest/'
                }]
            }
        },
        htmlmin: {
          main: {
            options: {
              collapseWhitespace: true,
              minifyCSS: true,
              minifyJS: true,
              removeComments: true,
            },
            files: [{
                expand:true,
                cwd: 'src',
                src: ['**/*.html'],
                dest: 'dest/'
            }]
          },
        },
        copy: {
            main: {
                files: [{
                    expand: true,
                    cwd:'src',
                    src: ['**/**','!**/*.html','!**/*.js','**/*.min.js','_locales/**'],
                    dest: 'dest/'
              }]
            }
        },
        compress: {
            main: {
                options: {
                    archive: 'bilibili_helper.zip'
                },
                files: [{
                    expand: true,
                    cwd: 'dest/',
                    src: ['**/*'],
                    dest: '/'
                 }]
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');

    grunt.registerTask('default', ['uglify:release','htmlmin:main','copy:main','compress:main']);
    grunt.registerTask('debug', ['uglify:release','htmlmin:main','copy:main']);
}
<|endoftext|>


<commit_before>"use strict";

module.exports = function(grunt) {
	grunt.initConfig({
		nodeunit : {
			zones : [
				"tests/zones/**/*.js"
			],
			core : [
				"tests/moment-timezone/*.js"
			]
		},

		build : {
			'moment-timezone-with-data'           : true,
			'moment-timezone-with-data-2010-2020' : [2010, 2020]
		},

		uglify : {
			all: {
				files: {
					'builds/moment-timezone.min.js'                     : 'moment-timezone.js',
					'builds/moment-timezone-with-data.min.js'           : 'builds/moment-timezone-with-data.js',
					'builds/moment-timezone-with-data-2010-2020.min.js' : 'builds/moment-timezone-with-data-2010-2020.js'
				}
			},
			options: {
				report : 'gzip',
				preserveComments : 'some'
			}
		},

		jshint: {
			all: 'moment-timezone.js'
		},

		clean: {
			data: ['temp']
		}
	});

	grunt.loadTasks("tasks");

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

	grunt.registerTask('release', ['jshint', 'data', 'nodeunit', 'build', 'uglify']);

	grunt.registerTask('releaseNoData', ['jshint', 'nodeunit', 'build', 'uglify']);

	grunt.registerTask('default', ['jshint', 'nodeunit']);
};
<commit_msg>Build 2012-2022.  (+/- 5 years)<commit_after>"use strict";

module.exports = function(grunt) {
	grunt.initConfig({
		nodeunit : {
			zones : [
				"tests/zones/**/*.js"
			],
			core : [
				"tests/moment-timezone/*.js"
			]
		},

		build : {
			'moment-timezone-with-data'           : true,
			'moment-timezone-with-data-2012-2022' : [2012, 2022]
		},

		uglify : {
			all: {
				files: {
					'builds/moment-timezone.min.js'                     : 'moment-timezone.js',
					'builds/moment-timezone-with-data.min.js'           : 'builds/moment-timezone-with-data.js',
					'builds/moment-timezone-with-data-2012-2022.min.js' : 'builds/moment-timezone-with-data-2012-2022.js'
				}
			},
			options: {
				report : 'gzip',
				preserveComments : 'some'
			}
		},

		jshint: {
			all: 'moment-timezone.js'
		},

		clean: {
			data: ['temp']
		}
	});

	grunt.loadTasks("tasks");

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

	grunt.registerTask('release', ['jshint', 'data', 'nodeunit', 'build', 'uglify']);

	grunt.registerTask('releaseNoData', ['jshint', 'nodeunit', 'build', 'uglify']);

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