@nx/storybook 23.0.0-rc.2 → 23.0.0-rc.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.
@@ -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/devkit/internal");
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, internal_3.isUsingTsSolutionSetup)(tree);
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, internal_3.findRuntimeTsConfigName)(projectRoot, tree);
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
- const existing = (0, internal_2.normalizeTargetDefaults)(nxJson.targetDefaults).find((e) => e.target === 'build-storybook' &&
377
- e.executor === undefined &&
378
- e.projects === undefined &&
379
- e.plugin === undefined);
380
- const inputs = existing?.inputs
381
- ? [...existing.inputs]
382
- : [
383
- 'default',
384
- nxJson.namedInputs && 'production' in nxJson.namedInputs
385
- ? '^production'
386
- : '^default',
387
- ];
388
- if (!inputs.includes('{projectRoot}/.storybook/**/*')) {
389
- inputs.push('{projectRoot}/.storybook/**/*');
390
- }
391
- // Drop the negation glob so Storybook rebuilds when .storybook changes.
392
- const negatedIndex = inputs.indexOf('!{projectRoot}/.storybook/**/*');
393
- if (negatedIndex !== -1)
394
- inputs.splice(negatedIndex, 1);
395
- if (!inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
396
- inputs.push('{projectRoot}/tsconfig.storybook.json');
397
- }
398
- (0, internal_2.upsertTargetDefault)(tree, nxJson, {
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, internal_3.getProjectType)(tree, root, projectType) ===
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, internal_3.getProjectType)(tree, root, projectType) ===
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, internal_3.getProjectType)(tree, root, projectType) === 'application'
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
- (0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'build-storybook', cache: true });
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-rc.2",
3
+ "version": "23.0.0-rc.4",
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-rc.2",
96
- "@nx/cypress": "23.0.0-rc.2",
97
- "@nx/js": "23.0.0-rc.2",
98
- "@nx/eslint": "23.0.0-rc.2"
95
+ "@nx/devkit": "23.0.0-rc.4",
96
+ "@nx/cypress": "23.0.0-rc.4",
97
+ "@nx/js": "23.0.0-rc.4",
98
+ "@nx/eslint": "23.0.0-rc.4"
99
99
  },
100
100
  "devDependencies": {
101
101
  "storybook": "9.0.6",
102
- "nx": "23.0.0-rc.2"
102
+ "nx": "23.0.0-rc.4"
103
103
  },
104
104
  "peerDependencies": {
105
105
  "storybook": ">=8.0.0 <11.0.0",
106
- "@nx/web": "23.0.0-rc.2"
106
+ "@nx/web": "23.0.0-rc.4"
107
107
  },
108
108
  "peerDependenciesMeta": {
109
109
  "@nx/web": {