Skip to content

Commit

Permalink
refactor: remove columnify in favor of cli-table3
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 1, 2020
1 parent ef8f439 commit dceebb6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 78 deletions.
40 changes: 13 additions & 27 deletions commands/Status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import columnify from 'columnify'
import CliTable from 'cli-table3'
import { inject } from '@adonisjs/fold'
import { flags, Kernel } from '@adonisjs/ace'
import { DatabaseContract } from '@ioc:Adonis/Lucid/Database'
Expand Down Expand Up @@ -80,36 +80,22 @@ export default class Status extends MigrationsBase {
await migrator.close()

this.printPreviewMessage()

/**
* List to be printed on the console
*/
const uiList = list.map((node) => {
return {
name: node.name,
status: this.colorizeStatus(node.status),
batch: node.batch || 'NA',
message: node.status === 'corrupt' ? 'The migration file is missing on filesystem' : '',
}
const table = new CliTable({
head: ['Name', 'Status', 'Batch', 'Message'],
})

/**
* Columnify options
* Push a new row to the table
*/
const columnifyOptions = {
config: {
batch: {
minWidth: 8,
},
name: {
minWidth: 60,
},
status: {
minWidth: 14,
},
},
}
list.forEach((node) => {
table.push([
node.name,
this.colorizeStatus(node.status),
node.batch || 'NA',
node.status === 'corrupt' ? 'The migration file is missing on filesystem' : '',
] as any)
})

console.log(columnify(uiList, columnifyOptions))
console.log(table.toString())
}
}
70 changes: 20 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@poppinss/hooks": "^1.0.3",
"@poppinss/utils": "^2.1.2",
"camelcase": "^5.3.1",
"columnify": "^1.5.4",
"cli-table3": "^0.5.1",
"knex": "^0.20.10",
"knex-dynamic-connection": "^1.0.4",
"log-update": "^4.0.0",
Expand Down

0 comments on commit dceebb6

Please sign in to comment.