@cap-kit/test-plugin 1.0.3 → 6.0.0
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/{CapKitTest.podspec → CapKitTestPlugin.podspec} +1 -1
- package/LICENSE +1 -1
- package/Package.swift +5 -9
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/capkit/test/TestPlugin.kt +8 -4
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/web.d.ts +1 -1
- package/ios/Sources/TestPlugin/TestConfig.swift +3 -5
- package/ios/Sources/TestPlugin/TestPlugin.swift +15 -11
- package/ios/Sources/TestPlugin/Version.swift +16 -0
- package/package.json +16 -15
- package/ios/Tests/TestPluginTests/TestPluginTests.swift +0 -21
package/LICENSE
CHANGED
package/Package.swift
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import PackageDescription
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
|
-
name: "
|
|
5
|
+
name: "CapKitTestPlugin",
|
|
6
6
|
platforms: [.iOS(.v15)],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
|
-
name: "
|
|
10
|
-
targets: ["
|
|
9
|
+
name: "CapKitTestPlugin",
|
|
10
|
+
targets: ["CapKitTestPlugin"]
|
|
11
11
|
)
|
|
12
12
|
],
|
|
13
13
|
dependencies: [
|
|
@@ -15,16 +15,12 @@ let package = Package(
|
|
|
15
15
|
],
|
|
16
16
|
targets: [
|
|
17
17
|
.target(
|
|
18
|
-
name: "
|
|
18
|
+
name: "CapKitTestPlugin",
|
|
19
19
|
dependencies: [
|
|
20
20
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
21
21
|
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
22
22
|
],
|
|
23
23
|
path: "ios/Sources/TestPlugin"
|
|
24
|
-
)
|
|
25
|
-
.testTarget(
|
|
26
|
-
name: "TestPluginTests",
|
|
27
|
-
dependencies: ["TestPlugin"],
|
|
28
|
-
path: "ios/Tests/TestPluginTests")
|
|
24
|
+
)
|
|
29
25
|
]
|
|
30
26
|
)
|
package/android/build.gradle
CHANGED
|
@@ -71,7 +71,7 @@ android {
|
|
|
71
71
|
buildTypes {
|
|
72
72
|
release {
|
|
73
73
|
minifyEnabled = false
|
|
74
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
74
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
lint {
|
|
@@ -57,13 +57,17 @@ class TestPlugin : Plugin() {
|
|
|
57
57
|
*/
|
|
58
58
|
@PluginMethod
|
|
59
59
|
fun echo(call: PluginCall) {
|
|
60
|
-
|
|
60
|
+
val jsValue = call.getString("value") ?: ""
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
val valueToEcho =
|
|
63
|
+
if (jsValue.isNotEmpty()) {
|
|
64
|
+
jsValue
|
|
65
|
+
} else {
|
|
66
|
+
config.customMessage ?: ""
|
|
67
|
+
}
|
|
64
68
|
|
|
65
69
|
val ret = JSObject()
|
|
66
|
-
ret.put("value", implementation.echo(
|
|
70
|
+
ret.put("value", implementation.echo(valueToEcho))
|
|
67
71
|
call.resolve(ret)
|
|
68
72
|
}
|
|
69
73
|
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* It acts as the main entry point for accessing the plugin's functionality
|
|
5
5
|
* across different platforms, including web.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { TestPlugin } from './definitions';
|
|
8
8
|
/**
|
|
9
9
|
* Main entry point for the Test Capacitor plugin.
|
|
10
10
|
*
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import
|
|
2
|
+
import { TestPlugin, EchoOptions, EchoResult, PluginVersionResult } from './definitions';
|
|
3
3
|
/**
|
|
4
4
|
* Web implementation of the Test plugin.
|
|
5
5
|
*
|
|
@@ -59,14 +59,12 @@ public struct TestConfig {
|
|
|
59
59
|
- Parameter plugin: The CAPPlugin instance used to access typed configuration.
|
|
60
60
|
*/
|
|
61
61
|
init(plugin: CAPPlugin) {
|
|
62
|
-
let
|
|
62
|
+
let pluginId = plugin.pluginId
|
|
63
63
|
|
|
64
64
|
// Bool
|
|
65
|
-
verboseLogging =
|
|
66
|
-
(config.value(forKey: Keys.verboseLogging) as? Bool) ?? defaultVerboseLogging
|
|
65
|
+
verboseLogging = plugin.getConfigValue(Keys.verboseLogging) as? Bool ?? defaultVerboseLogging
|
|
67
66
|
|
|
68
67
|
// String
|
|
69
|
-
customMessage =
|
|
70
|
-
(config.value(forKey: Keys.customMessage) as? String) ?? defaultCustomMessage
|
|
68
|
+
customMessage = plugin.getConfigValue(Keys.customMessage) as? String ?? defaultCustomMessage
|
|
71
69
|
}
|
|
72
70
|
}
|
|
@@ -64,27 +64,31 @@ public final class TestPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
64
64
|
and delegates the core logic to the native implementation.
|
|
65
65
|
*/
|
|
66
66
|
@objc func echo(_ call: CAPPluginCall) {
|
|
67
|
-
|
|
67
|
+
let jsValue = call.getString("value", "")
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
value += configMessage
|
|
69
|
+
let valueToEcho: String
|
|
70
|
+
if !jsValue.isEmpty {
|
|
71
|
+
valueToEcho = jsValue
|
|
72
|
+
} else {
|
|
73
|
+
valueToEcho = config?.customMessage ?? ""
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
// Log input only if verbose logging is enabled
|
|
77
|
+
TestLogger.debug("Echoing value:", valueToEcho)
|
|
78
|
+
|
|
77
79
|
call.resolve([
|
|
78
|
-
"value": implementation.echo(
|
|
80
|
+
"value": implementation.echo(valueToEcho)
|
|
79
81
|
])
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
// MARK: - Version
|
|
83
85
|
|
|
84
|
-
/// Retrieves the plugin version from
|
|
86
|
+
/// Retrieves the plugin version synchronized from package.json.
|
|
85
87
|
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
86
|
-
|
|
87
|
-
call.resolve([
|
|
88
|
+
// Standardized enum name across all CapKit plugins
|
|
89
|
+
call.resolve([
|
|
90
|
+
"version": PluginVersion.number
|
|
91
|
+
])
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
// MARK: - Settings
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// This file is automatically generated. Do not modify manually.
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
Container for the plugin's version information.
|
|
6
|
+
This enum provides a centralized, single source of truth for the native
|
|
7
|
+
version string, synchronized directly from the project's 'package.json'.
|
|
8
|
+
It ensures parity across JavaScript, Android, and iOS platforms.
|
|
9
|
+
*/
|
|
10
|
+
public enum PluginVersion {
|
|
11
|
+
/**
|
|
12
|
+
The semantic version string of the plugin.
|
|
13
|
+
Value synchronized from package.json: "6.0.0"
|
|
14
|
+
*/
|
|
15
|
+
public static let number = "6.0.0"
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-kit/test-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Architectural reference and boilerplate for Cap-Kit plugins.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"ios/Sources",
|
|
14
14
|
"ios/Tests",
|
|
15
15
|
"Package.swift",
|
|
16
|
-
"
|
|
16
|
+
"CapKitTestPlugin.podspec",
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
|
-
"author": "
|
|
19
|
+
"author": "CapKit Team",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
@@ -31,32 +31,33 @@
|
|
|
31
31
|
"capacitor",
|
|
32
32
|
"capacitor-plugin",
|
|
33
33
|
"ionic",
|
|
34
|
-
"native"
|
|
34
|
+
"native",
|
|
35
|
+
"cap-kit"
|
|
35
36
|
],
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@capacitor/cli": "^8.0.
|
|
41
|
-
"@capacitor/android": "^8.0.
|
|
42
|
-
"@capacitor/core": "^8.0.
|
|
41
|
+
"@capacitor/cli": "^8.0.2",
|
|
42
|
+
"@capacitor/android": "^8.0.2",
|
|
43
|
+
"@capacitor/core": "^8.0.2",
|
|
43
44
|
"@capacitor/docgen": "^0.3.1",
|
|
44
|
-
"@capacitor/ios": "^8.0.
|
|
45
|
+
"@capacitor/ios": "^8.0.2",
|
|
45
46
|
"@eslint/eslintrc": "^3.3.3",
|
|
46
47
|
"@eslint/js": "^9.39.2",
|
|
47
48
|
"eslint": "^9.39.2",
|
|
48
49
|
"eslint-plugin-import": "^2.32.0",
|
|
49
|
-
"globals": "^17.
|
|
50
|
-
"prettier": "^3.8.
|
|
50
|
+
"globals": "^17.2.0",
|
|
51
|
+
"prettier": "^3.8.1",
|
|
51
52
|
"prettier-plugin-java": "^2.8.1",
|
|
52
53
|
"rimraf": "^6.1.2",
|
|
53
|
-
"rollup": "^4.
|
|
54
|
+
"rollup": "^4.57.0",
|
|
54
55
|
"swiftlint": "^2.0.0",
|
|
55
56
|
"typescript": "^5.9.3",
|
|
56
|
-
"typescript-eslint": "^8.
|
|
57
|
+
"typescript-eslint": "^8.54.0"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"@capacitor/core": ">=8.0.
|
|
60
|
+
"@capacitor/core": ">=8.0.2"
|
|
60
61
|
},
|
|
61
62
|
"capacitor": {
|
|
62
63
|
"ios": {
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
},
|
|
69
70
|
"scripts": {
|
|
70
71
|
"verify": "pnpm run verify:ios && pnpm run verify:android && pnpm run verify:web",
|
|
71
|
-
"verify:ios": "xcodebuild -scheme
|
|
72
|
+
"verify:ios": "node ./scripts/sync-version.js && xcodebuild -scheme CapKitTestPlugin -destination generic/platform=iOS",
|
|
72
73
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
73
74
|
"verify:web": "pnpm run build",
|
|
74
75
|
"lint:android": "cd android && ./gradlew ktlintCheck",
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
81
82
|
"swiftlint": "node-swiftlint lint ios/Sources",
|
|
82
83
|
"docgen": "docgen --api TestPlugin --output-readme README.md --output-json dist/docs.json",
|
|
83
|
-
"build": "pnpm run clean && pnpm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
84
|
+
"build": "node ./scripts/sync-version.js && pnpm run clean && pnpm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
84
85
|
"clean": "rimraf ./dist",
|
|
85
86
|
"watch": "tsc --watch",
|
|
86
87
|
"test": "pnpm run verify",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import XCTest
|
|
2
|
-
@testable import TestPlugin
|
|
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
|
-
*/
|
|
10
|
-
class TestTests: XCTestCase {
|
|
11
|
-
func testEcho() {
|
|
12
|
-
// This is an example of a functional test case for a plugin.
|
|
13
|
-
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
14
|
-
|
|
15
|
-
let implementation = TestImpl()
|
|
16
|
-
let value = "Hello, World!"
|
|
17
|
-
let result = implementation.echo(value)
|
|
18
|
-
|
|
19
|
-
XCTAssertEqual(value, result)
|
|
20
|
-
}
|
|
21
|
-
}
|