UNPKG

boiler-magic

Version:

A boilerplate generator for Node.js apps

217 lines (145 loc) 4.24 kB
# 🚀 Boiler CLI A simple and developer-friendly command-line tool to quickly generate common files for your node express project. The goal is **easy-to-remember and readable commands**. --- ## 📦 Installation ```bash npm i boiler-magic ``` --- ## ⚡ Usage All commands follow this pattern: ``` boiler create:<resource> <Name> [options] ``` Where: * `<resource>` = what you want to generate (controller, model, route, etc.) * `<Name>` = the name of the file/class * `[options]` = additional flags like `--force` --- ## 🛠️ Commands ### 1. Create Controller ```bash boiler create:controller HomeController # or with force option to overwrite existing files boiler create:controller AuthController --force ``` * Generates a new controller in your `controllers/` folder. * Use `--force` flag to overwrite existing files. * Example output: `controllers/HomeController.js` --- ### 2. Create Model ```bash boiler create:model User # or with force option boiler create:model Product --force ``` * Generates a new model in your `models/` folder. * Use `--force` flag to overwrite existing files. * Example output: `models/User.js` --- ### 3. Create Route ```bash boiler create:route UserRoute # or with force option boiler create:route AuthRoute --force ``` * Generates a new route file in your `routes/` folder. * Use `--force` flag to overwrite existing files. * Example output: `routes/UserRoute.js` --- ### 4. Create Middleware ```bash boiler create:middleware AuthMiddleware # or with force option boiler create:middleware LogMiddleware --force ``` * Generates middleware logic for request handling. * Use `--force` flag to overwrite existing files. * Example output: `middleware/AuthMiddleware.js` --- ### 5. Create Service ```bash boiler create:service PaymentService # or with force option boiler create:service EmailService --force ``` * Generates a service file (useful for business logic). * Use `--force` flag to overwrite existing files. * Example output: `services/PaymentService.js` --- ### 6. Create Helper ```bash boiler create:helper StringHelper # or with force option boiler create:helper DateHelper --force ``` * Generates a utility/helper file. * Use `--force` flag to overwrite existing files. * Example output: `helpers/StringHelper.js` --- ### 7. Create Config ```bash boiler create:config Database # or with force option boiler create:config App --force ``` * Generates a config file inside `config/`. * Use `--force` flag to overwrite existing files. * Example output: `config/Database.js` --- ### 8. Create Migration ```bash boiler create:migration CreateUsersTable # or with force option boiler create:migration AddUserColumns --force ``` * Generates a database migration file. * Use `--force` flag to overwrite existing files. * Example output: `migrations/2025_create_users_table.js` --- ### 9. Create Seeder ```bash boiler create:seeder UserSeeder # or with force option boiler create:seeder ProductSeeder --force ``` * Generates a seeder file for populating the database. * Use `--force` flag to overwrite existing files. * Example output: `seeders/UserSeeder.js` --- ### 10. Create Test ```bash boiler create:test UserTest # or with force option boiler create:test AuthTest --force ``` * Generates a test file inside `tests/`. * Use `--force` flag to overwrite existing files. * Example output: `tests/UserTest.js` --- ## 🎯 Example Workflow ```bash boiler create:controller AuthController --force boiler create:model User --force boiler create:route AuthRoute --force boiler create:middleware AuthMiddleware --force ``` This will set up authentication boilerplate in seconds, overwriting any existing files. --- ## ⚙️ Options ### Force Overwrite (`--force`) Use the `--force` flag to overwrite existing files if they already exist. If the file doesn't exist, it will be created as normal. ```bash boiler create:controller ExistingController --force ``` --- 👉 With this CLI, you can keep commands **easy, short, and consistent**. --- ## 📄 License MIT License - feel free to use this tool in your projects! --- ## 🤝 Contributing Contributions are welcome! Please feel free to submit a Pull Request. --- # boiler-magic