From 5a03ed411df0295aab751ecbeabebb0f4f5ad602 Mon Sep 17 00:00:00 2001 From: Matthew Nelson Date: Mon, 18 Mar 2024 21:24:32 -0400 Subject: [PATCH] Add support for `wasmJs` & `wasmWasi` (#46) --- .kotlin-js-store/yarn.lock | 18 +++---- README.md | 6 +-- .../main/kotlin/-KmpConfigurationExtension.kt | 26 +++++++++- build.gradle.kts | 52 ++++++------------- gradle/libs.versions.toml | 16 +++--- gradle/wrapper/gradle-wrapper.properties | 4 +- 6 files changed, 60 insertions(+), 62 deletions(-) diff --git a/.kotlin-js-store/yarn.lock b/.kotlin-js-store/yarn.lock index 510dcd5..b7cef21 100644 --- a/.kotlin-js-store/yarn.lock +++ b/.kotlin-js-store/yarn.lock @@ -38,9 +38,9 @@ balanced-match@^1.0.0: integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + version "2.3.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== brace-expansion@^1.1.7: version "1.1.11" @@ -151,9 +151,9 @@ emoji-regex@^8.0.0: integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + version "3.1.2" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" + integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== escape-string-regexp@4.0.0: version "4.0.0" @@ -191,9 +191,9 @@ fs.realpath@^1.0.0: integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== get-caller-file@^2.0.5: version "2.0.5" diff --git a/README.md b/README.md index 017013d..c86db9b 100644 --- a/README.md +++ b/README.md @@ -148,9 +148,9 @@ dependencies { [badge-license]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat -[badge-kotlin]: https://img.shields.io/badge/kotlin-1.9.21-blue.svg?logo=kotlin -[badge-core]: https://img.shields.io/badge/kotlincrypto.core-0.4.0-blue.svg -[badge-hash]: https://img.shields.io/badge/kotlincrypto.hash-0.4.0-blue.svg +[badge-kotlin]: https://img.shields.io/badge/kotlin-1.9.23-blue.svg?logo=kotlin +[badge-core]: https://img.shields.io/badge/kotlincrypto.core-0.5.1-blue.svg +[badge-hash]: https://img.shields.io/badge/kotlincrypto.hash-0.5.1-blue.svg [badge-platform-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat diff --git a/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt b/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt index 5c63108..3dd646e 100644 --- a/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt +++ b/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt @@ -17,6 +17,7 @@ import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl import org.gradle.api.Action import org.gradle.api.JavaVersion +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl fun KmpConfigurationExtension.configureShared( publish: Boolean = false, @@ -33,8 +34,29 @@ fun KmpConfigurationExtension.configureShared( } js() -// wasmJs {} -// wasmWasi {} + + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + target { + browser { + testTask { + useMocha { timeout = "30s" } + } + } + nodejs { + testTask { + useMocha { timeout = "30s" } + } + } + } + } + + @OptIn(ExperimentalWasmDsl::class) + wasmWasi { + target { + nodejs() + } + } androidNativeAll() diff --git a/build.gradle.kts b/build.gradle.kts index aeec686..7728570 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin +import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension @@ -21,7 +23,6 @@ plugins { alias(libs.plugins.multiplatform) apply(false) alias(libs.plugins.android.library) apply(false) alias(libs.plugins.binaryCompat) - alias(libs.plugins.gradleVersions) } allprojects { @@ -47,11 +48,19 @@ plugins.withType { the().lockFileDirectory = rootDir.resolve(".kotlin-js-store") } -apiValidation { - @Suppress("LocalVariableName") - val CHECK_PUBLICATION = findProperty("CHECK_PUBLICATION") as? String +plugins.withType { + the().apply { + nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" + nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" + } + + tasks.withType().configureEach { + args.add("--ignore-engines") + } +} - if (CHECK_PUBLICATION != null) { +apiValidation { + if (findProperty("CHECK_PUBLICATION") != null) { ignoredProjects.add("check-publication") } else { nonPublicMarkers.add("org.kotlincrypto.core.InternalKotlinCryptoApi") @@ -59,34 +68,3 @@ apiValidation { ignoredProjects.add("testing") } } - -fun isNonStable(version: String): Boolean { - val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) } - val regex = "^[0-9,.v-]+(-r)?$".toRegex() - val isStable = stableKeyword || regex.matches(version) - return isStable.not() -} - -tasks.withType { - // Example 1: reject all non stable versions - rejectVersionIf { - isNonStable(candidate.version) - } - - // Example 2: disallow release candidates as upgradable versions from stable versions - rejectVersionIf { - isNonStable(candidate.version) && !isNonStable(currentVersion) - } - - // Example 3: using the full syntax - resolutionStrategy { - componentSelection { - @Suppress("RedundantSamConstructor") - all(Action { - if (isNonStable(candidate.version) && !isNonStable(currentVersion)) { - reject("Release candidate") - } - }) - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 756864d..5f90299 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,15 +1,14 @@ [versions] android = "8.1.4" androidxTestRunner = "1.5.2" -binaryCompat = "0.13.2" +binaryCompat = "0.14.0" bouncyCastle = "1.73" -configuration = "0.1.5" -cryptoCore = "0.4.0" -cryptoHash = "0.4.0" -encoding = "2.1.0" -gradleVersions = "0.50.0" -kotlin = "1.9.21" -publish = "0.25.3" +configuration = "0.2.1" +cryptoCore = "0.5.1" +cryptoHash = "0.5.1" +encoding = "2.2.1" +kotlin = "1.9.23" +publish = "0.27.0" [libraries] kotlincrypto-core-digest = { module = "org.kotlincrypto.core:digest", version.ref = "cryptoCore" } @@ -32,5 +31,4 @@ encoding-base64 = { module = "io.matthewnelson.encoding:base64", version.ref = " [plugins] android-library = { id = "com.android.library", version.ref = "android" } binaryCompat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompat" } -gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" } multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a2b81f7..6357ddc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -4,5 +4,5 @@ zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME # https://gradle.org/release-checksums/ -distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip +distributionSha256Sum=85719317abd2112f021d4f41f09ec370534ba288432065f4b477b6a3b652910d +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip