@nx/storybook 23.0.0-rc.3 → 23.0.0
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.
|
@@ -26,8 +26,7 @@ const path_1 = require("path");
|
|
|
26
26
|
const utilities_1 = require("../../../utils/utilities");
|
|
27
27
|
const versions_1 = require("../../../utils/versions");
|
|
28
28
|
const internal_1 = require("@nx/eslint/internal");
|
|
29
|
-
const internal_2 = require("@nx/
|
|
30
|
-
const internal_3 = require("@nx/js/internal");
|
|
29
|
+
const internal_2 = require("@nx/js/internal");
|
|
31
30
|
const DEFAULT_PORT = 4400;
|
|
32
31
|
function addStorybookTarget(tree, projectName, uiFramework, interactionTests) {
|
|
33
32
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
@@ -126,7 +125,7 @@ async function addStaticTarget(tree, opts) {
|
|
|
126
125
|
function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
|
|
127
126
|
const storybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
|
|
128
127
|
const offset = (0, devkit_1.offsetFromRoot)(projectRoot);
|
|
129
|
-
const useTsSolution = (0,
|
|
128
|
+
const useTsSolution = (0, internal_2.isUsingTsSolutionSetup)(tree);
|
|
130
129
|
// First let's check if old configuration file exists
|
|
131
130
|
// If it exists, let's rename it and move it to the new location
|
|
132
131
|
const oldStorybookTsConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, '.storybook/tsconfig.json');
|
|
@@ -175,7 +174,7 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
|
|
|
175
174
|
],
|
|
176
175
|
};
|
|
177
176
|
if (useTsSolution) {
|
|
178
|
-
const runtimeConfig = (0,
|
|
177
|
+
const runtimeConfig = (0, internal_2.findRuntimeTsConfigName)(projectRoot, tree);
|
|
179
178
|
if (runtimeConfig) {
|
|
180
179
|
storybookTsConfig.references ??= [];
|
|
181
180
|
storybookTsConfig.references.push({
|
|
@@ -372,38 +371,34 @@ function addStorybookToNamedInputs(tree) {
|
|
|
372
371
|
}
|
|
373
372
|
}
|
|
374
373
|
function addStorybookToTargetDefaults(tree, setCache = true) {
|
|
375
|
-
const nxJson = (0, devkit_1.readNxJson)(tree)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
//
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
inputs.splice(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
target: 'build-storybook',
|
|
400
|
-
...(setCache && existing?.cache === undefined ? { cache: true } : {}),
|
|
401
|
-
inputs,
|
|
402
|
-
});
|
|
374
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
375
|
+
nxJson.targetDefaults ??= {};
|
|
376
|
+
nxJson.targetDefaults['build-storybook'] ??= {};
|
|
377
|
+
if (setCache) {
|
|
378
|
+
nxJson.targetDefaults['build-storybook'].cache ??= true;
|
|
379
|
+
}
|
|
380
|
+
nxJson.targetDefaults['build-storybook'].inputs ??= [
|
|
381
|
+
'default',
|
|
382
|
+
nxJson.namedInputs && 'production' in nxJson.namedInputs
|
|
383
|
+
? '^production'
|
|
384
|
+
: '^default',
|
|
385
|
+
];
|
|
386
|
+
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/.storybook/**/*')) {
|
|
387
|
+
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/.storybook/**/*');
|
|
388
|
+
}
|
|
389
|
+
// Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
|
|
390
|
+
// because we want to rebuild Storybook if the .storybook folder changes
|
|
391
|
+
const index = nxJson.targetDefaults['build-storybook'].inputs.indexOf('!{projectRoot}/.storybook/**/*');
|
|
392
|
+
if (index !== -1) {
|
|
393
|
+
nxJson.targetDefaults['build-storybook'].inputs.splice(index, 1);
|
|
394
|
+
}
|
|
395
|
+
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
|
|
396
|
+
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/tsconfig.storybook.json');
|
|
397
|
+
}
|
|
403
398
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
404
399
|
}
|
|
405
400
|
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, usesReactNative) {
|
|
406
|
-
let projectDirectory = (0,
|
|
401
|
+
let projectDirectory = (0, internal_2.getProjectType)(tree, root, projectType) ===
|
|
407
402
|
'application'
|
|
408
403
|
? isNextJs
|
|
409
404
|
? 'components'
|
|
@@ -431,7 +426,7 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
431
426
|
interactionTests,
|
|
432
427
|
mainDir,
|
|
433
428
|
isNextJs: isNextJs &&
|
|
434
|
-
(0,
|
|
429
|
+
(0, internal_2.getProjectType)(tree, root, projectType) ===
|
|
435
430
|
'application',
|
|
436
431
|
usesSwc,
|
|
437
432
|
usesVite,
|
|
@@ -458,7 +453,7 @@ function getTsConfigPath(tree, projectName, path) {
|
|
|
458
453
|
const { root, projectType } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
459
454
|
return (0, path_1.join)(root, path?.length > 0
|
|
460
455
|
? path
|
|
461
|
-
: (0,
|
|
456
|
+
: (0, internal_2.getProjectType)(tree, root, projectType) === 'application'
|
|
462
457
|
? 'tsconfig.app.json'
|
|
463
458
|
: 'tsconfig.lib.json');
|
|
464
459
|
}
|
|
@@ -19,12 +19,14 @@ function checkDependenciesInstalled(host, schema) {
|
|
|
19
19
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions ?? true);
|
|
20
20
|
}
|
|
21
21
|
function addCacheableOperation(tree) {
|
|
22
|
-
const nxJson = (0, devkit_1.readNxJson)(tree)
|
|
22
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
23
23
|
const cacheableOperations = nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations;
|
|
24
24
|
if (cacheableOperations && !cacheableOperations.includes('build-storybook')) {
|
|
25
25
|
nxJson.tasksRunnerOptions.default.options.cacheableOperations.push('build-storybook');
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
nxJson.targetDefaults ??= {};
|
|
28
|
+
nxJson.targetDefaults['build-storybook'] ??= {};
|
|
29
|
+
nxJson.targetDefaults['build-storybook'].cache = true;
|
|
28
30
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
29
31
|
}
|
|
30
32
|
function moveToDevDependencies(tree) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "23.0.0
|
|
3
|
+
"version": "23.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -92,18 +92,18 @@
|
|
|
92
92
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
93
93
|
"semver": "^7.6.3",
|
|
94
94
|
"tslib": "^2.3.0",
|
|
95
|
-
"@nx/devkit": "23.0.0
|
|
96
|
-
"@nx/cypress": "23.0.0
|
|
97
|
-
"@nx/js": "23.0.0
|
|
98
|
-
"@nx/eslint": "23.0.0
|
|
95
|
+
"@nx/devkit": "23.0.0",
|
|
96
|
+
"@nx/cypress": "23.0.0",
|
|
97
|
+
"@nx/js": "23.0.0",
|
|
98
|
+
"@nx/eslint": "23.0.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"storybook": "9.0.6",
|
|
102
|
-
"nx": "23.0.0
|
|
102
|
+
"nx": "23.0.0"
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
105
|
"storybook": ">=8.0.0 <11.0.0",
|
|
106
|
-
"@nx/web": "23.0.0
|
|
106
|
+
"@nx/web": "23.0.0"
|
|
107
107
|
},
|
|
108
108
|
"peerDependenciesMeta": {
|
|
109
109
|
"@nx/web": {
|