Skip to content

Commit 7872ba1

Browse files
committed
fix: add rust-toolchain.toml to pin Rust 1.94 for CI
The aarch64-unknown-linux-gnu runner ships rustc 1.93 which doesn't satisfy rust-version = "1.94". Pin the toolchain so cargo-dist installs the correct version. Also adds docs/RELEASING.md, AGENTS.md, and fixes README license.
1 parent 8413326 commit 7872ba1

4 files changed

Lines changed: 189 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# AGENTS.md — Notes for AI coding agents
2+
3+
## Project overview
4+
5+
**fbadmin** is a Rust CLI for Firebase Authentication administration. It wraps the `rs-firebase-admin-sdk` crate and provides subcommands for user management, custom claims, auth action links, and emulator utilities.
6+
7+
## Repository layout
8+
9+
```
10+
src/
11+
main.rs # CLI struct (clap derive), arg parsing, command dispatch
12+
config.rs # Profile/config management (confy, TOML, local overrides)
13+
firebase.rs # AuthBackend enum, init_firebase() — SDK initialization
14+
output.rs # Render helpers: table, JSON, CSV, colored messages
15+
prompt.rs # Interactive prompts (dialoguer) for missing args
16+
errors.rs # IntoAnyhow trait for error-stack → anyhow conversion
17+
commands/
18+
mod.rs # Re-exports
19+
users.rs # users get/create/disable/enable/remove/list/list-inactive/count
20+
claims.rs # claims get/merge/remove/clear/find
21+
links.rs # links password-reset/email-verify/sign-in
22+
emulator.rs # emulator clear-users/config
23+
config_cmd.rs # config init/add/remove/default/list/show/which/path
24+
info.rs # info — resolved connection + connectivity check
25+
build.rs # vergen-gitcl: embeds git SHA + build date into --version
26+
dist-workspace.toml # cargo-dist release configuration
27+
Cargo.toml # Dependencies, package metadata, profiles
28+
```
29+
30+
## Key patterns
31+
32+
- **CLI structure**: All args are defined in `main.rs` via clap derive. Each command module has a `pub async fn run(cli: &Cli, command: &XxxCommand)` entry point.
33+
- **Error handling**: SDK calls return `Result<T, error_stack::Report<ApiClientError>>`. Use the `IntoAnyhow` trait (`.into_anyhow()`) to convert, then chain `.context("human-readable message")` for user-facing errors.
34+
- **Interactive prompts**: When a required arg is `None`, command modules call `prompt::resolve_email()` or similar. These use `dialoguer` and are TTY-aware.
35+
- **Output**: Always go through `output.rs` helpers (`render_single_record`, `render_table`, `render_success`, etc.) — they handle `--format` switching (table/json/csv) and colored output.
36+
- **Config resolution**: Profile is resolved from CLI flag → `FBADMIN_PROFILE` env → `default_profile` in config. Connection merges profile settings with CLI overrides. See `config::resolve_connection()`.
37+
- **Firebase init**: `firebase::init_firebase()` takes an `AuthBackend` enum (Emulator or Live with optional credentials/project). The `build_auth` helper in command modules wires config → AuthBackend → FirebaseAuth.
38+
- **Logging**: `tracing` with `tracing-subscriber`. Controlled by `-v` flag count. Logs go to stderr. Use `tracing::debug!` for internal details, `tracing::info!` for notable operations.
39+
40+
## Build and run
41+
42+
```bash
43+
cargo build # Debug build
44+
cargo run -- users list # Run with args
45+
cargo clippy # Lint
46+
cargo fmt # Format
47+
```
48+
49+
The project requires Rust 1.94+ (edition 2024).
50+
51+
## Releasing
52+
53+
See [docs/RELEASING.md](docs/RELEASING.md) for the full release process. Short version:
54+
55+
1. Bump `version` in `Cargo.toml`
56+
2. Update `RELEASES.md`
57+
3. `git tag vX.Y.Z && git push origin main --tags`
58+
59+
## Dependencies of note
60+
61+
| Crate | Purpose |
62+
|-------|---------|
63+
| `rs-firebase-admin-sdk` | Firebase Auth SDK (community) |
64+
| `google-cloud-auth` | ADC / service account auth |
65+
| `clap` (derive) | CLI argument parsing |
66+
| `confy` | OS-appropriate config file management |
67+
| `dialoguer` | Interactive terminal prompts |
68+
| `comfy-table` | Table rendering |
69+
| `console` | TTY detection, colored/styled output |
70+
| `anyhow` + `error-stack` | Error handling layers |
71+
| `tracing` | Structured logging |
72+
| `vergen-gitcl` | Build-time git metadata |
73+
74+
## Things to watch out for
75+
76+
- **`rs-firebase-admin-sdk` is community-maintained** — check for API changes when updating. There is no official Rust Firebase SDK.
77+
- **`IntoAnyhow` trait** in `errors.rs` is the bridge between `error-stack` (used by the SDK) and `anyhow` (used everywhere else). Always use it for SDK calls.
78+
- **`build.rs`** uses `vergen-gitcl` which shells out to `git`. CI builds need git available.
79+
- **The `.docs/` directory** contains internal design documents and is gitignored. It's not shipped or published.
80+
- **Config file paths** are OS-dependent (managed by `confy`). Don't hardcode paths.
81+
- **Destructive commands** (`remove`, `clear`, `disable`) should always respect `--dry-run` and `--yes` flags.
82+
83+
## License
84+
85+
AGPL-3.0-only

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ fbadmin claims get --email user@example.com -f json # Single record as JSON
131131

