@capawesome/capacitor-live-update 6.0.1 → 6.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/README.md CHANGED
@@ -2,13 +2,22 @@
2
2
 
3
3
  Capacitor plugin to update your app remotely in real-time.
4
4
 
5
- ## Install
5
+ ## Installation
6
6
 
7
7
  ```bash
8
8
  npm install @capawesome/capacitor-live-update
9
9
  npx cap sync
10
10
  ```
11
11
 
12
+ ### Android
13
+
14
+ #### Variables
15
+
16
+ This plugin will use the following project variables (defined in your app’s `variables.gradle` file):
17
+
18
+ - `$okhttp3Version` version of `com.squareup.okhttp3:okhttp` (default: `22.3.1`)
19
+ - `$zip4jVersion` version of `net.lingala.zip4j:zip4j` (default: `2.11.5`)
20
+
12
21
  ## Configuration
13
22
 
14
23
  <docgen-config>
@@ -11,7 +11,7 @@ import Alamofire
11
11
  private let defaultServerPathKey = "serverBasePath" // DO NOT CHANGE (See https://dub.sh/ceDl0zT)
12
12
  private let libraryDirectoryUrl = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
13
13
  private let plugin: LiveUpdatePlugin
14
- private let pluginDirectory = "NoCloud/ionic_built_snapshots" // DO NOT CHANGE (See https://dub.sh/BLluidt)
14
+ private let bundlesDirectory = "NoCloud/ionic_built_snapshots" // DO NOT CHANGE (See https://dub.sh/BLluidt)
15
15
  private let preferences: LiveUpdatePreferences
16
16
 
17
17
  private var rollbackDispatchWorkItem: DispatchWorkItem?
@@ -21,6 +21,7 @@ import Alamofire
21
21
  self.plugin = plugin
22
22
  self.preferences = LiveUpdatePreferences()
23
23
  super.init()
24
+ createBundlesDirectory()
24
25
 
25
26
  if config.enabled {
26
27
  if wasUpdated() && config.resetOnUpdate {
@@ -218,9 +219,9 @@ import Alamofire
218
219
  return
219
220
  }
220
221
  // Move the unzipped files to the bundles directory
221
- let bundleDirectoryUrl = self.libraryDirectoryUrl.appendingPathComponent(self.pluginDirectory).appendingPathComponent(bundleId)
222
+ let bundlePath = self.buildBundlePathFor(bundleId: bundleId)
222
223
  do {
223
- try FileManager.default.moveItem(atPath: indexHtmlFile.deletingLastPathComponent().path, toPath: bundleDirectoryUrl.path)
224
+ try FileManager.default.moveItem(atPath: indexHtmlFile.deletingLastPathComponent().path, toPath: bundlePath)
224
225
  completion(nil)
225
226
  } catch {
226
227
  completion(error)
@@ -240,13 +241,25 @@ import Alamofire
240
241
  }
241
242
 
242
243
  private func buildBundlePathFor(bundleId: String) -> String {
243
- let url = libraryDirectoryUrl.appendingPathComponent(pluginDirectory).appendingPathComponent(bundleId)
244
+ let url = libraryDirectoryUrl.appendingPathComponent(bundlesDirectory).appendingPathComponent(bundleId)
244
245
  return url.path
245
246
  }
246
247
 
248
+ private func createBundlesDirectory() {
249
+ let bundlesDirectoryUrl = libraryDirectoryUrl.appendingPathComponent(bundlesDirectory)
250
+ let exists = FileManager.default.fileExists(atPath: bundlesDirectoryUrl.path)
251
+ if !exists {
252
+ do {
253
+ try FileManager.default.createDirectory(at: bundlesDirectoryUrl, withIntermediateDirectories: true, attributes: nil)
254
+ } catch {
255
+ CAPLog.print("[", LiveUpdatePlugin.tag, "] ", "Failed to create bundles directory.")
256
+ }
257
+ }
258
+ }
259
+
247
260
  private func deleteBundle(bundleId: String) throws {
248
- let bundleDirectoryUrl = libraryDirectoryUrl.appendingPathComponent(pluginDirectory).appendingPathComponent(bundleId)
249
- try FileManager.default.removeItem(atPath: bundleDirectoryUrl.path)
261
+ let path = buildBundlePathFor(bundleId: bundleId)
262
+ try FileManager.default.removeItem(atPath: path)
250
263
  }
251
264
 
252
265
  private func deleteUnusedBundles() {
@@ -345,7 +358,7 @@ import Alamofire
345
358
  }
346
359
 
347
360
  private func getBundleIds() -> [String] {
348
- let url = libraryDirectoryUrl.appendingPathComponent(pluginDirectory)
361
+ let url = libraryDirectoryUrl.appendingPathComponent(bundlesDirectory)
349
362
  do {
350
363
  let pathExists = FileManager.default.fileExists(atPath: url.path)
351
364
  var files: [String] = []
@@ -396,8 +409,8 @@ import Alamofire
396
409
  }
397
410
 
398
411
  private func hasBundle(bundleId: String) -> Bool {
399
- let url = libraryDirectoryUrl.appendingPathComponent(pluginDirectory).appendingPathComponent(bundleId)
400
- return FileManager.default.fileExists(atPath: url.path)
412
+ let path = buildBundlePathFor(bundleId: bundleId)
413
+ return FileManager.default.fileExists(atPath: path)
401
414
  }
402
415
 
403
416
  private func rollback() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-live-update",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "Capacitor plugin to update your app remotely in real-time.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",