Merge pull request #758 from trheyi/main
feat: app afterMigrate hook support
This commit is contained in:
commit
6ec63f4d9c
3 changed files with 34 additions and 15 deletions
4
.github/workflows/release-macos.yml
vendored
4
.github/workflows/release-macos.yml
vendored
|
|
@ -13,7 +13,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "Downloading latest artifacts..."
|
echo "Downloading latest artifacts..."
|
||||||
ARTIFACT_URL="https://api.github.com/repos/YaoApp/yao/actions/artifacts"
|
ARTIFACT_URL="https://api.github.com/repos/YaoApp/yao/actions/artifacts"
|
||||||
ARTIFACTS=$(curl -s -H "Accept: application/vnd.github.v3+json" $ARTIFACT_URL | jq -r '.artifacts[] | select(.name | contains("yao-macos")) | .id')
|
ARTIFACT_CONTENT=$(curl -s -H "Accept: application/vnd.github.v3+json" $ARTIFACT_URL)
|
||||||
|
echo $ARTIFACT_CONTENT
|
||||||
|
ARTIFACTS=$(echo $ARTIFACT_CONTENT | jq -r '.artifacts[] | select(.name | contains("yao-macos")) | .id')
|
||||||
for id in $ARTIFACTS; do
|
for id in $ARTIFACTS; do
|
||||||
echo "https://api.github.com/repos/YaoApp/yao/actions/artifacts/$id/zip"
|
echo "https://api.github.com/repos/YaoApp/yao/actions/artifacts/$id/zip"
|
||||||
curl -L -H "Accept: application/vnd.github.v3+json" \
|
curl -L -H "Accept: application/vnd.github.v3+json" \
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/yaoapp/gou/model"
|
"github.com/yaoapp/gou/model"
|
||||||
|
"github.com/yaoapp/gou/process"
|
||||||
"github.com/yaoapp/kun/exception"
|
"github.com/yaoapp/kun/exception"
|
||||||
"github.com/yaoapp/yao/config"
|
"github.com/yaoapp/yao/config"
|
||||||
"github.com/yaoapp/yao/engine"
|
"github.com/yaoapp/yao/engine"
|
||||||
|
|
@ -88,6 +89,21 @@ var migrateCmd = &cobra.Command{
|
||||||
fmt.Printf(color.GreenString(L("SUCCESS")) + "\n")
|
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✨")))
|
// fmt.Println(color.GreenString(L("✨DONE✨")))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ type AppInfo struct {
|
||||||
Optional map[string]interface{} `json:"optional,omitempty"`
|
Optional map[string]interface{} `json:"optional,omitempty"`
|
||||||
Moapi Moapi `json:"moapi,omitempty"`
|
Moapi Moapi `json:"moapi,omitempty"`
|
||||||
AfterLoad string `json:"afterLoad,omitempty"` // Process executed after the app is loaded
|
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
|
// Moapi AIGC App Store API
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue