Skip to content

fix(): warning when updated file content is the same as current#50

Merged
luca-peruzzo merged 3 commits into
keycloakify:mainfrom
eduardoRoth:fix/eroth/update-error-message
May 11, 2026
Merged

fix(): warning when updated file content is the same as current#50
luca-peruzzo merged 3 commits into
keycloakify:mainfrom
eduardoRoth:fix/eroth/update-error-message

Conversation

@eduardoRoth
Copy link
Copy Markdown
Contributor

@eduardoRoth eduardoRoth commented May 8, 2026

I found this running npx keycloakify eject-page for register.ftl file. If the contents of the modified file are exactly the same as the current file contents, then it shows an error that might confuse users.

This update replace the error with a warning, and places the error on the writeFileSync method.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling during file updates with detailed logging for success and failure scenarios.
  • New Features

    • Enhanced page router code generation with dynamic imports and default fallback handling.
    • Added detection for unchanged file content to prevent unnecessary writes with user notification.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87ca837a-aefd-41de-bea9-a14c81b049e5

📥 Commits

Reviewing files that changed from the base of the PR and between d61e3e1 and cc45b84.

📒 Files selected for processing (1)
  • src/bin/eject-page.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/bin/eject-page.ts

📝 Walkthrough

Walkthrough

The eject-page CLI compares original vs modified file content and skips writes when unchanged, wraps writes in try/catch with colored success/error logs, and updates the CLI output to show a switch(pageId) router snippet including a case for the new page and a default fallback.

Changes

Page Ejection File Update Error Handling

Layer / File(s) Summary
File Update Detection and Error Handling
src/bin/eject-page.ts
When updating KcPage.ts and KcPageStory.ts, the command compares original and modified code, logs a yellow "No changes…" message and skips writing if content is unchanged. File writes are wrapped in try/catch, logging green success or red failure messages for write outcomes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A page ejected clean and bright,
with error guards standing tight!
No changes wasted, writes kept sound,
red warnings if trouble's found—
the CLI hops on with delight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: replacing an error message with a warning when file content is unchanged after updates, and moving the actual error handling to the writeFileSync method.
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 unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

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

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
src/bin/eject-page.ts (1)

371-383: ⚡ Quick win

Include the underlying write error in the failure message.

The current catch drops root-cause details, so users can’t quickly diagnose why the auto-update failed.

Proposed patch
-            } catch {
+            } catch (error) {
+                const errorMessage =
+                    error instanceof Error ? error.message : String(error);
                 console.log(
                     chalk.red(
-                        `Unable to automatically update ${fileName}, please update it manually`
+                        `Unable to automatically update ${fileName}, please update it manually (${errorMessage})`
                     )
                 );
             }
🤖 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 `@src/bin/eject-page.ts` around lines 371 - 383, The catch block after
fs.writeFileSync(filePath, Buffer.from(modifiedCode, 'utf8')) swallows the
underlying error; update the catch to capture the thrown error (e.g., catch
(err)) and include the error.message/details in the failure output so the log
for fileName and filePath shows the root-cause (use the same console.log/chalk
path used now but append the error info) to aid diagnosis when automatic update
fails.
🤖 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.

Nitpick comments:
In `@src/bin/eject-page.ts`:
- Around line 371-383: The catch block after fs.writeFileSync(filePath,
Buffer.from(modifiedCode, 'utf8')) swallows the underlying error; update the
catch to capture the thrown error (e.g., catch (err)) and include the
error.message/details in the failure output so the log for fileName and filePath
shows the root-cause (use the same console.log/chalk path used now but append
the error info) to aid diagnosis when automatic update fails.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d95d8d6-25e1-43cd-b184-248b937874b1

📥 Commits

Reviewing files that changed from the base of the PR and between 75ea05a and d61e3e1.

📒 Files selected for processing (1)
  • src/bin/eject-page.ts

@luca-peruzzo luca-peruzzo merged commit 4198cf5 into keycloakify:main May 11, 2026
6 checks passed
@luca-peruzzo
Copy link
Copy Markdown
Member

thanks!

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