generate-c2i
v1.0.5
Published
generate class implement interface
Downloads
7
Maintainers
Readme
c2i
Class Implementing Interface
This project is an NPM module that simplifies the process of generating classes that implement interfaces in project. It automates the generation of class files based on existing interface files and helps maintain consistency between the interface and class definitions.
Installation and Usage
To install and run the generate-c2i package, follow these steps:
Install the generate-c2i package using npm
npm i generate-c2i
Run the command in the terminal
npx generate-c2i <interfaceFolderPath> <classesFolderPath> <isConstructor?>
Arguments
The generate-c2i command accepts the following arguments:
- InterfaceFolderPath: The path of the folder containing interface files. This folder should exist in your Angular project's directory structure.
- ClassesFolderPath: The path of the folder where the generated class files will be saved. This folder will be created if it doesn't exist.
- Optional Boolean that generates the class files with constructor; default value is false
Output
The generate-c2i command will generate class files in the specified classesFolderPath based on the interfaces found in the interfaceFolderPath. The generated classes will implement the corresponding interfaces and maintain the same file names with a "Class" suffix.
Example
Here's an example of how to use the generate-c2i package:
npx generate-c2i ./src/app/shared/interfaces ./src/app/shared/classes true
This command will generate class files in the ./src/app/shared/classes folder based on the interfaces found in the ./src/app/shared/interfaces folder. The import statements in the generated classes with custom property.
Make sure to provide the correct paths to the interface and classes folders in your project for successful generation of class files.
Note
Please ensure that you have a backup of your code before running the c2i command, as it will modify your project by generating new class files based on the existing interfaces.