Skip to content

Commit

Permalink
Merge branch 'next' into patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniebigodes authored Oct 27, 2023
2 parents b03f402 + a8cda8d commit 7626e39
Show file tree
Hide file tree
Showing 55 changed files with 12,720 additions and 12,278 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

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
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'
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
6 changes: 2 additions & 4 deletions code/addons/interactions/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const fn = JestMock.fn.bind(JestMock);
// Aliasing `fn` to `action` here, so we get a more descriptive label in the UI.
const { action } = instrument({ action: fn }, { retain: true });
const channel = addons.getChannel();
const seen = new Set<any>();
const spies: any[] = [];

channel.on(FORCE_REMOUNT, () => spies.forEach((mock) => mock?.mockClear?.()));
Expand All @@ -28,8 +27,6 @@ channel.on(STORY_RENDER_PHASE_CHANGED, ({ newPhase }) => {
});

const addSpies = (id: string, val: any, key?: string): any => {
if (seen.has(val)) return val;
seen.add(val);
try {
if (Object.prototype.toString.call(val) === '[object Object]') {
// We have to mutate the original object for this to survive HMR.
Expand All @@ -40,7 +37,8 @@ const addSpies = (id: string, val: any, key?: string): any => {
if (Array.isArray(val)) {
return val.map((item, index) => addSpies(id, item, `${key}[${index}]`));
}
if (typeof val === 'function' && val.isAction) {
// eslint-disable-next-line no-underscore-dangle
if (typeof val === 'function' && val.isAction && !val._isMockFunction) {
Object.defineProperty(val, 'name', { value: key, writable: false });
Object.defineProperty(val, '__storyId__', { value: id, writable: false });
const spy = action(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ addToGlobalContext('cliVersion', versions.storybook);
export type StorybookBuilderOptions = JsonObject & {
browserTarget?: string | null;
tsConfig?: string;
test: boolean;
docs: boolean;
compodoc: boolean;
compodocArgs: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"description": "Starts Storybook in documentation mode. Learn more about it : https://storybook.js.org/docs/react/writing-docs/build-documentation#preview-storybooks-documentation.",
"default": false
},
"test": {
"type": "boolean",
"description": "Build the static version of the sandbox optimized for testing purposes",
"default": false
},
"compodoc": {
"type": "boolean",
"description": "Execute compodoc before.",
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ command('build')
)
.option('--force-build-preview', 'Build the preview iframe even if you are using --preview-url')
.option('--docs', 'Build a documentation-only site using addon-docs')
.option('--test', 'Build stories optimized for testing purposes.')
.action(async (options) => {
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
logger.setLevel(program.loglevel);
Expand Down
25 changes: 24 additions & 1 deletion code/lib/cli/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type Template = {
modifications?: {
skipTemplateStories?: boolean;
mainConfig?: Partial<StorybookConfig>;
testBuild?: boolean;
disableDocs?: boolean;
};
/**
Expand Down Expand Up @@ -559,7 +560,27 @@ const benchTemplates = {
},
skipTasks: ['e2e-tests-dev', 'test-runner', 'test-runner-dev', 'e2e-tests', 'chromatic'],
},
} satisfies Record<`bench/${string}`, Template & { isInternal: true }>;
'bench/react-vite-default-ts-test-build': {
...baseTemplates['react-vite/default-ts'],
name: 'Bench (react-vite/default-ts, test-build)',
isInternal: true,
modifications: {
skipTemplateStories: true,
testBuild: true,
},
skipTasks: ['e2e-tests-dev', 'test-runner', 'test-runner-dev', 'e2e-tests', 'chromatic'],
},
'bench/react-webpack-18-ts-test-build': {
...baseTemplates['react-webpack/18-ts'],
name: 'Bench (react-webpack/18-ts, test-build)',
isInternal: true,
modifications: {
skipTemplateStories: true,
testBuild: true,
},
skipTasks: ['e2e-tests-dev', 'test-runner', 'test-runner-dev', 'e2e-tests', 'chromatic'],
},
} satisfies Record<string, Template & { isInternal: true }>;

export const allTemplates: Record<TemplateKey, Template> = {
...baseTemplates,
Expand All @@ -580,6 +601,8 @@ export const normal: TemplateKey[] = [
'bench/react-vite-default-ts',
'bench/react-webpack-18-ts',
'bench/react-vite-default-ts-nodocs',
'bench/react-vite-default-ts-test-build',
'bench/react-webpack-18-ts-test-build',
];
export const merged: TemplateKey[] = [
...normal,
Expand Down
21 changes: 11 additions & 10 deletions code/lib/core-server/src/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
StorybookConfig,
} from '@storybook/types';
import { printConfig, readConfig, readCsf } from '@storybook/csf-tools';
import { join } from 'path';
import { join, isAbsolute } from 'path';
import { dedent } from 'ts-dedent';
import fetch from 'node-fetch';
import type { Channel } from '@storybook/channels';
Expand Down Expand Up @@ -61,15 +61,16 @@ export const favicon = async (
const lists = await Promise.all(
statics.map(async (dir) => {
const results = [];
const relativeDir = staticDirsValue
? getDirectoryFromWorkingDir({
configDir: options.configDir,
workingDir: process.cwd(),
directory: dir,
})
: dir;

const { staticPath, targetEndpoint } = await parseStaticDir(relativeDir);
const normalizedDir =
staticDirsValue && !isAbsolute(dir)
? getDirectoryFromWorkingDir({
configDir: options.configDir,
workingDir: process.cwd(),
directory: dir,
})
: dir;

const { staticPath, targetEndpoint } = await parseStaticDir(normalizedDir);

if (targetEndpoint === '/') {
const url = 'favicon.svg';
Expand Down
19 changes: 10 additions & 9 deletions code/lib/core-server/src/utils/server-statics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chalk from 'chalk';
import type { Router } from 'express';
import express from 'express';
import { pathExists } from 'fs-extra';
import path, { basename } from 'path';
import path, { basename, isAbsolute } from 'path';
import isEqual from 'lodash/isEqual.js';

import { dedent } from 'ts-dedent';
Expand All @@ -30,14 +30,15 @@ export async function useStatics(router: Router, options: Options) {
await Promise.all(
statics.map(async (dir) => {
try {
const relativeDir = staticDirs
? getDirectoryFromWorkingDir({
configDir: options.configDir,
workingDir: process.cwd(),
directory: dir,
})
: dir;
const { staticDir, staticPath, targetEndpoint } = await parseStaticDir(relativeDir);
const normalizedDir =
staticDirs && !isAbsolute(dir)
? getDirectoryFromWorkingDir({
configDir: options.configDir,
workingDir: process.cwd(),
directory: dir,
})
: dir;
const { staticDir, staticPath, targetEndpoint } = await parseStaticDir(normalizedDir);

// Don't log for the internal static dir
if (!targetEndpoint.startsWith('/sb-')) {
Expand Down
2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
"built": false
}
},
"packageManager": "yarn@3.5.1",
"packageManager": "yarn@4.0.0",
"engines": {
"node": ">=18.0.0"
},
Expand Down
Loading

0 comments on commit 7626e39

Please sign in to comment.