@stratal/seeders
v0.0.10
Published
Database seeder infrastructure for Stratal framework applications
Maintainers
Readme
@stratal/seeders
Database seeder infrastructure for Stratal framework applications.
Features
- Simple API — Extend the
Seederbase class and implementrun() - Automatic Discovery — Recursively traverses your module tree to find all seeders
- Dry-Run Mode — Preview which seeders will execute without running them
- Request-Scoped DI — Seeders run within a request scope with full access to the DI container
- Batch Execution — Run a single seeder by name or all seeders at once
- CLI-First — Powered by wrangler platform proxy for Cloudflare Workers integration
Installation
npm install -D @stratal/seeders
# or
yarn add -D @stratal/seedersPeer dependencies
| Package | Required |
|---|---|
| stratal | Yes |
AI Agent Skills
Stratal provides Agent Skills for AI coding assistants like Claude Code and Cursor. Install to give your AI agent knowledge of Stratal patterns, conventions, and APIs:
npx skills add strataljs/stratalQuick Start
Define a seeder by extending the Seeder base class:
import { Seeder } from '@stratal/seeders'
import { inject } from 'stratal/di'
import { DATABASE_TOKEN } from './tokens'
export class UserSeeder extends Seeder {
constructor(@inject(DATABASE_TOKEN) private db: Database) {
super()
}
async run(): Promise<void> {
await this.db.insert('users', { name: 'Alice', email: '[email protected]' })
}
}Register the seeder in a module:
import { Module } from 'stratal/module'
import { UserSeeder } from './user.seeder'
@Module({
providers: [UserSeeder],
})
export class SeedersModule {}Create an entry file that calls SeederRunner.run():
import { SeederRunner } from '@stratal/seeders'
import { AppModule } from './app.module'
SeederRunner.run(AppModule)Run your seeders via the CLI:
stratal-seed ./src/seeders/index.ts run userCLI
The stratal-seed command is the main entry point for running seeders.
stratal-seed <entry-file> <command> [options]Commands
| Command | Description |
|---|---|
| run <name> | Run a specific seeder by name |
| run --all | Run all discovered seeders |
| list | List all available seeders |
Options
| Option | Alias | Description |
|---|---|---|
| --all | -a | Run all seeders at once |
| --dry-run | -d | Preview without executing |
| --help | -h | Display help information |
Seeder names are derived from the class name: UserSeeder becomes user, RolePermissionsSeeder becomes role-permissions.
Documentation
Full guides and examples are available at stratal.dev.
License
MIT
