Debian Codegraph @

testscripts/commands/new.txt

raw
1 # Test the new command.
2
3 hugo new project -h
4 stdout 'Create a new project at the specified path.'
5 hugo new project my-yaml-project --format yml
6 checkfile my-yaml-project/hugo.yml
7 hugo new project my-project -f
8 stdout 'Congratulations! Your new Hugo project was created in'
9 cd my-project
10 checkfile archetypes/default.md
11 checkfile hugo.toml
12 exists assets
13 exists content
14 exists data
15 exists i18n
16 exists layouts
17 exists static
18 exists themes
19 ! exists resources
20
21 hugo new theme -h
22 stdout 'Create a new theme with the specified name in the ./themes directory.'
23 hugo new theme my-theme --format yml
24 stdout 'Creating new theme'
25 ! exists resources
26 cd themes
27 cd my-theme
28 checkfile archetypes/default.md
29 checkfile assets/css/main.css
30 checkfile assets/js/main.js
31 checkfile content/_index.md
32 checkfile content/posts/_index.md
33 checkfile content/posts/post-1.md
34 checkfile content/posts/post-2.md
35 checkfile content/posts/post-3/bryce-canyon.jpg
36 checkfile content/posts/post-3/index.md
37 checkfile layouts/baseof.html
38 checkfile layouts/home.html
39 checkfile layouts/section.html
40 checkfile layouts/page.html
41 checkfile layouts/taxonomy.html
42 checkfile layouts/term.html
43 checkfile layouts/_partials/footer.html
44 checkfile layouts/_partials/head.html
45 checkfile layouts/_partials/head/css.html
46 checkfile layouts/_partials/head/js.html
47 checkfile layouts/_partials/header.html
48 checkfile layouts/_partials/menu.html
49 checkfile layouts/_partials/terms.html
50 checkfile static/favicon.ico
51 checkfile hugo.yml
52 exists data
53 exists i18n
54
55 cd $WORK/my-project
56
57 hugo new -h
58 stdout 'Create a new content file.'
59 hugo new posts/my-first-post.md
60 checkfile content/posts/my-first-post.md
61
62 cd ..
63 cd my-existing-project
64 hugo new post/foo.md -t my-theme
65 grep 'Dummy content' content/post/foo.md
66
67 cd $WORK
68
69 # In the three archetype format tests below, skip Windows testing to avoid
70 # newline differences when comparing to golden.
71
72 hugo new project json-project --format json
73 [!windows] cmp json-project/archetypes/default.md archetype-golden-json.md
74
75 hugo new project toml-project --format toml
76 [!windows] cmp toml-project/archetypes/default.md archetype-golden-toml.md
77
78 hugo new project yaml-project --format yaml
79 [!windows] cmp yaml-project/archetypes/default.md archetype-golden-yaml.md
80
81 -- my-existing-project/hugo.toml --
82 theme = "my-theme"
83 -- my-existing-project/content/p1.md --
84 ---
85 title: "P1"
86 ---
87 -- my-existing-project/themes/my-theme/hugo.toml --
88 -- my-existing-project/themes/my-theme/archetypes/post.md --
89 ---
90 title: "{{ replace .Name "-" " " | title }}"
91 date: {{ .Date }}
92 draft: true
93 ---
94
95 Dummy content.
96
97 -- archetype-golden-json.md --
98 {
99 "date": "{{ .Date }}",
100 "draft": true,
101 "title": "{{ replace .File.ContentBaseName \"-\" \" \" | title }}"
102 }
103 -- archetype-golden-toml.md --
104 +++
105 date = '{{ .Date }}'
106 draft = true
107 title = '{{ replace .File.ContentBaseName "-" " " | title }}'
108 +++
109 -- archetype-golden-yaml.md --
110 ---
111 date: '{{ .Date }}'
112 draft: true
113 title: '{{ replace .File.ContentBaseName "-" " " | title }}'
114 ---