@xrmforge/devkit 0.7.12 → 0.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/templates/AGENT.md +707 -704
- package/dist/templates/azure-pipelines.yml +7 -11
- package/dist/templates/constants.ts +32 -32
- package/dist/templates/error-handler.ts +96 -96
- package/dist/templates/eslint.config.js +21 -21
- package/dist/templates/example-form.test.ts +33 -33
- package/dist/templates/example-form.ts +77 -77
- package/dist/templates/github-actions-ci.yml +7 -11
- package/dist/templates/logger.ts +67 -67
- package/dist/templates/validate-form.mjs +393 -356
- package/package.json +1 -1
- package/dist/templates/self-check.sh +0 -106
package/package.json
CHANGED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# XrmForge Self-Check - Pattern Compliance Verification
|
|
3
|
-
# Run this before tests to catch common violations.
|
|
4
|
-
# Exit code: 0 = all clean, 1 = violations found
|
|
5
|
-
|
|
6
|
-
set -uo pipefail
|
|
7
|
-
|
|
8
|
-
RED='\033[0;31m'
|
|
9
|
-
GREEN='\033[0;32m'
|
|
10
|
-
YELLOW='\033[0;33m'
|
|
11
|
-
NC='\033[0m'
|
|
12
|
-
|
|
13
|
-
violations=0
|
|
14
|
-
category_count=0
|
|
15
|
-
|
|
16
|
-
check() {
|
|
17
|
-
local label="$1"
|
|
18
|
-
shift
|
|
19
|
-
local count
|
|
20
|
-
count=$("$@" 2>/dev/null | wc -l | tr -d ' ')
|
|
21
|
-
category_count=$((category_count + 1))
|
|
22
|
-
if [ "$count" -gt 0 ]; then
|
|
23
|
-
echo -e "${RED}FAIL${NC} [$count] $label"
|
|
24
|
-
"$@" 2>/dev/null | head -20
|
|
25
|
-
violations=$((violations + count))
|
|
26
|
-
else
|
|
27
|
-
echo -e "${GREEN}OK${NC} [0] $label"
|
|
28
|
-
fi
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
echo "=== XrmForge Self-Check ==="
|
|
32
|
-
echo ""
|
|
33
|
-
echo "--- Pattern Compliance ---"
|
|
34
|
-
|
|
35
|
-
check "Raw field strings in getAttribute/getControl (must use Fields Enum)" \
|
|
36
|
-
bash -c 'grep -rn "getAttribute('" '"'"'" src/forms/ --include="*.ts" | grep -v "Fields\." ; grep -rn "getControl('" '"'"'" src/forms/ --include="*.ts" | grep -v "Fields\."'
|
|
37
|
-
|
|
38
|
-
check "Magic numbers in OptionSet comparisons (must use OptionSet Enum)" \
|
|
39
|
-
bash -c 'grep -rn "getValue() ===" src/ --include="*.ts" | grep -E "[0-9]{3,}"'
|
|
40
|
-
|
|
41
|
-
check "Direct _value access instead of parseLookup (Web API responses)" \
|
|
42
|
-
bash -c 'grep -rn "_value\b" src/ --include="*.ts" | grep -v "generated/" | grep -v "parseLookup" | grep -v "getValue"'
|
|
43
|
-
|
|
44
|
-
check "Raw entity names in WebApi calls (must use EntityNames)" \
|
|
45
|
-
bash -c 'grep -rn "retrieveRecord\|retrieveMultipleRecords\|deleteRecord\|createRecord\|updateRecord" src/ --include="*.ts" | grep "'"'"'[a-z]" | grep -v "EntityNames"'
|
|
46
|
-
|
|
47
|
-
check "Raw \$select strings (must use select() from @xrmforge/helpers)" \
|
|
48
|
-
bash -c 'grep -rn '"'"'\$select'"'"' src/ --include="*.ts" | grep -v "select(" | grep -v "generated/"'
|
|
49
|
-
|
|
50
|
-
check "FormContext base cast (use typedForm<Form>() instead of 'as Xrm.FormContext')" \
|
|
51
|
-
bash -c 'grep -rnE "as (unknown as )?Xrm\.FormContext" src/forms/ --include="*.ts"'
|
|
52
|
-
|
|
53
|
-
check "Exported handlers without wrapHandler" \
|
|
54
|
-
bash -c 'grep -rn "^export const\|^export async function\|^export function" src/forms/ --include="*.ts" | grep -v "wrapHandler"'
|
|
55
|
-
|
|
56
|
-
echo ""
|
|
57
|
-
echo "--- Code Quality ---"
|
|
58
|
-
|
|
59
|
-
check "console.* outside logger.ts" \
|
|
60
|
-
bash -c 'grep -rn "console\." src/ --include="*.ts" | grep -v "logger.ts" | grep -v "^\s*\*" | grep -v "^\s*//"'
|
|
61
|
-
|
|
62
|
-
check "Xrm.Page (deprecated since D365 v9.0)" \
|
|
63
|
-
bash -c 'grep -rn "Xrm\.Page" src/ --include="*.ts" | grep -v "^\s*\*" | grep -v "^\s*//"'
|
|
64
|
-
|
|
65
|
-
check "var declarations" \
|
|
66
|
-
bash -c 'grep -rnE "^\s*var " src/ --include="*.ts"'
|
|
67
|
-
|
|
68
|
-
check "eval()" \
|
|
69
|
-
bash -c 'grep -rn "\beval(" src/ --include="*.ts"'
|
|
70
|
-
|
|
71
|
-
check "XMLHttpRequest" \
|
|
72
|
-
bash -c 'grep -rn "XMLHttpRequest" src/ --include="*.ts"'
|
|
73
|
-
|
|
74
|
-
check "as any without eslint-disable comment" \
|
|
75
|
-
bash -c 'grep -rn "as any" src/ --include="*.ts" | grep -v "eslint-disable"'
|
|
76
|
-
|
|
77
|
-
check "Import from @xrmforge/typegen in browser code (use @xrmforge/helpers)" \
|
|
78
|
-
bash -c 'grep -rn "from.*@xrmforge/typegen" src/ --include="*.ts" | grep -v "generated/"'
|
|
79
|
-
|
|
80
|
-
echo ""
|
|
81
|
-
echo "--- Test Completeness ---"
|
|
82
|
-
|
|
83
|
-
missing_tests=0
|
|
84
|
-
for f in src/forms/*.ts; do
|
|
85
|
-
[ -f "$f" ] || continue
|
|
86
|
-
base=$(basename "$f" .ts)
|
|
87
|
-
if [ ! -f "tests/forms/${base}.test.ts" ]; then
|
|
88
|
-
echo -e "${YELLOW}WARN${NC} No test file: $f"
|
|
89
|
-
missing_tests=$((missing_tests + 1))
|
|
90
|
-
fi
|
|
91
|
-
done
|
|
92
|
-
if [ "$missing_tests" -eq 0 ]; then
|
|
93
|
-
echo -e "${GREEN}OK${NC} All form scripts have test files"
|
|
94
|
-
else
|
|
95
|
-
echo -e "${YELLOW}WARN${NC} $missing_tests form scripts without tests"
|
|
96
|
-
fi
|
|
97
|
-
|
|
98
|
-
echo ""
|
|
99
|
-
echo "=== Results ==="
|
|
100
|
-
if [ "$violations" -eq 0 ]; then
|
|
101
|
-
echo -e "${GREEN}All $category_count checks passed. 0 violations.${NC}"
|
|
102
|
-
exit 0
|
|
103
|
-
else
|
|
104
|
-
echo -e "${RED}$violations violations found across $category_count checks.${NC}"
|
|
105
|
-
exit 1
|
|
106
|
-
fi
|