Skip to content

Commit

Permalink
Merge pull request #24556 from storybookjs/version-non-patch-from-7.6…
Browse files Browse the repository at this point in the history
….0-alpha.2

Release: Prerelease alpha 7.6.0-alpha.3
  • Loading branch information
valentinpalkovic authored Oct 30, 2023
2 parents cfe7ac3 + 3d872a0 commit 81c9f25
Show file tree
Hide file tree
Showing 120 changed files with 13,910 additions and 12,426 deletions.
23 changes: 12 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ commands:
jobs:
pretty-docs:
executor:
class: small
class: medium
name: sb_node_16_classic
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
- restore_cache:
name: Restore Yarn cache
keys:
- prettydocs-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
- prettydocs-yarn-2-cache-v7--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
- run:
name: Install
command: |
cd scripts
yarn install
- save_cache:
name: Save Yarn cache
key: prettydocs-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
key: prettydocs-yarn-2-cache-v7--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
paths:
- ~/.yarn/berry/cache
- run:
Expand Down Expand Up @@ -499,11 +499,11 @@ workflows:
requires:
- unit-tests
- create-sandboxes:
parallelism: 12
parallelism: 14
requires:
- build
- build-sandboxes:
parallelism: 12
parallelism: 14
requires:
- create-sandboxes
- chromatic-sandboxes:
Expand All @@ -523,7 +523,7 @@ workflows:
requires:
- build-sandboxes
- bench:
parallelism: 3
parallelism: 5
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
Expand Down Expand Up @@ -555,11 +555,11 @@ workflows:
requires:
- unit-tests
- create-sandboxes:
parallelism: 21
parallelism: 23
requires:
- build
- build-sandboxes:
parallelism: 21
parallelism: 23
requires:
- create-sandboxes
- chromatic-sandboxes:
Expand All @@ -579,7 +579,7 @@ workflows:
requires:
- build-sandboxes
- bench:
parallelism: 3
parallelism: 5
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
Expand Down Expand Up @@ -609,14 +609,14 @@ workflows:
requires:
- build
- create-sandboxes:
parallelism: 36
parallelism: 38
requires:
- build
# - smoke-test-sandboxes: # disabled for now
# requires:
# - create-sandboxes
- build-sandboxes:
parallelism: 36
parallelism: 38
requires:
- create-sandboxes
- chromatic-sandboxes:
Expand All @@ -640,3 +640,4 @@ workflows:
# parallelism: 4
# requires:
# - create-sandboxes

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test-results
!/**/.yarn/plugins
!/**/.yarn/sdks
!/**/.yarn/versions
!/**/.yarn/patches
/**/.pnp.*
!/node_modules

Expand Down
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.1.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.0.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
compressionLevel: mixed

enableGlobalCache: false

installStatePath: ./.yarn/root-install-state.gz

nodeLinker: node-modules

npmPublishAccess: public

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.5.1.cjs
yarnPath: .yarn/releases/yarn-4.0.0.cjs
12 changes: 12 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 7.6.0-alpha.3

- Action: Attach spies on actions across stories when defined in meta - [#24451](https://github.com/storybookjs/storybook/pull/24451), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
- Addon A11y: Avoid CSP issue - [#24477](https://github.com/storybookjs/storybook/pull/24477), thanks [@Marklb](https://github.com/Marklb)!
- Addon-themes: Fix globals not being set when using absolute path - [#24596](https://github.com/storybookjs/storybook/pull/24596), thanks [@JReinhold](https://github.com/JReinhold)!
- CLI: Allow Yarn v4 in `link` command - [#24551](https://github.com/storybookjs/storybook/pull/24551), thanks [@yannbf](https://github.com/yannbf)!
- Core-Server: Ignore all node_module folders for watchpack - [#24553](https://github.com/storybookjs/storybook/pull/24553), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
- Core: Fix pnp support when cache dir is outside working dir - [#24572](https://github.com/storybookjs/storybook/pull/24572), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
- Manager: Update `store.settings.lastTrackedStoryId` - [#24115](https://github.com/storybookjs/storybook/pull/24115), thanks [@rashidshamloo](https://github.com/rashidshamloo)!
- Next.js: Support v14.0.0 - [#24593](https://github.com/storybookjs/storybook/pull/24593), thanks [@nikospapcom](https://github.com/nikospapcom)!
- Test: Create @storybook/test package based on vitest - [#24392](https://github.com/storybookjs/storybook/pull/24392), thanks [@kasperpeulen](https://github.com/kasperpeulen)!

## 7.6.0-alpha.2

- Actions: Fix missing crypto module crashing React Native - [#24546](https://github.com/storybookjs/storybook/pull/24546), thanks [@dannyhw](https://github.com/dannyhw)!
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/code/addons/storyshots-core/ @ndelangen
/code/addons/storyshots-puppeteer/ @ndelangen
/code/addons/storysource/ @ndelangen
/code/addons/themes/ @JReinhold @Integrayshaun
/code/addons/toolbars/ @ndelangen @JReinhold
/code/addons/viewport/ @yannbf @ndelangen

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ No process is defined for this.

### Merges to `main` without versioning

As described in more details in [the Patch Releases section](#patch-releases), there are scenarios where you want to patch [unreleasable](#which-changes-are-considered-releasable-and-what-does-it-mean) content back to `main` without bumping versions or publishing a new release. This happens automatically as long as all the unpicked patch pull requests have unreleasable labels. In that case the prepared patch pull request will change form slighty, to just cherry-picking the patches without bumping the versions.
As described in more details in [the Patch Releases section](#patch-releases), there are scenarios where you want to patch [unreleasable](#which-changes-are-considered-releasable-and-what-does-it-mean) content back to `main` without bumping versions or publishing a new release. This happens automatically as long as all the unpicked patch pull requests have unreleasable labels. In that case the prepared patch pull request will change form slightly, to just cherry-picking the patches without bumping the versions.

## FAQ

Expand Down
37 changes: 37 additions & 0 deletions code/.yarn/patches/@vitest-expect-npm-0.34.5-8031508efe.patch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ plugins:
unsafeHttpWhitelist:
- localhost

yarnPath: ../.yarn/releases/yarn-3.5.1.cjs
yarnPath: ../.yarn/releases/yarn-4.0.0.cjs
installStatePath: '../.yarn/code-install-state.gz'
8 changes: 7 additions & 1 deletion code/addons/a11y/src/a11yRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ const run = async (storyId: string) => {
}

const result = await axe.run(htmlElement, options);

// Axe result contains class instances, which telejson deserializes in a
// way that violates:
// Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
const resultJson = JSON.parse(JSON.stringify(result));

// It's possible that we requested a new run on a different story.
// Unfortunately, axe doesn't support a cancel method to abort current run.
// We check if the story we run against is still the current one,
// if not, trigger a new run using the current story
if (activeStoryId === storyId) {
channel.emit(EVENTS.RESULT, result);
channel.emit(EVENTS.RESULT, resultJson);
} else {
active = false;
run(activeStoryId);
Expand Down
7 changes: 6 additions & 1 deletion code/addons/actions/src/addArgs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { ArgsEnhancer } from '@storybook/types';
import { addActionsFromArgTypes, inferActionsFromArgTypesRegex } from './addArgsHelpers';
import {
addActionsFromArgTypes,
attachActionsToFunctionMocks,
inferActionsFromArgTypesRegex,
} from './addArgsHelpers';

export const argsEnhancers: ArgsEnhancer[] = [
addActionsFromArgTypes,
inferActionsFromArgTypesRegex,
attachActionsToFunctionMocks,
];
33 changes: 32 additions & 1 deletion code/addons/actions/src/addArgsHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle,no-param-reassign */
import type { Args, Renderer, ArgsEnhancer } from '@storybook/types';
import { action } from './runtime/action';

Expand Down Expand Up @@ -31,7 +32,7 @@ export const inferActionsFromArgTypesRegex: ArgsEnhancer<Renderer> = (context) =

return argTypesMatchingRegex.reduce((acc, [name, argType]) => {
if (isInInitialArgs(name, initialArgs)) {
acc[name] = action(name);
acc[name] = action(name, { implicit: true });
}
return acc;
}, {} as Args);
Expand Down Expand Up @@ -61,3 +62,33 @@ export const addActionsFromArgTypes: ArgsEnhancer<Renderer> = (context) => {
return acc;
}, {} as Args);
};

export const attachActionsToFunctionMocks: ArgsEnhancer<Renderer> = (context) => {
const {
initialArgs,
argTypes,
parameters: { actions },
} = context;
if (actions?.disable || !argTypes) {
return {};
}

const argTypesWithAction = Object.entries(initialArgs).filter(
([, value]) =>
typeof value === 'function' &&
'_isMockFunction' in value &&
value._isMockFunction &&
!value._actionAttached
);

return argTypesWithAction.reduce((acc, [key, value]) => {
const previous = value.getMockImplementation();
value.mockImplementation((...args: unknown[]) => {
action(key)(...args);
return previous?.(...args);
});
// this enhancer is being called multiple times
value._actionAttached = true;
return acc;
}, {} as Args);
};
1 change: 1 addition & 0 deletions code/addons/actions/src/models/ActionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface Options {
depth: number; // backards compatibility, remove in 7.0
clearOnStoryChange: boolean;
limit: number;
implicit: boolean;
}

export type ActionOptions = Partial<Options> & Partial<TelejsonOptions>;
17 changes: 17 additions & 0 deletions code/addons/actions/src/runtime/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ export function action(name: string, options: ActionOptions = {}): HandlerFuncti
};

const handler = function actionHandler(...args: any[]) {
// TODO: Enable once codemods are finished
// if (options.implicit) {
// const preview =
// '__STORYBOOK_PREVIEW__' in global
// ? (global.__STORYBOOK_PREVIEW__ as PreviewWeb<Renderer>)
// : undefined;
// if (
// preview?.storyRenders.some(
// (render) => render.phase === 'playing' || render.phase === 'rendering'
// )
// ) {
// console.warn(
// 'Can not use implicit actions during rendering or playing of a story.'
// );
// }
// }

const channel = addons.getChannel();
// this makes sure that in js enviroments like react native you can still get an id
const id = generateId();
Expand Down
10 changes: 1 addition & 9 deletions code/addons/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export default {
jsxOptions: {},
csfPluginOptions: null,
mdxPluginOptions: {},
transcludeMarkdown: true,
},
},
],
Expand All @@ -157,16 +156,9 @@ export default {

`csfPluginOptions` is an object for configuring `@storybook/csf-plugin`. When set to `null` it tells docs not to run the `csf-plugin` at all, which can be used as an optimization, or if you're already using `csf-plugin` in your `main.js`.

The `transcludeMarkdown` option enables mdx files to import `.md` files and render them as a component.

```mdx
import { Meta } from '@storybook/addon-docs';
import Changelog from '../CHANGELOG.md';
> With the release of version 7.0, it is no longer possible to import `.md` files directly into Storybook using the `transcludeMarkdown` [option](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#importing-plain-markdown-files-with-transcludemarkdown-has-changed). Instead, we recommend using the [`Markdown`](https://storybook.js.org/docs/react/api/doc-block-markdown) Doc Block for importing Markdown files into your Storybook documentation.
<Meta title="Changelog" />

<Changelog />
```

## TypeScript configuration

Expand Down
25 changes: 24 additions & 1 deletion code/addons/interactions/src/components/Interaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type Call, CallStates, type ControlStates } from '@storybook/instrument
import { styled, typography } from '@storybook/theming';
import { transparentize } from 'polished';

import { MatcherResult } from './MatcherResult';
import { Expected, MatcherResult, Received } from './MatcherResult';
import { MethodCall } from './MethodCall';
import { StatusIcon } from './StatusIcon';

Expand Down Expand Up @@ -120,6 +120,29 @@ const Exception = ({ exception }: { exception: Call['exception'] }) => {
return (
<RowMessage>
<pre>{paragraphs[0]}</pre>

{exception.showDiff && exception.diff ? (
<>
<br />
<MatcherResult message={exception.diff} style={{ padding: 0 }} />
</>
) : (
<pre>
<br />
{exception.expected && (
<>
Expected: <Expected value={exception.expected} />
<br />
</>
)}
{exception.actual && (
<>
Received: <Received value={exception.actual} />
<br />
</>
)}
</pre>
)}
{more && <p>See the full stack trace in the browser console.</p>}
</RowMessage>
);
Expand Down
9 changes: 8 additions & 1 deletion code/addons/interactions/src/components/MatcherResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ export const Expected = ({ value, parsed }: { value: any; parsed?: boolean }) =>
return <StyledExpected>{value}</StyledExpected>;
};

export const MatcherResult = ({ message }: { message: string }) => {
export const MatcherResult = ({
message,
style = {},
}: {
message: string;
style?: React.CSSProperties;
}) => {
const lines = message.split('\n');
return (
<pre
style={{
margin: 0,
padding: '8px 10px 8px 36px',
fontSize: typography.size.s1,
...style,
}}
>
{lines.flatMap((line: string, index: number) => {
Expand Down
Loading

0 comments on commit 81c9f25

Please sign in to comment.