Socket
Socket
Sign inDemoInstall

appversion

Package Overview
Dependencies
74
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.0 to 1.7.1

2

appversion.default.json

@@ -18,3 +18,3 @@ {

"config": {
"appversion": "1.7.0",
"appversion": "1.7.1",
"markdown": [],

@@ -21,0 +21,0 @@ "json": [],

@@ -1,10 +0,1 @@

/*
* Project: appversion
* Version: 1.7.0
* Author: delvedor
* Twitter: @delvedor
* License: MIT
* GitHub: https://github.com/delvedor/appversion
*/
'use strict'

@@ -11,0 +2,0 @@

@@ -5,3 +5,3 @@ {

"minor": 7,
"patch": 0
"patch": 1
},

@@ -19,3 +19,3 @@ "status": {

"config": {
"appversion": "1.7.0",
"appversion": "1.7.1",
"markdown": [

@@ -22,0 +22,0 @@ "README.md"

@@ -5,3 +5,3 @@ #! /usr/bin/env node

* Project: appversion
* Version: 1.7.0
* Version: 1.7.1
* Author: delvedor

@@ -8,0 +8,0 @@ * Twitter: @delvedor

@@ -1,10 +0,1 @@

/*
* Project: appversion
* Version: 1.7.0
* Author: delvedor
* Twitter: @delvedor
* License: MIT
* GitHub: https://github.com/delvedor/appversion
*/
'use strict'

@@ -11,0 +2,0 @@

# Changelog
## v1.7.1
- Reimplemented all the badge code with streams
## v1.7.0

@@ -4,0 +7,0 @@ - Added aliases: patch>fix, minor>feature major>breaking, for making more expressive the command

@@ -19,29 +19,46 @@ 'use strict'

* @param {Boolean} updateMD [If this parameter is undefined means that the function was called by the user, so it outputs the badge code.]
* @param {Object} previousObj [Past version/status object]
*/
function createBadge (tag, updateMD) {
if (!check('String', tag) && !check('Boolean | Undefined', updateMD)) return
function createBadge (tag, updateMD, previousObj) {
if (!check('String', tag) && !check('Boolean | Undefined', updateMD) && !check('Object | Undefined', previousObj)) return
tag === 'status' ? statusBadge(updateMD, previousObj) : versionBadge(updateMD, previousObj)
}
function versionBadge (updateMD, previousObj) {
let obj = readJson(JSON_FILE)
let parameter
// If the status.number is zero is not displayed
if (tag === 'status') {
parameter = obj.status.number > 0 ? `${obj.status.stage}%20${obj.status.number}` : obj.status.stage
let version = `${obj.version.major}.${obj.version.minor}.${obj.version.patch}`
let readmeCode = composeReadmeCode('version', `AppVersion-${version}`)
if (updateMD) {
let pastVersion = `${previousObj.version.major}.${previousObj.version.minor}.${previousObj.version.patch}`
let pastReadmeCode = composeReadmeCode('version', `AppVersion-${pastVersion}`)
obj.config.markdown.map((file) => {
return appendBadgeToMD(file, readmeCode, pastReadmeCode)
})
} else {
parameter = `${obj.version.major}.${obj.version.minor}.${obj.version.patch}`
printReadme(readmeCode, 'version')
}
}
function statusBadge (updateMD, previousObj) {
let obj = readJson(JSON_FILE)
let status = obj.status.number > 0 ? `${obj.status.stage}%20${obj.status.number}` : obj.status.stage
let readmeCode = composeReadmeCode('status', `Status-${status}`)
if (updateMD) {
// compose the url
let url = tag === 'version' ? shieldUrl(`AppVersion-${parameter}`) : shieldUrl(`Status-${parameter}`)
let pastStatus = previousObj.status.number > 0 ? `${previousObj.status.stage}%20${previousObj.status.number}` : previousObj.status.stage
let pastReadmeCode = composeReadmeCode('status', `Status-${pastStatus}`)
obj.config.markdown.map((file) => {
return appendBadgeToMD(url, file, `[![AppVersion-${tag}]`, `?#${tag}`)
return appendBadgeToMD(file, readmeCode, pastReadmeCode)
})
} else {
// compose the badge .md code
let readmeCode = tag === 'version' ? composeReadmeCode(tag, `AppVersion-${parameter}`) : composeReadmeCode(tag, `Status-${parameter}`)
console.log(chalk.green(`\n${chalk.bold('AppVersion:')} ${tag} badge generated!
${chalk.cyan(readmeCode)}
`))
printReadme(readmeCode, 'status')
}
}
function printReadme (code, tag) {
console.log(chalk.green(`\n${chalk.bold('AppVersion:')} ${tag} badge generated!
${chalk.cyan(code)}
`))
}
exports.createBadge = createBadge

@@ -6,4 +6,4 @@ 'use strict'

// apv parameters and functions
exports.apvVersion = '1.7.0'
exports.apvVersion = '1.7.1'
exports.JSON_FILE = 'appversion.json'
exports.JSON_FILE_DEFAULT = resolve(__dirname, '../', 'appversion.default.json')

@@ -21,2 +21,9 @@ 'use strict'

let obj = readJson(JSON_FILE)
let previousObj = {
version: {
major: obj.version.major,
minor: obj.version.minor,
patch: obj.version.patch
}
}
param = semver.clean(param)

@@ -35,3 +42,3 @@ if (!semver.valid(param)) {

writeOtherJson(`${version[0]}.${version[1]}.${version[2]}`)
createBadge('version', true)
createBadge('version', true, previousObj)
}

@@ -46,2 +53,8 @@

let obj = readJson(JSON_FILE)
let previousObj = {
status: {
stage: obj.status.stage,
number: obj.status.number
}
}
let status = param.split('.')

@@ -61,3 +74,3 @@ if (status[1] && !check('Number', Number(status[1]))) {

writeJson(obj, chalk.green(`\n${chalk.bold('AppVersion:')} Status updated to ${status[0]}.${status[1] || 0}\n`))
createBadge('status', true)
createBadge('status', true, previousObj)
}

@@ -64,0 +77,0 @@

@@ -41,2 +41,9 @@ 'use strict'

let obj = readJson(JSON_FILE)
let previousObj = {
version: {
major: obj.version.major,
minor: obj.version.minor,
patch: obj.version.patch
}
}
obj.version[param]++

@@ -49,3 +56,3 @@ if (param === 'major') obj.version.minor = obj.version.patch = 0

writeOtherJson(`${obj.version.major}.${obj.version.minor}.${obj.version.patch}`)
createBadge('version', true)
createBadge('version', true, previousObj)
}

@@ -52,0 +59,0 @@

@@ -8,2 +8,4 @@ 'use strict'

const walk = require('walk')
const replaceStream = require('replacestream')
const selfStream = require('self-stream')
// apv parameters and functions

@@ -15,21 +17,11 @@ const JSON_FILE = require('./parameters').JSON_FILE

* Search and updates the badge in a .md file.
* @param {String} url [The new url]
* @param {String} markdownFile [The name of the .md file]
* @param {String} tag [version or status tag]
* @param {String} getParam [parameter to put at the end of the url]
* @param {String} newBadge [new badge to append]
* @param {String} oldBadge [old badge to change]
*/
function appendBadgeToMD (url, markdownFile, tag, getParam) {
if (!check('String', url) || !check('String', markdownFile) || !check('String', tag) || !check('String', getParam)) return
try {
fs.readFile(resolve('./', markdownFile), 'utf8', (err, data) => {
if (err) console.log(err)
// if the badge not exist in the .md file
if (data.substring(0, data.indexOf(tag)) === -1) return
// update .md file
let apvBadge = `${data.substring(0, data.indexOf(tag))}${tag}(${url})]${data.substring(data.indexOf('(https://github.com/delvedor/appversion' + getParam + ')'))}`
fs.writeFile(resolve('./', markdownFile), apvBadge, (err) => { if (err) console.log(err) })
})
} catch (err) {
console.log(err)
}
function appendBadgeToMD (markdownFile, newBadge, oldBadge) {
const transform = [replaceStream(oldBadge, newBadge)]
selfStream(markdownFile, transform, (err) => {
if (err) console.log(err)
})
}

@@ -36,0 +28,0 @@

{
"name": "appversion",
"version": "1.7.0",
"version": "1.7.1",
"description": "AppVersion is a CLI tool whose purpose is to provide a unique manager of the version of you application.",

@@ -45,3 +45,5 @@ "main": "appversion.js",

"minimist": "^1.2.0",
"replacestream": "^4.0.0",
"request": "^2.69.0",
"self-stream": "^1.0.0",
"semver": "^5.1.0",

@@ -48,0 +50,0 @@ "type-check": "^0.3.2",

# AppVersion <a name="version"></a><a name="status"></a>
[![AppVersion-version](https://img.shields.io/badge/AppVersion-1.7.0-brightgreen.svg?style=flat)](https://github.com/delvedor/appversion?#version) [![AppVersion-status](https://img.shields.io/badge/Status-RC-brightgreen.svg?style=flat)](https://github.com/delvedor/appversion?#status) [![Build Status](https://travis-ci.org/delvedor/appversion.svg?branch=master)](https://travis-ci.org/delvedor/appversion) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![AppVersion-version](https://img.shields.io/badge/AppVersion-1.7.1-brightgreen.svg?style=flat)](https://github.com/delvedor/appversion?#version) [![AppVersion-status](https://img.shields.io/badge/Status-RC-brightgreen.svg?style=flat)](https://github.com/delvedor/appversion?#status) [![Build Status](https://travis-ci.org/delvedor/appversion.svg?branch=master)](https://travis-ci.org/delvedor/appversion) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)

@@ -141,5 +141,5 @@ **AppVersion** is a CLI tool whose purpose is to provide a **unique manager** of the version of you application.

|:------------|:-----------------|
| **M | B** | version.major |
| **m | F** | version.minor |
| **p | f** | version.patch |
| **M \ B** | version.major |
| **m \ F** | version.minor |
| **p \ f** | version.patch |
| **S** | status.stage |

@@ -212,3 +212,3 @@ | **s** | status.number |

If you are using Grunt or Gulp for automating your project, you can easily use AppVersion inside you grunt/gulp file.
Just require **appversion/automation** and call the `update|setVersion|setStatus` method with the correct parameter.
Just require **appversion/automation** and call the `update|setVersion|setStatus` methods with the correct parameter.
Below you can find an example:

@@ -236,3 +236,3 @@ ```javascript

- [x] Add aliases: patch>fix, minor>feature major>breaking
- [ ] Rewrite appendBadgeToMD with streams
- [x] Rewrite appendBadgeToMD with streams
- [ ] SHA generator

@@ -239,0 +239,0 @@

@@ -1,10 +0,1 @@

/*
* Project: appversion
* Version: 1.7.0
* Author: delvedor
* Twitter: @delvedor
* License: MIT
* GitHub: https://github.com/delvedor/appversion
*/
'use strict'

@@ -154,3 +145,3 @@

${readmeCode}
\n`
\n`
t.equal(stdout, expectedOutput, 'Generate version badge works correctly!')

@@ -168,3 +159,3 @@ })

${readmeCode}
\n`
\n`
t.equal(stdout, expectedOutput, 'Generate status badge works correctly!')

@@ -171,0 +162,0 @@ })

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc