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 575
/
shoulders.go
executable file
·92 lines (80 loc) · 2.27 KB
/
shoulders.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package grifts
import (
"fmt"
"html/template"
"os"
"os/exec"
"path"
"sort"
"strings"
"github.com/gobuffalo/envy"
"github.com/markbates/deplist"
"github.com/markbates/grift/grift"
)
var _ = grift.Desc("shoulders", "Prints a listing all of the 3rd party packages used by buffalo.")
var _ = grift.Add("shoulders:list", func(c *grift.Context) error {
giants, _ := deplist.List("examples")
for _, k := range []string{
"github.com/markbates/refresh",
"github.com/markbates/grift",
"github.com/markbates/pop",
"github.com/spf13/cobra",
"github.com/motemen/gore",
"golang.org/x/tools/cmd/goimports",
} {
giants[k] = k
}
deps := make([]string, 0, len(giants))
for k := range giants {
if !strings.Contains(k, "github.com/gobuffalo/buffalo") {
deps = append(deps, k)
}
}
sort.Strings(deps)
fmt.Println(strings.Join(deps, "\n"))
c.Set("giants", deps)
return nil
})
var _ = grift.Desc("shoulders", "Generates a file listing all of the 3rd party packages used by buffalo.")
var _ = grift.Add("shoulders", func(c *grift.Context) error {
err := grift.Run("shoulders:list", c)
if err != nil {
return err
}
f, err := os.Create(path.Join(envy.GoPath(), "src", "github.com", "gobuffalo", "buffalo", "SHOULDERS.md"))
if err != nil {
return err
}
t, err := template.New("").Parse(shouldersTemplate)
if err != nil {
return err
}
err = t.Execute(f, c.Get("giants"))
if err != nil {
return err
}
return commitAndPushShoulders()
})
func commitAndPushShoulders() error {
cmd := exec.Command("git", "commit", "SHOULDERS.md", "-m", "Updated SHOULDERS.md")
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
err := cmd.Run()
if err != nil {
return err
}
cmd = exec.Command("git", "push", "origin")
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
return cmd.Run()
}
var shouldersTemplate = `
# Buffalo Stands on the Shoulders of Giants
Buffalo does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them altogether in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work.
Thank you to the following **GIANTS**:
{{ range $v := .}}
* [{{$v}}](https://{{$v}})
{{ end }}
`