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: optionally deploy config in get-bee command #554

Merged
merged 3 commits into from
Dec 8, 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
16 changes: 1 addition & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Auth to Github Package Docker Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin

## Try getting the node modules from cache, if failed npm ci
- uses: actions/cache@v2
id: cache-npm
with:
path: node_modules
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-${{ matrix.node }}-${{ env.cache-name }}-
${{ runner.OS }}-node-${{ matrix.node }}-

- name: Install npm deps
run: npm install -g npm && npm ci && npm install -g @fairdatasociety/fdp-play
run: npm ci && npm install -g @fairdatasociety/fdp-play

- name: Start fdp-play environment
run: npm run bee
Expand Down
40 changes: 34 additions & 6 deletions src/command/utility/get-bee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Strings } from 'cafe-utility'
import { execSync } from 'child_process'
import { writeFileSync } from 'fs'
import { existsSync, writeFileSync } from 'fs'
import { LeafCommand } from 'furious-commander'
import fetch from 'node-fetch'
import { RootCommand } from '../root-command'
Expand Down Expand Up @@ -34,14 +35,41 @@ export class GetBee extends RootCommand implements LeafCommand {
await fetch(url)
.then(x => x.arrayBuffer())
.then(x => writeFileSync(`bee${suffixString}`, Buffer.from(x)))
this.console.info('Bee downloaded successfully')
this.console.log('Bee downloaded successfully')

if (process.platform !== 'win32') {
this.console.info(`Running chmod +x bee`)
this.console.info(`Running chmod +x bee to make it executable`)
execSync('chmod +x bee')
}
this.console.log('Verify the version of the downloaded Bee binary by running:')
this.console.log('')
this.console.log('./bee version')

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

return
}

this.console.info('')
this.console.info('Ultra-light: Limited download capabilities, no funding required.')
this.console.info('Light: Full functionality; requires xDAI to launch and xBZZ for uploading and retrieving data.')

const type = await this.console.promptList(['ultra-light', 'light'], 'Select the type of configuration to create')
writeFileSync(
'config.yaml',
`api-addr: 127.0.0.1:1633
blockchain-rpc-endpoint: "https://xdai.fairdatasociety.org"
cors-allowed-origins: ["*"]
data-dir: "${process.cwd()}/data-dir"
full-node: false
mainnet: true
resolver-options: ["https://cloudflare-eth.com"]
storage-incentives-enable: false
swap-enable: ${type === 'light' ? 'true' : 'false'}
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')
}
}
Loading