Skip to content

Commit

Permalink
Merge branch 'next' into update-docs-multiple-components
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniebigodes authored Apr 2, 2024
2 parents b8e46fe + cddf8ce commit 43b4f0f
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 26 deletions.
2 changes: 1 addition & 1 deletion code/frameworks/nextjs/src/css/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const configureCss = (baseConfig: WebpackConfig, nextConfig: NextConfig):
],
// We transform the "target.css" files from next.js into Javascript
// for Next.js to support fonts, so it should be ignored by the css-loader.
exclude: /next\/.*\/target.css$/,
exclude: /next(\\|\/|\\\\).*(\\|\/|\\\\)target\.css$/,
};
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function configureNextFont(baseConfig: Configuration, isSWC?: boolean) {

if (isSWC) {
baseConfig.module?.rules?.push({
test: /next\/.*\/target.css$/,
test: /next(\\|\/|\\\\).*(\\|\/|\\\\)target\.css$/,
loader: fontLoaderPath,
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ export async function getFontFaceDeclarations(
.map(({ prop, value }: { prop: string; value: string }) => `${prop}: ${value};`)
.join('\n');

const arePathsWin32Format = /^[a-z]:\\/iu.test(options.filename);
const cleanWin32Path = (pathString: string): string =>
arePathsWin32Format ? pathString.replace(/\\/gu, '/') : pathString;

const getFontFaceCSS = () => {
if (typeof localFontSrc === 'string') {
const localFontPath = cleanWin32Path(path.join(parentFolder, localFontSrc));
const localFontPath = path.join(parentFolder, localFontSrc).replaceAll('\\', '/');

return `@font-face {
font-family: ${id};
Expand All @@ -55,7 +51,7 @@ export async function getFontFaceDeclarations(
}
return localFontSrc
.map((font) => {
const localFontPath = cleanWin32Path(path.join(parentFolder, font.path));
const localFontPath = path.join(parentFolder, font.path).replaceAll('\\', '/');

return `@font-face {
font-family: ${id};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getFontFaceDeclarations as getLocalFontFaceDeclarations } from './local
import type { LoaderOptions } from './types';
import { getCSSMeta } from './utils/get-css-meta';
import { setFontDeclarationsInHead } from './utils/set-font-declarations-in-head';
import path from 'path';

type FontFaceDeclaration = {
id: string;
Expand Down Expand Up @@ -39,11 +40,19 @@ export default async function storybookNextjsFontLoader(this: any) {

let fontFaceDeclaration: FontFaceDeclaration | undefined;

if (options.source.endsWith('next/font/google') || options.source.endsWith('@next/font/google')) {
const pathSep = path.sep;

if (
options.source.endsWith(`next${pathSep}font${pathSep}google`) ||
options.source.endsWith(`@next${pathSep}font${pathSep}google`)
) {
fontFaceDeclaration = await getGoogleFontFaceDeclarations(options);
}

if (options.source.endsWith('next/font/local') || options.source.endsWith('@next/font/local')) {
if (
options.source.endsWith(`next${pathSep}font${pathSep}local`) ||
options.source.endsWith(`@next${pathSep}font${pathSep}local`)
) {
fontFaceDeclaration = await getLocalFontFaceDeclarations(options, rootCtx, swcMode);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, beforeEach, it, expect, vi } from 'vitest';
import dedent from 'ts-dedent';
import { Yarn2Proxy } from './Yarn2Proxy';

describe('Yarn 2 Proxy', () => {
Expand Down
7 changes: 5 additions & 2 deletions code/lib/core-common/src/js-package-manager/Yarn2Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const CRITICAL_YARN2_ERROR_CODES = {
YN0083: 'AUTOMERGE_GIT_ERROR',
};

// @ts-expect-error The error codes might be helpful in the future
const YARN2_ERROR_CODES = {
...CRITICAL_YARN2_ERROR_CODES,
YN0000: 'UNNAMED',
Expand Down Expand Up @@ -306,10 +307,12 @@ export class Yarn2Proxy extends JsPackageManager {
while ((match = regex.exec(logs)) !== null) {
const code = match[1];
const message = match[2].replace(/[┌│└]/g, '').trim();
if (CRITICAL_YARN2_ERROR_CODES[code]) {
if (code in CRITICAL_YARN2_ERROR_CODES) {
errorCodesWithMessages.push({
code,
message: `${CRITICAL_YARN2_ERROR_CODES[code]}\n-> ${message}\n`,
message: `${
CRITICAL_YARN2_ERROR_CODES[code as keyof typeof CRITICAL_YARN2_ERROR_CODES]
}\n-> ${message}\n`,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"trash": "^7.0.0",
"ts-dedent": "^2.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.3.2",
"typescript": "^5.4.3",
"util": "^0.12.4",
"vite": "^4.0.0",
"vitest": "^1.2.2",
Expand Down
1 change: 1 addition & 0 deletions code/presets/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
"dependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
"@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0",
"@storybook/types": "workspace:*",
"@types/semver": "^7.5.6",
"pnp-webpack-plugin": "^1.7.0",
Expand Down
1 change: 1 addition & 0 deletions code/presets/create-react-app/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Options } from '@storybook/types';

import type { PluginOptions as RDTSPluginOptions } from '@storybook/react-docgen-typescript-plugin';

export interface PluginOptions extends Options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import { vi, it, expect, afterEach, describe } from 'vitest';
import { render, screen, cleanup } from '@testing-library/react';
import { addons } from '@storybook/preview-api';
//@ts-expect-error our tsconfig.jsn#moduleResolution is set to 'node', which doesn't support this import

import * as addonInteractionsPreview from '@storybook/addon-interactions/preview';

Expand Down Expand Up @@ -92,6 +91,7 @@ describe('projectAnnotations', () => {
});

it('has spies when addon-interactions annotations are added', async () => {
//@ts-expect-error TODO investigate
const Story = composeStory(stories.WithActionArg, stories.default, addonInteractionsPreview);
expect(vi.mocked(Story.args.someActionArg!).mock).toBeDefined();

Expand Down
23 changes: 22 additions & 1 deletion code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6048,6 +6048,7 @@ __metadata:
dependencies:
"@pmmmwh/react-refresh-webpack-plugin": "npm:^0.5.1"
"@storybook/node-logger": "workspace:*"
"@storybook/react-docgen-typescript-plugin": "npm:1.0.6--canary.9.0c3f3b7.0"
"@storybook/types": "workspace:*"
"@types/node": "npm:^18.0.0"
"@types/semver": "npm:^7.5.6"
Expand Down Expand Up @@ -6458,7 +6459,7 @@ __metadata:
trash: "npm:^7.0.0"
ts-dedent: "npm:^2.0.0"
ts-node: "npm:^10.9.1"
typescript: "npm:^5.3.2"
typescript: "npm:^5.4.3"
util: "npm:^0.12.4"
vite: "npm:^4.0.0"
vitest: "npm:^1.2.2"
Expand Down Expand Up @@ -27534,6 +27535,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.4.3":
version: 5.4.3
resolution: "typescript@npm:5.4.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/22443a8760c3668e256c0b34b6b45c359ef6cecc10c42558806177a7d500ab1a7d7aac1f976d712e26989ddf6731d2fbdd3212b7c73290a45127c1c43ba2005a
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^3.8.3#optional!builtin<compat/typescript>":
version: 3.9.10
resolution: "typescript@patch:typescript@npm%3A3.9.10#optional!builtin<compat/typescript>::version=3.9.10&hash=3bd3d3"
Expand All @@ -27554,6 +27565,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.4.3#optional!builtin<compat/typescript>":
version: 5.4.3
resolution: "typescript@patch:typescript@npm%3A5.4.3#optional!builtin<compat/typescript>::version=5.4.3&hash=5adc0c"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/6e51f8b7e6ec55b897b9e56b67e864fe8f44e30f4a14357aad5dc0f7432db2f01efc0522df0b6c36d361c51f2dc3dcac5c832efd96a404cfabf884e915d38828
languageName: node
linkType: hard

"ufo@npm:^1.3.0":
version: 1.3.2
resolution: "ufo@npm:1.3.2"
Expand Down
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"ts-dedent": "^2.0.0",
"tsup": "^6.7.0",
"type-fest": "~2.19",
"typescript": "^5.3.2",
"typescript": "^5.4.3",
"util": "^0.12.4",
"uuid": "^9.0.0",
"vitest": "^1.2.2",
Expand Down
18 changes: 9 additions & 9 deletions scripts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@ __metadata:
ts-loader: "npm:^9.4.2"
tsup: "npm:^6.7.0"
type-fest: "npm:~2.19"
typescript: "npm:^5.3.2"
typescript: "npm:^5.4.3"
util: "npm:^0.12.4"
uuid: "npm:^9.0.0"
verdaccio: "npm:^5.19.1"
Expand Down Expand Up @@ -14963,23 +14963,23 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.3.2":
version: 5.4.2
resolution: "typescript@npm:5.4.2"
"typescript@npm:^5.4.3":
version: 5.4.3
resolution: "typescript@npm:5.4.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/583ff68cafb0c076695f72d61df6feee71689568179fb0d3a4834dac343df6b6ed7cf7b6f6c801fa52d43cd1d324e2f2d8ae4497b09f9e6cfe3d80a6d6c9ca52
checksum: 10c0/22443a8760c3668e256c0b34b6b45c359ef6cecc10c42558806177a7d500ab1a7d7aac1f976d712e26989ddf6731d2fbdd3212b7c73290a45127c1c43ba2005a
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.3.2#optional!builtin<compat/typescript>":
version: 5.4.2
resolution: "typescript@patch:typescript@npm%3A5.4.2#optional!builtin<compat/typescript>::version=5.4.2&hash=5adc0c"
"typescript@patch:typescript@npm%3A^5.4.3#optional!builtin<compat/typescript>":
version: 5.4.3
resolution: "typescript@patch:typescript@npm%3A5.4.3#optional!builtin<compat/typescript>::version=5.4.3&hash=5adc0c"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/fcf6658073d07283910d9a0e04b1d5d0ebc822c04dbb7abdd74c3151c7aa92fcddbac7d799404e358197222006ccdc4c0db219d223d2ee4ccd9e2b01333b49be
checksum: 10c0/6e51f8b7e6ec55b897b9e56b67e864fe8f44e30f4a14357aad5dc0f7432db2f01efc0522df0b6c36d361c51f2dc3dcac5c832efd96a404cfabf884e915d38828
languageName: node
linkType: hard

Expand Down

0 comments on commit 43b4f0f

Please sign in to comment.