@nx/storybook 17.3.0-beta.4 → 17.3.0-beta.6
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 +7 -2
- package/src/generators/configuration/lib/util-functions.d.ts +6 -2
- package/src/generators/configuration/lib/util-functions.js +33 -21
- 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/generators/init/init.js +7 -4
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +6 -0
- package/src/migrations/update-16-5-0/move-storybook-tsconfig.js +1 -0
- 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.6",
|
|
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.6",
|
|
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.6",
|
|
38
|
+
"@nx/js": "17.3.0-beta.6",
|
|
39
|
+
"@nx/eslint": "17.3.0-beta.6",
|
|
40
|
+
"@nrwl/storybook": "17.3.0-beta.6"
|
|
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
|
}
|
|
@@ -64,6 +66,9 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
64
66
|
(0, util_functions_1.updateLintConfig)(tree, schema);
|
|
65
67
|
(0, util_functions_1.addBuildStorybookToCacheableOperations)(tree);
|
|
66
68
|
(0, util_functions_1.addStorybookToNamedInputs)(tree);
|
|
69
|
+
if (!hasPlugin) {
|
|
70
|
+
(0, util_functions_1.addStorybookToTargetDefaults)(tree);
|
|
71
|
+
}
|
|
67
72
|
let devDeps = {};
|
|
68
73
|
if (!hasPlugin) {
|
|
69
74
|
if (schema.uiFramework === '@storybook/angular') {
|
|
@@ -18,13 +18,17 @@ 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
|
|
21
|
+
export declare function addStorybookToTargetDefaults(tree: Tree): void;
|
|
22
|
+
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
23
|
export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
|
|
23
24
|
export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
|
|
24
25
|
export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
|
|
25
26
|
export declare function workspaceHasRootProject(tree: Tree): boolean;
|
|
26
27
|
export declare function rootFileIsTs(tree: Tree, rootFileName: string, tsConfiguration: boolean): boolean;
|
|
27
28
|
export declare function getE2EProjectName(tree: Tree, mainProject: string): Promise<string | undefined>;
|
|
28
|
-
export declare function findViteConfig(tree: Tree, projectRoot: string):
|
|
29
|
+
export declare function findViteConfig(tree: Tree, projectRoot: string): {
|
|
30
|
+
fullConfigPath: string | undefined;
|
|
31
|
+
viteConfigFileName: string | undefined;
|
|
32
|
+
};
|
|
29
33
|
export declare function findNextConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
30
34
|
export declare function renameAndMoveOldTsConfig(projectRoot: string, pathToStorybookConfigFile: string, tree: Tree): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameAndMoveOldTsConfig = exports.findNextConfig = exports.findViteConfig = exports.getE2EProjectName = exports.rootFileIsTs = exports.workspaceHasRootProject = exports.projectIsRootProjectInStandaloneWorkspace = exports.addBuildStorybookToCacheableOperations = exports.getTsConfigPath = exports.createProjectStorybookDir = exports.addStorybookToNamedInputs = exports.normalizeSchema = exports.updateLintConfig = exports.configureTsSolutionConfig = exports.configureTsProjectConfig = exports.editTsconfigBaseJson = exports.createStorybookTsconfigFile = exports.addStaticTarget = exports.addAngularStorybookTarget = exports.addStorybookTarget = void 0;
|
|
3
|
+
exports.renameAndMoveOldTsConfig = exports.findNextConfig = exports.findViteConfig = exports.getE2EProjectName = exports.rootFileIsTs = exports.workspaceHasRootProject = exports.projectIsRootProjectInStandaloneWorkspace = exports.addBuildStorybookToCacheableOperations = exports.getTsConfigPath = exports.createProjectStorybookDir = exports.addStorybookToTargetDefaults = exports.addStorybookToNamedInputs = exports.normalizeSchema = exports.updateLintConfig = exports.configureTsSolutionConfig = exports.configureTsProjectConfig = exports.editTsconfigBaseJson = exports.createStorybookTsconfigFile = exports.addStaticTarget = exports.addAngularStorybookTarget = exports.addStorybookTarget = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const eslint_1 = require("@nx/eslint");
|
|
@@ -338,29 +338,36 @@ function addStorybookToNamedInputs(tree) {
|
|
|
338
338
|
nxJson.namedInputs.production.push('!{projectRoot}/tsconfig.storybook.json');
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
nxJson.targetDefaults ??= {};
|
|
342
|
-
nxJson.targetDefaults['build-storybook'] ??= {};
|
|
343
|
-
nxJson.targetDefaults['build-storybook'].inputs ??= [
|
|
344
|
-
'default',
|
|
345
|
-
hasProductionFileset ? '^production' : '^default',
|
|
346
|
-
];
|
|
347
|
-
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/.storybook/**/*')) {
|
|
348
|
-
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/.storybook/**/*');
|
|
349
|
-
}
|
|
350
|
-
// Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
|
|
351
|
-
// because we want to rebuild Storybook if the .storybook folder changes
|
|
352
|
-
const index = nxJson.targetDefaults['build-storybook'].inputs.indexOf('!{projectRoot}/.storybook/**/*');
|
|
353
|
-
if (index !== -1) {
|
|
354
|
-
nxJson.targetDefaults['build-storybook'].inputs.splice(index, 1);
|
|
355
|
-
}
|
|
356
|
-
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
|
|
357
|
-
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/tsconfig.storybook.json');
|
|
358
|
-
}
|
|
359
341
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
360
342
|
}
|
|
361
343
|
}
|
|
362
344
|
exports.addStorybookToNamedInputs = addStorybookToNamedInputs;
|
|
363
|
-
function
|
|
345
|
+
function addStorybookToTargetDefaults(tree) {
|
|
346
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
347
|
+
nxJson.targetDefaults ??= {};
|
|
348
|
+
nxJson.targetDefaults['build-storybook'] ??= {};
|
|
349
|
+
nxJson.targetDefaults['build-storybook'].inputs ??= [
|
|
350
|
+
'default',
|
|
351
|
+
nxJson.namedInputs && 'production' in nxJson.namedInputs
|
|
352
|
+
? '^production'
|
|
353
|
+
: '^default',
|
|
354
|
+
];
|
|
355
|
+
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/.storybook/**/*')) {
|
|
356
|
+
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/.storybook/**/*');
|
|
357
|
+
}
|
|
358
|
+
// Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
|
|
359
|
+
// because we want to rebuild Storybook if the .storybook folder changes
|
|
360
|
+
const index = nxJson.targetDefaults['build-storybook'].inputs.indexOf('!{projectRoot}/.storybook/**/*');
|
|
361
|
+
if (index !== -1) {
|
|
362
|
+
nxJson.targetDefaults['build-storybook'].inputs.splice(index, 1);
|
|
363
|
+
}
|
|
364
|
+
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
|
|
365
|
+
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/tsconfig.storybook.json');
|
|
366
|
+
}
|
|
367
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
368
|
+
}
|
|
369
|
+
exports.addStorybookToTargetDefaults = addStorybookToTargetDefaults;
|
|
370
|
+
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName) {
|
|
364
371
|
let projectDirectory = projectType === 'application'
|
|
365
372
|
? isNextJs
|
|
366
373
|
? 'components'
|
|
@@ -391,6 +398,8 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
391
398
|
usesVite,
|
|
392
399
|
isRootProject: projectIsRootProjectInStandaloneWorkspace,
|
|
393
400
|
viteConfigFilePath,
|
|
401
|
+
hasPlugin,
|
|
402
|
+
viteConfigFileName,
|
|
394
403
|
});
|
|
395
404
|
if (js) {
|
|
396
405
|
(0, devkit_1.toJS)(tree);
|
|
@@ -484,7 +493,10 @@ function findViteConfig(tree, projectRoot) {
|
|
|
484
493
|
for (const ext of allowsExt) {
|
|
485
494
|
const viteConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `vite.config.${ext}`);
|
|
486
495
|
if (tree.exists(viteConfigPath)) {
|
|
487
|
-
return
|
|
496
|
+
return {
|
|
497
|
+
fullConfigPath: viteConfigPath,
|
|
498
|
+
viteConfigFileName: `vite.config.${ext}`,
|
|
499
|
+
};
|
|
488
500
|
}
|
|
489
501
|
}
|
|
490
502
|
}
|
|
@@ -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
|
},
|
|
@@ -5,9 +5,10 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const utilities_1 = require("../../utils/utilities");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
function checkDependenciesInstalled(host) {
|
|
8
|
+
function checkDependenciesInstalled(host, schema) {
|
|
9
9
|
const devDependencies = {
|
|
10
10
|
'@nx/storybook': versions_1.nxVersion,
|
|
11
|
+
'@nx/web': versions_1.nxVersion,
|
|
11
12
|
};
|
|
12
13
|
if (process.env.NX_PCV3 === 'true') {
|
|
13
14
|
let storybook7VersionToInstall = versions_1.storybookVersion;
|
|
@@ -18,7 +19,7 @@ function checkDependenciesInstalled(host) {
|
|
|
18
19
|
}
|
|
19
20
|
devDependencies['storybook'] = storybook7VersionToInstall;
|
|
20
21
|
}
|
|
21
|
-
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
|
|
22
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
22
23
|
}
|
|
23
24
|
function addCacheableOperation(tree) {
|
|
24
25
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -47,14 +48,16 @@ function moveToDevDependencies(tree) {
|
|
|
47
48
|
return updated ? () => (0, devkit_1.installPackagesTask)(tree) : () => { };
|
|
48
49
|
}
|
|
49
50
|
async function initGenerator(tree, schema) {
|
|
50
|
-
addCacheableOperation(tree);
|
|
51
51
|
if (process.env.NX_PCV3 === 'true') {
|
|
52
52
|
(0, utilities_1.addPlugin)(tree);
|
|
53
53
|
}
|
|
54
|
+
else {
|
|
55
|
+
addCacheableOperation(tree);
|
|
56
|
+
}
|
|
54
57
|
const tasks = [];
|
|
55
58
|
if (!schema.skipPackageJson) {
|
|
56
59
|
tasks.push(moveToDevDependencies(tree));
|
|
57
|
-
tasks.push(checkDependenciesInstalled(tree));
|
|
60
|
+
tasks.push(checkDependenciesInstalled(tree, schema));
|
|
58
61
|
}
|
|
59
62
|
if (!schema.skipFormat) {
|
|
60
63
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
"description": "Do not add dependencies to `package.json`.",
|
|
15
15
|
"type": "boolean",
|
|
16
16
|
"default": false
|
|
17
|
+
},
|
|
18
|
+
"keepExistingVersions": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"x-priority": "internal",
|
|
21
|
+
"description": "Keep existing dependencies versions",
|
|
22
|
+
"default": false
|
|
17
23
|
}
|
|
18
24
|
}
|
|
19
25
|
}
|
|
@@ -14,6 +14,7 @@ async function default_1(tree) {
|
|
|
14
14
|
(0, util_functions_1.renameAndMoveOldTsConfig)(projectRoot, pathToStorybookConfigFile, tree);
|
|
15
15
|
});
|
|
16
16
|
(0, util_functions_1.addStorybookToNamedInputs)(tree);
|
|
17
|
+
(0, util_functions_1.addStorybookToTargetDefaults)(tree);
|
|
17
18
|
await (0, devkit_1.formatFiles)(tree);
|
|
18
19
|
}
|
|
19
20
|
exports.default = default_1;
|
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) {
|