@nx/angular 20.0.0-beta.0 → 20.0.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. package/generators.d.ts +0 -1
  2. package/generators.js +0 -1
  3. package/generators.json +0 -6
  4. package/package.json +8 -8
  5. package/src/generators/stories/schema.d.ts +0 -2
  6. package/src/generators/stories/schema.json +0 -10
  7. package/src/generators/stories/stories.js +0 -19
  8. package/src/generators/storybook-configuration/lib/generate-stories.js +0 -6
  9. package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +0 -2
  10. package/src/generators/storybook-configuration/schema.d.ts +0 -3
  11. package/src/generators/storybook-configuration/schema.json +0 -15
  12. package/src/generators/storybook-configuration/storybook-configuration.js +0 -3
  13. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -4
  14. package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -35
  15. package/src/generators/component-cypress-spec/files/__componentFileName__.__fileExt__ +0 -17
  16. package/src/generators/component-cypress-spec/lib/get-args-default-value.d.ts +0 -2
  17. package/src/generators/component-cypress-spec/lib/get-args-default-value.js +0 -24
  18. package/src/generators/component-cypress-spec/lib/get-component-selector.d.ts +0 -2
  19. package/src/generators/component-cypress-spec/lib/get-component-selector.js +0 -23
  20. package/src/generators/component-cypress-spec/schema.d.ts +0 -10
  21. package/src/generators/component-cypress-spec/schema.json +0 -66
  22. package/src/generators/stories/lib/get-e2e-project.d.ts +0 -2
  23. package/src/generators/stories/lib/get-e2e-project.js +0 -14
  24. package/src/generators/storybook-configuration/lib/validate-options.d.ts +0 -2
  25. package/src/generators/storybook-configuration/lib/validate-options.js +0 -8
package/generators.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './src/generators/add-linting/add-linting';
2
2
  export * from './src/generators/application/application';
3
- export * from './src/generators/component-cypress-spec/component-cypress-spec';
4
3
  export * from './src/generators/component-story/component-story';
5
4
  export * from './src/generators/component/component';
6
5
  export * from './src/generators/directive/directive';
package/generators.js CHANGED
@@ -4,7 +4,6 @@ exports.cypressComponentConfiguration = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("./src/generators/add-linting/add-linting"), exports);
6
6
  tslib_1.__exportStar(require("./src/generators/application/application"), exports);
7
- tslib_1.__exportStar(require("./src/generators/component-cypress-spec/component-cypress-spec"), exports);
8
7
  tslib_1.__exportStar(require("./src/generators/component-story/component-story"), exports);
9
8
  tslib_1.__exportStar(require("./src/generators/component/component"), exports);
10
9
  tslib_1.__exportStar(require("./src/generators/directive/directive"), exports);
package/generators.json CHANGED
@@ -22,12 +22,6 @@
22
22
  "aliases": ["c"],
23
23
  "description": "Generate an Angular Component."
24
24
  },
25
- "component-cypress-spec": {
26
- "factory": "./src/generators/component-cypress-spec/component-cypress-spec",
27
- "schema": "./src/generators/component-cypress-spec/schema.json",
28
- "description": "Creates a Cypress spec for a UI component that has a story.",
29
- "hidden": true
30
- },
31
25
  "component-story": {
32
26
  "factory": "./src/generators/component-story/component-story",
33
27
  "schema": "./src/generators/component-story/schema.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "20.0.0-beta.0",
3
+ "version": "20.0.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -80,14 +80,14 @@
80
80
  "webpack-merge": "^5.8.0",
81
81
  "webpack": "^5.88.0",
82
82
  "@module-federation/enhanced": "~0.6.0",
83
- "@nx/devkit": "20.0.0-beta.0",
84
- "@nx/js": "20.0.0-beta.0",
85
- "@nx/eslint": "20.0.0-beta.0",
86
- "@nx/webpack": "20.0.0-beta.0",
87
- "@nx/web": "20.0.0-beta.0",
88
- "@nx/workspace": "20.0.0-beta.0",
83
+ "@nx/devkit": "20.0.0-beta.2",
84
+ "@nx/js": "20.0.0-beta.2",
85
+ "@nx/eslint": "20.0.0-beta.2",
86
+ "@nx/webpack": "20.0.0-beta.2",
87
+ "@nx/web": "20.0.0-beta.2",
88
+ "@nx/workspace": "20.0.0-beta.2",
89
89
  "piscina": "^4.4.0",
90
- "@nrwl/angular": "20.0.0-beta.0"
90
+ "@nrwl/angular": "20.0.0-beta.2"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
@@ -3,6 +3,4 @@ export interface StoriesGeneratorOptions {
3
3
  interactionTests?: boolean;
4
4
  skipFormat?: boolean;
5
5
  ignorePaths?: string[];
6
- cypressProject?: string;
7
- generateCypressSpecs?: boolean;
8
6
  }
@@ -25,16 +25,6 @@
25
25
  "x-priority": "important",
26
26
  "default": true
27
27
  },
