Skip to content

Commit c4f804a

Browse files
authored
Merge pull request #13 from lzinga/dev
Updated to use TypeScript, reorganized folder structure, and made the demo available on GitHub Pages.
2 parents a99eb25 + d94d0fd commit c4f804a

36 files changed

+3707
-749
lines changed

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [main, master, dev]
6+
pull_request:
7+
branches: [main, master, dev]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [18, 20, 22]
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Check TypeScript compilation
28+
run: npm run type-check
29+
30+
- name: Run tests with coverage
31+
run: npm run test:run
32+
33+
- name: Build package
34+
run: npm run build
35+
36+
- name: Verify build output
37+
run: |
38+
test -f dist/index.js
39+
test -f dist/index.d.ts
40+
echo "Build verification successful"
41+
42+
lint:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: '20'
51+
cache: 'npm'
52+
53+
- name: Install dependencies
54+
run: npm ci
55+
56+
- name: Check TypeScript
57+
run: npm run type-check
58+
59+
- name: Verify package integrity
60+
run: npm run prepublishOnly --dry-run || echo "Package preparation check complete"
61+
62+
demo-test:
63+
runs-on: ubuntu-latest
64+
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: '20'
72+
cache: 'npm'
73+
74+
- name: Install root dependencies
75+
run: npm ci
76+
77+
- name: Build package
78+
run: npm run build
79+
80+
- name: Install demo dependencies
81+
run: |
82+
cd demo
83+
npm ci
84+
85+
- name: Build demo
86+
run: |
87+
cd demo
88+
npm run build

.github/workflows/deploy-demo.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Deploy Demo to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
cache: 'npm'
29+
30+
- name: Install root dependencies
31+
run: npm ci
32+
33+
- name: Build package
34+
run: npm run build
35+
36+
- name: Install demo dependencies
37+
run: |
38+
cd demo
39+
npm ci
40+
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v4
43+
44+
- name: Build demo for GitHub Pages
45+
run: |
46+
cd demo
47+
npm run build
48+
env:
49+
NODE_ENV: production
50+
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: './demo/build'
55+
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
runs-on: ubuntu-latest
61+
needs: build
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4

.github/workflows/main.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-npm:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: '20'
17+
cache: 'npm'
18+
registry-url: 'https://registry.npmjs.org'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run tests
24+
run: npm test
25+
26+
- name: Build package
27+
run: npm run build
28+
29+
- name: Check if version exists on npm
30+
id: check-npm-version
31+
run: |
32+
PACKAGE_NAME=$(node -p "require('./package.json').name")
33+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
34+
35+
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version > /dev/null 2>&1; then
36+
echo "Version $PACKAGE_VERSION already exists on npm"
37+
echo "exists=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "Version $PACKAGE_VERSION does not exist on npm"
40+
echo "exists=false" >> $GITHUB_OUTPUT
41+
fi
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
- name: Publish to npm
46+
if: steps.check-npm-version.outputs.exists == 'false'
47+
run: npm publish --access public
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
51+
- name: Skip npm publish
52+
if: steps.check-npm-version.outputs.exists == 'true'
53+
run: echo "Skipping npm publish - version already exists"
54+
55+
publish-github:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: '20'
64+
cache: 'npm'
65+
registry-url: 'https://npm.pkg.github.com'
66+
67+
- name: Install dependencies
68+
run: npm ci
69+
70+
- name: Build package
71+
run: npm run build
72+
73+
- name: Check if version exists on GitHub Packages
74+
id: check-github-version
75+
run: |
76+
PACKAGE_NAME=$(node -p "require('./package.json').name")
77+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
78+
79+
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version > /dev/null 2>&1; then
80+
echo "Version $PACKAGE_VERSION already exists on GitHub Packages"
81+
echo "exists=true" >> $GITHUB_OUTPUT
82+
else
83+
echo "Version $PACKAGE_VERSION does not exist on GitHub Packages"
84+
echo "exists=false" >> $GITHUB_OUTPUT
85+
fi
86+
env:
87+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Publish to GitHub Packages
90+
if: steps.check-github-version.outputs.exists == 'false'
91+
run: npm publish --access public
92+
env:
93+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- name: Skip GitHub Packages publish
96+
if: steps.check-github-version.outputs.exists == 'true'
97+
run: echo "Skipping GitHub Packages publish - version already exists"

.gitignore

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
1-
node_modules
2-
.DS_STORE
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build outputs
8+
dist/
9+
build/
10+
*.tsbuildinfo
11+
12+
# Environment files
13+
.env
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
# IDE and editor files
20+
.vscode/settings.json
21+
.idea/
22+
*.swp
23+
*.swo
24+
*~
25+
26+
# OS generated files
27+
.DS_Store
28+
.DS_Store?
29+
._*
30+
.Spotlight-V100
31+
.Trashes
32+
ehthumbs.db
33+
Thumbs.db
34+
35+
# Logs
36+
logs/
37+
*.log
38+
39+
# Coverage reports
40+
coverage/
41+
.nyc_output/
42+
43+
# Temporary files
44+
*.tmp
45+
*.temp
46+
.cache/
47+
48+
# Package manager lock files (keep package-lock.json for consistency)
49+
# yarn.lock
50+
# pnpm-lock.yaml

0 commit comments

Comments
 (0)