diff --git a/.easignore b/.easignore index e1285f2..96f0837 100644 --- a/.easignore +++ b/.easignore @@ -17,6 +17,7 @@ credentials.json *.key *.mobileprovision *.keystore +.idea/ # Metro .metro-health-check* diff --git a/.github/workflows/eas-build.yml b/.github/workflows/eas-build.yml index 2ca01ff..e180960 100644 --- a/.github/workflows/eas-build.yml +++ b/.github/workflows/eas-build.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20.x + node-version: 20 cache: yarn - name: Setup Expo and EAS @@ -24,9 +24,6 @@ jobs: - name: Run linters run: yarn lint - - name: Run prettier - run: yarn format:check - - name: Run tests run: yarn test diff --git a/.github/workflows/eas-update.yml b/.github/workflows/eas-update.yml new file mode 100644 index 0000000..6da6819 --- /dev/null +++ b/.github/workflows/eas-update.yml @@ -0,0 +1,27 @@ +name: eas update auto +on: + workflow_dispatch: + push: + branches: + - main +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + + - name: ๐Ÿ— Setup EAS + uses: expo/expo-github-action@v8 + with: + eas-version: latest + token: ${{ secrets.EXPO_TOKEN }} + + - name: ๐Ÿ“ฆ Install dependencies + run: yarn install + + - name: ๐Ÿš€ Create update + run: eas update --auto --non-interactive \ No newline at end of file diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 97a6ee5..731beda 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20.x + node-version: 20 cache: yarn - name: Install dependencies @@ -21,11 +21,9 @@ jobs: - name: Run linters run: yarn lint - - name: Run prettier - run: yarn format:check - name: Run tests run: yarn test - name: Check for code duplication - run: yarn check-duplicates + run: yarn duplication:check diff --git a/.gitignore b/.gitignore index 6d12b64..b6256cb 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ credentials.json *.key *.mobileprovision *.keystore +.idea/ # Metro .metro-health-check* diff --git a/.husky/commit-msg b/.husky/commit-msg index 5bc8a58..1c070ea 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1 +1 @@ -yarn lint:commit ${1} +yarn lint-commit ${1} diff --git a/package.json b/package.json index 79572bc..e11ec06 100644 --- a/package.json +++ b/package.json @@ -4,34 +4,32 @@ "private": true, "main": "expo-router/entry", "scripts": { - "android": "yarn expo run:android -d", - "eas-android": "eas build -p android -e development", - "eas-ios": "eas build -p ios -e development", - "eas-run-android": "eas build:run --latest -p android -e development", - "eas-run-ios": "eas build:run --latest -p ios -e development", - "check-deps": "./scripts/check-unused-deps.sh", - "check-duplicates": "yarn jscpd --config jscpd.json", - "check-duplicates:i": "yarn jscpd --config jscpd.json && open ./cpd/html/index.html", - "fast": "yarn install && yarn install-pods-fast", - "format": "prettier --write .", - "format:check": "prettier --check .", + "android": "expo run:android", + "android:prebuild": "expo prebuild -p android", + "android:rebuild": "run-s android:prebuild android", + "eas-android": "eas build --no-wait -e development -p android", + "eas-ios": "eas build --no-wait -e development -p ios", + "eas-run": "eas build:run --latest -e development -p", + "check-unused-deps": "./scripts/check-unused-deps.sh", + "duplication:check": "jscpd --config jscpd.json", + "duplication:view": "jscpd --config jscpd.json && open ./cpd/html/index.html", "increment-version": "./scripts/bump-version.sh", - "install-all": "yarn install && yarn install-pods", - "install-pods": "cd ios && pod install --repo-update && cd ..", - "install-pods-fast": "cd ios && pod install && cd ..", - "ios": "yarn expo run:ios", - "ios:prebuild": "yarn expo prebuild -p ios", - "ios:rebuild": "yarn ios:prebuild && yarn ios", - "lint": "yarn lint:js && yarn lint:ts", - "lint:commit": "yarn commitlint --config commitlint.config.js --edit", + "install-pods": "(cd ios && pod install)", + "ios": "expo run:ios", + "ios:prebuild": "expo prebuild -p ios", + "ios:rebuild": "run-s ios:prebuild ios", + "lint": "run-p lint:*", + "lint-commit": "commitlint --config commitlint.config.js --edit ", + "lint:format": "prettier --write .", + "lint:format:check": "prettier --check .", "lint:js": "eslint --cache . --quiet", - "lint:ts": "yarn tsc --skipLibCheck --noEmit", + "lint:ts": "tsc --skipLibCheck --noEmit", "nuke": "./scripts/nuke.sh", "postinstall": "patch-package", "prepare": "husky", - "start": "yarn expo start --dev-client", + "start": "expo start --dev-client", "switch-env": "./scripts/switch-env.sh", - "test": "yarn jest src", + "test": "jest src", "test-e2e": "./scripts/run-maestro-tests.sh", "test-detox:build": "detox build -c ios.sim.debug", "test-detox": "detox test -c ios.sim.debug" @@ -62,7 +60,6 @@ "expo-build-properties": "~0.12.5", "expo-constants": "~16.0.2", "expo-dev-client": "~4.0.28", - "expo-dev-launcher": "^4.0.28", "expo-font": "~12.0.10", "expo-image": "~1.13.0", "expo-insights": "~0.7.0", @@ -122,6 +119,7 @@ "babel-plugin-transform-remove-console": "^6.9.4", "conventional-changelog-atom": "^5.0.0", "detox": "^20.27.3", + "dotenv-cli": "^7.4.2", "eslint": "^8.57.1", "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-babel-module": "^5.3.2", @@ -141,6 +139,7 @@ "jest-expo": "^51.0.4", "jscpd": "^4.0.5", "lint-staged": "^15.2.10", + "npm-run-all": "^4.1.5", "patch-package": "^8.0.0", "postinstall-postinstall": "^2.1.0", "prettier": "3.3.3", diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 05bc026..99e8674 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -11,6 +11,8 @@ SUCCESS_ICON="โœ…" ERROR_ICON="๐Ÿ‘บ" UPDATING_ICON="๐ŸŒธ" +COMMIT_VERSION_UPDATE=true # Set to false to disable Git commit + json_file="app.json" # Define the expo_sdk_version variable @@ -20,40 +22,33 @@ expo_sdk_version="051" update_type="$1" decrement_flag="$2" -# Validate the update type argument (it must be major, minor, or patch) if [ -z "$update_type" ] || ! [[ "$update_type" =~ ^(major|minor|patch)$ ]]; then echo -e "${RED}${ERROR_ICON} Error: Invalid update type. Use one of ${NC}" exit 1 fi -# Validate the second argument (must be --decrement or nothing) if [ -n "$decrement_flag" ] && [ "$decrement_flag" != "--decrement" ]; then echo -e "${RED}${ERROR_ICON} Error: Invalid option. Use --decrement to decrease the version.${NC}" exit 1 fi -# Check if the JSON file exists if [ ! -f "$json_file" ]; then echo -e "${RED}${ERROR_ICON} Error: JSON file not found at path: $json_file${NC}" exit 1 fi -# Display a starting message with an emoji echo -e "${GREEN}${STARTING_ICON} Starting the update process... ${STARTING_ICON}${NC}" -# Extract the current version, buildNumber, and versionCode from the JSON file current_version=$(jq -r '.expo.version' "$json_file") current_build_number=$(jq -r '.expo.ios.buildNumber' "$json_file") current_version_code=$(jq -r '.expo.android.versionCode' "$json_file") -# Split the version into major, minor, and patch components IFS='.' read -r -a version_parts <<< "$current_version" # Handle the decrement flag (if present, decrement instead of increment) if [ "$decrement_flag" == "--decrement" ]; then case "$update_type" in "major") - # Prevent decrementing major below 1 if ((version_parts[0] > 1)); then ((version_parts[0]--)) version_parts[1]=0 @@ -64,7 +59,6 @@ if [ "$decrement_flag" == "--decrement" ]; then fi ;; "minor") - # Prevent decrementing minor below 0 and reset patch if ((version_parts[1] > 0)); then ((version_parts[1]--)) version_parts[2]=0 @@ -74,7 +68,6 @@ if [ "$decrement_flag" == "--decrement" ]; then fi ;; "patch") - # Prevent decrementing patch below 0 if ((version_parts[2] > 0)); then ((version_parts[2]--)) else @@ -108,20 +101,26 @@ for i in "${!version_parts[@]}"; do fi done -# Create the new version string new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}" -# Calculate the new versionCode dynamically new_version_code_dynamic="${expo_sdk_version}$(printf "%02d" "${version_parts[0]}")$(printf "%02d" "${version_parts[1]}")$(printf "%02d" "${version_parts[2]}")" # Update the version, buildNumber, and versionCode fields in the JSON file jq --arg new_version "$new_version" --arg new_version_code "$new_version_code_dynamic" '.expo.version = $new_version | .expo.ios.buildNumber = $new_version | .expo.android.versionCode = ($new_version_code | tonumber)' "$json_file" > tmp.json && mv tmp.json "$json_file" -# Run formatter to format the JSON file prettier --write "$json_file" -# Display a success message with an emoji echo -e "${GREEN} version, buildNumber and versionCode updated ${UPDATING_ICON}${NC}" echo -e "${GREEN}${SUCCESS_ICON}${NC} version: $new_version" echo -e "${GREEN}${SUCCESS_ICON}${NC} buildNumber: $new_version" echo -e "${GREEN}${SUCCESS_ICON}${NC} versionCode: $new_version_code_dynamic" + +if [ "$COMMIT_VERSION_UPDATE" = true ]; then + git add "$json_file" + git commit -m "chore: bump version to $new_version" + if [ $? -eq 0 ]; then + echo -e "${GREEN}${SUCCESS_ICON} Successfully committed version bump to $new_version.${NC}" + else + echo -e "${RED}${ERROR_ICON} Failed to create a commit.${NC}" + fi +fi \ No newline at end of file diff --git a/scripts/nuke.sh b/scripts/nuke.sh index 2288ab3..a466d69 100755 --- a/scripts/nuke.sh +++ b/scripts/nuke.sh @@ -1,14 +1,139 @@ -echo " ๐Ÿ•ณ Attempting to clean JS deps..." -rm -rf node_modules > /dev/null 2>&1 || true -echo "Done. " +#!/bin/bash -echo " ๐Ÿ•ณ Attempting to clean IOS project" -cd ios -pod deintegrate > /dev/null 2>&1 || true -pod cache clean --all > /dev/null 2>&1 || true -rm -rf build > /dev/null 2>&1 || true -cd .. -echo "Done. " +# Colors and Text Effects +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +BLUE='\033[1;34m' +CYAN='\033[0;36m' +PURPLE='\033[1;35m' +BOLD='\033[1m' +ITALIC='\033[3m' +NC='\033[0m' # No Color +echo -e "${PURPLE}" +cat << "EOF" + ____ + __,-~~/~ `---. + _/_,---( , ) + __ / < / ) \___ +- ---===;;;'====------------------===;;;===- - + \/ ~"~"~"~"~"~\~"~)~"/ + (_ ( \ ( > \) + \_( _ < >_>' + ~ `-i' ::>|--" + I;|.|.| + <|i::|i|`. + (` ^'"`-' ") -echo "Clean up complete. You can now run 'yarn fast' to install all the app dependencies." \ No newline at end of file +EOF +echo -e "${NC}" + +function separator { + echo -e "${PURPLE} + ---------------------------------------------${NC}" +} + +echo -e "${YELLOW}๐Ÿ”ฅ Nuking the project... ๐Ÿ”ฅ${NC}" +separator + +# Node modules +echo -e "${CYAN}๐Ÿงน Cleaning JS dependencies...${NC}" +rm -rf node_modules > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo -e "${GREEN}โœ… JS dependencies removed successfully!${NC}" +else + echo -e "${RED}โŒ Failed to remove JS dependencies.${NC}" +fi + +separator + +# IOS +echo -e "${CYAN}๐ŸŽ Cleaning iOS project...${NC}" +if [ -d "ios" ]; then + cd ios || exit + + pod deintegrate > /dev/null 2>&1 + pod cache clean --all > /dev/null 2>&1 + rm -rf build > /dev/null 2>&1 + + if [ $? -eq 0 ]; then + echo -e "${GREEN}โœ… iOS project cleaned successfully!${NC}" + else + echo -e "${RED}โŒ Failed to clean iOS project.${NC}" + fi + cd .. +else + echo -e "${RED}โŒ 'ios' folder not found. Skipping iOS cleanup.${NC}" +fi + +separator + +# Xcode Derived Data +echo -e "${CYAN}๐Ÿ—‘ Cleaning Xcode Derived Data...${NC}" + +rm -rf ~/Library/Developer/Xcode/DerivedData/* > /dev/null 2>&1 + +if [ $? -eq 0 ]; then + echo -e "${GREEN}โœ… Xcode Derived Data cleaned successfully!${NC}" +else + echo -e "${RED}โŒ Failed to clean Xcode Derived Data.${NC}" +fi + +separator + +# Android +echo -e "${CYAN}๐Ÿค– Cleaning Android project...${NC}" +if [ -d "android" ]; then + cd android || exit + + ./gradlew clean > /dev/null 2>&1 + rm -rf build/ > /dev/null 2>&1 + rm -rf .gradle/ > /dev/null 2>&1 + rm -rf app/build/ > /dev/null 2>&1 + + if [ $? -eq 0 ]; then + echo -e "${GREEN}โœ… Android project cleaned successfully!${NC}" + else + echo -e "${RED}โŒ Failed to clean Android project.${NC}" + fi + cd .. +else + echo -e "${RED}โŒ 'android' folder not found. Skipping Android cleanup.${NC}" +fi + +separator + +# Watchman cache +if command -v watchman > /dev/null 2>&1; then + echo -e "${CYAN}๐Ÿ‘€ Cleaning Watchman cache...${NC}" + + watchman watch-del-all > /dev/null 2>&1 + + if [ $? -eq 0 ]; then + echo -e "${GREEN}โœ… Watchman cache cleaned successfully!${NC}" + else + echo -e "${RED}โŒ Failed to clean Watchman cache.${NC}" + fi +else + echo -e "${RED}โŒ Watchman not installed. Skipping Watchman cleanup.${NC}" +fi + +separator + +echo -e "${PURPLE}" +cat << "EOF" + _ _ + | | | | + ____ _ _| | _ _____ __| | +| _ \| | | | |_/ ) ___ |/ _ | +| | | | |_| | _ (| ____( (_| | +|_| |_|____/|_| \_)_____)\____| + +EOF +echo -e "${NC}" + +echo -e "${YELLOW}๐Ÿš€ ${BOLD}Project nuked!${NC}" +echo -e "${CYAN}You can now run ${BOLD}'yarn install-all'${NC}${CYAN} to install all dependencies.${NC}" + +separator diff --git a/scripts/setup-husky.sh b/scripts/setup-husky.sh index 9dd5856..397d2b3 100644 --- a/scripts/setup-husky.sh +++ b/scripts/setup-husky.sh @@ -1,3 +1,3 @@ npx husky init -echo "yarn lint:commit \${1}" > .husky/commit-msg +echo "yarn lint-commit \${1}" > .husky/commit-msg echo "yarn lint-staged" > .husky/pre-commit \ No newline at end of file diff --git a/src/app/(tabs)/(demo)/GraphicsList.tsx b/src/app/(tabs)/(demo)/GraphicsList.tsx deleted file mode 100644 index f6add22..0000000 --- a/src/app/(tabs)/(demo)/GraphicsList.tsx +++ /dev/null @@ -1 +0,0 @@ -export { GraphicsList as default } from '@app/screens' diff --git a/src/app/(tabs)/(demo)/_layout.tsx b/src/app/(tabs)/(demo)/_layout.tsx index fdbf389..07df1de 100644 --- a/src/app/(tabs)/(demo)/_layout.tsx +++ b/src/app/(tabs)/(demo)/_layout.tsx @@ -8,7 +8,6 @@ const DemoStackLayout = () => { - ) } diff --git a/src/app/_layout.tsx b/src/app/_layout.tsx index 4f526c3..44e1369 100644 --- a/src/app/_layout.tsx +++ b/src/app/_layout.tsx @@ -6,6 +6,7 @@ import { Slot, useNavigationContainerRef, useRouter } from 'expo-router' import * as SplashScreen from 'expo-splash-screen' import { useEffect } from 'react' import { SafeAreaProvider } from 'react-native-safe-area-context' +import { enableScreens } from 'react-native-screens' import { NetInfoToast, Toast } from '@app/components' import { GOOGLE_WEB_CLIENT_ID, IS_PROD, SENTRY_DEBUG, SENTRY_DSN } from '@app/env' import { useLoadFonts } from '@app/hooks' @@ -29,6 +30,8 @@ Sentry.init({ ], }) +enableScreens(false) + const RootLayout = () => { const ref = useNavigationContainerRef() const { fontsFinishedLoading } = useLoadFonts() diff --git a/src/components/HeaderBackButton.tsx b/src/components/Buttons/HeaderBackButton.tsx similarity index 100% rename from src/components/HeaderBackButton.tsx rename to src/components/Buttons/HeaderBackButton.tsx diff --git a/src/components/__tests__/HeaderBackButton.test.tsx b/src/components/__tests__/HeaderBackButton.test.tsx index decd469..4c22e12 100644 --- a/src/components/__tests__/HeaderBackButton.test.tsx +++ b/src/components/__tests__/HeaderBackButton.test.tsx @@ -1,7 +1,7 @@ import { render } from '@testing-library/react-native' import React from 'react' import { ButtonDriver } from 'react-native-ui-lib/testkit' -import BackButton from '../HeaderBackButton' +import BackButton from '../Buttons/HeaderBackButton' const mockedNavigation = jest.fn() const mockedGetState = jest.fn().mockReturnValue({ index: 0 }) diff --git a/src/components/index.ts b/src/components/index.ts index 767a822..f4d6d38 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,4 +1,4 @@ -export { default as HeaderBackButton } from './HeaderBackButton' +export { default as HeaderBackButton } from './Buttons/HeaderBackButton' export { default as LanguageIconMask } from './LanguageIconMask' export { default as NetInfoToast } from './NetInfoToast' export { default as Background } from './Background' diff --git a/src/screens/Demo/index.tsx b/src/screens/Demo/index.tsx index ca8d872..6f7eb18 100644 --- a/src/screens/Demo/index.tsx +++ b/src/screens/Demo/index.tsx @@ -15,11 +15,6 @@ const Demo = () => { {t('navigateToMap')} - - - {t('navigateToGraphicsList')} - -