@nx/angular 18.1.0-beta.2 → 18.1.0-beta.3

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 (32) hide show
  1. package/migrations.json +6 -2
  2. package/package.json +11 -11
  3. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +4 -2
  4. package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -0
  5. package/src/generators/application/lib/add-e2e.js +3 -1
  6. package/src/generators/application/lib/create-files.js +9 -10
  7. package/src/generators/application/lib/normalize-options.js +1 -4
  8. package/src/generators/application/lib/update-editor-tsconfig.d.ts +1 -1
  9. package/src/generators/application/lib/update-editor-tsconfig.js +11 -14
  10. package/src/generators/application/schema.json +1 -0
  11. package/src/generators/component/lib/normalize-options.js +2 -2
  12. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -0
  13. package/src/generators/directive/lib/normalize-options.js +2 -1
  14. package/src/generators/library/lib/add-project.js +23 -24
  15. package/src/generators/library/lib/normalize-options.js +1 -5
  16. package/src/generators/library/lib/update-tsconfig.js +3 -3
  17. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +4 -1
  18. package/src/generators/ng-add/utilities/workspace.js +1 -3
  19. package/src/generators/setup-mf/lib/normalize-options.js +1 -1
  20. package/src/generators/storybook-configuration/storybook-configuration.js +5 -0
  21. package/src/generators/utils/project.d.ts +0 -1
  22. package/src/generators/utils/project.js +2 -29
  23. package/src/generators/utils/selector.d.ts +2 -2
  24. package/src/generators/utils/selector.js +11 -4
  25. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.d.ts +2 -0
  26. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.js +23 -0
  27. package/src/generators/utils/update-project-root-tsconfig.d.ts +3 -0
  28. package/src/generators/utils/update-project-root-tsconfig.js +26 -0
  29. package/src/utils/versions.d.ts +1 -1
  30. package/src/utils/versions.js +1 -1
  31. package/src/generators/utils/create-ts-config.d.ts +0 -9
  32. package/src/generators/utils/create-ts-config.js +0 -34
package/migrations.json CHANGED
@@ -1641,7 +1641,7 @@
1641
1641
  }
1642
1642
  },
1643
1643
  "18.1.0-jest": {
1644
- "version": "18.1.0-beta.1",
1644
+ "version": "18.1.0-beta.2",
1645
1645
  "requires": {
1646
1646
  "@angular-devkit/build-angular": ">=15.0.0 <18.0.0",
1647
1647
  "@angular/compiler-cli": ">=15.0.0 <18.0.0",
@@ -1651,13 +1651,17 @@
1651
1651
  },
1652
1652
  "packages": {
1653
1653
  "jest-preset-angular": {
1654
- "version": "~14.0.2",
1654
+ "version": "~14.0.3",
1655
1655
  "alwaysAddToPackageJson": false
1656
1656
  }
1657
1657
  }
1658
1658
  },
