From 785dc32a09c737de63cf2136c7dc3c434f5272ec Mon Sep 17 00:00:00 2001 From: Marcin Mielnicki Date: Mon, 16 Oct 2023 21:26:23 +0200 Subject: [PATCH] Move default script src to Script --- .../platan/tests_execution_chart/JsonToHtmlReportApp.kt | 3 +-- .../tests_execution_chart/gradle/config/formats/Script.kt | 5 ++--- .../tests_execution_chart/reporters/html/HtmlConfig.kt | 8 ++++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/functionalTest/kotlin/io/github/platan/tests_execution_chart/JsonToHtmlReportApp.kt b/src/functionalTest/kotlin/io/github/platan/tests_execution_chart/JsonToHtmlReportApp.kt index 22ca2d6..2014414 100644 --- a/src/functionalTest/kotlin/io/github/platan/tests_execution_chart/JsonToHtmlReportApp.kt +++ b/src/functionalTest/kotlin/io/github/platan/tests_execution_chart/JsonToHtmlReportApp.kt @@ -2,7 +2,6 @@ package io.github.platan.tests_execution_chart -import io.github.platan.tests_execution_chart.gradle.config.formats.DEFAULT_MERMAID_SCRIPT_SRC import io.github.platan.tests_execution_chart.report.ReportConfig import io.github.platan.tests_execution_chart.report.ReportCreator import io.github.platan.tests_execution_chart.report.data.TestExecutionScheduleReport @@ -32,7 +31,7 @@ fun main(args: Array) { val input by parser.option(ArgType.String, fullName = "input", description = "Input file in JSON format").required() val outputDir by parser.option(ArgType.String, fullName = "output-dir").required() val mermaidScriptSrc by parser.option(ArgType.String, fullName = "mermaid-script-src") - .default(DEFAULT_MERMAID_SCRIPT_SRC) + .default(HtmlConfig.Script.getSrcDefault()) val embed by parser.option(ArgType.Boolean, fullName = "embed-mermaid-script").default(false) val maxTextSize by parser.option(ArgType.Int, fullName = "mermaid-max-text-size").default(50_000) val taskName by parser.option(ArgType.String, fullName = "task-name").default("test") diff --git a/src/main/kotlin/io/github/platan/tests_execution_chart/gradle/config/formats/Script.kt b/src/main/kotlin/io/github/platan/tests_execution_chart/gradle/config/formats/Script.kt index 7ba2fca..cd8fa93 100644 --- a/src/main/kotlin/io/github/platan/tests_execution_chart/gradle/config/formats/Script.kt +++ b/src/main/kotlin/io/github/platan/tests_execution_chart/gradle/config/formats/Script.kt @@ -1,5 +1,6 @@ package io.github.platan.tests_execution_chart.gradle.config.formats +import io.github.platan.tests_execution_chart.reporters.html.HtmlConfig import org.gradle.api.Action import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property @@ -7,12 +8,10 @@ import org.gradle.api.tasks.Input import org.gradle.api.tasks.Nested import javax.inject.Inject -const val DEFAULT_MERMAID_SCRIPT_SRC = "https://cdn.jsdelivr.net/npm/mermaid@10.5.0/dist/mermaid.min.js" - abstract class Script @Inject constructor(objectFactory: ObjectFactory) { @get:Input - val src: Property = objectFactory.property(String::class.java).convention(DEFAULT_MERMAID_SCRIPT_SRC) + val src: Property = objectFactory.property(String::class.java).convention(HtmlConfig.Script.getSrcDefault()) @get:Input val embed: Property = objectFactory.property(Boolean::class.java).convention(false) diff --git a/tests-execution-chart-commons/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlConfig.kt b/tests-execution-chart-commons/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlConfig.kt index 093f3ab..804a154 100644 --- a/tests-execution-chart-commons/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlConfig.kt +++ b/tests-execution-chart-commons/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlConfig.kt @@ -5,6 +5,14 @@ import io.github.platan.tests_execution_chart.report.ReportConfig data class HtmlConfig(override val enabled: Boolean, override val outputLocation: String, val script: Script) : ReportConfig.Format { data class Script(val src: String, val embed: Boolean, val options: Options) { + + companion object { + private const val DEFAULT_MERMAID_SCRIPT_SRC = + "https://cdn.jsdelivr.net/npm/mermaid@10.5.0/dist/mermaid.min.js" + + fun getSrcDefault(): String = DEFAULT_MERMAID_SCRIPT_SRC + } + data class Options(val maxTextSize: Int) } }