From ef8873f725aa52d5e03eba2f4c062ae492cda1ff Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Sat, 18 Feb 2023 19:59:31 +0300 Subject: [PATCH] feat: migrate to kotlin-wrappers:kotlin-actions-toolkit --- cache-action-entrypoint/build.gradle.kts | 3 +- .../src/main/kotlin/main.kt | 4 +- cache-proxy/build.gradle.kts | 4 +- .../burrunan/gradle/proxy/CacheProxy.kt | 10 +- .../burrunan/gradle/proxy/CacheProxyTest.kt | 2 +- cache-service-mock/build.gradle.kts | 2 +- .../burrunan/gradle/cache/CacheService.kt | 20 +-- .../burrunan/gradle/cache/HttpExtensions.kt | 2 +- gradle-launcher/build.gradle.kts | 6 +- .../burrunan/launcher/GradleInstaller.kt | 18 ++- .../burrunan/launcher/GradleLauncher.kt | 2 +- .../launcher/RetrieveGradleVersionTest.kt | 2 +- gradle.properties | 2 +- hashing/build.gradle.kts | 3 +- .../github/burrunan/hashing/HashDetails.kt | 8 +- .../com/github/burrunan/hashing/hashFiles.kt | 8 +- layered-cache/build.gradle.kts | 4 +- settings.gradle.kts | 7 +- .../github/burrunan/test/testExtensions.kt | 2 +- wrappers/actions-cache/build.gradle.kts | 5 +- .../kotlin/actions/cache/CacheExtensions.kt | 5 +- .../cache/cache.module_@actions_cache.kt | 26 ---- .../actions/cache/internal/CacheContract.kt | 7 +- .../cache/options.module_@actions_cache.kt | 30 ----- wrappers/actions-core/build.gradle.kts | 20 --- .../actions/core/core.module_@actions_core.kt | 73 ----------- .../main/kotlin/actions/core/issueCommand.kt | 25 ---- .../actions/exec/exec.module_@actions_exec.kt | 24 ---- .../exec/interfaces.module_@actions_exec.kt | 46 ------- wrappers/actions-glob/build.gradle.kts | 20 --- .../kotlin/actions/glob/GlobberExtensions.kt | 27 ---- .../actions/glob/glob.module_@actions_glob.kt | 25 ---- ...ernal-glob-options.module_@actions_glob.kt | 25 ---- .../internal-globber.module_@actions_glob.kt | 29 ----- wrappers/actions-http-client/build.gradle.kts | 20 --- .../index.module_@actions_http-client.kt | 120 ------------------ .../interfaces.module_@actions_http-client.kt | 86 ------------- wrappers/actions-io/build.gradle.kts | 19 --- .../actions/io/io.module_@actions_io.kt | 30 ----- .../main/kotlin/actions/io/ioExtensions.kt | 37 ------ wrappers/actions-tool-cache/build.gradle.kts | 19 --- .../manifest.module_@actions_tool-cache.kt | 36 ------ .../tool-cache.module_@actions_tool-cache.kt | 67 ---------- .../actions/toolcache/toolcacheExtensions.kt | 78 ------------ .../build.gradle.kts | 2 +- .../actions/core/ActionFailedException.kt | 0 .../main/kotlin/actions/core/ActionStage.kt | 0 .../kotlin/actions/core/ActionsEnvironment.kt | 2 +- .../kotlin/actions/core/LoggingExtensions.kt | 0 .../src/main/kotlin/actions/core/ext/Group.kt | 0 .../actions/core/ext/InputExtensions.kt | 2 +- .../actions/core/issueCommandExtensions.kt | 13 +- .../kotlin/actions/exec/ExecExtensions.kt | 5 +- .../main/kotlin/actions/glob/removeFiles.kt | 5 +- .../burrunan/wrappers/nodejs/FsExtensions.kt | 2 +- .../wrappers/nodejs/StreamExtensions.kt | 5 +- .../octokit-request-error/build.gradle.kts | 2 +- wrappers/octokit-types/build.gradle.kts | 2 +- wrappers/octokit-webhooks/build.gradle.kts | 2 +- 59 files changed, 79 insertions(+), 971 deletions(-) delete mode 100644 wrappers/actions-cache/src/main/kotlin/actions/cache/cache.module_@actions_cache.kt delete mode 100644 wrappers/actions-cache/src/main/kotlin/actions/cache/options.module_@actions_cache.kt delete mode 100644 wrappers/actions-core/build.gradle.kts delete mode 100644 wrappers/actions-core/src/main/kotlin/actions/core/core.module_@actions_core.kt delete mode 100644 wrappers/actions-core/src/main/kotlin/actions/core/issueCommand.kt delete mode 100644 wrappers/actions-exec/src/main/kotlin/actions/exec/exec.module_@actions_exec.kt delete mode 100644 wrappers/actions-exec/src/main/kotlin/actions/exec/interfaces.module_@actions_exec.kt delete mode 100644 wrappers/actions-glob/build.gradle.kts delete mode 100644 wrappers/actions-glob/src/main/kotlin/actions/glob/GlobberExtensions.kt delete mode 100644 wrappers/actions-glob/src/main/kotlin/actions/glob/glob.module_@actions_glob.kt delete mode 100644 wrappers/actions-glob/src/main/kotlin/actions/glob/internal-glob-options.module_@actions_glob.kt delete mode 100644 wrappers/actions-glob/src/main/kotlin/actions/glob/internal-globber.module_@actions_glob.kt delete mode 100644 wrappers/actions-http-client/build.gradle.kts delete mode 100644 wrappers/actions-http-client/src/main/kotlin/actions/httpclient/index.module_@actions_http-client.kt delete mode 100644 wrappers/actions-http-client/src/main/kotlin/actions/httpclient/interfaces.module_@actions_http-client.kt delete mode 100644 wrappers/actions-io/build.gradle.kts delete mode 100644 wrappers/actions-io/src/main/kotlin/actions/io/io.module_@actions_io.kt delete mode 100644 wrappers/actions-io/src/main/kotlin/actions/io/ioExtensions.kt delete mode 100644 wrappers/actions-tool-cache/build.gradle.kts delete mode 100644 wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/manifest.module_@actions_tool-cache.kt delete mode 100644 wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/tool-cache.module_@actions_tool-cache.kt delete mode 100644 wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/toolcacheExtensions.kt rename wrappers/{actions-exec => actions-toolkit}/build.gradle.kts (91%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/ActionFailedException.kt (100%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/ActionStage.kt (100%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/ActionsEnvironment.kt (98%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/LoggingExtensions.kt (100%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/ext/Group.kt (100%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/ext/InputExtensions.kt (95%) rename wrappers/{actions-core => actions-toolkit}/src/main/kotlin/actions/core/issueCommandExtensions.kt (84%) rename wrappers/{actions-exec => actions-toolkit}/src/main/kotlin/actions/exec/ExecExtensions.kt (96%) rename wrappers/{actions-glob => actions-toolkit}/src/main/kotlin/actions/glob/removeFiles.kt (88%) diff --git a/cache-action-entrypoint/build.gradle.kts b/cache-action-entrypoint/build.gradle.kts index 5cff07a..072e5db 100644 --- a/cache-action-entrypoint/build.gradle.kts +++ b/cache-action-entrypoint/build.gradle.kts @@ -18,8 +18,7 @@ dependencies { implementation(project(":cache-proxy")) implementation(project(":gradle-launcher")) implementation(project(":layered-cache")) - implementation(project(":wrappers:actions-core")) - implementation(project(":wrappers:actions-io")) + implementation(project(":wrappers:actions-toolkit")) implementation(project(":wrappers:nodejs")) implementation(project(":wrappers:octokit-webhooks")) implementation(npm("string-argv", "0.3.1")) diff --git a/cache-action-entrypoint/src/main/kotlin/main.kt b/cache-action-entrypoint/src/main/kotlin/main.kt index f8cee67..84bf644 100644 --- a/cache-action-entrypoint/src/main/kotlin/main.kt +++ b/cache-action-entrypoint/src/main/kotlin/main.kt @@ -27,8 +27,8 @@ import com.github.burrunan.launcher.install import com.github.burrunan.launcher.launchGradle import com.github.burrunan.launcher.resolveDistribution import com.github.burrunan.wrappers.nodejs.normalizedPath -import kotlinx.js.globalThis -import kotlinx.js.set +import js.core.globalThis +import js.core.set import node.fs.writeFile import octokit.currentTrigger import node.path.path diff --git a/cache-proxy/build.gradle.kts b/cache-proxy/build.gradle.kts index eb080b5..aa0c78c 100644 --- a/cache-proxy/build.gradle.kts +++ b/cache-proxy/build.gradle.kts @@ -20,9 +20,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.mocha.KotlinMocha dependencies { implementation(project(":cache-service-mock")) implementation(project(":wrappers:actions-cache")) - implementation(project(":wrappers:actions-core")) - implementation(project(":wrappers:actions-exec")) - implementation(project(":wrappers:actions-glob")) + implementation(project(":wrappers:actions-toolkit")) implementation(project(":wrappers:nodejs")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core") diff --git a/cache-proxy/src/main/kotlin/com/github/burrunan/gradle/proxy/CacheProxy.kt b/cache-proxy/src/main/kotlin/com/github/burrunan/gradle/proxy/CacheProxy.kt index d11fca8..f7af7b2 100644 --- a/cache-proxy/src/main/kotlin/com/github/burrunan/gradle/proxy/CacheProxy.kt +++ b/cache-proxy/src/main/kotlin/com/github/burrunan/gradle/proxy/CacheProxy.kt @@ -29,8 +29,8 @@ import node.http.ServerResponse import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.await import kotlinx.coroutines.launch -import kotlinx.js.jso -import kotlinx.js.set +import js.core.jso +import js.core.set import node.fs.Stats import node.fs.stat import node.http.OutgoingHttpHeaders @@ -52,7 +52,7 @@ class CacheProxy { val cacheUrl: String? get() = _cacheUrl - private val server = node.http.createServer { req, res -> + private val server = node.http.createServer> { req, res -> val query = node.url.parse(req.url!!, true) val path = query.pathname ?: "" res.handle { @@ -67,7 +67,7 @@ class CacheProxy { private val compression = jso { compressionMethod = CompressionMethod.Gzip } - private suspend fun putEntry(id: String, req: IncomingMessage, res: ServerResponse) { + private suspend fun putEntry(id: String, req: IncomingMessage, res: ServerResponse<*>) { val fileName = path.join(TEMP_DIR, "bc-$id") try { req.pipeAndWait(createWriteStream(fileName)) @@ -95,7 +95,7 @@ class CacheProxy { } } - private suspend fun getEntry(id: String, res: ServerResponse) { + private suspend fun getEntry(id: String, res: ServerResponse<*>) { val cacheEntry = getCacheEntry(arrayOf(id), arrayOf(id), compression).await() ?: throw HttpException.notFound("No cache entry found for $id") val archiveLocation = cacheEntry.archiveLocation diff --git a/cache-proxy/src/test/kotlin/com/github/burrunan/gradle/proxy/CacheProxyTest.kt b/cache-proxy/src/test/kotlin/com/github/burrunan/gradle/proxy/CacheProxyTest.kt index 72879e6..812c481 100644 --- a/cache-proxy/src/test/kotlin/com/github/burrunan/gradle/proxy/CacheProxyTest.kt +++ b/cache-proxy/src/test/kotlin/com/github/burrunan/gradle/proxy/CacheProxyTest.kt @@ -21,7 +21,7 @@ import actions.glob.removeFiles import com.github.burrunan.gradle.cache.CacheService import com.github.burrunan.test.runTest import com.github.burrunan.wrappers.nodejs.mkdir -import kotlinx.js.get +import js.core.get import kotlinx.serialization.json.Json import kotlinx.serialization.json.encodeToDynamic import node.fs.copyFile diff --git a/cache-service-mock/build.gradle.kts b/cache-service-mock/build.gradle.kts index 0be3033..5dcf138 100644 --- a/cache-service-mock/build.gradle.kts +++ b/cache-service-mock/build.gradle.kts @@ -16,7 +16,7 @@ dependencies { implementation(project(":wrappers:actions-cache")) - implementation(project(":wrappers:actions-core")) + implementation(project(":wrappers:actions-toolkit")) implementation(project(":wrappers:nodejs")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core") diff --git a/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/CacheService.kt b/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/CacheService.kt index 1b59e73..0d94d4c 100644 --- a/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/CacheService.kt +++ b/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/CacheService.kt @@ -21,9 +21,9 @@ import com.github.burrunan.wrappers.js.suspendWithCallback import com.github.burrunan.wrappers.nodejs.exists import com.github.burrunan.wrappers.nodejs.readJson import com.github.burrunan.wrappers.nodejs.readToBuffer -import kotlinx.js.get -import kotlinx.js.jso -import kotlinx.js.set +import js.core.get +import js.core.jso +import js.core.set import node.http.IncomingMessage import node.http.OutgoingHttpHeaders import node.http.ServerResponse @@ -41,7 +41,7 @@ class CacheService { private val storage = CacheStorage() - private val server = node.http.createServer { req, res -> + private val server = node.http.createServer> { req, res -> val query = node.url.parse(req.url!!, true) val path = query.pathname ?: "" res.handle { @@ -59,7 +59,7 @@ class CacheService { } } - private fun getContents(query: Url, res: ServerResponse) { + private fun getContents(query: Url, res: ServerResponse<*>) { val key = query.query.unsafeCast()["key"] as String val entry = storage.getValue(key) res.writeHead( @@ -71,13 +71,13 @@ class CacheService { res.write(entry.value) } - private suspend fun cacheOp(cacheId: Number, req: IncomingMessage, res: ServerResponse) = when (req.method) { + private suspend fun cacheOp(cacheId: Number, req: IncomingMessage, res: ServerResponse<*>) = when (req.method) { "PATCH" -> uploadCache(cacheId, req, res) "POST" -> commitCache(cacheId, req, res) else -> throw HttpException.notImplemented("Unknown method: ${req.method}") } - private fun getCache(query: Url, res: ServerResponse) { + private fun getCache(query: Url, res: ServerResponse<*>) { val request = query.query.unsafeCast() var resultKey: String? = null var resultEntry: CacheEntry? = null @@ -114,7 +114,7 @@ class CacheService { ) } - private suspend fun uploadCache(cacheId: Number, req: IncomingMessage, res: ServerResponse) { + private suspend fun uploadCache(cacheId: Number, req: IncomingMessage, res: ServerResponse<*>) { val contentRange = req.headers.asDynamic()["content-range"] as String val (_, start, end) = contentRange.match("bytes (\\d+)-(\\d+)") ?: arrayOf("", "", "") if (start.isEmpty()) { @@ -124,12 +124,12 @@ class CacheService { res.writeHead(200, "OK") } - private suspend fun commitCache(cacheId: Number, req: IncomingMessage, res: ServerResponse) { + private suspend fun commitCache(cacheId: Number, req: IncomingMessage, res: ServerResponse<*>) { storage.commitCache(cacheId, req.readJson().size) res.writeHead(200, "OK") } - private suspend fun reserveCache(req: IncomingMessage, res: ServerResponse) { + private suspend fun reserveCache(req: IncomingMessage, res: ServerResponse<*>) { if (req.method != "POST") { throw HttpException.badRequest("Expecting POST method, got ${req.method}") } diff --git a/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/HttpExtensions.kt b/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/HttpExtensions.kt index a0fd758..d00053d 100644 --- a/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/HttpExtensions.kt +++ b/cache-service-mock/src/main/kotlin/com/github/burrunan/gradle/cache/HttpExtensions.kt @@ -21,7 +21,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.supervisorScope -fun ServerResponse.handle(action: suspend CoroutineScope.() -> Unit) = +fun ServerResponse<*>.handle(action: suspend CoroutineScope.() -> Unit) = GlobalScope.launch { try { supervisorScope { diff --git a/gradle-launcher/build.gradle.kts b/gradle-launcher/build.gradle.kts index d8d892d..d4c39d6 100644 --- a/gradle-launcher/build.gradle.kts +++ b/gradle-launcher/build.gradle.kts @@ -16,11 +16,7 @@ dependencies { implementation(project(":hashing")) - implementation(project(":wrappers:actions-core")) - implementation(project(":wrappers:actions-exec")) - implementation(project(":wrappers:actions-http-client")) - implementation(project(":wrappers:actions-io")) - implementation(project(":wrappers:actions-tool-cache")) + implementation(project(":wrappers:actions-toolkit")) implementation(project(":wrappers:java-properties")) implementation(project(":wrappers:nodejs")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") diff --git a/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleInstaller.kt b/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleInstaller.kt index 1af43a8..27028d0 100644 --- a/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleInstaller.kt +++ b/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleInstaller.kt @@ -19,28 +19,26 @@ package com.github.burrunan.launcher import actions.core.ActionFailedException import actions.core.info import actions.core.warning -import actions.httpclient.HttpClient -import actions.httpclient.HttpCodes -import actions.httpclient.IHeaders +import actions.http.client.HttpClient +import actions.http.client.HttpCodes import actions.io.rmRF -import actions.toolcache.cacheDir -import actions.toolcache.downloadTool -import actions.toolcache.extractZip +import actions.tool.cache.cacheDir +import actions.tool.cache.downloadTool +import actions.tool.cache.extractZip import com.github.burrunan.hashing.hashFiles import com.github.burrunan.wrappers.nodejs.exists import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.await import kotlinx.coroutines.launch -import kotlinx.js.jso +import js.core.recordOf import node.buffer.BufferEncoding -import node.fs.Mode import node.fs.chmod import node.fs.readFile import node.path.path import node.process.Platform suspend fun install(distribution: GradleDistribution): String { - val cachedTool = actions.toolcache.find("gradle", distribution.version) + val cachedTool = actions.tool.cache.find("gradle", distribution.version) val gradleDir = if (cachedTool.isNotEmpty()) { info("Detected Gradle ${distribution.version} at $cachedTool") cachedTool @@ -71,7 +69,7 @@ suspend fun install(distribution: GradleDistribution): String { } } -private val HTTP_AGENT = jso { set("User-Agent", "burrunan/gradle-cache-action") } +private val HTTP_AGENT = recordOf("User-Agent" to "burrunan/gradle-cache-action") suspend fun GradleVersion.Official.findUrl(): GradleDistribution { val url = "https://services.gradle.org/versions/all" diff --git a/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleLauncher.kt b/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleLauncher.kt index ac62ce2..c22294a 100644 --- a/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleLauncher.kt +++ b/gradle-launcher/src/main/kotlin/com/github/burrunan/launcher/GradleLauncher.kt @@ -21,7 +21,7 @@ import actions.core.setOutput import actions.exec.exec import com.github.burrunan.launcher.internal.GradleErrorCollector import com.github.burrunan.launcher.internal.GradleOutErrorCollector -import kotlinx.js.jso +import js.core.jso import node.process.process class GradleResult( diff --git a/gradle-launcher/src/test/kotlin/com/github/burrunan/launcher/RetrieveGradleVersionTest.kt b/gradle-launcher/src/test/kotlin/com/github/burrunan/launcher/RetrieveGradleVersionTest.kt index 2f79dcc..fc47204 100644 --- a/gradle-launcher/src/test/kotlin/com/github/burrunan/launcher/RetrieveGradleVersionTest.kt +++ b/gradle-launcher/src/test/kotlin/com/github/burrunan/launcher/RetrieveGradleVersionTest.kt @@ -17,7 +17,7 @@ package com.github.burrunan.launcher import actions.core.info -import actions.toolcache.findAllVersions +import actions.tool.cache.findAllVersions import com.github.burrunan.test.runTest import kotlin.test.Test diff --git a/gradle.properties b/gradle.properties index 0cc6a6b..f4d84cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,4 +24,4 @@ kotlin.code.style=official kotlinx-coroutines.version=1.6.4 kotlinx-serialization.version=1.3.3 -kotlin-wrappers.version=1.0.0-pre.375 +kotlin-wrappers.version=1.0.0-pre.499 diff --git a/hashing/build.gradle.kts b/hashing/build.gradle.kts index dd7f454..8bc4d19 100644 --- a/hashing/build.gradle.kts +++ b/hashing/build.gradle.kts @@ -18,8 +18,7 @@ plugins { } dependencies { - implementation(project(":wrappers:actions-core")) - implementation(project(":wrappers:actions-glob")) + implementation(project(":wrappers:actions-toolkit")) implementation(project(":wrappers:js")) implementation(project(":wrappers:nodejs")) implementation("org.jetbrains.kotlinx:kotlinx-serialization-core") diff --git a/hashing/src/main/kotlin/com/github/burrunan/hashing/HashDetails.kt b/hashing/src/main/kotlin/com/github/burrunan/hashing/HashDetails.kt index 1fddee2..02cb118 100644 --- a/hashing/src/main/kotlin/com/github/burrunan/hashing/HashDetails.kt +++ b/hashing/src/main/kotlin/com/github/burrunan/hashing/HashDetails.kt @@ -17,11 +17,9 @@ package com.github.burrunan.hashing import actions.core.ActionFailedException import actions.core.warning -import actions.glob.Globber -import actions.glob.glob import com.github.burrunan.wrappers.nodejs.normalizedPath import com.github.burrunan.wrappers.nodejs.pipeAndWait -import kotlinx.js.jso +import kotlinx.coroutines.await import kotlinx.serialization.Serializable import node.WritableStream import node.crypto.BinaryToTextEncoding @@ -70,8 +68,8 @@ suspend fun hashFilesDetailed( algorithm: String = "sha1", includeFileName: Boolean = true, ): HashDetails = try { - val globber = Globber(paths.joinToString("\n")) - val fileNames = globber.glob() + val globber = actions.glob.create(paths.joinToString("\n")) + val fileNames = globber.glob().await() // Sorting is needed for stable overall hash fileNames.sort() diff --git a/hashing/src/main/kotlin/com/github/burrunan/hashing/hashFiles.kt b/hashing/src/main/kotlin/com/github/burrunan/hashing/hashFiles.kt index b0d7734..de92962 100644 --- a/hashing/src/main/kotlin/com/github/burrunan/hashing/hashFiles.kt +++ b/hashing/src/main/kotlin/com/github/burrunan/hashing/hashFiles.kt @@ -17,11 +17,9 @@ package com.github.burrunan.hashing import actions.core.ActionFailedException import actions.core.warning -import actions.glob.Globber -import actions.glob.glob import com.github.burrunan.wrappers.nodejs.normalizedPath import com.github.burrunan.wrappers.nodejs.pipeAndWait -import kotlinx.js.jso +import kotlinx.coroutines.await import node.WritableStream import node.buffer.BufferEncoding import node.crypto.BinaryToTextEncoding @@ -42,8 +40,8 @@ suspend fun hashFiles( algorithm: String = "sha1", includeFileName: Boolean = true, ): HashResult = try { - val globber = Globber(paths.joinToString("\n")) - val fileNames = globber.glob() + val globber = actions.glob.create(paths.joinToString("\n")) + val fileNames = globber.glob().await() fileNames.sort() val githubWorkspace = process.cwd() diff --git a/layered-cache/build.gradle.kts b/layered-cache/build.gradle.kts index bd7e65f..b6ff0cc 100644 --- a/layered-cache/build.gradle.kts +++ b/layered-cache/build.gradle.kts @@ -22,9 +22,7 @@ dependencies { implementation(project(":gradle-launcher")) implementation(project(":hashing")) implementation(project(":wrappers:actions-cache")) - implementation(project(":wrappers:actions-core")) - implementation(project(":wrappers:actions-exec")) - implementation(project(":wrappers:actions-glob")) + implementation(project(":wrappers:actions-toolkit")) implementation(project(":wrappers:nodejs")) implementation(project(":wrappers:octokit-webhooks")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") diff --git a/settings.gradle.kts b/settings.gradle.kts index 8dcd7de..a12659f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,13 +36,8 @@ include( "test-library", "wrappers:js", "wrappers:nodejs", + "wrappers:actions-toolkit", "wrappers:actions-cache", - "wrappers:actions-core", - "wrappers:actions-exec", - "wrappers:actions-glob", - "wrappers:actions-http-client", - "wrappers:actions-io", - "wrappers:actions-tool-cache", "wrappers:java-properties", "wrappers:octokit-request-error", "wrappers:octokit-types", diff --git a/test-library/src/main/kotlin/com/github/burrunan/test/testExtensions.kt b/test-library/src/main/kotlin/com/github/burrunan/test/testExtensions.kt index 4f7dfa8..b2e5825 100644 --- a/test-library/src/main/kotlin/com/github/burrunan/test/testExtensions.kt +++ b/test-library/src/main/kotlin/com/github/burrunan/test/testExtensions.kt @@ -18,7 +18,7 @@ package com.github.burrunan.test import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.promise -import kotlinx.js.set +import js.core.set import node.process.process fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise { diff --git a/wrappers/actions-cache/build.gradle.kts b/wrappers/actions-cache/build.gradle.kts index dae722c..b69b551 100644 --- a/wrappers/actions-cache/build.gradle.kts +++ b/wrappers/actions-cache/build.gradle.kts @@ -15,7 +15,6 @@ */ dependencies { - api(npm("@actions/cache", "3.0.6")) - implementation(project(":wrappers:actions-core")) - api(project(":wrappers:actions-http-client")) + implementation("org.jetbrains.kotlin-wrappers:kotlin-actions-toolkit") + implementation(project(":wrappers:actions-toolkit")) } diff --git a/wrappers/actions-cache/src/main/kotlin/actions/cache/CacheExtensions.kt b/wrappers/actions-cache/src/main/kotlin/actions/cache/CacheExtensions.kt index 81640ba..6b5e0ac 100644 --- a/wrappers/actions-cache/src/main/kotlin/actions/cache/CacheExtensions.kt +++ b/wrappers/actions-cache/src/main/kotlin/actions/cache/CacheExtensions.kt @@ -17,7 +17,6 @@ package actions.cache import actions.core.info import actions.core.warning -import kotlinx.coroutines.await suspend fun restoreAndLog( paths: List, primaryKey: String, @@ -32,7 +31,7 @@ suspend fun restoreAndLog( version + primaryKey, restoreKeys.map { version + it }.toTypedArray(), ) - }.await() + } } catch (t: Throwable) { when (t.asDynamic().name) { "ValidationError" -> throw t @@ -55,7 +54,7 @@ suspend fun saveAndLog( version: String, ) { try { - saveCache(paths.toTypedArray(), version + key).await() + saveCache(paths.toTypedArray(), version + key) } catch (t: Throwable) { // TODO: propagate error when (t.asDynamic().name) { diff --git a/wrappers/actions-cache/src/main/kotlin/actions/cache/cache.module_@actions_cache.kt b/wrappers/actions-cache/src/main/kotlin/actions/cache/cache.module_@actions_cache.kt deleted file mode 100644 index 480a5a0..0000000 --- a/wrappers/actions-cache/src/main/kotlin/actions/cache/cache.module_@actions_cache.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JsModule("@actions/cache") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.cache - -import kotlin.js.Promise - -external fun restoreCache(paths: Array, primaryKey: String, restoreKeys: Array = definedExternally, options: DownloadOptions = definedExternally): Promise - -external fun saveCache(paths: Array, key: String, options: UploadOptions = definedExternally): Promise diff --git a/wrappers/actions-cache/src/main/kotlin/actions/cache/internal/CacheContract.kt b/wrappers/actions-cache/src/main/kotlin/actions/cache/internal/CacheContract.kt index 5c5b868..6e884b8 100644 --- a/wrappers/actions-cache/src/main/kotlin/actions/cache/internal/CacheContract.kt +++ b/wrappers/actions-cache/src/main/kotlin/actions/cache/internal/CacheContract.kt @@ -17,7 +17,6 @@ package actions.cache.internal import actions.cache.HttpClientError -import actions.httpclient.ITypedResponse external interface GetCacheParams { val keys: String @@ -59,6 +58,12 @@ external enum class CompressionMethod { Zstd } +external interface ITypedResponse { + var statusCode: Number + var result: T? + var headers: Any +} + external interface ITypedResponseWithError: ITypedResponse { val error: HttpClientError? } diff --git a/wrappers/actions-cache/src/main/kotlin/actions/cache/options.module_@actions_cache.kt b/wrappers/actions-cache/src/main/kotlin/actions/cache/options.module_@actions_cache.kt deleted file mode 100644 index eb893b7..0000000 --- a/wrappers/actions-cache/src/main/kotlin/actions/cache/options.module_@actions_cache.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.cache - -external interface UploadOptions { - var uploadConcurrency: Number? - var uploadChunkSize: Number? -} - -external interface DownloadOptions { - var useAzureSdk: Boolean? - var downloadConcurrency: Number? - var timeoutInMs: Number? -} diff --git a/wrappers/actions-core/build.gradle.kts b/wrappers/actions-core/build.gradle.kts deleted file mode 100644 index 3d38672..0000000 --- a/wrappers/actions-core/build.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -dependencies { - api(npm("@actions/core", "1.10.0")) - implementation(project(":wrappers:nodejs")) -} diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/core.module_@actions_core.kt b/wrappers/actions-core/src/main/kotlin/actions/core/core.module_@actions_core.kt deleted file mode 100644 index 52667b1..0000000 --- a/wrappers/actions-core/src/main/kotlin/actions/core/core.module_@actions_core.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JsModule("@actions/core") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.core - -import kotlin.js.Promise - -external interface InputOptions { - var required: Boolean? -} - -external enum class ExitCode { - Success /* = 0 */, - Failure /* = 1 */ -} - -external fun exportVariable(name: String, param_val: Any) - -external fun setSecret(secret: String) - -external fun addPath(inputPath: String) - -external fun getInput(name: String, options: InputOptions = definedExternally): String - -external fun setOutput(name: String, value: Any) - -external fun setCommandEcho(enabled: Boolean) - -external fun setFailed(message: String) - -external fun setFailed(message: Error) - -external fun isDebug(): Boolean - -external fun debug(message: String) - -// See error(message, file, line, col) -// external fun error(message: String) - -external fun error(message: Error) - -// See warning(message, file, line, col) -// external fun warning(message: String) - -external fun warning(message: Error) - -external fun info(message: String) - -external fun startGroup(name: String) - -external fun endGroup() - -external fun group(name: String, fn: () -> Promise): Promise - -external fun saveState(name: String, value: Any) - -external fun getState(name: String): String diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/issueCommand.kt b/wrappers/actions-core/src/main/kotlin/actions/core/issueCommand.kt deleted file mode 100644 index b78fe39..0000000 --- a/wrappers/actions-core/src/main/kotlin/actions/core/issueCommand.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JsModule("@actions/core/lib/command") -package actions.core - -@JsName("issueCommand") -external fun issueCommandRaw( - command: String, - properties: dynamic, - message: Any -) diff --git a/wrappers/actions-exec/src/main/kotlin/actions/exec/exec.module_@actions_exec.kt b/wrappers/actions-exec/src/main/kotlin/actions/exec/exec.module_@actions_exec.kt deleted file mode 100644 index 08e7e29..0000000 --- a/wrappers/actions-exec/src/main/kotlin/actions/exec/exec.module_@actions_exec.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JsModule("@actions/exec") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.exec - -import kotlin.js.Promise - -external fun exec(commandLine: String, args: Array = definedExternally, options: ExecOptions = definedExternally): Promise diff --git a/wrappers/actions-exec/src/main/kotlin/actions/exec/interfaces.module_@actions_exec.kt b/wrappers/actions-exec/src/main/kotlin/actions/exec/interfaces.module_@actions_exec.kt deleted file mode 100644 index 5e975c3..0000000 --- a/wrappers/actions-exec/src/main/kotlin/actions/exec/interfaces.module_@actions_exec.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.exec - -import node.buffer.Buffer -import node.process.ProcessEnv - -import node.stream.Writable - -external interface ExecListeners { - var stdout: ((data: Buffer) -> Unit)? - var stderr: ((data: Buffer) -> Unit)? - var stdline: ((data: String) -> Unit)? - var errline: ((data: String) -> Unit)? - var debug: ((data: String) -> Unit)? -} - -external interface ExecOptions { - var cwd: String? - var env: ProcessEnv? - var silent: Boolean? - var outStream: Writable? - var errStream: Writable? - var windowsVerbatimArguments: Boolean? - var failOnStdErr: Boolean? - var ignoreReturnCode: Boolean? - var delay: Number? - var input: Buffer? - var listeners: ExecListeners? -} diff --git a/wrappers/actions-glob/build.gradle.kts b/wrappers/actions-glob/build.gradle.kts deleted file mode 100644 index befca17..0000000 --- a/wrappers/actions-glob/build.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -dependencies { - api(project(":wrappers:nodejs")) - api(npm("@actions/glob", "0.3.0")) -} diff --git a/wrappers/actions-glob/src/main/kotlin/actions/glob/GlobberExtensions.kt b/wrappers/actions-glob/src/main/kotlin/actions/glob/GlobberExtensions.kt deleted file mode 100644 index a808414..0000000 --- a/wrappers/actions-glob/src/main/kotlin/actions/glob/GlobberExtensions.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package actions.glob - -import kotlinx.coroutines.await - -suspend fun Globber(patterns: String) = - createAsync(patterns).await() - -suspend fun Globber(patterns: String, options: GlobOptions) = - createAsync(patterns, options).await() - -suspend fun Globber.glob() = globAsync().await() diff --git a/wrappers/actions-glob/src/main/kotlin/actions/glob/glob.module_@actions_glob.kt b/wrappers/actions-glob/src/main/kotlin/actions/glob/glob.module_@actions_glob.kt deleted file mode 100644 index f2859a2..0000000 --- a/wrappers/actions-glob/src/main/kotlin/actions/glob/glob.module_@actions_glob.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JsModule("@actions/glob") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.glob - -import kotlin.js.Promise - -@JsName("create") -external fun createAsync(patterns: String, options: GlobOptions = definedExternally): Promise diff --git a/wrappers/actions-glob/src/main/kotlin/actions/glob/internal-glob-options.module_@actions_glob.kt b/wrappers/actions-glob/src/main/kotlin/actions/glob/internal-glob-options.module_@actions_glob.kt deleted file mode 100644 index 1663266..0000000 --- a/wrappers/actions-glob/src/main/kotlin/actions/glob/internal-glob-options.module_@actions_glob.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.glob - -external interface GlobOptions { - var followSymbolicLinks: Boolean? - var implicitDescendants: Boolean? - var omitBrokenSymbolicLinks: Boolean? -} diff --git a/wrappers/actions-glob/src/main/kotlin/actions/glob/internal-globber.module_@actions_glob.kt b/wrappers/actions-glob/src/main/kotlin/actions/glob/internal-globber.module_@actions_glob.kt deleted file mode 100644 index cec721c..0000000 --- a/wrappers/actions-glob/src/main/kotlin/actions/glob/internal-globber.module_@actions_glob.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.glob - -//import AsyncGenerator__2 -import kotlin.js.Promise - -external interface Globber { - fun getSearchPaths(): Array - @JsName("glob") - fun globAsync(): Promise> -// fun globGenerator(): AsyncGenerator__2 -} diff --git a/wrappers/actions-http-client/build.gradle.kts b/wrappers/actions-http-client/build.gradle.kts deleted file mode 100644 index 8639505..0000000 --- a/wrappers/actions-http-client/build.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -dependencies { - implementation(project(":wrappers:nodejs")) - implementation(npm("@actions/http-client", "2.0.1")) -} diff --git a/wrappers/actions-http-client/src/main/kotlin/actions/httpclient/index.module_@actions_http-client.kt b/wrappers/actions-http-client/src/main/kotlin/actions/httpclient/index.module_@actions_http-client.kt deleted file mode 100644 index e1eabcf..0000000 --- a/wrappers/actions-http-client/src/main/kotlin/actions/httpclient/index.module_@actions_http-client.kt +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JsModule("@actions/http-client") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.httpclient - -import node.http.Agent -import node.http.IncomingMessage -import node.stream.ReadableStream -import kotlin.js.Promise - -external enum class HttpCodes { - OK /* = 200 */, - MultipleChoices /* = 300 */, - MovedPermanently /* = 301 */, - ResourceMoved /* = 302 */, - SeeOther /* = 303 */, - NotModified /* = 304 */, - UseProxy /* = 305 */, - SwitchProxy /* = 306 */, - TemporaryRedirect /* = 307 */, - PermanentRedirect /* = 308 */, - BadRequest /* = 400 */, - Unauthorized /* = 401 */, - PaymentRequired /* = 402 */, - Forbidden /* = 403 */, - NotFound /* = 404 */, - MethodNotAllowed /* = 405 */, - NotAcceptable /* = 406 */, - ProxyAuthenticationRequired /* = 407 */, - RequestTimeout /* = 408 */, - Conflict /* = 409 */, - Gone /* = 410 */, - TooManyRequests /* = 429 */, - InternalServerError /* = 500 */, - NotImplemented /* = 501 */, - BadGateway /* = 502 */, - ServiceUnavailable /* = 503 */, - GatewayTimeout /* = 504 */ -} - -external enum class Headers { - Accept /* = "accept" */, - ContentType /* = "content-type" */ -} - -external enum class MediaTypes { - ApplicationJson /* = "application/json" */ -} - -external fun getProxyUrl(serverUrl: String): String - -external open class HttpClientResponse(message: IncomingMessage) : IHttpClientResponse { - override var message: IncomingMessage - override fun readBody(): Promise -} - -external fun isHttps(requestUrl: String): Boolean - -external open class HttpClient(userAgent: String = definedExternally, handlers: Array = definedExternally, requestOptions: IRequestOptions = definedExternally) { - open var userAgent: String? - open var handlers: Array - open var requestOptions: IRequestOptions - open var _ignoreSslError: Any - open var _socketTimeout: Any - open var _allowRedirects: Any - open var _allowRedirectDowngrade: Any - open var _maxRedirects: Any - open var _allowRetries: Any - open var _maxRetries: Any - open var _agent: Any - open var _proxyAgent: Any - open var _keepAlive: Any - open var _disposed: Any - open fun options(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun get(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun del(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun post(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun patch(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun put(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun head(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - open fun sendStream(verb: String, requestUrl: String, stream: ReadableStream, additionalHeaders: IHeaders = definedExternally): Promise - open fun getJson(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise> - open fun postJson(requestUrl: String, obj: Any, additionalHeaders: IHeaders = definedExternally): Promise> - open fun putJson(requestUrl: String, obj: Any, additionalHeaders: IHeaders = definedExternally): Promise> - open fun patchJson(requestUrl: String, obj: Any, additionalHeaders: IHeaders = definedExternally): Promise> - open fun request(verb: String, requestUrl: String, data: String, headers: IHeaders): Promise - open fun request(verb: String, requestUrl: String, data: ReadableStream, headers: IHeaders): Promise - open fun dispose() - open fun requestRaw(info: IRequestInfo, data: String): Promise - open fun requestRaw(info: IRequestInfo, data: ReadableStream): Promise - open fun requestRawWithCallback(info: IRequestInfo, data: String, onResult: (err: Any, res: IHttpClientResponse) -> Unit) - open fun requestRawWithCallback(info: IRequestInfo, data: ReadableStream, onResult: (err: Any, res: IHttpClientResponse) -> Unit) - open fun getAgent(serverUrl: String): Agent - open var _prepareRequest: Any - open var _mergeHeaders: Any - open var _getExistingOrDefaultHeader: Any - open var _getAgent: Any - open var _performExponentialBackoff: Any - open var _processResponse: Any - - companion object { - var dateTimeDeserializer: Any - } -} diff --git a/wrappers/actions-http-client/src/main/kotlin/actions/httpclient/interfaces.module_@actions_http-client.kt b/wrappers/actions-http-client/src/main/kotlin/actions/httpclient/interfaces.module_@actions_http-client.kt deleted file mode 100644 index 44e19be..0000000 --- a/wrappers/actions-http-client/src/main/kotlin/actions/httpclient/interfaces.module_@actions_http-client.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", - "DEPRECATION") - -package actions.httpclient - -import node.http.IncomingMessage -import node.http.RequestOptions -import node.stream.ReadableStream -import node.url.Url -import kotlin.js.Promise - -external interface IHeaders { - @nativeGetter - operator fun get(key: String): Any? - @nativeSetter - operator fun set(key: String, value: Any) -} - -external interface IHttpClient { - fun options(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - fun get(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - fun del(requestUrl: String, additionalHeaders: IHeaders = definedExternally): Promise - fun post(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise - fun patch(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise - fun put(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise - fun sendStream(verb: String, requestUrl: String, stream: ReadableStream, additionalHeaders: IHeaders = definedExternally): Promise - fun request(verb: String, requestUrl: String, data: String, headers: IHeaders): Promise - fun request(verb: String, requestUrl: String, data: ReadableStream, headers: IHeaders): Promise - fun requestRaw(info: IRequestInfo, data: String): Promise - fun requestRaw(info: IRequestInfo, data: ReadableStream): Promise - fun requestRawWithCallback(info: IRequestInfo, data: String, onResult: (err: Any, res: IHttpClientResponse) -> Unit) - fun requestRawWithCallback(info: IRequestInfo, data: ReadableStream, onResult: (err: Any, res: IHttpClientResponse) -> Unit) -} - -external interface IRequestHandler { - fun prepareRequest(options: RequestOptions) - fun canHandleAuthentication(response: IHttpClientResponse): Boolean - fun handleAuthentication(httpClient: IHttpClient, requestInfo: IRequestInfo, objs: Any): Promise -} - -external interface IHttpClientResponse { - var message: IncomingMessage - fun readBody(): Promise -} - -external interface IRequestInfo { - var options: RequestOptions - var parsedUrl: Url - var httpModule: Any -} - -external interface IRequestOptions { - var headers: IHeaders? - var socketTimeout: Number? - var ignoreSslError: Boolean? - var allowRedirects: Boolean? - var allowRedirectDowngrade: Boolean? - var maxRedirects: Number? - var maxSockets: Number? - var keepAlive: Boolean? - var deserializeDates: Boolean? - var allowRetries: Boolean? - var maxRetries: Number? -} - -external interface ITypedResponse { - var statusCode: Number - var result: T? - var headers: Any -} diff --git a/wrappers/actions-io/build.gradle.kts b/wrappers/actions-io/build.gradle.kts deleted file mode 100644 index 07f5746..0000000 --- a/wrappers/actions-io/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -dependencies { - api(npm("@actions/io", "1.1.2")) -} diff --git a/wrappers/actions-io/src/main/kotlin/actions/io/io.module_@actions_io.kt b/wrappers/actions-io/src/main/kotlin/actions/io/io.module_@actions_io.kt deleted file mode 100644 index 99ac1b3..0000000 --- a/wrappers/actions-io/src/main/kotlin/actions/io/io.module_@actions_io.kt +++ /dev/null @@ -1,30 +0,0 @@ -@file:JsModule("@actions/io") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.io - -import kotlin.js.Promise - -external interface CopyOptions { - var recursive: Boolean? - var force: Boolean? -} - -external interface MoveOptions { - var force: Boolean? -} - -@JsName("cp") -external fun cpAsync(source: String, dest: String, options: CopyOptions = definedExternally): Promise - -@JsName("mv") -external fun mvAsync(source: String, dest: String, options: MoveOptions = definedExternally): Promise - -@JsName("rmRF") -external fun rmRFAsync(inputPath: String): Promise - -@JsName("mkdirP") -external fun mkdirPAsync(fsPath: String): Promise - -@JsName("which") -external fun whichAsync(tool: String, check: Boolean = definedExternally): Promise diff --git a/wrappers/actions-io/src/main/kotlin/actions/io/ioExtensions.kt b/wrappers/actions-io/src/main/kotlin/actions/io/ioExtensions.kt deleted file mode 100644 index 9e53cdf..0000000 --- a/wrappers/actions-io/src/main/kotlin/actions/io/ioExtensions.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package actions.io - -import kotlinx.coroutines.await -import kotlinx.js.jso - -suspend fun cp(source: String, dest: String, recursive: Boolean = false, force: Boolean = false) = - cpAsync(source, dest, jso { - this.recursive = recursive - this.force = force - }).await() - -suspend fun mv(source: String, dest: String, force: Boolean = false) = - mvAsync(source, dest, jso { - this.force = force - }).await() - -suspend fun rmRF(inputPath: String) = rmRFAsync(inputPath).await() - -suspend fun mkdirP(fsPath: String) = mkdirPAsync(fsPath).await() - -suspend fun which(tool: String, check: Boolean = false) = whichAsync(tool, check).await() diff --git a/wrappers/actions-tool-cache/build.gradle.kts b/wrappers/actions-tool-cache/build.gradle.kts deleted file mode 100644 index 3403594..0000000 --- a/wrappers/actions-tool-cache/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -dependencies { - api(npm("@actions/tool-cache", "2.0.1")) -} diff --git a/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/manifest.module_@actions_tool-cache.kt b/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/manifest.module_@actions_tool-cache.kt deleted file mode 100644 index cca1bad..0000000 --- a/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/manifest.module_@actions_tool-cache.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.toolcache - -external interface IToolReleaseFile { - var filename: String - var platform: String - var platform_version: String? - var arch: String - var download_url: String -} - -external interface IToolRelease { - var version: String - var stable: Boolean - var release_url: String - var files: Array -} - -typealias HTTPError = Error diff --git a/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/tool-cache.module_@actions_tool-cache.kt b/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/tool-cache.module_@actions_tool-cache.kt deleted file mode 100644 index e095326..0000000 --- a/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/tool-cache.module_@actions_tool-cache.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@file:JsModule("@actions/tool-cache") -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") - -package actions.toolcache - -import kotlin.js.Promise - -@JsName("downloadTool") -external fun downloadToolAsync(url: String, dest: String = definedExternally, auth: String = definedExternally): Promise - -@JsName("extract7z") -external fun extract7zAsync(file: String, dest: String = definedExternally, _7zPath: String = definedExternally): Promise - -@JsName("extractTar") -external fun extractTarAsync(file: String): Promise - -@JsName("extractTar") -external fun extractTarAsync(file: String, dest: String = definedExternally): Promise - -@JsName("extractTar") -external fun extractTarAsync(file: String, dest: String, flags: String): Promise - -@JsName("extractTar") -external fun extractTarAsync(file: String, dest: String, flags: Array): Promise - -@JsName("extractXar") -external fun extractXarAsync(file: String, dest: String = definedExternally): Promise - -@JsName("extractXar") -external fun extractXarAsync(file: String, dest: String, flags: String): Promise - -@JsName("extractXar") -external fun extractXarAsync(file: String, dest: String, flags: Array): Promise - -@JsName("extractZip") -external fun extractZipAsync(file: String, dest: String = definedExternally): Promise - -@JsName("cacheDir") -external fun cacheDirAsync(sourceDir: String, tool: String, version: String, arch: String = definedExternally): Promise - -@JsName("cacheFile") -external fun cacheFileAsync(sourceFile: String, targetFile: String, tool: String, version: String, arch: String = definedExternally): Promise - -external fun find(toolName: String, versionSpec: String, arch: String = definedExternally): String - -external fun findAllVersions(toolName: String, arch: String = definedExternally): Array - -@JsName("getManifestFromRepo") -external fun getManifestFromRepoAsync(owner: String, repo: String, auth: String = definedExternally, branch: String = definedExternally): Promise> - -@JsName("findFromManifest") -external fun findFromManifestAsync(versionSpec: String, stable: Boolean, manifest: Array, archFilter: String = definedExternally): Promise diff --git a/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/toolcacheExtensions.kt b/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/toolcacheExtensions.kt deleted file mode 100644 index 759c4e4..0000000 --- a/wrappers/actions-tool-cache/src/main/kotlin/actions/toolcache/toolcacheExtensions.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2020 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package actions.toolcache - -import kotlinx.coroutines.await - -suspend fun downloadTool(url: String) = downloadToolAsync(url).await() -suspend fun downloadTool(url: String, dest: String) = downloadToolAsync(url, dest).await() -suspend fun downloadTool(url: String, dest: String, auth: String) = downloadToolAsync(url, dest, auth).await() - -suspend fun extract7z(file: String) = - extract7zAsync(file).await() -suspend fun extract7z(file: String, dest: String) = - extract7zAsync(file, dest).await() -suspend fun extract7z(file: String, dest: String, _7zPath: String) = - extract7zAsync(file, dest, _7zPath).await() - -suspend fun extractTar(file: String) = - extractTarAsync(file).await() -suspend fun extractTar(file: String, dest: String) = - extractTarAsync(file, dest).await() -suspend fun extractTar(file: String, dest: String, flags: String) = - extractTarAsync(file, dest, flags).await() -suspend fun extractTar(file: String, dest: String, flags: Array) = - extractTarAsync(file, dest, flags).await() - -suspend fun extractXar(file: String) = - extractXarAsync(file).await() -suspend fun extractXar(file: String, dest: String) = - extractXarAsync(file, dest).await() -suspend fun extractXar(file: String, dest: String, flags: String) = - extractXarAsync(file, dest, flags).await() - -suspend fun extractXar(file: String, dest: String, flags: Array) = - extractXarAsync(file, dest, flags).await() - -suspend fun extractZip(file: String) = - extractZipAsync(file).await() - -suspend fun extractZip(file: String, dest: String) = - extractZipAsync(file, dest).await() - -suspend fun cacheDir(sourceDir: String, tool: String, version: String) = - cacheDirAsync(sourceDir, tool, version).await() - -suspend fun cacheDir(sourceDir: String, tool: String, version: String, arch: String) = - cacheDirAsync(sourceDir, tool, version, arch).await() - -suspend fun cacheFile(sourceFile: String, targetFile: String, tool: String, version: String) = - cacheFileAsync(sourceFile, targetFile, tool, version).await() -suspend fun cacheFile(sourceFile: String, targetFile: String, tool: String, version: String, arch: String) = - cacheFileAsync(sourceFile, targetFile, tool, version, arch).await() - -suspend fun getManifestFromRepo(owner: String, repo: String) = - getManifestFromRepoAsync(owner, repo).await() -suspend fun getManifestFromRepo(owner: String, repo: String, auth: String) = - getManifestFromRepoAsync(owner, repo, auth).await() -suspend fun getManifestFromRepo(owner: String, repo: String, auth: String, branch: String) = - getManifestFromRepoAsync(owner, repo, auth, branch).await() - -suspend fun findFromManifest(versionSpec: String, stable: Boolean, manifest: Array) = - findFromManifestAsync(versionSpec, stable, manifest).await() -suspend fun findFromManifest(versionSpec: String, stable: Boolean, manifest: Array, archFilter: String) = - findFromManifestAsync(versionSpec, stable, manifest, archFilter).await() diff --git a/wrappers/actions-exec/build.gradle.kts b/wrappers/actions-toolkit/build.gradle.kts similarity index 91% rename from wrappers/actions-exec/build.gradle.kts rename to wrappers/actions-toolkit/build.gradle.kts index 4741bf5..3c57a08 100644 --- a/wrappers/actions-exec/build.gradle.kts +++ b/wrappers/actions-toolkit/build.gradle.kts @@ -16,5 +16,5 @@ dependencies { api(project(":wrappers:nodejs")) - api(npm("@actions/exec", "1.1.1")) + api("org.jetbrains.kotlin-wrappers:kotlin-actions-toolkit") } diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/ActionFailedException.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionFailedException.kt similarity index 100% rename from wrappers/actions-core/src/main/kotlin/actions/core/ActionFailedException.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionFailedException.kt diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/ActionStage.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionStage.kt similarity index 100% rename from wrappers/actions-core/src/main/kotlin/actions/core/ActionStage.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionStage.kt diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/ActionsEnvironment.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionsEnvironment.kt similarity index 98% rename from wrappers/actions-core/src/main/kotlin/actions/core/ActionsEnvironment.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionsEnvironment.kt index 1d64c0f..abc8f40 100644 --- a/wrappers/actions-core/src/main/kotlin/actions/core/ActionsEnvironment.kt +++ b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ActionsEnvironment.kt @@ -15,7 +15,7 @@ */ package actions.core -import kotlinx.js.get +import js.core.get import node.process.process import kotlin.reflect.KProperty diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/LoggingExtensions.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/LoggingExtensions.kt similarity index 100% rename from wrappers/actions-core/src/main/kotlin/actions/core/LoggingExtensions.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/LoggingExtensions.kt diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/ext/Group.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ext/Group.kt similarity index 100% rename from wrappers/actions-core/src/main/kotlin/actions/core/ext/Group.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/ext/Group.kt diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/ext/InputExtensions.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ext/InputExtensions.kt similarity index 95% rename from wrappers/actions-core/src/main/kotlin/actions/core/ext/InputExtensions.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/ext/InputExtensions.kt index fca51b7..e2079ed 100644 --- a/wrappers/actions-core/src/main/kotlin/actions/core/ext/InputExtensions.kt +++ b/wrappers/actions-toolkit/src/main/kotlin/actions/core/ext/InputExtensions.kt @@ -1,6 +1,6 @@ package actions.core.ext -import kotlinx.js.jso +import js.core.jso fun getInput(name: String, required: Boolean = false): String = actions.core.getInput(name, jso { this.required = required }) diff --git a/wrappers/actions-core/src/main/kotlin/actions/core/issueCommandExtensions.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/core/issueCommandExtensions.kt similarity index 84% rename from wrappers/actions-core/src/main/kotlin/actions/core/issueCommandExtensions.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/core/issueCommandExtensions.kt index 2f79bec..5446632 100644 --- a/wrappers/actions-core/src/main/kotlin/actions/core/issueCommandExtensions.kt +++ b/wrappers/actions-toolkit/src/main/kotlin/actions/core/issueCommandExtensions.kt @@ -16,16 +16,23 @@ package actions.core -import kotlinext.js.js +import js.core.jso -inline fun issueCommand(command: String, message: String, properties: dynamic.() -> Unit = {}) = - issueCommandRaw(command, js(properties), message) +external interface TypedCommandProperties : CommandProperties { + var file: String + var line: Int + var col: Int +} + +inline fun issueCommand(command: String, message: String, properties: TypedCommandProperties.() -> Unit = {}) = + issueCommand(command, jso(properties), message) fun warning(message: String, file: String? = null, line: Int? = null, col: Int? = null) { if (file == null) { issueCommand("warning", message) return } + issueCommand("warning", message) { this.file = file line?.let { v -> this.line = v } diff --git a/wrappers/actions-exec/src/main/kotlin/actions/exec/ExecExtensions.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/exec/ExecExtensions.kt similarity index 96% rename from wrappers/actions-exec/src/main/kotlin/actions/exec/ExecExtensions.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/exec/ExecExtensions.kt index a5db4bb..ae28102 100644 --- a/wrappers/actions-exec/src/main/kotlin/actions/exec/ExecExtensions.kt +++ b/wrappers/actions-toolkit/src/main/kotlin/actions/exec/ExecExtensions.kt @@ -15,8 +15,7 @@ */ package actions.exec -import kotlinx.js.jso -import kotlinx.coroutines.await +import js.core.jso class ExecResult( val exitCode: Int, @@ -49,7 +48,7 @@ suspend fun exec( } } } - ).await() + ) return ExecResult( exitCode = exitCode.toInt(), stdout = stdout.joinToString("\n"), diff --git a/wrappers/actions-glob/src/main/kotlin/actions/glob/removeFiles.kt b/wrappers/actions-toolkit/src/main/kotlin/actions/glob/removeFiles.kt similarity index 88% rename from wrappers/actions-glob/src/main/kotlin/actions/glob/removeFiles.kt rename to wrappers/actions-toolkit/src/main/kotlin/actions/glob/removeFiles.kt index bb5a333..bf3ef1d 100644 --- a/wrappers/actions-glob/src/main/kotlin/actions/glob/removeFiles.kt +++ b/wrappers/actions-toolkit/src/main/kotlin/actions/glob/removeFiles.kt @@ -16,6 +16,7 @@ package actions.glob +import kotlinx.coroutines.await import kotlinx.coroutines.launch import kotlinx.coroutines.supervisorScope import node.fs.unlink @@ -24,8 +25,8 @@ suspend fun removeFiles(files: List) { if (files.isEmpty()) { return } - val globber = Globber(files.joinToString("\n")) - val fileNames = globber.glob() + val globber = create(files.joinToString("\n")) + val fileNames = globber.glob().await() supervisorScope { for (file in fileNames) { launch { diff --git a/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/FsExtensions.kt b/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/FsExtensions.kt index 51a5c67..c5f02b7 100644 --- a/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/FsExtensions.kt +++ b/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/FsExtensions.kt @@ -15,7 +15,7 @@ */ package com.github.burrunan.wrappers.nodejs -import kotlinx.js.jso +import js.core.jso import node.fs.MakeDirectoryOptions import node.fs.existsSync import node.fs.mkdir diff --git a/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/StreamExtensions.kt b/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/StreamExtensions.kt index 28a2a14..e2ede05 100644 --- a/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/StreamExtensions.kt +++ b/wrappers/nodejs/src/main/kotlin/com/github/burrunan/wrappers/nodejs/StreamExtensions.kt @@ -16,18 +16,19 @@ package com.github.burrunan.wrappers.nodejs -import kotlinx.js.jso +import js.core.jso import node.ReadableStream import node.WritableStream import node.buffer.Buffer import node.buffer.BufferEncoding +import node.events.Event import node.stream.finished suspend fun ReadableStream.readJson(): T = JSON.parse(readToBuffer().toString(BufferEncoding.utf8)) suspend fun ReadableStream.readToBuffer(): Buffer { val data = mutableListOf() - on("data") { chunk: Any -> + on(Event.DATA) { chunk: Any -> data += chunk as Buffer } finished(this) diff --git a/wrappers/octokit-request-error/build.gradle.kts b/wrappers/octokit-request-error/build.gradle.kts index a78dad3..7f3087c 100644 --- a/wrappers/octokit-request-error/build.gradle.kts +++ b/wrappers/octokit-request-error/build.gradle.kts @@ -16,5 +16,5 @@ dependencies { api(project(":wrappers:octokit-types")) - api(npm("@octokit/request-error", "3.0.0")) + api("org.jetbrains.kotlin-wrappers:kotlin-actions-toolkit") } diff --git a/wrappers/octokit-types/build.gradle.kts b/wrappers/octokit-types/build.gradle.kts index 6b3f210..3c57a08 100644 --- a/wrappers/octokit-types/build.gradle.kts +++ b/wrappers/octokit-types/build.gradle.kts @@ -16,5 +16,5 @@ dependencies { api(project(":wrappers:nodejs")) - api(npm("@octokit/types", "6.39.0")) + api("org.jetbrains.kotlin-wrappers:kotlin-actions-toolkit") } diff --git a/wrappers/octokit-webhooks/build.gradle.kts b/wrappers/octokit-webhooks/build.gradle.kts index eab223f..945cdf8 100644 --- a/wrappers/octokit-webhooks/build.gradle.kts +++ b/wrappers/octokit-webhooks/build.gradle.kts @@ -17,5 +17,5 @@ dependencies { api(project(":wrappers:octokit-request-error")) api(npm("@octokit/webhooks", "10.0.8")) - implementation(project(":wrappers:actions-core")) + implementation(project(":wrappers:actions-toolkit")) }