Skip to content

Commit

Permalink
Merge pull request #25 from kaypee90/add-label-option
Browse files Browse the repository at this point in the history
feat: add option to create a label
  • Loading branch information
kaypee90 authored Oct 6, 2024
2 parents 75c67e0 + 93f7f90 commit 8aa1212
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ updates:
reviewers:
- kaypee90
open-pull-requests-limit: 5
labels:
- go mod
16 changes: 14 additions & 2 deletions cmd/depbot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
)

const version = "0.4.0"
const version = "0.5.0"

func displayAppVersion() {
fmt.Printf("Depbot %s\n", version)
Expand Down Expand Up @@ -45,20 +45,32 @@ func launchApplicaton() {
interval, err := getInterval()
handlePromptError(err)

var reviewers []string
reviewer, err := getReviewer()
handlePromptError(err)
if reviewer != "" {
reviewers = append(reviewers, reviewer)
}

openPullRequestsLimit, err := getOpenPullRequestLimit()
handlePromptError(err)

var labels []string
label, err := getLabel()
handlePromptError(err)
if label != "" {
labels = append(labels, label)
}

updates = append(updates, Update{
PackageEcosystem: packageEcosystem,
Directory: directory,
Schedule: Schedule{
Interval: interval,
},
Reviewers: []string{reviewer},
Reviewers: reviewers,
OpenPullRequestsLimit: openPullRequestsLimit,
Labels: labels,
})

if result, err := addAdditionalPackageManager(); err != nil || result == NO {
Expand Down
5 changes: 3 additions & 2 deletions cmd/depbot/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ type Update struct {
Directory string `yaml:"directory"`
Schedule Schedule `yaml:"schedule"`
Reviewers []string `yaml:"reviewers,omitempty"`
OpenPullRequestsLimit int `yaml:"open-pull-requests-limit,omitempty"`
OpenPullRequestsLimit uint64 `yaml:"open-pull-requests-limit,omitempty"`
Labels []string `yaml:"labels,omitempty"`
}

type Config struct {
Version int `yaml:"version"`
Version uint8 `yaml:"version"`
Updates []Update `yaml:"updates"`
}

Expand Down
27 changes: 20 additions & 7 deletions cmd/depbot/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (
"github.com/manifoldco/promptui"
)

const YES = "yes"
const NO = "no"
const (
YES = "yes"
NO = "no"
)

func getConfigurationOverrideConfirmation() (string, error) {
prompt := promptui.Select{
Expand All @@ -23,10 +25,12 @@ func getConfigurationOverrideConfirmation() (string, error) {
func getPackageEcosystem() (string, error) {
prompt := promptui.Select{
Label: "Select Package Ecosystem",
Items: []string{"cargo", "docker", "gomod", "gradle", "maven",
Items: []string{
"cargo", "docker", "gomod", "gradle", "maven",
"npm", "nuget", "pip", "poetry", "swift", "terraform",
"bundler", "composer", "devcontainers", "elm",
"gitsubmodule", "github-actions", "mix", "pub"},
"gitsubmodule", "github-actions", "mix", "pub",
},
}

_, result, err := prompt.Run()
Expand Down Expand Up @@ -66,25 +70,34 @@ func getReviewer() (string, error) {
return result, err
}

func getOpenPullRequestLimit() (int, error) {
func getOpenPullRequestLimit() (uint64, error) {
prompt := promptui.Prompt{
Label: "Provide Open Pull Request Limit (optional)",
}

result, err := prompt.Run()

if err != nil {
return 0, err
}

limit, err := strconv.Atoi(result)
limit, err := strconv.ParseUint(result, 10, 32)
if err != nil {
return 5, nil
}

return limit, nil
}

func getLabel() (string, error) {
prompt := promptui.Prompt{
Label: "Provide Label (optional)",
}

result, err := prompt.Run()

return result, err
}

func addAdditionalPackageManager() (string, error) {
prompt := promptui.Select{
Label: "Do you want to add another package manager?",
Expand Down
Binary file added depbot
Binary file not shown.

0 comments on commit 8aa1212

Please sign in to comment.