feat: app afterMigrate hook support
This commit is contained in:
parent
5f271a7f83
commit
dc162bb206
2 changed files with 31 additions and 14 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/fatih/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yaoapp/gou/model"
|
||||
"github.com/yaoapp/gou/process"
|
||||
"github.com/yaoapp/kun/exception"
|
||||
"github.com/yaoapp/yao/config"
|
||||
"github.com/yaoapp/yao/engine"
|
||||
|
|
@ -88,6 +89,21 @@ var migrateCmd = &cobra.Command{
|
|||
fmt.Printf(color.GreenString(L("SUCCESS")) + "\n")
|
||||
}
|
||||
|
||||
// After Migrate Hook
|
||||
if share.App.AfterMigrate != "" {
|
||||
option := map[string]any{"force": force, "reset": resetModel, "mode": config.Conf.Mode}
|
||||
p, err := process.Of(share.App.AfterMigrate, option)
|
||||
if err != nil {
|
||||
fmt.Println(color.RedString(L("AfterMigrate: %s %v"), share.App.AfterMigrate, err))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = p.Exec()
|
||||
if err != nil {
|
||||
fmt.Println(color.RedString(L("AfterMigrate: %s %v"), share.App.AfterMigrate, err))
|
||||
}
|
||||
}
|
||||
|
||||
// fmt.Println(color.GreenString(L("✨DONE✨")))
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,20 +71,21 @@ type Page struct {
|
|||
|
||||
// AppInfo 应用信息
|
||||
type AppInfo struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
L map[string]string `json:"-"`
|
||||
Short string `json:"short,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Icons maps.MapStrSync `json:"icons,omitempty"`
|
||||
Storage AppStorage `json:"storage,omitempty"`
|
||||
Option map[string]interface{} `json:"option,omitempty"`
|
||||
XGen string `json:"xgen,omitempty"`
|
||||
AdminRoot string `json:"adminRoot,omitempty"`
|
||||
Static Static `json:"public,omitempty"`
|
||||
Optional map[string]interface{} `json:"optional,omitempty"`
|
||||
Moapi Moapi `json:"moapi,omitempty"`
|
||||
AfterLoad string `json:"afterLoad,omitempty"` // Process executed after the app is loaded
|
||||
Name string `json:"name,omitempty"`
|
||||
L map[string]string `json:"-"`
|
||||
Short string `json:"short,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Icons maps.MapStrSync `json:"icons,omitempty"`
|
||||
Storage AppStorage `json:"storage,omitempty"`
|
||||
Option map[string]interface{} `json:"option,omitempty"`
|
||||
XGen string `json:"xgen,omitempty"`
|
||||
AdminRoot string `json:"adminRoot,omitempty"`
|
||||
Static Static `json:"public,omitempty"`
|
||||
Optional map[string]interface{} `json:"optional,omitempty"`
|
||||
Moapi Moapi `json:"moapi,omitempty"`
|
||||
AfterLoad string `json:"afterLoad,omitempty"` // Process executed after the app is loaded
|
||||
AfterMigrate string `json:"afterMigrate,omitempty"` // Process executed after the app is migrated
|
||||
}
|
||||
|
||||
// Moapi AIGC App Store API
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue