Skip to content

Commit e10596c

Browse files
committed
Ability to include specific semver version diffs
1 parent ed13d30 commit e10596c

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ Options:
4747
milestone or a release (default)
4848
* integration: selects the latest revision of the dependency
4949
module (such as SNAPSHOT) [string]
50+
--semver, -s Which semantic version diffs to include
51+
(https://semver.org). Flag can be used multiple times.
52+
Supported options:
53+
* major: Include upgrades with a major version change
54+
* minor: Include upgrades with a minor version change
55+
* patch: Include upgrades with a patch version change[array]
5056
--debug, -d Prints debugging information, such as commands executed and
5157
current status. [boolean] [Standard: false]
5258
--no-color Disables color output

index.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ const argv = require('yargs')
1010
nargs: 1,
1111
demand: false
1212
})
13+
.option('semver', {
14+
alias: 's',
15+
describe: 'Which semantic version diffs to include (https://semver.org). Flag can be used multiple times.\nSupported options:\n* major: Include upgrades with a major version change\n* minor: Include upgrades with a minor version change\n* patch: Include upgrades with a patch version change',
16+
type: 'string',
17+
array: true,
18+
nargs: 1,
19+
demand: false
20+
})
1321
.option('debug', {
1422
alias: 'd',
1523
describe: 'Prints debugging information, such as commands executed and current status.',
@@ -131,9 +139,9 @@ function debugLog (message) {
131139
const newVersion = it.available.release || it.available.milestone || it.available.integration
132140

133141
let title = `${it.name} - ${it.version} => ${newVersion}`
142+
let semverDiff = null
134143
try {
135-
136-
const semverDiff = semver.diff(oldVersion, newVersion)
144+
semverDiff = semver.diff(oldVersion, newVersion)
137145
if (semverDiff === 'patch') {
138146
title = title.green
139147
} else if (semverDiff === 'minor') {
@@ -154,11 +162,17 @@ function debugLog (message) {
154162
name: it.name,
155163
oldVersion: it.version,
156164
version: newVersion,
157-
projectUrl: it.projectUrl
165+
projectUrl: it.projectUrl,
166+
semverDiff: semverDiff
158167
}
159168
}
160169
})
161170

171+
const includeSemverDiffs = argv.semver
172+
if (includeSemverDiffs && includeSemverDiffs.length) {
173+
choices = choices.filter(it => !it.value.semverDiff || includeSemverDiffs.includes(it.value.semverDiff))
174+
}
175+
162176
choices.sort((a, b) => a.title.localeCompare(b.title))
163177

164178
debugLog(`Choices\n${JSON.stringify(choices)}\n\n`)
@@ -174,8 +188,8 @@ function debugLog (message) {
174188
})
175189
}
176190

177-
if (!outdatedDependencies.length) {
178-
console.info('Everything up to date.')
191+
if (!choices.length) {
192+
console.log('Everything up to date.')
179193
return
180194
}
181195

0 commit comments

Comments
 (0)