Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

fixed sqlite tags not working properly #947

Merged
merged 3 commits into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions buffalo/cmd/build/apkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,12 @@ func (b *Builder) buildADatabase() error {
if err != nil {
return errors.WithStack(err)
}
if !bytes.Contains(bb.Bytes(), []byte("sqlite")) {
logrus.Debug("no sqlite usage in database.yml detected, applying the nosqlite tag")
b.Tags = append(b.Tags, "nosqlite")
} else if !b.Static {
logrus.Debug("you are building a SQLite application, please consider using the `--static` flag to compile a static binary")
if bytes.Contains(bb.Bytes(), []byte("sqlite")) {
b.Tags = append(b.Tags, "sqlite")
if !b.Static {
logrus.Debug("you are building a SQLite application, please consider using the `--static` flag to compile a static binary")
}
}
} else {
logrus.Debug("no database.yml detected, applying the nosqlite tag")
// add the nosqlite build tag if there is no database being used
b.Tags = append(b.Tags, "nosqlite")
}
dgo.WriteString("package a\n")
dgo.WriteString(fmt.Sprintf("var DB_CONFIG = `%s`", bb.String()))
Expand Down
4 changes: 3 additions & 1 deletion buffalo/cmd/new.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"os"
"os/exec"
"os/user"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/gobuffalo/envy"
"github.com/gobuffalo/makr"
"github.com/gobuffalo/plush"
"github.com/gobuffalo/pop"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -131,7 +133,7 @@ func init() {
newCmd.Flags().BoolVar(&app.WithDep, "with-dep", false, "adds github.com/golang/dep to your app")
newCmd.Flags().BoolVar(&app.SkipWebpack, "skip-webpack", false, "skips adding Webpack to your app")
newCmd.Flags().BoolVar(&app.SkipYarn, "skip-yarn", false, "use npm instead of yarn for frontend dependencies management")
newCmd.Flags().StringVar(&app.DBType, "db-type", "postgres", "specify the type of database you want to use [postgres, mysql, sqlite3, cockroach]")
newCmd.Flags().StringVar(&app.DBType, "db-type", "postgres", fmt.Sprintf("specify the type of database you want to use [%s]", strings.Join(pop.AvailableDialects, ", ")))
newCmd.Flags().StringVar(&app.Docker, "docker", "multi", "specify the type of Docker file to generate [none, multi, standard]")
newCmd.Flags().StringVar(&app.CIProvider, "ci-provider", "none", "specify the type of ci file you would like buffalo to generate [none, travis, gitlab-ci]")
newCmd.Flags().StringVar(&app.VCS, "vcs", "git", "specify the Version control system you would like to use [none, git, bzr]")
Expand Down
12 changes: 10 additions & 2 deletions generators/newapp/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/gobuffalo/buffalo/meta"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/pop"
"github.com/markbates/inflect"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -59,8 +60,15 @@ func (g Generator) Validate() error {
return errors.New("you must enter a name for your new application")
}

if g.DBType != "postgres" && g.DBType != "mysql" && g.DBType != "sqlite3" && g.DBType != "cockroach" {
return fmt.Errorf("Unknown db-type %s expecting one of postgres, mysql or sqlite3", g.DBType)
var found bool
for _, d := range pop.AvailableDialects {
if d == g.DBType {
found = true
break
}
}
if !found {
return fmt.Errorf("Unknown db-type %s expecting one of %s", g.DBType, strings.Join(pop.AvailableDialects, ", "))
}

for _, n := range forbiddenAppNames {
Expand Down