mirror of
https://github.com/beego/bee.git
synced 2024-11-22 15:10:54 +00:00
Merge branch 'master' into develop
This commit is contained in:
commit
bccfd667c1
@ -7,7 +7,7 @@ Bee is a command line tool facilitating development with beego framework.
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Go version >= 1.1.
|
- Go version >= 1.3.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
2
fix.go
2
fix.go
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
var cmdFix = &Command{
|
var cmdFix = &Command{
|
||||||
UsageLine: "fix",
|
UsageLine: "fix",
|
||||||
Short: "fix the beego application to compatibel with beego 1.6",
|
Short: "fix the beego application to make it compatible with beego 1.6",
|
||||||
Long: `
|
Long: `
|
||||||
As from beego1.6, there's some incompatible code with the old version.
|
As from beego1.6, there's some incompatible code with the old version.
|
||||||
|
|
||||||
|
13
g_appcode.go
13
g_appcode.go
@ -516,7 +516,9 @@ func (*MysqlDB) GetGoDataType(sqlType string) (goType string) {
|
|||||||
func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string) {
|
func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string) {
|
||||||
rows, err := db.Query(`
|
rows, err := db.Query(`
|
||||||
SELECT table_name FROM information_schema.tables
|
SELECT table_name FROM information_schema.tables
|
||||||
WHERE table_catalog = current_database() and table_schema = 'public'`)
|
WHERE table_catalog = current_database() AND
|
||||||
|
table_type = 'BASE TABLE' AND
|
||||||
|
table_schema NOT IN ('pg_catalog', 'information_schema')`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ColorLog("[ERRO] Could not show tables: %s\n", err)
|
ColorLog("[ERRO] Could not show tables: %s\n", err)
|
||||||
ColorLog("[HINT] Check your connection string\n")
|
ColorLog("[HINT] Check your connection string\n")
|
||||||
@ -551,8 +553,10 @@ func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
information_schema.constraint_column_usage cu ON cu.constraint_name = c.constraint_name
|
information_schema.constraint_column_usage cu ON cu.constraint_name = c.constraint_name
|
||||||
WHERE
|
WHERE
|
||||||
c.table_catalog = current_database() AND c.table_schema = 'public' AND c.table_name = $1
|
c.table_catalog = current_database() AND c.table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||||
AND u.table_catalog = current_database() AND u.table_schema = 'public' AND u.table_name = $2`,
|
AND c.table_name = $1
|
||||||
|
AND u.table_catalog = current_database() AND u.table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||||
|
AND u.table_name = $2`,
|
||||||
table.Name, table.Name) // u.position_in_unique_constraint,
|
table.Name, table.Name) // u.position_in_unique_constraint,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ColorLog("[ERRO] Could not query INFORMATION_SCHEMA for PK/UK/FK information: %s\n", err)
|
ColorLog("[ERRO] Could not query INFORMATION_SCHEMA for PK/UK/FK information: %s\n", err)
|
||||||
@ -608,7 +612,8 @@ func (postgresDB *PostgresDB) GetColumns(db *sql.DB, table *Table, blackList map
|
|||||||
FROM
|
FROM
|
||||||
information_schema.columns
|
information_schema.columns
|
||||||
WHERE
|
WHERE
|
||||||
table_catalog = current_database() AND table_schema = 'public' AND table_name = $1`,
|
table_catalog = current_database() AND table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||||
|
AND table_name = $1`,
|
||||||
table.Name)
|
table.Name)
|
||||||
defer colDefRows.Close()
|
defer colDefRows.Close()
|
||||||
for colDefRows.Next() {
|
for colDefRows.Next() {
|
||||||
|
@ -395,10 +395,13 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat
|
|||||||
tmp = make([]rune, 0)
|
tmp = make([]rune, 0)
|
||||||
j += 1
|
j += 1
|
||||||
start = false
|
start = false
|
||||||
|
if j == 1 {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
st[j] = strings.TrimSpace(ss[i+1:])
|
st[j] = strings.TrimSpace(ss[i+1:])
|
||||||
break
|
break
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
start = true
|
start = true
|
||||||
|
6
run.go
6
run.go
@ -26,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var cmdRun = &Command{
|
var cmdRun = &Command{
|
||||||
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-e=Godeps -e=folderToExclude]",
|
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-e=Godeps -e=folderToExclude] [-tags=goBuildTags]",
|
||||||
Short: "run the app and start a Web server for development",
|
Short: "run the app and start a Web server for development",
|
||||||
Long: `
|
Long: `
|
||||||
Run command will supervise the file system of the beego project using inotify,
|
Run command will supervise the file system of the beego project using inotify,
|
||||||
@ -43,12 +43,16 @@ var gendoc docValue
|
|||||||
// The flags list of the paths excluded from watching
|
// The flags list of the paths excluded from watching
|
||||||
var excludedPaths strFlags
|
var excludedPaths strFlags
|
||||||
|
|
||||||
|
// Pass through to -tags arg of "go build"
|
||||||
|
var buildTags string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cmdRun.Run = runApp
|
cmdRun.Run = runApp
|
||||||
cmdRun.Flag.Var(&mainFiles, "main", "specify main go files")
|
cmdRun.Flag.Var(&mainFiles, "main", "specify main go files")
|
||||||
cmdRun.Flag.Var(&gendoc, "gendoc", "auto generate the docs")
|
cmdRun.Flag.Var(&gendoc, "gendoc", "auto generate the docs")
|
||||||
cmdRun.Flag.Var(&downdoc, "downdoc", "auto download swagger file when not exist")
|
cmdRun.Flag.Var(&downdoc, "downdoc", "auto download swagger file when not exist")
|
||||||
cmdRun.Flag.Var(&excludedPaths, "e", "Excluded paths[].")
|
cmdRun.Flag.Var(&excludedPaths, "e", "Excluded paths[].")
|
||||||
|
cmdRun.Flag.StringVar(&buildTags, "tags", "", "Build tags (https://golang.org/pkg/go/build/)")
|
||||||
}
|
}
|
||||||
|
|
||||||
var appname string
|
var appname string
|
||||||
|
7
watch.go
7
watch.go
@ -136,6 +136,7 @@ func Autobuild(files []string, isgenerate bool) {
|
|||||||
icmd := exec.Command("go", "list", "./...")
|
icmd := exec.Command("go", "list", "./...")
|
||||||
buf := bytes.NewBuffer([]byte(""))
|
buf := bytes.NewBuffer([]byte(""))
|
||||||
icmd.Stdout = buf
|
icmd.Stdout = buf
|
||||||
|
icmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
err = icmd.Run()
|
err = icmd.Run()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
list := strings.Split(buf.String(), "\n")[1:]
|
list := strings.Split(buf.String(), "\n")[1:]
|
||||||
@ -146,6 +147,7 @@ func Autobuild(files []string, isgenerate bool) {
|
|||||||
icmd = exec.Command(cmdName, "install", pkg)
|
icmd = exec.Command(cmdName, "install", pkg)
|
||||||
icmd.Stdout = os.Stdout
|
icmd.Stdout = os.Stdout
|
||||||
icmd.Stderr = os.Stderr
|
icmd.Stderr = os.Stderr
|
||||||
|
icmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
err = icmd.Run()
|
err = icmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
@ -156,6 +158,7 @@ func Autobuild(files []string, isgenerate bool) {
|
|||||||
|
|
||||||
if isgenerate {
|
if isgenerate {
|
||||||
icmd := exec.Command("bee", "generate", "docs")
|
icmd := exec.Command("bee", "generate", "docs")
|
||||||
|
icmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
icmd.Stdout = os.Stdout
|
icmd.Stdout = os.Stdout
|
||||||
icmd.Stderr = os.Stderr
|
icmd.Stderr = os.Stderr
|
||||||
icmd.Run()
|
icmd.Run()
|
||||||
@ -170,9 +173,13 @@ func Autobuild(files []string, isgenerate bool) {
|
|||||||
|
|
||||||
args := []string{"build"}
|
args := []string{"build"}
|
||||||
args = append(args, "-o", appName)
|
args = append(args, "-o", appName)
|
||||||
|
if buildTags != "" {
|
||||||
|
args = append(args, "-tags", buildTags)
|
||||||
|
}
|
||||||
args = append(args, files...)
|
args = append(args, files...)
|
||||||
|
|
||||||
bcmd := exec.Command(cmdName, args...)
|
bcmd := exec.Command(cmdName, args...)
|
||||||
|
bcmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
bcmd.Stdout = os.Stdout
|
bcmd.Stdout = os.Stdout
|
||||||
bcmd.Stderr = os.Stderr
|
bcmd.Stderr = os.Stderr
|
||||||
err = bcmd.Run()
|
err = bcmd.Run()
|
||||||
|
Loading…
Reference in New Issue
Block a user