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

//
// Javascript Bindigns helper file
//

// DO NOT ALTER THE ORDER
require('script/jsb_cocos2d_constants.js');
require('script/jsb_cocos2d.js');

require('script/jsb_property_impls.js');
require('script/jsb_property_apis.js');
require('script/jsb_create_apis.js');

if (cc.GLNode) {
    cc.GLNode.extend = cc.Class.extend; // move from jsb_cocos2d_extension
}

if (window.ccs) {
    require('script/studio/jsb_studio_boot.js');
    ccs.Armature.extend = cc.Class.extend; // move from jsb_cocos2d.js
    require('script/studio/jsb_cocos2d_studio.js');
    require('script/studio/jsb_studio_property_apis.js');
    require('script/studio/jsb_studio_create_apis.js');

    require('script/studio/jsb_studio_load.js');
    require('script/studio/parsers/jsb_studio_action-1.x.js');
    require('script/studio/parsers/jsb_studio_action-2.x.js');
    require('script/studio/parsers/jsb_studio_scene-1.x.js');
    require('script/studio/parsers/jsb_studio_timelineParser-1.x.js');
    require('script/studio/parsers/jsb_studio_timelineParser-2.x.js');
    require('script/studio/parsers/jsb_studio_uiParser-1.x.js');
    require('script/studio/parsers/jsb_studio_compatible.js');
}

if (window.ccui) {
    // move from jsb_boot.js line 912
    //start------------------------------
    cc.EditBox = ccui.EditBox;
    delete ccui.EditBox;

    cc.Scale9Sprite = ccui.Scale9Sprite;

    // GUI
    /**
     * @type {Object}
     * UI Helper
     */
    ccui.helper = ccui.Helper;
    //end------------------------------

    // move from jsb_cocos2d
    //start------------------------------
    ccui.Widget.extend = cc.Class.extend;
    ccui.Button.extend = cc.Class.extend;
    ccui.CheckBox.extend = cc.Class.extend;
    ccui.ImageView.extend = cc.Class.extend;
    ccui.LoadingBar.extend = cc.Class.extend;
    ccui.RichText.extend = cc.Class.extend;
    ccui.Slider.extend = cc.Class.extend;
    ccui.Text.extend = cc.Class.extend;
    ccui.TextAtlas.extend = cc.Class.extend;
    ccui.TextBMFont.extend = cc.Class.extend;
    ccui.TextField.extend = cc.Class.extend;
    ccui.Layout.extend = cc.Class.extend;
    ccui.ListView.extend = cc.Class.extend;
    ccui.PageView.extend = cc.Class.extend;
    ccui.ScrollView.extend = cc.Class.extend;
    ccui.Scale9Sprite.extend = cc.Class.extend;
    //end------------------------------

    require('script/ccui/jsb_cocos2d_ui.js');
    require('script/ccui/jsb_ccui_property_impls.js');
    require('script/ccui/jsb_ccui_property_apis.js');
    require('script/ccui/jsb_ccui_create_apis.js');
    require('script/ccui/jsb_ccui_deprecated.js');
}

if (cc.ControlButton) {
    require('script/extension/jsb_cocos2d_extension.js');
    require('script/extension/jsb_ext_property_apis.js');
    require('script/extension/jsb_ext_create_apis.js');
}

if (cc.PhysicsSprite) {
    cc.PhysicsSprite.extend = cc.Class.extend;// move from jsb_cocos2d.js
    require('script/physicsSprite/jsb_physicsSprite.js');
}

if (window.cp) {
    // chipmunk
    require('script/chipmunk/jsb_chipmunk_constants.js');
    require('script/chipmunk/jsb_chipmunk.js');
}

require('script/jsb_opengl_constants.js');
require('script/jsb_opengl.js');
require('script/jsb_cocosbuilder.js');
require('script/jsb_deprecated.js');
require('script/jsb_loaders.js');
require('script/jsb_pool.js');

if (jsb.fileUtils.isFileExist('jsb_pluginx.js')) {
    if (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) {
        require('jsb_pluginx.js');
    }
}
<commit_msg>Rename studio parser files<commit_after>/*
 * Copyright (c) 2013-2014 Chukong Technologies Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

//
// Javascript Bindigns helper file
//

// DO NOT ALTER THE ORDER
require('script/jsb_cocos2d_constants.js');
require('script/jsb_cocos2d.js');

require('script/jsb_property_impls.js');
require('script/jsb_property_apis.js');
require('script/jsb_create_apis.js');

if (cc.GLNode) {
    cc.GLNode.extend = cc.Class.extend; // move from jsb_cocos2d_extension
}

if (window.ccs) {
    require('script/studio/jsb_studio_boot.js');
    ccs.Armature.extend = cc.Class.extend; // move from jsb_cocos2d.js
    require('script/studio/jsb_cocos2d_studio.js');
    require('script/studio/jsb_studio_property_apis.js');
    require('script/studio/jsb_studio_create_apis.js');

    require('script/studio/jsb_studio_load.js');
    require('script/studio/parsers/action-1.x.js');
    require('script/studio/parsers/action-2.x.js');
    require('script/studio/parsers/scene-1.x.js');
    require('script/studio/parsers/timelineParser-1.x.js');
    require('script/studio/parsers/timelineParser-2.x.js');
    require('script/studio/parsers/uiParser-1.x.js');
    require('script/studio/parsers/compatible.js');
}

if (window.ccui) {
    // move from jsb_boot.js line 912
    //start------------------------------
    cc.EditBox = ccui.EditBox;
    delete ccui.EditBox;

    cc.Scale9Sprite = ccui.Scale9Sprite;

    // GUI
    /**
     * @type {Object}
     * UI Helper
     */
    ccui.helper = ccui.Helper;
    //end------------------------------

    // move from jsb_cocos2d
    //start------------------------------
    ccui.Widget.extend = cc.Class.extend;
    ccui.Button.extend = cc.Class.extend;
    ccui.CheckBox.extend = cc.Class.extend;
    ccui.ImageView.extend = cc.Class.extend;
    ccui.LoadingBar.extend = cc.Class.extend;
    ccui.RichText.extend = cc.Class.extend;
    ccui.Slider.extend = cc.Class.extend;
    ccui.Text.extend = cc.Class.extend;
    ccui.TextAtlas.extend = cc.Class.extend;
    ccui.TextBMFont.extend = cc.Class.extend;
    ccui.TextField.extend = cc.Class.extend;
    ccui.Layout.extend = cc.Class.extend;
    ccui.ListView.extend = cc.Class.extend;
    ccui.PageView.extend = cc.Class.extend;
    ccui.ScrollView.extend = cc.Class.extend;
    ccui.Scale9Sprite.extend = cc.Class.extend;
    //end------------------------------

    require('script/ccui/jsb_cocos2d_ui.js');
    require('script/ccui/jsb_ccui_property_impls.js');
    require('script/ccui/jsb_ccui_property_apis.js');
    require('script/ccui/jsb_ccui_create_apis.js');
    require('script/ccui/jsb_ccui_deprecated.js');
}

if (cc.ControlButton) {
    require('script/extension/jsb_cocos2d_extension.js');
    require('script/extension/jsb_ext_property_apis.js');
    require('script/extension/jsb_ext_create_apis.js');
}

if (cc.PhysicsSprite) {
    cc.PhysicsSprite.extend = cc.Class.extend;// move from jsb_cocos2d.js
    require('script/physicsSprite/jsb_physicsSprite.js');
}

if (window.cp) {
    // chipmunk
    require('script/chipmunk/jsb_chipmunk_constants.js');
    require('script/chipmunk/jsb_chipmunk.js');
}

require('script/jsb_opengl_constants.js');
require('script/jsb_opengl.js');
require('script/jsb_cocosbuilder.js');
require('script/jsb_deprecated.js');
require('script/jsb_loaders.js');
require('script/jsb_pool.js');

if (jsb.fileUtils.isFileExist('jsb_pluginx.js')) {
    if (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) {
        require('jsb_pluginx.js');
    }
}
<|endoftext|>


<commit_before>//
// Backbone.BaseRouter
//

'use strict';

// Copied over from Backbone, because it doesn't expose them.
var namedParam    = /(\(\?)?:\w+/g;

Backbone.BaseRouter = Backbone.Router.extend({

  // The single point of entry. This is called whenever a
  // route is matched. The routeData argument contains lots of
  // useful information.
  onNavigate: function(routeData) {},

  routeParams: {},

  route: function(origRoute, linked) {
    var route, routeStr;

    if (_.isRegExp(origRoute)) {
      route = origRoute;
      routeStr = origRoute.toString();
    } else {
      route = this._routeToRegExp(origRoute);
      routeStr = origRoute;
    }

    this.routeParams[origRoute] = this._extractRouteParams(routeStr);

    // Begin setting up our routeData,
    // based on what we already know.
    var routeData = {
      route: route,
      router: this,
      linked: linked
    };

    // Only attach the originalRoute to routeData if it isn't a RegExp.
    if (!_.isRegExp(origRoute)) {
      routeData.originalRoute = origRoute;
    }

    // Register a callback with history
    var router = this;
    Backbone.history.route(route, function(fragment, navOptions) {
      var routeParams = router._extractParameters(route, fragment);
      var queryString = routeParams.pop();

      // If the user is using baseHistory, then we'll get the navOptions back from BB.History
      if (navOptions) { routeData.navOptions = navOptions; }
      routeData.query = router._getQueryParameters(queryString);
      routeData.params = router._getNamedParams(routeStr, routeParams);
      routeData.uriFragment = fragment;

      router.onNavigate(routeData);
    });

    return this;
  },

  _extractRouteParams: function(route) {
    var namedParams = [];

    route.replace(namedParam, function(match, optional) {
      namedParams.push(match.substr(1));
    });

    return namedParams;
  },

  // Decodes the Url query string parameters & and returns them
  // as an object. Supports empty parameters, but not array-like
  // parameters (which aren't in the URI specification)
  _getQueryParameters: function(queryString) {

    if (!queryString) {
      return {};
    }

    var match;
    var search = /([^&=]+)=?([^&]*)/g;
    var urlParams = {};

    while (match = search.exec(queryString)) {
       urlParams[this._decodeParams(match[1])] = this._decodeParams(match[2]);
    }

    return urlParams;
  },

  _decodeParams: function (queryString) {
    var pl = /\+/g;  // Regex for replacing addition symbol with a space
    return decodeURIComponent(queryString.replace(pl, ' '));
  },

  // Returns the named parameters of the route
  _getNamedParams: function(route, routeParams) {
    if (!routeParams.length) { return {}; }

    var routeKeys = this.routeParams[route];
    var routeValues = routeParams.slice(0, routeKeys.length);

    return _.object(_.zip(routeKeys, routeValues));
  }
});
<commit_msg>Moves routeParams off of the prototype.<commit_after>//
// Backbone.BaseRouter
//

'use strict';

// Copied over from Backbone, because it doesn't expose them.
var namedParam    = /(\(\?)?:\w+/g;

Backbone.BaseRouter = Backbone.Router.extend({
  constructor: function() {
    this.routeParams = {};
    Backbone.Router.constructor.apply(this, arguments);
  },

  // The single point of entry. This is called whenever a
  // route is matched. The routeData argument contains lots of
  // useful information.
  onNavigate: function(routeData) {},

  route: function(origRoute, linked) {
    var route, routeStr;

    if (_.isRegExp(origRoute)) {
      route = origRoute;
      routeStr = origRoute.toString();
    } else {
      route = this._routeToRegExp(origRoute);
      routeStr = origRoute;
    }

    this.routeParams[origRoute] = this._extractRouteParams(routeStr);

    // Begin setting up our routeData,
    // based on what we already know.
    var routeData = {
      route: route,
      router: this,
      linked: linked
    };

    // Only attach the originalRoute to routeData if it isn't a RegExp.
    if (!_.isRegExp(origRoute)) {
      routeData.originalRoute = origRoute;
    }

    // Register a callback with history
    var router = this;
    Backbone.history.route(route, function(fragment, navOptions) {
      var routeParams = router._extractParameters(route, fragment);
      var queryString = routeParams.pop();

      // If the user is using baseHistory, then we'll get the navOptions back from BB.History
      if (navOptions) { routeData.navOptions = navOptions; }
      routeData.query = router._getQueryParameters(queryString);
      routeData.params = router._getNamedParams(routeStr, routeParams);
      routeData.uriFragment = fragment;

      router.onNavigate(routeData);
    });

    return this;
  },

  _extractRouteParams: function(route) {
    var namedParams = [];

    route.replace(namedParam, function(match, optional) {
      namedParams.push(match.substr(1));
    });

    return namedParams;
  },

  // Decodes the Url query string parameters & and returns them
  // as an object. Supports empty parameters, but not array-like
  // parameters (which aren't in the URI specification)
  _getQueryParameters: function(queryString) {

    if (!queryString) {
      return {};
    }

    var match;
    var search = /([^&=]+)=?([^&]*)/g;
    var urlParams = {};

    while (match = search.exec(queryString)) {
       urlParams[this._decodeParams(match[1])] = this._decodeParams(match[2]);
    }

    return urlParams;
  },

  _decodeParams: function (queryString) {
    var pl = /\+/g;  // Regex for replacing addition symbol with a space
    return decodeURIComponent(queryString.replace(pl, ' '));
  },

  // Returns the named parameters of the route
  _getNamedParams: function(route, routeParams) {
    if (!routeParams.length) { return {}; }

    var routeKeys = this.routeParams[route];
    var routeValues = routeParams.slice(0, routeKeys.length);

    return _.object(_.zip(routeKeys, routeValues));
  }
});
<|endoftext|>


<commit_before>// Generated on 2015-11-30 using generator-chrome-extension 0.4.4
'use strict';

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

module.exports = function (grunt) {

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

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin'
  });

  // Configurable paths
  var config = {
    app: 'app',
    dist: 'dist',
    srcScript: '<%= config.app %>/scripts'
  };

  grunt.initConfig({

    // Project settings
    config: config,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['bowerInstall']
      },
      js: {
        files: ['<%= config.srcScript %>/{,*/}*.js'],
        tasks: ['jshint', 'babel'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      styles: {
        files: ['<%= config.app %>/styles/{,*/}*.css'],
        tasks: [],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.app %>/*.html',
          '<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= config.app %>/manifest.json',
          '<%= config.app %>/_locales/{,*/}*.json'
        ]
      }
    },

    // Grunt server and debug server setting
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      chrome: {
        options: {
          open: false,
          base: [
            '<%= config.app %>'
          ]
        }
      },
      test: {
        options: {
          open: false,
          base: [
            'test',
            '<%= config.app %>'
          ]
        }
      }
    },

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

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= config.srcScript %>/{,*/}*.js',
        '!<%= config.app %>/scripts/vendor/*',
        'test/spec/{,*/}*.js'
      ]
    },
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://localhost:<%= connect.options.port %>/index.html']
        }
      }
    },

    // Automatically inject Bower components into the HTML file
    bowerInstall: {
      app: {
        src: [
          '<%= config.app %>/*.html'
        ]
      }
    },

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

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

    // The following *-min tasks produce minifies files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          // removeCommentsFromCDATA: true,
          // collapseWhitespace: true,
          // collapseBooleanAttributes: true,
          // removeAttributeQuotes: true,
          // removeRedundantAttributes: true,
          // useShortDoctype: true,
          // removeEmptyAttributes: true,
          // removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: '*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

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

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '*.{ico,png,txt}',
            'images/{,*/}*.{webp,gif}',
            '{,*/}*.html',
            'styles/{,*/}*.css',
            'styles/fonts/{,*/}*.*',
            '_locales/{,*/}*.json',
          ]
        }]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      chrome: [
      ],
      dist: [
        'imagemin',
        'svgmin'
      ],
      test: [
      ]
    },

    // Auto buildnumber, exclude debug files. smart builds that event pages
    chromeManifest: {
      dist: {
        options: {
          buildnumber: true,
          indentSize: 2,
          background: {
            target: 'scripts/background.js',
            exclude: [
              'scripts/chromereload.js'
            ]
          }
        },
        src: '<%= config.app %>',
        dest: '<%= config.dist %>'
      }
    },

    // Compress dist files to package
    compress: {
      dist: {
        options: {
          archive: function() {
            var manifest = grunt.file.readJSON('app/manifest.json');
            return 'package/Granottifier-' + manifest.version + '.zip';
          }
        },
        files: [{
          expand: true,
          cwd: 'dist/',
          src: ['**/*'],
          dest: ''
        }]
      }
    }
  });

  grunt.registerTask('debug', function () {
    grunt.task.run([
      'jshint',
      'concurrent:chrome',
      'connect:chrome',
      'watch'
    ]);
  });

  grunt.registerTask('test', [
    'connect:test',
    'mocha'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'chromeManifest:dist',
    'useminPrepare',
    'concurrent:dist',
    // No UI feature selected, cssmin task will be commented
    // 'cssmin',
    'concat',
    'uglify',
    'copy',
    'usemin',
    'compress'
  ]);

  grunt.registerTask('default', [
    'jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Prevent JSHint from stopping debug process<commit_after>// Generated on 2015-11-30 using generator-chrome-extension 0.4.4
'use strict';

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

module.exports = function (grunt) {

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

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin'
  });

  // Configurable paths
  var config = {
    app: 'app',
    dist: 'dist',
    srcScript: '<%= config.app %>/scripts'
  };

  grunt.initConfig({

    // Project settings
    config: config,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['bowerInstall']
      },
      js: {
        files: ['<%= config.srcScript %>/{,*/}*.js'],
        tasks: ['jshint', 'babel'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      styles: {
        files: ['<%= config.app %>/styles/{,*/}*.css'],
        tasks: [],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.app %>/*.html',
          '<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= config.app %>/manifest.json',
          '<%= config.app %>/_locales/{,*/}*.json'
        ]
      }
    },

    // Grunt server and debug server setting
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      chrome: {
        options: {
          open: false,
          base: [
            '<%= config.app %>'
          ]
        }
      },
      test: {
        options: {
          open: false,
          base: [
            'test',
            '<%= config.app %>'
          ]
        }
      }
    },

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

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish'),
        force: true
      },
      all: [
        'Gruntfile.js',
        '<%= config.srcScript %>/{,*/}*.js',
        '!<%= config.app %>/scripts/vendor/*',
        'test/spec/{,*/}*.js'
      ]
    },
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://localhost:<%= connect.options.port %>/index.html']
        }
      }
    },

    // Automatically inject Bower components into the HTML file
    bowerInstall: {
      app: {
        src: [
          '<%= config.app %>/*.html'
        ]
      }
    },

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

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

    // The following *-min tasks produce minifies files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          // removeCommentsFromCDATA: true,
          // collapseWhitespace: true,
          // collapseBooleanAttributes: true,
          // removeAttributeQuotes: true,
          // removeRedundantAttributes: true,
          // useShortDoctype: true,
          // removeEmptyAttributes: true,
          // removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: '*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

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

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '*.{ico,png,txt}',
            'images/{,*/}*.{webp,gif}',
            '{,*/}*.html',
            'styles/{,*/}*.css',
            'styles/fonts/{,*/}*.*',
            '_locales/{,*/}*.json',
          ]
        }]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      chrome: [
      ],
      dist: [
        'imagemin',
        'svgmin'
      ],
      test: [
      ]
    },

    // Auto buildnumber, exclude debug files. smart builds that event pages
    chromeManifest: {
      dist: {
        options: {
          buildnumber: true,
          indentSize: 2,
          background: {
            target: 'scripts/background.js',
            exclude: [
              'scripts/chromereload.js'
            ]
          }
        },
        src: '<%= config.app %>',
        dest: '<%= config.dist %>'
      }
    },

    // Compress dist files to package
    compress: {
      dist: {
        options: {
          archive: function() {
            var manifest = grunt.file.readJSON('app/manifest.json');
            return 'package/Granottifier-' + manifest.version + '.zip';
          }
        },
        files: [{
          expand: true,
          cwd: 'dist/',
          src: ['**/*'],
          dest: ''
        }]
      }
    }
  });

  grunt.registerTask('debug', function () {
    grunt.task.run([
      'jshint',
      'concurrent:chrome',
      'connect:chrome',
      'watch'
    ]);
  });

  grunt.registerTask('test', [
    'connect:test',
    'mocha'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'chromeManifest:dist',
    'useminPrepare',
    'concurrent:dist',
    // No UI feature selected, cssmin task will be commented
    // 'cssmin',
    'concat',
    'uglify',
    'copy',
    'usemin',
    'compress'
  ]);

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


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

    var libs = [
        'js/native.js',
        'js/hxManager.js',
        'js/workflow.js',
        'js/vendorPatch.js',
        'js/easing.js',
        'js/animator.js',
        'js/hx.js',
        'js/cdn.js'
    ];

    grunt.initConfig({

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

            clean : ["hx.min.js"],

            uglify : {
                options : {
                    banner : '/*! <%= pkg.name %> - <%= pkg.version %> - <%= pkg.author %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
                },
                release : {
                    files : {
                        'hx.min.js' : libs
                    }
                }
            },

            "git-describe" : {
                "options" : {
                    prop : "git-version"
                }
            },

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

    });

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

    grunt.registerTask('default', ['jshint','git-describe', 'clean', 'uglify']);

};<commit_msg>removed cdn.js<commit_after>module.exports = function( grunt ) {

    var libs = [
        'js/native.js',
        'js/hxManager.js',
        'js/workflow.js',
        'js/vendorPatch.js',
        'js/easing.js',
        'js/animator.js',
        'js/hx.js'
    ];

    grunt.initConfig({

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

            clean : ["hx.min.js"],

            uglify : {
                options : {
                    banner : '/*! <%= pkg.name %> - <%= pkg.version %> - <%= pkg.author %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
                },
                release : {
                    files : {
                        'hx.min.js' : libs
                    }
                }
            },

            "git-describe" : {
                "options" : {
                    prop : "git-version"
                }
            },

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

    });

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

    grunt.registerTask('default', ['jshint','git-describe', 'clean', 'uglify']);

};<|endoftext|>


