pear-install 1.0.5 → 1.0.7
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 +10 -4
- package/bin.js +2 -16
- package/cmd.js +19 -2
- package/index.js +11 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -68,11 +68,11 @@ await corestore.close()
|
|
|
68
68
|
### Events
|
|
69
69
|
|
|
70
70
|
- `installing` → `{ link, host }`
|
|
71
|
-
- `app` → `{ app, name, version, upgrade, key, dest }`
|
|
71
|
+
- `app` → `{ app, name, version, upgrade, verlink, key, dest }`
|
|
72
72
|
- `stats` → `{ download, upload, peers }`
|
|
73
73
|
- `final` → `{ success, installed, exists }`
|
|
74
74
|
|
|
75
|
-
##
|
|
75
|
+
## Command Integration: `/cmd`
|
|
76
76
|
|
|
77
77
|
For embedding in another CLI. Wraps `Install` as a `pear-opstream` of `{ tag, data }` records with stdout formatters.
|
|
78
78
|
|
|
@@ -86,12 +86,12 @@ await InstallCmd.output(json, stream)
|
|
|
86
86
|
### Tags
|
|
87
87
|
|
|
88
88
|
- `installing` → `{ link, host }`
|
|
89
|
-
- `app` → `{ app, name, version, upgrade, key, dest }`
|
|
89
|
+
- `app` → `{ app, name, version, upgrade, verlink, key, dest }`
|
|
90
90
|
- `stats` → `{ download, upload, peers }`
|
|
91
91
|
- `error` → `{ code, message, stack, info, success: false }`
|
|
92
92
|
- `final` → `{ success, installed, exists }`
|
|
93
93
|
|
|
94
|
-
### `InstallCmd.output(json, stream)`
|
|
94
|
+
### `await InstallCmd.output(json, stream)`
|
|
95
95
|
|
|
96
96
|
Drains `stream` to STDOUT.
|
|
97
97
|
|
|
@@ -100,6 +100,12 @@ Drains `stream` to STDOUT.
|
|
|
100
100
|
|
|
101
101
|
Returns the `final` record.
|
|
102
102
|
|
|
103
|
+
### `await InstallCmd.runner(cmd)`
|
|
104
|
+
|
|
105
|
+
Pass directly as a [paparam](https://github.com/holepunchto/paparam) command runner. Creates `InstallCmd` instance and passes it to `InstallCmd.output`
|
|
106
|
+
|
|
107
|
+
- `cmd` is a [paparam](https://github.com/holepunchto/paparam) `cmd` instance
|
|
108
|
+
|
|
103
109
|
## License
|
|
104
110
|
|
|
105
111
|
Apache-2.0
|
package/bin.js
CHANGED
|
@@ -2,26 +2,12 @@
|
|
|
2
2
|
const pkg = require('./package.json')
|
|
3
3
|
const { isWindows } = require('which-runtime')
|
|
4
4
|
const { command, arg, bail } = require('paparam')
|
|
5
|
-
const
|
|
5
|
+
const { runner } = require('./cmd')
|
|
6
6
|
|
|
7
7
|
const program = command(
|
|
8
8
|
'install',
|
|
9
9
|
arg('[link]', 'Pear link origin to install from'),
|
|
10
|
-
|
|
11
|
-
const { json, only, to, dhtBootstrap } = cmd.flags
|
|
12
|
-
const timeout = (cmd.flags.timeout || 30) * 1000
|
|
13
|
-
const link = cmd.args.link ?? pkg.pear.platform.key
|
|
14
|
-
const bootstrap = dhtBootstrap
|
|
15
|
-
? dhtBootstrap.split(',').map((tuple) => {
|
|
16
|
-
const [host, port] = tuple.split(':')
|
|
17
|
-
const int = +port
|
|
18
|
-
if (Number.isInteger(int) === false) throw new Error(`Invalid port: ${port}`)
|
|
19
|
-
return { host, port: int }
|
|
20
|
-
})
|
|
21
|
-
: undefined
|
|
22
|
-
const stream = new InstallCmd({ link, only, to, bootstrap, timeout })
|
|
23
|
-
await InstallCmd.output(json, stream)
|
|
24
|
-
},
|
|
10
|
+
runner,
|
|
25
11
|
pkg.command,
|
|
26
12
|
bail((info = {}) => {
|
|
27
13
|
process.exitCode = 1
|
package/cmd.js
CHANGED
|
@@ -3,6 +3,7 @@ const process = require('process')
|
|
|
3
3
|
const Opstream = require('pear-opstream')
|
|
4
4
|
const byteSize = require('tiny-byte-size')
|
|
5
5
|
const { isWindows } = require('which-runtime')
|
|
6
|
+
const pkg = require('./package.json')
|
|
6
7
|
const Install = require('.')
|
|
7
8
|
|
|
8
9
|
const down = isWindows ? '↓' : '⬇'
|
|
@@ -10,8 +11,8 @@ const down = isWindows ? '↓' : '⬇'
|
|
|
10
11
|
class InstallCmd extends Opstream {
|
|
11
12
|
static outputs = {
|
|
12
13
|
installing: ({ link }) => `Installing... ${link}`,
|
|
13
|
-
app: ({ app, version, upgrade, dest, key }) =>
|
|
14
|
-
`App: ${app}\nVersion: ${version}\nLink: ${upgrade}\nPathname: ${key}\nTarget: ${dest}`,
|
|
14
|
+
app: ({ app, version, upgrade, dest, key, verlink }) =>
|
|
15
|
+
`App: ${app}\nVersion: ${version}\nLink: ${upgrade}\nVerlink: ${verlink}\nPathname: ${key}\nTarget: ${dest}`,
|
|
15
16
|
stats({ download, peers }) {
|
|
16
17
|
const dl =
|
|
17
18
|
download.bytes + download.speed === 0
|
|
@@ -46,6 +47,22 @@ class InstallCmd extends Opstream {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
static async runner(cmd) {
|
|
51
|
+
const { json, only, to, dhtBootstrap } = cmd.flags
|
|
52
|
+
const timeout = (cmd.flags.timeout || 30) * 1000
|
|
53
|
+
const link = cmd.args.link ?? pkg.pear.platform.key
|
|
54
|
+
const bootstrap = dhtBootstrap
|
|
55
|
+
? dhtBootstrap.split(',').map((tuple) => {
|
|
56
|
+
const [host, port] = tuple.split(':')
|
|
57
|
+
const int = +port
|
|
58
|
+
if (Number.isInteger(int) === false) throw new Error(`Invalid port: ${port}`)
|
|
59
|
+
return { host, port: int }
|
|
60
|
+
})
|
|
61
|
+
: undefined
|
|
62
|
+
const stream = new InstallCmd({ link, only, to, bootstrap, timeout })
|
|
63
|
+
await InstallCmd.output(json, stream)
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
constructor(params) {
|
|
50
67
|
super((...args) => this.#op(...args), params)
|
|
51
68
|
}
|
package/index.js
CHANGED
|
@@ -192,7 +192,17 @@ class Install extends ReadyResource {
|
|
|
192
192
|
let installed = 0
|
|
193
193
|
for (const { filename, ext, dest, isBin } of installs) {
|
|
194
194
|
const key = appPath + filename + ext
|
|
195
|
-
|
|
195
|
+
const verlink = plink.serialize({ drive: this.drive.core })
|
|
196
|
+
this.emit('app', {
|
|
197
|
+
app: filename,
|
|
198
|
+
name,
|
|
199
|
+
version,
|
|
200
|
+
upgrade,
|
|
201
|
+
verlink,
|
|
202
|
+
key,
|
|
203
|
+
tmp,
|
|
204
|
+
dest
|
|
205
|
+
})
|
|
196
206
|
|
|
197
207
|
const from = path.join(tmp, 'by-arch', host, 'app', filename + ext)
|
|
198
208
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pear-install",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"description": "Install Pear and Pear Applications",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"bin": "bin.js",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": "./index.js",
|
|
15
|
-
"./cmd": "./cmd.js"
|
|
15
|
+
"./cmd": "./cmd.js",
|
|
16
|
+
"./package.json": "./package.json"
|
|
16
17
|
},
|
|
17
18
|
"imports": {
|
|
18
19
|
"process": {
|