Skip to content

Commit fc16c49

Browse files
committed
chore: Move core files to '@green-stack/core' package workspace
1 parent 5892833 commit fc16c49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+249
-72
lines changed

apps/expo/.env.example

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
EXPO_PUBLIC_BASE_URL=
2-
EXPO_PUBLIC_BACKEND_URL=
3-
EXPO_PUBLIC_API_URL=
4-
EXPO_PUBLIC_GRAPH_URL=
1+
## --- Notes ----------------------------------------------------------------------------------- */
2+
3+
## -i- The `.env.example` file can be copied into `.env.local` using `npx turbo env:local`
4+
## -i- For more info, development, staging & production environments, check the expo docs:
5+
## -i- https://docs.expo.dev/guides/environment-variables/
6+
7+
## -i- Note that Expo will inline environment variables in your bundle during builds & deployments
8+
## -i- This means dynamically retrieving environment variables from e.g. `process.env[someKey]` will not work
9+
## -i- It also means that you should never include sensitive / private keys
10+
11+
## -i- We suggest that for each environment variable you add here, you also add an entry in `appConfig.ts`
12+
## -i- There, you can add logic like ```envValue: process.env.EXPO_PUBLIC_ENV_KEY || process.env.NEXT_PUBLIC_ENV_KEY```
13+
## -i- Where you would only define the EXPO_PUBLIC_ prefixed versions here in `.env.local` locally and using Expo UI for deployed envs
14+
15+
## --- General --------------------------------------------------------------------------------- */
16+
## -i- Env vars that should always be present & the same locally, independent of the simulated environment
17+
## --------------------------------------------------------------------------------------------- */
18+
19+
EXPO_PUBLIC_BASE_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
20+
EXPO_PUBLIC_BACKEND_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
21+
EXPO_PUBLIC_API_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
22+
EXPO_PUBLIC_GRAPH_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
23+
24+
## --- LOCAL ----------------------------------------------------------------------------------- */
25+
## -i- Defaults you might want to switch out for local development by commenting / uncommenting
26+
## --------------------------------------------------------------------------------------------- */
27+
28+
# EXAMPLE= # ...
29+
30+
## --- DEV ------------------------------------------------------------------------------------- */
31+
# -i- Uncomment while on development branch to simulate the dev environment
32+
## --------------------------------------------------------------------------------------------- */
33+
34+
# EXAMPLE= # ...
35+
36+
## --- STAGE ----------------------------------------------------------------------------------- */
37+
# -i- Uncomment while on staging branch to simulate the stage environment
38+
## --------------------------------------------------------------------------------------------- */
39+
40+
# EXAMPLE= # ...
41+
42+
## --- PROD ------------------------------------------------------------------------------------ */
43+
# -i- Uncomment while on main branch to simulate the production environment
44+
## --------------------------------------------------------------------------------------------- */
45+
46+
# EXAMPLE= # ...

apps/expo/app/ExpoRootLayout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Stack } from 'expo-router'
22
import UniversalAppProviders from '@app/core/screens/UniversalAppProviders'
33
import UniversalRootLayout from '@app/core/screens/UniversalRootLayout'
4-
import { Image as ExpoContextImage } from '@app/core/components/Image.expo'
5-
import { Link as ExpoContextLink } from '@app/core/navigation/Link.expo'
6-
import { useRouter as useExpoContextRouter } from '@app/core/navigation/useRouter.expo'
7-
import { useRouteParams as useExpoRouteParams } from '@app/core/navigation/useRouteParams.expo'
4+
import { Image as ExpoContextImage } from '@green-stack/core/components/Image.expo'
5+
import { Link as ExpoContextLink } from '@green-stack/core/navigation/Link.expo'
6+
import { useRouter as useExpoContextRouter } from '@green-stack/core/navigation/useRouter.expo'
7+
import { useRouteParams as useExpoRouteParams } from '@green-stack/core/navigation/useRouteParams.expo'
88
import { NativeWindStyleSheet } from 'nativewind'
99

1010
// -i- Expo Router's layout setup is much simpler than Next.js's layout setup

