Some more work on gulp

Change the way versions are handled, and append the branch name if we're not publishing from master.
This commit is contained in:
Jürg Lehni 2016-01-18 01:18:57 +01:00
parent 4351ca310f
commit eaceb1bfc3
4 changed files with 30 additions and 15 deletions

View file

@ -22,7 +22,7 @@ var gulp = require('gulp'),
merge = require('merge-stream'), merge = require('merge-stream'),
del = require('del'), del = require('del'),
zip = require('gulp-zip'), zip = require('gulp-zip'),
gitty = require('gitty')('.'), gitty = require('gitty'),
fs = require('fs'); fs = require('fs');
/** /**
@ -54,6 +54,30 @@ var acornPath = 'bower_components/acorn/';
var buildNames = Object.keys(buildOptions); var buildNames = Object.keys(buildOptions);
var docNames = Object.keys(docOptions); var docNames = Object.keys(docOptions);
/**
* Git
*/
var gitRepo = gitty('.');
function git(param) {
var args = arguments.length === 1 ? param.split(' ') : [].slice.apply(arguments);
var operation = args.shift();
return new gitty.Command(gitRepo, operation, args).execSync().trim();
}
var gitDate = git('log -1 --pretty=format:%ad');
var gitVersion = git('describe --abbrev=0 --tags');
var gitBranch = git('rev-parse --abbrev-ref HEAD');
if (gitBranch !== 'master')
gitVersion += '-' + gitBranch;
gulp.task('nop');
/**
* Task: default
*/
gulp.on('error', function(err) { gulp.on('error', function(err) {
console.error(err.toString()); console.error(err.toString());
gulp.emit('end'); gulp.emit('end');
@ -120,7 +144,6 @@ gulp.task('build',
); );
// Get the date of the last commit from git. // Get the date of the last commit from git.
var gitLog = gitty.logSync('-1');
buildNames.forEach(function(name) { buildNames.forEach(function(name) {
gulp.task('build:' + name, ['build:start'], function() { gulp.task('build:' + name, ['build:start'], function() {
return gulp.src('src/paper.js') return gulp.src('src/paper.js')
@ -128,7 +151,8 @@ buildNames.forEach(function(name) {
evaluate: ['src/constants.js', 'src/options.js'], evaluate: ['src/constants.js', 'src/options.js'],
setup: function() { setup: function() {
var options = buildOptions[name]; var options = buildOptions[name];
options.date = gitLog[0].date; options.version = gitVersion;
options.date = gitDate;
// This object will be merged into the Prepro.js VM scope, // This object will be merged into the Prepro.js VM scope,
// which already holds a __options object from the above // which already holds a __options object from the above
// include statement. // include statement.

View file

@ -45,10 +45,7 @@ if (typeof window === 'object') {
// This object will be merged into the Prepro.js VM scope, which already // This object will be merged into the Prepro.js VM scope, which already
// holds a __options object from the above include statement. // holds a __options object from the above include statement.
return { return {
__options: { __options: { environment: 'node' }
version: 'dev',
environment: 'node'
}
}; };
}); });
// Load Paper.js library files. // Load Paper.js library files.

View file

@ -14,14 +14,8 @@
// browser based compile-time preprocessing when loading the separate source // browser based compile-time preprocessing when loading the separate source
// files directly through load.js / Prepro.js during development. // files directly through load.js / Prepro.js during development.
// The paper.js version.
// NOTE: Adjust value here before calling publish.sh, which then updates and
// publishes the various JSON package files automatically.
var version = '0.9.25';
var __options = { var __options = {
// If this file is loaded in the browser, we're in dev mode through load.js version: 'dev',
version: typeof window === 'object' ? 'dev' : version,
environment: 'browser', environment: 'browser',
parser: 'acorn', parser: 'acorn',
svg: true, svg: true,

View file

@ -1,5 +1,5 @@
/*! /*!
* Paper.js v*#=* __options.version - The Swiss Army Knife of Vector Graphics Scripting. * Paper.js *#=* __options.version - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/ * http://paperjs.org/
* *
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey * Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey