Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

echo "Running pre-commit checks..."

STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)

if [ -z "$STAGED_FILES" ]; then
exit 0
fi

FRONTEND_FILES=$(echo "$STAGED_FILES" | grep -E '^frontend/.*\.(js|jsx|ts|tsx|json|css|scss|md)$' || true)
BACKEND_FILES=$(echo "$STAGED_FILES" | grep -E '^backend/.*\.go$' || true)

if [ -n "$FRONTEND_FILES" ]; then
echo "This runs before the commit to test frontend linting!"
cd frontend
npm run pre-commit
if [ $? -ne 0 ]; then
echo "Error: Frontend formatting failed"
cd ..
exit 1
fi
cd ..
git add $FRONTEND_FILES
fi

if [ -n "$BACKEND_FILES" ]; then
if command -v gofmt >/dev/null 2>&1; then
echo "Formatting backend Go files with gofmt..."
echo "$BACKEND_FILES" | xargs gofmt -w
if [ $? -ne 0 ]; then
echo "Error: gofmt formatting failed"
exit 1
fi
echo "$BACKEND_FILES" | xargs git add
else
echo "Warning: gofmt not found. Skipping Go file formatting."
echo "Install Go to enable automatic Go formatting."
fi
fi

echo "Pre-commit checks completed successfully!"
exit 0
20 changes: 20 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules
dist
build
coverage
.next
.nuxt
.cache
.vscode
.idea
*.min.js
*.min.css
package-lock.json
yarn.lock
pnpm-lock.yaml
.husky
backend/docs/swagger.json
backend/docs/swagger.yaml
*.log
.env
.env.*
15 changes: 13 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Scan through our [existing issues](https://github.com/its-me-abhishek/ccsync/iss
1. Fork the repository.

- Using GitHub Desktop:

- [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop.
- Once Desktop is set up, you can use it to [fork the repo](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/cloning-and-forking-repositories-from-github-desktop)!

Expand All @@ -48,8 +49,18 @@ Please follow these rules or conventions while committing any new changes:
- `refactor`: refactoring production code, eg. renaming a variable
- `test`: adding missing tests, refactoring tests
- `chore`: updating grunt tasks, etc., no production code change
- Run `npx prettier --write .` before commiting so as to adhere to the linting scheme of the project's frontend
- Run `gofmt -w .` before commiting so as to adhere to the linting scheme of the project's backend

**Note:** This project uses Git pre-commit hooks to automatically format code before committing.

The hooks are set up automatically when you run `npm install` in the frontend directory. When you commit changes:

- Frontend files (JS/TS/JSON/CSS/MD) will be automatically formatted with Prettier
- Backend Go files will be automatically formatted with gofmt (if Go is installed)

If you need to manually format files:

- Run `npm run pre-commit` for frontend formatting (from frontend directory)
- Run `gofmt -w .` for backend formatting

### Pull Request

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Alternatively, you can run each service separately:

- **Backend**: See [backend/README.md](backend/README.md)
- **Frontend**: See [frontend/README.md](frontend/README.md)
- **Full Stack**: Use `docker-compose up`
- **Sync Server**: Use `docker-compose up syncserver`

## Testing with Postman
Expand Down
3 changes: 3 additions & 0 deletions development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The `setup.sh` script starts all three services (backend, frontend, and sync ser

> **Note:** The backend should ideally be run in a separate user environment (preferably root user) to avoid permission issues with Taskwarrior configuration files.


> **Git Hooks:** Pre-commit hooks are automatically configured when you run `npm install` in the frontend directory. These hooks will format your code before each commit.

## Prerequisites

Before running the setup script, ensure you have the following installed:
Expand Down
49 changes: 33 additions & 16 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@
"dev": "vite",
"build": "tsc && vite build",
"test": "jest",
"coverage": "jest --coverage"
"coverage": "jest --coverage",
"postinstall": "git config core.hooksPath .githooks",
"lint": "npx prettier --write .",
"pre-commit": "npm run lint"
},
"keywords": [],
"author": "",
Expand Down
Loading