From b100c07f938dfc06b6c6fd12a640148d694b7e95 Mon Sep 17 00:00:00 2001 From: DhaatuTheGamer Date: Wed, 15 Apr 2026 07:05:28 +0530 Subject: [PATCH] refactor: modernize project structure with Manifest V3, CI/CD integration, and comprehensive testing suite. --- .github/workflows/ci.yml | 74 +++ .gitignore | 15 + CONTRIBUTING.md | 84 +++ LICENSE | 2 +- PR_DESCRIPTION.md | 14 - README.md | 284 +++++++-- benchmark.js | 56 -- eslint.config.js | 83 +++ icons/icon128.png | Bin 4977 -> 9473 bytes icons/icon16.png | Bin 519 -> 1666 bytes icons/icon48.png | Bin 1077 -> 3003 bytes manifest.json | 1 + mock_popup.html | 44 -- package-lock.json | 1286 ++++++++++++++++++++++++++------------ package.json | 26 +- playwright_benchmark.js | 108 ---- popup/popup.html | 1 - run-tests.js | 67 -- run_tests.py | 72 --- scripts/background.js | 3 +- scripts/utils.js | 1 + test/benchmark.js | 80 --- test/mocks.js | 1 - test/test.js | 12 +- 24 files changed, 1418 insertions(+), 896 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 CONTRIBUTING.md delete mode 100644 PR_DESCRIPTION.md delete mode 100644 benchmark.js create mode 100644 eslint.config.js delete mode 100644 mock_popup.html delete mode 100644 playwright_benchmark.js delete mode 100644 run-tests.js delete mode 100644 run_tests.py delete mode 100644 test/benchmark.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..84f4c98 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Run ESLint + run: npm run lint + + test: + name: Test + runs-on: ubuntu-latest + needs: lint + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Install Playwright Chromium + run: npx playwright install chromium --with-deps + + - name: Run tests + run: npm test + + build: + name: Build + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + + - name: Build extension package + run: | + mkdir -p dist + zip -r dist/read-aloud-extension.zip \ + manifest.json \ + icons/ \ + popup/ \ + scripts/ \ + LICENSE \ + README.md + + - name: Verify package contents + run: unzip -l dist/read-aloud-extension.zip + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: read-aloud-extension + path: dist/read-aloud-extension.zip + retention-days: 30 diff --git a/.gitignore b/.gitignore index c2658d7..376c520 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,16 @@ node_modules/ +dist/ +package-lock.json + +# OS artifacts +.DS_Store +Thumbs.db + +# Editor directories +.vscode/ +.idea/ +*.swp +*.swo + +# Logs +*.log diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..95ed2df --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,84 @@ +# Contributing to Read Aloud Chrome Extension + +Thank you for your interest in contributing! This document provides guidelines for contributing to the Read Aloud Chrome Extension. + +## How to Report Bugs + +1. Check the [existing issues](https://github.com/dhaatrik/ReadAloud_ChromeExtension/issues) to see if the bug has already been reported. +2. If not, [open a new issue](https://github.com/dhaatrik/ReadAloud_ChromeExtension/issues/new) with: + - A clear and descriptive title. + - Steps to reproduce the bug. + - Expected behavior vs. actual behavior. + - Your browser version and OS. + +## How to Suggest Features + +Open a [new issue](https://github.com/dhaatrik/ReadAloud_ChromeExtension/issues/new) with the **feature request** label. Include: +- A clear description of the feature. +- Why it would be useful. +- Any relevant examples or mockups. + +## Development Setup + +1. **Clone the repository:** + ```bash + git clone https://github.com/dhaatrik/ReadAloud_ChromeExtension.git + cd ReadAloud_ChromeExtension + ``` + +2. **Install dependencies** (for running tests): + ```bash + npm install + ``` + +3. **Load the extension in Chrome:** + - Navigate to `chrome://extensions`. + - Enable **Developer mode**. + - Click **Load unpacked** and select the project directory. + +4. **Run the test suite:** + ```bash + npm test + ``` + +## Pull Request Process + +1. **Fork** the repository and create a new branch from `main`: + ```bash + git checkout -b feature/your-feature-name + ``` + +2. **Make your changes.** Follow the code style conventions below. + +3. **Test your changes** to ensure nothing is broken: + ```bash + npm test + ``` + +4. **Commit** with a clear, descriptive message: + ```bash + git commit -m "Add: brief description of change" + ``` + +5. **Push** your branch and open a Pull Request against `main`. + +## Code Style + +- Use **vanilla JavaScript** (no frameworks or transpilers). +- Use `const` and `let` — never `var`. +- Use JSDoc comments for all public functions. +- Keep functions small and focused. +- Follow the existing code structure and naming conventions. + +## Project Structure + +``` +scripts/ → Core extension logic (background, content, popup, utils) +popup/ → Popup UI (HTML + CSS) +icons/ → Extension icons +test/ → QUnit test suite with mocks +``` + +## License + +By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE). diff --git a/LICENSE b/LICENSE index d745ace..81ad697 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Dhaatrik Chowdhury +Copyright (c) 2026 Dhaatrik Chowdhury Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/PR_DESCRIPTION.md b/PR_DESCRIPTION.md deleted file mode 100644 index 24e93b9..0000000 --- a/PR_DESCRIPTION.md +++ /dev/null @@ -1,14 +0,0 @@ -⚡ Performance Optimization: DocumentFragment for Voice Selection - -💡 **What:** -Updated `scripts/popup.js` to populate the `voicesSelect` dropdown menu using a `DocumentFragment` instead of appending `