Skip to content

Commit

Permalink
Replace Dukat generated actions toolkit packages by kotlin-wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Feb 16, 2023
1 parent c15c4a6 commit d7655c1
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 185 deletions.
76 changes: 5 additions & 71 deletions gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,16 @@ configure<NodeJsRootExtension> {
dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(platform(libs.kotlin.wrappers.bom))
implementation(libs.kotlin.wrapper.actions.toolkit)
implementation(libs.kotlin.wrapper.js)
implementation(libs.kotlin.wrapper.node)
implementation(npm(libs.actions.cache))
implementation(npm(libs.actions.core))
implementation(npm(libs.actions.exec))
implementation(npm(libs.actions.http.client))
implementation(npm(libs.actions.io))
implementation(npm(libs.actions.tool.cache))
implementation(npm(libs.types.semver))
implementation(npm(libs.semver, generateExternals = false))
implementation(npm(libs.nullWritable))
}

tasks.withType(IntegratedDukatTask::class).configureEach {
doLast {
// work-around for https://github.com/Kotlin/dukat/issues/240
addJsModuleAnnotations(
this,
"core.module_@actions_core.kt" to "@actions/core",
"io.module_@actions_io.kt" to "@actions/io",
"exec.module_@actions_exec.kt" to "@actions/exec",
"index.module_@actions_http-client.kt" to "@actions/http-client",
"tool-cache.module_@actions_tool-cache.kt" to "@actions/tool-cache",
"cache.module_@actions_cache.kt" to "@actions/cache"
)
// work-around for https://github.com/Kotlin/dukat/issues/397
deleteExternalsFiles(
this,
Expand All @@ -164,31 +149,12 @@ tasks.withType(IntegratedDukatTask::class).configureEach {
)
fixExternalsFiles(
this,
"index.module_@actions_http-client.kt" to listOf(
"""\Qimport http.IncomingMessage\E$""" to "import node.http.IncomingMessage",
"""\Qimport http.OutgoingHttpHeaders\E$""" to "import node.http.OutgoingHttpHeaders",
"""\Qimport NodeJS.ReadableStream\E$""" to "import node.ReadableStream",
"""\Qimport http.Agent\E$""" to "import node.http.Agent",
"""\Qtypealias HttpClientError = Error\E$""" to "external class HttpClientError : Throwable"
),
"interfaces.module_@actions_exec.kt" to listOf(
"""\Qimport stream.internal.Writable\E$""" to "import node.stream.Writable",
"""\Qimport buffer.global.Buffer\E$""" to "import node.buffer.Buffer",
"""\Qvar env: `T$2`?\E\r?\n\Q get() = definedExternally\E\r?\n\Q set(value) = definedExternally\E""" to "var env: js.core.ReadonlyRecord<String, String>?"
),
"interfaces.module_@actions_http-client.kt" to listOf(
"""\Qimport http.OutgoingHttpHeaders\E$""" to "import node.http.OutgoingHttpHeaders",
"""\Qimport NodeJS.ReadableStream\E$""" to "import node.ReadableStream",
"""\Qimport http.IncomingHttpHeaders\E$""" to "import node.http.IncomingHttpHeaders",
"""\Qexternal interface HttpClient {\E$""" to "external interface HttpClient2 {",
"""\Qoptions: http.RequestOptions\E(\))?$""" to "options: node.http.RequestOptions$1"
),
"lib.dom.kt" to listOf(
"""\Qimport url.URL as _URL\E$""" to "import node.url.URL as _URL",
"""\Qimport url.URLSearchParams as _URLSearchParams\E$""" to "import node.url.URLSearchParams as _URLSearchParams",
"""\Qoverride fun addEventListener(type: String, listener: EventListenerObject\E""" to "fun addEventListener(type: String, listener: EventListenerObject",
"""\Qoverride fun removeEventListener(type: String, callback: EventListenerObject\E""" to "fun removeEventListener(type: String, callback: EventListenerObject",
"""\Q`T$16`\E""" to """`T\$16`<R, T>"""
"""\Q`T$19`\E""" to """`T\$19`<R, T>"""
),
// work-around for https://github.com/Kotlin/dukat/issues/402
"lib.es2018.asynciterable.module_dukat.kt" to listOf(
Expand All @@ -204,25 +170,12 @@ tasks.withType(IntegratedDukatTask::class).configureEach {
),
// work-around for https://github.com/Kotlin/dukat/issues/401
"null-writable.module_null-writable.kt" to listOf(
"""\Qimport stream.internal.`T$13`\E$""" to "",
"""\Qimport stream.internal.`T$17`\E$""" to "",
"""\Qimport stream.internal.Writable\E$""" to "import node.stream.Writable",
"""\Qoverride fun _write(_chunk: Any, _encoding: String, callback: (error: Error?) -> Unit)\E$""" to "override fun _write(chunk: Any, encoding: node.buffer.BufferEncoding, callback: (error: Error?) -> Unit)",
"""\Qopen fun _writev(_chunks: Array<`T$88`>, callback: (error: Error?) -> Unit)\E$""" to "",
"""\Qoverride fun _writev(chunks: Array<`T$13`>, callback: (error: Error?) -> Unit)\E$""" to ""
"""\Qopen fun _writev(_chunks: Array<`T$3`>, callback: (error: Error?) -> Unit)\E$""" to "",
"""\Qoverride fun _writev(chunks: Array<`T$17`>, callback: (error: Error?) -> Unit)\E$""" to ""
),
// work-around for https://github.com/Kotlin/dukat/issues/399
"tool-cache.module_@actions_tool-cache.kt" to listOf(
"""\Qimport http.OutgoingHttpHeaders\E$""" to "import node.http.OutgoingHttpHeaders",
"""\Qtypealias HTTPError = Error\E$""" to "external class HTTPError : Throwable",
"""\Qtypealias IToolRelease = IToolRelease\E$""" to "",
"""\Qtypealias IToolReleaseFile = IToolReleaseFile\E$""" to ""
),
// work-around for https://github.com/Kotlin/dukat/issues/398
"cache.module_@actions_cache.kt" to listOf(
"""\Qtypealias ValidationError = Error\E$""" to "external class ValidationError : Throwable",
"""\Qtypealias ReserveCacheError = Error\E$""" to "external class ReserveCacheError : Throwable"
),
// work-around for https://github.com/Kotlin/dukat/issues/400
"semver.module_semver.kt" to listOf(
"""\Q@JsModule("semver")\E$""" to """@JsModule("semver/classes/semver")"""
)
Expand All @@ -234,25 +187,6 @@ tasks.assemble {
dependsOn(project(":ncc-packer").tasks.named("nodeProductionRun"))
}

fun addJsModuleAnnotations(task: Task, vararg pairs: Pair<String, String>) {
for ((file, module) in pairs) {
task
.outputs
.files
.asFileTree
.matching { include("**/$file") }
.singleFile
.apply {
writeText(
"""
|@file:JsModule("$module")
${readText().prependIndent("|")}
""".trimMargin()
)
}
}
}

fun deleteExternalsFiles(task: Task, vararg files: String) {
if (files.isNotEmpty()) {
task
Expand Down
15 changes: 2 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
# limitations under the License.

[versions]
actions-cache = "3.0.5"
actions-core = "1.10.0"
actions-exec = "1.1.1"
actions-http-client = "2.0.1"
actions-io = "1.1.2"
actions-tool-cache = "2.0.1"
build-dukat = "0.5.7"
build-github-api = "1.117"
build-gradle-plugin-dependency-analysis = "1.19.0"
Expand All @@ -33,27 +27,22 @@ build-kotlinx-serialization = "1.4.1"
build-node = "16.18.1"
build-vercel-ncc = "0.36.1"
kotlin = "1.8.10"
kotlin-wrappers = "1.0.0-pre.491"
kotlin-wrappers = "1.0.0-pre.498"
kotlinx-coroutines = "1.6.4"
nullWritable = "1.0.5"
semver = "7.3.8"
types-semver = "7.3.13"
workflows-kotlin = "1.8.10"

[libraries]
actions-cache = { module = "actions:cache", version.ref = "actions-cache" }
actions-core = { module = "actions:core", version.ref = "actions-core" }
actions-exec = { module = "actions:exec", version.ref = "actions-exec" }
actions-http-client = { module = "actions:http-client", version.ref = "actions-http-client" }
actions-io = { module = "actions:io", version.ref = "actions-io" }
actions-tool-cache = { module = "actions:tool-cache", version.ref = "actions-tool-cache" }
build-github-api = { module = "org.kohsuke:github-api", version.ref = "build-github-api" }
build-inject = { module = "javax.inject:javax.inject", version.ref = "build-inject" }
build-kaml = { module = "com.charleskorn.kaml:kaml", version.ref = "build-kaml" }
build-kotlinx-serialization-bom = { module = "org.jetbrains.kotlinx:kotlinx-serialization-bom", version.ref = "build-kotlinx-serialization" }
build-kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core" }
build-kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json" }
build-vercel-ncc = { module = "vercel:ncc", version.ref = "build-vercel-ncc" }
kotlin-wrapper-actions-toolkit = { module = "org.jetbrains.kotlin-wrappers:kotlin-actions-toolkit" }
kotlin-wrapper-js = { module = "org.jetbrains.kotlin-wrappers:kotlin-js" }
kotlin-wrapper-node = { module = "org.jetbrains.kotlin-wrappers:kotlin-node" }
kotlin-wrappers-bom = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version.ref = "kotlin-wrappers" }
Expand Down
82 changes: 67 additions & 15 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,41 @@
# yarn lockfile v1


"@actions/cache@3.0.5":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@actions/cache/-/cache-3.0.5.tgz#ede622cdb42409698a2d79c3560fa429711dfcfd"
integrity sha512-0WpPmwnRPkn5k5ASmjoX8bY8NrZEPTwN+64nGYJmR/bHjEVgC8svdf5K956wi67tNJBGJky2+UfvNbUOtHmMHg==
"@actions/artifact@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@actions/artifact/-/artifact-1.1.1.tgz#b920bf2e67a5aeda49f10107673b0805690704eb"
integrity sha512-Vv4y0EW0ptEkU+Pjs5RGS/0EryTvI6s79LjSV9Gg/h+O3H/ddpjhuX/Bi/HZE4pbNPyjGtQjbdFWphkZhmgabA==
dependencies:
"@actions/core" "^1.9.1"
"@actions/http-client" "^2.0.1"
tmp "^0.2.1"
tmp-promise "^3.0.2"

"@actions/cache@^3.1.3":
version "3.1.3"
resolved "https://registry.yarnpkg.com/@actions/cache/-/cache-3.1.3.tgz#6521648a259dab2ce981cdaadf98bf192293b569"
integrity sha512-5YbATJUS6nVs9EkpK7JaliC3G5koKdJT99NLreL0gJlznudzZzXGNIheW5+HUT9C2DBvubOxYIyfX4v2UpZWrA==
dependencies:
"@actions/core" "^1.10.0"
"@actions/exec" "^1.0.1"
"@actions/glob" "^0.1.0"
"@actions/http-client" "^2.0.1"
"@actions/io" "^1.0.1"
"@azure/abort-controller" "^1.1.0"
"@azure/ms-rest-js" "^2.6.0"
"@azure/storage-blob" "^12.8.0"
semver "^6.1.0"
uuid "^3.3.3"

"@actions/core@1.10.0", "@actions/core@^1.10.0", "@actions/core@^1.2.6":
"@actions/core@^1.10.0", "@actions/core@^1.2.6", "@actions/core@^1.9.1":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f"
integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==
dependencies:
"@actions/http-client" "^2.0.1"
uuid "^8.3.2"

"@actions/exec@1.1.1", "@actions/exec@^1.0.0", "@actions/exec@^1.0.1":
"@actions/exec@^1.0.0", "@actions/exec@^1.0.1", "@actions/exec@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.1.1.tgz#2e43f28c54022537172819a7cf886c844221a611"
integrity sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==
Expand All @@ -40,19 +51,27 @@
"@actions/core" "^1.2.6"
minimatch "^3.0.4"

"@actions/http-client@2.0.1", "@actions/http-client@^2.0.1":
"@actions/glob@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@actions/glob/-/glob-0.4.0.tgz#b169b1c1c72f41e5df7b3d9349539c88fa68403c"
integrity sha512-+eKIGFhsFa4EBwaf/GMyzCdWrXWymGXfFmZU3FHQvYS8mPcHtTtZONbkcqqUMzw9mJ/pImEBFET1JNifhqGsAQ==
dependencies:
"@actions/core" "^1.9.1"
minimatch "^3.0.4"

"@actions/http-client@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.0.1.tgz#873f4ca98fe32f6839462a6f046332677322f99c"
integrity sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==
dependencies:
tunnel "^0.0.6"

"@actions/io@1.1.2", "@actions/io@^1.0.1", "@actions/io@^1.1.1":
"@actions/io@^1.0.1", "@actions/io@^1.1.1", "@actions/io@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.1.2.tgz#766ac09674a289ce0f1550ffe0a6eac9261a8ea9"
integrity sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==

"@actions/tool-cache@2.0.1":
"@actions/tool-cache@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-2.0.1.tgz#8a649b9c07838d9d750c9864814e66a7660ab720"
integrity sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==
Expand All @@ -64,7 +83,7 @@
semver "^6.1.0"
uuid "^3.3.2"

"@azure/abort-controller@^1.0.0":
"@azure/abort-controller@^1.0.0", "@azure/abort-controller@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@azure/abort-controller/-/abort-controller-1.1.0.tgz#788ee78457a55af8a1ad342acb182383d2119249"
integrity sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==
Expand Down Expand Up @@ -186,10 +205,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.0.tgz#f38c7139247a1d619f6cc6f27b072606af7c289d"
integrity sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w==

"@types/node@^18.11.18":
version "18.11.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==
"@types/node@^18.13.0":
version "18.13.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850"
integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==

"@types/semver@7.3.13":
version "7.3.13"
Expand Down Expand Up @@ -507,6 +526,18 @@ glob@7.2.0:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.1.3:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.1.1"
once "^1.3.0"
path-is-absolute "^1.0.0"

google-protobuf@3.12.2:
version "3.12.2"
resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.12.2.tgz#50ce9f9b6281235724eb243d6a83e969a2176e53"
Expand Down Expand Up @@ -627,7 +658,7 @@ minimatch@5.0.1:
dependencies:
brace-expansion "^2.0.1"

minimatch@^3.0.4:
minimatch@^3.0.4, minimatch@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
Expand Down Expand Up @@ -774,6 +805,13 @@ requires-port@^1.0.0:
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==

rimraf@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"

safe-buffer@^5.1.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
Expand Down Expand Up @@ -851,6 +889,20 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

tmp-promise@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.3.tgz#60a1a1cc98c988674fcbfd23b6e3367bdeac4ce7"
integrity sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==
dependencies:
tmp "^0.2.0"

tmp@^0.2.0, tmp@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==
dependencies:
rimraf "^3.0.0"

to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
Expand Down
Loading

0 comments on commit d7655c1

Please sign in to comment.