next.js
5e965bbb - Add script to patch project with preview tarball URLs (#91057)

Commit
30 days ago
Add script to patch project with preview tarball URLs (#91057) ### What? Adds a new script `scripts/patch-preview-tarball.mjs` that patches a target project's `package.json` to use Next.js preview tarballs from `vercel-packages.vercel.app`. ### Why? When testing unreleased Next.js changes against external projects (e.g., reproducing bugs, verifying fixes), there's no convenient way to point a project at a specific Next.js commit's build artifacts. This script automates the process of wiring up preview tarball URLs into a project's dependency overrides. ### How? The script: 1. **Resolves a commit SHA** via one of three methods: - `--commit <sha>` — use an explicit commit - `--branch <name>` — look up the branch tip via the GitHub API (`gh`) - *(default)* — use the local `git rev-parse HEAD` 2. **Builds tarball URLs** for `next`, `@next/mdx`, `@next/env`, and `@next/bundle-analyzer` using the `vercel-packages.vercel.app/next/commits/<sha>/<pkg>` pattern. 3. **Verifies** that the preview tarball exists (HEAD request to the `next` tarball URL). 4. **Patches `package.json`** in the target project (or its workspace root) by setting both `overrides` (npm/pnpm) and `resolutions` (yarn) for the packages. **Usage:** ```bash node scripts/patch-preview-tarball.mjs --project <path> [--commit <sha> | --branch <name>] ```
Author
Parents
Loading