diff --git a/Makefile b/Makefile index 3f69e6085..a536b4111 100644 --- a/Makefile +++ b/Makefile @@ -165,16 +165,16 @@ pre-ui: .PHONY: ui ui: pre-build - $(SET) REACT_APP_DATE="$(BUILD_DATE)" $(SEPARATOR) \ - $(SET) REACT_APP_GITHASH=$(GITHASH) $(SEPARATOR) \ - $(SET) REACT_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \ + $(SET) VITE_APP_DATE="$(BUILD_DATE)" $(SEPARATOR) \ + $(SET) VITE_APP_GITHASH=$(GITHASH) $(SEPARATOR) \ + $(SET) VITE_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \ cd ui/v2.5 && yarn build .PHONY: ui-start ui-start: pre-build - $(SET) REACT_APP_DATE="$(BUILD_DATE)" $(SEPARATOR) \ - $(SET) REACT_APP_GITHASH=$(GITHASH) $(SEPARATOR) \ - $(SET) REACT_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \ + $(SET) VITE_APP_DATE="$(BUILD_DATE)" $(SEPARATOR) \ + $(SET) VITE_APP_GITHASH=$(GITHASH) $(SEPARATOR) \ + $(SET) VITE_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \ cd ui/v2.5 && yarn start .PHONY: fmt-ui diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index e33b96018..4601962a4 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -24,22 +24,22 @@ NOTE: The `make` command in Windows will be `mingw32-make` with MingW. ### macOS -TODO - +1. If you don't have it already, install the [Homebrew package manager](https://brew.sh). +2. Install dependencies: `brew install go git yarn gcc make` ## Commands -* `make generate` - Generate Go and UI GraphQL files -* `make build` - Builds the binary (make sure to build the UI as well... see below) -* `make docker-build` - Locally builds and tags a complete 'stash/build' docker image * `make pre-ui` - Installs the UI dependencies. Only needs to be run once before building the UI for the first time, or if the dependencies are updated +* `make generate` - Generate Go and UI GraphQL files * `make fmt-ui` - Formats the UI source code * `make ui` - Builds the frontend +* `make build` - Builds the binary (make sure to build the UI as well... see below) +* `make docker-build` - Locally builds and tags a complete 'stash/build' docker image * `make lint` - Run the linter on the backend * `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 ui-start` - Runs the UI in development mode. Requires a running stash server to connect to. Stash port can be changed from the default of `9999` with environment variable `REACT_APP_PLATFORM_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. ## Building a release diff --git a/go.mod b/go.mod index f8f4efda0..fa5116e2a 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,10 @@ require ( gopkg.in/yaml.v2 v2.4.0 ) -require github.com/vektah/gqlparser/v2 v2.0.1 +require ( + github.com/vearutop/statigz v1.1.5 + github.com/vektah/gqlparser/v2 v2.0.1 +) require ( github.com/agnivade/levenshtein v1.1.0 // indirect diff --git a/go.sum b/go.sum index 27cbde3ef..4841ff7c5 100644 --- a/go.sum +++ b/go.sum @@ -79,6 +79,8 @@ github.com/anacrolix/missinggo v1.1.0/go.mod h1:MBJu3Sk/k3ZfGYcS7z18gwfu72Ey/xop github.com/anacrolix/tagflag v0.0.0-20180109131632-2146c8d41bf0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.3 h1:fpcw+r1N1h0Poc1F/pHbW40cUm/lMEQslZtCkBQ0UnM= +github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M= github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0= github.com/antchfx/xpath v1.1.6 h1:6sVh6hB5T6phw1pFpHRQ+C4bd8sNI+O58flqtg7h0R0= @@ -126,6 +128,8 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/bool64/dev v0.1.41 h1:L554LCQZc3d7mtcdPUgDbSrCVbr48/30zgu0VuC/FTA= +github.com/bool64/dev v0.1.41/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU= github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= github.com/bradfitz/iter v0.0.0-20190303215204-33e6a9893b0c/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= @@ -706,6 +710,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= +github.com/vearutop/statigz v1.1.5 h1:qWvRgXFsseWVTFCkIvwHQPpaLNf9WI0+dDJE7I9432o= +github.com/vearutop/statigz v1.1.5/go.mod h1:czAv7iXgPv/s+xsgXpVEhhD0NSOQ4wZPgmM/n7LANDI= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser v1.3.1 h1:8b0IcD3qZKWJQHSzynbDlrtP3IxVydZ2DZepCGofqfU= diff --git a/pkg/api/server.go b/pkg/api/server.go index 0cde14fb4..7f348d618 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -30,6 +30,7 @@ import ( "github.com/stashapp/stash/pkg/manager/config" "github.com/stashapp/stash/pkg/models" "github.com/stashapp/stash/pkg/utils" + "github.com/vearutop/statigz" ) var version string @@ -213,11 +214,8 @@ func Start(uiBox embed.FS, loginUIBox embed.FS) { if isStatic { w.Header().Add("Cache-Control", "max-age=604800000") } - uiRoot, err := fs.Sub(uiBox, uiRootDir) - if err != nil { - panic(err) - } - http.FileServer(http.FS(uiRoot)).ServeHTTP(w, r) + r.URL.Path = uiRootDir + r.URL.Path + statigz.FileServer(uiBox).ServeHTTP(w, r) } }) diff --git a/ui/v2.5/.babelrc b/ui/v2.5/.babelrc deleted file mode 100644 index c14b2828d..000000000 --- a/ui/v2.5/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["react-app"] -} diff --git a/ui/v2.5/craco.config.js b/ui/v2.5/craco.config.js deleted file mode 100644 index 5309c4c3e..000000000 --- a/ui/v2.5/craco.config.js +++ /dev/null @@ -1,4 +0,0 @@ -const CracoEsbuildPlugin = require('craco-esbuild'); -module.exports = { - plugins: [{ plugin: CracoEsbuildPlugin }], -}; diff --git a/ui/v2.5/public/index.html b/ui/v2.5/index.html similarity index 64% rename from ui/v2.5/public/index.html rename to ui/v2.5/index.html index 62c7d3940..4b6756202 100755 --- a/ui/v2.5/public/index.html +++ b/ui/v2.5/index.html @@ -3,7 +3,7 @@