@nx/react 16.6.0-beta.4 → 16.6.0-beta.5

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/react",
3
- "version": "16.6.0-beta.4",
3
+ "version": "16.6.0-beta.5",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -31,20 +31,21 @@
31
31
  "migrations": "./migrations.json"
32
32
  },
33
33
  "dependencies": {
34
- "@nrwl/react": "16.6.0-beta.4",
35
- "@nx/devkit": "16.6.0-beta.4",
36
- "@nx/js": "16.6.0-beta.4",
37
- "@nx/linter": "16.6.0-beta.4",
38
- "@nx/web": "16.6.0-beta.4",
34
+ "@nrwl/react": "16.6.0-beta.5",
35
+ "@nx/devkit": "16.6.0-beta.5",
36
+ "@nx/js": "16.6.0-beta.5",
37
+ "@nx/linter": "16.6.0-beta.5",
38
+ "@nx/web": "16.6.0-beta.5",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1",
40
40
  "@svgr/webpack": "^8.0.1",
41
41
  "chalk": "^4.1.0",
42
42
  "file-loader": "^6.2.0",
43
- "minimatch": "3.0.5"
43
+ "minimatch": "3.0.5",
44
+ "tslib": "^2.3.0"
44
45
  },
45
46
  "publishConfig": {
46
47
  "access": "public"
47
48
  },
48
49
  "types": "./index.d.ts",
49
- "gitHead": "b1a9ae7ce76697019b26ec9a172005840cca8da6"
50
+ "gitHead": "aab868aa0c30949832fe2c4b9cb109c204442e39"
50
51
  }
@@ -29,7 +29,7 @@ function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot) {
29
29
  return config.default || config;
30
30
  }
31
31
  catch (_a) {
32
- throw new Error(`Could not load ${moduleFederationConfigPath}. Was this project generated with "@nx/react:host"?\nSee: https://nx.dev/recipes/module-federation/faster-builds`);
32
+ throw new Error(`Could not load ${moduleFederationConfigPath}. Was this project generated with "@nx/react:host"?\nSee: https://nx.dev/concepts/more-concepts/faster-builds-with-module-federation`);
33
33
  }
34
34
  }
