diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ea6c1c94..7fdce187c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ This creates and funds a wallet `Satoshi` with password `test`. Start the UI on port 3000: ```sh -npm start +npm run dev:start ``` Make your changes and be sure to manually test them before submitting them to us. @@ -100,7 +100,7 @@ This creates and funds a wallet `Satoshi` with password `test`. Start the UI on port 3000: ```sh -npm start +npm run dev:start ``` Enjoy the test drive! diff --git a/docker/regtest/readme.md b/docker/regtest/readme.md index 82e53da4f..f33d10374 100644 --- a/docker/regtest/readme.md +++ b/docker/regtest/readme.md @@ -22,7 +22,7 @@ npm run regtest:init npm run regtest:mine # start jam in development mode -npm start +npm run dev:start [...] @@ -49,7 +49,7 @@ npm run regtest:init Once the regtest environment is up and running you can start Jam with: ```sh -npm start +npm run dev:start ``` ### Stop diff --git a/docs/developing.md b/docs/developing.md index 92d7b055d..f58b54cbe 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -11,7 +11,7 @@ For a complete development environment you need a local JoinMarket instance that ## Linting We use Create React App's [default ESLint integration](https://create-react-app.dev/docs/setting-up-your-editor/#displaying-lint-output-in-the-editor). -You'll see linting issues in the console when running the app with `npm start`. +You'll see linting issues in the console when running the app with `npm run dev:start`. Pull request builds will fail if ESLint is not happy with the code. ## Code Formatting @@ -118,5 +118,5 @@ In short: ```bash git clone https://github.com/joinmarket-webui/jam.git cd jam/ -npm install && npm start +npm install && npm run dev:start ``` diff --git a/package.json b/package.json index a6218d8d4..af65f84f1 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,8 @@ "serve": "14.0.1" }, "scripts": { + "dev:start": "REACT_APP_JAM_DEV_MODE=true npm start", + "dev:start:secondary": "PORT=3001 JAM_BACKEND=jam-standalone JAM_API_PORT=29080 npm run dev:start", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", @@ -55,7 +57,6 @@ "postinstall": "husky install", "lint": "prettier --check --no-error-on-unmatched-pattern 'src/**/*.{js,jsx,ts,tsx,json,css,md}'", "format": "prettier --write --no-error-on-unmatched-pattern 'src/**/*.{js,jsx,ts,tsx,json,css,md}'", - "start:regtest:secondary": "PORT=3001 JAM_BACKEND=jam-standalone JAM_API_PORT=29080 npm start", "version": "node scripts/changelog.mjs && git checkout -b \"prepare-v${npm_package_version}-$(date +%s)\" && git add --all && git commit --message \"chore(release): v${npm_package_version}\" && git push --set-upstream origin $(git branch --show-current)", "postversion": "which gh && gh pr create --title \"chore(release): v${npm_package_version}\" --body \"Prepares the v${npm_package_version} release.\" --assignee @me --label release --repo joinmarket-webui/jam --draft", "regtest:build": "npm run regtest:clear && docker-compose --env-file docker/regtest/.env.example --file docker/regtest/docker-compose.yml build --pull", diff --git a/src/components/CreateWallet.jsx b/src/components/CreateWallet.jsx index e3873ae5b..3c9308af6 100644 --- a/src/components/CreateWallet.jsx +++ b/src/components/CreateWallet.jsx @@ -10,7 +10,7 @@ import { walletDisplayName } from '../utils' import { useServiceInfo } from '../context/ServiceInfoContext' import * as Api from '../libs/JmWalletApi' import { routes } from '../constants/routes' -import { isFeatureEnabled } from '../constants/features' +import { isDebugFeatureEnabled } from '../constants/debugFeatures' import styles from './CreateWallet.module.css' const PreventLeavingPageByMistake = () => { @@ -192,7 +192,7 @@ const BackupConfirmation = ({ createdWallet, walletConfirmed, parentStepSetter } const { t } = useTranslation() const [seedBackup, setSeedBackup] = useState(false) const [seedWordConfirmations, setSeedWordConfirmations] = useState(new Array(seedphrase.length).fill(false)) - const [showSkipButton] = useState(isFeatureEnabled('skipWalletBackupConfirmation')) + const [showSkipButton] = useState(isDebugFeatureEnabled('skipWalletBackupConfirmation')) useEffect(() => { setSeedBackup(seedWordConfirmations.every((wordConfirmed) => wordConfirmed)) diff --git a/src/components/CreateWallet.test.jsx b/src/components/CreateWallet.test.jsx index c8daa64a9..e2bab9f07 100644 --- a/src/components/CreateWallet.test.jsx +++ b/src/components/CreateWallet.test.jsx @@ -2,7 +2,7 @@ import { BrowserRouter } from 'react-router-dom' import user from '@testing-library/user-event' import { render, screen, waitFor } from '../testUtils' import { act } from 'react-dom/test-utils' -import { __testSetFeatureEnabled } from '../constants/features' +import { __testSetDebugFeatureEnabled } from '../constants/debugFeatures' import * as apiMock from '../libs/JmWalletApi' @@ -159,7 +159,7 @@ describe('', () => { }) it('should verify that "skip" button IS visible when feature is enabled', async () => { - __testSetFeatureEnabled('skipWalletBackupConfirmation', true) + __testSetDebugFeatureEnabled('skipWalletBackupConfirmation', true) apiMock.postWalletCreate.mockResolvedValueOnce({ ok: true, diff --git a/src/constants/debugFeatures.ts b/src/constants/debugFeatures.ts index fe20ea92f..367e1fc8a 100644 --- a/src/constants/debugFeatures.ts +++ b/src/constants/debugFeatures.ts @@ -1,22 +1,20 @@ interface DebugFeatures { insecureScheduleTesting: boolean allowCreatingExpiredFidelityBond: boolean + skipWalletBackupConfirmation: boolean } -const devMode = process.env.NODE_ENV === 'development' +const devMode = process.env.NODE_ENV === 'development' && process.env.REACT_APP_JAM_DEV_MODE === 'true' const debugFeatures: DebugFeatures = { - insecureScheduleTesting: true, - allowCreatingExpiredFidelityBond: true, + allowCreatingExpiredFidelityBond: devMode, + insecureScheduleTesting: devMode, + skipWalletBackupConfirmation: devMode, } type DebugFeature = keyof DebugFeatures export const isDebugFeatureEnabled = (name: DebugFeature): boolean => { - if (!devMode) { - return false - } - return debugFeatures[name] || false } diff --git a/src/constants/features.ts b/src/constants/features.ts deleted file mode 100644 index d765f6210..000000000 --- a/src/constants/features.ts +++ /dev/null @@ -1,20 +0,0 @@ -interface Features { - skipWalletBackupConfirmation: boolean -} - -const devMode = process.env.NODE_ENV === 'development' - -const features: Features = { - skipWalletBackupConfirmation: devMode, -} - -type Feature = keyof Features - -export const isFeatureEnabled = (name: Feature): boolean => { - return features[name] || false -} - -// only to be used in tests -export const __testSetFeatureEnabled = (name: Feature, enabled: boolean): boolean => { - return (features[name] = enabled) -}