|
| 1 | +# Repository Overview |
| 2 | + |
| 3 | +Monorepo providing a Directus endpoint extension, a CLI for syncing schema/data, an e2e test harness, and documentation. |
| 4 | + |
| 5 | +## High-level flow |
| 6 | + |
| 7 | +- The CLI connects to a Directus instance and orchestrates pull/diff/push/seed/specs operations. |
| 8 | +- The API extension exposes endpoints used by the CLI for SyncID↔LocalID mapping and helpers. |
| 9 | +- E2E tests spin up a Directus server locally and validate the full flow (CLI + extension) end-to-end. |
| 10 | + |
| 11 | +## Packages |
| 12 | + |
| 13 | +### `packages/api` — Directus endpoint extension |
| 14 | +- Exposes `/directus-extension-sync` routes for SyncID mapping and helpers (e.g., permissions deduplication). |
| 15 | +- Uses Express-style router via Directus SDK, Zod validation, and Knex for a small mapping table. |
| 16 | +- Key files: `src/index.ts` (routes), `src/api/*` (middleware/helpers), `src/database/*` (IdMapper, Permissions). |
| 17 | + |
| 18 | +### `packages/cli` — Directus Sync CLI |
| 19 | +- Orchestrates schema and system collections synchronization; supports seed data and API specifications dump. |
| 20 | +- Structure: |
| 21 | + - `services/config`: options resolution (defaults → config file → CLI flags), Zod validation. |
| 22 | + - `services/collections`: per-collection pull/diff/push with id mapping. |
| 23 | + - `services/snapshot`: schema snapshot pull/diff/push. |
| 24 | + - `services/seed`: seed files loader/differ/pusher with dynamic id mapping. |
| 25 | + - `services/specifications`: GraphQL/OpenAPI dump. |
| 26 | + - `services/*-client.ts`: Directus SDK client, extension HTTP client, health checks. |
| 27 | + - `commands` + `program.ts`: command wiring and execution. |
| 28 | +- Technologies: TypeScript, typedi (DI), pino (logging), Zod, @directus/sdk. |
| 29 | + |
| 30 | +### `packages/e2e` — End-to-end tests |
| 31 | +- Jasmine-based tests against a locally started Directus server. |
| 32 | +- Helpers start the server, create a Directus client, and run CLI commands programmatically, asserting logs and state. |
| 33 | +- See `spec/helpers/sdk/*`, `spec/pull-diff-push/*`. |
| 34 | + |
| 35 | +### `website` — Documentation |
| 36 | +- Docusaurus site documenting installation, features, and how the sync works. |
| 37 | +- When updating the CLI help outputs, build the whole project (`npm run build` at the root), then run `npm run update-help-outputs` to update the help outputs in the website. |
| 38 | + |
| 39 | +## Other top-level |
| 40 | + |
| 41 | +- `docker/`: build/publish scripts and Dockerfile for distributing Directus with the extension. |
| 42 | +- `lerna.json`: monorepo management. |
| 43 | +- `DOCUMENTATION.md`, `CHANGELOG.md`, etc.: project docs and changelog. |
| 44 | + |
| 45 | +## Conventions |
| 46 | + |
| 47 | +- TypeScript across packages; DI via `typedi`; logging via `pino`; validation via `zod`. |
| 48 | +- Keep business logic in services; commands/endpoints orchestrate only. |
| 49 | +- Follow per-package rules under `.cursor/rules/` for detailed guidance. |
| 50 | + |
| 51 | +## Checks |
| 52 | + |
| 53 | +- Before committing, run `npm run lint` to run the linter and fix any issues. |
| 54 | +- Before pushing, run `npm run test` to run the tests and fix any issues. |
| 55 | +- Before pushing, run `npm run build` to build the project and fix any issues. |
| 56 | +- Before pushing, run `npm run docs:update` to update the help outputs in the website. |
0 commit comments