Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Commit 63d371b

Browse files
authored
Merge pull request #5 from Ingwersaft/enable-new-deployments
enable newly deployed deployment if it is disabled implementing #3
2 parents cb13367 + bafe051 commit 63d371b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
77
import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer.id
88

99
group = "com.mkring.wildlydeplyplugin"
10-
version = "0.2.6"
10+
version = "0.2.7-SNAPSHOT"
1111

1212
plugins {
1313
kotlin("jvm") version "1.2.61"

src/main/kotlin/com/mkring/wildlydeplyplugin/FileDeployer.kt

+20-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class FileDeployer(
1414
val file: String?, val host: String, val port: Int, val user: String?, val password: String?,
1515
val reload: Boolean, val force: Boolean, val name: String?, val runtimeName: String?, val awaitReload: Boolean
1616
) {
17-
1817
fun deploy() {
1918
println("deploy(): " + this)
2019
checkHostDns()
@@ -41,6 +40,9 @@ class FileDeployer(
4140
println("given $file existent: ${File(file).isFile}")
4241
val deploySuccess = cli.cmd("deploy $force $name $runtimeName $file").isSuccess
4342
println("deploy success: $deploySuccess")
43+
44+
enableDeploymentIfNecessary(name)
45+
4446
if (reload) {
4547
try {
4648
val reloadSuccess = cli.cmd("reload").isSuccess
@@ -61,6 +63,23 @@ class FileDeployer(
6163

6264
}
6365

66+
private fun enableDeploymentIfNecessary(name: String) {
67+
println("\nchecking if deployment is enabled...")
68+
val deploymentEnabled =
69+
blockingCmd("deployment-info", 2, ChronoUnit.MINUTES).response.get("result").asList().map {
70+
it.asProperty().name to it.getParam("enabled").removePrefix("enabled: ")
71+
}.firstOrNull {
72+
it.first == name.removePrefix("--name=")
73+
}?.second?.toBoolean()
74+
75+
if (deploymentEnabled == false) {
76+
println("not enabled! going to enable now!")
77+
blockingCmd("deploy $name", 2, ChronoUnit.MINUTES).response.also {
78+
println("enable response: $it\n")
79+
}
80+
}
81+
}
82+
6483
private fun connect(cli: CLI) {
6584
cli.connect(host, port, user, password?.toCharArray())
6685
}

0 commit comments

Comments
 (0)