2018-02-17 17:43:29 +02:00
|
|
|
// Package deprecate provides simple functions to standardize the output
|
|
|
|
// of deprecation notices on goreleaser
|
|
|
|
package deprecate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
|
|
|
"github.com/apex/log/handlers/cli"
|
|
|
|
"github.com/fatih/color"
|
2020-04-12 19:31:35 +02:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2018-02-17 17:43:29 +02:00
|
|
|
)
|
|
|
|
|
2018-05-01 05:58:10 +02:00
|
|
|
const baseURL = "https://goreleaser.com/deprecations#"
|
2018-02-17 17:43:29 +02:00
|
|
|
|
|
|
|
// Notice warns the user about the deprecation of the given property
|
2020-04-12 19:31:35 +02:00
|
|
|
func Notice(ctx *context.Context, property string) {
|
|
|
|
ctx.Deprecated = true
|
2018-02-17 17:43:29 +02:00
|
|
|
cli.Default.Padding += 3
|
|
|
|
defer func() {
|
|
|
|
cli.Default.Padding -= 3
|
|
|
|
}()
|
2018-05-01 05:58:10 +02:00
|
|
|
// replaces . and _ with -
|
|
|
|
url := baseURL + strings.NewReplacer(
|
|
|
|
".", "-",
|
|
|
|
"_", "-",
|
|
|
|
).Replace(property)
|
2018-02-17 17:43:29 +02:00
|
|
|
log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf(
|
|
|
|
"DEPRECATED: `%s` should not be used anymore, check %s for more info.",
|
|
|
|
property,
|
|
|
|
url,
|
|
|
|
))
|
|
|
|
}
|