diff --git a/.env.sample b/.env.sample index 7ac7d11..797a524 100644 --- a/.env.sample +++ b/.env.sample @@ -1,5 +1,5 @@ DATABASE_URL= -supabaseUrl= -supabaseAnonKey= expoProjectId= +EXPO_PUBLIC_SUPABASE_URL= +EXPO_PUBLIC_SUPABASE_ANON_KEY= EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY= diff --git a/.github/workflows/deploy-pr.yml b/.github/workflows/deploy-pr.yml index b0aa4cb..e723741 100644 --- a/.github/workflows/deploy-pr.yml +++ b/.github/workflows/deploy-pr.yml @@ -29,8 +29,8 @@ jobs: - name: Build web run: bun build:web env: - supabaseUrl: ${{ secrets.supabaseUrl }} - supabaseAnonKey: ${{ secrets.supabaseAnonKey }} + supabaseUrl: ${{ secrets.EXPO_PUBLIC_SUPABSE_URL }} + supabaseAnonKey: ${{ secrets.EXPO_PUBLIC_SUPABSE_ANON_KEY }} EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY }} expoProjectId: ${{ secrets.expoProjectId }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1c49032..75b1eb5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,8 +27,8 @@ jobs: - name: Build web run: bun build:web env: - supabaseUrl: ${{ secrets.supabaseUrl }} - supabaseAnonKey: ${{ secrets.supabaseAnonKey }} + supabaseUrl: ${{ secrets.EXPO_PUBLIC_SUPABSE_URL }} + supabaseAnonKey: ${{ secrets.EXPO_PUBLIC_SUPABSE_ANON_KEY }} EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY }} expoProjectId: ${{ secrets.expoProjectId }} diff --git a/app.config.ts b/app.config.ts index 58be48d..4af27de 100644 --- a/app.config.ts +++ b/app.config.ts @@ -2,27 +2,11 @@ import 'dotenv/config'; import type {ConfigContext, ExpoConfig} from '@expo/config'; import withAndroidLocalizedName from '@mmomtchev/expo-android-localized-app-name'; -import dotenv from 'dotenv'; -import {expand} from 'dotenv-expand'; -import path from 'path'; import {version} from './package.json'; -// https://github.com/expo/expo/issues/23727#issuecomment-1651609858 -if (process.env.STAGE) { - expand( - dotenv.config({ - path: path.join( - __dirname, - ['./.env', process.env.STAGE].filter(Boolean).join('.'), - ), - override: true, - }), - ); -} - const DEEP_LINK_URL = '[firebaseAppId].web.app'; -const buildNumber = 12; +const buildNumber = 13; export default ({config}: ConfigContext): ExpoConfig => ({ ...config, @@ -79,8 +63,6 @@ export default ({config}: ConfigContext): ExpoConfig => ({ backgroundColor: '#343434', }, extra: { - supabaseUrl: process.env.supabaseUrl, - supabaseAnonKey: process.env.supabaseAnonKey, eas: {projectId: '1a0107b0-1cef-4913-875f-639c38f59101'}, }, updates: { diff --git a/bun.lockb b/bun.lockb index 0ed9231..26f8476 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/config.ts b/config.ts index 02c10b7..34ebcf8 100644 --- a/config.ts +++ b/config.ts @@ -2,6 +2,4 @@ import Constants from 'expo-constants'; const extra = Constants?.expoConfig?.extra; -export const supabaseUrl = extra?.supabaseUrl; -export const supabaseAnonKey = extra?.supabaseAnonKey; export const expoProjectId = extra?.eas?.projectId; diff --git a/package.json b/package.json index c73dd8e..a4a7af3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "expo-router/entry", "scripts": { "start": "expo start", - "start:prod": "STAGE=prod expo start", + "start:prod": "dotenv -e .env.production -- expo start", "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", @@ -17,7 +17,7 @@ "test": "jest --runInBand", "ios:release": "dotenv -e .env -- expo run:ios --configuration Release", "android:release": "dotenv -e .env -- expo run:android --variant release", - "android:device:release": "STAGE=production react-native run-android --mode='release'", + "android:device:release": "dotenv -e .env.production -- react-native run-android --mode='release'", "eas:dev:updates": "dotenv -e .env -- eas update --branch development", "eas:preview:android": "dotenv -e .env.production -- eas build --profile preview --platform android", "eas:prod:updates": "dotenv -e .env.production -- eas update --branch production", diff --git a/src/hooks/useSupabase.tsx b/src/hooks/useSupabase.tsx index 59a56f3..3f77fb4 100644 --- a/src/hooks/useSupabase.tsx +++ b/src/hooks/useSupabase.tsx @@ -2,19 +2,24 @@ import {useSession} from '@clerk/clerk-expo'; import {createClient} from '@supabase/supabase-js'; import {useEffect, useState} from 'react'; import {Database} from '../types/supabase'; -import {supabaseAnonKey, supabaseUrl} from '../../config'; import {ActiveSessionResource} from '@clerk/types'; import {useSetRecoilState} from 'recoil'; import {authRecoilState} from '../recoil/atoms'; export type SupabaseClient = ReturnType>; +const supabaseUrl = process.env.EXPO_PUBLIC_SUPABASE_URL; +const supabaseAnonKey = process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY; + function createClerkSupabaseClient( session?: ActiveSessionResource | null, ): SupabaseClient | null { if (!session) return null; - return createClient(supabaseUrl, supabaseAnonKey, { + console.log('supabaseUrl', supabaseUrl); + console.log('supabaseAnonKey', supabaseAnonKey); + + return createClient(supabaseUrl!, supabaseAnonKey!, { global: { // Get the custom Supabase token from Clerk fetch: async (url, options = {}) => {