From 3d6ee144f2f127985c10509c2e5298cb59c561dc Mon Sep 17 00:00:00 2001 From: krico Date: Thu, 16 Apr 2015 01:33:08 +0200 Subject: [PATCH] introduced a tiny node module that gets the project version from pom.xml and is shared by gulp and karma --- schedule/schedule-appengine/dynamic-paths.js | 26 ++++++++ schedule/schedule-appengine/gulpfile.js | 59 ++++++------------- .../src/test/client/karma.conf.js | 2 +- 3 files changed, 44 insertions(+), 43 deletions(-) create mode 100644 schedule/schedule-appengine/dynamic-paths.js diff --git a/schedule/schedule-appengine/dynamic-paths.js b/schedule/schedule-appengine/dynamic-paths.js new file mode 100644 index 00000000..01ef8e6a --- /dev/null +++ b/schedule/schedule-appengine/dynamic-paths.js @@ -0,0 +1,26 @@ +var xml2json = require('xml-to-json'); + +function mavenVersion() { + //This is so ugly, I'm embarrassed ;-) + var gotIt = {err: null, result: null}; + + xml2json({ + input: __dirname + '/pom.xml', + output: null + }, function (err, result) { + gotIt.err = err; + gotIt.result = result; + }); + var uvrun = require("uvrun"); + while (gotIt.err === null && gotIt.result === null) + uvrun.runOnce(); + + if (gotIt.err) + throw gotIt.err; + + return gotIt.result.project.version; +} +var paths = require(__dirname + '/paths.json'); +paths.projectVersion = mavenVersion(); +paths.build = paths.buildTemplate.replace('@VERSION@', paths.projectVersion); +module.exports = paths; diff --git a/schedule/schedule-appengine/gulpfile.js b/schedule/schedule-appengine/gulpfile.js index 073677eb..89042dba 100644 --- a/schedule/schedule-appengine/gulpfile.js +++ b/schedule/schedule-appengine/gulpfile.js @@ -26,33 +26,8 @@ var argv = require('yargs').argv, templateCache = require('gulp-angular-templatecache'), plumber = require('gulp-plumber'); -var xml2json = require('xml-to-json'); - -function mavenVersion() { - //This is so ugly, I'm embarrassed ;-) - var gotIt = {err: null, result: null}; - - xml2json({ - input: './pom.xml', - output: null - }, function (err, result) { - gotIt.err = err; - gotIt.result = result; - }); - var uvrun = require("uvrun"); - while (gotIt.err === null && gotIt.result === null) - uvrun.runOnce(); - - if (gotIt.err) - throw gotIt.err; - - return gotIt.result.project.version; -} - -var pomVersion = mavenVersion(); -gutil.log('Project version: ' + gutil.colors.cyan(pomVersion)); -var paths = require('./paths.json'); -var target = paths.buildTemplate.replace('@VERSION@', pomVersion); +var paths = require('./dynamic-paths.js'); +gutil.log('Project version: ' + gutil.colors.cyan(paths.projectVersion)); gulp.task('clean', clean); gulp.task('sym', ['build'], sym); @@ -99,12 +74,12 @@ function rebuild() { function clean(cb) { - del([target, paths.symBuild], cb); + del([paths.build, paths.symBuild], cb); } function sym(cb) { return gulp - .src(target) + .src(paths.build) .pipe(symlink(paths.symBuild, {force: true, relative: true})); } @@ -129,12 +104,12 @@ function clientTpl(cb) { footer: '})(angular);' })) .pipe(sourcemaps.init()) - .pipe(gulp.dest(target + '/js')) + .pipe(gulp.dest(paths.build + '/js')) .pipe(ngAnnotate()) .pipe(uglify()) .pipe(rename({extname: '.min.js'})) .pipe(sourcemaps.write('./')) - .pipe(gulp.dest(target + '/js')); + .pipe(gulp.dest(paths.build + '/js')); } @@ -156,12 +131,12 @@ function clientJs(cb) { .pipe(replace('@VERSION@', versionInfo.version)) .pipe(plumber()) .pipe(concat('jasify.js')) - .pipe(gulp.dest(target + '/js')) + .pipe(gulp.dest(paths.build + '/js')) .pipe(ngAnnotate()) .pipe(uglify()) .pipe(rename({extname: '.min.js'})) .pipe(sourcemaps.write('./')) - .pipe(gulp.dest(target + '/js')); + .pipe(gulp.dest(paths.build + '/js')); } function clientDependenciesJsFun(key) { @@ -174,12 +149,12 @@ function clientDependenciesJsFun(key) { .pipe(sourcemaps.init()) .pipe(plumber()) .pipe(concat('dep-' + key + '.js')) - .pipe(gulp.dest(target + '/js')) + .pipe(gulp.dest(paths.build + '/js')) .pipe(ngAnnotate()) .pipe(uglify()) .pipe(rename({extname: '.min.js'})) .pipe(sourcemaps.write('./')) - .pipe(gulp.dest(target + '/js')); + .pipe(gulp.dest(paths.build + '/js')); }; } @@ -205,11 +180,11 @@ function clientCss(cb) { ] })) .pipe(concat('jasify.css')) - .pipe(gulp.dest(target + '/css')) + .pipe(gulp.dest(paths.build + '/css')) .pipe(minifyCSS()) .pipe(rename({extname: '.min.css'})) .pipe(sourcemaps.write('./')) - .pipe(gulp.dest(target + '/css')); + .pipe(gulp.dest(paths.build + '/css')); } function clientDependenciesCssFun(key) { @@ -223,14 +198,14 @@ function clientDependenciesCssFun(key) { return function (cb) { gulp.src(fonts) - .pipe(gulp.dest(target + '/fonts')); + .pipe(gulp.dest(paths.build + '/fonts')); return gulp.src(src) .pipe(concat('dep-' + key + '.css')) - .pipe(gulp.dest(target + '/css')) + .pipe(gulp.dest(paths.build + '/css')) .pipe(minifyCSS()) .pipe(rename({extname: '.min.css'})) - .pipe(gulp.dest(target + '/css')); + .pipe(gulp.dest(paths.build + '/css')); }; } @@ -238,12 +213,12 @@ function clientDependenciesCssFun(key) { function html(cb) { return gulp.src(paths.html) .pipe(htmlmin({collapseWhitespace: true, minifyJS: true})) - .pipe(gulp.dest(target + '/../')) + .pipe(gulp.dest(paths.build + '/../')) } function staticHtml(cb) { return gulp.src(paths.staticHtml) - .pipe(gulp.dest(target + '/../')) + .pipe(gulp.dest(paths.build + '/../')) } diff --git a/schedule/schedule-appengine/src/test/client/karma.conf.js b/schedule/schedule-appengine/src/test/client/karma.conf.js index d5dffadb..5bbec04c 100644 --- a/schedule/schedule-appengine/src/test/client/karma.conf.js +++ b/schedule/schedule-appengine/src/test/client/karma.conf.js @@ -1,5 +1,5 @@ module.exports = function (config, min) { - var paths = require('../../../paths.json'); + var paths = require('../../../dynamic-paths.js'); var files = [ paths.build + '/js/dep-boot.js', paths.build + '/js/dep-main.js',