|
1 | 1 | #! /usr/bin/env node
|
2 |
| -var colors = require('colors'); |
| 2 | +const colors = require('colors'); |
| 3 | +const semver = require('semver') |
3 | 4 |
|
4 |
| -var argv = require('yargs') |
| 5 | +const argv = require('yargs') |
5 | 6 | .option('resolution', {
|
6 | 7 | alias: 'r',
|
7 | 8 | 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)',
|
@@ -126,10 +127,28 @@ function debugLog (message) {
|
126 | 127 | debugLog(`Outdated dependencies parsed\n${JSON.stringify(outdatedDependencies)}\n\n`)
|
127 | 128 |
|
128 | 129 | let choices = outdatedDependencies.map(it => {
|
| 130 | + const oldVersion = it.version |
129 | 131 | const newVersion = it.available.release || it.available.milestone || it.available.integration
|
| 132 | + |
| 133 | + let title = `${it.name} - ${it.version} => ${newVersion}` |
| 134 | + try { |
| 135 | + |
| 136 | + const semverDiff = semver.diff(oldVersion, newVersion) |
| 137 | + if (semverDiff === 'patch') { |
| 138 | + title = title.green |
| 139 | + } else if (semverDiff === 'minor') { |
| 140 | + title = title.yellow |
| 141 | + } else if (semverDiff === 'major') { |
| 142 | + title = title.red |
| 143 | + } |
| 144 | + } catch (err) { |
| 145 | + debugLog(`Semver for ${title} cannot be diffed.`) |
| 146 | + debugLog(err) |
| 147 | + } |
| 148 | + |
130 | 149 | return {
|
131 | 150 | description: it.projectUrl,
|
132 |
| - title: `${it.name} - ${it.version} => ${newVersion}`, |
| 151 | + title: title, |
133 | 152 | value: {
|
134 | 153 | group: it.group,
|
135 | 154 | name: it.name,
|
@@ -164,7 +183,7 @@ function debugLog (message) {
|
164 | 183 | {
|
165 | 184 | type: 'multiselect',
|
166 | 185 | name: 'upgrades',
|
167 |
| - message: 'Pick upgrades', |
| 186 | + message: 'Pick upgrades\nColor explanation:\n' + 'Major-Version'.red + '\t' + 'Minor-Version'.yellow + '\t' + 'Patch-Version'.green, |
168 | 187 | choices: choices
|
169 | 188 | });
|
170 | 189 |
|
|
0 commit comments