Skip to content

Commit b83bbf9

Browse files
committed
#125: Documentation review - add CLI quick start and fix import
Added CLI usage section to README with createCLI example and commands. Updated docs/index.md to include .env file support in What's New. Fixed missing MigrationScriptExecutor import in CLI example.
1 parent 0d5886e commit b83bbf9

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,52 @@ folder: ./migrations
203203
logLevel: debug # error | warn | info | debug
204204
```
205205

206+
### CLI Usage (v0.7.0)
207+
208+
**Create a CLI for your database adapter:**
209+
210+
```typescript
211+
// cli.ts
212+
import { createCLI, MigrationScriptExecutor } from '@migration-script-runner/core';
213+
import { MyDatabaseHandler } from './database-handler';
214+
215+
const program = createCLI({
216+
name: 'my-db-migrate',
217+
version: '1.0.0',
218+
description: 'Database migration CLI',
219+
createExecutor: (config) => {
220+
const handler = new MyDatabaseHandler();
221+
return new MigrationScriptExecutor({ handler, config });
222+
}
223+
});
224+
225+
program.parse(process.argv);
226+
```
227+
228+
**Run migrations from command line:**
229+
230+
```bash
231+
# Run all pending migrations
232+
npx my-db-migrate migrate
233+
234+
# List all migrations with status
235+
npx my-db-migrate list
236+
237+
# Rollback last migration
238+
npx my-db-migrate down
239+
240+
# Validate migrations without running
241+
npx my-db-migrate validate
242+
243+
# Create database backup
244+
npx my-db-migrate backup
245+
246+
# Use environment-specific config
247+
npx my-db-migrate migrate --config-file .env.production
248+
```
249+
250+
**[→ Full CLI Documentation](https://migration-script-runner.github.io/msr-core/guides/cli-adapter-development)**
251+
206252
---
207253

208254
## 📚 Documentation

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ A database-agnostic migration framework for TypeScript and JavaScript projects.
114114

115115
## What's New in v0.7.0
116116

117-
🎉 Latest release brings CLI factory and improved architecture:
117+
🎉 Latest release brings CLI factory, .env file support, and improved architecture:
118118

119119
- **🖥️ CLI Factory** - Create command-line interfaces with built-in commands (migrate, list, down, validate, backup) using Commander.js - see [CLI Adapter Development Guide](guides/cli-adapter-development)
120+
- **🗂️ .env File Support** - Load configuration from .env, .env.production, .env.local files with configurable priority
120121
- **🎨 Facade Pattern** - Services grouped into logical facades (core, execution, output, orchestration) for better code organization
121122
- **🏭 Factory Pattern** - Dedicated service initialization reduces constructor complexity by 83%
122123
- **🔧 Protected Facades** - Adapters can extend MigrationScriptExecutor and access internal services through protected facades

0 commit comments

Comments
 (0)