Skip to content

Commit 27abc25

Browse files
committed
Initial commit
0 parents  commit 27abc25

9 files changed

+703
-0
lines changed

.easignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#.easignore file placeholder
2+
3+
#.gitignore file placeholder
4+
5+
# @start Managed by update-env.sh
6+
.DS_Store
7+
node_modules/
8+
npm-debug.*
9+
yarn-debug.*
10+
yarn-error.*
11+
*.pem
12+
*.p8
13+
*.p12
14+
*.key
15+
dist/
16+
web-build/
17+
tsconfig.tsbuildinfo
18+
/.idea/
19+
.env
20+
.env.*
21+
.env*.
22+
android/
23+
ios/
24+
.metro-health-check*
25+
.expo/
26+
expo-env.d.ts
27+
*.orig.*
28+
*.jks
29+
*.mobileprovision
30+
*.apk
31+
*.aab
32+
*.ipa
33+
.envrc
34+
others/
35+
# @env ------------------------
36+
.environment
37+
# @files ----------------------
38+
!environment.json
39+
# @end Managed by update-env.sh

.environment.zip

4.49 KB
Binary file not shown.

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#.gitignore file placeholder
2+
3+
# @start Managed by update-env.sh
4+
.DS_Store
5+
node_modules/
6+
npm-debug.*
7+
yarn-debug.*
8+
yarn-error.*
9+
*.pem
10+
*.p8
11+
*.p12
12+
*.key
13+
dist/
14+
web-build/
15+
tsconfig.tsbuildinfo
16+
/.idea/
17+
.env
18+
.env.*
19+
.env*.
20+
android/
21+
ios/
22+
.metro-health-check*
23+
.expo/
24+
expo-env.d.ts
25+
*.orig.*
26+
*.jks
27+
*.mobileprovision
28+
*.apk
29+
*.aab
30+
*.ipa
31+
.envrc
32+
others/
33+
# @env ------------------------
34+
.environment
35+
# @files ----------------------
36+
environment.json
37+
# @end Managed by update-env.sh

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 SMBCheeky
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[![GitHub last commit](https://img.shields.io/github/last-commit/smbcheeky/update-env)](https://github.com/smbcheeky/update-env)
2+
[![GitHub stars](https://img.shields.io/github/stars/smbcheeky/update-env)](https://img.shields.io/github/stars/smbcheeky/update-env)
3+
4+
## Description
5+
6+
This script was initially created to manage the environment configuration and secrets of any file-based project.
7+
8+
It allows the developer to exclude sensitive files from git version control and help keep every environment folder
9+
organized with relative paths, similar to the root project.
10+
11+
The script conditionally includes special treatment for development with React Native and Expo, but can be easily
12+
adjusted to ignore this part.
13+
14+
## Expo, React Native, EAS Build and .easignore
15+
16+
The EAS Build process uses the contents of .gitignore file to determine which files to include in the created JS bundle.
17+
If however the files are excluded from git version control, they are not included in the bundle unless they are
18+
explicitly included via the .easignore file.
19+
20+
If Expo is detected, the .easignore file will be automatically updated and the environment files entries will be
21+
included in the EAS Build process and still kept outside git version control.
22+
23+
## How does it work?
24+
25+
```bash
26+
chmod +x ./update-env.sh
27+
./update-env.sh production
28+
```
29+
30+
1. Copy the `update-env.sh` script to the root of the project
31+
2. The script checks for the existence of the `.environment` folder in the root of the project
32+
3. If the `.environment` folder exists, it checks for the existence of the `production` subfolder
33+
4. It makes sure all files that need to be included in git version control are included, and all files that are not, are
34+
excluded.
35+
5. It overrides the project files with the ones found in the `production` subfolder
36+
6. To make sure everything is copied correctly, the `production` subfolder needs uses the same folder structure as the
37+
root project directory.
38+
7. Once copied, the .gitignore file is updated to include the new entries
39+
8. .gitignore changes that are managed by the script are organized neatly in a special section inside the .gitignore
40+
file
41+
9. If Expo app.json, app.config.js or app.config.ts files are found, the .easignore file is also created and updated
42+
based on the .gitignore file with "a twist"
43+
10. The environment files that are ignored in the .gitignore file are now included in the .easignore file.
44+
11. .gitignore and .easignore existing entries are kept unchanged
45+
12. The `update-env.lock` file is created to keep track of the changes made by the script and to make sure when changes
46+
are made, it is visible in git version control
47+
13. If you want to add more files to the .gitignore file, but have them managed by the script, you can add them to
48+
the `update-env.ignore` file
49+
50+
## Setup example
51+
52+
- This setup is meant for two environments, `production` and `staging`
53+
- Add the `use-production` and `use-staging` scripts to your `package.json` file
54+
- Create a `.environment` folder in the root of your project
55+
- Create a `production` folder in the `.environment` folder
56+
- Add production files to the `production` folder while respecting the same relative path structure as the root project
57+
- Run `./update-env.sh production` to update the project
58+
- Create a `staging` folder in the `.environment` folder
59+
- Add staging files to the `staging` folder while respecting the same relative path structure as the root project
60+
- Run `./update-env.sh staging` to update the project
61+
62+
## Other notes
63+
64+
- The script can work with only one environment
65+
- The `.ignored` folder is meant to be used as is and is useful for case where you need to use a secret/certificate, but
66+
it is not linked to the project files
67+
- If you want to include a file in multiple environments, use copy and paste to add it manually to each one :) Trust me,
68+
it's better this way.
69+
- Environments are determined by the subfolders present in the `.environment` folder
70+
- An example archive of the `.environment` folder was committed along with the script
71+
- There are 2 environments added, `production` and `staging` + a generic `.ignored` folder
72+
- The `update-env.ignore` file is currently populated with entries used in Expo React Native projects
73+
- The `update-env.lock` file is updated during the script execution, and used similar to a log file
74+
- The `#.gitignore file placeholder` and `#.easignore file placeholder` are simple lines added to take place of existing
75+
lines in both files - they are used simply as part of the example and can be deleted

package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@smbcheeky/update-env",
3+
"version": "1.0.0",
4+
"description": "Simplify the management of environment configuration and files for Expo React Native projects that use EAS Build.",
5+
"scripts": {
6+
"use-production": "./update-env.sh production",
7+
"use-staging": "./update-env.sh staging"
8+
},
9+
"license": "MIT",
10+
"private": false,
11+
"homepage": "https://smbcheeky.com",
12+
"author": {
13+
"name": "Stefan B.",
14+
"email": "[email protected]",
15+
"url": "https://www.npmjs.com/~stefan-at-smb"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "git+https://github.com/SMBCheeky/update-env.git"
20+
},
21+
"bugs": {
22+
"url": "https://github.com/SMBCheeky/update-env/issues"
23+
}
24+
}

update-env.ignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.*
4+
yarn-debug.*
5+
yarn-error.*
6+
*.pem
7+
*.p8
8+
*.p12
9+
*.key
10+
dist/
11+
web-build/
12+
tsconfig.tsbuildinfo
13+
/.idea/
14+
.env
15+
.env.*
16+
.env*.
17+
18+
android/
19+
ios/
20+
.metro-health-check*
21+
.expo/
22+
expo-env.d.ts
23+
*.orig.*
24+
*.jks
25+
*.mobileprovision
26+
*.apk
27+
*.aab
28+
*.ipa
29+
30+
.envrc
31+
others/

update-env.lock

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Setup started...
2+
Check update-env.sh files...
3+
Reading update-env.ignore...
4+
> done
5+
Check environment files and folders...
6+
Copy environment files to project...
7+
> found environment.json
8+
> project now has environment.json
9+
> done
10+
.gitignore update...
11+
> # @start Managed by update-env.sh
12+
> .DS_Store
13+
> node_modules/
14+
> npm-debug.*
15+
> yarn-debug.*
16+
> yarn-error.*
17+
> *.pem
18+
> *.p8
19+
> *.p12
20+
> *.key
21+
> dist/
22+
> web-build/
23+
> tsconfig.tsbuildinfo
24+
> /.idea/
25+
> .env
26+
> .env.*
27+
> .env*.
28+
> android/
29+
> ios/
30+
> .metro-health-check*
31+
> .expo/
32+
> expo-env.d.ts
33+
> *.orig.*
34+
> *.jks
35+
> *.mobileprovision
36+
> *.apk
37+
> *.aab
38+
> *.ipa
39+
> .envrc
40+
> others/
41+
> # @env ------------------------
42+
> .environment
43+
> # @files ----------------------
44+
> environment.json
45+
> # @end Managed by update-env.sh
46+
> clean up whitespaces
47+
> done
48+
.easignore update...
49+
> copy over all .gitignore entries except for environment files
50+
> force include environment files in EAS Build...
51+
> !environment.json
52+
> clean up whitespaces
53+
> done
54+
Files actively checked and added to git...
55+
> update-env.ignore
56+
> update-env.lock
57+
> update-env.sh
58+
> .gitignore
59+
> .easignore
60+
> done
61+
Files actively checked and removed from git...
62+
> .environment
63+
> done
64+
Environment was successfully changed

0 commit comments

Comments
 (0)