Skip to content

Commit b3c6b3d

Browse files
Add Power Fx Snippets Validator and tools
- Created package.json for project dependencies and scripts. - Implemented validate-snippets.js for validating metadata and formatting of code snippets. - Added functionality for YAML front matter validation, required fields check, and content validation. - Included options for verbose logging, auto-fixing issues, and category-specific validation. - Established a summary report for validation results, including errors and warnings.
1 parent cb6cfb0 commit b3c6b3d

19 files changed

Lines changed: 5525 additions & 174 deletions

--new-structure-claude-code.md

Lines changed: 1262 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Bug Report
3+
about: Report an issue with an existing snippet
4+
title: "[BUG] "
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Bug Report
10+
11+
**Snippet Location**
12+
Provide the path to the snippet with the issue (e.g., `02-app-architecture/app-events/onstart-error-handling.md`)
13+
14+
**Describe the bug**
15+
A clear and concise description of what's wrong with the snippet.
16+
17+
**Expected behavior**
18+
What should the snippet do correctly?
19+
20+
**Current behavior**
21+
What's happening instead?
22+
23+
**Steps to reproduce**
24+
1. Go to '...'
25+
2. Try to implement '...'
26+
3. See error
27+
28+
**Environment**
29+
- Power Apps version:
30+
- Browser (if applicable):
31+
- Other relevant environment details:
32+
33+
**Screenshots**
34+
If applicable, add screenshots to help explain the problem.
35+
36+
**Additional context**
37+
Add any other context about the problem here.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Documentation Issue
3+
about: Report issues with READMEs, guides, or navigation
4+
title: "[DOCS] "
5+
labels: documentation
6+
assignees: ''
7+
---
8+
9+
## Documentation Issue
10+
11+
**Documentation Location**
12+
Provide the path to the documentation with issues (e.g., `README.md`, `02-app-architecture/README.md`)
13+
14+
**Type of issue**
15+
- [ ] Missing information
16+
- [ ] Outdated content
17+
- [ ] Incorrect information
18+
- [ ] Poor navigation/clarity
19+
- [ ] Broken links
20+
- [ ] Formatting issues
21+
- [ ] Other (please specify)
22+
23+
**Describe the issue**
24+
What's wrong with the documentation?
25+
26+
**Suggested fix**
27+
How should it be corrected or improved?
28+
29+
**Additional context**
30+
Add screenshots, links, or other context that might help.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Improvement Suggestion
3+
about: Suggest improvements to existing snippets or repository structure
4+
title: "[IMPROVEMENT] "
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Improvement Suggestion
10+
11+
**What area needs improvement?**
12+
- [ ] Existing snippet
13+
- [ ] Repository structure
14+
- [ ] Documentation
15+
- [ ] Navigation
16+
- [ ] Tools/Utilities
17+
- [ ] Other (please specify)
18+
19+
**Location (if applicable)**
20+
Provide the path or location of what needs improvement.
21+
22+
**Current situation**
23+
Describe what's currently implemented or how it works.
24+
25+
**Suggested improvement**
26+
Describe your proposed changes or improvements.
27+
28+
**Benefits**
29+
What benefits would this improvement provide?
30+
31+
**Implementation approach**
32+
If you have thoughts on how to implement this, share them here.
33+
34+
**Additional context**
35+
Add any other context or examples.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Snippet Request
3+
about: Request a new Power Fx code snippet
4+
title: "[SNIPPET] "
5+
labels: enhancement, snippet-request
6+
assignees: ''
7+
---
8+
9+
## Snippet Request
10+
11+
**What type of snippet are you requesting?**
12+
- [ ] App Architecture
13+
- [ ] User Interface
14+
- [ ] Data Management
15+
- [ ] Business Logic
16+
- [ ] Integration
17+
- [ ] Assets & Media
18+
- [ ] Advanced Pattern
19+
- [ ] Learning Resource
20+
- [ ] Other (please specify)
21+
22+
**Describe the snippet you need**
23+
A clear and concise description of what the snippet should do.
24+
25+
**Use case**
26+
Describe the specific scenario or problem this snippet would solve.
27+
28+
**Expected code structure**
29+
If you have a rough idea of what the code should look like, describe it here.
30+
31+
**Additional context**
32+
Add any other context, prerequisites, or related snippets here.
33+
34+
**Difficulty level**
35+
- [ ] Beginner
36+
- [ ] Intermediate
37+
- [ ] Advanced
38+
- [ ] Expert
39+
40+
**Would you be willing to contribute this snippet?**
41+
- [ ] Yes, I can provide the code
42+
- [ ] No, just requesting
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Validate Snippets
2+
3+
on:
4+
push:
5+
paths:
6+
- '**/*.md'
7+
- '**/*.yaml'
8+
pull_request:
9+
paths:
10+
- '**/*.md'
11+
- '**/*.yaml'
12+
13+
jobs:
14+
validate:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18'
25+
26+
- name: Install dependencies
27+
run: |
28+
npm install -g markdownlint-cli
29+
npm install -g js-yaml
30+
31+
- name: Validate markdown formatting
32+
run: |
33+
find . -name "*.md" -not -path "./node_modules/*" -not -path "./_archive/*" -exec markdownlint {} \;
34+
35+
- name: Validate YAML front matter
36+
run: |
37+
#!/bin/bash
38+
find . -name "*.md" -not -path "./node_modules/*" -not -path "./_archive/*" | while read file; do
39+
if head -n 20 "$file" | grep -q "^---$"; then
40+
echo "Validating front matter in $file"
41+
# Extract front matter and validate YAML
42+
awk '/^---$/ { if (++count == 2) exit; next } count == 1 { print }' "$file" | js-yaml --validate || echo "Invalid YAML in $file"
43+
fi
44+
done
45+
46+
- name: Check for required metadata fields
47+
run: |
48+
#!/bin/bash
49+
find . -name "*.md" -not -path "./node_modules/*" -not -path "./_archive/*" -not -path "./README.md" | while read file; do
50+
if head -n 20 "$file" | grep -q "^---$"; then
51+
front_matter=$(awk '/^---$/ { if (++count == 2) exit; next } count == 1 { print }' "$file")
52+
if ! echo "$front_matter" | grep -q "title:"; then
53+
echo "Missing 'title' field in $file"
54+
exit 1
55+
fi
56+
if ! echo "$front_matter" | grep -q "description:"; then
57+
echo "Missing 'description' field in $file"
58+
exit 1
59+
fi
60+
if ! echo "$front_matter" | grep -q "category:"; then
61+
echo "Missing 'category' field in $file"
62+
exit 1
63+
fi
64+
if ! echo "$front_matter" | grep -q "difficulty:"; then
65+
echo "Missing 'difficulty' field in $file"
66+
exit 1
67+
fi
68+
fi
69+
done
70+
71+
- name: Validate internal links
72+
run: |
73+
#!/bin/bash
74+
find . -name "*.md" -not -path "./node_modules/*" -not -path "./_archive/*" | while read file; do
75+
# Check for broken relative links
76+
grep -n "\[.*\](\.\." "$file" | while read line; do
77+
link=$(echo "$line" | grep -o "\[.*\](\.\.[^)]*)" | sed 's/.*(//' | sed 's/).*//')
78+
if [ -n "$link" ]; then
79+
# Resolve the relative path
80+
dir=$(dirname "$file")
81+
target="$dir/$link"
82+
if [ ! -f "$target" ] && [ ! -d "$target" ]; then
83+
echo "Broken link in $file: $link"
84+
fi
85+
fi
86+
done
87+
done

0 commit comments

Comments
 (0)