This commit is contained in:
Revaz Zakalashvili 2016-11-23 07:58:12 +00:00 committed by GitHub
commit 05f0d79025
2 changed files with 102 additions and 59 deletions

View File

@ -186,47 +186,89 @@ gulp.task('chat-styles', ['chat-styles-handlebars', 'chat-styles-js'], function(
// Compile and concatenate handlebars files for all chat styles. // Compile and concatenate handlebars files for all chat styles.
gulp.task('chat-styles-handlebars', function() { gulp.task('chat-styles-handlebars', function() {
// TODO: Process all available styles, not only the default one. var promises = [];
var stylePath = config.chatStylesPath + '/default'; fs.readdir(config.chatStylesPath, function(err, list){
if(err) return done(err);
return gulp.src(stylePath + '/templates_src/client_side/**/*.handlebars') list.filter(function(path){
.pipe(handlebars({ return fs.lstatSync(config.chatStylesPath + "/" + path).isDirectory();
// Use specific version of Handlebars.js }).map(function(dir){
handlebars: handlebarsEngine var defer = Q.defer();
})) var pipeline = gulp.src(config.chatStylesPath + '/' + dir + '/templates_src/client_side/**/*.handlebars')
.pipe(wrapHandlebarsTemplate()) .pipe(handlebars({
.pipe(concat('templates.js')) // Use specific version of Handlebars.js
.pipe(uglify({preserveComments: 'some'})) handlebars: handlebarsEngine
.pipe(header(config.compiledTemplatesHeader)) }))
.pipe(gulp.dest(stylePath + '/templates_compiled/client_side')); .pipe(wrapHandlebarsTemplate())
.pipe(concat('templates.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(header(config.compiledTemplatesHeader))
.pipe(gulp.dest(config.chatStylesPath + '/' + dir + '/templates_compiled/client_side'));
pipeline.on('end',function(){
defer.resolve();
});
promises.push(defer.promise);
});
});
return Q.all(promises);
}); });
// Compile and concatenate js files for all chat styles. // Compile and concatenate js files for all chat styles.
gulp.task('chat-styles-js', function() { gulp.task('chat-styles-js', function() {
// TODO: Process all available styles, not only the default one. var promises = [];
var stylePath = config.chatStylesPath + '/default'; fs.readdir(config.chatStylesPath, function(err, list){
if(err) return done(err);
list.filter(function(path){
return fs.lstatSync(config.chatStylesPath + "/" + path).isDirectory();
}).map(function(dir){
var defer = Q.defer();
var pipeline = gulp.src(config.chatStylesPath + '/' + dir + '/js/source/**/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest(config.chatStylesPath + '/' + dir + '/js/compiled'));
pipeline.on('end', function(){
defer.resolve();
});
promises.push(defer.promise);
});
});
return gulp.src(stylePath + '/js/source/**/*.js') return Q.all(promises);
.pipe(concat('scripts.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest(stylePath + '/js/compiled'));
}); });
// Performs all job related with pages styles. // Performs all job related with pages styles.
gulp.task('page-styles', function() { gulp.task('page-styles', function() {
// TODO: Process all available styles, not only the default one. var promises = [];
var stylePath = config.pageStylesPath + '/default'; fs.readdir(config.pageStylesPath, function(err, list){
if(err) return done(err);
list.filter(function(path){
return fs.lstatSync(config.pageStylesPath + "/" + path).isDirectory();
}).map(function(dir){
var defer = Q.defer();
var pipeline = gulp.src(config.pageStylesPath + '/' + dir + '/templates_src/client_side/**/*.handlebars')
.pipe(handlebars({
// Use specific version of Handlebars.js
handlebars: handlebarsEngine
}))
.pipe(wrapHandlebarsTemplate())
.pipe(concat('templates.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(header(config.compiledTemplatesHeader))
.pipe(gulp.dest(config.pageStylesPath + '/' + dir + '/templates_compiled/client_side'));
pipeline.on('end', function(){
defer.resolve();
});
promises.push(defer.promise);
});
});
return gulp.src(stylePath + '/templates_src/client_side/**/*.handlebars') return Q.all(promises);
.pipe(handlebars({ });
// Use specific version of Handlebars.js
handlebars: handlebarsEngine // Watch styles
})) gulp.task('watch', [], function(){
.pipe(wrapHandlebarsTemplate()) gulp.watch(config.pageStylesPath + '/**/*.handlebars', ['page-styles']);
.pipe(concat('templates.js')) gulp.watch(config.chatStylesPath + '/**/js/source/**/*.js', ['chat-styles-js']);
.pipe(uglify({preserveComments: 'some'})) gulp.watch(config.chatStylesPath + '/**/*.handlebars', ['chat-styles-handlebars']);
.pipe(header(config.compiledTemplatesHeader))
.pipe(gulp.dest(stylePath + '/templates_compiled/client_side'));
}); });
// Generate .pot files based on the sources // Generate .pot files based on the sources

View File

@ -1,30 +1,31 @@
{ {
"devDependencies": { "devDependencies": {
"gulp": "~3.8.11", "bower": "~1.4.1",
"gulp-phpcs": "~0.6.0", "del": "~1.2.0",
"gulp-uglify": "~1.2.0", "eslint": "~2.11.0",
"gulp-concat": "~2.5.2", "event-stream": "~3.3.1",
"gulp-order": "~1.1.1", "gulp": "~3.8.11",
"gulp-handlebars": "~4.0.0", "gulp-chmod": "~1.2.0",
"gulp-define-module": "~0.1.3", "gulp-concat": "~2.5.2",
"gulp-header": "~1.2.2", "gulp-concat-po": "~0.1.1",
"gulp-zip": "~3.0.2", "gulp-define-module": "~0.1.3",
"gulp-tar": "~1.4.0", "gulp-eslint": "~2.0.0",
"gulp-gzip": "~1.1.0", "gulp-gzip": "~1.1.0",
"gulp-chmod": "~1.2.0", "gulp-handlebars": "~4.0.0",
"gulp-xgettext": "~0.3.0", "gulp-header": "~1.2.2",
"gulp-concat-po": "~0.1.1", "gulp-order": "~1.1.1",
"gulp-rename": "~1.2.2", "gulp-phpcs": "~0.6.0",
"bower": "~1.4.1", "gulp-rename": "~1.2.2",
"handlebars": "~3.0.3", "gulp-tar": "~1.4.0",
"run-sequence": "~1.1.0", "gulp-uglify": "~1.2.0",
"through2": "~0.6.5", "gulp-xgettext": "~0.3.0",
"pofile": "~0.2.12", "gulp-zip": "~3.0.2",
"lodash": "~3.9.3", "handlebars": "~3.0.3",
"strftime": "~0.9.2", "lodash": "~3.9.3",
"del": "~1.2.0", "pofile": "~0.2.12",
"event-stream": "~3.3.1", "q": "^1.4.1",
"eslint": "~2.11.0", "run-sequence": "~1.1.0",
"gulp-eslint": "~2.0.0" "strftime": "~0.9.2",
} "through2": "~0.6.5"
}
} }