Skip to content

Commit 85a6da0

Browse files
authored
Merge pull request #35 from jamiefdhurst/improve-build-process
chore: improve build and update deps
2 parents 3732aac + bbe2aab commit 85a6da0

33 files changed

+5185
-1952
lines changed

.eslintignore

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

.eslintrc

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

.github/COMMIT_CONVENTION.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Commit Message Convention
2+
3+
This project uses a commit message convention to automatically determine version bumps and generate changelogs.
4+
5+
## Format
6+
7+
All commit messages must follow this format:
8+
9+
```
10+
<type>[optional scope]: <description>
11+
```
12+
13+
## Commit Types
14+
15+
### Version Bumps
16+
17+
These commit types will trigger a new release:
18+
19+
| Type | Version Bump | Description | Example |
20+
| --------------------------- | ----------------- | ------------------------------ | --------------------------------- |
21+
| `feat:`, `feature:`, `add:` | **Minor** (0.X.0) | New features or additions | `feat: Add user authentication` |
22+
| `fix:`, `bug:` | **Patch** (0.0.X) | Bug fixes | `fix: Resolve login issue` |
23+
| `update:`, `refactor:` | **Patch** (0.0.X) | Code improvements | `refactor: Simplify API client` |
24+
| `improve:`, `perf:` | **Patch** (0.0.X) | Performance improvements | `perf: Optimize database queries` |
25+
| `breaking:`, `major:` | **Major** (X.0.0) | Breaking changes | `breaking: Remove deprecated API` |
26+
| `<type>!:` | **Major** (X.0.0) | Breaking change (conventional) | `feat!: Redesign authentication` |
27+
28+
### No Version Bump
29+
30+
These commit types will NOT trigger a release:
31+
32+
| Type | Description | Example |
33+
| ----------------- | ----------------------- | ------------------------------ |
34+
| `docs:`, `doc:` | Documentation changes | `docs: Update README` |
35+
| `test:`, `tests:` | Test changes only | `test: Add integration tests` |
36+
| `chore:` | Maintenance tasks | `chore: Update dependencies` |
37+
| `build:` | Build system changes | `build: Update webpack config` |
38+
| `ci:` | CI/CD changes | `ci: Add new workflow step` |
39+
| `style:` | Code style/formatting | `style: Run prettier` |
40+
| `revert:` | Revert previous commits | `revert: Revert feature X` |
41+
42+
## Scopes (Optional)
43+
44+
You can add a scope to provide more context:
45+
46+
```
47+
feat(auth): Add OAuth support
48+
fix(api): Resolve timeout issue
49+
chore(deps): Update packages
50+
```
51+
52+
## Examples
53+
54+
### Good Commit Messages
55+
56+
```
57+
feat: Add dark mode toggle
58+
fix(ui): Resolve button alignment issue
59+
docs: Update installation instructions
60+
chore(deps): Bump lodash from 4.17.19 to 4.17.21
61+
refactor: Extract validation logic
62+
perf: Optimize image loading
63+
breaking: Remove support for Node 12
64+
build: Update webpack to v5
65+
ci: Add code coverage reporting
66+
style: Apply prettier formatting
67+
revert: Revert "Add experimental feature"
68+
```
69+
70+
### Bad Commit Messages (Will be Rejected)
71+
72+
```
73+
Update files
74+
WIP
75+
quick fix
76+
Fixed bug
77+
Added feature
78+
```
79+
80+
## Automatic Validation
81+
82+
Commit messages are validated in two places:
83+
84+
1. **Locally (git hook)**: When you commit, a git hook validates your message. If invalid, you'll see a helpful error message with examples.
85+
2. **In CI (GitHub Actions)**: All commits in a pull request are validated using the same hook. The PR will fail if any commits don't follow the convention.
86+
87+
This ensures everyone follows the same standards, whether they have git hooks installed or not.
88+
89+
## Version Calculation
90+
91+
- Pull requests show a comment indicating what version bump will occur
92+
- When merged to main, the version is automatically calculated and released
93+
- Only commits with releasable types trigger new versions
94+
95+
## Special Cases
96+
97+
- Merge commits are automatically skipped from validation
98+
- `[skip ci]` commits (auto-generated) are skipped from validation
99+
- Only non-releasable changes (docs/test/chore/build/ci/style/revert) won't trigger a release
100+
- If a PR contains both releasable and non-releasable commits, a release will be triggered
101+
- Dependabot is configured to use `chore(deps):` format automatically