28
- "generateCypressSpecs": {
29
- "type": "boolean",
30
- "description": "Specifies whether to automatically generate `*.spec.ts` files in the Cypress e2e app generated by the `cypress-configure` generator.",
31
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
32
- },
33
- "cypressProject": {
34
- "type": "string",
35
- "description": "The Cypress project to generate the stories under. This is inferred from `name` by default.",
36
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
37
- },
38
28
  "skipFormat": {
39
29
  "description": "Skip formatting files.",
40
30
  "type": "boolean",
@@ -3,26 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.angularStoriesGenerator = angularStoriesGenerator;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
- const component_cypress_spec_1 = tslib_1.__importDefault(require("../component-cypress-spec/component-cypress-spec"));
7
6
  const component_story_1 = tslib_1.__importDefault(require("../component-story/component-story"));
8
7
  const component_info_1 = require("../utils/storybook-ast/component-info");
9
8
  const entry_point_1 = require("../utils/storybook-ast/entry-point");
10
- const get_e2e_project_1 = require("./lib/get-e2e-project");
11
9
  const module_info_1 = require("../utils/storybook-ast/module-info");
12
10
  const minimatch_1 = require("minimatch");
13
11
  const versions_1 = require("../../utils/versions");
14
12
  async function angularStoriesGenerator(tree, options) {
15
- const e2eProjectName = options.cypressProject ?? `${options.name}-e2e`;
16
- const e2eProject = (0, get_e2e_project_1.getE2EProject)(tree, e2eProjectName);
17
13
  const entryPoints = (0, entry_point_1.getProjectEntryPoints)(tree, options.name);
18
14
  const componentsInfo = [];
19
15
  for (const entryPoint of entryPoints) {
20
16
  const moduleFilePaths = (0, module_info_1.getModuleFilePaths)(tree, entryPoint);
21
17
  componentsInfo.push(...(0, component_info_1.getComponentsInfo)(tree, entryPoint, moduleFilePaths, options.name), ...(0, component_info_1.getStandaloneComponentsInfo)(tree, entryPoint));
22
18
  }
23
- if (options.generateCypressSpecs && !e2eProject) {
24
- 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.`);
25
- }
26
19
  const componentInfos = componentsInfo.filter((f) => !options.ignorePaths?.some((pattern) => {
27
20
  const shouldIgnorePath = (0, minimatch_1.minimatch)((0, devkit_1.joinPathFragments)(f.moduleFolderPath, f.path, `${f.componentFileName}.ts`), pattern);
28
21
  return shouldIgnorePath;
@@ -39,18 +32,6 @@ async function angularStoriesGenerator(tree, options) {
39
32
  interactionTests: options.interactionTests ?? true,
40
33
  skipFormat: true,
41
34
  });
42
- if (options.generateCypressSpecs && e2eProject) {
43
- await (0, component_cypress_spec_1.default)(tree, {
44
- projectName: options.name,
45
- projectPath: info.moduleFolderPath,
46
- cypressProject: options.cypressProject,
47
- componentName: info.name,
48
- componentPath: info.path,
49
- componentFileName: info.componentFileName,
50
- specDirectory: (0, devkit_1.joinPathFragments)(info.entryPointName, info.path),
51
- skipFormat: true,
52
- });
53
- }
54
35
  }
55
36
  const tasks = [];
56
37
  if (options.interactionTests) {
@@ -2,17 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateStories = generateStories;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const versions_1 = require("../../../utils/versions");
6
5
  const stories_1 = require("../../stories/stories");
7
6
  async function generateStories(tree, options) {
8
7
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
9
- (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
10
- const { getE2eProjectName } = require('@nx/cypress/src/utils/project-name');
11
- const e2eProjectName = getE2eProjectName(options.project, project.root, options.cypressDirectory);
12
8
  await (0, stories_1.angularStoriesGenerator)(tree, {
13
9
  name: options.project,
14
- generateCypressSpecs: options.configureCypress && options.generateCypressSpecs,
15
- cypressProject: e2eProjectName,
16
10
  ignorePaths: options.ignorePaths,
17
11
  interactionTests: options.interactionTests,
18
12
  skipFormat: true,
@@ -8,9 +8,7 @@ async function generateStorybookConfiguration(tree, options) {
8
8
  return await configurationGenerator(tree, {
9
9
  project: options.project,
10
10
  uiFramework: '@storybook/angular',
11
- configureCypress: options.configureCypress,
12
11
  linter: options.linter,
13
- cypressDirectory: options.cypressDirectory,
14
12
  tsConfiguration: options.tsConfiguration,
15
13
  interactionTests: options.interactionTests,
16
14
  configureStaticServe: options.configureStaticServe,
@@ -9,7 +9,4 @@ export interface StorybookConfigurationOptions {
9
9
  skipFormat?: boolean;
10
10
  ignorePaths?: string[];
11
11
  interactionTests?: boolean;
12
- configureCypress?: boolean;
13
- generateCypressSpecs?: boolean;
14
- cypressDirectory?: string;
15
12
  }
@@ -26,11 +26,6 @@
26
26
  "x-priority": "important",
27
27
  "default": true
28
28
  },
29
- "configureCypress": {
30
- "type": "boolean",
31
- "description": "Specifies whether to configure Cypress or not.",
32
- "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
33
- },
34
29
  "generateStories": {
35
30
  "type": "boolean",
36
31
  "description": "Specifies whether to automatically generate `*.stories.ts` files for components declared in this project or not.",
@@ -38,11 +33,6 @@
38
33
  "default": true,
39
34
  "x-priority": "important"
40
35
  },
41
- "generateCypressSpecs": {
42
- "type": "boolean",
43
- "description": "Specifies whether to automatically generate test files in the generated Cypress e2e app.",
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
  "linter": {
59
44
  "description": "The tool to use for running lint checks.",
60
45
  "type": "string",
@@ -6,11 +6,8 @@ const update_app_editor_tsconfig_excluded_files_1 = require("../utils/update-app
6
6
  const assert_compatible_storybook_version_1 = require("./lib/assert-compatible-storybook-version");
7
7
  const generate_stories_1 = require("./lib/generate-stories");
8
8
  const generate_storybook_configuration_1 = require("./lib/generate-storybook-configuration");
9
- const validate_options_1 = require("./lib/validate-options");
10
- // TODO(katerina): Nx 19 -> remove Cypress
11
9
  async function storybookConfigurationGenerator(tree, options) {
12
10
  (0, assert_compatible_storybook_version_1.assertCompatibleStorybookVersion)();
13
- (0, validate_options_1.validateOptions)(options);
14
11
  const storybookGeneratorInstallTask = await (0, generate_storybook_configuration_1.generateStorybookConfiguration)(tree, {
15
12
  ...options,
16
13
  interactionTests: options.interactionTests ?? true, // default is true
@@ -1,4 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- import type { ComponentCypressSpecGeneratorOptions } from './schema';
3
- export declare function componentCypressSpecGenerator(tree: Tree, options: ComponentCypressSpecGeneratorOptions): Promise<void>;
4
- export default componentCypressSpecGenerator;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.componentCypressSpecGenerator = componentCypressSpecGenerator;
4
- const devkit_1 = require("@nx/devkit");
5
- const storybook_inputs_1 = require("../utils/storybook-ast/storybook-inputs");
6
- const get_args_default_value_1 = require("./lib/get-args-default-value");
7
- const get_component_selector_1 = require("./lib/get-component-selector");
8
- async function componentCypressSpecGenerator(tree, options) {
9
- const { cypressProject, projectName, projectPath, componentPath, componentFileName, componentName, specDirectory, } = options;
10
- const e2eProjectName = cypressProject || `${projectName}-e2e`;
11
- const { sourceRoot, root } = (0, devkit_1.readProjectConfiguration)(tree, e2eProjectName);
12
- const isCypressV10 = tree.exists((0, devkit_1.joinPathFragments)(root, 'cypress.config.ts'));
13
- const e2eLibIntegrationFolderPath = (0, devkit_1.joinPathFragments)(sourceRoot, isCypressV10 ? 'e2e' : 'integration');
14
- const templatesDir = (0, devkit_1.joinPathFragments)(__dirname, 'files');
15
- const destinationDir = (0, devkit_1.joinPathFragments)(e2eLibIntegrationFolderPath, specDirectory ?? componentPath);
16
- const storyFile = (0, devkit_1.joinPathFragments)(destinationDir, `${componentFileName}.${isCypressV10 ? 'cy' : 'spec'}.ts`);
17
- if (tree.exists(storyFile)) {
18
- return;
19
- }
20
- const fullComponentPath = (0, devkit_1.joinPathFragments)(projectPath, componentPath, `${componentFileName}.ts`);
21
- const props = (0, storybook_inputs_1.getComponentProps)(tree, fullComponentPath, get_args_default_value_1.getArgsDefaultValue);
22
- const componentSelector = (0, get_component_selector_1.getComponentSelector)(tree, fullComponentPath);
23
- (0, devkit_1.generateFiles)(tree, templatesDir, destinationDir, {
24
- projectName,
25
- componentFileName,
26
- componentName,
27
- componentSelector,
28
- props,
29
- fileExt: isCypressV10 ? 'cy.ts' : 'spec.ts',
30
- });
31
- if (!options.skipFormat) {
32
- await (0, devkit_1.formatFiles)(tree);
33
- }
34
- }
35
- exports.default = componentCypressSpecGenerator;
@@ -1,17 +0,0 @@
1
- describe('<%=projectName%>', () => {
2
- beforeEach(() =>
3
- cy.visit(
4
- '/iframe.html?id=<%= componentName.toLowerCase() %>--primary<% if ( props && props.length > 0 ) { %>&args=<% } %><%
5
- for(let prop of props) {
6
- %><%=prop.name%><%
7
- if(prop.defaultValue !== undefined && (prop.defaultValue || prop.defaultValue === false)) {
8
- %>:<%=prop.defaultValue%><%
9
- } %>;<%
10
- }%>'
11
- )
12
- );
13
-
14
- it('should render the component', () => {
15
- cy.get('<%=componentSelector%>').should('exist');
16
- });
17
- });
@@ -1,2 +0,0 @@
1
- import type { PropertyDeclaration } from 'typescript';
2
- export declare function getArgsDefaultValue(property: PropertyDeclaration): string | undefined;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getArgsDefaultValue = getArgsDefaultValue;
4
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
5
- let tsModule;
6
- function getArgsDefaultValue(property) {
7
- if (!property.initializer) {
8
- return undefined;
9
- }
10
- if (!tsModule) {
11
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
12
- }
13
- switch (property.initializer.kind) {
14
- case tsModule.SyntaxKind.StringLiteral:
15
- const returnString = property.initializer.getText().slice(1, -1);
16
- return returnString.replace(/\s/g, '+');
17
- case tsModule.SyntaxKind.NumericLiteral:
18
- case tsModule.SyntaxKind.TrueKeyword:
19
- case tsModule.SyntaxKind.FalseKeyword:
20
- return property.initializer.getText();
21
- default:
22
- return undefined;
23
- }
24
- }
@@ -1,2 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export declare function getComponentSelector(tree: Tree, path: string): string;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComponentSelector = getComponentSelector;
4
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
5
- const js_1 = require("@nx/js");
6
- const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
7
- let tsModule;
8
- function getComponentSelector(tree, path) {
9
- if (!tsModule) {
10
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
11
- }
12
- const file = (0, ast_utils_1.getTsSourceFile)(tree, path);
13
- const componentDecorators = (0, ast_utils_1.getDecoratorMetadata)(file, 'Component', '@angular/core');
14
- if (componentDecorators.length === 0) {
15
- throw new Error(`No @Component decorator in ${path}.`);
16
- }
17
- const componentDecorator = componentDecorators[0];
18
- const selectorNode = ((0, js_1.findNodes)(componentDecorator, tsModule.SyntaxKind.PropertyAssignment).find((node) => node.name.getText() === 'selector'));
19
- if (!selectorNode) {
20
- throw new Error(`No selector defined for the component in ${path}.`);
21
- }
22
- return selectorNode.initializer.getText().slice(1, -1);
23
- }
@@ -1,10 +0,0 @@
1
- export interface ComponentCypressSpecGeneratorOptions {
2
- projectName: string;
3
- projectPath: string;
4
- componentName: string;
5
- componentPath: string;
6
- componentFileName: string;
7
- cypressProject?: string;
8
- specDirectory?: string;
9
- skipFormat?: boolean;
10
- }
@@ -1,66 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "NxAngularComponentCypressSpecGenerator",
4
- "type": "object",
5
- "cli": "nx",
6
- "description": "Creates 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
- "properties": {
9
- "projectName": {
10
- "type": "string",
11
- "description": "The name of the project.",
12
- "$default": {
13
- "$source": "projectName"
14
- },
15
- "examples": ["ui-samples"],
16
- "x-priority": "important"
17
- },
18
- "projectPath": {
19
- "type": "string",
20
- "description": "Path to the project.",
21
- "examples": ["libs/ui-samples"],
22
- "x-priority": "important"
23
- },
24
- "componentName": {
25
- "type": "string",
26
- "description": "Class name of the component.",
27
- "examples": ["AwesomeComponent"],
28
- "x-priority": "important"
29
- },
30
- "componentPath": {
31
- "type": "string",
32
- "description": "Relative path to the component file from the project root.",
33
- "examples": ["awesome"],
34
- "x-priority": "important"
35
- },
36
- "componentFileName": {
37
- "type": "string",
38
- "description": "Component file name without the `.ts` extension.",
39
- "examples": ["awesome.component"],
40
- "x-priority": "important"
41
- },
42
- "cypressProject": {
43
- "type": "string",
44
- "description": "The Cypress project to generate the stories under. By default, inferred from `projectName`."
45
- },
46
- "specDirectory": {
47
- "type": "string",
48
- "description": "Directory where to place the generated spec file. By default matches the value of the `componentPath` option."
49
- },
50
- "skipFormat": {
51
- "description": "Skip formatting files.",
52
- "type": "boolean",
53
- "default": false,
54
- "x-priority": "internal"
55
- }
56
- },
57
- "additionalProperties": false,
58
- "required": [
59
- "projectName",
60
- "projectPath",
61
- "componentName",
62
- "componentPath",
63
- "componentFileName"
64
- ],
65
- "examplesFile": "../../../docs/component-cypress-spec-examples.md"
66
- }
@@ -1,2 +0,0 @@
1
- import type { ProjectConfiguration, Tree } from '@nx/devkit';
2
- export declare function getE2EProject(tree: Tree, e2eProjectName: string): ProjectConfiguration;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getE2EProject = getE2EProject;
4
- const devkit_1 = require("@nx/devkit");
5
- function getE2EProject(tree, e2eProjectName) {
6
- let e2eProject;
7
- try {
8
- e2eProject = (0, devkit_1.readProjectConfiguration)(tree, e2eProjectName);
9
- }
10
- catch {
11
- e2eProject = undefined;
12
- }
13
- return e2eProject;
14
- }
@@ -1,2 +0,0 @@
1
- import type { StorybookConfigurationOptions } from '../schema';
2
- export declare function validateOptions(options: StorybookConfigurationOptions): void;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateOptions = validateOptions;
4
- function validateOptions(options) {
5
- if (options.generateCypressSpecs && !options.generateStories) {
6
- throw new Error('Cannot set generateCypressSpecs to true when generateStories is set to false.');
7
- }
8
- }