Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix build step #229

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://github.com/Ezard/semantic-prs#configuration

# Validate the PR title and all commit messages
titleAndCommits: true
# Validate the PR title only
titleOnly: true

scopes: [github, README, L10n]
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# gradle.properties
# use gradle.properties.example to fill in paths
gradle.properties

# custom cache
.cache

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ git clone repository `https://github.com/scarf005/Marisa.git`

setup java, kotlin, and gradle in your intellij. language version must be 8.

```
# fill in your steam directory ending with '/steamapps'
userSteamDir=/home/scarf/.local/share/Steam/steamapps
# default: "$userSteamDir/workshop/content/$gameSteamId"
workshopDir=
```

copy `gradle.properties.example` to `gradle.properties` and provide path to your steam directory.

```sh
gradle changelog # install once
./gradlew -t changelog --warning-mode all # dev mode: recompile on changes
Expand Down
33 changes: 19 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ val changelog = File("docs/changelog/changelog.md").readText()
val changeBBCode = File("docs/changelog/changelog.bbcode").readText()
val changeSts = File("docs/changelog/changelog.sts.txt").readText()

val (gameDir, modTheSpireDir, basemodDir) = run {
val homeDir = System.getProperty("user.home")!!
val steamDir = "$homeDir/.local/share/Steam/steamapps"
val workShopDir = "$steamDir/workshop/content/Slay the Spire"
val mod = 1605060445
val base = 1605833019
Triple(
"$steamDir/common/SlayTheSpire",
"$workShopDir/$mod",
"$workShopDir/$base",
)
}
val userSteamDir = property("userSteamDir") ?: throw error("userSteamDir is not set")
val gameDir = "$userSteamDir/common/SlayTheSpire"

/** [store link](https://store.steampowered.com/app/646570/Slay_the_Spire/) */
val gameSteamId = 646570

/** [workshop link](https://steamcommunity.com/sharedfiles/filedetails?id=1605833019) */
val baseModId = 1605833019

/** [workshop link](https://steamcommunity.com/sharedfiles/filedetails?id=1605060445) */
val modTheSpireId = 1605060445

/** [workshop link](https://steamcommunity.com/sharedfiles/filedetails?id=2902980404) */
val marisaModId = 2902980404

val workShopDir = project.properties["workshopDir"] ?: "$userSteamDir/workshop/content/$gameSteamId"
val modTheSpireDir = "$workShopDir/$modTheSpireId"
val basemodDir = "$workShopDir/$baseModId"

buildscript {
repositories { mavenCentral() }
Expand Down Expand Up @@ -47,7 +53,7 @@ kotlin {
plugins {
application
java
kotlin("jvm") version "1.9.0"
kotlin("jvm") version "1.9.23"
}

repositories {
Expand Down Expand Up @@ -75,7 +81,6 @@ sourceSets {
exclude("**/*.ts", "**/deno.*", "schemas/**")
}
}

}

@Suppress("PropertyName", "LongLine")
Expand Down
321 changes: 303 additions & 18 deletions deno.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions gradle.properties

This file was deleted.

7 changes: 7 additions & 0 deletions gradle.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
org.gradle.caching=true
org.gradle.parallel=true
kotlin.experimental.tryK2=true
# fill in your steam directory ending with '/steamapps'
userSteamDir=
# default: "$userSteamDir/workshop/content/$gameSteamId"
workshopDir=
153 changes: 0 additions & 153 deletions releases.py

This file was deleted.

36 changes: 36 additions & 0 deletions releases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { join } from "https://deno.land/std@0.219.0/path/join.ts"
import { verifyHardLink } from "./scripts/link/mod.ts"
import { steam as SteamPath } from "./scripts/paths.ts"
import $ from "https://deno.land/x/dax/mod.ts"

export const basePath = "docs/changelog"

export const changelogPath = join(basePath, "changelog.md")
export const version = (await Deno.readTextFile(join(basePath, "version.txt"))).trim()

const changelogText = await Deno.readTextFile(changelogPath)
const title = changelogText.split("\n")[0].replace("# ", "")
const body = changelogText.split("\n").slice(1).join("\n")

export const jarPath = "build/libs/MarisaContinued.jar"
export const stsPath = join(SteamPath, "SlayTheSpire")

const github = async () => {
const artifact = `${jarPath}#MarisaContinued-${version}.jar`
const command =
$`gh release create --verify-tag --title ${title} --notes ${body} v${version} ${artifact}`
await command.printCommand()
await command.text()
}

if (import.meta.main) {
switch (Deno.args[0]) {
case "github": {
await github()
break
}
case "steam": {
await $`java -jar mod-uploader.jar upload -w MarisaContinued/`.cwd(stsPath)
}
}
}
29 changes: 29 additions & 0 deletions releases_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { join } from "https://deno.land/std@0.219.0/path/join.ts"
import { basePath, changelogPath, jarPath, stsPath, version } from "./releases.ts"
import { verifyHardLink } from "./scripts/link/mod.ts"
import { assertEquals } from "https://deno.land/std@0.219.0/assert/assert_equals.ts"
import { assertStringIncludes } from "https://deno.land/std@0.219.0/assert/assert_string_includes.ts"
import { readZip } from "https://deno.land/x/jszip@0.11.0/mod.ts"

Deno.test("hardlinks are verified", async () => {
await verifyHardLink({ quiet: true, check: true })
})

Deno.test("modjson.json has correct version", async () => {
const zip = await readZip(jarPath)
const modinfo = JSON.parse(await zip.file("ModTheSpire.json").async("text"))

assertEquals(modinfo["version"], version)
})

Deno.test("changelog.md has correct version", async () => {
const paths = [
join(stsPath, "MarisaContinued", "config.json"),
join(basePath, "changelog.bbcode"),
join(basePath, "changelog.sts.txt"),
changelogPath,
]
const configs = await Promise.all(paths.map((x) => Deno.readTextFile(x)))

configs.forEach((config) => assertStringIncludes(config, version))
})
27 changes: 15 additions & 12 deletions scripts/link/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ import { image, jar, mod } from "../paths.ts"
import { noop } from "./noop.ts"
import { createHardLink, forceCreateLinkTo, hardlinkError } from "./hardlink.ts"

export const verifyHardLink = async (
{ quiet, check }: { quiet?: true | undefined; check?: true | undefined },
) => {
const log = quiet ? noop : console.log
const action = check ? hardlinkError : createHardLink
const linkTo = forceCreateLinkTo(log)(action)

await Promise.all([
linkTo(jar)(join(mod, "content")),
linkTo(image)(mod),
])
}

const main = () =>
new Command()
.description("Hard link mod jar and image to steam's slay the spire folder")
.option("-q, --quiet", "Do not output to console. Used in gradle task.")
.option("-c, --check", "Exit with code 1 on failure instead.")
.action(async ({ quiet, check }) => {
const log = quiet ? noop : console.log
const action = check ? hardlinkError : createHardLink
const linkTo = forceCreateLinkTo(log)(action)

await Promise.all([
linkTo(jar)(join(mod, "content")),
linkTo(image)(mod),
])
})
.parse(Deno.args)
.action(verifyHardLink)

if (import.meta.main) {
main()
await main().parse(Deno.args)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assertEquals } from "https://deno.land/std@0.178.0/testing/asserts.ts"
import { dirEntries } from "./dirEntries.ts"

Deno.test(async function testDirEntries() {
const path = Deno.cwd().endsWith("localization") ? "." : "src/main/resources/localization"
const path = Deno.cwd().endsWith("localization") ? "." : "src/main/resources/marisa/localization/"

const entries = (await dirEntries(`${path}/ENG`))
.map((x) => x.name)
Expand Down
Loading