Skip to content

Commit

Permalink
Add retrieve types only command (#4555)
Browse files Browse the repository at this point in the history
* Add retrieve types only command

* no shorthand
  • Loading branch information
humandad authored Feb 4, 2025
1 parent a54a0e8 commit a5e10ba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apps/cli/pkg/cmd/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 26 additions & 1 deletion apps/cli/pkg/command/workspace/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ 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"
"github.com/thecloudmasters/cli/pkg/zip"
"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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/pkg/meta/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
1 change: 1 addition & 0 deletions apps/platform/pkg/meta/botcollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func init() {
"LISTENER",
"ROUTE",
"RUNACTION",
"GENERATOR",
},
}
}
Expand Down

0 comments on commit a5e10ba

Please sign in to comment.