()
| 9 | } |
| 10 | |
| 11 | async function main() { |
| 12 | await loadEnv() |
| 13 | checkEnvs() |
| 14 | await declareLocalType() |
| 15 | |
| 16 | if (!(await testDbConnect())) { |
| 17 | echo(chalk.red('❌ 数据库连接失败,请检查')) |
| 18 | process.exit(1) |
| 19 | } |
| 20 | |
| 21 | const { default: UserController } = await import('@/controllers/User.controller') |
| 22 | const users = await UserController.findAll() |
| 23 | |
| 24 | if (users.length === 0) { |
| 25 | echo(chalk.yellow('当前数据库中暂无用户')) |
| 26 | await exitWithDbClose() |
| 27 | } |
| 28 | |
| 29 | console.table( |
| 30 | users.map((user,) => ({ |
| 31 | Email: user.email, |
| 32 | Role: user.role || 'user', |
| 33 | CreatedAt: formatDate(user.createdAt), |
| 34 | })) |
| 35 | ) |
| 36 | |
| 37 | await exitWithDbClose() |
| 38 | } |
| 39 | |
| 40 | main().catch(async (error) => { |
| 41 | echo(chalk.red('❌ 获取用户列表失败')) |
no test coverage detected