Skip to content

Commit 2759acf

Browse files
Commerce agent messaging LWC custom components (#31)
Co-authored-by: Mike McMahon <[email protected]>
1 parent 8e29cad commit 2759acf

File tree

128 files changed

+31166
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+31166
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 4
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.eslintrc.cjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2025, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
* For full license text, see the LICENSE file in the repo
6+
* root or https://opensource.org/licenses/apache-2.0/
7+
*/
8+
module.exports = {
9+
extends: ['@salesforce/eslint-config-lwc/recommended', 'plugin:jsdoc/recommended'],
10+
plugins: ['notice', 'prettier', 'jsdoc'],
11+
rules: {
12+
'notice/notice': [
13+
'error',
14+
{
15+
mustMatch: 'Copyright \\(c\\) \\d{4}, salesforce.com, inc.',
16+
template: [
17+
'/*',
18+
' * Copyright (c) <%= YEAR %>, salesforce.com, inc.',
19+
' * All rights reserved.',
20+
' * SPDX-License-Identifier: Apache-2.0',
21+
' * For full license text, see the LICENSE file in the repo',
22+
' * root or https://opensource.org/licenses/apache-2-0/',
23+
' */',
24+
'',
25+
].join('\n'),
26+
},
27+
],
28+
'prettier/prettier': 'error',
29+
'jsdoc/check-tag-names': ['warn', { definedTags: ['slot'] }],
30+
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
31+
},
32+
overrides: [
33+
{
34+
files: ['*.test.js'],
35+
rules: {
36+
'@lwc/lwc/no-unexpected-wire-adapter-usages': 'off',
37+
},
38+
env: {
39+
node: true,
40+
},
41+
},
42+
{
43+
files: ['*.config.js', '.eslintrc.cjs'],
44+
env: {
45+
node: true,
46+
},
47+
},
48+
],
49+
};

.forceignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
2+
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
3+
#
4+
5+
package.xml
6+
7+
# LWC configuration files
8+
**/jsconfig.json
9+
**/.eslintrc.json
10+
11+
# LWC Jest
12+
**/__tests__/**

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Comment line immediately above ownership line is reserved for related other information. Please be careful while editing.
2+
#ECCN:Open Source
3+
4+
# Code Owners
5+
*

.github/branch-protection.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Branch Protection Configuration
2+
# This file serves as documentation for required branch protection settings
3+
# Apply these settings in GitHub repository settings under Branches > Add rule
4+
5+
branch_protection_rules:
6+
main:
7+
required_status_checks:
8+
strict: true
9+
contexts:
10+
- 'Validate Code'
11+
- 'Code Quality'
12+
- 'Security Checks'
13+
- 'Commit Message Check'
14+
15+
enforce_admins: true
16+
17+
required_pull_request_reviews:
18+
required_approving_review_count: 2
19+
dismiss_stale_reviews: true
20+
require_code_owner_reviews: true
21+
require_last_push_approval: true
22+
23+
restrictions:
24+
users: []
25+
teams: []
26+
27+
allow_force_pushes: false
28+
allow_deletions: false
29+
30+
required_conversation_resolution: true
31+
require_linear_history: true
32+
require_signed_commits: false
33+
34+
develop:
35+
required_status_checks:
36+
strict: true
37+
contexts:
38+
- 'Validate Code'
39+
- 'Code Quality'
40+
- 'Security Checks'
41+
42+
enforce_admins: false
43+
44+
required_pull_request_reviews:
45+
required_approving_review_count: 1
46+
dismiss_stale_reviews: true
47+
require_code_owner_reviews: false
48+
require_last_push_approval: false
49+
50+
restrictions:
51+
users: []
52+
teams: []
53+
54+
allow_force_pushes: false
55+
allow_deletions: false
56+
57+
required_conversation_resolution: true
58+
require_linear_history: false
59+
require_signed_commits: false
60+
# Quality Gates Summary:
61+
# 1. Code Coverage: Minimum 90% (enforced by Jest config)
62+
# 2. Linting: No ESLint errors (enforced by CI)
63+
# 3. Formatting: Prettier compliance (enforced by CI)
64+
# 4. Tests: All tests must pass (enforced by CI)
65+
# 5. Warnings: No console.warn/error (enforced by CI)
66+
# 6. Security: npm audit passes (enforced by CI)
67+
# 7. Commit Messages: Conventional commits (enforced by CI)

.github/workflows/pr-checks.yml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: Pull Request Checks
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
push:
7+
branches: [main, develop]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
validate:
15+
name: Validate Code
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0 # Fetch all history for better git operations
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: '18'
27+
cache: 'npm'
28+
29+
- name: Cache Jest
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/jest
33+
key: ${{ runner.os }}-jest-${{ hashFiles('**/package-lock.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-jest-
36+
37+
- name: Install Dependencies
38+
run: npm ci
39+
40+
- name: Run Linting
41+
run: npm run lint
42+
continue-on-error: false
43+
44+
- name: Check Code Formatting
45+
run: npm run format:verify
46+
continue-on-error: false
47+
48+
- name: Run Tests with Coverage and Check Warnings
49+
run: |
50+
# Run tests and capture output
51+
TEST_OUTPUT=$(npm run test:unit:coverage:ci 2>&1)
52+
TEST_EXIT_CODE=$?
53+
54+
# Display test output
55+
echo "$TEST_OUTPUT"
56+
57+
# Check for test failures first
58+
if [ $TEST_EXIT_CODE -ne 0 ]; then
59+
echo "❌ Tests failed"
60+
exit 1
61+
fi
62+
63+
# Check for unexpected warnings/errors
64+
UNEXPECTED_WARNINGS=$(echo "$TEST_OUTPUT" | grep -E "(console\.warn|console\.error|console\.log|Warning|Error)" | grep -v "grep -E" || true)
65+
66+
if [ -n "$UNEXPECTED_WARNINGS" ]; then
67+
echo "❌ Unexpected test warnings or errors detected:"
68+
echo "$UNEXPECTED_WARNINGS"
69+
exit 1
70+
else
71+
echo "✅ No unexpected test warnings or errors detected"
72+
fi
73+
env:
74+
CI: true # Ensures test output is optimized for CI
75+
continue-on-error: false
76+
77+
- name: Upload Coverage Report
78+
uses: actions/upload-artifact@v3
79+
with:
80+
name: coverage-report
81+
path: coverage/
82+
retention-days: 7
83+
84+
- name: Check Coverage Threshold
85+
run: |
86+
if [ -f "coverage/lcov-report/index.html" ]; then
87+
echo "Coverage report generated successfully"
88+
else
89+
echo "Coverage report not found"
90+
exit 1
91+
fi
92+
93+
# Check if coverage meets thresholds (90% as defined in jest.config.js)
94+
COVERAGE_THRESHOLD=90
95+
96+
# Extract coverage percentages from lcov.info
97+
if [ -f "coverage/lcov.info" ]; then
98+
echo "Checking coverage thresholds..."
99+
100+
# Check statements coverage
101+
STATEMENTS_COVERAGE=$(grep -o "SF:[0-9]*" coverage/lcov.info | wc -l)
102+
STATEMENTS_HIT=$(grep -o "LH:[0-9]*" coverage/lcov.info | awk -F: '{sum+=$2} END {print sum}')
103+
if [ "$STATEMENTS_HIT" -eq 0 ]; then
104+
STATEMENTS_HIT=0
105+
fi
106+
STATEMENTS_PERCENT=$((STATEMENTS_HIT * 100 / STATEMENTS_COVERAGE))
107+
108+
echo "Statements coverage: $STATEMENTS_PERCENT%"
109+
110+
if [ "$STATEMENTS_PERCENT" -lt "$COVERAGE_THRESHOLD" ]; then
111+
echo "❌ Statements coverage ($STATEMENTS_PERCENT%) is below threshold ($COVERAGE_THRESHOLD%)"
112+
exit 1
113+
fi
114+
115+
echo "✅ Coverage thresholds met"
116+
else
117+
echo "❌ Coverage report (lcov.info) not found"
118+
exit 1
119+
fi
120+
121+
- name: Comment PR with Coverage Report
122+
if: github.event_name == 'pull_request'
123+
uses: actions/github-script@v6
124+
with:
125+
script: |
126+
const fs = require('fs');
127+
const path = require('path');
128+
129+
try {
130+
const coveragePath = path.join(process.cwd(), 'coverage', 'lcov-report', 'index.html');
131+
if (fs.existsSync(coveragePath)) {
132+
const coverageContent = fs.readFileSync(coveragePath, 'utf8');
133+
const coverageMatch = coverageContent.match(/<span class="strong">(\d+\.?\d*)%<\/span>/);
134+
135+
if (coverageMatch) {
136+
const coverage = coverageMatch[1];
137+
const comment = `## 📊 Code Coverage Report
138+
139+
**Overall Coverage: ${coverage}%**
140+
141+
✅ Coverage meets the required threshold of 90%
142+
143+
[View detailed coverage report](${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts)`;
144+
145+
github.rest.issues.createComment({
146+
issue_number: context.issue.number,
147+
owner: context.repo.owner,
148+
repo: context.repo.repo,
149+
body: comment
150+
});
151+
}
152+
}
153+
} catch (error) {
154+
console.log('Could not create coverage comment:', error.message);
155+
}
156+
157+
code-quality:
158+
name: Code Quality
159+
runs-on: ubuntu-latest
160+
161+
steps:
162+
- uses: actions/checkout@v3
163+
164+
- name: Setup Node.js
165+
uses: actions/setup-node@v3
166+
with:
167+
node-version: '18'
168+
cache: 'npm'
169+
170+
- name: Install Dependencies
171+
run: npm ci
172+
173+
- name: Check LWC Component Structure
174+
run: |
175+
# Check if all LWC components have required files
176+
for dir in force-app/main/default/lwc/*/; do
177+
if [ ! -f "${dir}${dir%/}.js" ] || [ ! -f "${dir}${dir%/}.html" ]; then
178+
echo "Error: Component ${dir%/} is missing required files"
179+
exit 1
180+
fi
181+
done
182+
183+
security:
184+
name: Security Checks
185+
runs-on: ubuntu-latest
186+
187+
steps:
188+
- uses: actions/checkout@v3
189+
190+
- name: Setup Node.js
191+
uses: actions/setup-node@v3
192+
with:
193+
node-version: '18'
194+
cache: 'npm'
195+
196+
- name: Install Dependencies
197+
run: npm ci
198+
199+
- name: Run npm audit
200+
run: npm audit --production
201+
202+
- name: Run npm outdated
203+
run: npm outdated || true # Don't fail the build if there are outdated packages
204+
205+
commit-message:
206+
name: Commit Message Check
207+
runs-on: ubuntu-latest
208+
steps:
209+
- uses: actions/checkout@v3
210+
with:
211+
fetch-depth: 0
212+
213+
- name: Setup Node.js
214+
uses: actions/setup-node@v3
215+
with:
216+
node-version: '18'
217+
cache: 'npm'
218+
219+
- name: Install Dependencies
220+
run: npm ci
221+
222+
- name: Check Commit Messages
223+
run: npx commitlint --from=HEAD~1 --to=HEAD

0 commit comments

Comments
 (0)