@affectively/devops-scripts
v1.0.1
Published
DevOps automation scripts for monorepos - changed-file testing, type-checking, accessibility auditing, and more.
Maintainers
Readme
@affectively/devops-scripts
DevOps automation scripts for monorepos - changed-file testing, type-checking, accessibility auditing, and more.
Features
- Changed-File Testing - Run tests only for files changed since a base branch
- Changed-File Type-Checking - Type-check only changed files for faster CI
- Accessibility Auditing - Automated WCAG compliance checking
- Monorepo Aware - Works with Nx, Turborepo, and plain npm workspaces
Installation
npm install -D @affectively/devops-scripts
# or
yarn add -D @affectively/devops-scripts
# or
bun add -D @affectively/devops-scriptsQuick Start
Run Changed Tests
Run tests only for files changed against your base branch:
npx run-changed-tests
# or specify a base ref
npx run-changed-tests origin/mainRun Changed Type-Check
Type-check only changed files:
npx run-changed-typecheck
# or specify a base ref
npx run-changed-typecheck origin/developmentUsage in package.json
Add these to your package.json scripts:
{
"scripts": {
"test:changed": "run-changed-tests",
"type-check:changed": "run-changed-typecheck"
}
}How It Works
Changed File Detection
The scripts detect changed files using:
git diff --name-only <baseRef>...HEAD(committed changes)git status --porcelain(staged/unstaged changes)
Nx Integration
When Nx is detected, the scripts use nx affected for optimal performance:
nx affected -t test --base <baseRef> --parallel=6Fallback Mode
Without Nx, the scripts filter test files directly:
*.test.ts,*.test.tsx- Tests in
__tests__/directories adjacent to changed files
API
You can also use these as library functions:
import {
getChangedFiles,
filterTestFiles,
runChangedTests
} from '@affectively/devops-scripts';
// Get files changed since main
const files = getChangedFiles('origin/main');
// Filter to just test files
const tests = filterTestFiles(files);
// Run the full workflow
await runChangedTests({ baseRef: 'origin/main' });Configuration
Environment Variables
# Override the default base branch
DEFAULT_BASE_REF=origin/development
# Parallel test execution (Nx)
NX_PARALLEL=6Why Use Changed-File Commands?
| Approach | 1000-file monorepo | 50 changed files | |----------|-------------------|------------------| | Full test suite | ~10 minutes | ~10 minutes | | Changed-file tests | ~2 minutes | ~30 seconds |
Benefits:
- 10-100x faster feedback during development
- Reduced CI costs
- Faster pre-commit/pre-push hooks
License
MIT License - see LICENSE for details.
Made with ️ by AFFECTIVELY
