|
| 1 | +import { Strings } from 'cafe-utility' |
1 | 2 | import { execSync } from 'child_process' |
2 | | -import { writeFileSync } from 'fs' |
| 3 | +import { existsSync, writeFileSync } from 'fs' |
3 | 4 | import { LeafCommand } from 'furious-commander' |
4 | 5 | import fetch from 'node-fetch' |
5 | 6 | import { RootCommand } from '../root-command' |
@@ -34,14 +35,41 @@ export class GetBee extends RootCommand implements LeafCommand { |
34 | 35 | await fetch(url) |
35 | 36 | .then(x => x.arrayBuffer()) |
36 | 37 | .then(x => writeFileSync(`bee${suffixString}`, Buffer.from(x))) |
37 | | - this.console.info('Bee downloaded successfully') |
| 38 | + this.console.log('Bee downloaded successfully') |
38 | 39 |
|
39 | 40 | if (process.platform !== 'win32') { |
40 | | - this.console.info(`Running chmod +x bee`) |
| 41 | + this.console.info(`Running chmod +x bee to make it executable`) |
41 | 42 | execSync('chmod +x bee') |
42 | 43 | } |
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') |
46 | 74 | } |
47 | 75 | } |
0 commit comments