Updates build process.

This commit is contained in:
Lars Jung 2013-08-13 00:36:39 +02:00
parent 3733d0c6d0
commit a296311b88
2 changed files with 59 additions and 72 deletions

View file

@ -2,6 +2,8 @@
'use strict'; 'use strict';
module.exports = function (make) {
var path = require('path'), var path = require('path'),
pkg = require('./package.json'), pkg = require('./package.json'),
@ -10,7 +12,53 @@ var path = require('path'),
src = path.join(root, 'src'), src = path.join(root, 'src'),
build = path.join(root, 'build'), build = path.join(root, 'build'),
jshint = { $ = make.fQuery,
mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', ''),
mapRoot = $.map.p(root, build);
make.version('>=0.10.0');
make.defaults('build');
make.before(function () {
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 });
});
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
if (!/\+$/.test(pkg.version)) {
done();
return;
}
$.git(root, function (err, result) {
pkg.version += result.buildSuffix;
$.info({ method: 'check-version', message: 'version set to ' + pkg.version });
done();
});
});
make.target('clean', [], 'delete build folder').sync(function () {
$.DELETE(build);
});
make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
var jshint = {
// Enforcing Options // Enforcing Options
bitwise: true, bitwise: true,
curly: true, curly: true,
@ -24,75 +72,14 @@ var path = require('path'),
undef: true, undef: true,
// Environments // Environments
browser: true, browser: true
// Globals
predef: [
'modulejs'
]
}, },
globals = {
handlebarsEnv = { 'modulejs': true
pkg: pkg
},
mapSrc = function (blob) {
return blob.source.replace(src, build).replace(/\.less$/, '.css').replace(/\.jade$/, '');
},
mapRoot = function (blob) {
return blob.source.replace(root, path.join(build, '_h5ai'));
}; };
module.exports = function (make) {
var Event = make.Event,
$ = make.fQuery,
moment = make.moment;
make.version('>=0.8.1');
make.defaults('build');
make.before(function () {
handlebarsEnv.stamp = moment().format('YYYY-MM-DD HH:mm:ss');
});
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
if (!/-dev$/.test(pkg.version)) {
done();
return;
}
$.git(root, function (err, result) {
pkg.version += '-' + result.revListOriginMasterHead.length + '-' + result.revParseHead.slice(0, 7);
Event.info({
method: 'check-version',
message: 'version set to ' + pkg.version
});
done();
});
});
make.target('clean', [], 'delete build folder').sync(function () {
$.rmfr($.I_AM_SURE, build);
});
make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
$(src + '/_h5ai/client/js: **/*.js, ! lib/**') $(src + '/_h5ai/client/js: **/*.js, ! lib/**')
.jshint(jshint); .jshint(jshint, globals);
}); });
@ -102,28 +89,28 @@ module.exports = function (make) {
.modified(mapSrc, $(src + ': _h5ai/client/js/**')) .modified(mapSrc, $(src + ': _h5ai/client/js/**'))
.includify() .includify()
.uglifyjs() .uglifyjs()
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(src + ': _h5ai/client/css/*.less') $(src + ': _h5ai/client/css/*.less')
.modified(mapSrc, $(src + ': _h5ai/client/css/**')) .modified(mapSrc, $(src + ': _h5ai/client/css/**'))
.less() .less()
.cssmin() .cssmin()
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(src + ': **/*.jade') $(src + ': **/*.jade')
.modified(mapSrc) .modified(mapSrc)
.handlebars(handlebarsEnv) .handlebars(make.env)
.jade() .jade()
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade') $(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade')
.modified(mapSrc) .modified(mapSrc)
.handlebars(handlebarsEnv) .handlebars(make.env)
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(root + ': README*, LICENSE*') $(root + ': README*, LICENSE*')
.modified(mapRoot) .modified(mapRoot)
.write($.OVERWRITE, mapRoot); .WRITE(mapRoot);
}); });
@ -133,28 +120,28 @@ module.exports = function (make) {
.modified(mapSrc, $(src + ': _h5ai/client/js/**')) .modified(mapSrc, $(src + ': _h5ai/client/js/**'))
.includify() .includify()
// .uglifyjs() // .uglifyjs()
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(src + ': _h5ai/client/css/*.less') $(src + ': _h5ai/client/css/*.less')
.modified(mapSrc, $(src + ': _h5ai/client/css/**')) .modified(mapSrc, $(src + ': _h5ai/client/css/**'))
.less() .less()
// .cssmin() // .cssmin()
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(src + ': **/*.jade') $(src + ': **/*.jade')
.modified(mapSrc) .modified(mapSrc)
.handlebars(handlebarsEnv) .handlebars(make.env)
.jade() .jade()
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade') $(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade')
.modified(mapSrc) .modified(mapSrc)
.handlebars(handlebarsEnv) .handlebars(make.env)
.write($.OVERWRITE, mapSrc); .WRITE(mapSrc);
$(root + ': README*, LICENSE*') $(root + ': README*, LICENSE*')
.modified(mapRoot) .modified(mapRoot)
.write($.OVERWRITE, mapRoot); .WRITE(mapRoot);
}); });

View file

@ -1,6 +1,6 @@
{ {
"name": "h5ai", "name": "h5ai",
"version": "0.23.0-dev", "version": "0.23.0+",
"description": "a modern HTTP web server index", "description": "a modern HTTP web server index",
"url": "http://larsjung.de/h5ai/", "url": "http://larsjung.de/h5ai/",
"author": "Lars Jung", "author": "Lars Jung",