github.com/amane3/goreleaser@v0.182.0/internal/deprecate/deprecate.go (about)

     1  // Package deprecate provides simple functions to standardize the output
     2  // of deprecation notices on goreleaser
     3  package deprecate
     4  
     5  import (
     6  	"strings"
     7  
     8  	"github.com/amane3/goreleaser/pkg/context"
     9  	"github.com/apex/log"
    10  	"github.com/apex/log/handlers/cli"
    11  	"github.com/fatih/color"
    12  )
    13  
    14  const baseURL = "https://goreleaser.com/deprecations#"
    15  
    16  // Notice warns the user about the deprecation of the given property.
    17  func Notice(ctx *context.Context, property string) {
    18  	ctx.Deprecated = true
    19  	cli.Default.Padding += 3
    20  	defer func() {
    21  		cli.Default.Padding -= 3
    22  	}()
    23  	// replaces . and _ with -
    24  	url := baseURL + strings.NewReplacer(
    25  		".", "",
    26  		"_", "",
    27  	).Replace(property)
    28  	log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf(
    29  		"DEPRECATED: `%s` should not be used anymore, check %s for more info.",
    30  		property,
    31  		url,
    32  	))
    33  }