Skip to content

Commit

Permalink
fix load bug
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Feb 9, 2022
1 parent d763ad1 commit 657d68d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ xiang: bindata
.PHONY: release
release: clean
mkdir -p dist/release
git clone git@github.com:YaoApp/xiang.git dist/release
git clone git@github.com:YaoApp/yao.git dist/release
git clone git@github.com:YaoApp/kun.git dist/kun
git clone git@github.com:YaoApp/xun.git dist/xun
git clone git@github.com:YaoApp/gou.git dist/gou
Expand Down Expand Up @@ -187,7 +187,7 @@ hi:
.PHONY: arm
arm: clean
mkdir -p dist/release
git clone git@github.com:YaoApp/xiang.git dist/release
git clone git@github.com:YaoApp/yao.git dist/release
git clone git@github.com:YaoApp/kun.git dist/kun
git clone git@github.com:YaoApp/xun.git dist/xun
git clone git@github.com:YaoApp/gou.git dist/gou
Expand Down Expand Up @@ -219,7 +219,7 @@ arm: clean
.PHONY: linux
linux: clean
mkdir -p dist/release
git clone git@github.com:YaoApp/xiang.git dist/release
git clone git@github.com:YaoApp/yao.git dist/release
git clone git@github.com:YaoApp/kun.git dist/kun
git clone git@github.com:YaoApp/xun.git dist/xun
git clone git@github.com:YaoApp/gou.git dist/gou
Expand Down
1 change: 1 addition & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var initCmd = &cobra.Command{
makeAppJSON()
makeEnv()
defaultApps()
fmt.Println(color.GreenString(L("✨DONE✨")))
},
}

Expand Down
10 changes: 10 additions & 0 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/yaoapp/gou"
"github.com/yaoapp/kun/exception"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/engine"
)
Expand All @@ -17,6 +18,13 @@ var migrateCmd = &cobra.Command{
Short: L("Update database schema"),
Long: L("Update database schema"),
Run: func(cmd *cobra.Command, args []string) {
defer func() {
err := exception.Catch(recover())
if err != nil {
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
}
}()

Boot()
// 加载数据模型
err := engine.Load(config.Conf)
Expand All @@ -38,6 +46,8 @@ var migrateCmd = &cobra.Command{
fmt.Println(color.GreenString(L("Update schema model: %s (%s) "), mod.Name, mod.MetaData.Table.Name))
mod.Migrate(true)
}

fmt.Println(color.GreenString(L("✨DONE✨")))
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var langs = map[string]string{
"Update schema model: %s (%s) ": "更新表结构 model: %s (%s)",
"Model name": "模型名称",
"Initialize project": "项目初始化",
"✨DONE✨": "✨完成✨",
}

// L 多语言切换
Expand Down
10 changes: 10 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
jsoniter "github.com/json-iterator/go"
"github.com/spf13/cobra"
"github.com/yaoapp/gou"
"github.com/yaoapp/kun/exception"
"github.com/yaoapp/kun/utils"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/engine"
Expand All @@ -20,6 +21,13 @@ var runCmd = &cobra.Command{
Long: L("Execute process"),
Run: func(cmd *cobra.Command, args []string) {
defer gou.KillPlugins()
defer func() {
err := exception.Catch(recover())
if err != nil {
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
}
}()

Boot()
cfg := config.Conf
cfg.Session.IsCLI = true
Expand Down Expand Up @@ -66,5 +74,7 @@ var runCmd = &cobra.Command{
fmt.Println(color.WhiteString(L("%s Response"), name))
fmt.Println(color.WhiteString("--------------------------------------"))
utils.Dump(res)
fmt.Println(color.WhiteString("--------------------------------------"))
fmt.Println(color.GreenString(L("✨DONE✨")))
},
}
1 change: 1 addition & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var startCmd = &cobra.Command{
}
}

fmt.Println(color.GreenString(L("✨DONE✨")))
service.Start()
},
}
Expand Down
2 changes: 1 addition & 1 deletion engine/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func LoadEngine(from ...string) {
if len(from) > 0 {
scripts = share.GetFilesFS(from[0], ".json")
} else {
scripts = share.GetFilesBin("/xiang", ".json")
scripts = share.GetFilesBin("xiang", ".json")
}

if scripts == nil {
Expand Down

0 comments on commit 657d68d

Please sign in to comment.