github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/plugins/tools/refresh/initializer.go (about) 1 package refresh 2 3 import ( 4 "context" 5 "errors" 6 "fmt" 7 "path/filepath" 8 "time" 9 10 "github.com/gobuffalo/refresh/refresh" 11 "github.com/spf13/pflag" 12 "github.com/wawandco/ox/plugins/base/new" 13 ) 14 15 var ( 16 // the filename we will use for the generated yml. 17 filename = `.buffalo.dev.yml` 18 19 ErrNameRequired = errors.New("name argument is required") 20 ErrIncompleteArgs = errors.New("incomplete args") 21 ) 22 23 type Initializer struct{} 24 25 func (i Initializer) Name() string { 26 return "refresh/initializer" 27 } 28 29 func (i *Initializer) Initialize(ctx context.Context, options new.Options) error { 30 rootYML := filepath.Join(options.Folder, filename) 31 32 config := refresh.Configuration{ 33 AppRoot: ".", 34 BuildTargetPath: "." + string(filepath.Separator) + filepath.Join(".", "cmd", options.Name), 35 BuildPath: "bin", 36 BuildDelay: 200 * time.Nanosecond, 37 BinaryName: fmt.Sprintf("tmp-%v-build", options.Name), 38 IgnoredFolders: []string{ 39 "vendor", 40 "log", 41 "logs", 42 "assets", 43 "public", 44 "grifts", 45 "tmp", 46 "bin", 47 "node_modules", 48 ".sass-cache", 49 }, 50 51 IncludedExtensions: []string{".go", ".env"}, 52 EnableColors: true, 53 LogName: "ox", 54 } 55 56 err := config.Dump(rootYML) 57 if err != nil { 58 return err 59 } 60 61 return nil 62 } 63 64 func (i *Initializer) ParseFlags([]string) {} 65 func (i *Initializer) Flags() *pflag.FlagSet { 66 return pflag.NewFlagSet("refresh-initializer", pflag.ContinueOnError) 67 }