Skip to content

build: sync Cloudflare redirect artifact generation with Nuxt Config routeRules#39

Merged
toddeTV merged 6 commits into
mainfrom
build/redirect-artifact-generation
May 19, 2026
Merged

build: sync Cloudflare redirect artifact generation with Nuxt Config routeRules#39
toddeTV merged 6 commits into
mainfrom
build/redirect-artifact-generation

Conversation

@toddeTV
Copy link
Copy Markdown
Owner

@toddeTV toddeTV commented May 19, 2026

Summary by CodeRabbit

  • New Features

    • Automated generation and validation of redirect artifacts with drift detection, and CI checks to validate redirects.
  • Chores

    • Centralized redirect definitions in project metadata for consistent routing.
    • Build pipeline updated to create and verify redirect outputs during generation.
    • Deployment config updated to ignore local Cloudflare redirect artifacts; static bundled redirects removed in favor of generated artifacts.

Review Change Stack

@toddeTV toddeTV self-assigned this May 19, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 5d18af21-9d9e-4db6-bd7c-16eaa13f267d

📥 Commits

Reviewing files that changed from the base of the PR and between 684ddef and c977676.

📒 Files selected for processing (1)
  • scripts/generate-redirects.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/generate-redirects.ts

📝 Walkthrough

Walkthrough

This PR centralizes redirect management by moving static Cloudflare Pages redirect rules into project metadata. A new TypeScript CLI script generates redirect artifacts from metadata during build and validates them in tests. Nuxt config now derives route rules from the same metadata source, eliminating hardcoded redirect entries.

Changes

Redirect metadata and automation system

Layer / File(s) Summary
Redirect metadata types and configuration
project-metadata.config.ts
ProjectMetadata gains a redirects field. New interfaces model redirect entries, groups, and Nuxt route rules. Constants centralize legal and security paths. Config defines redirect groups with from/to mappings and status codes. Helpers derive Nuxt routeRules and render Cloudflare _redirects file content.
Redirect generation CLI script
scripts/generate-redirects.ts
New TypeScript CLI accepts --check and --output flags. Verification helper reads existing artifact and throws on missing or drifted content. Writer helper creates output directory and writes artifact. Main function orchestrates parsing, rendering, and check/write modes.
Build and test automation wiring
package.json, .github/workflows/validation-and-tests.yml
build:ssg chains redirect generation (generate + --check validate) after Nuxt build. New test:redirects script mirrors this sequence. CI workflow matrix adds Redirect Artifact Check entry.
Nuxt config refactoring
nuxt.config.ts
Consolidates project-metadata imports and derives redirectRouteRules from metadata helper. Replaces hardcoded legal/privacy/security redirects with metadata-driven routeRules spread.
Module re-exports and cleanup
shared/utils/project-metadata.ts, .gitignore
Re-exports redirect types and helper functions for use throughout codebase. .gitignore adds Cloudflare output and generated redirect files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • toddeTV/todde.tv#5: Extends the test matrix in .github/workflows/validation-and-tests.yml that was initially defined in PR #5.
  • toddeTV/todde.tv#38: Further refactors the metadata-driven redirect system started in PR #38 by introducing centralized configuration and automation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: synchronizing Cloudflare redirect artifact generation with Nuxt Config routeRules, which is the core objective across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/generate-redirects.ts (1)

12-85: ⚡ Quick win

Add brief JSDoc comments for all functions in this file.

This script defines multiple functions without JSDoc; please add short docblocks to align with repository standards.

As per coding guidelines, "Brief JSDoc on all functions."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/generate-redirects.ts` around lines 12 - 85, Add concise JSDoc blocks
above every top-level function: parseArgs, assertRedirectsFile,
writeRedirectsFile, and main. Each docblock should be one or two sentences
describing the function's purpose, include `@param` tags for each parameter (with
types and brief descriptions), and an `@returns` tag for non-void Promise return
types (or `@returns` {void} where appropriate); for assertRedirectsFile and
parseArgs also include `@throws` describing the error condition. Keep comments
brief and follow existing repository style (short description line, then tags).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/generate-redirects.ts`:
- Around line 46-56: The catch block around the readFile call currently treats
all errors as a missing artifact; change it to inspect the caught error (from
the await readFile(outputPath, 'utf8') call) and only throw the "Redirect
artifact is missing" Error when the error.code === 'ENOENT' (i.e., file not
found) using relative(process.cwd(), outputPath) for the message and include the
original error as cause; for any other error (permission, I/O, etc.) rethrow the
original error so those failures are preserved and correctly reported.

---

Nitpick comments:
In `@scripts/generate-redirects.ts`:
- Around line 12-85: Add concise JSDoc blocks above every top-level function:
parseArgs, assertRedirectsFile, writeRedirectsFile, and main. Each docblock
should be one or two sentences describing the function's purpose, include `@param`
tags for each parameter (with types and brief descriptions), and an `@returns` tag
for non-void Promise return types (or `@returns` {void} where appropriate); for
assertRedirectsFile and parseArgs also include `@throws` describing the error
condition. Keep comments brief and follow existing repository style (short
description line, then tags).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 32ccd3e4-00ba-45dd-8fc3-06e23f10cb8c

📥 Commits

Reviewing files that changed from the base of the PR and between b2b0a14 and 684ddef.

📒 Files selected for processing (8)
  • .github/workflows/validation-and-tests.yml
  • .gitignore
  • nuxt.config.ts
  • package.json
  • project-metadata.config.ts
  • public/_redirects
  • scripts/generate-redirects.ts
  • shared/utils/project-metadata.ts
💤 Files with no reviewable changes (1)
  • public/_redirects

Comment thread scripts/generate-redirects.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant