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

Maintenance: Merge @storybook/core with storybook #30168

Merged
merged 33 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
447caec
add bin to core
ndelangen Jan 2, 2025
ac6e73b
add bin to core
ndelangen Jan 2, 2025
bf23898
delete cli package
ndelangen Jan 2, 2025
858f098
remove CLI package
ndelangen Jan 2, 2025
2d955cd
fixes
ndelangen Jan 2, 2025
c42b53e
fix usage of cli path
ndelangen Jan 2, 2025
5f51f17
fix
ndelangen Jan 2, 2025
e256f9b
fix
ndelangen Jan 2, 2025
f081014
Merge branch 'next' into norbert/merge-core-cli
ndelangen Jan 3, 2025
2e9cfd8
fixes
ndelangen Jan 3, 2025
10bb8e0
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 19, 2025
8d4f43e
delete
ndelangen Feb 19, 2025
2a2e696
fix
ndelangen Feb 19, 2025
5892934
add dep
ndelangen Feb 19, 2025
c9a5021
fix lockfile
ndelangen Feb 19, 2025
2aeb261
fixes
ndelangen Feb 19, 2025
4315e64
ignore type issue
ndelangen Feb 19, 2025
26f8c42
fixes
ndelangen Feb 19, 2025
ed5fdf5
fix
ndelangen Feb 19, 2025
b1e5865
add frameworkToRenderer
ndelangen Feb 19, 2025
ed82b3b
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 24, 2025
6a394a8
make testing the CLI 200x faster
ndelangen Feb 24, 2025
fd20945
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 25, 2025
dc545e1
use VTA v4.0.0
ndelangen Feb 25, 2025
0d973af
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 26, 2025
2d119c5
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 26, 2025
2597b7c
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 26, 2025
ee5bf02
dedupe
ndelangen Feb 26, 2025
00e42a3
accept change by dedupe
ndelangen Feb 26, 2025
f7200e1
fix test
ndelangen Feb 26, 2025
335708c
Merge branch 'next' into norbert/merge-core-cli
ndelangen Feb 26, 2025
807c0c9
deal with dedupe effects
ndelangen Feb 26, 2025
bf12d25
ignore error
ndelangen Feb 26, 2025
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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion code/.storybook/bench.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
subEntry !== 'metafile' ? `${pkgName} - ${subEntry}` : pkgName,
];
})
.concat([['core - core', '@storybook/core - core - TOO BIG PLEASE UPLOAD MANUALLY']])
.concat([['core - core', 'core - TOO BIG PLEASE UPLOAD MANUALLY']])
),
},
},
Expand Down
4 changes: 2 additions & 2 deletions code/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { join } from 'node:path';

import { defineMain } from '../frameworks/react-vite/src/node';

const componentsPath = join(__dirname, '../core/src/components');
const managerApiPath = join(__dirname, '../core/src/manager-api');
const componentsPath = join(__dirname, '../core/src/components/index.ts');
const managerApiPath = join(__dirname, '../core/src/manager-api/index.ts');
const imageContextPath = join(__dirname, '../frameworks/nextjs/src/image-context.ts');

