Skip to content

Commit

Permalink
refactor(configurer): move mig creation to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed May 17, 2024
1 parent 6a3396c commit e3914fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
42 changes: 21 additions & 21 deletions configurer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ export default class QueueConfigurer extends BaseConfigurer {
public async configure() {
const task = this.logger.task()

const willUseDatabaseDriver = await this.prompt.confirm(
`Are you going to use the ${this.paint.yellow(
'"database"'
)} driver with a SQL database? Confirm it to create the ${this.paint.yellow(
'"jobs migration"'
)}.`
)

if (willUseDatabaseDriver) {
task.addPromise('Create jobs migration', async () => {
let [date, time] = new Date().toISOString().split('T')

date = date.replace(/-/g, '_')
time = time.split('.')[0].replace(/:/g, '')

return new File('./queue').copy(
Path.migrations(`${date}_${time}_create_jobs_table.${Path.ext()}`)
)
})
}

task.addPromise(`Create queue.${Path.ext()} config file`, () => {
return new File('./queue').copy(Path.config(`queue.${Path.ext()}`))
})
Expand Down Expand Up @@ -45,27 +66,6 @@ export default class QueueConfigurer extends BaseConfigurer {
.save()
})

const willUseDatabaseDriver = this.prompt.confirm(
`Are you going to use the ${this.paint.yellow(
'"database"'
)} driver with a SQL database? Confirm it to create the ${this.paint.yellow(
'"jobs migration"'
)}.`
)

if (willUseDatabaseDriver) {
task.addPromise('Create jobs migration', async () => {
let [date, time] = new Date().toISOString().split('T')

date = date.replace(/-/g, '_')
time = time.split('.')[0].replace(/:/g, '')

return new File('./queue').copy(
Path.migrations(`${date}_${time}_create_jobs_table.${Path.ext()}`)
)
})
}

await task.run()

console.log()
Expand Down
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "@athenna/queue",
"version": "4.1.0",
"version": "4.2.0",
"description": "The Athenna queue handler.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down

0 comments on commit e3914fb

Please sign in to comment.