From 301fe307423cc054daf44f06eea26e95c3c75bf8 Mon Sep 17 00:00:00 2001 From: mitchell Date: Thu, 2 Nov 2023 13:03:00 -0400 Subject: [PATCH] Moved cmdlets into runbits. --- architecture.md | 3 +-- cmd/state-installer/cmd.go | 2 +- cmd/state-remote-installer/main.go | 2 +- cmd/state/main.go | 6 +++--- {pkg/cmdlets => internal/runbits}/auth/keypair.go | 0 {pkg/cmdlets => internal/runbits}/auth/login.go | 0 {pkg/cmdlets => internal/runbits}/auth/signup.go | 0 {pkg/cmdlets => internal/runbits}/checker/checker.go | 0 {pkg/cmdlets => internal/runbits}/checkout/checkout.go | 2 +- {pkg/cmdlets => internal/runbits}/checkout/path.go | 0 .../runbits}/checkout/rationalize.go | 0 {pkg/cmdlets => internal/runbits}/commit/commit.go | 0 {pkg/cmdlets => internal/runbits}/errors/errors.go | 0 {pkg/cmdlets => internal/runbits}/git/git.go | 0 .../runbits}/git/test/integration/git_test.go | 10 +++++----- internal/runners/activate/activate.go | 6 +++--- internal/runners/auth/auth.go | 8 ++++---- internal/runners/auth/signup.go | 4 ++-- internal/runners/checkout/checkout.go | 6 +++--- internal/runners/history/history.go | 2 +- internal/runners/pull/pull.go | 2 +- internal/runners/revert/revert.go | 2 +- internal/runners/run/run.go | 2 +- internal/runners/state/state.go | 2 +- internal/runners/use/use.go | 6 +++--- pkg/cmdlets/README.md | 3 --- 26 files changed, 32 insertions(+), 36 deletions(-) rename {pkg/cmdlets => internal/runbits}/auth/keypair.go (100%) rename {pkg/cmdlets => internal/runbits}/auth/login.go (100%) rename {pkg/cmdlets => internal/runbits}/auth/signup.go (100%) rename {pkg/cmdlets => internal/runbits}/checker/checker.go (100%) rename {pkg/cmdlets => internal/runbits}/checkout/checkout.go (99%) rename {pkg/cmdlets => internal/runbits}/checkout/path.go (100%) rename {pkg/cmdlets => internal/runbits}/checkout/rationalize.go (100%) rename {pkg/cmdlets => internal/runbits}/commit/commit.go (100%) rename {pkg/cmdlets => internal/runbits}/errors/errors.go (100%) rename {pkg/cmdlets => internal/runbits}/git/git.go (100%) rename {pkg/cmdlets => internal/runbits}/git/test/integration/git_test.go (89%) delete mode 100644 pkg/cmdlets/README.md diff --git a/architecture.md b/architecture.md index 43d0c374de..c3bbdd2153 100644 --- a/architecture.md +++ b/architecture.md @@ -64,8 +64,7 @@ from use by external code. #### internal/runbits/ Packages that are made available for use by "runner" packages. In essence, -`internal/runners/internal/runbits`. A synonymous and deprecated directory -exists at `pkg/cmdlets/`. +`internal/runners/internal/runbits`. #### internal/runners/ diff --git a/cmd/state-installer/cmd.go b/cmd/state-installer/cmd.go index 5dfc5bfc6f..3c7e13d26d 100644 --- a/cmd/state-installer/cmd.go +++ b/cmd/state-installer/cmd.go @@ -29,10 +29,10 @@ import ( "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/rollbar" + "github.com/ActiveState/cli/internal/runbits/errors" "github.com/ActiveState/cli/internal/runbits/panics" "github.com/ActiveState/cli/internal/subshell" "github.com/ActiveState/cli/internal/subshell/bash" - "github.com/ActiveState/cli/pkg/cmdlets/errors" "github.com/ActiveState/cli/pkg/project" "github.com/ActiveState/cli/pkg/sysinfo" "golang.org/x/crypto/ssh/terminal" diff --git a/cmd/state-remote-installer/main.go b/cmd/state-remote-installer/main.go index de30e8c678..3b0713db2e 100644 --- a/cmd/state-remote-installer/main.go +++ b/cmd/state-remote-installer/main.go @@ -25,9 +25,9 @@ import ( "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/rollbar" "github.com/ActiveState/cli/internal/rtutils/ptr" + "github.com/ActiveState/cli/internal/runbits/errors" "github.com/ActiveState/cli/internal/runbits/panics" "github.com/ActiveState/cli/internal/updater" - "github.com/ActiveState/cli/pkg/cmdlets/errors" ) type Params struct { diff --git a/cmd/state/main.go b/cmd/state/main.go index 7b0a876276..1108865693 100644 --- a/cmd/state/main.go +++ b/cmd/state/main.go @@ -29,11 +29,11 @@ import ( "github.com/ActiveState/cli/internal/prompt" _ "github.com/ActiveState/cli/internal/prompt" // Sets up survey defaults "github.com/ActiveState/cli/internal/rollbar" + "github.com/ActiveState/cli/internal/runbits/errors" "github.com/ActiveState/cli/internal/runbits/legacy/projectmigration" "github.com/ActiveState/cli/internal/runbits/panics" "github.com/ActiveState/cli/internal/subshell" "github.com/ActiveState/cli/internal/svcctl" - cmdletErrors "github.com/ActiveState/cli/pkg/cmdlets/errors" secretsapi "github.com/ActiveState/cli/pkg/platform/api/secrets" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" @@ -101,7 +101,7 @@ func main() { // Run our main command logic, which is logic that defers to the error handling logic below err = run(os.Args, isInteractive, cfg, out) if err != nil { - exitCode, err = cmdletErrors.ParseUserFacing(err) + exitCode, err = errors.ParseUserFacing(err) if err != nil { out.Error(err) } @@ -252,7 +252,7 @@ func run(args []string, isInteractive bool, cfg *config.Instance, out output.Out cmdName = childCmd.JoinedSubCommandNames() + " " } err = errs.AddTips(err, locale.Tl("err_tip_run_help", "Run → [ACTIONABLE]`state {{.V0}}--help`[/RESET] for general help", cmdName)) - cmdletErrors.ReportError(err, cmds.Command(), an) + errors.ReportError(err, cmds.Command(), an) } return err diff --git a/pkg/cmdlets/auth/keypair.go b/internal/runbits/auth/keypair.go similarity index 100% rename from pkg/cmdlets/auth/keypair.go rename to internal/runbits/auth/keypair.go diff --git a/pkg/cmdlets/auth/login.go b/internal/runbits/auth/login.go similarity index 100% rename from pkg/cmdlets/auth/login.go rename to internal/runbits/auth/login.go diff --git a/pkg/cmdlets/auth/signup.go b/internal/runbits/auth/signup.go similarity index 100% rename from pkg/cmdlets/auth/signup.go rename to internal/runbits/auth/signup.go diff --git a/pkg/cmdlets/checker/checker.go b/internal/runbits/checker/checker.go similarity index 100% rename from pkg/cmdlets/checker/checker.go rename to internal/runbits/checker/checker.go diff --git a/pkg/cmdlets/checkout/checkout.go b/internal/runbits/checkout/checkout.go similarity index 99% rename from pkg/cmdlets/checkout/checkout.go rename to internal/runbits/checkout/checkout.go index 26bd63b2ab..5692e31ef3 100644 --- a/pkg/cmdlets/checkout/checkout.go +++ b/internal/runbits/checkout/checkout.go @@ -14,7 +14,7 @@ import ( "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/language" "github.com/ActiveState/cli/internal/output" - "github.com/ActiveState/cli/pkg/cmdlets/git" + "github.com/ActiveState/cli/internal/runbits/git" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" diff --git a/pkg/cmdlets/checkout/path.go b/internal/runbits/checkout/path.go similarity index 100% rename from pkg/cmdlets/checkout/path.go rename to internal/runbits/checkout/path.go diff --git a/pkg/cmdlets/checkout/rationalize.go b/internal/runbits/checkout/rationalize.go similarity index 100% rename from pkg/cmdlets/checkout/rationalize.go rename to internal/runbits/checkout/rationalize.go diff --git a/pkg/cmdlets/commit/commit.go b/internal/runbits/commit/commit.go similarity index 100% rename from pkg/cmdlets/commit/commit.go rename to internal/runbits/commit/commit.go diff --git a/pkg/cmdlets/errors/errors.go b/internal/runbits/errors/errors.go similarity index 100% rename from pkg/cmdlets/errors/errors.go rename to internal/runbits/errors/errors.go diff --git a/pkg/cmdlets/git/git.go b/internal/runbits/git/git.go similarity index 100% rename from pkg/cmdlets/git/git.go rename to internal/runbits/git/git.go diff --git a/pkg/cmdlets/git/test/integration/git_test.go b/internal/runbits/git/test/integration/git_test.go similarity index 89% rename from pkg/cmdlets/git/test/integration/git_test.go rename to internal/runbits/git/test/integration/git_test.go index ca691edaeb..07412744bc 100644 --- a/pkg/cmdlets/git/test/integration/git_test.go +++ b/internal/runbits/git/test/integration/git_test.go @@ -16,8 +16,8 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/locale" + runbitsGit "github.com/ActiveState/cli/internal/runbits/git" "github.com/ActiveState/cli/internal/testhelpers/outputhelper" - gitlet "github.com/ActiveState/cli/pkg/cmdlets/git" "github.com/ActiveState/cli/pkg/project" ) @@ -79,7 +79,7 @@ func (suite *GitTestSuite) AfterTest(suiteName, testName string) { } func (suite *GitTestSuite) TestEnsureCorrectProject() { - err := gitlet.EnsureCorrectProject("test-owner", "test-project", filepath.Join(suite.dir, constants.ConfigFileName), "test-repo", outputhelper.NewCatcher(), blackhole.New()) + err := runbitsGit.EnsureCorrectProject("test-owner", "test-project", filepath.Join(suite.dir, constants.ConfigFileName), "test-repo", outputhelper.NewCatcher(), blackhole.New()) suite.NoError(err, "projectfile URL should contain owner and name") } @@ -88,7 +88,7 @@ func (suite *GitTestSuite) TestEnsureCorrectProject_Missmatch() { name := "bad-project" projectPath := filepath.Join(suite.dir, constants.ConfigFileName) actualCatcher := outputhelper.NewCatcher() - err := gitlet.EnsureCorrectProject(owner, name, projectPath, "test-repo", actualCatcher, blackhole.New()) + err := runbitsGit.EnsureCorrectProject(owner, name, projectPath, "test-repo", actualCatcher, blackhole.New()) suite.NoError(err) proj, err := project.Parse(projectPath) @@ -104,7 +104,7 @@ func (suite *GitTestSuite) TestEnsureCorrectProject_Missmatch() { func (suite *GitTestSuite) TestMoveFiles() { anotherDir := filepath.Join(suite.anotherDir, "anotherDir") - err := gitlet.MoveFiles(suite.dir, anotherDir) + err := runbitsGit.MoveFiles(suite.dir, anotherDir) suite.NoError(err, "should be able to move files wihout error") _, err = os.Stat(filepath.Join(anotherDir, constants.ConfigFileName)) @@ -122,7 +122,7 @@ func (suite *GitTestSuite) TestMoveFilesDirNoEmpty() { err = fileutils.Touch(filepath.Join(anotherDir, "file.txt")) suite.Require().NoError(err) - err = gitlet.MoveFiles(suite.dir, anotherDir) + err = runbitsGit.MoveFiles(suite.dir, anotherDir) expected := locale.WrapError(err, "err_git_verify_dir", "Could not verify destination directory") suite.EqualError(err, expected.Error()) } diff --git a/internal/runners/activate/activate.go b/internal/runners/activate/activate.go index 94ba86b3b4..f83cfde243 100644 --- a/internal/runners/activate/activate.go +++ b/internal/runners/activate/activate.go @@ -22,14 +22,14 @@ import ( "github.com/ActiveState/cli/internal/process" "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/runbits/activation" + "github.com/ActiveState/cli/internal/runbits/checker" + "github.com/ActiveState/cli/internal/runbits/checkout" "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/runbits/findproject" + "github.com/ActiveState/cli/internal/runbits/git" "github.com/ActiveState/cli/internal/runbits/runtime" "github.com/ActiveState/cli/internal/subshell" "github.com/ActiveState/cli/internal/virtualenvironment" - "github.com/ActiveState/cli/pkg/cmdlets/checker" - "github.com/ActiveState/cli/pkg/cmdlets/checkout" - "github.com/ActiveState/cli/pkg/cmdlets/git" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/target" diff --git a/internal/runners/auth/auth.go b/internal/runners/auth/auth.go index 5a16385a8a..57efc2e415 100644 --- a/internal/runners/auth/auth.go +++ b/internal/runners/auth/auth.go @@ -6,7 +6,7 @@ import ( "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/prompt" - authlet "github.com/ActiveState/cli/pkg/cmdlets/auth" + "github.com/ActiveState/cli/internal/runbits/auth" "github.com/ActiveState/cli/pkg/platform/authentication" ) @@ -84,18 +84,18 @@ func (a *Auth) Run(params *AuthParams) error { func (a *Auth) authenticate(params *AuthParams) error { if params.Prompt || params.Username != "" { - return authlet.AuthenticateWithInput(params.Username, params.Password, params.Totp, params.NonInteractive, a.Cfg, a.Outputer, a.Prompter, a.Auth) + return auth.AuthenticateWithInput(params.Username, params.Password, params.Totp, params.NonInteractive, a.Cfg, a.Outputer, a.Prompter, a.Auth) } if params.Token != "" { - return authlet.AuthenticateWithToken(params.Token, a.Auth) + return auth.AuthenticateWithToken(params.Token, a.Auth) } if params.NonInteractive { return locale.NewInputError("err_auth_needinput") } - return authlet.AuthenticateWithBrowser(a.Outputer, a.Auth, a.Prompter) + return auth.AuthenticateWithBrowser(a.Outputer, a.Auth, a.Prompter) } func (a *Auth) verifyAuthentication() error { diff --git a/internal/runners/auth/signup.go b/internal/runners/auth/signup.go index 66183b4f8b..75ac4997b0 100644 --- a/internal/runners/auth/signup.go +++ b/internal/runners/auth/signup.go @@ -5,7 +5,7 @@ import ( "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/prompt" - authlet "github.com/ActiveState/cli/pkg/cmdlets/auth" + "github.com/ActiveState/cli/internal/runbits/auth" "github.com/ActiveState/cli/pkg/platform/authentication" ) @@ -29,5 +29,5 @@ func (s *Signup) Run(params *SignupParams) error { return locale.NewInputError("err_auth_authenticated", "You are already authenticated as: {{.V0}}. You can log out by running `state auth logout`.", s.Auth.WhoAmI()) } - return authlet.SignupWithBrowser(s.Outputer, s.Auth, s.Prompter) + return auth.SignupWithBrowser(s.Outputer, s.Auth, s.Prompter) } diff --git a/internal/runners/checkout/checkout.go b/internal/runners/checkout/checkout.go index 2f5b18fec8..d5ad5319f5 100644 --- a/internal/runners/checkout/checkout.go +++ b/internal/runners/checkout/checkout.go @@ -8,11 +8,11 @@ import ( "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" + "github.com/ActiveState/cli/internal/runbits/checker" + "github.com/ActiveState/cli/internal/runbits/checkout" + "github.com/ActiveState/cli/internal/runbits/git" "github.com/ActiveState/cli/internal/runbits/runtime" "github.com/ActiveState/cli/internal/subshell" - "github.com/ActiveState/cli/pkg/cmdlets/checker" - "github.com/ActiveState/cli/pkg/cmdlets/checkout" - "github.com/ActiveState/cli/pkg/cmdlets/git" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/setup" diff --git a/internal/runners/history/history.go b/internal/runners/history/history.go index 55f7d26e49..0ba655b9e0 100644 --- a/internal/runners/history/history.go +++ b/internal/runners/history/history.go @@ -5,8 +5,8 @@ import ( "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" + "github.com/ActiveState/cli/internal/runbits/commit" "github.com/ActiveState/cli/internal/runbits/commitmediator" - "github.com/ActiveState/cli/pkg/cmdlets/commit" "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" diff --git a/internal/runners/pull/pull.go b/internal/runners/pull/pull.go index cec6397029..5ece1db6cb 100644 --- a/internal/runners/pull/pull.go +++ b/internal/runners/pull/pull.go @@ -15,8 +15,8 @@ import ( "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/runbits" buildscriptRunbits "github.com/ActiveState/cli/internal/runbits/buildscript" + "github.com/ActiveState/cli/internal/runbits/commit" "github.com/ActiveState/cli/internal/runbits/commitmediator" - "github.com/ActiveState/cli/pkg/cmdlets/commit" "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" diff --git a/internal/runners/revert/revert.go b/internal/runners/revert/revert.go index 0462e26bbc..586e5af02a 100644 --- a/internal/runners/revert/revert.go +++ b/internal/runners/revert/revert.go @@ -8,8 +8,8 @@ import ( "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/runbits" + "github.com/ActiveState/cli/internal/runbits/commit" "github.com/ActiveState/cli/internal/runbits/commitmediator" - "github.com/ActiveState/cli/pkg/cmdlets/commit" gqlmodel "github.com/ActiveState/cli/pkg/platform/api/graphql/model" "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" diff --git a/internal/runners/run/run.go b/internal/runners/run/run.go index 6037ee2042..dc62091646 100644 --- a/internal/runners/run/run.go +++ b/internal/runners/run/run.go @@ -10,9 +10,9 @@ import ( "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" + "github.com/ActiveState/cli/internal/runbits/checker" "github.com/ActiveState/cli/internal/scriptrun" "github.com/ActiveState/cli/internal/subshell" - "github.com/ActiveState/cli/pkg/cmdlets/checker" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" diff --git a/internal/runners/state/state.go b/internal/runners/state/state.go index 6e40f7d4d6..1b6ddc3849 100644 --- a/internal/runners/state/state.go +++ b/internal/runners/state/state.go @@ -11,7 +11,7 @@ import ( "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/profile" - "github.com/ActiveState/cli/pkg/cmdlets/checker" + "github.com/ActiveState/cli/internal/runbits/checker" "github.com/ActiveState/cli/pkg/platform/model" ) diff --git a/internal/runners/use/use.go b/internal/runners/use/use.go index 7b42f8d641..c752af05dc 100644 --- a/internal/runners/use/use.go +++ b/internal/runners/use/use.go @@ -12,13 +12,13 @@ import ( "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/prompt" + "github.com/ActiveState/cli/internal/runbits/checker" + "github.com/ActiveState/cli/internal/runbits/checkout" "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/runbits/findproject" + "github.com/ActiveState/cli/internal/runbits/git" "github.com/ActiveState/cli/internal/runbits/runtime" "github.com/ActiveState/cli/internal/subshell" - "github.com/ActiveState/cli/pkg/cmdlets/checker" - "github.com/ActiveState/cli/pkg/cmdlets/checkout" - "github.com/ActiveState/cli/pkg/cmdlets/git" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/setup" diff --git a/pkg/cmdlets/README.md b/pkg/cmdlets/README.md deleted file mode 100644 index 314a6c7637..0000000000 --- a/pkg/cmdlets/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Commandlets (cmdlets) are packages that contain logic used by our commands that do not belong in any other package. In -most cases this logic is contained in the command itself, but in some cases logic needs to be shared between commands, -this is where cmdlets come in. \ No newline at end of file