hook-gen
v0.1.3
Published
A Typescript OpenApi CodeGen
Downloads
9
Maintainers
Keywords
Readme
HookGen
HookGen is a powerful tool designed to generate TypeScript types and code for Angular, React, and Next.js applications. It streamlines the development process by automating the creation of hooks and related types.
Features
- Generates TypeScript types for your project.
- Supports Angular, React, and Next.js frameworks.
- Simplifies the creation of hooks and other reusable code.
- Enhances code consistency and reduces boilerplate.
Installation
To install HookGen, you can use npm or yarn:
npm install hook-gen --save-dev
or
yarn add hook-gen --dev
Configuration
HookGen can be configured using a `.hookgenrc` file. Below is an example configuration:
{
"baseUrl": "openapi url",
"outDir": "./out",
"singleJson": true,
"hook": "ReactQuery", // SWR - ReactQuery - NG
"archive": true,
"fileTypes": {
"enums": "ts",
"types": "d.ts",
"client": "ts",
"api": "ts",
"hook": "ts"
},
"prettier": {
"singleQuote": false,
"useTabs": true,
"tabWidth": 4,
"printWidth": 200,
"parser": "typescript"
}
}
Usage
Add following line to your package.json file at script section:
{
"scripts": {
"hook-gen": "hook-gen",
"start": "***",
"lint": "***",
"test": "***"
}
}
After installing HookGen, you can use it in your project to generate TypeScript types and hooks.
Basic Command
npm run hook-gen
Options
"baseUrl": <url>
: Set base url of open api."hook": <library>
: Specify the library (SWR, ReactQuery, NG)."outDir": <directory>
: Specify the output directory for the generated files."archive": <boolean>
: download a copy from current version of swagger json."singleJson": <boolean>
: If it's 'true' base url must be end in .json file otherwise base url must be your openapi root url
Contributing
We welcome contributions to HookGen! If you have suggestions or bug reports, please open an issue or submit a pull request.
Running Locally
Clone the repository and install dependencies:
git clone https://github.com/MajidAlinejad/hookgen.git
cd hookgen
npm install
Run the project locally:
npm start
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
We appreciate the contributions of the open-source community and the developers who have helped make this project possible.
Contributors
Contact
For any inquiries or support, please contact Majid Alinejad at [email protected].
Happy coding!