Welcome to the Project Templates Repository! This repository helps you quickly start new projects with predefined templates and features. It includes a CLI tool to automate the process of setting up a new project, selecting a template, and integrating common features like Git configuration, Prettier settings, and more.
To set up the CLI, the preferred method is to use curl
by running the following command:
curl -s https://raw.githubusercontent.com/lx-0/project-templates/main/setup.sh | bash
Alternatively, you can use wget
:
wget -q -O - https://raw.githubusercontent.com/lx-0/project-templates/main/setup.sh | bash
This will clone the repository into ~/.project-templates
, make the CLI executable, and add it to your PATH
. After running the setup script, please restart your terminal or run source ~/.bashrc
(or source ~/.zshrc
if using Zsh) to apply the changes.
By default, the script runs in a quiet mode where command outputs are dimmed. If you want to see detailed output for all commands, you can use the --verbose
flag:
./setup.sh --verbose
To create a new project using one of the predefined templates:
Run the following command:
project-cli
-
Select a Project Template:
The script will list all available project templates. Choose the template you want by entering its corresponding number.
-
Name Your New Project:
After selecting a template, you'll be prompted to enter a name for your new project. The script will create a new directory with this name in the current directory.
-
Select Features to Integrate:
The script will then list available features (e.g., Git integration, Prettier config). You can select the features you want to include in your new project by typing their corresponding numbers, separated by spaces.
-
Complete the Setup:
The selected features will be integrated into your new project, and the setup process will be completed automatically.
You can also run the script with command-line arguments to skip the interactive prompts:
project-cli -t node-template -n my-node-app -f git-integration,prettier-config
In this example, the node-template
will be used to create a project named my-node-app
, with git-integration
and prettier-config
features integrated.
You can add your own custom templates to this repository by following these steps:
-
Create a New Template Directory:
In the
templates
directory, create a new directory for your template. For example, to add a template for a Django project, create a directory nameddjango-template
.mkdir templates/django-template
-
Add Template Files:
Populate the directory with the necessary files and structure for your template. This could include source code, configuration files,
README.md
, etc. -
Ensure Compatibility with the Script:
Make sure your template follows the general structure of existing templates so that it works seamlessly with the
project-cli.sh
script. -
Commit and Push:
Once your template is ready, commit your changes and push them to the repository.
git add templates/django-template git commit -m "Add Django project template" git push origin main
templates/django-template/
├── manage.py
├── requirements.txt
├── myapp/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── README.md
You can add new features that can be integrated into any project created from a template. Here’s how:
-
Create a New Feature Directory:
Inside the
features/
directory, create a new directory for your feature. For example, to add ESLint configuration, create a directory namedeslint-config
.mkdir features/eslint-config
-
Add Configuration Files:
Populate the feature directory with the relevant configuration files. For ESLint, this might include
.eslintrc.json
,.eslintignore
, etc. -
Document the Feature:
Include a
README.md
in the feature directory to explain what the feature does and how it should be used. -
Commit and Push:
Once your feature is ready, commit your changes and push them to the repository.
git add features/eslint-config git commit -m "Add ESLint configuration feature" git push origin main
features/eslint-config/
├── .eslintrc.json
├── .eslintignore
└── README.md
Here’s an overview of the directory structure used in this repository:
project-templates/
│
├── features/ # Contains shared features that can be integrated into any project
│ ├── vscode-settings/
│ ├── prettier-config/
│ ├── git-integration/
│ └── docker-config/
│
├── templates/
│ ├── node-template/ # Example project template for Node.js projects
│ ├── python-template/ # Example project template for Python projects
│ └── react-template/ # Example project template for React projects
│
├── bin/
│ └── project-cli.sh # Script to create a new project and integrate features
└── README.md
Feel free to contribute by adding new templates or features. Make sure to follow the structure and guidelines provided in this README.md
to ensure consistency across the repository.