<commit_before>var path = require("path");
var _ = require("lodash");

module.exports = function (grunt) {
    // Path to the client src
    var srcPath = path.resolve(__dirname, "src");

    // Load grunt modules
    grunt.loadNpmTasks('hr.js');
    grunt.loadNpmTasks('grunt-exec');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-node-webkit-builder');

    var NW_VERSION = "0.9.2";

    // Init GRUNT configuraton
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        hr: {
            app: {
                // Base directory for the application
                "base": srcPath,

                // Application name
                "name": "Codebox",

                // Mode debug
                "debug": true,

                // Main entry point for application
                "main": "main",

                // HTML entry point
                'index': grunt.file.read(path.resolve(srcPath, "index.html")),

                // Build output directory
                "build": path.resolve(__dirname, "build"),

                // Static files mappage
                "static": {
                    "ace": path.resolve(srcPath, "vendors", "ace"),
                    "fonts": path.resolve(srcPath, "resources", "fonts"),
                    "images": path.resolve(srcPath, "resources", "images")
                },

                // Stylesheet entry point
                "style": path.resolve(srcPath, "resources/stylesheets/main.less"),

                // Modules paths
                'paths': {
                    "ace": "vendors/ace/ace"
                },
                "shim": {
                    "main": {
                        deps: [
                            'hr/dom',
                            'vendors/bootstrap/carousel',
                            'vendors/bootstrap/dropdown',
                            'vendors/bootstrap/button',
                            'vendors/bootstrap/modal',
                            'vendors/bootstrap/affix',
                            'vendors/bootstrap/alert',
                            'vendors/bootstrap/collapse',
                            'vendors/bootstrap/tooltip',
                            'vendors/bootstrap/popover',
                            'vendors/bootstrap/scrollspy',
                            'vendors/bootstrap/tab',
                            'vendors/bootstrap/transition'
                        ]
                    },
                    "ace": {
                        exports: "ace"
                    }
                },
                'args': {},
                'options': {}
            }
        },
        nodewebkit: {
            options: {
                app_name: "GitBook",
                build_dir: './appbuilds',
                mac: true,
                win: true,
                linux32: true,
                linux64: true,
                mac_icns: "./build/static/images/icons/512.icns",
                credits: "./src/credits.html",
                version: NW_VERSION,
                zip: false
            },
            src: [
                "./**/*",
                "!./appbuilds/**",
                "!./node_modules/hr.js/**",
                "!./node_modules/grunt-*/**",
                "!./node_modules/grunt/**",
                "!./node_modules/nw-gyp/**"
            ]
        },
        clean: {
            build: ['build/'],
            releases: ['appbuilds/releases']
        },
        exec: {
            build_mac_release: {
                command: "./scripts/build_mac.sh",
                cwd: './',
                stdout: true,
                stderr: true
            },
            build_win_release: {
                command: "./scripts/build_win.sh",
                cwd: './',
                stdout: true,
                stderr: true
            },
            build_linux32_release: {
                command: "./scripts/build_linux32_tar.sh",
                cwd: './',
                stdout: true,
                stderr: true
            },
            build_linux64_release: {
                command: "./scripts/build_linux64_tar.sh",
                cwd: './',
                stdout: true,
                stderr: true
            }
        },
        copy: {
            // Installer for linux
            linux32Installer: {
                cwd: './',
                src: 'scripts/install_linux.sh',
                dest: './appbuilds/releases/GitBook/linux32/GitBook/install.sh'
            },
            // Entry point for linux
            linux32Start: {
                cwd: './',
                src: 'scripts/linux_start.sh',
                dest: './appbuilds/releases/GitBook/linux32/GitBook/start.sh'
            },
            // Icon for linux
            linux32Icon: {
                cwd: './',
                src: './build/static/images/icons/128.png',
                dest: './appbuilds/releases/GitBook/linux32/GitBook/icon.png'
            },
            // Installer for linux
            linux64Installer: {
                cwd: './',
                src: 'scripts/install_linux.sh',
                dest: './appbuilds/releases/GitBook/linux64/GitBook/install.sh'
            },
            // Entry point for linux
            linux64Start: {
                cwd: './',
                src: 'scripts/linux_start.sh',
                dest: './appbuilds/releases/GitBook/linux64/GitBook/start.sh'
            },
            // Icon for linux
            linux64Icon: {
                cwd: './',
                src: './build/static/images/icons/128.png',
                dest: './appbuilds/releases/GitBook/linux64/GitBook/icon.png'
            },
        }
    });

    // Build
    grunt.registerTask('build', [
        'hr:app'
    ]);

    // Release
    grunt.registerTask('build-mac', [
        'exec:build_mac_release'
    ]);
    grunt.registerTask('build-win', [
        'exec:build_win_release'
    ]);
    grunt.registerTask('build-linux32', [
        'copy:linux32Installer',
        'copy:linux32Start',
        'copy:linux32Icon',
        'exec:build_linux32_release'
    ]);
    grunt.registerTask('build-linux64', [
        'copy:linux64Installer',
        'copy:linux64Start',
        'copy:linux64Icon',
        'exec:build_linux64_release'
    ]);
    grunt.registerTask('build-apps', [
        'clean:build',
        'clean:releases',
        'build',
        'nodewebkit',
        'build-linux32',
        'build-linux64',
        'build-mac',
        'build-win'
    ]);

    grunt.registerTask('default', [
        'build'
    ]);
};
<commit_msg>Fix build scripts for linux 32 and 64<commit_after>var path = require("path");
var _ = require("lodash");

module.exports = function (grunt) {
    // Path to the client src
    var srcPath = path.resolve(__dirname, "src");

    // Load grunt modules
    grunt.loadNpmTasks('hr.js');
    grunt.loadNpmTasks('grunt-exec');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-node-webkit-builder');

    var NW_VERSION = "0.9.2";

    // Init GRUNT configuraton
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        hr: {
            app: {
                // Base directory for the application
                "base": srcPath,

                // Application name
                "name": "Codebox",

                // Mode debug
                "debug": true,

                // Main entry point for application
                "main": "main",

                // HTML entry point
                'index': grunt.file.read(path.resolve(srcPath, "index.html")),

                // Build output directory
                "build": path.resolve(__dirname, "build"),

                // Static files mappage
                "static": {
                    "ace": path.resolve(srcPath, "vendors", "ace"),
                    "fonts": path.resolve(srcPath, "resources", "fonts"),
                    "images": path.resolve(srcPath, "resources", "images")
                },

                // Stylesheet entry point
                "style": path.resolve(srcPath, "resources/stylesheets/main.less"),

                // Modules paths
                'paths': {
                    "ace": "vendors/ace/ace"
                },
                "shim": {
                    "main": {
                        deps: [
                            'hr/dom',
                            'vendors/bootstrap/carousel',
                            'vendors/bootstrap/dropdown',
                            'vendors/bootstrap/button',
                            'vendors/bootstrap/modal',
                            'vendors/bootstrap/affix',
                            'vendors/bootstrap/alert',
                            'vendors/bootstrap/collapse',
                            'vendors/bootstrap/tooltip',
                            'vendors/bootstrap/popover',
                            'vendors/bootstrap/scrollspy',
                            'vendors/bootstrap/tab',
                            'vendors/bootstrap/transition'
                        ]
                    },
                    "ace": {
                        exports: "ace"
                    }
                },
                'args': {},
                'options': {}
            }
        },
        nodewebkit: {
            options: {
                app_name: "GitBook",
                build_dir: './appbuilds',
                mac: true,
                win: true,
                linux32: true,
                linux64: true,
                mac_icns: "./build/static/images/icons/512.icns",
                credits: "./src/credits.html",
                version: NW_VERSION,
                zip: false
            },
            src: [
                "./**/*",
                "!./appbuilds/**",
                "!./node_modules/hr.js/**",
                "!./node_modules/grunt-*/**",
                "!./node_modules/grunt/**",
                "!./node_modules/nw-gyp/**"
            ]
        },
        clean: {
            build: ['build/'],
            releases: ['appbuilds/releases']
        },
        exec: {
            build_mac_release: {
                command: "./scripts/build_mac.sh",
                cwd: './',
                stdout: true,
                stderr: true
            },
            build_win_release: {
                command: "./scripts/build_win.sh",
                cwd: './',
                stdout: true,
                stderr: true
            },
            build_linux32_release: {
                command: "./scripts/build_linux32.sh",
                cwd: './',
                stdout: true,
                stderr: true
            },
            build_linux64_release: {
                command: "./scripts/build_linux64.sh",
                cwd: './',
                stdout: true,
                stderr: true
            }
        },
        copy: {
            // Installer for linux
            linux32Installer: {
                cwd: './',
                src: 'scripts/install_linux.sh',
                dest: './appbuilds/releases/GitBook/linux32/GitBook/install.sh'
            },
            // Entry point for linux
            linux32Start: {
                cwd: './',
                src: 'scripts/linux_start.sh',
                dest: './appbuilds/releases/GitBook/linux32/GitBook/start.sh'
            },
            // Icon for linux
            linux32Icon: {
                cwd: './',
                src: './build/static/images/icons/128.png',
                dest: './appbuilds/releases/GitBook/linux32/GitBook/icon.png'
            },
            // Installer for linux
            linux64Installer: {
                cwd: './',
                src: 'scripts/install_linux.sh',
                dest: './appbuilds/releases/GitBook/linux64/GitBook/install.sh'
            },
            // Entry point for linux
            linux64Start: {
                cwd: './',
                src: 'scripts/linux_start.sh',
                dest: './appbuilds/releases/GitBook/linux64/GitBook/start.sh'
            },
            // Icon for linux
            linux64Icon: {
                cwd: './',
                src: './build/static/images/icons/128.png',
                dest: './appbuilds/releases/GitBook/linux64/GitBook/icon.png'
            },
        }
    });

    // Build
    grunt.registerTask('build', [
        'hr:app'
    ]);

    // Release
    grunt.registerTask('build-mac', [
        'exec:build_mac_release'
    ]);
    grunt.registerTask('build-win', [
        'exec:build_win_release'
    ]);
    grunt.registerTask('build-linux32', [
        'copy:linux32Installer',
        'copy:linux32Start',
        'copy:linux32Icon',
        'exec:build_linux32_release'
    ]);
    grunt.registerTask('build-linux64', [
        'copy:linux64Installer',
        'copy:linux64Start',
        'copy:linux64Icon',
        'exec:build_linux64_release'
    ]);
    grunt.registerTask('build-apps', [
        'clean:build',
        'clean:releases',
        'build',
        'nodewebkit',
        'build-linux32',
        'build-linux64',
        'build-mac',
        'build-win'
    ]);

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


<commit_before>"use strict";

module.exports = function (grunt) {

	var deployPath = "deploy/",
		graphPath = deployPath + "js/<%= pkg.name %>.js",
		minGraphPath = deployPath + "js/<%= pkg.name %>.min.js",
		appPath = deployPath + "js/<%= pkg.name %>-app.js",
		minAppPath = deployPath + "js/<%= pkg.name %>-app.min.js";

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),
		bowerrc: grunt.file.readJSON(".bowerrc"),
		bump: {
			options: {
				files: ["bower.json", "package.json"],
				updateConfigs: ["pkg"],
				commit: false,
				commitMessage: "Release v%VERSION%",
				commitFiles: ["bower.json", "package.json"],
				createTag: false,
				tagName: "v%VERSION%",
				tagMessage: "Version %VERSION%",
				push: false
			}
		},
		clean: {
			js: [deployPath]
		},
		concat: {
			options: {
				process: function (src, filepath) {
					return "// Source: " + filepath + "\n" + src;
				}
			},
			graph: {
				src: ["src/js/header.js", "src/js/graph/**/*.js"],
				dest: graphPath
			},
			app: {
				src: ["src/js/app/header.js", "src/js/app/**/*.js"],
				dest: appPath
			}
		},
		connect: {
			devserver: {
				options: {
					protocol: "http",
					hostname: "localhost",
					port: 8000,
					base: deployPath,
					directory: deployPath,
					livereload: true,
					open: "http://localhost:8000/webvowl.html",
					middleware: function (connect, options) {
						return [
							connect.favicon("favicon.ico"),
							connect.static(options.base[0]),
							connect.directory(options.base)
						];
					}
				}
			}
		},
		copy: {
			dependencies: {
				files: [
					{expand: true, cwd: "<%= bowerrc.directory %>/d3/", src: ["d3*.js"], dest: deployPath + "/js/"},
					{expand: true, cwd: "<%= bowerrc.directory %>/jquery/", src: ["jquery.min.js", "jquery.min.js"], dest: deployPath + "/js/"}
				]
			},
			static: {
				files: [
					{expand: true, cwd: "src/css/", src: ["**"], dest: deployPath + "css/"},
					{expand: true, cwd: "src/js/data/", src: ["**"], dest: deployPath + "js/data/"},
					{expand: true, src: ["license.txt", "favicon.ico"], dest: deployPath}
				]
			}
		},
		htmlbuild: {
			dist: {
				src: "src/webvowl.html",
				dest: deployPath,
				options: {
					beautify: true,
					relative: true,
					data: {
						// Data to pass to templates
						version: "<%= pkg.version %>"
					}
				}
			}
		},
		jshint: {
			options: {
				jshintrc: true
			},
			source: ["src/js/**/*.js"],
			tests: ["test/*/**/*.js"]
		},
		karma: {
			unit: {
				configFile: "test/karma.conf.js"
			}
		},
		uglify: {
			options: {
				banner: "/*! <%= pkg.name %> v<%= pkg.version %> */\n"
			},
			graph: {
				src: graphPath,
				dest: minGraphPath
			},
			app: {
				src: appPath,
				dest: minAppPath
			}
		},
		watch: {
			options: {
				livereload: true
			},
			css: {
				files: ["src/css/**/*.css"],
				tasks: ["copy"]
			},
			html: {
				files: ["src/**/*.html"],
				tasks: ["htmlbuild"]
			},
			scripts: {
				files: ["src/js/**/*"],
				tasks: ["build"]
			}
		}
	});

	grunt.loadNpmTasks("grunt-bump");
	grunt.loadNpmTasks("grunt-contrib-clean");
	grunt.loadNpmTasks("grunt-contrib-concat");
	grunt.loadNpmTasks("grunt-contrib-connect");
	grunt.loadNpmTasks("grunt-contrib-copy");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-uglify");
	grunt.loadNpmTasks("grunt-contrib-watch");
	grunt.loadNpmTasks("grunt-html-build");
	grunt.loadNpmTasks("grunt-karma");

	grunt.registerTask("build", ["clean", "copy", "concat", "htmlbuild"]);
	grunt.registerTask("default", ["package"]);
	grunt.registerTask("package", ["build", "uglify"]);
	grunt.registerTask("webserver", ["build", "connect:devserver", "watch"]);
	grunt.registerTask("test", ["karma"]);
};<commit_msg>Fix copying of jquery files<commit_after>"use strict";

