-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.ts
More file actions
86 lines (75 loc) · 2.69 KB
/
cli.ts
File metadata and controls
86 lines (75 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import '@Typetron/Support'
import { program, Command } from 'commander'
import { NewProjectCommand } from './commands/NewProjectCommand'
import { boostrapApp } from './utils'
import * as packageJSON from './package.json'
import { Container } from '@Typetron/Container'
const typetron = program.description('Typetron CLI')
typetron.version(packageJSON.version, '-v')
// typetron
// .command('serve')
// .option('-p, --port [port]', 'The port to run the app at')
// .action(serveCommand)
typetron
.command('new <projectName>')
.action(async function(this: Command) {
const container = new Container()
const {NewProjectCommand} = await import('./commands/NewProjectCommand')
const command = container.get(NewProjectCommand)
await command.run(this.args)
})
typetron
.command('migrate')
.action(async () => {
console.log('Migrating...')
const app = await boostrapApp()
const {MigrateCommand} = await import('./commands/MigrateCommand')
const command = app.get(MigrateCommand)
await command.run()
})
typetron
.command('migrate:rollback')
.action(async () => {
console.log('Rolling back...')
const app = await boostrapApp()
const {RollbackCommand} = await import('./commands/RollbackCommand')
const command = app.get(RollbackCommand)
await command.run()
})
typetron
.command('migrate:reset')
.action(async () => {
console.log('Resetting database...')
const app = await boostrapApp()
const {ResetCommand} = await import('./commands/ResetCommand')
const command = app.get(ResetCommand)
await command.run()
})
typetron
.command('routes')
.action(async () => {
console.log('Reading routes...')
const app = await boostrapApp()
const {RoutesCommand} = await import('./commands/RoutesCommand')
const command = app.get(RoutesCommand)
await command.run()
})
typetron
.command(`generate <stub> <name>`)
.alias('g')
.action(async function(this: Command) {
const app = await boostrapApp()
const {GenerateCommand} = await import('./commands/generators/GenerateCommand')
const command = app.get(GenerateCommand)
await command.run(this.args)
})
typetron
.command('seed')
.action(async () => {
console.log('Seeding...')
const app = await boostrapApp()
const {SeedCommand} = await import('./commands/SeedCommand')
const command = app.get(SeedCommand)
await command.run()
})
typetron.parse(process.argv)