@nx/react 0.0.0-pr-27957-a99d5ea → 0.0.0-pr-28218-5048fd1

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.
Files changed (55) hide show
  1. package/generators.json +5 -11
  2. package/index.d.ts +0 -1
  3. package/index.js +1 -3
  4. package/package.json +8 -9
  5. package/plugins/storybook/index.js +1 -2
  6. package/src/generators/application/application.js +0 -1
  7. package/src/generators/application/lib/normalize-options.d.ts +1 -1
  8. package/src/generators/application/lib/normalize-options.js +2 -3
  9. package/src/generators/application/schema.d.ts +0 -1
  10. package/src/generators/application/schema.json +3 -9
  11. package/src/generators/component/component.d.ts +0 -1
  12. package/src/generators/component/component.js +0 -7
  13. package/src/generators/component/lib/normalize-options.js +0 -7
  14. package/src/generators/component/schema.d.ts +2 -20
  15. package/src/generators/component/schema.json +0 -29
  16. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
  17. package/src/generators/federate-module/federate-module.js +4 -5
  18. package/src/generators/hook/hook.d.ts +0 -1
  19. package/src/generators/hook/hook.js +9 -42
  20. package/src/generators/hook/schema.d.ts +3 -17
  21. package/src/generators/hook/schema.json +0 -29
  22. package/src/generators/host/host.d.ts +0 -1
  23. package/src/generators/host/host.js +2 -8
  24. package/src/generators/host/lib/add-module-federation-files.js +2 -2
  25. package/src/generators/host/lib/normalize-remote.js +10 -5
  26. package/src/generators/host/schema.d.ts +0 -1
  27. package/src/generators/host/schema.json +0 -6
  28. package/src/generators/library/lib/normalize-options.js +0 -1
  29. package/src/generators/library/library.js +1 -4
  30. package/src/generators/library/schema.d.ts +0 -1
  31. package/src/generators/library/schema.json +2 -7
  32. package/src/generators/redux/redux.d.ts +0 -1
  33. package/src/generators/redux/redux.js +0 -12
  34. package/src/generators/redux/schema.d.ts +3 -5
  35. package/src/generators/redux/schema.json +0 -9
  36. package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +2 -2
  37. package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -2
  38. package/src/generators/remote/remote.d.ts +0 -1
  39. package/src/generators/remote/remote.js +6 -12
  40. package/src/generators/remote/schema.d.ts +0 -1
  41. package/src/generators/remote/schema.json +0 -6
  42. package/src/generators/setup-tailwind/lib/update-project.js +1 -2
  43. package/src/generators/stories/schema.json +0 -10
  44. package/src/generators/stories/stories.d.ts +1 -3
  45. package/src/generators/stories/stories.js +2 -17
  46. package/src/generators/storybook-configuration/configuration.js +0 -9
  47. package/src/generators/storybook-configuration/schema.d.ts +0 -3
  48. package/src/generators/storybook-configuration/schema.json +0 -15
  49. package/src/utils/ct-utils.js +2 -7
  50. package/src/utils/versions.d.ts +1 -1
  51. package/src/utils/versions.js +1 -1
  52. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -13
  53. package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -104
  54. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +0 -13
  55. package/src/generators/component-cypress-spec/schema.json +0 -45
@@ -13,7 +13,6 @@ export interface Schema {
13
13
  js?: boolean;
14
14
  linter: Linter | LinterType;
15
15
  name: string;
16
- pascalCaseFiles?: boolean;
17
16
  remotes?: string[];
18
17
  setParserOptionsProject?: boolean;
19
18
  skipFormat?: boolean;
@@ -113,12 +113,6 @@
113
113
  "description": "Add tags to the application (used for linting).",
114
114
  "alias": "t"
115
115
  },
