docs(readme): integrate API key development instructions

- Remove separate DEV_API_KEYS.md file
- Add compile-time env var explanation in README
- Document npm run dev:tauri command usage
- Explain why .env must be sourced before build

cp
This commit is contained in:
vicrodh committed 2026-01-14 19:58:32 -06:00
1 parent 6e21b3ed1f
commit 7eb12b36bf
2 files changed
+19 -45

No files matched your search

-45
View File
@@ -1,45 +0,0 @@
# Development with API Keys
## Problem
The API keys in `.env` are embedded at **compile-time** using Rust's `option_env!()` macro, not at runtime. This means the `.env` file must be loaded into environment variables **before** compilation.
## Solution for Local Development
Use the custom script that loads `.env` before building:
```bash
npm run dev:tauri
```
This script:
1. Sources the `.env` file into the shell environment
2. Runs `npm run tauri dev` with those variables available during compilation
## Alternative: Manual Export
If you prefer to run `npm run tauri dev` directly, export the variables first:
```bash
# Load .env into current shell
set -a
source .env
set +a
# Now run dev
npm run tauri dev
```
## Why This is Needed
- **CI/CD builds**: Variables are injected via GitHub Secrets → environment → `option_env!()` at compile time
- **Local development**: Variables must be in shell environment before `cargo build` runs
- The `dotenvy::dotenv()` in `lib.rs` only loads variables at **runtime**, but `option_env!()` reads them at **compile time**
## Embedded Keys
The following keys are embedded at compile time:
- `LAST_FM_API_KEY` / `LAST_FM_API_SHARED_SECRET`
- `DISCOGS_API_CLIENT_KEY` / `DISCOGS_API_CLIENT_SECRET`
- `SPOTIFY_API_CLIENT_ID` / `SPOTIFY_API_CLIENT_SECRET`
- `TIDAL_API_CLIENT_ID` / `TIDAL_API_CLIENT_SECRET`
+19
View File
@@ -178,6 +178,25 @@ When building from source, you need to provide your own API keys. Copy the examp
cp .env.example .env
```
Edit `.env` with your API keys, then use the development script that properly loads them:
```bash
# Use this command for development with API keys
npm run dev:tauri
```
**Important**: API keys are embedded at compile-time using Rust's `option_env!()` macro. The `.env` file must be loaded into your shell environment before compilation. The `npm run dev:tauri` script does this automatically. If you prefer manual control:
```bash
# Load .env into current shell (once per terminal session)
set -a
source .env
set +a
# Now run dev
npm run tauri dev
```
#### Last.fm Integration
1. Go to [Last.fm API Account](https://www.last.fm/api/account/create)