Skip to content

Commit

Permalink
feat: expo 52. sentry, refactor config
Browse files Browse the repository at this point in the history
86975t2q2 - [PRE-EXP-52]: update expo-calendar

86979rtah - EXPO 52. remove react-native-cache

86979tkqj - [PRE-EXP-52]: suppression du package react-native-maps

fix: type

feat: add calendar permission

fix: android prebuild

typo app.json

Co-authored-by: Dimitri <gritsajuk.dimitri@gmail.com>

PR - feedback
  • Loading branch information
OverGlass committed Jan 9, 2025
1 parent 68523d4 commit 7fa2f64
Show file tree
Hide file tree
Showing 39 changed files with 30,571 additions and 22,553 deletions.
9 changes: 3 additions & 6 deletions .github/actions/setup-base/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: Prepare node & bun
description: prepare node and bun
description: prepare node and bun

runs:
using: composite
steps:
- name: 🏗 Setup node
uses: actions/setup-node@v4
with:
cache: yarn
node-version: 18.X
- name: 🏗 Setup yarn
uses: threeal/setup-yarn-action@v2.0.0
6 changes: 5 additions & 1 deletion .github/scripts/prepare-eas-envs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ const getEnvs = () => {
const addEnvsToEasJson = async () => {
const easJsonContent = await fs.readFile(easJsonPath, 'utf8')
const easJson = JSON.parse(easJsonContent)
easJson.build[profile].env = getEnvs()
const currentEnvs = easJson.build[profile].env ?? {}
easJson.build[profile].env = {
...currentEnvs,
...getEnvs(),
}
await fs.writeFile(easJsonPath, JSON.stringify(easJson, null, 2))
console.log(`Added envs to eas.json`)
}
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
# dependencies
node_modules/

#package managers
# Yarn files
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo/
Expand Down
151 changes: 107 additions & 44 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,124 @@ import FontLib from './assets/fonts/generated-lib-fonts'
const baseIdentifier = 'fr.en-marche.jecoute'
const basePackage = 'fr.en_marche.jecoute'

const setAssociatedDomain = (config: Partial<ExpoConfig>, associatedDomain: string) => {
config.ios.associatedDomains = [`applinks:${associatedDomain}`, `webcredentials:${associatedDomain}`, `activitycontinuation:${associatedDomain}`]
config.android.intentFilters[0].data[0].host = associatedDomain
interface ConfigOptions {
name: string
scheme?: string
bundleIdentifier: string
package: string
googleServicesFileIos: string
googleServicesFileAndroid: string
adaptiveIcon?: string
icon?: string
notification?: {
icon?: string
}
}

const setAssociatedDomain = (config: Partial<ExpoConfig>, associatedDomain: string | undefined) => {
if (!associatedDomain) return
if (config.ios) {
config.ios.associatedDomains = [`applinks:${associatedDomain}`, `webcredentials:${associatedDomain}`, `activitycontinuation:${associatedDomain}`]
}
if (config.android?.intentFilters?.[0]?.data?.[0]) {
config.android.intentFilters[0].data[0].host = associatedDomain
}
}

const applyConfig = (config: Partial<ExpoConfig>, options: ConfigOptions) => {
config.name = options.name
if (options.scheme) {
config.scheme = options.scheme
}
if (config.ios) {
config.ios.bundleIdentifier = options.bundleIdentifier
config.ios.googleServicesFile = options.googleServicesFileIos
if (options.icon) {
config.ios.icon = options.icon
}
}
if (config.android) {
config.android.package = options.package
config.android.googleServicesFile = options.googleServicesFileAndroid
if (options.adaptiveIcon && config.android.adaptiveIcon) {
config.android.adaptiveIcon.foregroundImage = options.adaptiveIcon
}
if (options.notification) {
config.notification = { ...config.notification, ...options.notification }
}
}
}

export default ({ config }: ConfigContext): Partial<ExpoConfig> => {
config.plugins.push([
'expo-font',
{
fonts: FontLib,
},
])
config.plugins.push([
'@rnmapbox/maps',
{
RNMapboxMapsDownloadToken: process.env.MAP_BOX_SECRET_KEY,
},
])
export default (payload: ConfigContext): Partial<ExpoConfig> => {
const config = { ...payload.config }
const plugins = [...(config.plugins || [])]
if (plugins) {
plugins.push([
'expo-font',
{
fonts: FontLib,
},
])
plugins.push([
'@rnmapbox/maps',
{
RNMapboxMapsDownloadToken: process.env.MAP_BOX_SECRET_KEY,
},
])
plugins.push(['expo-router', { origin: `https://${process.env.EXPO_PUBLIC_ASSOCIATED_DOMAIN}` }])
}
config.plugins = plugins

const profile = process.env.EAS_BUILD_PROFILE
setAssociatedDomain(config, process.env.EXPO_PUBLIC_ASSOCIATED_DOMAIN)
config.android.config.googleMaps.apiKey = process.env.EXPO_PUBLIC_ANDROID_GOOGLE_API_KEY

if (!profile || profile === 'development') {
config.name = 'Vox Dev'
config.scheme = 'vox-dev'
config.ios.bundleIdentifier = `${baseIdentifier}.development`
config.android.package = `${basePackage}.development`
if (profile === 'development') {
config.ios.googleServicesFile = process.env.GOOGLE_SERVICES_IOS_PATH_DEVELOPMENT
config.android.googleServicesFile = process.env.GOOGLE_SERVICES_ANDROID_PATH_DEVELOPMENT
} else {
config.ios.googleServicesFile = './config/GoogleService-Info.plist'
config.android.googleServicesFile = './config/google-services.json'
}
config.android.adaptiveIcon.foregroundImage = './assets/developement/adaptive-icon.jpg'
config.ios.icon = './assets/developement/icon.jpg'
applyConfig(config, {
name: 'Vox Dev',
scheme: 'vox-dev',
bundleIdentifier: `${baseIdentifier}.development`,
package: `${basePackage}.development`,
googleServicesFileIos: profile === 'development' ? process.env.GOOGLE_SERVICES_IOS_PATH_DEVELOPMENT || '' : './config/GoogleService-Info.plist',
googleServicesFileAndroid: profile === 'development' ? process.env.GOOGLE_SERVICES_ANDROID_PATH_DEVELOPMENT || '' : './config/google-services.json',
adaptiveIcon: './assets/developement/adaptive-icon.png',
icon: './assets/developement/icon.png',
notification: {
icon: './assets/developement/notif-icon.png',
},
})
} else if (profile === 'production') {
config.name = process.env.EXPO_PUBLIC_APP_NAME
config.ios.bundleIdentifier = baseIdentifier
config.android.package = basePackage
config.ios.googleServicesFile = process.env.GOOGLE_SERVICES_IOS_PATH_PRODUCTION
config.android.googleServicesFile = process.env.GOOGLE_SERVICES_ANDROID_PATH_PRODUCTION
applyConfig(config, {
name: 'Renaissance',
scheme: 'vox',
bundleIdentifier: baseIdentifier,
package: basePackage,
googleServicesFileIos: process.env.GOOGLE_SERVICES_IOS_PATH_PRODUCTION || '',
googleServicesFileAndroid: process.env.GOOGLE_SERVICES_ANDROID_PATH_PRODUCTION || '',
icon: './assets/icon.png',
adaptiveIcon: './assets/adaptive-icon.png',
notification: {
icon: './assets/notif-icon.png',
},
})
} else {
config.name = process.env.EXPO_PUBLIC_APP_NAME
config.scheme = 'vox-staging'
config.android.adaptiveIcon.foregroundImage = './assets/staging/adaptive-icon.jpg'
config.ios.icon = './assets/staging/icon.jpg'
config.ios.bundleIdentifier = `${baseIdentifier}.${profile}`
config.android.package = `${basePackage}.${profile}`
config.ios.googleServicesFile = process.env.GOOGLE_SERVICES_IOS_PATH_STAGING
config.android.googleServicesFile = process.env.GOOGLE_SERVICES_ANDROID_PATH_STAGING
applyConfig(config, {
name: process.env.EXPO_PUBLIC_APP_NAME || '',
scheme: 'vox-staging',
bundleIdentifier: `${baseIdentifier}.${profile}`,
package: `${basePackage}.${profile}`,
googleServicesFileIos: process.env.GOOGLE_SERVICES_IOS_PATH_STAGING || '',
googleServicesFileAndroid: process.env.GOOGLE_SERVICES_ANDROID_PATH_STAGING || '',
adaptiveIcon: './assets/staging/adaptive-icon.png',
icon: './assets/staging/icon.png',
notification: {
icon: './assets/staging/notif-icon.png',
},
})
}

config.extra.storybookEnabled = process.env.STORYBOOK_ENABLED
if (config.extra) {
config.extra.storybookEnabled = process.env.STORYBOOK_ENABLED
}

return config
}
26 changes: 8 additions & 18 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"expo": {
"name": "Renaissance",
"slug": "vox",
"scheme": "vox",
"version": "5.13.0",
"version": "5.13.1",
"owner": "parti-renaissance",
"runtimeVersion": {
"policy": "appVersion"
},
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
Expand Down Expand Up @@ -62,12 +59,7 @@
"android.permission.READ_CALENDAR",
"android.permission.FOREGROUND_SERVICE",
"android.permission.WRITE_CALENDAR"
],
"config": {
"googleMaps": {
"apiKey": "key"
}
}
]
},
"web": {
"favicon": "./assets/favicon.png",
Expand Down Expand Up @@ -109,21 +101,19 @@
[
"expo-location",
{
"locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location."
"locationAlwaysAndWhenInUsePermission": "Autorisez $(PRODUCT_NAME) à vous localiser pour vous aider à trouver les portes à frapper et les actions à réaliser."
}
],
["expo-notifications"],
[
"react-native-permissions",
"expo-calendar",
{
"iosPermissions": ["CalendarsWriteOnly"],
"androidPermissions": ["android.permission.WRITE_CALENDAR"]
"calendarPermission": "Autorisez $(PRODUCT_NAME) à ajouter des événements à votre calendrier"
}
],
["react-native-add-calendar-event"],
["expo-notifications"]
]
],
"extra": {
"eas_update_version": "1",
"eas_update_version": "0",
"router": {
"origin": false
},
Expand Down
12 changes: 11 additions & 1 deletion app/(app)/(tabs)/porte-a-porte/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { memo, useCallback, useState } from 'react'
import { Modal, StyleSheet, View } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { LatLng, Region } from '@/components/Maps/Maps'
import * as metatags from '@/config/metatags'
import { DoorToDoorCharterNotAccepted } from '@/core/entities/DoorToDoorCharterState'
import { GetDoorToDoorAddressesInteractor } from '@/core/interactor/GetDoorToDoorAddressesInteractor'
Expand All @@ -23,6 +22,16 @@ import { router } from 'expo-router'
import Head from 'expo-router/head'
import { YStack } from 'tamagui'

type LatLng = {
latitude: number
longitude: number
}

type Region = LatLng & {
latitudeDelta: number
longitudeDelta: number
}

const DoorToDoorMapView = memo(_DoorToDoorMapView)

export type RankingModalState = Readonly<{
Expand Down Expand Up @@ -56,6 +65,7 @@ const _fetchAdresses = async (forcedRegion?: Region) => {
}
region = getRegionFromLatLng(latLng)
}
if (!region) throw new Error("Can't get region")
return new GetDoorToDoorAddressesInteractor().execute(region.latitude, region.longitude, region.latitudeDelta, region.longitudeDelta)
}

