From 356ed908fa77d05ac0f6ab2cf0d0f9e63e8174ea Mon Sep 17 00:00:00 2001 From: nbintertech Date: Fri, 1 Mar 2024 06:59:38 -0600 Subject: [PATCH 1/2] Add env files for dev/prod --- .env.development | 1 + .env.production | 1 + package-lock.json | 44 +++++++++++++++++++++++++++ package.json | 3 ++ public/index.html | 4 +-- src/App.tsx | 6 ++-- src/Financing.tsx | 1 - src/components/SelectGameSettings.tsx | 5 ++- 8 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..2d95137 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +REACT_APP_SERVER_ENV=development \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..b883c55 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +REACT_APP_SERVER_ENV=production \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5470b8f..f39da91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "concurrently": "^8.0.1", "cross-env": "^7.0.3", "electron-log": "^4.4.8", + "env-cmd": "^10.1.0", "mui-image": "^1.0.7", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -51,6 +52,10 @@ "jest": "^29.3.1", "node-sass": "^7.0.1", "react-test-renderer": "^18.2.0" + }, + "engines": { + "node": "20.10.0", + "npm": "10.2.3" } }, "node_modules/@adobe/css-tools": { @@ -13022,6 +13027,29 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/env-cmd": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz", + "integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==", + "dependencies": { + "commander": "^4.0.0", + "cross-spawn": "^7.0.0" + }, + "bin": { + "env-cmd": "bin/env-cmd.js" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/env-cmd/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "engines": { + "node": ">= 6" + } + }, "node_modules/env-paths": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", @@ -42290,6 +42318,22 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==" }, + "env-cmd": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz", + "integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==", + "requires": { + "commander": "^4.0.0", + "cross-spawn": "^7.0.0" + }, + "dependencies": { + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==" + } + } + }, "env-paths": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", diff --git a/package.json b/package.json index cc0bec2..ece5e8c 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "concurrently": "^8.0.1", "cross-env": "^7.0.3", "electron-log": "^4.4.8", + "env-cmd": "^10.1.0", "mui-image": "^1.0.7", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -38,6 +39,8 @@ "scripts": { "start": "react-scripts start", "build": "react-scripts build", + "build:development": "env-cmd -f .env.development react-scripts build", + "build:production": "env-cmd -f .env.production react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "electron:serve": "concurrently -k \"cross-env BROWSER=none npm run start\" \"npm run electron:start\"", diff --git a/public/index.html b/public/index.html index 9984865..7d02203 100644 --- a/public/index.html +++ b/public/index.html @@ -28,14 +28,14 @@ diff --git a/src/App.tsx b/src/App.tsx index 143eae5..8943cc6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -120,9 +120,9 @@ export class App extends React.PureComponent { getInitialAppState(): AppState { let startPage = Pages.start; - // if (process.env.NODE_ENV == 'development') { - // startPage = Pages.selectGameSettings; - // } + if (process.env.REACT_APP_SERVER_ENV == 'development') { + startPage = Pages.selectGameSettings; + } let showDashboardAtStart = false; return { currentPage: startPage, diff --git a/src/Financing.tsx b/src/Financing.tsx index c49b0a2..5924e43 100644 --- a/src/Financing.tsx +++ b/src/Financing.tsx @@ -175,7 +175,6 @@ export function setCapitalFundingMilestone(capitalFundingState: CapitalFundingSt } } else if (!capitalFundingState.roundB.isEarned) { let roundBMilestonePercent = 35; - // let roundBMilestone = process.env.NODE_ENV == 'development' ? .8: 40; savingsMilestone = checkHasSavingsMilestone(stats, roundBMilestonePercent); if (savingsMilestone) { capitalFundingState.roundB.isEarned = true; diff --git a/src/components/SelectGameSettings.tsx b/src/components/SelectGameSettings.tsx index 1a5a01b..6f6e692 100644 --- a/src/components/SelectGameSettings.tsx +++ b/src/components/SelectGameSettings.tsx @@ -82,7 +82,7 @@ export function SelectGameSettings(props: SelectGameSettingsProps) { - {/* {process.env.NODE_ENV == 'development' && + {process.env.REACT_APP_SERVER_ENV == 'development' && - } */} + } You have the option to play through in 1 OR 2-year intervals. @@ -248,7 +248,6 @@ export function newSelectGameSettingsControl(props: SelectGameSettingsControlPro } export function getFinancingStartYear() { - // return process.env.NODE_ENV == 'development' ? 1 : 3; return 3; } From b5e7a432d402dcfe4e91a891f9aee9ef5b0e4785 Mon Sep 17 00:00:00 2001 From: Hayden Esser Date: Wed, 6 Mar 2024 03:32:34 +0000 Subject: [PATCH 2/2] Updated web.yml - added conditional to build step and updated build scripts used for dev/prod --- .github/workflows/web.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 25c40f5..759d763 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -25,7 +25,12 @@ jobs: - name: Install dependencies run: npm install - name: Build - run: CI=false npm run build + run: | + if [[ ${{ github.ref_name }} == "develop" ]]; then + CI=false npm run build:development + elif [[ ${{ github.ref_name }} == "main" ]]; then + CI=false npm run build:production + fi - name: Upload artifact uses: actions/upload-artifact@v3 with: