-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathblitz.ts
288 lines (284 loc) · 7.46 KB
/
blitz.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
import prismaSpec from "./prisma";
const prismaCommands = (prismaSpec as Fig.Subcommand).subcommands;
const commonOptions: Fig.Option[] = [
{
name: ["--help", "-h"],
description: "Show help for command",
priority: 1,
},
];
const icon =
"https://raw.githubusercontent.com/blitz-js/art/master/square-logo-600.png";
const completionSpec: Fig.Spec = {
name: "blitz",
description:
"Blitz.js CLI is your single access point for interacting with your app, from database management to code generation",
subcommands: [
{
name: ["build", "b"],
description: "Creates a production build",
icon,
options: commonOptions,
},
{
name: ["codegen", "cg"],
description: "Generates Routes Manifest",
icon,
options: commonOptions,
},
{
name: ["console", "c"],
description: "Run the Blitz console REPL",
icon,
options: commonOptions,
},
{
name: "db",
description: "Run database commands",
icon,
options: commonOptions,
args: {
name: "command",
description: "Run specific db command",
suggestions: [
{
name: "seed",
description:
"Generates seeded data in database via Prisma 2. You need db/seeds.ts or db/seeds/index.ts",
},
],
},
},
{
name: ["dev", "d"],
description: "Start a development server",
icon,
options: [
...commonOptions,
{
name: ["-p", "--port"],
description: "Set port number",
args: {
name: "port",
},
},
{
name: ["-H", "--hostname"],
description: "Set server hostname",
args: {
name: "hostname",
},
},
{
name: "--inspect",
description: "Enable the Node.js inspector",
},
{
name: "--no-incremental-build",
description: "Disable incremental build and start from a fresh cache",
},
],
},
{
name: ["export", "e"],
description: "Exports a static page",
icon,
options: [
...commonOptions,
{
name: ["-o", "--outdir"],
description: "Set the output dir (defaults to 'out')",
args: {
name: "outdir",
},
},
],
},
{
name: ["generate", "g"],
description: "Generate new files for your Blitz project",
isDangerous: true,
icon,
options: [
...commonOptions,
{
name: ["-c", "--context"],
description:
"Provide a context folder within which we'll place the generated files for better code organization. You can also supply this in the name of the model to be generated (e.g. `blitz generate query admin/projects`). Combining the `--context` flags and supplying context via the model name in the same command is not supported",
args: {
name: "context",
},
},
{
name: ["-p", "--parent"],
description:
"Specify a parent model to be used for generating nested routes for dependent data when generating pages, or to create hierarchical validation in queries and mutations. The code will be generated with the nested data model in mind. Most often this should be used in conjunction with 'blitz generate all'",
args: {
name: "parent",
},
},
{
name: ["-d", "--dry-run"],
description:
"Show what files will be created without writing them to disk",
},
],
args: [
{
name: "type",
description: "What files to generate",
suggestions: [
"all",
"crud",
"model",
"pages",
"queries",
"query",
"mutations",
"mutation",
"resource",
].map((suggestion) => ({
name: suggestion,
insertValue: `${suggestion} `,
priority: 100,
})),
},
{
name: "model",
description:
'The name of your model, like "user". Can be singular or plural - same result',
},
],
},
{
name: ["help", "h"],
description: "Display help for <%= config.bin %>",
options: [
{
name: "--all",
description: "See all commands in CLI",
},
],
args: {
name: "command",
description: "Command to show help for",
isOptional: true,
},
},
{
name: ["install", "i"],
description: "Install a Recipe into your Blitz app",
icon,
options: commonOptions,
args: [
{
name: "recipe",
description:
"Name of a Blitz recipe from @blitzjs/blitz/recipes, or a file path to a local recipe definition",
},
{
name: "recipe-flags",
description:
"A list of flags to pass to the recipe. Blitz will only parse these in the form key=value",
isOptional: true,
},
],
},
{
name: "new",
description: "Create a new Blitz project",
icon,
options: [
...commonOptions,
{
name: "--npm",
description: "Use npm as the package manager",
},
{
name: "--yarn",
description: "Use yarn as the package manager",
},
{
name: "--form",
description: "A form library",
args: {
name: "form",
suggestions: ["react-final-form", "react-hook-form", "formik"],
},
},
{
name: ["-d", "--dry-run"],
description:
"Show what files will be created without writing them to disk",
},
{
name: "--no-git",
description: "Skip git repository creation",
},
{
name: "--skip-upgrade",
description: "Skip blitz upgrade if outdated",
},
],
args: {
name: "name",
description: "Name of your new project",
},
},
{
name: ["prisma", "p"],
description: "Loads env variables then proxies all args to Prisma CLI",
subcommands: prismaCommands,
},
{
name: ["routes", "r"],
description: "Display all Blitz URL Routes",
icon,
options: commonOptions,
},
{
name: ["start", "s"],
description: "Start the production server",
icon,
options: [
...commonOptions,
{
name: ["-p", "--port"],
description: "Set port number",
args: {
name: "port",
},
},
{
name: ["-H", "--hostname"],
description: "Set server hostname",
args: {
name: "hostname",
},
},
{
name: "--inspect",
description: "Enable the Node.js inspector",
},
],
},
{
name: "autocomplete",
description: "Display autocomplete installation instructions",
icon,
options: [
{
name: ["-r", "--refresh-cache"],
description: "Refresh cache (ignores displaying instructions)",
},
],
args: {
name: "shell",
description: "Shell type",
suggestions: ["zsh", "bash"],
isOptional: true,
},
},
],
};
export default completionSpec;