mirror of
https://github.com/beego/bee.git
synced 2025-07-07 01:10:21 +00:00
Merge branch 'master' of https://github.com/beego/bee
# Conflicts: # generate/swaggergen/g_docs.go
This commit is contained in:
@ -166,6 +166,7 @@ func appCode(cmd *commands.Command, args []string, currpath string) {
|
||||
beeLogger.Log.Infof("Using '%s' as 'Level'", generate.Level)
|
||||
generate.GenerateAppcode(generate.SQLDriver.String(), generate.SQLConn.String(), generate.Level.String(), generate.Tables.String(), currpath)
|
||||
}
|
||||
|
||||
func migration(cmd *commands.Command, args []string, currpath string) {
|
||||
if len(args) < 2 {
|
||||
beeLogger.Log.Fatal("Wrong number of arguments. Run: bee help generate")
|
||||
|
@ -196,6 +196,17 @@ func checkForSchemaUpdateTable(db *sql.DB, driver string) {
|
||||
}
|
||||
}
|
||||
|
||||
func driverImportStatement(driver string) string {
|
||||
switch driver {
|
||||
case "mysql":
|
||||
return "github.com/go-sql-driver/mysql"
|
||||
case "postgres":
|
||||
return "github.com/lib/pq"
|
||||
default:
|
||||
return "github.com/go-sql-driver/mysql"
|
||||
}
|
||||
}
|
||||
|
||||
func showMigrationsTableSQL(driver string) string {
|
||||
switch driver {
|
||||
case "mysql":
|
||||
@ -263,6 +274,7 @@ func writeMigrationSourceFile(dir, source, driver, connStr string, latestTime in
|
||||
beeLogger.Log.Fatalf("Could not create file: %s", err)
|
||||
} else {
|
||||
content := strings.Replace(MigrationMainTPL, "{{DBDriver}}", driver, -1)
|
||||
content = strings.Replace(content, "{{DriverRepo}}", driverImportStatement(driver), -1)
|
||||
content = strings.Replace(content, "{{ConnStr}}", connStr, -1)
|
||||
content = strings.Replace(content, "{{LatestTime}}", strconv.FormatInt(latestTime, 10), -1)
|
||||
content = strings.Replace(content, "{{LatestName}}", latestName, -1)
|
||||
@ -346,8 +358,7 @@ import(
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/astaxie/beego/migration"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/lib/pq"
|
||||
_ "{{DriverRepo}}"
|
||||
)
|
||||
|
||||
func init(){
|
||||
|
@ -58,6 +58,8 @@ var (
|
||||
currentGoPath string
|
||||
// Current runmode
|
||||
runmode string
|
||||
// Extra args to run application
|
||||
runargs string
|
||||
// Extra directories
|
||||
extraPackages utils.StrFlags
|
||||
)
|
||||
@ -71,6 +73,7 @@ func init() {
|
||||
CmdRun.Flag.BoolVar(&vendorWatch, "vendor", false, "Enable watch vendor folder.")
|
||||
CmdRun.Flag.StringVar(&buildTags, "tags", "", "Set the build tags. See: https://golang.org/pkg/go/build/")
|
||||
CmdRun.Flag.StringVar(&runmode, "runmode", "", "Set the Beego run mode.")
|
||||
CmdRun.Flag.StringVar(&runargs, "runargs", "", "Extra args to run application")
|
||||
CmdRun.Flag.Var(&extraPackages, "ex", "List of extra package to watch.")
|
||||
exit = make(chan bool)
|
||||
commands.AvailableCommands = append(commands.AvailableCommands, CmdRun)
|
||||
|
@ -36,13 +36,14 @@ var (
|
||||
state sync.Mutex
|
||||
eventTime = make(map[string]int64)
|
||||
scheduleTime time.Time
|
||||
watchExts = []string{".go"}
|
||||
watchExtsStatic = []string{".html", ".tpl", ".js", ".css"}
|
||||
watchExts = config.Conf.WatchExts
|
||||
watchExtsStatic = config.Conf.WatchExtsStatic
|
||||
ignoredFilesRegExps = []string{
|
||||
`.#(\w+).go`,
|
||||
`.(\w+).go.swp`,
|
||||
`(\w+).go~`,
|
||||
`(\w+).tmp`,
|
||||
`commentsRouter_controllers.go`,
|
||||
}
|
||||
)
|
||||
|
||||
@ -86,6 +87,12 @@ func NewWatcher(paths []string, files []string, isgenerate bool) {
|
||||
scheduleTime = time.Now().Add(1 * time.Second)
|
||||
time.Sleep(scheduleTime.Sub(time.Now()))
|
||||
AutoBuild(files, isgenerate)
|
||||
|
||||
if config.Conf.EnableReload {
|
||||
// Wait 100ms more before refreshing the browser
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
sendReload(e.String())
|
||||
}
|
||||
}()
|
||||
}
|
||||
case err := <-watcher.Errors:
|
||||
@ -141,9 +148,9 @@ func AutoBuild(files []string, isgenerate bool) {
|
||||
}
|
||||
beeLogger.Log.Success("Docs generated!")
|
||||
}
|
||||
|
||||
appName := appname
|
||||
if err == nil {
|
||||
appName := appname
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
appName += ".exe"
|
||||
}
|
||||
@ -167,7 +174,7 @@ func AutoBuild(files []string, isgenerate bool) {
|
||||
}
|
||||
|
||||
beeLogger.Log.Success("Built Successfully!")
|
||||
Restart(appname)
|
||||
Restart(appName)
|
||||
}
|
||||
|
||||
// Kill kills the running command process
|
||||
@ -202,7 +209,13 @@ func Start(appname string) {
|
||||
cmd = exec.Command(appname)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Args = append([]string{appname}, config.Conf.CmdArgs...)
|
||||
if runargs != "" {
|
||||
r := regexp.MustCompile("'.+'|\".+\"|\\S+")
|
||||
m := r.FindAllString(runargs, -1)
|
||||
cmd.Args = append([]string{appname}, m...)
|
||||
} else {
|
||||
cmd.Args = append([]string{appname}, config.Conf.CmdArgs...)
|
||||
}
|
||||
cmd.Env = append(os.Environ(), config.Conf.Envs...)
|
||||
|
||||
go cmd.Run()
|
||||
|
@ -57,7 +57,7 @@ Prints the current Bee, Beego and Go version alongside the platform information.
|
||||
}
|
||||
var outputFormat string
|
||||
|
||||
const version = "1.9.1"
|
||||
const version = "1.10.0"
|
||||
|
||||
func init() {
|
||||
fs := flag.NewFlagSet("version", flag.ContinueOnError)
|
||||
|
Reference in New Issue
Block a user