This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move from markbates/pop to gobuffalo/pop (#933)
* wip r.Interface * renamed render.Interface to render.Auto * cleaned up tests for auto * Handle multiple types for resources fixes #389 * removed a few unneeded lines in the generated resource code * fixed broken test * wip moving to gobuffalo/pop * updated a dep * wip r.Interface * renamed render.Interface to render.Auto * cleaned up tests for auto * wip moving to gobuffalo/pop * Handle multiple types for resources fixes #389 * updated a dep * remove the unneeded go get willie call * Added a command to upgrade v0.10.3 to v0.11.0 * added updating of buffalo project dependencies * improved the updater to work a bit better
- Loading branch information
Showing
29 changed files
with
1,446 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gobuffalo/buffalo/buffalo/cmd/updater" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// updateCmd represents the info command | ||
var updateCmd = &cobra.Command{ | ||
Use: "update", | ||
Short: fmt.Sprintf("will attempt to upgrade a Buffalo application to version %s", Version), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
updater.Version = Version | ||
return updater.Run() | ||
}, | ||
} | ||
|
||
func init() { | ||
decorate("update", RootCmd) | ||
RootCmd.AddCommand(updateCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package updater | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/gobuffalo/envy" | ||
"github.com/markbates/deplist" | ||
"github.com/pkg/errors" | ||
"golang.org/x/sync/errgroup" | ||
) | ||
|
||
type lockToml struct { | ||
Name string `toml:"name"` | ||
Branch string `toml:"branch"` | ||
Packages []string `toml:"packages"` | ||
Revision string `toml:"revision"` | ||
Version string `toml:"version"` | ||
} | ||
|
||
func goGetUpdate(r *Runner) error { | ||
fmt.Println("~~~ Running go get ~~~") | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
wg, _ := errgroup.WithContext(ctx) | ||
deps, err := deplist.List() | ||
if err != nil { | ||
return errors.WithStack(err) | ||
} | ||
for dep := range deps { | ||
args := []string{"get", "-u"} | ||
args = append(args, dep) | ||
cc := exec.Command(envy.Get("GO_BIN", "go"), args...) | ||
f := func() error { | ||
cc.Stdin = os.Stdin | ||
cc.Stderr = os.Stderr | ||
cc.Stdout = os.Stdout | ||
return cc.Run() | ||
} | ||
wg.Go(f) | ||
} | ||
err = wg.Wait() | ||
if err != nil { | ||
return errors.Errorf("We encountered the following error trying to install and update the dependencies for this application:\n%s", err) | ||
} | ||
return nil | ||
} | ||
|
||
// DepEnsure runs `dep ensure -v` to make sure that any newly changed | ||
// imports are added to dep. | ||
func DepEnsure(r *Runner) error { | ||
if !r.App.WithDep { | ||
return goGetUpdate(r) | ||
} | ||
fmt.Println("~~~ Running dep ensure ~~~") | ||
cc := exec.Command("dep", "ensure", "-v") | ||
cc.Stdin = os.Stdin | ||
cc.Stderr = os.Stderr | ||
cc.Stdout = os.Stdout | ||
if err := cc.Run(); err != nil { | ||
return errors.WithStack(err) | ||
} | ||
|
||
for _, p := range []string{"github.com/gobuffalo/[email protected]", "github.com/gobuffalo/[email protected]"} { | ||
cc = exec.Command("dep", "ensure", "-v", "-add", p) | ||
cc.Stdin = os.Stdin | ||
cc.Stderr = os.Stderr | ||
cc.Stdout = os.Stdout | ||
if err := cc.Run(); err != nil { | ||
return errors.WithStack(err) | ||
} | ||
} | ||
|
||
for _, p := range []string{"github.com/markbates/inflect"} { | ||
cc = exec.Command("dep", "ensure", "-v", "-update", p) | ||
cc.Stdin = os.Stdin | ||
cc.Stderr = os.Stderr | ||
cc.Stdout = os.Stdout | ||
if err := cc.Run(); err != nil { | ||
return errors.WithStack(err) | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package updater | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// DeprecrationsCheck will either log, or fix, deprecated items in the application | ||
func DeprecrationsCheck(r *Runner) error { | ||
fmt.Println("~~~ Checking for deprecations ~~~") | ||
b, err := ioutil.ReadFile("main.go") | ||
if err != nil { | ||
return errors.WithStack(err) | ||
} | ||
if bytes.Contains(b, []byte("app.Start")) { | ||
r.Warnings = append(r.Warnings, "app.Start has been removed in v0.11.0. Use app.Serve Instead. [main.go]") | ||
} | ||
|
||
return filepath.Walk(filepath.Join(r.App.Root, "actions"), func(path string, info os.FileInfo, err error) error { | ||
if info.IsDir() { | ||
return nil | ||
} | ||
|
||
if filepath.Ext(path) != ".go" { | ||
return nil | ||
} | ||
|
||
b, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return errors.WithStack(err) | ||
} | ||
if bytes.Contains(b, []byte("Websocket()")) { | ||
r.Warnings = append(r.Warnings, fmt.Sprintf("buffalo.Context#Websocket has been deprecated in v0.11.0. Use github.com/gorilla/websocket directly. [%s]", path)) | ||
} | ||
|
||
return nil | ||
}) | ||
} |
Oops, something went wrong.