h5ai/makefile.js

159 lines
3.3 KiB
JavaScript
Raw Normal View History

/*jshint node: true */
'use strict';
2013-08-12 18:36:39 -04:00
module.exports = function (make) {
2013-08-12 18:36:39 -04:00
var path = require('path'),
2013-08-12 18:36:39 -04:00
pkg = require('./package.json'),
2013-08-12 18:36:39 -04:00
root = path.resolve(__dirname),
src = path.join(root, 'src'),
build = path.join(root, 'build'),
$ = make.fQuery,
2013-08-12 18:36:39 -04:00
mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', ''),
mapRoot = $.map.p(root, build);
2013-08-12 18:36:39 -04:00
make.version('>=0.10.0');
make.defaults('build');
make.before(function () {
2013-08-12 18:36:39 -04:00
var moment = make.moment();
make.env = {
pkg: pkg,
stamp: moment.format('YYYY-MM-DD HH:mm:ss')
};
$.info({ method: 'before', message: pkg.version + ' ' + make.env.stamp });
});
2012-09-13 18:25:20 -04:00
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
2013-08-12 18:36:39 -04:00
if (!/\+$/.test(pkg.version)) {
2012-09-13 18:25:20 -04:00
done();
return;
}
2012-09-13 18:25:20 -04:00
$.git(root, function (err, result) {
2013-08-12 18:36:39 -04:00
pkg.version += result.buildSuffix;
$.info({ method: 'check-version', message: 'version set to ' + pkg.version });
2012-09-13 18:25:20 -04:00
done();
});
2012-09-13 18:25:20 -04:00
});
2012-09-13 18:25:20 -04:00
make.target('clean', [], 'delete build folder').sync(function () {
2013-08-12 18:36:39 -04:00
$.DELETE(build);
2012-09-13 18:25:20 -04:00
});
2012-09-13 18:25:20 -04:00
make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
2013-08-12 18:36:39 -04:00
var jshint = {
// Enforcing Options
bitwise: true,
curly: true,
eqeqeq: true,
forin: true,
latedef: true,
newcap: true,
noempty: true,
plusplus: true,
trailing: true,
undef: true,
// Environments
browser: true
},
globals = {
'modulejs': true
};
2012-10-05 13:55:48 -04:00
$(src + '/_h5ai/client/js: **/*.js, ! lib/**')
2013-08-12 18:36:39 -04:00
.jshint(jshint, globals);
2012-09-13 18:25:20 -04:00
});
2012-09-13 18:25:20 -04:00
make.target('build', ['check-version'], 'build all updated files').sync(function () {
2013-08-16 13:09:37 -04:00
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.url + ' */';
2013-08-16 10:22:23 -04:00
2012-10-05 13:55:48 -04:00
$(src + ': _h5ai/client/js/*.js')
.modified(mapSrc, $(src + ': _h5ai/client/js/**'))
2012-09-13 18:25:20 -04:00
.includify()
2013-08-16 10:22:23 -04:00
.uglifyjs({header: header})
2013-08-12 18:36:39 -04:00
.WRITE(mapSrc);
2012-10-05 13:55:48 -04:00
$(src + ': _h5ai/client/css/*.less')
.modified(mapSrc, $(src + ': _h5ai/client/css/**'))
2012-09-13 18:25:20 -04:00
.less()
2013-08-16 10:22:23 -04:00
.cssmin({header: header})
2013-08-12 18:36:39 -04:00
.WRITE(mapSrc);
2012-09-13 18:25:20 -04:00
$(src + ': **/*.jade')
.modified(mapSrc)
2013-08-12 18:36:39 -04:00
.handlebars(make.env)
2012-09-13 18:25:20 -04:00
.jade()
2013-08-12 18:36:39 -04:00
.WRITE(mapSrc);
2012-10-05 14:00:45 -04:00
$(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade')
2012-09-13 18:25:20 -04:00
.modified(mapSrc)
2013-08-12 18:36:39 -04:00
.handlebars(make.env)
.WRITE(mapSrc);
2012-09-13 18:25:20 -04:00
$(root + ': README*, LICENSE*')
.modified(mapRoot)
2013-08-12 18:36:39 -04:00
.WRITE(mapRoot);
2012-09-13 18:25:20 -04:00
});
2012-09-13 18:25:20 -04:00
make.target('build-uncompressed', ['check-version'], 'build all updated files without compression').sync(function () {
2012-10-05 13:55:48 -04:00
$(src + ': _h5ai/client/js/*.js')
.modified(mapSrc, $(src + ': _h5ai/client/js/**'))
2012-09-13 18:25:20 -04:00
.includify()
// .uglifyjs()
2013-08-12 18:36:39 -04:00
.WRITE(mapSrc);
2012-10-05 13:55:48 -04:00
$(src + ': _h5ai/client/css/*.less')
.modified(mapSrc, $(src + ': _h5ai/client/css/**'))
2012-09-13 18:25:20 -04:00
.less()
// .cssmin()
2013-08-12 18:36:39 -04:00
.WRITE(mapSrc);
2012-09-13 18:25:20 -04:00
$(src + ': **/*.jade')
.modified(mapSrc)
2013-08-12 18:36:39 -04:00
.handlebars(make.env)
2012-09-13 18:25:20 -04:00
.jade()
2013-08-12 18:36:39 -04:00
.WRITE(mapSrc);
2012-10-05 13:55:48 -04:00
$(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade')
2012-09-13 18:25:20 -04:00
.modified(mapSrc)
2013-08-12 18:36:39 -04:00
.handlebars(make.env)
.WRITE(mapSrc);
2012-09-13 18:25:20 -04:00
$(root + ': README*, LICENSE*')
.modified(mapRoot)
2013-08-12 18:36:39 -04:00
.WRITE(mapRoot);
2012-09-13 18:25:20 -04:00
});
2012-09-13 18:25:20 -04:00
make.target('release', ['clean', 'build'], 'create a zipball').async(function (done, fail) {
2012-10-05 13:55:48 -04:00
$(build + ': **').shzip({
2012-10-05 14:29:37 -04:00
target: path.join(build, pkg.name + '-' + pkg.version + '.zip'),
2012-09-13 18:25:20 -04:00
dir: build,
callback: done
});
2012-09-13 18:25:20 -04:00
});
};