forked from jsnbuchanan/crowd-funder-for-time-pwa
docs: comprehensive documentation updates and modernization
- Update BUILDING.md with current build system information - Modernize various README files across the project - Update CHANGELOG.md with recent changes - Improve documentation consistency and formatting - Update platform-specific documentation (iOS, Electron, Docker) - Enhance test documentation and build guides
This commit is contained in:
@@ -31,6 +31,7 @@ All scripts automatically handle environment variables for different build types
|
||||
#### Automatic Environment Setup
|
||||
|
||||
Each script automatically:
|
||||
|
||||
1. **Sets platform-specific variables** based on build type
|
||||
2. **Gets git hash** for versioning (`VITE_GIT_HASH`)
|
||||
3. **Creates application directories** (`~/.local/share/TimeSafari/timesafari`)
|
||||
@@ -104,6 +105,7 @@ exit 0
|
||||
## Benefits of Unification
|
||||
|
||||
### Before (Redundant)
|
||||
|
||||
```bash
|
||||
# Each script had 50+ lines of duplicate code:
|
||||
readonly RED='\033[0;31m'
|
||||
@@ -121,6 +123,7 @@ export VITE_PWA_ENABLED=false
|
||||
```
|
||||
|
||||
### After (Unified)
|
||||
|
||||
```bash
|
||||
# Each script is now ~20 lines of focused logic:
|
||||
source "$(dirname "$0")/common.sh"
|
||||
@@ -133,6 +136,7 @@ print_footer "Script Title"
|
||||
## Usage Examples
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
./scripts/test-all.sh
|
||||
@@ -189,6 +193,7 @@ export NODE_ENV=production
|
||||
```
|
||||
|
||||
### .env File Support
|
||||
|
||||
Scripts automatically load variables from `.env` files if they exist:
|
||||
|
||||
```bash
|
||||
@@ -199,6 +204,7 @@ CUSTOM_VAR=value
|
||||
```
|
||||
|
||||
### Environment Validation
|
||||
|
||||
Required environment variables can be validated:
|
||||
|
||||
```bash
|
||||
@@ -207,6 +213,7 @@ validate_env_vars "VITE_API_URL" "VITE_DEBUG" || exit 1
|
||||
```
|
||||
|
||||
### Environment Inspection
|
||||
|
||||
View current environment variables with the `--env` flag:
|
||||
|
||||
```bash
|
||||
@@ -277,4 +284,4 @@ To verify the common utilities work correctly:
|
||||
- Timing information is automatically collected for all operations
|
||||
- Build artifacts are cleaned up automatically
|
||||
- No redundant command execution or file operations
|
||||
- Environment variables are set efficiently with minimal overhead
|
||||
- Environment variables are set efficiently with minimal overhead
|
||||
|
||||
@@ -5,22 +5,26 @@ This directory contains custom Git hooks for the TimeSafari project.
|
||||
## Debug Code Checker Hook
|
||||
|
||||
### Overview
|
||||
|
||||
The `pre-commit` hook automatically checks for debug code when committing to protected branches (master, main, production, release). This prevents debug statements from accidentally reaching production code.
|
||||
|
||||
### How It Works
|
||||
|
||||
1. **Branch Detection**: Only runs on protected branches (configurable)
|
||||
2. **File Filtering**: Automatically skips test files, scripts, and documentation
|
||||
3. **Pattern Matching**: Detects common debug patterns using regex
|
||||
4. **Commit Prevention**: Blocks commits containing debug code
|
||||
|
||||
### Protected Branches (Default)
|
||||
|
||||
- `master`
|
||||
- `main`
|
||||
- `main`
|
||||
- `production`
|
||||
- `release`
|
||||
- `stable`
|
||||
|
||||
### Debug Patterns Detected
|
||||
|
||||
- **Console statements**: `console.log`, `console.debug`, `console.error`
|
||||
- **Template debug**: `Debug:`, `debug:` in Vue templates
|
||||
- **Debug constants**: `DEBUG_`, `debug_` variables
|
||||
@@ -30,6 +34,7 @@ The `pre-commit` hook automatically checks for debug code when committing to pro
|
||||
- **Debug TODOs**: `TODO debug`, `FIXME debug`
|
||||
|
||||
### Files Automatically Skipped
|
||||
|
||||
- Test files: `*.test.js`, `*.spec.ts`, `*.test.vue`
|
||||
- Scripts: `scripts/` directory
|
||||
- Test directories: `test-*` directories
|
||||
@@ -38,49 +43,61 @@ The `pre-commit` hook automatically checks for debug code when committing to pro
|
||||
- IDE files: `.cursor/` directory
|
||||
|
||||
### Configuration
|
||||
|
||||
Edit `.git/hooks/debug-checker.config` to customize:
|
||||
|
||||
- Protected branches
|
||||
- Debug patterns
|
||||
- Skip patterns
|
||||
- Logging level
|
||||
|
||||
### Testing the Hook
|
||||
|
||||
Run the test script to verify the hook works:
|
||||
|
||||
```bash
|
||||
./scripts/test-debug-hook.sh
|
||||
```
|
||||
|
||||
### Manual Testing
|
||||
|
||||
1. Make changes to a file with debug code
|
||||
2. Stage the file: `git add <filename>`
|
||||
3. Try to commit: `git commit -m 'test'`
|
||||
4. Hook should prevent commit if debug code is found
|
||||
|
||||
### Bypassing the Hook (Emergency)
|
||||
|
||||
If you absolutely need to commit debug code to a protected branch:
|
||||
|
||||
```bash
|
||||
git commit --no-verify -m "emergency: debug code needed"
|
||||
```
|
||||
|
||||
⚠️ **Warning**: This bypasses all pre-commit hooks. Use sparingly and only in emergencies.
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### Hook not running
|
||||
|
||||
- Ensure the hook is executable: `chmod +x .git/hooks/pre-commit`
|
||||
- Check if you're on a protected branch
|
||||
- Verify the hook file exists and has correct permissions
|
||||
|
||||
#### False positives
|
||||
|
||||
- Add legitimate debug patterns to skip patterns in config
|
||||
- Use proper logging levels (`logger.info`, `logger.debug`) instead of console
|
||||
- Move debug code to feature branches first
|
||||
|
||||
#### Hook too strict
|
||||
|
||||
- Modify debug patterns in config file
|
||||
- Add more file types to skip patterns
|
||||
- Adjust protected branch list
|
||||
|
||||
### Best Practices
|
||||
|
||||
1. **Use feature branches** for development with debug code
|
||||
2. **Use proper logging** instead of console statements
|
||||
3. **Test thoroughly** before merging to protected branches
|
||||
@@ -88,14 +105,18 @@ git commit --no-verify -m "emergency: debug code needed"
|
||||
5. **Keep config updated** as project needs change
|
||||
|
||||
### Integration with CI/CD
|
||||
|
||||
This hook works locally. For CI/CD pipelines, consider:
|
||||
|
||||
- Running the same checks in your build process
|
||||
- Adding ESLint rules for console statements
|
||||
- Using TypeScript strict mode
|
||||
- Adding debug code detection to PR checks
|
||||
|
||||
### Support
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. Check the hook output for specific error messages
|
||||
2. Verify your branch is in the protected list
|
||||
3. Review the configuration file
|
||||
|
||||
Reference in New Issue
Block a user