Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
outputs:
version_changed: ${{ steps.version.outputs.changed }}
new_version: ${{ steps.version.outputs.version }}

steps:
- name: Checkout repository
Expand All @@ -68,6 +71,7 @@ jobs:
NPM_VERSION=$(npm view supabase-sql-dev-runner version 2>/dev/null || echo "0.0.0")
if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "Version changed from $NPM_VERSION to $PACKAGE_VERSION"
else
echo "changed=false" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -135,3 +139,33 @@ jobs:
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

create-release:
needs: [test, publish-npm]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.publish-npm.outputs.version_changed == 'true'
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create git tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ needs.publish-npm.outputs.new_version }}" -m "Release v${{ needs.publish-npm.outputs.new_version }}"
git push origin "v${{ needs.publish-npm.outputs.new_version }}"

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.publish-npm.outputs.new_version }}
name: v${{ needs.publish-npm.outputs.new_version }}
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 changes: 64 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,79 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.1] - 2025-12-11

### Changed

- Updated README documentation with clearer examples and setup instructions

## [1.0.0] - 2025-12-10

### Added

- Initial release
- Comprehensive test suite with 165 tests across 8 test files
- Test coverage for: CLI parsing, connection handling, logging, file scanning, SQL execution, and integration flows
- Comprehensive test suite with 352 tests across 13 test files
- Test coverage for: CLI parsing, connection handling, logging, file scanning, SQL execution, watcher, UI components, and integration flows

#### Core Features
- Sequential SQL file execution with alphabetical ordering
- Transaction safety with automatic rollback on errors
- Savepoint support for granular rollback per file
- Human confirmation prompt before execution (configurable)
- CLI tool with extensive options (`sql-runner`, `supabase-sql-runner`)
- Programmatic API with `SqlRunner` class and `runSqlScripts` convenience function
- Dual module support (ESM and CommonJS)
- Full TypeScript type definitions
- SSL enabled by default for secure connections
- Password masking in logs
- Verbose mode for detailed output
- Dry run mode to preview execution
- Watch mode (`--watch`) for development - re-runs on file changes with 30-second countdown
- Dry run mode (`--dry-run`) to preview execution without making changes
- File filtering with `--only` and `--skip` options
- Environment file loading (`.env` support)
- Execution logging to file
- Configuration file support (`.sqlrunnerrc`, `sql-runner.config.js`, etc.)

#### CLI Tool
- CLI commands: `sql-runner`, `supabase-sql-runner`, `npx sql-runner`
- Extensive CLI options for all features
- Colored output with symbols for better readability
- Progress display during execution
- Argument combination validation (warns about conflicting options)

#### Programmatic API
- `SqlRunner` class for full control
- `runSqlScripts` convenience function for simple usage
- Progress callbacks (`onBeforeFile`, `onAfterFile`, `onComplete`, `onError`)
- SQL NOTICE message handling via `onNotice` callback

#### Error Handling
- 10 specialized error detectors for common connection issues:
- DNS resolution errors (direct connection vs pooler)
- Connection refused/timeout
- Authentication failures
- SSL/TLS errors
- Prepared statement conflicts (transaction pooler)
- Database not found
- Too many connections
- Invalid URL format
- Helpful error messages with actionable suggestions
- PostgreSQL error details: code, line number, column, and visual pointer to error location
- Graceful handling of connection termination after rollback

#### Security
- SQL injection prevention with quoted identifiers for savepoints
- Password masking in logs
- SSL enabled by default for secure connections

#### Logging
- Execution logging to file (`./logs/sql-runner.log`)
- Separate error log (`./logs/sql-runner-error.log`)
- Graceful handling of log file write failures
- Verbose mode for detailed output

#### Build & Distribution
- Dual module support (ESM and CommonJS)
- Full TypeScript type definitions (`.d.ts` and `.d.cts`)
- Zero external dependencies except `pg` and `cosmiconfig`

#### UI System
- Custom terminal UI components (box, banner, table, spinner)
- Theming support with configurable colors
- Cross-platform symbol support (Unicode with ASCII fallbacks)

#### Developer Experience
- Environment file loading (`.env` support)
- CLAUDE.md documentation for AI assistants
- SOLID architecture throughout the codebase
Loading