Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1b5ee7c
#122: Implement pre-commit hooks with Husky to run lint and tests
vlavrynovych Dec 8, 2025
ca748a1
#123: Refactor to single-parameter constructor with extensible Config…
vlavrynovych Dec 8, 2025
a6159dd
#97: Refactor MigrationScriptExecutor using Orchestrator Pattern
vlavrynovych Dec 9, 2025
f863928
#62: Refactor MigrationScriptExecutor with Facade and Factory patterns
vlavrynovych Dec 9, 2025
ba5afde
#126: Add automatic environment variable parsing with EnvVarParser
vlavrynovych Dec 9, 2025
fb40e08
#128: Integrate auto-envparse package to replace internal EnvVarParser
vlavrynovych Dec 10, 2025
a247d3c
#128: Remove unused eslint-disable directive
vlavrynovych Dec 10, 2025
180cf2d
Revert "#128: Remove unused eslint-disable directive"
vlavrynovych Dec 10, 2025
c014f08
#128: Remove unused eslint-disable directive
vlavrynovych Dec 10, 2025
df167d2
#128: Fix test:mocha:report script to only run test files
vlavrynovych Dec 10, 2025
50a2882
Add GitHub Actions test workflow and badge
vlavrynovych Dec 10, 2025
33b6212
Update GitHub Actions to test on Node.js 18, 20, and 22
vlavrynovych Dec 10, 2025
54eb999
Update GitHub Actions to test on Node.js 20 and 22 only
vlavrynovych Dec 10, 2025
040a188
Fix CircleCI to use npm ci and cache package-lock.json
vlavrynovych Dec 10, 2025
1faa542
Fix CircleCI by forcing cache rebuild and adding Node engine requirement
vlavrynovych Dec 10, 2025
6444701
Fix ts-node loading in Node 20+ environments
vlavrynovych Dec 10, 2025
fffc377
Fix test:mocha:report to use .mocharc.json spec pattern
vlavrynovych Dec 10, 2025
49ba012
Fix ts-node CommonJS loading in CircleCI Node 20 environment
vlavrynovych Dec 10, 2025
65470b4
#128: Update auto-envparse to v1.1.1 with CommonJS support
vlavrynovych Dec 10, 2025
5c7a5ac
#128: Remove ESM workarounds after auto-envparse@1.1.1 CommonJS support
vlavrynovych Dec 10, 2025
0720470
#59: Add CLI factory with built-in commands and type-safe extensibility
vlavrynovych Dec 10, 2025
3d3139d
#86: Add comprehensive CLI vs API and production deployment documenta…
vlavrynovych Dec 11, 2025
ed021d9
#129: Upgrade auto-envparse to v2.1.0 and add .env file support
vlavrynovych Dec 13, 2025
0d5886e
#124: Fix test assertion quality - add error type and message validation
vlavrynovych Dec 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v3-dependencies-{{ checksum "package-lock.json" }}
- v3-dependencies-
- run:
name: Install Dependencies
command: npm install
command: npm ci
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
key: v3-dependencies-{{ checksum "package-lock.json" }}
- run:
name: Creates backups folder
command: mkdir backups
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

on:
push:
branches: [ master, develop, release/* ]
pull_request:
branches: [ master, develop ]

jobs:
test:
name: Test on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Create backups directory
run: mkdir -p backups

- name: Run linter
run: npm run lint

- name: Run tests
run: npm test

- name: Generate coverage report
run: npm run test:coverage
26 changes: 26 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "🔍 Running pre-commit checks..."

# TypeScript type checking
echo "📘 Type checking TypeScript..."
npx tsc --noEmit || exit 1

# Build check
echo "🔨 Building project..."
npm run build || exit 1

# Run linting
echo "📝 Running ESLint..."
npm run lint || exit 1

# Run tests with coverage
echo "🧪 Running tests with coverage..."
npm run test:coverage || exit 1

# Check coverage threshold
echo "📊 Verifying 100% coverage..."
npx nyc check-coverage --lines 100 --branches 100 --functions 100 --statements 100 || exit 1

echo "✅ All pre-commit checks passed!"
55 changes: 36 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Migration Script Runner

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/migration-script-runner/msr-core/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/migration-script-runner/msr-core/tree/master)
[![Test](https://github.com/migration-script-runner/msr-core/actions/workflows/test.yml/badge.svg)](https://github.com/migration-script-runner/msr-core/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/migration-script-runner/msr-core/badge.svg?branch=master)](https://coveralls.io/github/migration-script-runner/msr-core?branch=master)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vlavrynovych_msr&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vlavrynovych_msr)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=vlavrynovych_msr&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=vlavrynovych_msr)
Expand All @@ -20,7 +21,30 @@ MSR provides a lightweight, flexible framework for managing database migrations

---

## 🎉 What's New in v0.6.0
## 🎉 What's New in v0.7.0

**Enhanced architecture, adapter extensibility, and improved maintainability:**

- **🎨 Facade Pattern** - Services grouped into 4 logical facades (core, execution, output, orchestration) for better code organization
- **🏭 Factory Pattern** - Service initialization extracted to dedicated factory, reducing constructor complexity by 83%
- **🔧 Protected Facades** - Adapters can extend MigrationScriptExecutor and access internal services through protected facades
- **✨ Extensible Configuration** - New `IConfigLoader` interface allows adapters to customize environment variable handling
- **🗂️ .env File Support** - Load configuration from `.env`, `.env.production`, `.env.local` files with configurable priority
- **🔨 Simplified Constructor** - Single parameter constructor with config moved into dependencies object (**BREAKING**)
- **🔒 Better Encapsulation** - Internal services no longer exposed as public properties (**BREAKING**)
- **⚡ Reduced Complexity** - Constructor reduced from 142 lines to 23 lines (83% reduction)
- **📐 Workflow Ownership** - `executeBeforeMigrate()` moved to MigrationWorkflowOrchestrator for cleaner architecture
- **✨ 100% Test Coverage** - All statements, branches, functions, and lines covered (1228/1228 tests passing)

**⚠️ BREAKING CHANGES in v0.7.0:** Constructor signature changed (config moved into dependencies), and service properties removed (use public API methods instead). Migration takes 15-30 minutes. See the [v0.6.x → v0.7.0 Migration Guide](https://migration-script-runner.github.io/msr-core/version-migration/v0.6-to-v0.7) for step-by-step instructions.

**[→ View architecture docs](https://migration-script-runner.github.io/msr-core/development/architecture/design-patterns)**

---

## 📜 Previous Releases

### v0.6.0

**Enhanced type safety, metrics collection, and multi-format configuration:**

Expand All @@ -30,16 +54,8 @@ MSR provides a lightweight, flexible framework for managing database migrations
- **🔌 Plugin Architecture** - Extensible loader system with optional peer dependencies keeps core lightweight
- **🎚️ Log Level Control** - Configurable log levels (`error`, `warn`, `info`, `debug`) to control output verbosity
- **💡 Better Error Messages** - Actionable error messages with installation instructions when formats aren't available
- **✨ 100% Test Coverage** - All statements, branches, functions, and lines covered

> [!IMPORTANT]
> **v0.6.0 contains breaking changes:** Type parameters are now required for all interfaces (e.g., `IDatabaseMigrationHandler<IDB>`) and the constructor signature changed to dependency injection pattern. Migration takes 10-30 minutes. See the [v0.5.x → v0.6.0 Migration Guide](https://migration-script-runner.github.io/msr-core/version-migration/v0.5-to-v0.6) for step-by-step instructions.

**[→ View configuration docs](https://migration-script-runner.github.io/msr-core/configuration/)**

---

## 📜 Previous Releases
**[→ View migration guide](https://migration-script-runner.github.io/msr-core/version-migration/v0.5-to-v0.6)**

### v0.5.0

Expand All @@ -56,11 +72,13 @@ MSR provides a lightweight, flexible framework for managing database migrations

## ✨ Features

- **🖥️ CLI Factory** - Built-in command-line interface with migrate, list, down, validate, and backup commands (v0.7.0)
- **🔌 Database Agnostic** - Works with any database (SQL, NoSQL, NewSQL) by implementing a simple interface
- **🛡️ Type Safe** - Full TypeScript support with complete type definitions
- **💾 Smart Rollback** - Multiple strategies: backup/restore, down() methods, both, or none
- **🔒 Transaction Control** - Configurable transaction modes with automatic retry and isolation levels (v0.5.0)
- **⚙️ Environment Variables** - Full 12-factor app configuration support with MSR_* variables (v0.5.0)
- **🗂️ .env File Support** - Load configuration from .env, .env.production, .env.local, etc. with priority control (v0.7.0)
- **📄 Multi-Format Config** - Support for JS, JSON, YAML, TOML, and XML configuration files (v0.6.0)
- **🎚️ Log Level Control** - Configurable verbosity (error, warn, info, debug) for different environments (v0.6.0)
- **📊 Migration Tracking** - Maintains execution history in your database with checksums
Expand Down Expand Up @@ -159,7 +177,7 @@ config.folder = './migrations';
config.logLevel = 'info'; // v0.6.0: 'error' | 'warn' | 'info' | 'debug'

const handler = new MyDatabaseHandler();
const executor = new MigrationScriptExecutor<IMyDatabase>({ handler }, config);
const executor = new MigrationScriptExecutor<IMyDatabase>({ handler, config });

// Library usage - returns structured result
const result = await executor.up();
Expand Down Expand Up @@ -261,14 +279,13 @@ See our [GitHub Issues](https://github.com/migration-script-runner/msr-core/issu

This project is licensed under the **MIT License with Commons Clause and Attribution Requirements**.

> [!NOTE]
> **Quick Summary:**
> - ✅ Free to use in your applications (including commercial)
> - ✅ Free to modify and contribute
> - ❌ Cannot sell MSR or database adapters as standalone products
> - 🔒 Database adapters require attribution
>
> See the [LICENSE](LICENSE) file or read the [License Documentation](https://migration-script-runner.github.io/msr-core/license) for detailed examples and FAQ.
**Quick Summary:**
- ✅ Free to use in your applications (including commercial)
- ✅ Free to modify and contribute
- ❌ Cannot sell MSR or database adapters as standalone products
- 🔒 Database adapters require attribution

See the [LICENSE](LICENSE) file or read the [License Documentation](https://migration-script-runner.github.io/msr-core/license) for detailed examples and FAQ.

---

Expand Down
2 changes: 1 addition & 1 deletion docs/about/origin-story.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ interface IDatabaseMigrationHandler {
}

// Plug in any database
const executor = new MigrationScriptExecutor({ handler }, config);
const executor = new MigrationScriptExecutor({ handler , config });
```

#### From JavaScript to TypeScript
Expand Down
Loading