chore(monorepo): remove versions from private workspaces#7306
chore(monorepo): remove versions from private workspaces#7306
Conversation
Co-authored-by: alexander <alexander@n1s.se>
📝 WalkthroughWalkthroughThis PR removes hardcoded Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🚅 Deployed to the trpc-pr-7306 environment in trpc-sse-and-websockets
|
There was a problem hiding this comment.
Pull request overview
Removes redundant version fields from private/non-published workspace packages, and updates the version-pinning script so it can still derive a version when a workspace package no longer declares one.
Changes:
- Removed
versionfrom multiple private workspacepackage.jsonfiles (examples, tests, docs site). - Updated
scripts/version.tsto fall back to the monorepo version inlerna.jsonwhen a package lacks a localversion.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| www/package.json | Remove redundant version from a private workspace package. |
| www/og-image/package.json | Remove redundant version from a private workspace package. |
| scripts/version.ts | Fall back to lerna.json version when packages/*/package.json has no version, preserving @trpc/* dependency pinning. |
| packages/tests/package.json | Remove redundant version from a private workspace package. |
| examples/vercel-edge-runtime/package.json | Remove redundant version from a private workspace package. |
| examples/standalone-server/package.json | Remove redundant version from a private workspace package. |
| examples/soa/package.json | Remove redundant version from a private workspace package. |
| examples/openapi-codegen/package.json | Remove redundant version from a private workspace package. |
| examples/next-websockets-encoder/package.json | Remove redundant version from a private workspace package. |
| examples/next-sse-chat/package.json | Remove redundant version from a private workspace package. |
| examples/next-prisma-websockets-starter/package.json | Remove redundant version from a private workspace package. |
| examples/next-prisma-todomvc/package.json | Remove redundant version from a private workspace package. |
| examples/next-prisma-starter/package.json | Remove redundant version from a private workspace package. |
| examples/next-minimal-starter/package.json | Remove redundant version from a private workspace package. |
| examples/next-formdata/package.json | Remove redundant version from a private workspace package. |
| examples/next-edge-runtime/package.json | Remove redundant version from a private workspace package. |
| examples/next-big-router/package.json | Remove redundant version from a private workspace package. |
| examples/minimal/package.json | Remove redundant version from a private workspace package. |
| examples/minimal-react/server/package.json | Remove redundant version from a private workspace package. |
| examples/minimal-react/package.json | Remove redundant version from a private workspace package. |
| examples/minimal-react/client/package.json | Remove redundant version from a private workspace package. |
| examples/minimal-content-types/server/package.json | Remove redundant version from a private workspace package. |
| examples/minimal-content-types/package.json | Remove redundant version from a private workspace package. |
| examples/minimal-content-types/client/package.json | Remove redundant version from a private workspace package. |
| examples/lazy-load/package.json | Remove redundant version from a private workspace package. |
| examples/lambda-url/package.json | Remove redundant version from a private workspace package. |
| examples/lambda-api-gateway/package.json | Remove redundant version from a private workspace package. |
| examples/lambda-api-gateway-streaming/package.json | Remove redundant version from a private workspace package. |
| examples/fastify-server/package.json | Remove redundant version from a private workspace package. |
| examples/express-server/package.json | Remove redundant version from a private workspace package. |
| examples/express-minimal/package.json | Remove redundant version from a private workspace package. |
| examples/cloudflare-workers/package.json | Remove redundant version from a private workspace package. |
| examples/bun/package.json | Remove redundant version from a private workspace package. |
| examples/.test/ssg/package.json | Remove redundant version from a private workspace package. |
| examples/.test/ssg-infinite-serialization/package.json | Remove redundant version from a private workspace package. |
| examples/.test/monotest-tsconfig/package.json | Remove redundant version from a private workspace package. |
| examples/.test/monotest-trpc/package.json | Remove redundant version from a private workspace package. |
| examples/.test/monotest-app/package.json | Remove redundant version from a private workspace package. |
| examples/.test/monotest-api/package.json | Remove redundant version from a private workspace package. |
| examples/.test/monotest-api-router01/package.json | Remove redundant version from a private workspace package. |
| examples/.test/internal-types-export/package.json | Remove redundant version from a private workspace package. |
| examples/.test/diagnostics-big-router/package.json | Remove redundant version from a private workspace package. |
| examples/.experimental/next-app-dir/package.json | Remove redundant version from a private workspace package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/version.ts (1)
6-8: Validatelerna.jsonversion before using it.
as stringhere can mask malformed config and fail later in less obvious places. A small guard makes failures immediate and clearer.Proposed hardening
-const repoVersion = JSON.parse( - fs.readFileSync(path.join(import.meta.dirname, '..', 'lerna.json'), 'utf8'), -).version as string; +const lernaConfig = JSON.parse( + fs.readFileSync(path.join(import.meta.dirname, '..', 'lerna.json'), 'utf8'), +) as { version?: unknown }; + +if (typeof lernaConfig.version !== 'string' || lernaConfig.version.length === 0) { + throw new Error('Invalid lerna.json: expected non-empty string "version"'); +} + +const repoVersion = lernaConfig.version;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/version.ts` around lines 6 - 8, The code assigns repoVersion using a blind cast ("as string") which can hide malformed lerna.json; change the repoVersion initialization (the variable assigned from fs.readFileSync/JSON.parse) to perform a runtime check that the parsed object has a truthy string property "version" (e.g., typeof parsed.version === 'string' && parsed.version.trim() !== ''), and if not throw or log a clear error mentioning "lerna.json version missing or invalid" before proceeding; remove the unsafe "as string" cast and use the validated value for the rest of the script.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@scripts/version.ts`:
- Around line 6-8: The code assigns repoVersion using a blind cast ("as string")
which can hide malformed lerna.json; change the repoVersion initialization (the
variable assigned from fs.readFileSync/JSON.parse) to perform a runtime check
that the parsed object has a truthy string property "version" (e.g., typeof
parsed.version === 'string' && parsed.version.trim() !== ''), and if not throw
or log a clear error mentioning "lerna.json version missing or invalid" before
proceeding; remove the unsafe "as string" cast and use the validated value for
the rest of the script.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 956df7ce-da9d-448f-a7f0-85aba8fce69c
📒 Files selected for processing (43)
examples/.experimental/next-app-dir/package.jsonexamples/.test/diagnostics-big-router/package.jsonexamples/.test/internal-types-export/package.jsonexamples/.test/monotest-api-router01/package.jsonexamples/.test/monotest-api/package.jsonexamples/.test/monotest-app/package.jsonexamples/.test/monotest-trpc/package.jsonexamples/.test/monotest-tsconfig/package.jsonexamples/.test/ssg-infinite-serialization/package.jsonexamples/.test/ssg/package.jsonexamples/bun/package.jsonexamples/cloudflare-workers/package.jsonexamples/express-minimal/package.jsonexamples/express-server/package.jsonexamples/fastify-server/package.jsonexamples/lambda-api-gateway-streaming/package.jsonexamples/lambda-api-gateway/package.jsonexamples/lambda-url/package.jsonexamples/lazy-load/package.jsonexamples/minimal-content-types/client/package.jsonexamples/minimal-content-types/package.jsonexamples/minimal-content-types/server/package.jsonexamples/minimal-react/client/package.jsonexamples/minimal-react/package.jsonexamples/minimal-react/server/package.jsonexamples/minimal/package.jsonexamples/next-big-router/package.jsonexamples/next-edge-runtime/package.jsonexamples/next-formdata/package.jsonexamples/next-minimal-starter/package.jsonexamples/next-prisma-starter/package.jsonexamples/next-prisma-todomvc/package.jsonexamples/next-prisma-websockets-starter/package.jsonexamples/next-sse-chat/package.jsonexamples/next-websockets-encoder/package.jsonexamples/openapi-codegen/package.jsonexamples/soa/package.jsonexamples/standalone-server/package.jsonexamples/vercel-edge-runtime/package.jsonpackages/tests/package.jsonscripts/version.tswww/og-image/package.jsonwww/package.json
💤 Files with no reviewable changes (6)
- examples/.test/monotest-tsconfig/package.json
- examples/.test/monotest-api-router01/package.json
- examples/.test/monotest-api/package.json
- examples/.test/monotest-trpc/package.json
- examples/.test/ssg-infinite-serialization/package.json
- examples/.test/monotest-app/package.json
Closes #
🎯 Changes
Remove the redundant
versionfield from private/non-published workspace packages.Update
scripts/version.tsbecause it previously assumed every package inpackages/*declared a localversion. Once private workspaces like@trpc/testsstop carrying that field, the script still needs a version source for pinning@trpc/*dependencies, so it now falls back to the repo version fromlerna.json.✅ Checklist
Summary by CodeRabbit