Skip to content

Commit

Permalink
introduced a tiny node module that gets the project version from pom.…
Browse files Browse the repository at this point in the history
…xml and is shared by gulp and karma
  • Loading branch information
krico committed Apr 15, 2015
1 parent bea7ca8 commit 3d6ee14
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 deletions.
26 changes: 26 additions & 0 deletions schedule/schedule-appengine/dynamic-paths.js
Original file line number Diff line number Diff line change
@@ -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;
59 changes: 17 additions & 42 deletions schedule/schedule-appengine/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}));
}

Expand All @@ -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'));
}


Expand All @@ -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) {
Expand All @@ -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'));
};
}

Expand All @@ -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) {
Expand All @@ -223,27 +198,27 @@ 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'));
};
}


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 + '/../'))
}


Expand Down
2 changes: 1 addition & 1 deletion schedule/schedule-appengine/src/test/client/karma.conf.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 3d6ee14

Please sign in to comment.