Update build process.

This commit is contained in:
Lars Jung
2014-08-23 00:00:58 +02:00
parent 797aae9849
commit 715a8356eb
4 changed files with 81 additions and 63 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
build build
local local
node_modules node_modules

View File

@@ -17,18 +17,17 @@ install instructions on the [project page][web].
There are installation ready packages for the latest [releases][release] and There are installation ready packages for the latest [releases][release] and
[dev builds][develop]. But if you want to build **h5ai** yourself you need to [dev builds][develop]. But if you want to build **h5ai** yourself you need to
install the build tool [fQuery][fquery] first: install the global command line trigger for the build tool [`mkr`][mkr] first:
> npm install -g fquery@0.11.0 > npm install -g mkr-global
This will globally install fQuery and its command line tool `makejs`. Run To clone and build the project run the following commands, this will create a
`makejs --help` to see if everything worked fine. To clone and build the new folder `build` including a fresh zipball.
project run the following commands, this will create a new folder `build`
including a fresh zipball.
> git clone git://github.com/lrsjng/h5ai.git > git clone git://github.com/lrsjng/h5ai.git
> cd h5ai > cd h5ai
> makejs release > npm install
> mkr release
## License ## License
@@ -79,7 +78,7 @@ THE SOFTWARE.
[github-issues]: https://github.com/lrsjng/h5ai/issues [github-issues]: https://github.com/lrsjng/h5ai/issues
[release]: http://release.larsjung.de/h5ai/ [release]: http://release.larsjung.de/h5ai/
[develop]: http://release.larsjung.de/h5ai/develop/ [develop]: http://release.larsjung.de/h5ai/develop/
[fquery]: http://larsjung.de/fquery/ [mkr]: http://larsjung.de/mkr/ (target and task based build tool for Node.js)
[license-img]: http://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square [license-img]: http://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
[web-img]: http://img.shields.io/badge/web-larsjung.de/h5ai-a0a060.svg?style=flat-square [web-img]: http://img.shields.io/badge/web-larsjung.de/h5ai-a0a060.svg?style=flat-square

View File

