This commit is contained in:
KillerBossOriginal 2024-07-19 16:06:04 +02:00
parent c6d6e20093
commit 2269573df5
8 changed files with 136 additions and 27 deletions

View file

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="permission-checker-js-2.2.1">
<output-path>$PROJECT_DIR$/build/libs</output-path>
<root id="archive" name="permission-checker-js-2.2.1.jar">
<element id="module-output" name="permission-checker.jsMain" />
</root>
</artifact>
</component>

View file

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="permission-checker-js-3.0.0">
<output-path>$PROJECT_DIR$/build/libs</output-path>
<root id="archive" name="permission-checker-js-3.0.0.jar">
<element id="module-output" name="permission-checker.jsMain" />
</root>
</artifact>
</component>

View file

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="permission-checker-jvm-2.2.1">
<output-path>$PROJECT_DIR$/build/libs</output-path>
<root id="archive" name="permission-checker-jvm-2.2.1.jar">
<element id="module-output" name="permission-checker.jvmMain" />
</root>
</artifact>
</component>

View file

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="permission-checker-jvm-3.0.0">
<output-path>$PROJECT_DIR$/build/libs</output-path>
<root id="archive" name="permission-checker-jvm-3.0.0.jar">
<element id="module-output" name="permission-checker.jvmMain" />
</root>
</artifact>
</component>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
</component>
</project>

View file

@ -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<MavenPublication>("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<Jar>("dokkaHtmlJar") {
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}
tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}
publishing {
publications {
create<MavenPublication>("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")
}
}
}
}

View file

@ -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<String>, requiredPermission: Array<String>): Boolean {
var actualLength = 0
val requiredLength = requiredPermission.size

View file

@ -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<String>, requiredPermission: Array<String>): Boolean {
return org.thundernetwork.permissionchecker.checkList(permission, requiredPermission)
}