@nx/storybook 18.3.3 → 18.3.4
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/plugins/plugin.js +9 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.4",
|
|
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": "18.3.
|
|
33
|
+
"@nx/devkit": "18.3.4",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"semver": "^7.5.3",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/cypress": "18.3.
|
|
38
|
-
"@nx/js": "18.3.
|
|
39
|
-
"@nx/eslint": "18.3.
|
|
40
|
-
"@nrwl/storybook": "18.3.
|
|
37
|
+
"@nx/cypress": "18.3.4",
|
|
38
|
+
"@nx/js": "18.3.4",
|
|
39
|
+
"@nx/eslint": "18.3.4",
|
|
40
|
+
"@nrwl/storybook": "18.3.4"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
package/src/plugins/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
9
9
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
10
10
|
const js_1 = require("@nx/js");
|
|
11
|
-
const
|
|
11
|
+
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
12
12
|
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'storybook.hash');
|
|
13
13
|
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
14
14
|
const calculatedTargets = {};
|
|
@@ -25,7 +25,7 @@ const createDependencies = () => {
|
|
|
25
25
|
exports.createDependencies = createDependencies;
|
|
26
26
|
exports.createNodes = [
|
|
27
27
|
'**/.storybook/main.{js,ts,mjs,mts,cjs,cts}',
|
|
28
|
-
(configFilePath, options, context) => {
|
|
28
|
+
async (configFilePath, options, context) => {
|
|
29
29
|
let projectRoot = '';
|
|
30
30
|
if (configFilePath.includes('/.storybook')) {
|
|
31
31
|
projectRoot = (0, path_1.dirname)(configFilePath).replace('/.storybook', '');
|
|
@@ -49,7 +49,7 @@ exports.createNodes = [
|
|
|
49
49
|
const projectName = buildProjectName(projectRoot, context.workspaceRoot);
|
|
50
50
|
const targets = targetsCache[hash]
|
|
51
51
|
? targetsCache[hash]
|
|
52
|
-
: buildStorybookTargets(configFilePath, projectRoot, options, context, projectName);
|
|
52
|
+
: await buildStorybookTargets(configFilePath, projectRoot, options, context, projectName);
|
|
53
53
|
calculatedTargets[hash] = targets;
|
|
54
54
|
const result = {
|
|
55
55
|
projects: {
|
|
@@ -62,11 +62,11 @@ exports.createNodes = [
|
|
|
62
62
|
return result;
|
|
63
63
|
},
|
|
64
64
|
];
|
|
65
|
-
function buildStorybookTargets(configFilePath, projectRoot, options, context, projectName) {
|
|
65
|
+
async function buildStorybookTargets(configFilePath, projectRoot, options, context, projectName) {
|
|
66
66
|
const buildOutputs = getOutputs(projectRoot);
|
|
67
67
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
68
|
-
const storybookFramework = getStorybookFramework(configFilePath, context);
|
|
69
|
-
const frameworkIsAngular = storybookFramework ===
|
|
68
|
+
const storybookFramework = await getStorybookFramework(configFilePath, context);
|
|
69
|
+
const frameworkIsAngular = storybookFramework === '@storybook/angular';
|
|
70
70
|
if (frameworkIsAngular && !projectName) {
|
|
71
71
|
throw new Error(`Could not find a name for the project at '${projectRoot}'. Please make sure that the project has a package.json or project.json file with name specified.`);
|
|
72
72
|
}
|
|
@@ -162,33 +162,10 @@ function serveStaticTarget(options, projectRoot) {
|
|
|
162
162
|
};
|
|
163
163
|
return targetConfig;
|
|
164
164
|
}
|
|
165
|
-
function getStorybookFramework(configFilePath, context) {
|
|
165
|
+
async function getStorybookFramework(configFilePath, context) {
|
|
166
166
|
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
if (!importDeclarations) {
|
|
170
|
-
return parseFrameworkName(mainTsJs);
|
|
171
|
-
}
|
|
172
|
-
const storybookConfigImportPackage = tsquery_1.tsquery.query(importDeclarations, 'StringLiteral')?.[0];
|
|
173
|
-
if (storybookConfigImportPackage?.getText() === `'@storybook/core-common'`) {
|
|
174
|
-
return parseFrameworkName(mainTsJs);
|
|
175
|
-
}
|
|
176
|
-
return storybookConfigImportPackage?.getText();
|
|
177
|
-
}
|
|
178
|
-
function parseFrameworkName(mainTsJs) {
|
|
179
|
-
const frameworkPropertyAssignment = tsquery_1.tsquery.query(mainTsJs, `PropertyAssignment:has(Identifier:has([text="framework"]))`)?.[0];
|
|
180
|
-
if (!frameworkPropertyAssignment) {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
const propertyAssignments = tsquery_1.tsquery.query(frameworkPropertyAssignment, `PropertyAssignment:has(Identifier:has([text="name"]))`);
|
|
184
|
-
const namePropertyAssignment = propertyAssignments?.find((expression) => {
|
|
185
|
-
return expression.getText().startsWith('name');
|
|
186
|
-
});
|
|
187
|
-
if (!namePropertyAssignment) {
|
|
188
|
-
const storybookConfigImportPackage = tsquery_1.tsquery.query(frameworkPropertyAssignment, 'StringLiteral')?.[0];
|
|
189
|
-
return storybookConfigImportPackage?.getText();
|
|
190
|
-
}
|
|
191
|
-
return tsquery_1.tsquery.query(namePropertyAssignment, `StringLiteral`)?.[0]?.getText();
|
|
167
|
+
const { framework } = await (0, config_utils_1.loadConfigFile)(resolvedPath);
|
|
168
|
+
return typeof framework === 'string' ? framework : framework.name;
|
|
192
169
|
}
|
|
193
170
|
function getOutputs(projectRoot) {
|
|
194
171
|
const normalizedOutputPath = normalizeOutputPath(projectRoot);
|