Skip to content

Commit

Permalink
Merge pull request #219 from simple-robot/dev/main
Browse files Browse the repository at this point in the history
Release: v4.0.2
  • Loading branch information
ForteScarlet authored Oct 15, 2024
2 parents 060b99e + 6487b04 commit 8d43d8a
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 1,512 deletions.
8 changes: 8 additions & 0 deletions .changelog/v4.0.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
> [!note]
> 对应核心版本: [**v4.6.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.6.0)

我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-qq-guild/issues)[协助](https://github.com/simple-robot/simbot-component-qq-guild/pulls)
感谢您的贡献与支持!

也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可!
2 changes: 1 addition & 1 deletion .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
pull_request_target:
push:
branches:
- dev/main
Expand Down
38 changes: 11 additions & 27 deletions buildSrc/src/main/kotlin/JsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,14 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl

inline fun KotlinJsTargetDsl.configJs(
nodeJs: Boolean = true,
browser: Boolean = true,
block: () -> Unit = {}
) {
if (nodeJs) {
nodejs()
// {
//// testTask {
//// useMocha {
//// timeout = "10000"
//// }
//// }
// }
}

if (browser) {
browser()
// {
// testTask{
// useKarma {
// useChromeHeadless()
// // useConfigDirectory(File(project.rootProject.projectDir, "karma"))
// }
// }
// }
nodejs {
testTask {
useMocha()
}
}
}

binaries.library()
Expand All @@ -55,10 +39,10 @@ inline fun KotlinJsTargetDsl.configJs(
fun Project.configJsTestTasks() {
// val shouldRunJsBrowserTest = !hasProperty("teamcity") || hasProperty("enable-js-tests")
// if (shouldRunJsBrowserTest) return
tasks.findByName("cleanJsBrowserTest")?.apply {
onlyIf { false }
}
tasks.findByName("jsBrowserTest")?.apply {
onlyIf { false }
}
// tasks.findByName("cleanJsBrowserTest")?.apply {
// onlyIf { false }
// }
// tasks.findByName("jsBrowserTest")?.apply {
// onlyIf { false }
// }
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ object P {
override val homepage: String get() = HOMEPAGE


const val VERSION = "4.0.1"
const val NEXT_VERSION = "4.0.2"
const val VERSION = "4.0.2"
const val NEXT_VERSION = "4.0.3"

override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
override val version = if (isSnapshot()) snapshotVersion else VERSION
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "2.0.10"
kotlinx-coroutines = "1.8.1"
kotlinx-coroutines = "1.9.0"
kotlinx-serialization = "1.7.1"
kotlinx-datetime = "0.6.1"
dokka = "1.9.20"
Expand All @@ -17,7 +17,7 @@ ksp = "2.0.10-1.0.24"
kotlinPoet = "1.18.1"
# https://detekt.dev/docs/intro
# TODO apply detekt
detekt = "1.23.6"
detekt = "1.23.7"


[libraries]
Expand All @@ -36,7 +36,7 @@ simbot-common-loop = { group = "love.forte.simbot.common", name = "simbot-common
simbot-gradle = { group = "love.forte.simbot.gradle", name = "simbot-gradle-suspendtransforms", version.ref = "simbot" }

# jetbrains-annotation
jetbrains-annotations = "org.jetbrains:annotations:24.1.0"
jetbrains-annotations = "org.jetbrains:annotations:26.0.1"

# kotlinx-coroutines
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ private val IntentsClassName = ClassName(INTENTS_PACKAGE, INTENTS_CLASS_NAME)

private const val NO_WARP = "·"

private const val EVENT_NAME_BASED_MARKER_NAME = "EventNameBasedMarker"
private const val EVENT_NAME_BASED_MARKER_PKG = "love.forte.simbot.qguild.internal"

/**
* 寻找所有 `love.forte.simbot.qguild.event.EventIntents` 的子 `object` 类型,
* 并生成它们 intents 的各种聚合到 `EventIntentsAggregation` 中。
Expand Down Expand Up @@ -99,7 +102,10 @@ internal class EventIntentsAggregationProcessor(

val fileBuilder = FileSpec.builder(OUTPUT_PACKAGE, AGGREGATION_FILE_NAME)
fileBuilder.addType(aggregationBuilder.build())
fileBuilder.addFileComment("本文件内容为自动生成,生成于 %L", OffsetDateTime.now(ZoneOffset.ofHours(8)).toString())
fileBuilder.addFileComment(
"本文件内容为自动生成,生成于 %L",
OffsetDateTime.now(ZoneOffset.ofHours(8)).toString()
)

val targetFile = fileBuilder.build()

Expand Down Expand Up @@ -198,14 +204,40 @@ internal class EventIntentsAggregationProcessor(
data class NamesToType(val names: Set<String>, val declaration: KSClassDeclaration)

val nameToTypes = list.map { declaration ->
val baseName = declaration.simpleName.asString()
val nameBasedAnnotation = declaration.annotations
.firstOrNull {
(it.annotationType.resolve().declaration as? KSClassDeclaration)?.let { annoDecl ->
annoDecl.simpleName.asString() == EVENT_NAME_BASED_MARKER_NAME
&& annoDecl.packageName.asString() == EVENT_NAME_BASED_MARKER_PKG
} ?: false
}

fun baseName(): String = declaration.simpleName.asString()

fun findFromAnnotation(name: String): String? =
nameBasedAnnotation?.arguments?.firstOrNull {
it.name?.asString() == name
}?.value as? String?

val firstUpper = findFromAnnotation("firstUpper")
?.takeUnless { it.isBlank() }
?: baseName()
val firstLower = findFromAnnotation("firstLower")
?.takeUnless { it.isBlank() }
?: baseName().replaceFirstChar(Char::lowercaseChar)
val snackUpper = findFromAnnotation("snackUpper")
?.takeUnless { it.isBlank() }
?: baseName().toSnack(true)
val snackLower = findFromAnnotation("snackLower")
?.takeUnless { it.isBlank() }
?: baseName().toSnack(false)


val set = setOf(
baseName,
// 开头小写
baseName.replaceFirstChar(Char::lowercaseChar),
// 下划线的全大写与全小写
baseName.toSnack(false),
baseName.toSnack(true)
firstUpper,
firstLower,
snackUpper,
snackLower,
)

NamesToType(set, declaration)
Expand Down
Loading

0 comments on commit 8d43d8a

Please sign in to comment.