- custom generate typed-factorio files
- buildSrc archetype plugins
This commit is contained in:
parent
ec94c68187
commit
877c1cdb98
96 changed files with 24216 additions and 279 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import com.github.gradle.node.npm.task.NpmTask
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
// kotlin("js")
|
||||
base
|
||||
id("com.github.node-gradle.node")
|
||||
}
|
||||
|
||||
|
|
@ -11,141 +12,62 @@ version = rootProject.version
|
|||
node {
|
||||
download.set(true)
|
||||
version.set("14.18.0")
|
||||
// version.set("16.10.0")
|
||||
|
||||
nodeProjectDir.set(layout.projectDirectory.dir("src"))
|
||||
|
||||
distBaseUrl.set(null as String?) // set root dependencyResolutionManagement
|
||||
}
|
||||
// "@types/node": "ts4.4",
|
||||
// 16.10.3 = ts4.4, see https://www.npmjs.com/package/@types/node
|
||||
|
||||
val projectId = rootProject.name + "-" + project.name
|
||||
val modBuildDir = layout.buildDirectory.dir(projectId).get()
|
||||
//val tsSrcDir = layout.projectDirectory.dir("src")
|
||||
|
||||
//repositories {
|
||||
// mavenCentral()
|
||||
// maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
|
||||
// maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
|
||||
//}
|
||||
|
||||
//kotlin {
|
||||
// js(IR) {
|
||||
//
|
||||
// binaries.executable()
|
||||
//
|
||||
// browser {
|
||||
// commonWebpackConfig {
|
||||
// cssSupport.enabled = true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// useCommonJs()
|
||||
// nodejs()
|
||||
//
|
||||
// compilations["main"].apply {
|
||||
// packageJson {
|
||||
// customField(
|
||||
// "scripts",
|
||||
// mapOf(
|
||||
// "build" to "tstl",
|
||||
// "dev" to "tstl --watch",
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// sourceSets {
|
||||
// val main by getting {
|
||||
//// kotlin.srcDir("externals02")
|
||||
//// kotlin.srcDir("externals")
|
||||
//
|
||||
// dependencies {
|
||||
//
|
||||
// val kotlinWrappersVersion = "0.0.1-pre.254-kotlin-1.5.31"
|
||||
// implementation(
|
||||
// project.dependencies.enforcedPlatform(
|
||||
// "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
|
||||
// implementation(npm("react", "17.0.2"))
|
||||
// implementation(npm("react-dom", "17.0.2"))
|
||||
//
|
||||
//// implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7") {
|
||||
//// because("https://github.com/Kotlin/kotlinx-nodejs")
|
||||
//// }
|
||||
//
|
||||
// val generateExternals = false
|
||||
// implementation(npm("typescript-to-lua", "1.0.1", generateExternals = generateExternals))
|
||||
// implementation(npm("typed-factorio", "0.7.1", generateExternals = generateExternals))
|
||||
// implementation(npm("lua-types", "2.11.0", generateExternals = generateExternals))
|
||||
// implementation(npm("typescript", "4.4.3", generateExternals = generateExternals))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// val test by getting {
|
||||
// dependencies {
|
||||
// implementation(kotlin("test-js"))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
val tstlTask = tasks.register<com.github.gradle.node.npm.task.NpmTask>("tstl") {
|
||||
val tstlTask = tasks.register<NpmTask>("tstl") {
|
||||
description = "Typescript To Lua"
|
||||
group = "${rootProject.group}"
|
||||
group = projectId
|
||||
|
||||
dependsOn(tasks.npmInstall)
|
||||
|
||||
execOverrides { standardOutput = System.out }
|
||||
|
||||
npmCommand.set(listOf("run", "build"))
|
||||
args.set(listOf("--", "--outDir", "$buildDir/npm-output"))
|
||||
// args.set(listOf("test"))
|
||||
|
||||
val outputDir = modBuildDir.dir("tstl")
|
||||
args.set(parseSpaceSeparatedArgs("-- --outDir $outputDir"))
|
||||
outputs.dir(outputDir)
|
||||
|
||||
ignoreExitValue.set(false)
|
||||
// environment.set(mapOf("MY_CUSTOM_VARIABLE" to "hello"))
|
||||
workingDir.set(projectDir)
|
||||
execOverrides {
|
||||
standardOutput = System.out
|
||||
}
|
||||
inputs.dir("node_modules")
|
||||
inputs.dir(fileTree("src/main/typescript"))
|
||||
inputs.files(
|
||||
"tsconfig.json",
|
||||
"package.json",
|
||||
)
|
||||
outputs.dir("$buildDir/factorio-web-map/")
|
||||
// workingDir.set(tsSrcDir.asFile)
|
||||
inputs.dir(node.nodeProjectDir)
|
||||
// inputs.dir("node_modules")
|
||||
// inputs.dir(fileTree("src"))
|
||||
// inputs.files(
|
||||
// "tsconfig.json",
|
||||
// "package.json",
|
||||
// )
|
||||
// outputs.dir("$buildDir/factorio-web-map/")
|
||||
// outputs.dir("$buildDir/npm-output")
|
||||
// outputs.upToDateWhen { true }
|
||||
// outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
//sourceSets {
|
||||
// val typescript by creating {
|
||||
// setBuildDir("src/main/typescript")
|
||||
// }
|
||||
//}
|
||||
val modPackageTask = tasks.register<Zip>("package") {
|
||||
description = "Package mod"
|
||||
group = projectId
|
||||
|
||||
dependsOn(tstlTask)
|
||||
|
||||
//dependencies {
|
||||
// val kotlinWrappersVersion = "0.0.1-pre.254-kotlin-1.5.31"
|
||||
// implementation(
|
||||
// project.dependencies.enforcedPlatform(
|
||||
// "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
|
||||
// implementation(npm("react", "17.0.2"))
|
||||
// implementation(npm("react-dom", "17.0.2"))
|
||||
//
|
||||
// // @types/node
|
||||
from(layout.projectDirectory.dir("src")) {
|
||||
exclude("*.ts")
|
||||
into(rootProject.name)
|
||||
}
|
||||
from(tstlTask) {
|
||||
into(rootProject.name)
|
||||
}
|
||||
|
||||
archiveFileName.set("${rootProject.name}_${rootProject.version}.zip")
|
||||
destinationDirectory.set(modBuildDir.dir("dist"))
|
||||
|
||||
}
|
||||
|
||||
tasks.build { dependsOn(tstlTask, modPackageTask) }
|
||||
|
||||
//// implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7") {
|
||||
//// because("https://github.com/Kotlin/kotlinx-nodejs")
|
||||
//// }
|
||||
//
|
||||
// val generateExternals = false
|
||||
// implementation(npm("typescript-to-lua", "1.0.1", generateExternals = generateExternals))
|
||||
// implementation(npm("typed-factorio", "0.7.1", generateExternals = generateExternals))
|
||||
// implementation(npm("lua-types", "2.11.0", generateExternals = generateExternals))
|
||||
// implementation(npm("typescript", "4.4.3", generateExternals = generateExternals))
|
||||
//
|
||||
// testImplementation(kotlin("test-js"))
|
||||
//}
|
||||
1
modules/mod/data.ts
Normal file
1
modules/mod/data.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
// require("item")
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
||||
script.on_event(
|
||||
{defines.events.on_pre_build, defines.events.on_player_dropped_item},
|
||||
function(e)
|
||||
log(
|
||||
(("player " .. tostring(e.player_index)) .. " dropped item, tick:") .. tostring(e.tick)
|
||||
)
|
||||
end
|
||||
)
|
||||
12
modules/mod/item.ts
Normal file
12
modules/mod/item.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import * as util from "util";
|
||||
import { Data, Mods } from "typed-factorio/data/types"
|
||||
|
||||
|
||||
declare const data: Data
|
||||
declare const mods: Mods
|
||||
|
||||
let fireArmour = util.table.deepcopy(data.raw["armor"]["heavy-armor"])
|
||||
|
||||
fireArmour.name = "fire-armour"
|
||||
fireArmour.icon
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
rootProject.name = "factorio-web-map-mod"
|
||||
|
||||
rootProject.description = "Factorio Web Map mod"
|
||||
4
modules/mod/src/changelog.txt
Normal file
4
modules/mod/src/changelog.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.0.1
|
||||
Features:
|
||||
- Factorio Web Map
|
||||
1
modules/mod/src/control.ts
Normal file
1
modules/mod/src/control.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
require("events")
|
||||
19
modules/mod/src/events.ts
Normal file
19
modules/mod/src/events.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
script.on_event(
|
||||
[defines.events.on_pre_build, defines.events.on_player_dropped_item],
|
||||
(e: OnPreBuildEvent | OnPlayerDroppedItemEvent) => {
|
||||
game.print("player " + e.player_index + " dropped item, tick:" + e.tick)
|
||||
}
|
||||
);
|
||||
|
||||
script.on_event(
|
||||
defines.events.on_tick,
|
||||
(e: OnTickEvent) => {
|
||||
if (e.tick % 60 == 0) {
|
||||
game.print("test mod tick: " + e.tick)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
script.on_load(() => {
|
||||
game.print("loaded Factorio Web Map!")
|
||||
});
|
||||
8
modules/mod/src/info.json
Normal file
8
modules/mod/src/info.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "factorio-web-map",
|
||||
"version": "0.0.1",
|
||||
"title": "Factorio Web Map",
|
||||
"author": "fredthedeadhead",
|
||||
"factorio_version": "1.1",
|
||||
"dependencies": []
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
script.on_event(
|
||||
[defines.events.on_pre_build, defines.events.on_player_dropped_item],
|
||||
(e: OnPreBuildEvent | OnPlayerDroppedItemEvent) => {
|
||||
log("player " + e.player_index + " dropped item, tick:" + e.tick)
|
||||
}
|
||||
)
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"typescript-to-lua": "1.0.1",
|
||||
"typed-factorio": "0.7.1",
|
||||
"lua-types": "2.11.0",
|
||||
|
|
@ -24,5 +23,8 @@
|
|||
},
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
"bundledDependencies": [],
|
||||
"//": {
|
||||
"react-dom": "17.0.2"
|
||||
}
|
||||
}
|
||||
BIN
modules/mod/src/thumbnail.png
Normal file
BIN
modules/mod/src/thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 702 B |
19
modules/mod/test/docker-compose.yml
Normal file
19
modules/mod/test/docker-compose.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
version: "3.9"
|
||||
services:
|
||||
factorio:
|
||||
image: factoriotools/factorio:1.1.41
|
||||
# logging:
|
||||
# driver: "json-file"
|
||||
container_name: "factorio"
|
||||
restart: "unless-stopped"
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
- "27015:27015/tcp"
|
||||
volumes:
|
||||
- "./data:/factorio"
|
||||
# environment:
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - UPDATE_MODS_ON_START=true
|
||||
# - USERNAME=FactorioUsername
|
||||
# - TOKEN=FactorioToken
|
||||
Loading…
Add table
Add a link
Reference in a new issue