pear-prerelease 3.0.0 → 3.1.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/index.js +30 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,17 +9,19 @@ import { flag, command } from 'paparam'
|
|
|
9
9
|
|
|
10
10
|
const app = command('pear-prerelease',
|
|
11
11
|
flag('--dry-run'),
|
|
12
|
-
flag('--from
|
|
13
|
-
flag('--to
|
|
14
|
-
flag('--production
|
|
12
|
+
flag('--from|-f <link>'),
|
|
13
|
+
flag('--to|-t <link>'),
|
|
14
|
+
flag('--production|-p <link>'),
|
|
15
|
+
flag('--bootstrap'),
|
|
15
16
|
flag('--touch'),
|
|
16
|
-
flag('--storage
|
|
17
|
+
flag('--storage|-s <storage>')
|
|
17
18
|
).parse()
|
|
18
19
|
|
|
19
20
|
const exit = global.Bare ? Bare.exit.bind(Bare) : process.exit.bind(process)
|
|
20
21
|
if (!app) exit(0)
|
|
21
22
|
|
|
22
23
|
const DRY_RUN = app.flags.dryRun
|
|
24
|
+
const BOOTSTRAP = app.flags.bootstrap
|
|
23
25
|
const FROM = app.flags.from ? pearLink.parse(app.flags.from) : null
|
|
24
26
|
const TO = app.flags.to ? pearLink.parse(app.flags.to) : null
|
|
25
27
|
const PROD = app.flags.production ? pearLink.parse(app.flags.production) : null
|
|
@@ -33,7 +35,7 @@ if (app.flags.touch) {
|
|
|
33
35
|
await core.close()
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
if (FROM && TO) {
|
|
38
|
+
if (FROM && TO && PROD) {
|
|
37
39
|
const swarm = new Hyperswarm({
|
|
38
40
|
keyPair: await store.createKeyPair('hyperswarm')
|
|
39
41
|
})
|
|
@@ -43,8 +45,8 @@ if (FROM && TO) {
|
|
|
43
45
|
const to = new Hyperdrive(store.namespace('release'), TO.drive.key, { compat: false })
|
|
44
46
|
await to.ready()
|
|
45
47
|
|
|
46
|
-
const prod =
|
|
47
|
-
|
|
48
|
+
const prod = new Hyperdrive(store.namespace('prod'), PROD.drive.key)
|
|
49
|
+
await prod.ready()
|
|
48
50
|
|
|
49
51
|
const from = new Hyperdrive(store.session(), FROM.drive.key)
|
|
50
52
|
await from.ready()
|
|
@@ -58,35 +60,33 @@ if (FROM && TO) {
|
|
|
58
60
|
server: false
|
|
59
61
|
})
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
63
|
+
// hydrate prod target
|
|
64
|
+
if (prod.core.length === 0 && !BOOTSTRAP) {
|
|
65
|
+
await new Promise(resolve => prod.core.once('append', () => resolve()))
|
|
66
|
+
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
prod.core.download()
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
console.log('Copying in existing metadata data, might take a bit...')
|
|
71
|
+
while (to.core.length < prod.core.length) {
|
|
72
|
+
await to.core.append(await prod.core.get(to.core.length))
|
|
73
|
+
console.log('Copied blocks', to.core.length, '/', prod.core.length)
|
|
74
|
+
}
|
|
75
|
+
console.log('Done!')
|
|
76
|
+
console.log()
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
await to.getBlobs()
|
|
79
|
+
await prod.getBlobs()
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
prod.blobs.core.download()
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
console.log('Done!')
|
|
88
|
-
console.log()
|
|
83
|
+
console.log('Copying in existing blob data, might take a bit...')
|
|
84
|
+
while (to.blobs.core.length < prod.blobs.core.length) {
|
|
85
|
+
await to.blobs.core.append(await prod.blobs.core.get(to.blobs.core.length))
|
|
86
|
+
console.log('Copied blob blocks', to.blobs.core.length, '/', prod.blobs.core.length)
|
|
89
87
|
}
|
|
88
|
+
console.log('Done!')
|
|
89
|
+
console.log()
|
|
90
90
|
|
|
91
91
|
const co = from.checkout(FROM.drive.length || from.core.length)
|
|
92
92
|
await co.ready()
|