module.exports = function (grunt) {

	var deployPath = "deploy/",
		graphPath = deployPath + "js/<%= pkg.name %>.js",
		minGraphPath = deployPath + "js/<%= pkg.name %>.min.js",
		appPath = deployPath + "js/<%= pkg.name %>-app.js",
		minAppPath = deployPath + "js/<%= pkg.name %>-app.min.js";

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),
		bowerrc: grunt.file.readJSON(".bowerrc"),
		bump: {
			options: {
				files: ["bower.json", "package.json"],
				updateConfigs: ["pkg"],
				commit: false,
				commitMessage: "Release v%VERSION%",
				commitFiles: ["bower.json", "package.json"],
				createTag: false,
				tagName: "v%VERSION%",
				tagMessage: "Version %VERSION%",
				push: false
			}
		},
		clean: {
			js: [deployPath]
		},
		concat: {
			options: {
				process: function (src, filepath) {
					return "// Source: " + filepath + "\n" + src;
				}
			},
			graph: {
				src: ["src/js/header.js", "src/js/graph/**/*.js"],
				dest: graphPath
			},
			app: {
				src: ["src/js/app/header.js", "src/js/app/**/*.js"],
				dest: appPath
			}
		},
		connect: {
			devserver: {
				options: {
					protocol: "http",
					hostname: "localhost",
					port: 8000,
					base: deployPath,
					directory: deployPath,
					livereload: true,
					open: "http://localhost:8000/webvowl.html",
					middleware: function (connect, options) {
						return [
							connect.favicon("favicon.ico"),
							connect.static(options.base[0]),
							connect.directory(options.base)
						];
					}
				}
			}
		},
		copy: {
			dependencies: {
				files: [
					{expand: true, cwd: "<%= bowerrc.directory %>/d3/", src: ["d3*.js"], dest: deployPath + "/js/"},
					{expand: true, cwd: "<%= bowerrc.directory %>/jquery/", src: ["jquery.min.js", "jquery.min.map"], dest: deployPath + "/js/"}
				]
			},
			static: {
				files: [
					{expand: true, cwd: "src/css/", src: ["**"], dest: deployPath + "css/"},
					{expand: true, cwd: "src/js/data/", src: ["**"], dest: deployPath + "js/data/"},
					{expand: true, src: ["license.txt", "favicon.ico"], dest: deployPath}
				]
			}
		},
		htmlbuild: {
			dist: {
				src: "src/webvowl.html",
				dest: deployPath,
				options: {
					beautify: true,
					relative: true,
					data: {
						// Data to pass to templates
						version: "<%= pkg.version %>"
					}
				}
			}
		},
		jshint: {
			options: {
				jshintrc: true
			},
			source: ["src/js/**/*.js"],
			tests: ["test/*/**/*.js"]
		},
		karma: {
			unit: {
				configFile: "test/karma.conf.js"
			}
		},
		uglify: {
			options: {
				banner: "/*! <%= pkg.name %> v<%= pkg.version %> */\n"
			},
			graph: {
				src: graphPath,
				dest: minGraphPath
			},
			app: {
				src: appPath,
				dest: minAppPath
			}
		},
		watch: {
			options: {
				livereload: true
			},
			css: {
				files: ["src/css/**/*.css"],
				tasks: ["copy"]
			},
			html: {
				files: ["src/**/*.html"],
				tasks: ["htmlbuild"]
			},
			scripts: {
				files: ["src/js/**/*"],
				tasks: ["build"]
			}
		}
	});

	grunt.loadNpmTasks("grunt-bump");
	grunt.loadNpmTasks("grunt-contrib-clean");
	grunt.loadNpmTasks("grunt-contrib-concat");
	grunt.loadNpmTasks("grunt-contrib-connect");
	grunt.loadNpmTasks("grunt-contrib-copy");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-uglify");
	grunt.loadNpmTasks("grunt-contrib-watch");
	grunt.loadNpmTasks("grunt-html-build");
	grunt.loadNpmTasks("grunt-karma");

	grunt.registerTask("build", ["clean", "copy", "concat", "htmlbuild"]);
	grunt.registerTask("default", ["package"]);
	grunt.registerTask("package", ["build", "uglify"]);
	grunt.registerTask("webserver", ["build", "connect:devserver", "watch"]);
	grunt.registerTask("test", ["karma"]);
};<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt); //加载所有的任务
  //require('time-grunt')(grunt); 如果要使用 time-grunt 插件

  // var requireJsModules = [];
  // grunt.file.expand({cwd:"./static/js/"}, "**/*.js").forEach( function (file) {
  //     if (file !== 'opt.js') {
  //         requireJsModules.push(file.replace(/\.js$/, ''));
  //     }
  // });
  // grunt.log.write(requireJsModules);

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
  	// Metadata.
  	meta: {
  		basePath: './',
  		srcPath: './sass',
  		deployPath: './assets/css/'
  	},
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['lib/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      static_mappings: {
        // Because these src-dest file mappings are manually specified, every
        // time a new file is added or removed, the Gruntfile has to be updated.
        files: [
          {src: 'lib/a.js', dest: 'build/a.min.js'},
          {src: 'lib/b.js', dest: 'build/b.min.js'},
          {src: 'lib/subdir/c.js', dest: 'build/subdir/c.min.js'},
          {src: 'lib/subdir/d.js', dest: 'build/subdir/d.min.js'},
        ],
      },
      dynamic_mappings: {
        // Grunt will search for "**/*.js" under "lib/" when the "uglify" task
        // runs and build the appropriate src-dest file mappings then, so you
        // don't need to update the Gruntfile when files are added or removed.
        files: [
          {
            expand: true,     // Enable dynamic expansion.
            cwd: 'src/public/js/requirejs',      // Src matches are relative to this path.
            src: ['**/*.js'], // Actual pattern(s) to match.
            dest: 'dest/js',   // Destination path prefix.
            ext: '.min.js',   // Dest filepaths will have this extension.
            extDot: 'first'   // Extensions in filenames begin after the first dot
          },
        ],
      },
    },
  	cssmin: {
      compress: {
        files: [{
          expand: true,
          cwd: 'src',
          src: 'css/**/*.css',
          dest: 'dest'
        }]
      },
      buildcss: {
        files: {
          "dest/css/main.min.css": "src/css/**/*.css"
        }
      },
      devcss: {
        files: {
          "src/csslib/main.min.css": "src/css/**/*.css"
        }
      }
    },
  	htmlmin: {
  		dist: {
  			options: {
          //去注析
          removeComments: true,
          //去换行
          collapseWhitespace: true
  			},
  			files: [{
          expand: true,
          cwd: 'src',
          src: '**/*.html',
          dest: 'dest/'
        }]
  		}
  	},
  	imagemin: {
  		dist: { // Target
  			options: { // Target options
  				optimizationLevel: 3
  			},
  			files: { // Dictionary of files
  				'dist/images/photo.png': 'src/images/photo.png', // 'destination': 'source'
  				'dist/images/badge.jpg': 'src/images/badge.jpg'
  			}
  		},
  		dynamic_mappings: {
        options: {
          optimizationLevel: 5
        },
        files: [
          {
          expand: true,
          cwd: 'src/img/',
          src: ['**/*.{png,jpg,gif}'],
          dest: 'dest/img/',
          ext: '.png'
          }
        ]
       },
       compressAll: {
        options: {
          optimizationLevel: 5
        },
  			files: [
  			  {
  				expand: true,
  				cwd: 'src/img/',
  				src: ['**/*.{png,jpg,gif,webp}'],
  				dest: 'dest/img/',
  			  }
  			]
  		 }
	   },
  	sass: {
  		dist: {
  			options: {
  			  style: 'expanded',
  			  sourcemap: "none"
  			},
  			files: [{
  			  expand: true,
  			  cwd: 'sass',
  			  src: '**/*.scss',
  			  dest: 'src/css',
  			  ext: '.css',   // Dest filepaths will have this extension.
  			  extDot: 'first'
  			}]
  		}
  	},
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        browser: true,
        globals: {
          jQuery: true
        }
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      lib_test: {
        src: ['lib/**/*.js', 'test/**/*.js']
      }
    },
    qunit: {
      files: ['test/**/*.html']
    },
  	connect: {
        options: {
          port: 8001,
          hostname: '*', //默认就是这个值，可配置为本机某个 IP，localhost 或域名
          livereload: 35729  //声明给 watch 监听的端口
        },

        server: {
          options: {
            open: {
              target: 'http://localhost:8001/index.html' // target url to open

            }, //自动打开网页 http://
            base: [
              'src'  //主目录
            ],
            middleware: function (connect, options, defaultMiddleware) {
               var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
               return [
                  // Include the proxy first
                  proxy
               ].concat(defaultMiddleware);
            }
          }
        },
        server2: {
            proxies: [{
                context: '/api',
                host: '210.73.90.29',
                port: 8888,
                https: false,
                xforward: false,

            }]
        }

    },
    watch: {
      options: {
        spawn: false,
        event: ['added', 'deleted', 'changed'],
        reload: true
      },
  	  livereload: {
        options: {
          livereload: '<%=connect.options.livereload%>'  //监听前面声明的端口  35729
        },

        files: [  //下面文件的改变就会实时刷新网页
          'src/**/*.html',
          'src/**/*.js',
          'src/**/*.css'
        ]
      },
  	  scripts: {
        options: {
          spawn: false,
          event: ['added', 'deleted', 'changed'],
          reload: true
        },
  	    files: [
    		  '<%= meta.srcPath %>/**/*.scss'
    	    ],
    	    tasks: ['sass']
  	  },
      cssconcat: {
        files: [
          'src/css/**/*.css'
          ],
          tasks: ['cssmin:devcss']
      },
      // gruntfile: {
      //   files: '<%= jshint.gruntfile.src %>',
      //   tasks: ['jshint:gruntfile']
      // },
      // lib_test: {
      //   files: '<%= jshint.lib_test.src %>',
      //   tasks: ['jshint:lib_test', 'qunit']
      // }
    },
  	bower: {
  		install: {
  		  options: {
  			targetDir: './src/public/js',
  			layout: 'byComponent',
  			install: true,
  			verbose: false,
  			cleanTargetDir: false,
  			cleanBowerDir: false,
  			bowerOptions: {}
  		  }
  		}
	  },
    copy: {
      dev: {
        files: [
          {
            expand: true,
            src: ['src/**/*.js'],
            dest: 'dest/cp',
            filter: 'isFile'
          }
        ]
      }
    },
    requirejs: {
      compile: {
        options: {
          findNestedDependencies: true,
          // "uglify：使用 UglifyJS 压缩代码，默认值；
          // "uglify2"：使用 2.1.2+ 版本进行压缩；
          // "closure"： 使用 Google's Closure Compiler 进行压缩合并，需要 Java 环境；
          // "closure.keepLines"：使用 Closure Compiler 进行压缩合并并保留换行；
          // "none"：不做压缩合并；
          optimize: "uglify2",
          // "standard"：标准的压缩方式；
          // "standard.keepLines"：保留换行；
          // "standard.keepComments"：保留注释；
          // "standard.keepComments.keepLines"：保留换行；
          // "none"：不压缩；
          optimizeCss: "standard.keepLines",
          //删除之前压缩合并的文件，默认值 false
          removeCombined: true,
          // publish 任务时不可以将  generateSourceMaps  配置项打开
          generateSourceMaps: false,
          preserveLicenseComments: false,
          useSourceUrl: false,
          baseUrl: "src/",
          // 输出目录的路径。如果不设置，则默认为和 build 文件同级的 build 目录。
          // dir: "dest/dds",
          //要排除的文件的正则匹配的表达式
          //fileExclusionRegExp: /^\./,
          mainConfigFile: 'src/js/main.js',
          name : "js/main",
          //include: ['jquery'],
          out: "dest/js/main.min.js"
        }
      },
      almond: {
        options: {
          baseUrl: "src",
          optimize: "uglify2",
          include: "js/main",
          mainConfigFile: 'src/js/main.js',
          preserveLicenseComments: false,
          //insertRequire: ['main'],
          name: "public/js/almond/almond", // assumes a production build using almond
          out: "dest/to/optimizeds.js",
          wrap: true
          // wrap: {
          //     startFile: 'src/public/start.frag.js',
          //     endFile: 'src/public/end.frag.js'
          // }
        }
      },
      compile_split: {
        options: {
          findNestedDependencies: true,
          optimize: "none",
          optimizeCss: "standard.keepLines",
          removeCombined: true,
          generateSourceMaps: true,
           // publish 任务时不可以将  generateSourceMaps  配置项打开
          preserveLicenseComments: false,
          useSourceUrl: true,
          baseUrl: "src/",
          // 输出目录的路径。如果不设置，则默认为和 build 文件同级的 build 目录。
          dir: "dest/dds",
          //要排除的文件的正则匹配的表达式
          //fileExclusionRegExp: /^\./,
          mainConfigFile: 'src/js/main.js',
          //modules定义要被优化的模块数组。每一项是模块优化的配置，常用的几个参数如下：
          //name：模块名；
          //create：如果不存在，是否创建。默认 false；
          //include：额外引入的模块，和 name 定义的模块一起压缩合并；
          //exclude：要排除的模块。有些模块有公共的依赖模块，在合并的时候每个都会压缩进去
          modules: [
              {
                  name: "domready",
              },
              {
                name: "angular"
              },
              {
                name: "angularRoute"
              },
              {
                name: "angularResource"
              },
              {
                name: "app"
              },
              {
                name: "appCtrl"
              },
              {
                name: "comp"
              },
              {
                name: "service"
              }
              // {
              //     name: "app/in-storage",
              //     exclude: [
              //         "jquery",
              //         "app/common",
              //         "pkg/DatePicker/app"
              //     ]
              // }
          ]
        }
      },
      app_2: {
          options: {
            findNestedDependencies: true,
            baseUrl: "src/js",
            paths: {
                asset1: "../public/js",
                assets: "js"
            },
            name: "app",
            out: "dest/app_2/app-built.js"
          }
      },
      compile2: {
        options: {
          baseUrl: "src/",
          mainConfigFile: "dest/cp/src/js/main.js",
          out: "dest/jst/main.js"
        }
      }
    }
  });

  // These plugins provide necessary tasks.
  //grunt.loadNpmTasks('grunt-contrib-concat');

  // Load the plugin HTML/CSS/JS/IMG min
  // grunt.loadNpmTasks('grunt-contrib-htmlmin');
  // grunt.loadNpmTasks('grunt-contrib-uglify');
  // grunt.loadNpmTasks('grunt-contrib-cssmin');
  // grunt.loadNpmTasks('grunt-contrib-imagemin');

  //grunt.loadNpmTasks("grunt-contrib-sass");

  //grunt.loadNpmTasks('grunt-contrib-qunit');
  // grunt.loadNpmTasks('grunt-contrib-jshint');
  // grunt.loadNpmTasks('grunt-contrib-watch');
  //bower src copy
  // grunt.loadNpmTasks('grunt-bower-task');

  // Default task.
  grunt.registerTask('default', ['cssbuild', 'imagebuild', 'htmlbuild', 'requirejsmin', 'requirebuild']);

  //复制bower下载资源到public目录下
  grunt.registerTask('bowerbuild', ['bower']);

  //编译scss文件到css目录
  grunt.registerTask('sassbuild', ['sass']);

  //合并css文件
  grunt.registerTask('cssbuild', ['cssmin:buildcss']);

  //开发合并css文件
  grunt.registerTask('devcss', ['cssmin:devcss']);

  //图片压缩为png
  grunt.registerTask('imagebuild', ['imagemin:compressAll']);

  //html压缩
  grunt.registerTask('htmlbuild', ['htmlmin']);

  //copy文件
  grunt.registerTask('cpjs', ['copy']);

  //编译合并requirejs文件
  grunt.registerTask('requirebuild', ['requirejs:compile']);

  //压缩requirejs源码
  grunt.registerTask('requirejsmin', ['uglify:dynamic_mappings']);

  grunt.registerTask('almondbuild', ['requirejs:almond']);

  grunt.registerTask('build', ['htmlmin', 'uglify', 'cssmin', 'imagemin']);

  //自动打开浏览器并监听scss文件变更
  grunt.registerTask('server', [
   'configureProxies:server2',
   'connect:server',
   'watch'
  ]);
};
<commit_msg>修改copy<commit_after>/*global module:false*/
module.exports = function(grunt) {

	require('load-grunt-tasks')(grunt); // 加载所有的任务
	// require('time-grunt')(grunt); 如果要使用 time-grunt 插件

	// var requireJsModules = [];
	// grunt.file.expand({cwd:"./static/js/"}, "**/*.js").forEach( function
	// (file) {
	// if (file !== 'opt.js') {
	// requireJsModules.push(file.replace(/\.js$/, ''));
	// }
	// });
	// grunt.log.write(requireJsModules);

	// Project configuration.
	grunt
			.initConfig({
				// Metadata.
				pkg : grunt.file.readJSON('package.json'),
				// Metadata.
				meta : {
					basePath : './',
					srcPath : './sass',
					deployPath : './assets/css/'
				},
				banner : '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - '
						+ '<%= grunt.template.today("yyyy-mm-dd") %>\n'
						+ '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>'
						+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;'
						+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
				// Task configuration.
				concat : {
					options : {
						banner : '<%= banner %>',
						stripBanners : true
					},
					dist : {
						src : [ 'lib/<%= pkg.name %>.js' ],
						dest : 'dist/<%= pkg.name %>.js'
					}
				},
				uglify : {
					static_mappings : {
						// Because these src-dest file mappings are manually
						// specified, every
						// time a new file is added or removed, the Gruntfile
						// has to be updated.
						files : [ {
							src : 'lib/a.js',
							dest : 'build/a.min.js'
						}, {
							src : 'lib/b.js',
							dest : 'build/b.min.js'
						}, {
							src : 'lib/subdir/c.js',
							dest : 'build/subdir/c.min.js'
						}, {
							src : 'lib/subdir/d.js',
							dest : 'build/subdir/d.min.js'
						}, ],
					},
					dynamic_mappings : {
						// Grunt will search for "**/*.js" under "lib/" when the
						// "uglify" task
						// runs and build the appropriate src-dest file mappings
						// then, so you
						// don't need to update the Gruntfile when files are
						// added or removed.
						files : [ {
							expand : true, // Enable dynamic expansion.
							cwd : 'src/public/js/requirejs', // Src matches
							// are relative
							// to this path.
							src : [ '**/*.js' ], // Actual pattern(s) to
							// match.
							dest : 'dest/js', // Destination path prefix.
							ext : '.min.js', // Dest filepaths will have this
							// extension.
							extDot : 'first' // Extensions in filenames begin
						// after the first dot
						}, ],
					},
				},
				cssmin : {
					compress : {
						files : [ {
							expand : true,
							cwd : 'src',
							src : 'css/**/*.css',
							dest : 'dest'
						} ]
					},
					buildcss : {
						files : {
							"dest/css/main.min.css" : "src/css/**/*.css"
						}
					},
					devcss : {
						files : {
							"src/csslib/main.min.css" : "src/css/**/*.css"
						}
					}
				},
				htmlmin : {
					dist : {
						options : {
							// 去注析
							removeComments : true,
							// 去换行
							collapseWhitespace : true
						},
						files : [ {
							expand : true,
							cwd : 'src',
							src : '**/*.html',
							dest : 'dest/'
						} ]
					}
				},
				imagemin : {
					dist : { // Target
						options : { // Target options
							optimizationLevel : 3
						},
						files : { // Dictionary of files
							'dist/images/photo.png' : 'src/images/photo.png', // 'destination':
							// 'source'
							'dist/images/badge.jpg' : 'src/images/badge.jpg'
						}
					},
					dynamic_mappings : {
						options : {
							optimizationLevel : 5
						},
						files : [ {
							expand : true,
							cwd : 'src/img/',
							src : [ '**/*.{png,jpg,gif}' ],
							dest : 'dest/img/',
							ext : '.png'
						} ]
					},
					compressAll : {
						options : {
							optimizationLevel : 5
						},
						files : [ {
							expand : true,
							cwd : 'src/img/',
							src : [ '**/*.{png,jpg,gif,webp}' ],
							dest : 'dest/img/',
						} ]
					}
				},
				sass : {
					dist : {
						options : {
							style : 'expanded',
							sourcemap : "none"
						},
						files : [ {
							expand : true,
							cwd : 'sass',
							src : '**/*.scss',
							dest : 'src/css',
							ext : '.css', // Dest filepaths will have this
							// extension.
							extDot : 'first'
						} ]
					}
				},
				jshint : {
					options : {
						curly : true,
						eqeqeq : true,
						immed : true,
						latedef : true,
						newcap : true,
						noarg : true,
						sub : true,
						undef : true,
						unused : true,
						boss : true,
						eqnull : true,
						browser : true,
						globals : {
							jQuery : true
						}
					},
					gruntfile : {
						src : 'Gruntfile.js'
					},
					lib_test : {
						src : [ 'lib/**/*.js', 'test/**/*.js' ]
					}
				},
				qunit : {
					files : [ 'test/**/*.html' ]
				},
				connect : {
					options : {
						port : 8001,
						hostname : '*', // 默认就是这个值，可配置为本机某个 IP，localhost 或域名
						livereload : 35729
					// 声明给 watch 监听的端口
					},

					server : {
						options : {
							open : {
								target : 'http://localhost:8001/index.html' // target
							// url
							// to
							// open

							}, // 自动打开网页 http://
							base : [ 'src' // 主目录
							],
							middleware : function(connect, options,
									defaultMiddleware) {
								var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
								return [
								// Include the proxy first
								proxy ].concat(defaultMiddleware);
							}
						}
					},
					server2 : {
						proxies : [ {
							context : '/api',
							host : '210.73.90.29',
							port : 8888,
							https : false,
							xforward : false,

						} ]
					}

				},
				watch : {
					options : {
						spawn : false,
						event : [ 'added', 'deleted', 'changed' ],
						reload : true
					},
					livereload : {
						options : {
							livereload : '<%=connect.options.livereload%>' // 监听前面声明的端口
						// 35729
						},

						files : [ // 下面文件的改变就会实时刷新网页
						'src/**/*.html', 'src/**/*.js', 'src/**/*.css' ]
					},
					scripts : {
						options : {
							spawn : false,
							event : [ 'added', 'deleted', 'changed' ],
							reload : true
						},
						files : [ '<%= meta.srcPath %>/**/*.scss' ],
						tasks : [ 'sass' ]
					},
					cssconcat : {
						files : [ 'src/css/**/*.css' ],
						tasks : [ 'cssmin:devcss' ]
					},
				// gruntfile: {
				// files: '<%= jshint.gruntfile.src %>',
				// tasks: ['jshint:gruntfile']
				// },
				// lib_test: {
				// files: '<%= jshint.lib_test.src %>',
				// tasks: ['jshint:lib_test', 'qunit']
				// }
				},
				bower : {
					install : {
						options : {
							targetDir : './src/public/js',
							layout : 'byComponent',
							install : true,
							verbose : false,
							cleanTargetDir : false,
							cleanBowerDir : false,
							bowerOptions : {}
						}
					}
				},
				copy : {
					dev : {
						files : [ {
							expand : true,
							cwd : 'src/fonts',
							src : [ '**/*' ],
							dest : 'dest/fonts',
							filter : 'isFile'
						} ]
					}
				},
				requirejs : {
					compile : {
						options : {
							findNestedDependencies : true,
							// "uglify：使用 UglifyJS 压缩代码，默认值；
							// "uglify2"：使用 2.1.2+ 版本进行压缩；
							// "closure"： 使用 Google's Closure Compiler 进行压缩合并，需要
							// Java 环境；
							// "closure.keepLines"：使用 Closure Compiler
							// 进行压缩合并并保留换行；
							// "none"：不做压缩合并；
							optimize : "uglify2",
							// "standard"：标准的压缩方式；
							// "standard.keepLines"：保留换行；
							// "standard.keepComments"：保留注释；
							// "standard.keepComments.keepLines"：保留换行；
							// "none"：不压缩；
							optimizeCss : "standard.keepLines",
							// 删除之前压缩合并的文件，默认值 false
							removeCombined : true,
							// publish 任务时不可以将 generateSourceMaps 配置项打开
							generateSourceMaps : false,
							preserveLicenseComments : false,
							useSourceUrl : false,
							baseUrl : "src/",
							// 输出目录的路径。如果不设置，则默认为和 build 文件同级的 build 目录。
							// dir: "dest/dds",
							// 要排除的文件的正则匹配的表达式
							// fileExclusionRegExp: /^\./,
							mainConfigFile : 'src/js/main.js',
							name : "js/main",
							// include: ['jquery'],
							out : "dest/js/main.min.js"
						}
					},
					almond : {
						options : {
							baseUrl : "src",
							optimize : "uglify2",
							include : "js/main",
							mainConfigFile : 'src/js/main.js',
							preserveLicenseComments : false,
							// insertRequire: ['main'],
							name : "public/js/almond/almond", // assumes a
							// production
							// build using
							// almond
							out : "dest/to/optimizeds.js",
							wrap : true
						// wrap: {
						// startFile: 'src/public/start.frag.js',
						// endFile: 'src/public/end.frag.js'
						// }
						}
					},
					compile_split : {
						options : {
							findNestedDependencies : true,
							optimize : "none",
							optimizeCss : "standard.keepLines",
							removeCombined : true,
							generateSourceMaps : true,
							// publish 任务时不可以将 generateSourceMaps 配置项打开
							preserveLicenseComments : false,
							useSourceUrl : true,
							baseUrl : "src/",
							// 输出目录的路径。如果不设置，则默认为和 build 文件同级的 build 目录。
							dir : "dest/dds",
							// 要排除的文件的正则匹配的表达式
							// fileExclusionRegExp: /^\./,
							mainConfigFile : 'src/js/main.js',
							// modules定义要被优化的模块数组。每一项是模块优化的配置，常用的几个参数如下：
							// name：模块名；
							// create：如果不存在，是否创建。默认 false；
							// include：额外引入的模块，和 name 定义的模块一起压缩合并；
							// exclude：要排除的模块。有些模块有公共的依赖模块，在合并的时候每个都会压缩进去
							modules : [ {
								name : "domready",
							}, {
								name : "angular"
							}, {
								name : "angularRoute"
							}, {
								name : "angularResource"
							}, {
								name : "app"
							}, {
								name : "appCtrl"
							}, {
								name : "comp"
							}, {
								name : "service"
							}
							// {
							// name: "app/in-storage",
							// exclude: [
							// "jquery",
							// "app/common",
							// "pkg/DatePicker/app"
							// ]
							// }
							]
						}
					},
					app_2 : {
						options : {
							findNestedDependencies : true,
							baseUrl : "src/js",
							paths : {
								asset1 : "../public/js",
								assets : "js"
							},
							name : "app",
							out : "dest/app_2/app-built.js"
						}
					},
					compile2 : {
						options : {
							baseUrl : "src/",
							mainConfigFile : "dest/cp/src/js/main.js",
							out : "dest/jst/main.js"
						}
					}
				}
			});

	// These plugins provide necessary tasks.
	// grunt.loadNpmTasks('grunt-contrib-concat');

	// Load the plugin HTML/CSS/JS/IMG min
	// grunt.loadNpmTasks('grunt-contrib-htmlmin');
	// grunt.loadNpmTasks('grunt-contrib-uglify');
	// grunt.loadNpmTasks('grunt-contrib-cssmin');
	// grunt.loadNpmTasks('grunt-contrib-imagemin');

	// grunt.loadNpmTasks("grunt-contrib-sass");

	// grunt.loadNpmTasks('grunt-contrib-qunit');
	// grunt.loadNpmTasks('grunt-contrib-jshint');
	// grunt.loadNpmTasks('grunt-contrib-watch');
	// bower src copy
	// grunt.loadNpmTasks('grunt-bower-task');

	// Default task.
	grunt.registerTask('default', [ 'cssbuild', 'imagebuild', 'htmlbuild',
			'requirejsmin', 'requirebuild' ]);

	// 复制bower下载资源到public目录下
	grunt.registerTask('bowerbuild', [ 'bower' ]);

	// 编译scss文件到css目录
	grunt.registerTask('sassbuild', [ 'sass' ]);

	// 合并css文件
	grunt.registerTask('cssbuild', [ 'cssmin:buildcss' ]);

	// 开发合并css文件
	grunt.registerTask('devcss', [ 'cssmin:devcss' ]);

	// 图片压缩为png
	grunt.registerTask('imagebuild', [ 'imagemin:compressAll' ]);

	// html压缩
	grunt.registerTask('htmlbuild', [ 'htmlmin' ]);

	// copy文件
	grunt.registerTask('cpjs', [ 'copy' ]);

	// 编译合并requirejs文件
	grunt.registerTask('requirebuild', [ 'requirejs:compile' ]);

	// 压缩requirejs源码
	grunt.registerTask('requirejsmin', [ 'uglify:dynamic_mappings' ]);

	grunt.registerTask('almondbuild', [ 'requirejs:almond' ]);

	grunt.registerTask('build', [ 'htmlmin', 'uglify', 'cssmin', 'imagemin' ]);

	// 自动打开浏览器并监听scss文件变更
	grunt.registerTask('server', [ 'configureProxies:server2',
			'connect:server', 'watch' ]);
};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['src/**/*.js'],
        //dest: 'dist/token.js',
        //src: ['lib/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.dist.dest %>',
        dest: 'dist/<%= pkg.name %>.min.js'
      }
    },
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        smarttabs: true,
        globals: {}
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      lib_test: {
        src: ['lib/**/*.js', 'test/**/*.js']
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
    },
    karma: {
      unit: {
        configFile: 'karma.config.js',
        singleRun: true
      }
    },
    copy: {
      build: {
        cwd: 'src',
        src: ['*.html'],
        dest: 'dist',
        expand: true
      },
    },
    clean: {
      build: {
        src: ['dist']
      },
    },
