Fixed non-color output.
This commit is contained in:
parent
d5d63df08a
commit
3441ff0168
2 changed files with 27 additions and 20 deletions
|
@ -36,6 +36,15 @@ import com.beust.kobalt.misc.log
|
||||||
|
|
||||||
open class Utils {
|
open class Utils {
|
||||||
companion object {
|
companion object {
|
||||||
|
// Non-colors failure
|
||||||
|
fun alt(failed: Boolean): String {
|
||||||
|
if (failed) {
|
||||||
|
return " [FAILED]"
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// Match failure option in set
|
// Match failure option in set
|
||||||
fun isFail(failOn: Set<Fail>, match: Fail): Boolean {
|
fun isFail(failOn: Set<Fail>, match: Fail): Boolean {
|
||||||
return failOn.contains(match)
|
return failOn.contains(match)
|
||||||
|
|
|
@ -231,10 +231,10 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
val sv_count = o.get("sv_count").asInt
|
val sv_count = o.get("sv_count").asInt
|
||||||
|
|
||||||
// Sets deps, license and security failures
|
// Sets deps, license and security failures
|
||||||
val isFailDeps = Utils.isFail(config.failSet, Fail.dependenciesCheck)
|
val isFailDeps = Utils.isFail(config.failSet, Fail.dependenciesCheck) && out_number > 0
|
||||||
val isFailLicense = Utils.isFail(config.failSet, Fail.licensesCheck)
|
val isFailLicense = Utils.isFail(config.failSet, Fail.licensesCheck) && licenses_red > 0
|
||||||
val isFailUnknown = Utils.isFail(config.failSet, Fail.licensesUnknownCheck)
|
val isFailUnknown = Utils.isFail(config.failSet, Fail.licensesUnknownCheck) && licenses_unknown > 0
|
||||||
val isFailSecurity = Utils.isFail(config.failSet, Fail.securityCheck)
|
val isFailSecurity = Utils.isFail(config.failSet, Fail.securityCheck) && sv_count > 0
|
||||||
|
|
||||||
// Unknown dependencies
|
// Unknown dependencies
|
||||||
var unknownDeps = 0
|
var unknownDeps = 0
|
||||||
|
@ -258,14 +258,14 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
depsInfo.append(lf)
|
depsInfo.append(lf)
|
||||||
}
|
}
|
||||||
unknownDeps++
|
unknownDeps++
|
||||||
depsInfo.append(
|
depsInfo.append(Utils.redLight(" - $depName -> UNKNOWN", unknownDeps, false, config.colors))
|
||||||
Utils.redLight(" - $depName -> UNKNOWN", unknownDeps, false, config.colors))
|
|
||||||
} else if (dep.get("outdated").asBoolean) {
|
} else if (dep.get("outdated").asBoolean) {
|
||||||
if (depsInfo.isNotEmpty()) {
|
if (depsInfo.isNotEmpty()) {
|
||||||
depsInfo.append(lf)
|
depsInfo.append(lf)
|
||||||
}
|
}
|
||||||
depsInfo.append(Utils.redLight(" - $depName -> "
|
depsInfo.append(Utils.redLight(" - $depName -> "
|
||||||
+ curVer.asString, out_number, isFailDeps, config.colors))
|
+ curVer.asString, out_number, isFailDeps, config.colors)
|
||||||
|
+ Utils.alt(isFailDeps && !config.colors))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse licenses
|
// Parse licenses
|
||||||
|
@ -297,7 +297,8 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
licensesInfo.append(lf)
|
licensesInfo.append(lf)
|
||||||
}
|
}
|
||||||
licensesInfo.append(Utils.redLight(" - $depName: $whitelisted whitelist "
|
licensesInfo.append(Utils.redLight(" - $depName: $whitelisted whitelist "
|
||||||
+ Utils.plural("violation", whitelisted, "s"), whitelisted, isFailLicense, config.colors))
|
+ Utils.plural("violation", whitelisted, "s"), whitelisted, isFailLicense, config.colors)
|
||||||
|
+ Utils.alt(isFailLicense && !config.colors))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknowns
|
// Unknowns
|
||||||
|
@ -306,7 +307,8 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
licensesInfo.append(lf)
|
licensesInfo.append(lf)
|
||||||
}
|
}
|
||||||
licensesInfo.append(Utils.redLight(" - $depName: $unknowns "
|
licensesInfo.append(Utils.redLight(" - $depName: $unknowns "
|
||||||
+ Utils.plural("unknown license", unknowns, "s"), unknowns, isFailUnknown, config.colors))
|
+ Utils.plural("unknown license", unknowns, "s"), unknowns, isFailUnknown, config.colors)
|
||||||
|
+ Utils.alt(isFailUnknown && !config.colors))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security vulnerabilities
|
// Security vulnerabilities
|
||||||
|
@ -318,28 +320,27 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
val count = security.asJsonArray.size()
|
val count = security.asJsonArray.size()
|
||||||
|
|
||||||
securityInfo.append(Utils.redLight(" - $depName: $count "
|
securityInfo.append(Utils.redLight(" - $depName: $count "
|
||||||
+ Utils.plural("known issue", count, "s"), count, isFailSecurity, config.colors))
|
+ Utils.plural("known issue", count, "s"), count, isFailSecurity, config.colors)
|
||||||
|
+ Utils.alt(isFailSecurity && !config.colors))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Non-verbose failure
|
// Non-verbose failure
|
||||||
val verbose = (KobaltLogger.LOG_LEVEL > 1 || config.verbose)
|
val verbose = (KobaltLogger.LOG_LEVEL > 1 || config.verbose)
|
||||||
val alt = " [FAILED]"
|
|
||||||
|
|
||||||
// Log dependencies check results
|
// Log dependencies check results
|
||||||
log(1, " Dependencies: "
|
log(1, " Dependencies: "
|
||||||
+ Utils.redLight(out_number, isFailDeps, config.colors) + " outdated. "
|
+ Utils.redLight(out_number, isFailDeps, config.colors) + " outdated. "
|
||||||
+ Utils.redLight(unknownDeps, false, config.colors) + " unknown. $dep_number total."
|
+ Utils.redLight(unknownDeps, false, config.colors) + " unknown. $dep_number total."
|
||||||
+ if (isFailDeps && !config.colors) alt else "")
|
+ Utils.alt(isFailDeps && !config.colors))
|
||||||
Utils.log(depsInfo, verbose)
|
Utils.log(depsInfo, verbose)
|
||||||
|
|
||||||
// Log licenses check results
|
// Log licenses check results
|
||||||
log(1, " Licenses: "
|
log(1, " Licenses: "
|
||||||
+ Utils.redLight(licenses_red, isFailLicense, config.colors)
|
+ Utils.redLight(licenses_red, isFailLicense, config.colors) + " whitelist. "
|
||||||
+ " whitelist. "
|
|
||||||
+ Utils.redLight(licenses_unknown, isFailUnknown, config.colors)
|
+ Utils.redLight(licenses_unknown, isFailUnknown, config.colors)
|
||||||
+ Utils.plural(" unknown", licenses_unknown, "s.", ".")
|
+ Utils.plural(" unknown", licenses_unknown, "s.", ".")
|
||||||
+ if ((isFailLicense || isFailUnknown) && !config.colors) alt else "")
|
+ Utils.alt((isFailLicense || isFailUnknown) && !config.colors))
|
||||||
Utils.log(licensesInfo, verbose)
|
Utils.log(licensesInfo, verbose)
|
||||||
|
|
||||||
// Log security check results
|
// Log security check results
|
||||||
|
@ -347,7 +348,7 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
+ Utils.redLight(sv_count, isFailSecurity, config.colors)
|
+ Utils.redLight(sv_count, isFailSecurity, config.colors)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ Utils.plural("vulnerabilit", sv_count, "ies.", "y.")
|
+ Utils.plural("vulnerabilit", sv_count, "ies.", "y.")
|
||||||
+ if (isFailSecurity && !config.colors) alt else "")
|
+ Utils.alt(isFailSecurity && !config.colors))
|
||||||
Utils.log(securityInfo, verbose)
|
Utils.log(securityInfo, verbose)
|
||||||
|
|
||||||
// Show project url
|
// Show project url
|
||||||
|
@ -356,10 +357,7 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
||||||
}
|
}
|
||||||
|
|
||||||
// Task failure
|
// Task failure
|
||||||
if (out_number > 0 && isFailDeps
|
if (isFailDeps || isFailLicense || isFailUnknown || isFailSecurity) {
|
||||||
|| licenses_red > 0 && isFailLicense
|
|
||||||
|| licenses_unknown > 0 && isFailUnknown
|
|
||||||
|| sv_count > 0 && isFailSecurity) {
|
|
||||||
return TaskResult(false)
|
return TaskResult(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue