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: improve onboarding flow #556

Merged
merged 1 commit into from
Dec 9, 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
29 changes: 14 additions & 15 deletions src/command/stamp/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ export class Create extends StampCommand implements LeafCommand {

@Option({
key: 'capacity',
description: 'Size of data, e.g. 100MB, 1GB',
description: 'Size of data, e.g. 1GB',
type: 'string',
required: false,
})
public capacity!: string

@Option({
key: 'ttl',
description: 'Time to live of the postage stamp, e.g. 1d, 4w, "6 months", 1y',
description: 'Time to live of the postage stamp, e.g. 1d, 1w, 1month',
type: 'string',
required: false,
})
public ttl!: string

@Option({ key: 'immutable', description: 'Disable stamp reuse', type: 'boolean', default: true })
@Option({
key: 'immutable',
description: 'At full capacity, immutable prevents; mutable allows further uploads, overwriting old data',
type: 'boolean',
default: true,
})
public immutable!: boolean

@Option({ key: 'label', description: 'Label of the postage stamp' })
Expand All @@ -43,19 +48,19 @@ export class Create extends StampCommand implements LeafCommand {
let ttlInMillis = 0

if (!this.capacity) {
this.console.log('Please provide the capacity of the postage stamp')
this.console.log('This is the size of the data that can be uploaded with this stamp')
this.console.log('Example: 100MB, 1GB')
this.console.log('Please provide the total capacity of the postage stamp batch')
this.console.log('This represents the total size of data that can be uploaded')
this.console.log('Example: 1GB')
this.capacity = await this.console.askForValue('Capacity')
this.console.log('')
}

capacityInBytes = Numbers.makeStorage(this.capacity)

if (!this.ttl) {
this.console.log('Please provide the time to live of the postage stamp')
this.console.log('This is the time after which the stamp will expire')
this.console.log('Example: 1h, 1d, 1w')
this.console.log('Please provide the time-to-live (TTL) of the postage stamps')
this.console.log('Defines the duration after which the stamp will expire')
this.console.log('Example: 1d, 1w, 1month')
this.ttl = await this.console.askForValue('TTL')
this.console.log('')
}
Expand Down Expand Up @@ -91,12 +96,6 @@ export class Create extends StampCommand implements LeafCommand {
this.console.log(createKeyValue('Estimated TTL', Dates.secondsToHumanTime(estimatedTtl)))
this.console.log(createKeyValue('Type', this.immutable ? 'Immutable' : 'Mutable'))

if (this.immutable) {
this.console.info('At full capacity, an immutable stamp no longer allows new content uploads.')
} else {
this.console.info('At full capacity, a mutable stamp allows new content uploads, but overwrites old content.')
}

if (!this.quiet && !this.yes) {
this.yes = await this.console.confirm('Confirm the purchase')
}
Expand Down
3 changes: 3 additions & 0 deletions src/command/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BeeModes } from '@ethersphere/bee-js'
import { Numbers } from 'cafe-utility'
import chalk from 'chalk'
import { LeafCommand } from 'furious-commander'
import { exit } from 'process'
import { createKeyValue } from '../utils/text'
import { RootCommand } from './root-command'

Expand All @@ -20,6 +21,8 @@ export class Status extends RootCommand implements LeafCommand {
process.stdout.write(chalk.bold.green(' [OK]') + '\n')
} catch {
process.stdout.write(chalk.bold.red(' [FAILED]') + '\n')
process.stdout.write('\nIs your Bee node running?\n')
exit(1)
}
const versions = await this.bee.getVersions()
this.console.all(createKeyValue('Version', versions.beeVersion))
Expand Down
8 changes: 4 additions & 4 deletions src/command/utility/get-bee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class GetBee extends RootCommand implements LeafCommand {
execSync('chmod +x bee')
}

if (existsSync('config.yaml')) {
this.console.log('config.yaml already exists, done')
if (existsSync('bee.yaml')) {
this.console.log('bee.yaml already exists, done')

return
}
Expand All @@ -54,7 +54,7 @@ export class GetBee extends RootCommand implements LeafCommand {

const type = await this.console.promptList(['ultra-light', 'light'], 'Select the type of configuration to create')
writeFileSync(
'config.yaml',
'bee.yaml',
`api-addr: 127.0.0.1:1633
blockchain-rpc-endpoint: "https://xdai.fairdatasociety.org"
cors-allowed-origins: ["*"]
Expand All @@ -70,6 +70,6 @@ password: "${Strings.randomAlphanumeric(20)}"`,
this.console.info('')
this.console.log('All set! Start Bee node by running:')
this.console.info('')
this.console.log('./bee start --config=config.yaml')
this.console.log('./bee start --config=bee.yaml')
}
}
Loading