Skip to content

Commit

Permalink
Normalize tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
ngilain committed Jan 15, 2016
1 parent e95780a commit 84629c9
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 139 deletions.
76 changes: 38 additions & 38 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadTasks('./grunt_tasks');
grunt.loadTasks('./vendor/open-orchestra/open-orchestra-cms-bundle/GruntTasks');
grunt.loadTasks('./vendor/open-orchestra/open-orchestra-media-admin-bundle/GruntTasks');

var merge = require('merge');
var config = {
pkg: grunt.file.readJSON('package.json'),
env: process.env
};
config = merge.recursive(true, config, loadDirConfig('./grunt_tasks/options/'));
config = merge.recursive(true, config, loadDirConfig('./vendor/open-orchestra/open-orchestra-cms-bundle/GruntTasks/Options/'));
config = merge.recursive(true, config, loadDirConfig('./vendor/open-orchestra/open-orchestra-media-admin-bundle/GruntTasks/Options/'));

grunt.initConfig(config);
require('load-grunt-tasks')(grunt);
grunt.loadTasks('./grunt_tasks');
grunt.loadTasks('./vendor/open-orchestra/open-orchestra-cms-bundle/GruntTasks');
grunt.loadTasks('./vendor/open-orchestra/open-orchestra-media-admin-bundle/GruntTasks');

var merge = require('merge');
var config = {
pkg: grunt.file.readJSON('package.json'),
env: process.env
};
config = merge.recursive(true, config, loadDirConfig('./grunt_tasks/subtasks/'));
config = merge.recursive(true, config, loadDirConfig('./vendor/open-orchestra/open-orchestra-cms-bundle/GruntTasks/Subtasks/'));
config = merge.recursive(true, config, loadDirConfig('./vendor/open-orchestra/open-orchestra-media-admin-bundle/GruntTasks/Subtasks/'));

grunt.initConfig(config);
};

function loadDirConfig(path) {
var glob = require('glob');
var merge = require('merge');
var dirConfig = {};
var glob = require('glob');
var merge = require('merge');
var dirConfig = {};

glob.sync('*', {cwd: path}).forEach(function(filename) {
var fileConfig = loadFileConfig(path, filename);
dirConfig = merge.recursive(true, dirConfig, fileConfig);
});
glob.sync('*', {cwd: path}).forEach(function(filename) {
var fileConfig = loadFileConfig(path, filename);
dirConfig = merge.recursive(true, dirConfig, fileConfig);
});

return dirConfig;
return dirConfig;
}

function loadFileConfig(path, filename) {
var keys = filename.replace(/\.js$/,'').split('.');

var buildFileConfig = function(keys, filepath) {
if (keys.length == 0) {
return require(filepath);
} else {
var subArray = {};
var index = keys[0];
keys.shift();
subArray[index] = buildFileConfig(keys, filepath);
return subArray;
}
};

return buildFileConfig(keys, path + filename);
var keys = filename.replace(/\.js$/, '').split('.');

var buildFileConfig = function(keys, filepath) {
if (keys.length == 0) {
return require(filepath);
} else {
var subArray = {};
var index = keys[0];
keys.shift();
subArray[index] = buildFileConfig(keys, filepath);
return subArray;
}
};

return buildFileConfig(keys, path + filename);
}
27 changes: 14 additions & 13 deletions grunt_tasks/css_task.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module.exports = function(grunt) {
grunt.registerTask('css',
[
'less:discovering',
'less',
'concat:libcss',
'concat:smartadminpatchescss',
'concat:orchestracss',
'concat:mediacss',
'concat:presmartadmincss',
'concat:postsmartadmincss',
'cssmin'
]
);
grunt.registerTask(
'css',
[
'less:discovering',
'less',
'concat:lib_css',
'concat:smartadmin_patches_css',
'concat:orchestra_css',
'concat:mediacss',
'concat:pre_smartadmin_css',
'concat:post_smartadmin_css',
'cssmin'
]
);
};
24 changes: 13 additions & 11 deletions grunt_tasks/default_task.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module.exports = function(grunt) {
grunt.registerTask('default',
[
'clean',
'commands:assets_install',
'symlink',
'css',
'javascript',
'javascriptProd',
'commands:assetic_dump'
]
);
grunt.registerTask(
'default',
[
'clean:built',
'clean:symlinks',
'commands:assets_install',
'symlink',
'css',
'javascript',
'javascriptProd',
'commands:assetic_dump'
]
);
};
9 changes: 4 additions & 5 deletions grunt_tasks/javascriptProd_task.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = function(grunt) {
grunt.registerTask('javascriptProd',
[
'uglify'
]
);
grunt.registerTask(
'javascriptProd',
['uglify:all_js']
);
};
23 changes: 12 additions & 11 deletions grunt_tasks/javascript_task.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module.exports = function(grunt) {
grunt.registerTask('javascript',
[
'coffee:discovering',
'coffee',
'concat:smartadminjs',
'concat:libjs',
'concat:orchestrajs',
'concat:mediajs',
'concat:js'
]
);
grunt.registerTask(
'javascript',
[
'coffee:discovering',
'coffee',
'concat:smartadmin_js',
'concat:lib_js',
'concat:orchestra_js',
'concat:mediajs',
'concat:all_js'
]
);
};
3 changes: 0 additions & 3 deletions grunt_tasks/options/clean.js

