-
Notifications
You must be signed in to change notification settings - Fork 87
Prepare for SB10 #569
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
Prepare for SB10 #569
Changes from 14 commits
a064053
958c7be
fd3c654
b6bd5f6
2094e4b
7fd5891
f4b51e6
49024ff
de6531a
d23885c
2a1e346
8fcb31b
4da85c2
52a3bda
9afc71c
6552af9
d9d46ef
020e626
8609766
f3d1819
9fa10a3
7e6c71c
db60cb3
f437d4a
5cf9d6b
dbc63e2
29f1ef4
d0c3175
2c9779a
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 |
|---|---|---|
| @@ -1,20 +1,9 @@ | ||
| module.exports = { | ||
| presets: [ | ||
| ['@babel/preset-env', { targets: { node: 'current' } }], | ||
| '@babel/preset-typescript', | ||
| '@babel/preset-react', | ||
| ], | ||
| presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], | ||
| env: { | ||
| esm: { | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| modules: false, | ||
| targets: { node: 'current' }, | ||
| }, | ||
| ], | ||
| ], | ||
| test: { | ||
| presets: ['@babel/preset-typescript'], | ||
| plugins: ['@babel/plugin-transform-modules-commonjs'], | ||
| }, | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v18 | ||
| v20.16.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,8 @@ | |
| "@jest/types": "^29.6.3", | ||
| "@swc/core": "^1.5.22", | ||
| "@swc/jest": "^0.2.23", | ||
| "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0", | ||
|
Member
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. This looks pretty annoying to keep up to date. Is the intention that each time esbuild releases a new version, this will be updated? Why not use
Member
Author
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. You're right @IanVS However the version range you mention promises to be compatible with "all future versions" of I think that's a promise that can't be kept.
Member
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. That's fair. Though I think you can use |
||
| "esbuild-register": "^3.6.0", | ||
| "expect-playwright": "^0.8.0", | ||
| "jest": "^29.6.4", | ||
| "jest-circus": "^29.6.4", | ||
|
|
@@ -68,7 +70,8 @@ | |
| "jest-serializer-html": "^7.1.0", | ||
| "jest-watch-typeahead": "^2.0.0", | ||
| "nyc": "^15.1.0", | ||
| "playwright": "^1.14.0" | ||
| "playwright": "^1.14.0", | ||
| "semver": "^7.6.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@auto-it/released": "^11.1.6", | ||
|
|
@@ -81,7 +84,7 @@ | |
| "@storybook/addon-docs": "next", | ||
| "@storybook/react-vite": "next", | ||
| "@types/jest": "^29.0.0", | ||
| "@types/node": "^16.4.1", | ||
| "@types/node": "^20.0.0", | ||
| "@types/node-fetch": "^2.6.11", | ||
| "@vitejs/plugin-react": "^4.0.3", | ||
| "auto": "^11.1.6", | ||
|
|
@@ -101,7 +104,7 @@ | |
| "react": "^17.0.1", | ||
| "react-dom": "^17.0.1", | ||
| "read-pkg-up": "^7.0.1", | ||
| "storybook": "next", | ||
| "storybook": "^0.0.0-0 || ^8.2.0 || ^9.0.0 || ^9.1.0-0", | ||
| "tempy": "^1.0.1", | ||
| "ts-dedent": "^2.0.0", | ||
| "ts-jest": "^29.0.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import type { NormalizedStoriesSpecifier } from 'storybook/internal/types'; | ||
|
|
||
| import slash from 'slash'; | ||
| import { dedent } from 'ts-dedent'; | ||
|
|
||
| // FIXME: types duplicated type from `core-common', to be | ||
| // removed when we remove v6 back-compat. | ||
|
|
||
| // deal with files like "atoms/button/{button,index}.stories.js" | ||
| const sanitize = (parts: string[]) => { | ||
| if (parts.length === 0) { | ||
| return parts; | ||
| } | ||
|
|
||
| const last = parts[parts.length - 1]; | ||
| const lastStripped = last?.replace(/(?:[.](?:story|stories))?([.][^.]+)$/i, ''); | ||
|
|
||
| if (parts.length === 1) { | ||
| return [lastStripped]; | ||
| } | ||
|
|
||
| const nextToLast = parts[parts.length - 2]; | ||
| if (lastStripped && nextToLast && lastStripped.toLowerCase() === nextToLast.toLowerCase()) { | ||
| return [...parts.slice(0, -2), lastStripped]; | ||
| } | ||
|
|
||
| return lastStripped && | ||
| (/^(story|stories)([.][^.]+)$/i.test(last) || /^index$/i.test(lastStripped)) | ||
| ? parts.slice(0, -1) | ||
| : [...parts.slice(0, -1), lastStripped]; | ||
| }; | ||
|
|
||
| /** | ||
| * Combines path parts together, without duplicating separators (slashes). Used instead of | ||
| * `path.join` because this code runs in the browser. | ||
| * | ||
| * @param paths Array of paths to join together. | ||
| * @returns Joined path string, with single '/' between parts | ||
| */ | ||
| function pathJoin(paths: string[]): string { | ||
| return paths | ||
| .flatMap((p) => p.split('/')) | ||
| .filter(Boolean) | ||
| .join('/'); | ||
| } | ||
|
|
||
| export const userOrAutoTitleFromSpecifier = ( | ||
| fileName: string | number, | ||
| entry: NormalizedStoriesSpecifier, | ||
| userTitle?: string | ||
| ) => { | ||
| const { directory, importPathMatcher, titlePrefix = '' } = entry || {}; | ||
| // On Windows, backslashes are used in paths, which can cause problems here | ||
| // slash makes sure we always handle paths with unix-style forward slash | ||
|
|
||
| if (typeof fileName === 'number') { | ||
| console.warn(dedent` | ||
| CSF Auto-title received a numeric fileName. This typically happens when | ||
| webpack is mis-configured in production mode. To force webpack to produce | ||
| filenames, set optimization.moduleIds = "named" in your webpack config. | ||
| `); | ||
| } | ||
|
|
||
| const normalizedFileName = slash(String(fileName)); | ||
|
|
||
| if (importPathMatcher.exec(normalizedFileName)) { | ||
| if (!userTitle) { | ||
| const suffix = normalizedFileName.replace(directory, ''); | ||
| let parts = pathJoin([titlePrefix, suffix]).split('/'); | ||
| parts = sanitize(parts); | ||
| return parts.join('/'); | ||
| } | ||
|
|
||
| if (!titlePrefix) { | ||
| return userTitle; | ||
| } | ||
|
|
||
| return pathJoin([titlePrefix, userTitle]); | ||
| } | ||
|
|
||
| return undefined; | ||
| }; | ||
|
|
||
| export const userOrAutoTitle = ( | ||
| fileName: string, | ||
| storiesEntries: NormalizedStoriesSpecifier[], | ||
| userTitle?: string | ||
| ) => { | ||
| for (let i = 0; i < storiesEntries.length; i += 1) { | ||
| const title = userOrAutoTitleFromSpecifier(fileName, storiesEntries[i], userTitle); | ||
|
|
||
| if (title) { | ||
| return title; | ||
| } | ||
| } | ||
|
|
||
| return userTitle || undefined; | ||
| }; |
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.
Is this "the recipe"? 🤔💭❗