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

feat: add name to w3 space info output #164

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,17 @@
}
}

const space = client.spaces().find((s) => s.did() === spaceDID)
const name = space ? space.name : undefined

if (opts.json) {
console.log(JSON.stringify(info, null, 4))
console.log(JSON.stringify({ ...info, name }, null, 4))
} else {
const providers = info.providers?.join(', ') ?? ''
console.log(`
DID: ${info.did}
Providers: ${providers || chalk.dim('none')}`)
Providers: ${providers || chalk.dim('none')}
Name: ${name ?? chalk.dim('none')}`)
}
}

Expand Down Expand Up @@ -564,7 +568,7 @@
}
}

export async function whoami() {

Check warning on line 571 in index.js

View workflow job for this annotation

GitHub Actions / Test

Missing JSDoc comment
const client = await getClient()
console.log(client.did())
}
Expand Down
18 changes: 18 additions & 0 deletions test/bin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as ED25519 from '@ucanto/principal/ed25519'
import { sha256, delegate } from '@ucanto/core'
import * as Result from '@web3-storage/w3up-client/result'
import { base64 } from 'multiformats/bases/base64'
import { info } from 'console'

const w3 = Command.create('./bin.js')

Expand Down Expand Up @@ -533,6 +534,12 @@ export const testSpace = {
'space has no providers'
)

assert.match(
infoWithoutProvider.output,
pattern`Name: home`,
'space name is set'
)

Test.provisionSpace(context, {
space: spaceDID,
account: 'did:mailto:web.mail:alice',
Expand All @@ -549,6 +556,17 @@ export const testSpace = {
pattern`DID: ${spaceDID}\nProviders: .*${providerDID}`,
'added provider shows up in the space info'
)

const infoWithProviderJson = await w3
.args(['space', 'info', '--json'])
.env(context.env.alice)
.join()

assert.deepEqual(JSON.parse(infoWithProviderJson.output), {
did: spaceDID,
providers: [providerDID],
name: 'home'
})
}),

'w3 space provision --coupon': test(async (assert, context) => {
Expand Down