Personal Development Workflow - jvPalma/dotrun GitHub Wiki

Personal Development Workflow

This workflow demonstrates how individual developers can use dotrun to streamline their daily development tasks and create a personalized development environment.

Overview

A personal development workflow with dotrun helps developers:

  • Standardize development environment setup
  • Automate repetitive tasks
  • Maintain consistent tooling across projects
  • Share useful scripts with team members

Setup Process

1. Initial dotrun Setup

# Install dotrun
curl -sSL https://raw.githubusercontent.com/yourusername/dotrun/master/install.sh | bash

# Initialize your personal script collection
dotrun init my-dev-scripts
cd ~/.dotrun/my-dev-scripts

2. Create Personal Script Collection

# Create directory structure
mkdir -p scripts/{git,docker,node,python,utils}
mkdir -p configs
mkdir -p templates

3. Essential Personal Scripts

Git Workflow Scripts

scripts/git/quick-commit.sh

#!/bin/bash
# Quick commit with conventional commit format

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../utils/colors.sh"

# Get commit type
echo -e "${BLUE}Select commit type:${NC}"
echo "1) feat: A new feature"
echo "2) fix: A bug fix"
echo "3) docs: Documentation changes"
echo "4) style: Code style changes"
echo "5) refactor: Code refactoring"
echo "6) test: Adding or updating tests"
echo "7) chore: Maintenance tasks"

read -p "Enter choice (1-7): " choice

case $choice in
  1) type="feat" ;;
  2) type="fix" ;;
  3) type="docs" ;;
  4) type="style" ;;
  5) type="refactor" ;;
  6) type="test" ;;
  7) type="chore" ;;
  *)
    echo -e "${RED}Invalid choice${NC}"
    exit 1
    ;;
esac

# Get scope (optional)
read -p "Scope (optional): " scope
if [[ -n "$scope" ]]; then
  scope="($scope)"
fi

# Get description
read -p "Description: " description

# Get body (optional)
echo "Body (optional, press Enter twice when done):"
body=""
while IFS= read -r line; do
  [[ -z "$line" ]] && break
  body+="$line"$'\n'
done

# Create commit
commit_msg="${type}${scope}: ${description}"
if [[ -n "$body" ]]; then
  commit_msg+="\n\n${body}"
fi

git add .
git commit -m "$commit_msg"

echo -e "${GREEN}Commit created successfully!${NC}"

scripts/git/branch-cleanup.sh

#!/bin/bash
# Clean up merged branches

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../utils/colors.sh"

echo -e "${BLUE}Cleaning up merged branches...${NC}"

# Get current branch
current_branch=$(git branch --show-current)

# Get merged branches (excluding main/master)
merged_branches=$(git branch --merged | grep -v -E '(main|master|\*)' | xargs -n 1)

if [[ -z "$merged_branches" ]]; then
  echo -e "${YELLOW}No merged branches to clean up.${NC}"
  exit 0
fi

echo -e "${BLUE}Found merged branches:${NC}"
echo "$merged_branches"

read -p "Delete these branches? (y/N): " confirm
if [[ $confirm == [yY] ]]; then
  echo "$merged_branches" | xargs -n 1 git branch -d
  echo -e "${GREEN}Branches cleaned up successfully!${NC}"
else
  echo -e "${YELLOW}Branch cleanup cancelled.${NC}"
fi

Node.js Development Scripts

scripts/node/project-setup.sh

#!/bin/bash
# Set up a new Node.js project with common tools

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../utils/colors.sh"

PROJECT_NAME=${1:-"my-node-project"}

echo -e "${BLUE}Setting up Node.js project: $PROJECT_NAME${NC}"

# Create project directory
mkdir -p "$PROJECT_NAME"
cd "$PROJECT_NAME"

# Initialize package.json
npm init -y

# Install common dependencies
echo -e "${BLUE}Installing dependencies...${NC}"
npm install express cors helmet dotenv
npm install -D nodemon jest eslint prettier @types/node typescript ts-node

# Create basic project structure
mkdir -p src/{routes,middleware,utils} tests config

# Create basic files
cat >src/index.js <<'EOF'
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
require('dotenv').config();

const app = express();
const PORT = process.env.PORT || 3000;

// Middleware
app.use(helmet());
app.use(cors());
app.use(express.json());

// Routes
app.get('/', (req, res) => {
  res.json({ message: 'Hello World!' });
});

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});
EOF

cat >.env <<'EOF'
PORT=3000
NODE_ENV=development
EOF

