factorio mod deploy tweaks (better confirmation and link to the page)
This commit is contained in:
parent
0398e2026d
commit
d2768c3c9e
3 changed files with 37 additions and 14 deletions
|
|
@ -36,6 +36,7 @@ class FactorioModPortalPublishClient(
|
|||
private val modVersion: String,
|
||||
private val portalApiKey: String,
|
||||
private val portalUploadEndpoint: String,
|
||||
private val modPortalBaseURl: String,
|
||||
) {
|
||||
|
||||
private fun client() = HttpClient(CIO) {
|
||||
|
|
@ -61,11 +62,18 @@ class FactorioModPortalPublishClient(
|
|||
client().useToRun {
|
||||
val initUploadResponse = initUpload()
|
||||
|
||||
val confirmation = userInputHandler
|
||||
.askQuestion("Are you sure you want to publish $modName:$modVersion?", "no")
|
||||
.toBooleanLenient() ?: false
|
||||
val enteredVersion = userInputHandler
|
||||
.askQuestion(
|
||||
"""
|
||||
|Are you sure you want to publish $modName:$modVersion?
|
||||
|Enter the version number to confirm:
|
||||
""".trimMargin(),
|
||||
"",
|
||||
)
|
||||
|
||||
if (confirmation) {
|
||||
val confirmed = enteredVersion.trim() == modVersion.trim()
|
||||
|
||||
if (confirmed) {
|
||||
upload(initUploadResponse)
|
||||
} else {
|
||||
println("aborting upload")
|
||||
|
|
@ -120,6 +128,7 @@ class FactorioModPortalPublishClient(
|
|||
require(response.status.isSuccess() && submitUploadResponse is SubmitUploadResponse.Success) {
|
||||
"upload request failed"
|
||||
}
|
||||
println("Mod uploaded successfully! ${modPortalBaseURl.removeSuffix("/")}/$modName")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,15 @@ abstract class FactorioModPublishTask @Inject constructor(
|
|||
val portalApiUrl: Property<String> = objects.property<String>()
|
||||
.convention("https://mods.factorio.com/api/v2/")
|
||||
|
||||
/**
|
||||
* Base URL for linking to a mod page in the portal
|
||||
*
|
||||
* Example `https://mods.factorio.com/mod/my-mod-name`
|
||||
*/
|
||||
@get:Input
|
||||
val modPortalBaseURl: Property<String> = objects.property<String>()
|
||||
.convention("https://mods.factorio.com/mod/")
|
||||
|
||||
@get:Input
|
||||
val portalUploadEndpoint: Property<String> = objects.property<String>()
|
||||
.convention("mods/releases/init_upload")
|
||||
|
|
@ -65,12 +74,13 @@ abstract class FactorioModPublishTask @Inject constructor(
|
|||
.buildString()
|
||||
|
||||
val client = FactorioModPortalPublishClient(
|
||||
userInputHandler,
|
||||
distributionZip.get().asFile,
|
||||
modName.get(),
|
||||
modVersion.get(),
|
||||
portalApiKey.get(),
|
||||
portalUploadEndpoint,
|
||||
userInputHandler = userInputHandler,
|
||||
distributionZip = distributionZip.get().asFile,
|
||||
modName = modName.get(),
|
||||
modVersion = modVersion.get(),
|
||||
portalApiKey = portalApiKey.get(),
|
||||
portalUploadEndpoint = portalUploadEndpoint,
|
||||
modPortalBaseURl = modPortalBaseURl.get(),
|
||||
)
|
||||
|
||||
client.uploadMod()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
"engines": {
|
||||
"node": "~14.19.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"devDependencies": {
|
||||
},
|
||||
"dependencies": {
|
||||
"lua-types": "^2.11.0",
|
||||
"typescript-to-lua": "1.6.0",
|
||||
|
|
@ -17,7 +18,10 @@
|
|||
"typescript": "4.7.4"
|
||||
},
|
||||
"license": "UNLICENSED",
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
"peerDependencies": {
|
||||
},
|
||||
"optionalDependencies": {
|
||||
},
|
||||
"bundledDependencies": [
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue