From 8491f8d2bb4548afb2da0c52d301e9ad4ff3f821 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 23 Apr 2024 16:27:37 +0200 Subject: [PATCH] chore: Updated README --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 090fd57..55dc8bb 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,68 @@ # ember-codemod-remove-inject-as-service -_Codemod to [PROVIDE A SHORT DESCRIPTION.]_ +_Codemod to remove `inject as service`_1 + +1. [Features](#features) +1. [Usage](#usage) + - [Arguments](#arguments) + - [Limitations](#limitations) +1. [Compatibility](#compatibility) +1. [Contributing](#contributing) +1. [License](#license) + +1. `@ember/service` has provided `service` since [Ember 4.1](https://blog.emberjs.com/ember-4-1-released/). `inject`, which became an alias to `service`, is [planned to be deprecated in v6](https://rfcs.emberjs.com/id/1001-deprecate-named-inject). + + +## Features + +The codemod helps you standardize how you inject services: + +- Replace `inject` with `service`1 +- Replace `!` with `declare` in TS files2 +- Remove `private` and `readonly` keywords in TS files2 + +It preserves your code whenever possible. + +1. Replaces `inject as ...` and `service as ...`, too. + +2. Matches [the style shown in the Ember Guides](https://guides.emberjs.com/v5.8.0/typescript/core-concepts/services/#toc_using-services). ## Usage +Step 1. Quickly migrate. + +```sh +cd +npx ember-codemod-remove-inject-as-service +``` + +Step 2. Fix formatting issues. + +- Optional: Do a find-and-replace-all, if you want to place `@service()` and `declare` on the same line when possible. + + - Find: `@service\((.+)\)(\n|\s)+declare` + - Replace: `@service($1) declare` + +- Optional: Do a find-and-replace-all, if you want to place `@service` and `declare` on the same line when possible. + + - Find: `@service(\n|\s)+declare` + - Replace: `@service declare` + +- Run `lint:js:fix` (i.e. autofix from `eslint` and `prettier`). + + + ### Arguments -[PROVIDE REQUIRED AND OPTIONAL ARGUMENTS.] +You must pass `--type` to indicate what type of project you have. + +```sh +npx ember-codemod-remove-inject-as-service --type app +npx ember-codemod-remove-inject-as-service --type v1-addon +npx ember-codemod-remove-inject-as-service --type v2-addon +```