@nx/angular 18.0.0-canary.20240202-ea5befb → 18.0.0

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 (29) hide show
  1. package/executors.json +1 -1
  2. package/generators.d.ts +1 -1
  3. package/generators.js +3 -1
  4. package/generators.json +1 -1
  5. package/package.json +10 -10
  6. package/plugins/component-testing.d.ts +1 -26
  7. package/plugins/component-testing.js +11 -1
  8. package/src/builders/dev-server/dev-server.impl.js +5 -2
  9. package/src/builders/dev-server/schema.json +1 -1
  10. package/src/builders/webpack-browser/schema.d.ts +5 -1
  11. package/src/builders/webpack-browser/schema.json +3 -2
  12. package/src/builders/webpack-browser/webpack-browser.impl.js +4 -3
  13. package/src/generators/add-linting/add-linting.js +1 -0
  14. package/src/generators/add-linting/schema.d.ts +1 -0
  15. package/src/generators/application/application.js +1 -0
  16. package/src/generators/application/lib/add-e2e.js +2 -0
  17. package/src/generators/application/lib/add-linting.js +1 -0
  18. package/src/generators/application/lib/add-unit-test-runner.js +1 -0
  19. package/src/generators/application/lib/normalize-options.js +1 -0
  20. package/src/generators/application/schema.d.ts +1 -0
  21. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +2 -1
  22. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +30 -14
  23. package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
  24. package/src/generators/library/lib/add-project.js +6 -3
  25. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +1 -0
  26. package/src/generators/ng-add/utilities/workspace.js +3 -1
  27. package/src/generators/utils/add-jest.d.ts +1 -0
  28. package/src/generators/utils/add-jest.js +1 -0
  29. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +1 -1
package/executors.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "dev-server": {
41
41
  "implementation": "./src/builders/dev-server/dev-server.impl",
42
42
  "schema": "./src/builders/dev-server/schema.json",
43
- "description": "The `dev-server` executor is very similar to the standard `dev-server` builder provided by the Angular Devkit. It is usually used in tandem with `@nrwl/angular:webpack-browser` when your Angular application uses a custom webpack configuration."
43
+ "description": "Serves an Angular application using [Webpack](https://webpack.js.org/) when the build target is using a Webpack-based executor, or [Vite](https://vitejs.dev/) when the build target uses an esbuild-based executor."
44
44
  },
