From 07fcb40aab1936ce7b12718bdf6de55867c4b898 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 14 Sep 2012 00:25:20 +0200 Subject: [PATCH] Updates build process. --- makefile.js | 228 ++++++++++++------------- package.json | 12 ++ src/_h5ai/apache/autoindex.htaccess | 4 +- src/_h5ai/apache/h5ai-header.html.jade | 6 +- src/_h5ai/config.js | 2 +- src/_h5ai/config.php | 2 +- src/_h5ai/index.html.jade | 8 +- src/_h5ai/php/h5ai-index.php.jade | 8 +- 8 files changed, 134 insertions(+), 136 deletions(-) create mode 100644 package.json diff --git a/makefile.js b/makefile.js index 2fc8c3e8..b854df2a 100644 --- a/makefile.js +++ b/makefile.js @@ -2,10 +2,9 @@ 'use strict'; -var path = require('path'); +var path = require('path'), - -var version = '0.22-dev', + pkg = require('./package.json'), root = path.resolve(__dirname), 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$/, ''); }, - mapperRoot = function (blob) { + mapRoot = function (blob) { - return blob.source.replace(root, build + '/_h5ai'); + return blob.source.replace(root, path.join(build, '_h5ai')); }; @@ -48,136 +51,119 @@ module.exports = function (make) { var Event = make.Event, $ = make.fQuery, - moment = make.moment, - stamp, replacements; + moment = make.moment; + make.version('>=0.8'); make.defaults('build'); 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 info to dev builds').async(function (done, fail) { + + if (!/-dev$/.test(pkg.version)) { + done(); + return; + } + + $.git(root, function (err, result) { + + pkg.version += '-' + result.revListMasterHead.length + '-' + result.revParseHead.slice(0, 7); + Event.info({ + method: 'check-version', + message: 'version set to ' + pkg.version + }); + done(); }); }); - make.target('check-version', [], 'add git hash tag for dev builds') - .async(function (done, fail) { + make.target('clean', [], 'delete build folder').sync(function () { - if (!/-dev$/.test(version)) { - done(); - return; - } + $.rmfr($.I_AM_SURE, build); + }); - $.githash(root, function (err, hash) { - version += '-' + hash; - replacements.version = version; - Event.info({ - method: 'check-version', - message: 'version set to ' + 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/js: **/*.js, ! lib/**') - .jshint(jshint); - }); - - - make.target('build', ['check-version'], 'build all updated files') - .sync(function () { - - $(src + ': _h5ai/js/*.js') - .modified(mapper, $(src + ': _h5ai/js/**')) - .includify() - .uglifyjs() - .write($.OVERWRITE, mapper); - - $(src + ': _h5ai/css/*.less') - .modified(mapper, $(src + ': _h5ai/css/**')) - .less() - .cssmin() - .write($.OVERWRITE, mapper); - - $(src + ': **/*.jade') - .modified(mapper) - .handlebars(replacements) - .jade() - .write($.OVERWRITE, mapper); - - $(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade') - .modified(mapper) - .handlebars(replacements) - .write($.OVERWRITE, mapper); - - $(root + ': README*, LICENSE*') - .modified(mapperRoot) - .write($.OVERWRITE, mapperRoot); - }); - - - make.target('build-uncompressed', ['check-version'], 'build all updated files without compression') - .sync(function () { - - $(src + ': _h5ai/js/*.js') - .modified(mapper, $(src + ': _h5ai/js/**')) - .includify() - // .uglifyjs() - .write($.OVERWRITE, mapper); - - $(src + ': _h5ai/css/*.less') - .modified(mapper, $(src + ': _h5ai/css/**')) - .less() - // .cssmin() - .write($.OVERWRITE, mapper); - - $(src + ': **/*.jade') - .modified(mapper) - .handlebars(replacements) - .jade() - .write($.OVERWRITE, mapper); - - $(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade') - .modified(mapper) - .handlebars(replacements) - .write($.OVERWRITE, mapper); - - $(root + ': README*, LICENSE*') - .modified(mapperRoot) - .write($.OVERWRITE, mapperRoot); - }); - - - make.target('release', ['clean', 'build'], 'create a zipball') - .async(function (done, fail) { - - $(build + ': _h5ai/**').shzip({ - target: path.join(build, 'h5ai-' + version + '.zip'), - dir: build, - callback: done - }); + make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () { + + $(path.join(src, '_h5ai', 'js') + ': **/*.js, ! lib/**') + .jshint(jshint); + }); + + + make.target('build', ['check-version'], 'build all updated files').sync(function () { + + $(src + ': _h5ai/js/*.js') + .modified(mapSrc, $(src + ': _h5ai/js/**')) + .includify() + .uglifyjs() + .write($.OVERWRITE, mapSrc); + + $(src + ': _h5ai/css/*.less') + .modified(mapSrc, $(src + ': _h5ai/css/**')) + .less() + .cssmin() + .write($.OVERWRITE, mapSrc); + + $(src + ': **/*.jade') + .modified(mapSrc) + .handlebars(handlebarsEnv) + .jade() + .write($.OVERWRITE, mapSrc); + + $(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade') + .modified(mapSrc) + .handlebars(handlebarsEnv) + .write($.OVERWRITE, mapSrc); + + $(root + ': README*, LICENSE*') + .modified(mapRoot) + .write($.OVERWRITE, mapRoot); + }); + + + make.target('build-uncompressed', ['check-version'], 'build all updated files without compression').sync(function () { + + $(src + ': _h5ai/js/*.js') + .modified(mapSrc, $(src + ': _h5ai/js/**')) + .includify() + // .uglifyjs() + .write($.OVERWRITE, mapSrc); + + $(src + ': _h5ai/css/*.less') + .modified(mapSrc, $(src + ': _h5ai/css/**')) + .less() + // .cssmin() + .write($.OVERWRITE, mapSrc); + + $(src + ': **/*.jade') + .modified(mapSrc) + .handlebars(handlebarsEnv) + .jade() + .write($.OVERWRITE, mapSrc); + + $(src + ': **, ! _h5ai/js/**, ! _h5ai/css/**, ! **/*.jade') + .modified(mapSrc) + .handlebars(handlebarsEnv) + .write($.OVERWRITE, mapSrc); + + $(root + ': README*, LICENSE*') + .modified(mapRoot) + .write($.OVERWRITE, mapRoot); + }); + + + make.target('release', ['clean', 'build'], 'create a zipball').async(function (done, fail) { + + $(build + ': _h5ai/**').shzip({ + target: path.join(build, 'h5ai-' + pkg.version + '.zip'), + dir: build, + callback: done }); + }); }; diff --git a/package.json b/package.json new file mode 100644 index 00000000..1c02ad21 --- /dev/null +++ b/package.json @@ -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 ", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/lrsjng/h5ai.git" + } +} diff --git a/src/_h5ai/apache/autoindex.htaccess b/src/_h5ai/apache/autoindex.htaccess index 99595977..05604834 100644 --- a/src/_h5ai/apache/autoindex.htaccess +++ b/src/_h5ai/apache/autoindex.htaccess @@ -1,5 +1,5 @@ ################################ -# h5ai {{version}} +# {{pkg.name}} {{pkg.version}} # customized .htaccess ################################ @@ -19,5 +19,5 @@ IndexOptions NameWidth=* IndexOptions SuppressDescription IndexOptions SuppressHTMLPreamble IndexOptions SuppressRules -IndexOptions Type=text/html;h5ai={{version}} +IndexOptions Type=text/html;h5ai={{pkg.version}} IndexOptions XHTML diff --git a/src/_h5ai/apache/h5ai-header.html.jade b/src/_h5ai/apache/h5ai-header.html.jade index 5faa5ee6..68cd5d78 100644 --- a/src/_h5ai/apache/h5ai-header.html.jade +++ b/src/_h5ai/apache/h5ai-header.html.jade @@ -11,8 +11,8 @@ doctype 5 head meta( charset="utf-8" ) meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" ) - title Directory index · styled with h5ai {{version}} - meta( name="description", content="Directory index styled with h5ai {{version}} (http://larsjung.de/h5ai)" ) + title Directory index · styled with {{pkg.name}} {{pkg.version}} + meta( name="description", content="Directory index styled with h5ai {{pkg.version}} (http://larsjung.de/h5ai)" ) meta( name="viewport", content="width=device-width" ) 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" ) @@ -30,7 +30,7 @@ div#content div#bottombar.clearfix 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.oldBrowser | ⚡ Some features disabled! Works best in diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index 4f896e8d..2584bd7c 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -1,5 +1,5 @@ /* -h5ai {{version}} +{{pkg.name}} {{pkg.version}} Configuration options, types and localization diff --git a/src/_h5ai/config.php b/src/_h5ai/config.php index e7fcd80a..ccdcce70 100644 --- a/src/_h5ai/config.php +++ b/src/_h5ai/config.php @@ -1,6 +1,6 @@