New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.4 to 0.1.0

16

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

@@ -10,8 +10,7 @@ "main": "./dist/index.js",

"scripts": {
"build": "babel ./src --out-dir ./dist && npm run patch",
"build-m": "babel ./src --out-dir ./dist && npm run minor",
"build-a": "babel ./src --out-dir ./dist && npm run major",
"patch": "./bin/auto-vers -i",
"minor": "./bin/auto-vers -i minor",
"major": "./bin/auto-vers -i major",
"build": "babel ./src --out-dir ./dist",
"patch": "npm run build && ./bin/auto-vers -i",
"minor": "npm run build && ./bin/auto-vers -i minor",
"major": "npm run build && ./bin/auto-vers -i major",
"beta": "npm run build && ./bin/auto-vers -i prerelease",
"test": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha && ./node_modules/.bin/codecov"

@@ -25,3 +24,3 @@ },

"author": "hua199116<qiufenghyf@163.com>",
"license": "ISC",
"license": "MIT",
"bugs": {

@@ -33,2 +32,3 @@ "url": "https://github.com/hua1995116/auto-version/issues"

"colors": "^1.3.3",
"enquirer": "^2.3.0",
"semver": "^5.6.0"

@@ -35,0 +35,0 @@ },

# auto-vers
<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://travis-ci.org/hua1995116/auto-version"><img src="https://travis-ci.org/hua1995116/auto-version.svg?branch=master" /></a>
<a href="https://codecov.io/gh/hua1995116/auto-version"><img src="https://codecov.io/gh/hua1995116/auto-version/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>

@@ -15,26 +15,42 @@ <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>

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.
# Feature
- [x] upgrade major, minor, patch or prerelease
- [x] confirm update in cli
# Usage
```shell
npm i auto-vers
```
npm i auto-vers
auto-vers -h
## Cli
package.json
```json
{
...
"version": "1.0.0"
...
}
```
your package.json
bash
```
"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"
}
./bin/auto-vers -i
```
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.
package.json
```json
{
...
"version": "1.0.1"
...
}
```
# Options
options
```

@@ -49,4 +65,58 @@ -i --increment [<level>]

Such as 'beta','alpha'
-t --tip
Do not update the version directly, you can confirm.
```
## Node
package.json
```json
{
...
"version": "1.0.0"
...
}
```
index.js
```javascript
const autoVers = require('auto-vers');
autoVers({type: 'patch'}); // 1.0.1
```
```shell
node index.js
```
update package.json
```json
{
...
"version": "1.0.1"
...
}
```
options
```
{
type: major | minor | patch | prerelease,
url?: package.json's url,
extra?: alpha | beta | ...
}
```
# Practices
It is a good choice to build your application and upgrade the version at the same time.
```json
"script": {
"build": "babel ./src --out-dir ./dist",
"patch": "npm run build && ./bin/auto-vers -i",
"minor": "npm run build && ./bin/auto-vers -i minor",
"major": "npm run build && ./bin/auto-vers -i major",
"beta": "npm run build && ./bin/auto-vers -i prerelease",
}
```
# License

@@ -53,0 +123,0 @@

const semver = require('semver');
const colors = require('colors');
const { prompt } = require('enquirer');
const {pkgRead, pkgUpdate} = require('./pkg');
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, url, confirm}) {
const {version, text} = updateVersion({type, extra, url});
if(confirm) {
const question = {
type: 'confirm',
name: 'progress',
initial: 'yes',
message: text
};
prompt(question)
.then(answer => {
if(answer.progress) {
pkgUpdate(url, Object.assign(pkgRead(url), {version}));
} else {
console.log('cancel');
}
})
.catch(console.error);
} else {
console.log(text);
pkgUpdate(url, Object.assign(pkgRead(url), {version}));
}
return version;
}

@@ -15,4 +35,3 @@

let newVer = version ? version : getNewVersion(oldVer, type, extra);
console.log(`version will update ${oldVer} -> ${newVer}`.red);
return newVer;
return {version: newVer, text: `version will update ${oldVer} -> ${newVer}`.red};
}

@@ -19,0 +38,0 @@

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