Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automating the doc schema generation using husky. #2851

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
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
17 changes: 7 additions & 10 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

# Change to the current directory

# Checks code for typescript type errors and throws errors if found.
npm run typecheck
# Wait for server to be ready (adjust sleep time as needed)
sleep 10

# Formats staged code using prettier
# Checks and fixes all lint issues in code which don't require manual intervention.
# Throws errors if lint issues requiring manual intervention are found in code.
# Run your commands
npm run generate:docs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove generate:docs from pre-commit hook to prevent pipeline failures

The generate:docs script modifies git-tracked files in the docs/ directory, which can cause the pipeline to fail with "Unauthorized file modification" errors. Documentation generation should be moved to the CI/CD pipeline instead of running during pre-commit to:

  • Prevent commit failures due to unauthorized file modifications
  • Ensure consistent documentation across all branches
  • Avoid race conditions during concurrent commits
🔗 Analysis chain

Verify the impact of running npm run generate:docs in pre-commit

Adding npm run generate:docs to the pre-commit hook may cause the script to modify files that are not supposed to be changed during commit, leading to the pipeline failure:

[error]  Unauthorized file modification or deletion attempt

Please verify whether running this command in the pre-commit hook is appropriate and allowed.

Run the following script to identify files modified by the pre-commit hook:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check files modified by the pre-commit hook.

# Temporarily stash any staged changes
git stash -k --keep-index

# Run the pre-commit script
.husky/pre-commit

# List files modified by the pre-commit hook
git diff --name-only

# Restore the stashed changes
git stash pop

Length of output: 135


Script:

#!/bin/bash
# Check package.json for generate:docs script and search for documentation patterns
echo "=== Package.json scripts ==="
cat package.json | jq -r '.scripts | select(.["generate:docs"] != null)'

echo -e "\n=== Documentation output patterns ==="
# Look for common documentation output directories
fd -t d '(docs?|documentation|api-docs|reference)$'

echo -e "\n=== Documentation generation patterns ==="
# Search for documentation generation patterns
rg -l -i '(generate|build|create).*docs?' --type js --type json --type ts

Length of output: 3446


Script:

#!/bin/bash
# Examine schema generator implementation
echo "=== Schema Generator Content ==="
cat scripts/schema-generator.mjs

echo -e "\n=== Files in docs directory ==="
# Check if docs files are tracked
git ls-files docs/

echo -e "\n=== Git ignore patterns ==="
# Check if docs are ignored
cat .gitignore | grep -i "doc"

Length of output: 4268

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Unauthorized file modification or deletion attempt

npm run format:fix
# npm run lint:fix
npm run lint-staged

npm run gen:schema

# Generate table of contents for markdown files in root directory
npm run typecheck
npm run update:toc

# Add the changes made to the stage
git add .
Loading
Loading