@nx/angular 18.1.0-beta.0 → 18.1.0-beta.10

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 (79) hide show
  1. package/executors.d.ts +1 -0
  2. package/executors.js +1 -0
  3. package/executors.json +5 -0
  4. package/migrations.json +88 -0
  5. package/package.json +12 -14
  6. package/src/builders/dev-server/dev-server.impl.js +2 -38
  7. package/src/builders/dev-server/lib/validate-options.js +4 -0
  8. package/src/builders/dev-server/schema.d.ts +1 -0
  9. package/src/builders/dev-server/schema.json +18 -0
  10. package/src/executors/application/application.impl.js +3 -3
  11. package/src/executors/application/schema.json +12 -0
  12. package/src/executors/application/utils/validate-options.js +31 -23
  13. package/src/executors/extract-i18n/extract-i18n.impl.d.ts +3 -0
  14. package/src/executors/extract-i18n/extract-i18n.impl.js +43 -0
  15. package/src/executors/extract-i18n/schema.d.ts +8 -0
  16. package/src/executors/extract-i18n/schema.json +45 -0
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +4 -2
  18. package/src/executors/module-federation-dev-server/schema.json +1 -1
  19. package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +2 -2
  20. package/src/executors/utilities/ng-packagr/stylesheet-processor.js +11 -2
  21. package/src/executors/utilities/patch-builder-context.d.ts +3 -0
  22. package/src/executors/utilities/patch-builder-context.js +41 -0
  23. package/src/generators/add-linting/add-linting.d.ts +1 -1
  24. package/src/generators/add-linting/add-linting.js +8 -12
  25. package/src/generators/add-linting/lib/add-angular-eslint-dependencies.d.ts +2 -2
  26. package/src/generators/add-linting/lib/add-angular-eslint-dependencies.js +9 -5
  27. package/src/generators/add-linting/lib/buildable-project.d.ts +2 -0
  28. package/src/generators/add-linting/lib/buildable-project.js +9 -0
  29. package/src/generators/add-linting/schema.d.ts +0 -1
  30. package/src/generators/application/application.js +0 -1
  31. package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -0
  32. package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +1 -1
  33. package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +1 -1
  34. package/src/generators/application/lib/add-e2e.js +10 -6
  35. package/src/generators/application/lib/add-linting.js +0 -1
  36. package/src/generators/application/lib/add-unit-test-runner.js +0 -1
  37. package/src/generators/application/lib/create-files.js +9 -10
  38. package/src/generators/application/lib/normalize-options.js +1 -5
  39. package/src/generators/application/lib/update-editor-tsconfig.d.ts +1 -1
  40. package/src/generators/application/lib/update-editor-tsconfig.js +11 -14
  41. package/src/generators/application/schema.d.ts +0 -1
  42. package/src/generators/application/schema.json +1 -0
  43. package/src/generators/component/lib/normalize-options.js +2 -2
  44. package/src/generators/component-test/component-test.js +4 -2
  45. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +16 -11
  46. package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  47. package/src/generators/directive/lib/normalize-options.js +2 -1
  48. package/src/generators/library/lib/add-project.js +23 -24
  49. package/src/generators/library/lib/normalize-options.js +1 -5
  50. package/src/generators/library/lib/update-tsconfig.js +3 -3
  51. package/src/generators/library/schema.d.ts +1 -0
  52. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +30 -23
  53. package/src/generators/ng-add/utilities/workspace.js +2 -4
  54. package/src/generators/setup-mf/lib/add-cypress-workaround.js +14 -6
  55. package/src/generators/setup-mf/lib/normalize-options.js +1 -1
  56. package/src/generators/storybook-configuration/lib/generate-stories.js +4 -2
  57. package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +2 -0
  58. package/src/generators/storybook-configuration/storybook-configuration.js +5 -0
  59. package/src/generators/utils/add-jest.d.ts +0 -1
  60. package/src/generators/utils/add-jest.js +4 -3
  61. package/src/generators/utils/add-mf-env-to-inputs.js +4 -1
  62. package/src/generators/utils/project.d.ts +0 -1
  63. package/src/generators/utils/project.js +2 -29
  64. package/src/generators/utils/selector.d.ts +2 -2
  65. package/src/generators/utils/selector.js +11 -4
  66. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.d.ts +2 -0
  67. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.js +23 -0
  68. package/src/generators/utils/update-project-root-tsconfig.d.ts +3 -0
  69. package/src/generators/utils/update-project-root-tsconfig.js +26 -0
  70. package/src/migrations/update-18-1-0/update-angular-cli.d.ts +3 -0
  71. package/src/migrations/update-18-1-0/update-angular-cli.js +23 -0
  72. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
  73. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
  74. package/src/utils/mf/with-module-federation-ssr.js +3 -0
  75. package/src/utils/mf/with-module-federation.js +3 -0
  76. package/src/utils/versions.d.ts +4 -4
  77. package/src/utils/versions.js +4 -4
  78. package/src/generators/utils/create-ts-config.d.ts +0 -9
  79. package/src/generators/utils/create-ts-config.js +0 -34
