[Feature] Development quickstart guide and Makefile additions (#3495)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
mnh 2023-02-28 23:09:28 -05:00 committed by GitHub
parent b1325ce03f
commit a081b62823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 3 deletions

3
.gitignore vendored
View file

@ -62,4 +62,5 @@ node_modules
/stash /stash
dist dist
.DS_Store .DS_Store
/.local

View file

@ -9,9 +9,14 @@ endif
ifdef IS_WIN_SHELL ifdef IS_WIN_SHELL
SEPARATOR := && SEPARATOR := &&
SET := set SET := set
RM := del /s /q
RMDIR := rmdir /s /q
PWD := $(shell echo %cd%)
else else
SEPARATOR := ; SEPARATOR := ;
SET := export SET := export
RM := rm -f
RMDIR := rm -rf
endif endif
# set LDFLAGS environment variable to any extra ldflags required # 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 # can't use static build for OSX
cross-compile-macos-applesilicon: build-release cross-compile-macos-applesilicon: build-release
cross-compile-macos: cross-compile-macos:
rm -rf dist/Stash.app dist/Stash-macos.zip rm -rf dist/Stash.app dist/Stash-macos.zip
make cross-compile-macos-applesilicon make cross-compile-macos-applesilicon
make cross-compile-macos-intel make cross-compile-macos-intel
@ -175,7 +180,7 @@ generate-frontend:
cd ui/v2.5 && yarn run gqlgen cd ui/v2.5 && yarn run gqlgen
.PHONY: generate-backend .PHONY: generate-backend
generate-backend: touch-ui generate-backend: touch-ui
go generate -mod=vendor ./cmd/stash go generate -mod=vendor ./cmd/stash
.PHONY: generate-dataloaders .PHONY: generate-dataloaders
@ -211,6 +216,23 @@ it:
generate-test-mocks: generate-test-mocks:
go run -mod=vendor github.com/vektra/mockery/v2 --dir ./pkg/models --name '.*ReaderWriter' --outpkg mocks --output ./pkg/models/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 # installs UI dependencies. Run when first cloning repository, or if UI
# dependencies have changed # dependencies have changed
.PHONY: pre-ui .PHONY: pre-ui

View file

@ -39,8 +39,35 @@ NOTE: The `make` command in Windows will be `mingw32-make` with MingW. For examp
* `make fmt` - Run `go fmt` * `make fmt` - Run `go fmt`
* `make it` - Run the unit and integration tests * `make it` - Run the unit and integration tests
* `make validate` - Run all of the tests and checks required to submit a PR * `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. * `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 ## Building a release
1. Run `make pre-ui` to install UI dependencies 1. Run `make pre-ui` to install UI dependencies