const config = defineMain({
Expand Down
2 changes: 1 addition & 1 deletion code/.storybook/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default mergeConfig(
'**/Zoom.stories.tsx', // expected to fail in Vitest because of fetching /iframe.html to cause ECONNREFUSED
'**/lib/blocks/src/**', // won't work because of /~https://github.com/storybookjs/storybook/issues/29783
],
// TODO: bring this back once portable stories support @storybook/core/preview-api hooks
// TODO: bring this back once portable stories support storybook/internal/preview-api hooks
// @ts-expect-error this type does not exist but the property does!
testNamePattern: /^(?!.*(UseState)).*$/,
browser: {
Expand Down
4 changes: 2 additions & 2 deletions code/addons/a11y/src/postinstall.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PostinstallOptions } from '@storybook/cli/src/add';

// eslint-disable-next-line depend/ban-dependencies
import { execa } from 'execa';

import type { PostinstallOptions } from '../../../lib/cli-storybook/src/add';

const $ = execa({
preferLocal: true,
stdio: 'inherit',
Expand Down
1 change: 1 addition & 0 deletions code/addons/a11y/src/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const experimental_afterEach: AfterEach<any> = async ({
if (getIsVitestStandaloneRun()) {
if (hasViolations && getMode() === 'failed') {
if (!vitestMatchersExtended) {
// @ts-expect-error (unknown why vitest-axe is not typed correctly)
const { toHaveNoViolations } = await import('vitest-axe/matchers');
expect.extend({ toHaveNoViolations });
vitestMatchersExtended = true;
Expand Down
40 changes: 20 additions & 20 deletions code/addons/docs/src/compiler/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe('mdx3', () => {
function _createMdxContent(props) {
return _jsx("style", {
children: \`
h1 {
color: blue;
}
h1 {
color: blue;
}
\`
});
}
Expand Down Expand Up @@ -645,23 +645,23 @@ describe('docs-mdx-compiler-plugin', () => {
title: "Example/Introduction"
}), "\\n", _jsx("style", {
children: \`
.subheading {
--mediumdark: '#999999';
font-weight: 900;
font-size: 13px;
color: #999;
letter-spacing: 6px;
line-height: 24px;
text-transform: uppercase;
margin-bottom: 12px;
margin-top: 40px;
}
.link-list {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr 1fr;
row-gap: 10px;
}
.subheading {
--mediumdark: '#999999';
font-weight: 900;
font-size: 13px;
color: #999;
letter-spacing: 6px;
line-height: 24px;
text-transform: uppercase;
margin-bottom: 12px;
margin-top: 40px;
}
.link-list {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr 1fr;
row-gap: 10px;
}
\`
})]
});
Expand Down
16 changes: 8 additions & 8 deletions code/addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ async function webpack(
* In the future the `@storybook/theming` and `@storybook/components` can be removed, as they
* should be singletons in the future due to the peerDependency on `storybook` package.
*/
const cliPath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(cliPath, 'core', 'theming', 'index.js');
const themingCreatePath = join(cliPath, 'core', 'theming', 'create.js');
const corePath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(corePath, 'dist', 'theming', 'index.js');
const themingCreatePath = join(corePath, 'dist', 'theming', 'create.js');

const componentsPath = join(cliPath, 'core', 'components', 'index.js');
const componentsPath = join(corePath, 'dist', 'components', 'index.js');
const blocksPath = dirname(require.resolve('@storybook/blocks/package.json'));
if (Array.isArray(webpackConfig.resolve?.alias)) {
alias = [...webpackConfig.resolve?.alias];
Expand Down Expand Up @@ -181,10 +181,10 @@ export const viteFinal = async (config: any, options: Options) => {
// Use the resolvedReact preset to alias react and react-dom to either the users version or the version shipped with addon-docs
const { react, reactDom, mdx } = await getResolvedReact(options);

const cliPath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(cliPath, 'core', 'theming', 'index.js');
const themingCreatePath = join(cliPath, 'core', 'theming', 'create.js');
const componentsPath = join(cliPath, 'core', 'components', 'index.js');
const corePath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(corePath, 'dist', 'theming', 'index.js');
const themingCreatePath = join(corePath, 'dist', 'theming', 'create.js');
const componentsPath = join(corePath, 'dist', 'components', 'index.js');
const blocksPath = dirname(require.resolve('@storybook/blocks/package.json'));

const packageDeduplicationPlugin = {
Expand Down
1 change: 1 addition & 0 deletions code/addons/essentials/src/actions/manager.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-actions/manager';
1 change: 1 addition & 0 deletions code/addons/essentials/src/backgrounds/manager.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// @ts-expect-error (no types)
export * from '@storybook/addon-backgrounds/manager';
1 change: 1 addition & 0 deletions code/addons/essentials/src/outline/manager.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// @ts-expect-error (no types)
export * from '@storybook/addon-outline/manager';
1 change: 1 addition & 0 deletions code/addons/essentials/src/viewport/manager.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// @ts-expect-error (no types)
export * from '@storybook/addon-viewport/manager';
5 changes: 2 additions & 3 deletions code/addons/test/src/node/boot-test-runner.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { Channel, type ChannelTransport } from '@storybook/core/channels';

import { Channel, type ChannelTransport } from 'storybook/internal/channels';
import {
TESTING_MODULE_CANCEL_TEST_RUN_REQUEST,
TESTING_MODULE_PROGRESS_REPORT,
TESTING_MODULE_RUN_REQUEST,
} from '@storybook/core/core-events';
} from 'storybook/internal/core-events';

// eslint-disable-next-line depend/ban-dependencies
import { execaNode } from 'execa';
Expand Down
7 changes: 3 additions & 4 deletions code/addons/test/src/node/test-manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { createVitest as actualCreateVitest } from 'vitest/node';

import { Channel, type ChannelTransport } from 'storybook/internal/channels';
import { experimental_MockUniversalStore } from 'storybook/internal/core-server';

import { Channel, type ChannelTransport } from '@storybook/core/channels';
import type { StoryIndex } from '@storybook/types';
import type { StoryIndex } from 'storybook/internal/types';

import path from 'pathe';

Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ async function getStorybookInfo({ configDir, packageManager: pkgMgr }: Postinsta
const presets = await loadAllPresets({
corePresets: [join(frameworkName, 'preset')],
overridePresets: [
require.resolve('@storybook/core/core-server/presets/common-override-preset'),
require.resolve('storybook/internal/core-server/presets/common-override-preset'),
],
configDir,
packageJson,
Expand Down
1 change: 0 additions & 1 deletion code/addons/test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type StorybookTheme, useTheme } from 'storybook/internal/theming';
import type { StorybookConfig } from 'storybook/internal/types';

import Filter from 'ansi-to-html';
// eslint-disable-next-line depend/ban-dependencies
import stripAnsi from 'strip-ansi';

export function isTestAssertionError(error: unknown) {
Expand Down
2 changes: 0 additions & 2 deletions code/addons/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "../../../",
"module": "Preserve",
"moduleResolution": "Bundler",
"types": ["vitest"],
"strict": true
},
Expand Down
2 changes: 2 additions & 0 deletions code/builders/builder-vite/src/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export async function createViteServer(options: Options, devServer: Server) {
const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}$|^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/;

if (
// @ts-expect-error (unknown)
!(config.server.allowedHosts as string[])?.length &&
options.host &&
!ipRegex.test(options.host)
) {
// @ts-expect-error (unknown)
config.server.allowedHosts = [options.host.toLowerCase()];
}

Expand Down
5 changes: 3 additions & 2 deletions code/builders/builder-webpack5/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cp } from 'node:fs/promises';
import { join, parse } from 'node:path';
import { dirname, join, parse } from 'node:path';

import { PREVIEW_BUILDER_PROGRESS } from 'storybook/internal/core-events';
import { logger } from 'storybook/internal/node-logger';
Expand All @@ -14,7 +14,6 @@ import { checkWebpackVersion } from '@storybook/core-webpack';

import prettyTime from 'pretty-hrtime';
import sirv from 'sirv';
import { corePath } from 'storybook/core-path';
import type { Configuration, Stats, StatsOptions } from 'webpack';
import webpackDep, { DefinePlugin, IgnorePlugin, ProgressPlugin } from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
Expand All @@ -32,6 +31,8 @@ export const printDuration = (startTime: [number, number]) =>
.replace(' s', ' seconds')
.replace(' m', ' minutes');

const corePath = dirname(require.resolve('storybook/package.json'));

let compilation: ReturnType<typeof webpackDevMiddleware> | undefined;
let reject: (reason?: any) => void;

Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/bin/index.cjs → code/core/bin/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ process.once('uncaughtException', (error) => {
throw error;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Re-throwing error prevents proper error reporting to users. Consider handling the error gracefully instead of throwing

});

require('../dist/proxy.cjs');
require('../dist/bin/index.cjs');
Loading