Skip to content

Commit 319871d

Browse files
authored
Merge pull request #20 from link-assistant/issue-19-7350892c64e0
feat: add CLI support for local command and server mode
2 parents 9135b59 + 838b10c commit 319871d

51 files changed

Lines changed: 15332 additions & 873 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/ci-cd-pipeline.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'web-capture': patch
3+
---
4+
5+
Add comprehensive CI/CD pipeline based on js-ai-driven-development-pipeline-template
6+
7+
- Add GitHub Actions workflow for automated testing, linting, and releases
8+
- Integrate changesets for version management and changelog generation
9+
- Add ESLint, Prettier, and JSCPD for code quality checks
10+
- Configure lint-staged and Husky for pre-commit hooks
11+
- Add e2e tests that work in CI with Playwright
12+
- Automated npm publishing via OIDC trusted publishing
13+
- GitHub release generation with formatted notes

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/release.yml

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
name: Checks and release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
# Manual release support - consolidated here to work with npm trusted publishing
10+
# npm only allows ONE workflow file as trusted publisher, so all publishing
11+
# must go through this workflow (release.yml)
12+
workflow_dispatch:
13+
inputs:
14+
release_mode:
15+
description: 'Manual release mode'
16+
required: true
17+
type: choice
18+
default: 'instant'
19+
options:
20+
- instant
21+
- changeset-pr
22+
bump_type:
23+
description: 'Manual release type'
24+
required: true
25+
type: choice
26+
options:
27+
- patch
28+
- minor
29+
- major
30+
description:
31+
description: 'Manual release description (optional)'
32+
required: false
33+
type: string
34+
35+
concurrency: ${{ github.workflow }}-${{ github.ref }}
36+
37+
jobs:
38+
# Changeset check - only runs on PRs
39+
changeset-check:
40+
name: Check for Changesets
41+
runs-on: ubuntu-latest
42+
if: github.event_name == 'pull_request'
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '20.x'
52+
53+
- name: Install dependencies
54+
run: npm install
55+
56+
- name: Check for changesets
57+
run: |
58+
# Skip changeset check for automated version PRs
59+
if [[ "${{ github.head_ref }}" == "changeset-release/"* ]]; then
60+
echo "Skipping changeset check for automated release PR"
61+
exit 0
62+
fi
63+
64+
# Run changeset validation script
65+
node scripts/validate-changeset.mjs
66+
67+
# Linting and formatting - runs after changeset check on PRs, immediately on main
68+
lint:
69+
name: Lint and Format Check
70+
runs-on: ubuntu-latest
71+
needs: [changeset-check]
72+
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: '20.x'
80+
81+
- name: Install dependencies
82+
run: npm install
83+
84+
- name: Run ESLint
85+
run: npm run lint
86+
87+
- name: Check formatting
88+
run: npm run format:check
89+
90+
- name: Check code duplication
91+
run: npm run check:duplication
92+
93+
# Test matrix: Node.js on Ubuntu with unit tests and e2e tests
94+
test:
95+
name: Test (Node.js on ${{ matrix.os }})
96+
runs-on: ${{ matrix.os }}
97+
needs: [changeset-check]
98+
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
os: [ubuntu-latest]
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: Setup Node.js
107+
uses: actions/setup-node@v4
108+
with:
109+
node-version: '22.x'
110+
111+
- name: Install dependencies
112+
run: npm install
113+
114+
- name: Install Playwright browsers
115+
run: npx playwright install --with-deps chromium
116+
117+
- name: Install Puppeteer browsers
118+
run: npx puppeteer browsers install chrome
119+
120+
- name: Run unit, integration, and e2e process tests
121+
run: npm test -- --testPathIgnorePatterns="docker.test.js"
122+
123+
- name: Build Docker image for e2e tests
124+
run: docker compose build
125+
126+
- name: Run e2e Docker tests
127+
run: npm test -- tests/e2e/docker.test.js
128+
129+
# Release - only runs on main after tests pass (for push events)
130+
release:
131+
name: Release
132+
needs: [lint, test]
133+
# Use always() to ensure this job runs even if changeset-check was skipped
134+
# This is needed because lint/test jobs have a transitive dependency on changeset-check
135+
if: always() && github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.lint.result == 'success' && needs.test.result == 'success'
136+
runs-on: ubuntu-latest
137+
# Permissions required for npm OIDC trusted publishing
138+
permissions:
139+
contents: write
140+
pull-requests: write
141+
id-token: write
142+
steps:
143+
- uses: actions/checkout@v4
144+
with:
145+
fetch-depth: 0
146+
147+
- name: Setup Node.js
148+
uses: actions/setup-node@v4
149+
with:
150+
node-version: '22.x'
151+
registry-url: 'https://registry.npmjs.org'
152+
153+
- name: Install dependencies
154+
run: npm install
155+
156+
- name: Update npm for OIDC trusted publishing
157+
run: node scripts/setup-npm.mjs
158+
159+
- name: Check for changesets
160+
id: check_changesets
161+
run: |
162+
# Count changeset files (excluding README.md and config.json)
163+
CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" | wc -l)
164+
echo "Found $CHANGESET_COUNT changeset file(s)"
165+
echo "has_changesets=$([[ $CHANGESET_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
166+
167+
- name: Version packages and commit to main
168+
if: steps.check_changesets.outputs.has_changesets == 'true'
169+
id: version
170+
run: node scripts/version-and-commit.mjs --mode changeset
171+
172+
- name: Publish to npm
173+
# Run if version was committed OR if a previous attempt already committed (for re-runs)
174+
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
175+
id: publish
176+
run: node scripts/publish-to-npm.mjs --should-pull
177+
178+
- name: Create GitHub Release
179+
if: steps.publish.outputs.published == 'true'
180+
env:
181+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182+
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"
183+
184+
- name: Format GitHub release notes
185+
if: steps.publish.outputs.published == 'true'
186+
env:
187+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188+
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"
189+
190+
# Manual Instant Release - triggered via workflow_dispatch with instant mode
191+
# This job is in release.yml because npm trusted publishing
192+
# only allows one workflow file to be registered as a trusted publisher
193+
instant-release:
194+
name: Instant Release
195+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'instant'
196+
runs-on: ubuntu-latest
197+
# Permissions required for npm OIDC trusted publishing
198+
permissions:
199+
contents: write
200+
pull-requests: write
201+
id-token: write
202+
steps:
203+
- uses: actions/checkout@v4
204+
with:
205+
fetch-depth: 0
206+
207+
- name: Setup Node.js
208+
uses: actions/setup-node@v4
209+
with:
210+
node-version: '22.x'
211+
registry-url: 'https://registry.npmjs.org'
212+
213+
- name: Install dependencies
214+
run: npm install
215+
216+
- name: Update npm for OIDC trusted publishing
217+
run: node scripts/setup-npm.mjs
218+
219+
- name: Version packages and commit to main
220+
id: version
221+
run: node scripts/version-and-commit.mjs --mode instant --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"
222+
223+
- name: Publish to npm
224+
# Run if version was committed OR if a previous attempt already committed (for re-runs)
225+
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
226+
id: publish
227+
run: node scripts/publish-to-npm.mjs
228+
229+
- name: Create GitHub Release
230+
if: steps.publish.outputs.published == 'true'
231+
env:
232+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
233+
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"
234+
235+
- name: Format GitHub release notes
236+
if: steps.publish.outputs.published == 'true'
237+
env:
238+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
239+
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"
240+
241+
# Manual Changeset PR - creates a pull request with the changeset for review
242+
changeset-pr:
243+
name: Create Changeset PR
244+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changeset-pr'
245+
runs-on: ubuntu-latest
246+
permissions:
247+
contents: write
248+
pull-requests: write
249+
steps:
250+
- uses: actions/checkout@v4
251+
with:
252+
fetch-depth: 0
253+
254+
- name: Setup Node.js
255+
uses: actions/setup-node@v4
256+
with:
257+
node-version: '22.x'
258+
259+
- name: Install dependencies
260+
run: npm install
261+
262+
- name: Create changeset file
263+
run: node scripts/create-manual-changeset.mjs --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"
264+
265+
- name: Format changeset with Prettier
266+
run: |
267+
# Run Prettier on the changeset file to ensure it matches project style
268+
npx prettier --write ".changeset/*.md" || true
269+
270+
echo "Formatted changeset files"
271+
272+
- name: Create Pull Request
273+
uses: peter-evans/create-pull-request@v7
274+
with:
275+
token: ${{ secrets.GITHUB_TOKEN }}
276+
commit-message: 'chore: add changeset for manual ${{ github.event.inputs.bump_type }} release'
277+
branch: changeset-manual-release-${{ github.run_id }}
278+
delete-branch: true
279+
title: 'chore: manual ${{ github.event.inputs.bump_type }} release'
280+
body: |
281+
## Manual Release Request
282+
283+
This PR was created by a manual workflow trigger to prepare a **${{ github.event.inputs.bump_type }}** release.
284+
285+
### Release Details
286+
- **Type:** ${{ github.event.inputs.bump_type }}
287+
- **Description:** ${{ github.event.inputs.description || 'Manual release' }}
288+
- **Triggered by:** @${{ github.actor }}
289+
290+
### Next Steps
291+
1. Review the changeset in this PR
292+
2. Merge this PR to main
293+
3. The automated release workflow will create a version PR
294+
4. Merge the version PR to publish to npm and create a GitHub release

.jscpd.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"threshold": 0,
3+
"minTokens": 30,
4+
"minLines": 5,
5+
"skipComments": true,
6+
"ignore": [
7+
"**/node_modules/**",
8+
"**/build/**",
9+
"**/dist/**",
10+
"**/*.min.js",
11+
"**/coverage/**",
12+
"**/.changeset/**",
13+
"**/package-lock.json",
14+
"**/pnpm-lock.yaml",
15+
"**/yarn.lock"
16+
],
17+
"format": "console",
18+
"reporters": ["console", "html"],
19+
"output": "./reports/jscpd"
20+
}

.lenv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# web-capture default configuration
2+
# This file uses Links Notation format (key: value)
3+
4+
# Server port
5+
PORT: 3000
6+
7+
# Browser engine (puppeteer or playwright)
8+
BROWSER_ENGINE: puppeteer

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
coverage
3+
dist
4+
*.min.js
5+
package-lock.json
6+
.eslintcache
7+
CLAUDE.md

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf"
10+
}

0 commit comments

Comments
 (0)