45
45
  "webpack-server": {
46
46
  "implementation": "./src/builders/webpack-server/webpack-server.impl",
package/generators.d.ts CHANGED
@@ -25,6 +25,6 @@ export * from './src/generators/setup-tailwind/setup-tailwind';
25
25
  export * from './src/generators/stories/stories';
26
26
  export * from './src/generators/storybook-configuration/storybook-configuration';
27
27
  export * from './src/generators/web-worker/web-worker';
28
- export * from './src/generators/cypress-component-configuration/cypress-component-configuration';
28
+ export { cypressComponentConfiguration } from './src/generators/cypress-component-configuration/cypress-component-configuration';
29
29
  export * from './src/generators/component-test/component-test';
30
30
  export * from './src/utils/test-runners';
package/generators.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cypressComponentConfiguration = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  tslib_1.__exportStar(require("./src/generators/add-linting/add-linting"), exports);
5
6
  tslib_1.__exportStar(require("./src/generators/application/application"), exports);
@@ -28,6 +29,7 @@ tslib_1.__exportStar(require("./src/generators/setup-tailwind/setup-tailwind"),
28
29
  tslib_1.__exportStar(require("./src/generators/stories/stories"), exports);
29
30
  tslib_1.__exportStar(require("./src/generators/storybook-configuration/storybook-configuration"), exports);
30
31
  tslib_1.__exportStar(require("./src/generators/web-worker/web-worker"), exports);
31
- tslib_1.__exportStar(require("./src/generators/cypress-component-configuration/cypress-component-configuration"), exports);
32
+ var cypress_component_configuration_1 = require("./src/generators/cypress-component-configuration/cypress-component-configuration");
33
+ Object.defineProperty(exports, "cypressComponentConfiguration", { enumerable: true, get: function () { return cypress_component_configuration_1.cypressComponentConfiguration; } });
32
34
  tslib_1.__exportStar(require("./src/generators/component-test/component-test"), exports);
33
35
  tslib_1.__exportStar(require("./src/utils/test-runners"), exports);
package/generators.json CHANGED
@@ -173,7 +173,7 @@
173
173
  "description": "Adds Storybook configuration to a project."
174
174
  },
175
175
  "cypress-component-configuration": {
176
- "factory": "./src/generators/cypress-component-configuration/cypress-component-configuration",
176
+ "factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfigurationInternal",
177
177
  "schema": "./src/generators/cypress-component-configuration/schema.json",
178
178
  "description": "Setup Cypress component testing for a project."
179
179
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "18.0.0-canary.20240202-ea5befb",
3
+ "version": "18.0.0",
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, 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- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -78,16 +78,16 @@
78
78
  "tslib": "^2.3.0",
79
79
  "webpack": "^5.80.0",
80
80
  "webpack-merge": "^5.8.0",
81
- "@nx/devkit": "18.0.0-canary.20240202-ea5befb",
82
- "@nx/cypress": "18.0.0-canary.20240202-ea5befb",
83
- "@nx/jest": "18.0.0-canary.20240202-ea5befb",
84
- "@nx/js": "18.0.0-canary.20240202-ea5befb",
85
- "@nx/eslint": "18.0.0-canary.20240202-ea5befb",
86
- "@nx/webpack": "18.0.0-canary.20240202-ea5befb",
87
- "@nx/web": "18.0.0-canary.20240202-ea5befb",
88
- "@nx/workspace": "18.0.0-canary.20240202-ea5befb",
81
+ "@nx/devkit": "18.0.0",
82
+ "@nx/cypress": "18.0.0",
83
+ "@nx/jest": "18.0.0",
84
+ "@nx/js": "18.0.0",
85
+ "@nx/eslint": "18.0.0",
86
+ "@nx/webpack": "18.0.0",
87
+ "@nx/web": "18.0.0",
88
+ "@nx/workspace": "18.0.0",
89
89
  "piscina": "^4.2.1",
90
- "@nrwl/angular": "18.0.0-canary.20240202-ea5befb"
90
+ "@nrwl/angular": "18.0.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
@@ -17,29 +17,4 @@ import { NxComponentTestingOptions } from '@nx/cypress/plugins/cypress-preset';
17
17
  * @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
18
18
  * @param options override options
19
19
  */
20
- export declare function nxComponentTestingPreset(pathToConfig: string, options?: NxComponentTestingOptions): {
21
- specPattern: string[];
22
- indexHtmlFile: string;
23
- devServer: {
24
- options: {
25
- projectConfig: {
26
- root: string;
27
- sourceRoot: string;
28
- buildOptions: import("@angular-devkit/build-angular").BrowserBuilderOptions & {
29
- customWebpackConfig?: {
30
- path: string;
31
- };
32
- indexFileTransformer?: string;
33
- buildLibsFromSource?: boolean;
34
- } & {
35
- workspaceRoot: string;
36
- };
37
- };
38
- };
39
- framework: "angular";
40
- bundler: "webpack";
41
- };
42
- videosFolder: string;
43
- screenshotsFolder: string;
44
- chromeWebSecurity: boolean;
45
- };
20
+ export declare function nxComponentTestingPreset(pathToConfig: string, options?: NxComponentTestingOptions): any;
@@ -26,6 +26,13 @@ const semver_1 = require("semver");
26
26
  * @param options override options
27
27
  */
28
28
  function nxComponentTestingPreset(pathToConfig, options) {
29
+ if (global.NX_GRAPH_CREATION || global.NX_CYPRESS_INIT_GENERATOR_RUNNING) {
30
+ // this is only used by plugins, so we don't need the component testing
31
+ // options, cast to any to avoid type errors
32
+ return (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
33
+ testingType: 'component',
34
+ });
35
+ }
29
36
  let graph;
30
37
  try {
31
38
  graph = (0, devkit_1.readCachedProjectGraph)();
@@ -41,7 +48,10 @@ ${e.stack ? e.stack : e}`);
41
48
  const ctProjectConfig = (0, ct_helpers_1.getProjectConfigByPath)(graph, pathToConfig);
42
49
  const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
43
50
  const ctContext = (0, ct_helpers_1.createExecutorContext)(graph, ctProjectConfig.targets, ctProjectConfig.name, options?.ctTargetName || 'component-test', ctConfigurationName);
44
- const buildTarget = getBuildableTarget(ctContext);
51
+ const buildTarget = options?.buildTarget
52
+ ? (0, devkit_1.parseTargetString)(options.buildTarget, graph)
53
+ : // for backwards compat, if no buildTargetin the preset options, get it from the target options
54
+ getBuildableTarget(ctContext);
45
55
  if (!buildTarget.project && !graph.nodes?.[buildTarget.project]?.data) {
46
56
  throw new Error((0, devkit_1.stripIndents) `Unable to find project configuration for build target.
47
57
  Project Name? ${buildTarget.project}
@@ -54,9 +54,11 @@ function executeDevServerBuilder(rawOptions, context) {
54
54
  throw new Error(`Custom Webpack Config File Not Found!\nTo use a custom webpack config, please ensure the path to the custom webpack file is correct: \n${pathToWebpackConfig}`);
55
55
  }
56
56
  }
57
+ const normalizedIndexHtmlTransformer = buildTargetOptions.indexHtmlTransformer ??
58
+ buildTargetOptions.indexFileTransformer;
57
59
  let pathToIndexFileTransformer;
58
- if (buildTargetOptions.indexFileTransformer) {
59
- pathToIndexFileTransformer = (0, devkit_1.joinPathFragments)(context.workspaceRoot, buildTargetOptions.indexFileTransformer);
60
+ if (normalizedIndexHtmlTransformer) {
61
+ pathToIndexFileTransformer = (0, devkit_1.joinPathFragments)(context.workspaceRoot, normalizedIndexHtmlTransformer);
60
62
  if (pathToIndexFileTransformer && !(0, fs_1.existsSync)(pathToIndexFileTransformer)) {
61
63
  throw new Error(`File containing Index File Transformer function Not Found!\n Please ensure the path to the file containing the function is correct: \n${pathToIndexFileTransformer}`);
62
64
  }
@@ -184,6 +186,7 @@ function patchBuilderContext(context, isUsingEsbuildBuilder, buildTarget) {
184
186
  function cleanBuildTargetOptions(options) {
185
187
  delete options.buildLibsFromSource;
186
188
  delete options.customWebpackConfig;
189
+ delete options.indexHtmlTransformer;
187
190
  delete options.indexFileTransformer;
188
191
  delete options.plugins;
189
192
  return options;
@@ -3,7 +3,7 @@
3
3
  "outputCapture": "direct-nodejs",
4
4
  "$schema": "http://json-schema.org/draft-07/schema",
5
5
  "title": "Schema for Webpack Dev Server",
6
- "description": "The dev-server executor is very similar to the standard dev server builder provided by the Angular Devkit. It is usually used in tandem with `@nx/angular:webpack-browser` when your Angular application uses a custom webpack configuration.",
6
+ "description": "Serves an Angular application using [Webpack](https://webpack.js.org/) when the build target is using a Webpack-based executor, or [Vite](https://vitejs.dev/) when the build target uses an esbuild-based executor.",
7
7
  "examplesFile": "../../../docs/dev-server-examples.md",
8
8
  "type": "object",
9
9
  "presets": [
@@ -4,6 +4,10 @@ export type BrowserBuilderSchema = Schema & {
4
4
  customWebpackConfig?: {
5
5
  path: string;
6
6
  };
7
- indexFileTransformer?: string;
7
+ indexHtmlTransformer?: string;
8
8
  buildLibsFromSource?: boolean;
9
+ /**
10
+ * @deprecated Use `indexHtmlTransformer` instead. It will be removed in Nx 19.
11
+ */
12
+ indexFileTransformer?: string;
9
13
  };
@@ -458,9 +458,10 @@
458
458
  "x-priority": "important",
459
459
  "additionalProperties": false
460
460
  },
461
- "indexFileTransformer": {
461
+ "indexHtmlTransformer": {
462
462
  "description": "Path to transformer function to transform the index.html",
463
- "type": "string"
463
+ "type": "string",
464
+ "alias": "indexFileTransformer"
464
465
  },
465
466
  "buildLibsFromSource": {
466
467
  "type": "boolean",
@@ -24,7 +24,7 @@ function shouldSkipInitialTargetRun(projectGraph, project, target) {
24
24
  }
25
25
  function executeWebpackBrowserBuilder(options, context) {
26
26
  options.buildLibsFromSource ??= true;
27
- const { buildLibsFromSource, customWebpackConfig, indexFileTransformer, ...delegateBuilderOptions } = options;
27
+ const { buildLibsFromSource, customWebpackConfig, indexHtmlTransformer, indexFileTransformer, ...delegateBuilderOptions } = options;
28
28
  process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildLibsFromSource}`;
29
29
  process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({ ...context.target });
30
30
  const pathToWebpackConfig = customWebpackConfig?.path &&
@@ -32,8 +32,9 @@ function executeWebpackBrowserBuilder(options, context) {
32
32
  if (pathToWebpackConfig && !(0, fs_1.existsSync)(pathToWebpackConfig)) {
33
33
  throw new Error(`Custom Webpack Config File Not Found!\nTo use a custom webpack config, please ensure the path to the custom webpack file is correct: \n${pathToWebpackConfig}`);
34
34
  }
35
- const pathToIndexFileTransformer = indexFileTransformer &&
36
- (0, devkit_1.joinPathFragments)(context.workspaceRoot, indexFileTransformer);
35
+ const normalizedIndexHtmlTransformer = indexHtmlTransformer ?? indexFileTransformer;
36
+ const pathToIndexFileTransformer = normalizedIndexHtmlTransformer &&
37
+ (0, devkit_1.joinPathFragments)(context.workspaceRoot, normalizedIndexHtmlTransformer);
37
38
  if (pathToIndexFileTransformer && !(0, fs_1.existsSync)(pathToIndexFileTransformer)) {
38
39
  throw new Error(`File containing Index File Transformer function Not Found!\n Please ensure the path to the file containing the function is correct: \n${pathToIndexFileTransformer}`);
39
40
  }
@@ -20,6 +20,7 @@ async function addLintingGenerator(tree, options) {
20
20
  setParserOptionsProject: options.setParserOptionsProject,
21
21
  skipFormat: true,
22
22
  rootProject: rootProject,
23
+ addPlugin: options.addPlugin,
23
24
  });
24
25
  tasks.push(lintTask);
25
26
  if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
@@ -6,4 +6,5 @@ export interface AddLintingGeneratorSchema {
6
6
  skipFormat?: boolean;
7
7
  skipPackageJson?: boolean;
8
8
  unitTestRunner?: string;
9
+ addPlugin?: boolean;
9
10
  }
@@ -12,6 +12,7 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
12
12
  async function applicationGenerator(tree, schema) {
13
13
  return await applicationGeneratorInternal(tree, {
14
14
  projectNameAndRootFormat: 'derived',
15
+ addPlugin: false,
15
16
  ...schema,
16
17
  });
17
18
  }
@@ -26,6 +26,7 @@ async function addE2e(tree, options) {
26
26
  devServerTarget: `${options.name}:serve:development`,
27
27
  baseUrl: 'http://localhost:4200',
28
28
  rootProject: options.rootProject,
29
+ addPlugin: options.addPlugin,
29
30
  });
30
31
  }
31
32
  else if (options.e2eTestRunner === 'playwright') {
@@ -48,6 +49,7 @@ async function addE2e(tree, options) {
48
49
  webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
49
50
  webServerAddress: `http://localhost:${options.port ?? 4200}`,
50
51
  rootProject: options.rootProject,
52
+ addPlugin: options.addPlugin,
51
53
  });
52
54
  }
53
55
  }
@@ -15,6 +15,7 @@ async function addLinting(host, options) {
15
15
  skipPackageJson: options.skipPackageJson,
16
16
  unitTestRunner: options.unitTestRunner,
17
17
  skipFormat: true,
18
+ addPlugin: options.addPlugin,
18
19
  });
19
20
  }
20
21
  exports.addLinting = addLinting;
@@ -10,6 +10,7 @@ async function addUnitTestRunner(host, options) {
10
10
  projectRoot: options.appProjectRoot,
11
11
  skipPackageJson: options.skipPackageJson,
12
12
  strict: options.strict,
13
+ addPlugin: options.addPlugin,
13
14
  });
14
15
  }
15
16
  }
@@ -19,6 +19,7 @@ async function normalizeOptions(host, options) {
19
19
  });
20
20
  options.rootProject = appProjectRoot === '.';
21
21
  options.projectNameAndRootFormat = projectNameAndRootFormat;
22
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
22
23
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
23
24
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
24
25
  const parsedTags = options.tags
@@ -31,4 +31,5 @@ export interface Schema {
31
31
  minimal?: boolean;
32
32
  bundler?: 'webpack' | 'esbuild';
33
33
  ssr?: boolean;
34
+ addPlugin?: boolean;
34
35
  }
@@ -1,8 +1,9 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { CypressComponentConfigSchema } from './schema';
3
+ export declare function cypressComponentConfiguration(tree: Tree, options: CypressComponentConfigSchema): Promise<import("@nx/devkit").GeneratorCallback>;
3
4
  /**
4
5
  * This is for cypress built in component testing, if you want to test with
5
6
  * storybook + cypress then use the componentCypressGenerator instead.
6
7
  */
7
- export declare function cypressComponentConfiguration(tree: Tree, options: CypressComponentConfigSchema): Promise<import("@nx/devkit").GeneratorCallback>;
8
+ export declare function cypressComponentConfigurationInternal(tree: Tree, options: CypressComponentConfigSchema): Promise<import("@nx/devkit").GeneratorCallback>;
8
9
  export default cypressComponentConfiguration;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cypressComponentConfiguration = void 0;