@@ -1,4 +1,4 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
2
  import type { AddLintingGeneratorSchema } from './schema';
3
3
  export declare function addLintingGenerator(tree: Tree, options: AddLintingGeneratorSchema): Promise<GeneratorCallback>;
4
4
  export default addLintingGenerator;
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLintingGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const eslint_1 = require("@nx/eslint");
6
- const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
7
- const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
5
  const string_utils_1 = require("@nx/devkit/src/utils/string-utils");
6
+ const eslint_1 = require("@nx/eslint");
9
7
  const global_eslint_config_1 = require("@nx/eslint/src/generators/init/global-eslint-config");
8
+ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
9
+ const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
10
+ const buildable_project_1 = require("./lib/buildable-project");
10
11
  async function addLintingGenerator(tree, options) {
11
12
  const tasks = [];
12
13
  const rootProject = options.projectRoot === '.' || options.projectRoot === '';
@@ -20,7 +21,8 @@ async function addLintingGenerator(tree, options) {
20
21
  setParserOptionsProject: options.setParserOptionsProject,
21
22
  skipFormat: true,
22
23
  rootProject: rootProject,
23
- addPlugin: options.addPlugin,
24
+ addPlugin: false,
25
+ addExplicitTargets: true,
24
26
  });
25
27
  tasks.push(lintTask);
26
28
  if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
@@ -72,7 +74,7 @@ async function addLintingGenerator(tree, options) {
72
74
  */
73
75
  rules: {},
74
76
  },
75
- ...(isBuildableLibraryProject(tree, options.projectName)
77
+ ...((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)
76
78
  ? [
77
79
  {
78
80
  files: ['*.json'],
@@ -86,7 +88,7 @@ async function addLintingGenerator(tree, options) {
86
88
  ]);
87
89
  }
88
90
  if (!options.skipPackageJson) {
89
- const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree);
91
+ const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree, options.projectName);
90
92
  tasks.push(installTask);
91
93
  }
