Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: (DSP-2004) Apply good practice to code #6

Merged
merged 8 commits into from
Aug 27, 2024
Merged
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ jobs:
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}
--to ${{ github.event.pull_request.head.sha }}
--verbose

- name: 🔎 Validate PR title with commitlint
run: echo "${{ github.event.pull_request.title }}" | npx commitlint
71 changes: 0 additions & 71 deletions .release-it.json

This file was deleted.

8 changes: 5 additions & 3 deletions cmd/create_comment.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package cmd

import (
commentGithub "github.com/gbh-tech/github-pr-commenter/src"

"github.com/charmbracelet/log"
"github.com/spf13/cobra"
)

Expand All @@ -18,7 +17,10 @@ var createCommentPrCmd = &cobra.Command{
content, _ := cmd.Flags().GetString("content")
filePath, _ := cmd.Flags().GetString("filePath")

commentGithub.CreateComment(pull, org, repo, content, filePath)
_, err := GithubClient.CreateComment(pull, org, repo, content, filePath)
if err != nil {
log.Fatalf("Error: %v\n", err)
}
},
}

Expand Down
9 changes: 7 additions & 2 deletions cmd/get_comment.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package cmd

import (
commentGithub "github.com/gbh-tech/github-pr-commenter/src"
"fmt"

"github.com/charmbracelet/log"
"github.com/spf13/cobra"
)

Expand All @@ -17,7 +18,11 @@ var getCommentPrCmd = &cobra.Command{
content, _ := cmd.Flags().GetString("content")
filePath, _ := cmd.Flags().GetString("filePath")

commentGithub.GetUserComments(pull, org, repo, content, filePath)
commentID, err := GithubClient.GetUserComments(pull, org, repo, content, filePath)
if err != nil {
log.Fatalf("Error: %v\n", err)
}
fmt.Printf("%v", commentID)
},
}

Expand Down
11 changes: 11 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ package cmd
import (
"os"

commentGithub "github.com/gbh-tech/github-pr-commenter/src/comments"

"github.com/charmbracelet/log"
"github.com/spf13/cobra"
)

var GithubClient commentGithub.GithubClient

var RootCmd = &cobra.Command{
Use: "commenter",
Short: "A CLI to perform operation on GitHub PR issues.",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
token := os.Getenv("GITHUB_TOKEN")
err := commentGithub.NewClient(token, &GithubClient)
if err != nil {
log.Fatalf("Error initializing GitHub client: %v", err)
}
},
}

func init() {
Expand Down
8 changes: 5 additions & 3 deletions cmd/update_comment.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package cmd

import (
commentGithub "github.com/gbh-tech/github-pr-commenter/src"

"github.com/charmbracelet/log"
"github.com/spf13/cobra"
)

Expand All @@ -17,7 +16,10 @@ var updateCommentPrCmd = &cobra.Command{
filePath, _ := cmd.Flags().GetString("filePath")
commentID, _ := cmd.Flags().GetInt64("commentID")

commentGithub.UpdateComment(commentID, org, repo, content, filePath)
_, err := GithubClient.UpdateComment(commentID, org, repo, content, filePath)
if err != nil {
log.Fatalf("Error: %v\n", err)
}
javiercm1410 marked this conversation as resolved.
Show resolved Hide resolved
},
}

Expand Down
1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

77 changes: 77 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,82 @@
"commitlint": "^19.2.1",
"husky": "^9.0.11",
"release-it": "^17.3.0"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
],
"defaultIgnores": true
},
"release-it": {
"github": {
"release": false,
"releaseName": "v${version}"
},
"git": {
"commitMessage": "chore: release v${version}",
"tagMatch": "v[0-9]*\\.[0-9]*\\.[0-9]*",
"tagName": "v${version}",
"getLatestTagFromAllRefs": true,
"tagExclude": "*[-]*",
"push": true,
"release": true,
"pushArgs": ["--no-verify", "--follow-tags", "--force"],
"commitArgs": ["--no-verify"]
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": {
"name": "conventionalcommits",
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Miscellaneous"
},
{
"type": "docs",
"section": "Miscellaneous"
},
{
"type": "style",
"section": "Miscellaneous"
},
{
"type": "refactor",
"section": "Miscellaneous"
},
{
"type": "perf",
"section": "Miscellaneous"
},
{
"type": "test",
"section": "Miscellaneous"
},
{
"type": "build",
"section": "Miscellaneous"
},
{
"type": "revert",
"section": "Miscellaneous"
},
{
"type": "ci",
"section": "Miscellaneous"
}
]
},
"infile": "CHANGELOG.md"
}
}
}
}
88 changes: 0 additions & 88 deletions src/comments.go

This file was deleted.

Loading
Loading