Skip to content

Commit

Permalink
clean up project and multiple app variant infra
Browse files Browse the repository at this point in the history
  • Loading branch information
kibagateaux committed Dec 27, 2023
1 parent 74f3769 commit 306b7b1
Show file tree
Hide file tree
Showing 24 changed files with 243 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ ios/
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*
.hypothesis

# macOS
.DS_Store
Expand Down
6 changes: 3 additions & 3 deletions app.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-ignore-next-line no-undef
const VARIANT = process.env.EXPO_PUBLIC_APP_VARIANT;
// console.log('GENERATING APP CONFIG FOR VARIANT:', VARIANT);
const VARIANT = process.env.APP_VARIANT || 'development';
// console.log("GENERATING APP CONFIG FOR VARIANT:", VARIANT);
const isProd = VARIANT === 'production';
const packageName = isProd ? 'com.jinnihealth' : `com.jinnihealth.${VARIANT}`;
const appName = isProd ? 'Jinni Health' : `Jinni (${VARIANT}) `;
Expand Down Expand Up @@ -57,7 +57,7 @@ export default {
],
hooks: {
postPublish: [
VARIANT === 'development'
!isProd
? {}
: {
file: 'sentry-expo/upload-sourcemaps',
Expand Down
27 changes: 27 additions & 0 deletions build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Android
Make sure to add app variants to `android/app/build.gradle` if starting from scratch
```java
android {
...
// project.ext.sentryCli = [ flavorAware: true ]
flavorDimensions "env"
productFlavors {
production {
dimension "env"
applicationId 'com.jinnihealth'
}
staging {
dimension "env"
applicationId 'com.jinnihealth.staging'
}
development {
dimension "env"
applicationId 'com.jinnihealth.development'
}
}
}
```

# iOS
TODO

16 changes: 8 additions & 8 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@
"developmentClient": true,
"distribution": "internal",
"env": {
"EXPO_PUBLIC_APP_VARIANT": "development",
"EXPO_PUBLIC_API_URL": "apprentice.scryer.jinni.health"
"APP_VARIANT": "development",
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health"
},
"android": {
"buildType": "apk",
"gradleCommand": ":app:assembleDebug"
}
},
"testing": {
"staging": {
"env": {
"EXPO_PUBLIC_APP_VARIANT": "testing",
"EXPO_PUBLIC_API_URL": "apprentice.scryer.jinni.health"
"APP_VARIANT": "staging",
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health"
},
"android": {
"buildType": "apk",
"gradleCommand": ":app:assembleDebug"
"gradleCommand": ":app:assembleRelease"
}
},
"production": {
"env": {
"EXPO_PUBLIC_APP_VARIANT": "production",
"EXPO_PUBLIC_API_URL": "master.scryer.jinni.health"
"APP_VARIANT": "production",
"EXPO_PUBLIC_API_URL": "master-scryer.jinni.health"
},
"android": {
"buildType": "app-bundle",
Expand Down
21 changes: 17 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"test": "jest",
"test:ci": "jest --ci --colors",
"postinstall": "patch-package && rn-nodeify --install all --hack",
"run:android": "expo run:android --variant development --dev-client",
"install:android": "source .env; EXPO_PUBLIC_APP_VARIANT=testing; expo run:android -d",
"build:android": "source .env; eas build --local --platform android -e production",
"android": "APP_VARIANT=development npx expo run:android -d --variant developmentDebug",
"install:android": "source .env; APP_VARIANT=production npx eas build --local --platform android -e staging --output app.apk; adb install ./app.apk",
"deploy:secrets": "eas secret:push --scope jinni-health --env-file ./.env",
"ios": "expo run:ios",
"lint:dry": "eslint ./src/ .eslintrc.js --ext .ts,.tsx && prettier ./src/ --config .prettierrc --check",
Expand Down Expand Up @@ -66,8 +65,7 @@
"readable-stream": "^1.0.33",
"sentry-expo": "~7.0.0",
"stream-browserify": "^1.0.0",
"util": "^0.10.4",
"expo-dev-client": "~2.4.12"
"util": "^0.10.4"
},
"peerDependencies": {
"ethers": "5.7.0"
Expand All @@ -90,6 +88,7 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"expo-build-properties": "^0.8.3",
"expo-dev-client": "~2.4.12",
"husky": "^8.0.3",
"install": "^0.13.0",
"jest": "^29.7.0",
Expand Down
10 changes: 8 additions & 2 deletions src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { WidgetConfig } from 'types/UserConfig';
import { getIconForWidget } from 'utils/rendering';

export default function HomeLayout() {
// has to be in nested _layout https://docs.expo.dev/router/reference/authentication/#after
// useDeepLinks();
const homeConfig = useHomeConfig();
const [tabConfig, setTabConfig] = useState<WidgetConfig[]>([]);

Expand All @@ -23,10 +25,14 @@ export default function HomeLayout() {
}
}, [homeConfig, tabConfig]);

// console.log("Home:tabs", tabConfig)
console.log('pg:home:layout: no deep links');
return (
<ContextProvider>
<Tabs>
<Tabs
screenOptions={{
headerShown: false,
}}
>
{tabConfig.map((tab) => (
<Tabs.Screen
key={tab.title}
Expand Down
41 changes: 24 additions & 17 deletions src/app/inventory/[item].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ActivityIndicator,
} from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { useLocalSearchParams } from 'expo-router';
import { Stack, useLocalSearchParams } from 'expo-router';
import { useAuthRequest } from 'expo-auth-session';

import {
Expand Down Expand Up @@ -45,6 +45,8 @@ const ItemPage: React.FC<ItemPageProps> = () => {
const [itemOauthConfig, setItemOauth] = useState<OAuthProvider>(oauthConfigs.undefined);
const [activeAbilities, setActiveAbilities] = useState<ItemAbility[]>([]);

console.log('pg:inventory:item:Load', id, item?.tags);

const [request, , promptAsync] = useAuthRequest(
{
clientId: itemOauthConfig.clientId,
Expand All @@ -66,18 +68,23 @@ const ItemPage: React.FC<ItemPageProps> = () => {
item!.checkStatus().then((newStatus: ItemStatus) => {
console.log('pg:Inv:Item check item status', newStatus);
setStatus(newStatus);
Promise.all(
item.abilities?.filter(async (ability) => {
(await ability.canDo(newStatus)) === 'doable';
}) ?? [],
).then((active) => {
console.log('pb:Inv:Item post item status abilitiy check', active);
setActiveAbilities(active);
});
});
}
}, [item, status]);

useMemo(() => {
if (item?.abilities?.length && status) {
Promise.all(
item.abilities?.filter(async (ability) => {
(await ability.canDo(status!)) === 'doable';
}) ?? [],
).then((active) => {
console.log('pb:Inv:Item post item status abilitiy check', active);
setActiveAbilities(active);
});
}
}, [item, status]);

// console.log('Item: item', id, item);
// console.log('Item: status & modal', status, activeModal);

Expand Down Expand Up @@ -118,13 +125,13 @@ const ItemPage: React.FC<ItemPageProps> = () => {
: await item.equip();
// if result.error = "transceive fail" try majik ritual again
if (result) {
setStatus('post-equip');
// setStatus('post-equip');
// TODO api request to add item to their avatar (:DataProvider or :Resource?)
setStatus('equipped');
} else {
// assume failure
setStatus('unequipped');
}

// assume failure
setStatus('unequipped');
} catch (e) {
console.log('Error Equipping:', e);
setStatus('unequipped');
Expand Down Expand Up @@ -241,7 +248,7 @@ const ItemPage: React.FC<ItemPageProps> = () => {
};
const renderActiveItemAbilities = () => (
<View>
<Text style={styles.sectionTitle}>Abilities</Text>
<Text style={styles.sectionTitle}>Active Abilities</Text>
{activeAbilities.length ? (
<ScrollView horizontal style={{ flex: 1 }}>
{activeAbilities.map((ability) => (
Expand Down Expand Up @@ -349,11 +356,11 @@ const ItemPage: React.FC<ItemPageProps> = () => {

return (
<View style={styles.container}>
{/* <Stack.Screen
<Stack.Screen
options={{
title: item.name,
title: item.name,
}}
/> */}
/>
<View style={styles.topContainer}>
<View style={styles.itemImageContainer}>
<Image source={{ uri: item.image }} style={styles.itemImage} />
Expand Down
6 changes: 1 addition & 5 deletions src/app/inventory/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import { Stack } from 'expo-router';

export default function Layout() {
return (
<Stack
screenOptions={{
headerShown: false,
}}
>
<Stack>
<Stack.Screen name="index" />
<Stack.Screen name="[item]" />
</Stack>
Expand Down
Loading

0 comments on commit 306b7b1

Please sign in to comment.