Use git rev as semver metadata
This commit is contained in:
parent
acbc6d23a9
commit
ca01120227
28
Jakefile.js
28
Jakefile.js
@ -14,7 +14,7 @@ For a custom build, open build/build.html in the browser and follow the instruct
|
||||
|
||||
var build = require('./build/build.js'),
|
||||
buildDocs = require('./build/docs'),
|
||||
version = require('./src/Leaflet.js').version;
|
||||
git = require('git-rev');
|
||||
|
||||
function hint(msg, args) {
|
||||
return function () {
|
||||
@ -27,6 +27,21 @@ function hint(msg, args) {
|
||||
};
|
||||
}
|
||||
|
||||
// Returns the version string in package.json, plus a semver build metadata if
|
||||
// this is not an official release
|
||||
function calculateVersion(officialRelease, callback) {
|
||||
|
||||
var version = require('./package.json').version;
|
||||
|
||||
if (officialRelease) {
|
||||
callback(version);
|
||||
} else {
|
||||
git.short(function(str) {
|
||||
callback (version + '+' + str);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
desc('Check Leaflet source for errors with ESLint');
|
||||
task('lint', {async: true}, hint('Checking for JS errors...', 'src --config .eslintrc'));
|
||||
|
||||
@ -34,16 +49,9 @@ desc('Check Leaflet specs source for errors with ESLint');
|
||||
task('lintspec', {async: true}, hint('Checking for specs JS errors...', 'spec/suites --config spec/.eslintrc'));
|
||||
|
||||
desc('Combine and compress Leaflet source files');
|
||||
task('build', {async: true}, function (compsBase32, buildName) {
|
||||
var v;
|
||||
|
||||
jake.exec('git log -1 --pretty=format:"%h"', {breakOnError: false}, function () {
|
||||
task('build', {async: true}, function (compsBase32, buildName, officialRelease) {
|
||||
calculateVersion(officialRelease, function(v){
|
||||
build.build(complete, v, compsBase32, buildName);
|
||||
|
||||
}).on('stdout', function (data) {
|
||||
v = version + ' (' + data.toString() + ')';
|
||||
}).on('error', function () {
|
||||
v = version;
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -70,13 +70,23 @@ function loadSilently(path) {
|
||||
}
|
||||
}
|
||||
|
||||
function bundleFiles(files, copy) {
|
||||
// Concatenate the files while building up a sourcemap for the concatenation,
|
||||
// and replace the line defining L.version with the string prepared in the jakefile
|
||||
function bundleFiles(files, copy, version) {
|
||||
var node = new SourceNode(null, null, null, '');
|
||||
|
||||
node.add(new SourceNode(null, null, null, copy + '(function (window, document, undefined) {'));
|
||||
|
||||
for (var i = 0, len = files.length; i < len; i++) {
|
||||
var contents = fs.readFileSync(files[i], 'utf8');
|
||||
|
||||
if (files[i] === 'src/Leaflet.js') {
|
||||
contents = contents.replace(
|
||||
new RegExp('version: \'.*\''),
|
||||
'version: ' + JSON.stringify(version)
|
||||
);
|
||||
}
|
||||
|
||||
var lines = contents.split('\n');
|
||||
var lineCount = lines.length;
|
||||
var fileNode = new SourceNode(null, null, null, '');
|
||||
@ -119,7 +129,7 @@ exports.build = function (callback, version, compsBase32, buildName) {
|
||||
srcFilename = filenamePart + '-src.js',
|
||||
mapFilename = filenamePart + '-src.map',
|
||||
|
||||
bundle = bundleFiles(files, copy),
|
||||
bundle = bundleFiles(files, copy, version),
|
||||
newSrc = bundle.src + '\n//# sourceMappingURL=' + mapFilename,
|
||||
|
||||
oldSrc = loadSilently(srcPath),
|
||||
|
@ -8,7 +8,7 @@ npm test || exit 1
|
||||
|
||||
git checkout -b build
|
||||
|
||||
npm run build
|
||||
jake build[,,true]
|
||||
git add dist/leaflet-src.js dist/leaflet.js dist/leaflet-src.map -f
|
||||
|
||||
git commit -m "v$VERSION"
|
||||
|
@ -5,6 +5,7 @@
|
||||
"devDependencies": {
|
||||
"eslint": "^2.8.0",
|
||||
"eslint-config-mourner": "^2.0.1",
|
||||
"git-rev": "^0.2.1",
|
||||
"happen": "~0.3.1",
|
||||
"jake": "~8.0.12",
|
||||
"karma": "~0.13.22",
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
var L = {
|
||||
version: '1.0.0-rc.1'
|
||||
version: 'dev'
|
||||
};
|
||||
|
||||
function expose() {
|
||||
|
Loading…
Reference in New Issue
Block a user