User: rednesto Date: 09 Aug 24 23:44 Revision: b989f7deecdb035f9d2f32d636f22dcef8aac302 Summary: Add "lowercase" option to the replace derivation method I'm sneaking this in without bumping the format version as this I don't expect custom repo templates to exist at this point, and this behavior is kind of unexpected in the first place TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9578&personal=false Index: src/main/kotlin/creator/custom/derivation/ReplacePropertyDerivation.kt =================================================================== --- src/main/kotlin/creator/custom/derivation/ReplacePropertyDerivation.kt (revision 0fcf7a75e451cae403186138b569a8e69f2b0ce6) +++ src/main/kotlin/creator/custom/derivation/ReplacePropertyDerivation.kt (revision b989f7deecdb035f9d2f32d636f22dcef8aac302) @@ -28,13 +28,19 @@ val regex: Regex, val replacement: String, val maxLength: Int?, + val lowercase: Boolean, ) : PreparedDerivation { override fun derive(parentValues: List): Any? { val projectName = parentValues.first() as? String ?: return null - val sanitized = projectName.lowercase().replace(regex, replacement) + var sanitized = projectName + if (lowercase) { + sanitized = sanitized.lowercase() + } + + sanitized = sanitized.replace(regex, replacement) if (maxLength != null && sanitized.length > maxLength) { return sanitized.substring(0, maxLength) } @@ -88,7 +94,8 @@ } val maxLength = (derivation.parameters["maxLength"] as? Number)?.toInt() - return ReplacePropertyDerivation(regex, replacement, maxLength) + val lowercase = derivation.parameters["lowercase"] as? Boolean == true + return ReplacePropertyDerivation(regex, replacement, maxLength, lowercase) } } } Index: src/test/kotlin/creator/StringCreatorPropertyTest.kt =================================================================== --- src/test/kotlin/creator/StringCreatorPropertyTest.kt (revision 0fcf7a75e451cae403186138b569a8e69f2b0ce6) +++ src/test/kotlin/creator/StringCreatorPropertyTest.kt (revision b989f7deecdb035f9d2f32d636f22dcef8aac302) @@ -74,7 +74,8 @@ "parameters": { "regex": "[^a-z0-9-_]+", "replacement": "_", - "maxLength": 32 + "maxLength": 32, + "lowercase": true } } }