move schema to kotlin-multiplatform
This commit is contained in:
parent
6d60428ab9
commit
1f88d6f464
11 changed files with 118 additions and 46 deletions
|
|
@ -7,7 +7,7 @@ import kotlinx.serialization.json.jsonPrimitive
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.provider.MapProperty
|
||||
import org.gradle.api.specs.Spec
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
|
||||
|
|
@ -27,18 +27,23 @@ fun Project.isProcessRunning(process: String, ignoreCase: Boolean = true): Spec<
|
|||
|
||||
fun Project.areJsonPropertiesUpToDate(
|
||||
packageJsonFile: RegularFileProperty,
|
||||
properties: () -> Map<String, String>
|
||||
properties: MapProperty<String, String>
|
||||
): Spec<Task> = Spec<Task> {
|
||||
val packageJsonContent = packageJsonFile.get().asFile.readText()
|
||||
val packageJson = jsonMapper.parseToJsonElement(packageJsonContent).jsonObject
|
||||
|
||||
properties().all { (key, expectedVal) ->
|
||||
properties.get().all { (key, expectedVal) ->
|
||||
val actualVal = packageJson[key]?.jsonPrimitive?.content
|
||||
(expectedVal == actualVal).also {
|
||||
logger.log(
|
||||
if (it) LogLevel.LIFECYCLE else LogLevel.INFO,
|
||||
val isUpToDate = expectedVal == actualVal
|
||||
|
||||
if (isUpToDate) {
|
||||
logger.info("package.json property is up to date, '$key = $actualVal'")
|
||||
} else {
|
||||
logger.lifecycle(
|
||||
"package.json has outdated property '$key' (expected: $expectedVal, actual: $actualVal)"
|
||||
)
|
||||
}
|
||||
|
||||
isUpToDate
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ val updatePackageJson by tasks.registering(UpdatePackageJson::class) {
|
|||
propertiesToCheck.put("version", "${project.version}")
|
||||
|
||||
// check to see if the properties are already up-to-date
|
||||
onlyIf(!areJsonPropertiesUpToDate(packageJsonFile) { propertiesToCheck.get() })
|
||||
onlyIf(!areJsonPropertiesUpToDate(packageJsonFile, propertiesToCheck))
|
||||
|
||||
doLast {
|
||||
val packageJsonContent = packageJsonFile.get().asFile.readText()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue