mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
fe7e2123bd
* feat: replacing logs Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: tests et al Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * feat: update termenv/lipgloss Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * wip: output Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: pin dep Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: update Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: tests Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: tests Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: deps Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: dep Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Package deprecate provides simple functions to standardize the output
|
|
// of deprecation notices on goreleaser
|
|
package deprecate
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"text/template"
|
|
|
|
"github.com/caarlos0/log"
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
)
|
|
|
|
const baseURL = "https://goreleaser.com/deprecations#"
|
|
|
|
var warnStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("11")).Bold(true)
|
|
|
|
// Notice warns the user about the deprecation of the given property.
|
|
func Notice(ctx *context.Context, property string) {
|
|
NoticeCustom(ctx, property, "`{{ .Property }}` should not be used anymore, check {{ .URL }} for more info")
|
|
}
|
|
|
|
// NoticeCustom warns the user about the deprecation of the given property.
|
|
func NoticeCustom(ctx *context.Context, property, tmpl string) {
|
|
log.IncreasePadding()
|
|
defer log.DecreasePadding()
|
|
|
|
// replaces . and _ with -
|
|
url := baseURL + strings.NewReplacer(
|
|
".", "",
|
|
"_", "",
|
|
":", "",
|
|
" ", "-",
|
|
).Replace(property)
|
|
var out bytes.Buffer
|
|
if err := template.Must(template.New("deprecation").Parse("DEPRECATED: "+tmpl)).Execute(&out, templateData{
|
|
URL: url,
|
|
Property: property,
|
|
}); err != nil {
|
|
panic(err) // this should never happen
|
|
}
|
|
|
|
ctx.Deprecated = true
|
|
log.Warn(warnStyle.Render(out.String()))
|
|
}
|
|
|
|
type templateData struct {
|
|
URL string
|
|
Property string
|
|
}
|