cat >.gitignore <<'EOF'
node_modules/
.env
.env.local
.env.production
dist/
build/
*.log
.DS_Store
EOF

# Update package.json scripts
npm pkg set scripts.start="node src/index.js"
npm pkg set scripts.dev="nodemon src/index.js"
npm pkg set scripts.test="jest"
npm pkg set scripts.lint="eslint src/"

echo -e "${GREEN}Node.js project '$PROJECT_NAME' set up successfully!${NC}"
echo -e "${BLUE}Next steps:${NC}"
echo "  cd $PROJECT_NAME"
echo "  npm run dev"

Docker Development Scripts

scripts/docker/cleanup.sh

#!/bin/bash
# Clean up Docker resources

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../utils/colors.sh"

echo -e "${BLUE}Docker cleanup options:${NC}"
echo "1) Remove stopped containers"
echo "2) Remove unused images"
echo "3) Remove unused volumes"
echo "4) Remove unused networks"
echo "5) Full cleanup (all of the above)"
echo "6) Nuclear option (remove everything)"

read -p "Enter choice (1-6): " choice

case $choice in
  1)
    echo -e "${BLUE}Removing stopped containers...${NC}"
    docker container prune -f
    ;;
  2)
    echo -e "${BLUE}Removing unused images...${NC}"
    docker image prune -f
    ;;
  3)
    echo -e "${BLUE}Removing unused volumes...${NC}"
    docker volume prune -f
    ;;
  4)
    echo -e "${BLUE}Removing unused networks...${NC}"
    docker network prune -f
    ;;
  5)
    echo -e "${BLUE}Full cleanup...${NC}"
    docker container prune -f
    docker image prune -f
    docker volume prune -f
    docker network prune -f
    ;;
  6)
    echo -e "${RED}WARNING: This will remove ALL containers, images, volumes, and networks!${NC}"
    read -p "Are you absolutely sure? (type 'yes'): " confirm
    if [[ $confirm == "yes" ]]; then
      docker system prune -a --volumes -f
    else
      echo -e "${YELLOW}Nuclear cleanup cancelled.${NC}"
    fi
    ;;
  *)
    echo -e "${RED}Invalid choice${NC}"
    exit 1
    ;;
esac

echo -e "${GREEN}Docker cleanup completed!${NC}"

Utility Scripts

scripts/utils/colors.sh

#!/bin/bash
# Color definitions for scripts

# Regular colors
export RED='\033[0;31m'
export GREEN='\033[0;32m'
export YELLOW='\033[0;33m'
export BLUE='\033[0;34m'
export PURPLE='\033[0;35m'
export CYAN='\033[0;36m'
export WHITE='\033[0;37m'
export NC='\033[0m' # No Color

# Bold colors
export BRED='\033[1;31m'
export BGREEN='\033[1;32m'
export BYELLOW='\033[1;33m'
export BBLUE='\033[1;34m'
export BPURPLE='\033[1;35m'
export BCYAN='\033[1;36m'
export BWHITE='\033[1;37m'

scripts/utils/project-info.sh

#!/bin/bash
# Display project information

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/colors.sh"

echo -e "${BLUE}=== Project Information ===${NC}"

# Git information
if git rev-parse --git-dir >/dev/null 2>&1; then
  echo -e "${GREEN}Git Repository:${NC} $(basename $(git rev-parse --show-toplevel))"
  echo -e "${GREEN}Current Branch:${NC} $(git branch --show-current)"
  echo -e "${GREEN}Last Commit:${NC} $(git log -1 --pretty=format:'%h - %s (%cr)')"
fi

# Node.js information
if [[ -f "package.json" ]]; then
  echo -e "${GREEN}Node.js Project:${NC} $(node -p "require('./package.json').name")"
  echo -e "${GREEN}Version:${NC} $(node -p "require('./package.json').version")"
  if command -v node &>/dev/null; then
    echo -e "${GREEN}Node Version:${NC} $(node --version)"
  fi
fi

# Python information
if [[ -f "requirements.txt" ]] || [[ -f "pyproject.toml" ]]; then
  echo -e "${GREEN}Python Project Detected${NC}"
  if command -v python3 &>/dev/null; then
    echo -e "${GREEN}Python Version:${NC} $(python3 --version)"
  fi
fi

# Docker information
if [[ -f "Dockerfile" ]] || [[ -f "docker-compose.yml" ]]; then
  echo -e "${GREEN}Docker Configuration Detected${NC}"
