Skip to content

Instantly share code, notes, and snippets.

@kanakamedala-rajesh
Created September 26, 2025 11:29
Show Gist options
  • Select an option

  • Save kanakamedala-rajesh/7a0f20e09e7eee885be57e76ed241830 to your computer and use it in GitHub Desktop.

Select an option

Save kanakamedala-rajesh/7a0f20e09e7eee885be57e76ed241830 to your computer and use it in GitHub Desktop.
Cross Platform Development - Resolves CRLF/LF warning issues for Windows/Unix compatibility
# EditorConfig for Cross-Platform Development
# Ensures consistent coding styles across different editors and IDEs
# https://editorconfig.org
root = true
# Default settings for all files
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
# Markdown files
[*.md]
trim_trailing_whitespace = false
insert_final_newline = true
# JavaScript/TypeScript files
[*.{js,ts,tsx,jsx}]
indent_size = 2
max_line_length = 100
# JSON files
[*.json]
indent_size = 2
# YAML files
[*.{yml,yaml}]
indent_size = 2
# CSS/SCSS files
[*.{css,scss}]
indent_size = 2
# HTML files
[*.html]
indent_size = 2
# Shell scripts
[*.{sh,bash}]
indent_size = 2
end_of_line = lf
# Windows batch files
[*.{bat,cmd}]
end_of_line = crlf
# Package.json and lock files
[{package.json,package-lock.json,*.lock}]
indent_size = 2
# Configuration files
[*.config.{js,ts,json}]
indent_size = 2
# Git Attributes for Cross-Platform Compatibility
# Ensures consistent line endings across Windows and Unix systems
# Default behavior: normalize line endings to LF in repository
# and convert to native line endings on checkout
* text=auto
# Explicitly set line ending handling for text files
*.md text eol=lf
*.txt text eol=lf
*.json text eol=lf
*.js text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.jsx text eol=lf
*.css text eol=lf
*.scss text eol=lf
*.html text eol=lf
*.xml text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.toml text eol=lf
*.lock text eol=lf
*.svg text eol=lf
# Configuration files
*.config.* text eol=lf
.env* text eol=lf
.gitignore text eol=lf
.gitattributes text eol=lf
.editorconfig text eol=lf
.eslintrc* text eol=lf
.prettierrc* text eol=lf
tsconfig*.json text eol=lf
package.json text eol=lf
package-lock.json text eol=lf
# Shell scripts (Unix line endings)
*.sh text eol=lf
*.bash text eol=lf
# Windows batch files (Windows line endings)
*.bat text eol=crlf
*.cmd text eol=crlf
# Binary files (do not normalize)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.pdf binary
*.zip binary
*.tar.gz binary
*.woff binary
*.woff2 binary
*.ttf binary
*.otf binary
*.eot binary
# Node.js specific
node_modules/** binary
# Build artifacts
dist/** binary
build/** binary
.next/** binary
# IDE files
.vscode/** text eol=lf
*.code-workspace text eol=lf
#!/bin/bash
# Cross-Platform Line Ending Normalization Script
# This script ensures all text files use consistent LF line endings
set -e
echo "πŸ”§ Normalizing line endings for cross-platform compatibility..."
# Function to convert CRLF to LF for a file
normalize_file() {
local file="$1"
if [[ -f "$file" ]]; then
# Check if file has CRLF line endings
if grep -q $'\r$' "$file" 2>/dev/null; then
echo " πŸ“ Normalizing: $file"
# Convert CRLF to LF in place
sed -i 's/\r$//' "$file"
fi
fi
}
# Normalize specific file types
echo "πŸ“„ Normalizing Markdown files..."
find . -name "*.md" -type f | while read file; do
normalize_file "$file"
done
echo "πŸ“„ Normalizing JavaScript/TypeScript files..."
find . -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -type f | while read file; do
normalize_file "$file"
done
echo "πŸ“„ Normalizing JSON/YAML files..."
find . -name "*.json" -o -name "*.yml" -o -name "*.yaml" -type f | while read file; do
normalize_file "$file"
done
echo "πŸ“„ Normalizing CSS files..."
find . -name "*.css" -o -name "*.scss" -type f | while read file; do
normalize_file "$file"
done
echo "πŸ“„ Normalizing configuration files..."
normalize_file ".gitignore"
normalize_file ".gitattributes"
normalize_file ".editorconfig"
normalize_file "package.json"
normalize_file "package-lock.json"
# Normalize any other text files in project root
find . -maxdepth 1 -name "*.txt" -o -name "*.env*" -o -name "README*" -type f | while read file; do
normalize_file "$file"
done
echo "βœ… Line ending normalization complete!"
echo "πŸ”§ Git configuration:"
echo " core.autocrlf = $(git config core.autocrlf)"
echo " core.eol = $(git config core.eol)"
echo ""
echo "πŸ“‹ Next steps:"
echo " 1. Add and commit all files"
echo " 2. All future commits will maintain consistent line endings"
echo " 3. Both Windows and Unix systems will work seamlessly"
#!/bin/bash
# Cross-Platform Development Setup Script
# Ensures consistent development environment across Windows, macOS, and Linux
set -e
echo "πŸš€ Setting up PrismFolio for cross-platform development..."
# Detect operating system
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="Linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macOS"
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
OS="Windows"
else
OS="Unknown"
fi
echo "πŸ“ Detected OS: $OS"
# Configure Git for cross-platform compatibility
echo "πŸ”§ Configuring Git for cross-platform compatibility..."
# Set core Git configuration
git config core.autocrlf false
git config core.eol lf
git config core.attributesFile .gitattributes
# Set safe directory (for WSL/Windows compatibility)
if [[ "$OS" == "Windows" ]]; then
git config --global --add safe.directory "$(pwd)"
fi
echo "βœ… Git configuration complete:"
echo " core.autocrlf = $(git config core.autocrlf)"
echo " core.eol = $(git config core.eol)"
# Normalize existing files
echo "πŸ“ Normalizing line endings..."
if [[ -f "./.specify/scripts/bash/normalize-line-endings.sh" ]]; then
./.specify/scripts/bash/normalize-line-endings.sh
else
echo "⚠️ Line ending normalization script not found"
fi
# Check for required tools
echo "πŸ” Checking required development tools..."
# Check Node.js
if command -v node &> /dev/null; then
NODE_VERSION=$(node --version)
echo "βœ… Node.js: $NODE_VERSION"
else
echo "❌ Node.js not found. Please install Node.js 18+ from https://nodejs.org/"
fi
# Check npm
if command -v npm &> /dev/null; then
NPM_VERSION=$(npm --version)
echo "βœ… npm: $NPM_VERSION"
else
echo "❌ npm not found. Please install npm"
fi
# Check Git
if command -v git &> /dev/null; then
GIT_VERSION=$(git --version)
echo "βœ… Git: $GIT_VERSION"
else
echo "❌ Git not found. Please install Git"
fi
# Platform-specific instructions
echo ""
echo "🎯 Platform-specific notes:"
if [[ "$OS" == "Windows" ]]; then
echo "πŸ“ Windows Setup:"
echo " - Ensure you're using Git Bash, WSL, or PowerShell"
echo " - Line endings will be automatically handled by .gitattributes"
echo " - Use 'npm run dev' or yarn commands normally"
elif [[ "$OS" == "macOS" ]]; then
echo "πŸ“ macOS Setup:"
echo " - All tools should work natively"
echo " - Consider using Homebrew for package management"
echo " - Xcode command line tools may be required"
elif [[ "$OS" == "Linux" ]]; then
echo "πŸ“ Linux Setup:"
echo " - All tools should work natively"
echo " - Use your distribution's package manager if needed"
echo " - Ensure development packages are installed"
fi
echo ""
echo "πŸŽ‰ Cross-platform setup complete!"
echo ""
echo "πŸ“‹ Next steps:"
echo " 1. Run 'npm install' to install dependencies"
echo " 2. Copy '.env.example' to '.env' and configure"
echo " 3. Run 'npm run dev' to start development"
echo ""
echo "πŸ”— All team members can now work on any OS without conflicts!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment