Merge branch 'jeppe/sb-898-blocks-canvas' of github.com:storybookjs/storybook into jeppe/sb-898-blocks-story

This commit is contained in:
Jeppe Reinhold 2022-11-16 13:48:48 +01:00
commit f671096df1
236 changed files with 2034 additions and 1685 deletions

View File

@ -51,6 +51,7 @@ executors:
orbs:
git-shallow-clone: guitarrapc/git-shallow-clone@2.4.0
browser-tools: circleci/browser-tools@1.4.0
discord: antonioned/discord@0.1.0
commands:
# Forked off from https://github.com/guitarrapc/git-shallow-clone-orb
@ -101,7 +102,7 @@ commands:
then
export HOME=$(getent passwd $(id -un) | cut -d: -f6)
fi
# known_hosts
mkdir -p ~/.ssh
if [ -x "$(command -v ssh-keyscan)" ] && ([ "<< parameters.keyscan_github >>" == "true" ] || [ "<< parameters.keyscan_bitbucket >>" == "true" ])
@ -125,19 +126,19 @@ commands:
echo 'bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
' >> ~/.ssh/known_hosts
fi
(umask 077; touch ~/.ssh/id_rsa)
chmod 0600 ~/.ssh/id_rsa
(echo $CHECKOUT_KEY > ~/.ssh/id_rsa)
# use git+ssh instead of https
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
git config --global gc.auto 0 || true
# checkout
git clone << parameters.clone_options >> $CIRCLE_REPOSITORY_URL "<< parameters.path >>"
cd "<< parameters.path >>"
# Fetch remote and check the commit ID of the checked out code
if [ -n "$CIRCLE_TAG" ]
then
@ -151,7 +152,7 @@ commands:
# others
git fetch << parameters.fetch_options >> --force origin "$CIRCLE_BRANCH:remotes/origin/$CIRCLE_BRANCH"
fi
# Check the commit ID of the checked out code
if [ -n "$CIRCLE_TAG" ]
then
@ -162,7 +163,7 @@ commands:
git reset --hard "$CIRCLE_SHA1"
git checkout -q -B "$CIRCLE_BRANCH"
fi
git reset --hard "$CIRCLE_SHA1"
name: Checkout code shallow
cancel-workflow-on-failure:
@ -175,6 +176,22 @@ commands:
echo "Canceling workflow as previous step resulted in failure."
echo "To execute all checks locally, please run yarn ci-tests"
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${WORKFLOW_CANCELER}"
report-workflow-on-failure:
description: 'Reports failures to discord'
parameters:
template:
description: |
Which template to report in discord. Applicable for parallel sandbox jobs
type: string
default: 'none'
steps:
- run:
when: on_fail
command: git fetch --unshallow
- discord/status:
only_for_branches: main,next,next-release,latest-release
fail_only: true
failure_message: $(yarn get-report-message << pipeline.parameters.workflow >> << parameters.template >>)
jobs:
build:
executor:
@ -197,6 +214,7 @@ jobs:
command: |
cd code
yarn local-registry --publish
- report-workflow-on-failure
- save_cache:
name: Save Yarn cache
key: build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
@ -241,21 +259,22 @@ jobs:
name: set up cra repro, skip tests
command: |
cd code
node ./lib/cli/bin/index.js repro-next cra/default-js --output ../../cra-bench
SANDBOX_ROOT=../bench yarn task --task sandbox --template cra/default-ts --skip-template-stories --start-from=never --no-link
- run:
name: Run @storybook/bench on repro
command: |
cd ../cra-bench
cd bench/cra-default-ts
rm -rf node_modules
mkdir node_modules
npx -p @storybook/bench@next sb-bench 'yarn install' --label cra
- report-workflow-on-failure
- run:
name: prep artifacts
when: always
command: tar cvzf /tmp/sb-bench.tar.gz ../cra-bench
command: tar cvzf /tmp/cra-default-ts-bench.tar.gz bench/cra-default-ts
- store_artifacts:
path: /tmp/sb-bench.tar.gz
destination: sb-bench.tar.gz
path: /tmp/cra-default-ts-bench.tar.gz
destination: cra-default-ts-bench.tar.gz
react-vite-bench:
executor:
class: large
@ -281,21 +300,22 @@ jobs:
name: set up react-vite repro, skip tests
command: |
cd code
node ./lib/cli/bin/index.js repro-next react-vite/default-ts --output ../../react-vite-bench
SANDBOX_ROOT=../bench yarn task --task sandbox --template react-vite/default-ts --skip-template-stories --start-from=never --no-link
- run:
name: Run @storybook/bench on repro
command: |
cd ../react-vite-bench
cd bench/react-vite-default-ts
rm -rf node_modules
mkdir node_modules
npx -p @storybook/bench@next sb-bench 'yarn install' --label react-vite
- report-workflow-on-failure
- run:
name: prep artifacts
when: always
command: tar cvzf /tmp/sb-bench.tar.gz ../react-vite-bench
command: tar cvzf /tmp/react-vite-default-ts-bench.tar.gz bench/react-vite-default-ts
- store_artifacts:
path: /tmp/sb-bench.tar.gz
destination: sb-bench.tar.gz
path: /tmp/react-vite-default-ts-bench.tar.gz
destination: react-vite-default-ts-bench.tar.gz
lint:
executor:
class: medium
@ -310,6 +330,7 @@ jobs:
command: |
cd code
yarn lint
- report-workflow-on-failure
- cancel-workflow-on-failure
check:
executor:
@ -325,6 +346,7 @@ jobs:
command: |
yarn task --task check --start-from=auto --no-link --debug
git diff --exit-code
- report-workflow-on-failure
- cancel-workflow-on-failure
script-unit-tests:
executor: sb_node_16_browsers
@ -340,6 +362,7 @@ jobs:
yarn test --coverage --ci
- store_test_results:
path: scripts/junit.xml
- report-workflow-on-failure
- cancel-workflow-on-failure
unit-tests:
executor:
@ -361,6 +384,7 @@ jobs:
root: .
paths:
- code/coverage
- report-workflow-on-failure
- cancel-workflow-on-failure
coverage:
executor:
@ -376,6 +400,7 @@ jobs:
command: |
cd code
yarn coverage
- report-workflow-on-failure
chromatic-internal-storybooks:
executor:
class: medium
@ -391,6 +416,7 @@ jobs:
cd code
yarn storybook:ui:chromatic
yarn storybook:blocks:chromatic
- report-workflow-on-failure
- store_test_results:
path: test-results
## new workflow
@ -410,7 +436,9 @@ jobs:
at: .
- run:
name: Creating Sandboxes
command: yarn task --task sandbox --template $(yarn get-template << pipeline.parameters.workflow >> create) --no-link --start-from=never --junit
command: yarn task --task sandbox --template $(yarn get-template << pipeline.parameters.workflow >> sandbox) --no-link --start-from=never --junit
- report-workflow-on-failure:
template: $(yarn get-template << pipeline.parameters.workflow >> sandbox)
- persist_to_workspace:
root: .
paths:
@ -434,6 +462,8 @@ jobs:
- run:
name: Smoke Testing Sandboxes
command: yarn task --task smoke-test --template $(yarn get-template << pipeline.parameters.workflow >> smoke-test) --no-link --start-from=never --junit
- report-workflow-on-failure:
template: $(yarn get-template << pipeline.parameters.workflow >> smoke-test)
- store_test_results:
path: test-results
build-sandboxes:
@ -453,6 +483,8 @@ jobs:
- run:
name: Building Sandboxes
command: yarn task --task build --template $(yarn get-template << pipeline.parameters.workflow >> build) --no-link --start-from=never --junit
- report-workflow-on-failure:
template: $(yarn get-template << pipeline.parameters.workflow >> build)
- store_test_results:
path: test-results
- persist_to_workspace:
@ -476,6 +508,8 @@ jobs:
- run:
name: Running Test Runner
command: yarn task --task test-runner --template $(yarn get-template << pipeline.parameters.workflow >> test-runner) --no-link --start-from=never --junit
- report-workflow-on-failure:
template: $(yarn get-template << pipeline.parameters.workflow >> test-runner)
- store_test_results:
path: test-results
chromatic-sandboxes:
@ -494,6 +528,8 @@ jobs:
- run:
name: Running Chromatic
command: yarn task --task chromatic --template $(yarn get-template << pipeline.parameters.workflow >> chromatic) --no-link --start-from=never --junit
- report-workflow-on-failure:
template: $(yarn get-template << pipeline.parameters.workflow >> chromatic)
- store_test_results:
path: test-results
e2e-sandboxes:
@ -513,6 +549,8 @@ jobs:
- run:
name: Running E2E Tests
command: yarn task --task e2e-tests --template $(yarn get-template << pipeline.parameters.workflow >> e2e-tests) --no-link --start-from=never --junit
- report-workflow-on-failure:
template: $(yarn get-template << pipeline.parameters.workflow >> e2e-tests)
- store_test_results:
path: test-results
- store_artifacts: # this is where playwright puts more complex stuff
@ -523,8 +561,8 @@ workflows:
ci:
when:
and:
- equal: [ api, << pipeline.trigger_source >> ]
- equal: [ ci, << pipeline.parameters.workflow >> ]
- equal: [api, << pipeline.trigger_source >>]
- equal: [ci, << pipeline.parameters.workflow >>]
jobs:
- build
- lint:
@ -556,7 +594,7 @@ workflows:
- build-sandboxes
pr:
when:
equal: [ pr, << pipeline.parameters.workflow >> ]
equal: [pr, << pipeline.parameters.workflow >>]
jobs:
- build
- lint:
@ -605,7 +643,7 @@ workflows:
- build-sandboxes
merged:
when:
equal: [ merged, << pipeline.parameters.workflow >> ]
equal: [merged, << pipeline.parameters.workflow >>]
jobs:
- build
- lint:
@ -654,7 +692,7 @@ workflows:
- build-sandboxes
daily:
when:
equal: [ daily, << pipeline.parameters.workflow >> ]
equal: [daily, << pipeline.parameters.workflow >>]
jobs:
- build
- create-sandboxes:
@ -679,4 +717,4 @@ workflows:
- e2e-sandboxes:
parallelism: 24
requires:
- build-sandboxes
- build-sandboxes

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ junit.xml
test-results
/repros
/sandbox
/bench
.verdaccio-cache
# Yarn stuff

