BASH

Generate Basic Project Structure

Automate the creation of a common web project directory structure with subdirectories for `src`, `public`, `assets`, `dist`, and configuration files.

#!/bin/bash

PROJECT_NAME=$1

if [ -z "$PROJECT_NAME" ]; then
  echo "Usage: $0 <project_name>"
  exit 1
fi

mkdir "$PROJECT_NAME"
cd "$PROJECT_NAME" || exit 1

mkdir -p src/{components,pages,styles,utils}
mkdir -p public/{assets/{images,css,js},index.html}
mkdir dist

touch README.md .env .gitignore
echo "node_modules/
.env" > .gitignore

echo "Project '$PROJECT_NAME' structure created successfully."
tree -L 3 || echo "Install 'tree' for a better visual output."
How it works: This script creates a new directory named after the provided `PROJECT_NAME`. Inside, it sets up common web development subdirectories like `src` with its own subfolders, `public` for static assets, and a `dist` folder. It also creates placeholder files like `README.md`, `.env`, and `.gitignore` for a quick start.

Need help integrating this into your project?

Our team of expert developers can help you build your custom application from scratch.

Hire DigitalCodeLabs