apps/expo/tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { universalTheme } = require('@app/core/tailwind.theme.cjs')
1+
const { universalTheme } = require('@app/core/tailwind.theme.js')
22

33
/** @type {import('tailwindcss').Config} */
44
module.exports = {

apps/expo/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"include": [
44
"**/*.ts",
55
"**/*.tsx",
6-
"../../features/app-core/graphql-env.d.ts"
6+
"../../features/app-core/graphql-env.d.ts",
7+
"../../features/**/*.tsx",
8+
"../../features/**/*.ts",
9+
"../../packages/**/*.tsx",
10+
"../../packages/**/*.ts"
711
],
812
"exclude": ["node_modules"]
913
}

apps/next/.env.example

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,47 @@
1+
## --- Notes ----------------------------------------------------------------------------------- */
2+
3+
## -i- The `.env.example` file can be copied into `.env.local` using `npx turbo env:local`
4+
## -i- For development, staging & production environments, check the next.js docs:
5+
## -i- https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
6+
7+
## -i- Note that you should treat environment variables as if they could be inlined in your bundle during builds & deployments
8+
## -i- This means dynamically retrieving environment variables from e.g. `process.env[someKey]` might not work
9+
## -i- It also means that you should never prefix with `NEXT_PUBLIC_` for sensitive / private keys
10+
11+
## -i- We suggest that for each environment variable you add here, you also add an entry in `appConfig.ts`
12+
## -i- There, you can add logic like ```envValue: process.env.NEXT_PUBLIC_ENV_KEY || process.env.EXPO_PUBLIC_ENV_KEY```
13+
## -i- Where you would only define the NEXT_PUBLIC_ prefixed versions here in `.env.local` locally and using Next.js UI for deployed envs
14+
## -i- For environment variables you only be available server-side, you can omit `NEXT_PUBLIC_`
15+
16+
## --- General --------------------------------------------------------------------------------- */
17+
## -i- Env vars that should always be present & the same locally, independent of the simulated environment
18+
## --------------------------------------------------------------------------------------------- */
19+
120
NEXT_PUBLIC_BASE_URL=http://localhost:3000
221
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000
322
NEXT_PUBLIC_API_URL=http://localhost:3000/api
423
NEXT_PUBLIC_GRAPH_URL=http://localhost:3000/api/graphql
24+
25+
## --- LOCAL ----------------------------------------------------------------------------------- */
26+
## -i- Defaults you might want to switch out for local development by commenting / uncommenting
27+
## --------------------------------------------------------------------------------------------- */
28+
29+
# DB_URL= # TODO: Add DB layer connection for full local dev...
30+
31+
## --- DEV ------------------------------------------------------------------------------------- */
32+
# -i- Uncomment while on development branch to simulate the dev environment
33+
## --------------------------------------------------------------------------------------------- */
34+
35+
# DB_URL= # TODO: Add DB layer connection for the dev environment...
36+
37+
## --- STAGE ----------------------------------------------------------------------------------- */
38+
# -i- Uncomment while on staging branch to simulate the stage environment
39+
## --------------------------------------------------------------------------------------------- */
40+
41+
# DB_URL= # TODO: Add DB layer connection for the stage environment...
42+
43+
## --- PROD ------------------------------------------------------------------------------------ */
44+
# -i- Uncomment while on main branch to simulate the production environment
45+
## --------------------------------------------------------------------------------------------- */
46+
47+
# DB_URL= # TODO: Add DB layer connection for the production environment...

apps/next/app/NextClientRootLayout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use client'
22
import React from 'react'
33
import UniversalAppProviders from '@app/core/screens/UniversalAppProviders'
4-
import { Image as NextContextImage } from '@app/core/components/Image.next'
5-
import { Link as NextContextLink } from '@app/core/navigation/Link.next'
6-
import { useRouter as useNextContextRouter } from '@app/core/navigation/useRouter.next'
7-
import { useRouteParams as useNextRouteParams } from '@app/core/navigation/useRouteParams.next'
4+
import { Image as NextContextImage } from '@green-stack/core/components/Image.next'
5+
import { Link as NextContextLink } from '@green-stack/core/navigation/Link.next'
6+
import { useRouter as useNextContextRouter } from '@green-stack/core/navigation/useRouter.next'
7+
import { useRouteParams as useNextRouteParams } from '@green-stack/core/navigation/useRouteParams.next'
88

