mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2025-09-02 14:39:18 +00:00
Compare commits
7 Commits
build-0c8e
...
build-2576
Author | SHA1 | Date | |
---|---|---|---|
25767eecb2 | |||
603da9a021 | |||
b43016bb24 | |||
4c4845803d | |||
4ec7d3847f | |||
2bbfe99ff4 | |||
881d268ea9 |
17
.github/workflows/build.yml
vendored
Normal file
17
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
on: [push]
|
||||
|
||||
name: Build
|
||||
|
||||
jobs:
|
||||
build-ubuntu:
|
||||
name: Commit release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Build
|
||||
run: ./gradlew build packageUberJarForCurrentOS
|
13
.github/workflows/commit-release.yml
vendored
13
.github/workflows/commit-release.yml
vendored
@@ -1,4 +1,7 @@
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
name: Commit release
|
||||
|
||||
@@ -16,7 +19,13 @@ jobs:
|
||||
- name: Set version from gradle.properties
|
||||
run: echo "version=` cat gradle.properties | grep ^version= | grep -o [\\.0-9]* `" >> $GITHUB_ENV
|
||||
- name: Build
|
||||
run: ./gradlew packageUberJarForCurrentOS
|
||||
run: ./gradlew build packageUberJarForCurrentOS
|
||||
- name: Publish Web
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./web/build/distributions
|
||||
publish_branch: site
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
|
@@ -22,14 +22,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/")
|
||||
|
@@ -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
|
||||
}
|
@@ -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()
|
||||
|
@@ -1,16 +1,81 @@
|
||||
package dev.inmo.kmppscriptbuilder.web
|
||||
|
||||
import dev.inmo.kmppscriptbuilder.core.models.Config
|
||||
import dev.inmo.kmppscriptbuilder.core.utils.serialFormat
|
||||
import dev.inmo.kmppscriptbuilder.web.views.*
|
||||
import kotlinx.browser.document
|
||||
import kotlinx.dom.appendElement
|
||||
import org.w3c.dom.*
|
||||
import org.w3c.dom.url.URL
|
||||
import org.w3c.files.*
|
||||
|
||||
fun saveFile(content: String, filename: String) {
|
||||
val a = document.body!!.appendElement("a") {
|
||||
setAttribute("style", "visibility:hidden; display: none")
|
||||
} as HTMLAnchorElement
|
||||
val blob = Blob(arrayOf(content), BlobPropertyBag(
|
||||
"application/*;charset=utf-8"
|
||||
))
|
||||
val url = URL.createObjectURL(blob)
|
||||
a.href = url
|
||||
a.download = filename
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
a.remove()
|
||||
}
|
||||
|
||||
fun main() {
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
{
|
||||
val builderView = BuilderView()
|
||||
document.body ?.onclick = {
|
||||
println(builderView.config)
|
||||
Unit
|
||||
|
||||
(document.getElementById("openConfig") as HTMLElement).onclick = {
|
||||
val targetInput = document.body!!.appendElement("input") {
|
||||
setAttribute("style", "visibility:hidden; display: none")
|
||||
} as HTMLInputElement
|
||||
targetInput.type = "file"
|
||||
targetInput.onchange = {
|
||||
targetInput.files ?.also { files ->
|
||||
for (i in (0 until files.length) ) {
|
||||
files[i] ?.also { file ->
|
||||
val reader = FileReader()
|
||||
|
||||
reader.onload = {
|
||||
val content = it.target.asDynamic().result as String
|
||||
builderView.config = serialFormat.decodeFromString(Config.serializer(), content)
|
||||
false
|
||||
}
|
||||
|
||||
reader.readAsText(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetInput.click()
|
||||
targetInput.remove()
|
||||
false
|
||||
}
|
||||
(document.getElementById("saveConfig") as HTMLElement).onclick = {
|
||||
val filename = "publish.kpsb"
|
||||
val content = serialFormat.encodeToString(Config.serializer(), builderView.config)
|
||||
|
||||
saveFile(content, filename)
|
||||
|
||||
false
|
||||
}
|
||||
(document.getElementById("exportScript") as HTMLElement).onclick = {
|
||||
val filename = "publish.gradle"
|
||||
|
||||
val content = builderView.config.run {
|
||||
type.buildMavenGradleConfig(
|
||||
mavenConfig,
|
||||
licenses
|
||||
)
|
||||
}
|
||||
|
||||
saveFile(content, filename)
|
||||
false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@@ -10,11 +10,13 @@
|
||||
<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">
|
||||
<li uk-tooltip="title: Open file"><a href="#"><span uk-icon="icon: pull"></span></a></li><!--Open file-->
|
||||
<li uk-tooltip="title: Save file"><a href="#"><span uk-icon="icon: push"></span></a></li><!--Save file-->
|
||||
<li uk-tooltip="title: Open config" id="openConfig"><a href="#"><span uk-icon="icon: pull"></span></a></li><!--Open file-->
|
||||
<li uk-tooltip="title: Save config" id="saveConfig"><a href="#"><span uk-icon="icon: push"></span></a></li><!--Save file-->
|
||||
<li uk-tooltip="title: Export script" id="exportScript"><a href="#"><span uk-icon="icon: upload"></span></a></li><!--Save file-->
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
Reference in New Issue
Block a user