({
env = process.env,
networkInterfaces: interfaces = networkInterfaces(),
platform = process.platform,
} = {})
| 137 | } |
| 138 | |
| 139 | export function createDevConfig({ |
| 140 | env = process.env, |
| 141 | networkInterfaces: interfaces = networkInterfaces(), |
| 142 | platform = process.platform, |
| 143 | } = {}) { |
| 144 | const providedBaseUrl = env.EXPO_PUBLIC_TANSTACK_AI_BASE_URL |
| 145 | const providedPackagerHostname = env.REACT_NATIVE_PACKAGER_HOSTNAME |
| 146 | const hasProvidedPackagerHostname = Object.hasOwn( |
| 147 | env, |
| 148 | 'REACT_NATIVE_PACKAGER_HOSTNAME', |
| 149 | ) |
| 150 | const port = env.PORT ?? String(BACKEND_PORT) |
| 151 | const lanAddressInfo = pickLanAddressInfo(interfaces) |
| 152 | const lanAddress = lanAddressInfo?.address |
| 153 | const baseUrl = |
| 154 | providedBaseUrl ?? |
| 155 | (lanAddress ? `http://${lanAddress}:${port}` : `http://127.0.0.1:${port}`) |
| 156 | const packagerHostname = hasProvidedPackagerHostname |
| 157 | ? providedPackagerHostname |
| 158 | : undefined |
| 159 | const metroHostSource = hasProvidedPackagerHostname ? 'environment' : 'expo' |
| 160 | const serverEnv = { |
| 161 | ...env, |
| 162 | PORT: port, |
| 163 | } |
| 164 | const expoEnv = createExpoEnv({ |
| 165 | baseUrl, |
| 166 | env, |
| 167 | hasProvidedPackagerHostname, |
| 168 | packagerHostname, |
| 169 | }) |
| 170 | |
| 171 | return { |
| 172 | baseUrl, |
| 173 | lanAddress, |
| 174 | lanInterfaceName: lanAddressInfo?.interfaceName, |
| 175 | metroHostSource, |
| 176 | packagerHostname, |
| 177 | port, |
| 178 | pnpmCommand: getPnpmCommand(platform), |
| 179 | serverOpenAIKeyLoaded: Boolean(serverEnv.OPENAI_API_KEY), |
| 180 | usedProvidedBaseUrl: Boolean(providedBaseUrl), |
| 181 | usedProvidedPackagerHostname: hasProvidedPackagerHostname, |
| 182 | serverEnv, |
| 183 | expoEnv, |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | export function createSpawnConfig({ |
| 188 | command, |
no test coverage detected