@nx/react 0.0.0-pr-27957-a99d5ea → 0.0.0-pr-28229-afe192c

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 (60) 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 +9 -10
  5. package/plugins/storybook/index.js +1 -2
  6. package/src/generators/application/application.js +2 -3
  7. package/src/generators/application/lib/normalize-options.d.ts +1 -1
  8. package/src/generators/application/lib/normalize-options.js +4 -6
  9. package/src/generators/application/lib/show-possible-warnings.js +2 -2
  10. package/src/generators/application/schema.d.ts +2 -5
  11. package/src/generators/application/schema.json +14 -25
  12. package/src/generators/component/component.d.ts +0 -1
  13. package/src/generators/component/component.js +0 -7
  14. package/src/generators/component/lib/normalize-options.js +2 -10
  15. package/src/generators/component/schema.d.ts +4 -22
  16. package/src/generators/component/schema.json +7 -41
  17. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
  18. package/src/generators/federate-module/federate-module.js +12 -22
  19. package/src/generators/federate-module/schema.d.ts +0 -1
  20. package/src/generators/federate-module/schema.json +0 -5
  21. package/src/generators/hook/hook.d.ts +0 -1
  22. package/src/generators/hook/hook.js +10 -44
  23. package/src/generators/hook/schema.d.ts +3 -18
  24. package/src/generators/hook/schema.json +8 -31
  25. package/src/generators/host/host.d.ts +0 -1
  26. package/src/generators/host/host.js +4 -9
  27. package/src/generators/host/lib/add-module-federation-files.js +2 -2
  28. package/src/generators/host/lib/normalize-remote.js +10 -6
  29. package/src/generators/host/schema.d.ts +2 -5
  30. package/src/generators/host/schema.json +8 -20
  31. package/src/generators/library/lib/normalize-options.js +1 -2
  32. package/src/generators/library/library.js +3 -7
  33. package/src/generators/library/schema.d.ts +2 -5
  34. package/src/generators/library/schema.json +13 -22
  35. package/src/generators/redux/redux.d.ts +0 -1
  36. package/src/generators/redux/redux.js +8 -21
  37. package/src/generators/redux/schema.d.ts +3 -7
  38. package/src/generators/redux/schema.json +6 -21
  39. package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +2 -2
  40. package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -2
  41. package/src/generators/remote/remote.d.ts +0 -1
  42. package/src/generators/remote/remote.js +8 -12
  43. package/src/generators/remote/schema.d.ts +2 -5
  44. package/src/generators/remote/schema.json +8 -20
  45. package/src/generators/setup-ssr/setup-ssr.js +6 -0
  46. package/src/generators/setup-tailwind/lib/update-project.js +1 -2
  47. package/src/generators/stories/schema.json +0 -10
  48. package/src/generators/stories/stories.d.ts +1 -3
  49. package/src/generators/stories/stories.js +2 -17
  50. package/src/generators/storybook-configuration/configuration.js +0 -9
  51. package/src/generators/storybook-configuration/schema.d.ts +0 -3
  52. package/src/generators/storybook-configuration/schema.json +0 -15
  53. package/src/utils/ct-utils.js +2 -7
  54. package/src/utils/testing-generators.js +1 -2
  55. package/src/utils/versions.d.ts +1 -1
  56. package/src/utils/versions.js +1 -1
  57. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -13
  58. package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -104
  59. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +0 -13
  60. package/src/generators/component-cypress-spec/schema.json +0 -45
@@ -6,36 +6,21 @@
6
6
  "description": "Create a Redux state slice for a React project.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "path": {
10
10
  "type": "string",
11
- "description": "Redux slice name.",
11
+ "description": "Path where the Redux slice will be generated.",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
+ "x-prompt": "Where should the Redux slice be generated?",
16
17
  "x-priority": "important"
