Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auto-vers

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-vers - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.travis.yml

12

package.json
{
"name": "auto-vers",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -15,3 +15,4 @@ "main": "./dist/index.js",

"minor": "./bin/auto-vers -i minor",
"major": "./bin/auto-vers -i major"
"major": "./bin/auto-vers -i major",
"test": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha && ./node_modules/.bin/codecov"
},

@@ -34,4 +35,9 @@ "repository": {

"devDependencies": {
"babel-cli": "^6.26.0"
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"istanbul": "^0.4.5",
"mocha": "^5.2.0"
}
}
# auto-vers
> Auto update version for your application
<p align="center">
<a href="https://travis-ci.org/hua1995116/auto-vers"><img src="https://travis-ci.org/hua1995116/auto-vers.svg?branch=master" /></a>
<a href="https://codecov.io/gh/hua1995116/auto-vers"><img src="https://codecov.io/gh/hua1995116/auto-vers/branch/master/graph/badge.svg" /></a>
<a href="https://npmcharts.com/compare/auto-vers?minimal=true" rel="nofollow"><img src="https://img.shields.io/npm/dm/auto-vers.svg" style="max-width:100%;"></a>
<a href="https://www.npmjs.com/package/auto-vers" rel="nofollow"><img src="https://img.shields.io/npm/v/auto-vers.svg" style="max-width:100%;"></a>
<a href="https://www.npmjs.com/package/auto-vers" rel="nofollow"><img src="https://img.shields.io/npm/l/auto-vers.svg?style=flat" style="max-width:100%;"></a>
</p>
**Auto update version for your application**
> auto-vers is helpful to your work. It will auto update package version when build your application.
# Usage
```
npm i auto-vers
auto-vers -h
```
your package.json
```
"script": {
"build": "babel ./src --out-dir ./dist && ./bin/auto-vers -i",
"build-m": "babel ./src --out-dir ./dist && ./bin/auto-vers -i minor",
"build-a": "babel ./src --out-dir ./dist && ./bin/auto-vers -i major",
"build-t": "babel ./src --out-dir ./dist && ./bin/auto-vers -i prerelease"
}
```
When you iterate over your application, updating the version is a trivial but indispensable little thing. You can run it while packaging your app, and then will do more with less.
# Options
```
-i --increment [<level>]

@@ -14,2 +48,3 @@ Increment a version by the specified level. Level can

Such as 'beta','alpha'
```

@@ -16,0 +51,0 @@ # License

@@ -6,19 +6,17 @@ const semver = require('semver');

const packageCtx = pkgRead();
function autoVersion({type, extra, url}) {
const newVer = updateVersion({type, extra, url});
pkgUpdate(url, Object.assign(pkgRead(url), {version: newVer}));
return newVer;
}
function autoVersion(type, extra) {
const oldVer = getCurrentVersion();
let newVer = '';
if(type.indexOf('.') > -1) {
newVer = type;
} else {
newVer = getNewVersion(oldVer, type, extra);
}
function updateVersion({type, extra, url, version}) {
const oldVer = getCurrentVersion(url);
let newVer = version ? version : getNewVersion(oldVer, type, extra);
console.log(`version will update ${oldVer} -> ${newVer}`.red);
pkgUpdate(Object.assign(packageCtx, {version: newVer}))
return newVer;
}
function getCurrentVersion() {
return packageCtx.version;
function getCurrentVersion(url) {
return pkgRead(url).version;
}

@@ -25,0 +23,0 @@

@@ -5,4 +5,4 @@ const path = require('path');

function pkgRead() {
const pkg = pkgPath();
function pkgRead(url) {
const pkg = url ? url : pkgPath();
const packageCtx = fs.existsSync(pkg);

@@ -22,4 +22,4 @@ if(packageCtx) {

function pkgUpdate(data) {
const pkg = pkgPath();
function pkgUpdate(url, data) {
const pkg = url ? url : pkgPath();
data = JSON.stringify(data, null, 2);

@@ -26,0 +26,0 @@ fs.writeFileSync(pkg, data + os.EOL);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc