Skip to content

Commit

Permalink
Output deprecation notice from main instead of projectfile package.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Jun 10, 2024
1 parent 212868e commit 7742c3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
5 changes: 3 additions & 2 deletions cmd/state/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ func run(args []string, isInteractive bool, cfg *config.Instance, out output.Out
return logData
})

projectfile.RegisterOutputer(out) // note: this needs to be done before using auth

auth := authentication.New(cfg)
defer events.Close("auth", auth.Close)

Expand All @@ -174,6 +172,9 @@ func run(args []string, isInteractive bool, cfg *config.Instance, out output.Out
projectfile.RegisterMigrator(migrator.NewMigrator(auth, cfg))

// Retrieve project file
if os.Getenv("ACTIVESTATE_PROJECT") != "" {
out.Notice(locale.T("warning_activestate_project_env_var"))
}
pjPath, err := projectfile.GetProjectFilePath()
if err != nil && errs.Matches(err, &projectfile.ErrorNoProjectFromEnv{}) {
// Fail if we are meant to inherit the projectfile from the environment, but the file doesn't exist
Expand Down
16 changes: 0 additions & 16 deletions pkg/projectfile/projectfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/ActiveState/cli/internal/logging"
"github.com/ActiveState/cli/internal/multilog"
"github.com/ActiveState/cli/internal/osutils"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/profile"
"github.com/ActiveState/cli/internal/rollbar"
"github.com/ActiveState/cli/internal/rtutils"
Expand Down Expand Up @@ -66,14 +65,6 @@ func RegisterMigrator(m MigratorFunc) {
migrator = m
}

var out output.Outputer

// RegisterOutputer registers the outputer this package uses for outputing things like deprecation
// warnings.
func RegisterOutputer(o output.Outputer) {
out = o
}

type ErrorParseProject struct{ *locale.LocalizedError }

type ErrorNoProject struct{ *locale.LocalizedError }
Expand Down Expand Up @@ -821,16 +812,9 @@ func GetProjectFilePath() (string, error) {
return "", &ErrorNoProject{locale.NewInputError("err_no_projectfile")}
}

var printedActiveStateProjectDeprecationNotice = false

func getProjectFilePathFromEnv() (string, error) {
var projectFilePath string

if legacy := os.Getenv("ACTIVESTATE_PROJECT"); legacy != "" && !printedActiveStateProjectDeprecationNotice {
out.Notice(locale.T("warning_activestate_project_env_var"))
printedActiveStateProjectDeprecationNotice = true
}

if activatedProjectDirPath := os.Getenv(constants.ActivatedStateEnvVarName); activatedProjectDirPath != "" {
projectFilePath = filepath.Join(activatedProjectDirPath, constants.ConfigFileName)
}
Expand Down

0 comments on commit 7742c3a

Please sign in to comment.