Skip to content

Commit ddcfb14

Browse files
Merge pull request #175 from OpenDTU-App/136-add-feature-flags-to-check-if-app-was-from-ci-or-play-store
2 parents cebb3c0 + ca641c5 commit ddcfb14

File tree

16 files changed

+101
-13
lines changed

16 files changed

+101
-13
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,7 @@ yarn-error.log
7676
# Expo
7777
.expo
7878
dist/
79-
web-build/
79+
web-build/
80+
81+
# Environment
82+
.env

__mocks__/react-native-config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @type {import('react-native-config').Config} */
2+
const config = {
3+
DISABLE_IN_APP_UPDATES: 'false',
4+
};
5+
6+
export default config;

android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ apply plugin: "com.android.application"
22
apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
5+
// https://github.com/lugg/react-native-config/issues/729#issuecomment-1456603817
6+
apply from: project(":react-native-config").projectDir.getPath() + "/dotenv.gradle"
57

68
/**
79
* This is the configuration block to customize your React Native Android app.

default.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Disable in-app updates. For now, this is only enabled for CI builds.
2+
DISABLE_IN_APP_UPDATES=true

ios/Podfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,10 @@ PODS:
12851285
- DGCharts (= 5.0.0)
12861286
- React
12871287
- SwiftyJSON (= 5.0)
1288+
- react-native-config (1.5.3):
1289+
- react-native-config/App (= 1.5.3)
1290+
- react-native-config/App (1.5.3):
1291+
- React-Core
12881292
- react-native-get-random-values (1.11.0):
12891293
- React-Core
12901294
- react-native-netinfo (11.3.2):
@@ -1730,6 +1734,7 @@ DEPENDENCIES:
17301734
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
17311735
- React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
17321736
- react-native-charts-wrapper (from `../node_modules/react-native-charts-wrapper`)
1737+
- react-native-config (from `../node_modules/react-native-config`)
17331738
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
17341739
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
17351740
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
@@ -1863,6 +1868,8 @@ EXTERNAL SOURCES:
18631868
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
18641869
react-native-charts-wrapper:
18651870
:path: "../node_modules/react-native-charts-wrapper"
1871+
react-native-config:
1872+
:path: "../node_modules/react-native-config"
18661873
react-native-get-random-values:
18671874
:path: "../node_modules/react-native-get-random-values"
18681875
react-native-netinfo:
@@ -1989,6 +1996,7 @@ SPEC CHECKSUMS:
19891996
React-Mapbuffer: 1c08607305558666fd16678b85ef135e455d5c96
19901997
React-microtasksnativemodule: 87b8de96f937faefece8afd2cb3a518321b2ef99
19911998
react-native-charts-wrapper: cd83d9b1acb8e06ebd18bf297de597906e1cc87d
1999+
react-native-config: 8f7283449bbb048902f4e764affbbf24504454af
19922000
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
19932001
react-native-netinfo: 076df4f9b07f6670acf4ce9a75aac8d34c2e2ccc
19942002
react-native-safe-area-context: ab8f4a3d8180913bd78ae75dd599c94cce3d5e9a

licenses.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@
167167
"licenseUrl": "https://github.com/wuxudong/react-native-charts-wrapper",
168168
"parents": "opendtu-react-native"
169169
},
170+
171+
"licenses": "MIT",
172+
"repository": "https://github.com/luggit/react-native-config",
173+
"licenseUrl": "https://github.com/luggit/react-native-config/raw/master/LICENSE",
174+
"parents": "opendtu-react-native"
175+
},
170176
171177
"licenses": "(MIT AND Apache-2.0)",
172178
"repository": "https://github.com/DylanVann/react-native-fast-image",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"typecheck": "tsc --project tsconfig.json --pretty --noEmit --skipLibCheck",
2020
"start": "react-native start",
2121
"test": "jest --passWithNoTests",
22-
"postinstall": "yarn run npm-license-crawler -onlyDirectDependencies -json licenses.json && patch-package",
22+
"postinstall": "yarn run npm-license-crawler -onlyDirectDependencies -json licenses.json && patch-package && ./postinstall.sh",
2323
"postuninstall": "yarn run npm-license-crawler -onlyDirectDependencies -json licenses.json",
2424
"build-android": "bash -c \"pushd android ; ./gradlew assembleRelease ; popd\"",
2525
"postversion": "react-native-version --never-amend --skip-tag -L",
@@ -61,6 +61,7 @@
6161
"react-native": "0.75.2",
6262
"react-native-animated-bottom-drawer": "^0.0.23",
6363
"react-native-charts-wrapper": "^0.6.0",
64+
"react-native-config": "^1.5.3",
6465
"react-native-fast-image": "^8.6.3",
6566
"react-native-flex-layout": "^0.1.5",
6667
"react-native-fs": "^2.20.0",

postinstall.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
if command -v pod &> /dev/null; then
3+
(cd ios && pod install)
4+
else
5+
echo "pod command not found. Skipping pod install."
6+
fi

setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# ensure that the script is run inside git root
4+
if [ ! -d .git ]; then
5+
echo "Please run this script inside the git root"
6+
exit 1
7+
fi
8+
9+
# Copy default.env to .env if .env does not exist
10+
if [ ! -f .env ]; then
11+
cp default.env .env
12+
fi

src/App.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { FC } from 'react';
22
import { StrictMode, useEffect, useMemo, useState } from 'react';
33
import { useTranslation } from 'react-i18next';
4+
import Config from 'react-native-config';
45
import type { MD3Theme } from 'react-native-paper';
56
import {
67
adaptNavigationTheme,
@@ -313,7 +314,9 @@ const _App: FC = () => {
313314
}, [i18n.language, t]);
314315

315316
const showEnableAppUpdatesModal = useAppSelector(
316-
state => state.settings.enableAppUpdates === null,
317+
state =>
318+
state.settings.enableAppUpdates === null &&
319+
Config.DISABLE_IN_APP_UPDATES !== 'true',
317320
);
318321

319322
const showEnableFetchOpenDTUReleasesModal = useAppSelector(
@@ -326,6 +329,10 @@ const _App: FC = () => {
326329
});
327330
}, [dispatch]);
328331

332+
useEffect(() => {
333+
log.info('react-native-config', JSON.stringify(Config, null, 4));
334+
}, []);
335+
329336
if (!i18nLanguageMatchesSettings) {
330337
return null;
331338
}

0 commit comments

Comments
 (0)