Skip to content

Development #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tasks.withType<AbstractPublishToMaven>().configureEach {
// Gradle warns about some signing tasks using publishing task outputs without explicit
// dependencies. I'm not going to go through them all and fix them, so here's a quick fix.
dependsOn(tasks.withType<Sign>())
mustRunAfter(tasks.withType<Sign>())

doLast {
logger.lifecycle("[${this.name}] ${project.group}:${project.name}:${project.version}")
Expand All @@ -64,9 +65,12 @@ afterEvaluate {
// too early, before all the publications are added.
// Use .all { }, not .configureEach { }, otherwise the signing plugin doesn't create the tasks
// soon enough.
publishing.publications.withType<MavenPublication>().all {
signing.sign(this)
logger.lifecycle("configuring signature for publication ${this.name}")

if (sonatypeRepositoryCredentials.isPresent()) {
publishing.publications.withType<MavenPublication>().all {
signing.sign(this)
logger.lifecycle("configuring signature for publication ${this.name}")
}
}
}

Expand Down
9 changes: 4 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ kotlinCompileTesting = "1.4.8" # https://github.com/tschuchortdev/kotlin

kotlinx-serialization = "1.3.3" # https://github.com/Kotlin/kotlinx.serialization/releases/tag/v1.3.3
kotlinx-knit = "0.4.0" # https://github.com/Kotlin/kotlinx-knit/releases
kotlinx-coroutines = "1.6.1" # https://github.com/Kotlin/kotlinx.coroutines/releases
kotlinx-coroutines = "1.6.3" # https://github.com/Kotlin/kotlinx.coroutines/releases
kotlinx-kover = "0.5.1" # https://github.com/Kotlin/kotlinx-kover/releases

okio = "3.1.0" # https://search.maven.org/artifact/com.squareup.okio/okio
okio = "3.2.0" # https://search.maven.org/artifact/com.squareup.okio/okio

kotest = "5.3.0" # https://github.com/kotest/kotest/releases
kotestSnapshot = "5.3.0.1010-SNAPSHOT"
kotest = "5.3.1" # https://github.com/kotest/kotest/releases

kotlinProcess = "1.3.1" # https://github.com/pgreze/kotlin-process/releases

Expand Down Expand Up @@ -53,7 +52,7 @@ kotlinCompileTesting-ksp = { group = "com.github.tschuchortdev", name = "kotlin-

## Kotest ##

kotest-bom = { group = "io.kotest", name = "kotest-bom", version.ref = "kotestSnapshot" }
kotest-bom = { group = "io.kotest", name = "kotest-bom", version.ref = "kotest" }
kotest-assertionsCore = { group = "io.kotest", name = "kotest-assertions-core" }
kotest-assertionsJson = { group = "io.kotest", name = "kotest-assertions-json" }
kotest-property = { group = "io.kotest", name = "kotest-property" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import kotlinx.serialization.modules.SerializersModuleCollector
* @param[indent] Define the indentation that is used when generating source code
* @param[declarationSeparator] The string that is used when joining [TsDeclaration]s
* @param[namespaceConfig] (UNIMPLEMENTED) How elements are grouped into [TsDeclaration.TsNamespace]s.
* @param[typeAliasTyping] (UNIMPLEMENTED) Control if type aliases are simple, or 'branded'.
* @param[typeAliasTyping] Control whether type aliases are simple, or 'branded'.
* @param[serializersModule] Used to obtain contextual and polymorphic information.
*/
data class KxsTsConfig(
val indent: String = " ",
val declarationSeparator: String = "\n\n",
@UnimplementedKxsTsGenApi
val namespaceConfig: NamespaceConfig = NamespaceConfig.Disabled,
@UnimplementedKxsTsGenApi
val typeAliasTyping: TypeAliasTypingConfig = TypeAliasTypingConfig.None,
val serializersModule: SerializersModule = EmptySerializersModule,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import dev.adamko.kxstsgen.KxsTsConfig
/**
* Writes [TsElement]s as TypeScript source code.
*/
abstract class TsSourceCodeGenerator(
val config: KxsTsConfig = KxsTsConfig(),
) {
interface TsSourceCodeGenerator {

abstract fun groupElementsBy(element: TsElement): String?
fun groupElementsBy(element: TsElement): String?

open fun generateDeclaration(element: TsDeclaration): String {
fun generateDeclaration(element: TsDeclaration): String {
return when (element) {
is TsDeclaration.TsEnum -> generateEnum(element)
is TsDeclaration.TsInterface -> generateInterface(element)
Expand All @@ -23,21 +21,21 @@ abstract class TsSourceCodeGenerator(
}
}

abstract fun generateEnum(enum: TsDeclaration.TsEnum): String
abstract fun generateInterface(element: TsDeclaration.TsInterface): String
abstract fun generateNamespace(namespace: TsDeclaration.TsNamespace): String
abstract fun generateTypeAlias(element: TsDeclaration.TsTypeAlias): String
abstract fun generateTypeUnion(element: TsDeclaration.TsTypeUnion): String
abstract fun generateTuple(tuple: TsDeclaration.TsTuple): String
fun generateEnum(enum: TsDeclaration.TsEnum): String
fun generateInterface(element: TsDeclaration.TsInterface): String
fun generateNamespace(namespace: TsDeclaration.TsNamespace): String
fun generateTypeAlias(element: TsDeclaration.TsTypeAlias): String
fun generateTypeUnion(element: TsDeclaration.TsTypeUnion): String
fun generateTuple(tuple: TsDeclaration.TsTuple): String

abstract fun generateMapTypeReference(tsMap: TsLiteral.TsMap): String
fun generateMapTypeReference(tsMap: TsLiteral.TsMap): String

abstract fun generatePrimitive(primitive: TsLiteral.Primitive): String
abstract fun generateTypeReference(typeRef: TsTypeRef): String
fun generatePrimitive(primitive: TsLiteral.Primitive): String
fun generateTypeReference(typeRef: TsTypeRef): String

open class Default(
config: KxsTsConfig,
) : TsSourceCodeGenerator(config) {
private val config: KxsTsConfig,
) : TsSourceCodeGenerator {


override fun groupElementsBy(element: TsElement): String {
Expand Down