//    uglify: {
//      build: {
//        options: {
//          mangle: false
//        },
//        files: {
//          'dist/token.min.js': ['dist/**/*.js']
//        },
//      },
//    },
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: 'dist',
          src: '*.js',
          dest: 'dist'
        }]
      }
    },
//    concat: {
//      options: {
//        separator: ';'
//      },
//      dist: {
//        src: ['src/**/*.js'],
//        dest: 'dist/token.js',
//      },
//    },
  });

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

  // Default task.
  grunt.registerTask('default', ['jshint', 'karma', 'build']);

  grunt.registerTask('build', [
    'clean',
    'copy',
    'concat',
    'ngmin',
    'uglify',
  ]);
};
<commit_msg>Concat files for distribution<commit_after>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['src/**/*.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.dist.dest %>',
        dest: 'dist/<%= pkg.name %>.min.js'
      }
    },
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        smarttabs: true,
        globals: {}
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      lib_test: {
        src: ['lib/**/*.js', 'test/**/*.js']
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
    },
    karma: {
      unit: {
        configFile: 'karma.config.js',
        singleRun: true
      }
    },
    copy: {
      build: {
        cwd: 'src',
        src: ['*.html'],
        dest: 'dist',
        expand: true
      },
    },
    clean: {
      build: {
        src: ['dist']
      },
    },
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: 'dist',
          src: '*.js',
          dest: 'dist'
        }]
      }
    },
  });

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

  // Default task.
  grunt.registerTask('default', ['jshint', 'karma', 'build']);

  grunt.registerTask('build', [
    'clean',
    'copy',
    'concat',
    'ngmin',
    'uglify',
  ]);
};
<|endoftext|>


