Compare commits

...

9 Commits

Author SHA1 Message Date
7c50c58a90 fix 2021-05-01 20:22:12 +06:00
ceff1eb1ef updates 2021-05-01 20:12:06 +06:00
46d6d429bb one more fix for web 2021-03-14 21:53:26 +06:00
dd9e71c9a2 fix in web view for loading of config 2021-03-14 21:46:41 +06:00
6d2ffb8a6e Update gradle.properties 2021-03-12 00:11:37 +06:00
25767eecb2 add github badge onto web version 2021-03-02 17:19:17 +06:00
603da9a021 fixes in saves 2021-03-02 16:51:08 +06:00
b43016bb24 repositories properties now checked 2021-03-02 16:45:46 +06:00
4c4845803d Merge pull request #3 from InsanusMokrassar/rewrite_with_web
add and web target
2021-03-02 14:11:38 +06:00
9 changed files with 56 additions and 23 deletions

View File

@@ -2,6 +2,9 @@ package dev.inmo.kmppscriptbuilder.core.models
import kotlinx.serialization.Serializable
const val defaultProjectName = "\${project.name}"
const val defaultProjectDescription = "\${project.name}"
@Serializable
data class MavenConfig(
val name: String,
@@ -22,14 +25,20 @@ data class MavenPublishingRepository(
name.toUpperCase()
}
fun build(indent: String) = """maven {
name = "$name"
url = uri("$url")
credentials {
username = project.hasProperty('${nameCapitalized}_USER') ? project.property('${nameCapitalized}_USER') : System.getenv('${nameCapitalized}_USER')
password = project.hasProperty('${nameCapitalized}_PASSWORD') ? project.property('${nameCapitalized}_PASSWORD') : System.getenv('${nameCapitalized}_PASSWORD')
fun build(indent: String): String {
val usernameProperty = "${nameCapitalized}_USER"
val passwordProperty = "${nameCapitalized}_PASSWORD"
return """if ((project.hasProperty('${usernameProperty}') || System.getenv('${usernameProperty}') != null) && (project.hasProperty('${passwordProperty}') || System.getenv('${passwordProperty}') != null)) {
maven {
name = "$name"
url = uri("$url")
credentials {
username = project.hasProperty('${usernameProperty}') ? project.property('${usernameProperty}') : System.getenv('${usernameProperty}')
password = project.hasProperty('${passwordProperty}') ? project.property('${passwordProperty}') : System.getenv('${passwordProperty}')
}
}
}""".replace("\n", "\n$indent")
}
}
val SonatypeRepository = MavenPublishingRepository("sonatype", "https://oss.sonatype.org/service/local/staging/deploy/maven2/")

View File

@@ -0,0 +1,18 @@
package dev.inmo.kmppscriptbuilder.desktop.utils
import java.awt.Desktop
import java.lang.Exception
import java.net.URI
fun openLink(link: String): Boolean {
val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI(link))
return true
} catch (e: Exception) {
e.printStackTrace()
}
}
return false
}

View File

@@ -6,10 +6,18 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.DesktopPlatform
import androidx.compose.ui.res.loadSvgResource
import androidx.compose.ui.res.svgResource
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import dev.inmo.kmppscriptbuilder.core.models.Config
import dev.inmo.kmppscriptbuilder.desktop.utils.*
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
import java.awt.Desktop
import java.lang.Exception
import java.net.URL
class BuilderView : View() {
private val projectTypeView = ProjectTypeView()

View File

@@ -2,8 +2,7 @@ package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.runtime.*
import dev.inmo.kmppscriptbuilder.core.models.MavenConfig
import dev.inmo.kmppscriptbuilder.core.models.SonatypeRepository
import dev.inmo.kmppscriptbuilder.core.models.*
import dev.inmo.kmppscriptbuilder.desktop.utils.*
class MavenInfoView : VerticalView("Project information") {
@@ -18,8 +17,8 @@ class MavenInfoView : VerticalView("Project information") {
var mavenConfig: MavenConfig
get() = MavenConfig(
projectNameProperty,
projectDescriptionProperty,
projectNameProperty.ifBlank { defaultProjectName },
projectDescriptionProperty.ifBlank { defaultProjectDescription },
projectUrlProperty,
projectVcsUrlProperty,
includeGpgSignProperty,

View File

@@ -6,13 +6,13 @@ kotlin.incremental.js=true
android.useAndroidX=true
android.enableJetifier=true
kotlin_version=1.4.30
kotlin_coroutines_version=1.4.2
kotlin_version=1.4.31
kotlin_coroutines_version=1.4.3
kotlin_serialisation_core_version=1.1.0
ktor_version=1.5.1
micro_utils_version=0.4.27
ktor_version=1.5.2
micro_utils_version=0.4.36
compose_version=0.3.0
compose_version=0.3.2
# ANDROID

View File

@@ -14,12 +14,11 @@ fun saveFile(content: String, filename: String) {
setAttribute("style", "visibility:hidden; display: none")
} as HTMLAnchorElement
val blob = Blob(arrayOf(content), BlobPropertyBag(
"text/plain;charset=utf-8"
"application/*;charset=utf-8"
))
val url = URL.createObjectURL(blob)
a.href = url
a.download = filename
a.target = "_blank"
a.click()
URL.revokeObjectURL(url)
a.remove()

View File

@@ -1,7 +1,6 @@
package dev.inmo.kmppscriptbuilder.web.views
import dev.inmo.kmppscriptbuilder.core.models.MavenConfig
import dev.inmo.kmppscriptbuilder.core.models.SonatypeRepository
import dev.inmo.kmppscriptbuilder.core.models.*
import kotlinx.browser.document
import org.w3c.dom.HTMLElement
import org.w3c.dom.HTMLInputElement
@@ -18,8 +17,8 @@ class MavenProjectInfoView : View {
var mavenConfig: MavenConfig
get() = MavenConfig(
nameElement.value,
descriptionElement.value,
nameElement.value.ifBlank { defaultProjectName },
descriptionElement.value.ifBlank { defaultProjectDescription },
urlElement.value,
vcsUrlElement.value,
includeGpgElement.checked,
@@ -39,6 +38,6 @@ class MavenProjectInfoView : View {
developersView.developers = value.developers
val reposWithoutSonatype = value.repositories.filter { it != SonatypeRepository }
includeMavenCentralElement.checked = value.repositories.size != reposWithoutSonatype.size
repositoriesView.repositories = value.repositories
repositoriesView.repositories = reposWithoutSonatype
}
}

View File

@@ -21,7 +21,7 @@ class RepositoriesView(rootElement: HTMLElement) : MutableListView<MavenPublishi
override fun HTMLElement.addContentBeforeRemoveButton(value: MavenPublishingRepository) {
createTextField("Repository name", "This name will be used to identify repository in grade").value = value.name
createTextField("Repository URL", "For example: https://repo.maven.apache.org/maven2/").value = value.name
createTextField("Repository URL", "For example: https://repo.maven.apache.org/maven2/").value = value.url
}
override fun HTMLElement.updateElement(from: MavenPublishingRepository, to: MavenPublishingRepository) {

View File

@@ -10,6 +10,7 @@
<nav class="uk-navbar-container" uk-navbar>
<div class="uk-navbar-left">
<div class="uk-padding-small uk-text-lead">Kotlin Publication Scripts Builder</div>
<div class="uk-padding-small"><a href="https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder"><img src="https://img.shields.io/github/stars/InsanusMokrassar/KotlinPublicationScriptsBuilder?label=Github&style=plastic"/></a></div>
</div>
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">