From 2d3531dd6654a0029b9f50878c972ce5f9c0dcca Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sun, 27 Nov 2022 23:21:42 +0200 Subject: [PATCH] removed git path lookups and updated examples/base .gitignore --- examples/base/.gitignore | 9 ++++++--- examples/base/main.go | 4 +--- plugins/migratecmd/migratecmd.go | 19 +++---------------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/examples/base/.gitignore b/examples/base/.gitignore index 8901848e..b0b3cfb8 100644 --- a/examples/base/.gitignore +++ b/examples/base/.gitignore @@ -1,3 +1,6 @@ -pb_data/ -pb_public/ -pb_migrations/ +# ignore everything +/* + +# exclude from the ignore filter +!.gitignore +!main.go diff --git a/examples/base/main.go b/examples/base/main.go index a81a7b6d..92fd20d2 100644 --- a/examples/base/main.go +++ b/examples/base/main.go @@ -3,7 +3,6 @@ package main import ( "log" "os" - "os/exec" "github.com/pocketbase/pocketbase" "github.com/pocketbase/pocketbase/plugins/jsvm" @@ -27,11 +26,10 @@ func main() { ) var automigrate bool - _, gitErr := exec.LookPath("git") app.RootCmd.PersistentFlags().BoolVar( &automigrate, "automigrate", - gitErr == nil, + true, "enable/disable auto migrations", ) diff --git a/plugins/migratecmd/migratecmd.go b/plugins/migratecmd/migratecmd.go index 7ae84eea..b667b28b 100644 --- a/plugins/migratecmd/migratecmd.go +++ b/plugins/migratecmd/migratecmd.go @@ -4,13 +4,11 @@ import ( "fmt" "log" "os" - "os/exec" "path" "path/filepath" "time" "github.com/AlecAivazis/survey/v2" - "github.com/fatih/color" "github.com/pocketbase/pocketbase/core" "github.com/pocketbase/pocketbase/migrations" "github.com/pocketbase/pocketbase/models" @@ -33,9 +31,6 @@ type Options struct { // TemplateLang specifies the template language to use when // generating migrations - js or go (default). TemplateLang string - - // GitPath is the git cmd binary path (default to just "git"). - GitPath string } type plugin struct { @@ -70,10 +65,6 @@ func Register(app core.App, rootCmd *cobra.Command, options *Options) error { } } - if p.options.GitPath == "" { - p.options.GitPath = "git" - } - // attach the migrate command if rootCmd != nil { rootCmd.AddCommand(p.createCommand()) @@ -86,13 +77,9 @@ func Register(app core.App, rootCmd *cobra.Command, options *Options) error { return nil }) - if _, err := exec.LookPath(p.options.GitPath); err != nil { - color.Yellow("WARNING: Automigrate cannot be enabled because %s is not installed or accessible.", p.options.GitPath) - } else { - p.app.OnModelAfterCreate().Add(p.afterCollectionChange()) - p.app.OnModelAfterUpdate().Add(p.afterCollectionChange()) - p.app.OnModelAfterDelete().Add(p.afterCollectionChange()) - } + p.app.OnModelAfterCreate().Add(p.afterCollectionChange()) + p.app.OnModelAfterUpdate().Add(p.afterCollectionChange()) + p.app.OnModelAfterDelete().Add(p.afterCollectionChange()) } return nil