@nx/storybook 17.3.0-beta.5 → 17.3.0-beta.8
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 +3 -0
- package/src/generators/configuration/lib/util-functions.d.ts +1 -0
- package/src/generators/configuration/lib/util-functions.js +26 -19
- package/src/generators/init/init.js +12 -4
- package/src/generators/init/schema.d.ts +2 -0
- package/src/generators/init/schema.json +12 -0
- package/src/migrations/update-16-5-0/move-storybook-tsconfig.js +1 -0
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.8",
|
|
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.8",
|
|
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.8",
|
|
38
|
+
"@nx/js": "17.3.0-beta.8",
|
|
39
|
+
"@nx/eslint": "17.3.0-beta.8",
|
|
40
|
+
"@nrwl/storybook": "17.3.0-beta.8"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -66,6 +66,9 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
66
66
|
(0, util_functions_1.updateLintConfig)(tree, schema);
|
|
67
67
|
(0, util_functions_1.addBuildStorybookToCacheableOperations)(tree);
|
|
68
68
|
(0, util_functions_1.addStorybookToNamedInputs)(tree);
|
|
69
|
+
if (!hasPlugin) {
|
|
70
|
+
(0, util_functions_1.addStorybookToTargetDefaults)(tree);
|
|
71
|
+
}
|
|
69
72
|
let devDeps = {};
|
|
70
73
|
if (!hasPlugin) {
|
|
71
74
|
if (schema.uiFramework === '@storybook/angular') {
|
|
@@ -18,6 +18,7 @@ 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 addStorybookToTargetDefaults(tree: Tree): void;
|
|
21
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;
|
|
@@ -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,28 +338,35 @@ 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;
|
|
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;
|
|
363
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
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
5
6
|
const semver_1 = require("semver");
|
|
7
|
+
const plugin_1 = require("../../plugins/plugin");
|
|
6
8
|
const utilities_1 = require("../../utils/utilities");
|
|
7
9
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
function checkDependenciesInstalled(host) {
|
|
10
|
+
function checkDependenciesInstalled(host, schema) {
|
|
9
11
|
const devDependencies = {
|
|
10
12
|
'@nx/storybook': versions_1.nxVersion,
|
|
13
|
+
'@nx/web': versions_1.nxVersion,
|
|
11
14
|
};
|
|
12
15
|
if (process.env.NX_PCV3 === 'true') {
|
|
13
16
|
let storybook7VersionToInstall = versions_1.storybookVersion;
|
|
@@ -18,7 +21,7 @@ function checkDependenciesInstalled(host) {
|
|
|
18
21
|
}
|
|
19
22
|
devDependencies['storybook'] = storybook7VersionToInstall;
|
|
20
23
|
}
|
|
21
|
-
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
|
|
24
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
22
25
|
}
|
|
23
26
|
function addCacheableOperation(tree) {
|
|
24
27
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -47,14 +50,19 @@ function moveToDevDependencies(tree) {
|
|
|
47
50
|
return updated ? () => (0, devkit_1.installPackagesTask)(tree) : () => { };
|
|
48
51
|
}
|
|
49
52
|
async function initGenerator(tree, schema) {
|
|
50
|
-
addCacheableOperation(tree);
|
|
51
53
|
if (process.env.NX_PCV3 === 'true') {
|
|
52
54
|
(0, utilities_1.addPlugin)(tree);
|
|
53
55
|
}
|
|
56
|
+
else {
|
|
57
|
+
addCacheableOperation(tree);
|
|
58
|
+
}
|
|
54
59
|
const tasks = [];
|
|
55
60
|
if (!schema.skipPackageJson) {
|
|
56
61
|
tasks.push(moveToDevDependencies(tree));
|
|
57
|
-
tasks.push(checkDependenciesInstalled(tree));
|
|
62
|
+
tasks.push(checkDependenciesInstalled(tree, schema));
|
|
63
|
+
}
|
|
64
|
+
if (schema.updatePackageScripts) {
|
|
65
|
+
await (0, update_package_scripts_1.updatePackageScripts)(tree, plugin_1.createNodes);
|
|
58
66
|
}
|
|
59
67
|
if (!schema.skipFormat) {
|
|
60
68
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -14,6 +14,18 @@
|
|
|
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
|
|
23
|
+
},
|
|
24
|
+
"updatePackageScripts": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"x-priority": "internal",
|
|
27
|
+
"description": "Update `package.json` scripts with inferred targets",
|
|
28
|
+
"default": false
|
|
17
29
|
}
|
|
18
30
|
}
|
|
19
31
|
}
|
|
@@ -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;
|