added kvision web-map, cleaning up a few gradle things (tokens)
This commit is contained in:
parent
29d190b8f4
commit
6d60428ab9
31 changed files with 323 additions and 87 deletions
|
|
@ -5,6 +5,7 @@ import dev.adamko.kafkatorio.gradle.factorioModAttributes
|
|||
import dev.adamko.kafkatorio.gradle.typescriptAttributes
|
||||
import groovy.json.JsonOutput
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
|
|
@ -23,16 +24,18 @@ description =
|
|||
val modName: String by extra("${rootProject.name}-events")
|
||||
val distributionZipName: String by extra("${modName}_${project.version}.zip")
|
||||
|
||||
// version of Factorio that the mod is compatible with (must only be "major.minor" - patch causes error)
|
||||
val modFactorioCompatibility = SemVer.from(libs.versions.factorio.get()).run { "$major.$minor" }
|
||||
|
||||
val tokens: MutableMap<String, String> by project.extra
|
||||
tokens += mapOf(
|
||||
val licenseFile: RegularFile by rootProject.extra
|
||||
val projectTokens: MutableMap<String, String> by rootProject.extra
|
||||
projectTokens += mapOf(
|
||||
"mod.name" to modName,
|
||||
"mod.title" to "Kafkatorio Events",
|
||||
"mod.description" to (project.description ?: ""),
|
||||
"factorio.version" to libs.versions.factorio.get().substringBeforeLast("."),
|
||||
"factorio.version" to modFactorioCompatibility,
|
||||
)
|
||||
|
||||
val licenseFile: RegularFile by project.extra
|
||||
val tsSrcDir: Directory = layout.projectDirectory.dir("src/main/typescript")
|
||||
|
||||
node {
|
||||
|
|
@ -52,7 +55,7 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
description = "Convert Typescript To Lua"
|
||||
group = project.name
|
||||
|
||||
dependsOn(tasks.npmInstall, fetchEventsSchema)
|
||||
dependsOn(tasks.npmInstall, installEventsSchema)
|
||||
|
||||
execOverrides { standardOutput = System.out }
|
||||
|
||||
|
|
@ -84,7 +87,7 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
|
||||
}
|
||||
|
||||
val fetchEventsSchema by tasks.registering(Sync::class) {
|
||||
val installEventsSchema by tasks.registering(Sync::class) {
|
||||
description = "Fetch the latest shared data-model"
|
||||
group = project.name
|
||||
|
||||
|
|
@ -124,10 +127,10 @@ distributions {
|
|||
}
|
||||
from(licenseFile)
|
||||
from(typescriptToLua.map { it.outputs })
|
||||
filter<ReplaceTokens>("tokens" to tokens)
|
||||
filter<ReplaceTokens>("tokens" to projectTokens)
|
||||
includeEmptyDirs = false
|
||||
exclude {
|
||||
// exclude empty lines
|
||||
// exclude empty files
|
||||
it.file.run {
|
||||
isFile && useLines { lines -> lines.all { line -> line.isBlank() } }
|
||||
}
|
||||
|
|
@ -196,7 +199,6 @@ val downloadFactorioApiDocs by tasks.registering {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
val factorioModProvider by configurations.registering {
|
||||
asProvider()
|
||||
factorioModAttributes(objects)
|
||||
|
|
@ -204,13 +206,11 @@ val factorioModProvider by configurations.registering {
|
|||
}
|
||||
|
||||
tasks.updatePackageJson {
|
||||
propertiesToCheck["name"] = "${rootProject.name}-${project.name}"
|
||||
propertiesToCheck.put("name", "${rootProject.name}-${project.name}")
|
||||
packageJsonFile.set(layout.projectDirectory.file("src/main/typescript/package.json"))
|
||||
}
|
||||
|
||||
tasks.assemble { dependsOn(fetchEventsSchema, tasks.updatePackageJson) }
|
||||
//tasks.build { dependsOn(packageMod) }
|
||||
|
||||
tasks.assemble { dependsOn(installEventsSchema, tasks.updatePackageJson) }
|
||||
|
||||
//
|
||||
//idea {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"version": "@project.version@",
|
||||
"title": "@mod.title@",
|
||||
"description": "@mod.description@",
|
||||
"author": "fredthedeadhead",
|
||||
"author": "@author.email@",
|
||||
"factorio_version": "@factorio.version@",
|
||||
"dependencies": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "kafkatorio-events-mod",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "kafkatorio-events-mod",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tstl",
|
||||
|
|
@ -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,8 @@
|
|||
"//": {
|
||||
"typed-factorio": "0.10.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
},
|
||||
"optionalDependencies": {
|
||||
},
|
||||
"bundledDependencies": [
|
||||
]
|
||||
"license": "UNLICENSED",
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
// Generated code - do edit this file manually
|
||||
|
||||
// Generated by TypeScriptGenerator - do edit this file manually
|
||||
interface FactorioObjectData {
|
||||
object_name: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,11 +53,9 @@ fun main(args: Array<String>) {
|
|||
|
||||
@Language("TypeScript")
|
||||
val header = """
|
||||
|
||||
// Generated code - do edit this file manually
|
||||
|
||||
|
||||
""".trimIndent()
|
||||
|// Generated by TypeScriptGenerator - do edit this file manually
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
object PropertyNameTransformer : ClassTransformer {
|
||||
override fun transformPropertyName(
|
||||
|
|
|
|||
39
modules/web-map/.gettext.json
Normal file
39
modules/web-map/.gettext.json
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"js": {
|
||||
"parsers": [
|
||||
{
|
||||
"expression": "tr",
|
||||
"arguments": {
|
||||
"text": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"expression": "ntr",
|
||||
"arguments": {
|
||||
"text": 0,
|
||||
"textPlural": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"expression": "gettext",
|
||||
"arguments": {
|
||||
"text": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"expression": "ngettext",
|
||||
"arguments": {
|
||||
"text": 0,
|
||||
"textPlural": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"glob": {
|
||||
"pattern": "src/**/*.kt"
|
||||
}
|
||||
},
|
||||
"headers": {
|
||||
"Language": ""
|
||||
},
|
||||
"output": "src/main/resources/i18n/messages.pot"
|
||||
}
|
||||
8
modules/web-map/.gitignore
vendored
Normal file
8
modules/web-map/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.*/
|
||||
build/
|
||||
out/
|
||||
/refresh.sh
|
||||
*.imp
|
||||
*.ipr
|
||||
*.iws
|
||||
*.idea
|
||||
72
modules/web-map/build.gradle.kts
Normal file
72
modules/web-map/build.gradle.kts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||
|
||||
plugins {
|
||||
id("dev.adamko.kafkatorio.base")
|
||||
kotlin("plugin.serialization")
|
||||
kotlin("js") // version kotlinVersion
|
||||
id("io.kvision") version "5.6.1"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js(IR) {
|
||||
browser {
|
||||
runTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
sourceMaps = false
|
||||
devServer = KotlinWebpackConfig.DevServer(
|
||||
open = false,
|
||||
port = 3000,
|
||||
proxy = mutableMapOf(
|
||||
"/kv/*" to "http://localhost:8080",
|
||||
"/kvws/*" to mapOf("target" to "ws://localhost:8080", "ws" to true)
|
||||
),
|
||||
static = mutableListOf("$buildDir/processedResources/js/main")
|
||||
)
|
||||
}
|
||||
webpackTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
}
|
||||
testTask {
|
||||
useKarma {
|
||||
useChromeHeadless()
|
||||
}
|
||||
}
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val kvisionVersion: String = libs.versions.kvision.get()
|
||||
|
||||
main {
|
||||
dependencies {
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7")
|
||||
|
||||
implementation("io.kvision:kvision:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-bootstrap:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-bootstrap-css:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-bootstrap-icons:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-fontawesome:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-state:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-chart:$kvisionVersion")
|
||||
|
||||
val kotlinWrappersVersion = "0.0.1-pre.270-kotlin-1.6.0"
|
||||
implementation(
|
||||
project.dependencies.enforcedPlatform(
|
||||
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val webDir = file("src/main/web")
|
||||
resources.srcDir(webDir)
|
||||
}
|
||||
test {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
implementation("io.kvision:kvision-testutils:$kvisionVersion")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package dev.adamko.kafkatorio.webmap
|
||||
|
||||
import io.kvision.Application
|
||||
import io.kvision.CoreModule
|
||||
import io.kvision.BootstrapModule
|
||||
import io.kvision.BootstrapCssModule
|
||||
import io.kvision.BootstrapIconsModule
|
||||
import io.kvision.FontAwesomeModule
|
||||
import io.kvision.ChartModule
|
||||
import io.kvision.html.div
|
||||
import io.kvision.module
|
||||
import io.kvision.panel.root
|
||||
import io.kvision.startApplication
|
||||
|
||||
class App : Application() {
|
||||
override fun start() {
|
||||
root("kvapp") {
|
||||
div("Hello world")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
startApplication(
|
||||
::App,
|
||||
module.hot,
|
||||
BootstrapModule,
|
||||
BootstrapCssModule,
|
||||
BootstrapIconsModule,
|
||||
FontAwesomeModule,
|
||||
ChartModule,
|
||||
CoreModule
|
||||
)
|
||||
}
|
||||
12
modules/web-map/src/main/web/index.html
Normal file
12
modules/web-map/src/main/web/index.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>KVision Template</title>
|
||||
<script type="text/javascript" src="main.bundle.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="kvapp"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package test.dev.adamko.kafkatorio.webmap
|
||||
|
||||
import io.kvision.test.SimpleSpec
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class AppSpec : SimpleSpec {
|
||||
|
||||
@Test
|
||||
fun render() {
|
||||
run {
|
||||
assertTrue(true, "Dummy test")
|
||||
}
|
||||
}
|
||||
}
|
||||
3
modules/web-map/webpack.config.d/bootstrap.js
vendored
Normal file
3
modules/web-map/webpack.config.d/bootstrap.js
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
config.module.rules.push({test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, type: 'asset'});
|
||||
config.module.rules.push({test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, type: 'asset'});
|
||||
config.module.rules.push({test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, type: 'asset/resource'});
|
||||
2
modules/web-map/webpack.config.d/css.js
Normal file
2
modules/web-map/webpack.config.d/css.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
config.module.rules.push({ test: /\.css$/, use: ["style-loader", { loader: "css-loader", options: {sourceMap: false} } ] });
|
||||
|
||||
6
modules/web-map/webpack.config.d/file.js
Normal file
6
modules/web-map/webpack.config.d/file.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
config.module.rules.push(
|
||||
{
|
||||
test: /\.(jpe?g|png|gif|svg)$/i,
|
||||
type: 'asset/resource'
|
||||
}
|
||||
);
|
||||
6
modules/web-map/webpack.config.d/handlebars.js
Normal file
6
modules/web-map/webpack.config.d/handlebars.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
config.module.rules.push(
|
||||
{
|
||||
test: /\.hbs$/i,
|
||||
loader: 'handlebars-loader'
|
||||
}
|
||||
);
|
||||
9
modules/web-map/webpack.config.d/jquery.js
vendored
Normal file
9
modules/web-map/webpack.config.d/jquery.js
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;(function() {
|
||||
const webpack = require('webpack')
|
||||
|
||||
config.plugins.push(new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery",
|
||||
"window.jQuery": "jquery"
|
||||
}));
|
||||
})();
|
||||
15
modules/web-map/webpack.config.d/moment.js
Normal file
15
modules/web-map/webpack.config.d/moment.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
;(function() {
|
||||
const webpack = require('webpack')
|
||||
try {
|
||||
const moment = require("moment");
|
||||
config.plugins.push(new webpack.IgnorePlugin({
|
||||
resourceRegExp: /^\.\/locale$/,
|
||||
contextRegExp: /moment$/,
|
||||
}));
|
||||
config.plugins.push(new webpack.ProvidePlugin({
|
||||
moment: "moment",
|
||||
"window.moment": "moment"
|
||||
}));
|
||||
} catch (e) {
|
||||
}
|
||||
})();
|
||||
15
modules/web-map/webpack.config.d/webpack.js
Normal file
15
modules/web-map/webpack.config.d/webpack.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
config.resolve.modules.push("../../processedResources/js/main");
|
||||
|
||||
if (config.devServer) {
|
||||
config.devServer.hot = true;
|
||||
config.devtool = 'eval-cheap-source-map';
|
||||
} else {
|
||||
config.devtool = undefined;
|
||||
}
|
||||
|
||||
// disable bundle size warning
|
||||
config.performance = {
|
||||
assetFilter: function (assetFilename) {
|
||||
return !assetFilename.endsWith('.js');
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue