@nx/storybook 18.0.6 → 18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/storybook",
3
- "version": "18.0.6",
3
+ "version": "18.0.7",
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.0.6",
33
+ "@nx/devkit": "18.0.7",
34
34
  "@phenomnomnominal/tsquery": "~5.0.1",
35
35
  "semver": "^7.5.3",
36
36
  "tslib": "^2.3.0",
37
- "@nx/cypress": "18.0.6",
38
- "@nx/js": "18.0.6",
39
- "@nx/eslint": "18.0.6",
40
- "@nrwl/storybook": "18.0.6"
37
+ "@nx/cypress": "18.0.7",
38
+ "@nx/js": "18.0.7",
39
+ "@nx/eslint": "18.0.7",
40
+ "@nrwl/storybook": "18.0.7"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -65,7 +65,7 @@ exports.createNodes = [
65
65
  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 = getStorybookConfig(configFilePath, context);
68
+ const storybookFramework = getStorybookFramework(configFilePath, context);
69
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.`);
@@ -162,35 +162,33 @@ function serveStaticTarget(options, projectRoot) {
162
162
  };
163
163
  return targetConfig;
164
164
  }
165
- function getStorybookConfig(configFilePath, context) {
165
+ function getStorybookFramework(configFilePath, context) {
166
166
  const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
167
167
  const mainTsJs = (0, fs_1.readFileSync)(resolvedPath, 'utf-8');
168
168
  const importDeclarations = tsquery_1.tsquery.query(mainTsJs, 'ImportDeclaration:has(ImportSpecifier:has([text="StorybookConfig"]))')?.[0];
169
+ if (!importDeclarations) {
170
+ return parseFrameworkName(mainTsJs);
171
+ }
169
172
  const storybookConfigImportPackage = tsquery_1.tsquery.query(importDeclarations, 'StringLiteral')?.[0];
170
- let frameworkName;
171
173
  if (storybookConfigImportPackage?.getText() === `'@storybook/core-common'`) {
172
- const frameworkPropertyAssignment = tsquery_1.tsquery.query(mainTsJs, `PropertyAssignment:has(Identifier:has([text="framework"]))`)?.[0];
173
- if (!frameworkPropertyAssignment) {
174
- return;
175
- }
176
- const propertyAssignments = tsquery_1.tsquery.query(frameworkPropertyAssignment, `PropertyAssignment:has(Identifier:has([text="name"]))`);
177
- const namePropertyAssignment = propertyAssignments?.find((expression) => {
178
- return expression.getText().startsWith('name');
179
- });
180
- if (!namePropertyAssignment) {
181
- const storybookConfigImportPackage = tsquery_1.tsquery.query(frameworkPropertyAssignment, 'StringLiteral')?.[0];
182
- frameworkName = storybookConfigImportPackage?.getText();
183
- }
184
- else {
185
- frameworkName = tsquery_1.tsquery
186
- .query(namePropertyAssignment, `StringLiteral`)?.[0]
187
- ?.getText();
188
- }
174
+ return parseFrameworkName(mainTsJs);
189
175
  }
190
- else {
191
- frameworkName = storybookConfigImportPackage?.getText();
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();
192
190
  }
193
- return frameworkName;
191
+ return tsquery_1.tsquery.query(namePropertyAssignment, `StringLiteral`)?.[0]?.getText();
194
192
  }
195
193
  function getOutputs(projectRoot) {
196
194
  const normalizedOutputPath = normalizeOutputPath(projectRoot);