import Config from "./Config" ; import CLI from "./CLI" ; import Watcher from "./Watcher" ; import Uploader from "./Uploader" ; import InitConfig from './InitConfig' ; const observatory = require ( "observatory" ) ; export default class Sync { config : Config ; watch : Watcher ; cli : CLI ; uploader : Uploader ; task : any ; constructor ( ) { this . cli = new CLI ( ) ; this . task = observatory . add ( "Initializing..." ) ; if ( this . cli . hasStartupCommand ( "init" ) ) { new InitConfig ( ) ; } else { this . config = new Config ( this . cli ) ; this . task . status ( "reading config" ) ; this . config . ready ( ) . then ( ( ) => { this . task . status ( "watching files" ) ; this . uploader = new Uploader ( this . config , this . cli ) ; this . watch = new Watcher ( this . uploader , this . config , this . cli ) ; return this . watch . ready ( ) ; } ) . then ( ( ) => { this . task . status ( "connecting server" ) ; return this . uploader . connect ( ) ; } ) . then ( ( ) => { this . task . done ( "Connected" ) . details ( this . config . host ) ; this . cli . workspace ( ) ; } ) ; } } }