func runSave(cmd *cobra.Command, args []string) { var l *login.LoginInfo var a app.App // Check if you are logged in first if l = login.SavedLoginInfo(); l == nil { color.Red("You are not logged in. To login, type \"nestor login\"\n") os.Exit(1) } // Check if you have a valid nestor.json file nestorJsonPath, err := pathToNestorJson(args) if err != nil { color.Red("Could not find nestor.json in the path specified\n") os.Exit(1) } a.ManifestPath = nestorJsonPath err = a.ParseManifest() if err != nil { color.Red("%s\n", err.Error()) os.Exit(1) } // Check if existing app exists and if so, then we should be making calls to the "UPDATE" function // We are ignoring the error for now but at some point we will have to show an error that is not annoying err = a.Hydrate(l) if err != nil { color.Red("- Error fetching details for power\n") } color.Green("+ Building deployment artifact...\n") err = a.BuildArtifact() if err != nil { color.Red("- Error while building deployment artifact for your power\n") } // Check if you need to do coffee compilation err = a.CompileCoffeescript() if err != nil { color.Red("- There was an error compiling coffeescript in your power\n") os.Exit(1) } err = a.CalculateLocalSha256() if err != nil { color.Red("- There was an error calculating whether your power needs to be uploaded\n") os.Exit(1) } if a.LocalSha256 != a.RemoteSha256 { color.Green("+ Generating zip...\n") zip, err := a.ZipBytes() if err != nil { color.Red("- Error creating a zip of your power's deployment artifact\n") os.Exit(1) } color.Green("+ Uploading zip...\n") // Upload app contents buffer := bytes.NewBuffer(zip) err = a.Upload(buffer, l) if err != nil { color.Red("- Error while uploading deployment artifact: %+v\n", err) os.Exit(1) } } // Make API call to Nestor with contents from JSON file along with S3 URL so that the API can create a functioning bot app color.Green("+ Saving power to Nestor...\n") err = a.SaveToNestor(l) if err != nil { color.Red("- Error while saving power to nestor: %+v\n", err) os.Exit(1) } color.Green("+ Successfully saved power to Nestor!\n") fmt.Printf("\nYou can test your power by running `nestor shell`\n") fmt.Printf("To deploy your power to Slack, run `nestor deploy --latest`\n") }