create-clean-codebase
v1.0.0
Published
NPM package to easily create starter codebases, with a clean, maintainable and easy to understand starting point.
Downloads
67
Maintainers
Readme
CreateCleanCodebase
Create a clean and efficient starting point for any type of project! 🚀
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.
Table of Contents
- Installation
- Usage
- Supported Templates
- Template Customization
- Creating Custom Templates
- Contributing
- License
Installation
You can use CreateCleanCodebase without installing it globally:
npx create-clean-codebase@latest
Alternatively, install it globally via npm:
npm install -g create-clean-codebase
Usage
Run the following command to start creating your project:
npx create-clean-codebase
Follow the interactive prompts to select your desired template and customize it according to your needs.
Example
$ npx create-clean-codebase
Welcome to CreateCleanCodebase!
Select a template:
- NextJS
- Basic
- Supabase
- Python
- Flask
- Django
- Rust
- CLI Tool
- WebAssembly
What is the name of your project? my-nextjs-app
Creating your project...
Success! Your project 'my-nextjs-app' has been created.
Supported Templates
The following templates are currently available:
NextJS
- Basic: A basic Next.js project with TypeScript support.
- Supabase: Next.js with Supabase integration. (Work in Progress)
(More templates coming soon!)
Template Customization
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:
What is the name of your project? my-project
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.
Creating Custom Templates
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.
Here's an example of how templates are mapped:
// templateMappings.js
const templateMappings = {
templates: {
NextJS: {
Basic: {
template: true,
args: [
{
type: "input",
name: "project-name",
default: "my-project",
message: "What is the name of your project?"
},
],
path: "templates/nextjs/typescript/basic/",
},
Supabase: {
template: true,
path: "templates/nextjs/typescript/supabase/",
},
},
},
};
export default templateMappings;
Adding a New Template
Create the Template Files: Add your template files to the appropriate directory within
templates/<your_template_path>/codebase
.Update
templateMappings.js
: Add your new template to the mappings, specifying any arguments and the path to the template files.(Optional) Add
init.js
: If your template requires post-processing, include aninit.js
script in the template directory. This script receives therootPath
of the created codebase and any user arguments as an object.
Contributing
Contributions are welcome! If you have ideas for new templates or improvements, feel free to open an issue or submit a pull request.
- Fork the repository.
- Create your feature branch:
git checkout -b feature/YourFeature
- Commit your changes:
git commit -am 'feature: Add your feature'
- Push to the branch:
git push origin feature/YourFeature
- Open a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Coding!