3
+ exports.cypressComponentConfigurationInternal = exports.cypressComponentConfiguration = void 0;
4
4
  const cypress_1 = require("@nx/cypress");
5
5
  const config_1 = require("@nx/cypress/src/utils/config");
6
6
  const find_target_options_1 = require("@nx/cypress/src/utils/find-target-options");
@@ -10,28 +10,34 @@ const component_test_1 = require("../component-test/component-test");
10
10
  const component_info_1 = require("../utils/storybook-ast/component-info");
11
11
  const entry_point_1 = require("../utils/storybook-ast/entry-point");
12
12
  const module_info_1 = require("../utils/storybook-ast/module-info");
13
+ function cypressComponentConfiguration(tree, options) {
14
+ return cypressComponentConfigurationInternal(tree, {
15
+ addPlugin: false,
16
+ ...options,
17
+ });
18
+ }
19
+ exports.cypressComponentConfiguration = cypressComponentConfiguration;
13
20
  /**
14
21
  * This is for cypress built in component testing, if you want to test with
15
22
  * storybook + cypress then use the componentCypressGenerator instead.
16
23
  */
17
- async function cypressComponentConfiguration(tree, options) {
24
+ async function cypressComponentConfigurationInternal(tree, options) {
25
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
18
26
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
19
27
  const installTask = await (0, cypress_1.componentConfigurationGenerator)(tree, {
20
28
  project: options.project,
21
29
  skipFormat: true,
30
+ addPlugin: options.addPlugin,
22
31
  });
23
- await updateProjectConfig(tree, options);
32
+ await configureCypressCT(tree, options);
24
33
  await addFiles(tree, projectConfig, options);
25
34
  if (!options.skipFormat) {
26
35
  await (0, devkit_1.formatFiles)(tree);
27
36
  }
28
37
  return installTask;
29
38
  }
30
- exports.cypressComponentConfiguration = cypressComponentConfiguration;
39
+ exports.cypressComponentConfigurationInternal = cypressComponentConfigurationInternal;
31
40
  async function addFiles(tree, projectConfig, options) {
32
- const cyConfigFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
33
- const updatedCyConfig = await (0, config_1.addDefaultCTConfig)(tree.read(cyConfigFile, 'utf-8'));
34
- tree.write(cyConfigFile, `import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';\n${updatedCyConfig}`);
35
41
  const componentFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
36
42
  const updatedCmpContents = await (0, config_1.addMountDefinition)(tree.read(componentFile, 'utf-8'));
37
43
  tree.write(componentFile, `import { mount } from 'cypress/angular';\n${updatedCmpContents}`);
@@ -57,7 +63,7 @@ async function addFiles(tree, projectConfig, options) {
57
63
  }
58
64
  }
59
65
  }
