diff --git a/.gitignore b/.gitignore index 7b392ac70..197fd7302 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,5 @@ node_modules /stash dist -.DS_Store \ No newline at end of file +.DS_Store +/.local \ No newline at end of file diff --git a/Makefile b/Makefile index fe7628a56..85167f990 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,14 @@ endif ifdef IS_WIN_SHELL SEPARATOR := && SET := set + RM := del /s /q + RMDIR := rmdir /s /q + PWD := $(shell echo %cd%) else SEPARATOR := ; SET := export + RM := rm -f + RMDIR := rm -rf endif # set LDFLAGS environment variable to any extra ldflags required @@ -99,7 +104,7 @@ cross-compile-macos-applesilicon: GO_BUILD_TAGS := $(GO_BUILD_TAGS_DEFAULT) # can't use static build for OSX cross-compile-macos-applesilicon: build-release -cross-compile-macos: +cross-compile-macos: rm -rf dist/Stash.app dist/Stash-macos.zip make cross-compile-macos-applesilicon make cross-compile-macos-intel @@ -175,7 +180,7 @@ generate-frontend: cd ui/v2.5 && yarn run gqlgen .PHONY: generate-backend -generate-backend: touch-ui +generate-backend: touch-ui go generate -mod=vendor ./cmd/stash .PHONY: generate-dataloaders @@ -211,6 +216,23 @@ it: generate-test-mocks: go run -mod=vendor github.com/vektra/mockery/v2 --dir ./pkg/models --name '.*ReaderWriter' --outpkg mocks --output ./pkg/models/mocks +# runs server +# sets the config file to use the local dev config +.PHONY: server-start +server-start: export STASH_CONFIG_FILE=config.yml +server-start: +ifndef IS_WIN_SHELL + @mkdir -p .local +else + @if not exist ".local" mkdir .local +endif + cd .local && go run ../cmd/stash + +# removes local dev config files +.PHONY: server-clean +server-clean: + $(RMDIR) .local + # installs UI dependencies. Run when first cloning repository, or if UI # dependencies have changed .PHONY: pre-ui diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 6a563217d..b92f06de3 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -39,8 +39,35 @@ NOTE: The `make` command in Windows will be `mingw32-make` with MingW. For examp * `make fmt` - Run `go fmt` * `make it` - Run the unit and integration tests * `make validate` - Run all of the tests and checks required to submit a PR +* `make server-start` - Runs an instance of the server in the `.local` directory. +* `make server-clean` - Removes the `.local` directory and all of its contents. * `make ui-start` - Runs the UI in development mode. Requires a running stash server to connect to. Stash server port can be changed from the default of `9999` using environment variable `VITE_APP_PLATFORM_PORT`. UI runs on port `3000` or the next available port. +## Local development quickstart + +1. Run `make pre-ui` to install UI dependencies +2. Run `make generate` to create generated files +3. In one terminal, run `make server-start` to run the server code +4. In a separate terminal, run `make ui-start` to run the UI in development mode +5. Open the UI in a browser `http://localhost:3000/` + +Changes to the UI code can be seen by reloading the browser page. + +Changes to the server code requires a restart (`CTRL-C` in the server terminal). + +On first launch: +1. On the "Stash Setup Wizard" screen, choose a directory with some files to test with +2. Press "Next" to use the default locations for the database and generated content +3. Press the "Confirm" and "Finish" buttons to get into the UI +4. On the side menu, navigate to "Tasks -> Library -> Scan" and press the "Scan" button +5. You're all set! Set any other configurations you'd like and test your code changes. + +To start fresh with new configuration: +1. Stop the server (`CTRL-C` in the server terminal) +2. Run `make server-clean` to clear all config, database, and generated files (under `.local/`) +3. Run `make server-start` to restart the server +4. Follow the "On first launch" steps above + ## Building a release 1. Run `make pre-ui` to install UI dependencies