17
18
  },
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
- "directory": {
19
+ "name": {
28
20
  "type": "string",
29
- "alias": "dir",
30
- "default": "",
31
- "description": "The directory at which to create the Redux files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
21
+ "description": "Redux slice name.",
32
22
  "x-priority": "important"
33
23
  },
34
- "nameAndDirectoryFormat": {
35
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
36
- "type": "string",
37
- "enum": ["as-provided", "derived"]
38
- },
39
24
  "appProject": {
40
25
  "type": "string",
41
26
  "description": "The application project to add the slice to.",
@@ -47,5 +32,5 @@
47
32
  "default": false
48
33
  }
49
34
  },
50
- "required": ["name"]
35
+ "required": ["path"]
51
36
  }
@@ -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");
@@ -17,9 +16,10 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
17
16
  const maybe_js_1 = require("../../utils/maybe-js");
18
17
  const js_1 = require("@nx/js");
19
18
  const versions_1 = require("../../utils/versions");
19
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
20
20
  function addModuleFederationFiles(host, options) {
21
21
  const templateVariables = {
22
- ...(0, devkit_1.names)(options.name),
22
+ ...(0, devkit_1.names)(options.projectName),
23
23
  ...options,
24
24
  tmpl: '',
25
25
  };
@@ -46,15 +46,9 @@ function addModuleFederationFiles(host, options) {
46
46
  }
47
47
  }
48
48
  async function remoteGenerator(host, schema) {
49
- return await remoteGeneratorInternal(host, {
50
- projectNameAndRootFormat: 'derived',
51
- ...schema,
52
- });
53
- }
54
- async function remoteGeneratorInternal(host, schema) {
55
49
  const tasks = [];
56
50
  const options = {
57
- ...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:remote')),
51
+ ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
58
52
  // when js is set to true, we want to use the js configuration
59
53
  js: schema.js ?? false,
60
54
  typescriptConfiguration: schema.js
@@ -68,13 +62,15 @@ async function remoteGeneratorInternal(host, schema) {
68
62
  if (options.dynamic) {
69
63
  // Dynamic remotes generate with library { type: 'var' } by default.
70
64
  // We need to ensure that the remote name is a valid variable name.
71
- const isValidRemote = (0, js_1.isValidVariable)(options.name);
65
+ const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
72
66
  if (!isValidRemote.isValid) {
73
- throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
67
+ throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
74
68
  }
75
69
  }
70
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
76
71
  const initAppTask = await (0, application_1.default)(host, {
77
72
  ...options,
73
+ name: options.projectName,
78
74
  skipFormat: true,
79
75
  });
80
76
  tasks.push(initAppTask);
@@ -115,7 +111,7 @@ async function remoteGeneratorInternal(host, schema) {
115
111
  if (options.host && options.dynamic) {
116
112
  const hostConfig = (0, devkit_1.readProjectConfiguration)(host, schema.host);
117
113
  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);
114
+ (0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.devServerPort, pathToMFManifest);
119
115
  }
120
116
  (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
121
117
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion });
@@ -1,4 +1,3 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
  import type { SupportedStyles } from '../../../typings/style';
4
3
  import type { NormalizedSchema as ApplicationNormalizedSchema } from '../application/schema';
@@ -7,15 +6,13 @@ export interface Schema {
7
6
  classComponent?: boolean;
8
7
  compiler?: 'babel' | 'swc';
9
8
  devServerPort?: number;
10
- directory?: string;
11
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
+ directory: string;
12
10
  e2eTestRunner: 'cypress' | 'playwright' | 'none';
13
11
  globalCss?: boolean;
14
12
  host?: string;
15
13
  js?: boolean;
16
14
  linter: Linter | LinterType;
17
- name: string;
18
- pascalCaseFiles?: boolean;
15
+ name?: string;
19
16
  routing?: boolean;
20
17
  setParserOptionsProject?: boolean;
21
18
  skipFormat: boolean;
@@ -6,28 +6,22 @@
6
6
  "description": "Create Module Federation configuration files for given React Remote Application.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "directory": {
10
+ "description": "The directory of the new application.",
10
11
  "type": "string",
11
- "description": "The name of the remote application to generate the Module Federation configuration",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use as the remote application?",
17
- "pattern": "^[a-zA-Z][^:]*$",
18
- "x-priority": "important"
17
+ "x-prompt": "Which directory do you want to create the application in?"
19
18
  },
20
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
22
20
  "type": "string",
23
- "alias": "dir",
21
+ "description": "The name of the remote application to generate the Module Federation configuration",
22
+ "pattern": "^[a-zA-Z][^:]*$",
24
23
  "x-priority": "important"
25
24
  },
26
- "projectNameAndRootFormat": {
27
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
28
- "type": "string",
29
- "enum": ["as-provided", "derived"]
30
- },
31
25
  "dynamic": {
32
26
  "type": "boolean",
33
27
  "description": "Should the host application use dynamic federation?",
@@ -119,12 +113,6 @@
119
113
  "description": "Add tags to the application (used for linting).",
120
114
  "alias": "t"
121
115
  },
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
116
  "classComponent": {
129
117
  "type": "boolean",
130
118
  "description": "Use class components instead of functional component.",
@@ -192,6 +180,6 @@
192
180
  "x-priority": "important"
193
181
  }
194
182
  },
195
- "required": ["name"],
183
+ "required": ["directory"],
196
184
  "additionalProperties": false
197
185
  }
@@ -65,6 +65,12 @@ async function setupSsrGenerator(tree, options) {
65
65
  if (projectConfig.targets.build.options?.outputPath) {
66
66
  projectConfig.targets.build.options.outputPath = (0, devkit_1.joinPathFragments)(originalOutputPath, 'browser');
67
67
  }
68
+ if (projectConfig.targets.build.executor === '@nx/rspack:rspack') {
69
+ options.bundler = 'rspack';
70
+ }
71
+ else if (projectConfig.targets.build.executor === '@nx/webpack:webpack') {
72
+ options.bundler = 'webpack';
73
+ }
68
74
  projectConfig.targets = {
69
75
  ...projectConfig.targets,
70
76
  server: {
@@ -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
@@ -12,8 +12,7 @@ async function createApp(tree, appName) {
12
12
  skipFormat: true,
13
13
  style: 'css',
14
14
  unitTestRunner: 'none',
15
- name: appName,
16
- projectNameAndRootFormat: 'as-provided',
15
+ directory: appName,
17
16
  });
18
17
  }
19
18
  async function createLib(tree, libName) {
@@ -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
- });
@@ -1,45 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "cli": "nx",
4
- "$id": "NxReactComponentCypressSpec",
5
- "title": "Create component Cypress spec",
6
- "description": "Create a Storybook Cypress spec for a UI component that has a story.",
7
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20.",
8
- "type": "object",
9
- "properties": {
10
- "project": {
11
- "type": "string",
12
- "description": "The project name for which to generate tests.",
13
- "examples": ["shared-ui-component"],
14
- "$default": {
15
- "$source": "projectName",
16
- "index": 0
17
- },
18
- "x-prompt": "What's name of the project for which to generate tests?",
19
- "x-priority": "important"
20
- },
21
- "componentPath": {
22
- "type": "string",
23
- "description": "Relative path to the component file from the library root?",
24
- "examples": ["lib/components"],
25
- "x-prompt": "What's path of the component relative to the project's lib root for which to generate a test?",
26
- "x-priority": "important"
27
- },
28
- "js": {
29
- "type": "boolean",
30
- "description": "Generate JavaScript files rather than TypeScript files.",
31
- "default": false
32
- },
33
- "cypressProject": {
34
- "type": "string",
35
- "description": "The Cypress project to generate the stories under. By default, inferred from `project`."
36
- },
37
- "skipFormat": {
38
- "description": "Skip formatting files.",
39
- "type": "boolean",
40
- "default": false,
41
- "x-priority": "internal"
42
- }
43
- },
44
- "required": ["project", "componentPath"]
45
- }