@@ -2,22 +2,20 @@
'use strict'; 'use strict';
module.exports = function (make) { var path = require('path');
var $ = require('fquery');
var path = require('path'), var pkg = require('./package.json');
pkg = require('./package.json'), var root = path.resolve(__dirname);
var src = path.join(root, 'src');
var build = path.join(root, 'build');
root = path.resolve(__dirname), var mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', '');
src = path.join(root, 'src'), var mapRoot = $.map.p(root, path.join(build, '_h5ai'));
build = path.join(root, 'build'),
$ = make.fQuery,
mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', ''),
mapRoot = $.map.p(root, path.join(build, '_h5ai')),
// bad hack // bad hack
getBuildSuffix = function (callback) { var getBuildSuffix = function (callback) {
var child_process = require('child_process'); var child_process = require('child_process');
@@ -33,11 +31,23 @@ module.exports = function (make) {
}; };
make.version('=0.11.0'); $.plugin('fquery-cssmin');
make.defaults('release'); $.plugin('fquery-handlebars');
$.plugin('fquery-includeit');
$.plugin('fquery-jade');
$.plugin('fquery-jshint');
$.plugin('fquery-jszip');
$.plugin('fquery-less');
$.plugin('fquery-uglifyjs');
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) { module.exports = function (suite) {
suite.defaults('release');
suite.target('check-version', [], 'add git info to dev builds').task(function (done) {
if (!pkg.develop) { if (!pkg.develop) {
done(); done();
@@ -47,19 +57,19 @@ module.exports = function (make) {
getBuildSuffix(function (result) { getBuildSuffix(function (result) {
pkg.version += result; pkg.version += result;
$.info({ method: 'check-version', message: 'version set to ' + pkg.version }); $.Event.info({method: 'check-version', message: 'version set to ' + pkg.version});
done(); done();
}); });
}); });
make.target('clean', [], 'delete build folder').sync(function () { suite.target('clean', [], 'delete build folder').task(function () {
$.DELETE(build); $(build, {dirs: true}).delete();
}); });
make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () { suite.target('lint', [], 'lint all JavaScript files with JSHint').task(function () {
var jshint = { var jshint = {
// Enforcing Options // Enforcing Options
@@ -76,8 +86,8 @@ module.exports = function (make) {
// Environments // Environments
browser: true browser: true
}, };
globals = { var globals = {
'modulejs': true 'modulejs': true
}; };
@@ -86,92 +96,92 @@ module.exports = function (make) {
}); });
make.target('build', ['check-version'], 'build all updated files').sync(function () { suite.target('build', ['check-version'], 'build all updated files').task(function () {
var env = {pkg: pkg}; var env = {pkg: pkg};
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n'; var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
$(src + ': _h5ai/client/js/*.js') $(src + ': _h5ai/client/js/*.js')
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**')) .newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
.includify() .includeit()
.uglifyjs() .uglifyjs()
.wrap(header) .wrap(header)
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': _h5ai/client/css/*.less') $(src + ': _h5ai/client/css/*.less')
.newerThan(mapSrc, $(src + ': _h5ai/client/css/**')) .newerThan(mapSrc, $(src + ': _h5ai/client/css/**'))
.less() .less()
.cssmin() .cssmin()
.wrap(header) .wrap(header)
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': **/*.jade') $(src + ': **/*.jade')
.newerThan(mapSrc) .newerThan(mapSrc)
.handlebars(env) .handlebars(env)
.jade() .jade()
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade') $(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade')
.newerThan(mapSrc) .newerThan(mapSrc)
.handlebars(env) .handlebars(env)
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': _h5ai/client/css/fonts/**') $(src + ': _h5ai/client/css/fonts/**')
.newerThan(mapSrc) .newerThan(mapSrc)
.WRITE(mapSrc); .write(mapSrc, true);
$(root + ': *.md') $(root + ': *.md')
.newerThan(mapRoot) .newerThan(mapRoot)
.WRITE(mapRoot); .write(mapRoot, true);
}); });
make.target('build-uncompressed', ['check-version'], 'build all updated files without compression').sync(function () { suite.target('build-uncompressed', ['check-version'], 'build all updated files').task(function () {
var env = {pkg: pkg}; var env = {pkg: pkg};
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n'; var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
$(src + ': _h5ai/client/js/*.js') $(src + ': _h5ai/client/js/*.js')
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**')) .newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
.includify() .includeit()
// .uglifyjs() // .uglifyjs()
.wrap(header) .wrap(header)
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': _h5ai/client/css/*.less') $(src + ': _h5ai/client/css/*.less')
.newerThan(mapSrc, $(src + ': _h5ai/client/css/**')) .newerThan(mapSrc, $(src + ': _h5ai/client/css/**'))
.less() .less()
// .cssmin() // .cssmin()
.wrap(header) .wrap(header)
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': **/*.jade') $(src + ': **/*.jade')
.newerThan(mapSrc) .newerThan(mapSrc)
.handlebars(env) .handlebars(env)
.jade() .jade()
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade') $(src + ': **, ! _h5ai/client/js/**, ! _h5ai/client/css/**, ! **/*.jade')
.newerThan(mapSrc) .newerThan(mapSrc)
.handlebars(env) .handlebars(env)
.WRITE(mapSrc); .write(mapSrc, true);
$(src + ': _h5ai/client/css/fonts/**') $(src + ': _h5ai/client/css/fonts/**')
.newerThan(mapSrc) .newerThan(mapSrc)
.WRITE(mapSrc); .write(mapSrc, true);
$(root + ': *.md') $(root + ': *.md')
.newerThan(mapRoot) .newerThan(mapRoot)
.WRITE(mapRoot); .write(mapRoot, true);
}); });
make.target('release', ['clean', 'build'], 'create a zipball').async(function (done, fail) { suite.target('release', ['clean', 'build'], 'create a zipball').task(function () {
$(build + ': **').shzip({ var target = path.join(build, pkg.name + '-' + pkg.version + '.zip');
target: path.join(build, pkg.name + '-' + pkg.version + '.zip'),
dir: build, $(build + ': **')
callback: done .jszip({dir: build})
}); .write(target, true);
}); });
}; };

View File

@@ -14,8 +14,18 @@
"scripts": { "scripts": {
"test": "mocha --recursive test" "test": "mocha --recursive test"
}, },
"devDependencies": { "dependencies": {
"fquery": "~0.12.17",
"fquery-cssmin": "~0.1.4",
"fquery-handlebars": "~0.1.0",
"fquery-includeit": "~0.1.1",
"fquery-jade": "~0.2.1",
"fquery-jshint": "~0.1.0",
"fquery-jszip": "~0.1.0",
"fquery-less": "~0.1.5",
"fquery-uglifyjs": "~0.1.3",
"lodash": "~2.4.1", "lodash": "~2.4.1",
"mkr": "~0.3.0",
"mocha": "~1.21.3", "mocha": "~1.21.3",
"zombie": "~2.0.0-alpha31" "zombie": "~2.0.0-alpha31"
} }