Read-only mining codemod that computes a weighted migration-complexity score for every
AngularJS .component() and .directive() registration in a file. No files are written to the
target repo.
Service DI count (controller or directive factory params, excluding $scope/$element/$attrs/$transclude)
+1 each
For directives, the analysis runs over the whole factory function (the function passed to .directive(name, factory)), since link/compile closures are typically returned from inside
it. For components, it runs over the resolved controller function (inline, a named controller: X reference, or a controller registered elsewhere via .controller('X', ...)).
score_breakdown is a short key=value,... string (e.g. bindings=2,isolateScope=true,link=false,compile=false,template=3,watch=1,scopeRefs=5,dom=0,di=3)
so you can see which signals drove the score without re-parsing the file.
Limitations
File-local: controller/directive-factory resolution only looks within the same file. A controller: 'NamedCtrl' string that resolves to a controller registered in a different file
will not be found, and DI/$watch/DOM usage inside it will not be counted.
templateUrl complexity is a fixed proxy score (the referenced template file's contents are
not read), since this is a single-file AST miner.
Weights are heuristic and tuned for relative ranking (trivial vs. rewrite), not an exact
time/cost estimate.
# Test the transformation
pnpm test
# Validate the workflow
codemod workflow validate -w workflow.yaml
# Publish to registry
codemod login
codemod publish
License
MIT
Ready to evolve your codebase?
Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.