|
| 1 | +# Contributing to the InsForge Dart/Flutter SDK |
| 2 | + |
| 3 | +Thanks for helping improve the SDK! This guide covers the repository layout, |
| 4 | +local setup, testing, and the conventions we follow. |
| 5 | + |
| 6 | +## Repository layout |
| 7 | + |
| 8 | +This is a [Dart pub workspace](https://dart.dev/tools/pub/workspaces) (a |
| 9 | +monorepo resolved together): |
| 10 | + |
| 11 | +``` |
| 12 | +packages/ |
| 13 | + insforge/ # pure-Dart SDK (auth, database, storage, functions, ai) |
| 14 | + insforge_flutter/ # Flutter layer: SecureSessionStorage + Insforge singleton |
| 15 | +integration_tests/ # live, against-a-real-project tests (opt-in via env vars) |
| 16 | +samples/ |
| 17 | + twitter_app/ # full Flutter sample app |
| 18 | +``` |
| 19 | + |
| 20 | +`insforge_flutter` depends on and re-exports `insforge`. |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +- Flutter ≥ 3.24 (bundles a compatible Dart ≥ 3.5). `flutter --version` and |
| 25 | + `dart --version` must both work. |
| 26 | +- Because the workspace contains a Flutter package, resolve it with **`flutter |
| 27 | + pub get`** (not `dart pub get`) from the repo root. |
| 28 | + |
| 29 | +```bash |
| 30 | +flutter pub get |
| 31 | +``` |
| 32 | + |
| 33 | +## Running the checks |
| 34 | + |
| 35 | +Everything must pass before a change is merged. |
| 36 | + |
| 37 | +```bash |
| 38 | +# Static analysis (whole workspace) |
| 39 | +dart analyze . |
| 40 | + |
| 41 | +# Pure-Dart unit tests |
| 42 | +cd packages/insforge && dart test |
| 43 | + |
| 44 | +# Flutter unit tests |
| 45 | +cd packages/insforge_flutter && flutter test |
| 46 | +``` |
| 47 | + |
| 48 | +Formatting must be clean: |
| 49 | + |
| 50 | +```bash |
| 51 | +dart format . |
| 52 | +``` |
| 53 | + |
| 54 | +The analyzer config (`analysis_options.yaml`) enables stricter lints — |
| 55 | +notably `require_trailing_commas`, `prefer_single_quotes`, and |
| 56 | +`avoid_print`. CI runs `dart analyze .` plus every package's tests and fails |
| 57 | +on any issue. |
| 58 | + |
| 59 | +## Integration tests (live backend) |
| 60 | + |
| 61 | +`integration_tests/` exercises the SDK against a real InsForge project. With no |
| 62 | +environment variables set, **every test skips** — so it's safe in normal CI. |
| 63 | +To run it, provide a project and a pre-verified account: |
| 64 | + |
| 65 | +```bash |
| 66 | +cd integration_tests |
| 67 | +INSFORGE_INTEGRATION_BASE_URL=https://<project>.insforge.app \ |
| 68 | +INSFORGE_INTEGRATION_ANON_KEY=<anon-key> \ |
| 69 | +INSFORGE_INTEGRATION_TEST_EMAIL=<verified-account-email> \ |
| 70 | +INSFORGE_INTEGRATION_TEST_PASSWORD=<password> \ |
| 71 | +INSFORGE_INTEGRATION_API_KEY=<project-api-key> \ # for storage |
| 72 | +INSFORGE_INTEGRATION_OPENROUTER_KEY=<openrouter-key> \ # for ai |
| 73 | +dart test |
| 74 | +``` |
| 75 | + |
| 76 | +See `integration_tests/README.md` for the required backend schema (the |
| 77 | +`sdk_test` table, a `public` bucket, and a `hello-world` function). Never |
| 78 | +commit real keys — keep them in your shell. |
| 79 | + |
| 80 | +## Coding conventions |
| 81 | + |
| 82 | +- **Models** use hand-written `fromJson`/`toJson` (no codegen). Be tolerant of |
| 83 | + missing/optional fields the backend may omit. |
| 84 | +- **Errors**: throw the typed `InsforgeException` hierarchy; don't return |
| 85 | + `{data, error}` tuples. |
| 86 | +- **No Flutter in `insforge`**: the `insforge` package must stay pure Dart so it |
| 87 | + runs under `dart test`. Anything needing Flutter belongs in |
| 88 | + `insforge_flutter`. |
| 89 | +- Keep the public API stable; document deviations from the backend contract. |
| 90 | + |
| 91 | +## Commit messages |
| 92 | + |
| 93 | +We use [Conventional Commits](https://www.conventionalcommits.org): |
| 94 | + |
| 95 | +``` |
| 96 | +feat(database): accumulate multiple filters per column |
| 97 | +fix(auth): tolerate signUp response without a user |
| 98 | +test(integration): cover the email verification flow |
| 99 | +docs(readme): document the AI module |
| 100 | +``` |
| 101 | + |
| 102 | +Scopes are typically a module name (`auth`, `database`, `storage`, |
| 103 | +`functions`, `ai`, `core`) or `sample` / `integration` / `ci`. |
| 104 | + |
| 105 | +## Versioning & releasing |
| 106 | + |
| 107 | +`insforge` and `insforge_flutter` are released **in lockstep** — they always |
| 108 | +share the same version number. The version lives in three places that must stay |
| 109 | +in sync: |
| 110 | + |
| 111 | +- `packages/insforge/pubspec.yaml` → `version:` |
| 112 | +- `packages/insforge_flutter/pubspec.yaml` → `version:` **and** its |
| 113 | + `insforge: ^<version>` dependency constraint |
| 114 | +- `packages/insforge/lib/src/core/version.dart` → `insforgeSdkVersion` |
| 115 | + (a generated constant; the runtime `User-Agent` is `InsForge-Dart/<version>`) |
| 116 | + |
| 117 | +Don't edit these by hand — use the tool, which updates all of them at once: |
| 118 | + |
| 119 | +```bash |
| 120 | +dart run tool/set_version.dart 0.2.0 # set the version everywhere |
| 121 | +dart run tool/set_version.dart --check # verify they're in sync (CI runs this) |
| 122 | +``` |
| 123 | + |
| 124 | +`version.dart` is generated; never edit it directly. CI fails if the three drift |
| 125 | +apart. |
| 126 | + |
| 127 | +### Release checklist |
| 128 | + |
| 129 | +1. `dart run tool/set_version.dart <new-version>`. |
| 130 | +2. Add a `## <new-version>` section to each package's `CHANGELOG.md`. |
| 131 | +3. Commit, open a PR, merge to `main`. |
| 132 | +4. Tag the release: `git tag v<new-version> && git push --tags`. |
| 133 | +5. Publish **in order** (the Flutter package depends on the Dart one): |
| 134 | + ```bash |
| 135 | + cd packages/insforge && dart pub publish # wait until it's live |
| 136 | + cd ../insforge_flutter && dart pub publish |
| 137 | + ``` |
| 138 | + |
| 139 | +> Note on 0.x: under SemVer, `^0.1.0` means `>=0.1.0 <0.2.0`. Bumping the minor |
| 140 | +> (e.g. `0.1.x → 0.2.0`) is a breaking change, and the tool updates |
| 141 | +> `insforge_flutter`'s `insforge: ^…` constraint accordingly so it picks up the |
| 142 | +> new core. |
| 143 | +
|
| 144 | +## Pull requests |
| 145 | + |
| 146 | +1. Branch off `main`. |
| 147 | +2. Make the change with tests; keep `dart analyze .` and all suites green. |
| 148 | +3. If a change is driven by real backend behavior, add or update an integration |
| 149 | + test that proves it. |
| 150 | +4. Update `CHANGELOG.md` under the unreleased/next version. |
| 151 | +5. Open a PR describing the change and how you verified it. |
| 152 | + |
| 153 | +By contributing, you agree that your contributions are licensed under the |
| 154 | +project's [Apache License 2.0](LICENSE). |
0 commit comments