mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
Add AST-based migration framework for converting TypeScript tests to JSON: New files: - scripts/migrate-tests/converter.ts (350+ lines) * AST parser for .test.ts files * Extracts describe/it/expect blocks * Maps 30+ Jest/Vitest matchers to JSON types * Returns structured ConversionResult - scripts/migrate-tests/migrator.ts (250+ lines) * Batch discovery and migration orchestrator * Glob-based .test.ts file discovery * Automatic output directory creation * Dry-run mode for safe preview * Pretty-printed progress reporting * Package name mapping (frontends → packages) - scripts/migrate-tests/validator.ts (300+ lines) * JSON schema validation using AJV * Semantic checks (unique IDs, assertions) * Unused import warnings * Directory-wide validation support * Structured ValidationResult output - scripts/migrate-tests/index.ts * Unified export module - scripts/migrate-tests/README.md * Comprehensive usage guide * Conversion process documentation * Matcher mapping reference * Workflow recommendations * Troubleshooting guide Features: * 80/20 conversion (handles ~80% of tests cleanly) * Fallback for complex tests requiring manual adjustment * Dry-run mode to preview changes * Verbose logging for troubleshooting * Validates against tests_schema.json Matcher Support: * Basic: equals, deepEquals, notEquals, truthy, falsy * Numeric: greaterThan, lessThan, greaterThanOrEqual, lessThanOrEqual * Type: null, notNull, undefined, notUndefined, instanceOf * Collection: contains, matches, hasProperty, hasLength * DOM: toBeVisible, toBeInTheDocument, toHaveTextContent, toHaveAttribute, toHaveClass, toBeDisabled, toBeEnabled, toHaveValue * Control: throws, notThrows, custom This completes Phase 3 Task 4 of the JSON interpreter everywhere implementation. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Scripts Directory
This directory contains utility scripts for the MetaBuilder project.
Scripts
triage-duplicate-issues.sh
Purpose: Automatically finds and closes duplicate GitHub issues while keeping the most recent one open.
Features:
- 🔍 Dynamically searches for duplicate issues using GitHub API
- 📅 Sorts issues by creation date (newest first)
- ✅ Keeps the most recent issue open as the canonical tracking issue
- 🔒 Closes all older duplicates with explanatory comments
- ⚙️ Configurable search pattern via environment variables
- 🛡️ Error handling and rate limiting protection
Usage:
# Basic usage (uses default search pattern)
export GITHUB_TOKEN="ghp_your_github_token_here"
./scripts/triage-duplicate-issues.sh
# With custom search pattern
export GITHUB_TOKEN="ghp_your_github_token_here"
export SEARCH_TITLE="Your custom issue title"
./scripts/triage-duplicate-issues.sh
# Show help
./scripts/triage-duplicate-issues.sh --help
Environment Variables:
GITHUB_TOKEN(required): GitHub personal access token withrepoaccessSEARCH_TITLE(optional): Issue title pattern to search for- Default:
"🚨 Production Deployment Failed - Rollback Required"
- Default:
How it works:
- Searches GitHub API for all open issues matching the title pattern
- Sorts issues by creation date (newest first)
- Identifies the most recent issue to keep open
- Adds an explanatory comment to each older duplicate
- Closes older duplicates with
state_reason: "not_planned"
Example output:
🔍 Searching for issues with title: "🚨 Production Deployment Failed - Rollback Required"
📊 Found 5 duplicate issues
📌 Most recent issue: #124 (created: 2025-12-27T10:30:00Z)
🔧 Starting bulk issue triage...
📋 Planning to close 4 duplicate issues
📌 Keeping issue #124 open (most recent)
📝 Adding comment to issue #122...
✅ Added comment to issue #122
🔒 Closing issue #122...
✅ Closed issue #122
...
✨ Triage complete!
test-triage-logic.sh
Purpose: Comprehensive test suite for the triage script logic.
Features:
- ✅ Tests multiple duplicate issues handling
- ✅ Tests two duplicate issues
- ✅ Tests single issue (should not close)
- ✅ Tests empty input handling
- ✅ Validates date sorting
- ✅ Tests jq parsing and formatting
Usage:
./scripts/test-triage-logic.sh
Example output:
🧪 Testing triage-duplicate-issues.sh logic
=============================================
Test 1: Multiple duplicate issues (should close all except most recent)
-----------------------------------------------------------------------
Total issues found: 5
Most recent issue: #124
Issues to close: 122 121 119 117
Count to close: 4
✅ PASS: Correctly identified most recent and 4 issues to close
...
=============================================
✅ All tests passed!
generate_mod.py
Purpose: Python script for generating module files.
Development Guidelines
Adding New Scripts
When adding new scripts to this directory:
- Use descriptive names that clearly indicate the script's purpose
- Add executable permissions:
chmod +x script-name.sh - Include usage documentation in the script header
- Add help flag support (
--helpor-h) - Handle errors gracefully with proper exit codes
- Update this README with script documentation
Testing Scripts
- Run
shellcheckon bash scripts before committing - Create test scripts for complex logic
- Validate with sample data before using in production
- Test edge cases (empty input, single item, etc.)
Best Practices
- ✅ Use
set -eto exit on errors - ✅ Validate required environment variables
- ✅ Add descriptive comments
- ✅ Use meaningful variable names
- ✅ Include usage examples
- ✅ Handle rate limiting for API calls
- ✅ Provide clear error messages