mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 07:21:16 +08:00
Merge remote-tracking branch 'origin/next' into add-html-vite-framework
This commit is contained in:
commit
2cc33e0081
@ -358,7 +358,7 @@ jobs:
|
||||
executor:
|
||||
class: medium
|
||||
name: sb_playwright
|
||||
parallelism: 8
|
||||
parallelism: 9
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
|
1
.github/workflows/generate-repros-next.yml
vendored
1
.github/workflows/generate-repros-next.yml
vendored
@ -14,6 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
||||
CLEANUP_REPRO_NODE_MODULES: true
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
|
19
.vscode/settings.json
vendored
19
.vscode/settings.json
vendored
@ -1,4 +1,21 @@
|
||||
{
|
||||
"deepscan.enable": true,
|
||||
"typescript.tsdk": "./code/node_modules/typescript/lib"
|
||||
"eslint.workingDirectories": ["./code", "./scripts"],
|
||||
"typescript.tsdk": "./code/node_modules/typescript/lib",
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
}
|
||||
|
@ -1,54 +1,134 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
- Using welcoming and inclusive language
|
||||
- Being respectful of differing viewpoints and experiences
|
||||
- Gracefully accepting constructive criticism
|
||||
- Focusing on what is best for the community
|
||||
- Showing empathy towards other community members
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting one of the Steering committee members:
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting one of the Steering committee members for enforcement:
|
||||
|
||||
Norbert de Langen ~ @ndelangen - `ndelangen@me.com`
|
||||
Igor Davydkin ~ @igordv - `davydkin.igor@gmail.com`
|
||||
Tom Coleman ~ @tmeasday - `tom@thesnail.org`
|
||||
Michael Shilman ~ @shilman - `michael@lab80.co`
|
||||
Philip Riabchun ~ @hypnosphi - `talpa@yandex.ru`
|
||||
- Norbert de Langen ~ @ndelangen - `ndelangen@me.com`
|
||||
- Igor Davydkin ~ @igordv - `davydkin.igor@gmail.com`
|
||||
- Tom Coleman ~ @tmeasday - `tom@thesnail.org`
|
||||
- Michael Shilman ~ @shilman - `michael@lab80.co`
|
||||
- Philip Riabchun ~ @hypnosphi - `talpa@yandex.ru`
|
||||
|
||||
The steering committee will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
The steering committee will review and investigate all complaints and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
## Enforcement Guidelines
|
||||
|
||||
Project maintainers or community leaders who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
|
29
MIGRATION.md
29
MIGRATION.md
@ -360,7 +360,7 @@ Each addon is imported into the manager as an ESM module that's bundled separate
|
||||
|
||||
SB6.x framework packages shipped binaries called `start-storybook` and `build-storybook`.
|
||||
|
||||
In SB7.0, we've removed these binaries and replaced them with new commands in Storybook's CLI: `sb dev` and `sb build`. These commands will look for the `framework` field in your `.storybook/main.js` config--[which is now required](#framework-field-mandatory)--and use that to determine how to start/build your storybook. The benefit of this change is that it is now possible to install multiple frameworks in a project without having to worry about hoisting issues.
|
||||
In SB7.0, we've removed these binaries and replaced them with new commands in Storybook's CLI: `storybook dev` and `storybook build`. These commands will look for the `framework` field in your `.storybook/main.js` config--[which is now required](#framework-field-mandatory)--and use that to determine how to start/build your storybook. The benefit of this change is that it is now possible to install multiple frameworks in a project without having to worry about hoisting issues.
|
||||
|
||||
A typical storybook project includes two scripts in your projects `package.json`:
|
||||
|
||||
@ -463,8 +463,8 @@ module.exports = {
|
||||
framework: {
|
||||
name: '@storybook/react-webpack5',
|
||||
options: { fastRefresh: true },
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### Framework standalone build moved
|
||||
@ -657,12 +657,24 @@ You can configure Docs Page in `main.js`:
|
||||
```js
|
||||
module.exports = {
|
||||
docs: {
|
||||
docsPage: true, // set to false to disable docs page entirely
|
||||
docsPage: 'automatic', // see below for alternatives
|
||||
defaultName: 'Docs', // set to change the name of generated docs entries
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
If you are migrating from 6.x your `docs.docsPage` option will have been set to `'automatic'`, which has the effect of enabling docs page for _every_ CSF file. However, as of 7.0, the new default is `true`, which requires opting into DocsPage per-CSF file, with the `docsPage` **tag** on your component export:
|
||||
|
||||
```ts
|
||||
export default {
|
||||
component: MyComponent
|
||||
// Tags are a new feature coming in 7.1, that we are using to drive this behaviour.
|
||||
tags: ['docsPage']
|
||||
}
|
||||
```
|
||||
|
||||
You can also set `docsPage: false` to opt-out of docs page entirely.
|
||||
|
||||
You can change the default template in the same way as in 6.x, using the `docs.page` parameter.
|
||||
|
||||
#### Configuring the Docs Container
|
||||
@ -754,17 +766,16 @@ module.exports = {
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve('@storybook/source-loader'),
|
||||
options: {} /* your sourceLoaderOptions here */
|
||||
options: {} /* your sourceLoaderOptions here */,
|
||||
},
|
||||
],
|
||||
enforce: 'pre',
|
||||
})
|
||||
});
|
||||
return config;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
#### Dropped addon-docs manual configuration
|
||||
|
||||
Storybook Docs 5.x shipped with instructions for how to manually configure webpack and storybook without the use of Storybook's "presets" feature. Over time, these docs went out of sync. Now in Storybook 7 we have removed support for manual configuration entirely.
|
||||
|
@ -6,13 +6,11 @@ node_modules
|
||||
docs/public
|
||||
storybook-static
|
||||
built-storybooks
|
||||
lib/cli/test
|
||||
lib/codemod/src/transforms/__testfixtures__
|
||||
scripts/storage
|
||||
scripts/repros-generator
|
||||
*.bundle.js
|
||||
*.js.map
|
||||
*.d.ts
|
||||
examples/ember-cli/.storybook/preview-head.html
|
||||
examples/official-storybook/tests/addon-jest.test.js
|
||||
ember-output
|
||||
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"bracketSpacing": true,
|
||||
"trailingComma": "es5",
|
||||
"singleQuote": true,
|
||||
"arrowParens": "always"
|
||||
}
|
20
code/.vscode/settings.json
vendored
20
code/.vscode/settings.json
vendored
@ -1,3 +1,21 @@
|
||||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
"deepscan.enable": true,
|
||||
"eslint.workingDirectories": [".", "../scripts"],
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
"./react": {
|
||||
"require": "./dist/react/index.js",
|
||||
"import": "./dist/react/index.mjs",
|
||||
"types": "./dist/react.d.ts"
|
||||
"types": "./dist/react/index.d.ts"
|
||||
},
|
||||
"./register": {
|
||||
"require": "./dist/manager.js",
|
||||
|
4
code/addons/links/react.d.ts
vendored
4
code/addons/links/react.d.ts
vendored
@ -1,2 +1,2 @@
|
||||
export * from './dist/types/react';
|
||||
export { default } from './dist/types/react';
|
||||
export * from './dist/react';
|
||||
export { default } from './dist/react';
|
||||
|
@ -41,7 +41,7 @@
|
||||
"./preview": {
|
||||
"require": "./dist/preset/preview.js",
|
||||
"import": "./dist/preset/preview.mjs",
|
||||
"types": "./dist/preview.d.ts"
|
||||
"types": "./dist/preset/preview.d.ts"
|
||||
},
|
||||
"./register": {
|
||||
"require": "./dist/manager.js",
|
||||
|
@ -4,5 +4,4 @@ declare module 'preact-render-to-string/jsx';
|
||||
declare module 'react-test-renderer*';
|
||||
declare module 'rax-test-renderer*';
|
||||
|
||||
|
||||
declare module '@storybook/babel-plugin-require-context-hook/register';
|
||||
|
@ -5,6 +5,8 @@ import Button from './button.component';
|
||||
const meta: Meta<Button> = {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/angular/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args
|
||||
render: (args: Button) => ({
|
||||
props: {
|
||||
|
@ -8,6 +8,8 @@ import Header from './header.component';
|
||||
const meta: Meta<Header> = {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/angular/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => ({ props: args }),
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
|
@ -6,6 +6,8 @@ import { Button } from './Button';
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
|
@ -5,6 +5,8 @@ import { Header } from './Header';
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
||||
layout: 'fullscreen',
|
||||
|
@ -6,6 +6,8 @@ import { Button } from './Button';
|
||||
const meta: Meta<typeof Button> = {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
||||
argTypes: {
|
||||
backgroundColor: {
|
||||
|
@ -4,6 +4,8 @@ import { Header } from './Header';
|
||||
const meta: Meta<typeof Header> = {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
||||
layout: 'fullscreen',
|
||||
|
1
code/frameworks/react-vite/src/typings.d.ts
vendored
1
code/frameworks/react-vite/src/typings.d.ts
vendored
@ -2,6 +2,7 @@
|
||||
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
|
||||
declare module 'react-dom/client' {
|
||||
import React = require('react');
|
||||
|
||||
export interface HydrationOptions {
|
||||
onHydrated?(suspenseInstance: Comment): void;
|
||||
onDeleted?(suspenseInstance: Comment): void;
|
||||
|
@ -4,6 +4,7 @@ declare module 'global';
|
||||
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
|
||||
declare module 'react-dom/client' {
|
||||
import React = require('react');
|
||||
|
||||
export interface HydrationOptions {
|
||||
onHydrated?(suspenseInstance: Comment): void;
|
||||
onDeleted?(suspenseInstance: Comment): void;
|
||||
|
@ -66,7 +66,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "*",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
||||
"css-loader": "*",
|
||||
"vue": "^2.6.8",
|
||||
"vue-loader": "^15.7.0",
|
||||
|
@ -1,3 +1,3 @@
|
||||
declare module 'global';
|
||||
|
||||
declare module 'vue-loader/lib/plugin';
|
||||
declare module 'vue-loader/lib/plugin';
|
||||
|
@ -1,5 +1,5 @@
|
||||
declare module 'global';
|
||||
|
||||
declare module 'vue-loader' {
|
||||
export const VueLoaderPlugin: any
|
||||
export const VueLoaderPlugin: any;
|
||||
}
|
||||
|
10
code/lib/api/shortcut.d.ts
vendored
10
code/lib/api/shortcut.d.ts
vendored
@ -1,6 +1,8 @@
|
||||
export type KeyCollection = string[];
|
||||
|
||||
export function shortcutToHumanString(shortcut: KeyCollection): string
|
||||
export function eventToShortcut(e: KeyboardEvent): KeyCollection | null
|
||||
export function shortcutMatchesShortcut(inputShortcut: KeyCollection,
|
||||
shortcut: KeyCollection): boolean
|
||||
export function shortcutToHumanString(shortcut: KeyCollection): string;
|
||||
export function eventToShortcut(e: KeyboardEvent): KeyCollection | null;
|
||||
export function shortcutMatchesShortcut(
|
||||
inputShortcut: KeyCollection,
|
||||
shortcut: KeyCollection
|
||||
): boolean;
|
||||
|
@ -32,7 +32,7 @@ window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore
|
||||
|
||||
preview.initialize({ importFn, getProjectAnnotations });
|
||||
|
||||
if (module.hot) {
|
||||
if (import.meta.webpackHot) {
|
||||
import.meta.webpackHot.accept('./{{storiesFilename}}', () => {
|
||||
// importFn has changed so we need to patch the new one in
|
||||
preview.onStoriesChanged({ importFn });
|
||||
|
61
code/lib/cli/src/automigrate/fixes/docsPage-automatic.ts
Normal file
61
code/lib/cli/src/automigrate/fixes/docsPage-automatic.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import chalk from 'chalk';
|
||||
import { dedent } from 'ts-dedent';
|
||||
|
||||
import type { ConfigFile } from '@storybook/csf-tools';
|
||||
import { readConfig, writeConfig } from '@storybook/csf-tools';
|
||||
import { getStorybookInfo } from '@storybook/core-common';
|
||||
|
||||
import type { Fix } from '../types';
|
||||
|
||||
const logger = console;
|
||||
|
||||
interface DocsPageAutomaticFrameworkRunOptions {
|
||||
main: ConfigFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the docs.docsPage option to automatic if it isn't already set
|
||||
*/
|
||||
export const docsPageAutomatic: Fix<DocsPageAutomaticFrameworkRunOptions> = {
|
||||
id: 'docsPageAutomatic',
|
||||
|
||||
async check({ packageManager }) {
|
||||
const packageJson = packageManager.retrievePackageJson();
|
||||
|
||||
const { mainConfig } = getStorybookInfo(packageJson);
|
||||
|
||||
if (!mainConfig) {
|
||||
logger.warn('Unable to find storybook main.js config, skipping');
|
||||
return null;
|
||||
}
|
||||
|
||||
const main = await readConfig(mainConfig);
|
||||
const docs = main.getFieldValue(['docs']);
|
||||
|
||||
return docs?.docsPage === undefined ? { main } : null;
|
||||
},
|
||||
|
||||
prompt() {
|
||||
const docsPageAutomaticFormatted = chalk.cyan(`docs: { docsPage: 'automatic' }`);
|
||||
|
||||
return dedent`
|
||||
We've detected that your main.js configuration file has not configured docsPage. In 6.x we
|
||||
we defaulted to having a docsPage for every story, in 7.x you need to opt in per-component.
|
||||
However, we can set the \`docs.docsPage\` to 'automatic' to approximate the old behaviour:
|
||||
|
||||
${docsPageAutomaticFormatted}
|
||||
|
||||
More info: ${chalk.yellow(
|
||||
'https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#docs-page'
|
||||
)}
|
||||
`;
|
||||
},
|
||||
|
||||
async run({ result: { main }, dryRun }) {
|
||||
logger.info(`✅ Setting 'docs.docsPage' to 'automatic' in main.js`);
|
||||
if (!dryRun) {
|
||||
main.setFieldValue(['docsPage', 'docs'], 'automatic');
|
||||
await writeConfig(main);
|
||||
}
|
||||
},
|
||||
};
|
@ -12,6 +12,7 @@ import { sbScripts } from './sb-scripts';
|
||||
import { newFrameworks } from './new-frameworks';
|
||||
import { removedGlobalClientAPIs } from './remove-global-client-apis';
|
||||
import { mdx1to2 } from './mdx-1-to-2';
|
||||
import { docsPageAutomatic } from './docsPage-automatic';
|
||||
|
||||
export * from '../types';
|
||||
|
||||
@ -28,4 +29,5 @@ export const fixes: Fix[] = [
|
||||
newFrameworks,
|
||||
removedGlobalClientAPIs,
|
||||
mdx1to2,
|
||||
docsPageAutomatic,
|
||||
];
|
||||
|
@ -1,3 +1,4 @@
|
||||
import path from 'path';
|
||||
import fse from 'fs-extra';
|
||||
import { dedent } from 'ts-dedent';
|
||||
import type { NpmOptions } from '../NpmOptions';
|
||||
@ -191,9 +192,11 @@ export async function baseGenerator(
|
||||
|
||||
await configureMain({
|
||||
framework: { name: frameworkInclude, options: options.framework || {} },
|
||||
docs: { docsPage: true },
|
||||
addons: pnp ? addons.map(wrapForPnp) : addons,
|
||||
extensions,
|
||||
commonJs,
|
||||
...(staticDir ? { staticDirs: [path.join('..', staticDir)] } : null),
|
||||
...extraMain,
|
||||
...(type !== 'framework'
|
||||
? {
|
||||
@ -234,7 +237,6 @@ export async function baseGenerator(
|
||||
if (addScripts) {
|
||||
packageManager.addStorybookCommandInScripts({
|
||||
port: 6006,
|
||||
staticFolder: staticDir,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,14 @@ interface ConfigureMainOptions {
|
||||
addons: string[];
|
||||
extensions?: string[];
|
||||
commonJs?: boolean;
|
||||
staticDirs?: string[];
|
||||
/**
|
||||
* Extra values for main.js
|
||||
*
|
||||
* In order to provide non-serializable data like functions, you can use
|
||||
* { value: '%%yourFunctionCall()%%' }
|
||||
*
|
||||
* '%% and %%' will be replace.
|
||||
* '%% and %%' will be replaced.
|
||||
*
|
||||
*/
|
||||
[key: string]: any;
|
||||
|
@ -304,19 +304,11 @@ export abstract class JsPackageManager {
|
||||
return versions.reverse().find((version) => satisfies(version, constraint));
|
||||
}
|
||||
|
||||
public addStorybookCommandInScripts(options?: {
|
||||
port: number;
|
||||
staticFolder?: string;
|
||||
preCommand?: string;
|
||||
}) {
|
||||
public addStorybookCommandInScripts(options?: { port: number; preCommand?: string }) {
|
||||
const sbPort = options?.port ?? 6006;
|
||||
const storybookCmd = options?.staticFolder
|
||||
? `storybook dev -p ${sbPort} -s ${options.staticFolder}`
|
||||
: `storybook dev -p ${sbPort}`;
|
||||
const storybookCmd = `storybook dev -p ${sbPort}`;
|
||||
|
||||
const buildStorybookCmd = options?.staticFolder
|
||||
? `storybook build -s ${options.staticFolder}`
|
||||
: `storybook build`;
|
||||
const buildStorybookCmd = `storybook build`;
|
||||
|
||||
const preCommand = options?.preCommand ? this.getRunCommand(options.preCommand) : undefined;
|
||||
this.addScripts({
|
||||
|
@ -282,8 +282,6 @@ const vueCliTemplates = {
|
||||
skipTasks: [
|
||||
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
|
||||
'smoke-test',
|
||||
// Re-enable once https://github.com/storybookjs/storybook/issues/19453 is fixed.
|
||||
'test-runner',
|
||||
],
|
||||
expected: {
|
||||
framework: '@storybook/vue3-webpack5',
|
||||
@ -299,8 +297,6 @@ const vueCliTemplates = {
|
||||
skipTasks: [
|
||||
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
|
||||
'smoke-test',
|
||||
// Re-enable once https://github.com/storybookjs/storybook/issues/19453 is fixed.
|
||||
'test-runner',
|
||||
],
|
||||
expected: {
|
||||
framework: '@storybook/vue-webpack5',
|
||||
|
@ -10,7 +10,6 @@ const CLI_PATH = path.join(__dirname, '..', 'bin');
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
const run = (args, options = {}) =>
|
||||
spawnSync('node', [CLI_PATH].concat(args), options);
|
||||
const run = (args, options = {}) => spawnSync('node', [CLI_PATH].concat(args), options);
|
||||
|
||||
module.exports = run;
|
||||
|
@ -191,12 +191,12 @@ export class StoryStoreFacade<TFramework extends AnyFramework> {
|
||||
|
||||
// NOTE: this logic is equivalent to the `extractStories` function of `StoryIndexGenerator`
|
||||
const docsOptions = (global.DOCS_OPTIONS || {}) as DocsOptions;
|
||||
const docsPageOptedIn =
|
||||
docsOptions.docsPage === 'automatic' ||
|
||||
(docsOptions.docsPage && componentTags.includes('docsPage'));
|
||||
if (docsOptions.enabled && storyExports.length) {
|
||||
// We will use tags soon and this crappy filename test will go away
|
||||
if (
|
||||
fileName.match(/\.mdx$/) ||
|
||||
(docsOptions.docsPage && componentTags.includes('docsPage'))
|
||||
) {
|
||||
if (fileName.match(/\.mdx$/) || docsPageOptedIn) {
|
||||
const name = docsOptions.defaultName;
|
||||
const docsId = toId(componentId || title, name);
|
||||
this.entries[docsId] = {
|
||||
|
@ -11,4 +11,6 @@ export {
|
||||
setGlobalRender,
|
||||
} from './ClientApi';
|
||||
|
||||
export * from '@storybook/store';
|
||||
|
||||
export * from './queryparams';
|
||||
|
@ -46,7 +46,7 @@
|
||||
"globby": "^11.0.2",
|
||||
"jscodeshift": "^0.13.1",
|
||||
"lodash": "^4.17.21",
|
||||
"prettier": ">=2.2.1 <=2.3.0",
|
||||
"prettier": ">=2.2.1 <=3.0.0",
|
||||
"recast": "^0.19.0",
|
||||
"util": "^0.12.4"
|
||||
},
|
||||
|
@ -1295,6 +1295,50 @@ describe('start', () => {
|
||||
`);
|
||||
});
|
||||
});
|
||||
describe('when docsOptions.docsPage = automatic', () => {
|
||||
beforeEach(() => {
|
||||
global.DOCS_OPTIONS = { enabled: true, docsPage: 'automatic', defaultName: 'Docs' };
|
||||
});
|
||||
|
||||
it('adds stories for each component with docsPage tag', async () => {
|
||||
const renderToDOM = jest.fn();
|
||||
|
||||
const { configure, clientApi } = start(renderToDOM);
|
||||
configure('test', () => {
|
||||
(clientApi as any).addParameters({
|
||||
docs: { renderer: () => ({ render: jest.fn((_, _2, _3, d) => d()) }) },
|
||||
});
|
||||
clientApi
|
||||
.storiesOf('Component A', { id: 'file1' } as NodeModule)
|
||||
.add('Story One', jest.fn())
|
||||
.add('Story Two', jest.fn());
|
||||
|
||||
clientApi
|
||||
.storiesOf('Component B', { id: 'file2' } as NodeModule)
|
||||
.addParameters({ tags: ['docsPage'] })
|
||||
.add('Story Three', jest.fn());
|
||||
|
||||
return [componentCExports];
|
||||
});
|
||||
|
||||
await waitForRender();
|
||||
const setIndexData = mockChannel.emit.mock.calls.find(
|
||||
(call: [string, any]) => call[0] === SET_INDEX
|
||||
)[1];
|
||||
expect(Object.keys(setIndexData.entries)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"component-a--docs",
|
||||
"component-a--story-one",
|
||||
"component-a--story-two",
|
||||
"component-b--docs",
|
||||
"component-b--story-three",
|
||||
"component-c--docs",
|
||||
"component-c--story-one",
|
||||
"component-c--story-two",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('auto-title', () => {
|
||||
|
2
code/lib/core-common/src/test-typings.d.ts
vendored
2
code/lib/core-common/src/test-typings.d.ts
vendored
@ -2,4 +2,4 @@ declare namespace jest {
|
||||
interface Matchers<R> {
|
||||
toMatchPaths(paths: string[]): R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -441,6 +441,39 @@ describe('StoryIndexGenerator', () => {
|
||||
`);
|
||||
});
|
||||
|
||||
it('generates an entry for every CSF file when docsOptions.docsPage = automatic', async () => {
|
||||
const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/**/*.stories.(ts|js|jsx)',
|
||||
options
|
||||
);
|
||||
|
||||
const generator = new StoryIndexGenerator([specifier], {
|
||||
...docsPageOptions,
|
||||
docs: {
|
||||
...docsPageOptions.docs,
|
||||
docsPage: 'automatic',
|
||||
},
|
||||
});
|
||||
await generator.initialize();
|
||||
|
||||
expect(Object.keys((await generator.getIndex()).entries)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"a--docs",
|
||||
"a--story-one",
|
||||
"b--docs",
|
||||
"b--story-one",
|
||||
"d--docs",
|
||||
"d--story-one",
|
||||
"first-nested-deeply-f--docs",
|
||||
"first-nested-deeply-f--story-one",
|
||||
"nested-button--docs",
|
||||
"nested-button--story-one",
|
||||
"second-nested-g--docs",
|
||||
"second-nested-g--story-one",
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('does not generate a docs page entry if there is a standalone entry with the same name', async () => {
|
||||
const csfSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
|
||||
'./src/A.stories.js',
|
||||
|
@ -224,12 +224,12 @@ export class StoryIndexGenerator {
|
||||
});
|
||||
|
||||
if (this.options.docs.enabled && csf.stories.length) {
|
||||
const { docsPage } = this.options.docs;
|
||||
const docsPageOptedIn =
|
||||
docsPage === 'automatic' || (docsPage && componentTags.includes('docsPage'));
|
||||
// We always add a template for *.stories.mdx, but only if docs page is enabled for
|
||||
// regular CSF files
|
||||
if (
|
||||
storyIndexer.addDocsTemplate ||
|
||||
(this.options.docs.docsPage && componentTags.includes('docsPage'))
|
||||
) {
|
||||
if (storyIndexer.addDocsTemplate || docsPageOptedIn) {
|
||||
const name = this.options.docs.defaultName;
|
||||
const id = toId(csf.meta.title, name);
|
||||
entries.unshift({
|
||||
|
@ -1,3 +1,5 @@
|
||||
/// <reference types="@types/jest" />;
|
||||
|
||||
import { dedent } from 'ts-dedent';
|
||||
import { formatConfig, loadConfig } from './ConfigFile';
|
||||
|
||||
@ -83,6 +85,7 @@ describe('ConfigFile', () => {
|
||||
).toEqual('webpack5');
|
||||
});
|
||||
});
|
||||
|
||||
describe('module exports', () => {
|
||||
it('missing export', () => {
|
||||
expect(
|
||||
@ -142,6 +145,66 @@ describe('ConfigFile', () => {
|
||||
).toEqual([{ directory: '../src', titlePrefix: 'Demo' }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('default export', () => {
|
||||
it('missing export', () => {
|
||||
expect(
|
||||
getField(
|
||||
['core', 'builder'],
|
||||
dedent`
|
||||
export default { foo: { builder: 'webpack5' } }
|
||||
`
|
||||
)
|
||||
).toBeUndefined();
|
||||
});
|
||||
it('found scalar', () => {
|
||||
expect(
|
||||
getField(
|
||||
['core', 'builder'],
|
||||
dedent`
|
||||
export default { core: { builder: 'webpack5' } }
|
||||
`
|
||||
)
|
||||
).toEqual('webpack5');
|
||||
});
|
||||
it('variable ref export', () => {
|
||||
expect(
|
||||
getField(
|
||||
['core', 'builder'],
|
||||
dedent`
|
||||
const core = { builder: 'webpack5' };
|
||||
export default { core };
|
||||
`
|
||||
)
|
||||
).toEqual('webpack5');
|
||||
});
|
||||
it('variable rename', () => {
|
||||
expect(
|
||||
getField(
|
||||
['core', 'builder'],
|
||||
dedent`
|
||||
const coreVar = { builder: 'webpack5' };
|
||||
export default { core: coreVar };
|
||||
`
|
||||
)
|
||||
).toEqual('webpack5');
|
||||
});
|
||||
it('variable exports', () => {
|
||||
expect(
|
||||
getField(
|
||||
['stories'],
|
||||
dedent`
|
||||
import type { StorybookConfig } from '@storybook/react-webpack5';
|
||||
|
||||
const config: StorybookConfig = {
|
||||
stories: [{ directory: '../src', titlePrefix: 'Demo' }],
|
||||
}
|
||||
export default config;
|
||||
`
|
||||
)
|
||||
).toEqual([{ directory: '../src', titlePrefix: 'Demo' }]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('setField', () => {
|
||||
@ -228,6 +291,7 @@ describe('ConfigFile', () => {
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('module exports', () => {
|
||||
it('missing export', () => {
|
||||
expect(
|
||||
@ -283,6 +347,63 @@ describe('ConfigFile', () => {
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('default export', () => {
|
||||
it('missing export', () => {
|
||||
expect(
|
||||
setField(
|
||||
['core', 'builder'],
|
||||
'webpack5',
|
||||
dedent`
|
||||
export default { addons: [] };
|
||||
`
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
export default {
|
||||
addons: [],
|
||||
core: {
|
||||
builder: "webpack5"
|
||||
}
|
||||
};
|
||||
`);
|
||||
});
|
||||
it('missing field', () => {
|
||||
expect(
|
||||
setField(
|
||||
['core', 'builder'],
|
||||
'webpack5',
|
||||
dedent`
|
||||
export default { core: { foo: 'bar' }};
|
||||
`
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
export default {
|
||||
core: {
|
||||
foo: 'bar',
|
||||
builder: 'webpack5'
|
||||
}
|
||||
};
|
||||
`);
|
||||
});
|
||||
it('found scalar', () => {
|
||||
expect(
|
||||
setField(
|
||||
['core', 'builder'],
|
||||
'webpack5',
|
||||
dedent`
|
||||
export default { core: { builder: 'webpack4' } };
|
||||
`
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
export default {
|
||||
core: {
|
||||
builder: 'webpack5'
|
||||
}
|
||||
};
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('quotes', () => {
|
||||
it('no quotes', () => {
|
||||
expect(setField(['foo', 'bar'], 'baz', '')).toMatchInlineSnapshot(`
|
||||
|
@ -108,6 +108,30 @@ export class ConfigFile {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
traverse.default(this._ast, {
|
||||
ExportDefaultDeclaration: {
|
||||
enter({ node, parent }) {
|
||||
const decl =
|
||||
t.isIdentifier(node.declaration) && t.isProgram(parent)
|
||||
? _findVarInitialization(node.declaration.name, parent)
|
||||
: node.declaration;
|
||||
|
||||
if (t.isObjectExpression(decl)) {
|
||||
self._exportsObject = decl;
|
||||
decl.properties.forEach((p: t.ObjectProperty) => {
|
||||
const exportName = propKey(p);
|
||||
if (exportName) {
|
||||
let exportVal = p.value;
|
||||
if (t.isIdentifier(exportVal)) {
|
||||
exportVal = _findVarInitialization(exportVal.name, parent as t.Program);
|
||||
}
|
||||
self._exports[exportName] = exportVal as t.Expression;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
logger.warn(`Unexpected ${JSON.stringify(node)}`);
|
||||
}
|
||||
},
|
||||
},
|
||||
ExportNamedDeclaration: {
|
||||
enter({ node, parent }) {
|
||||
if (t.isVariableDeclaration(node.declaration)) {
|
||||
|
2
code/lib/source-loader/extract-source.d.ts
vendored
2
code/lib/source-loader/extract-source.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// DEPRECATED
|
||||
// Do not import @storybook/source-loader/extract-source directly.
|
||||
// Import @storybook/source-loader instead.
|
||||
export * from './dist/types/extract-source.d';
|
||||
export * from './dist/index';
|
||||
|
@ -47,7 +47,7 @@
|
||||
"@storybook/types": "7.0.0-alpha.47",
|
||||
"estraverse": "^5.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"prettier": ">=2.2.1 <=2.3.0"
|
||||
"prettier": ">=2.2.1 <=3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest-specific-snapshot": "^4.0.0",
|
||||
|
@ -1,6 +1,37 @@
|
||||
import { SHARED_STATE_CHANGED, SHARED_STATE_SET } from '@storybook/core-events';
|
||||
|
||||
import { addons, useMemo, useState, useEffect, useChannel } from '@storybook/addons';
|
||||
import {
|
||||
addons,
|
||||
HooksContext,
|
||||
applyHooks,
|
||||
useMemo,
|
||||
useCallback,
|
||||
useRef,
|
||||
useState,
|
||||
useReducer,
|
||||
useEffect,
|
||||
useChannel,
|
||||
useStoryContext,
|
||||
useParameter,
|
||||
useArgs,
|
||||
useGlobals,
|
||||
} from '@storybook/addons';
|
||||
|
||||
export {
|
||||
HooksContext,
|
||||
applyHooks,
|
||||
useMemo,
|
||||
useCallback,
|
||||
useRef,
|
||||
useState,
|
||||
useReducer,
|
||||
useEffect,
|
||||
useChannel,
|
||||
useStoryContext,
|
||||
useParameter,
|
||||
useArgs,
|
||||
useGlobals,
|
||||
};
|
||||
|
||||
export function useSharedState<S>(sharedId: string, defaultState?: S): [S, (s: S) => void] {
|
||||
const channel = addons.getChannel();
|
||||
|
50
code/lib/telemetry/src/get-framework-info.ts
Normal file
50
code/lib/telemetry/src/get-framework-info.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import type { PackageJson, StorybookConfig } from '@storybook/types';
|
||||
import { getActualPackageJson } from './package-json';
|
||||
|
||||
const knownRenderers = [
|
||||
'html',
|
||||
'react',
|
||||
'svelte',
|
||||
'vue3',
|
||||
'preact',
|
||||
'server',
|
||||
'vue',
|
||||
'web-components',
|
||||
'angular',
|
||||
'ember',
|
||||
];
|
||||
|
||||
const knownBuilders = ['builder-webpack5', 'builder-vite'];
|
||||
|
||||
function findMatchingPackage(packageJson: PackageJson, suffixes: string[]) {
|
||||
const { name = '', version, dependencies, devDependencies, peerDependencies } = packageJson;
|
||||
|
||||
const allDependencies = {
|
||||
// We include the framework itself because it may be a renderer too (e.g. angular)
|
||||
[name]: version,
|
||||
...dependencies,
|
||||
...devDependencies,
|
||||
...peerDependencies,
|
||||
};
|
||||
|
||||
return suffixes.map((suffix) => `@storybook/${suffix}`).find((pkg) => allDependencies[pkg]);
|
||||
}
|
||||
|
||||
export async function getFrameworkInfo(mainConfig: StorybookConfig) {
|
||||
const { framework: frameworkInput } = mainConfig;
|
||||
|
||||
if (!frameworkInput) return {};
|
||||
|
||||
const framework = typeof frameworkInput === 'string' ? { name: frameworkInput } : frameworkInput;
|
||||
|
||||
const frameworkPackageJson = await getActualPackageJson(framework.name);
|
||||
|
||||
const builder = findMatchingPackage(frameworkPackageJson, knownBuilders);
|
||||
const renderer = findMatchingPackage(frameworkPackageJson, knownRenderers);
|
||||
|
||||
return {
|
||||
framework,
|
||||
builder,
|
||||
renderer,
|
||||
};
|
||||
}
|
@ -9,8 +9,7 @@ export const getActualPackageVersions = async (packages: Record<string, Partial<
|
||||
|
||||
export const getActualPackageVersion = async (packageName: string) => {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-dynamic-require,global-require
|
||||
const packageJson = require(path.join(packageName, 'package.json'));
|
||||
const packageJson = await getActualPackageJson(packageName);
|
||||
return {
|
||||
name: packageName,
|
||||
version: packageJson.version,
|
||||
@ -19,3 +18,9 @@ export const getActualPackageVersion = async (packageName: string) => {
|
||||
return { name: packageName, version: null };
|
||||
}
|
||||
};
|
||||
|
||||
export const getActualPackageJson = async (packageName: string) => {
|
||||
// eslint-disable-next-line import/no-dynamic-require,global-require
|
||||
const packageJson = require(path.join(packageName, 'package.json'));
|
||||
return packageJson;
|
||||
};
|
@ -12,7 +12,7 @@ const mainJsMock: StorybookConfig = {
|
||||
stories: [],
|
||||
};
|
||||
|
||||
jest.mock('./package-versions', () => {
|
||||
jest.mock('./package-json', () => {
|
||||
const getActualPackageVersion = jest.fn((name) =>
|
||||
Promise.resolve({
|
||||
name,
|
||||
@ -24,9 +24,17 @@ jest.mock('./package-versions', () => {
|
||||
Promise.all(Object.keys(packages).map(getActualPackageVersion))
|
||||
);
|
||||
|
||||
const getActualPackageJson = jest.fn((name) => ({
|
||||
dependencies: {
|
||||
'@storybook/react': 'x.x.x',
|
||||
'@storybook/builder-vite': 'x.x.x',
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
getActualPackageVersions,
|
||||
getActualPackageVersion,
|
||||
getActualPackageJson,
|
||||
};
|
||||
});
|
||||
|
||||
@ -96,40 +104,39 @@ describe('sanitizeAddonName', () => {
|
||||
describe('await computeStorybookMetadata', () => {
|
||||
test('should return frameworkOptions from mainjs', async () => {
|
||||
const reactResult = await computeStorybookMetadata({
|
||||
packageJson: {
|
||||
...packageJsonMock,
|
||||
devDependencies: {
|
||||
'@storybook/react': 'x.x.x',
|
||||
},
|
||||
},
|
||||
packageJson: packageJsonMock,
|
||||
mainConfig: {
|
||||
...mainJsMock,
|
||||
reactOptions: {
|
||||
fastRefresh: false,
|
||||
framework: {
|
||||
name: '@storybook/react-vite',
|
||||
options: {
|
||||
fastRefresh: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(reactResult.framework).toEqual({ name: 'react', options: { fastRefresh: false } });
|
||||
expect(reactResult.framework).toEqual({
|
||||
name: '@storybook/react-vite',
|
||||
options: { fastRefresh: false },
|
||||
});
|
||||
|
||||
const angularResult = await computeStorybookMetadata({
|
||||
packageJson: {
|
||||
...packageJsonMock,
|
||||
devDependencies: {
|
||||
'@storybook/angular': 'x.x.x',
|
||||
},
|
||||
},
|
||||
packageJson: packageJsonMock,
|
||||
mainConfig: {
|
||||
...mainJsMock,
|
||||
angularOptions: {
|
||||
enableIvy: true,
|
||||
enableNgcc: true,
|
||||
framework: {
|
||||
name: '@storybook/angular',
|
||||
options: {
|
||||
enableIvy: true,
|
||||
enableNgcc: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(angularResult.framework).toEqual({
|
||||
name: 'angular',
|
||||
name: '@storybook/angular',
|
||||
options: { enableIvy: true, enableNgcc: true },
|
||||
});
|
||||
});
|
||||
@ -196,40 +203,20 @@ describe('await computeStorybookMetadata', () => {
|
||||
expect(result.features).toEqual(features);
|
||||
});
|
||||
|
||||
test('should handle different types of builders', async () => {
|
||||
const simpleBuilder = 'webpack4';
|
||||
const complexBuilder = {
|
||||
name: 'webpack5',
|
||||
options: {
|
||||
lazyCompilation: true,
|
||||
},
|
||||
};
|
||||
test('should infer builder and renderer from framework package.json', async () => {
|
||||
expect(
|
||||
(
|
||||
await computeStorybookMetadata({
|
||||
packageJson: packageJsonMock,
|
||||
mainConfig: {
|
||||
...mainJsMock,
|
||||
core: {
|
||||
builder: complexBuilder,
|
||||
},
|
||||
},
|
||||
})
|
||||
).builder
|
||||
).toEqual(complexBuilder);
|
||||
expect(
|
||||
(
|
||||
await computeStorybookMetadata({
|
||||
packageJson: packageJsonMock,
|
||||
mainConfig: {
|
||||
...mainJsMock,
|
||||
core: {
|
||||
builder: simpleBuilder,
|
||||
},
|
||||
},
|
||||
})
|
||||
).builder
|
||||
).toEqual({ name: simpleBuilder });
|
||||
await computeStorybookMetadata({
|
||||
packageJson: packageJsonMock,
|
||||
mainConfig: {
|
||||
...mainJsMock,
|
||||
framework: '@storybook/react-vite',
|
||||
},
|
||||
})
|
||||
).toMatchObject({
|
||||
framework: { name: '@storybook/react-vite' },
|
||||
renderer: '@storybook/react',
|
||||
builder: '@storybook/builder-vite',
|
||||
});
|
||||
});
|
||||
|
||||
test('should return the number of refs', async () => {
|
||||
|
@ -9,9 +9,10 @@ import {
|
||||
import type { StorybookConfig, PackageJson } from '@storybook/types';
|
||||
|
||||
import type { StorybookMetadata, Dependency, StorybookAddon } from './types';
|
||||
import { getActualPackageVersion, getActualPackageVersions } from './package-versions';
|
||||
import { getActualPackageVersion, getActualPackageVersions } from './package-json';
|
||||
import { getMonorepoType } from './get-monorepo-type';
|
||||
import { cleanPaths } from './sanitize';
|
||||
import { getFrameworkInfo } from './get-framework-info';
|
||||
|
||||
export const metaFrameworks = {
|
||||
next: 'Next',
|
||||
@ -23,31 +24,6 @@ export const metaFrameworks = {
|
||||
'@sveltejs/kit': 'svelte-kit',
|
||||
} as Record<string, string>;
|
||||
|
||||
// @TODO: This should be removed in 7.0 as the framework.options field in main.js will replace this
|
||||
const getFrameworkOptions = (mainConfig: any) => {
|
||||
const possibleOptions = [
|
||||
'angular',
|
||||
'ember',
|
||||
'html',
|
||||
'preact',
|
||||
'react',
|
||||
'server',
|
||||
'svelte',
|
||||
'vue',
|
||||
'vue3',
|
||||
'webComponents',
|
||||
].map((opt) => `${opt}Options`);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const opt of possibleOptions) {
|
||||
if (opt in mainConfig) {
|
||||
return mainConfig[opt] as any;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const sanitizeAddonName = (name: string) => {
|
||||
return cleanPaths(name)
|
||||
.replace(/\/dist\/.*/, '')
|
||||
@ -68,7 +44,6 @@ export const computeStorybookMetadata = async ({
|
||||
}): Promise<StorybookMetadata> => {
|
||||
const metadata: Partial<StorybookMetadata> = {
|
||||
generatedAt: new Date().getTime(),
|
||||
builder: { name: 'webpack5' },
|
||||
hasCustomBabel: false,
|
||||
hasCustomWebpack: false,
|
||||
hasStaticDirs: false,
|
||||
@ -118,14 +93,7 @@ export const computeStorybookMetadata = async ({
|
||||
metadata.typescriptOptions = mainConfig.typescript;
|
||||
}
|
||||
|
||||
if (mainConfig.core?.builder) {
|
||||
const { builder } = mainConfig.core;
|
||||
|
||||
metadata.builder = {
|
||||
name: typeof builder === 'string' ? builder : builder.name,
|
||||
options: typeof builder === 'string' ? undefined : builder?.options ?? undefined,
|
||||
};
|
||||
}
|
||||
const frameworkInfo = await getFrameworkInfo(mainConfig);
|
||||
|
||||
if (mainConfig.refs) {
|
||||
metadata.refCount = Object.keys(mainConfig.refs).length;
|
||||
@ -181,22 +149,16 @@ export const computeStorybookMetadata = async ({
|
||||
|
||||
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook'];
|
||||
|
||||
// FIXME: resolve framework/renderer split in 7.0
|
||||
// OR should be getting this from mainConfig instead?
|
||||
const storybookInfo = getStorybookInfo(packageJson);
|
||||
|
||||
const storybookVersion =
|
||||
storybookPackages[storybookInfo.frameworkPackage]?.version || storybookInfo.version;
|
||||
|
||||
return {
|
||||
...metadata,
|
||||
...frameworkInfo,
|
||||
storybookVersion,
|
||||
language,
|
||||
storybookPackages,
|
||||
framework: {
|
||||
name: storybookInfo.framework,
|
||||
options: getFrameworkOptions(mainConfig),
|
||||
},
|
||||
addons,
|
||||
hasStorybookEslint,
|
||||
};
|
||||
|
@ -17,14 +17,12 @@ export type StorybookMetadata = {
|
||||
storybookVersion: string;
|
||||
generatedAt?: number;
|
||||
language: 'typescript' | 'javascript';
|
||||
framework: {
|
||||
framework?: {
|
||||
name: string;
|
||||
options?: any;
|
||||
};
|
||||
builder?: {
|
||||
name: string;
|
||||
options?: Record<string, any>;
|
||||
};
|
||||
builder?: string;
|
||||
renderer?: string;
|
||||
monorepo?: MonorepoType;
|
||||
packageManager?: {
|
||||
type: PM;
|
||||
|
@ -1,5 +1,6 @@
|
||||
// this file is only actually used in development
|
||||
// for prod/dist bundles we are bundling Emotion into our package
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import '@emotion/react';
|
||||
|
||||
|
2
code/lib/theming/src/typings.d.ts
vendored
2
code/lib/theming/src/typings.d.ts
vendored
@ -1,3 +1,3 @@
|
||||
// todo the following packages need definition files or a TS migration
|
||||
declare module 'react-inspector';
|
||||
declare module 'global';
|
||||
declare module 'global';
|
||||
|
@ -296,9 +296,10 @@ export type DocsOptions = {
|
||||
*/
|
||||
defaultName?: string;
|
||||
/**
|
||||
* Should we generate a docs entry per CSF file?
|
||||
* Should we generate a docs entry per CSF file with the `docsPage` tag?
|
||||
* Set to 'automatic' to generate an entry irrespective of tag.
|
||||
*/
|
||||
docsPage?: boolean;
|
||||
docsPage?: boolean | 'automatic';
|
||||
/**
|
||||
* Only show doc entries in the side bar (usually set with the `--docs` CLI flag)
|
||||
*/
|
||||
|
43
code/presets/react-webpack/src/typings.d.ts
vendored
43
code/presets/react-webpack/src/typings.d.ts
vendored
@ -3,29 +3,29 @@ declare module 'global';
|
||||
// TODO: Replace, as soon as @types/react-dom 17.0.14 is used
|
||||
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
|
||||
declare module 'react-dom/client' {
|
||||
|
||||
import React = require('react');
|
||||
import React = require('react');
|
||||
|
||||
export interface HydrationOptions {
|
||||
onHydrated?(suspenseInstance: Comment): void;
|
||||
onDeleted?(suspenseInstance: Comment): void;
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
onHydrated?(suspenseInstance: Comment): void;
|
||||
onDeleted?(suspenseInstance: Comment): void;
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
}
|
||||
|
||||
export interface RootOptions {
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
}
|
||||
|
||||
export interface Root {
|
||||
render(children: React.ReactChild | Iterable<React.ReactNode>): void;
|
||||
unmount(): void;
|
||||
render(children: React.ReactChild | Iterable<React.ReactNode>): void;
|
||||
unmount(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,11 +33,14 @@ import React = require('react');
|
||||
*
|
||||
* @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
|
||||
*/
|
||||
export function createRoot(container: Element | Document | DocumentFragment | Comment, options?: RootOptions): Root;
|
||||
export function createRoot(
|
||||
container: Element | Document | DocumentFragment | Comment,
|
||||
options?: RootOptions
|
||||
): Root;
|
||||
|
||||
export function hydrateRoot(
|
||||
container: Element | Document | DocumentFragment | Comment,
|
||||
initialChildren: React.ReactChild | Iterable<React.ReactNode>,
|
||||
options?: HydrationOptions,
|
||||
container: Element | Document | DocumentFragment | Comment,
|
||||
initialChildren: React.ReactChild | Iterable<React.ReactNode>,
|
||||
options?: HydrationOptions
|
||||
): Root;
|
||||
}
|
||||
|
2
code/presets/vue-webpack/src/typings.d.ts
vendored
2
code/presets/vue-webpack/src/typings.d.ts
vendored
@ -1,3 +1 @@
|
||||
|
||||
|
||||
declare module 'vue-loader';
|
||||
|
2
code/presets/vue3-webpack/src/typings.d.ts
vendored
2
code/presets/vue3-webpack/src/typings.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
declare module 'global';
|
||||
|
||||
declare module 'vue-loader' {
|
||||
export const VueLoaderPlugin: any
|
||||
export const VueLoaderPlugin: any;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ import { createButton } from './Button';
|
||||
// More on default export: https://storybook.js.org/docs/html/writing-stories/introduction#default-export
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/html/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on component templates: https://storybook.js.org/docs/html/writing-stories/introduction#using-args
|
||||
render: ({ label, ...args }) => {
|
||||
// You can either use a function to create DOM elements or use a plain html string!
|
||||
|
@ -2,6 +2,8 @@ import { createHeader } from './Header';
|
||||
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/html/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => createHeader(args),
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/html/configure/story-layout
|
||||
|
@ -5,6 +5,8 @@ import { createButton } from './Button';
|
||||
// More on how to set up stories at: https://storybook.js.org/docs/html/writing-stories/introduction#default-export
|
||||
const meta: Meta<ButtonProps> = {
|
||||
title: 'Example/Button',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/html/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => {
|
||||
// You can either use a function to create DOM elements or use a plain html string!
|
||||
// return `<div>${label}</div>`;
|
||||
|
@ -4,6 +4,8 @@ import { createHeader } from './Header';
|
||||
|
||||
const meta: Meta<HeaderProps> = {
|
||||
title: 'Example/Header',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/html/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => createHeader(args),
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/html/configure/story-layout
|
||||
|
@ -4,6 +4,8 @@ import { Button } from './Button';
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/preact/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on argTypes: https://storybook.js.org/docs/preact/api/argtypes
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
|
@ -3,6 +3,8 @@ import { Header } from './Header';
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/preact/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/preact/configure/story-layout
|
||||
layout: 'fullscreen',
|
||||
|
@ -12,6 +12,8 @@ import type { SetOptional, Simplify } from 'type-fest';
|
||||
|
||||
import type { ReactFramework } from './types';
|
||||
|
||||
export { ReactFramework };
|
||||
|
||||
type JSXElement = keyof JSX.IntrinsicElements | JSXElementConstructor<any>;
|
||||
|
||||
/**
|
||||
|
43
code/renderers/react/src/typings.d.ts
vendored
43
code/renderers/react/src/typings.d.ts
vendored
@ -1,29 +1,29 @@
|
||||
// TODO: Replace, as soon as @types/react-dom 17.0.14 is used
|
||||
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
|
||||
declare module 'react-dom/client' {
|
||||
|
||||
import React = require('react');
|
||||
import React = require('react');
|
||||
|
||||
export interface HydrationOptions {
|
||||
onHydrated?(suspenseInstance: Comment): void;
|
||||
onDeleted?(suspenseInstance: Comment): void;
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
onHydrated?(suspenseInstance: Comment): void;
|
||||
onDeleted?(suspenseInstance: Comment): void;
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
}
|
||||
|
||||
export interface RootOptions {
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
/**
|
||||
* Prefix for `useId`.
|
||||
*/
|
||||
identifierPrefix?: string;
|
||||
onRecoverableError?: (error: unknown) => void;
|
||||
}
|
||||
|
||||
export interface Root {
|
||||
render(children: React.ReactChild | Iterable<React.ReactNode>): void;
|
||||
unmount(): void;
|
||||
render(children: React.ReactChild | Iterable<React.ReactNode>): void;
|
||||
unmount(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,11 +31,14 @@ import React = require('react');
|
||||
*
|
||||
* @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
|
||||
*/
|
||||
export function createRoot(container: Element | Document | DocumentFragment | Comment, options?: RootOptions): Root;
|
||||
export function createRoot(
|
||||
container: Element | Document | DocumentFragment | Comment,
|
||||
options?: RootOptions
|
||||
): Root;
|
||||
|
||||
export function hydrateRoot(
|
||||
container: Element | Document | DocumentFragment | Comment,
|
||||
initialChildren: React.ReactChild | Iterable<React.ReactNode>,
|
||||
options?: HydrationOptions,
|
||||
container: Element | Document | DocumentFragment | Comment,
|
||||
initialChildren: React.ReactChild | Iterable<React.ReactNode>,
|
||||
options?: HydrationOptions
|
||||
): Root;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import { Button } from './Button';
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
|
@ -3,6 +3,8 @@ import { Header } from './Header';
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
||||
layout: 'fullscreen',
|
||||
|
@ -6,6 +6,8 @@ import { Button } from './Button';
|
||||
const meta: Meta<typeof Button> = {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
|
@ -4,6 +4,8 @@ import { Header } from './Header';
|
||||
const meta: Meta<typeof Header> = {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
parameters: {
|
||||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
||||
layout: 'fullscreen',
|
||||
|
@ -5,6 +5,8 @@ import Button from './Button.svelte';
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: Button,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/svelte/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on component templates: https://storybook.js.org/docs/svelte/writing-stories/introduction#using-args
|
||||
render: (args) => ({
|
||||
Component: Button,
|
||||
|
@ -3,6 +3,8 @@ import Header from './Header.svelte';
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
component: Header,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/svelte/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => ({
|
||||
Component: Header,
|
||||
props: args,
|
||||
|
@ -4,6 +4,8 @@ import MyButton from './Button.vue';
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: MyButton,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
|
||||
render: (args, { argTypes }) => ({
|
||||
props: Object.keys(argTypes),
|
||||
|
@ -3,6 +3,8 @@ import MyHeader from './Header.vue';
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
component: MyHeader,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args, { argTypes }) => ({
|
||||
props: Object.keys(argTypes),
|
||||
components: {
|
||||
|
@ -4,6 +4,8 @@ import MyButton from './Button.vue';
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component: MyButton,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
|
||||
render: (args) => ({
|
||||
// Components used in your story `template` are defined in the `components` object
|
||||
|
@ -3,6 +3,8 @@ import MyHeader from './Header.vue';
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
component: MyHeader,
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => ({
|
||||
// Components used in your story `template` are defined in the `components` object
|
||||
components: {
|
||||
|
@ -3,6 +3,8 @@ import { Button } from './Button';
|
||||
// More on default export: https://storybook.js.org/docs/web-components/writing-stories/introduction#default-export
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/web-components/vue/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
// More on component templates: https://storybook.js.org/docs/web-components/writing-stories/introduction#using-args
|
||||
render: (args) => Button(args),
|
||||
// More on argTypes: https://storybook.js.org/docs/web-components/api/argtypes
|
||||
|
@ -2,6 +2,8 @@ import { Header } from './Header';
|
||||
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/web-components/vue/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => Header(args),
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,8 @@ import { Button } from './Button';
|
||||
// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction#default-export
|
||||
const meta: Meta<ButtonProps> = {
|
||||
title: 'Example/Button',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/web-components/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => Button(args),
|
||||
// More on argTypes: https://storybook.js.org/docs/web-components/api/argtypes
|
||||
argTypes: {
|
||||
|
@ -4,6 +4,8 @@ import { Header } from './Header';
|
||||
|
||||
const meta: Meta<HeaderProps> = {
|
||||
title: 'Example/Header',
|
||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/web-components/writing-docs/docs-page
|
||||
tags: ['docsPage'],
|
||||
render: (args) => Header(args),
|
||||
};
|
||||
|
||||
|
@ -6428,7 +6428,7 @@ __metadata:
|
||||
jest-specific-snapshot: ^4.0.0
|
||||
jscodeshift: ^0.13.1
|
||||
lodash: ^4.17.21
|
||||
prettier: ">=2.2.1 <=2.3.0"
|
||||
prettier: ">=2.2.1 <=3.0.0"
|
||||
recast: ^0.19.0
|
||||
typescript: ~4.6.3
|
||||
util: ^0.12.4
|
||||
@ -7745,7 +7745,7 @@ __metadata:
|
||||
estraverse: ^5.2.0
|
||||
jest-specific-snapshot: ^4.0.0
|
||||
lodash: ^4.17.21
|
||||
prettier: ">=2.2.1 <=2.3.0"
|
||||
prettier: ">=2.2.1 <=3.0.0"
|
||||
typescript: ~4.6.3
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||
@ -7976,7 +7976,7 @@ __metadata:
|
||||
vue-template-compiler: ^2.6.14
|
||||
peerDependencies:
|
||||
"@babel/core": "*"
|
||||
babel-loader: ^7.0.0 || ^8.0.0
|
||||
babel-loader: ^7.0.0 || ^8.0.0 || ^9.0.0
|
||||
css-loader: "*"
|
||||
vue: ^2.6.8
|
||||
vue-loader: ^15.7.0
|
||||
@ -28695,7 +28695,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:2.7.1, prettier@npm:>=2.5, prettier@npm:^1.18.2 || ^2.0.0":
|
||||
"prettier@npm:2.7.1, prettier@npm:>=2.2.1 <=3.0.0, prettier@npm:>=2.5, prettier@npm:^1.18.2 || ^2.0.0":
|
||||
version: 2.7.1
|
||||
resolution: "prettier@npm:2.7.1"
|
||||
bin:
|
||||
@ -28704,15 +28704,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:>=2.2.1 <=2.3.0":
|
||||
version: 2.3.0
|
||||
resolution: "prettier@npm:2.3.0"
|
||||
bin:
|
||||
prettier: bin-prettier.js
|
||||
checksum: b9f434af2f25a37aad0b133894827e980885eb8bf317444c9dde0401ed2c7f463f9996d691f5ee5a0a4450ab46a894cd6557516b561e2522821522ce1f4c6668
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"pretty-bytes@npm:^5.3.0":
|
||||
version: 5.6.0
|
||||
resolution: "pretty-bytes@npm:5.6.0"
|
||||
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"bracketSpacing": true,
|
||||
"trailingComma": "es5",
|
||||
"singleQuote": true,
|
||||
"arrowParens": "always"
|
||||
}
|
@ -6,7 +6,7 @@ import pLimit from 'p-limit';
|
||||
import prettyTime from 'pretty-hrtime';
|
||||
import { copy, emptyDir, ensureDir, move, remove, rename, writeFile } from 'fs-extra';
|
||||
import { program } from 'commander';
|
||||
import { AbortController } from 'node-abort-controller';
|
||||
import type { AbortController } from 'node-abort-controller';
|
||||
import { directory } from 'tempy';
|
||||
|
||||
import reproTemplates from '../../code/lib/cli/src/repro-templates';
|
||||
@ -16,9 +16,9 @@ import { JsPackageManagerFactory } from '../../code/lib/cli/src/js-package-manag
|
||||
import { maxConcurrentTasks } from '../utils/maxConcurrentTasks';
|
||||
|
||||
import { localizeYarnConfigFiles, setupYarn } from './utils/yarn';
|
||||
import { GeneratorConfig } from './utils/types';
|
||||
import type { GeneratorConfig } from './utils/types';
|
||||
import { getStackblitzUrl, renderTemplate } from './utils/template';
|
||||
import { JsPackageManager } from '../../code/lib/cli/src/js-package-manager';
|
||||
import type { JsPackageManager } from '../../code/lib/cli/src/js-package-manager';
|
||||
import { runRegistry } from '../tasks/run-registry';
|
||||
|
||||
const OUTPUT_DIRECTORY = join(__dirname, '..', '..', 'repros');
|
||||
@ -161,6 +161,13 @@ const runGenerators = async (
|
||||
|
||||
await addDocumentation(baseDir, { name, dirName });
|
||||
|
||||
// Remove node_modules to save space and avoid GH actions failing
|
||||
// They're not uploaded to the git repros repo anyway
|
||||
if (process.env.CLEANUP_REPRO_NODE_MODULES) {
|
||||
await remove(join(beforeDir, 'node_modules'));
|
||||
await remove(join(baseDir, 'node_modules'));
|
||||
}
|
||||
|
||||
console.log(
|
||||
`✅ Created ${dirName} in ./${relative(
|
||||
process.cwd(),
|
||||
|
@ -147,7 +147,7 @@
|
||||
"npmlog": "^5.0.1",
|
||||
"nx": "14.6.1",
|
||||
"p-limit": "^3.1.0",
|
||||
"prettier": ">=2.2.1 <=2.3.0",
|
||||
"prettier": ">=2.2.1 <=3.0.0",
|
||||
"pretty-hrtime": "^1.0.0",
|
||||
"process": "^0.11.10",
|
||||
"prompts": "^2.4.0",
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env ../../node_modules/.bin/ts-node
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import path, { join } from 'path';
|
||||
import path, { dirname, join, relative } from 'path';
|
||||
import { build } from 'tsup';
|
||||
import aliasPlugin from 'esbuild-plugin-alias';
|
||||
import dedent from 'ts-dedent';
|
||||
@ -36,21 +36,25 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
|
||||
await Promise.all(
|
||||
entries.map(async (file: string) => {
|
||||
console.log(`skipping generating types for ${file}`);
|
||||
const { name: entryName } = path.parse(file);
|
||||
|
||||
const pathName = join(process.cwd(), 'dist', `${entryName}.d.ts`);
|
||||
const { name: entryName, dir } = path.parse(file);
|
||||
|
||||
const pathName = join(process.cwd(), dir.replace('./src', 'dist'), `${entryName}.d.ts`);
|
||||
const srcName = join(process.cwd(), file);
|
||||
|
||||
const rel = relative(dirname(pathName), dirname(srcName));
|
||||
|
||||
await fs.ensureFile(pathName);
|
||||
await fs.writeFile(
|
||||
pathName,
|
||||
dedent`
|
||||
// devmode
|
||||
export * from '../src/${entryName}'
|
||||
export * from '${rel}/${entryName}';
|
||||
`
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const tsConfigPath = join(cwd, 'tsconfig.json');
|
||||
const tsConfigExists = await fs.pathExists(tsConfigPath);
|
||||
await Promise.all([
|
||||
|
@ -3,10 +3,4 @@ const base = require('@storybook/linter-config/prettier.config');
|
||||
module.exports = {
|
||||
...base,
|
||||
arrowParens: 'always',
|
||||
overrides: [
|
||||
{
|
||||
files: '*.html',
|
||||
options: { parser: 'babel' },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -3431,7 +3431,7 @@ __metadata:
|
||||
npmlog: ^5.0.1
|
||||
nx: 14.6.1
|
||||
p-limit: ^3.1.0
|
||||
prettier: ">=2.2.1 <=2.3.0"
|
||||
prettier: ">=2.2.1 <=3.0.0"
|
||||
pretty-hrtime: ^1.0.0
|
||||
process: ^0.11.10
|
||||
prompts: ^2.4.0
|
||||
@ -15669,12 +15669,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:>=2.2.1 <=2.3.0":
|
||||
version: 2.3.0
|
||||
resolution: "prettier@npm:2.3.0"
|
||||
"prettier@npm:>=2.2.1 <=3.0.0":
|
||||
version: 2.7.1
|
||||
resolution: "prettier@npm:2.7.1"
|
||||
bin:
|
||||
prettier: bin-prettier.js
|
||||
checksum: b9f434af2f25a37aad0b133894827e980885eb8bf317444c9dde0401ed2c7f463f9996d691f5ee5a0a4450ab46a894cd6557516b561e2522821522ce1f4c6668
|
||||
checksum: 359d2b7ecf36bd52924a48331cae506d335f18637fde6c686212f952b9ce678ce9f554a80571049b36ec2897a8a6c40094b776dea371cc5c04c481cf5b78504b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user