@cap-kit/test-plugin 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{TestPlugin.podspec → CapKitTest.podspec} +1 -1
- package/Package.swift +8 -5
- package/README.md +63 -31
- package/android/src/main/java/io/capkit/test/TestConfig.kt +39 -4
- package/android/src/main/java/io/capkit/test/TestImpl.kt +61 -0
- package/android/src/main/java/io/capkit/test/TestPlugin.kt +66 -10
- package/android/src/main/java/io/capkit/test/utils/TestLogger.kt +85 -0
- package/android/src/main/java/io/capkit/test/utils/TestUtils.kt +14 -0
- package/dist/docs.json +57 -21
- package/dist/esm/definitions.d.ts +137 -35
- package/dist/esm/definitions.js +23 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +4 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +16 -27
- package/dist/esm/web.js +25 -28
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +54 -39
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +54 -39
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/TestPlugin/TestConfig.swift +52 -9
- package/ios/Sources/TestPlugin/TestImpl.swift +51 -0
- package/ios/Sources/TestPlugin/TestPlugin.swift +83 -34
- package/ios/Sources/TestPlugin/Utils/TestLogger.swift +57 -0
- package/ios/Sources/TestPlugin/Utils/TestUtils.swift +12 -0
- package/ios/Tests/TestPluginTests/TestPluginTests.swift +7 -1
- package/package.json +11 -11
- package/android/src/main/java/io/capkit/test/Logger.kt +0 -25
- package/android/src/main/java/io/capkit/test/Test.kt +0 -20
- package/ios/Sources/TestPlugin/Logging.swift +0 -32
- package/ios/Sources/TestPlugin/Test.swift +0 -19
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Centralized logger for the Test plugin.
|
|
5
|
+
|
|
6
|
+
This logger mirrors the Android Logger pattern and provides:
|
|
7
|
+
- a single logging entry point
|
|
8
|
+
- runtime-controlled verbose logging
|
|
9
|
+
- consistent log formatting
|
|
10
|
+
|
|
11
|
+
Business logic MUST NOT perform configuration checks directly.
|
|
12
|
+
*/
|
|
13
|
+
enum TestLogger {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
Controls whether debug logs are printed.
|
|
17
|
+
|
|
18
|
+
This value is set once during plugin load
|
|
19
|
+
based on configuration values.
|
|
20
|
+
*/
|
|
21
|
+
static var verbose: Bool = false
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
Prints a verbose / debug log message.
|
|
25
|
+
|
|
26
|
+
This method is intended for development-time diagnostics
|
|
27
|
+
and is automatically silenced when verbose logging is disabled.
|
|
28
|
+
*/
|
|
29
|
+
static func debug(_ items: Any...) {
|
|
30
|
+
guard verbose else { return }
|
|
31
|
+
log(items)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
Prints an error log message.
|
|
36
|
+
|
|
37
|
+
Error logs are always printed regardless of verbosity.
|
|
38
|
+
*/
|
|
39
|
+
static func error(_ items: Any...) {
|
|
40
|
+
log(items)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
Low-level log printer with a consistent prefix.
|
|
46
|
+
|
|
47
|
+
This function should not be used directly outside this file.
|
|
48
|
+
*/
|
|
49
|
+
private func log(_ items: Any..., separator: String = " ", terminator: String = "\n") {
|
|
50
|
+
CAPLog.print("⚡️ Test -", terminator: separator)
|
|
51
|
+
for (itemIndex, item) in items.enumerated() {
|
|
52
|
+
CAPLog.print(
|
|
53
|
+
item,
|
|
54
|
+
terminator: itemIndex == items.count - 1 ? terminator : separator
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Utility helpers for the Test plugin.
|
|
5
|
+
|
|
6
|
+
This type is intentionally empty and serves as a placeholder
|
|
7
|
+
for future shared helper functions.
|
|
8
|
+
|
|
9
|
+
Keeping a dedicated utilities file helps maintain a clean
|
|
10
|
+
separation between core logic and helper code.
|
|
11
|
+
*/
|
|
12
|
+
struct TestUtils {}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import XCTest
|
|
2
2
|
@testable import TestPlugin
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
Basic functional tests for the Test plugin native implementation.
|
|
6
|
+
|
|
7
|
+
These tests validate the core behavior of the implementation
|
|
8
|
+
independently from the Capacitor bridge.
|
|
9
|
+
*/
|
|
4
10
|
class TestTests: XCTestCase {
|
|
5
11
|
func testEcho() {
|
|
6
12
|
// This is an example of a functional test case for a plugin.
|
|
7
13
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
8
14
|
|
|
9
|
-
let implementation =
|
|
15
|
+
let implementation = TestImpl()
|
|
10
16
|
let value = "Hello, World!"
|
|
11
17
|
let result = implementation.echo(value)
|
|
12
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-kit/test-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Test plugin for Cap-Kit.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"ios/Sources",
|
|
14
14
|
"ios/Tests",
|
|
15
15
|
"Package.swift",
|
|
16
|
-
"
|
|
16
|
+
"CapKitTest.podspec",
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"author": "Fabio Martino",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@capacitor/cli": "^8.0.
|
|
41
|
-
"@capacitor/android": "^8.0.
|
|
42
|
-
"@capacitor/core": "^8.0.
|
|
40
|
+
"@capacitor/cli": "^8.0.1",
|
|
41
|
+
"@capacitor/android": "^8.0.1",
|
|
42
|
+
"@capacitor/core": "^8.0.1",
|
|
43
43
|
"@capacitor/docgen": "^0.3.1",
|
|
44
|
-
"@capacitor/ios": "^8.0.
|
|
44
|
+
"@capacitor/ios": "^8.0.1",
|
|
45
45
|
"@eslint/eslintrc": "^3.3.3",
|
|
46
46
|
"@eslint/js": "^9.39.2",
|
|
47
47
|
"eslint": "^9.39.2",
|
|
48
48
|
"eslint-plugin-import": "^2.32.0",
|
|
49
49
|
"globals": "^17.0.0",
|
|
50
|
-
"prettier": "^3.
|
|
50
|
+
"prettier": "^3.8.0",
|
|
51
51
|
"prettier-plugin-java": "^2.8.1",
|
|
52
52
|
"rimraf": "^6.1.2",
|
|
53
|
-
"rollup": "^4.55.
|
|
53
|
+
"rollup": "^4.55.2",
|
|
54
54
|
"swiftlint": "^2.0.0",
|
|
55
55
|
"typescript": "^5.9.3",
|
|
56
|
-
"typescript-eslint": "^8.
|
|
56
|
+
"typescript-eslint": "^8.53.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@capacitor/core": ">=8.0.
|
|
59
|
+
"@capacitor/core": ">=8.0.1"
|
|
60
60
|
},
|
|
61
61
|
"capacitor": {
|
|
62
62
|
"ios": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"verify": "pnpm run verify:ios && pnpm run verify:android && pnpm run verify:web",
|
|
71
|
-
"verify:ios": "xcodebuild -scheme
|
|
71
|
+
"verify:ios": "xcodebuild -scheme CapKitTest -destination generic/platform=iOS",
|
|
72
72
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
73
73
|
"verify:web": "pnpm run build",
|
|
74
74
|
"lint:android": "cd android && ./gradlew ktlintCheck",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package io.capkit.test
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Utility object for logging messages with a custom prefix.
|
|
7
|
-
*/
|
|
8
|
-
object Logger {
|
|
9
|
-
private const val TAG = "⚡️ Test"
|
|
10
|
-
|
|
11
|
-
fun debug(vararg messages: String) {
|
|
12
|
-
log(TAG, *messages)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
fun log(
|
|
16
|
-
tag: String,
|
|
17
|
-
vararg messages: String,
|
|
18
|
-
) {
|
|
19
|
-
val sb = StringBuilder()
|
|
20
|
-
for (msg in messages) {
|
|
21
|
-
sb.append(msg).append(" ")
|
|
22
|
-
}
|
|
23
|
-
Log.d(tag, sb.toString())
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
package io.capkit.test
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Native implementation for the Test Capacitor plugin.
|
|
5
|
-
*
|
|
6
|
-
* This class contains platform logic only and does not depend on
|
|
7
|
-
* Capacitor plugin APIs.
|
|
8
|
-
*/
|
|
9
|
-
class Test {
|
|
10
|
-
/**
|
|
11
|
-
* Returns the provided string unchanged.
|
|
12
|
-
*
|
|
13
|
-
* @param value Input string.
|
|
14
|
-
* @return The same string.
|
|
15
|
-
*/
|
|
16
|
-
fun echo(value: String): String {
|
|
17
|
-
Logger.debug(value)
|
|
18
|
-
return value
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Capacitor
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Utility function for logging messages with a custom prefix.
|
|
5
|
-
*
|
|
6
|
-
* This function is designed to format log messages for the Test plugin. It prepends the log output
|
|
7
|
-
* with a custom prefix (`⚡️ Test -`) to easily identify logs associated with this plugin.
|
|
8
|
-
*
|
|
9
|
-
* @param items - Items to log, stringified and logged in order.
|
|
10
|
-
* @param separator - A string used to separate the logged items. Defaults to a single space (`" "`).
|
|
11
|
-
* @param terminator - A string appended to the end of the log message. Defaults to a newline (`"\n"`).
|
|
12
|
-
*
|
|
13
|
-
* Example Usage:
|
|
14
|
-
* ```
|
|
15
|
-
* log("This is a message", "with multiple parts", separator: ", ")
|
|
16
|
-
* // Output: ⚡️ Test - This is a message, with multiple parts
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Note:
|
|
20
|
-
* - This function uses Capacitor's `CAPLog.print` for outputting log messages.
|
|
21
|
-
* - Multiple items use `separator` and end with `terminator`.
|
|
22
|
-
*/
|
|
23
|
-
func log(_ items: Any..., separator: String = " ", terminator: String = "\n") {
|
|
24
|
-
// Prefix the log with "⚡️ Test -"
|
|
25
|
-
CAPLog.print("⚡️ Test -", terminator: separator)
|
|
26
|
-
|
|
27
|
-
// Iterate over the provided items and print each one
|
|
28
|
-
for (itemIndex, item) in items.enumerated() {
|
|
29
|
-
// Use the specified separator between items, and the terminator for the final item
|
|
30
|
-
CAPLog.print(item, terminator: itemIndex == items.count - 1 ? terminator : separator)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Native implementation for the Test Capacitor plugin.
|
|
5
|
-
*
|
|
6
|
-
* This class contains platform logic only and does not depend on Capacitor APIs.
|
|
7
|
-
*/
|
|
8
|
-
@objc public class Test: NSObject {
|
|
9
|
-
/**
|
|
10
|
-
* Returns the provided string unchanged.
|
|
11
|
-
*
|
|
12
|
-
* @param value Input string.
|
|
13
|
-
* @return The same string.
|
|
14
|
-
*/
|
|
15
|
-
@objc public func echo(_ value: String) -> String {
|
|
16
|
-
log(value)
|
|
17
|
-
return value
|
|
18
|
-
}
|
|
19
|
-
}
|