pear-runtime-updater 0.0.14 → 1.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.
Files changed (2) hide show
  1. package/index.js +3 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -9,7 +9,6 @@ const ReadyResource = require('ready-resource')
9
9
  const link = require('pear-link')
10
10
  const hid = require('hypercore-id-encoding')
11
11
  const { platform, arch } = require('which-runtime')
12
- const isMobile = platform === 'ios' || platform === 'android'
13
12
  const host = platform + '-' + arch
14
13
 
15
14
  module.exports = class PearRuntime extends ReadyResource {
@@ -22,7 +21,7 @@ module.exports = class PearRuntime extends ReadyResource {
22
21
  this.dir = opts.dir
23
22
  this.version = opts.version || 0
24
23
  this.app = opts.app
25
- this.name = this.app && path.basename(this.app)
24
+ this.name = opts.name ?? (this.app && path.basename(this.app))
26
25
  this.bundled = opts.bundled || !!this.app
27
26
 
28
27
  if (this.updates) {
@@ -89,9 +88,7 @@ module.exports = class PearRuntime extends ReadyResource {
89
88
  this.applied = true
90
89
 
91
90
  // mac only for now, linux similar, windows, more pain
92
- const segments = [this.next, 'by-arch', host, 'app']
93
- if (!isMobile) segments.push(this.name)
94
- await fsx.swap(path.join(...segments), this.app)
91
+ await fsx.swap(path.join(this.next, 'by-arch', host, 'app', this.name), this.app)
95
92
  await fs.promises.rm(this.next, { recursive: true, force: true })
96
93
  }
97
94
 
@@ -121,11 +118,10 @@ module.exports = class PearRuntime extends ReadyResource {
121
118
  const local = new Localdrive(next)
122
119
 
123
120
  this.emit('updating')
124
- const prefix = `/by-arch/${host}/app${isMobile ? '' : `/${this.name}`}`
121
+ const prefix = `/by-arch/${host}/app/${this.name}`
125
122
  for await (const data of co.mirror(local, { prefix })) {
126
123
  this.emit('updating-delta', data)
127
124
  }
128
- if (isMobile) await local.put(`${prefix}/package.json`, manifest)
129
125
 
130
126
  await co.close()
131
127
  await local.close()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-updater",
3
- "version": "0.0.14",
3
+ "version": "1.0.0",
4
4
  "description": "Listens for OTA Pear App updates",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc",