Skip to content
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

Release: Prerelease 8.0.0-beta.4 #26075

Merged
merged 133 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
5bd78d3
fix: table of contents leak into stories
vmizg Aug 2, 2023
93a5503
docs: update TOC docs
vmizg Aug 2, 2023
c8ecec6
fix: update TOC ignoreSelector
vmizg Aug 2, 2023
e98fcc2
Merge branch 'next' into fix-toc-heading-leak
yannbf Nov 20, 2023
d8e8900
fix(next): forward Image exports through mock to support getImageProps
piratetaco Jan 24, 2024
40981ae
fix: short and sweet cleaner reexport
piratetaco Jan 24, 2024
4b8446c
fix: apply defaultLoader to getImageProps mock
piratetaco Jan 24, 2024
01a1de3
type mock getImageProps
piratetaco Jan 24, 2024
16e22d1
docs: create get-image-props.stories.tsx
piratetaco Jan 25, 2024
5568ae3
Update next-image.tsx semi-colons
piratetaco Jan 25, 2024
03ae686
Merge remote-tracking branch 'origin/next' into pr/piratetaco/25745
valentinpalkovic Jan 31, 2024
d197a17
Fix linting
valentinpalkovic Jan 31, 2024
02094d2
Update Next.js
valentinpalkovic Jan 31, 2024
512dfb8
Rename ImageProps Story
valentinpalkovic Jan 31, 2024
88b7810
Fix type issues
valentinpalkovic Jan 31, 2024
91b9b23
Merge branch 'next' into patch-2
valentinpalkovic Jan 31, 2024
7b05b79
Merge branch 'next' into patch-2
valentinpalkovic Feb 1, 2024
d2147cc
Add GetImageProps.stories.jsx file
valentinpalkovic Feb 1, 2024
c31c044
Merge branch 'next' into patch-2
valentinpalkovic Feb 6, 2024
c125ec6
Autogenerate SupportedFrameworks
valentinpalkovic Feb 7, 2024
d351504
Docs: Remove references to the storiesOf API
jonniebigodes Feb 8, 2024
9c88052
Add Webpack5 Compiler automigration
valentinpalkovic Feb 12, 2024
7c77bf9
Adjust vitest.workspace.ts to fix Wallaby tooling
valentinpalkovic Feb 12, 2024
02a7b16
Remove console.log
valentinpalkovic Feb 12, 2024
82355f6
Undo prompt awaiting
valentinpalkovic Feb 12, 2024
14d3d12
Remove unnecessary comment
valentinpalkovic Feb 12, 2024
50ec83b
Remove deprecation
valentinpalkovic Feb 12, 2024
4bfe14e
Merge remote-tracking branch 'origin/next' into valentin/add-webpack5…
valentinpalkovic Feb 12, 2024
074d5da
Add remove argtypes-regex automigration
kasperpeulen Feb 12, 2024
ce77d9f
Add a test
kasperpeulen Feb 12, 2024
dcb87ef
Fix eslint
kasperpeulen Feb 12, 2024
24f232d
Update frameworks
valentinpalkovic Feb 12, 2024
a9ca551
Merge branch 'next' into kasper/remove-argtypes-regex
kasperpeulen Feb 12, 2024
000b7de
Update helpers to remove vue-vite vue-webpack5 keys from frameworkToR…
valentinpalkovic Feb 12, 2024
a16f2ba
Merge branch 'next' into valentin/add-webpack5-compiler-automigration
valentinpalkovic Feb 13, 2024
dbd4ea5
Pass shouldRemoveSWCFlag option also when Next.js is detected
valentinpalkovic Feb 13, 2024
359f4dc
Update snapshot
valentinpalkovic Feb 13, 2024
f1ecad8
Merge branch 'next' into valentin/add-webpack5-compiler-automigration
valentinpalkovic Feb 13, 2024
64a160b
Text formatting
valentinpalkovic Feb 13, 2024
846114b
print a clear warning/instruction when users encounter https://github…
ndelangen Feb 14, 2024
b0955e6
make message more useful
ndelangen Feb 15, 2024
ab6b308
Merge branch 'next' into norbert/handle-esm-main-error
ndelangen Feb 15, 2024
f70ed9e
use server error class
ndelangen Feb 15, 2024
7c007a2
Merge branch 'norbert/handle-esm-main-error' of https://github.com/st…
ndelangen Feb 15, 2024
a9f8b34
change to named exports
ndelangen Feb 15, 2024
c615357
fixes
ndelangen Feb 15, 2024
23ff2df
exclude the typescript property from basetype
ndelangen Feb 15, 2024
e08fa51
Feedback addressed
jonniebigodes Feb 15, 2024
45a7f33
Merge branch 'next' into docs_stories_of_removal
jonniebigodes Feb 15, 2024
5131e1f
Fix bug that meant we always warned about TS plugin
tmeasday Feb 16, 2024
8112bdb
upgrade `eslint-plugin-storybook`
ndelangen Feb 16, 2024
65916d3
additional feedback addressed
jonniebigodes Feb 16, 2024
31e3d9c
Merge pull request #26064 from storybookjs/norbert/upgrade-eslint-plu…
ndelangen Feb 16, 2024
54cb838
Merge pull request #26046 from storybookjs/norbert/fix-vite-mainconfg…
ndelangen Feb 16, 2024
c9e988f
Update webpack5Migration to webpack5CompilerSetup
valentinpalkovic Feb 16, 2024
5b988d0
Don't warn if explicit arg or argType is found
kasperpeulen Feb 16, 2024
a8ca21e
Merge remote-tracking branch 'origin/kasper/remove-argtypes-regex' in…
kasperpeulen Feb 16, 2024
6261cdf
Prompt the user at the end to select a specific compiler
valentinpalkovic Feb 16, 2024
21945ad
throw when mainConfig is missing or unable to be evaluated, also thro…
ndelangen Feb 16, 2024
a321a58
improve
ndelangen Feb 16, 2024
c4db489
Re-enable flaky tests
kasperpeulen Feb 16, 2024
aa66901
Merge pull request #25745 from piratetaco/patch-2
valentinpalkovic Feb 16, 2024
981c2bd
Merge branch 'next-release' into next
storybook-bot Feb 17, 2024
aea7ea3
Core: Add addon removal telemetry
shilman Feb 17, 2024
8654ac6
Merge branch 'next' into docs_stories_of_removal
jonniebigodes Feb 18, 2024
50d94ba
Merge pull request #26051 from storybookjs/tom/fix-warning
tmeasday Feb 18, 2024
b34b44d
Core: Update ip version to fix CVE-2023-42282
drik98 Feb 19, 2024
e0e439e
Update automigrate fixes prompt types
valentinpalkovic Feb 19, 2024
ece437c
Add tests
valentinpalkovic Feb 19, 2024
fd6a748
rename incorrectly named type interfaces
ndelangen Feb 19, 2024
1307cd3
resolve https://github.com/storybookjs/storybook/pull/25934#pullreque…
ndelangen Feb 19, 2024
a36c4ed
Merge pull request #26077 from storybookjs/shilman/addon-removal-tele…
shilman Feb 19, 2024
4ee0478
change var to boolean
ndelangen Feb 19, 2024
aeba750
Support both supported babel.config.js files in Next.js
valentinpalkovic Feb 19, 2024
cbe6f31
Update prompt value from 'notified' to 'notification'
valentinpalkovic Feb 19, 2024
bbcaba1
Update tests
valentinpalkovic Feb 19, 2024
cbed150
Update webpack5 compiler setup to use Babel or SWC based on project c…
valentinpalkovic Feb 19, 2024
ed46f1c
Merge pull request #26086 from drik98/next
valentinpalkovic Feb 19, 2024
5416e5a
Merge pull request #26072 from storybookjs/kasper/fix-flaky-tests
kasperpeulen Feb 19, 2024
675c289
Fix promptType value in webpack5-compiler-setup
valentinpalkovic Feb 19, 2024
f090f7a
Fix name of Vite TS plugin
tmeasday Feb 19, 2024
21ed4a3
Merge pull request #26000 from storybookjs/valentin/add-webpack5-comp…
valentinpalkovic Feb 19, 2024
81a4431
Merge remote-tracking branch 'origin/next' into kasper/remove-argtype…
valentinpalkovic Feb 19, 2024
d47fe18
Update promptType to 'manual' in removeArgtypesRegex fix
valentinpalkovic Feb 19, 2024
026fc03
Merge pull request #26093 from storybookjs/tom/fix-ts-plugin
tmeasday Feb 19, 2024
ab947ce
Merge branch 'next' into pr/23677
shilman Feb 19, 2024
17e7244
Merge pull request #23677 from vmizg/fix-toc-heading-leak
shilman Feb 19, 2024
952dba5
Warn when argTypesRegex is used together with the visual test addon
kasperpeulen Feb 19, 2024
88cea6f
Update code/lib/cli/src/automigrate/fixes/remove-argtypes-regex.ts
kasperpeulen Feb 19, 2024
15c8437
Add link to docs
kasperpeulen Feb 19, 2024
7ca1efa
add a line ignoring the storybook generated log files to git ignore
ndelangen Feb 19, 2024
eaff738
Merge branch 'next' into docs_stories_of_removal
jonniebigodes Feb 19, 2024
3029661
order imports a bit
ndelangen Feb 19, 2024
8422756
remove the logging to file feature from autoblockers
ndelangen Feb 19, 2024
1631180
Revert "remove the logging to file feature from autoblockers"
ndelangen Feb 19, 2024
5e8fd79
Merge branch 'next' into docs_stories_of_removal
jonniebigodes Feb 19, 2024
bc8f1b7
remove the logging to file feature from autoblockers
ndelangen Feb 19, 2024
9f0865d
Merge pull request #25963 from storybookjs/docs_stories_of_removal
jonniebigodes Feb 19, 2024
26a481e
Merge branch 'next' into norbert/remove-logging-feature-from-autobloc…
ndelangen Feb 19, 2024
82d231b
apply changes to tests
ndelangen Feb 19, 2024
cd4b848
Docs: Fix conditional rendering of sections
jonniebigodes Feb 19, 2024
e20a8c2
Avoid long lines, as wrapping lines is buggy in boxen
kasperpeulen Feb 19, 2024
d56a2de
Merge remote-tracking branch 'origin/kasper/remove-argtypes-regex' in…
kasperpeulen Feb 19, 2024
05787fe
Merge pull request #26094 from storybookjs/kasper/warn-argtypes-regex…
kasperpeulen Feb 19, 2024
933be7f
strip ansi to make it render the same on CI
ndelangen Feb 19, 2024
1250053
fix lockfile
ndelangen Feb 19, 2024
7db99a4
Merge branch 'next' into norbert/remove-logging-feature-from-autobloc…
ndelangen Feb 19, 2024
738c825
Merge branch 'next' into norbert/add-line-to-gitignore-file
ndelangen Feb 19, 2024
15ed50a
Merge pull request #26001 from storybookjs/kasper/remove-argtypes-regex
kasperpeulen Feb 19, 2024
0bd91ce
Merge branch 'next' into docs_fix_api_csf
jonniebigodes Feb 19, 2024
e83e47c
apply more migrations listed in https://github.com/storybookjs/storyb…
ndelangen Feb 19, 2024
c827d17
Merge branch 'next' into norbert/remove-logging-feature-from-autobloc…
ndelangen Feb 19, 2024
7ad2663
add to barrel
ndelangen Feb 19, 2024
9ec1c3a
Merge pull request #26101 from storybookjs/docs_fix_api_csf
jonniebigodes Feb 19, 2024
096d56d
Update code/lib/cli/src/initiate.ts
ndelangen Feb 20, 2024
998bcaf
Merge branch 'next' into norbert/add-line-to-gitignore-file
ndelangen Feb 20, 2024
c11a91b
fix type issue
ndelangen Feb 20, 2024
15d0bf7
Merge branch 'next' into norbert/automigrations-mdx1
ndelangen Feb 20, 2024
159fdbe
Merge branch 'norbert/automigrations-mdx1' of https://github.com/stor…
ndelangen Feb 20, 2024
018f58a
Merge pull request #26087 from storybookjs/norbert/fix-viteconfig-con…
ndelangen Feb 20, 2024
b5f8d9b
Merge pull request #26099 from storybookjs/norbert/add-line-to-gitign…
ndelangen Feb 20, 2024
8204e35
Adjust wording
valentinpalkovic Feb 20, 2024
332c593
Update CHANGELOG.md for v7.6.17 [skip ci]
storybook-bot Feb 20, 2024
6e4666a
Apply suggestions from code review
ndelangen Feb 20, 2024
3a87bff
cleanup
ndelangen Feb 20, 2024
d112816
Remove deprecated SvelteComponentTyped in favor of SvelteComponent
kasperpeulen Feb 20, 2024
c86284b
Build: Make sure portable stories won't break in Node environments
yannbf Feb 20, 2024
e0bafc2
Merge pull request #26113 from storybookjs/kasper/svelte-type
JReinhold Feb 20, 2024
1bc793c
Merge pull request #26117 from storybookjs/yann/portable-stories-node…
yannbf Feb 20, 2024
b0263eb
Merge pull request #26035 from storybookjs/norbert/handle-esm-main-error
ndelangen Feb 20, 2024
2cc319a
Merge pull request #26102 from storybookjs/norbert/automigrations-mdx1
ndelangen Feb 20, 2024
b7451ae
Merge pull request #26100 from storybookjs/norbert/remove-logging-fea…
ndelangen Feb 20, 2024
5dc206d
Write changelog for 8.0.0-beta.4 [skip ci]
storybook-bot Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 7.6.17

