@capgo/capacitor-updater 9.0.4 → 9.0.5

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.
@@ -164,7 +164,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
164
164
  // exposes it to code that runs without a plugin instance.
165
165
  private static final class VersionHolder {
166
166
 
167
- private final String pluginVersion = "9.0.4";
167
+ private final String pluginVersion = "9.0.5";
168
168
  }
169
169
 
170
170
  static final String PLUGIN_VERSION = new VersionHolder().pluginVersion;
@@ -95,7 +95,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
95
95
  deinit {
96
96
  implementation.shutdown()
97
97
  }
98
- private let pluginVersion: String = "9.0.4"
98
+ private let pluginVersion: String = "9.0.5"
99
99
  private let launchStartedAtMs = Int64(Date().timeIntervalSince1970 * 1000)
100
100
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
101
101
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
@@ -26,7 +26,7 @@ final class BuiltinHashesTests: XCTestCase {
26
26
  override func tearDown() {
27
27
  try? FileManager.default.removeItem(at: builtinFolder)
28
28
  implementation = nil
29
- CryptoCipher.setLogger(Logger(withTag: "TestLogger"))
29
+ CryptoCipher.setLogger(Logger.quietForTests())
30
30
  super.tearDown()
31
31
  }
32
32
 
@@ -19,12 +19,17 @@ private func channelSelfTestURL() throws -> URL {
19
19
 
20
20
  private func persistDefaultChannelTestUpdater(defaultChannel: String) -> ChannelRequestCapgoUpdater {
21
21
  let updater = ChannelRequestCapgoUpdater()
22
- updater.setLogger(Logger(withTag: "TestLogger"))
22
+ updater.setLogger(Logger.quietForTests())
23
23
  updater.defaultChannel = defaultChannel
24
24
  return updater
25
25
  }
26
26
 
27
27
  private class TestableCapacitorUpdaterPlugin: CapacitorUpdaterPlugin {
28
+ override init() {
29
+ super.init()
30
+ useQuietTestLogger()
31
+ }
32
+
28
33
  private(set) var notifiedEventNames: [String] = []
29
34
  private(set) var notifiedEventPayloads: [String: [String: Any]] = [:]
30
35
  private(set) var notifiedEventRetainValues: [String: Bool] = [:]
@@ -60,6 +65,11 @@ private class TestableCapacitorUpdaterPlugin: CapacitorUpdaterPlugin {
60
65
  }
61
66
 
62
67
  private final class RealSendReadyCapacitorUpdaterPlugin: CapacitorUpdaterPlugin {
68
+ override init() {
69
+ super.init()
70
+ useQuietTestLogger()
71
+ }
72
+
63
73
  private let eventLock = NSLock()
64
74
  private var _notifiedEventNames: [String] = []
65
75
  private var _notifiedEventPayloads: [String: [String: Any]] = [:]
@@ -801,7 +811,7 @@ class CapacitorUpdaterTests: XCTestCase {
801
811
  testPlugin.implementation = freshDownloadImplementation
802
812
  testPlugin.setAutoUpdateModeForTesting("onlyDownload")
803
813
  testPlugin.setUpdateUrlForTesting("https://example.com/channel")
804
- CryptoCipher.setLogger(Logger(withTag: "TestLogger"))
814
+ CryptoCipher.setLogger(Logger.quietForTests())
805
815
 
806
816
  return (testPlugin, freshDownloadImplementation)
807
817
  }
@@ -826,7 +836,7 @@ class CapacitorUpdaterTests: XCTestCase {
826
836
  testPlugin.implementation = implementation
827
837
  testPlugin.setAutoUpdateModeForTesting("atBackground")
828
838
  testPlugin.setUpdateUrlForTesting("https://example.com/channel")
829
- CryptoCipher.setLogger(Logger(withTag: "TestLogger"))
839
+ CryptoCipher.setLogger(Logger.quietForTests())
830
840
 
831
841
  return (testPlugin, implementation)
832
842
  }
@@ -843,7 +853,7 @@ class CapacitorUpdaterTests: XCTestCase {
843
853
  }
844
854
 
845
855
  private func makeDelayUpdateUtils() throws -> DelayUpdateUtils {
846
- let logger = Logger(withTag: "TestLogger")
856
+ let logger = Logger.quietForTests()
847
857
  let version = try CapgoSemanticVersion("1.0.0")
848
858
  return DelayUpdateUtils(currentVersionNative: version, logger: logger)
849
859
  }
@@ -1475,7 +1485,7 @@ class CapacitorUpdaterTests: XCTestCase {
1475
1485
 
1476
1486
  func testSetChannelRejectsNonSuccessStatusWithoutPersistingDefaultChannel() throws {
1477
1487
  let updater = ChannelRequestCapgoUpdater()
1478
- updater.setLogger(Logger(withTag: "TestLogger"))
1488
+ updater.setLogger(Logger.quietForTests())
1479
1489
  updater.channelUrl = channelSelfTestURLString
1480
1490
  updater.defaultChannel = "stable"
1481
1491
 
@@ -1507,7 +1517,7 @@ class CapacitorUpdaterTests: XCTestCase {
1507
1517
 
1508
1518
  func testUnsetChannelClearsOverrideWhenAllowed() {
1509
1519
  let updater = CapgoUpdater()
1510
- updater.setLogger(Logger(withTag: "TestLogger"))
1520
+ updater.setLogger(Logger.quietForTests())
1511
1521
  updater.defaultChannel = "beta"
1512
1522
 
1513
1523
  let defaultsKey = "CapacitorUpdaterTests.defaultChannel.\(UUID().uuidString)"
@@ -1533,7 +1543,7 @@ class CapacitorUpdaterTests: XCTestCase {
1533
1543
 
1534
1544
  func testUnsetChannelRejectsWhenDisabledByConfig() {
1535
1545
  let updater = CapgoUpdater()
1536
- updater.setLogger(Logger(withTag: "TestLogger"))
1546
+ updater.setLogger(Logger.quietForTests())
1537
1547
  updater.defaultChannel = "beta"
1538
1548
 
1539
1549
  let defaultsKey = "CapacitorUpdaterTests.defaultChannel.\(UUID().uuidString)"
@@ -1863,7 +1873,7 @@ class CapacitorUpdaterTests: XCTestCase {
1863
1873
 
1864
1874
  func testGetChannelPersistsServerChannelAsDefaultChannel() throws {
1865
1875
  let updater = ChannelRequestCapgoUpdater()
1866
- updater.setLogger(Logger(withTag: "TestLogger"))
1876
+ updater.setLogger(Logger.quietForTests())
1867
1877
  updater.channelUrl = channelSelfTestURLString
1868
1878
 
1869
1879
  let channelURL = try channelSelfTestURL()
@@ -1887,7 +1897,7 @@ class CapacitorUpdaterTests: XCTestCase {
1887
1897
 
1888
1898
  func testGetChannelDoesNotPersistBuiltinVersionNameAsDefaultChannel() {
1889
1899
  let updater = ChannelRequestCapgoUpdater()
1890
- updater.setLogger(Logger(withTag: "TestLogger"))
1900
+ updater.setLogger(Logger.quietForTests())
1891
1901
  updater.defaultChannel = "stable"
1892
1902
 
1893
1903
  let defaultsKey = "CapacitorUpdaterTests.defaultChannel.\(UUID().uuidString)"
@@ -1903,7 +1913,7 @@ class CapacitorUpdaterTests: XCTestCase {
1903
1913
 
1904
1914
  func testGetChannelDoesNotPersistDefaultStatusChannel() throws {
1905
1915
  let updater = ChannelRequestCapgoUpdater()
1906
- updater.setLogger(Logger(withTag: "TestLogger"))
1916
+ updater.setLogger(Logger.quietForTests())
1907
1917
  updater.channelUrl = channelSelfTestURLString
1908
1918
  updater.defaultChannel = ""
1909
1919
 
@@ -3424,7 +3434,7 @@ class CapacitorUpdaterTests: XCTestCase {
3424
3434
 
3425
3435
  private func makeSplashTimeoutPlugin(mode: String = "onLaunch") throws -> (SplashTimeoutCapacitorUpdaterPlugin, SplashTimeoutCapgoUpdater) {
3426
3436
  clearDelayStorage()
3427
- CryptoCipher.setLogger(Logger(withTag: "TestLogger"))
3437
+ CryptoCipher.setLogger(Logger.quietForTests())
3428
3438
  let implementation = SplashTimeoutCapgoUpdater()
3429
3439
  implementation.currentBundleValue = makeOnlyDownloadBundle(id: "current-id", version: "1.0.0", status: .SUCCESS)
3430
3440
  implementation.latestResponse = makeOnlyDownloadLatest()
@@ -4109,6 +4119,12 @@ class CapacitorUpdaterTests: XCTestCase {
4109
4119
 
4110
4120
  // MARK: - Logger Tests
4111
4121
 
4122
+ /// Test plugins log errors only: info lines block the test thread when xcodebuild drains the output pipe late.
4123
+ func testTestPluginsLogErrorsOnly() {
4124
+ XCTAssertEqual(TestableCapacitorUpdaterPlugin().logger.level, .error)
4125
+ XCTAssertEqual(Logger.quietForTests().level, .error)
4126
+ }
4127
+
4112
4128
  func testLoggerInitialization() {
4113
4129
  let logger = Logger(withTag: "TestTag")
4114
4130
  XCTAssertNotNil(logger)
@@ -4397,7 +4413,7 @@ class CapacitorUpdaterTests: XCTestCase {
4397
4413
 
4398
4414
  func testDeleteRejectsPathTraversalOutsideBundleRoot() throws {
4399
4415
  let updater = CapgoUpdater()
4400
- updater.setLogger(Logger(withTag: "TestLogger"))
4416
+ updater.setLogger(Logger.quietForTests())
4401
4417
 
4402
4418
  let deleted = updater.delete(id: "../outside-target", removeInfo: true)
4403
4419
 
@@ -4406,7 +4422,7 @@ class CapacitorUpdaterTests: XCTestCase {
4406
4422
 
4407
4423
  func testDeleteRemovesLegitimateInSandboxBundle() throws {
4408
4424
  let updater = CapgoUpdater()
4409
- updater.setLogger(Logger(withTag: "TestLogger"))
4425
+ updater.setLogger(Logger.quietForTests())
4410
4426
  let bundleId = "sandbox-\(UUID().uuidString)"
4411
4427
  let bundleDir = try updater.getBundleDirectory(id: bundleId)
4412
4428
  try FileManager.default.createDirectory(at: bundleDir, withIntermediateDirectories: true)
@@ -4431,7 +4447,7 @@ class CapacitorUpdaterTests: XCTestCase {
4431
4447
 
4432
4448
  func testDeleteRejectsDotBundleId() throws {
4433
4449
  let updater = CapgoUpdater()
4434
- updater.setLogger(Logger(withTag: "TestLogger"))
4450
+ updater.setLogger(Logger.quietForTests())
4435
4451
 
4436
4452
  XCTAssertFalse(updater.delete(id: ".", removeInfo: true))
4437
4453
  }
@@ -47,6 +47,11 @@ final class ChecksumRequiredTests: XCTestCase {
47
47
  }
48
48
 
49
49
  private final class TestableCapacitorUpdaterPlugin: CapacitorUpdaterPlugin {
50
+ override init() {
51
+ super.init()
52
+ useQuietTestLogger()
53
+ }
54
+
50
55
  override func runBackgroundDownloadWork(_ work: @escaping () -> Void) {
51
56
  work()
52
57
  }
@@ -31,7 +31,7 @@ final class ListChannelsTests: XCTestCase {
31
31
  """.utf8)
32
32
  let requestResult = CapgoUpdater.RequestResult(data: responseData, response: response, error: nil, timedOut: false)
33
33
  let updater = ListChannelsRequestCapgoUpdater(requestResult: requestResult)
34
- updater.setLogger(Logger(withTag: "TestLogger"))
34
+ updater.setLogger(Logger.quietForTests())
35
35
  updater.channelUrl = channelURL.absoluteString
36
36
 
37
37
  let result = updater.listChannels()
@@ -55,7 +55,7 @@ final class ListChannelsTests: XCTestCase {
55
55
  """.utf8)
56
56
  let requestResult = CapgoUpdater.RequestResult(data: responseData, response: response, error: nil, timedOut: false)
57
57
  let updater = ListChannelsRequestCapgoUpdater(requestResult: requestResult)
58
- updater.setLogger(Logger(withTag: "TestLogger"))
58
+ updater.setLogger(Logger.quietForTests())
59
59
  updater.channelUrl = channelURL.absoluteString
60
60
 
61
61
  let result = updater.listChannels()
@@ -99,7 +99,7 @@ final class PopulateDeltaCacheTests: XCTestCase {
99
99
  // CryptoCipher's logger is shared/static with no getter to snapshot the prior
100
100
  // value, so restore a normal (non-silent) default rather than leaving other
101
101
  // test suites silenced by this one.
102
- CryptoCipher.setLogger(Logger(withTag: "TestLogger"))
102
+ CryptoCipher.setLogger(Logger.quietForTests())
103
103
  super.tearDown()
104
104
  }
105
105
 
@@ -94,6 +94,11 @@ final class SessionKeyRequiredTests: XCTestCase {
94
94
  }
95
95
 
96
96
  private final class TestableCapacitorUpdaterPlugin: CapacitorUpdaterPlugin {
97
+ override init() {
98
+ super.init()
99
+ useQuietTestLogger()
100
+ }
101
+
97
102
  override func runBackgroundDownloadWork(_ work: @escaping () -> Void) {
98
103
  work()
99
104
  }
@@ -0,0 +1,17 @@
1
+ @testable import CapacitorUpdaterPlugin
2
+
3
+ extension Logger {
4
+ /// Logger for tests: errors only. Info and debug lines are written synchronously to the test runner's
5
+ /// stdout/stderr, and xcodebuild drains that pipe. On a busy CI runner xcodebuild reads it late, the pipe
6
+ /// fills, and the test thread blocks inside a log call (a core-b test stalled 17 s and 27 s this way).
7
+ static func quietForTests(_ tag: String = "TestLogger") -> Logger {
8
+ Logger(withTag: tag, options: Logger.Options(level: .error))
9
+ }
10
+ }
11
+
12
+ extension CapacitorUpdaterPlugin {
13
+ /// Plugins built in tests have no bridge, so their default logger logs every info line. Keep it to errors.
14
+ func useQuietTestLogger() {
15
+ logger = Logger.quietForTests("✨ CapgoUpdater")
16
+ }
17
+ }
@@ -198,7 +198,7 @@ final class UpdateLifecycleTests: XCTestCase {
198
198
  plugin.implementation = updater
199
199
  plugin.setUpdateUrlForTesting(updateUrl.absoluteString)
200
200
  plugin.setDelayUpdateUtilsForTesting(
201
- DelayUpdateUtils(currentVersionNative: try CapgoSemanticVersion("1.0.0"), logger: Logger(withTag: "UpdateLifecycleTests"))
201
+ DelayUpdateUtils(currentVersionNative: try CapgoSemanticVersion("1.0.0"), logger: Logger.quietForTests("UpdateLifecycleTests"))
202
202
  )
203
203
  UserDefaults.standard.removeObject(forKey: delayPreferencesKey)
204
204
  UserDefaults.standard.removeObject(forKey: delayConditionModeKey)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "9.0.4",
3
+ "version": "9.0.5",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",
@@ -76,7 +76,7 @@
76
76
  "clean": "rimraf ./dist",
77
77
  "watch": "tsc --watch",
78
78
  "prepublishOnly": "bun run build",
79
- "check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs && bun scripts/test-release-workflows.mjs && bun scripts/test-cli-crypto-output-guard.mjs && node scripts/test-builtin-hashes-hook.mjs && node scripts/check-ios-test-shards.mjs && node scripts/maestro/test-helpers.mjs && node scripts/maestro/test-smoke-sequence.mjs && bun scripts/maestro/test-deferred-flow.mjs && bun scripts/maestro/test-startup-update-flow.mjs && node scripts/maestro/test-local-plugin-manifest.mjs && node scripts/maestro/test-runner-attempt-cleanup.mjs",
79
+ "check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs && bun scripts/test-release-workflows.mjs && bun scripts/test-cli-crypto-output-guard.mjs && node scripts/test-builtin-hashes-hook.mjs && node scripts/check-ios-test-shards.mjs && node scripts/maestro/test-helpers.mjs && node scripts/maestro/test-smoke-sequence.mjs && bun scripts/maestro/test-deferred-flow.mjs && bun scripts/maestro/test-startup-update-flow.mjs && node scripts/maestro/test-local-plugin-manifest.mjs && node scripts/maestro/test-runner-attempt-cleanup.mjs && bash scripts/maestro/test-android-app-liveness.sh && bash scripts/maestro/test-android-scroll-gesture.sh",
80
80
  "check:cap9-deprecated": "bun scripts/check-cap9-deprecated.mjs",
81
81
  "changelog:ai": "node scripts/generate-ai-changelog.mjs",
82
82
  "example:install": "cd example-app && bun install --frozen-lockfile",