Skip to content

Commit ac4eb59

Browse files
committed
Formatted and added tests and ci/cd files
1 parent 1bf61c1 commit ac4eb59

Some content is hidden

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

65 files changed

+3555
-1810
lines changed

.eslintrc.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@
33
"env": { "browser": true, "es2020": true },
44
"extends": [
55
"eslint:recommended",
6-
"@typescript-eslint/recommended",
6+
"plugin:@typescript-eslint/recommended",
77
"plugin:react-hooks/recommended",
8-
"@typescript-eslint/recommended-requiring-type-checking"
8+
"plugin:prettier/recommended"
99
],
10-
"ignorePatterns": ["dist", ".eslintrc.cjs"],
10+
"ignorePatterns": ["dist", ".eslintrc.cjs", "example", "node_modules", "playwright.config.ts", "tests"],
1111
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaVersion": "latest",
14+
"sourceType": "module",
15+
"project": ["./tsconfig.json", "./tsconfig.node.json"],
16+
"tsconfigRootDir": "./"
17+
},
1218
"plugins": ["react-refresh"],
1319
"rules": {
1420
"react-refresh/only-export-components": [
1521
"warn",
1622
{ "allowConstantExport": true }
17-
]
23+
],
24+
"@typescript-eslint/no-explicit-any": "off"
1825
}
19-
}
26+
}

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '18'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run linting
26+
run: npm run lint
27+
28+
- name: Run type checking
29+
run: npm run type-check
30+
31+
- name: Check formatting
32+
run: npm run format:check
33+
34+
- name: Build library
35+
run: npm run build
36+
37+
- name: Build widget
38+
run: npm run build:widget
39+
40+
- name: Install Playwright
41+
run: npx playwright install chromium
42+
43+
- name: Run widget tests
44+
run: npm run test:ci
45+
46+
- name: Upload test results
47+
if: always()
48+
uses: actions/upload-artifact@v3
49+
with:
50+
name: playwright-report
51+
path: playwright-report/
52+
retention-days: 30

.github/workflows/publish.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '18'
18+
cache: 'npm'
19+
registry-url: 'https://registry.npmjs.org'
20+
21+
- name: Validate version
22+
run: |
23+
# Extract version from package.json
24+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
25+
26+
# Extract version from GitHub release tag (remove 'v' prefix if present)
27+
RELEASE_VERSION=${GITHUB_REF_NAME#v}
28+
29+
echo "Package version: $PACKAGE_VERSION"
30+
echo "Release version: $RELEASE_VERSION"
31+
32+
if [ "$PACKAGE_VERSION" != "$RELEASE_VERSION" ]; then
33+
echo "❌ Error: package.json version ($PACKAGE_VERSION) does not match release tag ($RELEASE_VERSION)"
34+
echo "Please ensure package.json version is updated before creating a release"
35+
exit 1
36+
fi
37+
38+
echo "✅ Version validation passed"
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Run linting
44+
run: npm run lint
45+
46+
- name: Run type checking
47+
run: npm run type-check
48+
49+
- name: Check formatting
50+
run: npm run format:check
51+
52+
- name: Build library
53+
run: npm run build
54+
55+
- name: Build widget
56+
run: npm run build:widget
57+
58+
- name: Install Playwright
59+
run: npx playwright install chromium
60+
61+
- name: Run widget tests
62+
run: npm run test:ci
63+
64+
- name: Publish to npm
65+
run: npm publish
66+
env:
67+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
68+
69+
- name: Upload test results
70+
if: always()
71+
uses: actions/upload-artifact@v3
72+
with:
73+
name: playwright-report
74+
path: playwright-report/
75+
retention-days: 30

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,9 @@ Thumbs.db
107107
*.stackdump
108108

109109
# NPM
110-
package-lock.json.bak
110+
package-lock.json.bak
111+
112+
# Playwright test artifacts
113+
playwright-report/
114+
test-results/
115+
playwright/.cache/

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
access=public
2+
registry=https://registry.npmjs.org/

.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Production
5+
dist/
6+
7+
# Lock files
8+
package-lock.json
9+
pnpm-lock.yaml
10+
yarn.lock
11+
12+
# Misc
13+
.DS_Store
14+
*.pem

.prettierrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf"
10+
}

0 commit comments

Comments
 (0)