浏览代码

Cleaned up the Grunt config a bit, removed an unneeded dep

Spencer Alger 12 年之前
父节点
当前提交
412cefed78
共有 2 个文件被更改,包括 79 次插入72 次删除
  1. 68 61
      Gruntfile.js
  2. 11 11
      package.json

+ 68 - 61
Gruntfile.js

@@ -170,6 +170,9 @@ module.exports = function (grunt) {
     },
     },
     s3: {
     s3: {
       dist: {
       dist: {
+        bucket: 'download.elasticsearch.org',
+        access: 'private',
+        // debug: true, // uncommment to prevent actual upload
         upload: [
         upload: [
           {
           {
             src: '<%= tempDir %>/dist.zip',
             src: '<%= tempDir %>/dist.zip',
@@ -180,71 +183,56 @@ module.exports = function (grunt) {
     }
     }
   };
   };
 
 
-  var fs = require('fs');
-  var requireModules = [
+  // setup the modules require will build
+  var requireModules = config.requirejs.compile_temp.options.modules = [
     {
     {
       // main/common module
       // main/common module
       name: 'app',
       name: 'app',
       include: [
       include: [
+        'css',
         'kbn',
         'kbn',
+        'text',
         'jquery',
         'jquery',
-        'underscore',
         'angular',
         'angular',
+        'settings',
         'bootstrap',
         'bootstrap',
         'modernizr',
         'modernizr',
-        'jquery',
-        'angular-sanitize',
+        'elasticjs',
         'timepicker',
         'timepicker',
         'datepicker',
         'datepicker',
-        'elasticjs',
-        'angular-strap',
-        'directives/all',
+        'underscore',
         'filters/all',
         'filters/all',
-        'services/all',
         'jquery.flot',
         'jquery.flot',
+        'services/all',
+        'angular-strap',
+        'directives/all',
         'jquery.flot.pie',
         'jquery.flot.pie',
-        'text',
-        'settings'
+        'angular-sanitize'
       ]
       ]
     }
     }
   ];
   ];
 
 
   // create a module for each directory in src/app/panels/
   // create a module for each directory in src/app/panels/
-  fs.readdirSync(config.srcDir+'/app/panels').forEach(function (panelName) {
-    requireModules.push({
-      name: 'panels/'+panelName+'/module',
-      exclude: ['app']
+  require('fs')
+    .readdirSync(config.srcDir+'/app/panels')
+    .forEach(function (panelName) {
+      requireModules.push({
+        name: 'panels/'+panelName+'/module',
+        exclude: ['app']
+      });
     });
     });
-  });
 
 
   // exclude the literal config definition from all modules
   // exclude the literal config definition from all modules
-  requireModules.forEach(function (module) {
-    module.excludeShallow = module.excludeShallow || [];
-    module.excludeShallow.push('config');
-  });
-
-  config.requirejs.compile_temp.options.modules = requireModules;
-
-  // load plugins
-  grunt.loadNpmTasks('grunt-s3');
-  grunt.loadNpmTasks('grunt-zip');
-  grunt.loadNpmTasks('grunt-ngmin');
-  grunt.loadNpmTasks('grunt-contrib-copy');
-  grunt.loadNpmTasks('grunt-contrib-less');
-  grunt.loadNpmTasks('grunt-git-describe');
-  grunt.loadNpmTasks('grunt-contrib-clean');
-  grunt.loadNpmTasks('grunt-contrib-jshint');
-  grunt.loadNpmTasks('grunt-contrib-cssmin');
-  grunt.loadNpmTasks('grunt-contrib-uglify');
-  grunt.loadNpmTasks('grunt-string-replace');
-  grunt.loadNpmTasks('grunt-contrib-htmlmin');
-  grunt.loadNpmTasks('grunt-contrib-requirejs');
+  requireModules
+    .forEach(function (module) {
+      module.excludeShallow = module.excludeShallow || [];
+      module.excludeShallow.push('config');
+    });
 
 
-  // Project configuration.
-  grunt.initConfig(config);
+  // Run jshint
+  grunt.registerTask('default', ['jshint:source', 'less:src']);
 
 
-  // Default task.
-  grunt.registerTask('default', ['jshint:source','less:src']);
+  // Concat and Minify the src directory into dist
   grunt.registerTask('build', [
   grunt.registerTask('build', [
     'jshint:source',
     'jshint:source',
     'clean:on_start',
     'clean:on_start',
@@ -255,29 +243,12 @@ module.exports = function (grunt) {
     'ngmin',
     'ngmin',
     'requirejs:compile_temp',
     'requirejs:compile_temp',
     'clean:temp',
     'clean:temp',
-    'write_revision_to_dest', // runs git-describe and replace:config
+    'build:write_revision',
     'uglify:dest'
     'uglify:dest'
   ]);
   ]);
 
 
-  grunt.registerTask('distribute', [
-    'load_s3_config',
-    'build',
-    'zip:dist',
-    's3:dist',
-    'clean:temp'
-  ]);
-
-  grunt.registerTask('load_s3_config', function () {
-    var config = grunt.file.readJSON('.aws-config.json');
-    grunt.config('s3.options', {
-      key: config.key,
-      secret: config.secret,
-      bucket: 'download.elasticsearch.org',
-      access: 'private'
-    });
-  });
-
-  grunt.registerTask('write_revision_to_dest', function() {
+  // run a string replacement on the require config, using the latest revision number as the cache buster
+  grunt.registerTask('build:write_revision', function() {
     grunt.event.once('git-describe', function (desc) {
     grunt.event.once('git-describe', function (desc) {
       grunt.config('string-replace.config', {
       grunt.config('string-replace.config', {
         src: '<%= destDir %>/app/components/require.config.js',
         src: '<%= destDir %>/app/components/require.config.js',
@@ -297,4 +268,40 @@ module.exports = function (grunt) {
     grunt.task.run('git-describe');
     grunt.task.run('git-describe');
   });
   });
 
 
+  // build, then zip and upload to s3
+  grunt.registerTask('distribute', [
+    'distribute:load_s3_config',
+    'build',
+    'zip:dist',
+    's3:dist',
+    'clean:temp'
+  ]);
+
+  // collect the key and secret from the .aws-config.json file, finish configuring the s3 task
+  grunt.registerTask('distribute:load_s3_config', function () {
+    var config = grunt.file.readJSON('.aws-config.json');
+    grunt.config('s3.options', {
+      key: config.key,
+      secret: config.secret
+    });
+  });
+
+  // load plugins
+  grunt.loadNpmTasks('grunt-s3');
+  grunt.loadNpmTasks('grunt-zip');
+  grunt.loadNpmTasks('grunt-ngmin');
+  grunt.loadNpmTasks('grunt-contrib-copy');
+  grunt.loadNpmTasks('grunt-contrib-less');
+  grunt.loadNpmTasks('grunt-git-describe');
+  grunt.loadNpmTasks('grunt-contrib-clean');
+  grunt.loadNpmTasks('grunt-contrib-jshint');
+  grunt.loadNpmTasks('grunt-contrib-cssmin');
+  grunt.loadNpmTasks('grunt-contrib-uglify');
+  grunt.loadNpmTasks('grunt-string-replace');
+  grunt.loadNpmTasks('grunt-contrib-htmlmin');
+  grunt.loadNpmTasks('grunt-contrib-requirejs');
+
+  // pass the config to grunt
+  grunt.initConfig(config);
+
 };
 };

+ 11 - 11
package.json

@@ -6,24 +6,24 @@
   "name": "kibana",
   "name": "kibana",
   "version": "3.0.0m3pre",
   "version": "3.0.0m3pre",
   "devDependencies": {
   "devDependencies": {
+    "rjs-build-analysis": "0.0.3",
+
     "grunt": "~0.4.0",
     "grunt": "~0.4.0",
+    "grunt-s3": "~0.2.0-alpha.2",
+    "grunt-zip": "~0.9.2",
+    "grunt-ngmin": "0.0.3",
     "grunt-contrib": "~0.7.0",
     "grunt-contrib": "~0.7.0",
-    "grunt-contrib-jshint": "~0.6.0",
     "grunt-contrib-less": "~0.7.0",
     "grunt-contrib-less": "~0.7.0",
-    "grunt-contrib-requirejs": "~0.4.1",
-    "grunt-ngmin": "0.0.3",
-    "cssmin": "~0.4.1",
-    "grunt-contrib-htmlmin": "~0.1.3",
     "grunt-contrib-copy": "~0.4.1",
     "grunt-contrib-copy": "~0.4.1",
-    "grunt-contrib-cssmin": "~0.6.1",
+    "grunt-git-describe": "~2.3.2",
     "grunt-contrib-clean": "~0.5.0",
     "grunt-contrib-clean": "~0.5.0",
+    "grunt-contrib-cssmin": "~0.6.1",
     "grunt-contrib-uglify": "~0.2.4",
     "grunt-contrib-uglify": "~0.2.4",
-    "rjs-build-analysis": "0.0.3",
-    "grunt-angular-templates": "~0.3.12",
+    "grunt-contrib-jshint": "~0.6.0",
     "grunt-string-replace": "~0.2.4",
     "grunt-string-replace": "~0.2.4",
-    "grunt-git-describe": "~2.3.2",
-    "grunt-zip": "~0.9.2",
-    "grunt-s3": "~0.2.0-alpha.2"
+    "grunt-contrib-htmlmin": "~0.1.3",
+    "grunt-contrib-requirejs": "~0.4.1",
+    "grunt-angular-templates": "~0.3.12"
   },
   },
   "license": "Apache License"
   "license": "Apache License"
 }
 }