1.1.2 • Published 7 months ago

@mayora/boilerplate v1.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

🚀 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.js

Alternatively, add it to your system's PATH or use it locally with node.

Usage

General Command Format

boilerplate <command> [options]

Commands

CommandDescription
setup <template-name>Create a new project using a specific template
--helpDisplay help menu
--listShow available templates

Available Templates

To see the available templates, run:

boilerplate --list

The 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 react

Naming 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 init to create a new repository.

5️⃣ Logging User Activity

  • All actions are logged in user_activity.log.

Example Usage

Basic Interactive Setup

boilerplate

Follow the prompts to choose a template and create a project.

Direct Setup

boilerplate setup node-api

Creates a node-api project from the corresponding template.

List Templates

boilerplate --list

Help Menu

boilerplate --help

Error 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: react

Troubleshooting

Permission Denied

If you get a permission error:

chmod +x boilerplate.js

Missing Dependencies

Ensure Node.js and npm are installed:

node -v
npm -v

Future Enhancements

  • Support for more frameworks (Vue, Angular).
  • Customizable templates.

1.1.2

7 months ago

1.1.1

7 months ago

1.1.0

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago