-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathtypeorm.ts
290 lines (288 loc) · 7.93 KB
/
typeorm.ts
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
const cliOptions: Record<string, Fig.Option> = {
help: { name: "--help", description: "Show help for command" },
version: { name: ["-v", "--version"], description: "Show the version" },
connection: {
name: ["-c", "--connection"],
args: { name: "connection" },
description: "Name of the connection on which to run a query",
},
config: {
name: ["-f", "--config"],
description: "Name of the file with connection configuration",
args: { name: "file", template: "filepaths" },
},
};
const completionSpec: Fig.Spec = {
name: "typeorm",
description: "TypeORM CLI",
subcommands: [
{
name: "schema:sync",
description: "Synchronizes your entities with database schema",
options: [
cliOptions.help,
{
...cliOptions.connection,
description:
"Name of the connection on which schema synchronization needs to to run",
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "schema:log",
description: "Shows sql to be executed by schema:sync command",
options: [
cliOptions.help,
{
...cliOptions.connection,
description:
"Name of the connection of which schema sync log should be shown",
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "schema:drop",
description:
"Drops all tables in the database on your default connection",
options: [
cliOptions.help,
{
...cliOptions.connection,
description: "Name of the connection on which to drop all tables",
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "query",
description: "Executes given SQL query on a default connection",
args: { name: "query", description: "The SQL Query to run" },
options: [
cliOptions.help,
cliOptions.connection,
cliOptions.config,
cliOptions.version,
],
},
{
name: "entity:create",
description: "Generates a new entity",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-n", "--name"],
description: "Name of the entity class",
args: { name: "entity" },
isRequired: true,
},
{
name: ["-d", "--dir"],
description: "Directory where entity should be created",
args: { name: "directory", template: "folders" },
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "subscriber:create",
description: "Generates a new subscriber",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-n", "--name"],
description: "Name of the subscriber class",
args: { name: "subscriber" },
isRequired: true,
},
{
name: ["-d", "--dir"],
description: "Directory where subscriber should be created",
args: { name: "directory", template: "folders" },
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "migration:create",
description: "Creates a new migration file",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-n", "--name"],
description: "Name of the migration class",
args: { name: "migration" },
isRequired: true,
},
{
name: ["-d", "--dir"],
description: "Directory where migration should be created",
args: { name: "directory", template: "folders" },
},
cliOptions.config,
{
name: ["-o", "--outputJs"],
description:
"Generate a migration file on Javascript instead of Typescript",
},
cliOptions.version,
],
},
{
name: "migration:generate",
description:
"Generates a new migration file with sql needs to be executed to update schema",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-n", "--name"],
description: "Name of the migration class",
args: { name: "migration" },
isRequired: true,
},
{
name: ["-d", "--dir"],
description: "Directory where migration should be created",
args: { name: "directory", template: "folders" },
},
{
name: ["-p", "--pretty"],
description: "Pretty-print generated SQL",
},
cliOptions.config,
{
name: ["-o", "--outputJs"],
description:
"Generate a migration file on Javascript instead of Typescript",
},
{
name: ["--dr", "--dryrun"],
description:
"Prints out the contents of the migration instead of writing it to a file",
},
{
name: ["--ch", "--check"],
description:
"Verifies that the current database is up to date and that no migrations are needed",
},
cliOptions.version,
],
},
{
name: "migration:run",
description: "Runs all pending migrations",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-t", "--transaction"],
description:
"Indicates if transaction should be used or not for migration run",
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "migration:show",
description: "Show all migrations and whether they have been run or not",
options: [
cliOptions.help,
cliOptions.connection,
cliOptions.config,
cliOptions.version,
],
},
{
name: "migration:revert",
description: "Reverts last executed migration",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-t", "--transaction"],
description:
"Indicates if transaction should be used or not for migration revert",
},
cliOptions.config,
cliOptions.version,
],
},
{
name: "version",
description: "Prints TypeORM version this project uses",
options: [cliOptions.help, cliOptions.version],
},
{
name: "cache:clear",
description: "Clears all data stored in query runner cache",
options: [
cliOptions.help,
cliOptions.connection,
cliOptions.config,
cliOptions.version,
],
},
{
name: "init",
description: "Generates initial TypeORM project structure",
options: [
cliOptions.help,
cliOptions.connection,
{
name: ["-n", "--name"],
description: "Name of the project directory",
args: { name: "name" },
},
{
name: ["--db", "--database"],
description: "Database type you'll use in your project",
args: {
name: "database",
suggestions: [
"mysql",
"mariadb",
"postgres",
"cockroachdb",
"sqlite",
"mssql",
"oracle",
"cordova",
"nativescript",
"react-native",
"expo",
"mongodb",
],
},
},
{
name: "--express",
description: "Indicates if express should be included in the project",
},
{
name: "--docker",
description:
"Set to true if docker-compose must be generated as well",
},
{
name: ["--pm", "--manager"],
description: "Install packages",
args: { name: "manager", suggestions: ["npm", "yarn"] },
},
cliOptions.version,
],
},
],
options: [cliOptions.help, cliOptions.version],
};
export default completionSpec;