@nx/storybook 24.0.5 → 24.0.7
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/dist/src/generators/configuration/lib/util-functions.js +9 -6
- package/dist/src/generators/migrate-10/calling-storybook-cli.d.ts +3 -1
- package/dist/src/generators/migrate-10/calling-storybook-cli.js +65 -9
- package/dist/src/generators/migrate-8/helper-functions.js +4 -4
- package/dist/src/generators/migrate-9/helper-functions.js +4 -4
- package/dist/src/plugins/plugin.js +16 -2
- package/dist/src/utils/utilities.d.ts +5 -0
- package/dist/src/utils/utilities.js +6 -1
- package/package.json +15 -8
|
@@ -320,15 +320,18 @@ function addStorybookToNamedInputs(tree, schema) {
|
|
|
320
320
|
if (nxJson.namedInputs) {
|
|
321
321
|
const hasProductionFileset = !!nxJson.namedInputs?.production;
|
|
322
322
|
if (hasProductionFileset) {
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
const storiesExclusion = `!{projectRoot}/${utilities_1.storybookFilePatterns.stories}`;
|
|
324
|
+
if (!nxJson.namedInputs.production.includes(storiesExclusion)) {
|
|
325
|
+
nxJson.namedInputs.production.push(storiesExclusion);
|
|
325
326
|
}
|
|
326
|
-
|
|
327
|
-
|
|
327
|
+
const configExclusion = `!{projectRoot}/${utilities_1.storybookFilePatterns.config}`;
|
|
328
|
+
if (!nxJson.namedInputs.production.includes(configExclusion)) {
|
|
329
|
+
nxJson.namedInputs.production.push(configExclusion);
|
|
328
330
|
}
|
|
331
|
+
const tsconfigExclusion = `!{projectRoot}/${utilities_1.storybookFilePatterns.tsconfig}`;
|
|
329
332
|
if (schema.uiFramework !== '@storybook/angular' &&
|
|
330
|
-
!nxJson.namedInputs.production.includes(
|
|
331
|
-
nxJson.namedInputs.production.push(
|
|
333
|
+
!nxJson.namedInputs.production.includes(tsconfigExclusion)) {
|
|
334
|
+
nxJson.namedInputs.production.push(tsconfigExclusion);
|
|
332
335
|
}
|
|
333
336
|
}
|
|
334
337
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Schema } from './schema';
|
|
2
|
-
export declare function callUpgrade(schema: Schema):
|
|
2
|
+
export declare function callUpgrade(schema: Schema): {
|
|
3
|
+
success: boolean;
|
|
4
|
+
};
|
|
3
5
|
export declare function checkStorybookInstalled(packageJson: Record<string, any>): boolean;
|
|
@@ -4,6 +4,7 @@ exports.callUpgrade = callUpgrade;
|
|
|
4
4
|
exports.checkStorybookInstalled = checkStorybookInstalled;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
7
|
+
const path_1 = require("path");
|
|
7
8
|
function callUpgrade(schema) {
|
|
8
9
|
const packageManager = (0, devkit_1.detectPackageManager)();
|
|
9
10
|
const pm = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
@@ -16,10 +17,20 @@ function callUpgrade(schema) {
|
|
|
16
17
|
],
|
|
17
18
|
color: 'blue',
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const nxVersions = readNxDependencyVersions();
|
|
21
|
+
try {
|
|
22
|
+
(0, child_process_1.execSync)(`${pm.dlx} ${packageManager === 'yarn' ? 'storybook' : 'storybook@latest'} upgrade ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, {
|
|
23
|
+
stdio: [0, 1, 2],
|
|
24
|
+
windowsHide: true,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
// The CLI installed the versions it bumped, and Nx skips its own install
|
|
29
|
+
// when the declarations end up unchanged, so reinstall here.
|
|
30
|
+
if (restoreNxDependencyVersions(nxVersions)) {
|
|
31
|
+
installRestoredNxVersions(pm.install);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
23
34
|
devkit_1.output.log({
|
|
24
35
|
title: `Storybook packages upgraded.`,
|
|
25
36
|
bodyLines: [
|
|
@@ -40,12 +51,57 @@ function callUpgrade(schema) {
|
|
|
40
51
|
color: 'red',
|
|
41
52
|
});
|
|
42
53
|
console.log(e);
|
|
43
|
-
return
|
|
54
|
+
return { success: false };
|
|
55
|
+
}
|
|
56
|
+
return { success: true };
|
|
57
|
+
}
|
|
58
|
+
function installRestoredNxVersions(installCommand) {
|
|
59
|
+
try {
|
|
60
|
+
(0, child_process_1.execSync)(installCommand, {
|
|
61
|
+
cwd: devkit_1.workspaceRoot,
|
|
62
|
+
stdio: [0, 1, 2],
|
|
63
|
+
windowsHide: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
devkit_1.output.warn({
|
|
68
|
+
title: 'Failed to install the restored Nx package versions',
|
|
69
|
+
bodyLines: [`Run "${installCommand}" to install them.`],
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const dependencySections = ['dependencies', 'devDependencies'];
|
|
74
|
+
function isNxPackage(name) {
|
|
75
|
+
return name === 'nx' || name.startsWith('@nx/');
|
|
76
|
+
}
|
|
77
|
+
function readNxDependencyVersions() {
|
|
78
|
+
const packageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(devkit_1.workspaceRoot, 'package.json'));
|
|
79
|
+
const versions = {};
|
|
80
|
+
for (const section of dependencySections) {
|
|
81
|
+
versions[section] = Object.fromEntries(Object.entries(packageJson[section] ?? {}).filter(([name]) => isNxPackage(name)));
|
|
82
|
+
}
|
|
83
|
+
return versions;
|
|
84
|
+
}
|
|
85
|
+
function restoreNxDependencyVersions(versions) {
|
|
86
|
+
const packageJsonPath = (0, path_1.join)(devkit_1.workspaceRoot, 'package.json');
|
|
87
|
+
const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
88
|
+
let changed = false;
|
|
89
|
+
for (const section of dependencySections) {
|
|
90
|
+
for (const [name, version] of Object.entries(versions[section])) {
|
|
91
|
+
if (packageJson[section]?.[name] !== version) {
|
|
92
|
+
packageJson[section][name] = version;
|
|
93
|
+
changed = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (changed) {
|
|
98
|
+
(0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
44
99
|
}
|
|
100
|
+
return changed;
|
|
45
101
|
}
|
|
46
102
|
function checkStorybookInstalled(packageJson) {
|
|
47
|
-
return ((packageJson.dependencies['storybook'] ||
|
|
48
|
-
packageJson.devDependencies['storybook']) &&
|
|
49
|
-
(packageJson.dependencies['@nx/storybook'] ||
|
|
50
|
-
packageJson.devDependencies['@nx/storybook']));
|
|
103
|
+
return ((packageJson.dependencies?.['storybook'] ||
|
|
104
|
+
packageJson.devDependencies?.['storybook']) &&
|
|
105
|
+
(packageJson.dependencies?.['@nx/storybook'] ||
|
|
106
|
+
packageJson.devDependencies?.['@nx/storybook']));
|
|
51
107
|
}
|
|
@@ -117,10 +117,10 @@ function handleMigrationResult(migrateResult, allStorybookProjects) {
|
|
|
117
117
|
return migrateResult;
|
|
118
118
|
}
|
|
119
119
|
function checkStorybookInstalled(packageJson) {
|
|
120
|
-
return ((packageJson.dependencies['@storybook/core-server'] ||
|
|
121
|
-
packageJson.devDependencies['@storybook/core-server']) &&
|
|
122
|
-
(packageJson.dependencies['@nx/storybook'] ||
|
|
123
|
-
packageJson.devDependencies['@nx/storybook']));
|
|
120
|
+
return ((packageJson.dependencies?.['@storybook/core-server'] ||
|
|
121
|
+
packageJson.devDependencies?.['@storybook/core-server']) &&
|
|
122
|
+
(packageJson.dependencies?.['@nx/storybook'] ||
|
|
123
|
+
packageJson.devDependencies?.['@nx/storybook']));
|
|
124
124
|
}
|
|
125
125
|
function logResult(tree, migrationSummary) {
|
|
126
126
|
devkit_1.output.log({
|
|
@@ -118,10 +118,10 @@ function handleMigrationResult(migrateResult, allStorybookProjects) {
|
|
|
118
118
|
return migrateResult;
|
|
119
119
|
}
|
|
120
120
|
function checkStorybookInstalled(packageJson) {
|
|
121
|
-
return ((packageJson.dependencies['storybook'] ||
|
|
122
|
-
packageJson.devDependencies['storybook']) &&
|
|
123
|
-
(packageJson.dependencies['@nx/storybook'] ||
|
|
124
|
-
packageJson.devDependencies['@nx/storybook']));
|
|
121
|
+
return ((packageJson.dependencies?.['storybook'] ||
|
|
122
|
+
packageJson.devDependencies?.['storybook']) &&
|
|
123
|
+
(packageJson.dependencies?.['@nx/storybook'] ||
|
|
124
|
+
packageJson.devDependencies?.['@nx/storybook']));
|
|
125
125
|
}
|
|
126
126
|
function logResult(tree, migrationSummary) {
|
|
127
127
|
devkit_1.output.log({
|
|
@@ -11,6 +11,12 @@ const internal_2 = require("@nx/js/internal");
|
|
|
11
11
|
const utilities_1 = require("../utils/utilities");
|
|
12
12
|
const dev_server_ready_check_1 = require("../utils/dev-server-ready-check");
|
|
13
13
|
const storybookConfigGlob = '**/.storybook/main.{js,ts,mjs,mts,cjs,cts}';
|
|
14
|
+
// `production` usually excludes these files. Its `!{projectRoot}/` exclusions
|
|
15
|
+
// don't filter `{workspaceRoot}/` filesets, so these keep the files hashed.
|
|
16
|
+
const storybookFileInputs = Object.values(utilities_1.storybookFilePatterns).map((pattern) => `{workspaceRoot}/{projectRoot}/${pattern}`);
|
|
17
|
+
// `^production` drops dependencies' stories too, which a host Storybook loads
|
|
18
|
+
// from the projects it depends on.
|
|
19
|
+
const dependencyStoriesInput = `^{projectRoot}/${utilities_1.storybookFilePatterns.stories}`;
|
|
14
20
|
// Vite-builder frameworks we infer the addon target for. The addon itself only
|
|
15
21
|
// checks that the resolved builder is Vite, so this list is conservative rather
|
|
16
22
|
// than exhaustive. `@storybook/sveltekit` uses the Vite builder despite the name.
|
|
@@ -40,7 +46,10 @@ exports.createNodes = [
|
|
|
40
46
|
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
41
47
|
try {
|
|
42
48
|
const { entries, preErrors } = await filterStorybookConfigs(configFilePaths, context);
|
|
43
|
-
const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot),
|
|
49
|
+
const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), {
|
|
50
|
+
...normalizedOptions,
|
|
51
|
+
namedInputs: context.nxJsonConfiguration.namedInputs ?? {},
|
|
52
|
+
}, context, entries.map(() => [lockFileName]));
|
|
44
53
|
let results = [];
|
|
45
54
|
let nodeErrors = [];
|
|
46
55
|
try {
|
|
@@ -136,7 +145,12 @@ async function buildStorybookTargets(configFilePath, projectRoot, options, conte
|
|
|
136
145
|
function storybookInputs(namedInputs, frameworkIsAngular, hasTestRunner) {
|
|
137
146
|
return [
|
|
138
147
|
...('production' in namedInputs
|
|
139
|
-
? [
|
|
148
|
+
? [
|
|
149
|
+
'production',
|
|
150
|
+
...storybookFileInputs,
|
|
151
|
+
'^production',
|
|
152
|
+
dependencyStoriesInput,
|
|
153
|
+
]
|
|
140
154
|
: ['default', '^default']),
|
|
141
155
|
{
|
|
142
156
|
externalDependencies: [
|
|
@@ -11,6 +11,11 @@ export declare const Constants: {
|
|
|
11
11
|
jsonIndentLevel: number;
|
|
12
12
|
coreAddonPrefix: string;
|
|
13
13
|
};
|
|
14
|
+
export declare const storybookFilePatterns: {
|
|
15
|
+
stories: string;
|
|
16
|
+
config: string;
|
|
17
|
+
tsconfig: string;
|
|
18
|
+
};
|
|
14
19
|
export declare function getStorybookVersionToInstall(tree: Tree): string;
|
|
15
20
|
export declare function safeFileDelete(tree: Tree, path: string): boolean;
|
|
16
21
|
export type TsConfig = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Constants = exports.getInstalledStorybookVersion = exports.storybookMajorVersion = void 0;
|
|
3
|
+
exports.storybookFilePatterns = exports.Constants = exports.getInstalledStorybookVersion = exports.storybookMajorVersion = void 0;
|
|
4
4
|
exports.getStorybookVersionToInstall = getStorybookVersionToInstall;
|
|
5
5
|
exports.safeFileDelete = safeFileDelete;
|
|
6
6
|
exports.dedupe = dedupe;
|
|
@@ -22,6 +22,11 @@ exports.Constants = {
|
|
|
22
22
|
jsonIndentLevel: 2,
|
|
23
23
|
coreAddonPrefix: '@storybook/addon-',
|
|
24
24
|
};
|
|
25
|
+
exports.storybookFilePatterns = {
|
|
26
|
+
stories: '**/*.stories.@(js|jsx|ts|tsx|mdx)',
|
|
27
|
+
config: '.storybook/**/*',
|
|
28
|
+
tsconfig: 'tsconfig.storybook.json',
|
|
29
|
+
};
|
|
25
30
|
function getStorybookVersionToInstall(tree) {
|
|
26
31
|
return (0, versions_1.versions)(tree).storybookVersion;
|
|
27
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -97,25 +97,32 @@
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@nx/devkit": "24.0.
|
|
100
|
+
"@nx/devkit": "24.0.7",
|
|
101
101
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
102
102
|
"semver": "^7.6.3",
|
|
103
103
|
"tslib": "^2.3.0",
|
|
104
|
-
"@nx/
|
|
105
|
-
"@nx/
|
|
106
|
-
"@nx/eslint": "24.0.5"
|
|
104
|
+
"@nx/js": "24.0.7",
|
|
105
|
+
"@nx/eslint": "24.0.7"
|
|
107
106
|
},
|
|
108
107
|
"devDependencies": {
|
|
109
|
-
"nx": "24.0.
|
|
108
|
+
"nx": "24.0.7",
|
|
110
109
|
"storybook": "9.0.6"
|
|
111
110
|
},
|
|
112
111
|
"peerDependencies": {
|
|
113
|
-
"@nx/
|
|
114
|
-
"
|
|
112
|
+
"@nx/cypress": "24.0.7",
|
|
113
|
+
"@nx/web": "24.0.7",
|
|
114
|
+
"storybook": ">=8.0.0 <11.0.0",
|
|
115
|
+
"typescript": "^5.8.0 || ^6.0.0"
|
|
115
116
|
},
|
|
116
117
|
"peerDependenciesMeta": {
|
|
118
|
+
"@nx/cypress": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
117
121
|
"@nx/web": {
|
|
118
122
|
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"typescript": {
|
|
125
|
+
"optional": true
|
|
119
126
|
}
|
|
120
127
|
},
|
|
121
128
|
"publishConfig": {
|