From 210082be93cd369b868e748c7e89e95fc3ce6bbe Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 11 Nov 2022 15:02:19 -0600 Subject: Add staging env --- src/env.native.ts | 13 +++++++++---- src/env.ts | 11 ++++++++--- src/state/index.ts | 10 ++++++++-- src/view/screens/Home.tsx | 6 +++++- src/view/screens/Login.tsx | 5 ++++- 5 files changed, 34 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/env.native.ts b/src/env.native.ts index 581b211ca..a2ec3a4dc 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 78fb88acc..a379e435f 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 2c3df7d07..a886e7611 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' - -export const DEFAULT_SERVICE = 'http://localhost:2583' +import {BUILD} from '../env' + +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 178b01dc2..9fca96461 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 759efd435..e386c8548 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} ` : ''}] + -- cgit 1.4.1