-
Notifications
You must be signed in to change notification settings - Fork 31
fix(cli): remove @o2s/framework references from Storybook config during scaffold #842
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,28 @@ import { ALWAYS_REMOVE_DIRS, ALWAYS_REMOVE_FILES } from '../constants'; | |
| import * as fs from 'fs-extra'; | ||
| import * as path from 'path'; | ||
|
|
||
| /** | ||
| * Removes @o2s/framework references from .storybook/main.ts after scaffolding. | ||
| * The packages/framework directory is always removed, so these aliases and | ||
| * optimizeDeps entries would cause Storybook to fail. | ||
| */ | ||
| const cleanStorybookConfig = async (projectDir: string): Promise<void> => { | ||
| const configPath = path.join(projectDir, '.storybook', 'main.ts'); | ||
| if (!(await fs.pathExists(configPath))) return; | ||
|
|
||
| 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'); | ||
| }; | ||
|
Comment on lines
+14
to
+25
|
||
|
|
||
| export const cleanupProject = async (projectDir: string): Promise<void> => { | ||
| console.log('Organizing project structure...'); | ||
|
|
||
|
|
@@ -18,4 +40,7 @@ export const cleanupProject = async (projectDir: string): Promise<void> => { | |
| await fs.remove(fullPath); | ||
| } | ||
| } | ||
|
|
||
| // Clean storybook config after removing framework directory | ||
| await cleanStorybookConfig(projectDir); | ||
| }; | ||
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.
The Storybook cleanup uses several near-identical regex
replacecalls. 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.