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 {
|
||||
companion object {
|
||||
// Non-colors failure
|
||||
fun alt(failed: Boolean): String {
|
||||
if (failed) {
|
||||
return " [FAILED]"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// Match failure option in set
|
||||
fun isFail(failOn: Set<Fail>, match: Fail): Boolean {
|
||||
return failOn.contains(match)
|
||||
|
|
|
@ -231,10 +231,10 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
val sv_count = o.get("sv_count").asInt
|
||||
|
||||
// Sets deps, license and security failures
|
||||
val isFailDeps = Utils.isFail(config.failSet, Fail.dependenciesCheck)
|
||||
val isFailLicense = Utils.isFail(config.failSet, Fail.licensesCheck)
|
||||
val isFailUnknown = Utils.isFail(config.failSet, Fail.licensesUnknownCheck)
|
||||
val isFailSecurity = Utils.isFail(config.failSet, Fail.securityCheck)
|
||||
val isFailDeps = Utils.isFail(config.failSet, Fail.dependenciesCheck) && out_number > 0
|
||||
val isFailLicense = Utils.isFail(config.failSet, Fail.licensesCheck) && licenses_red > 0
|
||||
val isFailUnknown = Utils.isFail(config.failSet, Fail.licensesUnknownCheck) && licenses_unknown > 0
|
||||
val isFailSecurity = Utils.isFail(config.failSet, Fail.securityCheck) && sv_count > 0
|
||||
|
||||
// Unknown dependencies
|
||||
var unknownDeps = 0
|
||||
|
@ -258,14 +258,14 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
depsInfo.append(lf)
|
||||
}
|
||||
unknownDeps++
|
||||
depsInfo.append(
|
||||
Utils.redLight(" - $depName -> UNKNOWN", unknownDeps, false, config.colors))
|
||||
depsInfo.append(Utils.redLight(" - $depName -> UNKNOWN", unknownDeps, false, config.colors))
|
||||
} else if (dep.get("outdated").asBoolean) {
|
||||
if (depsInfo.isNotEmpty()) {
|
||||
depsInfo.append(lf)
|
||||
}
|
||||
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
|
||||
|
@ -297,7 +297,8 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
licensesInfo.append(lf)
|
||||
}
|
||||
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
|
||||
|
@ -306,7 +307,8 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
licensesInfo.append(lf)
|
||||
}
|
||||
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
|
||||
|
@ -318,28 +320,27 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
val count = security.asJsonArray.size()
|
||||
|
||||
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
|
||||
val verbose = (KobaltLogger.LOG_LEVEL > 1 || config.verbose)
|
||||
val alt = " [FAILED]"
|
||||
|
||||
// Log dependencies check results
|
||||
log(1, " Dependencies: "
|
||||
+ Utils.redLight(out_number, isFailDeps, config.colors) + " outdated. "
|
||||
+ 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)
|
||||
|
||||
// Log licenses check results
|
||||
log(1, " Licenses: "
|
||||
+ Utils.redLight(licenses_red, isFailLicense, config.colors)
|
||||
+ " whitelist. "
|
||||
+ Utils.redLight(licenses_red, isFailLicense, config.colors) + " whitelist. "
|
||||
+ Utils.redLight(licenses_unknown, isFailUnknown, config.colors)
|
||||
+ Utils.plural(" unknown", licenses_unknown, "s.", ".")
|
||||
+ if ((isFailLicense || isFailUnknown) && !config.colors) alt else "")
|
||||
+ Utils.alt((isFailLicense || isFailUnknown) && !config.colors))
|
||||
Utils.log(licensesInfo, verbose)
|
||||
|
||||
// Log security check results
|
||||
|
@ -347,7 +348,7 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
+ Utils.redLight(sv_count, isFailSecurity, config.colors)
|
||||
+ ' '
|
||||
+ Utils.plural("vulnerabilit", sv_count, "ies.", "y.")
|
||||
+ if (isFailSecurity && !config.colors) alt else "")
|
||||
+ Utils.alt(isFailSecurity && !config.colors))
|
||||
Utils.log(securityInfo, verbose)
|
||||
|
||||
// Show project url
|
||||
|
@ -356,10 +357,7 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
|
|||
}
|
||||
|
||||
// Task failure
|
||||
if (out_number > 0 && isFailDeps
|
||||
|| licenses_red > 0 && isFailLicense
|
||||
|| licenses_unknown > 0 && isFailUnknown
|
||||
|| sv_count > 0 && isFailSecurity) {
|
||||
if (isFailDeps || isFailLicense || isFailUnknown || isFailSecurity) {
|
||||
return TaskResult(false)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue