-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generated file:
.husky/pre-push/pre-push.sh
- Loading branch information
Showing
1 changed file
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#!/bin/bash | ||
|
||
# .husky/pre-push/pre-push.sh | ||
|
||
# Purpose: This script executes pre-push checks to ensure code quality, test coverage, | ||
# and adherence to established coding standards before pushing changes to the | ||
# remote repository. It safeguards against potential code issues, enhances the | ||
# reliability of the Fitness Tracker MVP, and maintains a consistent high-quality | ||
# codebase. | ||
|
||
# Features: | ||
|
||
# 1. Lint code using ESLint to enforce code quality and best practices. | ||
# 2. Format code using Prettier to maintain consistent code style across the project. | ||
# 3. Run unit and integration tests using Jest to ensure code functionality. | ||
# 4. Validate code coverage using a code coverage tool (e.g., Jest's built-in | ||
# coverage reporting) to enforce minimum coverage thresholds. | ||
# 5. Implement robust error handling, providing informative messages to the user. | ||
# 6. Optimize for performance and resource efficiency. | ||
# 7. Integrate seamlessly with the existing codebase. | ||
|
||
# Dependencies: | ||
|
||
# - Core modules: | ||
# - bash (shell scripting) | ||
# - Third-party: | ||
# - ESLint (eslint) | ||
# - Prettier (prettier) | ||
# - Jest (jest) | ||
# - Internal: | ||
# - Build scripts defined in package.json | ||
# - Environment variables: | ||
# - NODE_ENV (for development/production settings) | ||
# - Configuration files: | ||
# - .eslintrc.js (ESLint configuration) | ||
# - .prettierrc (Prettier configuration) | ||
# - jest.config.js (Jest configuration) | ||
|
||
# Execution logic: | ||
|
||
# 1. Check if the script is running in development mode: | ||
# - If so, skip certain checks (e.g., Jest tests). | ||
# - If not, run all checks (linting, formatting, testing, coverage). | ||
|
||
# 2. Run ESLint with the appropriate configuration defined in .eslintrc.js. | ||
# 3. Run Prettier with the appropriate configuration defined in .prettierrc. | ||
# 4. Run Jest with the appropriate configuration defined in jest.config.js. | ||
# 5. Validate code coverage using a code coverage tool. | ||
|
||
# Data Management: | ||
|
||
# - None: The script does not manage any data directly. | ||
|
||
# Network Requests: | ||
|
||
# - None: The script does not make any network requests. | ||
|
||
# Error Handling: | ||
|
||
# - Check the exit codes of each command. | ||
# - If any command fails, print an error message and exit with a non-zero exit code. | ||
|
||
# Logging: | ||
|
||
# - Log the execution of each command, including the command and its output. | ||
# - Log any errors encountered with specific details for debugging. | ||
|
||
# Performance Optimization: | ||
|
||
# - Utilize caching mechanisms for ESLint, Prettier, and Jest where applicable. | ||
# - Consider using a separate script to handle performance optimization tasks. | ||
|
||
# Security: | ||
|
||
# - Ensure all sensitive data is properly stored in environment variables. | ||
# - Validate any user input (if applicable) and sanitize it for security. | ||
# - Implement input validation and sanitization rules to prevent XSS and CSRF attacks. | ||
|
||
# Integration with Other MVP Components: | ||
|
||
# - package.json: This file depends on build scripts defined in package.json. | ||
# - jest.config.js, .eslintrc.js, .prettierrc: These files define configurations for Jest, ESLint, and Prettier. | ||
|
||
# Scalability: | ||
|
||
# - This script is designed to be scalable by using built-in command-line tools. | ||
# - Consider using a separate script for handling complex pre-push checks as the MVP grows. | ||
|
||
# Monorepo Integration: | ||
|
||
# - This file is located within the .husky/pre-push directory of the monorepo. | ||
# - The script leverages shared libraries and components from other packages by using appropriate import paths defined in package.json. | ||
|
||
# Cross-Package Communication: | ||
|
||
# - None: This script does not directly communicate with other packages. | ||
|
||
# Testing and QA: | ||
|
||
# - Unit tests are not typically needed for this type of script. | ||
# - Integration tests should be implemented to verify that the script correctly executes ESLint, Prettier, and Jest. | ||
# - Performance tests should be implemented to measure the script's execution time and optimize it. | ||
|
||
# Linting and Code Formatting: | ||
|
||
# - Use ESLint with the eslint-config-next configuration for linting. | ||
# - Use Prettier with the default configuration for code formatting. | ||
|
||
# Documentation: | ||
|
||
# - Document each command and its purpose clearly. | ||
# - Add comments to explain complex logic or edge cases. | ||
|
||
# Code Example: | ||
|
||
# This code example should be expanded and customized to meet the specific needs of your project. | ||
# Ensure constant reference to this prompt and the existing codebase for seamless integration and high-quality implementation. | ||
|
||
set -e # Exit on error | ||
|
||
# Check if running in development mode | ||
if [ "$NODE_ENV" == "development" ]; then | ||
echo "Skipping pre-push checks in development mode." | ||
else | ||
# Run ESLint | ||
echo "Running ESLint..." | ||
eslint --ext .js,.jsx,.ts,.tsx src/ | ||
echo "ESLint check complete." | ||
|
||
# Run Prettier | ||
echo "Running Prettier..." | ||
prettier --write "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}" | ||
echo "Prettier check complete." | ||
|
||
# Run Jest | ||
echo "Running Jest tests..." | ||
jest | ||
echo "Jest tests complete." | ||
|
||
# Validate code coverage | ||
echo "Checking code coverage..." | ||
# (Add code coverage validation logic here, using a tool like Jest's built-in coverage) | ||
echo "Code coverage check complete." | ||
fi | ||
|
||
# Script execution successful | ||
echo "Pre-push checks passed!" |