diff --git a/.env b/.env deleted file mode 100644 index bed6a2d8..00000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_AUTH_LOBBY = 'http://localhost:3001' diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..d0f27967 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +REACT_APP_BUILD = 'staging' diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..d0f27967 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +REACT_APP_BUILD = 'staging' diff --git a/babel.config.js b/babel.config.js index c21f570c..16f63e6c 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,7 @@ module.exports = { [ 'module:react-native-dotenv', { - // envName: 'APP_ENV', + envName: 'APP_ENV', moduleName: '@env', path: '.env', blocklist: null, diff --git a/package.json b/package.json index df93583c..bac4265f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "ios": "react-native run-ios --simulator=\"iPhone 14\"", "web": "react-scripts start", "start": "react-native start", - "dev-env": "dev-env", + "clean-cache": "rm -rf node_modules/.cache/babel-loader/*", "test": "jest", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, diff --git a/src/env.native.ts b/src/env.native.ts index 581b211c..a2ec3a4d 100644 --- a/src/env.native.ts +++ b/src/env.native.ts @@ -1,8 +1,13 @@ // @ts-ignore types not available -prf -import {REACT_APP_AUTH_LOBBY} from '@env' +import {REACT_APP_BUILD} from '@env' -if (typeof REACT_APP_AUTH_LOBBY !== 'string') { - throw new Error('ENV: No auth lobby provided') +if (typeof REACT_APP_BUILD !== 'string') { + throw new Error('ENV: No env provided') +} +if (!['dev', 'staging', 'prod'].includes(REACT_APP_BUILD)) { + throw new Error( + `ENV: Env must be "dev", "staging", or "prod," got "${REACT_APP_BUILD}"`, + ) } -export const AUTH_LOBBY = REACT_APP_AUTH_LOBBY +export const BUILD = REACT_APP_BUILD diff --git a/src/env.ts b/src/env.ts index 78fb88ac..a379e435 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,5 +1,10 @@ -if (typeof process.env.REACT_APP_AUTH_LOBBY !== 'string') { - throw new Error('ENV: No auth lobby provided') +if (typeof process.env.REACT_APP_BUILD !== 'string') { + throw new Error('ENV: No env provided') +} +if (!['dev', 'staging', 'prod'].includes(process.env.REACT_APP_BUILD)) { + throw new Error( + `ENV: Env must be "dev", "staging", or "prod," got "${process.env.REACT_APP_BUILD}"`, + ) } -export const AUTH_LOBBY = process.env.REACT_APP_AUTH_LOBBY +export const BUILD = process.env.REACT_APP_BUILD diff --git a/src/state/index.ts b/src/state/index.ts index 2c3df7d0..a886e761 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -3,8 +3,14 @@ import {sessionClient as AtpApi} from '../third-party/api' import {RootStoreModel} from './models/root-store' import * as libapi from './lib/api' import * as storage from './lib/storage' +import {BUILD} from '../env' -export const DEFAULT_SERVICE = 'http://localhost:2583' +export const DEFAULT_SERVICE = + BUILD === 'prod' + ? 'http://localhost:2583' // TODO + : BUILD === 'staging' + ? 'https://pds.staging.bsky.dev' // TODO + : 'http://localhost:2583' const ROOT_STATE_STORAGE_KEY = 'root' const STATE_FETCH_INTERVAL = 15e3 diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 178b01dc..9fca9646 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -8,6 +8,7 @@ import {useStores} from '../../state' import {FeedModel} from '../../state/models/feed-view' import {ScreenParams} from '../routes' import {s} from '../lib/styles' +import {BUILD} from '../../env' export const Home = observer(function Home({ visible, @@ -53,7 +54,10 @@ export const Home = observer(function Home({ return ( - + diff --git a/src/view/screens/Login.tsx b/src/view/screens/Login.tsx index 759efd43..e386c854 100644 --- a/src/view/screens/Login.tsx +++ b/src/view/screens/Login.tsx @@ -18,6 +18,7 @@ import {s, colors} from '../lib/styles' import {makeValidHandle, createFullHandle} from '../lib/strings' import {useStores, DEFAULT_SERVICE} from '../../state' import {ServiceDescription} from '../../state/models/session' +import {BUILD} from '../../env' enum ScreenState { SigninOrCreateAccount, @@ -71,7 +72,9 @@ const SigninOrCreateAccount = ({ Bluesky - [ private beta ] + + [ private beta {BUILD !== 'prod' ? `- ${BUILD} ` : ''}] + diff --git a/todos.txt b/todos.txt index cac992e4..e9879bf4 100644 --- a/todos.txt +++ b/todos.txt @@ -33,4 +33,7 @@ Paul's todo list - Bugs - Auth token refresh seems broken - Check that sub components arent reloading too much - - Titles are getting screwed up (possibly swipe related) \ No newline at end of file + - Titles are getting screwed up (possibly swipe related) + > Dont suggest self for follows + > Double post on post? + > Handle no displayname everywhere \ No newline at end of file