deploy():Q.IPromise<IDeployResult> { let start = new Date().getTime(), config = this.serviceContainer.config, packageData:any = JSON.parse('' + fs.readFileSync(__dirname + '/../../package.json')); this.log.logAndKeepColors( color.yellow( "\n\n+----------------------------------------------------+" + "\n| ") + color.xterm(200).bold('Mouflon - your deployment manager') + ' ' + (' v' + packageData.version).substr(-10, 10) + color.yellow(" |" + "\n+----------------------------------------------------+") + "\n\n"); this.log.startSection(`Deploying "${config.projectName}" to "${config.stageName}"...`); this.log.debug('Timestamp is ' + color.whiteBright.bold(this.timestamp)); if (config.verbose) { this.log.debug('Verbose mode is enabled'); } this.log.debug('Working pathConfig: ' + config.pathConfig.getReadable()); return this.deployManager.deploy().then(() => { let end = new Date().getTime(); let result: IDeployResult = { project: config.projectName, stage: config.stageName, projectConfig: config.projectConfig, globalConfig: config.globalConfig, start: start, end: end, }; return result; }); }
static exitWithError(errorMessage: string) { console.log( color.yellow( "\n+----------------------------------------------+" + "\n| ") + color.xterm(200).bold('An error occurred - Can\'t continue') + color.yellow(" |" + "\n+----------------------------------------------+") + "\n" + "\nError:\n" + color.red.bold(errorMessage) + "\n"); process.exit(1); }
deploy() { var start = (new Date()).getTime(), deployPromise: Q.IPromise<boolean>, config = this.serviceContainer.config, packageData: any = JSON.parse('' + fs.readFileSync(__dirname + '/../../package.json')); this.serviceContainer.log.logAndKeepColors( color.yellow( "\n\n+----------------------------------------------------+" + "\n| ") + color.xterm(200).bold('Mouflon - your deployment manager') + ' ' + (' v' + packageData.version).substr(-10, 10) + color.yellow(" |" + "\n+----------------------------------------------------+") + "\n\n"); this.serviceContainer.log.startSection(sprintf('Deploying "%s" to "%s"...', config.projectName, config.stageName)); this.serviceContainer.log.debug('Timestamp is ' + color.whiteBright.bold(this.timestamp)); if (this.serviceContainer.config.verbose) { this.serviceContainer.log.debug('Verbose mode is enabled'); } this.serviceContainer.log.debug('Working paths: ' + this.serviceContainer.config.paths.getReadable()); deployPromise = this.deployManager.deploy(); deployPromise.then( () => { var end = (new Date()).getTime(); this.serviceContainer.log.closeSection(sprintf( 'It took %ss to deploy "%s" to "%s". :)' + "\n\n", (0.001 * (end - start)).toFixed(3), config.projectName, config.stageName )); }, (error) => { Utils.exitWithError(error); } ); }