mder/deploy.go

48 lines
1.1 KiB
Go
Raw Normal View History

2022-07-22 00:05:59 +08:00
package main
2022-07-24 14:26:30 +08:00
2023-01-07 12:26:54 +08:00
import "github.com/spf13/cobra"
2022-07-24 14:26:30 +08:00
func deployCmd() *cobra.Command {
var outter Outter
cmd := &cobra.Command{
2023-01-07 12:26:54 +08:00
Use: "deploy",
Aliases: []string{"d"},
Short: "deploy project to upyun",
PreRun: func(cmd *cobra.Command, args []string) {
2022-07-24 14:26:30 +08:00
outter.Config = readConfigFile()
2023-01-07 12:26:54 +08:00
config := outter.Config.Deploy
switch config.Type {
case UpyunDeploy:
if !isCommandExist("upx") {
if err := goInstall("github.com/upyun/upx"); err != nil {
sfault("install upx failed: %+v", err)
}
}
case GitDeploy:
}
2023-01-07 14:48:56 +08:00
// generate source
if err := generateCmd().Execute(); err != nil {
sfault("generate project failed: %v", err)
}
2022-07-24 14:26:30 +08:00
},
2023-01-07 12:26:54 +08:00
Run: func(cmd *cobra.Command, args []string) {
config := outter.Config.Deploy
switch config.Type {
case UpyunDeploy:
if config.UpyunAuth == "" {
serr("please config upyun auth string: upx auth [bucket] [operator] [password]")
return
}
if err := uploadToUpyun(config.UpyunAuth); err != nil {
serr("%v", err)
2023-01-07 14:48:56 +08:00
return
2023-01-07 12:26:54 +08:00
}
sout("deploy to upyun success")
2022-07-24 14:26:30 +08:00
}
2023-01-07 12:26:54 +08:00
},
2022-07-24 14:26:30 +08:00
}
2023-01-07 12:26:54 +08:00
return cmd
2022-07-24 14:26:30 +08:00
}