116
- "pascalCaseFiles": {
117
- "type": "boolean",
118
- "description": "Use pascal case component file name (e.g. App.tsx).",
119
- "alias": "P",
120
- "default": false
121
- },
122
116
  "classComponent": {
123
117
  "type": "boolean",
124
118
  "description": "Use class components instead of functional component.",
@@ -11,7 +11,6 @@ async function normalizeOptions(host, options) {
11
11
  directory: options.directory,
12
12
  importPath: options.importPath,
13
13
  projectNameAndRootFormat: options.projectNameAndRootFormat,
14
- callingGenerator: '@nx/react:library',
15
14
  });
16
15
  const nxJson = (0, devkit_1.readNxJson)(host);
17
16
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -23,7 +23,6 @@ const set_defaults_1 = require("./lib/set-defaults");
23
23
  async function libraryGenerator(host, schema) {
24
24
  return await libraryGeneratorInternal(host, {
25
25
  addPlugin: false,
26
- projectNameAndRootFormat: 'derived',
27
26
  ...schema,
28
27
  });
29
28
  }
@@ -125,6 +124,7 @@ async function libraryGeneratorInternal(host, schema) {
125
124
  skipFormat: true,
126
125
  testEnvironment: 'jsdom',
127
126
  addPlugin: options.addPlugin,
127
+ compiler: options.compiler,
128
128
  });
129
129
  tasks.push(vitestTask);
130
130
  createOrEditViteConfig(host, {
@@ -151,15 +151,12 @@ async function libraryGeneratorInternal(host, schema) {
151
151
  const componentTask = await (0, component_1.default)(host, {
152
152
  nameAndDirectoryFormat: 'as-provided',
153
153
  name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
154
- project: options.name,
155
- flat: true,
156
154
  style: options.style,
157
155
  skipTests: options.unitTestRunner === 'none' ||
158
156
  (options.unitTestRunner === 'vitest' && options.inSourceTests == true),
159
157
  export: true,
160
158
  routing: options.routing,
161
159
  js: options.js,
162
- pascalCaseFiles: options.pascalCaseFiles,
163
160
  inSourceTests: options.inSourceTests,
164
161
  skipFormat: true,
165
162
  globalCss: options.globalCss,
@@ -16,7 +16,6 @@ export interface Schema {
16
16
  js?: boolean;
17
17
  linter: Linter | LinterType;
18
18
  name: string;
19
- pascalCaseFiles?: boolean;
20
19
  publishable?: boolean;
21
20
  routing?: boolean;
22
21
  setParserOptionsProject?: boolean;
@@ -83,7 +83,8 @@
83
83
  },
84
84
  "unitTestRunner": {
85
85
  "type": "string",
86
- "enum": ["jest", "vitest", "none"],
86
+ "enum": ["vitest", "jest", "none"],
87
+ "default": "vitest",
87
88
  "description": "Test runner to use for unit tests.",
88
89
  "x-prompt": "What unit test runner should be used?"
89
90
  },
@@ -109,12 +110,6 @@
109
110
  "description": "Do not update `tsconfig.json` for development experience.",
110
111
  "x-priority": "internal"
111
112
  },
112
- "pascalCaseFiles": {
113
- "type": "boolean",
114
- "description": "Use pascal case component file name (e.g. `App.tsx`).",
115
- "alias": "P",
116
- "default": false
117
- },
118
113
  "routing": {
119
114
  "type": "boolean",
120
115
  "description": "Generate library with routes."
@@ -1,5 +1,4 @@
1
1
  import { Schema } from './schema';
2
2
  import { Tree } from '@nx/devkit';
3
3
  export declare function reduxGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
4
- export declare function reduxGeneratorInternal(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
5
4
  export default reduxGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reduxGenerator = reduxGenerator;
4
- exports.reduxGeneratorInternal = reduxGeneratorInternal;
5
4
  const path = require("path");
6
5
  const ast_utils_1 = require("../../utils/ast-utils");
7
6
  const versions_1 = require("../../utils/versions");
@@ -11,12 +10,6 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
11
10
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
12
11
  let tsModule;
13
12
  async function reduxGenerator(host, schema) {
14
- return reduxGeneratorInternal(host, {
15
- nameAndDirectoryFormat: 'derived',
16
- ...schema,
17
- });
18
- }
19
- async function reduxGeneratorInternal(host, schema) {
20
13
  const options = await normalizeOptions(host, schema);
21
14
  generateReduxFiles(host, options);
22
15
  addExportsToBarrel(host, options);
@@ -85,14 +78,9 @@ function updateReducerConfiguration(host, options) {
85
78
  }
86
79
  async function normalizeOptions(host, options) {
87
80
  const { artifactName: name, directory, fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
88
- artifactType: 'slice',
89
- callingGenerator: '@nx/react:redux',
90
81
  name: options.name,
91
82
  directory: options.directory,
92
- derivedDirectory: options.directory,
93
- flat: true,
94
83
  nameAndDirectoryFormat: options.nameAndDirectoryFormat,
95
- project: options.project,
96
84
  fileExtension: 'tsx',
97
85
  });
98
86
  let appProjectSourcePath;
@@ -1,13 +1,11 @@
1
+ import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
1
3
  export interface Schema {
2
4
  name: string;
3
- /**
4
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
5
- */
6
- project?: string;
7
5
  directory?: string;
8
6
  appProject?: string;
9
7
  js?: string;
10
- nameAndDirectoryFormat?: 'as-provided' | 'derived';
8
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
9
  }
12
10
 
13
11
  interface NormalizedSchema extends Schema {
@@ -15,15 +15,6 @@
15
15
  },
16
16
  "x-priority": "important"
17
17
  },
18
- "project": {
19
- "type": "string",
20
- "description": "The name of the project to add the slice to. If it is an application, then the store configuration will be updated too.",
21
- "alias": "p",
22
- "$default": {
23
- "$source": "projectName"
24
- },
25
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
26
- },
27
18
  "directory": {
28
19
  "type": "string",
29
20
  "alias": "dir",
@@ -1,3 +1,3 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- import type { Schema } from '../schema';
3
- export declare function setupTspathForRemote(tree: Tree, options: Schema): void;
2
+ import { NormalizedSchema } from '../../application/schema';
3
+ export declare function setupTspathForRemote(tree: Tree, options: NormalizedSchema): void;
@@ -5,10 +5,10 @@ const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
6
  const maybe_js_1 = require("../../../utils/maybe-js");
7
7
  function setupTspathForRemote(tree, options) {
8
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.name);
8
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
9
9
  const exportPath = (0, maybe_js_1.maybeJs)(options, './src/remote-entry.ts');
10
10
  const exportName = 'Module';
11
- (0, js_1.addTsConfigPath)(tree, `${options.name}/${exportName}`, [
11
+ (0, js_1.addTsConfigPath)(tree, `${options.projectName}/${exportName}`, [
12
12
  (0, devkit_1.joinPathFragments)(project.root, exportPath),
13
13
  ]);
14
14
  }
@@ -3,5 +3,4 @@ import { NormalizedSchema } from '../application/schema';
3
3
  import { Schema } from './schema';
4
4
  export declare function addModuleFederationFiles(host: Tree, options: NormalizedSchema<Schema>): void;
5
5
  export declare function remoteGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
6
- export declare function remoteGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
7
6
  export default remoteGenerator;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addModuleFederationFiles = addModuleFederationFiles;
4
4
  exports.remoteGenerator = remoteGenerator;
5
- exports.remoteGeneratorInternal = remoteGeneratorInternal;
6
5
  const path_1 = require("path");
7
6
  const devkit_1 = require("@nx/devkit");
8
7
  const normalize_options_1 = require("../application/lib/normalize-options");
@@ -19,7 +18,7 @@ const js_1 = require("@nx/js");
19
18
  const versions_1 = require("../../utils/versions");
20
19
  function addModuleFederationFiles(host, options) {
21
20
  const templateVariables = {
22
- ...(0, devkit_1.names)(options.name),
21
+ ...(0, devkit_1.names)(options.projectName),
23
22
  ...options,
24
23
  tmpl: '',
25
24
  };
@@ -46,15 +45,9 @@ function addModuleFederationFiles(host, options) {
46
45
  }
47
46
  }
48
47
  async function remoteGenerator(host, schema) {
49
- return await remoteGeneratorInternal(host, {
50
- projectNameAndRootFormat: 'derived',
51
- ...schema,
52
- });
53
- }
54
- async function remoteGeneratorInternal(host, schema) {
55
48
  const tasks = [];
56
49
  const options = {
57
- ...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:remote')),
50
+ ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
58
51
  // when js is set to true, we want to use the js configuration
59
52
  js: schema.js ?? false,
60
53
  typescriptConfiguration: schema.js
@@ -68,13 +61,14 @@ async function remoteGeneratorInternal(host, schema) {
68
61
  if (options.dynamic) {
69
62
  // Dynamic remotes generate with library { type: 'var' } by default.
70
63
  // We need to ensure that the remote name is a valid variable name.
71
- const isValidRemote = (0, js_1.isValidVariable)(options.name);
64
+ const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
72
65
  if (!isValidRemote.isValid) {
73
- throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
66
+ throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
74
67
  }
75
68
  }
76
69
  const initAppTask = await (0, application_1.default)(host, {
77
70
  ...options,
71
+ name: options.projectName,
78
72
  skipFormat: true,
79
73
  });
80
74
  tasks.push(initAppTask);
@@ -115,7 +109,7 @@ async function remoteGeneratorInternal(host, schema) {
115
109
  if (options.host && options.dynamic) {
116
110
  const hostConfig = (0, devkit_1.readProjectConfiguration)(host, schema.host);
117
111
  const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'assets/module-federation.manifest.json');
118
- (0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.name, options.devServerPort, pathToMFManifest);
112
+ (0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.devServerPort, pathToMFManifest);
119
113
  }
120
114
  (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
121
115
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion });
@@ -15,7 +15,6 @@ export interface Schema {
15
15
  js?: boolean;
16
16
  linter: Linter | LinterType;
17
17
  name: string;
18
- pascalCaseFiles?: boolean;
19
18
  routing?: boolean;
20
19
  setParserOptionsProject?: boolean;
21
20
  skipFormat: boolean;
@@ -119,12 +119,6 @@
119
119
  "description": "Add tags to the application (used for linting).",
120
120
  "alias": "t"
121
121
  },
122
- "pascalCaseFiles": {
123
- "type": "boolean",
124
- "description": "Use pascal case component file name (e.g. App.tsx).",
125
- "alias": "P",
126
- "default": false
127
- },
128
122
  "classComponent": {
129
123
  "type": "boolean",
130
124
  "description": "Use class components instead of functional component.",
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateProject = updateProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  function updateProject(tree, config, options) {
6
- if (config?.targets?.build?.executor === '@nx/webpack:webpack' ||
7
- config?.targets?.build?.executor === '@nrwl/webpack:webpack') {
6
+ if (config?.targets?.build?.executor === '@nx/webpack:webpack') {
8
7
  config.targets.build.options ??= {};
9
8
  config.targets.build.options.postcssConfig = (0, devkit_1.joinPathFragments)(config.root, 'postcss.config.js');
10
9
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, config);
@@ -17,16 +17,6 @@
17
17
  "x-prompt": "For which project do you want to generate stories?",
18
18
  "x-priority": "important"
19
19
  },
20
- "generateCypressSpecs": {
21
- "type": "boolean",
22
- "description": "Automatically generate `*.spec.ts` files in the cypress e2e app generated by the cypress-configure generator.",
23
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
24
- },
25
- "cypressProject": {
26
- "type": "string",
27
- "description": "The Cypress project to generate the stories under. This is inferred from `project` by default.",
28
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
29
- },
30
20
  "interactionTests": {
31
21
  "type": "boolean",
32
22
  "description": "Set up Storybook interaction tests.",
@@ -5,11 +5,9 @@ export interface StorybookStoriesSchema {
5
5
  js?: boolean;
6
6
  ignorePaths?: string[];
7
7
  skipFormat?: boolean;
8
- cypressProject?: string;
9
- generateCypressSpecs?: boolean;
10
8
  }
11
9
  export declare function projectRootPath(tree: Tree, config: ProjectConfiguration): Promise<string>;
12
10
  export declare function containsComponentDeclaration(tree: Tree, componentPath: string): boolean;
13
- export declare function createAllStories(tree: Tree, projectName: string, interactionTests: boolean, js: boolean, projects: Map<string, ProjectConfiguration>, projectConfiguration: ProjectConfiguration, generateCypressSpecs?: boolean, cypressProject?: string, ignorePaths?: string[]): Promise<void>;
11
+ export declare function createAllStories(tree: Tree, projectName: string, interactionTests: boolean, js: boolean, projects: Map<string, ProjectConfiguration>, projectConfiguration: ProjectConfiguration, ignorePaths?: string[]): Promise<void>;
14
12
  export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<GeneratorCallback>;
15
13
  export default storiesGenerator;
@@ -5,7 +5,6 @@ exports.containsComponentDeclaration = containsComponentDeclaration;
5
5
  exports.createAllStories = createAllStories;
6
6
  exports.storiesGenerator = storiesGenerator;
7
7
  const component_story_1 = require("../component-story/component-story");
8
- const component_cypress_spec_1 = require("../component-cypress-spec/component-cypress-spec");
9
8
  const ast_utils_1 = require("../../utils/ast-utils");
10
9
  const devkit_1 = require("@nx/devkit");
11
10
  const path_1 = require("path");
@@ -44,7 +43,7 @@ function containsComponentDeclaration(tree, componentPath) {
44
43
  return !!((0, ast_utils_1.getComponentNode)(sourceFile) ||
45
44
  (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile)?.length);
46
45
  }
47
- async function createAllStories(tree, projectName, interactionTests, js, projects, projectConfiguration, generateCypressSpecs, cypressProject, ignorePaths) {
46
+ async function createAllStories(tree, projectName, interactionTests, js, projects, projectConfiguration, ignorePaths) {
48
47
  const { isTheFileAStory } = await Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
49
48
  const { sourceRoot, root } = projectConfiguration;
50
49
  let componentPaths = [];
@@ -70,11 +69,6 @@ async function createAllStories(tree, projectName, interactionTests, js, project
70
69
  }
71
70
  }
72
71
  });
73
- const e2eProjectName = cypressProject || `${projectName}-e2e`;
74
- const e2eProject = projects.get(e2eProjectName);
75
- if (generateCypressSpecs && !e2eProject) {
76
- devkit_1.logger.info(`There was no e2e project "${e2eProjectName}" found, so cypress specs will not be generated. Pass "--cypressProject" to specify a different e2e project name`);
77
- }
78
72
  await Promise.all(componentPaths.map(async (componentPath) => {
79
73
  const relativeCmpDir = componentPath.replace((0, path_1.join)(sourceRoot, '/'), '');
80
74
  if (!containsComponentDeclaration(tree, componentPath)) {
@@ -86,22 +80,13 @@ async function createAllStories(tree, projectName, interactionTests, js, project
86
80
  skipFormat: true,
87
81
  interactionTests,
88
82
  });
89
- if (generateCypressSpecs && e2eProject) {
90
- await (0, component_cypress_spec_1.default)(tree, {
91
- project: projectName,
92
- componentPath: relativeCmpDir,
93
- js,
94
- cypressProject,
95
- skipFormat: true,
96
- });
97
- }
98
83
  }));
99
84
  }
100
85
  async function storiesGenerator(host, schema) {
101
86
  const projects = (0, devkit_1.getProjects)(host);
102
87
  const projectConfiguration = projects.get(schema.project);
103
88
  schema.interactionTests = schema.interactionTests ?? true;
104
- await createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.generateCypressSpecs, schema.cypressProject, schema.ignorePaths);
89
+ await createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.ignorePaths);
105
90
  const tasks = [];
106
91
  if (schema.interactionTests) {
107
92
  const { interactionTestsDependencies, addInteractionsInAddons } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
@@ -7,16 +7,10 @@ const stories_1 = require("../stories/stories");
7
7
  const devkit_1 = require("@nx/devkit");
8
8
  const versions_1 = require("../../utils/versions");
9
9
  async function generateStories(host, schema) {
10
- // TODO(katerina): Nx 19 -> remove Cypress
11
- (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
12
- const { getE2eProjectName } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
13
10
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
14
- const cypressProject = getE2eProjectName(schema.project, projectConfig.root, schema.cypressDirectory);
15
11
  await (0, stories_1.default)(host, {
16
12
  project: schema.project,
17
- generateCypressSpecs: schema.configureCypress && schema.generateCypressSpecs,
18
13
  js: schema.js,
19
- cypressProject,
20
14
  ignorePaths: schema.ignorePaths,
21
15
  skipFormat: true,
22
16
  interactionTests: schema.interactionTests ?? true,
@@ -39,7 +33,6 @@ async function storybookConfigurationGeneratorInternal(host, schema) {
39
33
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
40
34
  if (findWebpackConfig(host, projectConfig.root) ||
41
35
  projectConfig.targets['build']?.executor === '@nx/rollup:rollup' ||
42
- projectConfig.targets['build']?.executor === '@nrwl/rollup:rollup' ||
43
36
  projectConfig.targets['build']?.executor === '@nx/expo:build') {
44
37
  uiFramework = '@storybook/react-webpack5';
45
38
  }
@@ -48,10 +41,8 @@ async function storybookConfigurationGeneratorInternal(host, schema) {
48
41
  }
49
42
  const installTask = await configurationGenerator(host, {
50
43
  project: schema.project,
51
- configureCypress: schema.configureCypress,
52
44
  js: schema.js,
53
45
  linter: schema.linter,
54
- cypressDirectory: schema.cypressDirectory,
55
46
  tsConfiguration: schema.tsConfiguration ?? true, // default is true
56
47
  interactionTests: schema.interactionTests ?? true, // default is true
57
48
  configureStaticServe: schema.configureStaticServe,
@@ -9,8 +9,5 @@ export interface StorybookConfigureSchema {
9
9
  linter?: Linter | LinterType;
10
10
  ignorePaths?: string[];
11
11
  configureStaticServe?: boolean;
12
- configureCypress?: boolean;
13
- generateCypressSpecs?: boolean;
14
- cypressDirectory?: string;
15
12
  addPlugin?: boolean;
16
13
  }
@@ -26,11 +26,6 @@
26
26
  "alias": ["configureTestRunner"],
27
27
  "default": true
28
28
  },
29
- "configureCypress": {
30
- "type": "boolean",
31
- "description": "Run the cypress-configure generator.",
32
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
33
- },
34
29
  "generateStories": {
35
30
  "type": "boolean",
36
31
  "description": "Automatically generate `*.stories.ts` files for components declared in this project?",
@@ -38,11 +33,6 @@
38
33
  "default": true,
39
34
  "x-priority": "important"
40
35
  },
41
- "generateCypressSpecs": {
42
- "type": "boolean",
43
- "description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator.",
44
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
45
- },
46
36
  "configureStaticServe": {
47
37
  "type": "boolean",
48
38
  "description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
@@ -50,11 +40,6 @@
50
40
  "default": true,
51
41
  "x-priority": "important"
52
42
  },
53
- "cypressDirectory": {
54
- "type": "string",
55
- "description": "A directory where the Cypress project will be placed. Placed at the root by default.",
56
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
57
- },
58
43
  "js": {
59
44
  "type": "boolean",
60
45
  "description": "Generate JavaScript story files rather than TypeScript story files.",
@@ -60,17 +60,12 @@ function assertValidConfig(config) {
60
60
  }
61
61
  async function getBundlerFromTarget(found, tree) {
62
62
  if (found.target && found.config?.executor) {
63
- return found.config.executor === '@nrwl/vite:build' ||
64
- found.config.executor === '@nx/vite:build'
65
- ? 'vite'
66
- : 'webpack';
63
+ return found.config.executor === '@nx/vite:build' ? 'vite' : 'webpack';
67
64
  }
68
65
  const { target, project } = (0, devkit_1.parseTargetString)(found.target, await (0, devkit_1.createProjectGraphAsync)());
69
66
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
70
67
  const executor = projectConfig?.targets?.[target]?.executor;
71
- return executor === '@nrwl/vite:build' || executor === '@nx/vite:build'
72
- ? 'vite'
73
- : 'webpack';
68
+ return executor === '@nx/vite:build' ? 'vite' : 'webpack';
74
69
  }
75
70
  async function getActualBundler(tree, options, found) {
76
71
  // Specifically undefined to allow Remix workaround of passing an empty string
@@ -37,7 +37,7 @@ export declare const isbotVersion = "^3.6.5";
37
37
  export declare const corsVersion = "~2.8.5";
38
38
  export declare const typesCorsVersion = "~2.8.12";
39
39
  export declare const moduleFederationNodeVersion = "~2.5.0";
40
- export declare const moduleFederationEnhancedVersion = "~0.6.0";
40
+ export declare const moduleFederationEnhancedVersion = "0.6.6";
41
41
  export declare const lessVersion = "3.12.2";
42
42
  export declare const sassVersion = "^1.55.0";
43
43
  export declare const rollupPluginUrlVersion = "^8.0.2";
@@ -43,7 +43,7 @@ exports.isbotVersion = '^3.6.5';
43
43
  exports.corsVersion = '~2.8.5';
44
44
  exports.typesCorsVersion = '~2.8.12';
45
45
  exports.moduleFederationNodeVersion = '~2.5.0';
46
- exports.moduleFederationEnhancedVersion = '~0.6.0';
46
+ exports.moduleFederationEnhancedVersion = '0.6.6';
47
47
  // style preprocessors
48
48
  exports.lessVersion = '3.12.2';
49
49
  exports.sassVersion = '^1.55.0';
@@ -1,13 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import type * as ts from 'typescript';
3
- export interface CreateComponentSpecFileSchema {
4
- project: string;
5
- componentPath: string;
6
- js?: boolean;
7
- cypressProject?: string;
8
- skipFormat?: boolean;
9
- }
10
- export declare function componentCypressGenerator(host: Tree, schema: CreateComponentSpecFileSchema): Promise<void>;
11
- export declare function getArgsDefaultValue(property: ts.SyntaxKind): string;
12
- export declare function createComponentSpecFile(tree: Tree, { project, componentPath, js, cypressProject }: CreateComponentSpecFileSchema): void;
13
- export default componentCypressGenerator;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.componentCypressGenerator = componentCypressGenerator;
4
- exports.getArgsDefaultValue = getArgsDefaultValue;
5
- exports.createComponentSpecFile = createComponentSpecFile;
6
- const devkit_1 = require("@nx/devkit");
7
- const path_1 = require("path");
8
- const ast_utils_1 = require("../../utils/ast-utils");
9
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
10
- let tsModule;
11
- async function componentCypressGenerator(host, schema) {
12
- createComponentSpecFile(host, schema);
13
- if (!schema.skipFormat) {
14
- await (0, devkit_1.formatFiles)(host);
15
- }
16
- }
17
- // TODO: candidate to refactor with the angular component story
18
- function getArgsDefaultValue(property) {
19
- if (!tsModule) {
20
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
21
- }
22
- const typeNameToDefault = {
23
- [tsModule.SyntaxKind.StringKeyword]: '',
24
- [tsModule.SyntaxKind.NumberKeyword]: 0,
25
- [tsModule.SyntaxKind.BooleanKeyword]: false,
26
- };
27
- const resolvedValue = typeNameToDefault[property];
28
- if (resolvedValue === undefined) {
29
- return '';
30
- }
31
- else if (typeof resolvedValue === 'string') {
32
- return resolvedValue.replace(/\s/g, '+');
33
- }
34
- else {
35
- return resolvedValue;
36
- }
37
- }
38
- function createComponentSpecFile(tree, { project, componentPath, js, cypressProject }) {
39
- if (!tsModule) {
40
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
41
- }
42
- const e2eProjectName = cypressProject || `${project}-e2e`;
43
- const projects = (0, devkit_1.getProjects)(tree);
44
- const e2eProject = projects.get(e2eProjectName);
45
- // cypress >= v10 will have a cypress.config.ts < v10 will have a cypress.json
46
- const isCypressV10 = tree.exists((0, path_1.join)(e2eProject.root, 'cypress.config.ts'));
47
- const e2eLibIntegrationFolderPath = (0, path_1.join)(e2eProject.sourceRoot, isCypressV10 ? 'e2e' : 'integration');
48
- const proj = projects.get(project);
49
- const componentFilePath = (0, devkit_1.joinPathFragments)(proj.sourceRoot, componentPath);
50
- const componentName = componentFilePath
51
- .slice(componentFilePath.lastIndexOf('/') + 1)
52
- .replace('.tsx', '')
53
- .replace('.jsx', '')
54
- .replace('.js', '');
55
- const contents = tree.read(componentFilePath, 'utf-8');
56
- if (contents === null) {
57
- throw new Error(`Failed to read ${componentFilePath}`);
58
- }
59
- const sourceFile = tsModule.createSourceFile(componentFilePath, contents, tsModule.ScriptTarget.Latest, true);
60
- const cmpDeclaration = (0, ast_utils_1.getComponentNode)(sourceFile);
61
- if (!cmpDeclaration) {
62
- const componentNodes = (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile);
63
- if (componentNodes?.length) {
64
- componentNodes.forEach((declaration) => {
65
- findPropsAndGenerateFileForCypress(tree, sourceFile, declaration, e2eLibIntegrationFolderPath, componentName, project, js, true);
66
- });
67
- }
68
- else {
69
- throw new Error(`Could not find any React component in file ${componentFilePath}`);
70
- }
71
- }
72
- else {
73
- findPropsAndGenerateFileForCypress(tree, sourceFile, cmpDeclaration, e2eLibIntegrationFolderPath, componentName, project, js);
74
- }
75
- }
76
- function findPropsAndGenerateFileForCypress(tree, sourceFile, cmpDeclaration, e2eLibIntegrationFolderPath, componentName, project, js, fromNodeArray) {
77
- const info = (0, ast_utils_1.parseComponentPropsInfo)(sourceFile, cmpDeclaration);
78
- let props = [];
79
- if (info) {
80
- if (!tsModule) {
81
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
82
- }
83
- props = info.props.map((member) => {
84
- return {
85
- name: member.name.text,
86
- defaultValue: tsModule.isBindingElement(member)
87
- ? getArgsDefaultValue(member.kind)
88
- : getArgsDefaultValue(member.type.kind),
89
- };
90
- });
91
- }
92
- const isCypressV10 = (0, path_1.basename)(e2eLibIntegrationFolderPath) === 'e2e';
93
- const cyFilePrefix = isCypressV10 ? 'cy' : 'spec';
94
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files'), `${e2eLibIntegrationFolderPath}/${fromNodeArray
95
- ? componentName + '--' + cmpDeclaration.name.text
96
- : componentName}`, {
97
- projectName: project,
98
- componentName,
99
- componentSelector: cmpDeclaration.name.text,
100
- props,
101
- fileExt: js ? `${cyFilePrefix}.js` : `${cyFilePrefix}.ts`,
102
- });
103
- }
104
- exports.default = componentCypressGenerator;
@@ -1,13 +0,0 @@
1
- describe('<%=projectName%>: <%= componentSelector %> component', () => {
2
- beforeEach(() => cy.visit('/iframe.html?id=<%= componentSelector.toLowerCase() %>--primary<% if ( props && props.length > 0 ) { %>&args=<% } %><%
3
- for(let prop of props) {
4
- %><%=prop.name%><%
5
- if(prop.defaultValue !== undefined && (prop.defaultValue || prop.defaultValue === false)) {
6
- %>:<%=prop.defaultValue%><%
7
- } %>;<%
8
- }%>'));
9
-
10
- it('should render the component', () => {
11
- cy.get('h1').should('contain', 'Welcome to <%=componentSelector%>!');
12
- });
13
- });