Skip to content

Commit

Permalink
Merge pull request #3 from BRO3886/master
Browse files Browse the repository at this point in the history
Add support for aggregating github user readmes
  • Loading branch information
BRO3886 authored Dec 10, 2020
2 parents cb71d47 + d8b417b commit 91bc99c
Show file tree
Hide file tree
Showing 8 changed files with 888 additions and 24 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ vendor/

# Binaries folder
bin/
config.env
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ windows:
linux:
@echo "Building for linux"
go build -o ./bin/linux/katamari
@ cd bin/linux && ./katamari
cd bin/linux && ./katamari
all:
@echo "Building for every OS and Platform"
GOOS=windows GOARCH=386 go build -o ./bin/windows/katamari.exe
GOOS=linux GOARCH=386 go build -o ./bin/linux/katamari
GOOS=freebsd GOARCH=386 go build -o ./bin/freebsd/katamari-bsd
GOOS=darwin GOARCH=amd64 go build -o ./bin/mac/katamari-mac
GOOS=freebsd GOARCH=386 go build -o ./bin/freebsd/katamari
GOOS=darwin GOARCH=amd64 go build -o ./bin/mac/katamari
@echo "Zipping for release"
@tar -czvf bin/releases/katamari_linux.tar.gz bin/linux/katamari LICENSE
@tar -czvf bin/releases/katamari_win.tar.gz bin/windows/katamari.exe LICENSE
@tar -czvf bin/releases/katamari_mac_amd64.tar.gz bin/mac/katamari LICENSE
@tar -czvf bin/releases/katamari_bsd.tar.gz bin/freebsd/katamari LICENSE
run:
go run .
global:
go install .

# do not use
release:
gh release create $v './bin/windows/katamari.exe' './bin/linux/katamari' './bin/mac/katamari-mac'
gh release create $v ${find /bin/releases -type f -printf "%f "}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# Functionality
- [x] Aggregate all your project READMEs into a single static site
- [x] Support for aggregating User READMEs also
- [x] Generate the static site using Hugo
- [x] Default theme set to "Ananke" (needs git)
- [x] Store GitHub Access Token in config
Expand Down Expand Up @@ -40,6 +41,10 @@ go get -u github.com/GDGVIT/katamari
```bash
katamari create <github organization name>
```
or
```bash
katamari create -u <your github username>
```

## Building the katamari project
```bash
Expand Down
41 changes: 31 additions & 10 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var buildCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
org := viper.GetString("site")

isUser := viper.GetBool("isuser")

if org == "" {
utils.Err("config", fmt.Sprintf("configuration not found! make sure you have a %s file in the "+
"project dir.", chalk.Green.Color(".katamari.toml")))
Expand All @@ -67,27 +69,46 @@ var buildCmd = &cobra.Command{
tc := oauth2.NewClient(ctx, ts)
client = github.NewClient(tc)
} else {
utils.Warn("Access Token Missing", "Set an access token in a .katamari/config.json, else you might be rate limited by GitHub [refer README]")
utils.Warn("config", "Access Token Missing. Set an access token in a .katamari/config.json, else you might be rate limited by GitHub [refer README]")
client = github.NewClient(nil)
}

opt := &github.RepositoryListByOrgOptions{
orgOpt := &github.RepositoryListByOrgOptions{
Type: "public",
ListOptions: github.ListOptions{PerPage: 50},
}

usrOpt := &github.RepositoryListOptions{
Type: "public",
ListOptions: github.ListOptions{PerPage: 50},
}

var allRepos []*github.Repository

for {
repos, resp, err := client.Repositories.ListByOrg(ctx, org, opt)
if err != nil {
utils.Err("enoent", err.Error())
if isUser {
for {
repos, resp, err := client.Repositories.List(ctx, org, usrOpt)
if err != nil {
utils.Err("enoent", err.Error())
}
allRepos = append(allRepos, repos...)
if resp.NextPage == 0 {
break
}
usrOpt.Page = resp.NextPage
}
allRepos = append(allRepos, repos...)
if resp.NextPage == 0 {
break
} else {
for {
repos, resp, err := client.Repositories.ListByOrg(ctx, org, orgOpt)
if err != nil {
utils.Err("enoent", err.Error())
}
allRepos = append(allRepos, repos...)
if resp.NextPage == 0 {
break
}
orgOpt.Page = resp.NextPage
}
opt.Page = resp.NextPage
}

if err != nil {
Expand Down
17 changes: 14 additions & 3 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,24 @@ import (

// createCmd represents the create command
var createCmd = &cobra.Command{
Use: "create [organization's github username]",
Use: "create [organization's/user's github username]",
Short: "Create a new katamari project",
Long: `Use this command to create a new project using katamari.
Example: katamari create gdgvit`,
Examples:
katamari create GDGVIT
katamari create -u BRO3886
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
utils.Info("sill", "Initializing a new katamari project...")
viper.Set("site", args[0])
viper.Set("theme", "ananke")
viper.Set("theme", "smol")

if isUser {
utils.Info("sill", fmt.Sprintf("creating katamari project for user %s", chalk.Green.Color(args[0])))
viper.Set("isUser", true)
}

hugoPath, err := exec.LookPath("hugo")
if err != nil {
Expand Down Expand Up @@ -125,6 +133,9 @@ var createCmd = &cobra.Command{
},
}

var isUser bool

func init() {
createCmd.Flags().BoolVarP(&isUser, "user", "u", false, "use this flag to aggregate READMEs for a User")
rootCmd.AddCommand(createCmd)
}
49 changes: 45 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,55 @@ module github.com/GDGVIT/katamari
go 1.15

require (
cloud.google.com/go v0.73.0 // indirect
code.gitea.io/sdk/gitea v0.13.2 // indirect
github.com/Azure/azure-storage-blob-go v0.12.0 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.9 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.5.5 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/Djarvur/go-err113 v0.1.0 // indirect
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/aws/aws-sdk-go v1.36.5 // indirect
github.com/daixiang0/gci v0.2.7 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/golangci/misspell v0.3.5 // indirect
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/google/go-github/v32 v32.1.0
github.com/google/rpmpack v0.0.0-20201206194719-59e495f2b7e1 // indirect
github.com/goreleaser/fileglob v0.3.1 // indirect
github.com/goreleaser/goreleaser v0.149.0 // indirect
github.com/gostaticanalysis/analysisutil v0.6.1 // indirect
github.com/hashicorp/go-retryablehttp v0.6.8 // indirect
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/spf13/cobra v1.0.0
github.com/matoous/godox v0.0.0-20200801072554-4fb83dc2941e // indirect
github.com/polyfloyd/go-errorlint v0.0.0-20201127212506-19bd8db6546f // indirect
github.com/quasilyte/go-ruleguard v0.2.1 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200805063351-8f842688393c // indirect
github.com/sassoftware/go-rpmutils v0.1.1 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/stretchr/objx v0.3.0 // indirect
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b // indirect
github.com/tetafro/godot v1.3.2 // indirect
github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94 // indirect
github.com/tomarrell/wrapcheck v0.0.0-20201130113247-1683564d9756 // indirect
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb // indirect
golang.org/x/oauth2 v0.0.0-20201207163604-931764155e3f
github.com/xanzy/go-gitlab v0.40.1 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
gocloud.dev v0.21.0 // indirect
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 // indirect
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
google.golang.org/genproto v0.0.0-20201209185603-f92720507ed4 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
mvdan.cc/gofumpt v0.0.0-20201129102820-5c11c50e9475 // indirect
)
Loading

0 comments on commit 91bc99c

Please sign in to comment.