Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
13 changes: 13 additions & 0 deletions .changeset/ci-cd-pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'web-capture': patch
---

Add comprehensive CI/CD pipeline based on js-ai-driven-development-pipeline-template

- Add GitHub Actions workflow for automated testing, linting, and releases
- Integrate changesets for version management and changelog generation
- Add ESLint, Prettier, and JSCPD for code quality checks
- Configure lint-staged and Husky for pre-commit hooks
- Add e2e tests that work in CI with Playwright
- Automated npm publishing via OIDC trusted publishing
- GitHub release generation with formatted notes
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
294 changes: 294 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
name: Checks and release

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
# Manual release support - consolidated here to work with npm trusted publishing
# npm only allows ONE workflow file as trusted publisher, so all publishing
# must go through this workflow (release.yml)
workflow_dispatch:
inputs:
release_mode:
description: 'Manual release mode'
required: true
type: choice
default: 'instant'
options:
- instant
- changeset-pr
bump_type:
description: 'Manual release type'
required: true
type: choice
options:
- patch
- minor
- major
description:
description: 'Manual release description (optional)'
required: false
type: string

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
# Changeset check - only runs on PRs
changeset-check:
name: Check for Changesets
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Install dependencies
run: npm install

- name: Check for changesets
run: |
# Skip changeset check for automated version PRs
if [[ "${{ github.head_ref }}" == "changeset-release/"* ]]; then
echo "Skipping changeset check for automated release PR"
exit 0
fi

# Run changeset validation script
node scripts/validate-changeset.mjs

# Linting and formatting - runs after changeset check on PRs, immediately on main
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
needs: [changeset-check]
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npm run lint

- name: Check formatting
run: npm run format:check

- name: Check code duplication
run: npm run check:duplication

# Test matrix: Node.js on Ubuntu with unit tests and e2e tests
test:
name: Test (Node.js on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [changeset-check]
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Install dependencies
run: npm install

- name: Install Playwright browsers
run: npx playwright install --with-deps chromium

- name: Install Puppeteer browsers
run: npx puppeteer browsers install chrome

- name: Run unit, integration, and e2e process tests
run: npm test -- --testPathIgnorePatterns="docker.test.js"

- name: Build Docker image for e2e tests
run: docker compose build

- name: Run e2e Docker tests
run: npm test -- tests/e2e/docker.test.js

# Release - only runs on main after tests pass (for push events)
release:
name: Release
needs: [lint, test]
# Use always() to ensure this job runs even if changeset-check was skipped
# This is needed because lint/test jobs have a transitive dependency on changeset-check
if: always() && github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.lint.result == 'success' && needs.test.result == 'success'
runs-on: ubuntu-latest
# Permissions required for npm OIDC trusted publishing
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install

- name: Update npm for OIDC trusted publishing
run: node scripts/setup-npm.mjs

- name: Check for changesets
id: check_changesets
run: |
# Count changeset files (excluding README.md and config.json)
CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" | wc -l)
echo "Found $CHANGESET_COUNT changeset file(s)"
echo "has_changesets=$([[ $CHANGESET_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT

- name: Version packages and commit to main
if: steps.check_changesets.outputs.has_changesets == 'true'
id: version
run: node scripts/version-and-commit.mjs --mode changeset

- name: Publish to npm
# Run if version was committed OR if a previous attempt already committed (for re-runs)
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
id: publish
run: node scripts/publish-to-npm.mjs --should-pull

- name: Create GitHub Release
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"

- name: Format GitHub release notes
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"

# Manual Instant Release - triggered via workflow_dispatch with instant mode
# This job is in release.yml because npm trusted publishing
# only allows one workflow file to be registered as a trusted publisher
instant-release:
name: Instant Release
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'instant'
runs-on: ubuntu-latest
# Permissions required for npm OIDC trusted publishing
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install

- name: Update npm for OIDC trusted publishing
run: node scripts/setup-npm.mjs

- name: Version packages and commit to main
id: version
run: node scripts/version-and-commit.mjs --mode instant --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"

- name: Publish to npm
# Run if version was committed OR if a previous attempt already committed (for re-runs)
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
id: publish
run: node scripts/publish-to-npm.mjs

- name: Create GitHub Release
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"

- name: Format GitHub release notes
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"

# Manual Changeset PR - creates a pull request with the changeset for review
changeset-pr:
name: Create Changeset PR
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changeset-pr'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Install dependencies
run: npm install

- name: Create changeset file
run: node scripts/create-manual-changeset.mjs --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"

- name: Format changeset with Prettier
run: |
# Run Prettier on the changeset file to ensure it matches project style
npx prettier --write ".changeset/*.md" || true

echo "Formatted changeset files"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: add changeset for manual ${{ github.event.inputs.bump_type }} release'
branch: changeset-manual-release-${{ github.run_id }}
delete-branch: true
title: 'chore: manual ${{ github.event.inputs.bump_type }} release'
body: |
## Manual Release Request

This PR was created by a manual workflow trigger to prepare a **${{ github.event.inputs.bump_type }}** release.

### Release Details
- **Type:** ${{ github.event.inputs.bump_type }}
- **Description:** ${{ github.event.inputs.description || 'Manual release' }}
- **Triggered by:** @${{ github.actor }}

### Next Steps
1. Review the changeset in this PR
2. Merge this PR to main
3. The automated release workflow will create a version PR
4. Merge the version PR to publish to npm and create a GitHub release
20 changes: 20 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"threshold": 0,
"minTokens": 30,
"minLines": 5,
"skipComments": true,
"ignore": [
"**/node_modules/**",
"**/build/**",
"**/dist/**",
"**/*.min.js",
"**/coverage/**",
"**/.changeset/**",
"**/package-lock.json",
"**/pnpm-lock.yaml",
"**/yarn.lock"
],
"format": "console",
"reporters": ["console", "html"],
"output": "./reports/jscpd"
}
8 changes: 8 additions & 0 deletions .lenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# web-capture default configuration
# This file uses Links Notation format (key: value)

# Server port
PORT: 3000

# Browser engine (puppeteer or playwright)
BROWSER_ENGINE: puppeteer
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
coverage
dist
*.min.js
package-lock.json
.eslintcache
CLAUDE.md
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf"
}
Loading