Skip to content

fix(cli): remove @o2s/framework references from Storybook config during scaffold#842

Open
tranhoangtu-it wants to merge 1 commit intoo2sdev:mainfrom
tranhoangtu-it:fix/storybook-framework-aliases
Open

fix(cli): remove @o2s/framework references from Storybook config during scaffold#842
tranhoangtu-it wants to merge 1 commit intoo2sdev:mainfrom
tranhoangtu-it:fix/storybook-framework-aliases

Conversation

@tranhoangtu-it
Copy link
Copy Markdown

@tranhoangtu-it tranhoangtu-it commented Mar 29, 2026

Fixes #836

After scaffolding with create-o2s-app, Storybook fails because .storybook/main.ts contains resolve aliases and optimizeDeps entries pointing to packages/framework/ paths that no longer exist (removed by ALWAYS_REMOVE_DIRS).

Changes

Added cleanStorybookConfig() to cleanup.ts that strips:

  • @o2s/framework/modules and @o2s/framework/sdk from optimizeDeps.include
  • @o2s/framework/sdk and @o2s/framework/modules alias entries from resolve.alias

Runs automatically after directory cleanup, so the Storybook config is consistent with the scaffolded project structure.

Summary by CodeRabbit

  • Chores
    • Improved project scaffolding cleanup to properly remove outdated framework references from Storybook configuration, ensuring generated projects maintain valid configurations when removing framework packages.

Copilot AI review requested due to automatic review settings March 29, 2026 01:36
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
o2s-docs Skipped Skipped Mar 29, 2026 1:36am

Request Review

@vercel vercel bot temporarily deployed to Preview – o2s-docs March 29, 2026 01:36 Inactive
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 31812d3f-1a4e-43ef-a51d-06ee3de5b84f

📥 Commits

Reviewing files that changed from the base of the PR and between 0b23817 and ca10be7.

📒 Files selected for processing (1)
  • packages/cli/create-o2s-app/src/scaffold/cleanup.ts

Walkthrough

A new helper function cleanStorybookConfig() was added to remove broken @o2s/framework package references from the scaffolded project's .storybook/main.ts file, addressing Storybook startup failures after the framework directory is removed during scaffolding.

Changes

Cohort / File(s) Summary
Storybook Config Cleanup
packages/cli/create-o2s-app/src/scaffold/cleanup.ts
Added cleanStorybookConfig(projectDir) helper that uses regex-based filtering to remove @o2s/framework entries from optimizeDeps.include and resolve.alias in .storybook/main.ts. Integrated into cleanupProject() to run after directory removal.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A storybook fix, so neat and divine,
Framework aliases? Now removed line by line!
With regex and care, the config is clean,
Storybook spins up—the best you've seen! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing @o2s/framework references from Storybook config during the scaffold process, which directly addresses the issue.
Description check ✅ Passed The description covers the problem, links the related issue, and explains the changes made. However, it lacks detailed testing instructions and media as specified in the template.
Linked Issues check ✅ Passed The PR directly addresses issue #836 by implementing the proposed solution: adding cleanStorybookConfig() to remove @o2s/framework references from resolve.alias and optimizeDeps.include in .storybook/main.ts during scaffolding.
Out of Scope Changes check ✅ Passed All changes are focused and in-scope: only the cleanup.ts file was modified to add the new cleanStorybookConfig() helper function that addresses the linked issue without introducing unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a create-o2s-app scaffolding issue where Storybook fails to start due to stale .storybook/main.ts references to the removed packages/framework workspace.

Changes:

  • Add a scaffold cleanup step that removes @o2s/framework/* entries from Storybook optimizeDeps.include and resolve.alias.
  • Run the Storybook config cleanup automatically as part of cleanupProject().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to +25
let content = await fs.readFile(configPath, 'utf-8');

// Remove @o2s/framework lines from optimizeDeps.include
content = content.replace(/\s*'@o2s\/framework\/modules',?\n?/g, '');
content = content.replace(/\s*'@o2s\/framework\/sdk',?\n?/g, '');

// Remove @o2s/framework alias lines from resolve.alias
content = content.replace(/\s*'@o2s\/framework\/sdk':.*\n/g, '');
content = content.replace(/\s*'@o2s\/framework\/modules':.*\n/g, '');

await fs.writeFile(configPath, content, 'utf-8');
};
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

cleanStorybookConfig always rewrites .storybook/main.ts even when none of the patterns match (e.g., templates without the framework aliases). This adds unnecessary I/O and can change file timestamps during scaffolding. Consider only calling writeFile when the transformed content differs from the original read content.

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +22
// Remove @o2s/framework lines from optimizeDeps.include
content = content.replace(/\s*'@o2s\/framework\/modules',?\n?/g, '');
content = content.replace(/\s*'@o2s\/framework\/sdk',?\n?/g, '');

// Remove @o2s/framework alias lines from resolve.alias
content = content.replace(/\s*'@o2s\/framework\/sdk':.*\n/g, '');
content = content.replace(/\s*'@o2s\/framework\/modules':.*\n/g, '');
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The Storybook cleanup uses several near-identical regex replace calls. This duplication makes it easy to miss future framework entrypoints (or introduce inconsistencies between optimizeDeps and resolve.alias removals). Consider centralizing the list of framework specifiers/aliases and applying the removals in a loop so it stays consistent as the template evolves.

Copilot uses AI. Check for mistakes.
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.

[Bug] CLI scaffold: Storybook fails due to broken @o2s/framework aliases in .storybook/main.ts

2 participants