View File

@ -563,9 +563,10 @@ Bad publish
#### Bug Fixes
- CLI: Fix race condition in sb init [#19083](https://github.com/storybooks/storybook/pull/19083)
- Vite: Fix framework option checks, and SSv6 [#19062](https://github.com/storybooks/storybook/pull/19062)
- Core: Fix WebProjectAnnotations export in preview-web for back-compat [#19048](https://github.com/storybooks/storybook/pull/19048)
- CLI: Fix race condition in sb init [#19083](https://github.com/storybooks/storybook/pull/19083)
- Vite: Fix framework option checks, and SSv6 [#19062](https://github.com/storybooks/storybook/pull/19062)
- Core: Fix WebProjectAnnotations export in preview-web for back-compat [#19048](https://github.com/storybooks/storybook/pull/19048)
- Blocks: Fix Checkbox control update when using useArgs hook
#### Maintenance

View File

@ -43,8 +43,9 @@
- [7.0 Deprecations](#70-deprecations)
- [`Story` type deprecated](#story-type-deprecated)
- [`ComponentStory`, `ComponentStoryObj`, `ComponentStoryFn` and `ComponentMeta` types are deprecated](#componentstory-componentstoryobj-componentstoryfn-and-componentmeta-types-are-deprecated)
- [Renamed `renderToDOM` to `renderToCanvas`](#renamed-rendertodom-to-rendertoroot)
- [Renamed `renderToDOM` to `renderToCanvas`](#renamed-rendertodom-to-rendertocanvas)
- [Renamed `XFramework` to `XRenderer`](#renamed-xframework-to-xrenderer)
- [Renamed `DecoratorFn` to `Decorator`](#renamed-decoratorfn-to-decorator)
- [From version 6.4.x to 6.5.0](#from-version-64x-to-650)
- [Vue 3 upgrade](#vue-3-upgrade)
- [React18 new root API](#react18-new-root-api)
@ -864,6 +865,47 @@ import type { SvelteRenderer } from '@storybook/svelte';
// etc.
```
#### Renamed `DecoratorFn` to `Decorator`
In 6.x you could import the type `DecoratorFn`:
```ts
import type { DecoratorFn } from '@storybook/react';
```
This type is deprecated in 7.0, instead you can use the type `Decorator`, which is now available for all renderers:
```ts
import type { Decorator } from '@storybook/react';
// or
import type { Decorator } from '@storybook/vue';
// or
import type { Decorator } from '@storybook/svelte';
// etc.
```
The type `Decorator` accepts a generic parameter `TArgs`. This can be used like this:
```tsx
import type { Decorator } from '@storybook/react';
import { LocaleProvider } from './locale';
const withLocale: Decorator<{ locale: 'en' | 'es' }> = (Story, { args }) => (
<LocaleProvider lang={args.locale}>
<Story />
</LocaleProvider>
);
```
If you want to use `Decorator` in a backwards compatible way to `DecoratorFn`, you can use:
```tsx
import type { Args, Decorator } from '@storybook/react';
// Decorator<Args> behaves the same as DecoratorFn (without generic)
const withLocale: Decorator<Args> = (Story, { args }) => // args has type { [name: string]: any }
```
## From version 6.4.x to 6.5.0
### Vue 3 upgrade

View File

@ -1,7 +1,12 @@
<p align="center">
<a href="https://storybook.js.org/">
<img src="https://user-images.githubusercontent.com/321738/63501763-88dbf600-c4cc-11e9-96cd-94adadc2fd72.png" alt="Storybook" width="400" />
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/263385/199832481-bbbf5961-6a26-481d-8224-51258cce9b33.png">
<img src="https://user-images.githubusercontent.com/321738/63501763-88dbf600-c4cc-11e9-96cd-94adadc2fd72.png" alt="Storybook" width="400" />
</picture>
</a>
</p>
<p align="center">Build bulletproof UI components faster</p>

View File

@ -1,5 +1,4 @@
dist
lib/**/dll
build
coverage
node_modules

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -3,12 +3,5 @@
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -4,13 +4,5 @@
"rootDir": "./src",
"types": ["webpack-env"]
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,13 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -79,7 +79,7 @@
"@storybook/addons": "7.0.0-alpha.49",
"@storybook/client-logger": "7.0.0-alpha.49",
"@storybook/core-events": "7.0.0-alpha.49",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/router": "7.0.0-alpha.49",
"@storybook/types": "7.0.0-alpha.49",
"global": "^4.4.0",

View File

@ -14,7 +14,6 @@ jest.mock('global', () => ({
search: 'search',
},
},
// @ts-expect-error (Converted from ts-ignore)
window: global,
__STORYBOOK_STORY_STORE__: {
fromId: jest.fn(() => ({})),

View File

@ -5,9 +5,7 @@ import { linkTo, hrefTo } from './utils';
jest.mock('@storybook/addons');
jest.mock('global', () => ({
// @ts-expect-error (Converted from ts-ignore)
document: global.document,
// @ts-expect-error (Converted from ts-ignore)
window: global,
}));
@ -41,6 +39,7 @@ describe('preview', () => {
it('should select the story (only) provided', () => {
// simulate a currently selected, but not found as ID
// @ts-expect-error (not strict)
const handler = linkTo(undefined, 'name');
handler();

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -52,7 +52,6 @@ function integrityTest(integrityOptions: any, stories2snapsConverter: any) {
const snapshotExtension = stories2snapsConverter.getSnapshotExtension();
const storyshots = glob.sync(`**/*${snapshotExtension}`, integrityOptions);
// @ts-expect-error (Converted from ts-ignore)
expect(storyshots).notToBeAbandoned(stories2snapsConverter);
});
});

View File

@ -33,17 +33,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
setupAngularJestPreset();
const storybook = jest.requireActual('@storybook/angular');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/angular', () => {
const renderAPI = jest.requireActual('@storybook/angular');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/angular');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -52,7 +70,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for angular');
},
storybook: api,
storybook,
};
}

View File

@ -10,17 +10,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'html';
const storybook = jest.requireActual('@storybook/html');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/html', () => {
const renderAPI = jest.requireActual('@storybook/html');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/html');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -29,7 +47,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for HTML');
},
storybook: api,
storybook,
};
}

View File

@ -16,17 +16,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'preact';
const storybook = jest.requireActual('@storybook/preact');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/preact', () => {
const renderAPI = jest.requireActual('@storybook/preact');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/preact');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -35,7 +53,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for preact');
},
storybook: api,
storybook,
};
}

View File

@ -11,17 +11,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'rax';
const storybook = jest.requireActual('@storybook/rax');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/rax', () => {
const renderAPI = jest.requireActual('@storybook/rax');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/rax');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -30,7 +48,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for rax');
},
storybook: api,
storybook,
};
}

View File

@ -25,20 +25,14 @@ function configure(options: StoryshotsOptions, storybook: any) {
function load(options: StoryshotsOptions) {
const storybook = jest.requireActual('@storybook/react-native');
const clientAPI = jest.requireActual('@storybook/client-api');
const api = {
...clientAPI,
...storybook,
};
configure(options, api);
configure(options, storybook);
return {
renderTree: require('../react/renderTree').default,
renderShallowTree: require('../react/renderShallowTree').default,
framework: 'react-native' as const,
storybook: api,
storybook,
};
}

View File

@ -8,24 +8,42 @@ function test(options: StoryshotsOptions): boolean {
}
function load(options: StoryshotsOptions) {
const storybook = jest.requireActual('@storybook/react');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/react', () => {
const renderAPI = jest.requireActual('@storybook/react');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/react');
configure({
...options,
storybook: api,
storybook,
});
return {
framework: 'react' as const,
renderTree: jest.requireActual('./renderTree').default,
renderShallowTree: jest.requireActual('./renderShallowTree').default,
storybook: api,
storybook,
};
}

View File

@ -16,17 +16,35 @@ function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'riot';
mockRiotToIncludeCompiler();
const storybook = jest.requireActual('@storybook/riot');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/riot', () => {
const renderAPI = jest.requireActual('@storybook/riot');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/riot');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -35,7 +53,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for riot');
},
storybook: api,
storybook,
};
}

View File

@ -13,26 +13,43 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'svelte';
const storybook = jest.requireActual('@storybook/svelte');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/svelte', () => {
const renderAPI = jest.requireActual('@storybook/svelte');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/svelte');
configure({
...options,
storybook: api,
storybook,
});
return {
framework: 'svelte' as const,
renderTree: jest.requireActual('./renderTree').default,
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for svelte');
},
storybook: api,
storybook,
};
}

View File

@ -16,26 +16,43 @@ function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'vue';
mockVueToIncludeCompiler();
const storybook = jest.requireActual('@storybook/vue');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/vue', () => {
const renderAPI = jest.requireActual('@storybook/vue');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/vue');
configure({
...options,
storybook: api,
storybook,
});
return {
framework: 'vue' as const,
renderTree: jest.requireActual('./renderTree').default,
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for vue');
},
storybook: api,
storybook,
};
}

View File

@ -11,17 +11,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'vue3';
const storybook = jest.requireActual('@storybook/vue');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/vue3', () => {
const renderAPI = jest.requireActual('@storybook/vue3');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/vue3');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -30,7 +48,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for Vue 3');
},
storybook: api,
storybook,
};
}

View File

@ -10,17 +10,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'web-components';
const storybook = jest.requireActual('@storybook/html');
const clientAPI = jest.requireActual('@storybook/client-api');
let mockStartedAPI: any;
const api = {
...clientAPI,
...storybook,
};
jest.mock('@storybook/core-client', () => {
const coreClientAPI = jest.requireActual('@storybook/core-client');
return {
...coreClientAPI,
start: (...args: any[]) => {
mockStartedAPI = coreClientAPI.start(...args);
return mockStartedAPI;
},
};
});
jest.mock('@storybook/html', () => {
const renderAPI = jest.requireActual('@storybook/html');
renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
return renderAPI;
});
// eslint-disable-next-line global-require
const storybook = require('@storybook/html');
configure({
...options,
storybook: api,
storybook,
});
return {
@ -29,7 +47,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for web-components');
},
storybook: api,
storybook,
};
}

View File

@ -34,7 +34,7 @@
},
"dependencies": {
"@axe-core/puppeteer": "^4.2.0",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/node-logger": "7.0.0-alpha.49",
"@storybook/types": "7.0.0-alpha.49",
"@types/jest-image-snapshot": "^4.1.3",

View File

@ -5,6 +5,5 @@
"types": ["node"],
"declaration": true
},
"include": ["src/**/*"],
"exclude": []
"include": ["src/**/*"]
}

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -51,6 +51,7 @@
"@types/react": "^16.14.23",
"@types/react-dom": "^16.9.14",
"@types/semver": "^7.3.4",
"@types/webpack-env": "^1.18.0",
"core-js": "^3.8.2",
"find-up": "^5.0.0",
"global": "^4.4.0",

View File

@ -16,7 +16,7 @@ interface ClientApi extends Addon_ClientStoryApi<AngularRenderer['storyResult']>
load: (...args: any[]) => void;
}
const api = start(renderToCanvas, { decorateStory, render });
const api = start<AngularRenderer>(renderToCanvas, { decorateStory, render });
export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
return (api.clientApi.storiesOf(kind, m) as ReturnType<ClientApi['storiesOf']>).addParameters({

View File

@ -1,7 +1,18 @@
import { AnnotatedStoryFn, Args, ComponentAnnotations, StoryAnnotations } from '@storybook/types';
import {
AnnotatedStoryFn,
Args,
ComponentAnnotations,
DecoratorFunction,
LoaderFunction,
StoryAnnotations,
StoryContext as GenericStoryContext,
StrictArgs,
} from '@storybook/types';
import { AngularRenderer } from './types';
export type { Args, ArgTypes } from '@storybook/types';
export type { Args, ArgTypes, Parameters, StrictArgs } from '@storybook/types';
export type { Parameters as AngularParameters } from './types';
export type { AngularRenderer };
/**
* Metadata to configure the stories for a component.
@ -34,3 +45,7 @@ export type StoryObj<TArgs = Args> = StoryAnnotations<AngularRenderer, TArgs>;
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
export type Story<TArgs = Args> = StoryFn<TArgs>;
export type Decorator<TArgs = StrictArgs> = DecoratorFunction<AngularRenderer, TArgs>;
export type Loader<TArgs = StrictArgs> = LoaderFunction<AngularRenderer, TArgs>;
export type StoryContext<TArgs = StrictArgs> = GenericStoryContext<AngularRenderer, TArgs>;

View File

@ -1,9 +1,10 @@
import { start } from '@storybook/core-client';
import './globals';
import type { EmberRenderer } from './types';
import { renderToCanvas } from './render';
const { configure: coreConfigure, clientApi, forceReRender } = start(renderToCanvas);
const { configure: coreConfigure, clientApi, forceReRender } = start<EmberRenderer>(renderToCanvas);
export const { raw } = clientApi;

View File

@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
"include": ["src/**/*", "package.json"],
"exclude": ["src/**/*.test.*"]
"include": ["src/**/*", "package.json"]
}

View File

@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/__tests__/**/*"]
"include": ["src/**/*"]
}

View File

@ -82,7 +82,6 @@
},
"devDependencies": {
"@storybook/addon-actions": "7.0.0-alpha.49",
"@types/loader-utils": "^2.0.3",
"next": "^12.2.4",
"typescript": "~4.6.3",
"webpack": "^5.65.0"

View File

@ -1,3 +1,4 @@
// @ts-expect-error (loader-utils has no webpack5 compatible types)
import { interpolateName } from 'loader-utils';
import imageSizeOf from 'image-size';
import type { RawLoaderDefinition } from 'webpack';

View File

@ -5,6 +5,5 @@
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src/**/*", "template/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*", "template/**/*"]
}

View File

@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*"]
"include": ["src/**/*"]
}

View File

@ -5,6 +5,5 @@
"types": ["node"],
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*"]
}

View File

@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*"]
}

View File

@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": ["src/__tests__/**/*"]
"include": ["src/**/*"]
}

View File

@ -5,6 +5,5 @@
"types": ["node"],
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*"]
}

View File

@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*"]
"include": ["src/**/*"]
}

View File

@ -5,6 +5,5 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*"]
"include": ["src/**/*"]
}

View File

@ -5,6 +5,5 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*"]
"include": ["src/**/*"]
}

View File

@ -6,6 +6,5 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*"]
}

View File

@ -4,6 +4,5 @@
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*"]
"include": ["src/**/*"]
}

View File

@ -5,6 +5,5 @@
"types": ["node"],
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*"]
}

View File

@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/__tests__/**/*"]
"include": ["src/**/*"]
}

View File

@ -1,21 +1,17 @@
const os = require('os');
// TODO Revisit this test later, when we have a windows machine @valentinpalkovic
/**
* TODO: Some windows related tasks are still commented out, because they are behaving differently on
* a local Windows machine compared to the Windows Server 2022 machine running in GitHub Actions.
* The main issue is that path.sep is behaving differently on the two machines. Some more investagations
* are necessary!
* */
const skipOnWindows = [
'lib/core-server/src/utils/stories-json.test.ts',
'lib/core-server/src/utils/StoryIndexGenerator.test.ts',
'lib/cli/src/helpers.test.ts',
'lib/core-server/src/utils/__tests__/server-statics.test.ts',
'lib/core-common/src/utils/__tests__/template.test.ts',
'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
'lib/builder-manager/src/utils/files.test.ts',
'lib/cli/src/helpers.test.ts',
'lib/core-server/src/utils/__tests__/server-statics.test.ts',
'lib/core-common/src/utils/__tests__/template.test.ts',
'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
'lib/builder-manager/src/utils/files.test.ts',
];
module.exports = {

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -48,7 +48,7 @@
"@storybook/channels": "7.0.0-alpha.49",
"@storybook/client-logger": "7.0.0-alpha.49",
"@storybook/core-events": "7.0.0-alpha.49",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/router": "7.0.0-alpha.49",
"@storybook/theming": "7.0.0-alpha.49",
"@storybook/types": "7.0.0-alpha.49",

View File

@ -19,7 +19,7 @@ export interface SubAPI {
updateGlobals: (newGlobals: Globals) => void;
}
export const init: ModuleFn = ({ store, fullAPI }) => {
export const init: ModuleFn<SubAPI, SubState, true> = ({ store, fullAPI }) => {
const api: SubAPI = {
getGlobals() {
return store.getState().globals;

View File

@ -1,13 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src/**/*"]
}

View File

@ -1,17 +1,27 @@
import { platform } from 'os';
import { sanitizePath } from './files';
const os = platform();
const isWindows = os === 'win32';
test('sanitizePath', () => {
const addonsDir = '/Users/username/Projects/projectname/storybook';
const addonsDir = isWindows
? 'C:\\Users\\username\\Projects\\projectname\\storybook'
: '/Users/username/Projects/projectname/storybook';
const text = 'demo text';
const file = {
path: '/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs',
path: isWindows
? 'C:\\Users\\username\\Projects\\projectname\\storybook\\node_modules\\@storybook\\addon-x+y\\dist\\manager.mjs'
: '/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs',
contents: Uint8Array.from(Array.from(text).map((letter) => letter.charCodeAt(0))),
text,
};
const { location, url } = sanitizePath(file, addonsDir);
expect(location).toMatchInlineSnapshot(
`"/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs"`
expect(location).toEqual(
isWindows
? 'C:\\Users\\username\\Projects\\projectname\\storybook\\node_modules\\@storybook\\addon-x+y\\dist\\manager.mjs'
: '/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs'
);
expect(url).toMatchInlineSnapshot(
`"./sb-addons/node_modules/%40storybook/addon-x%2By/dist/manager.mjs"`

View File

@ -1,6 +1,6 @@
import type { OutputFile } from 'esbuild';
import fs from 'fs-extra';
import { join } from 'path';
import { join, normalize } from 'path';
import slash from 'slash';
import type { Compilation } from '../types';
@ -26,7 +26,8 @@ export async function readOrderedFiles(
export function sanitizePath(file: OutputFile, addonsDir: string) {
const filePath = file.path.replace(addonsDir, '');
const location = join(addonsDir, filePath);
const location = normalize(join(addonsDir, filePath));
const url = `./sb-addons${slash(filePath).split('/').map(encodeURIComponent).join('/')}`;
return { location, url };
}

View File

@ -4,6 +4,5 @@
"strict": true,
"skipLibCheck": true
},
"include": ["src/**/*", "typings.d.ts"],
"exclude": ["src/**.test.ts"]
"include": ["src/**/*", "typings.d.ts"]
}

View File

@ -1,5 +1,7 @@
import type { PreviewAnnotation } from '@storybook/types';
import { resolve } from 'path';
import slash from 'slash';
import { transformAbsPath } from './transform-abs-path';
/**
* Preview annotations can take several forms, and vite needs them to be
@ -21,7 +23,7 @@ export function processPreviewAnnotation(path: PreviewAnnotation | undefined) {
}
// resolve relative paths into absolute paths, but don't resolve "bare" imports
if (path?.startsWith('./') || path?.startsWith('../')) {
return resolve(path);
return slash(resolve(path));
}
// This should not occur, since we use `.filter(Boolean)` prior to
// calling this function, but this makes typescript happy
@ -29,5 +31,11 @@ export function processPreviewAnnotation(path: PreviewAnnotation | undefined) {
throw new Error('Could not determine path for previewAnnotation');
}
return path;
// For addon dependencies that use require.resolve(), we need to convert to a bare path
// so that vite will process it as a dependency (cjs -> esm, etc).
if (path.includes('node_modules')) {
return transformAbsPath(path);
}
return slash(path);
}

View File

@ -0,0 +1,11 @@
import path from 'path';
import { normalizePath } from 'vite';
// We need to convert from an absolute path, to a traditional node module import path,
// so that vite can correctly pre-bundle/optimize
export function transformAbsPath(absPath: string) {
const splits = absPath.split(`node_modules${path.sep}`);
// Return everything after the final "node_modules/"
const module = normalizePath(splits[splits.length - 1]);
return module;
}

View File

@ -5,6 +5,5 @@
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
"include": ["src/**/*"]
}

View File

@ -93,7 +93,6 @@
"webpack-virtual-modules": "^0.4.3"
},
"devDependencies": {
"@types/case-sensitive-paths-webpack-plugin": "^2.1.6",
"@types/terser-webpack-plugin": "^5.2.0",
"@types/webpack-dev-middleware": "^5.3.0",
"@types/webpack-hot-middleware": "^2.25.6",

View File

@ -2,6 +2,7 @@ import path from 'path';
import { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin, ProvidePlugin } from 'webpack';
import type { Configuration } from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
// @ts-expect-error (I removed this on purpose, because it's incorrect)
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import TerserWebpackPlugin from 'terser-webpack-plugin';
import VirtualModulePlugin from 'webpack-virtual-modules';

View File

@ -4,6 +4,5 @@
"strict": true,
"skipLibCheck": true
},
"include": ["src/**/*", "typings.d.ts", "templates/virtualModuleEntry.template.js"],
"exclude": ["src/**.test.ts"]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -8,7 +8,7 @@ import { RemovedAPIs, removedGlobalClientAPIs as migration } from './remove-glob
// eslint-disable-next-line global-require, jest/no-mocks-import
jest.mock('fs-extra', () => require('../../../../../__mocks__/fs-extra'));
const check = async ({ packageJson = {}, contents }) => {
const check = async ({ packageJson = {}, contents }: any) => {
if (contents) {
// eslint-disable-next-line global-require
require('fs-extra').__setMockFiles({

View File

@ -9,7 +9,7 @@ jest.mock('fs', () => ({
existsSync: jest.fn(),
}));
jest.mock('./dirs', () => ({
getRendererDir: (renderer) => `@storybook/${renderer}`,
getRendererDir: (renderer: string) => `@storybook/${renderer}`,
getCliDir: () => '@storybook/cli',
}));

View File

@ -198,6 +198,7 @@ export async function copyComponents(
const componentsPath = async () => {
const baseDir = getRendererDir(renderer);
const assetsDir = join(baseDir, 'template/cli');
const assetsLanguage = join(assetsDir, languageFolderMapping[language]);
const assetsJS = join(assetsDir, languageFolderMapping[SupportedLanguage.JAVASCRIPT]);
const assetsTSLegacy = join(
@ -232,7 +233,9 @@ export async function copyComponents(
};
const destinationPath = await targetPath();
await fse.copy(join(getCliDir(), 'rendererAssets/common'), destinationPath, { overwrite: true });
await fse.copy(join(getCliDir(), 'rendererAssets/common'), destinationPath, {
overwrite: true,
});
await fse.copy(await componentsPath(), destinationPath, { overwrite: true });
}

View File

@ -181,6 +181,7 @@ describe('NPM Proxy', () => {
const writePackageSpy = jest.spyOn(pnpmProxy, 'writePackageJson').mockImplementation(jest.fn);
jest.spyOn(pnpmProxy, 'retrievePackageJson').mockImplementation(
// @ts-expect-error (not strict)
jest.fn(() => ({
overrides: {
bar: 'x.x.x',

View File

@ -7,6 +7,5 @@
"strictNullChecks": false,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["templates/**/**", "**/*.test.*", "src/frameworks/**/*"]
"include": ["src/**/*"]
}

View File

@ -44,7 +44,7 @@
"dependencies": {
"@storybook/addons": "7.0.0-alpha.49",
"@storybook/client-logger": "7.0.0-alpha.49",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/store": "7.0.0-alpha.49",
"@storybook/types": "7.0.0-alpha.49",
"@types/qs": "^6.9.5",

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -38,7 +38,7 @@
},
"dependencies": {
"@babel/types": "^7.12.11",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/csf-tools": "7.0.0-alpha.49",
"@storybook/node-logger": "7.0.0-alpha.49",
"@storybook/types": "7.0.0-alpha.49",

View File

@ -1,11 +1,10 @@
import { describe } from '@jest/globals';
import { describe, it, expect } from '@jest/globals';
import { dedent } from 'ts-dedent';
import _transform from '../csf-2-to-3';
// @ts-expect-error (Converted from ts-ignore)
expect.addSnapshotSerializer({
print: (val: any) => val,
test: (val) => true,
test: () => true,
});
const jsTransform = (source: string) => _transform({ source }, null, {}).trim();

View File

@ -1,13 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src/**/*"]
}

View File

@ -42,7 +42,7 @@
"@storybook/client-api": "7.0.0-alpha.49",
"@storybook/client-logger": "7.0.0-alpha.49",
"@storybook/core-events": "7.0.0-alpha.49",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/preview-web": "7.0.0-alpha.49",
"@storybook/store": "7.0.0-alpha.49",
"@storybook/types": "7.0.0-alpha.49",

View File

@ -173,9 +173,9 @@ export const waitForEvents = (
events.forEach((event) => mockChannel.on(event, listener));
// Don't wait too long
waitForQuiescence().then(() =>
reject(new Error(`Event was not emitted in time: ${debugLabel || events}`))
);
waitForQuiescence().then(() => {
reject(new Error(`Event was not emitted in time: ${debugLabel || events}`));
});
});
};

View File

@ -1,5 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*", "typings.d.ts"],
"exclude": []
"include": ["src/**/*", "typings.d.ts"]
}

View File

@ -73,9 +73,9 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@types/mock-fs": "^4.13.0",
"@types/mock-fs": "^4.13.1",
"@types/picomatch": "^2.3.0",
"mock-fs": "^4.13.0",
"mock-fs": "^5.2.0",
"type-fest": "^2.17.0",
"typescript": "~4.6.3"
},

View File

@ -1,3 +1,5 @@
import './presets';
function wrapPreset(basePresets: any): { babel: Function; webpack: Function } {
return {
babel: async (config: any, args: any) => basePresets.apply('babel', config, args),

View File

@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": ["src/**.test.ts"]
"include": ["src/**/*"]
}

View File

@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": [
"src/**/*.test.*",
"src/**/tests/**/*",
"src/**/__tests__/**/*",
"src/**/*.stories.*",
"src/**/*.mockdata.*",
"src/**/__testfixtures__/**"
]
"include": ["src/**/*"]
}

View File

@ -39,7 +39,7 @@
"@storybook/core-client": "7.0.0-alpha.49",
"@storybook/core-common": "7.0.0-alpha.49",
"@storybook/core-events": "7.0.0-alpha.49",
"@storybook/csf": "0.0.2-next.5",
"@storybook/csf": "0.0.2-next.7",
"@storybook/csf-tools": "7.0.0-alpha.49",
"@storybook/docs-mdx": "0.0.1-canary.12433cf.0",
"@storybook/node-logger": "7.0.0-alpha.49",

View File

@ -19,6 +19,7 @@ import { buildStaticStandalone } from './build-static';
import { outputStats } from './utils/output-stats';
// @ts-expect-error (not strict)
const { SNAPSHOT_OS } = global;
const mkdtemp = promisify(mkdtempCb);
const { packageJson } = readUpSync({ cwd: __dirname });
@ -33,6 +34,7 @@ jest.mock('webpack', () => {
const actual = jest.requireActual('webpack');
Object.keys(actual).forEach((key) => {
// @ts-expect-error (not strict)
value[key] = actual[key];
});
return value;
@ -87,7 +89,9 @@ jest.mock('@storybook/store', () => {
});
jest.mock('http', () => ({
// @ts-expect-error (not strict)
...jest.requireActual('http'),
// @ts-expect-error (not strict)
createServer: () => ({ listen: (_options, cb) => cb(), on: jest.fn() }),
}));
jest.mock('ws');
@ -129,7 +133,7 @@ const baseOptions = {
const ROOT = getProjectRoot();
const CWD = process.cwd();
const NODE_MODULES = /.*node_modules/g;
const cleanRoots = (obj): any => {
const cleanRoots = (obj: any): any => {
if (!obj) return obj;
if (typeof obj === 'string')
return obj.replace(CWD, 'CWD').replace(ROOT, 'ROOT').replace(NODE_MODULES, 'NODE_MODULES');
@ -148,15 +152,18 @@ const cleanRoots = (obj): any => {
return obj;
};
const getConfig = (fn: any, name): Configuration | null => {
const call = fn.mock.calls.find((c) => c[0].name === name);
const getConfig = (fn: any, name: string): Configuration | null => {
const call = fn.mock.calls.find((c: any) => c[0].name === name);
if (!call) {
return null;
}
return call[0];
};
const prepareSnap = (get: any, name): Pick<Configuration, 'module' | 'entry' | 'plugins'> => {
const prepareSnap = (
get: any,
name: string
): Pick<Configuration, 'module' | 'entry' | 'plugins'> => {
const config = getConfig(get(), name);
if (!config) {
return null;
@ -173,7 +180,8 @@ const snap = (name: string) => `__snapshots__/${name}`;
// FIXME: we no longer have test cases
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('FIXME', () => {
describe.each([[]])('%s', (example) => {
// @ts-expect-error (not strict)
describe.each([[]])('%s', (example: string) => {
describe.each([
['manager', managerExecutor],
['preview', previewExecutor],
@ -209,8 +217,8 @@ describe.skip('FIXME', () => {
});
});
const progressPlugin = (config) =>
config.plugins.find((p) => p.constructor.name === 'ProgressPlugin');
const progressPlugin = (config: any) =>
config.plugins.find((p: any) => p.constructor.name === 'ProgressPlugin');
describe('dev cli flags', () => {
beforeEach(async () => {
@ -271,6 +279,7 @@ describe('dev cli flags', () => {
it('production mode', async () => {
expect.assertions(1);
// @ts-expect-error (not strict)
await expect(buildStaticStandalone(optionsWithInvalidStaticDir)).rejects.toThrow(
"Won't copy root directory. Check your staticDirs!"
);

View File

@ -1176,30 +1176,6 @@ describe('StoryIndexGenerator', () => {
expect(Object.keys((await generator.getIndex()).entries)).not.toContain('notitle--docs');
});
it('errors on dependency deletion', async () => {
const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
'./src/A.stories.(ts|js|jsx)',
options
);
const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
'./src/docs2/*.mdx',
options
);
const generator = new StoryIndexGenerator([docsSpecifier, storiesSpecifier], options);
await generator.initialize();
await generator.getIndex();
expect(toId).toHaveBeenCalledTimes(5);
expect(Object.keys((await generator.getIndex()).entries)).toContain('a--story-one');
generator.invalidate(storiesSpecifier, './src/A.stories.js', true);
await expect(() => generator.getIndex()).rejects.toThrowError(
/Could not find "..\/A.stories" for docs file/
);
});
it('cleans up properly on dependent docs deletion', async () => {
const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
'./src/A.stories.(ts|js|jsx)',

View File

@ -304,7 +304,12 @@ export class StoryIndexGenerator {
dependencies.forEach((dep) => {
if (dep.entries.length > 0) {
const first = dep.entries[0];
if (path.resolve(this.options.workingDir, first.importPath).startsWith(absoluteOf)) {
if (
path
.normalize(path.resolve(this.options.workingDir, first.importPath))
.startsWith(path.normalize(absoluteOf))
) {
ofTitle = first.title;
}
}
@ -485,11 +490,6 @@ export class StoryIndexGenerator {
}
});
});
const notFound = dependents.filter((dep) => !invalidated.has(dep));
if (notFound.length > 0) {
throw new Error(`Could not invalidate ${notFound.length} deps: ${notFound.join(', ')}`);
}
}
if (removed) {

View File

@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
"include": ["src/**/*"],
"exclude": ["src/**/**.test.ts", "src/**/**.disabled-test.ts"]
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src/**/*"]
}

View File

@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
"include": ["src/**/*"],
"exclude": ["src/**.test.ts"]
"include": ["src/**/*"]
}

View File

@ -20,7 +20,7 @@ export const unplugin = createUnplugin<CsfPluginOptions>((options) => {
const code = await fs.readFile(fname, 'utf-8');
try {
const csf = loadCsf(code, { makeTitle: (userTitle) => userTitle || 'default' }).parse();
enrichCsf(csf);
enrichCsf(csf, options);
return formatCsf(csf);
} catch (err: any) {
logger.warn(err.message);

Some files were not shown because too many files have changed in this diff Show More