mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2024-11-27 04:28:53 +00:00
temporal state
This commit is contained in:
parent
aa1756724a
commit
7aa30ef46c
2
.github/workflows/commit-release.yml
vendored
2
.github/workflows/commit-release.yml
vendored
@ -17,8 +17,6 @@ jobs:
|
|||||||
run: echo "version=` cat gradle.properties | grep ^version= | grep -o [\\.0-9]* `" >> $GITHUB_ENV
|
run: echo "version=` cat gradle.properties | grep ^version= | grep -o [\\.0-9]* `" >> $GITHUB_ENV
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew packageUberJarForCurrentOS
|
run: ./gradlew packageUberJarForCurrentOS
|
||||||
env:
|
|
||||||
additional_version: ""
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
project.version = "$version" + System.getenv("additional_version")
|
project.version = "$version" + (System.getenv("additional_version") != null ? System.getenv("additional_version") : "")
|
||||||
project.group = "$group"
|
project.group = "$group"
|
||||||
|
|
||||||
// apply from: "$publishGradlePath"
|
// apply from: "$publishGradlePath"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
project.version = "$version" + System.getenv("additional_version")
|
project.version = "$version" + (System.getenv("additional_version") != null ? System.getenv("additional_version") : "")
|
||||||
project.group = "$group"
|
project.group = "$group"
|
||||||
|
|
||||||
// apply from: "$publishGradlePath"
|
// apply from: "$publishGradlePath"
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
project.version = "$version" + System.getenv("additional_version")
|
project.version = "$version" + (System.getenv("additional_version") != null ? System.getenv("additional_version") : "")
|
||||||
project.group = "$group"
|
project.group = "$group"
|
||||||
|
|
||||||
// apply from: "$publishGradlePath"
|
// apply from: "$publishGradlePath"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
js (IR) {
|
js (IR) {
|
||||||
browser()
|
browser {
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,3 +4,14 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$mppJsProjectPresetPath"
|
apply from: "$mppJsProjectPresetPath"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation project(":kmppscriptbuilder.core")
|
||||||
|
implementation "dev.inmo:micro_utils.common:$micro_utils_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
15
web/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/web/main.kt
Normal file
15
web/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/web/main.kt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web
|
||||||
|
|
||||||
|
import dev.inmo.kmppscriptbuilder.web.views.MavenProjectInfoView
|
||||||
|
import dev.inmo.kmppscriptbuilder.web.views.ProjectTypeView
|
||||||
|
import kotlinx.browser.document
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
document.addEventListener(
|
||||||
|
"DOMContentLoaded",
|
||||||
|
{
|
||||||
|
val projectTypeView = ProjectTypeView()
|
||||||
|
val mavenInfoTypeView = MavenProjectInfoView()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.utils
|
||||||
|
|
||||||
|
import org.w3c.dom.HTMLElement
|
||||||
|
|
||||||
|
var HTMLElement.ukActive: Boolean
|
||||||
|
get() = classList.contains("uk-active")
|
||||||
|
set(value) {
|
||||||
|
if (value) {
|
||||||
|
classList.add("uk-active")
|
||||||
|
} else {
|
||||||
|
classList.remove("uk-active")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.views
|
||||||
|
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.Developer
|
||||||
|
import org.w3c.dom.*
|
||||||
|
|
||||||
|
class DevelopersView(rootElement: HTMLElement) : ListView<Developer>(rootElement, "Add developer", "Remove developer") {
|
||||||
|
private val HTMLElement.usernameElement: HTMLInputElement
|
||||||
|
get() = children[0] as HTMLInputElement
|
||||||
|
private val HTMLElement.nameElement: HTMLInputElement
|
||||||
|
get() = children[1] as HTMLInputElement
|
||||||
|
private val HTMLElement.emailElement: HTMLInputElement
|
||||||
|
get() = children[2] as HTMLInputElement
|
||||||
|
|
||||||
|
var developers: List<Developer>
|
||||||
|
get() = elements.values.map {
|
||||||
|
Developer(it.usernameElement.value, it.nameElement.value, it.emailElement.value)
|
||||||
|
}
|
||||||
|
set(value) {
|
||||||
|
data = value
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createPlainObject(): Developer = Developer("", "", "")
|
||||||
|
|
||||||
|
override fun HTMLElement.placeElement(value: Developer) {
|
||||||
|
createTextField("Developer ID", "Developer username").value = value.id
|
||||||
|
createTextField("Developer name", "").value = value.name
|
||||||
|
createTextField("Developer E-Mail", "").value = value.eMail
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun HTMLElement.updateElement(from: Developer, to: Developer) {
|
||||||
|
usernameElement.value = to.id
|
||||||
|
nameElement.value = to.name
|
||||||
|
emailElement.value = to.eMail
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.views
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.common.calculateDiff
|
||||||
|
import kotlinx.browser.document
|
||||||
|
import kotlinx.dom.appendElement
|
||||||
|
import org.w3c.dom.HTMLElement
|
||||||
|
|
||||||
|
abstract class ListView<T>(
|
||||||
|
private val rootElement: HTMLElement,
|
||||||
|
addButtonText: String = "Add",
|
||||||
|
private val removeButtonText: String = "Remove"
|
||||||
|
) : View {
|
||||||
|
protected val elements = mutableMapOf<T, HTMLElement>()
|
||||||
|
protected var data: List<T> = emptyList()
|
||||||
|
set(value) {
|
||||||
|
val old = field
|
||||||
|
field = value
|
||||||
|
val diff = old.calculateDiff(value)
|
||||||
|
diff.removed.forEach {
|
||||||
|
rootElement.removeChild(elements[it.value] ?: return@forEach)
|
||||||
|
}
|
||||||
|
diff.added.forEach {
|
||||||
|
val element = instantiateElement()
|
||||||
|
element.placeElement(it.value)
|
||||||
|
elements[it.value] = element
|
||||||
|
element.addRemoveButton(it.value)
|
||||||
|
}
|
||||||
|
diff.replaced.forEach { (old, new) ->
|
||||||
|
val element = elements[old.value] ?.also { it.updateElement(old.value, new.value) }
|
||||||
|
if (element == null) {
|
||||||
|
val newElement = instantiateElement()
|
||||||
|
newElement.placeElement(new.value)
|
||||||
|
elements[new.value] = newElement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
rootElement.createButton(addButtonText).apply {
|
||||||
|
onclick = {
|
||||||
|
data += createPlainObject()
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun createPlainObject(): T
|
||||||
|
protected abstract fun HTMLElement.placeElement(value: T)
|
||||||
|
protected abstract fun HTMLElement.updateElement(from: T, to: T)
|
||||||
|
|
||||||
|
private fun HTMLElement.addRemoveButton(value: T) {
|
||||||
|
createButton(removeButtonText).onclick = {
|
||||||
|
data = data.filter {
|
||||||
|
it != value
|
||||||
|
}
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private fun instantiateElement() = rootElement.appendElement("div") {
|
||||||
|
classList.add("uk-padding-small")
|
||||||
|
} as HTMLElement
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.views
|
||||||
|
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.MavenConfig
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.SonatypeRepository
|
||||||
|
import kotlinx.browser.document
|
||||||
|
import org.w3c.dom.HTMLElement
|
||||||
|
import org.w3c.dom.HTMLInputElement
|
||||||
|
|
||||||
|
class MavenProjectInfoView : View {
|
||||||
|
private val nameElement = document.getElementById("projectNameInput") as HTMLInputElement
|
||||||
|
private val descriptionElement = document.getElementById("projectDescriptionInput") as HTMLInputElement
|
||||||
|
private val urlElement = document.getElementById("projectUrlInput") as HTMLInputElement
|
||||||
|
private val vcsUrlElement = document.getElementById("projectVCSUrlInput") as HTMLInputElement
|
||||||
|
private val includeGpgElement = document.getElementById("includeGpgSignToggle") as HTMLInputElement
|
||||||
|
private val includeMavenCentralElement = document.getElementById("includeMavenCentralTargetRepoToggle") as HTMLInputElement
|
||||||
|
private val developersView = DevelopersView(document.getElementById("developersListDiv") as HTMLElement)
|
||||||
|
|
||||||
|
var mavenConfig: MavenConfig
|
||||||
|
get() = MavenConfig(
|
||||||
|
nameElement.value,
|
||||||
|
descriptionElement.value,
|
||||||
|
urlElement.value,
|
||||||
|
vcsUrlElement.value,
|
||||||
|
includeGpgElement.checked,
|
||||||
|
developersView.developers,// TODO:: Add developers
|
||||||
|
// TODO:: Add repositories
|
||||||
|
if (includeMavenCentralElement.checked) {
|
||||||
|
listOf(SonatypeRepository)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
set(value) {
|
||||||
|
nameElement.value = value.name
|
||||||
|
descriptionElement.value = value.description
|
||||||
|
urlElement.value = value.url
|
||||||
|
vcsUrlElement.value = value.vcsUrl
|
||||||
|
includeGpgElement.checked = value.includeGpgSigning
|
||||||
|
developersView.developers = value.developers
|
||||||
|
// TODO:: Add repositories
|
||||||
|
val reposWithoutSonatype = value.repositories.filter { it != SonatypeRepository }
|
||||||
|
includeMavenCentralElement.checked = value.repositories.size != reposWithoutSonatype.size
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.views
|
||||||
|
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.*
|
||||||
|
import dev.inmo.kmppscriptbuilder.web.utils.ukActive
|
||||||
|
import kotlinx.browser.document
|
||||||
|
import org.w3c.dom.HTMLElement
|
||||||
|
|
||||||
|
class ProjectTypeView : View {
|
||||||
|
private val mppProjectTypeElement = document.getElementById("mppProjectType") as HTMLElement
|
||||||
|
private val jvmProjectTypeElement = document.getElementById("jvmProjectType") as HTMLElement
|
||||||
|
|
||||||
|
var projectType: ProjectType
|
||||||
|
get() = if (jvmProjectTypeElement.ukActive) {
|
||||||
|
JVMProjectType
|
||||||
|
} else {
|
||||||
|
MultiplatformProjectType
|
||||||
|
}
|
||||||
|
set(value) {
|
||||||
|
mppProjectTypeElement.ukActive = value == MultiplatformProjectType
|
||||||
|
jvmProjectTypeElement.ukActive = value == JVMProjectType
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
mppProjectTypeElement.onclick = {
|
||||||
|
projectType = MultiplatformProjectType
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
jvmProjectTypeElement.onclick = {
|
||||||
|
projectType = JVMProjectType
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.views
|
||||||
|
|
||||||
|
interface View
|
@ -0,0 +1,30 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.web.views
|
||||||
|
|
||||||
|
import kotlinx.dom.appendElement
|
||||||
|
import org.w3c.dom.*
|
||||||
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
fun HTMLElement.createTextField(
|
||||||
|
label: String,
|
||||||
|
placeholder: String
|
||||||
|
): HTMLInputElement {
|
||||||
|
val uuid = "r" + Random.nextLong()
|
||||||
|
return appendElement("div") {
|
||||||
|
classList.add("uk-margin", "uk-width-1-1")
|
||||||
|
appendElement("label") {
|
||||||
|
classList.add("uk-form-label")
|
||||||
|
setAttribute("for", uuid)
|
||||||
|
innerText = label
|
||||||
|
}
|
||||||
|
}.appendElement("input") {
|
||||||
|
id = uuid
|
||||||
|
classList.add("uk-input", "uk-width-expand")
|
||||||
|
setAttribute("type", "text")
|
||||||
|
setAttribute("placeholder", placeholder)
|
||||||
|
} as HTMLInputElement
|
||||||
|
}
|
||||||
|
|
||||||
|
fun HTMLElement.createButton(text: String): HTMLButtonElement = appendElement("button") {
|
||||||
|
classList.add("uk-button", "uk-button-primary")
|
||||||
|
innerHTML = text
|
||||||
|
} as HTMLButtonElement
|
@ -66,8 +66,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<legend class="uk-legend">Developers info</legend>
|
<legend class="uk-legend">Developers info</legend>
|
||||||
<div class="uk-padding-small">
|
<div id="developersListDiv" class="uk-padding-small">
|
||||||
<button class="uk-button uk-button-primary">Add developer</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<legend class="uk-legend">Repositories info</legend>
|
<legend class="uk-legend">Repositories info</legend>
|
||||||
@ -79,5 +78,7 @@
|
|||||||
<!-- UIkit JS -->
|
<!-- UIkit JS -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/uikit@3.6.17/dist/js/uikit.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/uikit@3.6.17/dist/js/uikit.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/uikit@3.6.17/dist/js/uikit-icons.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/uikit@3.6.17/dist/js/uikit-icons.min.js"></script>
|
||||||
|
<!-- Internal JS -->
|
||||||
|
<script src="kmppscriptbuilder.web.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user