diff --git a/apps/cli/pkg/cmd/workspace.go b/apps/cli/pkg/cmd/workspace.go index 17560d082b..ca00b9cb32 100644 --- a/apps/cli/pkg/cmd/workspace.go +++ b/apps/cli/pkg/cmd/workspace.go @@ -26,6 +26,7 @@ func init() { Long: "Retrieves all metadata from a remote workspace to the local directory", Run: workspaceRetrieve, } + workspaceRetrieveCmd.Flags().Bool("onlyTypes", false, "Only retrieve types") workspaceDeployCmd := &cobra.Command{ Use: "deploy", @@ -72,13 +73,17 @@ func init() { Short: "uesio retrieve", Run: workspaceRetrieve, } + oldRetrieveCommand.Flags().Bool("onlyTypes", false, "Only retrieve types") rootCmd.AddCommand(workspaceCommand, oldDeployCommand, oldRetrieveCommand) } func workspaceRetrieve(cmd *cobra.Command, args []string) { - err := workspace.Retrieve() + onlyTypes, _ := cmd.Flags().GetBool("onlyTypes") + err := workspace.Retrieve(&workspace.RetrieveOptions{ + OnlyTypes: onlyTypes, + }) if err != nil { fmt.Println("Error: " + err.Error()) os.Exit(1) diff --git a/apps/cli/pkg/command/workspace/retrieve.go b/apps/cli/pkg/command/workspace/retrieve.go index fc05eb1a08..08a55de0d5 100644 --- a/apps/cli/pkg/command/workspace/retrieve.go +++ b/apps/cli/pkg/command/workspace/retrieve.go @@ -9,6 +9,7 @@ import ( "github.com/thecloudmasters/cli/pkg/auth" "github.com/thecloudmasters/cli/pkg/call" + "github.com/thecloudmasters/cli/pkg/command" "github.com/thecloudmasters/cli/pkg/config" "github.com/thecloudmasters/cli/pkg/config/ws" "github.com/thecloudmasters/cli/pkg/context" @@ -16,7 +17,15 @@ import ( "github.com/thecloudmasters/uesio/pkg/meta" ) -func Retrieve() error { +type RetrieveOptions struct { + OnlyTypes bool +} + +func Retrieve(options *RetrieveOptions) error { + + if options == nil { + options = &RetrieveOptions{} + } _, err := auth.Login() if err != nil { @@ -37,6 +46,22 @@ func Retrieve() error { return errors.New("No active workspace is set. Use \"uesio work\" to set one.") } + if options.OnlyTypes { + appContext := context.NewWorkspaceContext(appName, workspace) + + sessionId, err := config.GetSessionID() + if err != nil { + return err + } + + if err = command.GenerateAppTypeDefinitions(appName, workspace, sessionId, appContext); err != nil { + return err + } + + fmt.Println("Type definitions successfully updated.") + return nil + } + err = RetrieveBundleForAppWorkspace(appName, workspace, "") if err != nil { return err diff --git a/apps/platform/pkg/meta/bot.go b/apps/platform/pkg/meta/bot.go index 1b2546f98a..7580e69ddf 100644 --- a/apps/platform/pkg/meta/bot.go +++ b/apps/platform/pkg/meta/bot.go @@ -550,7 +550,7 @@ const NEWLINE = ` ` func (b *Bot) GenerateTypeDefinitions() (string, error) { - if b.Type != "ROUTE" && b.Type != "LISTENER" && b.Type != "RUNACTION" { + if b.Type != "ROUTE" && b.Type != "LISTENER" && b.Type != "RUNACTION" && b.Type != "GENERATOR" { return "", nil } if b.Name == "" || b.Namespace == "" { diff --git a/apps/platform/pkg/meta/botcollection.go b/apps/platform/pkg/meta/botcollection.go index b3e432905d..22c96cf818 100644 --- a/apps/platform/pkg/meta/botcollection.go +++ b/apps/platform/pkg/meta/botcollection.go @@ -182,6 +182,7 @@ func init() { "LISTENER", "ROUTE", "RUNACTION", + "GENERATOR", }, } }