mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Merge pull request #110 from duzun/master
Added a script to bump version in project files. Fix #107
This commit is contained in:
commit
378a298fee
84
bower.json
84
bower.json
@ -1,45 +1,43 @@
|
|||||||
{
|
{
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.6",
|
"version": "0.7.6",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Faisal Salman <fyzlman@gmail.com>"
|
"Faisal Salman <fyzlman@gmail.com>"
|
||||||
],
|
],
|
||||||
"private": false,
|
"private": false,
|
||||||
"main": "src/ua-parser.js",
|
"main": "src/ua-parser.js",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"build",
|
"build",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"bower_components",
|
"bower_components",
|
||||||
"test",
|
"test",
|
||||||
"tests"
|
"tests"
|
||||||
],
|
],
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Faisal Salman <fyzlman@gmail.com>",
|
"Faisal Salman <fyzlman@gmail.com>",
|
||||||
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
||||||
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
||||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
"Christopher De Cairos <chris.decairos@gmail.com>",
|
||||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
"Davit Barbakadze <jayarjo@gmail.com>",
|
||||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
||||||
"Douglas Li <doug@knotch.it>",
|
"Douglas Li <doug@knotch.it>",
|
||||||
"Dumitru Uzun <duzun@mail.ru>",
|
"Dumitru Uzun <duzun@mail.ru>",
|
||||||
"Erik Hesselink <hesselink@gmail.com>",
|
"Erik Hesselink <hesselink@gmail.com>",
|
||||||
"Fabian Becker <halfdan@xnorfz.de>",
|
"Fabian Becker <halfdan@xnorfz.de>",
|
||||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
"Hendrik Helwich <h.helwich@iplabs.de>",
|
||||||
"Jackpoll <jackpoll123456@gmail.com>",
|
"Jackpoll <jackpoll123456@gmail.com>",
|
||||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
"Jake Mc <startswithaj@users.noreply.github.com>",
|
||||||
"John Tantalo <john.tantalo@gmail.com>",
|
"John Tantalo <john.tantalo@gmail.com>",
|
||||||
"John Yanarella <jmy@codecatalyst.com>",
|
"John Yanarella <jmy@codecatalyst.com>",
|
||||||
"Jon Buckley <jon@jbuckley.ca>",
|
"Jon Buckley <jon@jbuckley.ca>",
|
||||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
"Kendall Buchanan <kendall@kendagriff.com>",
|
||||||
"Lee Treveil <leetreveil@gmail.com>",
|
"Lee Treveil <leetreveil@gmail.com>",
|
||||||
"Leonardo <leofiore@libero.it>",
|
"Leonardo <leofiore@libero.it>",
|
||||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
||||||
"Michael Hess <mhess@connectify.me>",
|
"Michael Hess <mhess@connectify.me>",
|
||||||
"OtakuSiD <otakusid@gmail.com>",
|
"OtakuSiD <otakusid@gmail.com>",
|
||||||
"Ross Noble <rosshnoble@gmail.com>",
|
"Ross Noble <rosshnoble@gmail.com>",
|
||||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>"
|
"Sandro Sonntag <sandro.sonntag@adorsys.de>"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
112
build/verup.js
Normal file
112
build/verup.js
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Increment and update version in all project files.
|
||||||
|
*
|
||||||
|
* Ussage:
|
||||||
|
*
|
||||||
|
* Increment revision by 1:
|
||||||
|
* node verup.js 1
|
||||||
|
*
|
||||||
|
* Increment minor version by 1:
|
||||||
|
* node verup.js 1.0
|
||||||
|
*
|
||||||
|
* Increment major version by 1:
|
||||||
|
* node verup.js 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Dumitru Uzun (DUzun.Me)
|
||||||
|
* @version 1.1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var _root = path.join(__dirname, '..');
|
||||||
|
var files = [
|
||||||
|
'ua-parser-js.jquery.json',
|
||||||
|
'component.json',
|
||||||
|
'bower.json',
|
||||||
|
'package.js',
|
||||||
|
'src/ua-parser.js'
|
||||||
|
];
|
||||||
|
|
||||||
|
var ver_reg = [
|
||||||
|
/^((?:\$|@|(\s*(?:var|,)?\s+))(?:LIBVERSION|version)[\s\:='"]+)([0-9]+(?:\.[0-9]+){2,2})/
|
||||||
|
, /^(\s?\*.*v)([0-9]+(?:\.[0-9]+){2,2})/
|
||||||
|
];
|
||||||
|
|
||||||
|
var packFile = path.join(_root, 'package.json');
|
||||||
|
var packo = require(packFile);
|
||||||
|
|
||||||
|
if ( !packo ) {
|
||||||
|
console.error('Can\'t read package.json file');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
var over = packo.version;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bump should be 1 for revision, 1.0 for minor and 1.0.0 for major version
|
||||||
|
*/
|
||||||
|
var bump = (process.argv[2] || '1').split('.').reverse();
|
||||||
|
|
||||||
|
if ( over ) {
|
||||||
|
var nver = over.split('.').reverse();
|
||||||
|
var b, l;
|
||||||
|
while(bump.length && !(b = parseInt(bump.pop())));
|
||||||
|
l = bump.length;
|
||||||
|
|
||||||
|
// console.log({b:b,nver:nver,over:over,l:l,bump:bump})
|
||||||
|
nver[l] = +nver[l] + b;
|
||||||
|
bump.forEach(function (v,i) { nver[i] = v; });
|
||||||
|
|
||||||
|
nver = nver.reverse().join('.');
|
||||||
|
packo.version = nver;
|
||||||
|
|
||||||
|
console.log('Bumping version: ' + over + ' -> ' + nver);
|
||||||
|
|
||||||
|
var buf = JSON.stringify(packo, null, 2);
|
||||||
|
|
||||||
|
if ( buf && over != nver ) {
|
||||||
|
buf += "\n";
|
||||||
|
fs.writeFileSync(packFile, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
files.forEach(function (f) {
|
||||||
|
var fn = path.join(_root, f);
|
||||||
|
var cnt = fs.readFileSync(fn, 'utf8');
|
||||||
|
var ext = path.extname(f);
|
||||||
|
var buf;
|
||||||
|
|
||||||
|
switch(ext) {
|
||||||
|
case '.json': {
|
||||||
|
var packo = JSON.parse(cnt);
|
||||||
|
packo.version = nver;
|
||||||
|
buf = JSON.stringify(packo, null, 2);
|
||||||
|
if ( buf ) {
|
||||||
|
buf += "\n";
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default: {
|
||||||
|
buf = cnt
|
||||||
|
.split('\n')
|
||||||
|
.map(function (l) {
|
||||||
|
for(var i=ver_reg.length; i--;) {
|
||||||
|
if ( ver_reg[i].test(l) ) {
|
||||||
|
return l.replace(ver_reg[i], function ($0,$1) { return $1 + nver })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
})
|
||||||
|
.join("\n")
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( buf && buf != cnt ) {
|
||||||
|
console.log("\t" + fn.replace(_root, ''));
|
||||||
|
fs.writeFileSync(fn, buf);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
@ -2,8 +2,18 @@
|
|||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.6",
|
"version": "0.7.6",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device", "cpu"],
|
"keywords": [
|
||||||
"scripts": ["src/ua-parser.js"],
|
"user-agent",
|
||||||
|
"parser",
|
||||||
|
"browser",
|
||||||
|
"engine",
|
||||||
|
"os",
|
||||||
|
"device",
|
||||||
|
"cpu"
|
||||||
|
],
|
||||||
|
"scripts": [
|
||||||
|
"src/ua-parser.js"
|
||||||
|
],
|
||||||
"main": "src/ua-parser.js",
|
"main": "src/ua-parser.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"development": {
|
"development": {
|
||||||
|
@ -42,14 +42,15 @@
|
|||||||
],
|
],
|
||||||
"main": "src/ua-parser.js",
|
"main": "src/ua-parser.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./build/build.sh"
|
"test": "./build/build.sh",
|
||||||
|
"verup": "node ./build/verup.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jshint": "~1.1.0",
|
"jshint": "~1.1.0",
|
||||||
"mocha": "~1.8.0",
|
"mocha": "~1.8.0",
|
||||||
"uglify-js": "~1.3.4"
|
"uglify-js": "~1.3.4"
|
||||||
},
|
},
|
||||||
"repository" : {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/faisalman/ua-parser-js.git"
|
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||||
},
|
},
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.6",
|
"version": "0.7.6",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"user-agent",
|
"user-agent",
|
||||||
"parser",
|
"parser",
|
||||||
"browser",
|
"browser",
|
||||||
"engine",
|
"engine",
|
||||||
"os",
|
"os",
|
||||||
"device",
|
"device",
|
||||||
"cpu"
|
"cpu"
|
||||||
],
|
],
|
||||||
"homepage": "https://faisalman.github.com/ua-parser-js",
|
"homepage": "https://faisalman.github.com/ua-parser-js",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Faisal Salman",
|
"name": "Faisal Salman",
|
||||||
"email": "fyzlman@gmail.com"
|
"email": "fyzlman@gmail.com"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jquery": ">=1.5"
|
"jquery": ">=1.5"
|
||||||
},
|
},
|
||||||
"licenses": [
|
"licenses": [
|
||||||
{
|
{
|
||||||
"type": "MIT",
|
"type": "MIT",
|
||||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
||||||
"docs": "https://github.com/faisalman/ua-parser-js",
|
"docs": "https://github.com/faisalman/ua-parser-js",
|
||||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js"
|
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user