diff --git a/.idea/artifacts/permission_checker_js_2_2_1.xml b/.idea/artifacts/permission_checker_js_2_2_1.xml
new file mode 100644
index 0000000..12582b8
--- /dev/null
+++ b/.idea/artifacts/permission_checker_js_2_2_1.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/permission_checker_js_3_0_0.xml b/.idea/artifacts/permission_checker_js_3_0_0.xml
new file mode 100644
index 0000000..c1bc481
--- /dev/null
+++ b/.idea/artifacts/permission_checker_js_3_0_0.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/permission_checker_jvm_2_2_1.xml b/.idea/artifacts/permission_checker_jvm_2_2_1.xml
new file mode 100644
index 0000000..14375ae
--- /dev/null
+++ b/.idea/artifacts/permission_checker_jvm_2_2_1.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/permission_checker_jvm_3_0_0.xml b/.idea/artifacts/permission_checker_jvm_3_0_0.xml
new file mode 100644
index 0000000..ba0e3d5
--- /dev/null
+++ b/.idea/artifacts/permission_checker_jvm_3_0_0.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
deleted file mode 100644
index cc3da93..0000000
--- a/.idea/jsLibraryMappings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 3ba3230..5388e42 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,10 +1,12 @@
plugins {
kotlin("multiplatform") version "2.0.0"
id("maven-publish")
+ id("signing")
+ id("org.jetbrains.dokka") version "1.9.20"
}
group = "org.thundernetwork.permissionchecker"
-version = "2.2.1"
+version = "3.0.0"
repositories {
mavenCentral()
@@ -14,7 +16,9 @@ dependencies {
}
kotlin {
- jvm {}
+ jvm {
+ withSourcesJar()
+ }
js (IR) {
nodejs {}
binaries.library()
@@ -36,25 +40,10 @@ kotlin {
}
}
}
-}
-
-publishing {
- // publications {
- // create("mavenJava") {
- // from(components["kotlin"])
- // groupId = project.group.toString()
- // artifactId = "permission-checker"
- // version = project.version.toString()
- // }
- // }
- repositories {
- maven {
- url = uri("https://source.thundernetwork.org/api/packages/ThunderNetworkRaD/maven") // Replace with your Maven repository URL
- credentials {
- username = ""
- password = ""
- }
+ js {
+ compilations["main"].packageJson {
+ customField("homepage", "https://github.com/ThunderNetworkRaD/permission-checker")
}
}
}
@@ -73,4 +62,71 @@ tasks.register("publishToNpm") {
commandLine("npm", "publish")
}
}
+}
+
+tasks.register("dokkaHtmlJar") {
+ dependsOn(tasks.dokkaHtml)
+ from(tasks.dokkaHtml.flatMap { it.outputDirectory })
+ archiveClassifier.set("html-docs")
+}
+
+tasks.register("dokkaJavadocJar") {
+ dependsOn(tasks.dokkaJavadoc)
+ from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
+ archiveClassifier.set("javadoc")
+}
+
+
+publishing {
+ publications {
+ create("mavenJava") {
+ from(components["kotlin"])
+
+ artifact(tasks["dokkaHtmlJar"])
+ artifact(tasks["dokkaJavadocJar"])
+
+ pom {
+ name.set("Permission Checker")
+ description.set("A project for checking permissions")
+ url.set("https://github.com/ThunderNetworkRaD/permission-checker")
+ licenses {
+ license {
+ name.set("The Apache License, Version 2.0")
+ url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
+ }
+ }
+ developers {
+ developer {
+ id.set("thundernetwork")
+ name.set("Thunder Network")
+ email.set("thundernetwork.org@gmail.com")
+ }
+ }
+ scm {
+ connection.set("scm:git:git://github.com/ThunderNetworkRaD/permission-checker.git")
+ developerConnection.set("scm:git:ssh://github.com/ThunderNetworkRaD/permission-checker.git")
+ url.set("https://github.com/ThunderNetworkRaD/permission-checker")
+ }
+ }
+ }
+ }
+
+ repositories {
+ maven {
+ name = "OSSRH"
+ url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
+ credentials {
+ username = System.getenv("MAVEN_USERNAME")
+ password = System.getenv("MAVEN_PASSWORD")
+ }
+ }
+ maven {
+ name = "GitHub"
+ url = uri("https://maven.pkg.github.com/ThunderNetworkRaD/permission-checker")
+ credentials {
+ username = System.getenv("GITHUB_ACTOR")
+ password = System.getenv("GPJ_PASSWORD")
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/commonMain/kotlin/App.kt b/src/commonMain/kotlin/App.kt
index 0f20e46..48f7319 100644
--- a/src/commonMain/kotlin/App.kt
+++ b/src/commonMain/kotlin/App.kt
@@ -1,5 +1,12 @@
package org.thundernetwork.permissionchecker
+/**
+ * Checks if a given permission matches a required permission.
+ *
+ * @param permission the permission to check
+ * @param requiredPermission the required permission
+ * @return true if the permission matches the required permission, false otherwise
+ */
fun checkSingle(permission: String, requiredPermission: String): Boolean {
var answer = false
if (permission == "*") answer = true
@@ -19,6 +26,13 @@ fun checkSingle(permission: String, requiredPermission: String): Boolean {
return answer
}
+/**
+ * Checks if the given list of permissions contains all the required permissions.
+ *
+ * @param permission the list of permissions to check
+ * @param requiredPermission the list of required permissions
+ * @return true if all the required permissions are present in the given list of permissions, false otherwise
+ */
fun checkList(permission: Array, requiredPermission: Array): Boolean {
var actualLength = 0
val requiredLength = requiredPermission.size
diff --git a/src/jsMain/kotlin/js.kt b/src/jsMain/kotlin/js.kt
index 4a17602..966f260 100644
--- a/src/jsMain/kotlin/js.kt
+++ b/src/jsMain/kotlin/js.kt
@@ -4,11 +4,24 @@
import kotlin.js.ExperimentalJsExport
import kotlin.js.JsExport
-
+/**
+ * Checks if a given permission matches a required permission.
+ *
+ * @param permission the permission to check
+ * @param requiredPermission the required permission
+ * @return true if the permission matches the required permission, false otherwise
+ */
fun checkSingle(permission: String, requiredPermission: String): Boolean {
return org.thundernetwork.permissionchecker.checkSingle(permission, requiredPermission)
}
+/**
+ * Checks if the given list of permissions contains all the required permissions.
+ *
+ * @param permission the list of permissions to check
+ * @param requiredPermission the list of required permissions
+ * @return true if all the required permissions are present in the given list of permissions, false otherwise
+ */
fun checkList(permission: Array, requiredPermission: Array): Boolean {
return org.thundernetwork.permissionchecker.checkList(permission, requiredPermission)
}
\ No newline at end of file