- more tidying up
- setting up distribution plugin - using more variables for mod config
This commit is contained in:
parent
afbfeda616
commit
7091f7648d
34 changed files with 293 additions and 169 deletions
|
|
@ -10,23 +10,42 @@ import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
|||
plugins {
|
||||
idea
|
||||
id("dev.adamko.kafkatorio.lang.node")
|
||||
distribution
|
||||
}
|
||||
|
||||
val tokens: Map<String, String> by project.extra
|
||||
val licenseFile: RegularFile by project.extra
|
||||
description =
|
||||
"Sends in-game information to a server over the internet (requires Kafkatorio Kafka-Pipe)"
|
||||
|
||||
|
||||
// Factorio required format is:
|
||||
// - filename: `mod-name_version.zip`
|
||||
// - zip contains one directory, `mod-name`
|
||||
val modName: String by extra("${rootProject.name}-events")
|
||||
val distributionZipName: String by extra("${modName}_${project.version}.zip")
|
||||
|
||||
|
||||
val tokens: MutableMap<String, String> by project.extra
|
||||
tokens += mapOf(
|
||||
"mod.name" to modName,
|
||||
"mod.title" to "Kafkatorio Events",
|
||||
"mod.description" to (project.description ?: ""),
|
||||
"factorio.version" to libs.versions.factorio.get().substringBeforeLast("."),
|
||||
)
|
||||
|
||||
val licenseFile: RegularFile by project.extra
|
||||
val tsSrcDir: Directory = layout.projectDirectory.dir("src/main/typescript")
|
||||
|
||||
node {
|
||||
nodeProjectDir.set(tsSrcDir)
|
||||
}
|
||||
|
||||
val typescriptEventsSchema by configurations.registering {
|
||||
val typescriptEventsSchema: Configuration by configurations.creating {
|
||||
asConsumer()
|
||||
typescriptAttributes(objects)
|
||||
defaultDependencies {
|
||||
project.dependencies.create(projects.modules.eventsSchema)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
typescriptEventsSchema(projects.modules.eventsSchema)
|
||||
}
|
||||
|
||||
val typescriptToLua by tasks.registering(NpmTask::class) {
|
||||
|
|
@ -39,13 +58,12 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
|
||||
npmCommand.set(listOf("run", "build"))
|
||||
|
||||
inputs.dir(project.node.nodeProjectDir)
|
||||
inputs.dir(tsSrcDir)
|
||||
.skipWhenEmpty()
|
||||
.withPropertyName("sourceFiles")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
val intermediateOutputDir = temporaryDir
|
||||
args.set(parseSpaceSeparatedArgs("-- --outDir $intermediateOutputDir"))
|
||||
args.set(parseSpaceSeparatedArgs("-- --outDir $temporaryDir"))
|
||||
val outputDir = layout.buildDirectory.dir("typescriptToLua")
|
||||
outputs.dir(outputDir)
|
||||
.withPropertyName("outputDir")
|
||||
|
|
@ -53,12 +71,13 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
ignoreExitValue.set(false)
|
||||
|
||||
doFirst("clean") {
|
||||
delete(intermediateOutputDir)
|
||||
delete(temporaryDir)
|
||||
mkdir(temporaryDir)
|
||||
}
|
||||
|
||||
doLast("syncTstlOutput") {
|
||||
sync {
|
||||
from(intermediateOutputDir)
|
||||
from(temporaryDir)
|
||||
into(outputDir)
|
||||
}
|
||||
}
|
||||
|
|
@ -66,54 +85,86 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
}
|
||||
|
||||
val fetchEventsSchema by tasks.registering(Sync::class) {
|
||||
group = project.name
|
||||
description = "Fetch the latest shared data-model"
|
||||
group = project.name
|
||||
|
||||
dependsOn(typescriptEventsSchema)
|
||||
|
||||
from(
|
||||
typescriptEventsSchema.map { c ->
|
||||
c.incoming
|
||||
.artifactView { lenient(true) }
|
||||
.artifacts
|
||||
.artifactFiles
|
||||
.filter { file -> file.exists() }
|
||||
typescriptEventsSchema.incoming
|
||||
.artifactView { lenient(true) }
|
||||
.artifacts
|
||||
.artifactFiles
|
||||
.filter { file -> file.exists() }
|
||||
.files
|
||||
.map { zipTree(it) }
|
||||
) {
|
||||
// drop the first directory inside the zip
|
||||
eachFile {
|
||||
relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray())
|
||||
}
|
||||
)
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
|
||||
into(layout.projectDirectory.dir("src/main/typescript/model"))
|
||||
into(layout.projectDirectory.dir("src/main/typescript/schema"))
|
||||
}
|
||||
|
||||
val packageMod by tasks.registering(Zip::class) {
|
||||
description = "Package mod files into ZIP"
|
||||
group = project.name
|
||||
tasks.distZip {
|
||||
archiveFileName.set(distributionZipName)
|
||||
}
|
||||
|
||||
dependsOn(typescriptToLua)
|
||||
distributions {
|
||||
main {
|
||||
|
||||
inputs.properties(tokens)
|
||||
distributionBaseName.set(modName)
|
||||
|
||||
from(layout.projectDirectory.dir("src/main/resources/mod-data")) {
|
||||
include("**/**")
|
||||
filter<ReplaceTokens>("tokens" to tokens)
|
||||
}
|
||||
dependsOn(typescriptToLua)
|
||||
from(licenseFile)
|
||||
contents {
|
||||
from(layout.projectDirectory.dir("src/main/resources/mod-data")) {
|
||||
include("**/**")
|
||||
filter<ReplaceTokens>("tokens" to tokens)
|
||||
}
|
||||
from(licenseFile)
|
||||
from(typescriptToLua.map { it.outputs })
|
||||
includeEmptyDirs = false
|
||||
exclude {
|
||||
it.file.run {
|
||||
isFile && useLines { lines -> lines.all { line -> line.isBlank() } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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<ReplaceTokens>("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
|
||||
|
|
@ -148,7 +199,7 @@ val downloadFactorioApiDocs by tasks.registering {
|
|||
val factorioModProvider by configurations.registering {
|
||||
asProvider()
|
||||
factorioModAttributes(objects)
|
||||
outgoing.artifact(packageMod)
|
||||
outgoing.artifact(tasks.distZip.flatMap { it.archiveFile })
|
||||
}
|
||||
|
||||
tasks.updatePackageJson {
|
||||
|
|
@ -157,7 +208,7 @@ tasks.updatePackageJson {
|
|||
}
|
||||
|
||||
tasks.assemble { dependsOn(fetchEventsSchema, tasks.updatePackageJson) }
|
||||
tasks.build { dependsOn(packageMod) }
|
||||
//tasks.build { dependsOn(packageMod) }
|
||||
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.0.1
|
||||
Features:
|
||||
- Factorio Web Map
|
||||
- Kafkatorio
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"name": "factorio-web-map",
|
||||
"name": "@mod.name@",
|
||||
"version": "@project.version@",
|
||||
"title": "Factorio Web Map",
|
||||
"title": "@mod.title@",
|
||||
"description": "@mod.description@",
|
||||
"author": "fredthedeadhead",
|
||||
"factorio_version": "1.1",
|
||||
"factorio_version": "@factorio.version@",
|
||||
"dependencies": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,9 +90,13 @@ script.on_event(
|
|||
(e: OnTickEvent) => {
|
||||
if (e.tick % 60 == 0) {
|
||||
|
||||
for (const [index,] of pairs(game.surfaces)) {
|
||||
let surface = game.surfaces[index]
|
||||
surfaceEvent(e.tick, surface, mapEventIdToName.get(e.name))
|
||||
|
||||
for (const [index, _] of pairs(game.surfaces)) {
|
||||
let s = game.get_surface(index) // TODO fix / report can't iterate over surfaces
|
||||
// let surface = game.surfaces[index]
|
||||
if (s != undefined) {
|
||||
surfaceEvent(e.tick, s, mapEventIdToName.get(e.name))
|
||||
}
|
||||
// surfaceEvent(e.tick, surface, "on_tick")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "factorio-web-map-mod",
|
||||
"name": "kafkatorio-events-mod",
|
||||
"version": "0.0.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
},
|
||||
"devDependencies": {},
|
||||
"dependencies": {
|
||||
"lua-types": "^2.11.0",
|
||||
"@types/node": "^12.0.8",
|
||||
|
|
@ -21,10 +20,7 @@
|
|||
"//": {
|
||||
"typed-factorio": "0.10.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
},
|
||||
"optionalDependencies": {
|
||||
},
|
||||
"bundledDependencies": [
|
||||
]
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,4 @@ interface SurfaceData extends FactorioObjectData {
|
|||
index: uint;
|
||||
name: string;
|
||||
object_name: string;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue