pear-runtime-updater 1.0.0 → 1.0.1
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/index.js +16 -7
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const fsx = require('fs-native-extensions')
|
|
|
8
8
|
const ReadyResource = require('ready-resource')
|
|
9
9
|
const link = require('pear-link')
|
|
10
10
|
const hid = require('hypercore-id-encoding')
|
|
11
|
-
const { platform, arch } = require('which-runtime')
|
|
11
|
+
const { platform, arch, isWindows } = require('which-runtime')
|
|
12
12
|
const host = platform + '-' + arch
|
|
13
13
|
|
|
14
14
|
module.exports = class PearRuntime extends ReadyResource {
|
|
@@ -22,6 +22,7 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
22
22
|
this.version = opts.version || 0
|
|
23
23
|
this.app = opts.app
|
|
24
24
|
this.name = opts.name ?? (this.app && path.basename(this.app))
|
|
25
|
+
if (isWindows) this.name = path.basename(this.name, path.extname(this.name)) + '.msix'
|
|
25
26
|
this.bundled = opts.bundled || !!this.app
|
|
26
27
|
|
|
27
28
|
if (this.updates) {
|
|
@@ -77,18 +78,26 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
async _close() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
await this.
|
|
83
|
-
await this.
|
|
81
|
+
if (!this.updates) return
|
|
82
|
+
|
|
83
|
+
await this.drive.close()
|
|
84
|
+
if (this.checkout !== null) await this.checkout.close()
|
|
85
|
+
await this.store.close()
|
|
86
|
+
await this.swarm.destroy()
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
async applyUpdate() {
|
|
87
90
|
if (!this.updated || this.applied || !this.bundled) return
|
|
88
91
|
this.applied = true
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const nextApp = path.join(this.next, 'by-arch', host, 'app', this.name)
|
|
94
|
+
if (isWindows) {
|
|
95
|
+
const MSIXManager = require('msix-manager') // require must be here for platform compatibility
|
|
96
|
+
const manager = new MSIXManager()
|
|
97
|
+
await manager.addPackage(nextApp)
|
|
98
|
+
} else {
|
|
99
|
+
await fsx.swap(nextApp, this.app)
|
|
100
|
+
}
|
|
92
101
|
await fs.promises.rm(this.next, { recursive: true, force: true })
|
|
93
102
|
}
|
|
94
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pear-runtime-updater",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Listens for OTA Pear App updates",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Holepunch Inc",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"hyperdrive": "^13.2.1",
|
|
42
42
|
"hyperswarm": "^4.16.0",
|
|
43
43
|
"localdrive": "^2.2.0",
|
|
44
|
+
"msix-manager": "^0.1.1",
|
|
44
45
|
"pear-link": "^4.2.1",
|
|
45
46
|
"ready-resource": "^1.2.0",
|
|
46
47
|
"which-runtime": "^1.3.2"
|