Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Public (non-secret) runtime config. Expo inlines these into the app at build
# time, and ONLY variables prefixed EXPO_PUBLIC_ are exposed to the client.
# See https://docs.expo.dev/guides/environment-variables/
#
# `yarn setup:oss` / `yarn setup:artsy` copy this to `.env` (gitignored) if you
# don't have one. Fill in real values as needed — every var is optional and the
# app boots fine with them left blank (Unleash + Sentry stay disabled).
#
# NOTE: secrets (e.g. ARTSY_API_CLIENT_KEY / ARTSY_API_CLIENT_SECRET) are NOT
# env vars — they are read through react-native-keys from keys.development.json
# / keys.production.json. See docs/configuration.

# Unleash feature flags — leave blank to disable remote flags (all flags resolve
# to false and no network request is made).
EXPO_PUBLIC_UNLEASH_URL=
EXPO_PUBLIC_UNLEASH_CLIENT_KEY=

# Sentry error reporting — leave blank to disable.
EXPO_PUBLIC_SENTRY_DSN=
33 changes: 26 additions & 7 deletions docs/environment_variables_configuration.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
## Environment Variables Configuration

Energy uses [shared configuration](https://github.com/artsy/README/blob/main/playbooks/development-environments.md#shared-configuration) to distribute common and sensitive configuration values. The [setup script](../scripts/prepare-env-vars) will download `.env.shared` from S3. Then it will add the environment variables ovverrides and any developer custom configuration from `.env.example` to `.env`. Finally, it will merge both into a `.env.dev` file that will be used for both builds.
Public runtime config lives in a local **`.env`** file at the project root. Expo
inlines it at build time, and **only** variables prefixed `EXPO_PUBLIC_` are
exposed to the app — see the
[Expo environment variables guide](https://docs.expo.dev/guides/environment-variables/).

> **Note**: Whenever you change an environment variable, you will need to rebuild the app again
`yarn setup:oss` and `yarn setup:artsy` copy the tracked **`.env.example`** to
`.env` (gitignored) if you don't have one. You can also do it by hand:

## Add/Update remote environment variable

```
aws s3 cp s3://artsy-citadel/dev/.env.energy .env.shared
aws s3 cp .env.shared s3://artsy-citadel/dev/.env.energy
```sh
cp .env.example .env
```

Every variable is optional — the app boots fine with them left blank:

| Variable | Purpose | Blank behavior |
| --- | --- | --- |
| `EXPO_PUBLIC_UNLEASH_URL` | Unleash proxy URL | Remote flags disabled (all flags `false`, no network) |
| `EXPO_PUBLIC_UNLEASH_CLIENT_KEY` | Unleash client key | Remote flags disabled |
| `EXPO_PUBLIC_SENTRY_DSN` | Sentry DSN | Error reporting disabled |

> **Note:** Expo inlines env vars at **build time**, so after changing a value
> you must rebuild the app.

## Secrets are not env vars

API secrets (e.g. `ARTSY_API_CLIENT_KEY` / `ARTSY_API_CLIENT_SECRET`) are read
through [`react-native-keys`](https://github.com/numandev1/react-native-keys)
from `keys.development.json` / `keys.production.json`, **not** from `.env`. See
[Configuration](./configuration).
40 changes: 0 additions & 40 deletions scripts/prepare-env-vars

This file was deleted.

15 changes: 11 additions & 4 deletions scripts/setup-env-for-artsy
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env bash
set -euxo pipefail

# Resolve the sibling scripts by this file's own location and run them from the
# project root, so `yarn setup:artsy` works from the repo root (where yarn runs
# it) and not only from inside scripts/.
# Resolve sibling scripts by this file's own location and run from the project
# root, so `yarn setup:artsy` works from the repo root (where yarn runs it) and
# not only from inside scripts/.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/.."

# Download Artsy's private fonts from S3 (needs Artsy AWS access).
"$SCRIPT_DIR/download-fonts"
"$SCRIPT_DIR/prepare-env-vars"

# Seed .env from the tracked example if you don't have one. Expo auto-loads
# .env and inlines EXPO_PUBLIC_* at build time; fill in real values by hand.
# (Secrets live in keys.*.json via react-native-keys, not here.)
if [ ! -f .env ]; then
cp .env.example .env
fi
8 changes: 8 additions & 0 deletions scripts/setup-oss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ for env in development production; do
fi
done

echo "▸ .env (Expo public config)"
if [ -f .env ]; then
echo " • keeping existing .env"
else
cp .env.example .env
echo " • created .env from .env.example — fill in EXPO_PUBLIC_* values (optional)"
fi

cat <<'EOF'

✅ OSS setup complete. Next:
Expand Down
Loading