- Addon-docs: Fix Table of Contents heading leak - [#23677](https://github.com/storybookjs/storybook/pull/23677), thanks [@vmizg](https://github.com/vmizg)!
- Core: Update ip version to fix CVE-2023-42282 - [#26086](https://github.com/storybookjs/storybook/pull/26086), thanks [@drik98](https://github.com/drik98)!

## 7.6.16

- Addon Themes: Make type generic less strict - [#26042](https://github.com/storybookjs/storybook/pull/26042), thanks [@yannbf](https://github.com/yannbf)!
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 8.0.0-beta.4

- Addon-actions: Warn when argTypesRegex is used together with the visual test addon - [#26094](https://github.com/storybookjs/storybook/pull/26094), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
- Addon-docs: Fix Table of Contents heading leak - [#23677](https://github.com/storybookjs/storybook/pull/23677), thanks [@vmizg](https://github.com/vmizg)!
- CLI: Add `legacyMdx1` & `@storybook/mdx1-csf` automigration - [#26102](https://github.com/storybookjs/storybook/pull/26102), thanks [@ndelangen](https://github.com/ndelangen)!
- CLI: Add line ignoring storybook's `.log` files upon `init` - [#26099](https://github.com/storybookjs/storybook/pull/26099), thanks [@ndelangen](https://github.com/ndelangen)!
- CLI: Add support for custom vite config to autoblocker - [#26087](https://github.com/storybookjs/storybook/pull/26087), thanks [@ndelangen](https://github.com/ndelangen)!
- CLI: Add webpack5 compiler automigration - [#26000](https://github.com/storybookjs/storybook/pull/26000), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
- CLI: Remove argTypesRegex automigration - [#26001](https://github.com/storybookjs/storybook/pull/26001), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
- CLI: Remove the logging to file feature from autoblockers - [#26100](https://github.com/storybookjs/storybook/pull/26100), thanks [@ndelangen](https://github.com/ndelangen)!
- Core: Add addon removal telemetry - [#26077](https://github.com/storybookjs/storybook/pull/26077), thanks [@shilman](https://github.com/shilman)!
- Core: Fix fail to load `main.ts` error message - [#26035](https://github.com/storybookjs/storybook/pull/26035), thanks [@ndelangen](https://github.com/ndelangen)!
- Core: Update ip version to fix CVE-2023-42282 - [#26086](https://github.com/storybookjs/storybook/pull/26086), thanks [@drik98](https://github.com/drik98)!
- Next.js: Support getImageProps API - [#25745](https://github.com/storybookjs/storybook/pull/25745), thanks [@piratetaco](https://github.com/piratetaco)!
- Svelte: Remove deprecated SvelteComponentTyped in favor of SvelteComponent - [#26113](https://github.com/storybookjs/storybook/pull/26113), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
- Vite: Fix bug that meant we always warned about TS plugin - [#26051](https://github.com/storybookjs/storybook/pull/26051), thanks [@tmeasday](https://github.com/tmeasday)!
- Vite: Fix config typing issue of the `typescript` property - [#26046](https://github.com/storybookjs/storybook/pull/26046), thanks [@ndelangen](https://github.com/ndelangen)!
- Vite: Fix issue getting preview stats with Vite builder - [#26093](https://github.com/storybookjs/storybook/pull/26093), thanks [@tmeasday](https://github.com/tmeasday)!

## 8.0.0-beta.3

- Addon-actions: Add spy to action for explicit actions - [#26033](https://github.com/storybookjs/storybook/pull/26033), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
Expand Down
7 changes: 5 additions & 2 deletions code/builders/builder-vite/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function build(options: Options) {

const turbosnapPluginName = 'rollup-plugin-turbosnap';
const hasTurbosnapPlugin =
finalConfig.plugins && hasVitePlugins(finalConfig.plugins, [turbosnapPluginName]);
finalConfig.plugins && (await hasVitePlugins(finalConfig.plugins, [turbosnapPluginName]));
if (hasTurbosnapPlugin) {
logger.warn(dedent`Found '${turbosnapPluginName}' which is now included by default in Storybook 8.
Removing from your plugins list. Ensure you pass \`--webpack-stats-json\` to generate stats.
Expand All @@ -53,6 +53,9 @@ export async function build(options: Options) {

await viteBuild(await sanitizeEnvVars(options, finalConfig));

const statsPlugin = findPlugin(finalConfig, 'rollup-plugin-webpack-stats') as WebpackStatsPlugin;
const statsPlugin = findPlugin(
finalConfig,
'storybook:rollup-plugin-webpack-stats'
) as WebpackStatsPlugin;
return statsPlugin?.storybookGetStats();
}
3 changes: 1 addition & 2 deletions code/e2e-tests/addon-docs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ test.describe('addon-docs', () => {
await expect(anotherStory).toContainText('Another button, just to show multiple stories');
});

// FIXME - get rid of the flake
test.skip('should show source=code view for stories', async ({ page }) => {
test('should show source=code view for stories', async ({ page }) => {
const skipped = [
// SSv6 does not render stories in the correct order in our sandboxes
'internal\\/ssv6',
Expand Down
3 changes: 1 addition & 2 deletions code/e2e-tests/tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { SbPage } from './util';

const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001';

// FIXME - get rid of the flake
test.describe.skip('tags', () => {
test.describe('tags', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"@types/babel__preset-env": "^7",
"@types/loader-utils": "^2.0.5",
"@types/react-refresh": "^0",
"next": "^14.0.2",
"next": "^14.1.0",
"typescript": "^5.3.2",
"webpack": "^5.65.0"
},
Expand Down
8 changes: 7 additions & 1 deletion code/frameworks/nextjs/src/images/next-image.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore import is aliased in webpack config
import OriginalNextImage from 'sb-original/next/image';
import * as NextImageNamespace from 'sb-original/next/image';
import type * as _NextImage from 'next/image';

import React from 'react';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -11,6 +12,8 @@ import { ImageContext as ImageContextValue } from '@storybook/nextjs/dist/image-
import { type ImageContext as ImageContextType } from '../image-context';
import { defaultLoader } from './next-image-default-loader';

const OriginalNextImage = NextImageNamespace.default;
const { getImageProps: originalGetImageProps } = NextImageNamespace;
const ImageContext = ImageContextValue as typeof ImageContextType;

const MockedNextImage = React.forwardRef<HTMLImageElement, _NextImage.ImageProps>(
Expand All @@ -30,4 +33,7 @@ const MockedNextImage = React.forwardRef<HTMLImageElement, _NextImage.ImageProps

MockedNextImage.displayName = 'NextImage';

export const getImageProps = (props: _NextImage.ImageProps) =>
originalGetImageProps?.({ loader: defaultLoader, ...props });

export default MockedNextImage;
3 changes: 2 additions & 1 deletion code/frameworks/nextjs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (baseConfig,
});

const babelRCPath = join(getProjectRoot(), '.babelrc');
const hasBabelConfig = fs.existsSync(babelRCPath);
const babelConfigPath = join(getProjectRoot(), 'babel.config.js');
const hasBabelConfig = fs.existsSync(babelRCPath) || fs.existsSync(babelConfigPath);
const nextjsVersion = getNextjsVersion();
const isDevelopment = options.configType !== 'PRODUCTION';

Expand Down
2 changes: 2 additions & 0 deletions code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ async function loaderTransform(this: any, parentTrace: any, source?: string, inp
swcCacheDir,
relativeFilePathFromRoot,
serverComponents,
// @ts-expect-error Relevant for Next.js < 14.1
// TODO: Remove this when Next.js < 14.1 is no longer supported
isReactServerLayer,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { getImageProps } from 'next/image';
import React from 'react';

import Accessibility from '../../assets/accessibility.svg';
import Testing from '../../assets/testing.png';

// referenced from https://nextjs.org/docs/pages/api-reference/components/image#theme-detection-picture
const Component = (props) => {
const {
props: { srcSet: dark },
} = getImageProps({ src: Accessibility, ...props });
const {
// capture rest on one to spread to img as default; it doesn't matter which barring art direction
props: { srcSet: light, ...rest },
} = getImageProps({ src: Testing, ...props });

return (
<picture>
<source media="(prefers-color-scheme: dark)" srcSet={dark} />
<source media="(prefers-color-scheme: light)" srcSet={light} />
<img {...rest} />
</picture>
);
};

export default {
component: Component,
args: {
alt: 'getImageProps Example',
},
};

export const Default = {};
2 changes: 1 addition & 1 deletion code/frameworks/react-vite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type TypescriptOptions = TypescriptOptionsBase & {
*/
export type StorybookConfig = Omit<
StorybookConfigBase,
keyof StorybookConfigVite | keyof StorybookConfigFramework
keyof StorybookConfigVite | keyof StorybookConfigFramework | 'typescript'
> &
StorybookConfigVite &
StorybookConfigFramework & {
Expand Down
2 changes: 2 additions & 0 deletions code/lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@babel/core": "^7.23.0",
"@babel/types": "^7.23.0",
"@ndelangen/get-tarball": "^3.0.7",
"@storybook/codemod": "workspace:*",
Expand Down Expand Up @@ -98,6 +99,7 @@
"@types/util-deprecate": "^1.0.0",
"boxen": "^7.1.1",
"slash": "^5.0.0",
"strip-ansi": "^7.1.0",
"strip-json-comments": "^3.1.1",
"typescript": "^5.3.2"
},
Expand Down
3 changes: 0 additions & 3 deletions code/lib/cli/src/autoblock/block-dependencies-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export const blocker = createBlocker({
return acc;
}, false);
},
message(options, data) {
return `Found ${data.packageName} version: ${data.installedVersion}, please upgrade to ${data.minimumVersion} or higher.`;
},
log(options, data) {
switch (data.packageName) {
case 'react-scripts':
Expand Down
3 changes: 0 additions & 3 deletions code/lib/cli/src/autoblock/block-node-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ export const blocker = createBlocker({
}
return false;
},
message(options, data) {
return `Please use Node.js v18 or higher.`;
},
log(options, data) {
return dedent`
We've detected you're using Node.js v${data.nodeVersion}.
Expand Down
11 changes: 5 additions & 6 deletions code/lib/cli/src/autoblock/block-stories-mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ export const blocker = createBlocker({
}
return { files };
},
message(options, data) {
return `Found ${data.files.length} stories.mdx ${
data.files.length === 1 ? 'file' : 'files'
}, these must be migrated.`;
},
log() {
log(options, data) {
return dedent`
Support for *.stories.mdx files has been removed.
Please see the migration guide for more information:
Expand All @@ -26,6 +21,10 @@ export const blocker = createBlocker({
Check the migration guide for more information:
https://mdxjs.com/blog/v3/

Found ${data.files.length} stories.mdx ${
data.files.length === 1 ? 'file' : 'files'
}, these must be migrated.

Manually run the migration script to convert your stories.mdx files to CSF format documented here:
https://storybook.js.org/docs/migration-guide#storiesmdx-to-mdxcsf
`;
Expand Down
5 changes: 0 additions & 5 deletions code/lib/cli/src/autoblock/block-storystorev6.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { relative } from 'path';
import { createBlocker } from './types';
import { dedent } from 'ts-dedent';
import type { StorybookConfigRaw } from '@storybook/types';
Expand All @@ -15,10 +14,6 @@ export const blocker = createBlocker({
}
return false;
},
message(options, data) {
const mainConfigPath = relative(process.cwd(), options.mainConfigPath);
return `StoryStoreV7 feature must be removed from ${mainConfigPath}`;
},
log() {
return dedent`
StoryStoreV7 feature must be removed from your Storybook configuration.
Expand Down
39 changes: 17 additions & 22 deletions code/lib/cli/src/autoblock/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect, test, vi } from 'vitest';
import { autoblock } from './index';
import { JsPackageManagerFactory } from '@storybook/core-common';
import { createBlocker } from './types';
import { writeFile as writeFileRaw } from 'node:fs/promises';
import { logger } from '@storybook/node-logger';
import { logger as loggerRaw } from '@storybook/node-logger';
import stripAnsi from 'strip-ansi';

vi.mock('node:fs/promises', () => ({
writeFile: vi.fn(),
Expand All @@ -19,26 +19,23 @@ vi.mock('@storybook/node-logger', () => ({
},
}));

const writeFile = vi.mocked(writeFileRaw);
const logger = vi.mocked(loggerRaw);

const blockers = {
alwaysPass: createBlocker({
id: 'alwaysPass',
check: async () => false,
message: () => 'Always pass',
log: () => 'Always pass',
}),
alwaysFail: createBlocker({
id: 'alwaysFail',
check: async () => ({ bad: true }),
message: () => 'Always fail',
log: () => '...',
log: () => 'Always fail',
}),
alwaysFail2: createBlocker({
id: 'alwaysFail2',
check: async () => ({ disaster: true }),
message: () => 'Always fail 2',
log: () => '...',
log: () => 'Always fail 2',
}),
} as const;

Expand Down Expand Up @@ -75,17 +72,15 @@ test('1 fail', async () => {
Promise.resolve({ blocker: blockers.alwaysPass }),
Promise.resolve({ blocker: blockers.alwaysFail }),
]);
expect(writeFile).toHaveBeenCalledWith(
expect.any(String),
expect.stringContaining('alwaysFail'),
expect.any(Object)
);

expect(result).toBe('alwaysFail');
expect(logger.plain).toHaveBeenCalledWith(expect.stringContaining('Oh no..'));
expect(stripAnsi(logger.plain.mock.calls[1][0])).toMatchInlineSnapshot(`
"Blocking your upgrade because of the following issues:

Always fail

expect(writeFile.mock.calls[0][1]).toMatchInlineSnapshot(`
"(alwaysFail):
..."
Fix the above issues and try running the upgrade command again."
`);
});

Expand All @@ -95,14 +90,14 @@ test('multiple fails', async () => {
Promise.resolve({ blocker: blockers.alwaysFail }),
Promise.resolve({ blocker: blockers.alwaysFail2 }),
]);
expect(writeFile.mock.calls[0][1]).toMatchInlineSnapshot(`
"(alwaysFail):
...
expect(stripAnsi(logger.plain.mock.calls[1][0])).toMatchInlineSnapshot(`
"Blocking your upgrade because of the following issues:

Always fail

----
Always fail 2

(alwaysFail2):
..."
Fix the above issues and try running the upgrade command again."
`);

expect(result).toBe('alwaysFail');
Expand Down
16 changes: 1 addition & 15 deletions code/lib/cli/src/autoblock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { AutoblockOptions, Blocker } from './types';
import { logger } from '@storybook/node-logger';
import chalk from 'chalk';
import boxen from 'boxen';
import { writeFile } from 'node:fs/promises';

const excludesFalse = <T>(x: T | false): x is T => x !== false;

Expand Down Expand Up @@ -34,7 +33,6 @@ export const autoblock = async (
return {
id: blocker.id,
value: true,
message: blocker.message(options, result),
log: blocker.log(options, result),
};
} else {
Expand All @@ -46,35 +44,23 @@ export const autoblock = async (
const faults = out.filter(excludesFalse);

if (faults.length > 0) {
const LOG_FILE_NAME = 'migration-storybook.log';

const messages = {
welcome: `Blocking your upgrade because of the following issues:`,
reminder: chalk.yellow('Fix the above issues and try running the upgrade command again.'),
logfile: chalk.yellow(`You can find more details in ./${LOG_FILE_NAME}.`),
};
const borderColor = '#FC521F';

logger.plain('Oh no..');
logger.plain(
boxen(
[messages.welcome]
.concat(faults.map((i) => i.message))
.concat(faults.map((i) => i.log))
.concat([messages.reminder])
.concat([messages.logfile])
.join('\n\n'),
{ borderStyle: 'round', padding: 1, borderColor }
)
);

await writeFile(
LOG_FILE_NAME,
faults.map((i) => '(' + i.id + '):\n' + i.log).join('\n\n----\n\n'),
{
encoding: 'utf-8',
}
);

return faults[0].id;
}

Expand Down
7 changes: 0 additions & 7 deletions code/lib/cli/src/autoblock/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ export interface Blocker<T> {
* @returns A truthy value to activate the block, return false to proceed.
*/
check: (options: AutoblockOptions) => Promise<T | false>;
/**
* Format a message to be printed to the log-file.
* @param context
* @param data returned from the check method.
* @returns The string to print to the terminal.
*/
message: (options: AutoblockOptions, data: T) => string;
/**
* Format a message to be printed to the log-file.
* @param context
Expand Down
Loading