-
- Notifications
You must be signed in to change notification settings - Fork 238
chore: update bump script to create PR #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe version bump script is enhanced to implement a GitHub PR-driven release workflow, replacing a simple console message with a multi-step process that includes git state validation, branch creation, package updates, build execution, PR creation, and optional auto-merge automation. Changes
Sequence DiagramsequenceDiagram actor User participant Script as Bump Script participant Git as Git/GitHub participant Build as Build System participant GitHub as GitHub API User->>Script: Trigger bump version Script->>Git: Check uncommitted changes alt Changes exist Script->>User: Confirm to proceed User-->>Script: Accept/Abort end Script->>Git: Checkout main & pull Script->>Git: Create release branch Script->>Script: Update package.json files Script->>Build: npm/bun install Script->>Build: npm/bun build Script->>Git: Commit changes Script->>Git: Push release branch Script->>GitHub: Create PR GitHub-->>Script: PR created Script->>User: Offer auto-merge option User-->>Script: Enable/Skip auto-merge alt Auto-merge enabled Script->>GitHub: Enable auto-merge on PR end Script->>User: Display next steps Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
scripts/bump-version.ts (3)
1-2: Consider usingBun.fileinstead ofnode:fs/promises.Per the coding guidelines, prefer
Bun.fileovernode:fsreadFile/writeFile methods for file operations.🔎 Proposed refactor using Bun.file
-import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path";Then update file operations throughout the file:
// Reading files const packageJson = JSON.parse(await Bun.file(CLI_PACKAGE_JSON_PATH).text()); // Writing files await Bun.write(CLI_PACKAGE_JSON_PATH, `${JSON.stringify(packageJson, null, 2)}\n`);Based on learnings and coding guidelines,
Bun.fileis the preferred approach for this repository.
10-10: Remove explicit return type.Per coding guidelines, TypeScript files should not use explicit return types.
🔎 Proposed fix
-async function main(): Promise<void> { +async function main() {
88-93: Consider user experience when switching branches.The script switches to
mainand creates a new branch without warning the user. While the uncommitted changes check prevents data loss, if the user is currently on a feature branch, they may be surprised by the branch switch.Consider adding a confirmation or informing the user before switching:
const currentBranch = (await $`git branch --show-current`.text()).trim(); if (currentBranch !== "main") { console.log(`\n⚠️ You are currently on branch '${currentBranch}'. Switching to main...`); }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scripts/bump-version.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
Define functions using the standard function declaration syntax, not arrow functions
Files:
scripts/bump-version.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
**/*.{ts,tsx}: Use TypeScript type aliases instead of interface declarations
Do not use explicit return types
Files:
scripts/bump-version.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
**/*.{ts,tsx,js,jsx}: Usebun <file>instead ofnode <file>orts-node <file>for running TypeScript/JavaScript files
Bun automatically loads .env files, so don't use the dotenv package
UseBun.serve()which supports WebSockets, HTTPS, and routes instead ofexpress
Usebun:sqlitemodule for SQLite instead ofbetter-sqlite3
UseBun.redisfor Redis instead ofioredis
UseBun.sqlfor Postgres instead ofpgorpostgres.js
Use built-inWebSocketinstead of thewspackage
PreferBun.fileovernode:fsreadFile/writeFile methods
UseBun.$template literal syntax instead ofexecafor shell command execution
Import .css files directly in TypeScript/JavaScript files; Bun's CSS bundler will handle bundling
Run server withbun --hot <file>to enable hot reloading during development
Files:
scripts/bump-version.ts
**/*.{ts,tsx,js,jsx,css}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use
bun build <file>instead ofwebpackoresbuildfor bundling TypeScript, JavaScript, and CSS files
Files:
scripts/bump-version.ts
**/*.{html,tsx,ts,jsx,js}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use HTML imports with
Bun.serve()for frontend instead of Vite
Files:
scripts/bump-version.ts
🧠 Learnings (4)
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR Repo: AmanVarshney01/create-better-t-stack PR: 0 File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0 Timestamp: 2025-12-03T07:48:26.419Z Learning: Applies to **/*.{ts,tsx,js,jsx} : Prefer `Bun.file` over `node:fs` readFile/writeFile methods Applied to files:
scripts/bump-version.ts
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR Repo: AmanVarshney01/create-better-t-stack PR: 0 File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0 Timestamp: 2025-12-03T07:48:26.419Z Learning: Applies to package.json : Use `bun run <script>` instead of `npm run <script>`, `yarn run <script>`, or `pnpm run <script>` Applied to files:
scripts/bump-version.ts
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR Repo: AmanVarshney01/create-better-t-stack PR: 0 File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0 Timestamp: 2025-12-03T07:48:26.419Z Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `Bun.$` template literal syntax instead of `execa` for shell command execution Applied to files:
scripts/bump-version.ts
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR Repo: AmanVarshney01/create-better-t-stack PR: 0 File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0 Timestamp: 2025-12-03T07:48:26.419Z Learning: Applies to {package.json,bun.lockb} : Use `bun install` instead of `npm install`, `yarn install`, or `pnpm install` Applied to files:
scripts/bump-version.ts
🔇 Additional comments (3)
scripts/bump-version.ts (3)
77-82: Good addition: Pre-flight check for uncommitted changes.This prevents accidentally losing work or creating commits with unintended changes. The check is well-placed before any git operations begin.
119-134: PR creation workflow looks good.The PR creation with a descriptive body and automatic branch setup is well-structured. The template literal for the PR body is clean and informative.
148-159: Dynamic step numbering and cleanup are well-handled.Good attention to detail with the conditional step numbering based on auto-merge selection, and cleaning up by switching back to main at the end.
| const shouldAutoMerge = await confirm({ | ||
| message: "Enable auto-merge? (PR will merge automatically when tests pass)", | ||
| initialValue: true, | ||
| }); | ||
| | ||
| if (shouldAutoMerge) { | ||
| console.log(`\n🔄 Enabling auto-merge...`); | ||
| await $`gh pr merge ${branchName} --auto --squash --delete-branch`; | ||
| console.log(`✅ Auto-merge enabled. PR will merge automatically when tests pass.`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle user cancellation from confirm prompt.
The confirm function from @clack/prompts returns a symbol (isCancel) when the user cancels (Ctrl+C). The current code doesn't handle this case, which could lead to unexpected behavior.
🔎 Proposed fix
+import { confirm, isCancel, select, text } from "@clack/prompts";Then update the confirm handling:
const shouldAutoMerge = await confirm({ message: "Enable auto-merge? (PR will merge automatically when tests pass)", initialValue: true, }); + if (isCancel(shouldAutoMerge)) { + console.log("\n⚠️ Skipping auto-merge setup."); + } else if (shouldAutoMerge) { - if (shouldAutoMerge) { console.log(`\n🔄 Enabling auto-merge...`); await $`gh pr merge ${branchName} --auto --squash --delete-branch`; console.log(`✅ Auto-merge enabled. PR will merge automatically when tests pass.`); }Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In scripts/bump-version.ts around lines 137 to 146, the confirm() result from @clack/prompts can return the cancel symbol (isCancel) when the user aborts; update the code to import or reference isCancel from @clack/prompts, check if shouldAutoMerge === isCancel right after the confirm call, and if so print a cancellation message and exit/return early (or treat as a negative response) to avoid continuing with enabling auto-merge; otherwise proceed with the existing true/false handling. | if (!shouldAutoMerge) { | ||
| console.log(` 2. Merge the PR manually`); | ||
| } | ||
| console.log( | ||
| ` ${shouldAutoMerge ? "2" : "3"}. The release workflow will automatically publish to NPM`, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor logic issue with step numbering when cancelled.
If shouldAutoMerge is a cancel symbol (not handled currently), the step numbering logic using ternary operator may not behave as expected since a symbol is truthy.
This is related to the cancel handling issue above. Once you handle the cancel case with isCancel, consider using a boolean variable to track the actual state:
const autoMergeEnabled = !isCancel(shouldAutoMerge) && shouldAutoMerge; // Then use autoMergeEnabled for the step numbering🤖 Prompt for AI Agents
In scripts/bump-version.ts around lines 151 to 156, the ternary-based step numbering treats a cancel Symbol as truthy and misnumbers steps; compute a boolean (e.g., autoMergeEnabled = !isCancel(shouldAutoMerge) && Boolean(shouldAutoMerge)) after handling cancel, then use that boolean for the conditional console.logs and the step number expression so cancel is treated as disabled and numbering remains correct.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.