-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsequelize.ts
255 lines (249 loc) · 6.07 KB
/
sequelize.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
const commonOptions: Fig.Option[] = [
{
name: "--env",
description: "The environment to run the command in",
args: { name: "environment" },
},
{
name: "--config",
description: "The path to the config file",
args: { name: "file path", template: "filepaths" },
},
{
name: "--options-path",
description: "The path to a JSON file with additional options",
args: { name: "file path", template: "filepaths" },
},
{
name: "--migrations-path",
description: "The path to the migrations folder",
args: { name: "folder path", template: "folders" },
},
{
name: "--seeders-path",
description: "The path to the seeders folder",
args: { name: "folder path", template: "folders" },
},
{
name: "--models-path",
description: "The path to the models folder",
args: { name: "folder path", template: "folders" },
},
{
name: "--url",
description: "The database connection string to use",
args: { name: "connection string" },
},
{
name: "--debug",
description: "When available show various debug information",
},
{
name: "--help",
description: "Show help",
},
{
name: "--version",
description: "Show version number",
},
];
const databaseOptions: Fig.Option[] = [
{
name: "--charset",
description: "Pass charset option to dialect, MYSQL only",
args: { name: "charset options" },
},
{
name: "--collate",
description: "Pass collate option to dialect",
args: { name: "collate options" },
},
{
name: "--encoding",
description: "Pass encoding option to dialect, PostgreSQL only",
args: { name: "encoding options" },
},
{
name: "--ctype",
description: "Pass ctype option to dialect, PostgreSQL only",
args: { name: "ctype option" },
},
{
name: "--template",
description: "Pass template option to dialect, PostgreSQL only",
args: { name: "template option" },
},
];
const initOptions: Fig.Option[] = [
{
name: "--force",
description: "Will drop the existing config folder and re-create it",
isDangerous: true,
},
];
const migrateOptions: Fig.Option[] = [
{
name: "--to",
description: "Migration name to run migrations until",
args: { name: "migration name" },
},
{
name: "--from",
description: "Migration name to start migrations from (excluding)",
args: { name: "migration name" },
},
];
const seedOneOptions: Fig.Option[] = [
{
name: "--seed",
description: "List of seed files",
args: { name: "file path", template: "filepaths", isVariadic: true },
},
];
const subCommands: Fig.Subcommand[] = [
{
name: "db:migrate",
description: "Run pending migrations",
options: migrateOptions,
},
{
name: "db:migrate:schema:timestamps:add",
description: "Update migration table to have timestamps",
options: migrateOptions,
},
{
name: "db:migrate:status",
description: "List the status of all migrations",
options: migrateOptions,
},
{
name: "db:migrate:undo",
description: "Reverts a migration",
options: [
{
name: "--name",
description: "Name of the migration to undo",
args: { name: "migration name" },
},
],
},
{
name: "db:migrate:undo:all",
description: "Revert all migrations ran",
options: [
{
name: "--to",
description: "Revert to the provided migration",
args: { name: "migration name" },
},
],
},
{
name: "db:seed",
description: "Run specified seeder",
options: seedOneOptions,
},
{
name: "db:seed:undo",
description: "Deletes data from the database",
options: seedOneOptions,
},
{ name: "db:seed:all", description: "Run every seeder" },
{ name: "db:seed:undo:all", description: "Deletes data from the database" },
{
name: "db:create",
description: "Create database specified by configuration",
options: databaseOptions,
},
{
name: "db:drop",
description: "Drop database specified by configuration",
options: databaseOptions,
},
{ name: "init", description: "Initializes project", options: initOptions },
{
name: "init:config",
description: "Initializes configuration",
options: initOptions,
},
{
name: "init:migrations",
description: "Initializes migrations",
options: initOptions,
},
{
name: "init:models",
description: "Initializes models",
options: initOptions,
},
{
name: "init:seeders",
description: "Initializes seeders",
options: initOptions,
},
{
name: ["migration:generate", "migration:create"],
description: "Generates a new migration file",
options: [
{
name: "--name",
description: "Defines the name of the migration",
args: { name: "migration name" },
},
],
},
{
name: ["model:generate", "model:create"],
description: "Generates a model and its migration",
options: [
{
name: "--name",
description: "Defines the name of the new model",
args: { name: "model name" },
},
{
name: "--attributes",
description: "A list of attributes",
args: { name: "attributes string" },
},
{
name: "--force",
description: "Forcefully re-creates model with the same name",
},
{
name: "--underscored",
description: "Use snake case for the timestamp's attribute names",
},
],
},
{
name: ["seed:generate", "seed:create"],
description: "Generates a new seed file",
options: [
{
name: "--name",
description: "Defines the name of the seed",
args: { name: "seed name" },
},
],
},
];
const completionSpec: Fig.Spec = {
name: "sequelize",
description: "The Sequelize Command Line Interface",
subcommands: subCommands.map((sc) => ({
...sc,
options: [...(sc.options || []), ...commonOptions],
})),
options: [
{
name: "--help",
description: "Show help",
},
{
name: "--version",
description: "Show version number",
},
],
};
export default completionSpec;