pear-runtime-updater 0.0.9 → 0.0.11

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 +13 -5
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -8,9 +8,10 @@ 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 MSIXManager = require('msix-manager')
12
+ const { platform, arch, isWindows } = require('which-runtime')
12
13
  const isMobile = platform === 'ios' || platform === 'android'
13
- const host = isMobile ? platform : platform + '-' + arch
14
+ const host = platform + '-' + arch
14
15
 
15
16
  module.exports = class PearRuntime extends ReadyResource {
16
17
  constructor(opts = {}) {
@@ -90,8 +91,14 @@ module.exports = class PearRuntime extends ReadyResource {
90
91
 
91
92
  // mac only for now, linux similar, windows, more pain
92
93
  const segments = [this.next, 'by-arch', host, 'app']
93
- if (!isMobile) segments.push(this.name)
94
- await fsx.swap(path.join(...segments), this.app)
94
+ if (!isMobile && !isWindows) segments.push(this.name)
95
+ if (isWindows) {
96
+ const manager = new MSIXManager()
97
+ const msix = this.name.slice(0, -3) + 'msix'
98
+ await manager.addPackage(...segments, msix)
99
+ } else {
100
+ await fsx.swap(path.join(...segments), this.app)
101
+ }
95
102
  await fs.promises.rm(this.next, { recursive: true, force: true })
96
103
  }
97
104
 
@@ -121,10 +128,11 @@ module.exports = class PearRuntime extends ReadyResource {
121
128
  const local = new Localdrive(next)
122
129
 
123
130
  this.emit('updating')
124
- const prefix = `/by-arch/${host}/app/${isMobile ? '' : this.name}`
131
+ const prefix = `/by-arch/${host}/app${isMobile ? '' : `/${this.name}`}`
125
132
  for await (const data of co.mirror(local, { prefix })) {
126
133
  this.emit('updating-delta', data)
127
134
  }
135
+ if (isMobile) await local.put(`${prefix}/package.json`, manifest)
128
136
 
129
137
  await co.close()
130
138
  await local.close()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-updater",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
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"