import { Command , flags } from '@oclif/command' ; import cli from 'cli-ux' ; import { config } from '../config/config' ; import { writeFileAsync } from '../utils/index' ; export default class Init extends Command { static description = 'This command initializes an autodot repo by creating the autodot.json file' ; static examples = [ `$ autodot init
		TODO: add example here
		` ] ; static flags = { help : flags . help ( { char : 'h' } ) , yes : flags . boolean ( { char : 'y' } ) } ; async run ( ) { try { const result = await this . makeConfigFile ( ) ; this . log ( result ) ; } catch ( e ) { this . error ( `${ e }` ) ; } } async makeConfigFile ( ) { let bootstrap ; let sync ; let repository ; let autodot ; try { bootstrap = await cli . prompt ( 'Bootstrap Command' ) ; sync = await cli . prompt ( 'Sync Command' ) ; repository = await cli . prompt ( 'GitHub Repository' ) ; autodot = { commands : { bootstrap , sync } , repository } ; await writeFileAsync ( `${ config . autodotPath }/autodot.json` , JSON . stringify ( autodot , null , 2 ) ) ; return 'Successfully created autodot.json' ; } catch ( e ) { throw e ; } } }