diff --git a/api/openapi.gen.go b/api/openapi.gen.go index 59d03df..b6d92c2 100644 --- a/api/openapi.gen.go +++ b/api/openapi.gen.go @@ -408,7 +408,7 @@ type CreateClientJSONBody struct { // CreateOrgJSONBody defines parameters for CreateOrg. type CreateOrgJSONBody struct { - // Name The name for this organization. + // Name The name for the new organization. Name string `json:"name"` } diff --git a/cmd.go b/cmd.go index 034333f..cb11cce 100644 --- a/cmd.go +++ b/cmd.go @@ -141,6 +141,22 @@ var rootDef = CmdDef{ }, }, }, + { + Name: "org", + + Use: "org [flags]", + Args: cobra.NoArgs, + Short: "Manage Organizations", + SubDefs: []CmdDef{ + { + Name: "create", + + Use: "create [flags]", + Args: cobra.NoArgs, + Short: "Create New Organization", + }, + }, + }, { Name: "service", diff --git a/cmd/anchor/main.go b/cmd/anchor/main.go index 523c02d..f9010e3 100644 --- a/cmd/anchor/main.go +++ b/cmd/anchor/main.go @@ -8,6 +8,7 @@ import ( "github.com/anchordotdev/cli" _ "github.com/anchordotdev/cli/auth" _ "github.com/anchordotdev/cli/lcl" + _ "github.com/anchordotdev/cli/org" _ "github.com/anchordotdev/cli/service" _ "github.com/anchordotdev/cli/trust" versionpkg "github.com/anchordotdev/cli/version" diff --git a/component/selector.go b/component/selector.go index 65f8a52..2c95a5f 100644 --- a/component/selector.go +++ b/component/selector.go @@ -54,9 +54,12 @@ func (s *Selector[T]) Choice(ctx context.Context, drv *ui.Driver) (*T, error) { var choices []ui.ListItem[T] for _, item := range s.Choices { choice := ui.ListItem[T]{ - Key: item.Key(), - String: fmt.Sprintf("%s (%s)", item.String(), item.Key()), - Value: item, + Key: item.Key(), + String: fmt.Sprintf("%s %s", + item.String(), + ui.Whisper(fmt.Sprintf("(%s)", item.Key())), + ), + Value: item, } choices = append(choices, choice) } diff --git a/lcl/bootstrap_test.go b/lcl/bootstrap_test.go index 595b9fd..a98def9 100644 --- a/lcl/bootstrap_test.go +++ b/lcl/bootstrap_test.go @@ -105,10 +105,11 @@ func TestBootstrap(t *testing.T) { "? What lcl.host domain would you like to use for diagnostics?", ) - tm.Type("hello-world") tm.Send(tea.KeyMsg{ - Type: tea.KeyEnter, + Runes: []rune("hello-world"), + Type: tea.KeyRunes, }) + tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) if !srv.IsProxy() { t.Skip("diagnostic unsupported in mock mode") diff --git a/lcl/lcl.go b/lcl/lcl.go index f55b2ff..70142c8 100644 --- a/lcl/lcl.go +++ b/lcl/lcl.go @@ -34,6 +34,7 @@ var CmdLcl = cli.NewCmd[Command](cli.CmdRoot, "lcl", func(cmd *cobra.Command) { // setup cmd.Flags().StringVar(&cfg.Service.Category, "category", cli.Defaults.Service.Category, "Language or software type of the service.") cmd.Flags().StringVar(&cfg.Service.CertStyle, "cert-style", cli.Defaults.Service.CertStyle, "Provisioning method for lcl.host certificates.") + cmd.Flags().StringVar(&cfg.Org.Name, "org-name", "", "Name for created org.") // alias cmd.Flags().StringVar(&cfg.Service.Category, "language", cli.Defaults.Service.Category, "Language to integrate with Anchor.") diff --git a/lcl/lcl_test.go b/lcl/lcl_test.go index c30c615..ca9d838 100644 --- a/lcl/lcl_test.go +++ b/lcl/lcl_test.go @@ -89,10 +89,15 @@ func TestCmdLcl(t *testing.T) { }) t.Run("--cert-style acme", func(t *testing.T) { - cfg := cmdtest.TestCfg(t, CmdLcl, "--method", "acme") + cfg := cmdtest.TestCfg(t, CmdLcl, "--cert-style", "acme") require.Equal(t, "acme", cfg.Service.CertStyle) }) + t.Run("--org-name org", func(t *testing.T) { + cfg := cmdtest.TestCfg(t, CmdLcl, "--org-name", "org") + require.Equal(t, "org", cfg.Org.Name) + }) + // alias t.Run("--language python", func(t *testing.T) { @@ -174,7 +179,10 @@ func TestLcl(t *testing.T) { "? What lcl.host domain would you like to use for diagnostics?", ) - tm.Type("hello-world") + tm.Send(tea.KeyMsg{ + Runes: []rune("hello-world"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, @@ -231,7 +239,10 @@ func TestLcl(t *testing.T) { uitest.WaitForGoldenContains(t, drv, errc, "? What is the application name?", ) - tm.Type("test-app") + tm.Send(tea.KeyMsg{ + Runes: []rune("test-app"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, diff --git a/lcl/setup.go b/lcl/setup.go index cc06582..40cdc9a 100644 --- a/lcl/setup.go +++ b/lcl/setup.go @@ -22,6 +22,8 @@ import ( "github.com/anchordotdev/cli/detection" "github.com/anchordotdev/cli/lcl/models" climodels "github.com/anchordotdev/cli/models" + "github.com/anchordotdev/cli/org" + orgmodels "github.com/anchordotdev/cli/org/models" "github.com/anchordotdev/cli/service" servicemodels "github.com/anchordotdev/cli/service/models" "github.com/anchordotdev/cli/ui" @@ -33,6 +35,7 @@ var CmdLclSetup = cli.NewCmd[Setup](CmdLcl, "setup", func(cmd *cobra.Command) { cmd.Flags().StringVar(&cfg.Service.Category, "category", cli.Defaults.Service.Category, "Language or software type of the service.") cmd.Flags().StringVar(&cfg.Service.CertStyle, "cert-style", cli.Defaults.Service.CertStyle, "Provisioning method for lcl.host certificates.") cmd.Flags().StringVarP(&cfg.Org.APID, "org", "o", cli.Defaults.Org.APID, "Organization for lcl.host application setup.") + cmd.Flags().StringVar(&cfg.Org.Name, "org-name", "", "Name for created org.") cmd.Flags().StringVarP(&cfg.Lcl.RealmAPID, "realm", "r", cli.Defaults.Lcl.RealmAPID, "Realm for lcl.host application setup.") cmd.Flags().StringVarP(&cfg.Service.APID, "service", "s", cli.Defaults.Service.APID, "Service for lcl.host application setup.") @@ -227,42 +230,30 @@ func (c *Setup) orgAPID(ctx context.Context, cfg *cli.Config, drv *ui.Driver) (s }, } - org, err := selector.Choice(ctx, drv) + selectedOrg, err := selector.Choice(ctx, drv) if err != nil { return "", err } - if org == nil || (*org == api.Organization{}) { - orgName, err := c.orgName(ctx, cfg, drv) - if err != nil { - return "", err + if selectedOrg == nil || (*selectedOrg == api.Organization{}) { + drv.Activate(ctx, &orgmodels.OrgCreateHeader{}) + drv.Activate(ctx, &orgmodels.OrgCreateHint{}) + defer drv.Send(ui.HideModelsMsg{ + Models: []string{"OrgCreateHeader", "OrgCreateHint"}, + }) + + cmdOrgCreate := &org.Create{ + Anc: c.anc, } - if org, err = c.anc.CreateOrg(ctx, orgName); err != nil { + org, err := cmdOrgCreate.Perform(ctx, drv) + if err != nil { return "", err } - // FIXME: provide nicer output about using newly created value, and hint flag? - return org.Apid, nil - } - return org.Apid, nil - -} -func (c *Setup) orgName(ctx context.Context, cfg *cli.Config, drv *ui.Driver) (string, error) { - if cfg.Org.Name != "" { - return cfg.Org.Name, nil + return org.Apid, nil } + return selectedOrg.Apid, nil - inputc := make(chan string) - drv.Activate(ctx, &models.SetupOrgName{ - InputCh: inputc, - }) - - select { - case orgName := <-inputc: - return orgName, nil - case <-ctx.Done(): - return "", ctx.Err() - } } func (c *Setup) realmAPID(ctx context.Context, cfg *cli.Config, drv *ui.Driver, orgAPID string) (string, error) { diff --git a/lcl/setup_test.go b/lcl/setup_test.go index dceaf2e..d71d6f7 100644 --- a/lcl/setup_test.go +++ b/lcl/setup_test.go @@ -29,10 +29,15 @@ func TestCmdLclSetup(t *testing.T) { }) t.Run("--cert-style acme", func(t *testing.T) { - cfg := cmdtest.TestCfg(t, CmdLclSetup, "--method", "acme") + cfg := cmdtest.TestCfg(t, CmdLclSetup, "--cert-style", "acme") require.Equal(t, "acme", cfg.Service.CertStyle) }) + t.Run("--org-name org", func(t *testing.T) { + cfg := cmdtest.TestCfg(t, CmdLclSetup, "--org-name", "org") + require.Equal(t, "org", cfg.Org.Name) + }) + // alias t.Run("--language python", func(t *testing.T) { @@ -59,7 +64,9 @@ func TestSetup(t *testing.T) { cfg := cmdtest.Config(ctx) cfg.API.URL = srv.URL - cfg.Test.ACME.URL = "http://anchor.lcl.host:" + srv.RailsPort + if srv.IsProxy() { + cfg.Test.ACME.URL = "http://anchor.lcl.host:" + srv.RailsPort + } cfg.Trust.MockMode = true cfg.Trust.NoSudo = true cfg.Trust.Stores = []string{"mock"} @@ -73,6 +80,67 @@ func TestSetup(t *testing.T) { setupGuideURL := cfg.SetupGuideURL("lcl_setup", "test-app") + t.Run("create-org-existing-service-basics", func(t *testing.T) { + if srv.IsProxy() { + t.Skip("lcl setup existing service unsupported in proxy mode") + } + + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + drv, tm := uitest.TestTUI(ctx, t) + + cmd := Setup{ + clipboard: new(clipboard.Mock), + } + + errc := make(chan error, 1) + go func() { + errc <- cmd.UI().RunTUI(ctx, drv) + errc <- tm.Quit() + }() + + uitest.WaitForGoldenContains(t, drv, errc, + "? Which organization's lcl.host local development environment do you want to setup?", + ) + tm.Send(tea.KeyMsg{Type: tea.KeyDown}) + tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) // select second option, "Create New Org" + + uitest.WaitForGoldenContains(t, drv, errc, + "? What is the new organization's name?", + ) + tm.Send(tea.KeyMsg{ + Runes: []rune("Org Name"), + Type: tea.KeyRunes, + }) + tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) + + uitest.WaitForGoldenContains(t, drv, errc, + "? Which org-slug/realm-slug service's lcl.host local development environment do you want to setup?", + ) + tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) + + uitest.WaitForGoldenContains(t, drv, errc, + "? How would you like to manage your environment variables?", + ) + + tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) + + tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3)) + + env, err := cmd.clipboard.ReadAll() + if err != nil { + t.Fatal(err) + } + + want := "export ACME_CONTACT=\"anky@anchor.dev\"\nexport ACME_DIRECTORY_URL=\"https://anchor.dev/org-slug/realm-slug/x509/ca/acme\"\nexport ACME_HMAC_KEY=\"abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nexport ACME_KID=\"aae_abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEF\"\nexport HTTPS_PORT=\"4433\"\nexport SERVER_NAMES=\"service.lcl.host\"\n" + if got := env; want != got { + t.Errorf("Want env clipboard:\n\n%q,\n\nGot:\n\n%q\n\n", want, got) + } + + uitest.TestGolden(t, drv.Golden()) + }) + t.Run("create-service-automated-basics", func(t *testing.T) { if srv.IsMock() { t.Skip("lcl setup create service unsupported in mock mode") @@ -108,7 +176,10 @@ func TestSetup(t *testing.T) { "? What is the application name?", ) - tm.Type("test-app") + tm.Send(tea.KeyMsg{ + Runes: []rune("test-app"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, @@ -181,7 +252,6 @@ func TestSetup(t *testing.T) { uitest.WaitForGoldenContains(t, drv, errc, "? Which lcl_setup/localhost service's lcl.host local development environment do you want to setup?", ) - tm.Send(tea.KeyMsg{Type: tea.KeyDown}) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) @@ -195,7 +265,10 @@ func TestSetup(t *testing.T) { "? What is the application name?", ) - tm.Type("test-app") + tm.Send(tea.KeyMsg{ + Runes: []rune("test-app"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, @@ -219,7 +292,7 @@ func TestSetup(t *testing.T) { } }) - t.Run(fmt.Sprintf("existing-service-basics-%s", uitest.TestTagOS()), func(t *testing.T) { + t.Run("existing-service-basics", func(t *testing.T) { if srv.IsProxy() { t.Skip("lcl setup existing service unsupported in proxy mode") } @@ -258,7 +331,15 @@ func TestSetup(t *testing.T) { tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3)) - // FIXME: check clipboard values for accuracy (can't easily access values) + env, err := cmd.clipboard.ReadAll() + if err != nil { + t.Fatal(err) + } + + want := "export ACME_CONTACT=\"anky@anchor.dev\"\nexport ACME_DIRECTORY_URL=\"https://anchor.dev/org-slug/realm-slug/x509/ca/acme\"\nexport ACME_HMAC_KEY=\"abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nexport ACME_KID=\"aae_abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEF\"\nexport HTTPS_PORT=\"4433\"\nexport SERVER_NAMES=\"service.lcl.host\"\n" + if got := env; want != got { + t.Errorf("Want env clipboard:\n\n%q,\n\nGot:\n\n%q\n\n", want, got) + } uitest.TestGolden(t, drv.Golden()) }) @@ -305,7 +386,10 @@ func TestSetup(t *testing.T) { "? What is the application name?", ) - tm.Type("Test App") + tm.Send(tea.KeyMsg{ + Runes: []rune("Test App"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, @@ -370,15 +454,19 @@ func TestSetup(t *testing.T) { uitest.WaitForGoldenContains(t, drv, errc, "? What is the application name?", ) - - tm.Type("test-explicit-subdomain-app") + tm.Send(tea.KeyMsg{ + Runes: []rune("test-explicit-subdomain-app"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, "? What lcl.host domain would you like to use for local application development?", ) - - tm.Type("this-is-my-weird-subdomain") + tm.Send(tea.KeyMsg{ + Runes: []rune("this-is-my-weird-subdomain"), + Type: tea.KeyRunes, + }) tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) uitest.WaitForGoldenContains(t, drv, errc, diff --git a/lcl/testdata/TestBootstrap/basics.golden b/lcl/testdata/TestBootstrap/basics.golden index 2c1b448..ccf2a6e 100644 --- a/lcl/testdata/TestBootstrap/basics.golden +++ b/lcl/testdata/TestBootstrap/basics.golden @@ -29,86 +29,6 @@ ? hi-lcl_config.lcl.host ─── DomainInput ──────────────────────────────────────────────────────────────── -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? h.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? he.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hel.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hell.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-w.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-wo.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-wor.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-worl.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - # Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` | We'll configure your browsers and OS to trust your local development certificates. - Checked diagnostic service on Anchor.dev: need to provision service. diff --git a/lcl/testdata/TestCmdLcl/--help.golden b/lcl/testdata/TestCmdLcl/--help.golden index ee85845..836668a 100644 --- a/lcl/testdata/TestCmdLcl/--help.golden +++ b/lcl/testdata/TestCmdLcl/--help.golden @@ -19,6 +19,7 @@ Flags: --domains strings Domains to create certificate for. -h, --help help for lcl -o, --org string Organization for lcl.host local development environment management. + --org-name string Name for created org. -r, --realm string Realm for lcl.host local development environment management. -s, --service string Service for lcl.host local development environment management. --subca string SubCA to create certificate for. diff --git a/lcl/testdata/TestCmdLclSetup/--help.golden b/lcl/testdata/TestCmdLclSetup/--help.golden index 07ec88e..1918aa8 100644 --- a/lcl/testdata/TestCmdLclSetup/--help.golden +++ b/lcl/testdata/TestCmdLclSetup/--help.golden @@ -8,6 +8,7 @@ Flags: --cert-style string Provisioning method for lcl.host certificates. -h, --help help for setup -o, --org string Organization for lcl.host application setup. + --org-name string Name for created org. -r, --realm string Realm for lcl.host application setup. -s, --service string Service for lcl.host application setup. diff --git a/lcl/testdata/TestLcl/basics.golden b/lcl/testdata/TestLcl/basics.golden index 00dc308..af56f29 100644 --- a/lcl/testdata/TestLcl/basics.golden +++ b/lcl/testdata/TestLcl/basics.golden @@ -114,166 +114,6 @@ ─── DomainInput ──────────────────────────────────────────────────────────────── | Let's set up fast and totally free lcl.host HTTPS! -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? h.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? he.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hel.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hell.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-w.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-wo.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-wor.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - ? What lcl.host domain would you like to use for diagnostics? - | We'll ignore any characters that are not valid in a domain. - ? hello-worl.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - # Setup lcl.host HTTPS Local Development Environment `anchor lcl` | We'll set you up to use HTTPS locally in your browsers and other programs. @@ -1079,244 +919,6 @@ ─── SetupServiceName ─────────────────────────────────────────────────────────── | Let's set up fast and totally free lcl.host HTTPS! -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? t -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? te -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? tes -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test- -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-a -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - -# Setup lcl.host HTTPS Local Development Environment `anchor lcl` - | We'll set you up to use HTTPS locally in your browsers and other programs. - -# Audit lcl.host HTTPS Local Development Environment `anchor lcl audit` - | We'll compare your local development CA certificates from Anchor and your local trust stores. - - Compared local and expected CA certificates: need to install 2 missing certificates. - -# Initial System Configuration for lcl.host Local HTTPS Development `anchor lcl bootstrap` - | We'll configure your browsers and OS to trust your local development certificates. - - Checked diagnostic service on Anchor.dev: need to provision service. - - Entered hello-world.lcl.host domain for lcl.host diagnostic certificate. - - Resolved hello-world.lcl.host domain: success! - | Now we'll provision Anchor.dev resources and HTTPS certificates for you. - - Created hello-world [hello-world.lcl.host, hello-world.localhost] diagnostic resources on Anchor.dev. - - Great, http://hello-world.lcl.host:4433 works as expected (without HTTPS). - | Now, we'll add your personal CA certificates to your system's trust stores. - -# Manage CA Certificates in your Local Trust Store(s) `anchor trust` - - Updated Mock: installed lcl/localhost - AnchorCA [ECDSA, RSA] - | Before we move on, let's test HTTPS. - - Success! https://hello-world.lcl.host:4433 works as expected (encrypted with HTTPS). - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl organization. You can also use `--org lcl`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-ap -─── SetupServiceName ─────────────────────────────────────────────────────────── -| Let's set up fast and totally free lcl.host HTTPS! - # Setup lcl.host HTTPS Local Development Environment `anchor lcl` | We'll set you up to use HTTPS locally in your browsers and other programs. diff --git a/lcl/testdata/TestSetup/existing-service-basics-windows.golden b/lcl/testdata/TestSetup/create-org-existing-service-basics.golden similarity index 64% rename from lcl/testdata/TestSetup/existing-service-basics-windows.golden rename to lcl/testdata/TestSetup/create-org-existing-service-basics.golden index dcda2b8..9666b58 100644 --- a/lcl/testdata/TestSetup/existing-service-basics-windows.golden +++ b/lcl/testdata/TestSetup/create-org-existing-service-basics.golden @@ -29,37 +29,126 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + ? Which organization's lcl.host local development environment do you want to setup? + Org Slug (org-slug) + > Create New Organization +─── Selector[github.com/anchordotdev/cli/api.Organization] ───────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. +─── OrgCreateHeader ──────────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` +─── OrgCreateHint ────────────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. +─── CreateOrgNameInput ───────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + ? What is the new organization's name? + ? +─── CreateOrgNameInput ───────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + ? What is the new organization's name? + ? Org Name +─── CreateOrgNameInput ───────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + - Entered Org Name organization name. +─── CreateOrgSpinner ─────────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + - Entered Org Name organization name. + * Creating new organization…⠋ +─── CreateOrgSpinner ─────────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. +─── CreateOrgResult ──────────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + - Created Org Name (org-slug) organization. +─── CreateOrgResult ──────────────────────────────────────────────────────────── + +# Setup lcl.host Application `anchor lcl setup` + | We'll integrate your application and system for HTTPS local development. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. ─── Fetcher[github.com/anchordotdev/cli/api.Realm] ───────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. * Fetching realms…⠋ ─── Fetcher[github.com/anchordotdev/cli/api.Realm] ───────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. ─── Fetcher[github.com/anchordotdev/cli/api.Service] ─────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. * Fetching services…⠋ ─── Fetcher[github.com/anchordotdev/cli/api.Service] ─────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. ─── Selector[github.com/anchordotdev/cli/api.Service] ────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. ? Which org-slug/realm-slug service's lcl.host local development environment do you want to setup? > service-name (service-name) @@ -68,14 +157,16 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. ─── ServiceEnvHeader ─────────────────────────────────────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -84,7 +175,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -94,7 +186,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -105,7 +198,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -115,7 +209,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -129,7 +224,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -140,7 +236,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. @@ -153,7 +250,8 @@ # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - - Selected org-slug organization. You can also use `--org org-slug`. + - Selected Create New Organization. + - Created Org Name (org-slug) organization. - Using realm-slug, the only available realm. You can also use `--realm realm-slug`. - Selected service-name service. You can also use `--service service-name`. diff --git a/lcl/testdata/TestSetup/create-service-automated-basics.golden b/lcl/testdata/TestSetup/create-service-automated-basics.golden index e733199..17de654 100644 --- a/lcl/testdata/TestSetup/create-service-automated-basics.golden +++ b/lcl/testdata/TestSetup/create-service-automated-basics.golden @@ -108,83 +108,6 @@ ? lcl ─── SetupServiceName ─────────────────────────────────────────────────────────── -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? t -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? te -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? tes -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test- -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-a -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - No services found, so we'll create one. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-ap -─── SetupServiceName ─────────────────────────────────────────────────────────── - # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - Selected lcl_setup organization. You can also use `--org lcl_setup`. diff --git a/lcl/testdata/TestSetup/create-service-manual-basics.golden b/lcl/testdata/TestSetup/create-service-manual-basics.golden index 94000b7..63b1bf5 100644 --- a/lcl/testdata/TestSetup/create-service-manual-basics.golden +++ b/lcl/testdata/TestSetup/create-service-manual-basics.golden @@ -132,83 +132,6 @@ ? lcl ─── SetupServiceName ─────────────────────────────────────────────────────────── -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? t -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? te -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? tes -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test- -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-a -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-ap -─── SetupServiceName ─────────────────────────────────────────────────────────── - # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - Selected lcl_setup organization. You can also use `--org lcl_setup`. diff --git a/lcl/testdata/TestSetup/create-service-with-custom-domain.golden b/lcl/testdata/TestSetup/create-service-with-custom-domain.golden index 980320b..8f96f9e 100644 --- a/lcl/testdata/TestSetup/create-service-with-custom-domain.golden +++ b/lcl/testdata/TestSetup/create-service-with-custom-domain.golden @@ -140,616 +140,8 @@ - Scanned current directory. - Entered go application server type. ? What is the application name? - ? t -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? te -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? tes -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test- -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-e -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-ex -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-exp -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-expl -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-expli -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explic -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explici -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit- -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-s -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-su -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-sub -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subd -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdo -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdom -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdoma -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdomai -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdomain -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdomain- -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdomain-a -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdomain-ap -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? test-explicit-subdomain-app -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? test-explicit-subdomain-app.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? t.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? th.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? thi.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-i.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-m.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-w.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-we.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-wei.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weir.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-s.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-su.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-sub.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-subd.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-subdo.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-subdom.lcl.host -─── DomainInput ──────────────────────────────────────────────────────────────── + ? test-explicit-subdomain-app +─── SetupServiceName ─────────────────────────────────────────────────────────── # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. @@ -759,9 +151,6 @@ - Scanned current directory. - Entered go application server type. - Entered test-explicit-subdomain-app application name. - ? What lcl.host domain would you like to use for local application development? - | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-subdoma.lcl.host ─── DomainInput ──────────────────────────────────────────────────────────────── # Setup lcl.host Application `anchor lcl setup` @@ -774,7 +163,7 @@ - Entered test-explicit-subdomain-app application name. ? What lcl.host domain would you like to use for local application development? | We'll ignore any characters that are not valid in a domain. - ? this-is-my-weird-subdomai.lcl.host + ? test-explicit-subdomain-app.lcl.host ─── DomainInput ──────────────────────────────────────────────────────────────── # Setup lcl.host Application `anchor lcl setup` diff --git a/lcl/testdata/TestSetup/create-service-with-parameterized-name.golden b/lcl/testdata/TestSetup/create-service-with-parameterized-name.golden index 551f4fe..50cf293 100644 --- a/lcl/testdata/TestSetup/create-service-with-parameterized-name.golden +++ b/lcl/testdata/TestSetup/create-service-with-parameterized-name.golden @@ -132,83 +132,6 @@ ? lcl ─── SetupServiceName ─────────────────────────────────────────────────────────── -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? T -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? Te -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? Tes -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? Test -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? Test -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? Test A -─── SetupServiceName ─────────────────────────────────────────────────────────── - -# Setup lcl.host Application `anchor lcl setup` - | We'll integrate your application and system for HTTPS local development. - - Selected lcl_setup organization. You can also use `--org lcl_setup`. - - Using localhost, the only available realm. You can also use `--realm localhost`. - - Selected Create New Service. - - Scanned current directory. - - Entered go application server type. - ? What is the application name? - ? Test Ap -─── SetupServiceName ─────────────────────────────────────────────────────────── - # Setup lcl.host Application `anchor lcl setup` | We'll integrate your application and system for HTTPS local development. - Selected lcl_setup organization. You can also use `--org lcl_setup`. diff --git a/lcl/testdata/TestSetup/existing-service-basics-unix.golden b/lcl/testdata/TestSetup/existing-service-basics.golden similarity index 100% rename from lcl/testdata/TestSetup/existing-service-basics-unix.golden rename to lcl/testdata/TestSetup/existing-service-basics.golden diff --git a/org/create.go b/org/create.go new file mode 100644 index 0000000..7bcac05 --- /dev/null +++ b/org/create.go @@ -0,0 +1,104 @@ +package org + +import ( + "context" + + "github.com/anchordotdev/cli" + "github.com/anchordotdev/cli/api" + "github.com/anchordotdev/cli/auth" + "github.com/anchordotdev/cli/org/models" + "github.com/anchordotdev/cli/ui" + "github.com/spf13/cobra" +) + +var CmdOrgCreate = cli.NewCmd[Create](CmdOrg, "create", func(cmd *cobra.Command) { + cfg := cli.ConfigFromCmd(cmd) + + cmd.Flags().StringVar(&cfg.Org.Name, "org-name", "", "Name for created org.") +}) + +type Create struct { + Anc *api.Session + + OrgName string +} + +func (c Create) UI() cli.UI { + return cli.UI{ + RunTUI: c.run, + } +} + +func (c *Create) run(ctx context.Context, drv *ui.Driver) error { + var err error + clientCmd := &auth.Client{ + Anc: c.Anc, + } + c.Anc, err = clientCmd.Perform(ctx, drv) + if err != nil { + return err + } + + drv.Activate(ctx, &models.OrgCreateHeader{}) + drv.Activate(ctx, &models.OrgCreateHint{}) + + _, err = c.Perform(ctx, drv) + if err != nil { + return err + } + + return nil +} + +func (c *Create) Perform(ctx context.Context, drv *ui.Driver) (*api.Organization, error) { + cfg := cli.ConfigFromContext(ctx) + + var err error + c.OrgName, err = c.orgName(ctx, cfg, drv) + if err != nil { + return nil, err + } + drv.Activate(ctx, &models.CreateOrgSpinner{}) + + org, err := c.Anc.CreateOrg(ctx, c.OrgName) + if err != nil { + return nil, err + } + + drv.Send(ui.HideModelsMsg{ + Models: []string{"CreateOrgNameInput", "CreateOrgSpinner"}, + }) + + drv.Activate(ctx, &models.CreateOrgResult{ + Org: *org, + }) + + return org, nil +} + +func (c *Create) orgName(ctx context.Context, cfg *cli.Config, drv *ui.Driver) (string, error) { + if c.OrgName != "" { + return c.OrgName, nil + } + if cfg.Org.Name != "" { + c.OrgName = cfg.Org.Name + return c.OrgName, nil + } + + if c.OrgName == "" { + inputc := make(chan string) + drv.Activate(ctx, &models.CreateOrgNameInput{ + InputCh: inputc, + }) + + select { + case orgName := <-inputc: + c.OrgName = orgName + return c.OrgName, nil + case <-ctx.Done(): + return "", ctx.Err() + } + } + + return "", nil +} diff --git a/org/create_test.go b/org/create_test.go new file mode 100644 index 0000000..4310330 --- /dev/null +++ b/org/create_test.go @@ -0,0 +1,70 @@ +package org + +import ( + "context" + "testing" + "time" + + tea "github.com/charmbracelet/bubbletea" + "github.com/stretchr/testify/require" + + "github.com/anchordotdev/cli" + "github.com/anchordotdev/cli/cmdtest" + "github.com/anchordotdev/cli/ui/uitest" + "github.com/charmbracelet/x/exp/teatest" +) + +func TestCmdOrg(t *testing.T) { + t.Run("--help", func(t *testing.T) { + cmdtest.TestHelp(t, CmdOrgCreate, "org", "create", "--help") + }) + + t.Run("--org-name org", func(t *testing.T) { + cfg := cmdtest.TestCfg(t, CmdOrgCreate, "--org-name", "org") + require.Equal(t, "org", cfg.Org.Name) + }) +} + +func TestCreateOrg(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + cfg := new(cli.Config) + cfg.API.URL = srv.URL + var err error + if cfg.API.Token, err = srv.GeneratePAT("anky@anchor.dev"); err != nil { + t.Fatal(err) + } + ctx = cli.ContextWithConfig(ctx, cfg) + + t.Run("basics", func(t *testing.T) { + if srv.IsProxy() { + t.Skip("org create unsupported in proxy mode") + } + + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + drv, tm := uitest.TestTUI(ctx, t) + + cmd := Create{} + + errc := make(chan error, 1) + go func() { + errc <- cmd.UI().RunTUI(ctx, drv) + errc <- tm.Quit() + }() + + uitest.WaitForGoldenContains(t, drv, errc, + "? What is the new organization's name?", + ) + tm.Send(tea.KeyMsg{ + Runes: []rune("Org Name"), + Type: tea.KeyRunes, + }) + tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) + + tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3)) + uitest.TestGolden(t, drv.Golden()) + }) +} diff --git a/org/models/create.go b/org/models/create.go new file mode 100644 index 0000000..c1be907 --- /dev/null +++ b/org/models/create.go @@ -0,0 +1,191 @@ +package models + +import ( + "fmt" + "slices" + "strings" + + tea "github.com/charmbracelet/bubbletea" + + "github.com/anchordotdev/cli/api" + "github.com/anchordotdev/cli/ui" + "github.com/charmbracelet/bubbles/spinner" + "github.com/charmbracelet/bubbles/textinput" +) + +type OrgCreateHeader struct { + hidden bool +} + +func (m *OrgCreateHeader) Init() tea.Cmd { return nil } + +func (m *OrgCreateHeader) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case ui.HideModelsMsg: + if slices.Contains(msg.Models, "OrgCreateHeader") { + m.hidden = true + } + } + + return m, nil +} + +func (m *OrgCreateHeader) View() string { + if m.hidden { + return "" + } + + var b strings.Builder + + fmt.Fprintln(&b, ui.Header(fmt.Sprintf("Create New Organization %s", ui.Whisper("`anchor org create`")))) + + return b.String() +} + +type OrgCreateHint struct { + hidden bool +} + +func (m *OrgCreateHint) Init() tea.Cmd { return nil } + +func (m *OrgCreateHint) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case ui.HideModelsMsg: + if slices.Contains(msg.Models, "OrgCreateHint") { + m.hidden = true + } + } + + return m, nil +} + +func (m *OrgCreateHint) View() string { + if m.hidden { + return "" + } + + var b strings.Builder + + fmt.Fprintln(&b, ui.StepHint("We'll create a new organization to facilitate collaboration.")) + + return b.String() +} + +type CreateOrgNameInput struct { + InputCh chan<- string + + hidden bool + input *textinput.Model + choice string +} + +func (m *CreateOrgNameInput) Init() tea.Cmd { + ti := textinput.New() + ti.Prompt = "" + ti.Cursor.Style = ui.Prompt + ti.Focus() + + m.input = &ti + + return textinput.Blink +} + +func (m *CreateOrgNameInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case ui.HideModelsMsg: + if slices.Contains(msg.Models, "CreateOrgNameInput") { + m.hidden = true + } + case tea.KeyMsg: + switch msg.Type { + case tea.KeyEnter: + if m.InputCh != nil { + value := m.input.Value() + + m.choice = value + m.InputCh <- value + m.InputCh = nil + } + return m, nil + case tea.KeyEsc: + return m, ui.Exit + } + } + + ti, cmd := m.input.Update(msg) + m.input = &ti + return m, cmd +} + +func (m *CreateOrgNameInput) View() string { + if m.hidden { + return "" + } + + var b strings.Builder + + if m.InputCh != nil { + fmt.Fprintln(&b, ui.StepPrompt("What is the new organization's name?")) + fmt.Fprintln(&b, ui.StepPrompt(m.input.View())) + return b.String() + } + + fmt.Fprintln(&b, ui.StepDone(fmt.Sprintf("Entered %s organization name.", ui.Emphasize(m.choice)))) + + return b.String() +} + +type CreateOrgSpinner struct { + hidden bool + spinner spinner.Model +} + +func (m *CreateOrgSpinner) Init() tea.Cmd { + m.spinner = ui.WaitingSpinner() + + return m.spinner.Tick +} + +func (m *CreateOrgSpinner) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case ui.HideModelsMsg: + if slices.Contains(msg.Models, "CreateOrgSpinner") { + m.hidden = true + } + } + + var cmd tea.Cmd + m.spinner, cmd = m.spinner.Update(msg) + return m, cmd +} + +func (m *CreateOrgSpinner) View() string { + if m.hidden { + return "" + } + + var b strings.Builder + + fmt.Fprintln(&b, ui.StepInProgress(fmt.Sprintf("Creating new organization…%s", m.spinner.View()))) + + return b.String() +} + +type CreateOrgResult struct { + Org api.Organization +} + +func (m *CreateOrgResult) Init() tea.Cmd { return nil } + +func (m *CreateOrgResult) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } + +func (m *CreateOrgResult) View() string { + var b strings.Builder + + fmt.Fprintln(&b, ui.StepDone(fmt.Sprintf("Created %s %s organization.", + m.Org.Name, + ui.Whisper(fmt.Sprintf("(%s)", m.Org.Apid)), + ))) + + return b.String() +} diff --git a/org/org.go b/org/org.go new file mode 100644 index 0000000..5dc39bb --- /dev/null +++ b/org/org.go @@ -0,0 +1,9 @@ +package org + +import ( + "github.com/anchordotdev/cli" + "github.com/spf13/cobra" +) + +var CmdOrg = cli.NewCmd[cli.ShowHelp](cli.CmdRoot, "org", func(cmd *cobra.Command) { +}) diff --git a/org/org_test.go b/org/org_test.go new file mode 100644 index 0000000..1ac82e8 --- /dev/null +++ b/org/org_test.go @@ -0,0 +1,25 @@ +package org + +import ( + "context" + "os" + "testing" + + "github.com/anchordotdev/cli/api/apitest" + _ "github.com/anchordotdev/cli/testflags" +) + +var srv = &apitest.Server{ + Host: "api.anchor.lcl.host", + RootDir: "../..", +} + +func TestMain(m *testing.M) { + if err := srv.Start(context.Background()); err != nil { + panic(err) + } + + defer os.Exit(m.Run()) + + srv.Close() +} diff --git a/org/testdata/TestCmdOrg/--help.golden b/org/testdata/TestCmdOrg/--help.golden new file mode 100644 index 0000000..8f454c9 --- /dev/null +++ b/org/testdata/TestCmdOrg/--help.golden @@ -0,0 +1,13 @@ +Create New Organization + +Usage: + anchor org create [flags] + +Flags: + -h, --help help for create + --org-name string Name for created org. + +Global Flags: + --api-token string Anchor API personal access token (PAT). + --config string Service configuration file. (default "anchor.toml") + --skip-config Skip loading configuration file. diff --git a/org/testdata/TestCreateOrg/basics.golden b/org/testdata/TestCreateOrg/basics.golden new file mode 100644 index 0000000..2a6e26b --- /dev/null +++ b/org/testdata/TestCreateOrg/basics.golden @@ -0,0 +1,43 @@ +─── Client ───────────────────────────────────────────────────────────────────── + * Checking authentication: probing credentials locally…⠋ +─── Client ───────────────────────────────────────────────────────────────────── + * Checking authentication: testing credentials remotely…⠋ +─── OrgCreateHeader ──────────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` +─── OrgCreateHint ────────────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. +─── CreateOrgNameInput ───────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + ? What is the new organization's name? + ? +─── CreateOrgNameInput ───────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + ? What is the new organization's name? + ? Org Name +─── CreateOrgNameInput ───────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + - Entered Org Name organization name. +─── CreateOrgSpinner ─────────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + - Entered Org Name organization name. + * Creating new organization…⠋ +─── CreateOrgSpinner ─────────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. +─── CreateOrgResult ──────────────────────────────────────────────────────────── + +# Create New Organization `anchor org create` + | We'll create a new organization to facilitate collaboration. + - Created Org Name (org-slug) organization. diff --git a/service/service.go b/service/service.go index 53c9710..db499d0 100644 --- a/service/service.go +++ b/service/service.go @@ -6,5 +6,4 @@ import ( ) var CmdService = cli.NewCmd[cli.ShowHelp](cli.CmdRoot, "service", func(cmd *cobra.Command) { - cmd.Hidden = true }) diff --git a/service/verify.go b/service/verify.go index 350ae80..60f7c1c 100644 --- a/service/verify.go +++ b/service/verify.go @@ -109,7 +109,7 @@ func (c *Verify) RunTUI(ctx context.Context, drv *ui.Driver) error { return nil } - c.probeTLS(ctx, drv, attachment, credentials, conn) + _ = c.probeTLS(ctx, drv, attachment, credentials, conn) return nil } @@ -145,11 +145,6 @@ func (c *Verify) probeTCP(ctx context.Context, cfg *cli.Config, drv *ui.Driver, innerDialer = new(net.Dialer) } - resolver := cfg.Test.NetResolver - if resolver == nil { - resolver = new(net.Resolver) - } - var addrs []string for _, ip := range ips { if strings.Contains(ip, ":") { diff --git a/testdata/TestCmdRoot/--help.golden b/testdata/TestCmdRoot/--help.golden index ef1b59b..6015399 100644 --- a/testdata/TestCmdRoot/--help.golden +++ b/testdata/TestCmdRoot/--help.golden @@ -11,6 +11,8 @@ Available Commands: completion Generate the autocompletion script for the specified shell help Help about any command lcl Manage lcl.host Local Development Environment + org Manage Organizations + service Manage services trust Manage CA Certificates in your Local Trust Store(s) version Show Version Info diff --git a/testdata/TestCmdRoot/root.golden b/testdata/TestCmdRoot/root.golden index ef1b59b..6015399 100644 --- a/testdata/TestCmdRoot/root.golden +++ b/testdata/TestCmdRoot/root.golden @@ -11,6 +11,8 @@ Available Commands: completion Generate the autocompletion script for the specified shell help Help about any command lcl Manage lcl.host Local Development Environment + org Manage Organizations + service Manage services trust Manage CA Certificates in your Local Trust Store(s) version Show Version Info diff --git a/ui/driver.go b/ui/driver.go index 04c5012..aac98ea 100644 --- a/ui/driver.go +++ b/ui/driver.go @@ -85,6 +85,10 @@ type activateMsg struct { donec chan<- struct{} } +type HideModelsMsg struct { + Models []string +} + func (d *Driver) Activate(ctx context.Context, model tea.Model) { donec := make(chan struct{}) @@ -150,6 +154,10 @@ func (d *Driver) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyCtrlC: return d, tea.Quit } + case HideModelsMsg: + for _, mdl := range d.models { + mdl.Update(msg) + } } if d.active == nil { diff --git a/ui/styles.go b/ui/styles.go index 25c394d..4c9dceb 100644 --- a/ui/styles.go +++ b/ui/styles.go @@ -103,6 +103,7 @@ func List[T any](items []ListItem[T]) list.Model { } l := list.New(lis, itemDelegate[T]{}, 80, len(items)) + l.InfiniteScrolling = true l.SetShowFilter(false) l.SetShowHelp(false) l.SetShowPagination(false)