tasks to move generated ts files to mod project
This commit is contained in:
parent
5ffd5010e4
commit
464d4c28fb
4 changed files with 177 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import com.github.gradle.node.npm.task.NpmTask
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
id("dev.adamko.factoriowebmap.archetype.node")
|
||||
|
|
@ -16,6 +16,66 @@ node {
|
|||
nodeProjectDir.set(tsSrcDir)
|
||||
}
|
||||
|
||||
val tsProto: Configuration by configurations.creating {
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
tsProto(projects.modules.factorioEventsDataModel.dependencyProject.configurations.getByName("tsProto"))
|
||||
}
|
||||
|
||||
val tsProtoFetch by tasks.creating(Sync::class) {
|
||||
group = project.name
|
||||
|
||||
dependsOn(projects.modules.factorioEventsDataModel.dependencyProject.tasks.named("protobufTypescript"))
|
||||
|
||||
val genSrcDir = projects
|
||||
.modules
|
||||
.factorioEventsDataModel
|
||||
.dependencyProject
|
||||
.layout
|
||||
.buildDirectory
|
||||
.dir("pbAndG/generated-sources/typescript")
|
||||
|
||||
val targetDir = "$projectDir/src/main/typescript/proto"
|
||||
|
||||
inputs.dir(genSrcDir)
|
||||
|
||||
from(genSrcDir)
|
||||
into(targetDir)
|
||||
|
||||
doLast {
|
||||
|
||||
fileTree(targetDir).forEach {
|
||||
var text = it.readText()
|
||||
|
||||
text = text.replace(
|
||||
Regex(
|
||||
"""if \(_m0\.util\.Long !== Long\)\s*\{\s*_m0\.util\.Long = Long as any;\s*_m0\.configure\(\);\s*\}"""
|
||||
),
|
||||
""
|
||||
)
|
||||
|
||||
text = text.replace(
|
||||
Regex("""import Long from "long";"""),
|
||||
""
|
||||
)
|
||||
|
||||
text = text.replace(
|
||||
Regex("""import _m0 from "protobufjs\/minimal";"""),
|
||||
""
|
||||
)
|
||||
|
||||
it.writeText(text)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.assemble { dependsOn(tsProtoFetch) }
|
||||
|
||||
|
||||
val tstlTask = tasks.register<NpmTask>("typescriptToLua") {
|
||||
description = "Convert Typescript To Lua"
|
||||
group = projectId
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
/* eslint-disable */
|
||||
|
||||
|
||||
|
||||
export interface FactorioServerLogRecord {
|
||||
modVersion: string;
|
||||
tick: number;
|
||||
eventType: string;
|
||||
data?: FactorioLuaObject;
|
||||
}
|
||||
|
||||
export interface FactorioLuaObject {
|
||||
objectName: string;
|
||||
luaControl?: LuaControl | undefined;
|
||||
}
|
||||
|
||||
/** https://lua-api.factorio.com/next/LuaControl.html */
|
||||
export interface LuaControl {
|
||||
isPlayer: boolean;
|
||||
surfaceIndex: number;
|
||||
position?: Position;
|
||||
forceIndex: number;
|
||||
player?: LuaPlayer | undefined;
|
||||
entity?: LuaEntity | undefined;
|
||||
}
|
||||
|
||||
/** https://lua-api.factorio.com/next/LuaPlayer.html */
|
||||
export interface LuaPlayer {
|
||||
/** unique ID */
|
||||
index: number;
|
||||
name: string;
|
||||
data: number[];
|
||||
colour?: Colour;
|
||||
isConnected: boolean;
|
||||
isAdmin: boolean;
|
||||
afkTimeTicks: number;
|
||||
onlineTimeTicks: number;
|
||||
lastOnlineTicks: number;
|
||||
}
|
||||
|
||||
/** https://lua-api.factorio.com/next/LuaEntity.html */
|
||||
export interface LuaEntity {
|
||||
/** (optional) unique ID */
|
||||
unitNumber?: number | undefined;
|
||||
name: string;
|
||||
type: string;
|
||||
/** https://lua-api.factorio.com/next/defines.html#defines.entity_status */
|
||||
status: string;
|
||||
isActive: boolean;
|
||||
isMoving: boolean;
|
||||
/** (optional) The player connected to this character or nil if none. */
|
||||
playerIndex?: number | undefined;
|
||||
/** (optional) The last player that changed any setting on this entity. */
|
||||
lastUserIndex?: number | undefined;
|
||||
/** (optional) */
|
||||
colour?: Colour;
|
||||
}
|
||||
|
||||
export interface LuaSurface {
|
||||
/** unique ID */
|
||||
index: number;
|
||||
name: string;
|
||||
daytime: number;
|
||||
}
|
||||
|
||||
export interface LuaForce {
|
||||
/** unique ID */
|
||||
index: number;
|
||||
forceName: string;
|
||||
playerIds: number[];
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Colour {
|
||||
red: number;
|
||||
green: number;
|
||||
blue: number;
|
||||
alpha: number;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue