fix(upgrade): improve CLI usability for monorepos and CI#7874
fix(upgrade): improve CLI usability for monorepos and CI#7874jacekradko wants to merge 9 commits intomainfrom
Conversation
- Traverse parent directories for lockfiles and packageManager field in package.json - Add -w flag for pnpm install/remove at workspace roots - Resolve catalog: protocol versions from pnpm-workspace.yaml - Show actionable example commands in non-interactive error messages - Pass verbose: 0 to jscodeshift for error-level file path logging
🦋 Changeset detectedLatest commit: 01217a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Next.js test fixtures and workspace YAMLs for catalog-based dependency resolution. Expands integration tests to cover catalog version resolution, workspace traversal, lockfile/packageManager precedence, and CLI SDK-detection messaging in non-interactive mode. Introduces resolveCatalogVersion to read pnpm-workspace.yaml while traversing parent directories and updates getSdkVersion to consult catalog resolutions. Enhances package-manager detection to traverse upward, adds isInPnpmWorkspace, and updates install/uninstall/upgrade/remove commands to accept cwd and append pnpm -w when inside a workspace. Improves CLI non-interactive error output and refines codemod verbosity and result reporting. 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/upgrade/src/util/detect-sdk.js`:
- Around line 52-77: Add a JSDoc block above the exported function
resolveCatalogVersion(packageName, dir) that documents it as a public API:
describe both parameters (packageName: string — package identifier to search
for; dir: string — starting directory to traverse upward), explain traversal
behavior (walks parent directories until the filesystem root looking for
pnpm-workspace.yaml), explain parsing behavior (reads the file, matches catalog
entries using the existing regex to extract the version for the given package
name), and state the return value and semantics (returns the matched version
string or null if not found or on read/parse errors). Also include
`@export/`@returns/@param tags and mention that errors are swallowed and result in
null.
- Around line 52-67: resolveCatalogVersion currently searches the entire
pnpm-workspace.yaml for the package name and returns the first match, which
returns wrong versions for named catalogs; update getSdkVersion to extract the
catalog name from the incoming version string (e.g., "catalog:peer-react" →
"peer-react") and pass that catalogName into resolveCatalogVersion, and then
change resolveCatalogVersion to first locate the specific catalog section (e.g.,
a YAML mapping like "catalog.<name>:" or "catalog:\n <name>:") and restrict the
package-version regex search to only that section before matching the
packageName, ensuring the returned version comes from the requested catalog;
reference the functions getSdkVersion and resolveCatalogVersion and the
variables packageName and version string when wiring this change.
|
!snapshot |
|
Hey @jacekradko - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.3.0-snapshot.v20260220160119 --save-exact
npm i @clerk/astro@3.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/backend@3.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/chrome-extension@3.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/clerk-js@6.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/dev-cli@1.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/expo@3.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/expo-passkeys@1.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/express@2.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/fastify@2.7.0-snapshot.v20260220160119 --save-exact
npm i @clerk/localizations@4.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/msw@0.0.1-snapshot.v20260220160119 --save-exact
npm i @clerk/nextjs@7.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/nuxt@2.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/react@6.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/react-router@3.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/shared@4.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/tanstack-react-start@1.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/testing@2.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/ui@1.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/upgrade@2.0.0-snapshot.v20260220160119 --save-exact
npm i @clerk/vue@2.0.0-snapshot.v20260220160119 --save-exact |
Summary
Improves
@clerk/upgradeCLI for monorepo and CI environments:detectPackageManager()now walks up the directory tree to find lockfiles and thepackageManagerfield inpackage.json(Corepack), fixing detection in monorepo subdirectories-wflag:getInstallCommand()andgetUninstallCommand()automatically add-wwhen the target directory is inside a pnpm workspace, preventing "Running this command will add the dependency to the workspace root" errorscatalog:protocol versions:getSdkVersion()now resolves both default (catalog:) and named (catalog:mycat) version specifiers by parsingpnpm-workspace.yamlcatalogs--sdk=nextjsfrom monorepo root), the CLI now searches workspace packages for the version automatically--dir=./apps/webor--sdk/--releaseflags instead of generic errorsverbose: 0to jscodeshift so error-level logging (file paths + error messages) is printed; usesspinner.error()when errors occur.mdand.tsbuildinfofiles from breaking-change scans (matching existing codemod behavior for.md)Testing
Tested across 4 monorepo scenarios:
npx @clerk/upgrade --dry-run@clerk/backendfrom root — now shows monorepo-aware guidance suggesting--diror--sdk--dirsubdirectorynpx @clerk/upgrade --dry-run --dir=./apps/web@clerk/nextjs, resolvedcatalog:version, ran 12 codemods--sdkfrom rootnpx @clerk/upgrade --dry-run --sdk=nextjs--release)--sdk+--releasefrom rootnpx @clerk/upgrade --dry-run --sdk=nextjs --release=core-3Test plan
pnpm buildsucceeds--dir=./apps/webdetects package manager from parent, resolvescatalog:version--sdk=nextjsfrom root resolves version from workspace packages--sdk=nextjs --release=core-3from root runs full scan successfully--dirsuggestion