92
94
  if (!options.skipFormat) {
@@ -95,10 +97,4 @@ async function addLintingGenerator(tree, options) {
95
97
  return (0, devkit_1.runTasksInSerial)(...tasks);
96
98
  }
97
99
  exports.addLintingGenerator = addLintingGenerator;
98
- function isBuildableLibraryProject(tree, projectName) {
99
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
100
- return (projectConfig.projectType === 'library' &&
101
- projectConfig.targets?.build &&
102
- !!projectConfig.targets.build);
103
- }
104
100
  exports.default = addLintingGenerator;
@@ -1,2 +1,2 @@
1
- import type { GeneratorCallback, Tree } from '@nx/devkit';
2
- export declare function addAngularEsLintDependencies(tree: Tree): GeneratorCallback;
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
+ export declare function addAngularEsLintDependencies(tree: Tree, projectName: string): GeneratorCallback;
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addAngularEsLintDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const version_utils_1 = require("../../utils/version-utils");
6
- function addAngularEsLintDependencies(tree) {
6
+ const buildable_project_1 = require("./buildable-project");
7
+ function addAngularEsLintDependencies(tree, projectName) {
7
8
  const angularEslintVersionToInstall = (0, version_utils_1.versions)(tree).angularEslintVersion;
8
- const jsoncEslintParserVersionToInstall = (0, version_utils_1.versions)(tree).jsoncEslintParserVersion;
9
- return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
9
+ const devDependencies = {
10
10
  '@angular-eslint/eslint-plugin': angularEslintVersionToInstall,
11
11
  '@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall,
12
12
  '@angular-eslint/template-parser': angularEslintVersionToInstall,
13
- 'jsonc-eslint-parser': jsoncEslintParserVersionToInstall,
14
- });
13
+ };
14
+ if ((0, buildable_project_1.isBuildableLibraryProject)(tree, projectName)) {
15
+ const jsoncEslintParserVersionToInstall = (0, version_utils_1.versions)(tree).jsoncEslintParserVersion;
16
+ devDependencies['jsonc-eslint-parser'] = jsoncEslintParserVersionToInstall;
17
+ }
18
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies);
15
19
  }
16
20
  exports.addAngularEsLintDependencies = addAngularEsLintDependencies;
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function isBuildableLibraryProject(tree: Tree, projectName: string): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBuildableLibraryProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function isBuildableLibraryProject(tree, projectName) {
6
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
7
+ return (projectConfig.projectType === 'library' && !!projectConfig.targets?.build);
8
+ }
9
+ exports.isBuildableLibraryProject = isBuildableLibraryProject;
@@ -6,5 +6,4 @@ export interface AddLintingGeneratorSchema {
6
6
  skipFormat?: boolean;
7
7
  skipPackageJson?: boolean;
8
8
  unitTestRunner?: string;
9
- addPlugin?: boolean;
10
9
  }
@@ -12,7 +12,6 @@ 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,
16
15
  ...schema,
17
16
  });
18
17
  }
@@ -7,6 +7,9 @@
7
7
  "files": [],
8
8
  "include": [],
