Преглед изворни кода

dev building and optimized builds work

Torkel Ödegaard пре 10 година
родитељ
комит
da832368f0

+ 1 - 1
package.json

@@ -24,7 +24,7 @@
     "grunt-contrib-htmlmin": "~0.1.3",
     "grunt-contrib-jshint": "~0.10.0",
     "grunt-contrib-less": "~0.7.0",
-    "grunt-contrib-requirejs": "~0.4.1",
+    "grunt-contrib-requirejs": "~0.4.4",
     "grunt-contrib-uglify": "~0.8.0",
     "grunt-contrib-watch": "^0.6.1",
     "grunt-filerev": "^0.2.1",

+ 0 - 1
public/app/controllers/errorCtrl.js

@@ -8,7 +8,6 @@ function (angular) {
 
   var module = angular.module('grafana.controllers');
 
-
   module.controller('ErrorCtrl', function($scope, contextSrv) {
 
     var showSideMenu = contextSrv.sidemenu;

+ 4 - 4
public/test/karma.conf.js

@@ -9,10 +9,10 @@ module.exports = function(config) {
     // list of files / patterns to load in the browser
     files: [
       'public/test/test-main.js',
-      {pattern: 'public/.app_gen/**/*.js', included: false},
-      {pattern: 'public/vendor/**/*.js', included: false},
-      {pattern: 'public/test/**/*.js', included: false},
-      {pattern: 'public/**/*.js', included: false}
+      {pattern: 'public_gen/.app_gen/**/*.js', included: false},
+      {pattern: 'public_gen/vendor/**/*.js', included: false},
+      {pattern: 'public_gen/test/**/*.js', included: false},
+      {pattern: 'public_gen/**/*.js', included: false}
     ],
 
     // list of files to exclude

+ 1 - 1
public/test/test-main.js

@@ -1,5 +1,5 @@
 require.config({
-  baseUrl: 'http://localhost:9876/base/public/app_gen',
+  baseUrl: 'http://localhost:9876/base/public_gen/app',
 
   paths: {
     specs:                 '../test/specs',

+ 11 - 14
tasks/build_task.js

@@ -6,18 +6,18 @@ module.exports = function(grunt) {
     'jshint:source',
     'jshint:tests',
     'jscs',
-    'clean:on_start',
-    'copy:app_gen_build',
+    'clean:release',
+    'copy:public_to_gen',
     'typescript:build',
     'karma:test',
     'css',
-    'copy:everything_but_less_to_temp',
     'htmlmin:build',
     'ngtemplates',
     'cssmin:build',
     'ngAnnotate:build',
     'requirejs:build',
     'concat:js',
+    'clean:temp',
     'filerev',
     'remapFilerev',
     'usemin',
@@ -26,14 +26,13 @@ module.exports = function(grunt) {
   ]);
 
   // task to add [[.AppSubUrl]] to reved path
-  grunt.registerTask('remapFilerev', function(){
-    var root = grunt.config().destDir;
+  grunt.registerTask('remapFilerev', function() {
+    var root = grunt.config().genDir;
     var summary = grunt.filerev.summary;
     var fixed = {};
 
     for(var key in summary){
       if(summary.hasOwnProperty(key)){
-
         var orig = key.replace(root, root+'/[[.AppSubUrl]]');
         var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]');
         fixed[orig] = revved;
@@ -44,29 +43,27 @@ module.exports = function(grunt) {
   });
 
   grunt.registerTask('build-post-process', function() {
-    grunt.config('copy.dist_to_tmp', {
+    grunt.config('copy.public_gen_to_dest', {
       expand: true,
-      cwd: '<%= destDir %>',
+      cwd: '<%= genDir %>',
       src: '**/*',
-      dest: '<%= tempDir %>/public/',
+      dest: '<%= destDir %>/public/',
     });
-    grunt.config('clean.dest_dir', ['<%= destDir %>']);
     grunt.config('copy.backend_bin', {
       cwd: 'bin',
       expand: true,
       src: ['*'],
       options: { mode: true},
-      dest: '<%= tempDir %>/bin/'
+      dest: '<%= destDir %>/bin/'
     });
     grunt.config('copy.backend_files', {
       expand: true,
       src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/**/*', 'scripts/*'],
       options: { mode: true},
-      dest: '<%= tempDir %>'
+      dest: '<%= destDir %>'
     });
 
-    grunt.task.run('copy:dist_to_tmp');
-    grunt.task.run('clean:dest_dir');
+    grunt.task.run('copy:public_gen_to_dest');
     grunt.task.run('copy:backend_bin');
     grunt.task.run('copy:backend_files');
   });

+ 1 - 1
tasks/default_task.js

@@ -7,7 +7,7 @@ module.exports = function(grunt) {
     'jscs',
     'jshint',
     'clean:gen',
-    'copy:everything_but_ts_and_less',
+    'copy:public_to_gen',
     'css',
     'typescript:build'
   ]);

+ 1 - 1
tasks/options/compress.js

@@ -9,7 +9,7 @@ module.exports = function(config) {
       files : [
         {
           expand: true,
-          cwd: '<%= tempDir %>',
+          cwd: '<%= destDir %>',
           src: ['**/*'],
           dest: '<%= pkg.name %>-<%= pkg.version %>/',
         },

+ 4 - 4
tasks/options/concat.js

@@ -27,11 +27,11 @@ module.exports = function(config) {
 
     js: {
       src: [
-        '<%= destDir %>/vendor/requirejs/require.js',
-        '<%= destDir %>/app/components/require.config.js',
-        '<%= destDir %>/app/app.js',
+        '<%= tempDir %>/vendor/requirejs/require.js',
+        '<%= tempDir %>/app/components/require.config.js',
+        '<%= tempDir %>/app/app.js',
       ],
-      dest: '<%= destDir %>/app/app.js'
+      dest: '<%= genDir %>/app/app.js'
     },
   };
 };

+ 1 - 1
tasks/options/copy.js

@@ -8,7 +8,7 @@ module.exports = function(config) {
       dest: '<%= tempDir %>'
     },
 
-    everything_but_less: {
+    public_to_gen: {
       cwd: '<%= srcDir %>',
       expand: true,
       src: ['**/*', '!**/*.less'],

+ 3 - 3
tasks/options/cssmin.js

@@ -2,9 +2,9 @@ module.exports = function(config) {
   return {
     build: {
       expand: true,
-      cwd: '<%= tempDir %>',
+      cwd: '<%= genDir %>',
       src: '**/*.css',
-      dest: '<%= tempDir %>'
+      dest: '<%= genDir %>'
     }
   };
-};
+};

+ 6 - 6
tasks/options/filerev.js

@@ -6,16 +6,16 @@ module.exports = function(config) {
       length: 8,
     },
     cssDark: {
-      src: '<%= destDir %>/css/grafana.dark.min.css',
-      dest: '<%= destDir %>/css'
+      src: '<%= genDir %>/css/grafana.dark.min.css',
+      dest: '<%= genDir %>/css'
     },
     cssLight: {
-      src: '<%= destDir %>/css/grafana.light.min.css',
-      dest: '<%= destDir %>/css'
+      src: '<%= genDir %>/css/grafana.light.min.css',
+      dest: '<%= genDir %>/css'
     },
     js: {
-      src: '<%= destDir %>/app/app.js',
-      dest: '<%= destDir %>/app'
+      src: '<%= genDir %>/app/app.js',
+      dest: '<%= genDir %>/app'
     }
   };
 };

+ 3 - 3
tasks/options/htmlmin.js

@@ -6,13 +6,13 @@ module.exports = function(config) {
         collapseWhitespace: true
       },
       expand: true,
-      cwd: '<%= tempDir %>',
+      cwd: '<%= genDir %>',
       src: [
         //'index.html',
         'app/panels/**/*.html',
         'app/partials/**/*.html'
       ],
-      dest: '<%= tempDir %>'
+      dest: '<%= genDir %>'
     }
   };
-};
+};

+ 2 - 2
tasks/options/ngAnnotate.js

@@ -2,7 +2,7 @@ module.exports = function(config) {
   return {
     build: {
       expand: true,
-      cwd:'<%= tempDir %>',
+      cwd:'<%= genDir %>',
       src: [
         'app/controllers/**/*.js',
         'app/plugins/**/*.js',
@@ -15,7 +15,7 @@ module.exports = function(config) {
         'app/app.js',
         'vendor/angular/**/*.js',
       ],
-      dest: '<%= tempDir %>'
+      dest: '<%= genDir %>'
     }
   };
 };

+ 2 - 2
tasks/options/ngtemplates.js

@@ -1,9 +1,9 @@
 module.exports = function(config) {
   return {
     grafana: {
-      cwd:  '<%= tempDir %>',
+      cwd:  '<%= genDir %>',
       src:  ['app/**/*.html'],
-      dest: '<%= tempDir %>/app/components/partials.js',
+      dest: '<%= genDir %>/app/components/partials.js',
       options: {
         bootstrap: function(module, script) {
           return "define('components/partials', ['angular'], function(angular) { \n" +

+ 5 - 5
tasks/options/requirejs.js

@@ -4,10 +4,10 @@ module.exports = function(config,grunt) {
   function buildRequireJsOptions() {
 
     var options = {
-      appDir: '<%= tempDir %>',
-      dir:  '<%= destDir %>',
-      mainConfigFile: '<%= tempDir %>/app/components/require.config.js',
-      baseUrl: 'app_gen',
+      appDir: '<%= genDir %>',
+      dir:  '<%= tempDir %>',
+      mainConfigFile: '<%= genDir %>/app/components/require.config.js',
+      baseUrl: 'app',
       waitSeconds: 0,
 
       modules: [], // populated below,
@@ -74,7 +74,7 @@ module.exports = function(config,grunt) {
     ];
 
     var fs = require('fs');
-    var panelPath = config.srcDir+'/app/panels';
+    var panelPath = config.genDir+'/app/panels';
 
     // create a module for each directory in public/app/panels/
     fs.readdirSync(panelPath).forEach(function (panelName) {

+ 3 - 3
tasks/options/uglify.js

@@ -2,9 +2,9 @@ module.exports = function(config) {
   return {
     dest: {
       expand: true,
-      src: ['**/*.js', '!dashboards/*.js', '!vendor/jquery/**/*.js'],
-      dest: '<%= destDir %>',
-      cwd: '<%= destDir %>',
+      src: ['**/*.js', '!dashboards/*.js', '!vendor/**/*.js'],
+      dest: '<%= genDir %>',
+      cwd: '<%= genDir %>',
       options: {
         quite: true,
         compress: {},

+ 3 - 2
tasks/options/usemin.js

@@ -3,10 +3,11 @@ module.exports = function() {
 
   return {
     html: [
-      '<%= destDir %>/views/index.html',
+      '<%= genDir %>/views/index.html',
+      '<%= genDir %>/views/500.html',
     ],
     options: {
-      assetsDirs: ['<%= destDir %>'],
+      assetsDirs: ['<%= genDir %>'],
       patterns: {
         css: [
           [/(\.css)/, 'Replacing reference to image.png']

+ 0 - 7
tasks/options/useminPrepare.js

@@ -1,7 +0,0 @@
-module.exports = function(config) {
-  return {
-    html: [
-      'tmp/index.html',
-    ]
-  };
-};

+ 1 - 1
tasks/options/watch.js

@@ -10,7 +10,7 @@ module.exports = function(config) {
 
     copy_to_gen: {
       files: ['<%= srcDir %>/**/*', '!<%= srcDir %>/**/*.less'],
-      tasks: ['copy:everything_but_less'],
+      tasks: ['copy:public_to_gen'],
       options: {
         spawn: false
       }