-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathhugo.ts
1019 lines (1010 loc) · 26.3 KB
/
hugo.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
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const help = (name: string): Fig.Option => ({
name: ["-h", "--help"],
description: `help for ${name}`,
});
const globalOptions: Fig.Option[] = [
{
name: "--config",
description: "Config file (default is path/config.yaml|json|toml)",
priority: 50,
args: {
name: "file",
description: "Default is path/config.yaml|json|toml",
template: "filepaths",
},
},
{
name: "--configDir",
description: "Config dir (default 'config')",
priority: 50,
args: {
name: "directory path",
description: "Default is 'config'",
template: "folders",
},
},
{
name: "--debug",
description: "Debug output (default false)",
priority: 50,
args: {
name: "boolean",
},
},
{
name: ["-e", "--environment"],
description: "Build environment",
priority: 50,
args: {
name: "environment",
},
},
{
name: "--ignoreVendor",
description: "Ignores any _vendor directory (default false)",
priority: 50,
args: {
name: "boolean",
},
},
{
name: "--ignoreVendorPaths",
description:
"Ignores any _vendor for module paths matching the given Glob pattern",
priority: 50,
args: {
name: "glob pattern",
},
},
{
name: "--log",
description: "Enable Logging (default false)",
priority: 50,
args: {
name: "boolean",
},
},
{
name: "--logFile",
description: "Log File path (if set, logging enabled automatically)",
priority: 50,
args: {
name: "file",
template: "filepaths",
},
},
{
name: "--quiet",
description: "Build in quiet mode (default false)",
priority: 50,
args: {
name: "boolean",
},
},
{
name: ["-s", "--source"],
description: "Filesystem path to read files relative from",
priority: 50,
args: {
name: "file",
template: "filepaths",
},
},
{
name: "--themesDir",
description: "Filesystem path to themes directory",
priority: 50,
args: {
name: "file",
description: "Default is path/config.yaml|json|toml",
template: "filepaths",
},
},
{
name: ["-v", "--verbose"],
description: "Verbose output (default false)",
priority: 50,
args: {
name: "boolean",
},
},
{
name: "--verboseLog",
description: "Verbose logging (default false)",
priority: 50,
args: {
name: "boolean",
},
},
];
// options common to 'hugo', 'hugo mod', 'hugo new', and 'hugo server' commands
const commonOptions: Fig.Option[] = [
{
name: ["-b", "--baseURL"],
description: "Hostname (and path) to the root, e.g. http://spf13.com/",
args: {
name: "hostname and path",
},
},
{
name: ["-D", "--buildDrafts"],
description: "Include content marked as draft (default false)",
args: {
name: "boolean",
},
},
{
name: ["-E", "--buildExpired"],
description: "Include expired content (default false)",
args: {
name: "boolean",
},
},
{
name: ["-F", "--buildFuture"],
description:
"Include content with publishdate in the future (default false)",
args: {
name: "boolean",
},
},
{
name: "--cacheDir",
description:
"Filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/",
args: {
name: "path",
template: "folders",
},
},
{
name: "--cleanDestinationDir",
description:
"Remove files from destination not found in static directories (default false)",
args: {
name: "boolean",
},
},
{
name: ["-c", "--contentDir"],
description: "Filesystem path to content directory",
args: {
name: "path",
template: "folders",
},
},
{
name: ["-d", "--destination"],
description: "Filesystem path to write files to",
args: {
name: "path",
template: "folders",
},
},
{
name: "--disableKinds",
description: "Disable different kind of pages (home, RSS etc.)",
args: {
name: "kind,kind",
suggestions: [
"page",
"home",
"section",
"taxonomy",
"term",
"RSS",
"sitemap",
"robotsTXT",
"404",
],
},
},
{
name: "--enableGitInfo",
description:
"Add Git revision, date and author info to the pages (default false)",
args: {
name: "boolean",
},
},
{
name: "--forceSyncStatic",
description: "Copy all files when static is changed (default false)",
args: {
name: "boolean",
},
},
{
name: "--gc",
description:
"Enable to run some cleanup tasks (remove unused cache files) after the build (default false)",
args: {
name: "boolean",
},
},
{
name: "--i18n-warnings",
description: "Print missing translations (default false)",
args: {
name: "boolean",
},
},
{
name: "--ignoreCache",
description: "Ignores the cache directory (default false)",
args: {
name: "boolean",
},
},
{
name: ["-l", "--layoutDir"],
description: "Filesystem path to layout directory",
args: {
name: "path",
template: "folders",
},
},
{
name: "--minify",
description:
"Minify any supported output format (HTML, XML etc.) (default false)",
args: {
name: "boolean",
},
},
{
name: "--noChmod",
description: "Don't sync permission mode of files (default false)",
args: {
name: "boolean",
},
},
{
name: "--noTimes",
description: "Don't sync modification time of files (default false)",
args: {
name: "boolean",
},
},
{
name: "--path-warnings",
description: "Print warnings on duplicate target paths etc (default false)",
args: {
name: "boolean",
},
},
{
name: "--poll",
description:
"Set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes",
args: {
name: "milliseconds",
},
},
{
name: "--print-mem",
description: "Print memory usage to screen at intervals (default false)",
args: {
name: "boolean",
},
},
{
name: "--templateMetrics",
description: "Display metrics about template executions (default false)",
args: {
name: "boolean",
},
},
{
name: "--templateMetricsHints",
description:
"Calculate some improvement hints when combined with --templateMetrics (default false)",
args: {
name: "boolean",
},
},
{
name: ["-t", "--theme"],
description: "Themes to use (located in /themes/THEMENAME/)",
args: { name: "theme name" },
},
{
name: "--trace",
description: "Write trace to file (not useful in general)",
args: {
name: "file",
template: "filepaths",
},
},
];
// options common to 'hugo' and 'hugo server' commands
const watch = {
name: ["-w", "--watch"],
description:
"Watch filesystem for changes and recreate as needed (default true)",
args: {
name: "boolean",
},
};
// options common to 'toJSON', 'toTOML', 'toYAML' commands
const convertOptions: Fig.Option[] = [
{
name: ["-o", "--output"],
description: "Filesystem path to write files to",
args: {
name: "path",
template: "folders",
},
},
{
name: "--unsafe",
description: "Enable less safe operations, please backup first",
isDangerous: true,
},
];
const completionSpec: Fig.Spec = {
name: "hugo",
description: "Hugo builds your site",
subcommands: [
{
name: "check",
description: "Contains some verification checks",
args: {
name: "command",
},
subcommands: [
{
name: "ulimit",
description: "Check system ulimit settings",
options: [help("ulimit")],
},
],
options: [help("check"), ...globalOptions],
},
{
name: "config",
description: "Print the site configuration",
subcommands: [
{
name: "mounts",
description: "Print the configured file mounts",
options: [help("mounts")],
},
],
options: [help("config"), ...globalOptions],
},
{
name: "convert",
description: "Convert your content to different formats",
args: {
name: "command",
},
subcommands: [
{
name: "toJSON",
description: "Convert front matter to JSON",
isDangerous: true,
options: [help("toJSON"), ...convertOptions],
},
{
name: "toTOML",
description: "Convert front matter to TOML",
isDangerous: true,
options: [help("toTOML"), ...convertOptions],
},
{
name: "toYAML",
description: "Convert front matter to YAML",
isDangerous: true,
options: [help("toYAML"), ...convertOptions],
},
],
options: [help("convert"), ...globalOptions],
},
{
name: "deploy",
description: "Deploy your site to a Cloud provider",
options: [
help("deploy"),
...globalOptions,
{
name: "--confirm",
description:
"Ask for confirmation before making changes to the target",
},
{
name: "--dryRun",
description: "Dry run",
},
{
name: "--force",
description: "Force upload of all files",
},
{
name: "--invalidateCDN",
description:
"Invalidate the CDN cache listed in the deployment target (default true)",
},
{
name: "--maxDeletes",
description:
"Maximum # of files to delete, or -1 to disable (default 256)",
args: {
name: "int",
},
},
{
name: "--target",
description:
"Target deployment from deployments section in config file; defaults to the first one",
args: {
name: "target",
},
},
],
},
{
name: "env",
description: "Print Hugo version and environment info",
options: [
help("env"),
...globalOptions,
{
name: "-v",
description: "Get a full dependency list",
},
],
},
{
name: "gen",
description: "A collection of several useful generators",
args: {
name: "command",
},
subcommands: [
{
name: "autocomplete",
description:
"Generate shell autocompletion script for Hugo (default outputs to stdout)",
options: [
help("autocomplete"),
{
name: ["-f", "--completionfile"],
description: "Autocompletion file, defaults to stdout",
args: {
name: "file",
template: "filepaths",
},
},
{
name: ["-t", "--type"],
description:
"Autocompletion type (bash, zsh, fish, or powershell) (default 'bash')",
args: {
name: "type",
default: "bash",
suggestions: [
{ name: "bash", description: "Default" },
{ name: "zsh" },
{ name: "fish" },
{ name: "powershell" },
],
},
},
],
},
{
name: "chromastyles",
description:
"Generate CSS stylesheet for the Chroma code highlighter (default outputs to stdout)",
options: [
help("chromastyles"),
{
name: "--highlightStyle",
description:
"Style used for highlighting lines (see https://github.com/alecthomas/chroma) (default 'bg:#ffffcc')",
args: {
name: "hex triplet",
},
},
{
name: "--linesStyle",
description:
"Style used for line numbers (see https://github.com/alecthomas/chroma)",
args: {
name: "hex triplet",
},
},
{
name: "--style",
description:
"Highlighter style (see https://help.farbox.com/pygments.html) (default 'friendly')",
args: {
name: "style name",
suggestions: [
{ name: "friendly", description: "Default" },
{ name: "abap" },
{ name: "algol" },
{ name: "algol_nu" },
{ name: "api" },
{ name: "arduino" },
{ name: "autumn" },
{ name: "base16-snazzy" },
{ name: "borland" },
{ name: "bw" },
{ name: "colorful" },
{ name: "doom-one" },
{ name: "doom-one2" },
{ name: "dracula" },
{ name: "emacs" },
{ name: "fruity" },
{ name: "github" },
{ name: "hr_dark" },
{ name: "hr_high_contrast" },
{ name: "igor" },
{ name: "lovelace" },
{ name: "manni" },
{ name: "monokai" },
{ name: "monokailight" },
{ name: "murphy" },
{ name: "native" },
{ name: "nord" },
{ name: "paraiso-dark" },
{ name: "paraiso-light" },
{ name: "pastie" },
{ name: "perldoc" },
{ name: "pygments" },
{ name: "rainbow_dash" },
{ name: "rrt" },
{ name: "solarized-dark" },
{ name: "solarized-dark256" },
{ name: "solarized-light" },
{ name: "swapoff" },
{ name: "tango" },
{ name: "trac" },
{ name: "vim" },
{ name: "vs" },
{ name: "vulcan" },
{ name: "xcode-dark" },
{ name: "xcode" },
],
},
},
],
},
{
name: "doc",
description:
"Generate Markdown documentation for the Hugo CLI (default '/tmp/hugodoc/')",
options: [
help("doc"),
{
name: "--dir",
description:
"The directory to write the doc. (default '/tmp/hugodoc/')",
args: {
name: "path",
template: "folders",
},
},
],
},
{
name: "man",
description: "Generate man pages for the Hugo CLI (default 'man/')",
options: [
help("man"),
{
name: "--dir",
description:
"The directory to write the man pages. (default 'man/')",
args: {
name: "path",
template: "folders",
},
},
],
},
],
options: [help("gen"), ...globalOptions],
},
{
name: "help",
description: "Help about any command",
args: {
name: "command",
suggestions: [
{ name: "check" },
{ name: "config" },
{ name: "convert" },
{ name: "deploy" },
{ name: "env" },
{ name: "gen" },
{ name: "help" },
{ name: "import" },
{ name: "list" },
{ name: "mod" },
{ name: "new" },
{ name: "server" },
{ name: "version" },
],
},
},
{
name: "import",
description: "Import your site from others",
args: {
name: "command",
},
subcommands: [
{
name: "jekyll",
displayName: "jekyll",
description:
"Import from Jekyll requires two paths, e.g. ` + `hugo import jekyll jekyll_root_path target_path`",
args: [
{
name: "jekyll_root_path",
template: "folders",
},
{
name: "target_path",
template: "folders",
},
],
options: [
help("jekyll"),
{
name: "--force",
description: "Allow import into non-empty target directory",
isDangerous: true,
},
],
},
],
options: [help("import"), ...globalOptions],
},
{
name: "list",
description: "Listing out various types of content",
args: {
name: "command",
},
subcommands: [
{
name: "drafts",
description: "List all drafts",
options: [help("drafts")],
},
{
name: "future",
description: "List all posts dated in the future",
options: [help("future")],
},
{
name: "expired",
description: "List all posts already expired",
options: [help("expired")],
},
{
name: "all",
description: "List all posts",
options: [help("all")],
},
],
options: [help("list"), ...globalOptions],
},
{
name: "mod",
description: "Various Hugo Modules helpers",
args: {
name: "command",
},
subcommands: [
{
name: "clean",
description: "Delete the Hugo Module cache for the current project",
options: [
help("clean"),
{
name: "--all",
description: "Clean entire module cache",
},
{
name: "--pattern",
description:
'Pattern matching module paths to clean (all if not set)", "e.g. "**hugo*"',
args: {
name: "path",
},
},
],
},
{
name: "get",
description: "Resolves dependencies in your current Hugo Project",
// Run `go help get` for more information. All flags available for `go get` are also relevant here.
options: [
help("get"),
{
name: "-d",
description: "Download packages only and do not install",
},
{
name: "-f",
description:
"Valid only when -u is set, forces get -u not to verify that each package has been checked out from the source control repository implied by its import path. This can be useful if the source is a local fork of the original",
},
{
name: "-fix",
description:
"Run the fix tool on downloaded packages before resolving dependencies or building the code",
},
{
name: "-insecure",
description:
"Permits fetching from repositories and resolving custom domains using insecure schemes such as HTTP. Use with caution",
},
{
name: "-t",
description:
"Also download the packages required to build the tests for the specified packages",
},
{
name: "-u",
description:
"Recursively update modules. Use network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages",
},
{
name: "-v",
description: "Enables verbose progress and debug output",
},
],
},
{
name: "graph",
description:
"Use `hugo mod graph` from the relevant module directory and it will print the dependency graph, including vendoring, module replacement or disabled status",
options: [help("graph")],
},
{
name: "init",
description: "Initialize this project as a Hugo Module",
options: [help("init")],
},
{
name: "npm",
description: "Various npm helpers",
subcommands: [
{
name: "pack",
description:
"Experimental: Prepares and writes a composite package.json file for your project",
options: [help("pack")],
},
],
options: [help("npm")],
},
{
name: "tidy",
description: "Remove unused entries in go.mod and go.sum",
options: [help("tidy")],
},
{
name: "vendor",
description:
"Vendor all module dependencies into the _vendor directory",
options: [help("vendor")],
},
{
name: "verify",
description: "Verify dependencies",
options: [
help("verify"),
{
name: "--clean",
description:
"Delete module cache for dependencies that fail verification",
},
],
},
],
options: [help("mod"), ...commonOptions, ...globalOptions],
},
{
name: "new",
description: "Create new content for your site",
args: {
name: "content-section/file-name.md",
},
subcommands: [
{
name: "site",
description: "Create a new site (skeleton)",
args: {
name: "path",
template: "folders",
},
options: [
help("site"),
{
name: "--force",
description: "Init inside non-empty directory",
isDangerous: true,
},
{
name: ["-f", "--format"],
description: 'Config & frontmatter format (default "toml")',
args: {
name: "format",
suggestions: [
{ name: "toml", description: "Default" },
{ name: "yaml" },
{ name: "json" },
],
},
},
],
},
{
name: "theme",
description: "Create a new theme",
args: {
name: "name",
},
options: [help("theme")],
},
],
options: [
help("new"),
...commonOptions,
...globalOptions,
{
name: ["-k", "--kind"],
description: "Content type to create",
args: [
{
name: "archetype|default",
generators: {
script: ["ls", "./archetypes/"],
postProcess: (output) =>
output.split("\n").map((fileName) => ({
name: fileName.slice(0, fileName.lastIndexOf(".")),
icon: "fig://icon?type=string",
})),
},
},
{
name: "content-section/file-name.md",
},
],
},
{
name: "--editor",
description: "Edit new content with this editor, if provided",
args: {
name: "editor",
},
},
],
},
{
name: "server",
description: "A high performance webserver",
options: [
help("server"),
...commonOptions,
...globalOptions,
watch,
{
name: "--appendPort",
description: "Append port to baseURL (default true)",
args: {
name: "boolean",
},
},
{
name: "--bind",
description:
"Interface to which the server will bind (default '127.0.0.1')",
args: {
name: "ip address",
},
},
{
name: "--disableBrowserError",
description:
"Do not show build errors in the browser (default false)",
args: {
name: "boolean",
},
},
{
name: "--disableFastRender",
description: "Enables full re-renders on changes (default false)",
args: {
name: "boolean",
},
},
{
name: "--disableLiveReload",
description:
"Watch without enabling live browser reload on rebuild (default false)",
args: {
name: "boolean",
},
},
{
name: "--liveReloadPort",
description:
"Port for live reloading (i.e. 443 in HTTPS proxy situations) (default -1)",
args: {
name: "port",
},
},
{
name: "--meminterval",
description:
"Interval to poll memory usage (requires --memstats), valid time units are 'ns', 'us' (or 'µs'), 'ms', 's', 'm', 'h'. (default '100ms')",
args: {
name: "time unit",
},
},
{
name: "--memstats",
description: "Log memory usage to this file",
args: {
name: "file",
template: "filepaths",
},
},
{
name: "--navigateToChanged",
description:
"Navigate to changed content file on live browser reload (default false)",
args: {
name: "boolean",
},
},
{
name: "--noHTTPCache",
description: "Prevent HTTP caching (default false)",
args: {
name: "boolean",
},
},
{
name: ["-p", "--port"],
description: "Port on which the server will listen (default 1313)",
args: {
name: "port",
},
},
{
name: "--renderToDisk",
description:
"Render to Destination path (default is false: render to memory & serve from there)",
args: {
name: "boolean",
},
},
],
},