-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathnetlify.ts
917 lines (872 loc) · 19.9 KB
/
netlify.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
const debugProxyOptions: Fig.Option[] = [
{
name: "--debug",
description: "Print debugging information",
},
{
name: "--httpProxy",
description: "Proxy server address to route requests through",
args: {
name: "httpProxy",
},
},
{
name: "--httpProxyCertificateFilename",
description: "Certificate file to use when connecting using a proxy server",
args: {
name: "httpProxyCertificateFilename",
},
},
];
const addonAuth: Fig.Subcommand = {
name: ["addons:auth", "addon:auth"],
description: "Login to add-on provider",
args: {
name: "name",
description: "Add-on slug",
},
options: [...debugProxyOptions],
};
const addonConfig: Fig.Subcommand = {
name: ["addons:config", "addon:config"],
description: "Configure add-on settings",
args: {
name: "name",
description: "Add-on namespace",
},
options: [...debugProxyOptions],
};
const addonCreate: Fig.Subcommand = {
name: ["addons:create", "addon:create"],
description: "Add an add-on extension to your site",
args: {
name: "name",
description: "Add-on namespace",
},
options: [...debugProxyOptions],
};
const addonDelete: Fig.Subcommand = {
name: ["addons:delete", "addon:delete"],
description: "Remove an add-on extension to your site",
args: {
name: "name",
description: "Add-on namespace",
},
options: [
{
name: ["-f", "--force"],
description: "Delete without prompting (useful for CI)",
isDangerous: true,
},
...debugProxyOptions,
],
};
const addonList: Fig.Subcommand = {
name: ["addons:list", "addon:list"],
description: "List currently installed add-ons for site",
options: [
{
name: "--json",
description: "Output return values as JSON",
},
...debugProxyOptions,
],
};
const api: Fig.Subcommand = {
name: "api",
description: "Run any Netlify API method",
args: {
name: "apiMethod",
description: "Open API method to run",
},
options: [
{
name: ["-d", "--data"],
description: "Data to use",
args: {
name: "data",
},
},
{
name: "--list",
description: "List out available API methods",
},
...debugProxyOptions,
],
};
const build: Fig.Subcommand = {
name: "build",
description: "(Beta) Build on your local machine",
options: [
{
name: ["-o", "--offline"],
description: "Disables any features that require network access",
},
{
name: "--context",
description: "Build context",
args: {
name: "context",
},
},
{
name: "--dry",
description: "Dry run: show instructions without running them",
},
...debugProxyOptions,
],
};
const completion: Fig.Subcommand = {
name: "completion",
description: "(Beta) Generate shell completion script",
options: [
{
name: ["-s", "--shell"],
description: "Name of shell (bash|fish|zsh)",
isRequired: true,
args: {
name: "shell",
suggestions: ["bash", "fish", "zsh"],
},
},
],
};
const completionGenerate: Fig.Subcommand = {
name: "completion:generate",
description: "Generates completion script",
options: [
{
name: ["-s", "--shell"],
description: "(required) Name of shell [bash|fish|zsh]",
isRequired: true,
},
],
};
const completionGenerateAlias: Fig.Subcommand = {
name: "completion:generate:alias",
description: "Generates completion script for alias",
options: [
{
name: ["-s", "--shell"],
description: "(required) Name of shell [bash|fish|zsh]",
isRequired: true,
},
],
};
const deploy: Fig.Subcommand = {
name: "deploy",
description: "Create a new deploy from the contents of a folder",
options: [
{
name: ["-a", "--auth"],
description: "Netlify auth token to deploy with",
args: {
name: "auth",
},
},
{
name: ["-b", "--branch"],
description:
"Serves the same functionality as --alias. Deprecated and will be removed in future versions",
args: {
name: "branch",
},
},
{
name: ["-d", "--dir"],
description: "Specify a folder to deploy",
args: {
name: "dir",
template: "folders",
},
},
{
name: ["-f", "--functions"],
description: "Specify a functions folder to deploy",
args: {
name: "functions",
template: "folders",
},
},
{
name: ["-m", "--message"],
description: "A short message to include in the deploy log",
args: {
name: "message",
},
},
{
name: ["-o", "--open"],
description: "Open site after deploy",
},
{
name: ["-p", "--prod"],
description: "Deploy to production",
},
{
name: ["-s", "--site"],
description: "A site ID to deploy to",
args: {
name: "site",
},
},
{
name: "--alias",
description:
"Specifies the alias for deployment, the string at the beginning of the deploy subdomain",
args: {
name: "alias",
},
},
{
name: "--build",
description: "Run build command before deploying",
},
...debugProxyOptions,
{
name: "--json",
description: "Output deployment data as JSON",
},
{
name: "--prodIfUnlocked",
description: "Deploy to production if unlocked, create a draft otherwise",
},
{
name: "--skip-functions-cache",
description:
"Ignore any functions created as part of a previous `build` or `deploy` commands, forcing them to be bundled again as part of the deployment",
},
{
name: "--timeout",
description: "Timeout to wait for deployment to finish",
args: {
name: "timeout",
},
},
{
name: "trigger",
description:
"Trigger a new build of your site on Netlify without uploading local files",
},
],
};
const dev: Fig.Subcommand = {
name: "dev",
description: "Local dev server",
options: [
{
name: ["-c", "--command"],
description: "Command to run",
args: {
name: "command",
isCommand: true,
},
},
{
name: ["-d", "--dir"],
description: "Dir with static files",
args: {
name: "dir",
template: "filepaths",
},
},
{
name: ["-f", "--functions"],
description: "Specify a functions folder to serve",
args: {
name: "functions",
template: "folders",
},
},
{
name: ["-l", "--live"],
description: "Start a public live session",
},
{
name: ["-o", "--offline"],
description: "Disables any features that require network access",
},
{
name: ["-p", "--port"],
description: "Port of netlify dev",
args: {
name: "port",
},
},
...debugProxyOptions,
{
name: "--framework",
description:
"Framework to use. Defaults to #auto which automatically detects a framework",
args: {
name: "framework",
},
},
{
name: "--targetPort",
description: "Port of target app server",
args: {
name: "targetPort",
},
},
],
};
const devExec: Fig.Subcommand = {
name: "dev:exec",
description: "Exec command",
options: [...debugProxyOptions],
};
const devTrace: Fig.Subcommand = {
name: "dev:trace",
description: "Trace command",
args: {
name: "url",
description: "Sets the request URL",
},
options: [
{
name: ["-H", "--header"],
description:
'Request header, this flag can be used multiple times. Example: "Host: netlify.test"',
args: {
name: "header",
},
},
{
name: ["-X", "--request"],
description: "Specifies a custom request method [default: GET]",
args: {
name: "request",
},
},
{
name: ["-B", "--cookie"],
description:
'Request cookie, this flag can be used multiple times. Example: "nf_jwt=token"',
args: {
name: "cookie",
},
},
{
name: ["-w", "--watch"],
description: "Path to the publish directory",
args: {
name: "watch",
template: "filepaths",
},
},
{
name: "--debug",
description: "Print debugging information",
},
],
};
const env: Fig.Subcommand = {
name: "env",
description: "(Beta) Control environment variables for the current site",
options: [...debugProxyOptions],
};
const envGet: Fig.Subcommand = {
name: "env:get",
description:
"Get resolved value of specified environment variable (includes netlify.toml)",
options: [...debugProxyOptions],
};
const envImport: Fig.Subcommand = {
name: "env:import",
description: "Import and set environment variables from .env file",
args: {
name: "filename",
description: ".env file to import",
template: "filepaths",
},
options: [
{
name: ["-r", "--replaceExisting"],
description:
"Replace all existing variables instead of merging them with the current ones",
},
...debugProxyOptions,
],
};
const envList: Fig.Subcommand = {
name: "env:list",
description:
"Lists resolved environment variables for site (includes netlify.toml)",
options: [...debugProxyOptions],
};
const envSet: Fig.Subcommand = {
name: "env:set",
description: "Set value of environment variable",
args: [
{
name: "name",
description: "Environment variable name",
},
{
name: "value",
description: "Value to set to",
},
],
options: [...debugProxyOptions],
};
const envUnset: Fig.Subcommand = {
name: ["env:unset", "env:delete", "env:remove"],
description: "Unset an environment variable which removes it from the UI",
args: {
name: "name",
description: "Environment variable name",
},
options: [...debugProxyOptions],
};
const functionsBuild: Fig.Subcommand = {
name: ["functions:build", "function:build"],
description: "Build functions locally",
options: [
{
name: ["-f", "--functions"],
description: "Specify a functions directory to build to",
args: {
name: "functions",
template: "folders",
},
},
{
name: ["-s", "--src"],
description: "Specify the source directory for the functions",
args: {
name: "src",
},
},
...debugProxyOptions,
],
};
const functionsCreate: Fig.Subcommand = {
name: ["functions:create", "function:create"],
description: "Create a new function locally",
args: {
name: "name",
description:
"Name of your new function file inside your functions directory",
},
options: [
{
name: ["-n", "--name"],
description: "Function name",
args: {
name: "name",
},
},
{
name: ["-u", "--url"],
description: "Pull template from URL",
args: {
name: "url",
},
},
...debugProxyOptions,
],
};
const functionsInvoke: Fig.Subcommand = {
name: ["functions:invoke", "function:trigger"],
description:
"Trigger a function while in netlify dev with simulated data, good for testing function calls including Netlify's Event Triggered Functions",
args: {
name: "name",
description: "Function name to invoke",
},
options: [
{
name: ["-f", "--functions"],
description:
"Specify a functions folder to parse, overriding netlify.toml",
args: {
name: "functions",
template: "folders",
},
},
{
name: ["-n", "--name"],
description: "Function name to invoke",
args: {
name: "name",
},
},
{
name: ["-p", "--payload"],
description:
"Supply POST payload in stringified json, or a path to a json file",
args: {
name: "payload",
template: "filepaths",
},
},
{
name: ["-q", "--querystring"],
description: "Querystring to add to your function invocation",
args: {
name: "querystring",
},
},
...debugProxyOptions,
{
name: "--identity",
description: "Simulate Netlify Identity authentication JWT",
exclusiveOn: ["--no-identity"],
},
{
name: "--no-identity",
description: "Affirm unauthenticated request",
exclusiveOn: ["--identity"],
},
{
name: "port",
description: "Port where netlify dev is accessible. e.g. 8888",
args: {
name: "port",
},
},
],
};
const functionsList: Fig.Subcommand = {
name: ["functions:list", "function:list"],
description: "List functions that exist locally",
options: [
{
name: ["-f", "--functions"],
description: "Specify a functions directory to list",
args: {
name: "functions",
template: "folders",
},
},
{
name: ["-n", "--name"],
description: "Name to print",
args: {
name: "name",
},
},
...debugProxyOptions,
{
name: "--json",
description: "Output function data as JSON",
},
],
};
const functionsServe: Fig.Subcommand = {
name: ["functions:serve", "function:server"],
description: "(Beta) Serve functions locally",
options: [
{
name: ["-f", "--functions"],
description: "Specify a functions folder to deploy",
args: {
name: "functions",
template: "folders",
},
},
{
name: ["-o", "--offline"],
description: "Disables any features that require network access",
},
{
name: ["-p", "--port"],
description: "Port of netlify dev",
args: {
name: "port",
},
},
...debugProxyOptions,
],
};
const init: Fig.Subcommand = {
name: "init",
description:
"Configure continuous deployment for a new or existing site. To create a new site without continuous deployment, use `netlify sites:create`",
options: [
{
name: ["-m", "--manual"],
description: "Manually configure a git remote for CI",
},
{
name: "--force",
description:
"Reinitialize CI hooks if the linked site is already configured to use CI",
},
{
name: "--gitRemoteName",
description: 'Name of Git remote to use. e.g. "origin"',
args: {
name: "gitRemoteName",
},
},
...debugProxyOptions,
],
};
const link: Fig.Subcommand = {
name: "link",
description:
"Link a local repo or project folder to an existing site on Netlify",
options: [
{
name: "--gitRemoteName",
description: 'Name of Git remote to use. e.g. "origin"',
args: {
name: "gitRemoteName",
},
},
{
name: "--id",
description: "ID of site to link to",
args: {
name: "id",
},
},
{
name: "--name",
description: "Name of site to link to",
args: {
name: "name",
},
},
...debugProxyOptions,
],
};
const lm: Fig.Subcommand = {
name: "lm",
description: "Handle Netlify Large Media operations",
options: [...debugProxyOptions],
};
const lmInfo: Fig.Subcommand = {
name: "lm:info",
description: "Show large media requirements information",
options: [...debugProxyOptions],
};
const lmInstall: Fig.Subcommand = {
name: ["lm:install", "lm:init"],
description: "Configures your computer to use Netlify Large Media",
options: [
{
name: ["-f", "--force"],
description: "Force the credentials helper installation",
},
],
};
const lmSetup: Fig.Subcommand = {
name: "lm:setup",
description: "Configures your site to use Netlify Large Media",
options: [
{
name: ["-f", "--force-install"],
description: "Force the credentials helper installation",
},
{
name: ["-s", "--skip-install"],
description: "Skip the credentials helper installation check",
},
...debugProxyOptions,
],
};
const login: Fig.Subcommand = {
name: "login",
description: "Login to your Netlify account",
options: [
{
name: "--auth",
description: "Netlify auth token",
args: {
name: "auth",
},
},
...debugProxyOptions,
{
name: "--json",
description: "Output return values as JSON",
},
{
name: "--new",
description: "Login to new Netlify account",
},
{
name: "--silent",
description: "Silence CLI output",
},
],
};
const open: Fig.Subcommand = {
name: "open",
description: "Open settings for the site linked to the current folder",
options: [
{
name: "--admin",
description: "Open Netlify site",
},
{
name: "--site",
description: "Open site",
},
...debugProxyOptions,
],
};
const openAdmin: Fig.Subcommand = {
name: "open:admin",
description: "Opens current site admin UI in Netlify",
options: [...debugProxyOptions],
};
const openSite: Fig.Subcommand = {
name: "open:site",
description: "Opens current site url in browser",
options: [...debugProxyOptions],
};
const sitesCreate: Fig.Subcommand = {
name: "sites:create",
description: "Create an empty site (advanced)",
options: [
{
name: ["-a", "--account-slug"],
description: "Account slug to create the site under",
},
{
name: ["-c", "--with-ci"],
description: "Initialize CI hooks during site creation",
},
{
name: ["-m", "--manual"],
description: "Force manual CI setup. Used --with-ci flag",
dependsOn: ["-c", "--with-ci"],
},
{
name: ["-n", "--name"],
description: "Name of site",
},
...debugProxyOptions,
],
};
const sitesDelete: Fig.Subcommand = {
name: "sites:delete",
description: "Delete a site",
args: {
name: "siteId",
description: "Site ID to delete",
},
options: [
{
name: ["-f", "--force"],
description: "Delete without prompting (useful for CI)",
isDangerous: true,
},
...debugProxyOptions,
],
};
const sitesList: Fig.Subcommand = {
name: "sites:list",
description: "List all sites you have access to",
options: [
{
name: "--json",
description: "Output site data as JSON",
},
...debugProxyOptions,
],
};
const status: Fig.Subcommand = {
name: "status",
description: "Print status information",
options: [
{
name: "verbose",
description: "Output system info",
},
...debugProxyOptions,
],
};
const statusHooks: Fig.Subcommand = {
name: "status:hooks",
description: "Print hook information of the linked site",
options: [...debugProxyOptions],
};
const unlink: Fig.Subcommand = {
name: "unlink",
description: "Unlink a local folder from a Netlify site",
options: [...debugProxyOptions],
};
const watch: Fig.Subcommand = {
name: "watch",
description: "Watch for site deploy to finish",
options: [...debugProxyOptions],
};
const subcommands: Fig.Subcommand[] = [
addonAuth,
addonConfig,
addonCreate,
addonDelete,
addonList,
api,
build,
completion,
completionGenerate,
completionGenerateAlias,
deploy,
dev,
devExec,
devTrace,
env,
envGet,
envImport,
envList,
envSet,
envUnset,
functionsBuild,
functionsCreate,
functionsInvoke,
functionsList,
functionsServe,
init,
link,
lm,
lmInfo,
lmInstall,
lmSetup,
login,
open,
openAdmin,
openSite,
sitesCreate,
sitesDelete,
sitesList,
status,
statusHooks,
unlink,
watch,
];
const completionSpec: Fig.Spec = {
name: "netlify",
description: "Netlify command line tool",
subcommands: [
...subcommands,
{
name: "help",
description: "List available sub-commands",
args: {
name: "subcommand",
description: "The command to display help for",
isOptional: true,
suggestions: subcommands,
},
},
],
options: [
{
name: "--telemetry-disable",
description: "Opt out of sharing usage data",
exclusiveOn: ["--telemetry-enable"],
},
{
name: "--telemetry-enable",
description: "Allow your usage to help shape development",
exclusiveOn: ["--telemetry-disable"],
},
],
};
export default completionSpec;