BASH

Initial Project Setup with Git Clone and Directory Structure

Quickly set up a new web development project by cloning a Git repository and creating standard subdirectories for assets, config, or logs.

#!/bin/bash

REPO_URL=$1
PROJECT_NAME=$2

if [ -z "$REPO_URL" ] || [ -z "$PROJECT_NAME" ]; then
    echo "Usage: $0 <git_repo_url> <project_directory_name>
"
    exit 1
fi

echo "Cloning repository $REPO_URL into $PROJECT_NAME...
"
git clone "$REPO_URL" "$PROJECT_NAME"

if [ $? -ne 0 ]; then
    echo "Error: Failed to clone repository.
"
    exit 1
fi

cd "$PROJECT_NAME" || { echo "Error: Could not change directory to $PROJECT_NAME
"; exit 1; }

echo "Creating standard project directories...
"
mkdir -p assets/css assets/js assets/img config logs tmp

echo "Project $PROJECT_NAME setup complete in $(pwd).
"
ls -F # List contents
How it works: This script automates the initial setup for a new web development project. It takes a Git repository URL and a desired project directory name as arguments. First, it clones the specified Git repository. Upon successful cloning, it navigates into the new project directory and creates a common set of subdirectories such as `assets/css`, `assets/js`, `assets/img`, `config`, `logs`, and `tmp`. This helps standardize project structures and saves manual setup time for developers.

Need help integrating this into your project?

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

Hire DigitalCodeLabs