├── README.md ├── github-star └── main.go ├── thank-you-stars.bat └── thank-you-stars.sh /README.md: -------------------------------------------------------------------------------- 1 | # thank-you-stars 2 | 3 | Star for dependency packages 4 | 5 | ## Usage 6 | 7 | ``` 8 | $ thank-you-stars 9 | ``` 10 | 11 | ## License 12 | 13 | MIT 14 | 15 | ## Author 16 | 17 | Yasuhiro Matsumoto (a.k.a. mattn) 18 | -------------------------------------------------------------------------------- /github-star/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log" 6 | "os" 7 | "strings" 8 | 9 | "github.com/google/go-github/github" 10 | "golang.org/x/oauth2" 11 | ) 12 | 13 | func main() { 14 | ctx := context.Background() 15 | ts := oauth2.StaticTokenSource( 16 | &oauth2.Token{AccessToken: os.Getenv("GITHUB_AUTH_TOKEN")}, 17 | ) 18 | client := github.NewClient(oauth2.NewClient(ctx, ts)) 19 | 20 | for _, arg := range os.Args[1:] { 21 | if !strings.HasPrefix(arg, "github.com/") { 22 | log.Fatal("unknown repository") 23 | } 24 | userrepo := strings.Split(arg[11:], "/") 25 | if len(userrepo) != 2 { 26 | log.Fatal("unknown repository") 27 | } 28 | resp, err := client.Activity.Star(ctx, userrepo[0], userrepo[1]) 29 | if err != nil { 30 | log.Fatal(err) 31 | } 32 | resp.Body.Close() 33 | if resp.StatusCode != 200 { 34 | log.Fatal(resp.Status) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /thank-you-stars.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal enabledelayedexpansion 4 | 5 | go get github.com/mattn/thank-you-stars/github-star 6 | set DEPS=go list -f "{{join .Deps \"\n\"}}" 7 | for /F %%i in ('%DEPS%') do ( 8 | set PKGLIST=go list -f "{{if not .Standard}}{{.ImportPath}}{{end}}" %%i ^| findstr "^github\.com/" 9 | for /F %%j in ('!PKGLIST!') do ( 10 | github-star %%j 11 | echo Stared %%j 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /thank-you-stars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | go get github.com/mattn/thank-you-stars/github-star 4 | go list -f '{{join .Deps "\n"}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | grep '^github\.com' | xargs -n 1 github-star 5 | --------------------------------------------------------------------------------