1659
1659
  "18.1.0": {
1660
1660
  "version": "18.1.0-beta.1",
1661
+ "x-prompt": "Do you want to update the Angular version to v17.2?",
1662
+ "requires": {
1663
+ "@angular/core": ">=17.1.0 <17.2.0"
1664
+ },
1661
1665
  "packages": {
1662
1666
  "@angular-devkit/build-angular": {
1663
1667
  "version": "~17.2.0",
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "18.1.0-beta.2",
3
+ "version": "18.1.0-beta.3",
4
4
  "private": false,
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.",
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- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/nrwl/nx.git",
@@ -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.1.0-beta.2",
82
- "@nx/cypress": "18.1.0-beta.2",
83
- "@nx/jest": "18.1.0-beta.2",
84
- "@nx/js": "18.1.0-beta.2",
85
- "@nx/eslint": "18.1.0-beta.2",
86
- "@nx/webpack": "18.1.0-beta.2",
87
- "@nx/web": "18.1.0-beta.2",
88
- "@nx/workspace": "18.1.0-beta.2",
81
+ "@nx/devkit": "18.1.0-beta.3",
82
+ "@nx/cypress": "18.1.0-beta.3",
83
+ "@nx/jest": "18.1.0-beta.3",
84
+ "@nx/js": "18.1.0-beta.3",
85
+ "@nx/eslint": "18.1.0-beta.3",
86
+ "@nx/webpack": "18.1.0-beta.3",
87
+ "@nx/web": "18.1.0-beta.3",
88
+ "@nx/workspace": "18.1.0-beta.3",
89
89
  "piscina": "^4.2.1",
90
- "@nrwl/angular": "18.1.0-beta.2"
90
+ "@nrwl/angular": "18.1.0-beta.3"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
@@ -101,8 +101,10 @@ async function* moduleFederationDevServerExecutor(schema, context) {
101
101
  devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
102
102
  next({ success: true, baseUrl: `http://localhost:${options.port}` });
103
103
  }
104
- catch {
105
- throw new Error(`Timed out waiting for remote to start. Check above for any errors.`);
104
+ catch (err) {
105
+ throw new Error(`Failed to start remotes. Check above for any errors.`, {
106
+ cause: err,
107
+ });
106
108
  }
107
109
  finally {
108
110
  done();
@@ -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
  }
@@ -7,7 +7,9 @@ const versions_1 = require("../../../utils/versions");
7
7
  const version_utils_1 = require("../../utils/version-utils");
8
8
  async function addE2e(tree, options) {
9
9
  // since e2e are separate projects, default to adding plugins
10
- const addPlugin = process.env.NX_ADD_PLUGINS !== 'false';
10
+ const nxJson = (0, devkit_1.readNxJson)(tree);
11
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
12
+ nxJson.useInferencePlugins !== false;
11
13
  if (options.e2eTestRunner === 'cypress') {
12
14
  // TODO: This can call `@nx/web:static-config` generator when ready
13
15
  addFileServerTarget(tree, options, 'serve-static');
@@ -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, {
@@ -24,7 +22,6 @@ async function normalizeOptions(host, options) {
24
22
  const parsedTags = options.tags
25
23
  ? options.tags.split(',').map((s) => s.trim())
26
24
  : [];
27
- const prefix = (0, project_1.normalizeNewProjectPrefix)(options.prefix, (0, get_npm_scope_1.getNpmScope)(host), 'app');
28
25
  let bundler = options.bundler;
29
26
  if (!bundler) {
30
27
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(host);
@@ -44,7 +41,7 @@ async function normalizeOptions(host, options) {
44
41
  strict: true,
45
42
  standalone: true,
46
43
  ...options,
47
- prefix,
44
+ prefix: options.prefix || 'app',
48
45
  name: appProjectName,
49
46
  appProjectRoot,
50
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;
@@ -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,
@@ -10,6 +10,7 @@ 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
+ const update_app_editor_tsconfig_excluded_files_1 = require("../utils/update-app-editor-tsconfig-excluded-files");
13
14
  function cypressComponentConfiguration(tree, options) {
14
15
  return cypressComponentConfigurationInternal(tree, {
15
16
  ...options,
@@ -30,6 +31,9 @@ async function cypressComponentConfigurationInternal(tree, options) {
30
31
  });
31
32
  await configureCypressCT(tree, options);
32
33
  await addFiles(tree, projectConfig, options);
34
+ if (projectConfig.projectType === 'application') {
35
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, projectConfig);
36
+ }
33
37
  if (!options.skipFormat) {
34
38
  await (0, devkit_1.formatFiles)(tree);
35
39
  }
@@ -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
  }
@@ -235,6 +235,9 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
235
235
  tags: [],
236
236
  implicitDependencies: [this.appName],
237
237
  });
238
+ const nxJson = (0, devkit_1.readNxJson)(this.tree) ?? {};
239
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
240
+ nxJson.useInferencePlugins !== false;
238
241
  await (0, cypress_1.configurationGenerator)(this.tree, {
239
242
  project: this.project.name,
240
243
  linter: this.isProjectUsingEsLint ? eslint_1.Linter.EsLint : eslint_1.Linter.None,
@@ -242,7 +245,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
242
245
  // any target would do, we replace it later with the target existing in the project being migrated
243
246
  devServerTarget: `${this.appName}:serve`,
244
247
  baseUrl: 'http://localhost:4200',
245
- addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
248
+ addPlugin,
246
249
  });
247
250
  const cypressConfigFilePath = this.updateOrCreateCypressConfigFile(oldCypressConfigFilePath);
248
251
  this.updateCypressProjectConfiguration(cypressConfigFilePath);
@@ -29,9 +29,7 @@ exports.validateWorkspace = validateWorkspace;
29
29
  function createNxJson(tree, options, defaultProject) {
30
30
  const targets = getWorkspaceCommonTargets(tree);
31
31
  (0, devkit_1.writeJson)(tree, 'nx.json', {
32
- affected: {
33
- defaultBase: options.defaultBase ?? (0, default_base_1.deduceDefaultBase)(),
34
- },
32
+ defaultBase: options.defaultBase ?? (0, default_base_1.deduceDefaultBase)(),
35
33
  namedInputs: {
36
34
  sharedGlobals: [],
37
35
  default: ['{projectRoot}/**/*', 'sharedGlobals'],
@@ -7,7 +7,7 @@ function normalizeOptions(tree, options) {
7
7
  ...options,
8
8
  typescriptConfiguration: options.typescriptConfiguration ?? true,
9
9
  federationType: options.federationType ?? 'static',
10
- prefix: options.prefix ?? (0, project_1.getProjectPrefix)(tree, options.appName),
10
+ prefix: options.prefix ?? (0, project_1.getProjectPrefix)(tree, options.appName) ?? 'app',
11
11
  standalone: options.standalone ?? true,
12
12
  };
13
13
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.storybookConfigurationGenerator = 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
  const assert_compatible_storybook_version_1 = require("./lib/assert-compatible-storybook-version");
6
7
  const generate_stories_1 = require("./lib/generate-stories");
7
8
  const generate_storybook_configuration_1 = require("./lib/generate-storybook-configuration");
@@ -22,6 +23,10 @@ async function storybookConfigurationGenerator(tree, options) {
22
23
  skipFormat: true,
23
24
  });
24
25
  }
26
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
27
+ if (project.projectType === 'application') {
28
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, project);
29
+ }
25
30
  if (!options.skipFormat) {
26
31
  await (0, devkit_1.formatFiles)(tree);
27
32
  }
@@ -1,3 +1,2 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- export declare function normalizeNewProjectPrefix(prefix: string | undefined, npmScope: string | undefined, fallbackPrefix: string): string;
3
2
  export declare function getProjectPrefix(tree: Tree, project: string): string | undefined;
@@ -1,35 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProjectPrefix = exports.normalizeNewProjectPrefix = void 0;
3
+ exports.getProjectPrefix = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
6
- function normalizeNewProjectPrefix(prefix, npmScope, fallbackPrefix) {
7
- // Prefix needs to be a valid html selector, if npmScope it's not valid, we don't default
8
- // to it and let it fall through to the Angular schematic to handle it
9
- // https://github.com/angular/angular-cli/blob/aa9f0528f174e856a4923cb24861fdf6e6f96b48/packages/schematics/angular/component/index.ts#L64
10
- const htmlSelectorRegex = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
11
- if (prefix) {
12
- if (!htmlSelectorRegex.test(prefix)) {
13
- throw new Error('The provided "prefix" is invalid. The prefix must start with a letter, and must contain only alphanumeric characters or dashes.');
14
- }
15
- return prefix;
16
- }
17
- if (npmScope && !htmlSelectorRegex.test(npmScope)) {
18
- throw new Error(`The "--prefix" option was not provided, therefore attempted to use the "npmScope" defined in "nx.json" to set the application's selector prefix, but it is invalid.
19
-
20
- There are two options that can be followed to resolve this issue:
21
- - Pass a valid "--prefix" option.
22
- - Update the "npmScope" in "nx.json" (Note: this can be an involved process, as other libraries and applications may need to be updated to match the new scope).
23
-
24
- If you encountered this error when creating a new Nx Workspace, the workspace name or "npmScope" is invalid to use as the selector prefix for the application being generated.
25
-
26
- Valid selector prefixes must start with a letter, and must contain only alphanumeric characters or dashes.`);
27
- }
28
- return npmScope || fallbackPrefix;
29
- }
30
- exports.normalizeNewProjectPrefix = normalizeNewProjectPrefix;
31
5
  function getProjectPrefix(tree, project) {
32
- return ((0, devkit_1.readProjectConfiguration)(tree, project)
33
- .prefix ?? (0, get_npm_scope_1.getNpmScope)(tree));
6
+ return (0, devkit_1.readProjectConfiguration)(tree, project).prefix;
34
7
  }
35
8
  exports.getProjectPrefix = getProjectPrefix;
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
2
1
  import { names } from '@nx/devkit';
3
- export declare function buildSelector(tree: Tree, name: string, prefix: string | undefined, projectPrefix: string | undefined, casing: keyof Pick<ReturnType<typeof names>, 'fileName' | 'propertyName'>): string;
2
+ export declare function buildSelector(name: string, prefix: string | undefined, projectPrefix: string | undefined, casing: keyof Pick<ReturnType<typeof names>, 'fileName' | 'propertyName'>): string;
3
+ export declare function validateHtmlSelector(selector: string): void;
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSelector = void 0;
3
+ exports.validateHtmlSelector = exports.buildSelector = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
6
- function buildSelector(tree, name, prefix, projectPrefix, casing) {
5
+ function buildSelector(name, prefix, projectPrefix, casing) {
7
6
  let selector = name;
8
- prefix ??= projectPrefix ?? (0, get_npm_scope_1.getNpmScope)(tree);
7
+ prefix ??= projectPrefix;
9
8
  if (prefix) {
10
9
  selector = `${prefix}-${selector}`;
11
10
  }
12
11
  return (0, devkit_1.names)(selector)[casing];
13
12
  }
14
13
  exports.buildSelector = buildSelector;
14
+ // https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/utility/validation.ts#L11-L14
15
+ const htmlSelectorRegex = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
16
+ function validateHtmlSelector(selector) {
17
+ if (selector && !htmlSelectorRegex.test(selector)) {
18
+ throw new Error(`The selector "${selector}" is invalid.`);
19
+ }
20
+ }
21
+ exports.validateHtmlSelector = validateHtmlSelector;
@@ -0,0 +1,2 @@
1
+ import { type ProjectConfiguration, type Tree } from '@nx/devkit';
2
+ export declare function updateAppEditorTsConfigExcludedFiles(tree: Tree, projectConfig: ProjectConfiguration): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAppEditorTsConfigExcludedFiles = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function updateAppEditorTsConfigExcludedFiles(tree, projectConfig) {
6
+ if (projectConfig.projectType !== 'application') {
7
+ return;
8
+ }
9
+ const editorTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.editor.json');
10
+ const appTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.app.json');
11
+ if (!tree.exists(editorTsConfigPath) || !tree.exists(appTsConfigPath)) {
12
+ return;
13
+ }
14
+ const appTsConfig = (0, devkit_1.readJson)(tree, appTsConfigPath);
15
+ (0, devkit_1.updateJson)(tree, editorTsConfigPath, (json) => {
16
+ const exclude = [...(json.exclude ?? []), ...(appTsConfig.exclude ?? [])];
17
+ if (exclude.length) {
18
+ json.exclude = Array.from(new Set(exclude));
19
+ }
20
+ return json;
21
+ });
22
+ }
23
+ exports.updateAppEditorTsConfigExcludedFiles = updateAppEditorTsConfigExcludedFiles;
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export { extractTsConfigBase } from '@nx/js';
3
+ export declare function updateProjectRootTsConfig(host: Tree, projectRoot: string, relativePathToRootTsConfig: string, isRootProject?: boolean): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProjectRootTsConfig = exports.extractTsConfigBase = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
6
+ var js_2 = require("@nx/js");
7
+ Object.defineProperty(exports, "extractTsConfigBase", { enumerable: true, get: function () { return js_2.extractTsConfigBase; } });
8
+ function updateProjectRootTsConfig(host, projectRoot, relativePathToRootTsConfig, isRootProject) {
9
+ (0, devkit_1.updateJson)(host, `${projectRoot}/tsconfig.json`, (json) => {
10
+ if (isRootProject) {
11
+ // inline tsconfig.base.json into the project
12
+ json.compileOnSave = false;
13
+ json.compilerOptions = {
14
+ ...js_1.tsConfigBaseOptions,
15
+ ...json.compilerOptions,
16
+ };
17
+ json.exclude = ['node_modules', 'tmp'];
18
+ delete json.extends;
19
+ }
20
+ else {
21
+ json.extends = relativePathToRootTsConfig;
22
+ }
23
+ return json;
24
+ });
25
+ }
26
+ exports.updateProjectRootTsConfig = updateProjectRootTsConfig;
@@ -19,7 +19,7 @@ export declare const postcssVersion = "^8.4.5";
19
19
  export declare const postcssUrlVersion = "~10.1.3";
20
20
  export declare const autoprefixerVersion = "^10.4.0";
21
21
  export declare const tsNodeVersion = "10.9.1";
22
- export declare const jestPresetAngularVersion = "~14.0.2";
22
+ export declare const jestPresetAngularVersion = "~14.0.3";
23
23
  export declare const typesNodeVersion = "18.16.9";
24
24
  export declare const jasmineMarblesVersion = "^0.9.2";
25
25
  export declare const jsoncEslintParserVersion = "^2.1.0";
@@ -22,7 +22,7 @@ exports.postcssVersion = '^8.4.5';
22
22
  exports.postcssUrlVersion = '~10.1.3';
23
23
  exports.autoprefixerVersion = '^10.4.0';
24
24
  exports.tsNodeVersion = '10.9.1';
25
- exports.jestPresetAngularVersion = '~14.0.2';
25
+ exports.jestPresetAngularVersion = '~14.0.3';
26
26
  exports.typesNodeVersion = '18.16.9';
27
27
  exports.jasmineMarblesVersion = '^0.9.2';
28
28
  exports.jsoncEslintParserVersion = '^2.1.0';
@@ -1,9 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export { extractTsConfigBase } from '@nx/js';
3
- export declare function createTsConfig(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
4
- strict?: boolean;
5
- style?: string;
6
- bundler?: string;
7
- rootProject?: boolean;
8
- esModuleInterop?: boolean;
9
- }, relativePathToRootTsConfig: string): void;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTsConfig = exports.extractTsConfigBase = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const js_1 = require("@nx/js");
6
- var js_2 = require("@nx/js");
7
- Object.defineProperty(exports, "extractTsConfigBase", { enumerable: true, get: function () { return js_2.extractTsConfigBase; } });
8
- function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
9
- const json = {
10
- compilerOptions: {
11
- target: 'es2022',
12
- useDefineForClassFields: false,
13
- esModuleInterop: options.esModuleInterop ? true : undefined,
14
- },
15
- files: [],
16
- include: [],
17
- references: [
18
- {
19
- path: type === 'app' ? './tsconfig.app.json' : './tsconfig.lib.json',
20
- },
21
- ],
22
- };
23
- // inline tsconfig.base.json into the project
24
- if (options.rootProject) {
25
- json.compileOnSave = false;
26
- json.compilerOptions = { ...js_1.tsConfigBaseOptions, ...json.compilerOptions };
27
- json.exclude = ['node_modules', 'tmp'];
28
- }
29
- else {
30
- json.extends = relativePathToRootTsConfig;
31
- }
32
- (0, devkit_1.writeJson)(host, `${projectRoot}/tsconfig.json`, json);
33
- }
34
- exports.createTsConfig = createTsConfig;