2018-02-17 13: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 14:31:35 -03:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2018-02-17 13:43:29 -02:00
|
|
|
)
|
|
|
|
|
2018-04-30 20:58:10 -07:00
|
|
|
const baseURL = "https://goreleaser.com/deprecations#"
|
2018-02-17 13:43:29 -02:00
|
|
|
|
2020-05-26 00:48:10 -03:00
|
|
|
// Notice warns the user about the deprecation of the given property.
|
2020-04-12 14:31:35 -03:00
|
|
|
func Notice(ctx *context.Context, property string) {
|
|
|
|
ctx.Deprecated = true
|
2018-02-17 13:43:29 -02:00
|
|
|
cli.Default.Padding += 3
|
|
|
|
defer func() {
|
|
|
|
cli.Default.Padding -= 3
|
|
|
|
}()
|
2018-04-30 20:58:10 -07:00
|
|
|
// replaces . and _ with -
|
|
|
|
url := baseURL + strings.NewReplacer(
|
2020-07-06 14:48:17 +01:00
|
|
|
".", "",
|
|
|
|
"_", "",
|
2018-04-30 20:58:10 -07:00
|
|
|
).Replace(property)
|
2018-02-17 13: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,
|
|
|
|
))
|
|
|
|
}
|