From 714dafcb2047bde4d870eeca3309b4380b3d40fa Mon Sep 17 00:00:00 2001 From: mdrakos Date: Tue, 17 Oct 2023 15:50:08 -0700 Subject: [PATCH 01/10] Initial headless changes --- internal/constants/constants.go | 1 + internal/locale/locales/en-us.yaml | 2 - internal/runbits/requirements/requirements.go | 66 +++++-------------- internal/runners/activate/activate.go | 22 ++----- internal/runners/exec/exec.go | 8 +-- internal/runners/history/history.go | 21 +++--- internal/runners/pull/pull.go | 4 +- internal/runners/shell/shell.go | 6 +- internal/subshell/sscommon/rcfile.go | 26 +++----- pkg/platform/runtime/setup/setup.go | 8 +-- test/integration/bundle_int_test.go | 2 +- test/integration/import_int_test.go | 2 +- test/integration/package_int_test.go | 2 +- 13 files changed, 52 insertions(+), 118 deletions(-) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index c988044d5a..dc2dbee9b9 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -303,6 +303,7 @@ const ActiveStateSupportURL = "https://www.activestate.com/support/?utm_source=p const ActiveStateDashboardURL = "https://platform.activestate.com/?utm_source=platform-application-gui&utm_medium=activestate-desktop&utm_content=drop-down&utm_campaign=maru" // DashboardCommitURL is the URL used to inspect commits +// TODO: Can this be removed? const DashboardCommitURL = "https://platform.activestate.com/commit/" // BugTrackerURL is the URL of our bug tracker diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index 8813a80e7c..27fae7d976 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -1837,8 +1837,6 @@ package_ingredient_alternatives_nolang: No results found for search term "[NOTICE]{{.V0}}[/RESET]". This may be because you have not installed a language for your project. Install a language by running "[ACTIONABLE]state languages install [/RESET]". -progress_project: - other: " • Initializing Project" progress_search: other: " • Searching for [ACTIONABLE]{{.V0}}[/RESET] in the ActiveState Catalog" setup_runtime: diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index f89281cd54..aab0992659 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -1,9 +1,7 @@ package requirements import ( - "errors" "fmt" - "os" "strconv" "strings" @@ -26,11 +24,9 @@ import ( medmodel "github.com/ActiveState/cli/pkg/platform/api/mediator/model" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" - "github.com/ActiveState/cli/pkg/platform/runtime/artifact" "github.com/ActiveState/cli/pkg/platform/runtime/buildscript" "github.com/ActiveState/cli/pkg/platform/runtime/target" "github.com/ActiveState/cli/pkg/project" - "github.com/ActiveState/cli/pkg/projectfile" "github.com/thoas/go-funk" ) @@ -104,32 +100,18 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ }() var err error - pj := r.Project - if pj == nil { - pg = output.StartSpinner(out, locale.Tl("progress_project", "", requirementName), constants.TerminalAnimationInterval) - pj, err = initializeProject() - if err != nil { - return locale.WrapError(err, "err_package_get_project", "Could not get project from path") - } - pg.Stop(locale.T("progress_success")) - pg = nil // The defer above will redundantly call pg.Stop on success if we don't set this to nil - - defer func() { - if rerr != nil && !errors.Is(err, artifact.CamelRuntimeBuilding) { - if err := os.Remove(pj.Source().Path()); err != nil { - multilog.Error("could not remove temporary project file: %s", errs.JoinMessage(err)) - } - } - }() + if r.Project == nil { + return locale.NewInputError("err_no_project", "No project found") } - out.Notice(locale.Tl("operating_message", "", pj.NamespaceString(), pj.Dir())) + out.Notice(locale.Tl("operating_message", "", r.Project.NamespaceString(), r.Project.Dir())) switch nsType { case model.NamespacePackage, model.NamespaceBundle: - commitID, err := localcommit.Get(pj.Dir()) + commitID, err := localcommit.Get(r.Project.Dir()) if err != nil && !localcommit.IsFileDoesNotExistError(err) { return errs.Wrap(err, "Unable to get local commit") } + language, err := model.LanguageByCommit(commitID) if err == nil { langName = language.Name @@ -183,16 +165,19 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ if err != nil { return locale.WrapError(err, "package_err_cannot_obtain_search_results") } + if len(packages) == 0 { suggestions, err := getSuggestions(ns, requirementName) if err != nil { multilog.Error("Failed to retrieve suggestions: %v", err) } + if len(suggestions) == 0 { return &ErrNoMatches{ locale.WrapInputError(err, "package_ingredient_alternatives_nosuggest", "", requirementName), requirementName, nil} } + return &ErrNoMatches{ locale.WrapInputError(err, "package_ingredient_alternatives", "", requirementName, strings.Join(suggestions, "\n")), requirementName, ptr.To(strings.Join(suggestions, "\n"))} @@ -204,7 +189,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ pg = nil } - parentCommitID, err := localcommit.Get(pj.Dir()) + parentCommitID, err := localcommit.Get(r.Project.Dir()) if err != nil && !localcommit.IsFileDoesNotExistError(err) { return errs.Wrap(err, "Unable to get local commit") } @@ -251,8 +236,8 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ } params := model.StageCommitParams{ - Owner: pj.Owner(), - Project: pj.Name(), + Owner: r.Project.Owner(), + Project: r.Project.Name(), ParentCommit: string(parentCommitID), Description: commitMessage(operation, name, version, ns, requirementBitWidth), RequirementName: name, @@ -283,29 +268,29 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ return errs.Wrap(err, "Unsupported namespace type: %s", ns.Type().String()) } - expr, err := bp.GetBuildExpression(pj.Owner(), pj.Name(), commitID.String()) + expr, err := bp.GetBuildExpression(r.Project.Owner(), r.Project.Name(), commitID.String()) if err != nil { return errs.Wrap(err, "Could not get remote build expr") } - if err := localcommit.Set(pj.Dir(), commitID.String()); err != nil { + if err := localcommit.Set(r.Project.Dir(), commitID.String()); err != nil { return locale.WrapError(err, "err_package_update_commit_id") } // Note: a commit ID file needs to exist at this point. - err = buildscript.Update(pj, expr, r.Auth) + err = buildscript.Update(r.Project, expr, r.Auth) if err != nil { return locale.WrapError(err, "err_update_build_script") } // refresh or install runtime - err = runbits.RefreshRuntime(r.Auth, r.Output, r.Analytics, pj, commitID, true, trigger, r.SvcModel) + err = runbits.RefreshRuntime(r.Auth, r.Output, r.Analytics, r.Project, commitID, true, trigger, r.SvcModel) if err != nil { return err } if !hasParentCommit { - out.Notice(locale.Tr("install_initial_success", pj.Source().Path())) + out.Notice(locale.Tr("install_initial_success", r.Project.Source().Path())) } // Print the result @@ -413,25 +398,6 @@ func getSuggestions(ns model.Namespace, name string) ([]string, error) { return suggestions, nil } -func initializeProject() (*project.Project, error) { - target, err := os.Getwd() - if err != nil { - return nil, locale.WrapError(err, "err_add_get_wd", "Could not get working directory for new project") - } - - createParams := &projectfile.CreateParams{ - ProjectURL: constants.DashboardCommitURL, - Directory: target, - } - - _, err = projectfile.Create(createParams) - if err != nil { - return nil, locale.WrapError(err, "err_add_create_projectfile", "Could not create new projectfile") - } - - return project.FromPath(target) -} - func commitMessage(op bpModel.Operation, name, version string, namespace model.Namespace, word int) string { switch namespace.Type() { case model.NamespaceLanguage: diff --git a/internal/runners/activate/activate.go b/internal/runners/activate/activate.go index 1088ed9698..97cd2abbe9 100644 --- a/internal/runners/activate/activate.go +++ b/internal/runners/activate/activate.go @@ -138,18 +138,12 @@ func (r *Activate) Run(params *ActivateParams) (rerr error) { } } - if proj != nil && params.Branch != "" { - if proj.IsHeadless() { - return locale.NewInputError( - "err_conflicting_branch_while_headless", - "Cannot activate branch [NOTICE]{{.V0}}[/RESET] while in a headless state. Please visit {{.V1}} to create your project.", - params.Branch, proj.URL(), - ) - } + if proj.IsHeadless() { + return locale.NewInputError("err_activate_headless", "Cannot activate a headless project. Please visit {{.V0}} to create your project.", proj.URL()) + } - if params.Branch != proj.BranchName() { - return locale.NewInputError("err_conflicting_branch_while_checkedout", "", params.Branch, proj.BranchName()) - } + if proj != nil && params.Branch != "" && params.Branch != proj.BranchName() { + return locale.NewInputError("err_conflicting_branch_while_checkedout", "", params.Branch, proj.BranchName()) } // Have to call this once the project has been set @@ -208,11 +202,7 @@ func (r *Activate) Run(params *ActivateParams) (rerr error) { return locale.WrapError(err, "err_activate_wait", "Could not activate runtime environment.") } - if proj.IsHeadless() { - r.out.Notice(locale.T("info_deactivated_by_commit")) - } else { - r.out.Notice(locale.T("info_deactivated", proj)) - } + r.out.Notice(locale.T("info_deactivated", proj)) return nil } diff --git a/internal/runners/exec/exec.go b/internal/runners/exec/exec.go index bb0b174ead..601828940e 100644 --- a/internal/runners/exec/exec.go +++ b/internal/runners/exec/exec.go @@ -95,13 +95,9 @@ func (s *Exec) Run(params *Params, args ...string) (rerr error) { projectDir = projectFromRuntimeDir(s.cfg, params.Path) proj, err = project.FromPath(projectDir) if err != nil { - logging.Warning("Could not get project dir from path: %s", errs.JoinMessage(err)) - // We do not know if the project is headless at this point so we default to true - // as there is no head - rtTarget = target.NewCustomTarget("", "", "", params.Path, trigger, true) - } else { - rtTarget = target.NewProjectTarget(proj, nil, trigger) + return locale.WrapInputError(err, "exec_no_project_at_path", "Could not find project file at {{.V0}}", projectDir) } + rtTarget = target.NewProjectTarget(proj, nil, trigger) projectNamespace = proj.NamespaceString() } else { proj = s.proj diff --git a/internal/runners/history/history.go b/internal/runners/history/history.go index 0b971dab75..d5b15fd827 100644 --- a/internal/runners/history/history.go +++ b/internal/runners/history/history.go @@ -44,17 +44,18 @@ func (h *History) Run(params *HistoryParams) error { return errs.Wrap(err, "Unable to get local commit") } - var latestRemoteID *strfmt.UUID - if !h.project.IsHeadless() { - remoteBranch, err := model.BranchForProjectNameByName(h.project.Owner(), h.project.Name(), h.project.BranchName()) - if err != nil { - return locale.WrapError(err, "err_history_remote_branch", "Could not get branch by local branch name") - } + if h.project.IsHeadless() { + return locale.NewInputError("err_history_headless", "Cannot get history for headless project. Please visit {{.V0}} to convert your project and try again.", h.project.URL()) + } - latestRemoteID, err = model.CommonParent(remoteBranch.CommitID, &localCommitID) - if err != nil { - return locale.WrapError(err, "err_history_common_parent", "Could not determine common parent commit") - } + remoteBranch, err := model.BranchForProjectNameByName(h.project.Owner(), h.project.Name(), h.project.BranchName()) + if err != nil { + return locale.WrapError(err, "err_history_remote_branch", "Could not get branch by local branch name") + } + + latestRemoteID, err := model.CommonParent(remoteBranch.CommitID, &localCommitID) + if err != nil { + return locale.WrapError(err, "err_history_common_parent", "Could not determine common parent commit") } commits, err := model.CommitHistoryFromID(localCommitID) diff --git a/internal/runners/pull/pull.go b/internal/runners/pull/pull.go index 7d0a96872e..2234aee863 100644 --- a/internal/runners/pull/pull.go +++ b/internal/runners/pull/pull.go @@ -83,11 +83,11 @@ func (p *Pull) Run(params *PullParams) error { } p.out.Notice(locale.Tl("operating_message", "", p.project.NamespaceString(), p.project.Dir())) - if p.project.IsHeadless() && params.SetProject == "" { + if p.project.IsHeadless() { return locale.NewInputError("err_pull_headless", "You must first create a project. Please visit {{.V0}} to create your project.", p.project.URL()) } - if !p.project.IsHeadless() && p.project.BranchName() == "" { + if p.project.BranchName() == "" { return locale.NewError("err_pull_branch", "Your [NOTICE]activestate.yaml[/RESET] project field does not contain a branch. Please ensure you are using the latest version of the State Tool by running [ACTIONABLE]`state update`[/RESET] and then trying again.") } diff --git a/internal/runners/shell/shell.go b/internal/runners/shell/shell.go index 00a3077332..dfb4f6c9a2 100644 --- a/internal/runners/shell/shell.go +++ b/internal/runners/shell/shell.go @@ -102,11 +102,7 @@ func (u *Shell) Run(params *Params) error { return locale.WrapError(err, "err_shell_wait", "Could not start runtime shell/prompt.") } - if proj.IsHeadless() { - u.out.Notice(locale.T("info_deactivated_by_commit")) - } else { - u.out.Notice(locale.T("info_deactivated", proj)) - } + u.out.Notice(locale.T("info_deactivated", proj)) return nil } diff --git a/internal/subshell/sscommon/rcfile.go b/internal/subshell/sscommon/rcfile.go index b40d2d7e87..0a7f5ac828 100644 --- a/internal/subshell/sscommon/rcfile.go +++ b/internal/subshell/sscommon/rcfile.go @@ -303,15 +303,6 @@ func SetupProjectRcFile(prj *project.Project, templateName, ext string, env map[ isConsole := ext == ".bat" // yeah this is a dirty cheat, should find something more deterministic - var activatedMessage string - if !prj.IsHeadless() { - activatedMessage = locale.Tl("project_activated", - "[SUCCESS]✔ Project \"{{.V0}}\" Has Been Activated[/RESET]", prj.Namespace().String()) - } else { - activatedMessage = locale.Tl("headless_project_activated", - "[SUCCESS]✔ Virtual Environment Activated[/RESET]") - } - actualEnv := map[string]string{} for k, v := range env { if strings.Contains(v, "\n") { @@ -322,14 +313,15 @@ func SetupProjectRcFile(prj *project.Project, templateName, ext string, env map[ } rcData := map[string]interface{}{ - "Owner": prj.Owner(), - "Name": prj.Name(), - "Env": actualEnv, - "WD": wd, - "UserScripts": userScripts, - "Scripts": scripts, - "ExecName": constants.CommandName, - "ActivatedMessage": colorize.ColorizedOrStrip(activatedMessage, isConsole), + "Owner": prj.Owner(), + "Name": prj.Name(), + "Env": actualEnv, + "WD": wd, + "UserScripts": userScripts, + "Scripts": scripts, + "ExecName": constants.CommandName, + "ActivatedMessage": colorize.ColorizedOrStrip(locale.Tl("project_activated", + "[SUCCESS]✔ Project \"{{.V0}}\" Has Been Activated[/RESET]", prj.Namespace().String()), isConsole), } currExec := osutils.Executable() diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index fb87535339..32c590eada 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -421,13 +421,7 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal downloadablePrebuiltResults, err := setup.DownloadsFromBuild(*buildResult.Build, runtimeArtifacts) if err != nil { if errors.Is(err, artifact.CamelRuntimeBuilding) { - localeID := "build_status_in_progress" - messageURL := apimodel.ProjectURL(s.target.Owner(), s.target.Name(), s.target.CommitUUID().String()) - if s.target.Owner() == "" && s.target.Name() == "" { - localeID = "build_status_in_progress_headless" - messageURL = apimodel.CommitURL(s.target.CommitUUID().String()) - } - return nil, nil, locale.WrapInputError(err, localeID, "", messageURL) + return nil, nil, locale.WrapInputError(err, "build_status_in_progress", "", apimodel.ProjectURL(s.target.Owner(), s.target.Name(), s.target.CommitUUID().String())) } return nil, nil, errs.Wrap(err, "could not extract artifacts that are ready to download.") } diff --git a/test/integration/bundle_int_test.go b/test/integration/bundle_int_test.go index 9ed02334f7..464fbbfa73 100644 --- a/test/integration/bundle_int_test.go +++ b/test/integration/bundle_int_test.go @@ -165,7 +165,7 @@ func (suite *BundleIntegrationTestSuite) TestBundle_searchWithBadLang() { cp.ExpectExitCode(1) } -func (suite *BundleIntegrationTestSuite) TestBundle_headless_operation() { +func (suite *BundleIntegrationTestSuite) TestBundle_detached_operation() { suite.OnlyRunForTags(tagsuite.Bundle) if runtime.GOOS == "darwin" { suite.T().Skip("Skipping mac for now as the builds are still too unreliable") diff --git a/test/integration/import_int_test.go b/test/integration/import_int_test.go index df3ab98706..059c06048f 100644 --- a/test/integration/import_int_test.go +++ b/test/integration/import_int_test.go @@ -16,7 +16,7 @@ type ImportIntegrationTestSuite struct { tagsuite.Suite } -func (suite *ImportIntegrationTestSuite) TestImport_headless() { +func (suite *ImportIntegrationTestSuite) TestImport_detached() { suite.OnlyRunForTags(tagsuite.Import) if runtime.GOOS == "darwin" { suite.T().Skip("Skipping mac for now as the builds are still too unreliable") diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index 0ecc082265..160515e3f9 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -331,7 +331,7 @@ func (suite *PackageIntegrationTestSuite) TestPackage_import() { }) } -func (suite *PackageIntegrationTestSuite) TestPackage_headless_operation() { +func (suite *PackageIntegrationTestSuite) TestPackage_detached_operation() { suite.OnlyRunForTags(tagsuite.Package) if runtime.GOOS == "darwin" { suite.T().Skip("Skipping mac for now as the builds are still too unreliable") From 092aea681c39f749b9b51cda22b63d3a1e427427 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Wed, 18 Oct 2023 10:25:32 -0700 Subject: [PATCH 02/10] More headless removal --- internal/constants/constants.go | 3 --- internal/locale/locales/en-us.yaml | 8 -------- internal/runners/deploy/deploy.go | 3 +-- internal/runners/prepare/prepare.go | 2 +- pkg/platform/runtime/executors/executors.go | 5 ++--- .../runtime/executors/executors_test.go | 2 +- pkg/platform/runtime/runtime.go | 3 --- pkg/platform/runtime/setup/setup.go | 1 - pkg/platform/runtime/target/target.go | 17 ++--------------- 9 files changed, 7 insertions(+), 37 deletions(-) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index dc2dbee9b9..6313383ccc 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -281,9 +281,6 @@ const PlatformSignupURL = "https://platform.activestate.com" + "/create-account" // DocumentationURL is the url for the state tool documentation const DocumentationURL = "http://docs.activestate.com/platform/state/" -// DocumentationURLHeadless is the documentation URL for headless state docs -const DocumentationURLHeadless = DocumentationURL + "advanced-topics/detached/" - // DocumentationURLGetStarted is the documentation URL for creating projects const DocumentationURLGetStarted = DocumentationURL + "create-project/?utm_source=platform-application-gui&utm_medium=activestate-desktop&utm_content=drop-down&utm_campaign=maru" diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index 27fae7d976..b89a8a7008 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -784,8 +784,6 @@ build_status_unknown: other: "Build status could not be retrieved, please view the project at: [NOTICE]{{.V0}}[/RESET] for more information" build_status_in_progress: other: "Your changes are currently being built remotely on the ActiveState Platform. Please visit [NOTICE]{{.V0}}[/RESET] to see the progress." -build_status_in_progress_headless: - other: "Your changes are currently being built remotely on the ActiveState Platform. Please visit [NOTICE]{{.V0}}[/RESET] to see the progress (you may have to first convert your runtime to a project)." build_status_unknown_error: other: "Build reported an unknown error: {{.V0}}; Please view the project at: [ACTIONABLE]{{.V1}}[/RESET] for more information" build_status_failed: @@ -1156,12 +1154,6 @@ bundle_updated: other: "Bundle updated: [NOTICE]{{.V0}}[/RESET]" bundle_version_updated: other: "Bundle updated: [NOTICE]{{.V0}}@{{.V1}}[/RESET]" -package_headless_added: - other: "Package added: [NOTICE]{{.V0}}[/RESET]" -package_headless_updated: - other: "Package updated: [NOTICE]{{.V0}}[/RESET]" -package_headless_removed: - other: "Package uninstalled: [NOTICE]{{.V0}}[/RESET]" err_package_removed: other: Failed to remove package err_bundle_removed: diff --git a/internal/runners/deploy/deploy.go b/internal/runners/deploy/deploy.go index 58472b4381..4de02d08fe 100644 --- a/internal/runners/deploy/deploy.go +++ b/internal/runners/deploy/deploy.go @@ -95,8 +95,7 @@ func (d *Deploy) Run(params *Params) error { return locale.WrapError(err, "err_deploy_commitid", "Could not grab commit ID for project: {{.V0}}.", params.Namespace.String()) } - // Headless argument is simply false here as you cannot deploy a headless project - rtTarget := target.NewCustomTarget(params.Namespace.Owner, params.Namespace.Project, commitID, params.Path, target.TriggerDeploy, false) /* TODO: handle empty path */ + rtTarget := target.NewCustomTarget(params.Namespace.Owner, params.Namespace.Project, commitID, params.Path, target.TriggerDeploy) /* TODO: handle empty path */ logging.Debug("runSteps: %s", d.step.String()) diff --git a/internal/runners/prepare/prepare.go b/internal/runners/prepare/prepare.go index f1dd8402c9..a5e30e8574 100644 --- a/internal/runners/prepare/prepare.go +++ b/internal/runners/prepare/prepare.go @@ -79,7 +79,7 @@ func (r *Prepare) resetExecutors() error { return errs.Wrap(err, "Unable to get local commit") } - run, err := rt.New(target.NewCustomTarget(proj.Owner(), proj.Name(), commitID, defaultTargetDir, target.TriggerResetExec, proj.IsHeadless()), r.analytics, r.svcModel, nil) + run, err := rt.New(target.NewCustomTarget(proj.Owner(), proj.Name(), commitID, defaultTargetDir, target.TriggerResetExec), r.analytics, r.svcModel, nil) if err != nil { if rt.IsNeedsUpdateError(err) { return nil // project was never set up, so no executors to reset diff --git a/pkg/platform/runtime/executors/executors.go b/pkg/platform/runtime/executors/executors.go index 0cf1dedc56..3c5c88dd80 100644 --- a/pkg/platform/runtime/executors/executors.go +++ b/pkg/platform/runtime/executors/executors.go @@ -1,13 +1,14 @@ package executors import ( - "github.com/ActiveState/cli/pkg/project" "io/ioutil" "os" "path/filepath" rt "runtime" "strings" + "github.com/ActiveState/cli/pkg/project" + "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/osutils" @@ -31,7 +32,6 @@ type Targeter interface { Name() string Owner() string Dir() string - Headless() bool } type Executors struct { @@ -74,7 +74,6 @@ func (es *Executors) Apply(sockPath string, targeter Targeter, env map[string]st CommitUUID: targeter.CommitUUID().String(), Namespace: ns.String(), Dir: targeter.Dir(), - Headless: targeter.Headless(), } m := execmeta.New(sockPath, osutils.EnvMapToSlice(env), t, executors) if err := m.WriteToDisk(es.executorPath); err != nil { diff --git a/pkg/platform/runtime/executors/executors_test.go b/pkg/platform/runtime/executors/executors_test.go index c4ca4b0a3a..cf13178cff 100644 --- a/pkg/platform/runtime/executors/executors_test.go +++ b/pkg/platform/runtime/executors/executors_test.go @@ -25,7 +25,7 @@ func TestExecutor(t *testing.T) { err = fileutils.WriteFile(dummyExecSrc, dummyExecData) require.NoError(t, err, errs.JoinMessage(err)) - target := target.NewCustomTarget("owner", "project", "1234abcd-1234-abcd-1234-abcd1234abcd", "dummy/path", target.NewExecTrigger("test"), false) + target := target.NewCustomTarget("owner", "project", "1234abcd-1234-abcd-1234-abcd1234abcd", "dummy/path", target.NewExecTrigger("test")) execDir := filepath.Join(tmpDir, "exec") execInit := New(execDir) execInit.altExecSrcPath = dummyExecSrc diff --git a/pkg/platform/runtime/runtime.go b/pkg/platform/runtime/runtime.go index 7e36db21e4..806ea0e22e 100644 --- a/pkg/platform/runtime/runtime.go +++ b/pkg/platform/runtime/runtime.go @@ -6,7 +6,6 @@ import ( "fmt" "os" "path/filepath" - "strconv" "strings" "golang.org/x/net/context" @@ -90,7 +89,6 @@ func New(target setup.Targeter, an analytics.Dispatcher, svcm *model.SvcModel, a recordAttempt(an, target) an.Event(anaConsts.CatRuntimeDebug, anaConsts.ActRuntimeStart, &dimensions.Values{ Trigger: ptr.To(target.Trigger().String()), - Headless: ptr.To(strconv.FormatBool(target.Headless())), CommitID: ptr.To(target.CommitUUID().String()), ProjectNameSpace: ptr.To(project.NewNamespace(target.Owner(), target.Name(), target.CommitUUID().String()).String()), InstanceID: ptr.To(instanceid.ID()), @@ -321,7 +319,6 @@ func usageDims(target setup.Targeter) *dimensions.Values { return &dimensions.Values{ Trigger: ptr.To(target.Trigger().String()), CommitID: ptr.To(target.CommitUUID().String()), - Headless: ptr.To(strconv.FormatBool(target.Headless())), ProjectNameSpace: ptr.To(project.NewNamespace(target.Owner(), target.Name(), target.CommitUUID().String()).String()), InstanceID: ptr.To(instanceid.ID()), } diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index 32c590eada..371c6c41ef 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -115,7 +115,6 @@ type Targeter interface { Name() string Owner() string Dir() string - Headless() bool Trigger() target.Trigger ProjectDir() string diff --git a/pkg/platform/runtime/target/target.go b/pkg/platform/runtime/target/target.go index 49e19564c5..acbf3acdda 100644 --- a/pkg/platform/runtime/target/target.go +++ b/pkg/platform/runtime/target/target.go @@ -103,10 +103,6 @@ func (p *ProjectTarget) Trigger() Trigger { return p.trigger } -func (p *ProjectTarget) Headless() bool { - return p.Project.IsHeadless() -} - func (p *ProjectTarget) ReadOnly() bool { return false } @@ -136,17 +132,16 @@ type CustomTarget struct { commitUUID strfmt.UUID dir string trigger Trigger - headless bool } -func NewCustomTarget(owner string, name string, commitUUID strfmt.UUID, dir string, trigger Trigger, headless bool) *CustomTarget { +func NewCustomTarget(owner string, name string, commitUUID strfmt.UUID, dir string, trigger Trigger) *CustomTarget { cleanDir, err := fileutils.ResolveUniquePath(dir) if err != nil { multilog.Error("Could not resolve unique path for dir: %s, error: %s", dir, err.Error()) } else { dir = cleanDir } - return &CustomTarget{owner, name, commitUUID, dir, trigger, headless} + return &CustomTarget{owner, name, commitUUID, dir, trigger} } func (c *CustomTarget) Owner() string { @@ -172,10 +167,6 @@ func (c *CustomTarget) Trigger() Trigger { return c.trigger } -func (c *CustomTarget) Headless() bool { - return c.headless -} - func (c *CustomTarget) ReadOnly() bool { return c.commitUUID == "" } @@ -238,10 +229,6 @@ func (i *OfflineTarget) Trigger() Trigger { return i.trigger } -func (i *OfflineTarget) Headless() bool { - return false -} - func (i *OfflineTarget) ReadOnly() bool { return false } From 03f77deaa64666e8bda344a7bf54c5d85fb3eede Mon Sep 17 00:00:00 2001 From: mdrakos Date: Thu, 19 Oct 2023 13:27:50 -0700 Subject: [PATCH 03/10] Remove push from headless flow --- internal/locale/locales/en-us.yaml | 2 -- internal/runners/push/push.go | 7 ------- 2 files changed, 9 deletions(-) diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index b89a8a7008..b95d39c06f 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -1229,8 +1229,6 @@ init_description: other: Initialize a new project push_description: other: Push your latest changes to the platform -push_first_new_project: - other: 'Since this is your first time running "push" you''ll need to create a new project on the ActiveState Platform.' push_prompt_owner: other: "Who would you like the owner of this project to be?" push_prompt_not_authorized: diff --git a/internal/runners/push/push.go b/internal/runners/push/push.go index a033afad55..25a54f1d83 100644 --- a/internal/runners/push/push.go +++ b/internal/runners/push/push.go @@ -57,7 +57,6 @@ type intention uint16 const ( pushCustomNamespace intention = 0x0001 // User is pushing to a custom remote, ignoring the namespace in the current yaml pushFromNoPermission = 0x0002 // User made modifications to someone elses project, and it now trying to push them - pushFromHeadless = 0x0004 // User is operating in headless mode and is now trying to push // The rest is supplemental intendCreateProject = 0x0008 @@ -106,8 +105,6 @@ func (r *Push) Run(params PushParams) (rerr error) { // Capture the primary intend of the user var intend intention switch { - case r.project.IsHeadless(): - intend = pushFromHeadless | intendCreateProject case targetNamespace.IsValid() && !r.auth.CanWrite(r.project.Owner()): intend = pushFromNoPermission | intendCreateProject case params.Namespace.IsValid(): @@ -127,10 +124,6 @@ func (r *Push) Run(params PushParams) (rerr error) { // - No namespace could be detect so far // - We want to create a copy of the current namespace, and no custom namespace was provided if !targetNamespace.IsValid() || (intend&pushFromNoPermission > 0 && !params.Namespace.IsValid()) { - var err error - if intend&pushFromHeadless > 0 { - r.out.Notice(locale.T("push_first_new_project")) - } targetNamespace, err = r.promptNamespace() if err != nil { return errs.Wrap(err, "Could not prompt for namespace") From bf15df1a13045ab90c9d3304ac9a8a9156d2feef Mon Sep 17 00:00:00 2001 From: mdrakos Date: Thu, 19 Oct 2023 14:30:27 -0700 Subject: [PATCH 04/10] Remove headless integration tests --- test/integration/package_int_test.go | 31 ----------------- test/integration/push_int_test.go | 52 ---------------------------- 2 files changed, 83 deletions(-) diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index 160515e3f9..d824fe0cde 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "path/filepath" "runtime" "testing" @@ -448,36 +447,6 @@ scripts: ts.PrepareCommitIdFile("a9d0bc88-585a-49cf-89c1-6c07af781cff") } -func (suite *PackageIntegrationTestSuite) TestInstall_Empty() { - suite.OnlyRunForTags(tagsuite.Package) - if runtime.GOOS == "darwin" { - suite.T().Skip("Skipping mac for now as the builds are still too unreliable") - return - } - - ts := e2e.New(suite.T(), false) - defer ts.Close() - - cp := ts.SpawnWithOpts( - e2e.OptArgs("install", "JSON"), - e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), - ) - cp.Expect("Installing Package") - cp.ExpectExitCode(0, e2e.RuntimeSourcingTimeoutOpt) - - configFilepath := filepath.Join(ts.Dirs.Work, constants.ConfigFileName) - suite.Require().FileExists(configFilepath) - - content, err := ioutil.ReadFile(configFilepath) - suite.Require().NoError(err) - if !suite.Contains(string(content), constants.DashboardCommitURL) { - suite.Fail("activestate.yaml does not contain dashboard commit URL") - } - - commitIdFile := filepath.Join(ts.Dirs.Work, constants.ProjectConfigDirName, constants.CommitIdFileName) - suite.Assert().FileExists(commitIdFile) -} - func (suite *PackageIntegrationTestSuite) TestPackage_UninstallDoesNotExist() { suite.OnlyRunForTags(tagsuite.Package) diff --git a/test/integration/push_int_test.go b/test/integration/push_int_test.go index 60937938aa..c72f41b3d6 100644 --- a/test/integration/push_int_test.go +++ b/test/integration/push_int_test.go @@ -105,58 +105,6 @@ func (suite *PushIntegrationTestSuite) TestInitAndPush() { cp.ExpectExitCode(0) } -// Test pushing to a new project from a headless commit -func (suite *PushIntegrationTestSuite) TestPush_HeadlessConvert_NewProject() { - if runtime.GOOS == "windows" { - suite.T().Skip("Skipped on Windows for now because SendKeyDown() doesnt work (regardless of bash/cmd)") - } - - suite.OnlyRunForTags(tagsuite.Push) - ts := e2e.New(suite.T(), false) - defer ts.Close() - ts.LoginAsPersistentUser() - pname := strutils.UUID() - namespace := fmt.Sprintf("%s/%s", suite.username, pname) - - cp := ts.SpawnWithOpts(e2e.OptArgs("install", suite.extraPackage)) - - cp.Expect("An activestate.yaml has been created", termtest.OptExpectTimeout(time.Second*40)) - switch runtime.GOOS { - case "darwin": - cp.ExpectRe("added|being built", termtest.OptExpectTimeout(60*time.Second)) // while cold storage is off - cp.Wait() - default: - cp.Expect("added", termtest.OptExpectTimeout(60*time.Second)) - cp.ExpectExitCode(0) - } - - pjfilepath := filepath.Join(ts.Dirs.Work, constants.ConfigFileName) - pjfile, err := projectfile.Parse(pjfilepath) - suite.Require().NoError(err) - if !strings.Contains(pjfile.Project, "/commit/") { - suite.FailNow("project field should be headless but isn't: " + pjfile.Project) - } - - cp = ts.SpawnWithOpts(e2e.OptArgs("push")) - cp.Expect("Who would you like the owner of this project to be?") - cp.SendEnter() - cp.Expect("What would you like the name of this project to be?") - cp.SendKeyDown() - cp.Expect("> Other") - cp.SendEnter() - cp.Expect(">") - cp.SendLine(pname.String()) - cp.Expect("Project created") - cp.ExpectExitCode(0) - ts.NotifyProjectCreated(suite.username, pname.String()) - - pjfile, err = projectfile.Parse(pjfilepath) - suite.Require().NoError(err) - if !strings.Contains(pjfile.Project, fmt.Sprintf("/%s?", namespace)) { - suite.FailNow("project field should include project again: " + pjfile.Project) - } -} - // Test pushing without permission, and choosing to create a new project func (suite *PushIntegrationTestSuite) TestPush_NoPermission_NewProject() { if runtime.GOOS == "windows" { From f649027b1ae3e4b0fca1ede5fdcffb4de326c219 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Mon, 23 Oct 2023 16:07:47 -0700 Subject: [PATCH 05/10] Fix test failures --- test/integration/activate_int_test.go | 5 ++--- test/integration/bundle_int_test.go | 5 +++++ test/integration/package_int_test.go | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/integration/activate_int_test.go b/test/integration/activate_int_test.go index f7d60bac60..603ad5d4ff 100644 --- a/test/integration/activate_int_test.go +++ b/test/integration/activate_int_test.go @@ -552,9 +552,8 @@ func (suite *ActivateIntegrationTestSuite) TestActivateCommitURL() { // Ensure we have the most up to date version of the project before activating cp := ts.Spawn("activate") - cp.Expect("Activated", e2e.RuntimeSourcingTimeoutOpt) - cp.SendLine("exit") - cp.ExpectExitCode(0) + cp.Expect("Cannot activate a headless project", e2e.RuntimeSourcingTimeoutOpt) + cp.ExpectExitCode(1) } func (suite *ActivateIntegrationTestSuite) TestActivate_AlreadyActive() { diff --git a/test/integration/bundle_int_test.go b/test/integration/bundle_int_test.go index 74b9551330..ed4cf0775b 100644 --- a/test/integration/bundle_int_test.go +++ b/test/integration/bundle_int_test.go @@ -221,6 +221,11 @@ func (suite *BundleIntegrationTestSuite) TestJSON() { cp.ExpectExitCode(0) AssertValidJSON(suite.T(), cp) + cp = ts.Spawn("checkout", "ActiveState-CLI/Bundles", ".") + cp.Expect("Skipping runtime setup") + cp.Expect("Checked out project") + cp.ExpectExitCode(0) + cp = ts.SpawnWithOpts( e2e.OptArgs("bundles", "install", "Testing", "--output", "json"), e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index 7e5bb7d68c..81578f1b6d 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -470,6 +470,11 @@ func (suite *PackageIntegrationTestSuite) TestJSON() { cp.ExpectExitCode(0) AssertValidJSON(suite.T(), cp) + cp = ts.Spawn("checkout", "ActiveState-CLI/Packages-Perl", ".") + cp.Expect("Skipping runtime setup") + cp.Expect("Checked out project") + cp.ExpectExitCode(0) + cp = ts.SpawnWithOpts( e2e.OptArgs("install", "Text-CSV", "--output", "editor"), e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), From 93d9cadbc3abc658a30e4b669a07adfe0b496b53 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Tue, 24 Oct 2023 13:55:57 -0700 Subject: [PATCH 06/10] Don't allow push on headless projects --- internal/runners/push/push.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/runners/push/push.go b/internal/runners/push/push.go index 25a54f1d83..c32b12ed8f 100644 --- a/internal/runners/push/push.go +++ b/internal/runners/push/push.go @@ -102,6 +102,10 @@ func (r *Push) Run(params PushParams) (rerr error) { logging.Debug("%s can write to %s: %v", r.auth.WhoAmI(), targetNamespace.Owner, r.auth.CanWrite(targetNamespace.Owner)) } + if r.project.IsHeadless() { + return locale.NewInputError("err_push_headless", "Cannot push headless projects. Please visit {{.V0}} to create your project.", r.project.URL()) + } + // Capture the primary intend of the user var intend intention switch { From 33ce693b4eb676f1a10d2692d9a387b84838df41 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Tue, 24 Oct 2023 14:24:40 -0700 Subject: [PATCH 07/10] Cleanup --- internal/locale/locales/en-us.yaml | 6 +++--- internal/runbits/rationalize/types.go | 2 ++ internal/runners/activate/activate.go | 2 +- internal/runners/push/push.go | 7 ++++++- internal/runners/push/rationalize.go | 10 +++++++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index 4fdc7a6ea1..9b854dc311 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -57,8 +57,6 @@ err_output_flag_value_invalid: other: Could not recognize output type info_deactivated: other: "[DISABLED]Deactivated {{.Owner}}/{{.Name}}[/RESET]" -info_deactivated_by_commit: - other: "[DISABLED]Deactivated[/RESET]" venv_installer_is_nil: other: Provided installer should not be nil error_unsupported_language: @@ -1721,8 +1719,10 @@ err_tip_push_outdated: other: Run '[ACTIONABLE]state pull[/RESET]'. err_push_not_authenticated: other: In order to update your project you need to be authenticated, please run '[ACTIONABLE]state auth[/RESET]' to authenticate. -err_push_headless: +err_push_no_project: other: No project found, you may need to create one first. +err_push_headless: + other: Cannot push a headless project. To convert your project please visit {{.V0}} push_push_tip_headless_init: other: Run '[ACTIONABLE]state init[/RESET]' to create a project with the State Tool. push_push_tip_headless_cwd: diff --git a/internal/runbits/rationalize/types.go b/internal/runbits/rationalize/types.go index 264794e7fa..51a69035f6 100644 --- a/internal/runbits/rationalize/types.go +++ b/internal/runbits/rationalize/types.go @@ -17,6 +17,8 @@ var ErrNotAuthenticated = errors.New("not authenticated") var ErrActionAborted = errors.New("aborted by user") +var ErrHeadless = errors.New("headless") + type ErrAPI struct { Wrapped error Code int diff --git a/internal/runners/activate/activate.go b/internal/runners/activate/activate.go index ae3dc37082..94ba86b3b4 100644 --- a/internal/runners/activate/activate.go +++ b/internal/runners/activate/activate.go @@ -138,7 +138,7 @@ func (r *Activate) Run(params *ActivateParams) (rerr error) { } } - if proj.IsHeadless() { + if proj != nil && proj.IsHeadless() { return locale.NewInputError("err_activate_headless", "Cannot activate a headless project. Please visit {{.V0}} to create your project.", proj.URL()) } diff --git a/internal/runners/push/push.go b/internal/runners/push/push.go index c32b12ed8f..463f29de57 100644 --- a/internal/runners/push/push.go +++ b/internal/runners/push/push.go @@ -74,6 +74,11 @@ type errProjectNameInUse struct { Namespace *project.Namespaced } +type errHeadless struct { + error + ProjectURL string +} + func (r *Push) Run(params PushParams) (rerr error) { defer rationalizeError(&rerr) @@ -103,7 +108,7 @@ func (r *Push) Run(params PushParams) (rerr error) { } if r.project.IsHeadless() { - return locale.NewInputError("err_push_headless", "Cannot push headless projects. Please visit {{.V0}} to create your project.", r.project.URL()) + return &errHeadless{err, r.project.URL()} } // Capture the primary intend of the user diff --git a/internal/runners/push/rationalize.go b/internal/runners/push/rationalize.go index 9b98194860..8f574ab991 100644 --- a/internal/runners/push/rationalize.go +++ b/internal/runners/push/rationalize.go @@ -15,6 +15,8 @@ func rationalizeError(err *error) { var projectNameInUseErr *errProjectNameInUse + var headlessErr *errHeadless + switch { // Not authenticated @@ -26,13 +28,19 @@ func rationalizeError(err *error) { // No activestate.yaml case errors.Is(*err, rationalize.ErrNoProject): *err = errs.WrapUserFacing(*err, - locale.T("err_push_headless"), + locale.T("err_push_no_project"), errs.SetInput(), errs.SetTips( locale.T("push_push_tip_headless_init"), locale.T("push_push_tip_headless_cwd"), )) + case errors.As(*err, &headlessErr): + *err = errs.WrapUserFacing(*err, + locale.Tr("err_push_headless", headlessErr.ProjectURL), + errs.SetInput(), + ) + // No commits made yet case errors.Is(*err, errNoCommit): *err = errs.WrapUserFacing(*err, From d304fb497d821eece5b9154dac60b01cff6d0702 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Wed, 25 Oct 2023 15:06:20 -0700 Subject: [PATCH 08/10] Fix failing integration tests --- test/integration/bundle_int_test.go | 6 ++++-- test/integration/package_int_test.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/integration/bundle_int_test.go b/test/integration/bundle_int_test.go index ed4cf0775b..d7a90bc98f 100644 --- a/test/integration/bundle_int_test.go +++ b/test/integration/bundle_int_test.go @@ -221,8 +221,10 @@ func (suite *BundleIntegrationTestSuite) TestJSON() { cp.ExpectExitCode(0) AssertValidJSON(suite.T(), cp) - cp = ts.Spawn("checkout", "ActiveState-CLI/Bundles", ".") - cp.Expect("Skipping runtime setup") + cp = ts.SpawnWithOpts( + e2e.OptArgs("checkout", "ActiveState-CLI/Bundles", "."), + e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), + ) cp.Expect("Checked out project") cp.ExpectExitCode(0) diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index 81578f1b6d..77f4e4c4c4 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -470,8 +470,10 @@ func (suite *PackageIntegrationTestSuite) TestJSON() { cp.ExpectExitCode(0) AssertValidJSON(suite.T(), cp) - cp = ts.Spawn("checkout", "ActiveState-CLI/Packages-Perl", ".") - cp.Expect("Skipping runtime setup") + cp = ts.SpawnWithOpts( + e2e.OptArgs("checkout", "ActiveState-CLI/Packages-Perl", "."), + e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), + ) cp.Expect("Checked out project") cp.ExpectExitCode(0) From 5a90844252be7b20cd8f6084a7bd2d78634c7e9b Mon Sep 17 00:00:00 2001 From: mdrakos Date: Thu, 26 Oct 2023 14:30:31 -0700 Subject: [PATCH 09/10] Address PR review feedback Removed unreferenced code Use rationalized error type Attempt to speed up integration tests --- internal/constants/constants.go | 4 ---- internal/runbits/rationalize/types.go | 2 -- internal/runbits/requirements/requirements.go | 3 ++- pkg/platform/model/projects.go | 6 ------ test/integration/bundle_int_test.go | 1 - test/integration/package_int_test.go | 1 - 6 files changed, 2 insertions(+), 15 deletions(-) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 3d24c34c23..e2a794a63c 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -312,10 +312,6 @@ const ActiveStateSupportURL = "https://www.activestate.com/support/?utm_source=p // ActiveStateDashboardURL is the URL for the ActiveState account preferences page const ActiveStateDashboardURL = "https://platform.activestate.com/?utm_source=platform-application-gui&utm_medium=activestate-desktop&utm_content=drop-down&utm_campaign=maru" -// DashboardCommitURL is the URL used to inspect commits -// TODO: Can this be removed? -const DashboardCommitURL = "https://platform.activestate.com/commit/" - // BugTrackerURL is the URL of our bug tracker const BugTrackerURL = "https://github.com/ActiveState/state-tool/issues" diff --git a/internal/runbits/rationalize/types.go b/internal/runbits/rationalize/types.go index 51a69035f6..264794e7fa 100644 --- a/internal/runbits/rationalize/types.go +++ b/internal/runbits/rationalize/types.go @@ -17,8 +17,6 @@ var ErrNotAuthenticated = errors.New("not authenticated") var ErrActionAborted = errors.New("aborted by user") -var ErrHeadless = errors.New("headless") - type ErrAPI struct { Wrapped error Code int diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index aab0992659..ad2ab06a22 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -19,6 +19,7 @@ import ( "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/rtutils/ptr" "github.com/ActiveState/cli/internal/runbits" + "github.com/ActiveState/cli/internal/runbits/rationalize" "github.com/ActiveState/cli/pkg/localcommit" bpModel "github.com/ActiveState/cli/pkg/platform/api/buildplanner/model" medmodel "github.com/ActiveState/cli/pkg/platform/api/mediator/model" @@ -101,7 +102,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ var err error if r.Project == nil { - return locale.NewInputError("err_no_project", "No project found") + return rationalize.ErrNoProject } out.Notice(locale.Tl("operating_message", "", r.Project.NamespaceString(), r.Project.Dir())) diff --git a/pkg/platform/model/projects.go b/pkg/platform/model/projects.go index 4de74f5554..e3cc24da17 100644 --- a/pkg/platform/model/projects.go +++ b/pkg/platform/model/projects.go @@ -2,7 +2,6 @@ package model import ( "fmt" - "strings" "github.com/go-openapi/strfmt" @@ -264,11 +263,6 @@ func ProjectURL(owner, name, commitID string) string { return url } -// CommitURL creates a valid platform commit URL for the given commit -func CommitURL(commitID string) string { - return fmt.Sprintf("%s/%s", strings.TrimSuffix(constants.DashboardCommitURL, "/"), commitID) -} - func AddBranch(projectID strfmt.UUID, label string) (strfmt.UUID, error) { var branchID strfmt.UUID addParams := projects.NewAddBranchParams() diff --git a/test/integration/bundle_int_test.go b/test/integration/bundle_int_test.go index d7a90bc98f..8e1ad7e905 100644 --- a/test/integration/bundle_int_test.go +++ b/test/integration/bundle_int_test.go @@ -223,7 +223,6 @@ func (suite *BundleIntegrationTestSuite) TestJSON() { cp = ts.SpawnWithOpts( e2e.OptArgs("checkout", "ActiveState-CLI/Bundles", "."), - e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), ) cp.Expect("Checked out project") cp.ExpectExitCode(0) diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index 77f4e4c4c4..f15c01a3f7 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -472,7 +472,6 @@ func (suite *PackageIntegrationTestSuite) TestJSON() { cp = ts.SpawnWithOpts( e2e.OptArgs("checkout", "ActiveState-CLI/Packages-Perl", "."), - e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), ) cp.Expect("Checked out project") cp.ExpectExitCode(0) From b755fef78004bf0d8a6f0c561d471026d1877af4 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Mon, 30 Oct 2023 13:47:36 -0700 Subject: [PATCH 10/10] Add back runtime download --- test/integration/bundle_int_test.go | 1 + test/integration/package_int_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/test/integration/bundle_int_test.go b/test/integration/bundle_int_test.go index 8e1ad7e905..d7a90bc98f 100644 --- a/test/integration/bundle_int_test.go +++ b/test/integration/bundle_int_test.go @@ -223,6 +223,7 @@ func (suite *BundleIntegrationTestSuite) TestJSON() { cp = ts.SpawnWithOpts( e2e.OptArgs("checkout", "ActiveState-CLI/Bundles", "."), + e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), ) cp.Expect("Checked out project") cp.ExpectExitCode(0) diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index f15c01a3f7..77f4e4c4c4 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -472,6 +472,7 @@ func (suite *PackageIntegrationTestSuite) TestJSON() { cp = ts.SpawnWithOpts( e2e.OptArgs("checkout", "ActiveState-CLI/Packages-Perl", "."), + e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), ) cp.Expect("Checked out project") cp.ExpectExitCode(0)