|
| 1 | +# CreateCleanCodebase |
| 2 | + |
| 3 | +[](https://www.npmjs.com/package/create-clean-codebase) |
| 4 | +[](http://npm-stat.com/charts.html?package=create-clean-codebase) |
| 5 | +[](LICENSE) |
| 6 | + |
| 7 | +Create a clean and efficient starting point for any type of project! 🚀 |
| 8 | + |
| 9 | +**CreateCleanCodebase** simplifies the process of setting up new development projects by allowing you to select from a variety of well-structured templates. Whether you're starting a Next.js app, a Python script, or a Rust project, kickstart your development with a solid foundation. |
| 10 | + |
| 11 | +## Table of Contents |
| 12 | + |
| 13 | +- [Installation](#installation) |
| 14 | +- [Usage](#usage) |
| 15 | +- [Supported Templates](#supported-templates) |
| 16 | +- [Template Customization](#template-customization) |
| 17 | +- [Creating Custom Templates](#creating-custom-templates) |
| 18 | +- [Contributing](#contributing) |
| 19 | +- [License](#license) |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +You can use CreateCleanCodebase without installing it globally: |
| 24 | + |
| 25 | +```bash |
| 26 | +npx create-clean-codebase@latest |
| 27 | +``` |
| 28 | + |
| 29 | +Alternatively, install it globally via npm: |
| 30 | + |
| 31 | +```bash |
| 32 | +npm install -g create-clean-codebase |
| 33 | +``` |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +Run the following command to start creating your project: |
| 38 | + |
| 39 | +```bash |
| 40 | +npx create-clean-codebase |
| 41 | +``` |
| 42 | + |
| 43 | +Follow the interactive prompts to select your desired template and customize it according to your needs. |
| 44 | + |
| 45 | +### Example |
| 46 | + |
| 47 | +```bash |
| 48 | +$ npx create-clean-codebase |
| 49 | + |
| 50 | +Welcome to CreateCleanCodebase! |
| 51 | + |
| 52 | +Select a template: |
| 53 | +- NextJS |
| 54 | + - Basic |
| 55 | + - Supabase |
| 56 | +- Python |
| 57 | + - Flask |
| 58 | + - Django |
| 59 | +- Rust |
| 60 | + - CLI Tool |
| 61 | + - WebAssembly |
| 62 | + |
| 63 | +What is the name of your project? my-nextjs-app |
| 64 | + |
| 65 | +Creating your project... |
| 66 | + |
| 67 | +Success! Your project 'my-nextjs-app' has been created. |
| 68 | +``` |
| 69 | + |
| 70 | +## Supported Templates |
| 71 | + |
| 72 | +The following templates are currently available: |
| 73 | + |
| 74 | +### NextJS |
| 75 | + |
| 76 | +- **Basic**: A basic Next.js project with TypeScript support. |
| 77 | +- **Supabase**: Next.js with Supabase integration. *(Work in Progress)* |
| 78 | + |
| 79 | +*(More templates coming soon!)* |
| 80 | + |
| 81 | +## Template Customization |
| 82 | + |
| 83 | +Some templates support additional customization through user input. For example, when selecting the **Basic** NextJS template, you might be prompted to provide the project name: |
| 84 | + |
| 85 | +```bash |
| 86 | +What is the name of your project? my-project |
| 87 | +``` |
| 88 | + |
| 89 | +Templates can include an `init.js` script that runs after the template files are copied. This script can modify files based on your input, allowing for dynamic customization of the generated codebase. |
| 90 | + |
| 91 | +## Creating Custom Templates |
| 92 | + |
| 93 | +You can define custom templates for your own use or to contribute to the project. Templates are defined in the `templateMappings.js` file and their corresponding files are stored in the `codebase` directory. |
| 94 | + |
| 95 | +Here's an example of how templates are mapped: |
| 96 | + |
| 97 | +```javascript |
| 98 | +// templateMappings.js |
| 99 | + |
| 100 | +const templateMappings = { |
| 101 | + templates: { |
| 102 | + NextJS: { |
| 103 | + Basic: { |
| 104 | + template: true, |
| 105 | + args: [ |
| 106 | + { |
| 107 | + type: "input", |
| 108 | + name: "project-name", |
| 109 | + default: "my-project", |
| 110 | + message: "What is the name of your project?" |
| 111 | + }, |
| 112 | + ], |
| 113 | + path: "templates/nextjs/typescript/basic/", |
| 114 | + }, |
| 115 | + Supabase: { |
| 116 | + template: true, |
| 117 | + path: "templates/nextjs/typescript/supabase/", |
| 118 | + }, |
| 119 | + }, |
| 120 | + }, |
| 121 | +}; |
| 122 | + |
| 123 | +export default templateMappings; |
| 124 | +``` |
| 125 | + |
| 126 | +### Adding a New Template |
| 127 | + |
| 128 | +1. **Create the Template Files**: Add your template files to the appropriate directory within `templates/<your_template_path>/codebase`. |
| 129 | + |
| 130 | +2. **Update `templateMappings.js`**: Add your new template to the mappings, specifying any arguments and the path to the template files. |
| 131 | + |
| 132 | +3. **(Optional) Add `init.js`**: If your template requires post-processing, include an `init.js` script in the template directory. This script receives the `rootPath` of the created codebase and any user arguments as an object. |
| 133 | + |
| 134 | +## Contributing |
| 135 | + |
| 136 | +Contributions are welcome! If you have ideas for new templates or improvements, feel free to open an issue or submit a pull request. |
| 137 | + |
| 138 | +1. Fork the repository. |
| 139 | +2. Create your feature branch: `git checkout -b feature/YourFeature` |
| 140 | +3. Commit your changes: `git commit -am 'feature: Add your feature'` |
| 141 | +4. Push to the branch: `git push origin feature/YourFeature` |
| 142 | +5. Open a pull request. |
| 143 | + |
| 144 | +## License |
| 145 | + |
| 146 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +*Happy Coding!* |
0 commit comments