yarn initialize
The yarn initialize script wraps the Open Saasframe CLI saasframe init command and delivers a ready-to-run workspace. It installs dependencies, prepares generated module artifacts, applies database migrations, seeds baseline RBAC data, and populates demo CRM content (companies, people, deals, activities, todos) unless you disable it with --no-examples. Enable --stresstest to tack on a synthetic, high-volume dataset that includes additional companies, pipeline deals, activities, and notes — all wired with realistic custom field values and a live progress bar.
Usage
yarn initialize [--org=<name>] [--email=<address>] [--password=<value>] [--roles=<csv>] [--skip-password-policy] [--no-examples] [--stresstest] [--lite] [-n <count>] [--count=<count>] [--reinstall|-r]
Ensure DATABASE_URL points to the Postgres instance you want to initialize before running the command.
Options
| Option | Description | Default |
|---|---|---|
--org, --orgName | Name of the organization that will be created. | Acme Corp |
--email | Superadmin login email. Companion admin@… and employee@… accounts are also provisioned. | superadmin@acme.com |
--password | Password applied to all seeded accounts. | secret |
--roles | Comma-separated list of roles ensured before user creation. | superadmin,admin,employee |
--skip-password-policy | Skip password policy validation during auth setup (useful for demo defaults like secret). | off |
--no-examples | Skip demo CRM seeders (companies, people, deals, activities, todos). Alias: --no-exampls. | off |
--stresstest | Generate a high-volume synthetic CRM dataset (contacts, companies, deals, activities, notes) in addition to the curated examples. | off |
--lite | When paired with --stresstest, skips deals, activities, notes, and custom fields for faster high-volume contact generation. | off |
-n, --count, --stress-count, --stresstest-count | Number of synthetic contacts to create when --stresstest is enabled. | 6000 |
--reinstall, -r | Drops every table in the target database before bootstrapping. Requires a valid DATABASE_URL. | off |
Environment Defaults
When you omit CLI flags, the init flow will read environment defaults for the seeded accounts:
| Variable | Description | Default |
|---|---|---|
SF_INIT_SUPERADMIN_EMAIL | Superadmin login email used when --email is not provided. | superadmin@acme.com |
SF_INIT_SUPERADMIN_PASSWORD | Superadmin password used when --password is not provided. | secret |
SF_INIT_ADMIN_EMAIL | Derived admin account email override. | admin@<superadmin-domain> |
SF_INIT_EMPLOYEE_EMAIL | Derived employee account email override. | employee@<superadmin-domain> |
SF_INIT_ADMIN_PASSWORD | Admin account password override. When unset, a random 16-char base64url password is generated and surfaced in the init summary. | (randomly generated) |
SF_INIT_EMPLOYEE_PASSWORD | Employee account password override. When unset, a random 16-char base64url password is generated and surfaced in the init summary. | (randomly generated) |
SF_INIT_GENERATE_RANDOM_PASSWORD | Deprecated, no-op. Random derived passwords are now the unconditional default when overrides are unset; setting the flag prints a one-time deprecation warning and is otherwise ignored. | (unused) |
yarn initialize passes --include-demo-users to saasframe auth setup so the derived admin@… / employee@… demo accounts are seeded as part of the dev/demo bootstrap. Standalone callers of saasframe auth setup must opt in themselves; without that flag, no demo accounts are seeded.
What the Command Does
- Installs workspace dependencies with
yarn install. - Runs code generators directly (entity IDs, module registry, entities, DI, API client) — no process spawning.
- Applies all per-module migrations via the internal migration engine.
- Bootstraps the application (registers modules, DI registrars, entity IDs).
- Seeds configuration defaults (
configs restore-defaults). - Runs
auth setupto create the tenant, organization, and user accounts specified. - Seeds feature toggle defaults (
feature_toggles seed-defaults). - If tenant ID is available, seeds tenant-scoped roles (
auth seed-roles). - If organization and tenant IDs are detected:
- Seeds customer dictionaries (
customers seed-dictionaries). - Seeds catalog units (
catalog seed-units). - Seeds availability schedules.
- Seeds encryption defaults (if
TENANT_DATA_ENCRYPTIONis enabled). - Seeds catalog price kinds, tax rates, sales statuses, adjustment kinds, shipping methods, and payment methods.
- Unless
--no-examplesis present, seeds demo CRM data (customers seed-examples), catalog examples, sales examples, and example Todos (example seed-todos). - When
--stresstestis present, seeds synthetic contacts, companies, deals, activities, and notes with custom fields (and a progress bar) viacustomers seed-stresstest. Add--liteto focus on raw contacts without the heavier extras. - Enables default dashboard widgets (
dashboards seed-defaults). - Triggers vector search reindex and query index reindex.
- Seeds customer dictionaries (
On success, the command prints a boxed summary with created accounts and their passwords.
The init command now calls CLI handlers directly instead of spawning separate processes for each step. This significantly reduces initialization time by eliminating ~25+ process spawns and maintaining shared state (DI container, entity IDs, etc.) across all operations.
Reinstall Mode
When --reinstall is present the command:
- Loads env variables via
dotenv/config. - Connects to the configured database and drops all tables in the
publicschema usingCASCADE. - Continues with a clean bootstrap and reseeds example data (unless you add
--no-examples).
Use this mode for destructive resets in development. Never run it against production databases.
Troubleshooting
- Missing
DATABASE_URL— the command aborts before performing database work. Export the variable or place it in.env. - Dependency install fails — run
yarn installmanually to inspect the error, then re-runyarn initialize. - Migrations fail — confirm the database credentials and ensure the target user can create tables. The CLI stops on the first failure so you can address the issue before re-running.