@mayora/boilerplate v1.1.2
🚀 Boilerplate CLI Documentation
Overview
The Boilerplate CLI is a command-line tool that helps developers quickly set up a new project using predefined templates. It streamlines project creation by managing dependencies, initializing Git, and providing a structured project setup.
Prerequisites
- Node.js: Version 14 or higher is recommended.
- npm: Installed alongside Node.js.
- Git: Optional, but recommended for version control.
Installation
To use the script globally, place the file in a directory and ensure it has execute permissions:
chmod +x boilerplate.jsAlternatively, add it to your system's PATH or use it locally with node.
Usage
General Command Format
boilerplate <command> [options]Commands
| Command | Description |
|---|---|
setup <template-name> | Create a new project using a specific template |
--help | Display help menu |
--list | Show available templates |
Available Templates
To see the available templates, run:
boilerplate --listThe script reads template names from the templates/ directory.
Creating a New Project
Interactive Mode
If no command is provided, the CLI will guide you through project creation:
boilerplate- It will prompt you to select a template.
- It will ask for a project name.
- It will show a preview of the template's contents.
- It will confirm if you want to proceed.
- It will ask if you want to initialize a Git repository.
Direct Setup
To directly set up a project:
boilerplate setup <template-name>Example:
boilerplate setup reactNaming the Project
You will be prompted to enter a project name. The name must:
- Contain only letters, numbers, hyphens (
-), or underscores (_). - Not include spaces or special characters.
Features & Workflow
1️⃣ Node.js Version Check
If your Node.js version is below 14, the script prompts for an update.
2️⃣ Template Selection
The CLI fetches available templates from the templates/ directory.
3️⃣ Project Creation
- Creates a directory for your project.
- Copies files from the selected template.
- Installs dependencies using
npm install.
4️⃣ Git Initialization (Optional)
- If enabled, it runs
git initto create a new repository.
5️⃣ Logging User Activity
- All actions are logged in
user_activity.log.
Example Usage
Basic Interactive Setup
boilerplateFollow the prompts to choose a template and create a project.
Direct Setup
boilerplate setup node-apiCreates a node-api project from the corresponding template.
List Templates
boilerplate --listHelp Menu
boilerplate --helpError Handling
- If an invalid template is selected, an error is shown.
- If project creation fails, logs are recorded in
user_activity.log.
Logging
The CLI logs user actions to user_activity.log in the project directory:
2025-04-04T10:15:30.123Z - User started the setup with command: setup and template: react
2025-04-04T10:15:45.456Z - User selected template: react
2025-04-04T10:16:00.789Z - Creating new project: my-react-app with template: reactTroubleshooting
Permission Denied
If you get a permission error:
chmod +x boilerplate.jsMissing Dependencies
Ensure Node.js and npm are installed:
node -v
npm -vFuture Enhancements
- Support for more frameworks (Vue, Angular).
- Customizable templates.