| 147 | } |
| 148 | |
| 149 | print(): void { |
| 150 | logger.info('Printing scan report...') |
| 151 | // flip the table to put total at the bottom |
| 152 | const tableToPrint = [ |
| 153 | ...this.internalTable.data.slice(1), |
| 154 | this.internalTable.data[0], |
| 155 | ] |
| 156 | this.table.push( |
| 157 | ...tableToPrint.map(val => { |
| 158 | const key = Object.keys(val)[0] |
| 159 | const [, status] = val[key] |
| 160 | /** |
| 161 | * Color the service key based upon the status in the table. |
| 162 | * We must do this at the end because coloring the text alters the text and we use the text |
| 163 | * to find the correct object when adding to the table |
| 164 | */ |
| 165 | let coloredKey = chalk.green(key) |
| 166 | if (status?.includes('connections')) { |
| 167 | coloredKey = chalk.yellow(key) |
| 168 | } |
| 169 | if (status?.includes('data')) { |
| 170 | coloredKey = chalk.red(key) |
| 171 | } |
| 172 | return { [coloredKey]: val[key] } |
| 173 | }) |
| 174 | ) |
| 175 | console.log(this.table.toString()) |
| 176 | if (this.internalTable.status !== statusLevel.pass) { |
| 177 | logger[this.internalTable.status === statusLevel.fail ? 'error' : 'warn']( |
| 178 | `While CG ran successfully, there were some ${ |
| 179 | this.internalTable.status === statusLevel.fail ? 'major' : 'minor' |
| 180 | } issues formatting and inserting your data into dGraph.` |
| 181 | ) |
| 182 | logger.info( |
| 183 | 'For a complete list of these errors and what they mean for you, please see https://github.com/cloudgraphdev/cli#common-errors' |
| 184 | ) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | private isInTable(service: string): boolean { |
| 189 | return !!this.internalTable.data.find(val => { |