Skip to content

Conversation

@brkalow
Copy link
Member

@brkalow brkalow commented Dec 8, 2025

Description

This builds on #7386.

  • Adds a migration guide generation script
  • Updates output of the CLI and the scan results to be easier to parse
CleanShot 2025-12-08 at 13 23 52@2x CleanShot 2025-12-08 at 13 24 14@2x

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Add a command to generate upgrade guides for specific SDK versions
    • Add a --dryRun CLI flag to preview upgrade actions without applying them
  • Tests

    • Add fixtures covering Next.js v6 upgrade scenarios
  • Chores

    • Add release changeset documenting the migration guide generator and scan improvements

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

🦋 Changeset detected

Latest commit: 5042ef6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/upgrade Minor

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

@vercel
Copy link

vercel bot commented Dec 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Dec 13, 2025 6:06am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Adds a new npm script and accompanying Node.js CLI tool to generate SDK-specific upgrade guides; introduces test fixtures for a Next.js v6 scenario; adds a dryRun CLI flag; and applies small refactors (internal variable rename and JSDoc removal).

Changes

Cohort / File(s) Summary
Package config & script entry
packages/upgrade/package.json
Adds a generate-guide npm script mapping to node scripts/generate-guide.js.
Guide generation script
packages/upgrade/scripts/generate-guide.js
New CLI script: parses --version and --sdk, dynamically loads src/versions/{version}/index.js, reads src/versions/{version}/changes/*.md (gray-matter), filters by SDK, groups by category, generates Markdown upgrade guide, prints to stdout, and handles errors.
CLI flags
packages/upgrade/src/cli.js
Adds exported dryRun boolean flag (default false) and reorders flag declarations (moves sdk after dryRun); preserves skipUpgrade.
Test fixtures
packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/package.json, packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
New fixture project with dependencies on @clerk/nextjs, next, and react; adds App (ClerkProvider wrapper), SignInPage, and SamlCallback components.
Refactor / cleanup
packages/upgrade/src/codemods/transform-align-experimental-unstable-prefixes.cjs, packages/upgrade/src/runner.js
Removes a large JSDoc block from the codemod file and renames local variable globpatterns in runner internals (no behavioral change).
Release metadata
.changeset/quiet-mirrors-breathe.md
Adds a changeset noting a minor release: "Add a migration guide generator and improve scan output."

Sequence Diagram

sequenceDiagram
    participant CLI as CLI User
    participant Main as generate-guide (main)
    participant FS as File System
    participant Parser as Gray-Matter
    participant Gen as Markdown Generator
    participant Stdout as stdout

    CLI->>Main: run --version & --sdk
    Main->>Main: validate args
    Main->>FS: import src/versions/{version}/index.js
    FS-->>Main: versionConfig
    Main->>FS: read src/versions/{version}/changes/*.md
    FS-->>Parser: raw markdown files
    Parser-->>Main: parsed front-matter + content
    Main->>Main: filter by sdk & group by category
    Main->>Gen: build markdown using versionConfig & grouped changes
    Gen-->>Main: markdown document
    Main->>Stdout: print guide
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to: dynamic import error handling in generate-guide.js, gray-matter parsing and filtering logic, CLI dryRun integration points, and the new Next.js fixture component exports.

Poem

🐰 I hopped through markdown, front-matter bright,
Collected changes, sorted them right.
A CLI whisper, version in hand—
Guides for upgrades across the land.
Tiny refactors, fixtures in sight.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding migration guide generation and improving output formatting.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch brk.feat/generate-migration-guide

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd9cd4 and 794d6b0.

📒 Files selected for processing (1)
  • .changeset/quiet-mirrors-breathe.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/quiet-mirrors-breathe.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
  • GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan

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

Base automatically changed from brk.feat/core-3-changes to main December 12, 2025 17:40
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 12, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7397

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7397

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7397

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7397

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7397

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7397

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@7397

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7397

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7397

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7397

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7397

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7397

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7397

@clerk/react

npm i https://pkg.pr.new/@clerk/react@7397

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7397

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7397

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7397

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7397

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7397

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7397

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7397

commit: 5042ef6

Copy link
Contributor

@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 (2)
packages/upgrade/scripts/generate-guide.js (2)

34-44: Consider using async file operations.

While synchronous file operations (fs.existsSync) are acceptable for CLI scripts, using the async versions (fs.promises.access or fs.promises.stat) would be more consistent with modern Node.js patterns.

Example:

 async function loadVersionConfig(version) {
   const configPath = path.join(VERSIONS_DIR, version, 'index.js');
 
-  if (!fs.existsSync(configPath)) {
+  try {
+    await fs.promises.access(configPath);
+  } catch {
     throw new Error(`Version config not found: ${configPath}`);
   }

46-79: Consider using async file operations.

Similar to loadVersionConfig, this function uses synchronous file operations (fs.existsSync, fs.readdirSync, fs.readFileSync). While acceptable for a CLI script, async versions would be more consistent with modern Node.js patterns.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8c8873d and 0bd9cd4.

⛔ Files ignored due to path filters (1)
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • packages/upgrade/package.json (1 hunks)
  • packages/upgrade/scripts/generate-guide.js (1 hunks)
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/package.json (1 hunks)
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx (1 hunks)
  • packages/upgrade/src/cli.js (2 hunks)
  • packages/upgrade/src/codemods/transform-align-experimental-unstable-prefixes.cjs (0 hunks)
  • packages/upgrade/src/runner.js (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/upgrade/src/codemods/transform-align-experimental-unstable-prefixes.cjs
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/upgrade/src/runner.js
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
  • packages/upgrade/scripts/generate-guide.js
  • packages/upgrade/src/cli.js
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/upgrade/src/runner.js
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
  • packages/upgrade/package.json
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/package.json
  • packages/upgrade/scripts/generate-guide.js
  • packages/upgrade/src/cli.js
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Files:

  • packages/upgrade/src/runner.js
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
  • packages/upgrade/scripts/generate-guide.js
  • packages/upgrade/src/cli.js
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/upgrade/src/runner.js
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
  • packages/upgrade/src/cli.js
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use ESLint with custom configurations tailored for different package types

Files:

  • packages/upgrade/src/runner.js
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
  • packages/upgrade/scripts/generate-guide.js
  • packages/upgrade/src/cli.js
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use Prettier for code formatting across all packages

Files:

  • packages/upgrade/src/runner.js
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
  • packages/upgrade/package.json
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/package.json
  • packages/upgrade/scripts/generate-guide.js
  • packages/upgrade/src/cli.js
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components

**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components

Files:

  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
**/*.{md,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Update documentation for API changes

Files:

  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g., UserProfile, NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...

Files:

  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx
packages/*/package.json

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/*/package.json: Packages should export TypeScript types alongside runtime code
Follow semantic versioning for all packages

All packages must be published under @clerk namespace

packages/*/package.json: Framework packages should depend on @clerk/clerk-js for core functionality
@clerk/shared should be a common dependency for most packages in the monorepo

Files:

  • packages/upgrade/package.json
**/package.json

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Use pnpm as the package manager for this monorepo

Files:

  • packages/upgrade/package.json
  • packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/package.json
🧬 Code graph analysis (2)
packages/upgrade/src/runner.js (1)
packages/upgrade/src/codemods/index.js (2)
  • result (61-61)
  • runCodemod (36-80)
packages/upgrade/src/cli.js (1)
packages/upgrade/scripts/generate-guide.js (2)
  • cli (12-32)
  • cli (157-157)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (12)
packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/package.json (1)

1-9: LGTM! Test fixture package.json is well-structured.

The fixture correctly represents a minimal Next.js 14 project with Clerk Next.js v6, appropriate for testing upgrade scenarios.

packages/upgrade/src/__tests__/fixtures/nextjs-v6-scan-issues/src/app.tsx (3)

3-15: Verify: Are missing TypeScript types intentional for this test fixture?

The App component is missing TypeScript type annotations for props and return type, which violates coding guidelines. Given this is in a scan-issues fixture directory, these may be intentional to test the scanner's detection capabilities.

If intentional: No action needed.
If not intentional: Add proper types.

As per coding guidelines, components should have explicit types:

+import type { ReactNode } from 'react';
+
-export default function App({ children }) {
+export default function App({ children }: { children: ReactNode }): JSX.Element {
   return (
     <ClerkProvider

17-24: Verify: Is the missing return type intentional?

The SignInPage component lacks an explicit return type annotation, which is required per coding guidelines. This may be intentional for testing scanner behavior.

If not intentional, add the return type:

-export function SignInPage() {
+export function SignInPage(): JSX.Element {
   return (

26-30: Verify: Are the unused variable and incomplete implementation intentional?

This component has several potential issues:

  1. isSignedIn is extracted but never used
  2. The comment suggests missing SAML callback logic
  3. Missing return type annotation

Given this is in a scan-issues fixture, these may be intentional to test the upgrade scanner's detection capabilities.

If not intentional, consider:

-export function SamlCallback() {
+export function SamlCallback(): JSX.Element {
   const { isSignedIn } = useAuth();
-  // Handle saml callback
-  return <div>SAML SSO Callback</div>;
+  
+  if (!isSignedIn) {
+    return <div>Authenticating...</div>;
+  }
+  
+  return <div>SAML SSO Callback - Authenticated</div>;
 }
packages/upgrade/src/runner.js (1)

40-46: LGTM! Variable rename improves clarity.

The variable rename from glob to patterns aligns with the parameter name in runCodemod (as shown in codemods/index.js line 35), making the code more consistent and easier to follow.

packages/upgrade/src/cli.js (2)

57-57: LGTM! The dryRun flag is properly integrated.

The flag is correctly defined, added to the options object, and used throughout the upgrade flow (warning display at line 81-84, and in performUpgrade at line 182-189).

Also applies to: 73-73


63-63: LGTM! The skipUpgrade flag is properly integrated.

The flag is correctly defined, added to the options object, and used in the upgrade flow at line 149 to skip the package upgrade step.

Also applies to: 78-78

packages/upgrade/package.json (1)

24-24: LGTM! Script addition follows established patterns.

The new generate-guide script is correctly defined and points to the corresponding script file introduced in this PR.

packages/upgrade/scripts/generate-guide.js (4)

1-32: LGTM! CLI setup is well-structured.

The script correctly sets up the CLI with clear usage examples and properly requires both version and sdk flags.


81-102: LGTM! Helper functions are well-implemented.

Both groupByCategory and getCategoryHeading have clear logic and appropriate fallback behavior.


104-154: LGTM! Markdown generation logic is well-structured.

The function correctly handles category ordering with both predefined categories (breaking, deprecation-removal, warning) and any additional categories. The fallback for versionName is reasonable.


156-174: LGTM! Main function has appropriate error handling.

The orchestration logic is clear, error handling is suitable for a CLI script, and outputting to stdout enables flexible usage (e.g., piping to files as shown in the usage examples).

Comment on lines +56 to +76
for (const file of files) {
const filePath = path.join(changesDir, file);
const content = fs.readFileSync(filePath, 'utf8');
const parsed = matter(content);
const fm = parsed.data;

const packages = fm.packages || ['*'];
const appliesToSdk = packages.includes('*') || packages.includes(sdk);

if (!appliesToSdk) {
continue;
}

changes.push({
title: fm.title,
packages,
category: fm.category || 'breaking',
content: parsed.content.trim(),
slug: file.replace('.md', ''),
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Validate required frontmatter fields.

The code doesn't validate that fm.title exists before using it. If a markdown file is missing the title field in its frontmatter, the generated output will contain "### undefined" (see line 129 where change.title is used).

Apply this fix to validate required fields:

   for (const file of files) {
     const filePath = path.join(changesDir, file);
     const content = fs.readFileSync(filePath, 'utf8');
     const parsed = matter(content);
     const fm = parsed.data;
+
+    if (!fm.title) {
+      console.warn(`Warning: ${file} is missing a title field, skipping`);
+      continue;
+    }
 
     const packages = fm.packages || ['*'];
     const appliesToSdk = packages.includes('*') || packages.includes(sdk);
🤖 Prompt for AI Agents
In packages/upgrade/scripts/generate-guide.js around lines 56 to 76, the code
reads frontmatter but doesn't validate required fields like title; add a check
after reading fm to ensure fm.title exists and is non-empty — if missing, either
log a clear error/warning with the file path and skip that file (continue) or
throw an Error to fail the build; update changes.push to only run when the
required fields are present so generated guides never contain "undefined"
titles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants