-
-
Notifications
You must be signed in to change notification settings - Fork 888
auto docs 2, to check the permission issue #3297
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
auto docs 2, to check the permission issue #3297
Conversation
WalkthroughThis pull request introduces changes to documentation generation and linting configuration. A new script Changes
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions
participant TD as TypeDoc
participant FRL as fix-readme-links.js
GHA->>TD: Run documentation generation
TD-->>GHA: Generate documentation files
GHA->>FRL: Execute link replacement script
FRL->>FRL: Recursively process Markdown files
FRL-->>GHA: Update links in documentation
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
fix-readme-links.js (1)
4-4
: Consider making the docs directory configurable.The hard-coded path
'./docs/docs/auto-docs'
should be made configurable through environment variables or command-line arguments to improve flexibility and reusability.-const docsDir = path.resolve('./docs/docs/auto-docs'); +const docsDir = path.resolve(process.env.DOCS_DIR || './docs/docs/auto-docs');.github/workflows/pull-request.yml (1)
472-472
: Fix trailing spaces in YAML file.Remove trailing spaces to comply with YAML formatting standards.
- node-version: '20.x' + node-version: '20.x'🧰 Tools
🪛 yamllint (1.35.1)
[error] 472-472: trailing spaces
(trailing-spaces)
🪛 GitHub Actions: PR Workflow
[error] Unauthorized modification or deletion of sensitive file
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.eslintignore
(1 hunks).github/workflows/pull-request.yml
(3 hunks)fix-readme-links.js
(1 hunks)package.json
(2 hunks)tsconfig.docs.json
(1 hunks)typedoc.json
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tsconfig.docs.json
- typedoc.json
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
.eslintignore
[error] Unauthorized modification or deletion of sensitive file
package.json
[error] Unauthorized modification or deletion of sensitive file
.github/workflows/pull-request.yml
[error] Unauthorized modification or deletion of sensitive file
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 472-472: trailing spaces
(trailing-spaces)
[error] 560-560: no new line character at the end of file
(new-line-at-end-of-file)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (1)
.eslintignore (1)
6-6
:⚠️ Potential issueUnauthorized modification of sensitive file.
The
.eslintignore
file is listed as a sensitive file that requires authorization to modify. Please request authorization by applying the 'ignore-sensitive-files-pr' label to this PR.🧰 Tools
🪛 GitHub Actions: PR Workflow
[error] Unauthorized modification or deletion of sensitive file
function replaceLinks(dir) { | ||
const files = fs.readdirSync(dir); | ||
files.forEach((file) => { | ||
const filePath = path.join(dir, file); | ||
if (fs.lstatSync(filePath).isDirectory()) { | ||
replaceLinks(filePath); | ||
} else if (file.endsWith('.md')) { | ||
let content = fs.readFileSync(filePath, 'utf8'); | ||
|
||
// Replace any README.md links with root directory ("/") | ||
content = content.replace(/\[.*?\]\((.*?)README\.md\)/g, (match) => { | ||
return '[Admin Docs](/)'; // Redirect broken links to the root | ||
}); | ||
|
||
fs.writeFileSync(filePath, content, 'utf8'); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for file operations.
The function lacks error handling for file system operations which could fail due to permissions or I/O issues.
Apply this diff to add proper error handling:
function replaceLinks(dir) {
- const files = fs.readdirSync(dir);
- files.forEach((file) => {
- const filePath = path.join(dir, file);
- if (fs.lstatSync(filePath).isDirectory()) {
- replaceLinks(filePath);
- } else if (file.endsWith('.md')) {
- let content = fs.readFileSync(filePath, 'utf8');
+ try {
+ const files = fs.readdirSync(dir);
+ files.forEach((file) => {
+ const filePath = path.join(dir, file);
+ try {
+ if (fs.lstatSync(filePath).isDirectory()) {
+ replaceLinks(filePath);
+ } else if (file.endsWith('.md')) {
+ let content = fs.readFileSync(filePath, 'utf8');
- // Replace any README.md links with root directory ("/")
- content = content.replace(/\[.*?\]\((.*?)README\.md\)/g, (match) => {
- return '[Admin Docs](/)'; // Redirect broken links to the root
- });
+ // Replace any README.md links with root directory ("/")
+ content = content.replace(/\[.*?\]\((.*?)README\.md\)/g, (match) => {
+ return '[Admin Docs](/)'; // Redirect broken links to the root
+ });
- fs.writeFileSync(filePath, content, 'utf8');
+ fs.writeFileSync(filePath, content, 'utf8');
+ }
+ } catch (err) {
+ console.error(`Error processing file ${filePath}:`, err);
+ }
+ });
+ } catch (err) {
+ console.error(`Error reading directory ${dir}:`, err);
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function replaceLinks(dir) { | |
const files = fs.readdirSync(dir); | |
files.forEach((file) => { | |
const filePath = path.join(dir, file); | |
if (fs.lstatSync(filePath).isDirectory()) { | |
replaceLinks(filePath); | |
} else if (file.endsWith('.md')) { | |
let content = fs.readFileSync(filePath, 'utf8'); | |
// Replace any README.md links with root directory ("/") | |
content = content.replace(/\[.*?\]\((.*?)README\.md\)/g, (match) => { | |
return '[Admin Docs](/)'; // Redirect broken links to the root | |
}); | |
fs.writeFileSync(filePath, content, 'utf8'); | |
} | |
}); | |
} | |
function replaceLinks(dir) { | |
try { | |
const files = fs.readdirSync(dir); | |
files.forEach((file) => { | |
const filePath = path.join(dir, file); | |
try { | |
if (fs.lstatSync(filePath).isDirectory()) { | |
replaceLinks(filePath); | |
} else if (file.endsWith('.md')) { | |
let content = fs.readFileSync(filePath, 'utf8'); | |
// Replace any README.md links with root directory ("/") | |
content = content.replace(/\[.*?\]\((.*?)README\.md\)/g, (match) => { | |
return '[Admin Docs](/)'; // Redirect broken links to the root | |
}); | |
fs.writeFileSync(filePath, content, 'utf8'); | |
} | |
} catch (err) { | |
console.error(`Error processing file ${filePath}:`, err); | |
} | |
}); | |
} catch (err) { | |
console.error(`Error reading directory ${dir}:`, err); | |
} | |
} |
"check-localstorage": "node scripts/githooks/check-localstorage-usage.js", | ||
"postgenerate-docs": "find docs/docs/auto-docs -name 'README.md' -delete", | ||
"generate-docs": "typedoc && npm run postgenerate-docs && node fix-readme-links.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unauthorized modification of sensitive file.
The package.json
file is listed as a sensitive file that requires authorization to modify. Please request authorization by applying the 'ignore-sensitive-files-pr' label to this PR.
🧰 Tools
🪛 GitHub Actions: PR Workflow
[error] Unauthorized modification or deletion of sensitive file
generate-docs: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout the Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22.x' | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Generate Documentation | ||
run: npm run generate-docs | ||
|
||
- name: Commit and Push Changes | ||
env: | ||
HEAD_REF: ${{ github.head_ref }} | ||
run: | | ||
if [[ $(git status --porcelain) ]]; then | ||
echo "Changes detected. Auto-committing updates." | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add --all | ||
git commit -m "Auto-generate documentation" | ||
if ! git push origin HEAD:"$HEAD_REF"; then | ||
echo "Failed to push changes. Please check if you have the correct permissions." | ||
exit 1 | ||
fi | ||
else | ||
echo "No changes detected." | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unauthorized modification of sensitive file.
The .github/workflows/pull-request.yml
file is listed as a sensitive file that requires authorization to modify. Please request authorization by applying the 'ignore-sensitive-files-pr' label to this PR.
🧰 Tools
🪛 GitHub Actions: PR Workflow
[error] Unauthorized modification or deletion of sensitive file
What kind of change does this PR introduce?
Issue Number:
Fixes #
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Does this PR introduce a breaking change?
Checklist
CodeRabbit AI Review
Test Coverage
Other information
Have you read the contributing guide?
Summary by CodeRabbit
New Features
Chores
Documentation