Skip to content
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

Release: v4.0.0-beta6 #166

Merged
merged 4 commits into from
Aug 12, 2024
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
7 changes: 7 additions & 0 deletions .changelog/v4.0.0-beta6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> 对应核心版本: [**v4.5.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.5.0)

> [!warning]
> 目前版本尚处于 **`beta`** 阶段,代表仍然可能存在部分已知问题或未知问题,
> 以及尚未完善的内容和落后于官方更新的内容。

我们欢迎并期望着您的 [反馈](https://github.com/simple-robot/simbot-component-kook/issues) 或 [协助](https://github.com/simple-robot/simbot-component-kook/pulls),感谢您的贡献与支持!
27 changes: 2 additions & 25 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ jobs:

# Create gitHub release
- name: Create Github Release
uses: softprops/action-gh-release@v0.1.15
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.PUSH_TOKEN }}
body_path: .changelog/${{ github.ref_name }}.md
body: ''
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, 'preview') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'dev') }}

Expand Down Expand Up @@ -137,27 +138,3 @@ jobs:
# deploy to sub dir
destination_dir: components/kook

# deploy-website:
# name: Deploy Website
# runs-on: ubuntu-latest
# needs: run-test-and-publish
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v3
# with:
# node-version: 16.x
# cache: npm
# cache-dependency-path: ./website/package-lock.json
#
# - run: |
# npm ci
# npm run build
# working-directory: ./website
#
# # https://github.com/marketplace/actions/github-pages-action
# - name: Push to doc repository
# uses: peaceiris/actions-gh-pages@v3
# with:
# personal_token: ${{ secrets.PUSH_TOKEN }}
# publish_branch: gh-pages
# publish_dir: ./website/build
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v4.0.0-beta6

> Release & Pull Notes: [v4.0.0-beta6](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-beta6)