<commit_before>'use strict';

var	port = process.env.PORT || 3333;

module.exports = function(grunt) {

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

        /**
         * connect
         */
        connect: {
            server: {
                options: {
                    port: port,
                }
            }
        },

        /**
         * jasmine_node
         */
        jasmine_node: {
            options: {
                forceExit: true,
                host: 'http://localhost:' + port + '/',
                match: '.',
                matchall: false,
                extensions: 'js',
                specNameMatcher: 'spec'
            },
            all: ['spec/']
        },

        /**
         * jshint
         */
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            gruntfile: {
                src: 'Gruntfile.js'
            },
            index: {
                src: 'index.js'
            },
            spec: {
                src: ['spec/**/*.js']
            },
        },
      });

    /**
     * Load the plugins
     */
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-jasmine-node');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    /**
     * Default task(s).
     */
    grunt.registerTask('default', ['jshint']);

    /**
     * Jasmine unit tests
     */
    grunt.registerTask('test', ['connect','jasmine_node']);
};
<commit_msg>Remove connect configuration<commit_after>'use strict';
//require('./index');

var port = process.env.PORT || 3333;

module.exports = function(grunt) {

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

        /**
         * jasmine_node
         */
        jasmine_node: {
            options: {
                forceExit: true,
                host: 'http://localhost:' + port + '/',
                match: '.',
                matchall: false,
                extensions: 'js',
                specNameMatcher: '[sS]pec'
            },
            all: []
        },

        /**
         * jshint
         */
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            gruntfile: {
                src: 'Gruntfile.js'
            },
            index: {
                src: 'index.js'
            },
            spec: {
                src: ['spec/**/*.js']
            },
        },
      });

    /**
     * Load the plugins
     */
    grunt.loadNpmTasks('grunt-jasmine-node');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    /**
     * Default task(s).
     */
    grunt.registerTask('default', ['jshint']);

    /**
     * Jasmine unit tests
     */
    grunt.registerTask('test', ['jasmine_node']);
};
<|endoftext|>


