Skip to content

fix: createNextJSPages throwing preventing copy of store discovery-co… - #3356

Merged
hellofanny merged 1 commit into
devfrom
fix/copy-starter
Jun 1, 2026
Merged

hellofanny merged 1 commit into
devfrom
fix/copy-starter

Conversation

@ommeirelles

@ommeirelles ommeirelles commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

When running cli the step of creating the .faststore folder was not copying the discovery.config of the store because the createNextJsPages trhow an error of use trying to create new nextjs pages/apis that is not allowed.

The behaviour of not allowing is not changed, only kept the flow of script as it was before fixing the config copy that was being steped in this case.

Summary by CodeRabbit

  • Refactor
    • Improved error handling and diagnostics in the initialization process to ensure more accurate error reporting when setup encounters issues.

Review Change Stack

@ommeirelles
ommeirelles requested a review from a team as a code owner May 28, 2026 17:46
@ommeirelles
ommeirelles requested review from emersonlaurentino and hellofanny and removed request for a team May 28, 2026 17:46
@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The PR refines error handling in the CLI's copyUserStarterToCustomizations function by narrowing its try/catch boundary. The catch now protects only starter/customizations copy and Next.js page generation; store config file copying and the success log message execute outside the guarded block, allowing failures in those operations to propagate independently.

Changes

Error Handling Scope Adjustment

Layer / File(s) Summary
Error handling scope refinement
packages/cli/src/utils/generate.ts
Try/catch in copyUserStarterToCustomizations now guards only starter/customizations copy and Next.js page generation; store config selection and success log moved outside to fail independently.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🎯 The catch grows narrower, precise and tight,
Guarding only the files in need of its light,
Config and logs dance free from the shield,
Each failure exact, each truth now revealed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: addressing an issue where createNextJSPages throwing an error prevented the copy of store discovery config from completing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/copy-starter

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

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/utils/generate.ts`:
- Line 257: The unconditional success message is printed even when the prior
operations fail; update the flow in generate.ts so that the success log
(logger.log(`${chalk.green('success')} - Starter files copied`)) only runs when
the try block completes without error — e.g., introduce a boolean success flag
or move that log inside the try after calling copySync and createNextJsPages,
and ensure the catch only logs the error and does not trigger the success
message; reference copySync and createNextJsPages to locate the operations whose
success should gate the log.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 36182082-291d-47b7-ba10-3a678f917353

📥 Commits

Reviewing files that changed from the base of the PR and between b12fa64 and c186fcf.

📒 Files selected for processing (1)
  • packages/cli/src/utils/generate.ts

)
}

logger.log(`${chalk.green('success')} - Starter files copied`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid unconditional success log after a caught failure

If copySync/createNextJsPages fails in the try block, Line 257 still logs success, which can hide partial failure. Gate this log behind a success flag (or log separate success messages per step).

Suggested patch
 function copyUserStarterToCustomizations(basePath: string) {
@@
-  try {
+  let starterCopySucceeded = false
+  try {
     if (existsSync(userSrcDir) && readdirSync(userSrcDir).length > 0) {
       copySync(userSrcDir, tmpCustomizationsSrcDir, { dereference: true })
       createNextJsPages(basePath)
+      starterCopySucceeded = true
     }
   } catch (err) {
     logger.error(`${chalk.red('error')} - ${err}`)
   }
@@
-  logger.log(`${chalk.green('success')} - Starter files copied`)
+  if (starterCopySucceeded) {
+    logger.log(`${chalk.green('success')} - Starter files copied`)
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/utils/generate.ts` at line 257, The unconditional success
message is printed even when the prior operations fail; update the flow in
generate.ts so that the success log (logger.log(`${chalk.green('success')} -
Starter files copied`)) only runs when the try block completes without error —
e.g., introduce a boolean success flag or move that log inside the try after
calling copySync and createNextJsPages, and ensure the catch only logs the error
and does not trigger the success message; reference copySync and
createNextJsPages to locate the operations whose success should gate the log.

@sonar-workflows

Copy link
Copy Markdown

@hellofanny
hellofanny merged commit cf318ab into dev Jun 1, 2026
10 checks passed
@hellofanny
hellofanny deleted the fix/copy-starter branch June 1, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants