Registry
Aalexbit-codemod avatar

angularjs-service-inventory

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

alexbit-codemod0 executions

  • mining
  • metrics
  • angularjs
  • code-mining
  • migration-assessment
  • angularjs_service

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
# Install from registry
codemod run angularjs-service-inventory

# Or run locally
codemod run -w workflow.yaml

Usage

bash
npx codemod@latest workflow run -w codemods/angularjs-to-angular/angularjs-service-inventory \
  -t /path/to/angularjs/repo \
  --allow-dirty --no-interactive

Development

bash
# Test the transformation
pnpm test

# Check types
pnpm check-types

# 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.