pear-runtime-updater 3.0.1 → 3.0.3

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.
Files changed (2) hide show
  1. package/index.js +9 -4
  2. package/package.json +6 -5
package/index.js CHANGED
@@ -7,6 +7,7 @@ const ReadyResource = require('ready-resource')
7
7
  const link = require('pear-link')
8
8
  const hid = require('hypercore-id-encoding')
9
9
  const { platform, arch, isWindows } = require('which-runtime')
10
+ const semver = require('bare-semver')
10
11
  const host = platform + '-' + arch
11
12
 
12
13
  module.exports = class PearRuntimeUpdater extends ReadyResource {
@@ -20,11 +21,10 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
20
21
 
21
22
  this.dir = opts.dir
22
23
  this.store = opts.store
23
- this.version = opts.version || 0
24
+ this.version = opts.version || '0.0.0-0'
24
25
  this.app = opts.app
25
26
  this.name = opts.name
26
27
  this.bundled = opts.bundled || !!this.app
27
- this.win32RestartAfterUpdate = opts.win32 && opts.win32.restart
28
28
 
29
29
  const { drive: upgrade } = link.parse(opts.upgrade)
30
30
  this.key = hid.decode(upgrade.key)
@@ -71,7 +71,7 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
71
71
  if (isWindows) {
72
72
  const MSIXManager = require('msix-manager') // require must be here for platform compatibility
73
73
  const manager = new MSIXManager()
74
- await manager.addPackage(nextApp, { restartOnUpdate: this.win32RestartAfterUpdate })
74
+ await manager.addPackage(nextApp, { forceUpdateFromAnyVersion: true })
75
75
  } else {
76
76
  await fsx.swap(nextApp, this.app)
77
77
  }
@@ -94,10 +94,15 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
94
94
  this.checkout = co
95
95
 
96
96
  const manifest = await co.get('/package.json')
97
- if (!manifest || JSON.parse(manifest).version === this.version) {
97
+
98
+ const current = semver.Version.parse(this.version)
99
+ const remote = manifest ? semver.Version.parse(JSON.parse(manifest).version) : null
100
+
101
+ if (!remote || current.compare(remote) >= 0) {
98
102
  this.updating = false
99
103
  this.checkout = null
100
104
  await co.close()
105
+ if (this.drive.core.length > length) this._updateBackground()
101
106
  return
102
107
  }
103
108
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-updater",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Listens for OTA Pear App updates",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc",
@@ -20,8 +20,8 @@
20
20
  "scripts": {
21
21
  "format": "prettier . --write",
22
22
  "test": "npm run test:node && npm run test:bare",
23
- "test:node": "brittle-node test/updates.test.js",
24
- "test:bare": "brittle-bare test/updates.test.js",
23
+ "test:node": "brittle-node test/index.test.js",
24
+ "test:bare": "brittle-bare test/index.test.js",
25
25
  "lint": "prettier --check . && lunte"
26
26
  },
27
27
  "imports": {
@@ -45,11 +45,12 @@
45
45
  "dependencies": {
46
46
  "bare-fs": "^4.5.3",
47
47
  "bare-path": "^3.0.0",
48
+ "bare-semver": "^1.0.2",
48
49
  "fs-native-extensions": "^1.4.5",
49
50
  "hypercore-id-encoding": "^1.3.0",
50
51
  "hyperdrive": "^13.2.1",
51
52
  "localdrive": "^2.2.0",
52
- "msix-manager": "^0.2.1",
53
+ "msix-manager": "^0.2.4",
53
54
  "pear-link": "^4.2.1",
54
55
  "ready-resource": "^1.2.0",
55
56
  "which-runtime": "^1.3.2"
@@ -63,7 +64,7 @@
63
64
  "corestore": "^7.9.1",
64
65
  "hyperswarm": "^4.17.0",
65
66
  "lunte": "^1.6.0",
66
- "pear-build": "^0.2.0",
67
+ "pear-build": "^1.1.0",
67
68
  "prettier": "^3.8.1",
68
69
  "prettier-config-holepunch": "^2.0.0",
69
70
  "test-tmp": "^1.4.0"