Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0161e33
Merge pull request #22820 from storybookjs/chore_docs_removes_title
jonniebigodes May 26, 2023
87f7d64
Merge pull request #22771 from specialdoom/my-first-storybook-contrib…
ndelangen May 30, 2023
0a8dc2d
Merge pull request #22841 from storybookjs/norbert/fix-dev-theming
ndelangen May 31, 2023
a8d086b
Merge pull request #22848 from pruthvip15/patch-1
jonniebigodes May 31, 2023
39ad447
Merge pull request #22863 from storybookjs/chore_docs_migration_upgra…
jonniebigodes May 31, 2023
8213fd2
Merge pull request #22880 from storybookjs/chore_docs_adds_video_side…
jonniebigodes Jun 1, 2023
d62b23c
Merge pull request #22906 from storybookjs/shilman/22896-server-add-yml
shilman Jun 4, 2023
a1db3af
7.0.19 changelog
shilman Jun 4, 2023
fdb2e0e
Merge pull request #22856 from storybookjs/chore_vet_outdated_refs_docs
jonniebigodes May 31, 2023
2aa0331
7.0.19 changelog update
shilman Jun 4, 2023
4b7765f
Merge pull request #22835 from storybookjs/chaks/add-e2e-test-to-addo…
shilman Jun 5, 2023
4b8a7c9
Update 7.0.19 changelog
shilman Jun 5, 2023
5b7d078
Merge pull request #22911 from storybookjs/shilman/autodocs-clarifica…
kylegach Jun 5, 2023
7ce32fe
Merge pull request #22933 from storybookjs/shilman/fix-cli-upgrade-no…
shilman Jun 6, 2023
f430e76
Merge pull request #22873 from storybookjs/shilman/21414-exclude-node…
shilman Jun 6, 2023
3317178
Update 7.0.19 changelog
shilman Jun 6, 2023
bfb602e
Merge pull request #22957 from storybookjs/feat/silence-compodoc-on-q…
yannbf Jun 7, 2023
6c42bb0
Merge pull request #22964 from storybookjs/fix/allow-open-flag-in-ang…
yannbf Jun 7, 2023
35b1fb3
Merge pull request #22966 from storybookjs/versioned-docs-links
kylegach Jun 7, 2023
d9edefd
Merge pull request #22782 from storybookjs/shilman/22619-improve-mdx-…
shilman Jun 8, 2023
46a8d3f
Update 7.0.19 changelog
shilman Jun 8, 2023
9efe2be
Merge pull request #22934 from storybookjs/revert-22835-chaks/add-e2e…
kasperpeulen Jun 6, 2023
b4d7e2a
Update 7.0.19 changelog
shilman Jun 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 7.0.19 (June 8, 2023)

#### Bug Fixes

