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