more re-organisation to new name
This commit is contained in:
parent
633e898f3c
commit
8c75b47a96
37 changed files with 219 additions and 197 deletions
|
|
@ -1,23 +1,15 @@
|
|||
import com.github.gradle.node.npm.task.NpmTask
|
||||
import dev.adamko.factoriowebmap.configurations.asConsumer
|
||||
import dev.adamko.factoriowebmap.configurations.asProvider
|
||||
import dev.adamko.factoriowebmap.configurations.factorioModAttributes
|
||||
import dev.adamko.factoriowebmap.configurations.typescriptAttributes
|
||||
import dev.adamko.kafkatorio.gradle.asConsumer
|
||||
import dev.adamko.kafkatorio.gradle.asProvider
|
||||
import dev.adamko.kafkatorio.gradle.factorioModAttributes
|
||||
import dev.adamko.kafkatorio.gradle.typescriptAttributes
|
||||
import groovy.json.JsonOutput
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import org.gradle.kotlin.dsl.support.useToRun
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
import org.jetbrains.kotlin.util.suffixIfNot
|
||||
|
||||
plugins {
|
||||
idea
|
||||
id("dev.adamko.factoriowebmap.archetype.node")
|
||||
id("dev.adamko.kafkatorio.lang.node")
|
||||
}
|
||||
|
||||
val tokens: Map<String, String> by project.extra
|
||||
|
|
@ -29,8 +21,7 @@ node {
|
|||
nodeProjectDir.set(tsSrcDir)
|
||||
}
|
||||
|
||||
|
||||
val dataModelTs by configurations.registering {
|
||||
val typescriptEventsSchema by configurations.registering {
|
||||
asConsumer()
|
||||
typescriptAttributes(objects)
|
||||
defaultDependencies {
|
||||
|
|
@ -38,7 +29,6 @@ val dataModelTs by configurations.registering {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
val typescriptToLua by tasks.registering(NpmTask::class) {
|
||||
description = "Convert Typescript To Lua"
|
||||
group = project.name
|
||||
|
|
@ -75,56 +65,14 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
|
||||
}
|
||||
|
||||
val updatePackageJsonVersion by tasks.registering {
|
||||
group = project.name
|
||||
description = """
|
||||
Read the package.json file and set the version to be the project's version.
|
||||
""".trimIndent()
|
||||
|
||||
val projectVersion = "${project.version}"
|
||||
inputs.properties(
|
||||
"projectVersion" to projectVersion,
|
||||
)
|
||||
|
||||
val packageJsonFile = layout.projectDirectory.file("src/main/typescript/package.json")
|
||||
outputs.file(packageJsonFile)
|
||||
|
||||
val jsonFormatter = Json {
|
||||
prettyPrint = true
|
||||
prettyPrintIndent = " "
|
||||
}
|
||||
|
||||
onlyIf {
|
||||
// check to see if the version is already up-to-date
|
||||
val packageJsonContent = packageJsonFile.asFile.readText()
|
||||
val packageJson = jsonFormatter.parseToJsonElement(packageJsonContent).jsonObject
|
||||
packageJson["version"]?.jsonPrimitive?.content != projectVersion
|
||||
}
|
||||
|
||||
doLast {
|
||||
val packageJsonContent = packageJsonFile.asFile.readText()
|
||||
val packageJson = jsonFormatter.parseToJsonElement(packageJsonContent).jsonObject
|
||||
val packageJsonUpdate = JsonObject(
|
||||
packageJson + ("version" to JsonPrimitive(projectVersion))
|
||||
)
|
||||
val packageJsonContentUpdated =
|
||||
jsonFormatter
|
||||
.encodeToString(packageJsonUpdate)
|
||||
.suffixIfNot("\n")
|
||||
packageJsonFile.asFile.writer().useToRun {
|
||||
write(packageJsonContentUpdated)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val updateDataModel by tasks.registering(Sync::class) {
|
||||
val fetchEventsSchema by tasks.registering(Sync::class) {
|
||||
group = project.name
|
||||
description = "Fetch the latest shared data-model"
|
||||
|
||||
dependsOn(dataModelTs)
|
||||
dependsOn(typescriptEventsSchema)
|
||||
|
||||
from(
|
||||
dataModelTs.map { c ->
|
||||
typescriptEventsSchema.map { c ->
|
||||
c.incoming
|
||||
.artifactView { lenient(true) }
|
||||
.artifacts
|
||||
|
|
@ -136,7 +84,6 @@ val updateDataModel by tasks.registering(Sync::class) {
|
|||
into(layout.projectDirectory.dir("src/main/typescript/model"))
|
||||
}
|
||||
|
||||
|
||||
val packageMod by tasks.registering(Zip::class) {
|
||||
description = "Package mod files into ZIP"
|
||||
group = project.name
|
||||
|
|
@ -204,8 +151,11 @@ val factorioModProvider by configurations.registering {
|
|||
outgoing.artifact(packageMod)
|
||||
}
|
||||
|
||||
tasks.updatePackageJson {
|
||||
propertiesToCheck["name"] = "${rootProject.name}-${project.name}"
|
||||
}
|
||||
|
||||
tasks.assemble { dependsOn(updateDataModel, updatePackageJsonVersion) }
|
||||
tasks.assemble { dependsOn(fetchEventsSchema, tasks.updatePackageJson) }
|
||||
tasks.build { dependsOn(packageMod) }
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,4 @@
|
|||
// import {Data, Mods} from "typed-factorio/settings/types"
|
||||
// import { events } from "typed-factorio/generated"
|
||||
|
||||
// declare const factorioData: Data
|
||||
// declare const factorioMods: Mods
|
||||
|
||||
|
||||
import {Serdes} from "./serdes/serdes"
|
||||
// import {FactorioEvent, JsonTable} from "./model/model";
|
||||
|
||||
|
||||
const MOD_VERSION = script.active_mods["factorio-web-map"]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "factorio-web-map-mod",
|
||||
"name": "kafkatorio-events",
|
||||
"version": "0.0.7",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue