diff --git a/README.md b/README.md index 6b2785637b..f512b28290 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ If you want to develop on Windows, we recommend setting up a Ubuntu virtual mach We use a makefile for our build system. These commands will usually be all you need while developing for this project: ```sh # Installs a pre-commit git hook so that your go code is automatically formatted (if you don't use an IDE that supports that). If you want to manually format go code you can run make fmt. +# Also installs `air` to reload the dev servers automatically make setup # Run all the tests. Currently only the backend sim has tests. @@ -92,6 +93,9 @@ make update-tests # Recompiles the entire client before launching using `make dist/wotlk` make host +# With file-watching so the server auto-restarts and recompiles on Go or TS changes: +WATCH=1 make host + # Delete all generated files (.pb.go and .ts proto files, and dist/) make clean @@ -103,6 +107,9 @@ make host_$spec # To rebuild client for a spec just do 'make $spec' and refresh browser. make rundevserver +# With file-watching so the server auto-restarts and recompiles on Go or TS changes: +WATCH=1 make rundevserver + # Creates the 'wowsimwotlk' binary that can host the UI and run simulations natively (instead of with wasm). # Builds the UI and the compiles it into the binary so that you can host the sim as a server instead of wasm on the client. # It does this by first doing make dist/wotlk and then copying all those files to binary_dist/wotlk and loading all the files in that directory into its binary on compile. diff --git a/makefile b/makefile index ec6a579178..2c1d0f99d7 100644 --- a/makefile +++ b/makefile @@ -153,14 +153,16 @@ devserver: sim/core/proto/api.pb.go sim/web/main.go binary_dist/dist.go .PHONY: air air: ifeq ($(WATCH), 1) - @ ! command -v air && curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin || true + @if ! command -v air; then \ + echo "Missing air dependency. Please run \`make setup\`"; \ + exit 1; \ + fi endif -rundevserver: devserver air +rundevserver: air devserver ifeq ($(WATCH), 1) - ulimit -n 10240 - air -tmp_dir "/tmp" -build.include_ext "go,ts,js,html" -build.bin "true" -build.cmd "make" -build.exclude_dir "dist,node_modules,sim,tools" & - air -tmp_dir "/tmp" -build.args_bin "--usefs=true --launch=false" -build.bin "./wowsimwotlk" -build.cmd "make devserver" -build.exclude_dir "assets,dist,node_modules,ui,tools" + ulimit -n 10240 && air -tmp_dir "/tmp" -build.include_ext "go,ts,js,html" -build.bin "true" -build.cmd "make" -build.exclude_dir "dist,node_modules,sim,tools" & + ulimit -n 10240 && air -tmp_dir "/tmp" -build.args_bin "--usefs=true --launch=false" -build.bin "./wowsimwotlk" -build.cmd "make devserver" -build.exclude_dir "assets,dist,node_modules,ui,tools" else ./wowsimwotlk --usefs=true --launch=false endif @@ -209,13 +211,13 @@ tsfmt: setup: cp pre-commit .git/hooks chmod +x .git/hooks/pre-commit + ! command -v air && curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin || true # Host a local server, for dev testing .PHONY: host -host: $(OUT_DIR)/.dirstamp node_modules air +host: air $(OUT_DIR)/.dirstamp node_modules ifeq ($(WATCH), 1) - ulimit -n 10240 - air -tmp_dir "/tmp" -build.include_ext "go,ts,js,html" -build.bin "npx" -build.args_bin "http-server $(OUT_DIR)/.." -build.cmd "make" -build.exclude_dir "dist,node_modules,tools" + ulimit -n 10240 && air -tmp_dir "/tmp" -build.include_ext "go,ts,js,html" -build.bin "npx" -build.args_bin "http-server $(OUT_DIR)/.." -build.cmd "make" -build.exclude_dir "dist,node_modules,tools" else # Intentionally serve one level up, so the local site has 'wotlk' as the first # directory just like github pages.