refactor(server): generate runtime configs and use .build/config for development
This commit is contained in:
@@ -23,9 +23,9 @@ func runDevelopmentCommand(args []string) (bool, error) {
|
||||
}
|
||||
serveArgs := append([]string(nil), args[2:]...)
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--version-config", filepath.Join(root, "versions.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--authentication-config", filepath.Join(root, "authentication.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--resource-config", filepath.Join(root, "resources.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--game-config", filepath.Join(root, "game.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--authentication-config", filepath.Join(root, ".build", "config", "authentication.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--resource-config", filepath.Join(root, ".build", "config", "resources.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--game-config", filepath.Join(root, ".build", "config", "game.json"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--data-dir", filepath.Join(root, "data"))
|
||||
serveArgs = appendDefaultFlag(serveArgs, "--state", filepath.Join(root, "data", "state", "state.db"))
|
||||
return true, serve(serveArgs)
|
||||
@@ -38,9 +38,7 @@ func findDevelopmentRoot() (string, error) {
|
||||
}
|
||||
for directory := filepath.Clean(working); ; directory = filepath.Dir(directory) {
|
||||
if regularDevelopmentFile(filepath.Join(directory, "versions.json")) &&
|
||||
regularDevelopmentFile(filepath.Join(directory, "go", "go.mod")) &&
|
||||
regularDevelopmentFile(filepath.Join(directory, "authentication.json")) &&
|
||||
regularDevelopmentFile(filepath.Join(directory, "resources.json")) {
|
||||
regularDevelopmentFile(filepath.Join(directory, "go", "go.mod")) {
|
||||
return directory, nil
|
||||
}
|
||||
parent := filepath.Dir(directory)
|
||||
|
||||
@@ -2,7 +2,29 @@
|
||||
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFindDevelopmentRootWithoutRuntimeConfigurations(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
child := filepath.Join(root, "go", "cmd")
|
||||
if err := os.MkdirAll(child, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{filepath.Join(root, "versions.json"), filepath.Join(root, "go", "go.mod")} {
|
||||
if err := os.WriteFile(path, nil, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
t.Chdir(child)
|
||||
got, err := findDevelopmentRoot()
|
||||
if err != nil || got != root {
|
||||
t.Fatalf("development root = %q, %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppendDefaultFlagPreservesExplicitOverride(t *testing.T) {
|
||||
for _, args := range [][]string{{"--data-dir", "custom"}, {"--data-dir=custom"}} {
|
||||
|
||||
Reference in New Issue
Block a user