mirror of
https://github.com/pocketbase/pocketbase.git
synced 2024-11-24 09:02:26 +02:00
removed git path lookups and updated examples/base .gitignore
This commit is contained in:
parent
7ac3a74440
commit
2d3531dd66
9
examples/base/.gitignore
vendored
9
examples/base/.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
pb_data/
|
# ignore everything
|
||||||
pb_public/
|
/*
|
||||||
pb_migrations/
|
|
||||||
|
# exclude from the ignore filter
|
||||||
|
!.gitignore
|
||||||
|
!main.go
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
"github.com/pocketbase/pocketbase"
|
"github.com/pocketbase/pocketbase"
|
||||||
"github.com/pocketbase/pocketbase/plugins/jsvm"
|
"github.com/pocketbase/pocketbase/plugins/jsvm"
|
||||||
@ -27,11 +26,10 @@ func main() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
var automigrate bool
|
var automigrate bool
|
||||||
_, gitErr := exec.LookPath("git")
|
|
||||||
app.RootCmd.PersistentFlags().BoolVar(
|
app.RootCmd.PersistentFlags().BoolVar(
|
||||||
&automigrate,
|
&automigrate,
|
||||||
"automigrate",
|
"automigrate",
|
||||||
gitErr == nil,
|
true,
|
||||||
"enable/disable auto migrations",
|
"enable/disable auto migrations",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,13 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/AlecAivazis/survey/v2"
|
"github.com/AlecAivazis/survey/v2"
|
||||||
"github.com/fatih/color"
|
|
||||||
"github.com/pocketbase/pocketbase/core"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/migrations"
|
"github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
@ -33,9 +31,6 @@ type Options struct {
|
|||||||
// TemplateLang specifies the template language to use when
|
// TemplateLang specifies the template language to use when
|
||||||
// generating migrations - js or go (default).
|
// generating migrations - js or go (default).
|
||||||
TemplateLang string
|
TemplateLang string
|
||||||
|
|
||||||
// GitPath is the git cmd binary path (default to just "git").
|
|
||||||
GitPath string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type plugin struct {
|
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
|
// attach the migrate command
|
||||||
if rootCmd != nil {
|
if rootCmd != nil {
|
||||||
rootCmd.AddCommand(p.createCommand())
|
rootCmd.AddCommand(p.createCommand())
|
||||||
@ -86,14 +77,10 @@ func Register(app core.App, rootCmd *cobra.Command, options *Options) error {
|
|||||||
return nil
|
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.OnModelAfterCreate().Add(p.afterCollectionChange())
|
||||||
p.app.OnModelAfterUpdate().Add(p.afterCollectionChange())
|
p.app.OnModelAfterUpdate().Add(p.afterCollectionChange())
|
||||||
p.app.OnModelAfterDelete().Add(p.afterCollectionChange())
|
p.app.OnModelAfterDelete().Add(p.afterCollectionChange())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user