Skip to content

Commit a626692

Browse files
committed
initial commit.
0 parents  commit a626692

28 files changed

+722
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
package-lock.json

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2024 RaxoCoding
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# CreateCleanCodebase
2+
3+
[![npm version](https://img.shields.io/npm/v/create-clean-codebase)](https://www.npmjs.com/package/create-clean-codebase)
4+
[![npm downloads](https://img.shields.io/npm/dt/create-clean-codebase.svg?style=flat-square)](http://npm-stat.com/charts.html?package=create-clean-codebase)
5+
[![License](https://img.shields.io/github/license/RaxoCoding/CreateCleanCodebase)](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!*

index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env node
2+
3+
// @libs
4+
import chalk from "chalk";
5+
6+
// @local
7+
import templateMappings from "./templateMappings.js";
8+
import getTargetTemplateWithArgs from "./utils/getTargetTemplateWithArgs.js";
9+
import copyCodebase from "./utils/copyCodebase.js";
10+
import runInit from "./utils/runInit.js";
11+
12+
async function init() {
13+
console.log("Easily create a clean codebase!")
14+
15+
const targetTemplate = await getTargetTemplateWithArgs(templateMappings);
16+
17+
console.log("Generating codebase...");
18+
19+
await copyCodebase(targetTemplate.path + "/codebase", "./codebase/");
20+
21+
console.log("Finished generating codebase");
22+
23+
console.log("Running init script...");
24+
25+
await runInit(targetTemplate.path + "/init.js", "./codebase/", targetTemplate.args);
26+
27+
console.log("Project setup finished!");
28+
}
29+
30+
init();

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "create-clean-codebase",
3+
"version": "1.0.0",
4+
"description": "NPM package to easily create starter codebases, with a clean, maintainable and easy to understand starting point. ",
5+
"bin": {
6+
"create-clean-codebase": "./index.js"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/RaxoCoding/CreateCleanCodebase"
11+
},
12+
"keywords": [
13+
"clean",
14+
"codebase",
15+
"template",
16+
"starter"
17+
],
18+
"author": "RaxoCoding",
19+
"license": "MIT",
20+
"bugs": {
21+
"url": "https://github.com/RaxoCoding/CreateCleanCodebase/issues"
22+
},
23+
"homepage": "https://github.com/RaxoCoding/CreateCleanCodebase#readme",
24+
"dependencies": {
25+
"chalk": "^5.3.0",
26+
"cross-spawn": "^7.0.3",
27+
"inquirer": "^12.0.0"
28+
},
29+
"type": "module"
30+
}

templateMappings.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Maps the different templates and their sub-templates available
2+
3+
const templateMappings = {
4+
templates: {
5+
NextJS: {
6+
Basic: {
7+
template: true,
8+
args: [
9+
{
10+
type: "input",
11+
name: "project-name",
12+
default: "my-project",
13+
message: "What is the name of your project?"
14+
},
15+
],
16+
path: "templates/nextjs/typescript/basic/",
17+
},
18+
Supabase: {
19+
template: true,
20+
path: "templates/nextjs/typescript/supabase/",
21+
},
22+
},
23+
},
24+
};
25+
26+
export default templateMappings;

templates/.gitkeep

Whitespace-only changes.

templates/nextjs/.gitkeep

Whitespace-only changes.

templates/nextjs/typescript/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}

0 commit comments

Comments
 (0)