- optimize(internal): 简单优化内部的KSP ([`bd15b6a`](https://github.com/simple-robot/simpler-robot/commit/bd15b6a))
- fix(api): 修复 CreateAssetApi 使用的错误请求头 ([`f0a0fe0`](https://github.com/simple-robot/simpler-robot/commit/f0a0fe0))

# v4.0.0-beta5

> Release & Pull Notes: [v4.0.0-beta5](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-beta5)
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ object P : ProjectDetail() {
override val homepage: String
get() = HOMEPAGE

const val VERSION = "4.0.0-beta5"
const val NEXT_VERSION = "4.0.0-beta6"
const val VERSION = "4.0.0-beta6"
const val NEXT_VERSION = "4.0.0-beta7"

override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
override val version = if (isSnapshot()) snapshotVersion else VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

package kook.internal.processors.apireader

import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getKotlinClassByName
import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.isAbstract
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessor
Expand All @@ -42,29 +41,11 @@ abstract class ReaderProcessor(private val environment: SymbolProcessorEnvironme
abstract val optionName: String
abstract val targetClassName: String

@OptIn(KspExperimental::class)
override fun process(resolver: Resolver): List<KSAnnotated> {
val targetFilePath: String? = environment.options[optionName]

val targetFile = File(targetFilePath ?: run {
val msg = "target output file option ['$optionName'] is null!"
environment.logger.warn(msg)
return emptyList()
})

environment.logger.info("target output file: ${targetFile.absolutePath}")
val targetClass = resolver.getKotlinClassByName(targetClassName)
environment.logger.info("apiClass: $targetClassName")
targetClass ?: return emptyList()

val targetClasses = resolver.getAllFiles().flatMap { it.declarations }
.filterIsInstance<KSClassDeclaration>()
.filter {
targetClass.asStarProjectedType().isAssignableFrom(it.asStarProjectedType())
}
.filter { !it.isAbstract() }
.toList()
private var targetFile: File? = null
private val targetClasses = mutableListOf<KSClassDeclaration>()

override fun finish() {
val targetFile = targetFile ?: return
if (!targetFile.exists()) {
targetFile.parentFile.mkdirs()
} else {
Expand All @@ -80,7 +61,32 @@ abstract class ReaderProcessor(private val environment: SymbolProcessorEnvironme
).use { writer ->
writer.writeDeflistTo(targetClasses)
}
}

override fun process(resolver: Resolver): List<KSAnnotated> {
val targetFilePath: String? = environment.options[optionName]

val targetFile = File(targetFilePath ?: run {
val msg = "target output file option ['$optionName'] is null!"
environment.logger.warn(msg)
return emptyList()
})

this.targetFile = targetFile

environment.logger.info("target output file: ${targetFile.absolutePath}")
val targetClass = resolver.getClassDeclarationByName(targetClassName)
environment.logger.info("apiClass: $targetClassName found $targetClass", targetClass)
targetClass ?: return emptyList()

// find all
resolver.getAllFiles().flatMap { it.declarations }
.filterIsInstance<KSClassDeclaration>()
.filter {
targetClass.asStarProjectedType().isAssignableFrom(it.asStarProjectedType())
}
.filter { !it.isAbstract() }
.toCollection(targetClasses)

return emptyList()
}
Expand All @@ -91,7 +97,7 @@ abstract class ReaderProcessor(private val environment: SymbolProcessorEnvironme
*
* @author ForteScarlet
*/
class ApiReaderProcessor(private val environment: SymbolProcessorEnvironment) : ReaderProcessor(environment) {
class ApiReaderProcessor(environment: SymbolProcessorEnvironment) : ReaderProcessor(environment) {
override val optionName: String = API_READ_TARGET_FILE_OPTION_KEY
override val targetClassName: String = KOOK_API_CLASS_NAME
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

package kook.internal.processors.apireader

import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getKotlinClassByName
import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.getVisibility
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessor
Expand Down Expand Up @@ -50,7 +49,29 @@ class EventReaderProcessor(private val environment: SymbolProcessorEnvironment)
private val targetClassName = environment.options[EVENT_READ_TARGET_CLASS_OPTION_KEY]
?: KOOK_EVENT_CLASS_NAME

@OptIn(KspExperimental::class)
private var targetFile: File? = null
private val targetClasses = mutableListOf<KSClassDeclaration>()

override fun finish() {
val targetFile = targetFile ?: return

if (!targetFile.exists()) {
targetFile.parentFile.mkdirs()
} else {
targetFile.delete()
}

targetFile.toPath().bufferedWriter(
options = arrayOf(
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.CREATE
)
).use { writer ->
writer.writeDeflistTo(targetClasses)
}
}

override fun process(resolver: Resolver): List<KSAnnotated> {
val targetFilePath: String? = environment.options[EVENT_READ_TARGET_FILE_OPTION_KEY]

Expand All @@ -59,37 +80,22 @@ class EventReaderProcessor(private val environment: SymbolProcessorEnvironment)
environment.logger.warn(msg)
return emptyList()
})
this.targetFile = targetFile

environment.logger.info("Target class name: $targetClassName")
environment.logger.info("Target output file: ${targetFile.absolutePath}")
val targetClass = resolver.getKotlinClassByName(targetClassName)
environment.logger.info("apiClass: $targetClass")
val targetClass = resolver.getClassDeclarationByName(targetClassName)
environment.logger.info("apiClass: $targetClass found at $targetClass", targetClass)
targetClass ?: return emptyList()

val targetClasses = resolver.getAllFiles().flatMap { it.declarations }
resolver.getAllFiles().flatMap { it.declarations }
.filterIsInstance<KSClassDeclaration>()
.filter {
targetClass.asStarProjectedType().isAssignableFrom(it.asStarProjectedType())
}
// .filter { !it.isAbstract() }
.filter { it.getVisibility() in EXPECT_VISIBILITY }
.toList()

if (!targetFile.exists()) {
targetFile.parentFile.mkdirs()
} else {
targetFile.delete()
}

targetFile.toPath().bufferedWriter(
options = arrayOf(
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.CREATE
)
).use { writer ->
writer.writeDeflistTo(targetClasses)
}
.toCollection(targetClasses)

return emptyList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
private const val DEFAULT_FILENAME = "unknown-file"
private const val ASSET_API_FORM_PROPERTY_NAME = "file"
private val HEADERS = Headers.build {
append(HttpHeaders.ContentType, "form-data")
append(HttpHeaders.ContentType, ContentType.MultiPart.FormData)
}

/**
Expand Down Expand Up @@ -114,7 +114,7 @@
* 提供文件数据的 [ChannelProvider] 作为上传API。
*
* @param fileChannelProvider 文件数据 [ChannelProvider]
* @param filename 使用在表单数据中 [HttpHeaders.ContentDisposition] 的 `filename` 属性,

Check warning on line 117 in simbot-component-kook-api/src/commonMain/kotlin/love/forte/simbot/kook/api/asset/CreateAssetApi.kt

View workflow job for this annotation

GitHub Actions / qodana

Unresolved reference in KDoc

Cannot resolve symbol 'HttpHeaders'
* 如果为 `null` 则会提供一个默认的文件名称 `unknown-file`。
*/
@JvmStatic
Expand Down
Loading
Loading