Skip to content

Commit e2085b9

Browse files
authored
feat: optionally deploy config in get-bee command (#554)
* feat: optionally deploy config in get-bee command * chore: wording * ci: simplify test ci
1 parent 1d4b36b commit e2085b9

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,8 @@ jobs:
3131
with:
3232
node-version: ${{ matrix.node-version }}
3333

34-
- name: Auth to Github Package Docker Registry
35-
run: |
36-
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
37-
38-
## Try getting the node modules from cache, if failed npm ci
39-
- uses: actions/cache@v2
40-
id: cache-npm
41-
with:
42-
path: node_modules
43-
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
44-
restore-keys: |
45-
${{ runner.OS }}-node-${{ matrix.node }}-${{ env.cache-name }}-
46-
${{ runner.OS }}-node-${{ matrix.node }}-
47-
4834
- name: Install npm deps
49-
run: npm install -g npm && npm ci && npm install -g @fairdatasociety/fdp-play
35+
run: npm ci && npm install -g @fairdatasociety/fdp-play
5036

5137
- name: Start fdp-play environment
5238
run: npm run bee

src/command/utility/get-bee.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Strings } from 'cafe-utility'
12
import { execSync } from 'child_process'
2-
import { writeFileSync } from 'fs'
3+
import { existsSync, writeFileSync } from 'fs'
34
import { LeafCommand } from 'furious-commander'
45
import fetch from 'node-fetch'
56
import { RootCommand } from '../root-command'
@@ -34,14 +35,41 @@ export class GetBee extends RootCommand implements LeafCommand {
3435
await fetch(url)
3536
.then(x => x.arrayBuffer())
3637
.then(x => writeFileSync(`bee${suffixString}`, Buffer.from(x)))
37-
this.console.info('Bee downloaded successfully')
38+
this.console.log('Bee downloaded successfully')
3839

3940
if (process.platform !== 'win32') {
40-
this.console.info(`Running chmod +x bee`)
41+
this.console.info(`Running chmod +x bee to make it executable`)
4142
execSync('chmod +x bee')
4243
}
43-
this.console.log('Verify the version of the downloaded Bee binary by running:')
44-
this.console.log('')
45-
this.console.log('./bee version')
44+
45+
if (existsSync('config.yaml')) {
46+
this.console.log('config.yaml already exists, done')
47+
48+
return
49+
}
50+
51+
this.console.info('')
52+
this.console.info('Ultra-light: Limited download capabilities, no funding required.')
53+
this.console.info('Light: Full functionality; requires xDAI to launch and xBZZ for uploading and retrieving data.')
54+
55+
const type = await this.console.promptList(['ultra-light', 'light'], 'Select the type of configuration to create')
56+
writeFileSync(
57+
'config.yaml',
58+
`api-addr: 127.0.0.1:1633
59+
blockchain-rpc-endpoint: "https://xdai.fairdatasociety.org"
60+
cors-allowed-origins: ["*"]
61+
data-dir: "${process.cwd()}/data-dir"
62+
full-node: false
63+
mainnet: true
64+
resolver-options: ["https://cloudflare-eth.com"]
65+
storage-incentives-enable: false
66+
swap-enable: ${type === 'light' ? 'true' : 'false'}
67+
password: "${Strings.randomAlphanumeric(20)}"`,
68+
)
69+
70+
this.console.info('')
71+
this.console.log('All set! Start Bee node by running:')
72+
this.console.info('')
73+
this.console.log('./bee start --config=config.yaml')
4674
}
4775
}

0 commit comments

Comments
 (0)