35
35
  function moduleFederationDevServer(options, context) {
@@ -25,6 +25,9 @@ export const Primary = {
25
25
 
26
26
  <% if ( interactionTests ) { %>
27
27
  export const Heading: Story = {
28
+ args: {<% for (let prop of props) { %>
29
+ <%= prop.name %>: <%- prop.defaultValue %>,<% } %>
30
+ },
28
31
  play: async ({ canvasElement }) => {
29
32
  const canvas = within(canvasElement);
30
33
  expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy();
@@ -19,13 +19,11 @@
19
19
  },
20
20
  "generateCypressSpecs": {
21
21
  "type": "boolean",
22
- "description": "Automatically generate `*.spec.ts` files in the cypress e2e app generated by the cypress-configure generator.",
23
- "x-deprecated": "Please use Storybook interaction tests instead."
22
+ "description": "Automatically generate `*.spec.ts` files in the cypress e2e app generated by the cypress-configure generator."
24
23
  },
25
24
  "cypressProject": {
26
25
  "type": "string",
27
- "description": "The Cypress project to generate the stories under. This is inferred from `project` by default.",
28
- "x-deprecated": "Please use Storybook interaction tests instead."
26
+ "description": "The Cypress project to generate the stories under. This is inferred from `project` by default."
29
27
  },
30
28
  "interactionTests": {
31
29
  "type": "boolean",
@@ -1,16 +1,16 @@
1
- import { ProjectConfiguration, Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, ProjectConfiguration, Tree } from '@nx/devkit';
2
2
  export interface StorybookStoriesSchema {
3
3
  project: string;
4
4
  interactionTests?: boolean;
5
5
  js?: boolean;
6
- cypressProject?: string;
7
- generateCypressSpecs?: boolean;
8
6
  ignorePaths?: string[];
9
7
  skipFormat?: boolean;
8
+ cypressProject?: string;
9
+ generateCypressSpecs?: boolean;
10
10
  }
11
11
  export declare function projectRootPath(tree: Tree, config: ProjectConfiguration): Promise<string>;
12
12
  export declare function containsComponentDeclaration(tree: Tree, componentPath: string): boolean;
13
- export declare function createAllStories(tree: Tree, projectName: string, interactionTests: boolean, js: boolean, generateCypressSpecs?: boolean, cypressProject?: string, ignorePaths?: string[]): Promise<void>;
14
- export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<void>;
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>;
14
+ export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<GeneratorCallback>;
15
15
  export default storiesGenerator;
16
16
  export declare const storiesSchematic: (generatorOptions: StorybookStoriesSchema) => (tree: any, context: any) => Promise<any>;
@@ -9,6 +9,7 @@ const devkit_1 = require("@nx/devkit");
9
9
  const path_1 = require("path");
10
10
  const minimatch = require("minimatch");
11
11
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
12
+ const versions_1 = require("../../utils/versions");
12
13
  let tsModule;
13
14
  function projectRootPath(tree, config) {
14
15
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -47,11 +48,9 @@ function containsComponentDeclaration(tree, componentPath) {
47
48
  ((_a = (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile)) === null || _a === void 0 ? void 0 : _a.length));
48
49
  }
49
50
  exports.containsComponentDeclaration = containsComponentDeclaration;
50
- function createAllStories(tree, projectName, interactionTests, js, generateCypressSpecs, cypressProject, ignorePaths) {
51
+ function createAllStories(tree, projectName, interactionTests, js, projects, projectConfiguration, generateCypressSpecs, cypressProject, ignorePaths) {
51
52
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
52
53
  const { isTheFileAStory } = yield Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
53
- const projects = (0, devkit_1.getProjects)(tree);
54
- const projectConfiguration = projects.get(projectName);
55
54
  const { sourceRoot, root } = projectConfiguration;
56
55
  let componentPaths = [];
57
56
  const projectPath = yield projectRootPath(tree, projectConfiguration);
@@ -108,10 +107,20 @@ exports.createAllStories = createAllStories;
108
107
  function storiesGenerator(host, schema) {
109
108
  var _a;
110
109
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
111
- yield createAllStories(host, schema.project, (_a = schema.interactionTests) !== null && _a !== void 0 ? _a : true, schema.js, schema.generateCypressSpecs, schema.cypressProject, schema.ignorePaths);
110
+ const projects = (0, devkit_1.getProjects)(host);
111
+ const projectConfiguration = projects.get(schema.project);
112
+ schema.interactionTests = (_a = schema.interactionTests) !== null && _a !== void 0 ? _a : true;
113
+ yield createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.generateCypressSpecs, schema.cypressProject, schema.ignorePaths);
114
+ const tasks = [];
115
+ if (schema.interactionTests) {
116
+ const { interactionTestsDependencies, addInteractionsInAddons } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
117
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, interactionTestsDependencies()));
118
+ addInteractionsInAddons(host, projectConfiguration);
119
+ }
112
120
  if (!schema.skipFormat) {
113
121
  yield (0, devkit_1.formatFiles)(host);
114
122
  }
123
+ return (0, devkit_1.runTasksInSerial)(...tasks);
115
124
  });
116
125
  }
117
126
  exports.storiesGenerator = storiesGenerator;
@@ -8,7 +8,7 @@ const versions_1 = require("../../utils/versions");
8
8
  function generateStories(host, schema) {
9
9
  var _a;
10
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- // TODO(katerina): remove Cypress for Nx 18
11
+ // TODO(v18): remove Cypress
12
12
  (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
13
13
  const { getE2eProjectName } = yield Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
14
14
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.name);
@@ -4,12 +4,12 @@ export interface StorybookConfigureSchema {
4
4
  name: string;
5
5
  interactionTests?: boolean;
6
6
  generateStories?: boolean;
7
- configureCypress?: boolean;
8
- generateCypressSpecs?: boolean;
9
7
  js?: boolean;
10
8
  tsConfiguration?: boolean;
11
9
  linter?: Linter;
12
- cypressDirectory?: string;
13
10
  ignorePaths?: string[];
14
11
  configureStaticServe?: boolean;
12
+ configureCypress?: boolean;
13
+ generateCypressSpecs?: boolean;
14
+ cypressDirectory?: string;
15
15
  }
@@ -28,8 +28,7 @@
28
28
  },
29
29
  "configureCypress": {
30
30
  "type": "boolean",
31
- "description": "Run the cypress-configure generator.",
32
- "x-deprecated": "Please use Storybook interaction tests instead."
31
+ "description": "Run the cypress-configure generator."
33
32
  },
34
33
  "generateStories": {
35
34
  "type": "boolean",
@@ -40,8 +39,7 @@
40
39
  },
41
40
  "generateCypressSpecs": {
42
41
  "type": "boolean",
43
- "description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator.",
44
- "x-deprecated": "Please use Storybook interaction tests instead."
42
+ "description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator."
45
43
  },
46
44
  "configureStaticServe": {
47
45
  "type": "boolean",
@@ -52,8 +50,7 @@
52
50
  },
53
51
  "cypressDirectory": {
54
52
  "type": "string",
55
- "description": "A directory where the Cypress project will be placed. Placed at the root by default.",
56
- "x-deprecated": "Please use Storybook interaction tests instead."
53
+ "description": "A directory where the Cypress project will be placed. Placed at the root by default."
57
54
  },
58
55
  "js": {
59
56
  "type": "boolean",