Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New CLI command: pear data to print local database contents #525

Merged
merged 35 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0225e72
add CLI command `pear list`
AndreiRegiani Jan 6, 2025
e36dee1
add `cmd/list.js` and `sidecar/ops/list.js`
AndreiRegiani Jan 6, 2025
3fa84fc
list->data
AndreiRegiani Jan 7, 2025
c81292e
ops/data.js using Model
AndreiRegiani Jan 7, 2025
60edea4
cmd/data.js IPC and output format
AndreiRegiani Jan 13, 2025
31515ea
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 13, 2025
a024528
sync cmd <> ops
AndreiRegiani Jan 13, 2025
cad026a
use this.sidecar.mode, refinements
AndreiRegiani Jan 14, 2025
d8f4b47
--json support
AndreiRegiani Jan 14, 2025
442171d
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 14, 2025
bd009e0
`reset` merge conflict fix
AndreiRegiani Jan 14, 2025
e40d941
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 14, 2025
da4d1c5
pear data apps [link]
AndreiRegiani Jan 14, 2025
219c039
Fine tuning
AndreiRegiani Jan 14, 2025
8258865
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 14, 2025
b4378ae
data prints hex representation of encryption key
rafapaezbas Jan 15, 2025
c0279ab
toString('hex') may find a null, remove from GUI IPC
AndreiRegiani Jan 15, 2025
58edeff
ansi color styles
AndreiRegiani Jan 15, 2025
c7cd01b
--show-secrets
AndreiRegiani Jan 15, 2025
14a3bce
Add 09-data.test.js
AndreiRegiani Jan 16, 2025
7672fa9
flag: showSecrets -> secrets
AndreiRegiani Jan 16, 2025
e2e499e
Test implementation
AndreiRegiani Jan 17, 2025
bbf5480
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 17, 2025
c44b827
Conflict: 10-data.test.js
AndreiRegiani Jan 17, 2025
48df7b2
TEMP: pear-ipc alpha
AndreiRegiani Jan 17, 2025
64bc9eb
CI fix setDhtNodes
AndreiRegiani Jan 17, 2025
e126498
padding, secrets
AndreiRegiani Jan 20, 2025
6229b67
10-data-test.js: fix
AndreiRegiani Jan 20, 2025
fd16d0d
10-data.test.js: refinements
AndreiRegiani Jan 21, 2025
64c2f91
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 21, 2025
ecd8146
Merge branch 'main' into cli-list-bundles
AndreiRegiani Jan 21, 2025
29fc524
deriveEncryptionKey
AndreiRegiani Jan 21, 2025
a30f6c7
plan(16)
AndreiRegiani Jan 21, 2025
871d6b9
Merge branch 'cli-list-bundles' of github.com:holepunchto/pear into c…
AndreiRegiani Jan 21, 2025
1483378
updated pear-ipc
rafapaezbas Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
10-data.test.js: refinements
AndreiRegiani committed Jan 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit fd16d0d1a056dba5000de6215b25f685b6bd1bf1
34 changes: 17 additions & 17 deletions test/10-data.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
'use strict'
const test = require('brittle')
const path = require('bare-path')
const crypto = require('hypercore-crypto')
const hypercoreid = require('hypercore-id-encoding')
const crypto = require('hypercore-crypto')
const Helper = require('./helper')
const storageDir = path.join(Helper.localDir, 'test', 'fixtures', 'storage')
const encrypted = path.join(Helper.localDir, 'test', 'fixtures', 'encrypted')

test('pear data', async function ({ ok, is, plan, comment, teardown, timeout }) {
test('pear data', async function ({ ok, is, comment, timeout, teardown }) {
timeout(180000)
plan(10)

const dir = storageDir
const dir = encrypted
const helper = new Helper()
teardown(() => helper.close(), { order: Infinity })
await helper.ready()

comment('staging')
const id = Math.floor(Math.random() * 10000)
const password = hypercoreid.encode(crypto.randomBytes(32))
const touch = await helper.touch({ dir, channel: `test-${id}` })
const { key } = await Helper.pick(touch, { tag: 'result' })
await helper.permit({ key: hypercoreid.decode(key), password })
const staging = helper.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
teardown(() => Helper.teardownStream(staging))
const staged = await Helper.pick(staging, [{ tag: 'addendum' }, { tag: 'final' }])
await staged.final

const link = `pear://${key}`
const run = await Helper.run({ link })
let data = await helper.data({ resource: 'apps' })
const { pipe } = await Helper.run({ link })

comment('staging with encryption key')
const staging = helper.stage({ channel: `test-${id}`, dir, dryRun: false })
teardown(() => Helper.teardownStream(staging))
const final = await Helper.pick(staging, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('pear data apps')
let data = await helper.data({ resource: 'apps' })
let result = await Helper.pick(data, [{ tag: 'apps' }])
const bundles = await result.apps
ok(bundles.length > 0, 'Bundle array exists')
@@ -41,17 +40,18 @@ test('pear data', async function ({ ok, is, plan, comment, teardown, timeout })
data = await helper.data({ resource: 'link', link })
result = await Helper.pick(data, [{ tag: 'link' }])
let bundle = await result.link
ok(bundle.encryptionKey === undefined, 'Encryption key is hidden without --secrets')
ok(bundle.link.startsWith('pear://'), 'Link starts with pear://')
is(bundle.link, link, 'Link matches the one just created')
is(bundle.link, link, 'Link matches to the one just created')
is(typeof bundle.appStorage, 'string', 'Field appStorage is a string')

comment('pear data --secrets apps [link]')
data = await helper.data({ resource: 'link', link, secrets: true })
result = await Helper.pick(data, [{ tag: 'link' }])
bundle = await result.link
is(bundle.encryptionKey, password.toString('hex'), 'Encryption key matches')
is(hypercoreid.encode(bundle.encryptionKey), password, 'Encryption key matches')
ok(bundle.link.startsWith('pear://'), 'Link starts with pear://')
is(bundle.link, link, 'Link matches the one just created')
is(bundle.link, link, 'Link matches to the one just created')
is(typeof bundle.appStorage, 'string', 'Field appStorage is a string')

comment('pear data dht')
@@ -62,6 +62,6 @@ test('pear data', async function ({ ok, is, plan, comment, teardown, timeout })
is(typeof dht[0].host, 'string', 'Field host is a string')
is(typeof dht[0].port, 'number', 'Field port is a number')

await Helper.untilClose(run.pipe)
await Helper.untilClose(pipe)
ok(true, 'ended')
})