Skip to content

Commit

Permalink
Merge branch 'version/0-48-0-RC1' into mitchell/dx-3178-2
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Jan 2, 2025
2 parents f34443f + 245e064 commit fb5432e
Show file tree
Hide file tree
Showing 268 changed files with 7,248 additions and 8,872 deletions.
5 changes: 5 additions & 0 deletions activestate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ scripts:
TARGET_BRANCH="master"
fi
if [ "$TARGET_BRANCH" == "master" ]; then
echo "Target branch is master, not checking for newlines"
exit 0
fi
git fetch --quiet origin $TARGET_BRANCH:refs/remotes/origin/$TARGET_BRANCH
CHANGED=$(git diff --name-only origin/$TARGET_BRANCH | grep -v testdata | grep -v vendor)
Expand Down
2 changes: 1 addition & 1 deletion cmd/state-installer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func main() {
OutWriter: os.Stdout,
ErrWriter: os.Stderr,
Colored: true,
Interactive: false,
Interactive: term.IsTerminal(int(os.Stdin.Fd())),
})
if err != nil {
multilog.Critical("Could not set up output handler: " + errs.JoinMessage(err))
Expand Down
15 changes: 11 additions & 4 deletions cmd/state-installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ func (i *Installer) Install() (rerr error) {
if err != nil {
return errs.Wrap(err, "Could not determine if running as Windows administrator")
}
if isAdmin && !i.Params.force && !i.Params.isUpdate && !i.Params.nonInteractive {
prompter := prompt.New(true, i.an)
confirm, err := prompter.Confirm("", locale.T("installer_prompt_is_admin"), ptr.To(false))
if isAdmin && !i.Params.isUpdate {
prompter := prompt.New(i.out, i.an)
if i.Params.nonInteractive {
prompter.SetInteractive(false)
}
if i.Params.force {
prompter.SetForce(true)
}
defaultChoice := i.Params.nonInteractive
confirm, err := prompter.Confirm("", locale.T("installer_prompt_is_admin"), &defaultChoice, ptr.To(true))
if err != nil {
return errs.Wrap(err, "Unable to confirm")
return errs.Wrap(err, "Not confirmed")
}
if !confirm {
return locale.NewInputError("installer_aborted", "Installation aborted by the user")
Expand Down
3 changes: 3 additions & 0 deletions cmd/state-installer/test/integration/installer_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (suite *InstallerIntegrationTestSuite) TestInstallFromLocalSource() {

// Assert output
cp.Expect("Installing State Tool")
if runtime.GOOS == "windows" {
cp.Expect("Continuing because State Tool is running in non-interactive mode") // admin prompt
}
cp.Expect("Done")
cp.Expect("successfully installed")
suite.NotContains(cp.Output(), "Downloading State Tool")
Expand Down
13 changes: 9 additions & 4 deletions cmd/state-remote-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ActiveState/cli/internal/runbits/errors"
"github.com/ActiveState/cli/internal/runbits/panics"
"github.com/ActiveState/cli/internal/updater"
"golang.org/x/term"
)

type Params struct {
Expand Down Expand Up @@ -90,7 +91,7 @@ func main() {
OutWriter: os.Stdout,
ErrWriter: os.Stderr,
Colored: true,
Interactive: false,
Interactive: term.IsTerminal(int(os.Stdin.Fd())),
})
if err != nil {
logging.Error("Could not set up output handler: " + errs.JoinMessage(err))
Expand All @@ -116,7 +117,7 @@ func main() {
an = sync.New(anaConst.SrcStateRemoteInstaller, cfg, nil, out)

// Set up prompter
prompter := prompt.New(true, an)
prompter := prompt.New(out, an)

params := newParams()
cmd := captain.NewCommand(
Expand Down Expand Up @@ -172,11 +173,15 @@ func main() {
}

func execute(out output.Outputer, prompt prompt.Prompter, cfg *config.Instance, an analytics.Dispatcher, args []string, params *Params) error {
if params.nonInteractive {
prompt.SetInteractive(false)
}
defaultChoice := params.nonInteractive
msg := locale.Tr("tos_disclaimer", constants.TermsOfServiceURLLatest)
msg += locale.Tr("tos_disclaimer_prompt", constants.TermsOfServiceURLLatest)
cont, err := prompt.Confirm(locale.Tr("install_remote_title"), msg, ptr.To(true))
cont, err := prompt.Confirm(locale.Tr("install_remote_title"), msg, &defaultChoice, nil)
if err != nil {
return errs.Wrap(err, "Could not prompt for confirmation")
return errs.Wrap(err, "Not confirmed")
}

if !cont {
Expand Down
205 changes: 0 additions & 205 deletions cmd/state-svc/internal/messages/messages.go

This file was deleted.

Loading

0 comments on commit fb5432e

Please sign in to comment.