fi

echo -e "${BLUE}=========================${NC}"

4. Configuration Templates

configs/eslint.config.js

module.exports = {
  env: {
    node: true,
    es2021: true,
  },
  extends: ["eslint:recommended"],
  parserOptions: {
    ecmaVersion: 12,
    sourceType: "module",
  },
  rules: {
    indent: ["error", 2],
    "linebreak-style": ["error", "unix"],
    quotes: ["error", "single"],
    semi: ["error", "always"],
    "no-console": "warn",
    "no-unused-vars": "error",
  },
};

configs/prettier.config.js

module.exports = {
  semi: true,
  trailingComma: "es5",
  singleQuote: true,
  printWidth: 80,
  tabWidth: 2,
  useTabs: false,
};

5. Daily Workflow Integration

Morning Setup Script

scripts/daily-setup.sh

#!/bin/bash
# Daily development setup

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/utils/colors.sh"

echo -e "${BLUE}=== Daily Development Setup ===${NC}"

# Check system status
echo -e "${BLUE}System Status:${NC}"
echo "  Disk Space: $(df -h / | awk 'NR==2{print $4}') available"
echo "  Memory: $(free -h | awk 'NR==2{print $7}') available"

# Git status across projects
echo -e "\n${BLUE}Git Repositories Status:${NC}"
for dir in ~/projects/*/; do
  if [[ -d "$dir/.git" ]]; then
    cd "$dir"
    status=$(git status --porcelain)
    if [[ -n "$status" ]]; then
      echo -e "  ${YELLOW}$(basename "$dir"):${NC} has uncommitted changes"
    else
      echo -e "  ${GREEN}$(basename "$dir"):${NC} clean"
    fi
  fi
done

# Check for system updates (Linux)
if command -v apt &>/dev/null; then
  echo -e "\n${BLUE}Checking for system updates...${NC}"
  updates=$(apt list --upgradable 2>/dev/null | grep -c upgradable || true)
  echo "  Available updates: $updates"
fi

# Docker cleanup suggestion
if command -v docker &>/dev/null; then
  docker_images=$(docker images -q | wc -l)
  docker_containers=$(docker ps -a -q | wc -l)
  echo -e "\n${BLUE}Docker Status:${NC}"
  echo "  Images: $docker_images"
  echo "  Containers: $docker_containers"

  if [[ $docker_images -gt 10 ]]; then
    echo -e "  ${YELLOW}Consider running docker cleanup${NC}"
  fi
fi

echo -e "\n${GREEN}Daily setup complete! Happy coding! 🚀${NC}"

6. Integration with Tools

VS Code Integration

configs/vscode-settings.json

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "terminal.integrated.defaultProfile.linux": "bash",
  "terminal.integrated.profiles.linux": {
    "dotrun": {
      "path": "bash",
      "args": ["-c", "dotrun list && exec bash"]
    }
  }
}

Zsh Integration

configs/zshrc-additions.sh

# Add to ~/.zshrc

# dotrun aliases
alias dr="dotrun"
alias drl="dotrun list"
alias drr="dotrun run"

# Quick project navigation
alias projects="cd ~/projects"

# Git aliases with dotrun
alias gc="dotrun run quick-commit"
alias gclean="dotrun run branch-cleanup"

# Development shortcuts
alias setup-node="dotrun run node/project-setup"
alias daily="dotrun run daily-setup"
alias pinfo="dotrun run utils/project-info"

Best Practices

1. Script Organization

  • Keep scripts focused on single tasks
  • Use consistent naming conventions
  • Include help documentation in scripts
  • Use the shared colors utility for consistent output

2. Version Control

  • Commit your script collection to a personal repository
  • Use branches for experimental scripts
  • Tag stable versions of your script collection

3. Security Considerations

  • Never commit API keys or sensitive data
  • Use environment variables for configuration
  • Set appropriate file permissions (755 for scripts)

4. Maintenance

  • Regularly review and update scripts
  • Remove unused or outdated scripts
  • Document script dependencies and requirements

Example Daily Workflow

# Morning routine
dotrun run daily-setup

# Start working on a feature
cd ~/projects/my-app
dotrun run utils/project-info
dotrun run git/new-feature-branch feature/user-authentication

# Development work...

# End of day
dotrun run git/quick-commit
dotrun run docker/cleanup

This personal development workflow helps maintain consistency across projects while providing powerful automation for common development tasks.

⚠️ **GitHub.com Fallback** ⚠️