-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from cacoco/cacoco/UpateJSONScanning
Major updates, fixes and more tests
- Loading branch information
Showing
53 changed files
with
3,264 additions
and
1,558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*.so | ||
*.dylib | ||
bin/ | ||
dist/ | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
|
||
# The lines below are called `modelines`. See `:help modeline` | ||
# Feel free to remove those if you don't want/need to use them. | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
version: 1 | ||
|
||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cacoco/codemetagenerator/internal/model" | ||
"github.com/cacoco/codemetagenerator/internal/utils" | ||
"github.com/onsi/gomega" | ||
) | ||
|
||
func TestNewAuthor(t *testing.T) { | ||
g := gomega.NewWithT(t) | ||
|
||
var stack utils.Stack[string] | ||
stack.Push("id\n") | ||
stack.Push("person@email.org\n") | ||
stack.Push("familyName\n") | ||
stack.Push("givenName\n") | ||
stack.Push("\n") // enter to select the first option | ||
reader := utils.TestReader{In: utils.TestStdin{Data: stack}} | ||
writer := utils.TestWriter{} | ||
|
||
author, err := newAuthor(&reader, &writer) | ||
if author == nil { | ||
t.Errorf("Expected author to not be nil") | ||
} | ||
if err != nil { | ||
t.Errorf("Unexpected error: %v", err) | ||
} | ||
expected := map[string]any{ | ||
model.Type: model.PersonType, | ||
model.FamilyName: "familyName", | ||
model.GivenName: "givenName", | ||
model.Email: "person@email.org", | ||
model.Id: "id", | ||
} | ||
g.Ω(*author).Should(gomega.Equal(expected)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/cacoco/codemetagenerator/internal/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func clean(basedir string, writer utils.Writer) error { | ||
codemetageneratorHomeDir := utils.GetHomeDir(basedir) | ||
if _, err := os.Stat(codemetageneratorHomeDir); err == nil { | ||
err := os.RemoveAll(codemetageneratorHomeDir) | ||
if err != nil { | ||
return fmt.Errorf("unable to remove codemetagenerator home directory: %s", err.Error()) | ||
} | ||
writer.Println("✅ Successfully cleaned the $HOME/.codemetagenerator directory.") | ||
} | ||
return nil | ||
} | ||
|
||
// cleanCmd represents the clean command | ||
var cleanCmd = &cobra.Command{ | ||
Use: "clean", | ||
Args: cobra.NoArgs, | ||
Short: "Clean the $HOME/.codemetagenerator directory", | ||
Long: `Removes the $HOME/.codemetagenerator directory used to store the in-progress | ||
codemeta.json file.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return clean(utils.UserHomeDir, &utils.StdoutWriter{}) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(cleanCmd) | ||
} |
Oops, something went wrong.