angularjs-template-patterns
Mine AngularJS template patterns (ng-repeat, filters, ng-include, one-time bindings); read-only metrics
# angularjs-template-patterns
Read-only mining codemod that scans AngularJS HTML templates and emits a `template_pattern`
metric describing legacy template patterns relevant to an Angular migration assessment. It
never modifies files — every match is reported via `codemod:metrics` and the transform always
returns `null`.
## What it detects
| Pattern | Automation | Risk |
| -------------------------------------------------------------------------------------------- | ---------- | ------ |
| `ng-repeat` (incl. `ng-repeat-start`/`-end`) | full | low |
| `ng-if` | full | low |
| `ng-switch` / `ng-switch-when` / `ng-switch-default` | full | low |
| `ng-include` with a static template URL (attribute or `<ng-include>` element) | partial | medium |
| `filter` — `{{ expr \| someFilter }}` interpolation | partial | medium |
| `one-time-binding` — `::` inside `{{ }}` or in a bare `ng-*` directive expression | full | low |
| `dynamic-template` — `ng-include` whose template URL is a computed expression, not a literal | manual | high |
## Metric cardinality
Each finding increments `template_pattern` with:
```ts
{
file: "app/invoices/invoice-list.html",
line: "12",
snippet: "ng-repeat=\"invoice in invoices\"",
pattern: "ng-repeat" | "ng-if" | "ng-switch" | "ng-include" | "filter" | "one-time-binding" | "dynamic-template",
migration_category: "template",
risk: "low" | "medium" | "high",
automation: "full" | "partial" | "manual",
effort_points: "1" | "2" | "3" | "8",
recommended_phase: "phase-3" | "phase-4",
}
```
## Installation
```bash
# Install from registry
codemod run angularjs-template-patterns
# Or run locally
codemod run -w workflow.yaml
```
## Development
```bash
# Test the transformation
pnpm test
# Validate the workflow
codemod workflow validate -w workflow.yaml
# Publish to registry
codemod login
codemod publish
```
## License
MIT