60
- async function updateProjectConfig(tree, options) {
66
+ async function configureCypressCT(tree, options) {
61
67
  let found = { target: options.buildTarget, config: undefined };
62
68
  if (!options.buildTarget) {
63
69
  found = await (0, find_target_options_1.findBuildConfig)(tree, {
@@ -71,13 +77,23 @@ async function updateProjectConfig(tree, options) {
71
77
  });
72
78
  assertValidConfig(found?.config);
73
79
  }
80
+ const ctConfigOptions = {};
74
81
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
75
- projectConfig.targets['component-test'].options = {
76
- ...projectConfig.targets['component-test'].options,
77
- skipServe: true,
78
- devServerTarget: found.target,
79
- };
80
- (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
82
+ if (projectConfig.targets?.['component-test']?.executor ===
83
+ '@nx/cypress:cypress') {
84
+ projectConfig.targets['component-test'].options = {
85
+ ...projectConfig.targets['component-test'].options,
86
+ skipServe: true,
87
+ devServerTarget: found.target,
88
+ };
89
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
90
+ }
91
+ else {
92
+ ctConfigOptions.buildTarget = found.target;
93
+ }
94
+ const cypressConfigPath = (0, config_1.getProjectCypressConfigPath)(tree, projectConfig.root);
95
+ const updatedCyConfig = await (0, config_1.addDefaultCTConfig)(tree.read(cypressConfigPath, 'utf-8'), ctConfigOptions);
96
+ tree.write(cypressConfigPath, `import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';\n${updatedCyConfig}`);
81
97
  }
82
98
  function assertValidConfig(config) {
83
99
  if (!config) {
@@ -3,4 +3,5 @@ export interface CypressComponentConfigSchema {
3
3
  generateTests: boolean;
4
4
  skipFormat?: boolean;
5
5
  buildTarget?: string;
6
+ addPlugin?: boolean;
6
7
  }
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
5
6
  function addProject(tree, libraryOptions) {
7
+ const executor = libraryOptions.publishable
8
+ ? '@nx/angular:package'
9
+ : '@nx/angular:ng-packagr-lite';
10
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
6
11
  const project = {
7
12
  name: libraryOptions.name,
8
13
  root: libraryOptions.projectRoot,
@@ -13,9 +18,7 @@ function addProject(tree, libraryOptions) {
13
18
  targets: {
14
19
  build: libraryOptions.buildable || libraryOptions.publishable
15
20
  ? {
16
- executor: libraryOptions.publishable
17
- ? '@nx/angular:package'
18
- : '@nx/angular:ng-packagr-lite',
21
+ executor,
19
22
  outputs: ['{workspaceRoot}/dist/{projectRoot}'],
20
23
  options: {
21
24
  project: `${libraryOptions.projectRoot}/ng-package.json`,
@@ -242,6 +242,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
242
242
  // any target would do, we replace it later with the target existing in the project being migrated
243
243
  devServerTarget: `${this.appName}:serve`,
244
244
  baseUrl: 'http://localhost:4200',
245
+ addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
245
246
  });
246
247
  const cypressConfigFilePath = this.updateOrCreateCypressConfigFile(oldCypressConfigFilePath);
247
248
  this.updateCypressProjectConfiguration(cypressConfigFilePath);
@@ -150,7 +150,9 @@ function updatePackageJson(tree) {
150
150
  }
151
151
  exports.updatePackageJson = updatePackageJson;
152
152
  async function updateRootEsLintConfig(tree, existingEsLintConfig, unitTestRunner) {
153
- await (0, eslint_1.lintInitGenerator)(tree, {});
153
+ await (0, eslint_1.lintInitGenerator)(tree, {
154
+ addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
155
+ });
154
156
  if (!existingEsLintConfig) {
155
157
  // There was no eslint config in the root, so we set it up and use it as-is
156
158
  (0, setup_root_eslint_1.setupRootEsLint)(tree, { unitTestRunner });
@@ -4,5 +4,6 @@ export type AddJestOptions = {
4
4
  projectRoot: string;
5
5
  skipPackageJson: boolean;
6
6
  strict: boolean;
7
+ addPlugin?: boolean;
7
8
  };
8
9
  export declare function addJest(tree: Tree, options: AddJestOptions): Promise<void>;
@@ -17,6 +17,7 @@ async function addJest(tree, options) {
17
17
  skipSerializers: false,
18
18
  skipPackageJson: options.skipPackageJson,
19
19
  skipFormat: true,
20
+ addPlugin: options.addPlugin,
20
21
  });
21
22
  const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', 'test-setup.ts');
22
23
  if (options.strict && tree.exists(setupFile)) {
@@ -13,7 +13,7 @@ exports.default = default_1;
13
13
  function isWebpackBrowserUsed(tree) {
14
14
  const projects = (0, devkit_1.getProjects)(tree);
15
15
  for (const project of projects.values()) {
16
- const targets = project.targets;
16
+ const targets = project.targets || {};
17
17
  for (const [_, target] of Object.entries(targets)) {
18
18
  if (target.executor === '@nx/angular:webpack-browser' &&
19
19
  (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||