mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
refactor(dev): use ENV var to enable hub dev mode
This commit is contained in:
@@ -48,6 +48,7 @@ dev-server: generate-locales
|
|||||||
cd ./site && npm run dev; \
|
cd ./site && npm run dev; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dev-hub: export ENV=dev
|
||||||
dev-hub:
|
dev-hub:
|
||||||
mkdir -p ./site/dist && touch ./site/dist/index.html
|
mkdir -p ./site/dist && touch ./site/dist/index.html
|
||||||
@if command -v entr >/dev/null 2>&1; then \
|
@if command -v entr >/dev/null 2>&1; then \
|
||||||
|
@@ -77,13 +77,12 @@ func GetEnv(key string) (value string, exists bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hub) Run() {
|
func (h *Hub) Run() {
|
||||||
// loosely check if it was executed using "go run"
|
isDev := os.Getenv("ENV") == "dev"
|
||||||
isGoRun := strings.HasPrefix(os.Args[0], os.TempDir())
|
|
||||||
|
|
||||||
// enable auto creation of migration files when making collection changes in the Admin UI
|
// enable auto creation of migration files when making collection changes in the Admin UI
|
||||||
migratecmd.MustRegister(h, h.RootCmd, migratecmd.Config{
|
migratecmd.MustRegister(h, h.RootCmd, migratecmd.Config{
|
||||||
// (the isGoRun check is to enable it only during development)
|
// (the isDev check is to enable it only during development)
|
||||||
Automigrate: isGoRun,
|
Automigrate: isDev,
|
||||||
Dir: "../../migrations",
|
Dir: "../../migrations",
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -132,7 +131,7 @@ func (h *Hub) Run() {
|
|||||||
|
|
||||||
// serve web ui
|
// serve web ui
|
||||||
h.OnServe().BindFunc(func(se *core.ServeEvent) error {
|
h.OnServe().BindFunc(func(se *core.ServeEvent) error {
|
||||||
switch isGoRun {
|
switch isDev {
|
||||||
case true:
|
case true:
|
||||||
proxy := httputil.NewSingleHostReverseProxy(&url.URL{
|
proxy := httputil.NewSingleHostReverseProxy(&url.URL{
|
||||||
Scheme: "http",
|
Scheme: "http",
|
||||||
|
Reference in New Issue
Block a user