From e034763ce0f7f94c7fa390e00f81bc6069d85a43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:52:53 -0500 Subject: [PATCH 1/4] chore(deps): bump phin and load-bmfont (#503) Bumps [phin](https://github.com/ethanent/phin) and [load-bmfont](https://github.com/Jam3/load-bmfont). These dependencies needed to be updated together. Updates `phin` from 2.9.3 to 3.7.1 - [Commits](https://github.com/ethanent/phin/commits) Updates `load-bmfont` from 1.4.1 to 1.4.2 - [Commits](https://github.com/Jam3/load-bmfont/compare/v1.4.1...v1.4.2) --- updated-dependencies: - dependency-name: phin dependency-type: indirect - dependency-name: load-bmfont dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ffe4cc4..f06f4fa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11072,6 +11072,15 @@ "license": "Apache-2.0", "optional": true }, + "node_modules/centra": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/centra/-/centra-2.7.0.tgz", + "integrity": "sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.6" + } + }, "node_modules/chai": { "version": "4.3.10", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", @@ -21674,9 +21683,9 @@ "license": "MIT" }, "node_modules/load-bmfont": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.1.tgz", - "integrity": "sha512-8UyQoYmdRDy81Brz6aLAUhfZLwr5zV0L3taTQ4hju7m6biuwiWiJXjPhBJxbUQJA8PrkvJ/7Enqmwk2sM14soA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.2.tgz", + "integrity": "sha512-qElWkmjW9Oq1F9EI5Gt7aD9zcdHb9spJCW1L/dmPf7KzCCEJxq8nhHz5eCgI9aMf7vrG/wyaCqdsI+Iy9ZTlog==", "dev": true, "dependencies": { "buffer-equal": "0.0.1", @@ -21684,7 +21693,7 @@ "parse-bmfont-ascii": "^1.0.3", "parse-bmfont-binary": "^1.0.5", "parse-bmfont-xml": "^1.1.4", - "phin": "^2.9.1", + "phin": "^3.7.1", "xhr": "^2.0.1", "xtend": "^4.0.0" } @@ -24272,10 +24281,16 @@ } }, "node_modules/phin": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", - "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==", - "dev": true + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/phin/-/phin-3.7.1.tgz", + "integrity": "sha512-GEazpTWwTZaEQ9RhL7Nyz0WwqilbqgLahDM3D0hxWwmVDI52nXEybHqiN6/elwpkJBhcuj+WbBu+QfT0uhPGfQ==", + "dev": true, + "dependencies": { + "centra": "^2.7.0" + }, + "engines": { + "node": ">= 8" + } }, "node_modules/picocolors": { "version": "1.0.0", @@ -40430,6 +40445,15 @@ "version": "0.11.0", "optional": true }, + "centra": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/centra/-/centra-2.7.0.tgz", + "integrity": "sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==", + "dev": true, + "requires": { + "follow-redirects": "^1.15.6" + } + }, "chai": { "version": "4.3.10", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", @@ -47827,9 +47851,9 @@ "version": "1.2.4" }, "load-bmfont": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.1.tgz", - "integrity": "sha512-8UyQoYmdRDy81Brz6aLAUhfZLwr5zV0L3taTQ4hju7m6biuwiWiJXjPhBJxbUQJA8PrkvJ/7Enqmwk2sM14soA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.2.tgz", + "integrity": "sha512-qElWkmjW9Oq1F9EI5Gt7aD9zcdHb9spJCW1L/dmPf7KzCCEJxq8nhHz5eCgI9aMf7vrG/wyaCqdsI+Iy9ZTlog==", "dev": true, "requires": { "buffer-equal": "0.0.1", @@ -47837,7 +47861,7 @@ "parse-bmfont-ascii": "^1.0.3", "parse-bmfont-binary": "^1.0.5", "parse-bmfont-xml": "^1.1.4", - "phin": "^2.9.1", + "phin": "^3.7.1", "xhr": "^2.0.1", "xtend": "^4.0.0" }, @@ -49583,10 +49607,13 @@ } }, "phin": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", - "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==", - "dev": true + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/phin/-/phin-3.7.1.tgz", + "integrity": "sha512-GEazpTWwTZaEQ9RhL7Nyz0WwqilbqgLahDM3D0hxWwmVDI52nXEybHqiN6/elwpkJBhcuj+WbBu+QfT0uhPGfQ==", + "dev": true, + "requires": { + "centra": "^2.7.0" + } }, "picocolors": { "version": "1.0.0", From 7d1d8e506af5ebeb7d6356bea0b6ff1ea403a218 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:27:48 -0500 Subject: [PATCH 2/4] chore(deps): bump fast-loops from 1.1.3 to 1.1.4 (#504) Bumps [fast-loops](https://github.com/robinweser/fast-loops) from 1.1.3 to 1.1.4. - [Commits](https://github.com/robinweser/fast-loops/commits) --- updated-dependencies: - dependency-name: fast-loops dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f06f4fa9..3f2807f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15026,8 +15026,9 @@ "license": "MIT" }, "node_modules/fast-loops": { - "version": "1.1.3", - "license": "MIT" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-loops/-/fast-loops-1.1.4.tgz", + "integrity": "sha512-8dbd3XWoKCTms18ize6JmQF1SFnnfj5s0B7rRry22EofgMu7B6LKHVh+XfFqFGsqnbH54xgeO83PzpKI+ODhlg==" }, "node_modules/fast-memoize": { "version": "2.5.2", @@ -43127,7 +43128,9 @@ "dev": true }, "fast-loops": { - "version": "1.1.3" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-loops/-/fast-loops-1.1.4.tgz", + "integrity": "sha512-8dbd3XWoKCTms18ize6JmQF1SFnnfj5s0B7rRry22EofgMu7B6LKHVh+XfFqFGsqnbH54xgeO83PzpKI+ODhlg==" }, "fast-memoize": { "version": "2.5.2" From 4e053444fe2f0f6db1a48734b78d2d5f39cef535 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Thu, 29 Aug 2024 20:58:18 -0500 Subject: [PATCH 3/4] feat(project): Replace Create React App with Vite (#506) * chore(deps): [wip] use vite for dev server chore(config): treat .js files as .jsx chore(project): rename .jsx files to .js * fix(ui): eliminate some visual regressions * fix(project): eliminate Sass warnings * chore(project): [wip] switch from jest to vitest * chore(project): [wip] fix some tests chore(project): [wip] await importActual * chore(project): [wip] remove top-level importActual * chore(project): [wip] fix some broken tests chore(project): [wip] fix broken test chore(project): [wip] fix broken test chore(project): [wip] fix broken test chore(project): [wip] fix broken test chore(project): [wip] fix broken test chore(project): [wip] fix broken test * chore(project): replace failing Enzyme tests with RTL tests * chore(project): [wip] fix broken utils tests * fix(project): define vitest global * chore(ci): report test coverage * fix(project): load cow template assets as dataUris * fix(vercel): update ignoreCommand * fix(vercel): update framework and outputDirectory * feat(project): use VITE_* environment variables * fix(ui): patch vertical hr style * chore(pwa): use vite-plugin-pwa * fix(ui): remove bad line-height setting * fix(workflows): use dist directory * fix(tsconfig): update exclude list * chore(deps): remove unused jest packages * chore(scripts): update test:debug and pre-commit hook * chore(deps): remove react-scripts * fix(scripts): update build:native configuration * chore(build): generate source maps * fix(scripts): make print:crops work again * fix(config): use --base where PUBLIC_URL was used previously * fix(project): use import.meta.env.MODE instead of import.meta.env.NODE_ENV * chore(package): treat package as a module * refactor: cleanup --- .env | 10 +- .eslintrc.json | 3 + .github/workflows/ci.yml | 11 +- .github/workflows/run-release.yml | 14 +- .gitignore | 1 + README.md | 6 +- public/index.html => index.html | 23 +- manifest.js | 34 + package-lock.json | 62777 ++++++++-------- package.json | 74 +- public/manifest.json | 31 - src/common/services/randomNumber.js | 6 +- src/common/services/randomNumber.test.js | 2 +- src/common/utils.test.js | 10 +- .../AccountingView/AccountingView.test.js | 4 +- .../AnimatedNumber/AnimatedNumber.js | 2 - .../AnimatedNumber/AnimatedNumber.sass | 1 - src/components/ContextPane/ContextPane.sass | 2 + .../CowCard/Subheader/Subheader.test.js | 2 +- src/components/CowPen/CowPen.sass | 2 +- src/components/CowPen/CowPen.test.js | 17 +- .../CowPenContextMenu.test.js | 4 +- src/components/Farmhand/Farmhand.js | 24 +- src/components/Farmhand/Farmhand.sass | 17 +- src/components/Farmhand/Farmhand.test.js | 4 +- src/components/Farmhand/FarmhandReducers.js | 2 +- .../helpers/getInventoryQuantities.test.js | 2 +- .../FermentationRecipeList.test.js | 2 +- src/components/Field/Field.js | 1 + src/components/Field/Field.sass | 2 +- src/components/Field/Field.test.js | 65 +- src/components/Home/Home.js | 8 +- src/components/Home/Home.test.js | 2 +- src/components/Inventory/Inventory.js | 2 - src/components/Inventory/Inventory.sass | 1 - src/components/Inventory/Inventory.test.js | 33 +- src/components/Item/Item.test.js | 2 +- .../KeybindingsView/KeybindingsView.js | 2 - .../KeybindingsView/KeybindingsView.sass | 1 - src/components/Navigation/Navigation.js | 4 +- .../OnlinePeersView/OnlinePeer/OnlinePeer.js | 2 - .../OnlinePeer/OnlinePeer.sass | 2 - .../OnlinePeersView/OnlinePeersView.js | 2 - .../OnlinePeersView/OnlinePeersView.sass | 1 - src/components/Plot/Plot.rtl.test.js | 8 +- src/components/Plot/Plot.sass | 2 +- src/components/Plot/Plot.test.js | 12 +- .../PriceEventView/PriceEventView.js | 2 - .../PriceEventView/PriceEventView.sass | 1 - .../SettingsView/RandomSeedInput.js | 4 +- .../SettingsView/RandomSeedInput.test.js | 2 +- .../TierPurchase/TierPurchase.test.js | 2 +- src/components/Toolbelt/Toolbelt.test.js | 4 +- .../UpdateNotifier/UpdateNotifier.js | 32 + src/components/UpdateNotifier/index.js | 1 + .../UpgradePurchase/UpgradePurchase.test.js | 2 +- .../WineRecipeList/WineRecipe.test.js | 2 +- src/components/Workshop/Workshop.test.js | 18 +- src/config.js | 36 +- src/constants.js | 2 +- src/data/__mocks__/items.js | 3 +- src/data/__mocks__/maps.js | 12 +- src/data/__mocks__/recipes.js | 3 +- src/data/achievements.test.js | 10 +- src/factories/CoalFactory.test.js | 2 +- src/factories/OreFactory.test.js | 4 +- src/factories/ResourceFactory.test.js | 14 +- src/factories/StoneFactory.test.js | 2 +- src/game-logic/cows/cow-selection.test.js | 14 +- src/game-logic/reducers/applyCrows.test.js | 4 +- .../reducers/applyPrecipitation.test.js | 8 +- src/game-logic/reducers/clearPlot.test.js | 4 +- .../reducers/computeStateForNextDay.test.js | 6 +- .../reducers/createPriceEvent.test.js | 2 +- src/game-logic/reducers/fertilizePlot.test.js | 2 +- src/game-logic/reducers/forRange.test.js | 2 +- .../reducers/generatePriceEvents.test.js | 16 +- src/game-logic/reducers/harvestPlot.test.js | 2 +- .../reducers/incrementPlotContentAge.test.js | 4 +- src/game-logic/reducers/makeRecipe.test.js | 19 +- src/game-logic/reducers/makeWine.test.js | 2 +- src/game-logic/reducers/minePlot.test.js | 4 +- src/game-logic/reducers/plantInPlot.test.js | 4 +- .../reducers/processCellarSpoilage.test.js | 8 +- .../reducers/processLevelUp.test.js | 68 +- src/game-logic/reducers/processNerfs.test.js | 2 +- .../reducers/processSprinklers.test.js | 2 +- .../reducers/processWeather.test.js | 8 +- src/game-logic/reducers/purchaseForest.js | 2 +- src/game-logic/reducers/purchaseItem.test.js | 2 +- src/game-logic/reducers/sellItem.test.js | 94 +- src/game-logic/reducers/spawnWeeds.test.js | 2 +- src/game-logic/reducers/unlockTool.test.js | 2 +- .../reducers/updateAchievements.test.js | 30 +- .../reducers/updateLearnedRecipes.test.js | 8 +- src/game-logic/reducers/waterAllPlots.test.js | 4 +- src/game-logic/reducers/waterPlot.test.js | 2 +- src/handlers/ui-events.js | 16 +- src/handlers/ui-events.test.js | 67 +- src/img/index.js | 18 +- src/index.js | 3 - src/index.sass | 2 +- src/react-app-env.d.ts | 2 - src/service-worker.js | 73 - src/serviceWorkerRegistration.js | 143 - src/services/cellar.test.js | 2 +- src/setupTests.js | 6 +- src/shell/bootup.test.js | 10 +- src/shell/field.test.js | 81 + src/shell/pending-notifications.test.js | 4 +- src/test-utils/stubs/saveDataStubFactory.js | 3 + src/utils/__snapshots__/index.test.js.snap | 4 +- src/utils/index.js | 2 +- src/utils/index.test.js | 170 +- tsconfig.json | 8 +- vercel.json | 3 + vite.config.js | 96 + 117 files changed, 33425 insertions(+), 31012 deletions(-) rename public/index.html => index.html (82%) create mode 100644 manifest.js delete mode 100644 public/manifest.json delete mode 100644 src/components/AnimatedNumber/AnimatedNumber.sass delete mode 100644 src/components/Inventory/Inventory.sass delete mode 100644 src/components/KeybindingsView/KeybindingsView.sass delete mode 100644 src/components/OnlinePeersView/OnlinePeer/OnlinePeer.sass delete mode 100644 src/components/OnlinePeersView/OnlinePeersView.sass delete mode 100644 src/components/PriceEventView/PriceEventView.sass create mode 100644 src/components/UpdateNotifier/UpdateNotifier.js create mode 100644 src/components/UpdateNotifier/index.js delete mode 100644 src/service-worker.js delete mode 100644 src/serviceWorkerRegistration.js create mode 100644 src/shell/field.test.js create mode 100644 vite.config.js diff --git a/.env b/.env index aba3261e..eaae24c6 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ BROWSER=none -REACT_APP_API_ROOT=https://farmhand.vercel.app/ -REACT_APP_NAME=$npm_package_name -REACT_APP_VERSION=$npm_package_version -REACT_APP_TURN_USERNAME= -REACT_APP_TURN_CREDENTIAL= +VITE_API_ROOT=https://farmhand.vercel.app/ +VITE_NAME=$npm_package_name +VITE_FARMHAND_PACKAGE_VERSION=$npm_package_version +VITE_TURN_USERNAME= +VITE_TURN_CREDENTIAL= diff --git a/.eslintrc.json b/.eslintrc.json index 3e6205b8..da44f406 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,7 @@ { + "globals": { + "vitest": true + }, "extends": ["react-app"], "rules": { "import/order": [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e0fadb6..252a26ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,14 +24,7 @@ jobs: run: npm ci - name: 'Run tests' - run: npm test -- --reporters=default --reporters=jest-junit - - - name: Test Report - uses: dorny/test-reporter@v1 - with: - name: Jest Tests # Name of the check run which will be created - path: reports/jest-*.xml # Path to test results - reporter: jest-junit # Format of test results + run: npm test -- --coverage --run - name: 'Check types' # TODO: Change this to check:types when all type errors are fixed @@ -44,4 +37,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: build-output - path: build + path: dist diff --git a/.github/workflows/run-release.yml b/.github/workflows/run-release.yml index 943ad52a..aaf9bebd 100644 --- a/.github/workflows/run-release.yml +++ b/.github/workflows/run-release.yml @@ -61,13 +61,13 @@ jobs: tags: true branch: main - - run: PUBLIC_URL='./' npm run build + - run: npm run build -- --base="./" - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Prepare Web Artifacts - run: zip farmhand-web-${{ env.PACKAGE_VERSION }}.zip -r build/* + run: zip farmhand-web-${{ env.PACKAGE_VERSION }}.zip -r dist/* - name: Create Release id: create_release @@ -82,7 +82,7 @@ jobs: files: | ./farmhand-web-${{ env.PACKAGE_VERSION }}.zip - - run: node -e "console.log(require('./package.json').version)" > build/version.txt + - run: node -e "console.log(require('./package.json').version)" > dist/version.txt - name: Publish itch.io build uses: josephbmanley/butler-publish-itchio-action@master env: @@ -90,18 +90,18 @@ jobs: CHANNEL: html5 ITCH_GAME: Farmhand ITCH_USER: jeremyckahn - PACKAGE: build - VERSION_FILE: build/version.txt + PACKAGE: dist + VERSION_FILE: dist/version.txt - run: | - PUBLIC_URL='/farmhand' npm run build + npm run build -- --base='/farmhand' # https://github.com/marketplace/actions/deploy-to-github-pages - name: Deploy to jeremyckahn.github.io/farmhand uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages - folder: build + folder: dist clean: true single-commit: true diff --git a/.gitignore b/.gitignore index 8dca9e3b..5a00c1ad 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ build Session.vim .DS_Store .idea +coverage .vercel diff --git a/README.md b/README.md index 8a48b6e1..2d579be3 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Farmhand uses a [SemVer](https://semver.org/)-like versioning system. It differs ## Project overview -- This project is built with [Create React App](https://create-react-app.dev/), so please refer to the documentation of that project to learn about the development toolchain. +- This project uses [Vite](https://vitejs.dev/), so please refer to the documentation of that project to learn about the development toolchain. - Farmhand uses [Piskel](https://www.piskelapp.com/) for the art assets. ## Running locally @@ -138,13 +138,13 @@ The process will take several minutes to complete and it will notify the Discord Farmhand supports feature flags for code that should only be enabled in specific environments. To create a feature flag, add a line that looks like this in the relevant `.env` file: ``` -REACT_APP_ENABLE_[FEATURE_NAME]=true +VITE_ENABLE_[FEATURE_NAME]=true ``` Where `[FEATURE_NAME]` is replaced with the name of your feature. So, adding this to `.env.development.local`: ``` -REACT_APP_ENABLE_MINING=true +VITE_ENABLE_MINING=true ``` Would enable the `MINING` feature only for the local development environment. You can access the enabled feature flags at runtime by `import`ing the `features` Object from [`config.js`](https://github.com/jeremyckahn/farmhand/blob/develop/src/config.js). See [Adding Custom Environment Variables](https://create-react-app.dev/docs/adding-custom-environment-variables/) for more information on how to use environment variables. diff --git a/public/index.html b/index.html similarity index 82% rename from public/index.html rename to index.html index 87e8afb3..83fedcd4 100644 --- a/public/index.html +++ b/index.html @@ -6,39 +6,31 @@ + - - - - + Farmhand