<commit_before>// # Gruntfile
// Automation for the project.

'use strict';

var GruntConfig = require('thehelp-project').GruntConfig;

// We simply create an instance of the `GruntConfig` class from
// `thehelp-project`, then call the register functions we need.
module.exports = function(grunt) {
  var config = new GruntConfig(grunt);

  config.standardSetup();
  config.standardDefault();
};
<commit_msg>Add integration test to default grunt task<commit_after>// # Gruntfile
// Automation for the project.

'use strict';

var GruntConfig = require('thehelp-project').GruntConfig;

// We simply create an instance of the `GruntConfig` class from
// `thehelp-project`, then call the register functions we need.
module.exports = function(grunt) {
  var config = new GruntConfig(grunt);

  config.standardSetup();
  config.standardDefault();

  grunt.config('shell.integration', {
    command: 'cd test/default && ./run.sh && ./clean.sh'
  });

  var tasks = config.defaultTasks.concat(['shell:integration']);
  grunt.registerTask('default', tasks);
};
<|endoftext|>


<commit_before>/* global module, require */

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

	// Time how long tasks take. Can help when optimizing build times
/*	require('time-grunt')(grunt);
*/
	// Automatically load required Grunt tasks
	require('jit-grunt')(grunt, {
		nwjs: 'grunt-nw-builder',
		sloc: 'grunt-file-sloc'
	});

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

		replace: {
			jsqrcode: {
				files: [{
					src: ['bower_components/jsqrcode/lib/qrcode-decoder.min.js'],
					dest: 'build/'
				}],
				options: {
					usePrefix: false,
					patterns: [{
						match: 'qrcode=qrcode||{}',
						replacement: 'qrcode={}'
					}]
				}
			}
		},

		concat: {
			vendor: {
				src: [
					'bower_components/angular-route/angular-route.min.js',
					'bower_components/buffer/buffer.min.js',
					'bower_components/decimal.js/decimal.js',
					'build/bower_components/jsqrcode/lib/qrcode-decoder.min.js',
					'bower_components/moment/min/moment-with-locales.js',
					'bower_components/qrcode.js/qrcode.js',
					'bower_components/sjcl/sjcl.js',
					'bower_components/stellar-sdk/stellar-sdk.min.js',
					'bower_components/toml-j0.4/dist/toml-browser.js'
				],
				dest: 'dist/js/vendor.js'
			},
			js: {
				src: [
					'app/app.js',
					'app/**/*.js'
				],
				dest: 'dist/js/stargazer.js'
			}
		},

		// Copies remaining files to places other tasks can use
		copy: {
			'font-awesome': {
				files: [{
					src: 'bower_components/font-awesome/css/font-awesome.min.css',
					dest: 'content/css/font-awesome.min.css'
				},{
					expand: true,
					cwd: 'bower_components/font-awesome/fonts/',
					src: ['fontawesome-webfont.*'],
					dest: 'content/fonts/'
				}]
			},
			ionic: {
				files: [{
					src: 'bower_components/ionic/release/js/ionic.bundle.js',
					dest: 'dist/js/ionic.bundle.js'
				}, {
					expand: true,
					cwd: 'bower_components/ionic/release/fonts/',
					src: ['*'],
					dest: 'content/fonts/'
				}, {
					src: 'bower_components/ionic/release/css/ionic.min.css',
					dest: 'content/css/ionic.min.css'
				}]
			},
			lodash: {
				files: [{
					src: 'bower_components/lodash/dist/lodash.min.js',
					dest: 'dist/js/lodash.min.js'
				}]
			},
			content: {
				expand: true,
				cwd: 'content',
				src: ['**/*'],
				dest: 'dist/'
			},
			html: {
				expand: true,
				cwd: '',
				src: ['app/**/*.html'],
				dest: 'dist/'
			}
		},

		watch: {
			options: {
				spawn: false
			},
			files: [
				'app/**/*',
				'content/**/*'
			],
			tasks: [
				'build'
			]
		},

		nwjs: {
			options: {
				version: 'latest',
				flavor: 'normal',
				platforms: ['osx64', 'win64'],
				buildDir: './webkitbuilds'		// Where the build version of my NW.js app is saved
			},
			src: ['./nwjs/**'] // Your NW.js app
		},

		sloc: {
			'style3': {
				files: [
					{ src: ['app/**/*.js'] }
				]
			}
		}
	});

	grunt.registerTask('build', [
		'replace:jsqrcode',
		'concat',
		'copy'
	]);

	grunt.registerTask('default', [
		'build',
		'watch'
	]);
};
<commit_msg>Add linux64 as a build target<commit_after>/* global module, require */

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

	// Time how long tasks take. Can help when optimizing build times
/*	require('time-grunt')(grunt);
*/
	// Automatically load required Grunt tasks
	require('jit-grunt')(grunt, {
		nwjs: 'grunt-nw-builder',
		sloc: 'grunt-file-sloc'
	});

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

		replace: {
			jsqrcode: {
				files: [{
					src: ['bower_components/jsqrcode/lib/qrcode-decoder.min.js'],
					dest: 'build/'
				}],
				options: {
					usePrefix: false,
					patterns: [{
						match: 'qrcode=qrcode||{}',
						replacement: 'qrcode={}'
					}]
				}
			}
		},

		concat: {
			vendor: {
				src: [
					'bower_components/angular-route/angular-route.min.js',
					'bower_components/buffer/buffer.min.js',
					'bower_components/decimal.js/decimal.js',
					'build/bower_components/jsqrcode/lib/qrcode-decoder.min.js',
					'bower_components/moment/min/moment-with-locales.js',
					'bower_components/qrcode.js/qrcode.js',
					'bower_components/sjcl/sjcl.js',
					'bower_components/stellar-sdk/stellar-sdk.min.js',
					'bower_components/toml-j0.4/dist/toml-browser.js'
				],
				dest: 'dist/js/vendor.js'
			},
			js: {
				src: [
					'app/app.js',
					'app/**/*.js'
				],
				dest: 'dist/js/stargazer.js'
			}
		},

		// Copies remaining files to places other tasks can use
		copy: {
			'font-awesome': {
				files: [{
					src: 'bower_components/font-awesome/css/font-awesome.min.css',
					dest: 'content/css/font-awesome.min.css'
				},{
					expand: true,
					cwd: 'bower_components/font-awesome/fonts/',
					src: ['fontawesome-webfont.*'],
					dest: 'content/fonts/'
				}]
			},
			ionic: {
				files: [{
					src: 'bower_components/ionic/release/js/ionic.bundle.js',
					dest: 'dist/js/ionic.bundle.js'
				}, {
					expand: true,
					cwd: 'bower_components/ionic/release/fonts/',
					src: ['*'],
					dest: 'content/fonts/'
				}, {
					src: 'bower_components/ionic/release/css/ionic.min.css',
					dest: 'content/css/ionic.min.css'
				}]
			},
			lodash: {
				files: [{
					src: 'bower_components/lodash/dist/lodash.min.js',
					dest: 'dist/js/lodash.min.js'
				}]
			},
			content: {
				expand: true,
				cwd: 'content',
				src: ['**/*'],
				dest: 'dist/'
			},
			html: {
				expand: true,
				cwd: '',
				src: ['app/**/*.html'],
				dest: 'dist/'
			}
		},

		watch: {
			options: {
				spawn: false
			},
			files: [
				'app/**/*',
				'content/**/*'
			],
			tasks: [
				'build'
			]
		},

		nwjs: {
			options: {
				version: 'latest',
				flavor: 'normal',
				platforms: ['osx64', 'win64', 'linux64'],
				buildDir: './webkitbuilds'		// Where the build version of my NW.js app is saved
			},
			src: ['./nwjs/**'] // Your NW.js app
		},

		sloc: {
			'style3': {
				files: [
					{ src: ['app/**/*.js'] }
				]
			}
		}
	});

	grunt.registerTask('build', [
		'replace:jsqrcode',
		'concat',
		'copy'
	]);

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