zettapi_client
Version:
Admin panel and client-side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project.
133 lines (112 loc) • 3.07 kB
JavaScript
var gulp = require('gulp');
var gulpSequence = require('gulp-sequence');
var pump = require('pump');
var through = require('through');
var sloc = require('gulp-sloc');
var htmlmin = require('gulp-htmlmin');
var templateCache = require('gulp-angular-templatecache');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var sourcemaps = require('gulp-sourcemaps');
var clean = require('gulp-clean');
var gettext = require('gulp-angular-gettext');
var jshint = require('gulp-jshint');
var htmlhint = require('gulp-htmlhint');
var client = ['lib/index.js', 'lib/templates.js', 'lib/translations.js', 'lib/**/*.js', '!**/.svn/*.*', '!**/.svn/**/*.*'];
var all = ['!**/.svn/*.*', '!**/.svn/**/*.*'];
gulp.task('default', ['build']);
gulp.task('hint', function (callback) {
gulpSequence('jshint', 'htmlhint', 'sloc', callback);
});
gulp.task('build', function (callback) {
gulpSequence(['cache', 'translations'], ['concat', 'concat.min'], callback);
});
gulp.task('cache', function (callback) {
pump([
gulp.src(all.concat('lib/**/*.html')),
htmlmin({ collapseWhitespace: true }),
templateCache('templates.js', { module: 'zapi' }),
gulp.dest('lib')
], callback);
});
gulp.task('concat', function (callback) {
pump([
gulp.src(client),
concat('zettapi.js'),
ngAnnotate(),
sourcemaps.init(),
sourcemaps.write(),
gulp.dest('dist')
], callback);
});
gulp.task('concat.min', function (callback) {
pump([
gulp.src(client),
concat('zettapi.min.js'),
ngAnnotate(),
//uglify(),
gulp.dest('dist')
], callback);
});
gulp.task('pot', ['pot:clean'], function (callback) {
pump([
gulp.src(['lib/**/*.html', 'lib/**/*.js']),
gettext.extract('template.pot', {
extensions: {
html: 'html',
js: 'html'
}
}),
gulp.dest('lang')
], callback);
});
gulp.task('pot:clean', function (callback) {
pump([
gulp.src('lib/translations.js', {read: false}),
clean()
], callback);
});
gulp.task('translations', function (callback) {
pump([
gulp.src('lang/*.po'),
gettext.compile({
module: "zapi"
}),
concat('translations.js'),
gulp.dest('lib')
], callback);
});
gulp.task('sloc', function (callback) {
pump([
gulp.src(client),
sloc()
], callback);
});
gulp.task('jshint', function (callback) {
pump([
gulp.src(all.concat(['lib/*.js', 'lib/**/*.js'])),
jshint(),
jshint.reporter('jshint-stylish'),
count('js files found')
], callback);
});
gulp.task('htmlhint', function (callback) {
pump([
gulp.src(all.concat(['lib/*.html', 'lib/**/*.html'])),
htmlhint("./gulp/htmlhintrc"),
htmlhint.reporter("htmlhint-stylish"),
count('html files found')
], callback);
});
function count(message) {
var count = 0;
function countFiles(file) {
count++;
}
function endStream() {
console.log(count + ' ' + message || 'files processed.');
this.emit('end');
}
return through(countFiles, endStream);
}