-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Reconstruct Chrome Extension Architecture for Production-Grade Scalability (v3.0.0)
- Loading branch information
Showing
48 changed files
with
1,960 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: chrome-extension CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- "extensions/chrome/**" | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- "extensions/chrome/**" | ||
|
||
defaults: | ||
run: | ||
working-directory: ./extensions/chrome | ||
|
||
jobs: | ||
lint-and-format: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: Run ESLint and format fix | ||
run: bun run fix | ||
|
||
- name: Run markdown lint | ||
# DON't TOUCH THIS LINE BELOW # | ||
run: bunx markdownlint-cli2 "./**/*.md" --config .markdownlint-cli2.jsonc | ||
|
||
test-and-build: | ||
needs: lint-and-format | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: Run tests | ||
run: bun test | ||
|
||
- name: Build extension | ||
run: bun run build | ||
|
||
- name: Zip Extension | ||
run: zip -r chrome-extension.zip dist/ | ||
|
||
# Automatically increments the patch version (e.g., 1.0.0 -> 1.0.1) | ||
# and creates a release | ||
# Only increment patch version for non-major versions | ||
- name: Check existing tag | ||
id: check_tag | ||
run: | | ||
current_version=$(node -p "require('./package.json').version") | ||
if [[ "$current_version" =~ ^[0-9]+\.0\.0$ ]]; then | ||
# Don't increment major versions (x.0.0) | ||
echo "version=$current_version" >> $GITHUB_OUTPUT | ||
echo "version_changed=false" >> $GITHUB_OUTPUT | ||
elif git ls-remote --tags origin refs/tags/v$current_version >/dev/null; then | ||
# If tag exists and it's not a major version, increment patch | ||
IFS='.' read -r major minor patch <<< "$current_version" | ||
new_version="$major.$minor.$((patch + 1))" | ||
echo "version=$new_version" >> $GITHUB_OUTPUT | ||
echo "version_changed=true" >> $GITHUB_OUTPUT | ||
# Update package.json with new version | ||
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" package.json | ||
# Update manifest.json with new version | ||
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" public/manifest.json | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git add package.json public/manifest.json | ||
git commit -m "chore: bump version to $new_version [skip ci]" | ||
git push | ||
else | ||
echo "version=$current_version" >> $GITHUB_OUTPUT | ||
echo "version_changed=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create Release | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: Chrome Extension v${{ steps.check_tag.outputs.version }} | ||
tag_name: v${{ steps.check_tag.outputs.version }} | ||
files: extensions/chrome/chrome-extension.zip | ||
generate_release_notes: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
fail_on_unmatched_files: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Dependencies | ||
node_modules/ | ||
.pnp/ | ||
.pnp.js | ||
bun.lockb | ||
|
||
# Testing | ||
coverage/ | ||
.nyc_output/ | ||
|
||
# Production & Build files | ||
dist/ | ||
build/ | ||
*.tsbuildinfo | ||
|
||
# Development & IDE | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.idea/ | ||
.vscode/* | ||
!.vscode/extensions.json | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
|
||
# Debug logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
debug.log | ||
*.log | ||
|
||
# Cache directories | ||
.npm/ | ||
.eslintcache | ||
.stylelintcache | ||
.prettiercache | ||
.cache/ | ||
|
||
# Chrome Extension specific | ||
*.crx | ||
*.pem | ||
*.zip | ||
|
||
# Temporary files | ||
*.swp | ||
*.swo | ||
*~ | ||
|
||
# OS generated files | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env sh | ||
|
||
# DON'T TOUCH THIS FILE IF YOU DON'T KNOW WHAT YOU ARE DOING | ||
|
||
echo "Checking for changes in chrome..." | ||
if git log -1 --name-only --pretty=format: | grep "^extensions/chrome" > /dev/null; then | ||
echo "Changes detected, fetching..." | ||
git fetch | ||
echo "Fetch complete" | ||
echo "Pulling changes..." | ||
git pull | ||
echo "Pull complete" | ||
fi | ||
|
||
# TODO: config this for other extensions too |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env sh | ||
|
||
# DON'T TOUCH THIS FILE IF YOU DON'T KNOW WHAT YOU ARE DOING | ||
|
||
# Check if there are changes in extensions directory | ||
if ! git diff --cached --name-only | grep "^extensions/chrome" > /dev/null; then | ||
echo "No changes in chrome" | ||
exit 0 | ||
fi | ||
|
||
if ! cd extensions/chrome; then | ||
echo "Failed to change directory" | ||
exit 1 | ||
fi | ||
|
||
if ! bun run lint:staged; then | ||
echo "Lint failed" | ||
exit 1 | ||
fi | ||
|
||
# TODO: config this for other extensions too |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Dependencies | ||
node_modules/ | ||
|
||
# Package manager files | ||
bun.lockb | ||
|
||
# Build output | ||
dist/ | ||
build/ | ||
|
||
# IDE and editor files | ||
.idea/ | ||
.vscode/ | ||
*.swp | ||
*.swo | ||
.DS_Store | ||
|
||
# Environment variables | ||
.env | ||
.env.local | ||
.env.*.local | ||
|
||
# Debug logs | ||
debug.log | ||
|
||
# Test coverage | ||
coverage/ |
Oops, something went wrong.