Skip to content

Commit c03d970

Browse files
authored
use shared config dependency (#71)
1 parent 24ae82e commit c03d970

21 files changed

Lines changed: 16295 additions & 292 deletions

AGENTS.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# AGENTS.md - WurstSetup / Grill Notes
2+
3+
This repo builds the Grill CLI and project setup tooling. The generated map-project agent notes live in `templates/AGENTS.md`; keep this root file focused on WurstSetup itself.
4+
5+
## Current Architecture
6+
7+
- Project config models come from `com.github.wurstscript:wurst-project-config`; do not reintroduce local DAO copies.
8+
- Local helpers in `config/ProjectConfigModels.kt` should stay thin: typealiases plus immutable copy helpers for shared records.
9+
- `YamlHelper.dumpProjectConfig` intentionally serializes a pruned YAML map instead of the shared records directly. This preserves the old user-facing `wurst.build` behavior by omitting null/default nested fields.
10+
- `wbschema.json` should stay lenient and aligned with the shared config parser, especially for `scriptMode`, `wc3Patch`, and nullable legacy fields.
11+
12+
## WC3 Patch And Core JASS
13+
14+
- `CoreJassProvider.DEFAULT_PATCH` is `v2.0`.
15+
- Core JASS is fetched from `wurstscript/jass-history`.
16+
- Friendly patch targets must resolve through the shared parser / `Wc3PatchTarget` style rules:
17+
- below `1.29` => pre-1.29 behavior and stdlib
18+
- `1.29` through `1.31` => classic
19+
- `1.32+`, `1.36`, `2.0`, and `Reforged-*` => Reforged
20+
- Do not add alias hacks for broken jass-history folder names. Fix `wurstscript/jass-history` instead.
21+
- Bundled core JASS fallbacks are patch-specific. Do not silently use the old `reforged` bundle as the `v2.0` fallback.
22+
- Keep provenance in `_build/core-jass.properties`; mismatched cached `common.j` / `blizzard.j` should be refreshed.
23+
24+
## Generate Workflow
25+
26+
- `grill generate` should write a schema-valid minimal `wurst.build`.
27+
- Keep `dependencies`, `scriptMode`, and `wc3Patch`.
28+
- `buildMapData` should only seed known fields: `name`, `fileName`, and `author`. Do not emit nested default scaffolding like `scenarioData`, `optionsFlags`, `players: []`, `forces: []`, or `loadingScreen: null`.
29+
- Generate supports `--wc3-path <dir>`. It should detect/show the Warcraft III client family and warn if it does not match the selected project patch target.
30+
- The VS Code setting `wurst.wc3path` should only be written for a valid detected/selected WC3 folder.
31+
32+
## Install / Userdir
33+
34+
- Grill installs itself to `~/.wurst/grill-cli/grill.jar`.
35+
- The Gradle task `make_for_userdir` must keep that jar refreshed for local testing.
36+
- `remove wurstscript` must not delete the whole `~/.wurst` folder; it should remove compiler artifacts only and leave Grill/runtime state intact.
37+
- Tests should not mutate the real user install. Use the `wurst.install.dir` system property override when testing installation/removal behavior.
38+
39+
## Compiler Interaction
40+
41+
- Build/typecheck should not require parsing the installed Warcraft executable when `wc3Patch` is pinned.
42+
- Run/launch is different: the selected WC3 executable controls launch arguments. If the client family and project patch target differ, warn and allow choosing another WC3 folder.
43+
- Keep compiler-facing patch behavior tested in the WurstScript repo as well; Grill and compiler can diverge if only one side is tested.
44+
45+
## Test Commands
46+
47+
Run the full WurstSetup suite before publishing:
48+
49+
```bash
50+
./gradlew test
51+
```
52+
53+
Useful focused checks:
54+
55+
```bash
56+
./gradlew test --tests GenerateTests --tests YamlHelperTests --tests Wc3ClientDetectorTests
57+
./gradlew test --tests CMDTests.testUnInstallCmd
58+
./gradlew make_for_userdir
59+
```
60+
61+
`git diff --check` should be clean apart from Windows CRLF warnings.

build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies {
4444
implementation 'com.fasterxml.jackson.core:jackson-databind'
4545
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
4646
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
47+
implementation 'com.github.wurstscript:wurst-project-config:2c7ccd1a5f'
4748
implementation 'com.github.Frotty:SimpleRegistry:f96dda96bd'
4849
implementation 'org.jline:jline:3.30.13'
4950
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'
@@ -135,6 +136,25 @@ dist.dependsOn versionInfoFile
135136

136137
dist.archiveFileName = "WurstSetup.jar"
137138

139+
def fatJar = dist.archiveFile.map { it.asFile }
140+
def wurstUserDir = "${System.properties['user.home']}/.wurst"
141+
def grillCliDir = "${wurstUserDir}/grill-cli"
142+
143+
tasks.register('delete_legacy_userdir_grill_jar', Delete) {
144+
delete "${wurstUserDir}/WurstSetup.jar"
145+
}
146+
147+
tasks.register('make_for_userdir', Copy) {
148+
dependsOn 'dist', 'delete_legacy_userdir_grill_jar'
149+
from fatJar
150+
into grillCliDir
151+
rename { 'grill.jar' }
152+
}
153+
154+
tasks.register('make_for_userdir_grill_cli') {
155+
dependsOn 'make_for_userdir'
156+
}
157+
138158
task copy_jar(type: Copy) {
139159
mkdir("downloads/")
140160
from 'build/libs/'

src/main/kotlin/config/DAOs.kt

Lines changed: 0 additions & 130 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package config
2+
3+
const val CONFIG_FILE_NAME = "wurst.build"
4+
5+
typealias ScriptMode = org.wurstscript.projectconfig.ScriptMode
6+
typealias Race = org.wurstscript.projectconfig.Race
7+
typealias Controller = org.wurstscript.projectconfig.Controller
8+
typealias WurstProjectConfigData = org.wurstscript.projectconfig.WurstProjectConfigData
9+
typealias WurstProjectBuildMapData = org.wurstscript.projectconfig.WurstProjectBuildMapData
10+
typealias WurstProjectBuildScenarioData = org.wurstscript.projectconfig.WurstProjectBuildScenarioData
11+
typealias WurstProjectBuildLoadingScreenData = org.wurstscript.projectconfig.WurstProjectBuildLoadingScreenData
12+
typealias WurstProjectBuildOptionFlagsData = org.wurstscript.projectconfig.WurstProjectBuildOptionFlagsData
13+
typealias WurstProjectBuildPlayer = org.wurstscript.projectconfig.WurstProjectBuildPlayer
14+
typealias WurstProjectBuildForce = org.wurstscript.projectconfig.WurstProjectBuildForce
15+
typealias WurstProjectBuildForceFlags = org.wurstscript.projectconfig.WurstProjectBuildForceFlags
16+
17+
fun newProjectConfig(
18+
projectName: String = "unnamed",
19+
dependencies: List<String> = emptyList(),
20+
buildMapData: WurstProjectBuildMapData = WurstProjectBuildMapData.empty(),
21+
scriptMode: ScriptMode? = null,
22+
wc3Patch: String? = null
23+
): WurstProjectConfigData {
24+
return WurstProjectConfigData(projectName, dependencies, buildMapData, scriptMode, wc3Patch)
25+
}
26+
27+
fun WurstProjectConfigData.withProjectName(projectName: String): WurstProjectConfigData {
28+
return WurstProjectConfigData(projectName, dependencies(), buildMapData(), scriptMode(), wc3Patch())
29+
}
30+
31+
fun WurstProjectConfigData.withWc3Patch(wc3Patch: String?): WurstProjectConfigData {
32+
return WurstProjectConfigData(projectName(), dependencies(), buildMapData(), scriptMode(), wc3Patch)
33+
}
34+
35+
fun WurstProjectConfigData.withDependencies(dependencies: List<String>): WurstProjectConfigData {
36+
return WurstProjectConfigData(projectName(), dependencies, buildMapData(), scriptMode(), wc3Patch())
37+
}
38+
39+
fun WurstProjectConfigData.withAddedDependency(dependency: String): WurstProjectConfigData {
40+
return withDependencies(dependencies() + dependency)
41+
}
42+
43+
fun WurstProjectConfigData.withRemovedDependency(dependency: String): WurstProjectConfigData {
44+
return withDependencies(dependencies().filterNot { it == dependency })
45+
}

src/main/kotlin/config/WurstProjectConfig.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ object WurstProjectConfig {
4747
if (Files.exists(buildFile) && buildFile.fileName.toString().equals(CONFIG_FILE_NAME, ignoreCase = true)) {
4848
val config = YamlHelper.loadProjectConfig(buildFile)
4949
val projectRoot = buildFile.parent
50-
if (config.projectName.isEmpty()) {
51-
config.projectName = projectRoot?.fileName.toString()
52-
saveProjectConfig(projectRoot, config)
50+
if (config.projectName.isBlank()) {
51+
val namedConfig = config.withProjectName(projectRoot?.fileName?.toString() ?: "unnamed")
52+
saveProjectConfig(projectRoot, namedConfig)
53+
Log.print("done\n")
54+
return namedConfig
5355
}
5456
Log.print("done\n")
5557
return config

src/main/kotlin/file/CLICommand.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ enum class GlobalOptions(val optionName: String = "", val argCount: Int = 0) {
7777
override fun runOption(setupMain: SetupMain, args: List<String>) {
7878
setupMain.wc3Patch = CoreJassProvider.normalizePatchInput(args[0])
7979
}
80+
},
81+
WC3_PATH("--wc3-path", 1) {
82+
override fun runOption(setupMain: SetupMain, args: List<String>) {
83+
setupMain.gamePath = java.nio.file.Paths.get(args[0])
84+
setupMain.gamePathExplicit = true
85+
}
8086
};
8187

8288
abstract fun runOption(setupMain: SetupMain, args: List<String>)

0 commit comments

Comments
 (0)