mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2025-09-03 06:59:17 +00:00
Compare commits
2 Commits
build-0c8e
...
build-2bbf
Author | SHA1 | Date | |
---|---|---|---|
2bbfe99ff4 | |||
881d268ea9 |
8
.github/workflows/commit-release.yml
vendored
8
.github/workflows/commit-release.yml
vendored
@@ -16,7 +16,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
|
||||
|
@@ -1,16 +1,82 @@
|
||||
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(
|
||||
"text/plain;charset=utf-8"
|
||||
))
|
||||
val url = URL.createObjectURL(blob)
|
||||
a.href = url
|
||||
a.download = filename
|
||||
a.target = "_blank"
|
||||
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
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@@ -13,8 +13,9 @@
|
||||
</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