@nx/storybook 16.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +26 -0
- package/generators.json +58 -0
- package/index.d.ts +3 -0
- package/index.js +10 -0
- package/index.js.map +1 -0
- package/migrations.json +294 -0
- package/package.json +49 -0
- package/presets/cypress.d.ts +22 -0
- package/presets/cypress.js +9 -0
- package/presets/cypress.js.map +1 -0
- package/src/executors/build-storybook/build-storybook.impl.d.ts +7 -0
- package/src/executors/build-storybook/build-storybook.impl.js +58 -0
- package/src/executors/build-storybook/build-storybook.impl.js.map +1 -0
- package/src/executors/build-storybook/compat.d.ts +2 -0
- package/src/executors/build-storybook/compat.js +6 -0
- package/src/executors/build-storybook/compat.js.map +1 -0
- package/src/executors/build-storybook/schema.json +122 -0
- package/src/executors/storybook/compat.d.ts +2 -0
- package/src/executors/storybook/compat.js +6 -0
- package/src/executors/storybook/compat.js.map +1 -0
- package/src/executors/storybook/schema.json +94 -0
- package/src/executors/storybook/storybook.impl.d.ts +11 -0
- package/src/executors/storybook/storybook.impl.js +53 -0
- package/src/executors/storybook/storybook.impl.js.map +1 -0
- package/src/executors/utils.d.ts +12 -0
- package/src/executors/utils.js +148 -0
- package/src/executors/utils.js.map +1 -0
- package/src/generators/configuration/configuration.d.ts +5 -0
- package/src/generators/configuration/configuration.js +191 -0
- package/src/generators/configuration/configuration.js.map +1 -0
- package/src/generators/configuration/lib/user-prompts.d.ts +6 -0
- package/src/generators/configuration/lib/user-prompts.js +90 -0
- package/src/generators/configuration/lib/user-prompts.js.map +1 -0
- package/src/generators/configuration/lib/util-functions.d.ts +27 -0
- package/src/generators/configuration/lib/util-functions.js +359 -0
- package/src/generators/configuration/lib/util-functions.js.map +1 -0
- package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +46 -0
- package/src/generators/configuration/project-files/.storybook/preview.js__tmpl__ +0 -0
- package/src/generators/configuration/project-files/.storybook/tsconfig.json__tmpl__ +26 -0
- package/src/generators/configuration/project-files-7/.storybook/main.js__tmpl__ +34 -0
- package/src/generators/configuration/project-files-7/.storybook/preview.js__tmpl__ +0 -0
- package/src/generators/configuration/project-files-7/.storybook/tsconfig.json__tmpl__ +26 -0
- package/src/generators/configuration/project-files-7-ts/.storybook/main.ts__tmpl__ +36 -0
- package/src/generators/configuration/project-files-7-ts/.storybook/preview.ts__tmpl__ +0 -0
- package/src/generators/configuration/project-files-7-ts/.storybook/tsconfig.json__tmpl__ +28 -0
- package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +49 -0
- package/src/generators/configuration/project-files-ts/.storybook/preview.ts__tmpl__ +0 -0
- package/src/generators/configuration/project-files-ts/.storybook/tsconfig.json__tmpl__ +28 -0
- package/src/generators/configuration/schema.d.ts +19 -0
- package/src/generators/configuration/schema.json +124 -0
- package/src/generators/cypress-project/cypress-project.d.ts +14 -0
- package/src/generators/cypress-project/cypress-project.js +98 -0
- package/src/generators/cypress-project/cypress-project.js.map +1 -0
- package/src/generators/cypress-project/files/cypress.config.ts__tpl__ +6 -0
- package/src/generators/cypress-project/schema.json +55 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +181 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +8 -0
- package/src/generators/init/schema.json +60 -0
- package/src/generators/migrate-7/calling-storybook-cli.d.ts +13 -0
- package/src/generators/migrate-7/calling-storybook-cli.js +85 -0
- package/src/generators/migrate-7/calling-storybook-cli.js.map +1 -0
- package/src/generators/migrate-7/files/storybook-migration-summary.md__tmpl__ +80 -0
- package/src/generators/migrate-7/helper-functions.d.ts +69 -0
- package/src/generators/migrate-7/helper-functions.js +449 -0
- package/src/generators/migrate-7/helper-functions.js.map +1 -0
- package/src/generators/migrate-7/migrate-7.d.ts +5 -0
- package/src/generators/migrate-7/migrate-7.js +73 -0
- package/src/generators/migrate-7/migrate-7.js.map +1 -0
- package/src/generators/migrate-7/schema.d.ts +9 -0
- package/src/generators/migrate-7/schema.json +35 -0
- package/src/migrations/update-13-4-6/set-project-build-config.d.ts +2 -0
- package/src/migrations/update-13-4-6/set-project-build-config.js +61 -0
- package/src/migrations/update-13-4-6/set-project-build-config.js.map +1 -0
- package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.d.ts +6 -0
- package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.js +120 -0
- package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.js.map +1 -0
- package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.d.ts +8 -0
- package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.js +294 -0
- package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.js.map +1 -0
- package/src/migrations/update-14-0-0/migrate-to-storybook-6.d.ts +2 -0
- package/src/migrations/update-14-0-0/migrate-to-storybook-6.js +13 -0
- package/src/migrations/update-14-0-0/migrate-to-storybook-6.js.map +1 -0
- package/src/migrations/update-14-1-8/change-storybook-targets-generator.d.ts +4 -0
- package/src/migrations/update-14-1-8/change-storybook-targets-generator.js +105 -0
- package/src/migrations/update-14-1-8/change-storybook-targets-generator.js.map +1 -0
- package/src/migrations/update-14-1-8/change-storybook-targets.d.ts +2 -0
- package/src/migrations/update-14-1-8/change-storybook-targets.js +11 -0
- package/src/migrations/update-14-1-8/change-storybook-targets.js.map +1 -0
- package/src/migrations/update-15-0-0/add-storybook-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-storybook-inputs.js +47 -0
- package/src/migrations/update-15-0-0/add-storybook-inputs.js.map +1 -0
- package/src/migrations/update-15-4-6/refactor-executor-options.d.ts +2 -0
- package/src/migrations/update-15-4-6/refactor-executor-options.js +67 -0
- package/src/migrations/update-15-4-6/refactor-executor-options.js.map +1 -0
- package/src/migrations/update-15-5-3/ensure-webpack-package.d.ts +2 -0
- package/src/migrations/update-15-5-3/ensure-webpack-package.js +33 -0
- package/src/migrations/update-15-5-3/ensure-webpack-package.js.map +1 -0
- package/src/migrations/update-15-7-0/add-addon-essentials-to-all.d.ts +24 -0
- package/src/migrations/update-15-7-0/add-addon-essentials-to-all.js +278 -0
- package/src/migrations/update-15-7-0/add-addon-essentials-to-all.js.map +1 -0
- package/src/migrations/update-15-7-0/remove-root-config.d.ts +14 -0
- package/src/migrations/update-15-7-0/remove-root-config.js +210 -0
- package/src/migrations/update-15-7-0/remove-root-config.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/utils/models.d.ts +5 -0
- package/src/utils/models.js +3 -0
- package/src/utils/models.js.map +1 -0
- package/src/utils/test-configs/.storybook/main.js +8 -0
- package/src/utils/test-configs/.storybook/tsconfig.json +19 -0
- package/src/utils/testing.d.ts +3 -0
- package/src/utils/testing.js +38 -0
- package/src/utils/testing.js.map +1 -0
- package/src/utils/utilities.d.ts +53 -0
- package/src/utils/utilities.js +255 -0
- package/src/utils/utilities.js.map +1 -0
- package/src/utils/versions.d.ts +20 -0
- package/src/utils/versions.js +24 -0
- package/src/utils/versions.js.map +1 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"emitDecoratorMetadata": true
|
|
5
|
+
<% if(uiFramework === '@storybook/react') { %>, "outDir": "" <% } %>
|
|
6
|
+
},
|
|
7
|
+
<% if(uiFramework === '@storybook/react') { %>"files": [
|
|
8
|
+
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nrwl/react/typings/styled-jsx.d.ts",
|
|
9
|
+
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nrwl/react/typings/cssmodule.d.ts",
|
|
10
|
+
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nrwl/react/typings/image.d.ts"
|
|
11
|
+
],<% } %>
|
|
12
|
+
"exclude": ["../**/*.spec.ts" <% if(uiFramework === '@storybook/react') { %>, "../**/*.spec.js", "../**/*.spec.tsx", "../**/*.spec.jsx"<% } %>],
|
|
13
|
+
"include": [<% if(uiFramework === '@storybook/angular' && projectType === 'library') { %>
|
|
14
|
+
"../src/**/*.stories.ts",
|
|
15
|
+
"../src/**/*.stories.js",
|
|
16
|
+
"../src/**/*.stories.jsx",
|
|
17
|
+
"../src/**/*.stories.tsx",
|
|
18
|
+
"../src/**/*.stories.mdx",
|
|
19
|
+
"*.ts",
|
|
20
|
+
"*.js"<% } else { %>
|
|
21
|
+
"../<%= mainDir %>/**/*.stories.ts",
|
|
22
|
+
"../<%= mainDir %>/**/*.stories.js",
|
|
23
|
+
"../<%= mainDir %>/**/*.stories.jsx",
|
|
24
|
+
"../<%= mainDir %>/**/*.stories.tsx",
|
|
25
|
+
"../<%= mainDir %>/**/*.stories.mdx",
|
|
26
|
+
"*.ts",
|
|
27
|
+
"*.js"<% if(uiFramework === '@storybook/react-native') { %>, "*.tsx"<% } %><% } %>]
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Linter } from '@nx/linter';
|
|
2
|
+
import { UiFramework7, UiFramework } from '../../utils/models';
|
|
3
|
+
|
|
4
|
+
export interface StorybookConfigureSchema {
|
|
5
|
+
name: string;
|
|
6
|
+
uiFramework?: UiFramework; // TODO(katerina): Remove when Storybook 7
|
|
7
|
+
configureCypress?: boolean;
|
|
8
|
+
bundler?: 'webpack' | 'vite'; // TODO(katerina): Remove when Storybook 7
|
|
9
|
+
linter?: Linter;
|
|
10
|
+
js?: boolean;
|
|
11
|
+
tsConfiguration?: boolean;
|
|
12
|
+
cypressDirectory?: string;
|
|
13
|
+
standaloneConfig?: boolean;
|
|
14
|
+
configureTestRunner?: boolean;
|
|
15
|
+
configureStaticServe?: boolean;
|
|
16
|
+
storybook7Configuration?: boolean; // TODO(katerina): Change when Storybook 7
|
|
17
|
+
storybook7UiFramework?: UiFramework7; // TODO(katerina): Change when Storybook 7
|
|
18
|
+
skipFormat?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxStorybookConfigure",
|
|
5
|
+
"title": "Storybook Configuration",
|
|
6
|
+
"description": "Add Storybook configuration to a UI library or an application.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"aliases": ["project", "projectName"],
|
|
12
|
+
"description": "Project for which to generate Storybook configuration.",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "argv",
|
|
15
|
+
"index": 0
|
|
16
|
+
},
|
|
17
|
+
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
18
|
+
"x-dropdown": "projects",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"configureCypress": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Run the cypress-configure generator.",
|
|
24
|
+
"x-prompt": "Configure a cypress e2e app to run against the storybook instance?",
|
|
25
|
+
"x-priority": "important"
|
|
26
|
+
},
|
|
27
|
+
"cypressDirectory": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "A directory where the Cypress project will be placed. Added at root by default."
|
|
30
|
+
},
|
|
31
|
+
"linter": {
|
|
32
|
+
"description": "The tool to use for running lint checks.",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["eslint", "none"],
|
|
35
|
+
"default": "eslint"
|
|
36
|
+
},
|
|
37
|
+
"js": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
40
|
+
"default": false
|
|
41
|
+
},
|
|
42
|
+
"tsConfiguration": {
|
|
43
|
+
"type": "boolean",
|
|
44
|
+
"description": "Configure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.",
|
|
45
|
+
"default": false,
|
|
46
|
+
"x-priority": "important"
|
|
47
|
+
},
|
|
48
|
+
"standaloneConfig": {
|
|
49
|
+
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"default": true,
|
|
52
|
+
"x-deprecated": "Nx only supports standaloneConfig"
|
|
53
|
+
},
|
|
54
|
+
"configureStaticServe": {
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"description": "Add a static-storybook to serve the static storybook built files.",
|
|
57
|
+
"default": false
|
|
58
|
+
},
|
|
59
|
+
"configureTestRunner": {
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"description": "Add a Storybook Test-Runner target."
|
|
62
|
+
},
|
|
63
|
+
"bundler": {
|
|
64
|
+
"description": "The Storybook builder to use.",
|
|
65
|
+
"type": "string",
|
|
66
|
+
"enum": ["vite", "webpack"],
|
|
67
|
+
"default": "webpack",
|
|
68
|
+
"x-priority": "important"
|
|
69
|
+
},
|
|
70
|
+
"storybook7Configuration": {
|
|
71
|
+
"description": "Configure your workspace using Storybook version 7. Defaults to true.",
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"default": true,
|
|
74
|
+
"hidden": true,
|
|
75
|
+
"aliases": ["storybook7betaConfiguration"]
|
|
76
|
+
},
|
|
77
|
+
"storybook7UiFramework": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "Storybook UI Framework to use, for Storybook version 7.",
|
|
80
|
+
"enum": [
|
|
81
|
+
"@storybook/angular",
|
|
82
|
+
"@storybook/html-webpack5",
|
|
83
|
+
"@storybook/nextjs",
|
|
84
|
+
"@storybook/preact-webpack5",
|
|
85
|
+
"@storybook/react-webpack5",
|
|
86
|
+
"@storybook/react-vite",
|
|
87
|
+
"@storybook/server-webpack5",
|
|
88
|
+
"@storybook/svelte-webpack5",
|
|
89
|
+
"@storybook/svelte-vite",
|
|
90
|
+
"@storybook/sveltekit",
|
|
91
|
+
"@storybook/vue-webpack5",
|
|
92
|
+
"@storybook/vue-vite",
|
|
93
|
+
"@storybook/vue3-webpack5",
|
|
94
|
+
"@storybook/vue3-vite",
|
|
95
|
+
"@storybook/web-components-webpack5",
|
|
96
|
+
"@storybook/web-components-vite"
|
|
97
|
+
],
|
|
98
|
+
"x-priority": "important",
|
|
99
|
+
"hidden": false
|
|
100
|
+
},
|
|
101
|
+
"uiFramework": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "Storybook UI Framework to use.",
|
|
104
|
+
"enum": [
|
|
105
|
+
"@storybook/angular",
|
|
106
|
+
"@storybook/react",
|
|
107
|
+
"@storybook/react-native",
|
|
108
|
+
"@storybook/html",
|
|
109
|
+
"@storybook/web-components",
|
|
110
|
+
"@storybook/vue",
|
|
111
|
+
"@storybook/vue3",
|
|
112
|
+
"@storybook/svelte"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"skipFormat": {
|
|
116
|
+
"description": "Skip formatting files.",
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"default": false,
|
|
119
|
+
"x-priority": "internal"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"required": ["name"],
|
|
123
|
+
"examplesFile": "../../../docs/configuration-generator-examples.md"
|
|
124
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Linter } from '@nx/linter';
|
|
3
|
+
export interface CypressConfigureSchema {
|
|
4
|
+
name: string;
|
|
5
|
+
js?: boolean;
|
|
6
|
+
directory?: string;
|
|
7
|
+
linter: Linter;
|
|
8
|
+
standaloneConfig?: boolean;
|
|
9
|
+
ciTargetName?: string;
|
|
10
|
+
skipFormat?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function cypressProjectGenerator(tree: Tree, schema: CypressConfigureSchema): Promise<GeneratorCallback>;
|
|
13
|
+
export default cypressProjectGenerator;
|
|
14
|
+
export declare const cypressProjectSchematic: (generatorOptions: CypressConfigureSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cypressProjectSchematic = exports.cypressProjectGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cypress_1 = require("@nx/cypress");
|
|
6
|
+
const project_name_1 = require("@nx/cypress/src/utils/project-name");
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const utilities_1 = require("../../utils/utilities");
|
|
10
|
+
function cypressProjectGenerator(tree, schema) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const libConfig = (0, devkit_1.readProjectConfiguration)(tree, schema.name);
|
|
13
|
+
const libRoot = libConfig.root;
|
|
14
|
+
const cypressProjectName = `${schema.directory ? (0, project_name_1.getUnscopedLibName)(libRoot) : schema.name}-e2e`;
|
|
15
|
+
const tasks = [];
|
|
16
|
+
if (!projectAlreadyHasCypress(tree)) {
|
|
17
|
+
tasks.push(yield (0, cypress_1.cypressInitGenerator)(tree, {}));
|
|
18
|
+
}
|
|
19
|
+
const installTask = yield (0, cypress_1.cypressProjectGenerator)(tree, {
|
|
20
|
+
name: cypressProjectName,
|
|
21
|
+
project: schema.name,
|
|
22
|
+
js: schema.js,
|
|
23
|
+
linter: schema.linter,
|
|
24
|
+
directory: schema.directory,
|
|
25
|
+
standaloneConfig: schema.standaloneConfig,
|
|
26
|
+
skipFormat: true,
|
|
27
|
+
});
|
|
28
|
+
tasks.push(installTask);
|
|
29
|
+
const generatedCypressProjectName = (0, project_name_1.getE2eProjectName)(schema.name, libRoot, schema.directory);
|
|
30
|
+
removeUnneededFiles(tree, generatedCypressProjectName, schema.js);
|
|
31
|
+
addBaseUrlToCypressConfig(tree, generatedCypressProjectName);
|
|
32
|
+
updateAngularJsonBuilder(tree, {
|
|
33
|
+
e2eProjectName: generatedCypressProjectName,
|
|
34
|
+
targetProjectName: schema.name,
|
|
35
|
+
ciTargetName: schema.ciTargetName,
|
|
36
|
+
});
|
|
37
|
+
if (!schema.skipFormat) {
|
|
38
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
39
|
+
}
|
|
40
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.cypressProjectGenerator = cypressProjectGenerator;
|
|
44
|
+
function removeUnneededFiles(tree, projectName, js) {
|
|
45
|
+
const { sourceRoot, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
46
|
+
const fileType = js ? 'js' : 'ts';
|
|
47
|
+
if (tree.exists((0, path_1.join)(root, 'cypress.config.ts'))) {
|
|
48
|
+
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/e2e/app.cy.${fileType}`);
|
|
49
|
+
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/support/app.po.${fileType}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/integration/app.spec.${fileType}`);
|
|
53
|
+
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/support/app.po.${fileType}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function addBaseUrlToCypressConfig(tree, projectName) {
|
|
57
|
+
const projectRoot = (0, devkit_1.readProjectConfiguration)(tree, projectName).root;
|
|
58
|
+
const cypressJson = (0, path_1.join)(projectRoot, 'cypress.json');
|
|
59
|
+
const cypressTs = (0, path_1.join)(projectRoot, 'cypress.config.ts');
|
|
60
|
+
// TODO(caleb): remove this when cypress < v10 is deprecated
|
|
61
|
+
if (tree.exists(cypressJson)) {
|
|
62
|
+
// cypress < v10
|
|
63
|
+
(0, devkit_1.updateJson)(tree, cypressJson, (json) => {
|
|
64
|
+
json.baseUrl = 'http://localhost:4400';
|
|
65
|
+
return json;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else if (tree.exists(cypressTs)) {
|
|
69
|
+
// cypress >= v10
|
|
70
|
+
tree.delete(cypressTs);
|
|
71
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), projectRoot, {
|
|
72
|
+
tpl: '',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function updateAngularJsonBuilder(tree, opts) {
|
|
77
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, opts.e2eProjectName);
|
|
78
|
+
const e2eTarget = project.targets.e2e;
|
|
79
|
+
project.targets.e2e = Object.assign(Object.assign({}, e2eTarget), { options: Object.assign(Object.assign({}, e2eTarget.options), { devServerTarget: `${opts.targetProjectName}:storybook` }), configurations: {
|
|
80
|
+
ci: {
|
|
81
|
+
devServerTarget: opts.ciTargetName
|
|
82
|
+
? `${opts.targetProjectName}:${opts.ciTargetName}:ci`
|
|
83
|
+
: `${opts.targetProjectName}:storybook:ci`,
|
|
84
|
+
},
|
|
85
|
+
} });
|
|
86
|
+
(0, devkit_1.updateProjectConfiguration)(tree, opts.e2eProjectName, project);
|
|
87
|
+
}
|
|
88
|
+
function projectAlreadyHasCypress(tree) {
|
|
89
|
+
var _a, _b, _c, _d;
|
|
90
|
+
const packageJsonContents = (0, devkit_1.readJson)(tree, 'package.json');
|
|
91
|
+
return ((((_a = packageJsonContents === null || packageJsonContents === void 0 ? void 0 : packageJsonContents['devDependencies']) === null || _a === void 0 ? void 0 : _a['@nrwl/cypress']) ||
|
|
92
|
+
((_b = packageJsonContents === null || packageJsonContents === void 0 ? void 0 : packageJsonContents['dependencies']) === null || _b === void 0 ? void 0 : _b['@nrwl/cypress'])) &&
|
|
93
|
+
(((_c = packageJsonContents === null || packageJsonContents === void 0 ? void 0 : packageJsonContents['devDependencies']) === null || _c === void 0 ? void 0 : _c['cypress']) ||
|
|
94
|
+
((_d = packageJsonContents === null || packageJsonContents === void 0 ? void 0 : packageJsonContents['dependencies']) === null || _d === void 0 ? void 0 : _d['cypress'])));
|
|
95
|
+
}
|
|
96
|
+
exports.default = cypressProjectGenerator;
|
|
97
|
+
exports.cypressProjectSchematic = (0, devkit_1.convertNxGenerator)(cypressProjectGenerator);
|
|
98
|
+
//# sourceMappingURL=cypress-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cypress-project.js","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/cypress-project/cypress-project.ts"],"names":[],"mappings":";;;;AAAA,yCAGqB;AACrB,qEAG4C;AAC5C,uCAYoB;AAGpB,+BAA4B;AAC5B,qDAAuD;AAYvD,SAAsB,uBAAuB,CAC3C,IAAU,EACV,MAA8B;;QAE9B,MAAM,SAAS,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC;QAC/B,MAAM,kBAAkB,GAAG,GACzB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,iCAAkB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAC1D,MAAM,CAAC;QAEP,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE;YACnC,KAAK,CAAC,IAAI,CAAC,MAAM,IAAA,8BAAqB,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;SACnD;QAED,MAAM,WAAW,GAAG,MAAM,IAAA,iCAAwB,EAAC,IAAI,EAAE;YACvD,IAAI,EAAE,kBAAkB;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
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "cypress-configure",
|
|
5
|
+
"title": "Cypress Configuration",
|
|
6
|
+
"description": "Add cypress E2E app to test a ui library that is set up for Storybook.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"aliases": ["project", "projectName"],
|
|
12
|
+
"description": "Project for which to generate the cypress E2E app.",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "argv",
|
|
15
|
+
"index": 0
|
|
16
|
+
},
|
|
17
|
+
"x-prompt": "For which project do you want to generate the Cypress E2E app?",
|
|
18
|
+
"x-dropdown": "projects",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"js": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
24
|
+
"default": false
|
|
25
|
+
},
|
|
26
|
+
"directory": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "A directory where the project is placed."
|
|
29
|
+
},
|
|
30
|
+
"linter": {
|
|
31
|
+
"description": "The tool to use for running lint checks.",
|
|
32
|
+
"type": "string",
|
|
33
|
+
"enum": ["eslint", "none"],
|
|
34
|
+
"default": "eslint"
|
|
35
|
+
},
|
|
36
|
+
"standaloneConfig": {
|
|
37
|
+
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"default": true,
|
|
40
|
+
"x-deprecated": "Nx only supports standaloneConfig"
|
|
41
|
+
},
|
|
42
|
+
"ciTargetName": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "The name of the devServerTarget to use for the Cypress CI configuration. Used to control if using <storybook-project>:static-storybook:ci or <storybook-project>:storybook:ci",
|
|
45
|
+
"x-priority": "internal"
|
|
46
|
+
},
|
|
47
|
+
"skipFormat": {
|
|
48
|
+
"description": "Skip formatting files.",
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"default": false,
|
|
51
|
+
"x-priority": "internal"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"required": ["name"]
|
|
55
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export default initGenerator;
|
|
5
|
+
export declare const initSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initSchematic = exports.initGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
8
|
+
function checkDependenciesInstalled(host, schema) {
|
|
9
|
+
const packageJson = (0, devkit_1.readJson)(host, 'package.json');
|
|
10
|
+
const devDependencies = {};
|
|
11
|
+
const dependencies = {};
|
|
12
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
13
|
+
packageJson.devDependencices = packageJson.devDependencices || {};
|
|
14
|
+
// base deps
|
|
15
|
+
devDependencies['@nrwl/storybook'] = versions_1.nxVersion;
|
|
16
|
+
if (schema.storybook7Configuration) {
|
|
17
|
+
// Needed for Storybook 7
|
|
18
|
+
// https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#react-peer-dependencies-required
|
|
19
|
+
if (!packageJson.dependencies['react'] &&
|
|
20
|
+
!packageJson.devDependencies['react']) {
|
|
21
|
+
dependencies['react'] = versions_1.reactVersion;
|
|
22
|
+
}
|
|
23
|
+
if (!packageJson.dependencies['react-dom'] &&
|
|
24
|
+
!packageJson.devDependencies['react-dom']) {
|
|
25
|
+
dependencies['react-dom'] = versions_1.reactVersion;
|
|
26
|
+
}
|
|
27
|
+
if (schema.uiFramework === '@storybook/react-native') {
|
|
28
|
+
devDependencies['@storybook/react-native'] = versions_1.storybookReactNativeVersion;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
devDependencies[schema.uiFramework] = versions_1.storybook7Version;
|
|
32
|
+
}
|
|
33
|
+
devDependencies['@storybook/core-server'] = versions_1.storybook7Version;
|
|
34
|
+
devDependencies['@storybook/addon-essentials'] = versions_1.storybook7Version;
|
|
35
|
+
if (schema.uiFramework === '@storybook/angular') {
|
|
36
|
+
if (!packageJson.dependencies['@angular/forms'] &&
|
|
37
|
+
!packageJson.devDependencies['@angular/forms']) {
|
|
38
|
+
devDependencies['@angular/forms'] = '*';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (schema.uiFramework === '@storybook/web-components-vite' ||
|
|
42
|
+
schema.uiFramework === '@storybook/web-components-webpack5') {
|
|
43
|
+
devDependencies['lit'] = versions_1.litVersion;
|
|
44
|
+
}
|
|
45
|
+
if (schema.uiFramework === '@storybook/react-native') {
|
|
46
|
+
devDependencies['@storybook/addon-ondevice-actions'] =
|
|
47
|
+
versions_1.storybookReactNativeVersion;
|
|
48
|
+
devDependencies['@storybook/addon-ondevice-backgrounds'] =
|
|
49
|
+
versions_1.storybookReactNativeVersion;
|
|
50
|
+
devDependencies['@storybook/addon-ondevice-controls'] =
|
|
51
|
+
versions_1.storybookReactNativeVersion;
|
|
52
|
+
devDependencies['@storybook/addon-ondevice-notes'] =
|
|
53
|
+
versions_1.storybookReactNativeVersion;
|
|
54
|
+
devDependencies['react-native-storybook-loader'] =
|
|
55
|
+
versions_1.reactNativeStorybookLoader;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// TODO(katerina): Remove when Storybook v7
|
|
60
|
+
if (schema.uiFramework === '@storybook/react-native') {
|
|
61
|
+
devDependencies['@storybook/react-native'] = versions_1.storybookReactNativeVersion;
|
|
62
|
+
}
|
|
63
|
+
else if (schema.uiFramework !== undefined) {
|
|
64
|
+
devDependencies[schema.uiFramework] = versions_1.storybookVersion;
|
|
65
|
+
}
|
|
66
|
+
devDependencies['@storybook/core-server'] = versions_1.storybookVersion;
|
|
67
|
+
devDependencies['@storybook/addon-essentials'] = versions_1.storybookVersion;
|
|
68
|
+
if (schema.bundler === 'vite') {
|
|
69
|
+
devDependencies['@storybook/builder-vite'] = versions_1.viteBuilderVersion;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
devDependencies['@storybook/builder-webpack5'] = versions_1.storybookVersion;
|
|
73
|
+
devDependencies['@storybook/manager-webpack5'] = versions_1.storybookVersion;
|
|
74
|
+
}
|
|
75
|
+
devDependencies['html-webpack-plugin'] = versions_1.htmlWebpackPluginVersion;
|
|
76
|
+
if (schema.uiFramework === '@storybook/angular') {
|
|
77
|
+
devDependencies['webpack'] = versions_1.webpack5Version;
|
|
78
|
+
if (!packageJson.dependencies['@angular/forms'] &&
|
|
79
|
+
!packageJson.devDependencies['@angular/forms']) {
|
|
80
|
+
devDependencies['@angular/forms'] = '*';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (schema.uiFramework === '@storybook/react') {
|
|
84
|
+
devDependencies['@svgr/webpack'] = versions_1.svgrVersion;
|
|
85
|
+
devDependencies['url-loader'] = versions_1.urlLoaderVersion;
|
|
86
|
+
devDependencies['babel-loader'] = versions_1.babelLoaderVersion;
|
|
87
|
+
devDependencies['@babel/core'] = versions_1.babelCoreVersion;
|
|
88
|
+
devDependencies['@babel/preset-typescript'] =
|
|
89
|
+
versions_1.babelPresetTypescriptVersion;
|
|
90
|
+
if (schema.bundler === 'webpack') {
|
|
91
|
+
devDependencies['@nrwl/webpack'] = versions_1.nxVersion;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (schema.uiFramework === '@storybook/web-components') {
|
|
95
|
+
devDependencies['lit-html'] = versions_1.litHtmlVersion;
|
|
96
|
+
}
|
|
97
|
+
if (schema.uiFramework === '@storybook/react-native') {
|
|
98
|
+
devDependencies['@storybook/addon-ondevice-actions'] =
|
|
99
|
+
versions_1.storybookReactNativeVersion;
|
|
100
|
+
devDependencies['@storybook/addon-ondevice-backgrounds'] =
|
|
101
|
+
versions_1.storybookReactNativeVersion;
|
|
102
|
+
devDependencies['@storybook/addon-ondevice-controls'] =
|
|
103
|
+
versions_1.storybookReactNativeVersion;
|
|
104
|
+
devDependencies['@storybook/addon-ondevice-notes'] =
|
|
105
|
+
versions_1.storybookReactNativeVersion;
|
|
106
|
+
devDependencies['react-native-storybook-loader'] =
|
|
107
|
+
versions_1.reactNativeStorybookLoader;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, dependencies, devDependencies);
|
|
111
|
+
}
|
|
112
|
+
function addCacheableOperation(tree) {
|
|
113
|
+
var _a;
|
|
114
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
115
|
+
if (!nxJson.tasksRunnerOptions ||
|
|
116
|
+
!nxJson.tasksRunnerOptions.default ||
|
|
117
|
+
(nxJson.tasksRunnerOptions.default.runner !==
|
|
118
|
+
'@nrwl/workspace/tasks-runners/default' &&
|
|
119
|
+
nxJson.tasksRunnerOptions.default.runner !== 'nx/tasks-runners/default')) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
nxJson.tasksRunnerOptions.default.options =
|
|
123
|
+
nxJson.tasksRunnerOptions.default.options || {};
|
|
124
|
+
nxJson.tasksRunnerOptions.default.options.cacheableOperations =
|
|
125
|
+
nxJson.tasksRunnerOptions.default.options.cacheableOperations || [];
|
|
126
|
+
if (!((_a = nxJson.tasksRunnerOptions.default.options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes('build-storybook'))) {
|
|
127
|
+
nxJson.tasksRunnerOptions.default.options.cacheableOperations.push('build-storybook');
|
|
128
|
+
}
|
|
129
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
130
|
+
}
|
|
131
|
+
function moveToDevDependencies(tree) {
|
|
132
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
133
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
134
|
+
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
135
|
+
if (packageJson.dependencies['@nrwl/storybook']) {
|
|
136
|
+
packageJson.devDependencies['@nrwl/storybook'] =
|
|
137
|
+
packageJson.dependencies['@nrwl/storybook'];
|
|
138
|
+
delete packageJson.dependencies['@nrwl/storybook'];
|
|
139
|
+
}
|
|
140
|
+
return packageJson;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* This is a temporary fix for Storybook to support TypeScript configuration files.
|
|
145
|
+
* The issue is that if there is a root tsconfig.json file, Storybook will use it, and
|
|
146
|
+
* ignore the tsconfig.json file in the .storybook folder. This results in module being set
|
|
147
|
+
* to esnext, and Storybook does not recognise the main.ts code as a module.
|
|
148
|
+
*/
|
|
149
|
+
function editRootTsConfig(tree) {
|
|
150
|
+
if (tree.exists('tsconfig.json')) {
|
|
151
|
+
(0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
|
|
152
|
+
var _a;
|
|
153
|
+
if (json['ts-node']) {
|
|
154
|
+
json['ts-node'] = Object.assign(Object.assign({}, json['ts-node']), { compilerOptions: Object.assign(Object.assign({}, ((_a = json['ts-node'].compilerOptions) !== null && _a !== void 0 ? _a : {})), { module: 'commonjs' }) });
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
json['ts-node'] = {
|
|
158
|
+
compilerOptions: {
|
|
159
|
+
module: 'commonjs',
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return json;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function initGenerator(tree, schema) {
|
|
168
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const tasks = [];
|
|
170
|
+
tasks.push(yield (0, js_1.initGenerator)(tree, Object.assign(Object.assign({}, schema), { skipFormat: true })));
|
|
171
|
+
tasks.push(checkDependenciesInstalled(tree, schema));
|
|
172
|
+
moveToDevDependencies(tree);
|
|
173
|
+
editRootTsConfig(tree);
|
|
174
|
+
addCacheableOperation(tree);
|
|
175
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.initGenerator = initGenerator;
|
|
179
|
+
exports.default = initGenerator;
|
|
180
|
+
exports.initSchematic = (0, devkit_1.convertNxGenerator)(initGenerator);
|
|
181
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":";;;;AAAA,uCAUoB;AACpB,+BAA0D;AAE1D,mDAiB8B;AAG9B,SAAS,0BAA0B,CAAC,IAAU,EAAE,MAAc;IAC5D,MAAM,WAAW,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAEnD,MAAM,eAAe,GAAG,EAAE,CAAC;IAC3B,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC;IAC1D,WAAW,CAAC,gBAAgB,GAAG,WAAW,CAAC,gBAAgB,IAAI,EAAE,CAAC;IAElE,YAAY;IACZ,eAAe,CAAC,iBAAiB,CAAC,GAAG,oBAAS,CAAC;IAE/C,IAAI,MAAM,CAAC,uBAAuB,EAAE;QAClC,yBAAyB;QACzB,mGAAmG;QACnG,IACE,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC;YAClC,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,EACrC;YACA,YAAY,CAAC,OAAO,CAA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AG;oBAChB,eAAe,EAAE;wBACf,MAAM,EAAE,UAAU;qBACnB;iBACF,CAAC;aACH;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAED,SAAsB,aAAa,CAAC,IAAU,EAAE,MAAc;;QAC5D,MAAM,KAAK,GAAwB,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CACR,MAAM,IAAA,kBAAe,EAAC,IAAI,kCACrB,MAAM,KACT,UAAU,EAAE,IAAI,IAChB,CACH,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC5B,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAbD,sCAaC;AAED,kBAAe,aAAa,CAAC;AAChB,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UiFramework, UiFramework7 } from '../../utils/models';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
uiFramework: UiFramework | UiFramework7;
|
|
5
|
+
bundler?: 'webpack' | 'vite'; // TODO(katerina): Remove when Storybook 7
|
|
6
|
+
storybook7Configuration?: boolean;
|
|
7
|
+
js?: boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cli": "nx",
|
|
3
|
+
"title": "Add Storybook Configuration to the workspace",
|
|
4
|
+
"description": "Add Storybook Configuration to the workspace.",
|
|
5
|
+
"$id": "init-storybook-plugin",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"uiFramework": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Storybook UI Framework to use.",
|
|
11
|
+
"enum": [
|
|
12
|
+
"@storybook/angular",
|
|
13
|
+
"@storybook/html-webpack5",
|
|
14
|
+
"@storybook/nextjs",
|
|
15
|
+
"@storybook/preact-webpack5",
|
|
16
|
+
"@storybook/react-webpack5",
|
|
17
|
+
"@storybook/react-vite",
|
|
18
|
+
"@storybook/server-webpack5",
|
|
19
|
+
"@storybook/svelte-webpack5",
|
|
20
|
+
"@storybook/svelte-vite",
|
|
21
|
+
"@storybook/sveltekit",
|
|
22
|
+
"@storybook/vue-webpack5",
|
|
23
|
+
"@storybook/vue-vite",
|
|
24
|
+
"@storybook/vue3-webpack5",
|
|
25
|
+
"@storybook/vue3-vite",
|
|
26
|
+
"@storybook/web-components-webpack5",
|
|
27
|
+
"@storybook/web-components-vite",
|
|
28
|
+
"@storybook/react",
|
|
29
|
+
"@storybook/html",
|
|
30
|
+
"@storybook/web-components",
|
|
31
|
+
"@storybook/vue",
|
|
32
|
+
"@storybook/vue3",
|
|
33
|
+
"@storybook/svelte",
|
|
34
|
+
"@storybook/react-native"
|
|
35
|
+
],
|
|
36
|
+
"x-prompt": "What UI framework plugin should storybook use?",
|
|
37
|
+
"x-priority": "important"
|
|
38
|
+
},
|
|
39
|
+
"bundler": {
|
|
40
|
+
"description": "The bundler to use.",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"enum": ["vite", "webpack"],
|
|
43
|
+
"x-prompt": "Which bundler do you want to use?",
|
|
44
|
+
"default": "webpack",
|
|
45
|
+
"x-priority": "important"
|
|
46
|
+
},
|
|
47
|
+
"storybook7Configuration": {
|
|
48
|
+
"description": "Configure your workspace using Storybook version 7.",
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"default": true,
|
|
51
|
+
"hidden": false,
|
|
52
|
+
"aliases": ["storybook7betaConfiguration"]
|
|
53
|
+
},
|
|
54
|
+
"js": {
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
57
|
+
"default": false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function callUpgrade(schema: Schema): 1 | Buffer;
|
|
4
|
+
export declare function callAutomigrate(allStorybookProjects: {
|
|
5
|
+
[key: string]: {
|
|
6
|
+
configDir: string;
|
|
7
|
+
uiFramework: string;
|
|
8
|
+
viteConfigFilePath?: string;
|
|
9
|
+
};
|
|
10
|
+
}, schema: Schema): {
|
|
11
|
+
successfulProjects: {};
|
|
12
|
+
failedProjects: {};
|
|
13
|
+
};
|