Dependency Update Routine
Section titled “Dependency Update Routine”This document defines the repeatable dependency update process for NutsNews.
Created for GitHub issue #33.
Issue #33 asks for a routine that keeps dependencies reasonably current without breaking the site.
Acceptance criteria:
Dependency updates have a repeatable process.The dependency routine should:
- Review
npm auditoutput. - Review
npm outdatedoutput. - Update safe patch/minor versions.
- Avoid forced upgrades without testing.
- Confirm the web build still passes.
- Confirm Worker TypeScript checks still pass when Worker dependencies change.
- Leave a local report that can be reviewed before committing.
Project Areas Covered
Section titled “Project Areas Covered”NutsNews has three npm projects:
| Area | Path | Runtime |
|---|---|---|
| Web app and admin portal | web/ | Next.js on Vercel |
| RSS ingestion shards | worker/ | Cloudflare Workers |
| Shard controller | controller/ | Cloudflare Workers |
The dependency routine checks all three.
Commands
Section titled “Commands”Run from the repository root.
Check only
Section titled “Check only”Use this when you want to inspect dependency health without changing lockfiles:
./scripts/dependency_update_routine.sh checkThis mode:
- Installs from lockfiles with
npm ci. - Captures
npm outdated --long. - Captures
npm audit --audit-level=moderate. - Runs validation checks.
- Writes a report under
dependency-update-reports/.
Apply safe patch/minor updates
Section titled “Apply safe patch/minor updates”Use this when you want to update dependencies within the safe version ranges already allowed by package.json:
./scripts/dependency_update_routine.sh updateThis mode does everything from check mode and also runs:
npm update --saveThe script intentionally does not run:
npm audit fix --forceForced fixes can jump major versions and break the site. Handle those in a separate issue after reading release notes and testing.
What the Script Validates
Section titled “What the Script Validates”The web project must pass:
npm run lintnpm run buildThe build check is required because Issue #33 explicitly requires confirming the web build after dependency updates.
Worker
Section titled “Worker”The Worker project must pass:
npm run generate:wranglernpx tsc --noEmit --project tsconfig.jsonThis catches TypeScript, Wrangler config, and Cloudflare Worker typing problems.
Controller
Section titled “Controller”The controller routine checks TypeScript only when a tsconfig.json exists.
The controller currently has no build script, so dependency updates are validated through install/audit/outdated reporting and deployment-time Wrangler checks.
Report Location
Section titled “Report Location”Every run writes a timestamped local report:
dependency-update-reports/<yyyymmdd-hhmmss>/The report includes:
summary.md- Per-project routine logs
package.before.jsonpackage.after.jsonpackage-lock.before.jsonpackage-lock.after.json
These reports are ignored by Git.
Recommended Cadence
Section titled “Recommended Cadence”Run the check routine:
- Once per month.
- Before closing dependency/security maintenance issues.
- Before applying Dependabot PRs.
- After adding major new libraries.
- After a security advisory appears in GitHub or
npm audit.
Run update mode only when you have time to review and test.
Dependabot
Section titled “Dependabot”This repo includes:
.github/dependabot.ymlDependabot is configured to check npm dependencies weekly for:
web/worker/controller/
Dependabot groups patch/minor updates separately by project. Treat those PRs as suggestions, not automatic production releases.
Before merging a dependency PR, run:
./scripts/dependency_update_routine.sh checkIf the PR changes web dependencies, confirm:
cd webnpm run buildSafe Update Rules
Section titled “Safe Update Rules”Safe by default:
- Patch updates.
- Minor updates inside existing semver ranges.
- Type package updates that pass build/typecheck.
- Lockfile-only refreshes that pass validation.
Not safe by default:
- Major version upgrades.
npm audit fix --force.- Framework upgrades without reading release notes.
- Next.js, React, Wrangler, Supabase, Sentry, or NextAuth upgrades without build/deploy testing.
- Updates that require environment variable changes.
Manual Review Checklist
Section titled “Manual Review Checklist”After running update mode:
git status --shortgit diff -- web/package.json web/package-lock.json worker/package.json worker/package-lock.json controller/package.json controller/package-lock.jsonConfirm:
[ ] npm audit output was reviewed.[ ] npm outdated output was reviewed.[ ] No forced audit fix was used.[ ] Web lint passed.[ ] Web build passed.[ ] Worker Wrangler generation passed.[ ] Worker TypeScript passed.[ ] Any major upgrades were excluded or moved to a separate issue.[ ] Runtime smoke checks are planned after deploy.Commit Pattern
Section titled “Commit Pattern”Use a clear commit message:
git add web/package.json web/package-lock.json worker/package.json worker/package-lock.json controller/package.json controller/package-lock.jsongit commit -m "Update safe npm dependencies"For a routine-only documentation/script update:
git add .github/dependabot.yml .gitignore README.md docs/README.md docs/OPERATIONS.md docs/ARCHITECTURE.md docs/DEPLOYMENT_CHECKLIST.md docs/DEPENDENCY_UPDATES.md scripts/dependency_update_routine.shgit commit -m "Add dependency update routine"Rollback
Section titled “Rollback”If an update breaks local validation:
git restore web/package.json web/package-lock.json worker/package.json worker/package-lock.json controller/package.json controller/package-lock.jsonThen rerun check mode:
./scripts/dependency_update_routine.sh checkIf the problem happens after deployment, revert the dependency update commit and redeploy.
Production Smoke Checks After Deploy
Section titled “Production Smoke Checks After Deploy”After dependency updates are deployed, run:
./scripts/post_deploy_verify.shThen check:
curl -I "https://www.nutsnews.com/"curl -s "https://www.nutsnews.com/api/articles?page=0" | head -c 500curl "https://nutsnews-controller.nutsnews.workers.dev/?shard=0"curl "https://nutsnews-worker-0.nutsnews.workers.dev/?limit=1"Also review:
- Sentry errors
- Better Stack logs
- Better Stack uptime
/admin/shards/admin/feed-health/admin/feeds
