Skip to content

Commit

Permalink
chore: convert stories to CSF format for typescript stories (#253)
Browse files Browse the repository at this point in the history
* update storybook packages to 5.3.9

* update storybook config files to 5.3 convention

the addon.ts and config.ts file name convention from <=5.2 has been deprecated

* add necessary dependencies for custom jscodeshift codemods

* remove unused @storybook/addon-options dependency

* fork stories-of-to-csf.js

* remove deprecated @storybook/addon-options that was not being used

* Don't run pretter when parser is ts or tsx

* add script to run the jscodeshift transform

* make storiesof-to-csf.js work for tsx files

The tsx parser AST the word "StringLiteral" instead of "Literal", which the
js parser AST uses. Because of this, the `storiesOf` stories were being filtered
out, and nothing was being modified. Now it works for tsx.

* run storiesof-to-csf.js on the component library stories

* use the Storybook 5.3 main.js format for finding stories

it seems necessary for CSF to work.
note that this path is much less flexible than the current one:
it only looks for stories in packages/component-library/
I couldn't get the regex or glob to work in the new format, so this will
fixed in a later release. Currently this is the only directory where stories are found.

* remove some unused and unecessary exports, so that the conversion script will work

* rerun storiesof-to-csf, this time upgrading remaining stories

* sort stories using latest recommend method

This is described in https://github.com/storybookjs/storybook/blob/master/lib/ui/README.md

* move transform script to a neater location

* run prettier

Co-authored-by: Seb Pearce <sebpearce@gmail.com>
  • Loading branch information
mbylstra and sebpearce committed Jan 31, 2020
1 parent 22947fd commit 431ffb8
Show file tree
Hide file tree
Showing 40 changed files with 7,061 additions and 4,510 deletions.
23 changes: 14 additions & 9 deletions package.json
Expand Up @@ -48,22 +48,21 @@
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.6.0",
"@cultureamp/elm-storybook": "cultureamp/elm-storybook#0.1.0",
"@storybook/addon-a11y": "^5.2.5",
"@storybook/addon-actions": "^5.2.5",
"@storybook/addon-backgrounds": "^5.2.5",
"@storybook/addon-a11y": "^5.3.9",
"@storybook/addon-actions": "^5.3.9",
"@storybook/addon-backgrounds": "^5.3.9",
"@storybook/addon-console": "^1.2.1",
"@storybook/addon-options": "^5.2.5",
"@storybook/addon-storysource": "^5.2.5",
"@storybook/addon-viewport": "^5.2.5",
"@storybook/react": "^5.2.5",
"@storybook/theming": "^5.2.5",
"@storybook/addon-storysource": "^5.3.9",
"@storybook/addon-viewport": "^5.3.9",
"@storybook/react": "^5.3.9",
"@storybook/theming": "^5.3.9",
"@testing-library/react": "^8.0.1",
"@types/chalk": "^2.2.0",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.5",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@types/storybook__react": "^4.0.2",
"@types/storybook__react": "^5.2.1",
"@types/webpack": "^4.39.1",
"babel-elm-assets-plugin": "^1.2.2",
"babel-loader": "^8.0.6",
Expand Down Expand Up @@ -102,5 +101,11 @@
"typescript": "^3.6.3",
"typescript-tslint-plugin": "^0.5.4",
"webpack": "^4.40.2"
},
"devDependencies": {
"@storybook/codemod": "^5.3.9",
"@storybook/csf": "^0.0.1",
"@storybook/node-logger": "^5.3.9",
"jscodeshift": "^0.7.0"
}
}

0 comments on commit 431ffb8

Please sign in to comment.