Skip to content

Latest commit

 

History

History

README.md

@wroud/di-tools-codemod

Welcome to @wroud/di-tools-codemod, a tool designed to help you migrate your codebase from Inversify to @wroud/di effortlessly. This codemod automates the transformation process, ensuring a smooth transition to @wroud/di.

Features

  • Automated Migration: Converts your existing Inversify code to use @wroud/di.
  • Configuration Support: Allows customization through a di-tools-codemod.json configuration file.

Installation

npm

npm install @wroud/di-tools-codemod

Install via yarn

yarn add @wroud/di-tools-codemod

Usage

To use the codemod, run the following command in your terminal:

yarn di-tools-codemod ./packages/*/src/**/*.{ts,tsx}

Configuration

You can provide a di-tools-codemod.json configuration file in the same folder where you run the codemod to customize the migration process.

{
  "transformer": {
    "esm": false,
    "copyright": ""
  },
  "supportedPackages": [
    {
      "name": "inversify",
      "replace": "@wroud/di",
      "injectableDecorator": "injectable",
      "injectDecorator": "inject",
      "multiInjectDecorator": "multiInject"
    }
  ],
  "generateModule": true
}

Example

Before

import { injectable } from "inversify";

@injectable()
export class NotificationService {
  constructor(
    private readonly a: A,
    private readonly b: B,
    private readonly c: C,
  ) {}
}

After

import { injectable } from "@wroud/di";

@injectable(() => [A, B, C])
export class NotificationService {
  constructor(
    private readonly a: A,
    private readonly b: B,
    private readonly c: C,
  ) {}
}

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

License

This project is licensed under the MIT License. See the LICENSE file for details.