-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathConsoleKernel.imba
More file actions
151 lines (120 loc) · 4.62 KB
/
Copy pathConsoleKernel.imba
File metadata and controls
151 lines (120 loc) · 4.62 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { existsSync } from 'fs-extra'
import { ConfigCacheCommand } from './Console/Commands/ConfigCacheCommand'
import { ConfigClearCommand } from './Console/Commands/ConfigClearCommand'
import { DbSeedCommand } from './Console/Commands/DbSeedCommand'
import { DownCommand } from './Console/Commands/DownCommand'
import { EnvironmentCommand } from './Console/Commands/EnvironmentCommand'
import { GenerateKeyCommand } from './Console/Commands/GenerateKeyCommand'
import { InspireCommand } from './Console/Commands/InspireCommand'
import { MakeCommandCommand } from './Console/Commands/MakeCommandCommand'
import { MakeConfigCommand } from './Console/Commands/MakeConfigCommand'
import { MakeControllerCommand } from './Console/Commands/MakeControllerCommand'
import { MakeCrudCommand } from './Console/Commands/MakeCrudCommand'
import { MakeFactoryCommand } from './Console/Commands/MakeFactoryCommand'
import { MakeExceptionCommand } from './Console/Commands/MakeExceptionCommand'
import { MakeMailCommand } from './Console/Commands/MakeMailCommand'
import { MakeMiddlewareCommand } from './Console/Commands/MakeMiddlewareCommand'
import { MakeMigrationCommand } from './Console/Commands/MakeMigrationCommand'
import { MakeRepositoryCommand } from './Console/Commands/MakeRepositoryCommand'
import { MakeRequestCommand } from './Console/Commands/MakeRequestCommand'
import { MakeResolverCommand } from './Console/Commands/MakeResolverCommand'
import { MakeSeederCommand } from './Console/Commands/MakeSeederCommand'
import { MakeTagCommand } from './Console/Commands/MakeTagCommand'
import { MakeViewCommand } from './Console/Commands/MakeViewCommand'
import { MigrateCommand } from './Console/Commands/MigrateCommand'
import { MigrateDownCommand } from './Console/Commands/MigrateDownCommand'
import { MigrateFreshCommand } from './Console/Commands/MigrateFreshCommand'
import { MigrateLatestCommand } from './Console/Commands/MigrateLatestCommand'
import { MigrateRollbackCommand } from './Console/Commands/MigrateRollbackCommand'
import { MigrateUpCommand } from './Console/Commands/MigrateUpCommand'
import { PackagePublishCommand } from './Console/Commands/PackagePublishCommand'
import { RouteListCommand } from './Console/Commands/RouteListCommand'
import { ServeCommand } from './Console/Commands/ServeCommand'
import { SessionPruneExpiredCommand } from './Console/Commands/SessionPruneExpiredCommand'
import { ShellCommand } from './Console/Commands/ShellCommand'
import { UpCommand } from './Console/Commands/UpCommand'
import { execSync } from 'child_process'
import { join } from 'path'
import Output from '@formidablejs/console/lib/Output'
import type { Application } from '@formidablejs/console'
export default class ConsoleKernel
get default
[
# db commands
DbSeedCommand
# env command
EnvironmentCommand
# key command
GenerateKeyCommand
# shell command
ShellCommand
# config commands
ConfigCacheCommand
ConfigClearCommand
# serve command
ServeCommand
# session command
SessionPruneExpiredCommand
# package commands
PackagePublishCommand
# make commands
MakeCommandCommand
MakeConfigCommand
MakeControllerCommand
MakeCrudCommand
MakeFactoryCommand
MakeExceptionCommand
MakeMailCommand
MakeMiddlewareCommand
MakeMigrationCommand
MakeRepositoryCommand
MakeRequestCommand
MakeResolverCommand
MakeSeederCommand
MakeTagCommand
MakeViewCommand
# maintenance commands
DownCommand
UpCommand
# migration commands
MigrateCommand
MigrateDownCommand
MigrateFreshCommand
MigrateLatestCommand
MigrateRollbackCommand
MigrateUpCommand
# route commands
RouteListCommand
# other
InspireCommand
]
get registered
[
]
def registerCommands app\Application, ctx
const commands = self.default.concat(self.registered)
let length = commands.length
while length--
const command = commands[length]
command.ctx = ctx
app.register(command)
self.loadEvents app\Application
def loadEvents app\Application
app.onDefaultCommand do(e)
process.exit!
const appPackage = join(process.cwd!, 'package.json')
if !existsSync(appPackage)
return
const hooks = require(appPackage).hooks || {}
for own event, commands of hooks
if !Array.isArray(commands)
commands = []
for command in commands
app.onEvent event, do
Output.write "\n <dim>> {command}</dim>\n"
execSync(command, {
cwd: process.cwd!,
stdio: 'inherit'
})
const repeat = process.stdout.columns <= 200 ? process.stdout.columns : (process.stdout.columns / 2)
Output.write "<dim> " + ('-'.repeat(repeat - ' '.length)) + "</dim>"