diff --git a/changelog.md b/changelog.md index 45c9fc571b..1073d929d9 100644 --- a/changelog.md +++ b/changelog.md @@ -26,6 +26,8 @@ workflow. headless projects) ([PR #1198](https://github.com/ActiveState/cli/pull/1198)) - You can now switch between update channels via `state update --set-channel` ([PR #1190](https://github.com/ActiveState/cli/pull/1190)) +- State tool will now provide instructions on how to get out of a detached + state ([PR #1249](https://github.com/ActiveState/cli/pull/1249)) - State tool now supports branches via flags in `state activate` and the `state branch` subcommand. See `state branch --help` for more information. diff --git a/cmd/state/internal/cmdtree/activate.go b/cmd/state/internal/cmdtree/activate.go index f17ffc90b6..bdb55bbd6c 100644 --- a/cmd/state/internal/cmdtree/activate.go +++ b/cmd/state/internal/cmdtree/activate.go @@ -14,6 +14,8 @@ import ( "github.com/ActiveState/cli/pkg/project" ) +const activateCmdName = "activate" + func newActivateCommand(prime *primer.Values) *captain.Command { runner := activate.NewActivate(prime) @@ -23,7 +25,7 @@ func newActivateCommand(prime *primer.Values) *captain.Command { } cmd := captain.NewCommand( - "activate", + activateCmdName, "", locale.T("activate_project"), prime.Output(), diff --git a/cmd/state/internal/cmdtree/cmdtree.go b/cmd/state/internal/cmdtree/cmdtree.go index 7ea4021803..d3236d7884 100644 --- a/cmd/state/internal/cmdtree/cmdtree.go +++ b/cmd/state/internal/cmdtree/cmdtree.go @@ -4,11 +4,14 @@ import ( "github.com/ActiveState/cli/cmd/state/internal/cmdtree/intercepts/cmdcall" "github.com/ActiveState/cli/internal/captain" "github.com/ActiveState/cli/internal/condition" + "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" + "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/runners/state" secretsapi "github.com/ActiveState/cli/pkg/platform/api/secrets" + "github.com/ActiveState/cli/pkg/project" ) // CmdTree manages a tree of captain.Command instances. @@ -266,7 +269,7 @@ func newStateCommand(globals *globalOptions, prime *primer.Values) *captain.Comm cmdCall := cmdcall.New(prime) - cmd.SetInterceptChain(cmdCall.InterceptExec) + cmd.SetInterceptChain(cmdCall.InterceptExec, interceptAddHeadlessNotify(prime.Output(), prime.Project())) return cmd } @@ -312,3 +315,16 @@ func (a *addCmdAs) deprecatedAlias(aliased *captain.Command, name string) { a.parent.AddChildren(cmd) } + +func interceptAddHeadlessNotify(out output.Outputer, pj *project.Project) captain.InterceptFunc { + return func(next captain.ExecuteFunc) captain.ExecuteFunc { + return func(cmd *captain.Command, args []string) error { + if pj != nil && pj.IsHeadless() && (cmd.Group() == PackagesGroup || cmd.Name() == activateCmdName) { + out.Notice(output.Heading(locale.Tr("headless_notify_title"))) + out.Notice(locale.Tr("headless_notify", pj.URL(), constants.DocumentationURLHeadless)) + } + + return next(cmd, args) + } + } +} diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 4de4f80eaf..dcd810cb2a 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -173,6 +173,9 @@ 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/" + // BugTrackerURL is the URL of our bug tracker const BugTrackerURL = "https://github.com/ActiveState/state-tool/issues" diff --git a/locale/en-us.yaml b/locale/en-us.yaml index 201169853c..96eb489216 100644 --- a/locale/en-us.yaml +++ b/locale/en-us.yaml @@ -1654,3 +1654,10 @@ err_fetch_branch: other: "Cold not get branch [NOTICE]{{.V0}}[/RESET] for project" err_refresh_runtime: other: "Failed to update runtime" +headless_notify_title: + other: Detached State +headless_notify: + other: | + Any changes you make are local only and will not be saved the platform. Visit: [ACTIONABLE]{{.V0}}[/RESET] to create a platform project from this commit. + + For more information, including how to merge these changes into an existing project, visit: [ACTIONABLE]{{.V1}}[/RESET]. diff --git a/test/integration/package_int_test.go b/test/integration/package_int_test.go index 670d8956ce..5cf36100b3 100644 --- a/test/integration/package_int_test.go +++ b/test/integration/package_int_test.go @@ -362,6 +362,7 @@ func (suite *PackageIntegrationTestSuite) TestPackage_headless_operation() { suite.Run("install (update)", func() { cp := ts.Spawn("install", "dateparser@0.7.6") + cp.ExpectLongString("Any changes you make are local only") cp.ExpectRe("(?:Package updated|project is currently building)", 50*time.Second) cp.Wait() }) diff --git a/version.txt b/version.txt index af2dabf3ff..4e8f395fa5 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.25.1 +0.26.0