Aalexbit-codemod

angularjs-service-inventory

Mine AngularJS services, factories, providers, constants, values; read-only metrics

miningmetricsangularjscode-miningmigration-assessmentangularjs_service
PRO
0 executions
Use dashboard

Run locally

npx codemod angularjs-service-inventory

This is a Pro codemod. Preview changes and insights for free, no login or code sharing required. Applying changes and accessing insights requires a paid plan and sign in.Learn more

angularjs-service-inventory

Read-only mining codemod that inventories AngularJS .service(), .factory(), .provider(), .constant(), and .value() registrations for migration assessment. Each finding is classified with a risk level, an automation confidence, an effort-point estimate, and a recommended migration phase. No files are written to the target repo.

What it does

Scans .js/.ts/.jsx/.tsx files for AngularJS DI-container registrations shaped like <module-or-provider>.<method>('Name', ...):

RegistrationAngular equivalentAutomationRiskEffortPhase
.constant(name, value)Plain TS constant / InjectionTokenfulllow1phase-1
.value(name, value)Plain TS constant / InjectionTokenfulllow1phase-1
.service(name, ctor)@Injectable() classfulllow2phase-2
.factory(name, fn)@Injectable() class (needs restructuring from a returned object literal to a class)partialmedium3phase-2
.provider(name, fn)Factory provider / InjectionToken (needs re-modeling the $get pattern)partialhigh5phase-2

The service/constant/value name is only recorded when it is a string literal; dynamically computed names (e.g. .service(dynamicName, ...)) are skipped since they can't be resolved statically. Calls with no arguments are also skipped safely.

Heuristic limitation: detection is name-based (matches any call whose callee property is service/factory/provider/constant/value), so it does not verify that the receiver is actually an AngularJS module or provider object. In practice this is rarely an issue for AngularJS codebases, but unrelated APIs that happen to share these method names could produce false positives.

Metrics

MetricCardinalities
angularjs_servicefile, line, snippet, service_name, registration_type (service|factory|provider|constant|value), migration_category (service), risk, automation, effort_points, recommended_phase

Installation

bash

Usage

bash

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.