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

feat: Update releaser configs #97

Merged
merged 7 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
project_name: waku
report_sizes: true

version: 2

before:
hooks:
- go mod download
Expand Down Expand Up @@ -51,10 +53,17 @@ aurs:
install -Dm644 "./LICENSE" "$pkgdir/usr/share/licenses/$pkgname"

# completions
# not too sure how to provide them
install -Dm644 <(./waku compleetion bash") "$pkgdir/usr/share/bash-completion/completions/$pkgname"
install -Dm644 <(./waku compleetion zsh") "$pkgdir/usr/share/zsh/site-functions/_waku"
install -Dm644 <(./waku compleetion fish") "$pkgdir/usr/share/fish/completions/waku.fish"

# man page
# not too sure how to provide them
mkdir -p man1
./waku main man1
for manpage in "$srcdir/man1"/*.1; do
install -Dm644 "$manpage" -t "$pkgdir/usr/share/man/man1"
done

commit_author:
name: goreleaserbot
email: [email protected]
Expand All @@ -63,11 +72,16 @@ aurs:
dockers:
- image_templates:
- "caffeinec/waku:latest"
- "caffeinec/waku:{{ .Major }}"
- "caffeinec/waku:v{{ .Major }}"
- "caffeinec/waku:{{ .Tag }}"
- "ghcr.io/caffeine-addictt/waku:latest"
- "ghcr.io/caffeine-addictt/waku:{{ .Major }}"
- "ghcr.io/caffeine-addictt/waku:v{{ .Major }}"
- "ghcr.io/caffeine-addictt/waku:{{ .Tag }}"
extra_files:
- cmd/
- go.mod
- go.sum
- main.go
skip_push: false
dockerfile: Dockerfile
use: buildx
Expand Down Expand Up @@ -123,7 +137,7 @@ chocolateys:
require_license_acceptance: false
docs_url: https://github.com/caffeine-addictt/waku/blob/main/README.md
bug_tracker_url: https://github.com/caffeine-addictt/waku/issues
tags: "repository git generator simple quick quickstart template project project-generator"
tags: "repository git generator simple quick quickstart template project project-generator cli command-line go"
summary: "A simple template repository generator."
description: A simple template repository generator. Lets make starting new proejcts feel like a breeze again!
release_notes: "https://github.com/caffeine-addictt/waku/releases/tag/{{ .Tag }}"
Expand Down
40 changes: 40 additions & 0 deletions cmd/man.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cmd

import (
"os"
"path/filepath"

"github.com/caffeine-addictt/waku/cmd/utils"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var ManCmd = &cobra.Command{
Use: "man",
Short: "generate man pages",
Long: utils.MultilineString(
"Generate man pages for the command.",
"By default, man pages are generated in /usr/share/man/man1.",
),
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
dirPathDirty := "/usr/share/man/man1/"
if len(args) == 1 {
dirPathDirty = args[0]
}

dirPath := filepath.Clean(dirPathDirty)
if err := doc.GenManTree(RootCmd, &doc.GenManHeader{
Title: "Waku Command Reference",
Source: "Waku (waku!) 枠組み",
Section: "1",
}, dirPath); err != nil {
cmd.PrintErrf("could not create man pages: %v\n", err)
os.Exit(1)
}
},
}

func init() {
RootCmd.AddCommand(ManCmd)
}
7 changes: 6 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import (

"github.com/caffeine-addictt/waku/cmd/commands"
"github.com/caffeine-addictt/waku/cmd/options"
"github.com/caffeine-addictt/waku/cmd/utils"
"github.com/spf13/cobra"
)

// The Root command
var RootCmd = &cobra.Command{
Use: "waku",
Short: "let's make starting new projects feel like a breeze again",
Long: "This tool helps you to create a new project from templates.\n\nLet's make starting new projects feel like a breeze again.",
Long: utils.MultilineString(
"Waku helps you kickstart new projects from templates.",
"",
"Let's make starting new projects feel like a breeze again.",
),
}

// Setting up configuration
Expand Down
6 changes: 6 additions & 0 deletions cmd/utils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
"unicode"
)

// MultilineString provides a
// pleasing way to write multiline strings.
func MultilineString(s ...string) string {
return strings.Join(s, "\n")
}

// StringStartsWith returns true if the given string
// starts with the given string look, or if they start similarily.
func StringStartsWith(s, look string) bool {
Expand Down
21 changes: 21 additions & 0 deletions cmd/utils/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ import (
"github.com/stretchr/testify/assert"
)

func TestMultilineString(t *testing.T) {
tt := []struct {
out string
rule string
input []string
}{
{"Hello World\nHello World", "two lines", []string{"Hello World", "Hello World"}},
{"Hello World", "one line", []string{"Hello World"}},
{"", "empty", []string{}},
{"\n\n", "empty newlines", []string{"", "", ""}},
{"Hello World\nHello World", "newline character", []string{"Hello World\nHello World"}},
}

for _, tc := range tt {
t.Run(tc.rule, func(t *testing.T) {
got := utils.MultilineString(tc.input...)
assert.Equal(t, tc.out, got, tc.rule)
})
}
}

func TestStringStartsWith(t *testing.T) {
tt := []struct {
inputs [2]string
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/charmbracelet/x/ansi v0.2.3 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240829200707-9a7bd603a0d7 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
Expand All @@ -33,6 +34,7 @@ require (
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ github.com/charmbracelet/x/exp/strings v0.0.0-20240829200707-9a7bd603a0d7 h1:RR1
github.com/charmbracelet/x/exp/strings v0.0.0-20240829200707-9a7bd603a0d7/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -52,6 +53,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
Expand Down
Loading