Skip to content

Commit 228905c

Browse files
committed
#1 Add resolution arg
1 parent 00eafb9 commit 228905c

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ npm i -g gradle-upgrade-interactive
3636

3737
Simply run `gradle-upgrade-interactive`.
3838

39+
```
40+
Options:
41+
--help Show help [boolean]
42+
--version Show version number [boolean]
43+
--resolution, -r Controls the dependency resolution strategy.
44+
Supported options:
45+
* release: selects the latest release
46+
* milestone: select the latest version being either a
47+
milestone or a release (default)
48+
* integration: selects the latest revision of the dependency
49+
module (such as SNAPSHOT) [string]
50+
```
51+
3952
## How it works
4053

4154
The [gradle-versions-plugin](https://github.com/ben-manes/gradle-versions-plugin) is called to generate a JSON report containing the outdated dependencies.

index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#! /usr/bin/env node
2+
var argv = require('yargs')
3+
.option('resolution', {
4+
alias: 'r',
5+
describe: 'Controls the dependency resolution strategy.\nSupported options:\n* release: selects the latest release\n* milestone: select the latest version being either a milestone or a release (default)\n* integration: selects the latest revision of the dependency module (such as SNAPSHOT)',
6+
type: 'string',
7+
nargs: 1,
8+
demand: false
9+
}).argv
210

311
const prompts = require('prompts');
412
const fs = require('fs');
@@ -32,7 +40,13 @@ if (!gradleCommand) {
3240

3341
console.log('Checking for upgrades')
3442

35-
const gdu = spawnSync(gradleCommand, ['dependencyUpdates', '-Drevision=release', '-DoutputFormatter=json', '-DoutputDir=build/dependencyUpdates']);
43+
const gduArgs = ['dependencyUpdates', '-DoutputFormatter=json', '-DoutputDir=build/dependencyUpdates']
44+
const gduResolution = argv.resolution
45+
if (gduResolution) {
46+
gduArgs.push(`-Drevision=${gduResolution}`)
47+
}
48+
49+
const gdu = spawnSync(gradleCommand, gduArgs);
3650

3751
if (gdu.status !== 0) {
3852
console.log(`Error executing gradle dependency updates (StatusCode=${gdu.status}), have you installed the gradle versions plugin?`)
@@ -45,9 +59,9 @@ if (gdu.status !== 0) {
4559
const upgradeReport = fs.readFileSync('build/dependencyUpdates/report.json');
4660
let dependencyUpdates = JSON.parse(upgradeReport);
4761
let outdatedDependencies = dependencyUpdates.outdated.dependencies
48-
62+
4963
let choices = outdatedDependencies.map(it => {
50-
const newVersion = it.available.release
64+
const newVersion = it.available.release || it.available.milestone || it.available.integration
5165
return { description: `Group ${it.group}`, title: `${it.name} - ${it.version} => ${newVersion}`, value: { group: it.group, name: it.name, oldVersion: it.version, version: newVersion } }
5266
})
5367

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"test": "jest"
1717
},
1818
"dependencies": {
19-
"prompts": "^2.2.1"
19+
"prompts": "^2.2.1",
20+
"yargs": "^14.0.0"
2021
},
2122
"devDependencies": {
2223
"jest": "^24.9.0"

yarn.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3512,3 +3512,20 @@ yargs@^13.3.0:
35123512
which-module "^2.0.0"
35133513
y18n "^4.0.0"
35143514
yargs-parser "^13.1.1"
3515+
3516+
yargs@^14.0.0:
3517+
version "14.0.0"
3518+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.0.0.tgz#ba4cacc802b3c0b3e36a9e791723763d57a85066"
3519+
integrity sha512-ssa5JuRjMeZEUjg7bEL99AwpitxU/zWGAGpdj0di41pOEmJti8NR6kyUIJBkR78DTYNPZOU08luUo0GTHuB+ow==
3520+
dependencies:
3521+
cliui "^5.0.0"
3522+
decamelize "^1.2.0"
3523+
find-up "^3.0.0"
3524+
get-caller-file "^2.0.1"
3525+
require-directory "^2.1.1"
3526+
require-main-filename "^2.0.0"
3527+
set-blocking "^2.0.0"
3528+
string-width "^3.0.0"
3529+
which-module "^2.0.0"
3530+
y18n "^4.0.0"
3531+
yargs-parser "^13.1.1"

0 commit comments

Comments
 (0)