In the sample app, developers are required to define certain properties in both the local.properties and .env files. This redundancy not only creates confusion but also introduces a higher potential for errors. If developers mistakenly enter different values in these files, it could lead to unexpected behavior or the abandonment of the module altogether.
For example, the DROPBOX_CLIENT_SECRET is defined in .env but is missing from local.properties.sample. Following the current setup, this results in the following error during build:
460 actionable tasks: 456 executed, 4 up-to-date
info Connecting to the development server...
info Starting the app on "FMR0223B28045079"...
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.openmobilehub.reactnative.storage.sample/.MainActivity }
BUNDLE ./index.js
error: src/contexts/auth/getAuthClient.ts: /Users/diegozuluaga/tools/git/react-native-omh-storage/apps/sample-app/src/contexts/auth/getAuthClient.ts: "DROPBOX_CLIENT_SECRET" is not defined in .env
1 | import {
2 | DROPBOX_CLIENT_ID,
> 3 | DROPBOX_CLIENT_SECRET,
| ^^^^^^^^^^^^^^^^^^^^^
4 | GOOGLE_CLIENT_ID,
5 | MICROSOFT_CLIENT_ID,
6 | } from '@env';
Current Setup:
-
local.properties.sample
GOOGLE_CLIENT_ID=
MICROSOFT_CLIENT_ID=
MICROSOFT_SIGNATURE_HASH=
DROPBOX_CLIENT_ID=
-
.env.sample
GOOGLE_CLIENT_ID=
MICROSOFT_CLIENT_ID=
DROPBOX_CLIENT_ID=
DROPBOX_CLIENT_SECRET=
Additional Question:
Why does the build process not fail when a property is defined in local.properties but missing from .env? This behavior is inconsistent and can cause confusion, as developers might expect a failure if a required property is missing from one of the configuration files.
Problems:
- Duplication of Effort: Developers need to define the same properties in two different files, increasing the likelihood of inconsistencies.
- Potential for Errors: If values differ between the two files, this can lead to build errors or incorrect app behavior.
- Incomplete Property Definitions: The
DROPBOX_CLIENT_SECRET is not defined in local.properties.sample, leading to an undefined error during the build.
Suggestion:
To streamline the setup process and reduce the potential for errors, I suggest the following:
- Single Source of Truth: Use the
local.properties file as the single source of truth.
- Automated
.env Generation: Implement a script or build step that generates the .env file based on the values defined in local.properties.
This approach will simplify the configuration process, ensure consistency across files, and minimize the chances of errors due to mismatched property values.
In the sample app, developers are required to define certain properties in both the
local.propertiesand.envfiles. This redundancy not only creates confusion but also introduces a higher potential for errors. If developers mistakenly enter different values in these files, it could lead to unexpected behavior or the abandonment of the module altogether.For example, the
DROPBOX_CLIENT_SECRETis defined in.envbut is missing fromlocal.properties.sample. Following the current setup, this results in the following error during build:Current Setup:
local.properties.sample
.env.sample
Additional Question:
Why does the build process not fail when a property is defined in local.properties but missing from .env? This behavior is inconsistent and can cause confusion, as developers might expect a failure if a required property is missing from one of the configuration files.
Problems:
DROPBOX_CLIENT_SECRETis not defined inlocal.properties.sample, leading to an undefined error during the build.Suggestion:
To streamline the setup process and reduce the potential for errors, I suggest the following:
local.propertiesfile as the single source of truth..envGeneration: Implement a script or build step that generates the.envfile based on the values defined inlocal.properties.This approach will simplify the configuration process, ensure consistency across files, and minimize the chances of errors due to mismatched property values.