-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
WIP: Codemods and refactorings #30292
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
f1a2c53
Csf Tools: Support CSF4 in enrichCsf for source extraction
yannbf 6c27056
Apply suggestions from code review
yannbf 659930e
Use csf-tools in csf factory codemod
yannbf 7db0050
Add defineConfig helper for main.js
yannbf ebe6bf9
move defineConfig to its own import path
yannbf df000bb
fix internal type import
yannbf 5ac85ef
rename the import and function
yannbf 778405d
Move csf factory codemod to automigrations
yannbf e68b8f9
address review comments
yannbf 1f79546
refactor and use automigrate instead of codemod in sandbox
yannbf b0972bc
remove entrypoint
yannbf 325a554
only apply codemod to starter stories in sandbox, rename to csf-facto…
yannbf 9df03e6
fix angular and ember build
yannbf 37811bb
Merge pull request #30282 from storybookjs/yann/move-csf-factory-to-a…
yannbf 503f883
Merge pull request #30250 from storybookjs/yann/csf-factories-extra
yannbf d4e3695
ConfigFile: Support pnp wrapped names
yannbf 6648198
add codemod for main/preview in factory format
yannbf 211fb4b
add storybook config + addon sync codemod
yannbf 310ebf2
sync main and preview in sb add
yannbf f38a9f6
Merge pull request #30312 from storybookjs/yann/csf-config-factory-co…
yannbf 5c3752a
move defineMainConfig definition to the index level
yannbf 04d9f58
modify preview/main config format in codemods/csf file
yannbf 71fefda
add fixes, fix types, fix tests
yannbf 69941ca
fix portable stories test
yannbf 5b4cd43
fix build
yannbf 80c80ac
fix lint
yannbf 2ec88ee
update snapshots
yannbf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,20 @@ export const enrichCsfStory = ( | |
options?: EnrichCsfOptions | ||
) => { | ||
const storyExport = csfSource.getStoryExport(key); | ||
const isCsfFactory = | ||
t.isCallExpression(storyExport) && | ||
t.isMemberExpression(storyExport.callee) && | ||
t.isIdentifier(storyExport.callee.object) && | ||
storyExport.callee.object.name === 'meta'; | ||
Comment on lines
+18
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: This factory detection could miss edge cases where meta is imported under a different name. Consider making this more robust by checking the call signature rather than just the name. |
||
const source = !options?.disableSource && extractSource(storyExport); | ||
const description = | ||
!options?.disableDescription && extractDescription(csfSource._storyStatements[key]); | ||
const parameters = []; | ||
const originalParameters = t.memberExpression(t.identifier(key), t.identifier('parameters')); | ||
// in csf 1/2/3 use Story.parameters; CSF factories use Story.annotations.parameters | ||
const baseStoryObject = isCsfFactory | ||
? t.memberExpression(t.identifier(key), t.identifier('annotations')) | ||
: t.identifier(key); | ||
const originalParameters = t.memberExpression(baseStoryObject, t.identifier('parameters')); | ||
parameters.push(t.spreadElement(originalParameters)); | ||
const optionalDocs = t.optionalMemberExpression( | ||
originalParameters, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { StorybookConfig } from './types'; | ||
|
||
export function defineMain(config: StorybookConfig) { | ||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './client/index'; | ||
export * from './types'; | ||
export * from './defineMainConfig'; | ||
|
||
/* | ||
* ATTENTION: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { StorybookConfig } from './types'; | ||
|
||
export function defineMain(config: StorybookConfig) { | ||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
syntax: extra forward slash in path '..//frameworks/nextjs/src/image-context.ts'