# Test the new command.

hugo new site -h
stdout 'Create a new site at the specified path.'
hugo new site my-yaml-site --format yml
checkfile my-yaml-site/hugo.yml
hugo new site mysite -f
stdout 'Congratulations! Your new Hugo site was created in'
cd mysite
checkfile archetypes/default.md
checkfile hugo.toml
exists assets
exists content
exists data
exists i18n
exists layouts
exists static
exists themes
! exists resources

hugo new theme -h
stdout 'Create a new theme with the specified name in the ./themes directory.'
hugo new theme mytheme --format yml
stdout 'Creating new theme'
! exists resources
cd themes
cd mytheme
checkfile archetypes/default.md
checkfile assets/css/main.css
checkfile assets/js/main.js
checkfile content/_index.md
checkfile content/posts/_index.md
checkfile content/posts/post-1.md
checkfile content/posts/post-2.md
checkfile content/posts/post-3/bryce-canyon.jpg
checkfile content/posts/post-3/index.md
checkfile layouts/baseof.html
checkfile layouts/home.html
checkfile layouts/section.html
checkfile layouts/page.html
checkfile layouts/taxonomy.html
checkfile layouts/term.html
checkfile layouts/_partials/footer.html
checkfile layouts/_partials/head.html
checkfile layouts/_partials/head/css.html
checkfile layouts/_partials/head/js.html
checkfile layouts/_partials/header.html
checkfile layouts/_partials/menu.html
checkfile layouts/_partials/terms.html
checkfile static/favicon.ico
checkfile hugo.yml
exists data
exists i18n

cd $WORK/mysite

hugo new -h
stdout 'Create a new content file.'
hugo new posts/my-first-post.md
checkfile content/posts/my-first-post.md

cd ..
cd myexistingsite
hugo new post/foo.md -t mytheme
grep 'Dummy content' content/post/foo.md

cd $WORK

# In the three archetype format tests below, skip Windows testing to avoid
# newline differences when comparing to golden.

hugo new site json-site --format json
[!windows] cmp json-site/archetypes/default.md archetype-golden-json.md

hugo new site toml-site --format toml
[!windows] cmp toml-site/archetypes/default.md archetype-golden-toml.md

hugo new site yaml-site --format yaml
[!windows] cmp yaml-site/archetypes/default.md archetype-golden-yaml.md

-- myexistingsite/hugo.toml --
theme = "mytheme"
-- myexistingsite/content/p1.md --
---
title: "P1"
---
-- myexistingsite/themes/mytheme/hugo.toml --
-- myexistingsite/themes/mytheme/archetypes/post.md --
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---

Dummy content.

-- archetype-golden-json.md --
{
   "date": "{{ .Date }}",
   "draft": true,
   "title": "{{ replace .File.ContentBaseName \"-\" \" \" | title }}"
}
-- archetype-golden-toml.md --
+++
date = '{{ .Date }}'
draft = true
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
+++
-- archetype-golden-yaml.md --
---
date: '{{ .Date }}'
draft: true
title: '{{ replace .File.ContentBaseName "-" " " | title }}'
---