132132
## License
133133

134-
MIT
134+
AGPL-3.0-only — see [LICENSE](LICENSE).

docs/RELEASING.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Releasing fbadmin
2+
3+
Releases are automated via [cargo-dist](https://opensource.axo.dev/cargo-dist/). Pushing a semver tag triggers GitHub Actions which builds binaries, creates a GitHub Release, and publishes a Homebrew formula.
4+
5+
## Prerequisites
6+
7+
- Push access to `NeoScript/firebase-admin-cli`
8+
- `HOMEBREW_TAP_TOKEN` repo secret set on `firebase-admin-cli` — a fine-grained PAT with **Contents: Read and write** on `NeoScript/homebrew-fbadmin`
9+
10+
## Release checklist
11+
12+
1. **Bump the version** in `Cargo.toml`:
13+
14+
```toml
15+
[package]
16+
version = "0.2.0"
17+
```
18+
19+
2. **Update RELEASES.md** — add a section for the new version at the top:
20+
21+
```markdown
22+
# v0.2.0
23+
24+
- Added feature X
25+
- Fixed bug Y
26+
```
27+
28+
3. **Regenerate the release workflow** (only needed if you changed `dist-workspace.toml`):
29+
30+
```bash
31+
dist generate
32+
```
33+
34+
4. **Commit**:
35+
36+
```bash
37+
git add -A
38+
git commit -m "chore: prepare v0.2.0 release"
39+
```
40+
41+
5. **Tag and push**:
42+
43+
```bash
44+
git tag v0.2.0
45+
git push origin main --tags
46+
```
47+
48+
6. **Monitor** the Release workflow at https://github.com/NeoScript/firebase-admin-cli/actions
49+
50+
## What the workflow does
51+
52+
The `release.yml` workflow:
53+
54+
1. **plan** — determines what to build from the tag
55+
2. **build-local-artifacts** — compiles binaries for each target:
56+
- `aarch64-apple-darwin` (Apple Silicon)
57+
- `x86_64-apple-darwin` (Intel Mac)
58+
- `aarch64-unknown-linux-gnu` (Linux ARM64)
59+
- `x86_64-unknown-linux-gnu` (Linux x64)
60+
- `x86_64-pc-windows-msvc` (Windows x64)
61+
3. **build-global-artifacts** — generates shell/powershell installer scripts and checksums
62+
4. **host** — creates the GitHub Release and uploads all artifacts
63+
5. **publish-homebrew-formula** — pushes a `.rb` formula to `NeoScript/homebrew-fbadmin`
64+
6. **announce** — finalizes the release
65+
66+
## Configuration
67+
68+
Release settings live in `dist-workspace.toml`:
69+
70+
```toml
71+
[dist]
72+
cargo-dist-version = "0.31.0"
73+
ci = "github"
74+
installers = ["shell", "powershell", "homebrew"]
75+
targets = [...]
76+
tap = "NeoScript/homebrew-fbadmin"
77+
publish-jobs = ["homebrew"]
78+
```
79+
80+
To change targets, installers, or upgrade cargo-dist, edit this file and run `dist generate` to regenerate the workflow.
81+
82+
## Adding a new target
83+
84+
1. Add the Rust target triple to `targets` in `dist-workspace.toml`
85+
2. Run `dist generate`
86+
3. Commit the updated `dist-workspace.toml` and `.github/workflows/release.yml`
87+
88+
## Troubleshooting
89+
90+
- **Workflow didn't trigger**: the workflow must already exist on the branch when the tag is pushed. If you added the workflow and tag in the same push, delete and re-push the tag:
91+
92+
```bash
93+
git push origin :refs/tags/vX.Y.Z
94+
git tag -d vX.Y.Z
95+
git tag vX.Y.Z
96+
git push origin vX.Y.Z
97+
```
98+
99+
- **Homebrew publish failed**: verify the `HOMEBREW_TAP_TOKEN` secret is set and the PAT hasn't expired. The token needs **Contents: Read and write** on `NeoScript/homebrew-fbadmin`.
100+
101+
- **Build failed for a target**: check the build logs in GitHub Actions. Common causes are missing system deps for cross-compilation or Rust version mismatches.

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "1.94"

0 commit comments

Comments
 (0)