diff --git a/challenges/react-navigation/02.md b/challenges/react-navigation/02.md index 6127fb67..5aff33b1 100644 --- a/challenges/react-navigation/02.md +++ b/challenges/react-navigation/02.md @@ -6,8 +6,7 @@ ## 👾 Before we start the exercise -- Check the [`route` prop documentation](https://reactnavigation.org/docs/route-prop). -- Do you remember how to [pass to the destination route](https://reactnavigation.org/docs/navigation-prop#common-api-reference)? +- Check the [`route` prop documentation](https://reactnavigation.org/docs/params). ## 👨‍🚀 Exercise 2 diff --git a/challenges/release/02.md b/challenges/release/02.md index 66dc30a0..8c8e51a1 100644 --- a/challenges/release/02.md +++ b/challenges/release/02.md @@ -40,20 +40,19 @@ If you want to store secret key in your repository like `SENTRY_API_KEY`, you ca To create a new secret, run : ```console -eas secret +eas env ``` ```console -eas secret:create // create a new secret -eas secret:list // view any existing secrets for this project +eas env:create // create a new secret +eas env:list // view any existing secrets for this project ``` -- [ ] use `eas secret:create` and create a fake `SWAPI_KEY` because there is no API key for the Star Wars API. +- [ ] use `eas env:create` and create a fake `SWAPI_KEY` because there is no API key for the Star Wars API. In the next lesson, we are going to build your app and show you how to install it on your phone. ## 👽 Bonus -- [ ] Add a custom icon for your dev app - -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. \ No newline at end of file +- [ ] Check [with-env config](https://github.com/betomoedano/with-environments/blob/main/app.config.ts) and update your `app.config` file. +- [ ] [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. diff --git a/hackathon/spacecraft/.env.local b/hackathon/spacecraft/.env.local new file mode 100644 index 00000000..f1be5886 --- /dev/null +++ b/hackathon/spacecraft/.env.local @@ -0,0 +1,3 @@ +# Environment: development + +APP_ENV=development \ No newline at end of file diff --git a/hackathon/spacecraft/app.config.js b/hackathon/spacecraft/app.config.js deleted file mode 100644 index 64fcc8e5..00000000 --- a/hackathon/spacecraft/app.config.js +++ /dev/null @@ -1,65 +0,0 @@ -module.exports = { - android: { - adaptiveIcon: { - backgroundColor: "#ffffff", - foregroundImage: "./assets/adaptive-icon.png", - }, - package: "weshipit.today.spacecraft", - playStoreUrl: - "https://play.google.com/store/apps/details?id=weshipit.today.spacecraft", - }, - assetBundlePatterns: ["**/*"], - description: "Learning materials for the `react-native-bootcamp` repository.", - extra: { - eas: { - projectId: "012accc3-4ce5-4bae-9f4d-2f842489f07a", - }, - storybookEnabled: process.env.STORYBOOK_ENABLED, - }, - icon: "./assets/icon.png", - ios: { - appStoreUrl: - "https://apps.apple.com/fr/app/retail-shake-scanner/id1234567890", - bundleIdentifier: "weshipit.today.spacecraft", - supportsTablet: true, - }, - name: "spacecraft", - newArchEnabled: true, - orientation: "portrait", - owner: "weshipit", - plugins: [ - [ - "app-icon-badge", - { - // enable/ disable the plugin based on the environment (usually disabled for production builds) - badges: [ - { - background: "#FF0000", // by default it will be black and we are only supporting hex format for colors - color: "white", // by default it will be white and the only color supported for now is white and black - text: process.env.ENVIRONMENT || "unkown", // banner text - type: "banner", // banner or ribbon - }, - { - text: process.env.version, - type: "ribbon", - }, - ], - enabled: process.env.ENVIRONMENT === "production" ? false : true, - }, - ], - ], - slug: "spacecraft", - splash: { - backgroundColor: "#ffffff", - image: "./assets/splash.png", - resizeMode: "contain", - }, - updates: { - fallbackToCacheTimeout: 0, - url: "https://u.expo.dev/012accc3-4ce5-4bae-9f4d-2f842489f07a", - }, - version: "1.0.2", - web: { - favicon: "./assets/favicon.png", - }, -}; diff --git a/hackathon/spacecraft/app.config.ts b/hackathon/spacecraft/app.config.ts new file mode 100644 index 00000000..57f402ba --- /dev/null +++ b/hackathon/spacecraft/app.config.ts @@ -0,0 +1,111 @@ +import { ExpoConfig } from "@expo/config-types"; + +import { version } from "./package.json"; + +// Project constants +const EAS_PROJECT_ID = "012accc3-4ce5-4bae-9f4d-2f842489f07a"; +const PROJECT_SLUG = "spacecraft"; +const OWNER = "weshipit"; + +// App production config +const APP_NAME = "Spacecraft"; +const BUNDLE_IDENTIFIER = "weshipit.today.spacecraft"; +const PACKAGE_NAME = "weshipit.today.spacecraft"; +const SCHEME = "spacecraft"; + +export default ({ config }: { config: ExpoConfig }): ExpoConfig => { + const environment = process.env.APP_ENV || "development"; + console.log("⚙️ Building app for environment:", environment); + + const { adaptiveIcon, bundleIdentifier, icon, name, packageName, scheme } = + getDynamicAppConfig( + environment as "development" | "preview" | "production", + ); + + return { + ...config, + android: { + adaptiveIcon: { + backgroundColor: "#ffffff", + foregroundImage: adaptiveIcon, + }, + package: packageName, + playStoreUrl: + "https://play.google.com/store/apps/details?id=weshipit.today.spacecraft", + }, + extra: { + eas: { + projectId: EAS_PROJECT_ID, + }, + storybookEnabled: process.env.STORYBOOK_ENABLED, + }, + icon: icon, + ios: { + appStoreUrl: "https://apps.apple.com/fr/app//idxxxxxxxxx", + bundleIdentifier: bundleIdentifier, + supportsTablet: true, + }, + name: name, + newArchEnabled: true, + orientation: "portrait", + owner: OWNER, + plugins: [], + runtimeVersion: { + policy: "appVersion", + }, + scheme: scheme, + slug: PROJECT_SLUG, + splash: { + backgroundColor: "#ffffff", + image: "./assets/splash.png", + resizeMode: "contain", + }, + updates: { + fallbackToCacheTimeout: 0, + url: `https://u.expo.dev/${EAS_PROJECT_ID}`, + }, + userInterfaceStyle: "automatic", + version, + web: { + bundler: "metro", + favicon: "./assets/favicon.png", + output: "static", + }, + }; +}; + +// Dynamically configure the app based on the environment +export const getDynamicAppConfig = ( + environment: "development" | "preview" | "production", +) => { + if (environment === "production") { + return { + adaptiveIcon: "./assets/adaptive-icon.png", + bundleIdentifier: BUNDLE_IDENTIFIER, + icon: "./assets/icon.png", + name: APP_NAME, + packageName: PACKAGE_NAME, + scheme: SCHEME, + }; + } + + if (environment === "preview") { + return { + adaptiveIcon: "./assets/adaptive-icon-preview.png", + bundleIdentifier: `${BUNDLE_IDENTIFIER}.preview`, + icon: "./assets/icon-preview.png", + name: `${APP_NAME} Preview`, + packageName: `${PACKAGE_NAME}.preview`, + scheme: `${SCHEME}-prev`, + }; + } + + return { + adaptiveIcon: "./assets/adaptive-icon-dev.png", + bundleIdentifier: `${BUNDLE_IDENTIFIER}.dev`, + icon: "./assets/icon-dev.png", + name: `${APP_NAME} Development`, + packageName: `${PACKAGE_NAME}.dev`, + scheme: `${SCHEME}-dev`, + }; +}; diff --git a/hackathon/spacecraft/assets/adaptive-icon-development.png b/hackathon/spacecraft/assets/adaptive-icon-development.png new file mode 100644 index 00000000..56d59794 Binary files /dev/null and b/hackathon/spacecraft/assets/adaptive-icon-development.png differ diff --git a/hackathon/spacecraft/assets/adaptive-icon-preview.png b/hackathon/spacecraft/assets/adaptive-icon-preview.png new file mode 100644 index 00000000..0d7eca79 Binary files /dev/null and b/hackathon/spacecraft/assets/adaptive-icon-preview.png differ diff --git a/hackathon/spacecraft/assets/adaptive-icon.png b/hackathon/spacecraft/assets/adaptive-icon.png index 124fd2d5..a640c784 100644 Binary files a/hackathon/spacecraft/assets/adaptive-icon.png and b/hackathon/spacecraft/assets/adaptive-icon.png differ diff --git a/hackathon/spacecraft/assets/icon-development.png b/hackathon/spacecraft/assets/icon-development.png new file mode 100644 index 00000000..45014987 Binary files /dev/null and b/hackathon/spacecraft/assets/icon-development.png differ diff --git a/hackathon/spacecraft/assets/icon-preview.png b/hackathon/spacecraft/assets/icon-preview.png new file mode 100644 index 00000000..5657652f Binary files /dev/null and b/hackathon/spacecraft/assets/icon-preview.png differ diff --git a/hackathon/spacecraft/package.json b/hackathon/spacecraft/package.json index 871cfa40..d3755aed 100644 --- a/hackathon/spacecraft/package.json +++ b/hackathon/spacecraft/package.json @@ -81,7 +81,6 @@ "@types/react-dom": "~18.3.1", "@typescript-eslint/eslint-plugin": "^7.11.0", "@typescript-eslint/parser": "^7.11.0", - "app-icon-badge": "^0.1.2", "babel-loader": "^9.1.3", "babel-plugin-module-resolver": "^5.0.0", "babel-plugin-transform-remove-console": "^6.9.4", @@ -99,4 +98,4 @@ "prettier": "^3.2.5", "typescript": "~5.3.3" } -} +} \ No newline at end of file