9
9
  "references": [
10
+ {
11
+ "path": "./tsconfig.editor.json"
12
+ },
10
13
  {
11
14
  "path": "./tsconfig.app.json"
12
15
  }
@@ -699,7 +699,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
699
699
  You can activate distributed tasks executions and caching by
700
700
  running:
701
701
  </p>
702
- <pre>nx connect-to-nx-cloud</pre>
702
+ <pre>nx connect</pre>
703
703
  <a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
704
704
  </div>
705
705
  <a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
@@ -702,7 +702,7 @@ import { CommonModule } from '@angular/common';
702
702
  You can activate distributed tasks executions and caching by
703
703
  running:
704
704
  </p>
705
- <pre>nx connect-to-nx-cloud</pre>
705
+ <pre>nx connect</pre>
706
706
  <a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
707
707
  </div>
708
708
  <a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addE2e = void 0;
4
- const cypress_1 = require("@nx/cypress");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const versions_1 = require("../../../utils/versions");
7
6
  const version_utils_1 = require("../../utils/version-utils");
8
7
  async function addE2e(tree, options) {
8
+ // since e2e are separate projects, default to adding plugins
9
+ const nxJson = (0, devkit_1.readNxJson)(tree);
10
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
11
+ nxJson.useInferencePlugins !== false;
9
12
  if (options.e2eTestRunner === 'cypress') {
13
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
10
14
  // TODO: This can call `@nx/web:static-config` generator when ready
11
15
  addFileServerTarget(tree, options, 'serve-static');
12
16
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -17,7 +21,7 @@ async function addE2e(tree, options) {
17
21
  tags: [],
18
22
  implicitDependencies: [options.name],
19
23
  });
20
- await (0, cypress_1.configurationGenerator)(tree, {
24
+ await configurationGenerator(tree, {
21
25
  project: options.e2eProjectName,
22
26
  directory: 'src',
23
27
  linter: options.linter,
@@ -26,11 +30,11 @@ async function addE2e(tree, options) {
26
30
  devServerTarget: `${options.name}:serve:development`,
27
31
  baseUrl: 'http://localhost:4200',
28
32
  rootProject: options.rootProject,
29
- addPlugin: options.addPlugin,
33
+ addPlugin,
30
34
  });
31
35
  }
32
36
  else if (options.e2eTestRunner === 'playwright') {
33
- const { configurationGenerator: playwrightConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
37
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
34
38
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
35
39
  projectType: 'application',
36
40
  root: options.e2eProjectRoot,
@@ -38,7 +42,7 @@ async function addE2e(tree, options) {
38
42
  targets: {},
39
43
  implicitDependencies: [options.name],
40
44
  });
41
- await playwrightConfigurationGenerator(tree, {
45
+ await configurationGenerator(tree, {
42
46
  project: options.e2eProjectName,
43
47
  skipFormat: true,
44
48
  skipPackageJson: options.skipPackageJson,
@@ -49,7 +53,7 @@ async function addE2e(tree, options) {
49
53
  webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
50
54
  webServerAddress: `http://localhost:${options.port ?? 4200}`,
51
55
  rootProject: options.rootProject,
52
- addPlugin: options.addPlugin,
56
+ addPlugin,
53
57
  });
54
58
  }
55
59
  }
@@ -15,7 +15,6 @@ async function addLinting(host, options) {
15
15
  skipPackageJson: options.skipPackageJson,
16
16
  unitTestRunner: options.unitTestRunner,
17
17
  skipFormat: true,
18
- addPlugin: options.addPlugin,
19
18
  });
20
19
  }
21
20
  exports.addLinting = addLinting;
@@ -10,7 +10,6 @@ async function addUnitTestRunner(host, options) {
10
10
  projectRoot: options.appProjectRoot,
11
11
  skipPackageJson: options.skipPackageJson,
12
12
  strict: options.strict,
13
- addPlugin: options.addPlugin,
14
13
  });
15
14
  }
16
15
  }
@@ -3,14 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFiles = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const create_ts_config_1 = require("../../utils/create-ts-config");
6
+ const update_project_root_tsconfig_1 = require("../../utils/update-project-root-tsconfig");
7
7
  const test_runners_1 = require("../../../utils/test-runners");
8
8
  const version_utils_1 = require("../../utils/version-utils");
9
+ const selector_1 = require("../../utils/selector");
9
10
  async function createFiles(tree, options, rootOffset) {
10
11
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
11
12
  const isUsingApplicationBuilder = angularMajorVersion >= 17 && options.bundler === 'esbuild';
13
+ const rootSelector = `${options.prefix}-root`;
14
+ (0, selector_1.validateHtmlSelector)(rootSelector);
15
+ const nxWelcomeSelector = `${options.prefix}-nx-welcome`;
16
+ (0, selector_1.validateHtmlSelector)(nxWelcomeSelector);
12
17
  const substitutions = {
13
- rootSelector: `${options.prefix}-root`,
18
+ rootSelector,
14
19
  appName: options.name,
15
20
  inlineStyle: options.inlineStyle,
16
21
  inlineTemplate: options.inlineTemplate,
@@ -19,7 +24,7 @@ async function createFiles(tree, options, rootOffset) {
19
24
  unitTesting: options.unitTestRunner !== test_runners_1.UnitTestRunner.None,
20
25
  routing: options.routing,
21
26
  minimal: options.minimal,
22
- nxWelcomeSelector: `${options.prefix}-nx-welcome`,
27
+ nxWelcomeSelector,
23
28
  rootTsConfig: (0, devkit_1.joinPathFragments)(rootOffset, (0, js_1.getRootTsConfigFileName)(tree)),
24
29
  angularMajorVersion,
25
30
  rootOffset,
@@ -33,13 +38,7 @@ async function createFiles(tree, options, rootOffset) {
33
38
  else {
34
39
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/ng-module'), options.appProjectRoot, substitutions);
35
40
  }
36
- (0, create_ts_config_1.createTsConfig)(tree, options.appProjectRoot, 'app', {
37
- bundler: options.bundler,
38
- rootProject: options.rootProject,
39
- strict: options.strict,
40
- style: options.style,
41
- esModuleInterop: isUsingApplicationBuilder,
42
- }, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot));
41
+ (0, update_project_root_tsconfig_1.updateProjectRootTsConfig)(tree, options.appProjectRoot, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot), options.rootProject);
43
42
  if (!options.routing) {
44
43
  tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, '/src/app/app.routes.ts'));
45
44
  }
@@ -4,9 +4,7 @@ exports.normalizeOptions = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const eslint_1 = require("@nx/eslint");
7
- const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
8
7
  const test_runners_1 = require("../../../utils/test-runners");
9
- const project_1 = require("../../utils/project");
10
8
  const version_utils_1 = require("../../utils/version-utils");
11
9
  async function normalizeOptions(host, options) {
12
10
  const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -19,13 +17,11 @@ async function normalizeOptions(host, options) {
19
17
  });
20
18
  options.rootProject = appProjectRoot === '.';
21
19
  options.projectNameAndRootFormat = projectNameAndRootFormat;
22
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
23
20
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
24
21
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
25
22
  const parsedTags = options.tags
26
23
  ? options.tags.split(',').map((s) => s.trim())
27
24
  : [];
28
- const prefix = (0, project_1.normalizeNewProjectPrefix)(options.prefix, (0, get_npm_scope_1.getNpmScope)(host), 'app');
29
25
  let bundler = options.bundler;
30
26
  if (!bundler) {
31
27
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(host);
@@ -45,7 +41,7 @@ async function normalizeOptions(host, options) {
45
41
  strict: true,
46
42
  standalone: true,
47
43
  ...options,
48
- prefix,
44
+ prefix: options.prefix || 'app',
49
45
  name: appProjectName,
50
46
  appProjectRoot,
51
47
  appProjectSourceRoot: `${appProjectRoot}/src`,
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
1
+ import { type Tree } from '@nx/devkit';
2
2
  import type { NormalizedSchema } from './normalized-schema';
3
3
  export declare function updateEditorTsConfig(tree: Tree, options: NormalizedSchema): void;
@@ -2,24 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateEditorTsConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const update_app_editor_tsconfig_excluded_files_1 = require("../../utils/update-app-editor-tsconfig-excluded-files");
5
6
  function getCompilerOptionsTypes(tsConfig) {
6
7
  return tsConfig?.compilerOptions?.types ?? [];
7
8
  }
8
9
  function updateEditorTsConfig(tree, options) {
9
- const types = getCompilerOptionsTypes((0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json')));
10
- if (options.unitTestRunner !== 'none') {
11
- types.push(...getCompilerOptionsTypes((0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'))));
12
- }
13
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.editor.json'), (json) => {
14
- json.compilerOptions.types = types;
15
- return json;
16
- });
17
- // This should be the last tsconfig references so it's not in the template
18
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
19
- json.references.push({
20
- path: './tsconfig.editor.json',
10
+ const appTsConfig = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'));
11
+ const types = getCompilerOptionsTypes(appTsConfig);
12
+ if (types?.length) {
13
+ (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.editor.json'), (json) => {
14
+ json.compilerOptions ??= {};
15
+ json.compilerOptions.types = Array.from(new Set(types));
16
+ return json;
21
17
  });
22
- return json;
23
- });
18
+ }
19
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.name);
20
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, project);
24
21
  }
25
22
  exports.updateEditorTsConfig = updateEditorTsConfig;
@@ -31,5 +31,4 @@ export interface Schema {
31
31
  minimal?: boolean;
32
32
  bundler?: 'webpack' | 'esbuild';
33
33
  ssr?: boolean;
34
- addPlugin?: boolean;
35
34
  }
@@ -81,6 +81,7 @@
81
81
  "type": "string",
82
82
  "format": "html-selector",
83
83
  "description": "The prefix to apply to generated selectors.",
84
+ "default": "app",
84
85
  "alias": "p"
85
86
  },
86
87
  "skipTests": {
@@ -20,8 +20,8 @@ async function normalizeOptions(tree, options) {
20
20
  const { className: suffixClassName } = (0, devkit_1.names)(options.type);
21
21
  const symbolName = `${className}${suffixClassName}`;
22
22
  const { prefix, root, sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
23
- const selector = options.selector ??
24
- (0, selector_1.buildSelector)(tree, name, options.prefix, prefix, 'fileName');
23
+ const selector = options.selector ?? (0, selector_1.buildSelector)(name, options.prefix, prefix, 'fileName');
24
+ (0, selector_1.validateHtmlSelector)(selector);
25
25
  return {
26
26
  ...options,
27
27
  name,
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.componentTestGenerator = void 0;
4
- const cypress_version_1 = require("@nx/cypress/src/utils/cypress-version");
5
4
  const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
6
  const storybook_inputs_1 = require("../utils/storybook-ast/storybook-inputs");
7
7
  async function componentTestGenerator(tree, options) {
8
- (0, cypress_version_1.assertMinimumCypressVersion)(10);
8
+ (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
9
+ const { assertMinimumCypressVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/cypress-version'));
10
+ assertMinimumCypressVersion(10);
9
11
  const { root } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
10
12
  const componentDirPath = (0, devkit_1.joinPathFragments)(root, options.componentDir);
11
13
  const componentFilePath = (0, devkit_1.joinPathFragments)(componentDirPath, `${options.componentFileName}.ts`);
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cypressComponentConfigurationInternal = exports.cypressComponentConfiguration = void 0;
4
- const cypress_1 = require("@nx/cypress");
5
- const config_1 = require("@nx/cypress/src/utils/config");
6
- const find_target_options_1 = require("@nx/cypress/src/utils/find-target-options");
7
4
  const devkit_1 = require("@nx/devkit");
8
5
  const path_1 = require("path");
6
+ const versions_1 = require("../../utils/versions");
9
7
  const component_test_1 = require("../component-test/component-test");
10
8
  const component_info_1 = require("../utils/storybook-ast/component-info");
11
9
  const entry_point_1 = require("../utils/storybook-ast/entry-point");
12
10
  const module_info_1 = require("../utils/storybook-ast/module-info");
11
+ const update_app_editor_tsconfig_excluded_files_1 = require("../utils/update-app-editor-tsconfig-excluded-files");
13
12
  function cypressComponentConfiguration(tree, options) {
14
13
  return cypressComponentConfigurationInternal(tree, {
15
- addPlugin: false,
16
14
  ...options,
17
15
  });
18
16
  }
@@ -22,15 +20,19 @@ exports.cypressComponentConfiguration = cypressComponentConfiguration;
22
20
  * storybook + cypress then use the componentCypressGenerator instead.
23
21
  */
24
22
  async function cypressComponentConfigurationInternal(tree, options) {
25
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
26
23
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
27
- const installTask = await (0, cypress_1.componentConfigurationGenerator)(tree, {
24
+ const { componentConfigurationGenerator: baseCyCTConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
25
+ const installTask = await baseCyCTConfig(tree, {
28
26
  project: options.project,
29
27
  skipFormat: true,
30
- addPlugin: options.addPlugin,
28
+ addPlugin: false,
29
+ addExplicitTargets: true,
31
30
  });
32
31
  await configureCypressCT(tree, options);
33
32
  await addFiles(tree, projectConfig, options);
33
+ if (projectConfig.projectType === 'application') {
34
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, projectConfig);
35
+ }
34
36
  if (!options.skipFormat) {
35
37
  await (0, devkit_1.formatFiles)(tree);
36
38
  }
@@ -39,7 +41,8 @@ async function cypressComponentConfigurationInternal(tree, options) {
39
41
  exports.cypressComponentConfigurationInternal = cypressComponentConfigurationInternal;
40
42
  async function addFiles(tree, projectConfig, options) {
41
43
  const componentFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
42
- const updatedCmpContents = await (0, config_1.addMountDefinition)(tree.read(componentFile, 'utf-8'));
44
+ const { addMountDefinition } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
45
+ const updatedCmpContents = await addMountDefinition(tree.read(componentFile, 'utf-8'));
43
46
  tree.write(componentFile, `import { mount } from 'cypress/angular';\n${updatedCmpContents}`);
44
47
  if (options.generateTests) {
45
48
  const entryPoints = (0, entry_point_1.getProjectEntryPoints)(tree, options.project);
@@ -66,7 +69,8 @@ async function addFiles(tree, projectConfig, options) {
66
69
  async function configureCypressCT(tree, options) {
67
70
  let found = { target: options.buildTarget, config: undefined };
68
71
  if (!options.buildTarget) {
69
- found = await (0, find_target_options_1.findBuildConfig)(tree, {
72
+ const { findBuildConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/find-target-options'));
73
+ found = await findBuildConfig(tree, {
70
74
  project: options.project,
71
75
  buildTarget: options.buildTarget,
72
76
  validExecutorNames: new Set([
@@ -91,8 +95,9 @@ async function configureCypressCT(tree, options) {
91
95
  else {
92
96
  ctConfigOptions.buildTarget = found.target;
93
97
  }
94
- const cypressConfigPath = (0, config_1.getProjectCypressConfigPath)(tree, projectConfig.root);
95
- const updatedCyConfig = await (0, config_1.addDefaultCTConfig)(tree.read(cypressConfigPath, 'utf-8'), ctConfigOptions);
98
+ const { addDefaultCTConfig, getProjectCypressConfigPath } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
99
+ const cypressConfigPath = getProjectCypressConfigPath(tree, projectConfig.root);
100
+ const updatedCyConfig = await addDefaultCTConfig(tree.read(cypressConfigPath, 'utf-8'), ctConfigOptions);
96
101
  tree.write(cypressConfigPath, `import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';\n${updatedCyConfig}`);
97
102
  }
98
103
  function assertValidConfig(config) {
@@ -3,5 +3,4 @@ export interface CypressComponentConfigSchema {
3
3
  generateTests: boolean;
4
4
  skipFormat?: boolean;
5
5
  buildTarget?: string;
6
- addPlugin?: boolean;
7
6
  }
@@ -20,7 +20,8 @@ async function normalizeOptions(tree, options) {
20
20
  const symbolName = `${className}${suffixClassName}`;
21
21
  const { prefix } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
22
22
  const selector = options.selector ??
23
- (0, selector_1.buildSelector)(tree, name, options.prefix, prefix, 'propertyName');
23
+ (0, selector_1.buildSelector)(name, options.prefix, prefix, 'propertyName');
24
+ (0, selector_1.validateHtmlSelector)(selector);
24
25
  return {
25
26
  ...options,
26
27
  projectName,
@@ -4,10 +4,6 @@ exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
6
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);
11
7
  const project = {
12
8
  name: libraryOptions.name,
13
9
  root: libraryOptions.projectRoot,
@@ -15,27 +11,30 @@ function addProject(tree, libraryOptions) {
15
11
  prefix: libraryOptions.prefix,
16
12
  tags: libraryOptions.parsedTags,
17
13
  projectType: 'library',
18
- targets: {
19
- build: libraryOptions.buildable || libraryOptions.publishable
20
- ? {
21
- executor,
22
- outputs: ['{workspaceRoot}/dist/{projectRoot}'],
23
- options: {
24
- project: `${libraryOptions.projectRoot}/ng-package.json`,
25
- },
26
- configurations: {
27
- production: {
28
- tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.prod.json`,
29
- },
30
- development: {
31
- tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.json`,
32
- },
33
- },
34
- defaultConfiguration: 'production',
35
- }
36
- : undefined,
37
- },
14
+ targets: {},
38
15
  };
16
+ if (libraryOptions.buildable || libraryOptions.publishable) {
17
+ const executor = libraryOptions.publishable
18
+ ? '@nx/angular:package'
19
+ : '@nx/angular:ng-packagr-lite';
20
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
21
+ project.targets.build = {
22
+ executor,
23
+ outputs: ['{workspaceRoot}/dist/{projectRoot}'],
24
+ options: {
25
+ project: `${libraryOptions.projectRoot}/ng-package.json`,
26
+ },
27
+ configurations: {
28
+ production: {
29
+ tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.prod.json`,
30
+ },
31
+ development: {
32
+ tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.json`,
33
+ },
34
+ },
35
+ defaultConfiguration: 'production',
36
+ };
37
+ }
39
38
  (0, devkit_1.addProjectConfiguration)(tree, libraryOptions.name, project);
40
39
  return project;
41
40
  }
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
- const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
7
6
  const eslint_1 = require("@nx/eslint");
8
7
  const test_runners_1 = require("../../../utils/test-runners");
9
- const project_1 = require("../../utils/project");
10
8
  async function normalizeOptions(host, schema) {
11
9
  schema.standalone = schema.standalone ?? true;
12
10
  // Create a schema with populated default values
@@ -40,14 +38,12 @@ async function normalizeOptions(host, schema) {
40
38
  ? options.tags.split(',').map((s) => s.trim())
41
39
  : [];
42
40
  const modulePath = `${projectRoot}/src/lib/${fileName}.module.ts`;
43
- const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
44
- const prefix = (0, project_1.normalizeNewProjectPrefix)(options.prefix, npmScope, 'lib');
45
41
  const ngCliSchematicLibRoot = projectName;
46
42
  const allNormalizedOptions = {
47
43
  ...options,
48
44
  linter: options.linter ?? eslint_1.Linter.EsLint,
49
45
  unitTestRunner: options.unitTestRunner ?? test_runners_1.UnitTestRunner.Jest,
50
- prefix,
46
+ prefix: options.prefix ?? 'lib',
51
47
  name: projectName,
52
48
  projectRoot,
53
49
  entryFile: 'index',
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateTsConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const create_ts_config_1 = require("../../utils/create-ts-config");
6
+ const update_project_root_tsconfig_1 = require("../../utils/update-project-root-tsconfig");
7
7
  function updateProjectConfig(host, options) {
8
8
  (0, devkit_1.updateJson)(host, `${options.projectRoot}/tsconfig.lib.json`, (json) => {
9
9
  json.include = ['src/**/*.ts'];
@@ -18,7 +18,7 @@ function updateProjectConfig(host, options) {
18
18
  return json;
19
19
  });
20
20
  // tsconfig.json
21
- (0, create_ts_config_1.createTsConfig)(host, options.projectRoot, 'lib', options, (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot));
21
+ (0, update_project_root_tsconfig_1.updateProjectRootTsConfig)(host, options.projectRoot, (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot));
22
22
  }
23
23
  function updateProjectIvyConfig(host, options) {
24
24
  if (options.buildable || options.publishable) {
@@ -30,7 +30,7 @@ function updateProjectIvyConfig(host, options) {
30
30
  }
31
31
  }
32
32
  function updateTsConfig(host, options) {
33
- (0, create_ts_config_1.extractTsConfigBase)(host);
33
+ (0, update_project_root_tsconfig_1.extractTsConfigBase)(host);
34
34
  updateProjectConfig(host, options);
35
35
  updateProjectIvyConfig(host, options);
36
36
  }
@@ -40,4 +40,5 @@ export interface Schema {
40
40
  skipTests?: boolean;
41
41
  selector?: string;
42
42
  skipSelector?: boolean;
43
+ addPlugin?: boolean;
43
44
  }