From 08ab1c582c100e31467510d2662720318066eb14 Mon Sep 17 00:00:00 2001
From: Adam <897017+aSemy@users.noreply.github.com>
Date: Tue, 28 Dec 2021 17:05:52 +0100
Subject: [PATCH] tidying up
---
build.gradle.kts | 2 +-
buildSrc/build.gradle.kts | 5 +-
.../kafkatorio/lang/kotlin-js.gradle.kts | 4 +-
.../kafkatorio/lang/kotlin-jvm.gradle.kts | 1 -
.../adamko/kafkatorio/lang/node.gradle.kts | 4 +
...w-to-run-npx-gradle-task-with-kotlin-js.md | 0
gradle/libs.versions.toml | 2 +-
modules/events-mod/build.gradle.kts | 34 +-----
.../events-mod/src/main/typescript/events.ts | 6 +-
.../src/main/typescript/package.json | 14 ++-
.../src/main/typescript/serdes/serdes.ts | 100 ++++++++----------
.../processor/FactorioEventLogConsumer.kt | 7 --
.../processor/FactorioEventsTopology.kt | 4 +-
.../kafkatorio/processor/WebsocketServer.kt | 2 +-
.../processor/config/ApplicationProperties.kt | 8 --
.../kafkatorio/processor/eventProcessor.kt | 15 +--
.../kafkatorio/events/schema/builtinTypes.kt | 98 -----------------
.../events/schema/factorioEvents.kt | 75 +++++--------
.../adamko/kafkatorio/events/schema/kt2ts.kt | 3 +
.../infra-factorio-client/build.gradle.kts | 2 +
.../infra-factorio-server/build.gradle.kts | 43 --------
.../factorioEvents.Dockerfile | 0
.../kafka-pipe.sh | 0
.../kcat.conf | 0
24 files changed, 105 insertions(+), 324 deletions(-)
rename asd.md => docs/notes/question-how-to-run-npx-gradle-task-with-kotlin-js.md (100%)
delete mode 100644 modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventLogConsumer.kt
delete mode 100644 modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/builtinTypes.kt
rename modules/infra-factorio-server/{src => factorio-and-kpipe-server}/factorioEvents.Dockerfile (100%)
rename modules/infra-factorio-server/{src => factorio-and-kpipe-server}/kafka-pipe.sh (100%)
rename modules/infra-factorio-server/{src => factorio-and-kpipe-server}/kcat.conf (100%)
diff --git a/build.gradle.kts b/build.gradle.kts
index 0ed4990..b67ca9a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,7 +6,7 @@ plugins {
}
group = "dev.adamko.kafkatorio"
-version = "0.1.5"
+version = "0.1.6"
val licenseFile: RegularFile by extra(layout.projectDirectory.file("LICENSE"))
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 2a694a2..6566320 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -15,7 +15,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
- val kotlinXSerializationVersion = "1.3.1"
+ val kotlinXSerializationVersion = "1.3.2"
implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-serialization-bom:$kotlinXSerializationVersion"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json")
@@ -24,6 +24,9 @@ dependencies {
implementation("com.github.node-gradle:gradle-node-plugin:3.1.1")
implementation("net.swiftzer.semver:semver:1.1.2")
+
+ // https://github.com/avast/gradle-docker-compose-plugin
+ implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.12")
}
val projectJvmTarget = "11"
diff --git a/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-js.gradle.kts b/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-js.gradle.kts
index 62c6d7b..4c11e6d 100644
--- a/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-js.gradle.kts
+++ b/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-js.gradle.kts
@@ -32,13 +32,13 @@ val rootPackageJson by rootProject.tasks.getting(RootPackageJsonTask::class)
val nodePath: Directory by extra {
val file = rootPackageJson.rootPackageJson.parentFile.normalize()
- logger.lifecycle("Kotlin/JS NODE_PATH: $file")
+ logger.info("Kotlin/JS NODE_PATH: $file")
project.layout.dir(project.provider { file }).get()
}
val nodeModulesDir: Directory by extra {
val file = nodePath.dir(NpmProject.NODE_MODULES)
- logger.lifecycle("Kotlin/JS NODE_MODULES: $file")
+ logger.info("Kotlin/JS NODE_MODULES: $file")
file
}
diff --git a/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-jvm.gradle.kts b/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-jvm.gradle.kts
index 122d74a..f3aa96e 100644
--- a/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-jvm.gradle.kts
+++ b/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/kotlin-jvm.gradle.kts
@@ -19,7 +19,6 @@ dependencies {
//
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
-// implementation(kotlin("stdlib"))
//
diff --git a/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/node.gradle.kts b/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/node.gradle.kts
index 17a4450..f335393 100644
--- a/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/node.gradle.kts
+++ b/buildSrc/src/main/kotlin/dev/adamko/kafkatorio/lang/node.gradle.kts
@@ -1,6 +1,7 @@
package dev.adamko.kafkatorio.lang
import com.github.gradle.node.NodePlugin
+import com.github.gradle.node.npm.task.NpmTask
import dev.adamko.kafkatorio.gradle.areJsonPropertiesUpToDate
import dev.adamko.kafkatorio.gradle.not
import dev.adamko.kafkatorio.jsonMapper
@@ -55,3 +56,6 @@ val updatePackageJson by tasks.registering(UpdatePackageJson::class) {
}
tasks.assemble { dependsOn(updatePackageJson) }
+tasks.withType {
+ dependsOn(updatePackageJson)
+}
diff --git a/asd.md b/docs/notes/question-how-to-run-npx-gradle-task-with-kotlin-js.md
similarity index 100%
rename from asd.md
rename to docs/notes/question-how-to-run-npx-gradle-task-with-kotlin-js.md
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index acfc587..cd4b7ac 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -12,7 +12,7 @@ kotlin = "1.6.10"
camel-kafkaConnectors = "0.11.0"
http4k = "4.17.6.0"
kafka = "3.0.0"
-kotlinx-serialization = "1.3.1"
+kotlinx-serialization = "1.3.2"
kvision = "5.6.1"
log4j2 = "2.14.1"
qosLogback = "1.2.5"
diff --git a/modules/events-mod/build.gradle.kts b/modules/events-mod/build.gradle.kts
index bb2c28e..12719aa 100644
--- a/modules/events-mod/build.gradle.kts
+++ b/modules/events-mod/build.gradle.kts
@@ -138,7 +138,7 @@ distributions {
filter("tokens" to projectTokens)
includeEmptyDirs = false
exclude {
-// exclude empty files
+ // exclude empty files
it.file.run {
isFile && useLines { lines -> lines.all { line -> line.isBlank() } }
}
@@ -148,36 +148,6 @@ distributions {
}
}
-//val packageMod by tasks.registering(Zip::class) {
-// description = "Package mod files into ZIP"
-// group = project.name
-//
-// dependsOn(typescriptToLua)
-//
-// inputs.properties(tokens)
-//
-// from(layout.projectDirectory.dir("src/main/resources/mod-data")) {
-// include("**/**")
-// filter("tokens" to tokens)
-// }
-// from(licenseFile)
-//
-// into(rootProject.name)
-//
-// // Factorio required format is:
-// // - filename: `mod-name_version.zip`
-// // - zip contains one directory, `mod-name`
-// archiveFileName.set("${rootProject.name}_${project.version}.zip")
-// destinationDirectory.set(layout.buildDirectory.dir("dist"))
-//
-// doLast {
-// val outDir = destinationDirectory.asFile.get().toRelativeString(layout.projectDirectory.asFile)
-// val outZip = "${archiveFileName.orNull}"
-// logger.lifecycle("Packaged mod into $outDir/$outZip")
-// }
-//}
-
-
val downloadFactorioApiDocs by tasks.registering {
group = project.name
@@ -244,3 +214,5 @@ tasks.assemble { dependsOn(installEventsTsSchema, tasks.updatePackageJson) }
// }
// }
// }
+
+tasks.npmInstall
diff --git a/modules/events-mod/src/main/typescript/events.ts b/modules/events-mod/src/main/typescript/events.ts
index e9e071f..7ac5ec3 100644
--- a/modules/events-mod/src/main/typescript/events.ts
+++ b/modules/events-mod/src/main/typescript/events.ts
@@ -10,7 +10,7 @@ for (const [k, v] of pairs(defines.events)) {
function handlePlayerUpdate(tick: uint, playerIndex: uint, eventType: string) {
let player: LuaPlayer = game.players[playerIndex]
- let table = Serdes.Player.playerToTable(player)
+ let table = Serdes.playerToTable(player)
emitEvent(table, tick, eventType)
handleCharactersEvent(tick, playerIndex, eventType)
@@ -31,12 +31,12 @@ function handleCharactersEvent(tick: uint, playerIndex: uint, eventType: string)
}
function handleEntityUpdate(tick: uint, entity: LuaEntity, eventType: string) {
- let table = Serdes.Entity.entityToTable(entity)
+ let table = Serdes.entityToTable(entity)
emitEvent(table, tick, eventType)
}
function surfaceEvent(tick: uint, surface: LuaSurface, eventType: string) {
- let table = Serdes.Surface.surfaceToTable(surface)
+ let table = Serdes.surfaceToTable(surface)
emitEvent(table, tick, eventType)
}
diff --git a/modules/events-mod/src/main/typescript/package.json b/modules/events-mod/src/main/typescript/package.json
index 966ac89..033dca2 100644
--- a/modules/events-mod/src/main/typescript/package.json
+++ b/modules/events-mod/src/main/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "kafkatorio-events-mod",
- "version": "0.1.5",
+ "version": "0.1.6",
"private": true,
"scripts": {
"build": "tstl",
@@ -9,7 +9,8 @@
"engines": {
"node": ">=10.13.0"
},
- "devDependencies": {},
+ "devDependencies": {
+ },
"dependencies": {
"lua-types": "^2.11.0",
"@types/node": "^12.0.8",
@@ -18,7 +19,10 @@
"typescript": "4.5.4"
},
"license": "UNLICENSED",
- "peerDependencies": {},
- "optionalDependencies": {},
- "bundledDependencies": []
+ "peerDependencies": {
+ },
+ "optionalDependencies": {
+ },
+ "bundledDependencies": [
+ ]
}
diff --git a/modules/events-mod/src/main/typescript/serdes/serdes.ts b/modules/events-mod/src/main/typescript/serdes/serdes.ts
index 2a4a8e1..76425c4 100644
--- a/modules/events-mod/src/main/typescript/serdes/serdes.ts
+++ b/modules/events-mod/src/main/typescript/serdes/serdes.ts
@@ -1,79 +1,65 @@
export namespace Serdes {
- export namespace Player {
- export function playerToTable(player: LuaPlayer): PlayerData {
- let charIds = Entity.entitiesToUnitNumbers(player.get_associated_characters())
- return {
- object_name: player.object_name,
+ export function playerToTable(player: LuaPlayer): PlayerData {
+ let charIds = entitiesToUnitNumbers(player.get_associated_characters())
+ return {
+ object_name: player.object_name,
- name: player.name,
- character_unit_number: player.character?.unit_number ?? null,
- associated_characters_unit_numbers: charIds,
- position: DataClasses.positionTableToTable(player.position),
- }
+ name: player.name,
+ character_unit_number: player.character?.unit_number ?? null,
+ associated_characters_unit_numbers: charIds,
+ position: positionTableToTable(player.position),
}
-
}
- export namespace Entity {
+ export function entityToTable(entity: LuaEntity): EntityData {
- export function entityToTable(entity: LuaEntity): EntityData {
+ let player: LuaPlayer | null = entity.is_player() ? entity.player!! : null
- let player: LuaPlayer | null = entity.is_player() ? entity.player!! : null
+ return {
+ object_name: entity.object_name,
- return {
- object_name: entity.object_name,
+ // entity data
+ name: entity.name,
+ type: entity.type,
+ active: entity.active,
+ health: entity.health ?? null,
+ health_ratio: entity.get_health_ratio(),
+ surface_index: entity.surface.index,
+ unit_number: entity.unit_number ?? null,
+ position: positionTableToTable(entity.position),
- // entity data
- name: entity.name,
- type: entity.type,
- active: entity.active,
- health: entity.health ?? null,
- health_ratio: entity.get_health_ratio(),
- surface_index: entity.surface.index,
- unit_number: entity.unit_number ?? null,
- position: DataClasses.positionTableToTable(entity.position),
-
- // player data
- player_index: player?.index ?? null
- }
+ // player data
+ player_index: player?.index ?? null
}
-
- export function entitiesToUnitNumbers(entities: LuaEntity[]): uint[] {
- let result: (uint) [] = []
- for (let entity of entities) {
- if (entity.unit_number != null) {
- result[result.length] = entity.unit_number
- }
- }
- return result
- }
-
}
- export namespace Surface {
-
- export function surfaceToTable(surface: LuaSurface): SurfaceData {
- return {
- object_name: surface.object_name,
-
- name: surface.name,
- index: surface.index,
- daytime: surface.daytime,
+ export function entitiesToUnitNumbers(entities: LuaEntity[]): uint[] {
+ let result: (uint) [] = []
+ for (let entity of entities) {
+ if (entity.unit_number != null) {
+ result[result.length] = entity.unit_number
}
}
-
+ return result
}
- export namespace DataClasses {
+ export function surfaceToTable(surface: LuaSurface): SurfaceData {
+ return {
+ object_name: surface.object_name,
- export function positionTableToTable(positionTable: PositionTable): PositionData {
- return {
- x: positionTable.x,
- y: positionTable.y,
- }
+ name: surface.name,
+ index: surface.index,
+ daytime: surface.daytime,
}
-
}
+
+ export function positionTableToTable(positionTable: PositionTable): PositionData {
+ return {
+ x: positionTable.x,
+ y: positionTable.y,
+ }
+ }
+
}
diff --git a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventLogConsumer.kt b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventLogConsumer.kt
deleted file mode 100644
index 5ced240..0000000
--- a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventLogConsumer.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package dev.adamko.kafkatorio.processor
-
-/**
- * Process the raw messages from a server.
- */
-class FactorioEventLogConsumer {
-}
\ No newline at end of file
diff --git a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventsTopology.kt b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventsTopology.kt
index d9e2359..d87339d 100644
--- a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventsTopology.kt
+++ b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/FactorioEventsTopology.kt
@@ -13,8 +13,8 @@ import org.apache.kafka.streams.kstream.Consumed
import org.apache.kafka.streams.kstream.Produced
class FactorioEventsTopology(
- val websocketServer: WebsocketServer,
- val builder: StreamsBuilder = StreamsBuilder(),
+ private val websocketServer: WebsocketServer,
+ private val builder: StreamsBuilder = StreamsBuilder(),
) {
private val sourceTopic = "factorio-server-log"
diff --git a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/WebsocketServer.kt b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/WebsocketServer.kt
index 4789991..05efe69 100644
--- a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/WebsocketServer.kt
+++ b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/WebsocketServer.kt
@@ -47,7 +47,7 @@ class WebsocketServer {
messages.emit(msg)
}
- suspend fun start(): PolyHandler = supervisorScope builder@{
+ suspend fun build(): PolyHandler = supervisorScope builder@{
coroutineContext.job.invokeOnCompletion { e ->
e?.let { serverJob.completeExceptionally(it) } ?: serverJob.complete()
diff --git a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt
index c3fe7ec..f462adb 100644
--- a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt
+++ b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt
@@ -1,19 +1,11 @@
package dev.adamko.kafkatorio.processor.config
-import com.fasterxml.jackson.databind.JsonNode
import dev.adamko.kafkatorio.processor.config.PortVal.Companion.portVal
-import java.io.StringReader
import java.time.Clock
import java.util.Properties
import org.http4k.cloudnative.env.Environment
import org.http4k.cloudnative.env.EnvironmentKey
-import org.http4k.core.Credentials
-import org.http4k.core.Uri
-import org.http4k.format.Json
-import org.http4k.lens.boolean
-import org.http4k.lens.map
import org.http4k.lens.nonEmptyString
-import org.http4k.lens.uri
/**
* Load properties, in descending priority order, from
diff --git a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/eventProcessor.kt b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/eventProcessor.kt
index 75b47fb..ca3d7e2 100644
--- a/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/eventProcessor.kt
+++ b/modules/events-processor/src/main/kotlin/dev/adamko/kafkatorio/processor/eventProcessor.kt
@@ -15,18 +15,5 @@ fun main() = runBlocking {
val topology = FactorioEventsTopology(wsServer)
topology.build()
- wsServer.start().asServer(Undertow(9073)).start().block()
+ wsServer.build().asServer(Undertow(9073)).start().block()
}
-
-//
-//
-//// a standard websocket app
-//val websocketServer = websockets(
-// "/lua-objects" bind { ws: Websocket ->
-// ws.send(WsMessage("bob"))
-// ws.onMessage {
-// println("server received: $it")
-// ws.send(it)
-// }
-// }
-//).asServer(Undertow(9097)).start()
diff --git a/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/builtinTypes.kt b/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/builtinTypes.kt
deleted file mode 100644
index 20d85e5..0000000
--- a/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/builtinTypes.kt
+++ /dev/null
@@ -1,98 +0,0 @@
-@file:Suppress("ClassName")
-
-package dev.adamko.kafkatorio.events.schema
-
-
-import kotlin.jvm.JvmInline
-import kotlinx.serialization.Serializable
-
-
-/*
- * The basic types used in the Factorio API. While Lua only supports the `boolean`, `number`,
- * `string`, and `table` types (as they relate to the types listed below), the API docs will
- * specify what C++ types these are converted to or from internally.
- */
-
-
-/**
- * Tables are enclosed in curly brackets, like this `{}`
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#table)
- */
-typealias F_table = MutableMap
-
-sealed interface FBuiltInType {
-
- sealed interface FNumber {
- /**
- * A floating-point number. This is a single-precision floating point number. Whilst Lua only uses double-precision
- * numbers, when a function takes a float, the game engine will immediately convert the double-precision number to
- * single-precision.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#float)
- */
- @Serializable
- @JvmInline
- value class F_float(val float: Float) : FNumber
- /**
- * A double-precision floating-point number. This is the same data type as all Lua numbers use.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#double)
- */
- @Serializable
- @JvmInline
- value class F_double(val double: Double) : FNumber
-
- /**
- * 32-bit signed integer. Possible values are -2,147,483,648 to 2,147,483,647.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#int)
- */
- @Serializable
- @JvmInline
- value class F_int(val int: Int) : FNumber
- /**
- * 8-bit signed integer. Possible values are -128 to 127.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#int8)
- */
- @Serializable
- @JvmInline
- value class F_int8(val int8: Byte) : FNumber
-
- /**
- * 32-bit unsigned integer. Possible values are 0 to 4,294,967,295.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint)
- */
- @Serializable
- @JvmInline
- value class F_uint(val uint: UInt) : FNumber
- /**
- * 8-bit unsigned integer. Possible values are 0 to 255.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint8)
- */
- @Serializable
- @JvmInline
- value class F_uint8(val uint8: UByte) : FNumber
- /**
- * 16-bit unsigned integer. Possible values are 0 to 65535.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint16)
- */
- @Serializable
- @JvmInline
- value class F_uint16(val uint16: UShort) : FNumber
- /**
- * 64-bit unsigned integer. Possible values are 0 to 18,446,744,073,709,551,615.
- *
- * [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint64)
- */
- @Serializable
- @JvmInline
- value class F_uint64(val uint64: ULong) : FNumber
- }
-
-
-}
diff --git a/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEvents.kt b/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEvents.kt
index f1692b7..81090ed 100644
--- a/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEvents.kt
+++ b/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEvents.kt
@@ -11,18 +11,13 @@ import kotlinx.serialization.json.JsonClassDiscriminator
@Serializable
data class FactorioEvent(
/** the initial Factorio event ({defines.events}) trigger */
- @SerialName("event_type")
- val eventType: String,
+ @SerialName("event_type") val eventType: String,
/** Schema versioning */
- @SerialName("mod_version")
- val modVersion: String,
- @SerialName("factorio_version")
- val factorioVersion: String,
+ @SerialName("mod_version") val modVersion: String,
+ @SerialName("factorio_version") val factorioVersion: String,
/** game time */
- @SerialName("tick")
- val tick: UInt,
- @SerialName("data")
- val data: T
+ @SerialName("tick") val tick: UInt,
+ @SerialName("data") val data: T
)
@@ -58,64 +53,46 @@ sealed class FactorioObjectData {
@SerialName("LuaPlayer")
data class PlayerData(
@Serializable(with = ListAsObjectSerializer::class)
- @SerialName("associated_characters_unit_numbers")
- val associatedCharactersUnitNumbers: List,
- @SerialName("character_unit_number")
- val characterUnitNumber: UInt?,
- @SerialName("name")
- val name: String,
- @SerialName("position")
- val position: PositionData,
+ @SerialName("associated_characters_unit_numbers") val associatedCharactersUnitNumbers: List,
+ @SerialName("character_unit_number") val characterUnitNumber: UInt?,
+ @SerialName("name") val name: String,
+ @SerialName("position") val position: PositionData,
) : FactorioObjectData() {
@Transient
- override val objectName: String= "LuaPlayer"
+ override val objectName: String = "LuaPlayer"
}
@Serializable
@SerialName("LuaEntity")
data class EntityData(
- @SerialName("active")
- val active: Boolean,
- @SerialName("health")
- val health: Double?,
- @SerialName("health_ratio")
- val healthRatio: Double,
- @SerialName("name")
- val name: String,
- @SerialName("position")
- val position: PositionData,
- @SerialName("surface_index")
- val surfaceIndex: Int,
- @SerialName("type")
- val type: String,
- @SerialName("unit_number")
- val unitNumber: UInt? = null,
+ @SerialName("active") val active: Boolean,
+ @SerialName("health") val health: Double?,
+ @SerialName("health_ratio") val healthRatio: Double,
+ @SerialName("name") val name: String,
+ @SerialName("position") val position: PositionData,
+ @SerialName("surface_index") val surfaceIndex: Int,
+ @SerialName("type") val type: String,
+ @SerialName("unit_number") val unitNumber: UInt? = null,
- @SerialName("player_index")
- val playerIndex: UInt? = null,
+ @SerialName("player_index") val playerIndex: UInt? = null,
) : FactorioObjectData() {
@Transient
- override val objectName: String= "LuaEntity"
+ override val objectName: String = "LuaEntity"
}
@Serializable
@SerialName("LuaSurface")
data class SurfaceData(
- @SerialName("daytime")
- val daytime: Double,
- @SerialName("index")
- val index: UInt,
- @SerialName("name")
- val name: String,
+ @SerialName("daytime") val daytime: Double,
+ @SerialName("index") val index: UInt,
+ @SerialName("name") val name: String,
) : FactorioObjectData() {
@Transient
- override val objectName: String="LuaSurface"
+ override val objectName: String = "LuaSurface"
}
@Serializable
data class PositionData(
- @SerialName("x")
- val x: Double,
- @SerialName("y")
- val y: Double,
+ @SerialName("x") val x: Double,
+ @SerialName("y") val y: Double,
)
diff --git a/modules/events-schema/src/jvmMain/kotlin/dev/adamko/kafkatorio/events/schema/kt2ts.kt b/modules/events-schema/src/jvmMain/kotlin/dev/adamko/kafkatorio/events/schema/kt2ts.kt
index d16ec4f..4a8af3f 100644
--- a/modules/events-schema/src/jvmMain/kotlin/dev/adamko/kafkatorio/events/schema/kt2ts.kt
+++ b/modules/events-schema/src/jvmMain/kotlin/dev/adamko/kafkatorio/events/schema/kt2ts.kt
@@ -8,6 +8,9 @@ import me.ntrrgc.tsGenerator.TypeScriptGenerator
import me.ntrrgc.tsGenerator.camelCaseToSnakeCase
import org.intellij.lang.annotations.Language
+/**
+ * Convert Kotlin classes to Typescript classes, using [TypeScriptGenerator]
+ */
fun main(args: Array) {
val gen =
diff --git a/modules/infra-factorio-client/build.gradle.kts b/modules/infra-factorio-client/build.gradle.kts
index 531ef55..c52e925 100644
--- a/modules/infra-factorio-client/build.gradle.kts
+++ b/modules/infra-factorio-client/build.gradle.kts
@@ -8,6 +8,8 @@ plugins {
id("dev.adamko.kafkatorio.infra.process-runner")
}
+description = "Start the Factorio game client"
+
val clientModsDirectory = file("""D:\Users\Adam\AppData\Roaming\Factorio\mods""")
val factorioGameId = "427520"
val steamExe = """C:\Program Files (x86)\Steam\steam.exe"""
diff --git a/modules/infra-factorio-server/build.gradle.kts b/modules/infra-factorio-server/build.gradle.kts
index 36e61b7..5951ca5 100644
--- a/modules/infra-factorio-server/build.gradle.kts
+++ b/modules/infra-factorio-server/build.gradle.kts
@@ -48,46 +48,3 @@ tasks.dockerEnv {
}
tasks.build { dependsOn(deployModToServer) }
-
-//
-//val factorioServerStop = tasks.register("factorioServerStop") {
-// group = project.name
-//
-// mustRunAfter(deployModToServer)
-//
-// workingDir(modInfraDir)
-// commandLine = parseSpaceSeparatedArgs("docker-compose stop factorio-server")
-//}
-
-//val factorioServerUp = tasks.register("factorioServerUp") {
-// group = project.name
-//
-// mustRunAfter(deployModToServer)
-// dependsOn(factorioServerStop)
-//
-// workingDir(modInfraDir)
-// commandLine = parseSpaceSeparatedArgs("docker-compose up -d factorio-server")
-//}
-
-//val factorioServerRestart: Task by tasks.creating {
-// group = project.name
-//
-// dependsOn(factorioServerStop, factorioServerUp)
-//}
-//
-
-//
-//tasks.processRun {
-// description = "Build the mod, upload to Server and Client, and start both"
-// dependsOn(
-// deployModToServer,
-// factorioServerRestart,
-// )
-//}
-//
-//tasks.processKill {
-// dependsOn(
-// factorioServerStop,
-// )
-//}
-//
diff --git a/modules/infra-factorio-server/src/factorioEvents.Dockerfile b/modules/infra-factorio-server/factorio-and-kpipe-server/factorioEvents.Dockerfile
similarity index 100%
rename from modules/infra-factorio-server/src/factorioEvents.Dockerfile
rename to modules/infra-factorio-server/factorio-and-kpipe-server/factorioEvents.Dockerfile
diff --git a/modules/infra-factorio-server/src/kafka-pipe.sh b/modules/infra-factorio-server/factorio-and-kpipe-server/kafka-pipe.sh
similarity index 100%
rename from modules/infra-factorio-server/src/kafka-pipe.sh
rename to modules/infra-factorio-server/factorio-and-kpipe-server/kafka-pipe.sh
diff --git a/modules/infra-factorio-server/src/kcat.conf b/modules/infra-factorio-server/factorio-and-kpipe-server/kcat.conf
similarity index 100%
rename from modules/infra-factorio-server/src/kcat.conf
rename to modules/infra-factorio-server/factorio-and-kpipe-server/kcat.conf