au-rogue
Version:
Conservative Aurelia 1 to 2 codemods. Changes only what is safe, reports everything.
152 lines (112 loc) ⢠4.65 kB
Markdown
# au-rogue
Conservative codemods that migrate Aurelia 1 projects toward Aurelia 2. It edits only the parts that are safe to transform automatically, then writes a comprehensive report for everything else.
**š”ļø Conservative approach**: Only transforms what's guaranteed safe, reports everything else
**š Comprehensive reporting**: Detailed analysis with migration guidance
**š Easy to use**: Simple CLI with dry-run mode for safe exploration
## Features
### Automatic Transformations
- ā
Removes `@autoinject` decorators and converts to `resolve()` patterns
- ā
Removes `@computedFrom` decorators (keeps getter methods)
- ā
Strips `PLATFORM.moduleName()` calls
- ā
Converts template `.delegate` to `.trigger`
- ā
Updates various template attributes and elements
### Analysis & Guidance
- š Detects router patterns needing manual migration
- š Identifies lifecycle method changes required
- š Flags `NavigationInstruction` usage
- š Analyzes event handlers for `preventDefault` needs
- š Provides bootstrap migration examples
- š Suggests `@aurelia/compat-v1` when beneficial
### Reporting
- š Generates detailed Markdown and JSON reports
- š Categorizes changes: edits, warnings, notes
- š Shows before/after code diffs
- š Provides specific migration guidance
## Installation
```bash
# Install globally
npm install -g au-rogue
# Or run without installing
npx au-rogue --help
```
## Usage
### Quick Start
```bash
# Navigate to your Aurelia 1 project root
cd my-aurelia-app
# Run in dry mode first (recommended)
npx au-rogue --dry
# Review the generated reports:
# - au-rogue.report.md (human-readable)
# - au-rogue.report.json (machine-readable)
# Apply the transformations
npx au-rogue
```
### Command Line Options
```bash
# Show help
npx au-rogue --help
# Dry run (preview changes without modifying files)
npx au-rogue --dry
# Custom file patterns
npx au-rogue --sources "src/**/*.ts" --templates "src/**/*.html"
# Include compatibility suggestions
npx au-rogue --compat
# Custom report output directory
npx au-rogue --report-dir ./migration-reports
```
### Output Files
The tool generates two report files:
- **au-rogue.report.md** - Human-readable migration report
- **au-rogue.report.json** - Machine-readable data for tooling integration
## Example Output
Running au-rogue on an Aurelia 1 project provides detailed feedback:
```
š Migration Summary
Edits: 23, Adds: 0, Removes: 5, Warnings: 12, Notes: 18
ā
Automatic transformations:
⢠Removed @autoinject decorators from 8 classes
⢠Removed @computedFrom decorators from 5 getters
⢠Removed 12 PLATFORM.moduleName() calls
⢠Updated .delegate to .trigger in 3 templates
ā ļø Manual review needed:
⢠Router configuration in App class needs migration
⢠4 NavigationInstruction usages detected
⢠Event handlers may need preventDefault modifiers
š” Migration guidance provided:
⢠Bootstrap migration example for main.ts
⢠Router migration strategies
⢠@aurelia/compat-v1 compatibility suggestions
```
## What Gets Transformed
### ā
Safe Automatic Changes
- **Dependency Injection**: `@autoinject` ā `resolve()` patterns
- **Computed Properties**: Remove `@computedFrom` decorators
- **Platform Modules**: Remove `PLATFORM.moduleName()` wrappers
- **Templates**: `.delegate` ā `.trigger`, attribute updates
- **Imports**: Clean up unused imports
### ā ļø Flagged for Manual Review
- **Router patterns**: `configureRouter()`, `NavigationInstruction`
- **Complex DI**: Interface types, non-runtime types
- **Lifecycle methods**: v1 hooks needing v2 equivalents
- **Event handlers**: Cases needing `preventDefault`
- **Bootstrap**: `main.ts` configuration migration
### š” Guidance Provided
- Complete bootstrap migration examples
- Router migration strategies (`@aurelia/router` vs `@aurelia/router-lite`)
- Compatibility package recommendations
- Lifecycle method mapping
- Best practices for manual migrations
## Safety & Reliability
- **Conservative approach**: Only transforms guaranteed-safe patterns
- **Comprehensive testing**: 107+ test cases covering edge cases
- **Idempotent**: Running multiple times is safe
- **Dry-run mode**: Preview all changes before applying
- **Detailed reporting**: Full transparency of all changes and decisions
## Contributing
See our [examples directory](./examples) for realistic test cases. The tool is designed to be:
- **Extensible**: Easy to add new transformation passes
- **Well-tested**: Every transformation has comprehensive test coverage
- **Documented**: Clear examples and explanations
## License
MIT