Setup & Lifecycle
Install thunder-core and run its setup lifecycle to create database indexes and seed default RBAC roles.
Installing the plugin only copies files and merges the import map. The setup script does not run automatically - you must trigger setup (DB indexes + RBAC seeding) explicitly.
Installing and Running Setup
--setup alone runs setup against the production environment. Pass a comma-separated list to target others:
deno task add:plugin -n Huruf-Tech/thunder-core --setup
deno task add:plugin -n Huruf-Tech/thunder-core --setup=development,productionRun setup any time after install (prompts for environments if --envs is omitted):
deno task setup:plugin -n Huruf-Tech/thunder-core
deno task setup:plugin -n Huruf-Tech/thunder-core --envs=development,productionSetup runs scripts/setupPlugin.ts once per selected environment, with ENV_TYPE set to that environment so the script connects to the correct database.
What the Lifecycle Scripts Do
| Script | Responsibility |
|---|---|
scripts/setupPlugin.ts | Entry point - calls syncDBIndexes() then syncAccessControl(). |
scripts/syncDBIndexes.ts | Creates the plugin's MongoDB indexes and unique constraints. |
scripts/syncAccessControl.ts | Seeds the default RBAC policies and roles. |
scripts/cleanupPlugin.ts | Runs on uninstall (remove:plugin --clean). |
Read scripts/syncDBIndexes.ts for the exact index definitions and unique constraints, and scripts/syncAccessControl.ts for the seeded policy permissions and role to policy mappings.
syncAccessControl is idempotent. It goes through ACManager, which upserts policies and roles and $addToSets permissions, so you can safely re-run it after adding new default permissions - it will not duplicate or remove anything.
Re-run it any time with:
deno task sync:ac:dev # development
deno task sync:ac:prod # productionBefore You Run Setup
Make sure the required environment variables (especially DATABASE_URL and SECRET_KEY) are set for each environment you target, since each run loads the matching .env / .env.<environment> files.