2016-03-21 19:28:42 -04:00
|
|
|
// Copyright 2016 The Hugo Authors. All rights reserved.
|
2015-02-08 10:11:04 -05:00
|
|
|
//
|
2015-11-23 22:16:36 -05:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
2014-05-02 01:06:01 -04:00
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2015-11-23 22:16:36 -05:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2014-05-02 01:06:01 -04:00
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2014-05-08 18:30:11 -04:00
|
|
|
"bytes"
|
2015-12-08 17:38:26 -05:00
|
|
|
"errors"
|
2017-01-10 04:55:03 -05:00
|
|
|
"fmt"
|
2014-05-08 18:30:11 -04:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2014-05-02 01:06:01 -04:00
|
|
|
"strings"
|
2015-02-08 10:11:04 -05:00
|
|
|
"time"
|
2014-05-02 01:06:01 -04:00
|
|
|
|
2017-06-13 12:42:45 -04:00
|
|
|
"github.com/gohugoio/hugo/create"
|
|
|
|
"github.com/gohugoio/hugo/helpers"
|
|
|
|
"github.com/gohugoio/hugo/hugofs"
|
|
|
|
"github.com/gohugoio/hugo/hugolib"
|
|
|
|
"github.com/gohugoio/hugo/parser"
|
2017-06-13 13:07:35 -04:00
|
|
|
"github.com/spf13/afero"
|
|
|
|
"github.com/spf13/cobra"
|
2014-05-02 01:06:01 -04:00
|
|
|
jww "github.com/spf13/jwalterweatherman"
|
2014-05-29 18:40:16 -04:00
|
|
|
"github.com/spf13/viper"
|
2014-05-02 01:06:01 -04:00
|
|
|
)
|
|
|
|
|
2016-02-05 12:41:40 -05:00
|
|
|
var (
|
2016-03-14 10:24:42 -04:00
|
|
|
configFormat string
|
|
|
|
contentEditor string
|
|
|
|
contentType string
|
2016-02-05 12:41:40 -05:00
|
|
|
)
|
2014-05-02 01:06:01 -04:00
|
|
|
|
|
|
|
func init() {
|
2014-05-08 18:30:11 -04:00
|
|
|
newSiteCmd.Flags().StringVarP(&configFormat, "format", "f", "toml", "config & frontmatter format")
|
2017-04-26 15:58:10 -04:00
|
|
|
newSiteCmd.Flags().Bool("force", false, "init inside non-empty directory")
|
|
|
|
newCmd.Flags().StringVarP(&contentType, "kind", "k", "", "content type to create")
|
2016-02-05 16:58:17 -05:00
|
|
|
newCmd.PersistentFlags().StringVarP(&source, "source", "s", "", "filesystem path to read files relative from")
|
2015-12-16 01:41:10 -05:00
|
|
|
newCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
|
2016-02-05 12:41:40 -05:00
|
|
|
newCmd.Flags().StringVar(&contentEditor, "editor", "", "edit new content with this editor, if provided")
|
|
|
|
|
2014-05-02 01:06:01 -04:00
|
|
|
newCmd.AddCommand(newSiteCmd)
|
2014-05-08 18:30:11 -04:00
|
|
|
newCmd.AddCommand(newThemeCmd)
|
2016-02-05 12:41:40 -05:00
|
|
|
|
2014-05-02 01:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var newCmd = &cobra.Command{
|
|
|
|
Use: "new [path]",
|
|
|
|
Short: "Create new content for your site",
|
2014-09-28 00:52:15 -04:00
|
|
|
Long: `Create a new content file and automatically set the date and title.
|
2014-05-02 01:06:01 -04:00
|
|
|
It will guess which kind of file to create based on the path provided.
|
2015-08-04 05:15:12 -04:00
|
|
|
|
|
|
|
You can also specify the kind with ` + "`-k KIND`" + `.
|
|
|
|
|
|
|
|
If archetypes are provided in your theme or site, they will be used.`,
|
|
|
|
|
2015-12-02 05:42:53 -05:00
|
|
|
RunE: NewContent,
|
2014-05-02 01:06:01 -04:00
|
|
|
}
|
|
|
|
|
2014-05-08 18:30:11 -04:00
|
|
|
var newSiteCmd = &cobra.Command{
|
|
|
|
Use: "site [path]",
|
|
|
|
Short: "Create a new site (skeleton)",
|
|
|
|
Long: `Create a new site in the provided directory.
|
|
|
|
The new site will have the correct structure, but no content or theme yet.
|
2015-08-04 05:15:12 -04:00
|
|
|
Use ` + "`hugo new [contentPath]`" + ` to create new content.`,
|
2015-12-02 05:42:53 -05:00
|
|
|
RunE: NewSite,
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var newThemeCmd = &cobra.Command{
|
|
|
|
Use: "theme [name]",
|
|
|
|
Short: "Create a new theme",
|
|
|
|
Long: `Create a new theme (skeleton) called [name] in the current directory.
|
|
|
|
New theme is a skeleton. Please add content to the touched files. Add your
|
|
|
|
name to the copyright line in the license and adjust the theme.toml file
|
2015-08-04 05:15:12 -04:00
|
|
|
as you see fit.`,
|
2015-12-02 05:42:53 -05:00
|
|
|
RunE: NewTheme,
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-02-08 10:11:04 -05:00
|
|
|
// NewContent adds new content to a Hugo site.
|
2015-12-02 05:42:53 -05:00
|
|
|
func NewContent(cmd *cobra.Command, args []string) error {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
cfgInit := func(c *commandeer) error {
|
|
|
|
if cmd.Flags().Changed("editor") {
|
|
|
|
c.Set("newContentEditor", contentEditor)
|
|
|
|
}
|
|
|
|
return nil
|
2015-12-02 05:42:53 -05:00
|
|
|
}
|
2014-05-02 01:06:01 -04:00
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
c, err := InitializeConfig(false, cfgInit)
|
|
|
|
|
2017-03-25 09:37:04 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-02-04 22:20:06 -05:00
|
|
|
|
2014-05-02 01:06:01 -04:00
|
|
|
if len(args) < 1 {
|
2015-12-02 05:42:53 -05:00
|
|
|
return newUserError("path needs to be provided")
|
2014-05-02 01:06:01 -04:00
|
|
|
}
|
|
|
|
|
2017-03-24 03:14:14 -04:00
|
|
|
createPath := args[0]
|
2014-05-02 01:06:01 -04:00
|
|
|
|
|
|
|
var kind string
|
|
|
|
|
2017-03-24 03:14:14 -04:00
|
|
|
createPath, kind = newContentPathSection(createPath)
|
2014-05-02 01:06:01 -04:00
|
|
|
|
|
|
|
if contentType != "" {
|
|
|
|
kind = contentType
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
cfg := c.DepsCfg
|
|
|
|
|
2017-06-18 13:39:42 -04:00
|
|
|
ps, err := helpers.NewPathSpec(cfg.Fs, cfg.Cfg)
|
2017-01-10 04:55:03 -05:00
|
|
|
if err != nil {
|
2017-06-18 13:39:42 -04:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// If a site isn't in use in the archetype template, we can skip the build.
|
|
|
|
siteFactory := func(filename string, siteUsed bool) (*hugolib.Site, error) {
|
|
|
|
if !siteUsed {
|
|
|
|
return hugolib.NewSite(*cfg)
|
|
|
|
}
|
|
|
|
var s *hugolib.Site
|
|
|
|
if err := c.initSites(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
if err := Hugo.Build(hugolib.BuildCfg{SkipRender: true}); err != nil {
|
2017-06-18 13:39:42 -04:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
s = Hugo.Sites[0]
|
|
|
|
|
|
|
|
if len(Hugo.Sites) > 1 {
|
|
|
|
// Find the best match.
|
|
|
|
for _, ss := range Hugo.Sites {
|
|
|
|
if strings.Contains(createPath, "."+ss.Language.Lang) {
|
|
|
|
s = ss
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s, nil
|
2017-01-10 04:55:03 -05:00
|
|
|
}
|
|
|
|
|
2017-06-18 13:39:42 -04:00
|
|
|
return create.NewContent(ps, siteFactory, kind, createPath)
|
2014-05-02 01:06:01 -04:00
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
func doNewSite(fs *hugofs.Fs, basepath string, force bool) error {
|
2017-06-22 14:39:55 -04:00
|
|
|
archeTypePath := filepath.Join(basepath, "archetypes")
|
2015-09-25 17:39:46 -04:00
|
|
|
dirs := []string{
|
|
|
|
filepath.Join(basepath, "layouts"),
|
|
|
|
filepath.Join(basepath, "content"),
|
2017-06-22 14:39:55 -04:00
|
|
|
archeTypePath,
|
2015-09-25 17:39:46 -04:00
|
|
|
filepath.Join(basepath, "static"),
|
|
|
|
filepath.Join(basepath, "data"),
|
2015-12-03 20:32:12 -05:00
|
|
|
filepath.Join(basepath, "themes"),
|
2015-09-25 17:39:46 -04:00
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
if exists, _ := helpers.Exists(basepath, fs.Source); exists {
|
|
|
|
if isDir, _ := helpers.IsDir(basepath, fs.Source); !isDir {
|
2015-09-25 17:39:46 -04:00
|
|
|
return errors.New(basepath + " already exists but not a directory")
|
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
isEmpty, _ := helpers.IsEmpty(basepath, fs.Source)
|
2015-09-25 17:39:46 -04:00
|
|
|
|
|
|
|
switch {
|
|
|
|
case !isEmpty && !force:
|
2015-10-17 08:05:48 -04:00
|
|
|
return errors.New(basepath + " already exists and is not empty")
|
2015-09-25 17:39:46 -04:00
|
|
|
|
|
|
|
case !isEmpty && force:
|
|
|
|
all := append(dirs, filepath.Join(basepath, "config."+configFormat))
|
|
|
|
for _, path := range all {
|
2017-01-10 04:55:03 -05:00
|
|
|
if exists, _ := helpers.Exists(path, fs.Source); exists {
|
2015-09-25 17:39:46 -04:00
|
|
|
return errors.New(path + " already exists")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, dir := range dirs {
|
2017-01-10 04:55:03 -05:00
|
|
|
if err := fs.Source.MkdirAll(dir, 0777); err != nil {
|
|
|
|
return fmt.Errorf("Failed to create dir: %s", err)
|
|
|
|
}
|
2015-09-25 17:39:46 -04:00
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
createConfig(fs, basepath, configFormat)
|
2015-09-25 17:39:46 -04:00
|
|
|
|
2017-06-22 14:39:55 -04:00
|
|
|
// Create a defaul archetype file.
|
|
|
|
helpers.SafeWriteToDisk(filepath.Join(archeTypePath, "default.md"),
|
|
|
|
strings.NewReader(create.ArchetypeTemplateTemplate), fs.Source)
|
|
|
|
|
2016-10-09 04:59:07 -04:00
|
|
|
jww.FEEDBACK.Printf("Congratulations! Your new Hugo site is created in %s.\n\n", basepath)
|
|
|
|
jww.FEEDBACK.Println(nextStepsText())
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func nextStepsText() string {
|
|
|
|
var nextStepsText bytes.Buffer
|
|
|
|
|
|
|
|
nextStepsText.WriteString(`Just a few more steps and you're ready to go:
|
2016-04-02 19:24:56 -04:00
|
|
|
|
2016-09-26 16:23:57 -04:00
|
|
|
1. Download a theme into the same-named folder.
|
|
|
|
Choose a theme from https://themes.gohugo.io/, or
|
|
|
|
create your own with the "hugo new theme <THEMENAME>" command.
|
|
|
|
2. Perhaps you want to add some content. You can add single files
|
2016-10-09 04:59:07 -04:00
|
|
|
with "hugo new `)
|
|
|
|
|
|
|
|
nextStepsText.WriteString(filepath.Join("<SECTIONNAME>", "<FILENAME>.<FORMAT>"))
|
|
|
|
|
|
|
|
nextStepsText.WriteString(`".
|
2016-09-26 16:23:57 -04:00
|
|
|
3. Start the built-in live server via "hugo server".
|
|
|
|
|
|
|
|
Visit https://gohugo.io/ for quickstart guide and full documentation.`)
|
2015-12-16 22:41:33 -05:00
|
|
|
|
2016-10-09 04:59:07 -04:00
|
|
|
return nextStepsText.String()
|
2015-09-25 17:39:46 -04:00
|
|
|
}
|
|
|
|
|
2015-12-16 22:41:33 -05:00
|
|
|
// NewSite creates a new Hugo site and initializes a structured Hugo directory.
|
2015-12-02 05:42:53 -05:00
|
|
|
func NewSite(cmd *cobra.Command, args []string) error {
|
2014-05-08 18:30:11 -04:00
|
|
|
if len(args) < 1 {
|
2015-12-02 05:42:53 -05:00
|
|
|
return newUserError("path needs to be provided")
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
createpath, err := filepath.Abs(filepath.Clean(args[0]))
|
|
|
|
if err != nil {
|
2015-12-02 05:42:53 -05:00
|
|
|
return newUserError(err)
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-09-25 17:39:46 -04:00
|
|
|
forceNew, _ := cmd.Flags().GetBool("force")
|
2015-12-02 05:42:53 -05:00
|
|
|
|
2017-02-04 22:20:06 -05:00
|
|
|
return doNewSite(hugofs.NewDefault(viper.New()), createpath, forceNew)
|
2014-05-02 01:06:01 -04:00
|
|
|
}
|
|
|
|
|
2015-02-08 10:11:04 -05:00
|
|
|
// NewTheme creates a new Hugo theme.
|
2015-12-02 05:42:53 -05:00
|
|
|
func NewTheme(cmd *cobra.Command, args []string) error {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
c, err := InitializeConfig(false, nil)
|
2017-01-10 04:55:03 -05:00
|
|
|
|
|
|
|
if err != nil {
|
2015-12-02 05:42:53 -05:00
|
|
|
return err
|
|
|
|
}
|
2014-05-02 01:06:01 -04:00
|
|
|
|
2014-05-08 18:30:11 -04:00
|
|
|
if len(args) < 1 {
|
2015-12-02 05:42:53 -05:00
|
|
|
return newUserError("theme name needs to be provided")
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
2017-02-04 22:20:06 -05:00
|
|
|
createpath := c.PathSpec().AbsPathify(filepath.Join(c.Cfg.GetString("themesDir"), args[0]))
|
2015-11-23 14:44:59 -05:00
|
|
|
jww.INFO.Println("creating theme at", createpath)
|
2014-05-08 18:30:11 -04:00
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
cfg := c.DepsCfg
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
if x, _ := helpers.Exists(createpath, cfg.Fs.Source); x {
|
2015-12-02 10:27:08 -05:00
|
|
|
return newUserError(createpath, "already exists")
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
mkdir(createpath, "layouts", "_default")
|
2014-05-27 18:30:25 -04:00
|
|
|
mkdir(createpath, "layouts", "partials")
|
2014-05-08 18:30:11 -04:00
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
touchFile(cfg.Fs.Source, createpath, "layouts", "index.html")
|
|
|
|
touchFile(cfg.Fs.Source, createpath, "layouts", "404.html")
|
|
|
|
touchFile(cfg.Fs.Source, createpath, "layouts", "_default", "list.html")
|
|
|
|
touchFile(cfg.Fs.Source, createpath, "layouts", "_default", "single.html")
|
2014-05-08 18:30:11 -04:00
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
touchFile(cfg.Fs.Source, createpath, "layouts", "partials", "header.html")
|
|
|
|
touchFile(cfg.Fs.Source, createpath, "layouts", "partials", "footer.html")
|
2014-05-08 18:30:11 -04:00
|
|
|
|
|
|
|
mkdir(createpath, "archetypes")
|
2015-10-14 14:12:59 -04:00
|
|
|
|
|
|
|
archDefault := []byte("+++\n+++\n")
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
err = helpers.WriteToDisk(filepath.Join(createpath, "archetypes", "default.md"), bytes.NewReader(archDefault), cfg.Fs.Source)
|
2015-10-14 14:12:59 -04:00
|
|
|
if err != nil {
|
2015-12-02 10:27:08 -05:00
|
|
|
return err
|
2015-10-14 14:12:59 -04:00
|
|
|
}
|
2014-05-08 18:30:11 -04:00
|
|
|
|
|
|
|
mkdir(createpath, "static", "js")
|
|
|
|
mkdir(createpath, "static", "css")
|
|
|
|
|
|
|
|
by := []byte(`The MIT License (MIT)
|
|
|
|
|
2015-02-08 10:11:04 -05:00
|
|
|
Copyright (c) ` + time.Now().Format("2006") + ` YOUR_NAME_HERE
|
2014-05-08 18:30:11 -04:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
`)
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
err = helpers.WriteToDisk(filepath.Join(createpath, "LICENSE.md"), bytes.NewReader(by), cfg.Fs.Source)
|
2014-05-08 18:30:11 -04:00
|
|
|
if err != nil {
|
2015-12-02 10:27:08 -05:00
|
|
|
return err
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
createThemeMD(cfg.Fs, createpath)
|
2015-12-02 05:42:53 -05:00
|
|
|
|
|
|
|
return nil
|
2014-05-08 18:30:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func mkdir(x ...string) {
|
2014-11-06 11:56:14 -05:00
|
|
|
p := filepath.Join(x...)
|
2014-05-08 18:30:11 -04:00
|
|
|
|
2015-02-08 10:11:04 -05:00
|
|
|
err := os.MkdirAll(p, 0777) // before umask
|
2014-05-08 18:30:11 -04:00
|
|
|
if err != nil {
|
|
|
|
jww.FATAL.Fatalln(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
func touchFile(fs afero.Fs, x ...string) {
|
2014-11-06 11:56:14 -05:00
|
|
|
inpath := filepath.Join(x...)
|
2014-05-08 18:30:11 -04:00
|
|
|
mkdir(filepath.Dir(inpath))
|
2017-01-10 04:55:03 -05:00
|
|
|
err := helpers.WriteToDisk(inpath, bytes.NewReader([]byte{}), fs)
|
2014-05-08 18:30:11 -04:00
|
|
|
if err != nil {
|
|
|
|
jww.FATAL.Fatalln(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
func createThemeMD(fs *hugofs.Fs, inpath string) (err error) {
|
2014-05-08 18:30:11 -04:00
|
|
|
|
2015-03-10 11:49:42 -04:00
|
|
|
by := []byte(`# theme.toml template for a Hugo theme
|
2017-06-13 12:47:17 -04:00
|
|
|
# See https://github.com/gohugoio/hugoThemes#themetoml for an example
|
2015-03-10 11:49:42 -04:00
|
|
|
|
|
|
|
name = "` + strings.Title(helpers.MakeTitle(filepath.Base(inpath))) + `"
|
2015-02-08 10:11:04 -05:00
|
|
|
license = "MIT"
|
2015-03-10 11:49:42 -04:00
|
|
|
licenselink = "https://github.com/yourname/yourtheme/blob/master/LICENSE.md"
|
2015-02-08 10:11:04 -05:00
|
|
|
description = ""
|
2017-06-26 14:38:45 -04:00
|
|
|
homepage = "http://example.com/"
|
2017-01-19 13:58:53 -05:00
|
|
|
tags = []
|
|
|
|
features = []
|
2018-01-08 06:12:41 -05:00
|
|
|
min_version = "0.32"
|
2015-02-08 10:11:04 -05:00
|
|
|
|
|
|
|
[author]
|
|
|
|
name = ""
|
|
|
|
homepage = ""
|
|
|
|
|
|
|
|
# If porting an existing theme
|
|
|
|
[original]
|
|
|
|
name = ""
|
|
|
|
homepage = ""
|
|
|
|
repo = ""
|
|
|
|
`)
|
2014-05-08 18:30:11 -04:00
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
err = helpers.WriteToDisk(filepath.Join(inpath, "theme.toml"), bytes.NewReader(by), fs.Source)
|
2014-05-08 18:30:11 -04:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-05-12 12:12:58 -04:00
|
|
|
func newContentPathSection(path string) (string, string) {
|
|
|
|
// Forward slashes is used in all examples. Convert if needed.
|
|
|
|
// Issue #1133
|
2017-01-10 04:55:03 -05:00
|
|
|
createpath := filepath.FromSlash(path)
|
2015-05-12 12:12:58 -04:00
|
|
|
var section string
|
|
|
|
// assume the first directory is the section (kind)
|
|
|
|
if strings.Contains(createpath[1:], helpers.FilePathSeparator) {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
parts := strings.Split(strings.TrimPrefix(createpath, helpers.FilePathSeparator), helpers.FilePathSeparator)
|
|
|
|
if len(parts) > 0 {
|
|
|
|
section = parts[0]
|
|
|
|
}
|
|
|
|
|
2015-05-12 12:12:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return createpath, section
|
|
|
|
}
|
|
|
|
|
2017-01-10 04:55:03 -05:00
|
|
|
func createConfig(fs *hugofs.Fs, inpath string, kind string) (err error) {
|
2017-05-31 06:10:46 -04:00
|
|
|
in := map[string]string{
|
2016-11-23 10:13:50 -05:00
|
|
|
"baseURL": "http://example.org/",
|
2015-02-08 10:11:04 -05:00
|
|
|
"title": "My New Hugo Site",
|
|
|
|
"languageCode": "en-us",
|
|
|
|
}
|
2014-05-08 18:30:11 -04:00
|
|
|
kind = parser.FormatSanitize(kind)
|
|
|
|
|
2016-12-26 16:23:20 -05:00
|
|
|
var buf bytes.Buffer
|
|
|
|
err = parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind), &buf)
|
2014-05-08 18:30:11 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-12-26 16:23:20 -05:00
|
|
|
return helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), &buf, fs.Source)
|
2014-05-02 01:06:01 -04:00
|
|
|
}
|