@nx/storybook 17.3.0-beta.4 → 17.3.0-beta.5
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/package.json +6 -6
- package/src/generators/configuration/configuration.js +4 -2
- package/src/generators/configuration/lib/util-functions.d.ts +5 -2
- package/src/generators/configuration/lib/util-functions.js +7 -2
- package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +6 -1
- package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +5 -1
- package/src/plugins/plugin.js +24 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "17.3.0-beta.
|
|
3
|
+
"version": "17.3.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nx/devkit": "17.3.0-beta.
|
|
33
|
+
"@nx/devkit": "17.3.0-beta.5",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"semver": "7.5.3",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/cypress": "17.3.0-beta.
|
|
38
|
-
"@nx/js": "17.3.0-beta.
|
|
39
|
-
"@nx/eslint": "17.3.0-beta.
|
|
40
|
-
"@nrwl/storybook": "17.3.0-beta.
|
|
37
|
+
"@nx/cypress": "17.3.0-beta.5",
|
|
38
|
+
"@nx/js": "17.3.0-beta.5",
|
|
39
|
+
"@nx/eslint": "17.3.0-beta.5",
|
|
40
|
+
"@nrwl/storybook": "17.3.0-beta.5"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -20,7 +20,9 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
20
20
|
const tasks = [];
|
|
21
21
|
const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
22
22
|
const { compiler } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(targets);
|
|
23
|
-
const
|
|
23
|
+
const viteConfig = (0, util_functions_1.findViteConfig)(tree, root);
|
|
24
|
+
const viteConfigFilePath = viteConfig?.fullConfigPath;
|
|
25
|
+
const viteConfigFileName = viteConfig?.viteConfigFileName;
|
|
24
26
|
const nextConfigFilePath = (0, util_functions_1.findNextConfig)(tree, root);
|
|
25
27
|
if (viteConfigFilePath) {
|
|
26
28
|
if (schema.uiFramework === '@storybook/react-webpack5') {
|
|
@@ -54,7 +56,7 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
54
56
|
? 'components'
|
|
55
57
|
: 'src';
|
|
56
58
|
const usesVite = !!viteConfigFilePath || schema.uiFramework?.endsWith('-vite');
|
|
57
|
-
(0, util_functions_1.createProjectStorybookDir)(tree, schema.project, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextConfigFilePath, compiler === 'swc', usesVite, viteConfigFilePath);
|
|
59
|
+
(0, util_functions_1.createProjectStorybookDir)(tree, schema.project, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextConfigFilePath, compiler === 'swc', usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName);
|
|
58
60
|
if (schema.uiFramework !== '@storybook/angular') {
|
|
59
61
|
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
60
62
|
}
|
|
@@ -18,13 +18,16 @@ export declare function configureTsSolutionConfig(tree: Tree, schema: StorybookC
|
|
|
18
18
|
export declare function updateLintConfig(tree: Tree, schema: StorybookConfigureSchema): void;
|
|
19
19
|
export declare function normalizeSchema(schema: StorybookConfigureSchema): StorybookConfigureSchema;
|
|
20
20
|
export declare function addStorybookToNamedInputs(tree: Tree): void;
|
|
21
|
-
export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string): void;
|
|
21
|
+
export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string, hasPlugin?: boolean, viteConfigFileName?: string): void;
|
|
22
22
|
export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
|
|
23
23
|
export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
|
|
24
24
|
export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
|
|
25
25
|
export declare function workspaceHasRootProject(tree: Tree): boolean;
|
|
26
26
|
export declare function rootFileIsTs(tree: Tree, rootFileName: string, tsConfiguration: boolean): boolean;
|
|
27
27
|
export declare function getE2EProjectName(tree: Tree, mainProject: string): Promise<string | undefined>;
|
|
28
|
-
export declare function findViteConfig(tree: Tree, projectRoot: string):
|
|
28
|
+
export declare function findViteConfig(tree: Tree, projectRoot: string): {
|
|
29
|
+
fullConfigPath: string | undefined;
|
|
30
|
+
viteConfigFileName: string | undefined;
|
|
31
|
+
};
|
|
29
32
|
export declare function findNextConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
30
33
|
export declare function renameAndMoveOldTsConfig(projectRoot: string, pathToStorybookConfigFile: string, tree: Tree): void;
|
|
@@ -360,7 +360,7 @@ function addStorybookToNamedInputs(tree) {
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
exports.addStorybookToNamedInputs = addStorybookToNamedInputs;
|
|
363
|
-
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath) {
|
|
363
|
+
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName) {
|
|
364
364
|
let projectDirectory = projectType === 'application'
|
|
365
365
|
? isNextJs
|
|
366
366
|
? 'components'
|
|
@@ -391,6 +391,8 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
391
391
|
usesVite,
|
|
392
392
|
isRootProject: projectIsRootProjectInStandaloneWorkspace,
|
|
393
393
|
viteConfigFilePath,
|
|
394
|
+
hasPlugin,
|
|
395
|
+
viteConfigFileName,
|
|
394
396
|
});
|
|
395
397
|
if (js) {
|
|
396
398
|
(0, devkit_1.toJS)(tree);
|
|
@@ -484,7 +486,10 @@ function findViteConfig(tree, projectRoot) {
|
|
|
484
486
|
for (const ext of allowsExt) {
|
|
485
487
|
const viteConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `vite.config.${ext}`);
|
|
486
488
|
if (tree.exists(viteConfigPath)) {
|
|
487
|
-
return
|
|
489
|
+
return {
|
|
490
|
+
fullConfigPath: viteConfigPath,
|
|
491
|
+
viteConfigFileName: `vite.config.${ext}`,
|
|
492
|
+
};
|
|
488
493
|
}
|
|
489
494
|
}
|
|
490
495
|
}
|
|
@@ -13,7 +13,12 @@ const config = {
|
|
|
13
13
|
framework: {
|
|
14
14
|
name: '<%= uiFramework %>',
|
|
15
15
|
options: {
|
|
16
|
-
|
|
16
|
+
<% if (usesVite && viteConfigFilePath && hasPlugin) { %>
|
|
17
|
+
builder: {
|
|
18
|
+
viteConfigPath: '<%= viteConfigFileName %>',
|
|
19
|
+
},
|
|
20
|
+
<% } %>
|
|
21
|
+
<% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
|
|
17
22
|
builder: {
|
|
18
23
|
viteConfigPath: '<%= viteConfigFilePath %>',
|
|
19
24
|
},
|
|
@@ -14,7 +14,11 @@ const config: StorybookConfig = {
|
|
|
14
14
|
framework: {
|
|
15
15
|
name: '<%= uiFramework %>',
|
|
16
16
|
options: {
|
|
17
|
-
<% if (usesVite && viteConfigFilePath) { %>
|
|
17
|
+
<% if (usesVite && viteConfigFilePath && hasPlugin) { %>
|
|
18
|
+
builder: {
|
|
19
|
+
viteConfigPath: '<%= viteConfigFileName %>',
|
|
20
|
+
},
|
|
21
|
+
<% } %><% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
|
|
18
22
|
builder: {
|
|
19
23
|
viteConfigPath: '<%= viteConfigFilePath %>',
|
|
20
24
|
},
|
package/src/plugins/plugin.js
CHANGED
|
@@ -60,7 +60,7 @@ exports.createNodes = [
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
// For root projects, the name is not inferred from root package.json, so we need to manually set it.
|
|
63
|
-
// TODO(
|
|
63
|
+
// TODO(katerina): Remove this workaround once Craigory's PR (https://github.com/nrwl/nx/pull/21125) is merged
|
|
64
64
|
if (projectRoot === '.') {
|
|
65
65
|
result.projects[projectRoot]['name'] = projectName;
|
|
66
66
|
}
|
|
@@ -73,23 +73,22 @@ function buildStorybookTargets(configFilePath, projectRoot, options, context, pr
|
|
|
73
73
|
const storybookFramework = getStorybookConfig(configFilePath, context);
|
|
74
74
|
const frameworkIsAngular = storybookFramework === "'@storybook/angular'";
|
|
75
75
|
const targets = {};
|
|
76
|
-
targets[options.buildStorybookTargetName] = buildTarget(namedInputs, buildOutputs,
|
|
77
|
-
targets[options.serveStorybookTargetName] = serveTarget(
|
|
78
|
-
targets[options.testStorybookTargetName] = testTarget(
|
|
76
|
+
targets[options.buildStorybookTargetName] = buildTarget(namedInputs, buildOutputs, projectRoot, frameworkIsAngular, projectName, configFilePath);
|
|
77
|
+
targets[options.serveStorybookTargetName] = serveTarget(projectRoot, frameworkIsAngular, projectName, configFilePath);
|
|
78
|
+
targets[options.testStorybookTargetName] = testTarget(projectRoot);
|
|
79
79
|
targets[options.staticStorybookTargetName] = serveStaticTarget(options, projectRoot);
|
|
80
80
|
return targets;
|
|
81
81
|
}
|
|
82
|
-
function buildTarget(namedInputs, outputs,
|
|
83
|
-
const outputDir = (0, devkit_1.joinPathFragments)('dist/storybook', projectRoot);
|
|
82
|
+
function buildTarget(namedInputs, outputs, projectRoot, frameworkIsAngular, projectName, configFilePath) {
|
|
84
83
|
let targetConfig;
|
|
85
84
|
if (frameworkIsAngular) {
|
|
86
85
|
targetConfig = {
|
|
87
86
|
executor: '@storybook/angular:build-storybook',
|
|
88
87
|
options: {
|
|
89
|
-
outputDir: `${outputDir}`,
|
|
90
88
|
configDir: `${(0, path_1.dirname)(configFilePath)}`,
|
|
91
89
|
browserTarget: `${projectName}:build-storybook`,
|
|
92
90
|
compodoc: false,
|
|
91
|
+
outputDir: (0, devkit_1.joinPathFragments)(projectRoot, 'static-storybook'),
|
|
93
92
|
},
|
|
94
93
|
cache: true,
|
|
95
94
|
outputs,
|
|
@@ -109,7 +108,8 @@ function buildTarget(namedInputs, outputs, configFilePath, projectRoot, framewor
|
|
|
109
108
|
}
|
|
110
109
|
else {
|
|
111
110
|
targetConfig = {
|
|
112
|
-
command: `storybook build
|
|
111
|
+
command: `storybook build`,
|
|
112
|
+
options: { cwd: projectRoot },
|
|
113
113
|
cache: true,
|
|
114
114
|
outputs,
|
|
115
115
|
inputs: [
|
|
@@ -124,7 +124,7 @@ function buildTarget(namedInputs, outputs, configFilePath, projectRoot, framewor
|
|
|
124
124
|
}
|
|
125
125
|
return targetConfig;
|
|
126
126
|
}
|
|
127
|
-
function serveTarget(
|
|
127
|
+
function serveTarget(projectRoot, frameworkIsAngular, projectName, configFilePath) {
|
|
128
128
|
if (frameworkIsAngular) {
|
|
129
129
|
return {
|
|
130
130
|
executor: '@storybook/angular:start-storybook',
|
|
@@ -137,13 +137,15 @@ function serveTarget(configFilePath, frameworkIsAngular, projectName) {
|
|
|
137
137
|
}
|
|
138
138
|
else {
|
|
139
139
|
return {
|
|
140
|
-
command: `storybook dev
|
|
140
|
+
command: `storybook dev`,
|
|
141
|
+
options: { cwd: projectRoot },
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
|
-
function testTarget(
|
|
145
|
+
function testTarget(projectRoot) {
|
|
145
146
|
const targetConfig = {
|
|
146
|
-
command: `test-storybook
|
|
147
|
+
command: `test-storybook`,
|
|
148
|
+
options: { cwd: projectRoot },
|
|
147
149
|
inputs: [
|
|
148
150
|
{
|
|
149
151
|
externalDependencies: ['storybook', '@storybook/test-runner'],
|
|
@@ -157,8 +159,7 @@ function serveStaticTarget(options, projectRoot) {
|
|
|
157
159
|
executor: '@nx/web:file-server',
|
|
158
160
|
options: {
|
|
159
161
|
buildTarget: `${options.buildStorybookTargetName}`,
|
|
160
|
-
|
|
161
|
-
staticFilePath: (0, devkit_1.joinPathFragments)('dist/storybook', projectRoot),
|
|
162
|
+
staticFilePath: (0, devkit_1.joinPathFragments)(projectRoot, 'static-storybook'),
|
|
162
163
|
},
|
|
163
164
|
};
|
|
164
165
|
return targetConfig;
|
|
@@ -194,33 +195,21 @@ function getStorybookConfig(configFilePath, context) {
|
|
|
194
195
|
return frameworkName;
|
|
195
196
|
}
|
|
196
197
|
function getOutputs(_projectRoot) {
|
|
197
|
-
// TODO(katerina): need to read the output from CLI args
|
|
198
|
-
// const outputPath = <output path as read from CLI>;
|
|
199
198
|
const normalizedOutputPath = normalizeOutputPath(undefined, _projectRoot);
|
|
200
|
-
const outputs = [
|
|
199
|
+
const outputs = [
|
|
200
|
+
normalizedOutputPath,
|
|
201
|
+
`{options.output-dir}`,
|
|
202
|
+
`{options.outputDir}`,
|
|
203
|
+
`{options.o}`,
|
|
204
|
+
];
|
|
201
205
|
return outputs;
|
|
202
206
|
}
|
|
203
207
|
function normalizeOutputPath(outputPath, projectRoot) {
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
return `{projectRoot}/dist/storybook`;
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
return `{workspaceRoot}/dist/storybook/{projectRoot}`;
|
|
210
|
-
}
|
|
208
|
+
if (projectRoot === '.') {
|
|
209
|
+
return `{projectRoot}/static-storybook`;
|
|
211
210
|
}
|
|
212
211
|
else {
|
|
213
|
-
|
|
214
|
-
return `{workspaceRoot}/${(0, path_1.relative)(devkit_1.workspaceRoot, outputPath)}`;
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
if (outputPath.startsWith('..')) {
|
|
218
|
-
return (0, path_1.join)('{workspaceRoot}', (0, path_1.join)(projectRoot, outputPath));
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
return (0, path_1.join)('{projectRoot}', outputPath);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
212
|
+
return `{workspaceRoot}/{projectRoot}/static-storybook`;
|
|
224
213
|
}
|
|
225
214
|
}
|
|
226
215
|
function normalizeOptions(options) {
|