- Server: Fix .stories.yml support [#22906](https://github.com/storybooks/storybook/pull/22906)
- Docs: Fix Source block snippet updates [#22835](https://github.com/storybooks/storybook/pull/22835)
- Core: Fix indexing errors by excluding node_modules stories [#22873](https://github.com/storybooks/storybook/pull/22873)
- CLI: Fix upgrade notification message [#22933](https://github.com/storybooks/storybook/pull/22933)
- Angular: Add --open/--no-open flag to dev command [#22964](https://github.com/storybooks/storybook/pull/22964)
- Angular: Silence compodoc when running storybook with --quiet [#22957](https://github.com/storybooks/storybook/pull/22957)

#### Maintenance

- Core: Improve MDX of error in story index [#22782](https://github.com/storybooks/storybook/pull/22782)

#### Build

- Build: Fix the theme output during development [#22841](https://github.com/storybooks/storybook/pull/22841)
- Revert "Docs: E2E tests for Source block update fix" [#22934](https://github.com/storybookjs/storybook/pull/22934)
## 7.0.18 (May 26, 2023)

#### Bug Fixes
Expand Down
26 changes: 24 additions & 2 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [Deploying build artifacts](#deploying-build-artifacts)
- [Dropped support for file URLs](#dropped-support-for-file-urls)
- [Serving with nginx](#serving-with-nginx)
- [Ignore story files from node\_modules](#ignore-story-files-from-node_modules)
- [7.0 Core changes](#70-core-changes)
- [7.0 feature flags removed](#70-feature-flags-removed)
- [Story context is prepared before for supporting fine grained updates](#story-context-is-prepared-before-for-supporting-fine-grained-updates)
Expand Down Expand Up @@ -87,7 +88,6 @@
- [Dropped addon-docs manual configuration](#dropped-addon-docs-manual-configuration)
- [Autoplay in docs](#autoplay-in-docs)
- [Removed STORYBOOK\_REACT\_CLASSES global](#removed-storybook_react_classes-global)
- [parameters.docs.source.excludeDecorators defaults to true](#parametersdocssourceexcludedecorators-defaults-to-true)
- [7.0 Deprecations and default changes](#70-deprecations-and-default-changes)
- [storyStoreV7 enabled by default](#storystorev7-enabled-by-default)
- [`Story` type deprecated](#story-type-deprecated)
Expand Down Expand Up @@ -938,6 +938,28 @@ With [nginx](https://www.nginx.com/), you need to extend [the MIME type handling

It would otherwise default to serving the `.mjs` files as `application/octet-stream`.

##### Ignore story files from node_modules

In 6.x Storybook literally followed the glob patterns specified in your `.storybook/main.js` `stories` field. Storybook 7.0 ignores files from `node_modules` unless your glob pattern includes the string `"node_modules"`.

Given the following `main.js`:

```js
export default {
stories: ['../**/*.stories.*']
}
```

If you want to restore the previous behavior to include `node_modules`, you can update it to:

```js
export default {
stories: ['../**/*.stories.*', '../**/node_modules/**/*.stories.*']
}
```

The first glob would have node_modules automatically excluded by Storybook, and the second glob would include all stories that are under a nested `node_modules` directory.

### 7.0 Core changes

#### 7.0 feature flags removed
Expand Down Expand Up @@ -1215,7 +1237,7 @@ In v6.x `@storybook/web-components` had a peer dependency on `lit-html` v1 or v2

#### Create React App: dropped CRA4 support

Since v7 [drops webpack4 support](#webpack4-support-discontinued), it longer supports Create React App < 5.0. If you're using an earlier version of CRA, please upgrade or stay on Storybook 6.x.
Since v7 [drops webpack4 support](#webpack4-support-discontinued), it no longer supports Create React App < 5.0. If you're using an earlier version of CRA, please upgrade or stay on Storybook 6.x.

#### HTML: No longer auto-dedents source code

Expand Down
15 changes: 11 additions & 4 deletions code/frameworks/angular/src/builders/start-storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ addToGlobalContext('cliVersion', versions.storybook);
export type StorybookBuilderOptions = JsonObject & {
browserTarget?: string | null;
tsConfig?: string;
docs: boolean;
compodoc: boolean;
compodocArgs: string[];
styles?: StyleElement[];
Expand All @@ -50,6 +49,8 @@ export type StorybookBuilderOptions = JsonObject & {
| 'ci'
| 'quiet'
| 'disableTelemetry'
| 'open'
| 'docs'
>;

export type StorybookBuilderOutput = JsonObject & BuilderOutput & {};
Expand All @@ -58,9 +59,13 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (options, cont
const builder = from(setup(options, context)).pipe(
switchMap(({ tsConfig }) => {
const runCompodoc$ = options.compodoc
? runCompodoc({ compodocArgs: options.compodocArgs, tsconfig: tsConfig }, context).pipe(
mapTo({ tsConfig })
)
? runCompodoc(
{
compodocArgs: [...options.compodocArgs, ...(options.quiet ? ['--silent'] : [])],
tsconfig: tsConfig,
},
context
).pipe(mapTo({ tsConfig }))
: of({});

return runCompodoc$.pipe(mapTo({ tsConfig }));
Expand Down Expand Up @@ -93,6 +98,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (options, cont
sslKey,
disableTelemetry,
assets,
open,
} = options;

const standaloneOptions: StandaloneOptions = {
Expand All @@ -117,6 +123,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (options, cont
...(assets ? { assets } : {}),
},
tsConfig,
open,
};

return standaloneOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"description": "CI mode (skip interactive prompts, don't open browser).",
"default": false
},
"open": {
"type": "boolean",
"description": "Whether to open Storybook automatically in the browser.",
"default": true
},
"quiet": {
"type": "boolean",
"description": "Suppress verbose build output.",
Expand Down
7 changes: 5 additions & 2 deletions code/lib/builder-vite/src/list-stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path';
import slash from 'slash';
import { promise as glob } from 'glob-promise';
import { normalizeStories } from '@storybook/core-common';
import { normalizeStories, commonGlobOptions } from '@storybook/core-common';

import type { Options } from '@storybook/types';

Expand All @@ -17,7 +17,10 @@ export async function listStories(options: Options) {
? pattern
: path.join(options.configDir, pattern);

return glob(slash(absolutePattern), { follow: true });
return glob(slash(absolutePattern), {
...commonGlobOptions(absolutePattern),
follow: true,
});
})
)
).reduce((carry, stories) => carry.concat(stories), []);
Expand Down
3 changes: 2 additions & 1 deletion code/lib/cli/src/automigrate/fixes/mdx-gfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import semver from 'semver';
import { join } from 'path';
import slash from 'slash';
import glob from 'globby';
import { commonGlobOptions } from '@storybook/core-common';
import { getStorybookData, updateMainConfig } from '../helpers/mainConfigFile';
import type { Fix } from '../types';
import { getStorybookVersionSpecifier } from '../../helpers';
Expand Down Expand Up @@ -37,7 +38,7 @@ export const mdxgfm: Fix<Options> = {
? slash(join(configDir, item))
: slash(join(configDir, item.directory, item.files));

const files = await glob(pattern);
const files = await glob(pattern, commonGlobOptions(pattern));

return files.some((f) => f.endsWith('.mdx'));
}, Promise.resolve(false));
Expand Down
1 change: 0 additions & 1 deletion code/lib/cli/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ const internalTemplates = {
builder: '@storybook/builder-webpack5',
},
isInternal: true,
inDevelopment: true,
},
// 'internal/pnp': {
// ...baseTemplates['cra/default-ts'],
Expand Down
1 change: 1 addition & 0 deletions code/lib/core-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './utils/cache';
export * from './utils/check-addon-order';
export * from './utils/envs';
export * from './utils/findDistEsm';
export * from './utils/common-glob-options';
export * from './utils/get-builder-options';
export * from './utils/get-framework-name';
export * from './utils/get-renderer-name';
Expand Down
5 changes: 5 additions & 0 deletions code/lib/core-common/src/utils/common-glob-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const NODE_MODULES_RE = /node_modules/;

// Exclude node_modules stories everywhere we call `glob`
export const commonGlobOptions = (glob: string) =>
NODE_MODULES_RE.test(glob) ? {} : { ignore: ['**/node_modules/**'] };
9 changes: 5 additions & 4 deletions code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
StoryName,
} from '@storybook/types';
import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/preview-api';
import { normalizeStoryPath } from '@storybook/core-common';
import { commonGlobOptions, normalizeStoryPath } from '@storybook/core-common';
import { logger, once } from '@storybook/node-logger';
import { getStorySortParameter } from '@storybook/csf-tools';
import { toId } from '@storybook/csf';
Expand Down Expand Up @@ -121,7 +121,7 @@ export class StoryIndexGenerator {
const fullGlob = slash(
path.join(this.options.workingDir, specifier.directory, specifier.files)
);
const files = await glob(fullGlob);
const files = await glob(fullGlob, commonGlobOptions(fullGlob));

if (files.length === 0) {
once.warn(
Expand Down Expand Up @@ -352,11 +352,12 @@ export class StoryIndexGenerator {

if (!csfEntry)
throw new Error(
dedent`Could not find CSF file at path "${result.of}" referenced by \`of={}\` in docs file "${relativePath}".
dedent`Could not find or load CSF file at path "${result.of}" referenced by \`of={}\` in docs file "${relativePath}".

- Does that file exist?
- If so, is it a CSF file (\`.stories.*\`)?
- If so, is it matched by the \`stories\` glob in \`main.js\`?`
- If so, is it matched by the \`stories\` glob in \`main.js\`?
- If so, has the file successfully loaded in Storybook and are its stories visible?`
);
}

Expand Down
5 changes: 3 additions & 2 deletions code/lib/core-server/src/utils/update-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export function createUpdateMessage(updateInfo: VersionCheck, version: string):
let updateMessage;

try {
const suffix = semver.prerelease(updateInfo.data.latest.version) ? '--prerelease' : '';
const upgradeCommand = `npx storybook@latest upgrade ${suffix}`.trim();
const isPrerelease = semver.prerelease(updateInfo.data.latest.version);
const suffix = isPrerelease ? '@next upgrade --prerelease' : '@latest upgrade';
const upgradeCommand = `npx storybook${suffix}`;
updateMessage =
updateInfo.success && semver.lt(version, updateInfo.data.latest.version)
? dedent`
Expand Down
3 changes: 2 additions & 1 deletion code/lib/core-server/src/utils/watch-story-specifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import glob from 'globby';
import uniq from 'lodash/uniq.js';

import type { NormalizedStoriesSpecifier, Path } from '@storybook/types';
import { commonGlobOptions } from '@storybook/core-common';

const isDirectory = (directory: Path) => {
try {
Expand Down Expand Up @@ -74,7 +75,7 @@ export function watchStorySpecifiers(
path.basename(specifier.files)
);
// glob only supports forward slashes
const files = await glob(slash(dirGlob));
const files = await glob(slash(dirGlob), commonGlobOptions(dirGlob));

files.forEach((filePath) => {
const fileImportPath = toImportPath(
Expand Down
2 changes: 1 addition & 1 deletion code/lib/theming/scripts/fix-theme-type-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const run = async () => {
const target = join(process.cwd(), 'dist', 'index.d.ts');
const contents = await readFile(target, 'utf8');

const footer = contents.includes('// devmode')
const footer = contents.includes('// dev-mode')
? `export { StorybookTheme as Theme } from '../src/index';`
: dedent`
interface Theme extends StorybookTheme {}
Expand Down
10 changes: 7 additions & 3 deletions code/lib/types/src/modules/addons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ export type Addon_BaseDecorators<StoryFnReturnType> = Array<
(story: () => StoryFnReturnType, context: Addon_StoryContext) => StoryFnReturnType
>;

export interface Addon_BaseAnnotations<TArgs, StoryFnReturnType> {
export interface Addon_BaseAnnotations<
TArgs,
StoryFnReturnType,
TRenderer extends Renderer = Renderer
> {
/**
* Dynamic data that are provided (and possibly updated by) Storybook and its addons.
* @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs)
Expand Down Expand Up @@ -192,12 +196,12 @@ export interface Addon_BaseAnnotations<TArgs, StoryFnReturnType> {
/**
* Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used.
*/
render?: (args: TArgs, context: Addon_StoryContext) => StoryFnReturnType;
render?: (args: TArgs, context: Addon_StoryContext<TRenderer>) => StoryFnReturnType;

/**
* Function that is executed after the story is rendered.
*/
play?: (context: Addon_StoryContext) => Promise<void> | void;
play?: (context: Addon_StoryContext<TRenderer>) => Promise<void> | void;
}

export interface Addon_Annotations<TArgs, StoryFnReturnType>
Expand Down
5 changes: 4 additions & 1 deletion code/presets/server-webpack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const webpack: StorybookConfig['webpack'] = (config) => {
test: /\.stories\.ya?ml/,
use: [
require.resolve('@storybook/preset-server-webpack/dist/loader'),
require.resolve('yaml-loader'),
{
loader: require.resolve('yaml-loader'),
options: { asJSON: true },
},
],
},
];
Expand Down
3 changes: 2 additions & 1 deletion code/presets/server-webpack/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default (content: string) => {
const after = compileCsfModule(JSON.parse(content));
return after;
} catch (e) {
//
// for debugging
console.log(content, e);
}
return content;
};
3 changes: 2 additions & 1 deletion code/renderers/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"@storybook/types": "7.0.18",
"@types/fs-extra": "^11.0.1",
"fs-extra": "^11.1.0",
"ts-dedent": "^2.0.0"
"ts-dedent": "^2.0.0",
"yaml": "^2.3.1"
},
"devDependencies": {
"typescript": "~4.9.3"
Expand Down
11 changes: 7 additions & 4 deletions code/renderers/server/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import fs from 'fs-extra';
import yaml from 'yaml';
import { toId } from '@storybook/csf';
import type { StaticMeta } from '@storybook/csf-tools';
import type { IndexerOptions, IndexedStory, StoryIndexer } from '@storybook/types';

export const storyIndexers = (indexers: StoryIndexer[] | null) => {
const jsonIndexer = async (fileName: string, opts: IndexerOptions) => {
const json = await fs.readJson(fileName, 'utf-8');
const serverIndexer = async (fileName: string, opts: IndexerOptions) => {
const json = fileName.endsWith('.json')
? await fs.readJson(fileName, 'utf-8')
: yaml.parse((await fs.readFile(fileName, 'utf-8')).toString());
const meta: StaticMeta = {
title: json.title,
};
Expand All @@ -25,8 +28,8 @@ export const storyIndexers = (indexers: StoryIndexer[] | null) => {
};
return [
{
test: /(stories|story)\.json$/,
indexer: jsonIndexer,
test: /(stories|story)\.(json|ya?ml)$/,
indexer: serverIndexer,
},
...(indexers || []),
];
Expand Down
19 changes: 9 additions & 10 deletions code/ui/blocks/src/blocks/SourceContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { FC, Context, PropsWithChildren } from 'react';
import React, { createContext, useEffect, useState } from 'react';

import { dequal as deepEqual } from 'dequal';
import type { Channel } from '@storybook/channels';

import { SNIPPET_RENDERED } from '@storybook/docs-tools';
Expand Down Expand Up @@ -64,11 +63,14 @@ export const SourceContainer: FC<PropsWithChildren<{ channel: Channel }>> = ({
: idOrEvent;

const hash = args ? argsHash(args) : UNKNOWN_ARGS_HASH;

// optimization: if the source is the same, ignore the incoming event
if (sources[id] && sources[id][hash] && sources[id][hash].code === source) {
return;
}
// FIXME: In SB8.0 when we remove the Source block deprecations,
// we should restore this optimizationand make the Source block
// smarter about understanding when its args change.
//
// See https://github.com/storybookjs/storybook/pull/22807
//
// optimization: don't update if the source is the same
// if (deepEqual(currentSource, { code: source, format })) return;

setSources((current) => {
const newSources = {
Expand All @@ -79,10 +81,7 @@ export const SourceContainer: FC<PropsWithChildren<{ channel: Channel }>> = ({
},
};

if (!deepEqual(current, newSources)) {
return newSources;
}
return current;
return newSources;
});
};

Expand Down
Loading