Skip to content

Commit

Permalink
Move default script src to Script
Browse files Browse the repository at this point in the history
  • Loading branch information
platan committed Oct 16, 2023
1 parent 34a6d65 commit 785dc32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -32,7 +31,7 @@ fun main(args: Array<String>) {
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")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
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
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/[email protected]/dist/mermaid.min.js"

abstract class Script @Inject constructor(objectFactory: ObjectFactory) {

@get:Input
val src: Property<String> = objectFactory.property(String::class.java).convention(DEFAULT_MERMAID_SCRIPT_SRC)
val src: Property<String> = objectFactory.property(String::class.java).convention(HtmlConfig.Script.getSrcDefault())

@get:Input
val embed: Property<Boolean> = objectFactory.property(Boolean::class.java).convention(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/dist/mermaid.min.js"

fun getSrcDefault(): String = DEFAULT_MERMAID_SCRIPT_SRC
}

data class Options(val maxTextSize: Int)
}
}

0 comments on commit 785dc32

Please sign in to comment.