Skip to content

Commit 1d6b6d4

Browse files
authored
Merge pull request #274 from flexbox/with-env
feat: 🎸 add with env
2 parents 07c785f + 34e7c0d commit 1d6b6d4

File tree

11 files changed

+122
-76
lines changed

11 files changed

+122
-76
lines changed

challenges/react-navigation/02.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
## 👾 Before we start the exercise
88

9-
- Check the [`route` prop documentation](https://reactnavigation.org/docs/route-prop).
10-
- Do you remember how to [pass to the destination route](https://reactnavigation.org/docs/navigation-prop#common-api-reference)?
9+
- Check the [`route` prop documentation](https://reactnavigation.org/docs/params).
1110

1211
## 👨‍🚀 Exercise 2
1312

challenges/release/02.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,19 @@ If you want to store secret key in your repository like `SENTRY_API_KEY`, you ca
4040
To create a new secret, run :
4141

4242
```console
43-
eas secret
43+
eas env
4444
```
4545

4646
```console
47-
eas secret:create // create a new secret
48-
eas secret:list // view any existing secrets for this project
47+
eas env:create // create a new secret
48+
eas env:list // view any existing secrets for this project
4949
```
5050

51-
- [ ] use `eas secret:create` and create a fake `SWAPI_KEY` because there is no API key for the Star Wars API.
51+
- [ ] use `eas env:create` and create a fake `SWAPI_KEY` because there is no API key for the Star Wars API.
5252

5353
In the next lesson, we are going to build your app and show you how to install it on your phone.
5454

5555
## 👽 Bonus
5656

57-
- [ ] Add a custom icon for your dev app
58-
59-
Use [App-icon-badge](https://github.com/obytes/app-icon-badge) and update your `app.config.js` to have a custom icon for your dev app.
57+
- [ ] Check [with-env config](https://github.com/betomoedano/with-environments/blob/main/app.config.ts) and update your `app.config` file.
58+
- [ ] [Create new icons with Figma](https://www.figma.com/community/file/1466490409418563617/expo-app-icon-splash-v2-community) like [with-env icons](https://github.com/betomoedano/with-environments/tree/main/assets/images/icons) to have a custom icon for your dev app.

hackathon/spacecraft/.env.local

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Environment: development
2+
3+
APP_ENV=development

hackathon/spacecraft/app.config.js

-65
This file was deleted.

hackathon/spacecraft/app.config.ts

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { ExpoConfig } from "@expo/config-types";
2+
3+
import { version } from "./package.json";
4+
5+
// Project constants
6+
const EAS_PROJECT_ID = "012accc3-4ce5-4bae-9f4d-2f842489f07a";
7+
const PROJECT_SLUG = "spacecraft";
8+
const OWNER = "weshipit";
9+
10+
// App production config
11+
const APP_NAME = "Spacecraft";
12+
const BUNDLE_IDENTIFIER = "weshipit.today.spacecraft";
13+
const PACKAGE_NAME = "weshipit.today.spacecraft";
14+
const SCHEME = "spacecraft";
15+
16+
export default ({ config }: { config: ExpoConfig }): ExpoConfig => {
17+
const environment = process.env.APP_ENV || "development";
18+
console.log("⚙️ Building app for environment:", environment);
19+
20+
const { adaptiveIcon, bundleIdentifier, icon, name, packageName, scheme } =
21+
getDynamicAppConfig(
22+
environment as "development" | "preview" | "production",
23+
);
24+
25+
return {
26+
...config,
27+
android: {
28+
adaptiveIcon: {
29+
backgroundColor: "#ffffff",
30+
foregroundImage: adaptiveIcon,
31+
},
32+
package: packageName,
33+
playStoreUrl:
34+
"https://play.google.com/store/apps/details?id=weshipit.today.spacecraft",
35+
},
36+
extra: {
37+
eas: {
38+
projectId: EAS_PROJECT_ID,
39+
},
40+
storybookEnabled: process.env.STORYBOOK_ENABLED,
41+
},
42+
icon: icon,
43+
ios: {
44+
appStoreUrl: "https://apps.apple.com/fr/app/<compagny_name>/idxxxxxxxxx",
45+
bundleIdentifier: bundleIdentifier,
46+
supportsTablet: true,
47+
},
48+
name: name,
49+
newArchEnabled: true,
50+
orientation: "portrait",
51+
owner: OWNER,
52+
plugins: [],
53+
runtimeVersion: {
54+
policy: "appVersion",
55+
},
56+
scheme: scheme,
57+
slug: PROJECT_SLUG,
58+
splash: {
59+
backgroundColor: "#ffffff",
60+
image: "./assets/splash.png",
61+
resizeMode: "contain",
62+
},
63+
updates: {
64+
fallbackToCacheTimeout: 0,
65+
url: `https://u.expo.dev/${EAS_PROJECT_ID}`,
66+
},
67+
userInterfaceStyle: "automatic",
68+
version,
69+
web: {
70+
bundler: "metro",
71+
favicon: "./assets/favicon.png",
72+
output: "static",
73+
},
74+
};
75+
};
76+
77+
// Dynamically configure the app based on the environment
78+
export const getDynamicAppConfig = (
79+
environment: "development" | "preview" | "production",
80+
) => {
81+
if (environment === "production") {
82+
return {
83+
adaptiveIcon: "./assets/adaptive-icon.png",
84+
bundleIdentifier: BUNDLE_IDENTIFIER,
85+
icon: "./assets/icon.png",
86+
name: APP_NAME,
87+
packageName: PACKAGE_NAME,
88+
scheme: SCHEME,
89+
};
90+
}
91+
92+
if (environment === "preview") {
93+
return {
94+
adaptiveIcon: "./assets/adaptive-icon-preview.png",
95+
bundleIdentifier: `${BUNDLE_IDENTIFIER}.preview`,
96+
icon: "./assets/icon-preview.png",
97+
name: `${APP_NAME} Preview`,
98+
packageName: `${PACKAGE_NAME}.preview`,
99+
scheme: `${SCHEME}-prev`,
100+
};
101+
}
102+
103+
return {
104+
adaptiveIcon: "./assets/adaptive-icon-dev.png",
105+
bundleIdentifier: `${BUNDLE_IDENTIFIER}.dev`,
106+
icon: "./assets/icon-dev.png",
107+
name: `${APP_NAME} Development`,
108+
packageName: `${PACKAGE_NAME}.dev`,
109+
scheme: `${SCHEME}-dev`,
110+
};
111+
};
Loading
Loading
26.9 KB
Loading
Loading
34.8 KB
Loading

hackathon/spacecraft/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"@types/react-dom": "~18.3.1",
8282
"@typescript-eslint/eslint-plugin": "^7.11.0",
8383
"@typescript-eslint/parser": "^7.11.0",
84-
"app-icon-badge": "^0.1.2",
8584
"babel-loader": "^9.1.3",
8685
"babel-plugin-module-resolver": "^5.0.0",
8786
"babel-plugin-transform-remove-console": "^6.9.4",
@@ -99,4 +98,4 @@
9998
"prettier": "^3.2.5",
10099
"typescript": "~5.3.3"
101100
}
102-
}
101+
}

0 commit comments

Comments
 (0)