Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Adding packr files (#1956)
Browse files Browse the repository at this point in the history
  • Loading branch information
paganotoni authored Apr 13, 2020
1 parent 0a8d59f commit c335d58
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 47 deletions.
5 changes: 3 additions & 2 deletions buffalo/cmd/fix/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ var checks = []Check{
DeprecrationsCheck,
fixDocker,
encodeApp,
removeOldPlugins,
Plugins,
Plugins{}.RemoveOld,
Plugins{}.CleanCache,
Plugins{}.Reinstall,
Plush,
}

Expand Down
28 changes: 12 additions & 16 deletions buffalo/cmd/fix/plugins.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package fix

import (
"bytes"
"context"
"fmt"
"os"
"path"
"strings"

cmdPlugins "github.com/gobuffalo/buffalo/buffalo/cmd/plugins"
"github.com/gobuffalo/buffalo/genny/plugins/install"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins"
Expand All @@ -16,10 +16,17 @@ import (
"github.com/gobuffalo/meta"
)

// Plugins will fix plugins between releases
func Plugins(r *Runner) error {
type Plugins struct{}

//CleanCache cleans the plugins cache folder by removing it
func (pf Plugins) CleanCache(r *Runner) error {
fmt.Println("~~~ Cleaning plugins cache ~~~")
os.RemoveAll(plugins.CachePath)
return nil
}

//Reinstall installs latest versions of the plugins
func (pf Plugins) Reinstall(r *Runner) error {
plugs, err := plugdeps.List(r.App)
if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) {
return err
Expand All @@ -37,8 +44,7 @@ func Plugins(r *Runner) error {
return run.Run()
}

// removeOldPlugins will remove old Pop plugin
func removeOldPlugins(r *Runner) error {
func (pf Plugins) RemoveOld(r *Runner) error {
fmt.Println("~~~ Removing old plugins ~~~")

run := genny.WetRunner(context.Background())
Expand All @@ -57,17 +63,7 @@ func removeOldPlugins(r *Runner) error {

fmt.Println("~~~ Removing github.com/gobuffalo/buffalo-pop plugin ~~~")

run.WithRun(func(r *genny.Runner) error {
p := plugdeps.ConfigPath(app)
bb := &bytes.Buffer{}
if err := plugs.Encode(bb); err != nil {
return err
}
return r.File(genny.NewFile(p, bb))
})
if err != nil {
return err
}
run.WithRun(cmdPlugins.NewEncodePluginsRunner(app, plugs))

return run.Run()
}
22 changes: 22 additions & 0 deletions buffalo/cmd/plugins/encode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package plugins

import (
"bytes"

"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/meta"
)

// NewEncodePluginsRunner will return a runner that will encode the plugins file
func NewEncodePluginsRunner(app meta.App, plugs *plugdeps.Plugins) func(r *genny.Runner) error {
return func(r *genny.Runner) error {
p := plugdeps.ConfigPath(app)
bb := &bytes.Buffer{}
if err := plugs.Encode(bb); err != nil {
return err
}

return r.File(genny.NewFile(p, bb))
}
}
14 changes: 1 addition & 13 deletions buffalo/cmd/plugins/remove.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plugins

import (
"bytes"
"context"
"fmt"
"path"
Expand Down Expand Up @@ -46,18 +45,7 @@ var removeCmd = &cobra.Command{
})
}

run.WithRun(func(r *genny.Runner) error {
p := plugdeps.ConfigPath(app)
bb := &bytes.Buffer{}
if err := plugs.Encode(bb); err != nil {
return err
}
return r.File(genny.NewFile(p, bb))
})
if err != nil {
return err
}

run.WithRun(NewEncodePluginsRunner(app, plugs))
return run.Run()
},
}
Expand Down
8 changes: 0 additions & 8 deletions genny/assets/webpack/webpack-packr.go

This file was deleted.

8 changes: 0 additions & 8 deletions genny/build/build-packr.go

This file was deleted.

0 comments on commit c335d58

Please sign in to comment.