angularjs-module-inventory
Mine AngularJS modules, dependencies, root/shared modules; read-only metrics
# angularjs-module-inventory
Read-only mining codemod that inventories AngularJS `angular.module(...)` usage
for migration assessment. It does not modify any source files — it only emits
metrics that can be aggregated into a migration report.
## What it mines
For every `angular.module('name', [...])` definition and `angular.module('name')`
getter, the codemod emits one `angularjs_module` metric entry classifying the
module as a **root** module (application bootstrap), a **shared** module (common
naming or many dependents), or a regular feature module.
Heuristics used (single-file, AST-only — no cross-file resolution):
- **`kind`**: `definition` when the call passes a second argument (the
dependency array), `getter` when it only passes the module name.
- **`is_root`**: `true` when the call is a `definition` with at least one
dependency and the module name matches a common app-root name (`app`,
`myApp`, `application`, `main`).
- **`is_shared`**: `true` when the module name contains a common shared
segment (`shared`, `common`, `core`, `ui`, `utils`/`util`, e.g. `app.core`),
**or** the module name appears as a dependency in 2+ other `angular.module()`
calls within the same file.
- **`risk` / `automation` / `effort_points` / `recommended_phase`**: derived
from the above — root and shared modules are riskier, need more manual
review, and are recommended earlier in the rollout (`phase-1` / `phase-2`),
while regular feature modules are fully automatable and scheduled for
`phase-3`.
## Metric: `angularjs_module`
| Cardinality | Description |
| -------------------- | ----------------------------------------------------- |
| `file` | Relative path of the source file |
| `line` | 1-based line number of the `angular.module(...)` call |
| `snippet` | Trimmed source snippet of the call (max 160 chars) |
| `module_name` | The module name string, e.g. `app.billing` |
| `kind` | `definition` \| `getter` |
| `dependency_count` | Number of string dependencies in the deps array |
| `is_root` | `true` \| `false` |
| `is_shared` | `true` \| `false` |
| `migration_category` | Always `module` |
| `risk` | `low` \| `medium` \| `high` |
| `automation` | `full` \| `partial` \| `manual` |
| `effort_points` | `1` \| `2` \| `3` \| `5` \| `8` \| `13` |
| `recommended_phase` | `phase-1` .. `phase-5` |
## Installation
```bash
# Install from registry
codemod run angularjs-module-inventory
# Or run locally
codemod run -w workflow.yaml
```
## Development
```bash
# Test the transformation
pnpm test
# Check types
pnpm run check-types
# Validate the workflow
codemod workflow validate -w workflow.yaml
# Publish to registry
codemod login
codemod publish
```
## License
MIT