codemod_recipe 0.1.0
codemod_recipe: ^0.1.0 copied to clipboard
Reusable recipe primitives for deterministic Dart codemods and file scaffolds.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased] #
Added #
- Added
dart runexecutables for all examples to improve UX. - Extended test suite with edge-case tests for template rendering (empty context, special characters, Unicode identifiers).
- Enhanced documentation with inline code examples in docstrings.
0.1.0 - 2026-06-01 #
Added #
- Initial release of
codemod_recipe. CodemodRecipefor declaring arguments, ordered operations, and post-execution actions.CodemodRunnerfor CLI parsing, dry-run/apply workflows, and error handling.CodemodContextfor storing raw argument values and providing generic case helpers (snake, camel, pascal).CodemodTemplatefor rendering inline or file-backed templates with Mustache-style placeholders and casing filters.CodeEditorfor AST-guided Dart source modifications including adding methods, fields, and constructor parameters.CodemodOperationabstractions:EditDartFileOperationfor editing existing Dart files with transforms.CreateFileOperationfor scaffolding new files from templates.
CodeTransforminterface for deterministic source-to-patches operations.- Generic transforms:
AddImportTransformfor adding import directives.AddMethodTransformfor adding methods to classes.AddFieldTransformfor adding fields to classes.AddConstructorParamTransformfor adding constructor parameters.AddClassAnnotationTransformfor adding annotations to classes.TemplateTransformfor inserting rendered snippets at custom offsets.
- Post-execution actions:
DartFormatPostExecutionfor runningdart formaton changed files.BuildRunnerPostExecutionfor runningbuild_runnerafter changes.ProcessPostExecutionfor running custom processes.
FileChangeabstractions:PatchFileChangefor patch-based edits to existing files.CreateFileChangefor full-content file creation or overwriting.
- Patch helper utilities including
applyPatches,validateNonOverlappingPatches, and AST-based patch builders. - Comprehensive test coverage for all core components.