From f8399addc886976f9f7068a6b737bb2289454f9b Mon Sep 17 00:00:00 2001 From: Tadjaur Date: Wed, 15 May 2024 06:56:18 +0100 Subject: [PATCH 1/6] Fix config for android local build --- .github/workflows/expo.build.yml | 12 ++++++-- apps/expo/app.config.js | 13 --------- apps/expo/env.example | 28 +++++-------------- apps/next/env.example | 8 ++++++ apps/vite/env.example | 8 ++++++ packages/app/auth/hooks/useGoogleAuth.ts | 4 +-- packages/app/constants/api.ts | 7 +++-- packages/config/package.json | 1 - packages/config/src/index.js | 23 ++++++++------- .../src/sources/vite/viteSource.native.js | 2 +- 10 files changed, 51 insertions(+), 55 deletions(-) create mode 100644 apps/next/env.example create mode 100644 apps/vite/env.example diff --git a/.github/workflows/expo.build.yml b/.github/workflows/expo.build.yml index e5ef68613..7b2c502ee 100644 --- a/.github/workflows/expo.build.yml +++ b/.github/workflows/expo.build.yml @@ -10,6 +10,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} + EXPO_PUBLIC_CLIENT_URL: ${{ vars.EXPO_PUBLIC_CLIENT_URL }} + EXPO_PUBLIC_API_URL: ${{ vars.EXPO_PUBLIC_API_URL }} + EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ vars.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN }} + jobs: build-android: runs-on: ubuntu-latest @@ -33,7 +39,7 @@ jobs: run: | eas build --non-interactive --platform android --local env: - MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} + EXPO_PUBLIC_ANDROID_CLIENT_ID: ${{ vars.EXPO_PUBLIC_ANDROID_CLIENT_ID }} - name: Upload APK uses: actions/upload-artifact@v3 @@ -62,10 +68,10 @@ jobs: run: | eas build --non-interactive --platform ios --local env: - MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} + EXPO_PUBLIC_IOS_CLIENT_ID: ${{ vars.EXPO_PUBLIC_IOS_CLIENT_ID }} - name: Upload IPA uses: actions/upload-artifact@v3 with: name: ios-ipa - path: /home/runner/work/PackRat/PackRat/apps/expo/build-*.ipa \ No newline at end of file + path: /home/runner/work/PackRat/PackRat/apps/expo/build-*.ipa diff --git a/apps/expo/app.config.js b/apps/expo/app.config.js index cb7e75895..f7c19c2c7 100644 --- a/apps/expo/app.config.js +++ b/apps/expo/app.config.js @@ -1,17 +1,4 @@ -import 'dotenv/config'; - module.exports = ({ config }) => { - config.extra.NODE_ENV = process.env.NODE_ENV; - config.extra.CLIENT_URL = process.env.CLIENT_URL; - config.extra.MAPBOX_ACCESS_TOKEN = process.env.MAPBOX_ACCESS_TOKEN; - config.extra.API_URL = process.env.API_URL; - - config.extra.EXPO_PUBLIC_NODE_ENV = process.env.EXPO_PUBLIC_NODE_ENV; - config.extra.EXPO_PUBLIC_CLIENT_URL = process.env.EXPO_PUBLIC_CLIENT_URL; - config.extra.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN = - process.env.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN; - config.extra.EXPO_PUBLIC_API_URL = process.env.EXPO_PUBLIC_API_URL; - return { ...config, plugins: config.plugins.map((i) => { diff --git a/apps/expo/env.example b/apps/expo/env.example index 467e05689..515b847f0 100644 --- a/apps/expo/env.example +++ b/apps/expo/env.example @@ -1,23 +1,9 @@ -—————————Client Env ——————————— -MONGODB_URI="Your mongodb URI" -CLIENT_URL="Your client url" +—————————EXPO CLIENT ENV ——————————— NODE_ENV='development' -API_URL='Your api url' -NPS_API = "Your api key" -GEOAPIFY_KEY = "Your api key" -GOOGLE_PLACES_API_KEY = 'Your api key' -MAPBOX_API_KEY = "Your api key, starts with pk..." -OPENWEATHER_KEY = "Your api key" -X_RAPIDAPI_KEY = "Your api key" -MAPBOX_ACCESS_TOKEN = "Your api key, starts with pk..." +EXPO_PUBLIC_CLIENT_URL="Your client url" +EXPO_PUBLIC_API_URL="Your api url" +EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..." +EXPO_PUBLIC_ANDROID_CLIENT_ID="962352557394-........................apps.googleusercontent.com" +EXPO_PUBLIC_IOS_CLIENT_ID="962352557394-........................apps.googleusercontent.com" MAPBOX_DOWNLOADS_TOKEN="Your api key, starts with sk..." -WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com" -ANDROID_CLIENT_ID="962352557394-........................apps.googleusercontent.com" -IOS_CLIENT_ID="962352557394-........................apps.googleusercontent.com" -FIREBASE_API_KEY = 'Your api key' -FIREBASE_AUTH_DOMAIN = "Your auth domain" -FIREBASE_PROJECT_ID = "Your firebase project id" -FIREBASE_STORAGE_BUCKET = "Your firebase_storage_key_link" -FIREBASE_MESSAGING_SENDER_ID = "Your firebase_messaging_sender_ID" -FIREBASE_APP_ID = "Your firebase app id" -FIREBASE_MEASUREMENT_ID = "Your firebase_measurement_id" \ No newline at end of file + diff --git a/apps/next/env.example b/apps/next/env.example new file mode 100644 index 000000000..805f3e1f1 --- /dev/null +++ b/apps/next/env.example @@ -0,0 +1,8 @@ +—————————NEXT CLIENT ENV——————————— +NODE_ENV='development' +NEXT_PUBLIC_APP='next' +NEXT_PUBLIC_CLIENT_URL="Your client url" +NEXT_PUBLIC_API_URL="Your api url" +NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..." +NEXT_PUBLIC_WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com" + diff --git a/apps/vite/env.example b/apps/vite/env.example new file mode 100644 index 000000000..033203ad2 --- /dev/null +++ b/apps/vite/env.example @@ -0,0 +1,8 @@ +—————————VITE CLIENT ENV——————————— +NODE_ENV='development' +VITE_PUBLIC_APP='vite' +VITE_PUBLIC_CLIENT_URL="Your client url" +VITE_PUBLIC_API_URL="Your api url" +VITE_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..." +VITE_PUBLIC_WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com" + diff --git a/packages/app/auth/hooks/useGoogleAuth.ts b/packages/app/auth/hooks/useGoogleAuth.ts index 41cc333b1..3111180ec 100644 --- a/packages/app/auth/hooks/useGoogleAuth.ts +++ b/packages/app/auth/hooks/useGoogleAuth.ts @@ -3,9 +3,9 @@ import * as Google from 'expo-auth-session/providers/google'; import { queryTrpc } from 'app/trpc'; import { useSessionSignIn } from './useSessionSignIn'; -import { GOOGLE_ID, IOS_CLIENT_ID, ANDROID_CLIENT_ID } from '@packrat/config'; +import { WEB_CLIENT_ID, IOS_CLIENT_ID, ANDROID_CLIENT_ID } from '@packrat/config'; -const webClientId = String(GOOGLE_ID); +const webClientId = String(WEB_CLIENT_ID); const iosClientId = String(IOS_CLIENT_ID); const androidClientId = String(ANDROID_CLIENT_ID); diff --git a/packages/app/constants/api.ts b/packages/app/constants/api.ts index 2ed5e6e6a..e1ec8847d 100644 --- a/packages/app/constants/api.ts +++ b/packages/app/constants/api.ts @@ -1,5 +1,8 @@ -// export const api = "http://add your ip address"; - import { API_URL } from '@packrat/config'; +/** + * The api url. + * format: "{scheme}://{serverhost}:{port}/api" + * e.g: "http://localhost:4200/api" +*/ export const api = API_URL; diff --git a/packages/config/package.json b/packages/config/package.json index c9b0c50c0..08ee1ba41 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -4,6 +4,5 @@ "private": true, "main": "src/index.js", "dependencies": { - "react-native": "0.73.6" } } diff --git a/packages/config/src/index.js b/packages/config/src/index.js index 2f6119d51..03a554dde 100644 --- a/packages/config/src/index.js +++ b/packages/config/src/index.js @@ -1,4 +1,3 @@ -import { Platform } from 'react-native'; import { viteSource } from './sources/vite'; /** @@ -8,38 +7,38 @@ import { viteSource } from './sources/vite'; // Simplifying environment variable access using logical OR const API_URL = - viteSource?.VITE_PUBLIC_API_URL || + viteSource.VITE_PUBLIC_API_URL || process.env.NEXT_PUBLIC_API_URL || process.env.EXPO_PUBLIC_API_URL; -const GOOGLE_ID = - viteSource?.VITE_PUBLIC_GOOGLE_ID || - process.env.NEXT_PUBLIC_GOOGLE_ID || - process.env.EXPO_PUBLIC_GOOGLE_ID; +const WEB_CLIENT_ID = + viteSource.VITE_PUBLIC_WEB_CLIENT_ID || + process.env.NEXT_PUBLIC_WEB_CLIENT_ID || + process.env.EXPO_PUBLIC_WEB_CLIENT_ID; const IOS_CLIENT_ID = - viteSource?.VITE_PUBLIC_IOS_CLIENT_ID || + viteSource.VITE_PUBLIC_IOS_CLIENT_ID || process.env.NEXT_PUBLIC_IOS_CLIENT_ID || process.env.EXPO_PUBLIC_IOS_CLIENT_ID; const ANDROID_CLIENT_ID = - viteSource?.VITE_PUBLIC_ANDROID_CLIENT_ID || + viteSource.VITE_PUBLIC_ANDROID_CLIENT_ID || process.env.NEXT_PUBLIC_ANDROID_CLIENT_ID || process.env.EXPO_PUBLIC_ANDROID_CLIENT_ID; const MAPBOX_ACCESS_TOKEN = - viteSource?.VITE_PUBLIC_MAPBOX_ACCESS_TOKEN || + viteSource.VITE_PUBLIC_MAPBOX_ACCESS_TOKEN || process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN || process.env.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN; const APP = - viteSource?.VITE_PUBLIC_APP || + viteSource.VITE_PUBLIC_APP || process.env.NEXT_PUBLIC_APP || process.env.EXPO_PUBLIC_APP; const CLIENT_URL = - viteSource?.VITE_PUBLIC_CLIENT_URL || + viteSource.VITE_PUBLIC_CLIENT_URL || process.env.NEXT_PUBLIC_CLIENT_URL || process.env.EXPO_PUBLIC_CLIENT_URL; const NODE_ENV = process.env.NODE_ENV; export { API_URL, - GOOGLE_ID, + WEB_CLIENT_ID, IOS_CLIENT_ID, ANDROID_CLIENT_ID, MAPBOX_ACCESS_TOKEN, diff --git a/packages/config/src/sources/vite/viteSource.native.js b/packages/config/src/sources/vite/viteSource.native.js index 54c8ceef6..f0efc9221 100644 --- a/packages/config/src/sources/vite/viteSource.native.js +++ b/packages/config/src/sources/vite/viteSource.native.js @@ -1,4 +1,4 @@ // DUMMY FILE. This is not actually used in the project. It is to fix Expo's build process. -export const viteSource = process.env, +export const viteSource = {}; From 6810ea7b1c92da400705ff2fbbc61af7085a49f8 Mon Sep 17 00:00:00 2001 From: Tadjaur Date: Wed, 15 May 2024 07:04:01 +0100 Subject: [PATCH 2/6] use secret instead of vars in private like variable --- .github/workflows/expo.build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/expo.build.yml b/.github/workflows/expo.build.yml index 7b2c502ee..e6563ef6d 100644 --- a/.github/workflows/expo.build.yml +++ b/.github/workflows/expo.build.yml @@ -10,11 +10,11 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: +env: # Define a shared environment variable for android and ios build. MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} EXPO_PUBLIC_CLIENT_URL: ${{ vars.EXPO_PUBLIC_CLIENT_URL }} EXPO_PUBLIC_API_URL: ${{ vars.EXPO_PUBLIC_API_URL }} - EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ vars.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN }} + EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ secrets.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN }} jobs: build-android: @@ -39,7 +39,7 @@ jobs: run: | eas build --non-interactive --platform android --local env: - EXPO_PUBLIC_ANDROID_CLIENT_ID: ${{ vars.EXPO_PUBLIC_ANDROID_CLIENT_ID }} + EXPO_PUBLIC_ANDROID_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_ANDROID_CLIENT_ID }} - name: Upload APK uses: actions/upload-artifact@v3 @@ -68,7 +68,7 @@ jobs: run: | eas build --non-interactive --platform ios --local env: - EXPO_PUBLIC_IOS_CLIENT_ID: ${{ vars.EXPO_PUBLIC_IOS_CLIENT_ID }} + EXPO_PUBLIC_IOS_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_IOS_CLIENT_ID }} - name: Upload IPA uses: actions/upload-artifact@v3 From 7b9886e89ab2acff7f17e02e2c0c9ada3c4c0641 Mon Sep 17 00:00:00 2001 From: Tadjaur Date: Wed, 15 May 2024 12:00:26 +0100 Subject: [PATCH 3/6] update deps --- packages/config/package.json | 4 +- packages/crosspath/types/lib-interface.d.ts | 4 +- packages/crosspath/types/model/types.d.ts | 41 +++++++++------------ yarn.lock | 2 - 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/packages/config/package.json b/packages/config/package.json index 08ee1ba41..84b771c33 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -2,7 +2,5 @@ "name": "@packrat/config", "version": "1.0.0", "private": true, - "main": "src/index.js", - "dependencies": { - } + "main": "src/index.js" } diff --git a/packages/crosspath/types/lib-interface.d.ts b/packages/crosspath/types/lib-interface.d.ts index acf8c94d3..524b24431 100644 --- a/packages/crosspath/types/lib-interface.d.ts +++ b/packages/crosspath/types/lib-interface.d.ts @@ -1,6 +1,4 @@ import { LinkComponent, Router, CreateParam } from './model'; -export declare function Link( - props: Parameters, -): ReturnType; +export declare function Link(props: Parameters): ReturnType; export declare const createParam: CreateParam; export declare function useRouter(): Router; diff --git a/packages/crosspath/types/model/types.d.ts b/packages/crosspath/types/model/types.d.ts index 5e7b7414e..9c3ee437d 100644 --- a/packages/crosspath/types/model/types.d.ts +++ b/packages/crosspath/types/model/types.d.ts @@ -1,32 +1,27 @@ import { FC } from 'react'; import { LinkProps } from 'solito/link'; export interface CreateParamOptions { - initial?: string; - parse?: (param: string) => unknown; - stringify?: (param: unknown) => string; + initial?: string; + parse?: (param: string) => unknown; + stringify?: (param: unknown) => string; } export interface Router { - push: (url: URL) => void; - replace: (url: URL) => void; - back: () => void; + push: (url: URL) => void; + replace: (url: URL) => void; + back: () => void; } export type LinkComponent = FC; -export type URL = - | string - | { - pathname?: string; - query?: Record; - state?: Record; - hash?: string; - as?: string | object; - }; +export type URL = string | { + pathname?: string; + query?: Record; + state?: Record; + hash?: string; + as?: string | object; +}; export type CreateParam = () => { - useParam: ( - key: keyof T, - options?: CreateParamOptions, - ) => [value: any, setValue: (value: any) => void]; - useParams: (key: keyof T) => { - params: T; - setParams: (value: any) => void; - }; + useParam: (key: keyof T, options?: CreateParamOptions) => [value: any, setValue: (value: any) => void]; + useParams: (key: keyof T) => { + params: T; + setParams: (value: any) => void; + }; }; diff --git a/yarn.lock b/yarn.lock index a57c75983..080b38744 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5326,8 +5326,6 @@ __metadata: "@packrat/config@workspace:packages/config": version: 0.0.0-use.local resolution: "@packrat/config@workspace:packages/config" - dependencies: - react-native: "npm:0.73.6" languageName: unknown linkType: soft From ff336df03c2eb941f8df84c4228ddf84a4e33e57 Mon Sep 17 00:00:00 2001 From: Tadjaur Date: Wed, 15 May 2024 18:24:05 +0100 Subject: [PATCH 4/6] update vars to secrets in expo.build action --- .github/workflows/expo.build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/expo.build.yml b/.github/workflows/expo.build.yml index e6563ef6d..b12de0187 100644 --- a/.github/workflows/expo.build.yml +++ b/.github/workflows/expo.build.yml @@ -12,8 +12,8 @@ concurrency: env: # Define a shared environment variable for android and ios build. MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} - EXPO_PUBLIC_CLIENT_URL: ${{ vars.EXPO_PUBLIC_CLIENT_URL }} - EXPO_PUBLIC_API_URL: ${{ vars.EXPO_PUBLIC_API_URL }} + EXPO_PUBLIC_CLIENT_URL: ${{ secrets.EXPO_PUBLIC_CLIENT_URL }} + EXPO_PUBLIC_API_URL: ${{ secrets.EXPO_PUBLIC_API_URL }} EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ secrets.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN }} jobs: From 7b67af7f8d1483e12c48e96004d432fcf4e541ed Mon Sep 17 00:00:00 2001 From: Andrew Bierman <94939237+andrew-bierman@users.noreply.github.com> Date: Wed, 15 May 2024 20:28:50 -0400 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=90=9B=20fix=20upload=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/expo.build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/expo.build.yml b/.github/workflows/expo.build.yml index b12de0187..e6c3513c4 100644 --- a/.github/workflows/expo.build.yml +++ b/.github/workflows/expo.build.yml @@ -37,7 +37,7 @@ jobs: - name: Run Local Build for Android working-directory: ./apps/expo run: | - eas build --non-interactive --platform android --local + eas build --profile preview --platform android --local --non-interactive env: EXPO_PUBLIC_ANDROID_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_ANDROID_CLIENT_ID }} @@ -66,7 +66,7 @@ jobs: - name: Run Local Build for iOS working-directory: ./apps/expo run: | - eas build --non-interactive --platform ios --local + eas build --profile preview --platform android --local --non-interactive env: EXPO_PUBLIC_IOS_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_IOS_CLIENT_ID }} From d6f9c018bb952e2a7a7a16547c8ae4e5864a41df Mon Sep 17 00:00:00 2001 From: Andrew Bierman <94939237+andrew-bierman@users.noreply.github.com> Date: Wed, 15 May 2024 20:29:27 -0400 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=90=9B=20fix=20ios=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/expo.build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/expo.build.yml b/.github/workflows/expo.build.yml index e6c3513c4..8563c0d54 100644 --- a/.github/workflows/expo.build.yml +++ b/.github/workflows/expo.build.yml @@ -66,7 +66,7 @@ jobs: - name: Run Local Build for iOS working-directory: ./apps/expo run: | - eas build --profile preview --platform android --local --non-interactive + eas build --profile preview --platform ios --local --non-interactive env: EXPO_PUBLIC_IOS_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_IOS_CLIENT_ID }}