pear-runtime-updater 1.0.1 → 2.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/README.md +2 -0
- package/index.js +8 -6
- package/package.json +22 -5
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ const updater = new PearRuntimeUpdater({
|
|
|
28
28
|
upgrade,
|
|
29
29
|
version,
|
|
30
30
|
app: getApp() // path to .app / .AppImage
|
|
31
|
+
name: 'name.ext' // <name>.app, <name>.AppImage, <name>.msix
|
|
31
32
|
})
|
|
32
33
|
|
|
33
34
|
await updater.ready()
|
|
@@ -56,6 +57,7 @@ process.on('beforeExit', () => updater.close())
|
|
|
56
57
|
|
|
57
58
|
- `opts.dir` – (required) Directory to store data (e.g. app data dir).
|
|
58
59
|
- `opts.upgrade` – (required) Pear upgrade link (e.g. from `package.json` `upgrade` field).
|
|
60
|
+
- `opts.name` – (required) Application name with extension.
|
|
59
61
|
- `opts.version` – (optional) Current app version; used to decide if an update should be stored.
|
|
60
62
|
- `opts.app` – (optional) Path to the app bundle (for bundled apps; used with `applyUpdate()`).
|
|
61
63
|
- `opts.bundled` – (optional) Whether the app is bundled. Defaults to `!!opts.app`.
|
package/index.js
CHANGED
|
@@ -11,19 +11,21 @@ const hid = require('hypercore-id-encoding')
|
|
|
11
11
|
const { platform, arch, isWindows } = require('which-runtime')
|
|
12
12
|
const host = platform + '-' + arch
|
|
13
13
|
|
|
14
|
-
module.exports = class
|
|
14
|
+
module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
15
15
|
constructor(opts = {}) {
|
|
16
16
|
super()
|
|
17
17
|
this.updates = opts.updates !== false
|
|
18
18
|
if (!opts.dir) throw new Error('dir required')
|
|
19
19
|
if (!opts.upgrade) throw new Error('upgrade link required')
|
|
20
|
+
if (!opts.name) throw new Error('name required')
|
|
20
21
|
|
|
21
22
|
this.dir = opts.dir
|
|
22
23
|
this.version = opts.version || 0
|
|
23
24
|
this.app = opts.app
|
|
24
|
-
this.name = opts.name
|
|
25
|
-
|
|
25
|
+
this.name = opts.name
|
|
26
|
+
this.bootstrap = opts.bootstrap
|
|
26
27
|
this.bundled = opts.bundled || !!this.app
|
|
28
|
+
this.win32RestartAfterUpdate = opts.win32 && opts.win32.restart
|
|
27
29
|
|
|
28
30
|
if (this.updates) {
|
|
29
31
|
const { drive: upgrade } = link.parse(opts.upgrade)
|
|
@@ -63,7 +65,7 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
63
65
|
|
|
64
66
|
if (!this.swarm) {
|
|
65
67
|
const keyPair = await this.store.createKeyPair('pear-container')
|
|
66
|
-
this.swarm = new Hyperswarm({ keyPair })
|
|
68
|
+
this.swarm = new Hyperswarm({ keyPair, bootstrap: this.bootstrap })
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
this.swarm.on('connection', (connection) => this.store.replicate(connection))
|
|
@@ -94,7 +96,7 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
94
96
|
if (isWindows) {
|
|
95
97
|
const MSIXManager = require('msix-manager') // require must be here for platform compatibility
|
|
96
98
|
const manager = new MSIXManager()
|
|
97
|
-
await manager.addPackage(nextApp)
|
|
99
|
+
await manager.addPackage(nextApp, { restartOnUpdate: this.win32RestartAfterUpdate })
|
|
98
100
|
} else {
|
|
99
101
|
await fsx.swap(nextApp, this.app)
|
|
100
102
|
}
|
|
@@ -102,7 +104,7 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
_updateBackground() {
|
|
105
|
-
this._update().catch(
|
|
107
|
+
this._update().catch((err) => this.emit('error', err))
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
async _update() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pear-runtime-updater",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Listens for OTA Pear App updates",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Holepunch Inc",
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"format": "prettier . --write",
|
|
22
|
-
"test": "
|
|
23
|
-
"
|
|
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",
|
|
25
|
+
"lint": "prettier --check . && lunte"
|
|
24
26
|
},
|
|
25
27
|
"imports": {
|
|
26
28
|
"fs": {
|
|
@@ -30,6 +32,14 @@
|
|
|
30
32
|
"path": {
|
|
31
33
|
"bare": "bare-path",
|
|
32
34
|
"default": "path"
|
|
35
|
+
},
|
|
36
|
+
"os": {
|
|
37
|
+
"bare": "bare-os",
|
|
38
|
+
"default": "os"
|
|
39
|
+
},
|
|
40
|
+
"child_process": {
|
|
41
|
+
"bare": "bare-subprocess",
|
|
42
|
+
"default": "child_process"
|
|
33
43
|
}
|
|
34
44
|
},
|
|
35
45
|
"dependencies": {
|
|
@@ -41,14 +51,21 @@
|
|
|
41
51
|
"hyperdrive": "^13.2.1",
|
|
42
52
|
"hyperswarm": "^4.16.0",
|
|
43
53
|
"localdrive": "^2.2.0",
|
|
44
|
-
"msix-manager": "^0.1.
|
|
54
|
+
"msix-manager": "^0.1.2",
|
|
45
55
|
"pear-link": "^4.2.1",
|
|
46
56
|
"ready-resource": "^1.2.0",
|
|
47
57
|
"which-runtime": "^1.3.2"
|
|
48
58
|
},
|
|
49
59
|
"devDependencies": {
|
|
60
|
+
"@hyperswarm/testnet": "^3.1.4",
|
|
61
|
+
"bare-env": "^3.0.0",
|
|
62
|
+
"bare-os": "^3.7.0",
|
|
63
|
+
"bare-subprocess": "^5.2.2",
|
|
64
|
+
"brittle": "^3.19.1",
|
|
50
65
|
"lunte": "^1.6.0",
|
|
66
|
+
"pear-build": "^0.2.0",
|
|
51
67
|
"prettier": "^3.8.1",
|
|
52
|
-
"prettier-config-holepunch": "^2.0.0"
|
|
68
|
+
"prettier-config-holepunch": "^2.0.0",
|
|
69
|
+
"test-tmp": "^1.4.0"
|
|
53
70
|
}
|
|
54
71
|
}
|