-
-
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.
- Loading branch information
0 parents
commit a436b96
Showing
20 changed files
with
728 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [rsteube] | ||
polar: carapace-sh |
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,43 @@ | ||
name: Bug | ||
description: File a bug/issue | ||
title: "<title>" | ||
labels: [bug, fund] | ||
body: | ||
- type: textarea | ||
attributes: | ||
label: Current Behavior | ||
description: A concise description of what you're experiencing. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: Expected Behavior | ||
description: A concise description of what you expected to happen. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: Steps To Reproduce | ||
description: Steps to reproduce the behavior. | ||
placeholder: | | ||
1. In this environment... | ||
2. With this config... | ||
3. Run '...' | ||
4. See error... | ||
validations: | ||
required: false | ||
- type: input | ||
attributes: | ||
label: Version | ||
description: Version where this occured. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: Anything else? | ||
description: | | ||
Links? References? Anything that will give us more context about the issue you are encountering! | ||
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. | ||
validations: | ||
required: false |
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,26 @@ | ||
name: Request | ||
description: Submit a request | ||
title: "<title>" | ||
labels: [enhancement, fund] | ||
body: | ||
- type: textarea | ||
attributes: | ||
label: Request | ||
description: Describe the feature or problem you’d like to solve. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: Proposed solution | ||
description: How will it benefit the project and its users. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: Anything else? | ||
description: | | ||
Links? References? Anything that will give us more context about the request! | ||
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. | ||
validations: | ||
required: false |
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,16 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/cmd" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
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,50 @@ | ||
name: Go | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/carapace-sh/go:1.23.1 | ||
steps: | ||
- name: shallow clone | ||
uses: actions/checkout@v4 | ||
if: "!startsWith(github.ref, 'refs/tags/')" | ||
|
||
- name: deep clone | ||
uses: actions/checkout@v4 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: fix git safe.directory | ||
run: git config --global --add safe.directory '*' | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v -coverprofile=profile.cov ./... | ||
|
||
- name: "Check formatting" | ||
run: '[ "$(gofmt -d -s . | tee -a /dev/stderr)" = "" ]' | ||
|
||
- uses: shogo82148/actions-goveralls@v1 | ||
with: | ||
path-to-profile: profile.cov | ||
|
||
- name: "staticcheck" | ||
run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck ./... | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
AUR_KEY: ${{ secrets.AUR_KEY }} | ||
GORELEASER_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} |
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,39 @@ | ||
version: 2 | ||
before: | ||
hooks: | ||
- go mod download | ||
builds: | ||
- id: default | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
main: ./cmd/carapace-selfupdate | ||
binary: carapace-selfupdate | ||
- id: termux | ||
env: | ||
- CGO_ENABLED=1 | ||
goos: | ||
- android | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- arm | ||
- "386" | ||
main: ./cmd/carapace-selfupdate | ||
binary: carapace-selfupdate | ||
gobinary: go-termux | ||
archives: | ||
- id: default | ||
builds: | ||
- default | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
- id: termux | ||
builds: | ||
- termux | ||
name_template: '{{ .Binary }}_{{ .Version }}_termux_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' | ||
|
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 rsteube | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
# carapace-selfupdate |
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,22 @@ | ||
package selfupdate | ||
|
||
import ( | ||
"crypto/sha256" | ||
"io" | ||
"os" | ||
) | ||
|
||
//lint:ignore U1000 TODO | ||
func verify(path string) error { | ||
f, err := os.Open(path) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
|
||
h := sha256.New() | ||
if _, err := io.Copy(h, f); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
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 ( | ||
"github.com/carapace-sh/carapace" | ||
selfupdate "github.com/carapace-sh/carapace-selfupdate" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "carapace-selfupdate", | ||
Short: "", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute(version string) error { | ||
rootCmd.Version = version | ||
return rootCmd.Execute() | ||
} | ||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
cmd := selfupdate.Command("carapace-sh", "carapace-bin", selfupdate.WithBinary("carapace")) | ||
cmd.Use = "carapace" | ||
rootCmd.AddCommand(cmd) | ||
|
||
cmd = selfupdate.Command("carapace-sh", "carapace-bridge") | ||
cmd.Use = "bridge" | ||
rootCmd.AddCommand(cmd) | ||
|
||
cmd = selfupdate.Command("carapace-sh", "carapace-shlex") | ||
cmd.Use = "shlex" | ||
rootCmd.AddCommand(cmd) | ||
|
||
cmd = selfupdate.Command("carapace-sh", "carapace-spec") | ||
cmd.Use = "spec" | ||
rootCmd.AddCommand(cmd) | ||
|
||
} |
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,18 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/carapace-sh/carapace-selfupdate/cmd/carapace-selfupdate/cmd" | ||
) | ||
|
||
var commit, date string | ||
var version = "develop" | ||
|
||
func main() { | ||
if strings.Contains(version, "SNAPSHOT") { | ||
version += fmt.Sprintf(" (%v) [%v]", date, commit) | ||
} | ||
cmd.Execute(version) | ||
} |
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,18 @@ | ||
module github.com/carapace-sh/carapace-selfupdate/cmd | ||
|
||
go 1.23.1 | ||
|
||
require ( | ||
github.com/carapace-sh/carapace v1.5.0 | ||
github.com/carapace-sh/carapace-selfupdate v0.0.0-00010101000000-000000000000 | ||
github.com/spf13/cobra v1.8.1 | ||
) | ||
|
||
require ( | ||
github.com/carapace-sh/carapace-shlex v1.0.1 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
replace github.com/carapace-sh/carapace-selfupdate => ../ |
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,16 @@ | ||
github.com/carapace-sh/carapace v1.5.0 h1:rjNMTo5sY3YybMKbzEuaM19HEG6JXhvCTOrioV0QUHY= | ||
github.com/carapace-sh/carapace v1.5.0/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs= | ||
github.com/carapace-sh/carapace-shlex v1.0.1 h1:ww0JCgWpOVuqWG7k3724pJ18Lq8gh5pHQs9j3ojUs1c= | ||
github.com/carapace-sh/carapace-shlex v1.0.1/go.mod h1:lJ4ZsdxytE0wHJ8Ta9S7Qq0XpjgjU0mdfCqiI2FHx7M= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= | ||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= | ||
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= | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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,72 @@ | ||
package selfupdate | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-selfupdate/filter" | ||
"github.com/carapace-sh/carapace/pkg/style" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func Command(owner, repository string, opts ...option) *cobra.Command { | ||
opts = append([]option{ | ||
WithBinary(repository), | ||
WithAssetFilter(filter.Goreleaser(repository)), | ||
}, opts...) | ||
repo := map[string]string{ | ||
"stable": repository, | ||
"nightly": "nightly", | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "selfupdate [source] [tag] [asset]", | ||
Args: cobra.MinimumNArgs(3), // TODO implicit update to latest | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) > 2 { // TODO test | ||
c := New(owner, repo[args[0]], append([]option{WithProgress(cmd.ErrOrStderr())}, opts...)...) | ||
return c.Install(args[1], args[2]) | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().BoolP("all", "a", false, "show all tags/assets") | ||
// cmd.Flags().BoolP("force", "f", false, "force") // TODO force | ||
cmd.Flags().BoolP("help", "h", false, "help for selfupdate") // TODO use cobras help flag | ||
// cmd.Flags().Bool("no-verify", false, "disable checksum verification") // TODO disable verification | ||
|
||
carapace.Gen(cmd).Standalone() | ||
|
||
carapace.Gen(cmd).PositionalCompletion( | ||
carapace.ActionStyledValuesDescribed( | ||
"stable", fmt.Sprintf("https://github.com/%v/%v", owner, repository), style.Green, | ||
"nightly", fmt.Sprintf("https://github.com/%v/nightly", owner), style.Red, | ||
), | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
opts = append(opts, WithProgress(io.Discard)) | ||
if cmd.Flag("all").Changed { | ||
opts = append(opts, WithAssetFilter(nil)) | ||
} | ||
tags, err := New(owner, repo[c.Args[0]], opts...).Tags() | ||
if err != nil { | ||
return carapace.ActionMessage(err.Error()) | ||
} | ||
return carapace.ActionValues(tags...) | ||
}), | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
opts = append(opts, WithProgress(io.Discard)) | ||
if cmd.Flag("all").Changed { | ||
opts = append(opts, WithAssetFilter(nil)) | ||
} | ||
assets, err := New(owner, repo[c.Args[0]], opts...).Assets(c.Args[1]) | ||
if err != nil { | ||
return carapace.ActionMessage(err.Error()) | ||
} | ||
return carapace.ActionValues(assets...).StyleF(style.ForPathExt) | ||
}), | ||
) | ||
|
||
return cmd | ||
} |
Oops, something went wrong.