99
// -i- This is a regular react client component
1010
// -i- It's still rendered on the server during SSR, but it also hydrates on the client

apps/next/tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { universalTheme } = require('@app/core/tailwind.theme.cjs')
1+
const { universalTheme } = require('@app/core/tailwind.theme.js')
22

33
/** @type {import('tailwindcss').Config} */
44
module.exports = {

apps/next/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"**/*.ts",
55
"**/*.tsx",
66
".next/types/**/*.ts",
7-
"../../features/app-core/graphql-env.d.ts"
7+
"../../features/app-core/graphql-env.d.ts",
8+
"../../features/**/*.tsx",
9+
"../../features/**/*.ts",
10+
"../../packages/**/*.tsx",
11+
"../../packages/**/*.ts"
812
],
913
"exclude": [
1014
"node_modules"
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
import Constants from 'expo-constants'
22
import { Platform } from 'react-native'
33

4-
export const isLocalhost = Platform.OS === 'web' && globalThis?.location?.hostname === 'localhost'
5-
export const isExpoWebLocal = isLocalhost && globalThis?.location?.port === '8081'
6-
export const fallbackExpoWebHost = isExpoWebLocal ? "localhost" : ''
4+
/* --- Notes ----------------------------------------------------------------------------------- */
5+
6+
// -i- Workpacke package '@green-stack/core' expects this file to be at '/features/app-core/appConfig.ts'
7+
// -i- Please keep it here to avoid issues
8+
9+
/* --- Computed Fallbacks ---------------------------------------------------------------------- */
10+
11+
export const isWebLocalhost = Platform.OS === 'web' && globalThis?.location?.hostname === 'localhost'
12+
export const isExpoWebLocal = isWebLocalhost && globalThis?.location?.port === '8081'
13+
export const fallbackExpoWebHost = isExpoWebLocal ? 'localhost' : ''
714

815
export const expoDebuggerHost = Constants?.expoGoConfig?.debuggerHost || Constants.manifest2?.extra?.expoGo?.debuggerHost // prettier-ignore
916
export const localURL = expoDebuggerHost?.split?.(':').shift() || fallbackExpoWebHost
17+
export const isExpoMobileLocal = !!expoDebuggerHost
1018

1119
export const fallbackBaseURL = localURL ? `http://${localURL}:3000` : ''
1220

1321
/** --- appConfig ------------------------------------------------------------------------------ */
1422
/** -i- App config variables powered by env vars universally, and including some expo contants config on mobile */
1523
export const appConfig = {
16-
isExpoWebLocal: isExpoWebLocal,
24+
// -i- Flags -i-
25+
isLocal: isWebLocalhost || isExpoMobileLocal,
26+
isWebLocalhost,
27+
isExpoWebLocal,
28+
isExpoMobileLocal,
29+
// -i- Server URLs -i-
1730
baseURL: process.env.NEXT_PUBLIC_BASE_URL || process.env.EXPO_PUBLIC_BASE_URL || `${fallbackBaseURL}`, // prettier-ignore
1831
backendURL: process.env.NEXT_PUBLIC_BACKEND_URL || process.env.EXPO_PUBLIC_BACKEND_URL || `${fallbackBaseURL}`, // prettier-ignore
1932
apiURL: process.env.NEXT_PUBLIC_API_URL || process.env.EXPO_PUBLIC_API_URL || `${fallbackBaseURL}/api`, // prettier-ignore
@@ -23,5 +36,5 @@ export const appConfig = {
2336
/* --- Debug ----------------------------------------------------------------------------------- */
2437

2538
if (Platform.OS !== 'web') {
26-
if (appConfig.baseURL === '') console.warn('appConfig.baseURL is empty, check your environment variables')
39+
if (appConfig.baseURL === '') console.warn('appConfig.baseURL is empty, you may be missing some environment variables')
2740
}
File renamed without changes.

0 commit comments

Comments
 (0)