github.com/JarrahG/buffalocli@v0.0.0-20230801092127-b85bfd5d395a/internal/genny/add/add.go (about)

     1  package add
     2  
     3  import (
     4  	"bytes"
     5  
     6  	"github.com/JarrahG/buffalocli/internal/plugins/plugdeps"
     7  	"github.com/gobuffalo/genny/v2"
     8  )
     9  
    10  // New add plugin to the config file
    11  func New(opts *Options) (*genny.Generator, error) {
    12  	g := genny.New()
    13  
    14  	if err := opts.Validate(); err != nil {
    15  		return g, err
    16  	}
    17  
    18  	bb := &bytes.Buffer{}
    19  	plugs := plugdeps.New()
    20  	plugs.Add(opts.Plugins...)
    21  	if err := plugs.Encode(bb); err != nil {
    22  		return g, err
    23  	}
    24  
    25  	g.File(genny.NewFile(plugdeps.ConfigPath(opts.App), bb))
    26  	return g, nil
    27  }