.github/dependabot.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
open-pull-requests-limit: 10
10+
commit-message:
11+
prefix: "chore"
12+
prefix-development: "chore"
13+
include: "scope"
14+
ignore:
15+
# Keep Obsidian at current version - controlled via package.json overrides
16+
- dependency-name: "obsidian"
17+
groups:
18+
# Group all TypeScript/ESLint related updates
19+
typescript-eslint:
20+
patterns:
21+
- "@typescript-eslint/*"
22+
- "typescript"
23+
# Group all Jest related updates
24+
jest:
25+
patterns:
26+
- "jest*"
27+
- "@types/jest"
28+
- "ts-jest"
29+
# Group development tools
30+
dev-tools:
31+
patterns:
32+
- "prettier"
33+
- "husky"
34+
- "lint-staged"
35+
- "eslint"
36+
37+
# Enable version updates for GitHub Actions
38+
- package-ecosystem: "github-actions"
39+
directory: "/"
40+
schedule:
41+
interval: "weekly"
42+
day: "monday"
43+
open-pull-requests-limit: 5
44+
labels:
45+
- "⬆️ dependencies"
46+
commit-message:
47+
prefix: "chore"
48+
include: "scope"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
3+
# Get the latest tag, or default to 0.0.0 if no tags exist
4+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
5+
echo "Latest tag: $LATEST_TAG"
6+
7+
# Get commits since the latest tag
8+
if [ "$LATEST_TAG" = "0.0.0" ]; then
9+
COMMITS=$(git log --pretty=format:"%s" --no-merges)
10+
else
11+
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s" --no-merges)
12+
fi
13+
14+
# Initialize bump type and releasable commits flag
15+
BUMP_TYPE="patch"
16+
HAS_RELEASABLE_COMMITS=false
17+
18+
# Analyze commits to determine bump type
19+
while IFS= read -r commit; do
20+
# Skip empty lines
21+
[ -z "$commit" ] && continue
22+
23+
# Convert to lowercase for case-insensitive matching
24+
commit_lower=$(echo "$commit" | tr '[:upper:]' '[:lower:]')
25+
26+
# Skip commits that are only documentation, tests, chores, build, ci, style, or reverts
27+
if [[ "$commit_lower" =~ ^docs?(\(.*\))?:|^documentation:|^test(s)?(\(.*\))?:|^chore(\(.*\))?:|^build(\(.*\))?:|^ci(\(.*\))?:|^style(\(.*\))?:|^revert(\(.*\))?: ]] || \
28+
[[ "$commit_lower" =~ ^update.*documentation|^update.*readme|^update.*test ]]; then
29+
echo "Skipping non-release commit: $commit"
30+
continue
31+
fi
32+
33+
# Mark that we have at least one releasable commit
34+
HAS_RELEASABLE_COMMITS=true
35+
36+
# Check for major version indicators
37+
if [[ "$commit_lower" =~ ^breaking|^major|breaking\ change|breaking:|^[^:]+\!: ]]; then
38+
BUMP_TYPE="major"
39+
echo "Found breaking change: $commit"
40+
break
41+
fi
42+
43+
# Check for minor version indicators (features, additions)
44+
if [[ "$commit_lower" =~ ^feat|^feature|^add|^minor ]]; then
45+
if [ "$BUMP_TYPE" != "major" ]; then
46+
BUMP_TYPE="minor"
47+
echo "Found feature/addition: $commit"
48+
fi
49+
fi
50+
51+
# Everything else defaults to patch (fixes, updates, refactors, etc.)
52+
done <<< "$COMMITS"
53+
54+
# If only non-releasable commits were found, don't create a release
55+
if [ "$HAS_RELEASABLE_COMMITS" = false ]; then
56+
echo "Only non-releasable changes found (docs/test/chore/build/ci/style/revert) - no release needed"
57+
BUMP_TYPE="none"
58+
fi
59+
60+
echo "Determined bump type: $BUMP_TYPE"
61+
62+
# Parse current version
63+
if [ "$LATEST_TAG" = "0.0.0" ]; then
64+
MAJOR=0
65+
MINOR=0
66+
PATCH=0
67+
else
68+
# Remove 'v' prefix if present
69+
VERSION=${LATEST_TAG#v}
70+
71+
# Split version into components
72+
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
73+
fi
74+
75+
# Calculate new version based on bump type
76+
case $BUMP_TYPE in
77+
major)
78+
MAJOR=$((MAJOR + 1))
79+
MINOR=0
80+
PATCH=0
81+
;;
82+
minor)
83+
MINOR=$((MINOR + 1))
84+
PATCH=0
85+
;;
86+
patch)
87+
PATCH=$((PATCH + 1))
88+
;;
89+
none)
90+
# Keep version the same
91+
;;
92+
esac
93+
94+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
95+
echo "New version: $NEW_VERSION"
96+
97+
# Determine if we should create a release
98+
if [ "$BUMP_TYPE" = "none" ] || [ "$LATEST_TAG" = "$NEW_VERSION" ] || [ "v$LATEST_TAG" = "$NEW_VERSION" ]; then
99+
SHOULD_RELEASE="false"
100+
echo "No release will be created (version unchanged)"
101+
else
102+
SHOULD_RELEASE="true"
103+
echo "Release will be created"
104+
fi
105+
106+
# Output to GitHub Actions
107+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
108+
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
109+
echo "previous_version=$LATEST_TAG" >> $GITHUB_OUTPUT
110+
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)