chaubey-mern
v1.1.0
Published
CLI package to generate complete MERN and web development assignment projects.
Maintainers
Readme
chaubey-mern
Comprehensive CLI package to scaffold complete MERN and web development assignment projects (Assignments 1–8) from verified source templates.
chaubey-mern enables students and instructors to instantly scaffold standalone, ready-to-run assignment projects with preserved folder structures, accurate configurations, credential safety, dynamic student metadata, atomic staging, and clear next-step instructions.
Supported Assignments (Curriculum 1–8)
The package provides turnkey project generators for all 8 curriculum assignments:
| Assignment ID | Title | Category | Tech Stack | Database | Metadata Supported |
|---|---|---|---|---|---|
| assignment-1 | Assignment 1: JavaScript Calculator | Core JavaScript & DOM | HTML5, CSS3, Vanilla JS | None | None |
| assignment-2 | Assignment 2: To-Do List Application | Core JavaScript & DOM | HTML5, CSS3, Vanilla JS | None | Student Name, PRN, Date |
| assignment-3 | Assignment 3: JavaScript Form Validation | Core JavaScript & DOM | HTML5, CSS3, Vanilla JS | None | Student Name, PRN, Date |
| assignment-4 | Assignment 4: React Profile Card using Props | React & Components | React 19, Vite 8, CSS3 | None | Student Name, PRN, Date |
| assignment-5 | Assignment 5: Controlled React Form | React & State Management | React 19, Vite 8, CSS3 | None | Student Name, PRN, Date |
| assignment-6 | Assignment 6: React Counter App using useState | React & State Management | React 19, Vite 8, CSS3 | None | Student Name, PRN, Date |
| assignment-7 | Assignment 7: REST API using Express.js | Backend & Express | Node.js, Express.js (v5) | None (In-memory) | None |
| assignment-8 | Assignment 8: MongoDB Integration using Mongoose | Full Stack & MERN | Node.js, Express.js, Mongoose, MongoDB | MongoDB | None (requires .env) |
Prerequisites
- Node.js: Version
18.0.0or higher (tested on Node v24.14.0). - npm: Version
9.0.0or higher. - A modern web browser (for Assignments 1–6).
- MongoDB (local
mongoddaemon or free MongoDB Atlas account for Assignment 8).
Usage
Direct Execution via npx (Zero Installation)
# 1. List all 8 supported assignments
npx chaubey-mern assignments
# 2. Generate any assignment (e.g. Assignment 1)
npx chaubey-mern create assignment-1 my-calculator
# 3. Generate Assignment 2 with student attribution
npx chaubey-mern create assignment-2 my-todo --student-name "Jane Doe" --student-id "PRN-12345"
# 4. Generate Assignment 4 (React Profile Cards) non-interactively
npx chaubey-mern create assignment-4 my-profiles --no-input
# 5. Generate Assignment 7 (Express REST API)
npx chaubey-mern create assignment-7 my-express-api --no-input
# 6. Generate Assignment 8 (MongoDB + Mongoose)
npx chaubey-mern create assignment-8 my-mongo-app --no-input
# 7. Check version and help
npx chaubey-mern --version
npx chaubey-mern --helpCLI Command Reference
create <assignment-id> [destination]
Scaffolds the specified assignment template into the target destination directory.
- Arguments:
<assignment-id>: One ofassignment-1throughassignment-8.[destination]: (Optional) Path to target directory. Defaults to./<assignment-id>.
- Options:
-f, --force: Overwrite destination if the directory already exists and contains files.--no-input: Disable interactive prompts and run non-interactively (ideal for CI/CD and scripts).--student-name <name>: Provide student name for assignment submission.--student-id <id>: Provide student PRN or ID.--submission-date <date>: Provide submission date (YYYY-MM-DD).
Examples:
# Interactive creation (prompts for optional student metadata when applicable)
npx chaubey-mern create assignment-2
# Scripted non-interactive creation
npx chaubey-mern create assignment-3 ./form-project --no-input --student-name "Aarav Sharma" --student-id "PRN-2026-99"
# Overwrite existing folder with --force
npx chaubey-mern create assignment-1 ./calc-project --forceassignments
Displays an inventory of all 8 assignments with titles, tech stacks, and descriptions.
npx chaubey-mern assignmentsRunning the Generated Assignments
Assignments 1–3: Static Browser Applications
- Navigate to the generated directory:
cd assignment-1 # or assignment-2 / assignment-3 - Open the HTML entry point in your browser:
- Assignment 1: Open
intex.html - Assignment 2: Open
index.html - Assignment 3: Open
index.html - Alternatively, serve locally:
npx serve .
- Assignment 1: Open
Assignments 4–6: React + Vite Applications
- Navigate to the generated directory:
cd assignment-4 # or assignment-5 / assignment-6 - Install dependencies:
npm install - Start the Vite development server:
npm run dev - Open the displayed local URL in your browser (typically
http://localhost:5173).
Assignment 7: Express.js REST API
- Navigate to the generated directory:
cd assignment-7 - Install dependencies:
npm install - Start the Express server:
node server.js - Access endpoints on
http://localhost:5000/api/users:GET /api/users: Fetch all usersPOST /api/users: Add a user{ "name": "...", "email": "..." }PUT /api/users/:id: Update a userDELETE /api/users/:id: Remove a user
Assignment 8: MongoDB Integration using Mongoose
- Navigate to the generated directory:
cd assignment-8 - Install dependencies:
npm install - Configure environment variables:
Edit# Copy template cp .env.example .env.envwith your MongoDB connection string:# For local MongoDB: MONGODB_URI=mongodb://127.0.0.1:27017/productDB PORT=5000 # Or for MongoDB Atlas: # MONGODB_URI=mongodb+srv://<username>:<password>@cluster0.example.mongodb.net/productDB?retryWrites=true&w=majority - Start the server:
node server.js - Test Product CRUD API endpoints on
http://localhost:5000/api/products:POST /api/products: Create product{ "name": "...", "price": 99, "category": "...", "stock": 10 }GET /api/products: Retrieve all productsGET /api/products/:id: Get product by IDPUT /api/products/:id: Update price or stockDELETE /api/products/:id: Delete product
Security & Credential Protection
- No Personal Credentials: Real
.envfiles, MongoDB connection strings with passwords, and private certificates are strictly excluded from packaging and project generation. - Content Scanner: Active validation ensures no raw database passwords or private keys are ever embedded into staged templates.
- Safe .env.example: Automatically generated with safe placeholders whenever an assignment requires database or environment configuration.
- Destination Protection: Refuses root paths (
C:\,/), system folders (C:\Windows,/bin, etc.), blocks path traversal (../../), and guards against accidental non-empty directory overwrites without--force. - Atomic Staging: Generation takes place in an isolated temporary staging directory (
os.tmpdir()). If any failure occurs, the target directory remains untouched.
Dynamic Student Attribution
- Privacy Preserved: The original template author attributions (e.g.
Adarsh Kumar,Skand Chaubey,Ankit Kumar) are systematically replaced with the generating student's details, or omitted with a clean generic title if skipped. - HTML Injection Protected: All student metadata is escaped to prevent XSS or malformed markup.
- Format Validation: Dates are validated against the standard
YYYY-MM-DDcalendar format.
Development & Testing
# Run complete test suite (35+ automated tests)
npm test
# Run tests in watch mode
npm run test:watch
# Package into tarball
npm packLicense
MIT © 2026 Chaubey
