Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storybook): some storybook doc and other fixes #10387

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 14 additions & 37 deletions docs/generated/packages/storybook.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,7 @@
"presets": [
{
"name": "Default minimum setup",
"keys": ["uiFramework", "port", "projectBuildConfig", "config"]
},
{
"name": "Angular setup with styles",
"keys": [
"uiFramework",
"port",
"projectBuildConfig",
"config",
"styles",
"stylePreprocessorOptions"
]
"keys": ["uiFramework", "port", "config"]
}
],
"properties": {
Expand All @@ -254,7 +243,7 @@
"@storybook/vue3",
"@storybook/svelte"
],
"default": "@storybook/angular",
"default": "@storybook/react",
"hidden": true
},
"port": {
Expand Down Expand Up @@ -291,10 +280,6 @@
"items": { "type": "string" },
"x-deprecated": "In Storybook 6.4 the `--static-dir` CLI flag has been replaced with the the `staticDirs` field in `.storybook/main.js`. It will be removed completely in Storybook 7.0."
},
"projectBuildConfig": {
"type": "string",
"description": "Workspace project where Storybook reads the Webpack config from."
},
"config": {
"type": "object",
"description": ".storybook configuration.",
Expand Down Expand Up @@ -347,30 +332,22 @@
"presets": [
{
"name": "Default minimum setup",
"keys": [
"uiFramework",
"outputPath",
"projectBuildConfig",
"config"
]
},
{
"name": "Angular setup with styles",
"keys": [
"uiFramework",
"outputPath",
"projectBuildConfig",
"config",
"styles",
"stylePreprocessorOptions"
]
"keys": ["uiFramework", "outputPath", "config"]
}
],
"properties": {
"uiFramework": {
"type": "string",
"description": "Storybook framework npm package.",
"default": "@storybook/angular",
"enum": [
"@storybook/react",
"@storybook/html",
"@storybook/web-components",
"@storybook/vue",
"@storybook/vue3",
"@storybook/svelte"
],
"default": "@storybook/react",
"hidden": true
},
"outputPath": {
Expand All @@ -383,7 +360,7 @@
},
"styles": {
"type": "array",
"description": "Global styles to be included in the build. This is for Angular projects only. It will be ignored in non-Angular projects.",
"description": "Global styles to be included in the build.",
"items": {
"oneOf": [
{
Expand Down Expand Up @@ -417,7 +394,7 @@
"properties": {
"includePaths": {
"type": "array",
"description": "The paths to include. Paths will be resolved to workspace root. This is for Angular projects only. It will be ignored in non-Angular projects.",
"description": "The paths to include. Paths will be resolved to workspace root.",
"items": { "type": "string" }
}
}
Expand Down
27 changes: 12 additions & 15 deletions packages/storybook/src/executors/build-storybook/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@
"presets": [
{
"name": "Default minimum setup",
"keys": ["uiFramework", "outputPath", "projectBuildConfig", "config"]
},
{
"name": "Angular setup with styles",
"keys": [
"uiFramework",
"outputPath",
"projectBuildConfig",
"config",
"styles",
"stylePreprocessorOptions"
]
"keys": ["uiFramework", "outputPath", "config"]
}
],
"properties": {
"uiFramework": {
"type": "string",
"description": "Storybook framework npm package.",
"default": "@storybook/angular",
"enum": [
"@storybook/react",
"@storybook/html",
"@storybook/web-components",
"@storybook/vue",
"@storybook/vue3",
"@storybook/svelte"
],
"default": "@storybook/react",
"hidden": true
},
"outputPath": {
Expand All @@ -37,7 +34,7 @@
},
"styles": {
"type": "array",
"description": "Global styles to be included in the build. This is for Angular projects only. It will be ignored in non-Angular projects.",
"description": "Global styles to be included in the build.",
"items": {
"$ref": "#/definitions/extraEntryPoint"
}
Expand All @@ -48,7 +45,7 @@
"properties": {
"includePaths": {
"type": "array",
"description": "The paths to include. Paths will be resolved to workspace root. This is for Angular projects only. It will be ignored in non-Angular projects.",
"description": "The paths to include. Paths will be resolved to workspace root.",
"items": {
"type": "string"
}
Expand Down
19 changes: 2 additions & 17 deletions packages/storybook/src/executors/storybook/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,7 @@
"presets": [
{
"name": "Default minimum setup",
"keys": ["uiFramework", "port", "projectBuildConfig", "config"]
},
{
"name": "Angular setup with styles",
"keys": [
"uiFramework",
"port",
"projectBuildConfig",
"config",
"styles",
"stylePreprocessorOptions"
]
"keys": ["uiFramework", "port", "config"]
}
],
"properties": {
Expand All @@ -32,7 +21,7 @@
"@storybook/vue3",
"@storybook/svelte"
],
"default": "@storybook/angular",
"default": "@storybook/react",
"hidden": true
},
"port": {
Expand Down Expand Up @@ -71,10 +60,6 @@
},
"x-deprecated": "In Storybook 6.4 the `--static-dir` CLI flag has been replaced with the the `staticDirs` field in `.storybook/main.js`. It will be removed completely in Storybook 7.0."
},
"projectBuildConfig": {
"type": "string",
"description": "Workspace project where Storybook reads the Webpack config from."
},
"config": {
"type": "object",
"description": ".storybook configuration.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,18 @@ export function migrateAllStorybookInstances(tree: Tree) {
}[] = [...projects.entries()]
.filter(
([_, projectConfig]) =>
projectConfig.targets &&
projectConfig.targets.storybook &&
projectConfig.targets.storybook.executor !==
projectConfig?.targets?.storybook &&
projectConfig?.targets?.storybook?.executor !==
'@nrwl/react-native:storybook'
)
.map(([projectName, projectConfig]) => {
if (projectConfig.targets && projectConfig.targets.storybook) {
return {
name: projectName,
uiFramework: projectConfig.targets.storybook.options.uiFramework,
configFolder:
projectConfig.targets.storybook.options.config.configFolder,
};
}
return {
name: projectName,
uiFramework: projectConfig?.targets?.storybook?.options?.uiFramework,
configFolder:
projectConfig?.targets?.storybook?.options?.config?.configFolder ??
'',
};
});

for (const projectWithStorybook of projectsThatHaveStorybookConfiguration) {
Expand Down Expand Up @@ -168,7 +166,7 @@ function migrateProjectLevelStorybookInstance(
const { root, projectType } = readProjectConfiguration(tree, projectName);
const projectDirectory = projectType === 'application' ? 'app' : 'lib';
const old_folder_exists_already = tree.exists(
configFolder.replace('.storybook', '.old_storybook')
configFolder?.replace('.storybook', '.old_storybook')
);
const new_config_exists_already = tree.exists(`${configFolder}/main.js`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ export function findAllAngularProjectsWithStorybookConfiguration(tree: Tree): {
'@storybook/angular'
)
?.map(([projectName, projectConfig]) => {
if (projectConfig?.targets?.storybook) {
return {
name: projectName,
configFolder:
projectConfig.targets.storybook?.options?.config?.configFolder,
projectRoot: projectConfig.root,
projectSrc: projectConfig.sourceRoot,
};
}
return {
name: projectName,
configFolder:
projectConfig.targets.storybook?.options?.config?.configFolder,
projectRoot: projectConfig.root,
projectSrc: projectConfig.sourceRoot,
};
});
return projectsThatHaveStorybookConfiguration;
}
Expand Down