From a70580e703aef69e8ec2c67010e840568db54369 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Wed, 30 Sep 2026 19:46:24 +0700 Subject: [PATCH] ci: security, licensing and style gates; pin every action by SHA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New checks - security.yml: dependency-review blocks PRs that add a high/critical advisory; actionlint + zizmor lint the workflows themselves (template injection, permissions, credential persistence, unpinned uses); OpenSSF Scorecard weekly and on main (published, not uploaded as alerts). - compliance.yml: REUSE lint over the whole repo (REUSE.toml + LICENSES/, no per-file headers) and Conventional-Commit PR titles. - rust.yml (src-tauri changes + weekly): rustfmt, clippy -D warnings, cargo test, and cargo-deny for RustSec advisories, licenses and sources. - ci.yml `check` gains: coverage thresholds (src/engine, worker), check:licenses, check:bundle, and a `wrangler deploy --dry-run`. Licensing - THIRD_PARTY_NOTICES.md is now generated from package.json, the installed packages and Cargo.toml/Cargo.lock (`npm run generate:third-party`); CI fails when it is stale or when anything bundled into the app carries a license outside the allowlist. It had drifted to React 18 / Vite 7 / Tailwind 3. - Vite's build.license emits the full text of every bundled package's license to /licenses/third-party.md (served publicly, before the gate). Bundle budget - scripts/check-bundle-size.ts measures what CLAUDE.md's "500KB" never defined: initial load (everything index.html references) <= 280 KB gzip (197 KB today) and no JS chunk over 500 KB raw. Coverage - @vitest/coverage-v8; thresholds sit just under today's numbers. The engine is at 89% lines / 64% functions — not the 100% CLAUDE.md claimed. Supply chain - Every third-party action pinned to a commit SHA (Dependabot updates the SHA and its version comment); checkout never persists credentials. - Release workflows: a `verify` job (typecheck, tests, version sync, Tauri alignment, tag == package version) gates the build; no dependency caches in release jobs; permissions granted per job. - Reusable Discord workflows receive only the secrets they declare instead of `secrets: inherit` (which exposed the Android signing keys to them). - Rust: cargo-deny found RUSTSEC-2026-0194/0195 (quick-xml DoS, via plist) that Dependabot had not raised; plist 1.10 brings quick-xml 0.41. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/announce-release.yml | 28 ++- .github/workflows/ci.yml | 41 +++- .github/workflows/compliance.yml | 57 +++++ .github/workflows/notify-ci-failure.yml | 11 +- .github/workflows/notify-release-pipeline.yml | 4 +- .github/workflows/release-android.yml | 68 ++++-- .github/workflows/release-desktop.yml | 49 +++- .github/workflows/rust.yml | 75 +++++++ .github/workflows/security.yml | 87 +++++++ .github/zizmor.yml | 11 + LICENSES/Apache-2.0.txt | 201 +++++++++++++++++ REUSE.toml | 14 ++ THIRD_PARTY_NOTICES.md | 132 ++++++----- package-lock.json | 171 ++++++++++++++ package.json | 6 +- scripts/check-bundle-size.ts | 74 ++++++ scripts/lib/third-party.ts | 212 ++++++++++++++++++ scripts/third-party.ts | 10 + src-tauri/Cargo.lock | 8 +- src-tauri/deny.toml | 33 +++ src-tauri/src/lib.rs | 3 +- tests/scripts/third-party.test.ts | 38 ++++ vite.config.ts | 3 + vitest.config.ts | 14 ++ wrangler.jsonc | 1 + 25 files changed, 1235 insertions(+), 116 deletions(-) create mode 100644 .github/workflows/compliance.yml create mode 100644 .github/workflows/rust.yml create mode 100644 .github/workflows/security.yml create mode 100644 .github/zizmor.yml create mode 100644 LICENSES/Apache-2.0.txt create mode 100644 REUSE.toml create mode 100644 scripts/check-bundle-size.ts create mode 100644 scripts/lib/third-party.ts create mode 100644 scripts/third-party.ts create mode 100644 src-tauri/deny.toml create mode 100644 tests/scripts/third-party.test.ts diff --git a/.github/workflows/announce-release.yml b/.github/workflows/announce-release.yml index a7c683a..26cce9b 100644 --- a/.github/workflows/announce-release.yml +++ b/.github/workflows/announce-release.yml @@ -10,32 +10,42 @@ on: required: true type: string -# `link-discussion` needs `contents: write` (to edit the release) and -# `discussions: write` (so GitHub auto-creates the linked Discussion under -# the configured category). The reusable announce job only needs read. permissions: - contents: write - discussions: write + contents: read jobs: link-discussion: runs-on: ubuntu-latest + # `contents: write` edits the release; `discussions: write` lets GitHub + # auto-create the linked Discussion under the configured category. + permissions: + contents: write + discussions: write steps: - name: Link release to Announcements discussion env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Via env, never interpolated into the script: a tag name is + # user-controlled text. + TAG: ${{ github.event.release.tag_name || inputs.tag }} + REPO: ${{ github.repository }} # Setting --discussion-category on a published release causes # GitHub to auto-create the linked Discussion. Requires the # repo to have Discussions enabled with an "Announcements" # category (configured manually under repo Settings). run: | - gh release edit "${{ github.event.release.tag_name || inputs.tag }}" \ - --repo "${{ github.repository }}" \ - --discussion-category "Announcements" + gh release edit "$TAG" --repo "$REPO" --discussion-category "Announcements" announce: needs: link-discussion + permissions: + contents: read uses: poli0981/.github/.github/workflows/announce-release.yml@main with: tag_override: ${{ inputs.tag || '' }} - secrets: inherit \ No newline at end of file + # Only what the shared workflow declares — not `inherit`, which would hand + # every repository secret (Android signing keys included) to it. + secrets: + DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }} + DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }} + DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e91b295..2fb5090 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [main, dev] + branches: [main] pull_request: branches: [main] @@ -21,30 +21,36 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: + # `check` is the required status on `main` (ruleset "main-protection") — keep + # the job id stable. check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 + # Actions are pinned by commit SHA (a tag can be moved; a SHA cannot). + # Dependabot keeps the SHA and the version comment up to date. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - node-version: 22 + persist-credentials: false + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: .node-version cache: npm - run: npm ci # --- correctness ------------------------------------------------------ - # `typecheck` covers src/ (what Vite actually builds); `typecheck:all` - # adds tests/ and scripts/, which went unchecked until v0.35.0 and were - # hiding three silently-stale fixture fields. + # `typecheck` covers src/ (what Vite builds); `typecheck:all` adds tests/, + # scripts/, worker/ and build-plugins/. - name: Type check (src) run: npm run typecheck - - name: Type check (tests + scripts) + - name: Type check (tests, scripts, worker, build plugins) run: npm run typecheck:all - name: Lint run: npm run lint - name: Validate locales run: npm run validate:locales - - name: Test - run: npm run test:run + # Coverage thresholds for src/engine and worker live in vitest.config.ts. + - name: Test (with coverage thresholds) + run: npm run test:coverage # --- consistency ------------------------------------------------------ - name: Check formatting @@ -59,10 +65,17 @@ jobs: - name: Check Tauri npm/crate alignment run: npm run check:tauri + # --- licensing -------------------------------------------------------- + # Every package bundled into the app has an allowed license, and + # THIRD_PARTY_NOTICES.md matches what is actually installed. + - name: Check licenses and third-party notices + run: npm run check:licenses + # --- security --------------------------------------------------------- # Advisory-only: a fresh high-severity advisory in a transitive dep must # not turn every unrelated PR red before Dependabot has had a chance to - # open its fix PR. The Dependabot alerts tab is the source of truth. + # open its fix PR. The Dependabot alerts tab is the source of truth, and + # dependency-review (security.yml) blocks PRs that *introduce* one. - name: Audit dependencies run: npm audit --audit-level=high continue-on-error: true @@ -70,3 +83,9 @@ jobs: # --- build ------------------------------------------------------------ - name: Build run: npm run build + - name: Check bundle budget + run: npm run check:bundle + # Validates wrangler.jsonc and bundles the Worker exactly as Workers + # Builds will — without deploying anything. + - name: Dry-run the Cloudflare deploy + run: npx wrangler deploy --dry-run --outdir .wrangler/dry-run diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml new file mode 100644 index 0000000..06ff2b3 --- /dev/null +++ b/.github/workflows/compliance.yml @@ -0,0 +1,57 @@ +name: Compliance + +on: + pull_request: + branches: [main] + types: [opened, edited, synchronize, reopened] + push: + branches: [main] + +permissions: + contents: read + +concurrency: + group: compliance-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + # REUSE (https://reuse.software): every file in the repo has a declared + # copyright holder and SPDX license — via REUSE.toml, not per-file headers. + # Fails when a file arrives that the annotations do not cover (e.g. a font + # or icon under another license) until REUSE.toml says what it is. + reuse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 # v6.0.0 + + # PR titles follow the commit convention (`type(scope): message`) — merge + # commits carry them into main's history and the changelog. + pr-title: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + pull-requests: read + steps: + - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + refactor + perf + docs + test + ci + build + chore + revert + requireScope: false + subjectPattern: ^(?![A-Z]).+$ + subjectPatternError: | + The subject "{subject}" should start with a lower-case letter, like + the rest of the history (e.g. "feat(editor): add next-part button"). diff --git a/.github/workflows/notify-ci-failure.yml b/.github/workflows/notify-ci-failure.yml index e09bb66..89a09dd 100644 --- a/.github/workflows/notify-ci-failure.yml +++ b/.github/workflows/notify-ci-failure.yml @@ -2,9 +2,10 @@ name: Notify CI Failures on: workflow_run: - # Match the exact `name:` of the CI workflow (.github/workflows/ci.yml). - # Renaming CI silently breaks this filter — keep them in sync. - workflows: ["CI"] + # Match the exact `name:` of each watched workflow (ci.yml, security.yml, + # compliance.yml, rust.yml). Renaming one silently breaks this filter — + # keep them in sync. + workflows: ["CI", "Security", "Compliance", "Rust"] types: [completed] # REQUIRED: declare permissions matching the reusable workflow's needs. @@ -16,4 +17,6 @@ permissions: jobs: notify: uses: poli0981/.github/.github/workflows/notify-ci-failure.yml@main - secrets: inherit + # Only the webhook the shared workflow declares — not `inherit`. + secrets: + DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }} diff --git a/.github/workflows/notify-release-pipeline.yml b/.github/workflows/notify-release-pipeline.yml index aeb2763..d595fdb 100644 --- a/.github/workflows/notify-release-pipeline.yml +++ b/.github/workflows/notify-release-pipeline.yml @@ -15,4 +15,6 @@ permissions: jobs: notify: uses: poli0981/.github/.github/workflows/notify-release-pipeline.yml@main - secrets: inherit + # Only the webhook the shared workflow declares — not `inherit`. + secrets: + DISCORD_RELEASE_PIPELINE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_PIPELINE_WEBHOOK }} diff --git a/.github/workflows/release-android.yml b/.github/workflows/release-android.yml index 40fd36b..4346d47 100644 --- a/.github/workflows/release-android.yml +++ b/.github/workflows/release-android.yml @@ -6,49 +6,72 @@ on: workflow_dispatch: inputs: tag: - description: "Tag to build (e.g. v0.29.0). The manifests must already carry this version." + description: "Tag to build (e.g. v1.0.0). The manifests must already carry this version." required: true type: string permissions: - contents: write + contents: read jobs: - build-android: + # Same gate as release-desktop.yml: never sign an APK for a tag whose code + # fails the checks or whose version fields disagree with the tag. + verify: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.event.inputs.tag || github.ref }} - - - uses: actions/setup-node@v7 + persist-credentials: false + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: - node-version: 22 - cache: npm + node-version-file: .node-version + - run: npm ci + - run: npm run typecheck + - run: npm run test:run + - run: npm run check:version + - run: npm run check:tauri + - name: Tag matches the manifests + env: + TAG: ${{ github.event.inputs.tag || github.ref_name }} + run: | + version="v$(node -p "require('./package.json').version")" + if [ "$version" != "$TAG" ]; then + echo "::error::Tag $TAG does not match package.json ($version)" + exit 1 + fi - - uses: actions/setup-java@v6 + build-android: + needs: verify + runs-on: ubuntu-latest + permissions: + contents: write # upload the APK to the draft release + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + persist-credentials: false + + # No dependency caches in a release job (see release-desktop.yml). + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: .node-version + + - uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 with: distribution: temurin java-version: "17" - - uses: android-actions/setup-android@v4 + - uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4 - name: Install Android NDK (r27 LTS) run: sdkmanager "ndk;27.3.13750724" - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable with: + toolchain: stable targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android - - name: Cache cargo - uses: actions/cache@v6 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - src-tauri/target - key: ${{ runner.os }}-android-cargo-${{ hashFiles('src-tauri/Cargo.lock') }} - - run: npm ci - name: Install Tauri CLI @@ -82,7 +105,7 @@ jobs: # Keep the APK regardless of whether the release upload works, so a # broken upload never costs a 20-minute rebuild. - name: Upload APK as workflow artifact - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: ytdescgen-android-apk path: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk @@ -103,6 +126,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ github.event.inputs.tag || github.ref_name }} + REPO: ${{ github.repository }} APK: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk run: | - gh release upload "$TAG" "$APK" --clobber --repo "${{ github.repository }}" + gh release upload "$TAG" "$APK" --clobber --repo "$REPO" diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index efe8f7a..903b1d8 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -10,15 +10,45 @@ on: workflow_dispatch: inputs: tag: - description: "Tag to build (e.g. v0.9.0). The job still expects the manifests to already carry this version." + description: "Tag to build (e.g. v1.0.0). The job still expects the manifests to already carry this version." required: true type: string permissions: - contents: write + contents: read jobs: + # Nothing gets built for a tag whose code does not pass the gate or whose + # six version fields disagree with the tag itself. + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + persist-credentials: false + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: .node-version + - run: npm ci + - run: npm run typecheck + - run: npm run test:run + - run: npm run check:version + - run: npm run check:tauri + - name: Tag matches the manifests + env: + TAG: ${{ github.event.inputs.tag || github.ref_name }} + run: | + version="v$(node -p "require('./package.json').version")" + if [ "$version" != "$TAG" ]; then + echo "::error::Tag $TAG does not match package.json ($version)" + exit 1 + fi + build: + needs: verify + permissions: + contents: write # create the draft release and upload the binaries strategy: fail-fast: false matrix: @@ -52,17 +82,20 @@ jobs: bundleArgs: "" runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # On `workflow_dispatch` checkout the requested tag; on a # tag push we already get the tag commit by default. ref: ${{ github.event.inputs.tag || github.ref }} - - uses: actions/setup-node@v7 + persist-credentials: false + # No dependency caches in a release job: a poisoned cache entry written + # by any other workflow would otherwise flow straight into the binaries. + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: - node-version: 22 - cache: npm - - uses: dtolnay/rust-toolchain@stable + node-version-file: .node-version + - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable with: + toolchain: stable targets: ${{ matrix.target }} - name: Install Linux dependencies if: matrix.os == 'ubuntu-latest' @@ -75,7 +108,7 @@ jobs: librsvg2-dev \ patchelf - run: npm ci - - uses: tauri-apps/tauri-action@v1 + - uses: tauri-apps/tauri-action@1deb371b0cd8bd54025b384f1cd735e725c4060f # v1.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # AppImage bundling on hosted runners flakes: linuxdeploy (itself diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..6bc0ba0 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,75 @@ +name: Rust + +# The Tauri shell changes rarely, so this only runs when it does (or weekly, +# to catch new RustSec advisories). Not a required check for that reason. +on: + pull_request: + branches: [main] + paths: + - "src-tauri/**" + - ".github/workflows/rust.yml" + push: + branches: [main] + paths: + - "src-tauri/**" + - ".github/workflows/rust.yml" + schedule: + - cron: "41 4 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: rust-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Install Linux dependencies + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf + - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable + with: + toolchain: stable + components: rustfmt, clippy + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 + with: + workspaces: src-tauri + # tauri::generate_context!() embeds the frontend at compile time, so + # clippy and the tests need a built dist/. + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: .node-version + cache: npm + - run: npm ci + - run: npm run build + - name: rustfmt + working-directory: src-tauri + run: cargo fmt --all -- --check + - name: clippy + working-directory: src-tauri + run: cargo clippy --all-targets --locked -- -D warnings + - name: test + working-directory: src-tauri + run: cargo test --locked + + # RustSec advisories, license allowlist, duplicate/banned crates and + # registry sources for the whole crate tree (src-tauri/deny.toml). + cargo-deny: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 + with: + manifest-path: src-tauri/Cargo.toml + command: check advisories licenses sources diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..985a6cd --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,87 @@ +name: Security + +on: + pull_request: + branches: [main] + push: + branches: [main] + schedule: + # Mondays 04:17 UTC — new advisories and Scorecard drift surface weekly + # even when nothing is being merged. + - cron: "17 4 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: security-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + # Blocks a PR that ADDS a dependency with a known high/critical advisory. + # Licenses are checked by `npm run check:licenses` (ci.yml) instead: the + # dependency graph's license data is patchy for npm and would flag noise. + dependency-review: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 + with: + fail-on-severity: high + license-check: false + + # Lint the workflows themselves: syntax/expressions (actionlint) and + # security smells — template injection, over-broad permissions, credential + # persistence, unpinned actions (zizmor, config in .github/zizmor.yml). + workflow-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: actionlint + uses: docker://rhysd/actionlint:1.7.12 + with: + args: -color + - name: zizmor + uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4 + with: + # Report in the log and fail the job; no SARIF upload, so findings + # are fixed in the PR instead of piling up as code-scanning alerts. + advanced-security: false + min-severity: medium + + # OpenSSF Scorecard: supply-chain posture (pinned deps, token permissions, + # branch protection …). Informational — results go to the job summary and + # scorecard.dev, not to code scanning. + scorecard: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # publish_results: signs the result for scorecard.dev + actions: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4 + with: + results_file: scorecard.json + results_format: json + publish_results: true + - name: Summarise + run: | + { + echo "### OpenSSF Scorecard" + echo + echo "| Check | Score |" + echo "| --- | --- |" + jq -r '.checks[] | "| \(.name) | \(.score) |"' scorecard.json + echo + echo "Aggregate: **$(jq -r '.score' scorecard.json) / 10**" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 0000000..900428c --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,11 @@ +# zizmor (workflow security linter) configuration — see security.yml. +rules: + unpinned-uses: + config: + policies: + # The shared notification / announcement workflows live in the + # maintainer's own `poli0981/.github` repository and are deliberately + # tracked at `main`, so a fix there reaches every repo at once. + "poli0981/*": any + # Everything else must be pinned to a full commit SHA. + "*": hash-pin diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt new file mode 100644 index 0000000..ee42b9d --- /dev/null +++ b/LICENSES/Apache-2.0.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for describing the origin of the Work and + reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Support. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or support. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing permissions and + limitations under the License. diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 0000000..d288297 --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,14 @@ +# REUSE (https://reuse.software) licensing information for the whole +# repository, checked in CI by .github/workflows/compliance.yml. +# +# Everything here is original work released under Apache-2.0 unless a more +# specific annotation below says otherwise. Add one whenever a file under +# another license lands (a font, a vendored icon set, …) — CI fails until it +# is declared. +version = 1 + +[[annotations]] +path = "**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2026 poli0981 (SkullMute) and YTDescGen contributors" +SPDX-License-Identifier = "Apache-2.0" diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 19741b6..67f4f8e 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -1,79 +1,101 @@ + + # Third-Party Notices -YTDescGen incorporates the following third-party software. Each dependency retains its own license; consult the linked project page for the full text of each license. +YTDescGen is built on the open-source software and services below. Each component keeps its own license; the linked project pages carry the full terms. -## Runtime Dependencies (web bundle) +The **complete license text of every package bundled into the web app** — including transitive dependencies such as `scheduler` or `@babel/runtime` — is published with each release at [`/licenses/third-party.md`](https://ytgenerator.stream/licenses/third-party.md), generated by Vite from the exact build. + +## Runtime dependencies + +Bundled into the web app and the desktop / Android apps. | Package | Version | License | Project | | --- | --- | --- | --- | -| `react` | ^18.3.0 | MIT | | -| `react-dom` | ^18.3.0 | MIT | | -| `react-router-dom` | ^6.26.0 | MIT | | -| `react-i18next` | ^15.0.0 | MIT | | -| `i18next` | ^23.15.0 | MIT | | -| `zustand` | ^4.5.0 | MIT | | -| `react-hot-toast` | ^2.4.0 | MIT | | -| `lucide-react` | ^0.400.0 | ISC | | -| `clsx` | ^2.1.0 | MIT | | -| `@tauri-apps/api` | ^2.11.0 | Apache-2.0 OR MIT | | -| `@tauri-apps/plugin-dialog` | ^2.0.0 | Apache-2.0 OR MIT | | -| `@tauri-apps/plugin-fs` | ^2.0.0 | Apache-2.0 OR MIT | | -| `@tauri-apps/plugin-opener` | ^2.0.0 | Apache-2.0 OR MIT | | -| `@tauri-apps/plugin-shell` | ^2.0.0 | Apache-2.0 OR MIT | | +| `@tauri-apps/api` | 2.12.0 | Apache-2.0 OR MIT | | +| `@tauri-apps/plugin-dialog` | 2.8.0 | MIT OR Apache-2.0 | | +| `@tauri-apps/plugin-fs` | 2.6.0 | MIT OR Apache-2.0 | | +| `@tauri-apps/plugin-opener` | 2.7.0 | MIT OR Apache-2.0 | | +| `@tauri-apps/plugin-shell` | 2.4.0 | MIT OR Apache-2.0 | | +| `clsx` | 2.1.1 | MIT | | +| `i18next` | 26.4.2 | MIT | | +| `i18next-resources-to-backend` | 1.2.3 | MIT | | +| `lucide-react` | 0.577.0 | ISC | | +| `react` | 19.3.0 | MIT | | +| `react-dom` | 19.3.0 | MIT | | +| `react-hot-toast` | 2.6.1 | MIT | | +| `react-i18next` | 17.0.15 | MIT | | +| `react-router-dom` | 7.18.4 | MIT | | +| `zustand` | 5.0.15 | MIT | | -## Build / Dev Dependencies +## Build and development tools + +Used to build, test and check YTDescGen. Not shipped to users. | Package | Version | License | Project | | --- | --- | --- | --- | -| `vite` | ^7.3.3 | MIT | | -| `@vitejs/plugin-react` | ^4.3.0 | MIT | | -| `typescript` | ^5.5.0 | Apache-2.0 | | -| `tsx` | ^4.16.0 | MIT | | -| `tailwindcss` | ^3.4.0 | MIT | | -| `prettier-plugin-tailwindcss` | ^0.6.0 | MIT | | -| `postcss` | ^8.5.14 | MIT | | -| `autoprefixer` | ^10.4.0 | MIT | | -| `eslint` | ^9.0.0 | MIT | | -| `@eslint/js` | ^9.0.0 | MIT | | -| `eslint-plugin-react-hooks` | ^5.0.0 | MIT | | -| `typescript-eslint` | ^8.0.0 | MIT | | -| `prettier` | ^3.3.0 | MIT | | -| `vitest` | ^3.2.4 | MIT | | -| `@testing-library/react` | ^16.0.0 | MIT | | -| `@testing-library/jest-dom` | ^6.4.0 | MIT | | -| `@types/react` | ^18.3.0 | MIT | DefinitelyTyped | -| `@types/react-dom` | ^18.3.0 | MIT | DefinitelyTyped | +| `@eslint/js` | 10.0.1 | MIT | | +| `@resvg/resvg-js` | 2.6.2 | MPL-2.0 | — | +| `@tailwindcss/postcss` | 4.3.3 | MIT | | +| `@tauri-apps/cli` | 2.12.0 | Apache-2.0 OR MIT | | +| `@testing-library/jest-dom` | 7.0.1 | MIT | | +| `@testing-library/react` | 16.3.3 | MIT | | +| `@types/node` | 26.6.3 | MIT | | +| `@types/react` | 19.3.0 | MIT | | +| `@types/react-dom` | 19.3.0 | MIT | | +| `@vitejs/plugin-react` | 6.1.1 | MIT | | +| `@vitest/coverage-v8` | 4.1.11 | MIT | | +| `autoprefixer` | 10.6.1 | MIT | | +| `eslint` | 10.11.0 | MIT | | +| `eslint-plugin-react-hooks` | 7.1.1 | MIT | | +| `knip` | 6.38.0 | ISC | | +| `marked` | 18.0.14 | MIT | | +| `postcss` | 8.5.28 | MIT | | +| `prettier` | 3.9.9 | MIT | | +| `prettier-plugin-tailwindcss` | 0.8.1 | MIT | | +| `tailwindcss` | 4.3.3 | MIT | | +| `tsx` | 4.23.15 | MIT | | +| `typescript` | 5.9.3 | Apache-2.0 | | +| `typescript-eslint` | 8.71.0 | MIT | | +| `vite` | 8.3.1 | MIT | | +| `vitest` | 4.1.11 | MIT | | +| `wrangler` | 4.144.0 | MIT OR Apache-2.0 | | -## Tauri Desktop (Rust crates) +## Desktop and Android shell (Rust crates) + +Direct dependencies of `src-tauri/`. Transitive crates are checked in CI by `cargo deny` (see `src-tauri/deny.toml`); `cargo tree` lists them all. | Crate | Version | License | Project | | --- | --- | --- | --- | -| `tauri` | ^2 | Apache-2.0 OR MIT | | -| `tauri-build` | ^2 | Apache-2.0 OR MIT | | -| `tauri-plugin-dialog` | ^2 | Apache-2.0 OR MIT | | -| `tauri-plugin-fs` | ^2 | Apache-2.0 OR MIT | | -| `tauri-plugin-opener` | ^2 | Apache-2.0 OR MIT | | -| `tauri-plugin-shell` | ^2 | Apache-2.0 OR MIT | | -| `tauri-plugin-single-instance` | ^2 | Apache-2.0 OR MIT | | -| `serde` | ^1 | Apache-2.0 OR MIT | | -| `serde_json` | ^1 | Apache-2.0 OR MIT | | +| `tauri` | 2.12.0 | Apache-2.0 OR MIT | | +| `tauri-build` | 2.7.0 | Apache-2.0 OR MIT | | +| `tauri-plugin-dialog` | 2.8.0 | Apache-2.0 OR MIT | | +| `tauri-plugin-fs` | 2.6.0 | Apache-2.0 OR MIT | | +| `tauri-plugin-opener` | 2.7.0 | Apache-2.0 OR MIT | | +| `tauri-plugin-shell` | 2.4.0 | Apache-2.0 OR MIT | | +| `tauri-plugin-single-instance` | 2.5.1 | Apache-2.0 OR MIT | | -Transitive dependencies are not enumerated here. `cargo tree` (in `src-tauri/`) and `npm list --all` produce the exhaustive trees; this list covers the direct dependencies declared in `package.json` and `src-tauri/Cargo.toml`. +## Fonts and icons -## Fonts & Icons +- **Icons:** [Lucide](https://lucide.dev/) (`lucide-react`, ISC). Brand marks, where shown, come from [Simple Icons](https://simpleicons.org/) (CC0-1.0); the trademarks belong to their owners. +- **Fonts:** the app uses the operating system's fonts. -The application uses **system fonts** (`Inter` / `SF Pro` / `Segoe UI` / `Roboto`, fallback `sans-serif`). No custom font files are bundled in the web build. +## Services (web app only) -Icons are provided by [`lucide-react`](https://github.com/lucide-icons/lucide) (ISC license — see above). +The web app at ytgenerator.stream is delivered by Cloudflare. These are services, not bundled code; the [Privacy Policy](PRIVACY.md) explains what each processes. -## AI-Assisted Development Disclosure +| Service | Purpose | Terms | +| --- | --- | --- | +| Cloudflare Workers | Hosting and delivery | | +| Cloudflare Turnstile | Bot check before entering | | +| Cloudflare Web Analytics | Cookieless, aggregate visit statistics | | -Per [`DISCLAIMER.md`](./DISCLAIMER.md), this project was co-authored with **Anthropic's Claude Code (model 4.7 Opus, 1M-context variant)**. The model contributed to source code, locale translations, documentation, and CI configuration. All output was reviewed by the human maintainer (`@poli0981`) before being committed. +The desktop and Android apps use none of them. -No third-party content was reproduced verbatim from the model's training data. Any external text quoted in this repository (notably the Apache License 2.0 in [`LICENSE`](./LICENSE) and the Contributor Covenant link in [`CODE_OF_CONDUCT.md`](./CODE_OF_CONDUCT.md)) is sourced from canonical public locations. +## AI-assisted development -Claude is a product of Anthropic, PBC — . No license is granted by Anthropic to use this project; the Apache 2.0 license in `LICENSE` is granted by `@poli0981` as the project author. +As described in the [Disclaimer](DISCLAIMER.md), YTDescGen is developed with **Anthropic's Claude Code** (Claude Opus models). The model contributes source code, translations, documentation and CI configuration; every change is reviewed by the maintainer (`@poli0981`) before it is merged. Claude is a product of Anthropic, PBC — . The Apache-2.0 license in [`LICENSE`](LICENSE) is granted by the project author, not by Anthropic. -## Reporting an Omission +## Questions and omissions -If you believe a dependency is missing from this list, please open an issue or PR per [`CONTRIBUTING.md`](./CONTRIBUTING.md). +Licensing and attribution questions: **copyright@poli0981.dev**. If you believe something is missing here, open an issue or pull request per [`CONTRIBUTING.md`](CONTRIBUTING.md). diff --git a/package-lock.json b/package-lock.json index 162434c..8dca316 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "^6.1.1", + "@vitest/coverage-v8": "^4.1.11", "autoprefixer": "^10.6.1", "eslint": "^10.11.0", "eslint-plugin-react-hooks": "^7.1.1", @@ -322,6 +323,16 @@ "node": ">=6.9.0" } }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -4068,6 +4079,37 @@ } } }, + "node_modules/@vitest/coverage-v8": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.11.tgz", + "integrity": "sha512-8MVGEFnJIcdGjcbfKmeq8z0pZHH0JlVtoVZH9Q/qwUp6wyFnEJUBMrw9DCaj+ra3vShGmhavjalMIhPNxZAUcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/utils": "4.1.11", + "ast-v8-to-istanbul": "^1.0.0", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.2.0", + "magicast": "^0.5.2", + "obug": "^2.1.1", + "std-env": "^4.0.0-rc.1", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "4.1.11", + "vitest": "4.1.11" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, "node_modules/@vitest/expect": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz", @@ -4266,6 +4308,25 @@ "node": ">=12" } }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.7.tgz", + "integrity": "sha512-kFL68AG6ajd8fg248zwM9GQrUWEp79gsmjum34OEXjs4yHuUMZfYKwOLW9GMmB4oNvVrj+EAGxsP7ye2UR9UlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/autoprefixer": { "version": "10.6.1", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.6.1.tgz", @@ -5026,6 +5087,16 @@ "dev": true, "license": "ISC" }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/hashery": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", @@ -5063,6 +5134,13 @@ "dev": true, "license": "MIT" }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/html-parse-stringify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-4.0.1.tgz", @@ -5169,6 +5247,58 @@ "dev": true, "license": "ISC" }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jiti": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", @@ -5628,6 +5758,47 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.5.tgz", + "integrity": "sha512-UicdXN8zQ3JHlxVq+28afMXPr1z7WNY6+7EJnzTdQWkTAlMLF5fNCCKxJHBQwGaNGR11581EiQmQzx73+MvszA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "source-map-js": "^1.2.1" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/marked": { "version": "18.0.14", "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.14.tgz", diff --git a/package.json b/package.json index e50f5b0..d553d47 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,10 @@ "generate:brand": "tsx scripts/generate-brand-assets.ts", "cf:dev": "wrangler dev", "cf:check": "wrangler deploy --dry-run --outdir .wrangler/dry-run", - "check:tauri": "tsx scripts/check-tauri-versions.ts" + "check:tauri": "tsx scripts/check-tauri-versions.ts", + "check:bundle": "tsx scripts/check-bundle-size.ts", + "check:licenses": "tsx scripts/third-party.ts", + "generate:third-party": "tsx scripts/third-party.ts --write" }, "dependencies": { "@tauri-apps/api": "^2.12.0", @@ -57,6 +60,7 @@ "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "^6.1.1", + "@vitest/coverage-v8": "^4.1.11", "autoprefixer": "^10.6.1", "eslint": "^10.11.0", "eslint-plugin-react-hooks": "^7.1.1", diff --git a/scripts/check-bundle-size.ts b/scripts/check-bundle-size.ts new file mode 100644 index 0000000..925fe25 --- /dev/null +++ b/scripts/check-bundle-size.ts @@ -0,0 +1,74 @@ +/** + * Bundle budget for the web build — run after `npm run build`. + * + * CLAUDE.md used to say "keep the bundle under 500KB" without saying what was + * measured, and nothing measured it. This does: + * + * - INITIAL LOAD: every script, modulepreload and stylesheet `dist/index.html` + * references, summed gzip. That is what a first visit downloads before the + * app can render. Lazy chunks (pages, locales, the legal documents) are + * excluded on purpose — they only load when used. + * - LARGEST CHUNK: no single JS file over the raw limit, so one accidental + * import cannot balloon a lazy page either. + * + * Numbers are printed as a table (and to the GitHub step summary in CI). + * Run via `npm run check:bundle`. + */ +import { appendFileSync, readFileSync, readdirSync } from "fs"; +import { resolve } from "path"; +import { gzipSync } from "zlib"; + +const DIST = resolve(import.meta.dirname, "../dist"); + +/** v1.0.0 baseline was 193 KB gzip before the redesign; keep headroom, not a blank cheque. */ +export const INITIAL_GZIP_BUDGET = 280 * 1024; +export const MAX_CHUNK_RAW = 500 * 1024; + +const kb = (bytes: number): string => `${(bytes / 1024).toFixed(1)} KB`; + +function initialAssets(html: string): string[] { + const refs = new Set(); + const pattern = /(?:src|href)="\/(assets\/[^"]+\.(?:js|css))"/g; + for (let match = pattern.exec(html); match; match = pattern.exec(html)) { + if (match[1]) refs.add(match[1]); + } + return [...refs]; +} + +const html = readFileSync(resolve(DIST, "index.html"), "utf8"); +const initial = initialAssets(html).map((file) => { + const bytes = readFileSync(resolve(DIST, file)); + return { file, raw: bytes.length, gzip: gzipSync(bytes, { level: 9 }).length }; +}); +const initialGzip = initial.reduce((sum, a) => sum + a.gzip, 0); + +const chunks = readdirSync(resolve(DIST, "assets")) + .filter((name) => name.endsWith(".js")) + .map((name) => ({ name, raw: readFileSync(resolve(DIST, "assets", name)).length })) + .sort((a, b) => b.raw - a.raw); +const largest = chunks[0]; + +const rows = [ + `| Initial load (${initial.length} files, gzip) | ${kb(initialGzip)} | ${kb(INITIAL_GZIP_BUDGET)} | ${initialGzip <= INITIAL_GZIP_BUDGET ? "✅" : "❌"} |`, + `| Largest chunk (${largest?.name ?? "—"}, raw) | ${kb(largest?.raw ?? 0)} | ${kb(MAX_CHUNK_RAW)} | ${(largest?.raw ?? 0) <= MAX_CHUNK_RAW ? "✅" : "❌"} |`, +]; +const table = ["| Metric | Size | Budget | |", "| --- | --- | --- | --- |", ...rows].join("\n"); +console.log(table); +console.log("\nInitial-load files:"); +for (const a of initial.sort((x, y) => y.gzip - x.gzip)) { + console.log( + ` ${a.file.padEnd(48)} ${kb(a.raw).padStart(10)} raw ${kb(a.gzip).padStart(9)} gzip`, + ); +} + +if (process.env.GITHUB_STEP_SUMMARY) { + appendFileSync(process.env.GITHUB_STEP_SUMMARY, `### Bundle budget\n\n${table}\n`); +} + +const overChunks = chunks.filter((c) => c.raw > MAX_CHUNK_RAW); +if (initialGzip > INITIAL_GZIP_BUDGET || overChunks.length > 0) { + console.error( + "\nBundle budget exceeded — lazy-load the new code or raise the budget deliberately.", + ); + process.exit(1); +} diff --git a/scripts/lib/third-party.ts b/scripts/lib/third-party.ts new file mode 100644 index 0000000..6dbb601 --- /dev/null +++ b/scripts/lib/third-party.ts @@ -0,0 +1,212 @@ +/** + * Third-party licensing, generated and enforced. + * + * npm run generate:third-party rewrite THIRD_PARTY_NOTICES.md + * npm run check:licenses fail if it is stale, or if anything shipped + * to users carries a license not on the list + * + * THIRD_PARTY_NOTICES.md used to be hand-maintained and had drifted three + * majors behind (React 18, Vite 7, Tailwind 3 …). It is now built from + * package.json, the installed packages and Cargo.toml/Cargo.lock, so CI + * catches the drift instead of a reader. The full license texts of every + * package bundled into the web app are emitted separately by Vite + * (`build.license`) to /licenses/third-party.md. + */ +import { readFileSync, writeFileSync } from "fs"; +import { resolve } from "path"; + +const ROOT = resolve(import.meta.dirname, "../.."); +const NOTICES = resolve(ROOT, "THIRD_PARTY_NOTICES.md"); + +/** Licenses acceptable for code that ships inside the app. */ +const ALLOWED = new Set([ + "MIT", + "ISC", + "Apache-2.0", + "BSD-2-Clause", + "BSD-3-Clause", + "0BSD", + "CC0-1.0", + "Unlicense", + "BlueOak-1.0.0", + "OFL-1.1", + "Zlib", + "MPL-2.0", +]); + +/** SPDX expression → allowed? `OR` needs one side, `AND` needs both. */ +export function licenseAllowed(expression: string): boolean { + const expr = expression.trim().replace(/^\((.*)\)$/, "$1"); + if (/\sOR\s/i.test(expr)) return expr.split(/\s+OR\s+/i).some(licenseAllowed); + if (/\sAND\s/i.test(expr)) return expr.split(/\s+AND\s+/i).every(licenseAllowed); + return ALLOWED.has(expr); +} + +interface PackageJson { + version?: string; + license?: string; + homepage?: string; + repository?: string | { url?: string }; + dependencies?: Record; + devDependencies?: Record; +} + +function readJson(path: string): T { + return JSON.parse(readFileSync(path, "utf8")) as T; +} + +function projectUrl(pkg: PackageJson): string { + const repo = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url; + const fromRepo = repo + ?.replace(/^git\+/, "") + .replace(/^git:\/\//, "https://") + .replace(/^github:/, "https://github.com/") + .replace(/\.git$/, ""); + if (fromRepo && /^https?:\/\//.test(fromRepo)) return fromRepo; + if (fromRepo && /^[\w.-]+\/[\w.-]+$/.test(fromRepo)) return `https://github.com/${fromRepo}`; + return pkg.homepage ?? ""; +} + +interface Row { + name: string; + version: string; + license: string; + url: string; +} + +function npmRows(names: string[]): Row[] { + return names.sort().map((name) => { + const pkg = readJson(resolve(ROOT, "node_modules", name, "package.json")); + return { + name, + version: pkg.version ?? "?", + license: pkg.license ?? "UNKNOWN", + url: projectUrl(pkg), + }; + }); +} + +function crateRows(): Row[] { + const toml = readFileSync(resolve(ROOT, "src-tauri/Cargo.toml"), "utf8").replace(/\r\n/g, "\n"); + const lock = readFileSync(resolve(ROOT, "src-tauri/Cargo.lock"), "utf8").replace(/\r\n/g, "\n"); + const names = [...toml.matchAll(/^([a-z][a-z0-9_-]*)\s*=\s*(?:"|\{)/gm)] + .map((m) => m[1] ?? "") + .filter((n) => n.startsWith("tauri")); + return [...new Set(names)].sort().map((name) => { + const version = + new RegExp(`\\[\\[package\\]\\]\\nname = "${name}"\\nversion = "([^"]+)"`).exec(lock)?.[1] ?? + "?"; + const url = name.startsWith("tauri-plugin") + ? "https://github.com/tauri-apps/plugins-workspace" + : "https://github.com/tauri-apps/tauri"; + return { name, version, license: "Apache-2.0 OR MIT", url }; + }); +} + +function table(rows: Row[], heading: string): string { + const lines = rows.map( + (r) => `| \`${r.name}\` | ${r.version} | ${r.license} | ${r.url ? `<${r.url}>` : "—"} |`, + ); + return [ + `| ${heading} | Version | License | Project |`, + "| --- | --- | --- | --- |", + ...lines, + ].join("\n"); +} + +export function renderNotices(): string { + const pkg = readJson(resolve(ROOT, "package.json")); + const runtime = npmRows(Object.keys(pkg.dependencies ?? {})); + const dev = npmRows(Object.keys(pkg.devDependencies ?? {})); + return ` + +# Third-Party Notices + +YTDescGen is built on the open-source software and services below. Each component keeps its own license; the linked project pages carry the full terms. + +The **complete license text of every package bundled into the web app** — including transitive dependencies such as \`scheduler\` or \`@babel/runtime\` — is published with each release at [\`/licenses/third-party.md\`](https://ytgenerator.stream/licenses/third-party.md), generated by Vite from the exact build. + +## Runtime dependencies + +Bundled into the web app and the desktop / Android apps. + +${table(runtime, "Package")} + +## Build and development tools + +Used to build, test and check YTDescGen. Not shipped to users. + +${table(dev, "Package")} + +## Desktop and Android shell (Rust crates) + +Direct dependencies of \`src-tauri/\`. Transitive crates are checked in CI by \`cargo deny\` (see \`src-tauri/deny.toml\`); \`cargo tree\` lists them all. + +${table(crateRows(), "Crate")} + +## Fonts and icons + +- **Icons:** [Lucide](https://lucide.dev/) (\`lucide-react\`, ISC). Brand marks, where shown, come from [Simple Icons](https://simpleicons.org/) (CC0-1.0); the trademarks belong to their owners. +- **Fonts:** the app uses the operating system's fonts. + +## Services (web app only) + +The web app at ytgenerator.stream is delivered by Cloudflare. These are services, not bundled code; the [Privacy Policy](PRIVACY.md) explains what each processes. + +| Service | Purpose | Terms | +| --- | --- | --- | +| Cloudflare Workers | Hosting and delivery | | +| Cloudflare Turnstile | Bot check before entering | | +| Cloudflare Web Analytics | Cookieless, aggregate visit statistics | | + +The desktop and Android apps use none of them. + +## AI-assisted development + +As described in the [Disclaimer](DISCLAIMER.md), YTDescGen is developed with **Anthropic's Claude Code** (Claude Opus models). The model contributes source code, translations, documentation and CI configuration; every change is reviewed by the maintainer (\`@poli0981\`) before it is merged. Claude is a product of Anthropic, PBC — . The Apache-2.0 license in [\`LICENSE\`](LICENSE) is granted by the project author, not by Anthropic. + +## Questions and omissions + +Licensing and attribution questions: **copyright@poli0981.dev**. If you believe something is missing here, open an issue or pull request per [\`CONTRIBUTING.md\`](CONTRIBUTING.md). +`; +} + +/** Production packages (bundled into the app) whose license is not allowed. */ +export function disallowedProductionLicenses(): string[] { + const lock = readJson<{ + packages: Record; + }>(resolve(ROOT, "package-lock.json")); + const bad: string[] = []; + for (const [path, entry] of Object.entries(lock.packages)) { + if (path === "" || entry.dev || entry.devOptional) continue; + const license = typeof entry.license === "string" ? entry.license : "UNKNOWN"; + if (!licenseAllowed(license)) bad.push(`${path.replace(/^.*node_modules\//, "")} (${license})`); + } + return bad; +} + +export function main(): void { + const write = process.argv.includes("--write"); + const expected = renderNotices(); + if (write) { + writeFileSync(NOTICES, expected); + console.log("THIRD_PARTY_NOTICES.md regenerated."); + return; + } + let failed = false; + const bad = disallowedProductionLicenses(); + if (bad.length > 0) { + failed = true; + console.error(`✗ Bundled packages with licenses outside the allowlist:\n ${bad.join("\n ")}`); + } else { + console.log("✓ Every bundled package has an allowed license."); + } + const current = readFileSync(NOTICES, "utf8").replace(/\r\n/g, "\n"); + if (current !== expected) { + failed = true; + console.error("✗ THIRD_PARTY_NOTICES.md is stale — run `npm run generate:third-party`."); + } else { + console.log("✓ THIRD_PARTY_NOTICES.md matches package.json, the lockfile and Cargo.toml."); + } + if (failed) process.exit(1); +} diff --git a/scripts/third-party.ts b/scripts/third-party.ts new file mode 100644 index 0000000..24826eb --- /dev/null +++ b/scripts/third-party.ts @@ -0,0 +1,10 @@ +/** + * CLI for scripts/lib/third-party.ts: + * + * npm run generate:third-party rewrite THIRD_PARTY_NOTICES.md + * npm run check:licenses verify it is current and every bundled + * package has an allowed license + */ +import { main } from "./lib/third-party"; + +main(); diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 917f4d9..979a7b2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2480,9 +2480,9 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plist" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" +checksum = "7da1d65da6dd5d1e44199ac0f58712d241c0f439f80adea8924d832384087f85" dependencies = [ "base64 0.22.1", "indexmap 2.13.1", @@ -2626,9 +2626,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.38.4" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" dependencies = [ "memchr", ] diff --git a/src-tauri/deny.toml b/src-tauri/deny.toml new file mode 100644 index 0000000..91549be --- /dev/null +++ b/src-tauri/deny.toml @@ -0,0 +1,33 @@ +# cargo-deny configuration for the Tauri shell. Run by +# .github/workflows/rust.yml (on changes under src-tauri/, and weekly for new +# RustSec advisories): `cargo deny check advisories licenses sources`. + +[graph] +all-features = false + +[advisories] +# Unmaintained crates only fail the check when this crate depends on them +# directly. The transitive ones today (e.g. proc-macro-error, RUSTSEC-2024-0370, +# via tauri's gtk-rs 0.18 Linux stack) have no safe upgrade until tauri moves +# on, and would otherwise keep this job permanently red. Vulnerabilities +# always fail, whatever the depth. +unmaintained = "workspace" + +[licenses] +confidence-threshold = 0.9 +# Permissive licenses, plus MPL-2.0 (file-level copyleft; used unmodified). +allow = [ + "MIT", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-3-Clause", + "ISC", + "Zlib", + "Unicode-3.0", + "MPL-2.0", +] + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 33f40d8..5e73d4c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -46,7 +46,8 @@ fn append_to_file(path: String, content: String) -> Result<(), String> { .create(true) .open(&path) .map_err(|e| e.to_string())?; - file.write_all(content.as_bytes()).map_err(|e| e.to_string()) + file.write_all(content.as_bytes()) + .map_err(|e| e.to_string()) } /// List entries in a directory, returning their file names (not full diff --git a/tests/scripts/third-party.test.ts b/tests/scripts/third-party.test.ts new file mode 100644 index 0000000..fe5b76b --- /dev/null +++ b/tests/scripts/third-party.test.ts @@ -0,0 +1,38 @@ +import { describe, it, expect } from "vitest"; +import { + disallowedProductionLicenses, + licenseAllowed, + renderNotices, +} from "../../scripts/lib/third-party"; + +describe("licenseAllowed", () => { + it.each([ + ["MIT", true], + ["Apache-2.0 OR MIT", true], + ["MIT OR GPL-3.0-only", true], + ["(MIT OR Apache-2.0)", true], + ["BSD-3-Clause AND MIT", true], + ["Apache-2.0 AND LGPL-3.0-or-later", false], + ["GPL-3.0-only", false], + ["AGPL-3.0-or-later", false], + ["UNKNOWN", false], + ["", false], + ])("%s → %s", (expression, allowed) => { + expect(licenseAllowed(expression)).toBe(allowed); + }); +}); + +describe("the installed tree", () => { + it("ships no package under a license outside the allowlist", () => { + expect(disallowedProductionLicenses()).toEqual([]); + }); + + it("renders notices that list every runtime dependency and the Cloudflare services", () => { + const md = renderNotices(); + for (const name of ["react", "zustand", "i18next", "@tauri-apps/api"]) { + expect(md).toContain(`| \`${name}\` |`); + } + expect(md).toContain("Cloudflare Turnstile"); + expect(md).toContain("/licenses/third-party.md"); + }); +}); diff --git a/vite.config.ts b/vite.config.ts index 124c546..164796b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -44,6 +44,9 @@ export default defineConfig({ // Never inline assets as data: URIs — the Tauri CSP only allows 'self' // for images and fonts, so an inlined icon would silently fail there. assetsInlineLimit: 0, + // The full license text of every bundled package, for the "Third-party + // notices" page to link to (Apache-2.0 / MIT / ISC all ask for it). + license: { fileName: "licenses/third-party.md" }, rollupOptions: { output: { // Vite 8 bundles with Rolldown, which only accepts the function form of diff --git a/vitest.config.ts b/vitest.config.ts index fddccc6..c2f1d97 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -25,5 +25,19 @@ export default defineConfig({ // default environment is node — a test that renders needs an explicit // `// @vitest-environment jsdom` docblock (and jsdom installed). include: ["tests/**/*.test.{ts,tsx}", "src/**/*.test.{ts,tsx}"], + // `npm run test:coverage` (what CI runs). Thresholds sit just under the + // measured coverage so they catch regressions without blocking work; raise + // them as tests are added. The engine is the part the whole app trusts, + // the worker is the part that guards the site. + coverage: { + provider: "v8", + include: ["src/engine/**", "worker/**", "build-plugins/**"], + exclude: ["worker/index.ts"], + reporter: ["text-summary", "json-summary"], + thresholds: { + "src/engine/**": { statements: 88, branches: 85, functions: 60, lines: 88 }, + "worker/**": { statements: 95, branches: 85, functions: 95, lines: 95 }, + }, + }, }, }); diff --git a/wrangler.jsonc b/wrangler.jsonc index 852cd6f..8980e3a 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -44,6 +44,7 @@ "!/robots.txt", "!/sitemap.xml", "!/theme-init.js", + "!/licenses/*", "!/404.html" ] },