Updates build process.

This commit is contained in:
Lars Jung 2012-09-14 00:25:20 +02:00
parent 6d188f1271
commit 07fcb40aab
8 changed files with 134 additions and 136 deletions

View file

@ -2,10 +2,9 @@
'use strict'; 'use strict';
var path = require('path'); var path = require('path'),
pkg = require('./package.json'),
var version = '0.22-dev',
root = path.resolve(__dirname), root = path.resolve(__dirname),
src = path.join(root, 'src'), src = path.join(root, 'src'),
@ -33,14 +32,18 @@ var version = '0.22-dev',
] ]
}, },
mapper = function (blob) { handlebarsEnv = {
pkg: pkg
},
mapSrc = function (blob) {
return blob.source.replace(src, build).replace(/\.less$/, '.css').replace(/\.jade$/, ''); return blob.source.replace(src, build).replace(/\.less$/, '.css').replace(/\.jade$/, '');
}, },
mapperRoot = function (blob) { mapRoot = function (blob) {
return blob.source.replace(root, build + '/_h5ai'); return blob.source.replace(root, path.join(build, '_h5ai'));
}; };
@ -48,134 +51,117 @@ module.exports = function (make) {
var Event = make.Event, var Event = make.Event,
$ = make.fQuery, $ = make.fQuery,
moment = make.moment, moment = make.moment;
stamp, replacements;
make.version('>=0.8');
make.defaults('build'); make.defaults('build');
make.before(function () { make.before(function () {
stamp = moment(); handlebarsEnv.stamp = moment().format('YYYY-MM-DD HH:mm:ss');
replacements = {
version: version,
stamp: stamp.format('YYYY-MM-DD HH:mm:ss')
};
Event.info({
method: 'before',
message: version + ' ' + replacements.stamp
});
}); });
make.target('check-version', [], 'add git hash tag for dev builds') make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
.async(function (done, fail) {
if (!/-dev$/.test(version)) { if (!/-dev$/.test(pkg.version)) {
done(); done();
return; return;
} }
$.githash(root, function (err, hash) { $.git(root, function (err, result) {
version += '-' + hash; pkg.version += '-' + result.revListMasterHead.length + '-' + result.revParseHead.slice(0, 7);
replacements.version = version;
Event.info({ Event.info({
method: 'check-version', method: 'check-version',
message: 'version set to ' + version message: 'version set to ' + pkg.version
}); });
done(); done();
}); });
}); });
make.target('clean', [], 'delete build folder') make.target('clean', [], 'delete build folder').sync(function () {
.sync(function () {
$.rmfr($.I_AM_SURE, build); $.rmfr($.I_AM_SURE, build);
}); });
make.target('lint', [], 'lint all JavaScript files with JSHint') make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
.sync(function () {
$(src + '/_h5ai/js: **/*.js, ! lib/**') $(path.join(src, '_h5ai', 'js') + ': **/*.js, ! lib/**')
.jshint(jshint); .jshint(jshint);
}); });
make.target('build', ['check-version'], 'build all updated files') make.target('build', ['check-version'], 'build all updated files').sync(function () {
.sync(function () {
$(src + ': _h5ai/js/*.js') $(src + ': _h5ai/js/*.js')
.modified(mapper, $(src + ': _h5ai/js/**')) .modified(mapSrc, $(src + ': _h5ai/js/**'))
.includify() .includify()
.uglifyjs() .uglifyjs()
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(src + ': _h5ai/css/*.less') $(src + ': _h5ai/css/*.less')
.modified(mapper, $(src + ': _h5ai/css/**')) .modified(mapSrc, $(src + ': _h5ai/css/**'))
.less() .less()
.cssmin() .cssmin()
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(src + ': **/*.jade') $(src + ': **/*.jade')
.modified(mapper) .modified(mapSrc)
.handlebars(replacements) .handlebars(handlebarsEnv)
.jade() .jade()
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade') $(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade')
.modified(mapper) .modified(mapSrc)
.handlebars(replacements) .handlebars(handlebarsEnv)
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(root + ': README*, LICENSE*') $(root + ': README*, LICENSE*')
.modified(mapperRoot) .modified(mapRoot)
.write($.OVERWRITE, mapperRoot); .write($.OVERWRITE, mapRoot);
}); });
make.target('build-uncompressed', ['check-version'], 'build all updated files without compression') make.target('build-uncompressed', ['check-version'], 'build all updated files without compression').sync(function () {
.sync(function () {
$(src + ': _h5ai/js/*.js') $(src + ': _h5ai/js/*.js')
.modified(mapper, $(src + ': _h5ai/js/**')) .modified(mapSrc, $(src + ': _h5ai/js/**'))
.includify() .includify()
// .uglifyjs() // .uglifyjs()
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(src + ': _h5ai/css/*.less') $(src + ': _h5ai/css/*.less')
.modified(mapper, $(src + ': _h5ai/css/**')) .modified(mapSrc, $(src + ': _h5ai/css/**'))
.less() .less()
// .cssmin() // .cssmin()
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(src + ': **/*.jade') $(src + ': **/*.jade')
.modified(mapper) .modified(mapSrc)
.handlebars(replacements) .handlebars(handlebarsEnv)
.jade() .jade()
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade') $(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade')
.modified(mapper) .modified(mapSrc)
.handlebars(replacements) .handlebars(handlebarsEnv)
.write($.OVERWRITE, mapper); .write($.OVERWRITE, mapSrc);
$(root + ': README*, LICENSE*') $(root + ': README*, LICENSE*')
.modified(mapperRoot) .modified(mapRoot)
.write($.OVERWRITE, mapperRoot); .write($.OVERWRITE, mapRoot);
}); });
make.target('release', ['clean', 'build'], 'create a zipball') make.target('release', ['clean', 'build'], 'create a zipball').async(function (done, fail) {
.async(function (done, fail) {
$(build + ': _h5ai/**').shzip({ $(build + ': _h5ai/**').shzip({
target: path.join(build, 'h5ai-' + version + '.zip'), target: path.join(build, 'h5ai-' + pkg.version + '.zip'),
dir: build, dir: build,
callback: done callback: done
}); });

12
package.json Normal file
View file

@ -0,0 +1,12 @@
{
"name": "h5ai",
"version": "0.22-dev",
"description": "a modern HTTP web server index",
"url": "http://larsjung.de/h5ai/",
"author": "Lars Jung <lrsjng@gmail.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/lrsjng/h5ai.git"
}
}

View file

@ -1,5 +1,5 @@
################################ ################################
# h5ai {{version}} # {{pkg.name}} {{pkg.version}}
# customized .htaccess # customized .htaccess
################################ ################################
@ -19,5 +19,5 @@ IndexOptions NameWidth=*
IndexOptions SuppressDescription IndexOptions SuppressDescription
IndexOptions SuppressHTMLPreamble IndexOptions SuppressHTMLPreamble
IndexOptions SuppressRules IndexOptions SuppressRules
IndexOptions Type=text/html;h5ai={{version}} IndexOptions Type=text/html;h5ai={{pkg.version}}
IndexOptions XHTML IndexOptions XHTML

View file

@ -11,8 +11,8 @@ doctype 5
head head
meta( charset="utf-8" ) meta( charset="utf-8" )
meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" ) meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" )
title Directory index · styled with h5ai {{version}} title Directory index · styled with {{pkg.name}} {{pkg.version}}
meta( name="description", content="Directory index styled with h5ai {{version}} (http://larsjung.de/h5ai)" ) meta( name="description", content="Directory index styled with h5ai {{pkg.version}} (http://larsjung.de/h5ai)" )
meta( name="viewport", content="width=device-width" ) meta( name="viewport", content="width=device-width" )
link( rel="shortcut icon", type="image/png", href!="#{h5ai}images/h5ai-16x16.png" ) link( rel="shortcut icon", type="image/png", href!="#{h5ai}images/h5ai-16x16.png" )
link( rel="apple-touch-icon", type="image/png", href!="#{h5ai}images/h5ai-48x48.png" ) link( rel="apple-touch-icon", type="image/png", href!="#{h5ai}images/h5ai-48x48.png" )
@ -30,7 +30,7 @@ div#content
div#bottombar.clearfix div#bottombar.clearfix
span.left span.left
a#h5ai-reference( href="http://larsjung.de/h5ai", title="h5ai project page" ) h5ai {{version}} a#h5ai-reference( href="http://larsjung.de/h5ai", title="h5ai project page" ) {{pkg.name}} {{pkg.version}}
span.hideOnJs.noJsMsg ⚡ JavaScript is disabled! ⚡ span.hideOnJs.noJsMsg ⚡ JavaScript is disabled! ⚡
span.oldBrowser span.oldBrowser
| ⚡ Some features disabled! Works best in | ⚡ Some features disabled! Works best in

View file

@ -1,5 +1,5 @@
/* /*
h5ai {{version}} {{pkg.name}} {{pkg.version}}
Configuration Configuration
options, types and localization options, types and localization

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
* h5ai {{version}} * {{pkg.name}} {{pkg.version}}
* *
* PHP Configuration * PHP Configuration
* filesystem paths and file ignore rules * filesystem paths and file ignore rules

View file

@ -8,7 +8,7 @@ html.no-js( lang="en" )
head head
meta( charset="utf-8" ) meta( charset="utf-8" )
meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" ) meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" )
title h5ai {{version}} server details title {{pkg.name}} {{pkg.version}} server details
meta( name="description", content="h5ai server details" ) meta( name="description", content="h5ai server details" )
meta( name="viewport", content="width=device-width" ) meta( name="viewport", content="width=device-width" )
link( rel="shortcut icon", type="image/png", href="images/h5ai-16x16.png" ) link( rel="shortcut icon", type="image/png", href="images/h5ai-16x16.png" )
@ -19,8 +19,8 @@ html.no-js( lang="en" )
body#h5ai-info body#h5ai-info
h1 h5ai h1 {{pkg.name}}
span.build-version version {{version}} span.build-version version {{pkg.version}}
span.build-stamp {{stamp}} span.build-stamp {{stamp}}
h2 server supports h2 server supports
@ -68,7 +68,7 @@ html.no-js( lang="en" )
div#bottombar.clearfix div#bottombar.clearfix
span.left span.left
a#h5ai-reference( href="http://larsjung.de/h5ai", title="h5ai project page" ) h5ai {{version}} a#h5ai-reference( href="http://larsjung.de/h5ai", title="h5ai project page" ) {{pkg.name}} {{pkg.version}}
span.hideOnJs.noJsMsg ⚡ JavaScript is disabled! ⚡ span.hideOnJs.noJsMsg ⚡ JavaScript is disabled! ⚡
span.oldBrowser span.oldBrowser
| ⚡ Some features disabled! Works best in | ⚡ Some features disabled! Works best in

View file

@ -1,5 +1,5 @@
|<?php |<?php
| header("Content-type: text/html;h5ai={{version}}"); | header("Content-type: text/html;h5ai={{pkg.version}}");
| $h5ai_php = str_replace("\\", "/", dirname(__FILE__)) . "/inc/H5ai.php"; | $h5ai_php = str_replace("\\", "/", dirname(__FILE__)) . "/inc/H5ai.php";
| if (!file_exists($h5ai_php)) { | if (!file_exists($h5ai_php)) {
| function find_h5ai($path, $h5ai) { | function find_h5ai($path, $h5ai) {
@ -34,8 +34,8 @@ html.no-js( lang="en" )
head head
meta( charset="utf-8" ) meta( charset="utf-8" )
meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" ) meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" )
title Directory index · styled with h5ai {{version}} title Directory index · styled with {{pkg.name}} {{pkg.version}}
meta( name="description", content="Directory index styled with h5ai {{version}} (http://larsjung.de/h5ai)" ) meta( name="description", content="Directory index styled with h5ai {{pkg.version}} (http://larsjung.de/h5ai)" )
meta( name="viewport", content="width=device-width" ) meta( name="viewport", content="width=device-width" )
link( rel="shortcut icon", type="image/png", href!="#{h5ai}images/h5ai-16x16.png" ) link( rel="shortcut icon", type="image/png", href!="#{h5ai}images/h5ai-16x16.png" )
link( rel="apple-touch-icon", type="image/png", href!="#{h5ai}images/h5ai-48x48.png" ) link( rel="apple-touch-icon", type="image/png", href!="#{h5ai}images/h5ai-48x48.png" )
@ -53,7 +53,7 @@ html.no-js( lang="en" )
div#bottombar.clearfix div#bottombar.clearfix
span.left span.left
a#h5ai-reference( href="http://larsjung.de/h5ai", title="h5ai project page" ) h5ai {{version}} a#h5ai-reference( href="http://larsjung.de/h5ai", title="h5ai project page" ) {{pkg.name}} {{pkg.version}}
span.hideOnJs.noJsMsg ⚡ JavaScript is disabled! ⚡ span.hideOnJs.noJsMsg ⚡ JavaScript is disabled! ⚡
span.oldBrowser span.oldBrowser
| ⚡ Some features disabled! Works best in | ⚡ Some features disabled! Works best in