Expand Down
6 changes: 3 additions & 3 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (isWeb) {

initRootAppNotification()

const { routingInstrumentation } = ErrorMonitor.configure()
const { navigationIntegration } = ErrorMonitor.configure()

SplashScreen.preventAutoHideAsync()

Expand All @@ -33,7 +33,7 @@ const useRegisterRoutingInstrumentation = () => {

useEffect(() => {
if (navigationRef) {
routingInstrumentation.registerNavigationContainer(navigationRef)
navigationIntegration.registerNavigationContainer(navigationRef)
}
}, [navigationRef])
}
Expand Down Expand Up @@ -113,4 +113,4 @@ function Root() {
)
}

export default Root
export default ErrorMonitor.wrap(Root)
Binary file removed assets/developement/adaptive-icon.jpg
Binary file not shown.
Binary file added assets/developement/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/developement/icon.jpg
Binary file not shown.
Binary file added assets/developement/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/developement/notif-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notif-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/staging/adaptive-icon.jpg
Binary file not shown.
Binary file added assets/staging/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/staging/icon.jpg
Binary file not shown.
Binary file added assets/staging/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/staging/notif-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"autoIncrement": true,
"android": {
"resourceClass": "large"
},
"env": {
"YARN_ENABLE_IMMUTABLE_INSTALLS": "false",
"YARN_ENABLE_GLOBAL_CACHE": "false"
}
},
"production": {
Expand All @@ -22,6 +26,10 @@
"autoIncrement": true,
"android": {
"resourceClass": "large"
},
"env": {
"YARN_ENABLE_IMMUTABLE_INSTALLS": "false",
"YARN_ENABLE_GLOBAL_CACHE": "false"
}
}
},
Expand Down
Loading

0 comments on commit 7fa2f64

Please sign in to comment.