This file was deleted.

8 changes: 0 additions & 8 deletions grunt_tasks/options/commands.js

This file was deleted.

9 changes: 0 additions & 9 deletions grunt_tasks/options/concat.js.js

This file was deleted.

8 changes: 0 additions & 8 deletions grunt_tasks/options/concat.postsmartadmincss.js

This file was deleted.

6 changes: 0 additions & 6 deletions grunt_tasks/options/concat.presmartadmincss.js

This file was deleted.

10 changes: 0 additions & 10 deletions grunt_tasks/options/cssmin.js

This file was deleted.

7 changes: 0 additions & 7 deletions grunt_tasks/options/uglify.js

This file was deleted.

10 changes: 0 additions & 10 deletions grunt_tasks/options/watch.js

This file was deleted.

5 changes: 5 additions & 0 deletions grunt_tasks/subtasks/clean.built.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = [
'web/built',
'web/js',
'web/css'
];
6 changes: 6 additions & 0 deletions grunt_tasks/subtasks/clean.symlinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = [
'web/img',
'web/images',
'web/sound',
'web/fonts'
];
3 changes: 3 additions & 0 deletions grunt_tasks/subtasks/commands.assetic_dump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
cmd: 'php app/console assetic:dump'
};
3 changes: 3 additions & 0 deletions grunt_tasks/subtasks/commands.assets_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
cmd: 'php app/console assets:install --symlink'
};
9 changes: 9 additions & 0 deletions grunt_tasks/subtasks/concat.all_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
src: [
'web/built/smartadmin.js',
'web/built/lib.js',
'web/built/orchestra.js',
'web/built/media.js'
],
dest: 'web/js/all.js'
};
8 changes: 8 additions & 0 deletions grunt_tasks/subtasks/concat.post_smartadmin_css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
src: [
'web/built/smartadminpatches.css',
'web/built/orchestra.css',
'web/built/media.css'
],
dest: 'web/css/postsmartadmin.css'
};
4 changes: 4 additions & 0 deletions grunt_tasks/subtasks/concat.pre_smartadmin_css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
src: ['web/built/lib.css'],
dest: 'web/css/presmartadmin.css'
};
8 changes: 8 additions & 0 deletions grunt_tasks/subtasks/cssmin.minify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
expand: true,
src: [
'web/css/presmartadmin.css',
'web/css/postsmartadmin.css'
],
ext: '.min.css'
};
5 changes: 5 additions & 0 deletions grunt_tasks/subtasks/uglify.all_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
files: {
'web/js/all.min.js': ['web/js/all.js']
}
};

0 comments on commit 84629c9

Please sign in to comment.