mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
4266634752
- improves deprecation warning styles a bit so they caught the readers eye faster and are easier to read - warns if the user uses `builds.target` in conjunction with other options which are ignored in that case - improved env output - improved no configuration found warning some of the changes: <img width="1263" alt="CleanShot 2023-07-24 at 21 38 41@2x" src="https://github.com/goreleaser/goreleaser/assets/245435/40465853-7177-44d6-b07b-61b67590669a"> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
49 lines
1.2 KiB
Go
49 lines
1.2 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/goreleaser/goreleaser/internal/logext"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
)
|
|
|
|
const baseURL = "https://goreleaser.com/deprecations#"
|
|
|
|
// 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) {
|
|
// 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: logext.URL(url),
|
|
Property: logext.Keyword(property),
|
|
}); err != nil {
|
|
panic(err) // this should never happen
|
|
}
|
|
|
|
ctx.Deprecated = true
|
|
log.Warn(logext.Warning(out.String()))
|
|
}
|
|
|
|
type templateData struct {
|
|
URL string
|
|
Property string
|
|
}
|