Skip to content

Commit

Permalink
feat(storybook): version 7 generators
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Jan 12, 2023
1 parent 9f19e93 commit d3a014a
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
"configureTestRunner": {
"type": "boolean",
"description": "Add a Storybook Test-Runner target."
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
"bundler": {
"description": "The Storybook builder to use.",
"enum": ["vite", "webpack"]
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
}
},
"required": ["name"],
Expand Down
27 changes: 27 additions & 0 deletions docs/generated/packages/storybook/generators/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,33 @@
"enum": ["vite", "webpack"],
"x-prompt": "Which Storybook builder do you want to use?",
"default": "webpack"
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
},
"storybook7UiFramework": {
"type": "string",
"description": "Storybook UI Framework to use.",
"enum": [
"@storybook/angular",
"@storybook/html-webpack5",
"@storybook/nextjs",
"@storybook/preact-webpack5",
"@storybook/react-webpack5",
"@storybook/react-vite",
"@storybook/server-webpack5",
"@storybook/svelte-webpack5",
"@storybook/svelte-vite",
"@storybook/sveltekit",
"@storybook/vue-webpack5",
"@storybook/vue-vite",
"@storybook/vue3-webpack5",
"@storybook/vue3-vite",
"@storybook/web-components-webpack5",
"@storybook/web-components-vite"
]
}
},
"required": ["name"],
Expand Down
20 changes: 20 additions & 0 deletions docs/generated/packages/storybook/generators/init.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
"description": "Storybook UI Framework to use.",
"enum": [
"@storybook/angular",
"@storybook/html-webpack5",
"@storybook/nextjs",
"@storybook/preact-webpack5",
"@storybook/react-webpack5",
"@storybook/react-vite",
"@storybook/server-webpack5",
"@storybook/svelte-webpack5",
"@storybook/svelte-vite",
"@storybook/sveltekit",
"@storybook/vue-webpack5",
"@storybook/vue-vite",
"@storybook/vue3-webpack5",
"@storybook/vue3-vite",
"@storybook/web-components-webpack5",
"@storybook/web-components-vite",
"@storybook/react",
"@storybook/html",
"@storybook/web-components",
Expand All @@ -29,6 +44,11 @@
"enum": ["vite", "webpack"],
"x-prompt": "Which bundler do you want to use?",
"default": "webpack"
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
}
},
"presets": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface StorybookConfigurationOptions {
skipFormat?: boolean;
ignorePaths?: string[];
configureTestRunner?: boolean;
storybook7betaConfiguration?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"configureTestRunner": {
"type": "boolean",
"description": "Add a Storybook Test-Runner target."
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface StorybookConfigureSchema {
ignorePaths?: string[];
bundler?: 'webpack' | 'vite';
configureTestRunner?: boolean;
storybook7betaConfiguration?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"bundler": {
"description": "The Storybook builder to use.",
"enum": ["vite", "webpack"]
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
}
},
"required": ["name"],
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook/src/executors/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface CommonNxStorybookConfig {
export type UiFramework7 =
| '@storybook/angular'
| '@storybook/html-webpack5'
| '@storybook/next'
| '@storybook/nextjs'
| '@storybook/preact-webpack5'
| '@storybook/react-webpack5'
| '@storybook/react-vite'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ export async function configurationGenerator(
schema.bundler = 'vite';
}

const initTask = await initGenerator(tree, {
uiFramework: schema.uiFramework,
const initTask = initGenerator(tree, {
uiFramework: schema.storybook7betaConfiguration
? schema.storybook7UiFramework
: schema.uiFramework,
bundler: schema.bundler,
storybook7betaConfiguration: schema.storybook7betaConfiguration,
});
tasks.push(initTask);

Expand Down
13 changes: 4 additions & 9 deletions packages/storybook/src/generators/configuration/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { Linter } from '@nrwl/linter';
import { UiFramework7, UiFramework } from '../../executors/models';

export interface StorybookConfigureSchema {
name: string;
uiFramework:
| '@storybook/angular'
| '@storybook/react'
| '@storybook/react-native'
| '@storybook/html'
| '@storybook/web-components'
| '@storybook/vue'
| '@storybook/vue3'
| '@storybook/svelte';
uiFramework: UiFramework;
configureCypress?: boolean;
bundler?: 'webpack' | 'vite';
linter?: Linter;
Expand All @@ -19,4 +12,6 @@ export interface StorybookConfigureSchema {
cypressDirectory?: string;
standaloneConfig?: boolean;
configureTestRunner?: boolean;
storybook7betaConfiguration?: boolean;
storybook7UiFramework?: UiFramework7;
}
27 changes: 27 additions & 0 deletions packages/storybook/src/generators/configuration/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,33 @@
"enum": ["vite", "webpack"],
"x-prompt": "Which Storybook builder do you want to use?",
"default": "webpack"
},
"storybook7betaConfiguration": {
"description": "Configure your workspace to use Storybook 7, even though Storybook v7 is still in beta.",
"type": "boolean",
"default": false
},
"storybook7UiFramework": {
"type": "string",
"description": "Storybook UI Framework to use.",
"enum": [
"@storybook/angular",
"@storybook/html-webpack5",
"@storybook/nextjs",
"@storybook/preact-webpack5",
"@storybook/react-webpack5",
"@storybook/react-vite",
"@storybook/server-webpack5",
"@storybook/svelte-webpack5",
"@storybook/svelte-vite",
"@storybook/sveltekit",
"@storybook/vue-webpack5",
"@storybook/vue-vite",
"@storybook/vue3-webpack5",
"@storybook/vue3-vite",
"@storybook/web-components-webpack5",
"@storybook/web-components-vite"
]
}
},
"required": ["name"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { join, relative } from 'path';
import {
dedupe,
findStorybookAndBuildTargetsAndCompiler,
isFramework,
TsConfig,
} from '../../utils/utilities';
import { StorybookConfigureSchema } from './schema';
Expand Down Expand Up @@ -168,7 +167,8 @@ export function configureTsProjectConfig(
...(tsConfigContent.exclude || []),
'**/*.stories.ts',
'**/*.stories.js',
...(isFramework('react', schema) || isFramework('react-native', schema)
...(schema.uiFramework === '@storybook/react' ||
schema.uiFramework === '@storybook/react-native'
? ['**/*.stories.jsx', '**/*.stories.tsx']
: []),
];
Expand Down
Loading

0 comments on commit d3a014a

Please sign in to comment.