nx 18.1.0 → 18.1.1

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 (121) hide show
  1. package/bin/init-local.js +13 -1
  2. package/package.json +12 -12
  3. package/release/changelog-renderer/index.d.ts +2 -0
  4. package/release/changelog-renderer/index.js +4 -18
  5. package/schemas/nx-schema.json +62 -1
  6. package/schemas/project-schema.json +20 -0
  7. package/src/adapter/angular-json.d.ts +1 -2
  8. package/src/adapter/angular-json.js +0 -1
  9. package/src/adapter/ngcli-adapter.js +3 -3
  10. package/src/command-line/generate/generator-utils.js +2 -2
  11. package/src/command-line/init/implementation/add-nx-to-nest.js +2 -2
  12. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
  13. package/src/command-line/init/implementation/utils.d.ts +1 -3
  14. package/src/command-line/init/implementation/utils.js +9 -16
  15. package/src/command-line/init/init-v2.js +3 -2
  16. package/src/command-line/release/changelog.js +17 -14
  17. package/src/command-line/release/command-object.d.ts +1 -0
  18. package/src/command-line/release/config/config.d.ts +12 -15
  19. package/src/command-line/release/config/config.js +151 -22
  20. package/src/command-line/release/config/conventional-commits.d.ts +2 -0
  21. package/src/command-line/release/config/conventional-commits.js +98 -0
  22. package/src/command-line/release/publish.js +4 -3
  23. package/src/command-line/release/release.js +12 -11
  24. package/src/command-line/release/utils/git.js +30 -1
  25. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
  26. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -13
  27. package/src/command-line/release/utils/semver.d.ts +2 -8
  28. package/src/command-line/release/utils/semver.js +4 -1
  29. package/src/command-line/release/utils/shared.d.ts +5 -1
  30. package/src/command-line/release/version.d.ts +6 -1
  31. package/src/command-line/release/version.js +71 -19
  32. package/src/command-line/run/executor-utils.js +2 -2
  33. package/src/command-line/run/run.js +3 -3
  34. package/src/config/nx-json.d.ts +31 -0
  35. package/src/config/schema-utils.js +2 -2
  36. package/src/core/graph/main.js +1 -1
  37. package/src/core/graph/polyfills.js +1 -1
  38. package/src/core/graph/styles.css +1 -1
  39. package/src/daemon/server/project-graph-incremental-recomputation.js +1 -0
  40. package/src/devkit-exports.d.ts +1 -2
  41. package/src/devkit-internals.d.ts +0 -1
  42. package/src/devkit-internals.js +1 -3
  43. package/src/executors/run-commands/run-commands.impl.d.ts +7 -1
  44. package/src/executors/run-commands/run-commands.impl.js +120 -57
  45. package/src/executors/run-script/run-script.impl.js +5 -5
  46. package/src/generators/utils/project-configuration.js +2 -2
  47. package/src/hasher/hash-task.js +2 -2
  48. package/src/migrations/update-15-1-0/set-project-names.js +2 -4
  49. package/src/migrations/update-17-2-0/move-default-base.d.ts +1 -1
  50. package/src/migrations/update-17-2-0/move-default-base.js +3 -1
  51. package/src/migrations/update-17-3-0/nx-release-path.js +0 -1
  52. package/src/native/index.d.ts +14 -11
  53. package/src/native/index.js +3 -4
  54. package/src/plugins/js/index.d.ts +1 -1
  55. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  56. package/src/plugins/js/lock-file/lock-file.js +13 -1
  57. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  58. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  59. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  60. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  61. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  62. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  63. package/src/plugins/js/utils/register.js +3 -1
  64. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  65. package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
  66. package/src/plugins/package-json-workspaces/index.d.ts +0 -1
  67. package/src/plugins/package-json-workspaces/index.js +0 -2
  68. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
  69. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
  70. package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
  71. package/src/plugins/project-json/build-nodes/project-json.js +0 -1
  72. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
  73. package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
  74. package/src/project-graph/affected/locators/project-glob-changes.js +3 -2
  75. package/src/project-graph/build-project-graph.js +8 -11
  76. package/src/project-graph/file-utils.js +6 -4
  77. package/src/project-graph/project-graph-builder.d.ts +1 -1
  78. package/src/project-graph/project-graph.js +3 -0
  79. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  80. package/src/project-graph/utils/project-configuration-utils.d.ts +4 -4
  81. package/src/project-graph/utils/project-configuration-utils.js +58 -17
  82. package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -8
  83. package/src/project-graph/utils/retrieve-workspace-files.js +18 -20
  84. package/src/tasks-runner/fork.js +7 -7
  85. package/src/tasks-runner/forked-process-task-runner.d.ts +2 -4
  86. package/src/tasks-runner/forked-process-task-runner.js +13 -17
  87. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +16 -13
  88. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +8 -7
  89. package/src/tasks-runner/{psuedo-ipc.d.ts → pseudo-ipc.d.ts} +7 -7
  90. package/src/tasks-runner/{psuedo-ipc.js → pseudo-ipc.js} +9 -9
  91. package/src/tasks-runner/pseudo-terminal.d.ts +42 -0
  92. package/src/tasks-runner/pseudo-terminal.js +133 -0
  93. package/src/tasks-runner/task-orchestrator.js +45 -9
  94. package/src/tasks-runner/tasks-schedule.js +3 -3
  95. package/src/tasks-runner/utils.d.ts +7 -6
  96. package/src/tasks-runner/utils.js +11 -7
  97. package/src/utils/ignore.js +1 -1
  98. package/src/utils/logger.d.ts +0 -1
  99. package/src/utils/logger.js +0 -5
  100. package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +45 -7
  101. package/src/utils/nx-plugin.deprecated.d.ts +2 -4
  102. package/src/utils/nx-plugin.deprecated.js +4 -4
  103. package/src/utils/nx-plugin.js +293 -0
  104. package/src/utils/output.js +1 -1
  105. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  106. package/src/utils/plugins/plugin-capabilities.js +7 -8
  107. package/src/project-graph/plugins/index.d.ts +0 -2
  108. package/src/project-graph/plugins/index.js +0 -8
  109. package/src/project-graph/plugins/internal-api.d.ts +0 -18
  110. package/src/project-graph/plugins/internal-api.js +0 -48
  111. package/src/project-graph/plugins/messaging.d.ts +0 -94
  112. package/src/project-graph/plugins/messaging.js +0 -23
  113. package/src/project-graph/plugins/plugin-pool.d.ts +0 -4
  114. package/src/project-graph/plugins/plugin-pool.js +0 -216
  115. package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
  116. package/src/project-graph/plugins/plugin-worker.js +0 -115
  117. package/src/project-graph/plugins/public-api.js +0 -4
  118. package/src/project-graph/plugins/utils.d.ts +0 -9
  119. package/src/project-graph/plugins/utils.js +0 -55
  120. package/src/project-graph/plugins/worker-api.d.ts +0 -26
  121. package/src/project-graph/plugins/worker-api.js +0 -177
package/bin/init-local.js CHANGED
@@ -99,7 +99,14 @@ function isKnownCommand(command) {
99
99
  }
100
100
  function shouldDelegateToAngularCLI() {
101
101
  const command = process.argv[2];
102
- const commands = ['analytics', 'config', 'doc', 'update', 'completion'];
102
+ const commands = [
103
+ 'analytics',
104
+ 'cache',
105
+ 'completion',
106
+ 'config',
107
+ 'doc',
108
+ 'update',
109
+ ];
103
110
  return commands.indexOf(command) > -1;
104
111
  }
105
112
  function handleAngularCLIFallbacks(workspace) {
@@ -122,6 +129,11 @@ function handleAngularCLIFallbacks(workspace) {
122
129
  For more information, see https://nx.dev/features/integrate-with-editors`);
123
130
  }
124
131
  }
132
+ else if (process.argv[2] === 'cache') {
133
+ console.log(`"ng cache" is not natively supported by Nx.
134
+ To clear the cache, you can delete the ".angular/cache" directory (or the directory configured by "cli.cache.path" in the "nx.json" file).
135
+ To update the cache configuration, you can directly update the relevant options in your "nx.json" file (https://angular.io/guide/workspace-config#cache-options).`);
136
+ }
125
137
  else {
126
138
  try {
127
139
  // nx-ignore-next-line
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.1.0",
3
+ "version": "18.1.1",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "18.1.0"
69
+ "@nrwl/tao": "18.1.1"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "18.1.0",
85
- "@nx/nx-darwin-arm64": "18.1.0",
86
- "@nx/nx-linux-x64-gnu": "18.1.0",
87
- "@nx/nx-linux-x64-musl": "18.1.0",
88
- "@nx/nx-win32-x64-msvc": "18.1.0",
89
- "@nx/nx-linux-arm64-gnu": "18.1.0",
90
- "@nx/nx-linux-arm64-musl": "18.1.0",
91
- "@nx/nx-linux-arm-gnueabihf": "18.1.0",
92
- "@nx/nx-win32-arm64-msvc": "18.1.0",
93
- "@nx/nx-freebsd-x64": "18.1.0"
84
+ "@nx/nx-darwin-x64": "18.1.1",
85
+ "@nx/nx-darwin-arm64": "18.1.1",
86
+ "@nx/nx-linux-x64-gnu": "18.1.1",
87
+ "@nx/nx-linux-x64-musl": "18.1.1",
88
+ "@nx/nx-win32-x64-msvc": "18.1.1",
89
+ "@nx/nx-linux-arm64-gnu": "18.1.1",
90
+ "@nx/nx-linux-arm64-musl": "18.1.1",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.1.1",
92
+ "@nx/nx-win32-arm64-msvc": "18.1.1",
93
+ "@nx/nx-freebsd-x64": "18.1.1"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -1,3 +1,4 @@
1
+ import { NxReleaseConfig } from '../../src/command-line/release/config/config';
1
2
  import type { GitCommit } from '../../src/command-line/release/utils/git';
2
3
  import { RepoSlug } from '../../src/command-line/release/utils/github';
3
4
  import type { ProjectGraph } from '../../src/config/project-graph';
@@ -26,6 +27,7 @@ export type ChangelogRenderer = (config: {
26
27
  entryWhenNoChanges: string | false;
27
28
  changelogRenderOptions: DefaultChangelogRenderOptions;
28
29
  repoSlug?: RepoSlug;
30
+ conventionalCommitsConfig: NxReleaseConfig['conventionalCommits'];
29
31
  }) => Promise<string> | string;
30
32
  /**
31
33
  * The specific options available to the default implementation of the ChangelogRenderer that nx exports
@@ -10,24 +10,10 @@ const axios = _axios;
10
10
  * The default ChangelogRenderer implementation that nx exports for the common case of generating markdown
11
11
  * from the given commits and other metadata.
12
12
  */
13
- const defaultChangelogRenderer = async ({ projectGraph, commits, releaseVersion, project, entryWhenNoChanges, changelogRenderOptions, repoSlug, }) => {
13
+ const defaultChangelogRenderer = async ({ projectGraph, commits, releaseVersion, project, entryWhenNoChanges, changelogRenderOptions, repoSlug, conventionalCommitsConfig, }) => {
14
+ const commitTypes = conventionalCommitsConfig.types;
14
15
  const markdownLines = [];
15
16
  const breakingChanges = [];
16
- const commitTypes = {
17
- feat: { title: '🚀 Features' },
18
- perf: { title: '🔥 Performance' },
19
- fix: { title: '🩹 Fixes' },
20
- refactor: { title: '💅 Refactors' },
21
- docs: { title: '📖 Documentation' },
22
- build: { title: '📦 Build' },
23
- types: { title: '🌊 Types' },
24
- chore: { title: '🏡 Chore' },
25
- examples: { title: '🏀 Examples' },
26
- test: { title: '✅ Tests' },
27
- style: { title: '🎨 Styles' },
28
- ci: { title: '🤖 CI' },
29
- revert: { title: '⏪ Revert' },
30
- };
31
17
  // If the current range of commits contains both a commit and its revert, we strip them both from the final list
32
18
  for (const commit of commits) {
33
19
  if (commit.type === 'revert') {
@@ -56,7 +42,7 @@ const defaultChangelogRenderer = async ({ projectGraph, commits, releaseVersion,
56
42
  if (!group || group.length === 0) {
57
43
  continue;
58
44
  }
59
- markdownLines.push('', '### ' + commitTypes[type].title, '');
45
+ markdownLines.push('', '### ' + commitTypes[type].changelog.title, '');
60
46
  /**
61
47
  * In order to make the final changelog most readable, we organize commits as follows:
62
48
  * - By scope, where scopes are in alphabetical order (commits with no scope are listed first)
@@ -99,7 +85,7 @@ const defaultChangelogRenderer = async ({ projectGraph, commits, releaseVersion,
99
85
  if (!group || group.length === 0) {
100
86
  continue;
101
87
  }
102
- markdownLines.push('', `### ${commitTypes[type].title}`, '');
88
+ markdownLines.push('', `### ${commitTypes[type].changelog.title}`, '');
103
89
  const commitsInChronologicalOrder = group.reverse();
104
90
  for (const commit of commitsInChronologicalOrder) {
105
91
  const line = formatCommit(commit, changelogRenderOptions, repoSlug);
@@ -157,11 +157,16 @@
157
157
  "$ref": "#/definitions/NxReleaseVersionConfiguration"
158
158
  },
159
159
  {
160
- "anyOf": [
160
+ "allOf": [
161
161
  {
162
162
  "not": {
163
163
  "required": ["git"]
164
164
  }
165
+ },
166
+ {
167
+ "not": {
168
+ "required": ["preVersionCommand"]
169
+ }
165
170
  }
166
171
  ]
167
172
  }
@@ -216,6 +221,9 @@
216
221
  }
217
222
  }
218
223
  },
224
+ "conventionalCommits": {
225
+ "$ref": "#/definitions/NxReleaseConventionalCommitsConfiguration"
226
+ },
219
227
  "projectsRelationship": {
220
228
  "type": "string",
221
229
  "enum": ["fixed", "independent"]
@@ -576,6 +584,10 @@
576
584
  },
577
585
  "git": {
578
586
  "$ref": "#/definitions/NxReleaseGitConfiguration"
587
+ },
588
+ "preVersionCommand": {
589
+ "type": "string",
590
+ "description": "A command to run after validation of nx release configuration, but before versioning begins. Used for preparing build artifacts. If --dry-run is passed, the command is still executed, but with the NX_DRY_RUN environment variable set to 'true'."
579
591
  }
580
592
  }
581
593
  },
@@ -627,6 +639,55 @@
627
639
  "ChangelogRenderOptions": {
628
640
  "type": "object",
629
641
  "additionalProperties": true
642
+ },
643
+ "NxReleaseConventionalCommitsConfiguration": {
644
+ "type": "object",
645
+ "properties": {
646
+ "types": {
647
+ "type": "object",
648
+ "description": "A map of commit types to their configuration. If a type is set to 'true', then it will be enabled with the default 'semverBump' of 'patch' and will appear in the changelog. If a type is set to 'false', then it will not trigger a version bump and will be hidden from the changelog.",
649
+ "additionalProperties": {
650
+ "oneOf": [
651
+ {
652
+ "type": "boolean"
653
+ },
654
+ {
655
+ "type": "object",
656
+ "properties": {
657
+ "semverBump": {
658
+ "type": "string",
659
+ "enum": ["major", "minor", "patch", "none"],
660
+ "description": "The semver bump to apply to the version of the project(s) when a commit of this type is included in the release.",
661
+ "default": "patch"
662
+ },
663
+ "changelog": {
664
+ "description": "Configuration for the changelog section for commits of this type. If set to 'true', then commits of this type will be included in the changelog with their default title for the type. If set to 'false', then commits of this type will not be included in the changelog.",
665
+ "oneOf": [
666
+ {
667
+ "type": "boolean"
668
+ },
669
+ {
670
+ "type": "object",
671
+ "properties": {
672
+ "title": {
673
+ "type": "string",
674
+ "description": "The title of the section in the changelog for commits of this type"
675
+ },
676
+ "hidden": {
677
+ "type": "boolean",
678
+ "description": "Whether or not to include commits of this type in the changelog",
679
+ "default": false
680
+ }
681
+ }
682
+ }
683
+ ]
684
+ }
685
+ }
686
+ }
687
+ ]
688
+ }
689
+ }
690
+ }
630
691
  }
631
692
  }
632
693
  }
@@ -127,6 +127,26 @@
127
127
  "items": {
128
128
  "type": "string"
129
129
  }
130
+ },
131
+ "release": {
132
+ "type": "object",
133
+ "description": "Configuration for the nx release commands.",
134
+ "properties": {
135
+ "version": {
136
+ "type": "object",
137
+ "description": "Configuration for the nx release version command.",
138
+ "properties": {
139
+ "generator": {
140
+ "type": "string",
141
+ "description": "The version generator to use. Defaults to @nx/js:release-version."
142
+ },
143
+ "generatorOptions": {
144
+ "type": "object",
145
+ "description": "Options for the version generator."
146
+ }
147
+ }
148
+ }
149
+ }
130
150
  }
131
151
  },
132
152
  "definitions": {
@@ -1,8 +1,7 @@
1
1
  import { ProjectsConfigurations } from '../config/workspace-json-project-json';
2
- import { NxPluginV2 } from '../project-graph/plugins';
2
+ import { NxPluginV2 } from '../utils/nx-plugin';
3
3
  export declare const NX_ANGULAR_JSON_PLUGIN_NAME = "nx-angular-json-plugin";
4
4
  export declare const NxAngularJsonPlugin: NxPluginV2;
5
- export default NxAngularJsonPlugin;
6
5
  export declare function shouldMergeAngularProjects(root: string, includeProjectsFromAngularJson: boolean): boolean;
7
6
  export declare function isAngularPluginInstalled(): boolean;
8
7
  export declare function toNewFormat(w: any): ProjectsConfigurations;
@@ -14,7 +14,6 @@ exports.NxAngularJsonPlugin = {
14
14
  }),
15
15
  ],
16
16
  };
17
- exports.default = exports.NxAngularJsonPlugin;
18
17
  function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
19
18
  if ((0, fs_1.existsSync)(path.join(root, 'angular.json')) &&
20
19
  // Include projects from angular.json if explicitly required.
@@ -19,7 +19,7 @@ const package_json_1 = require("../utils/package-json");
19
19
  const package_manager_1 = require("../utils/package-manager");
20
20
  const angular_json_1 = require("./angular-json");
21
21
  const executor_utils_1 = require("../command-line/run/executor-utils");
22
- const plugins_1 = require("../project-graph/plugins");
22
+ const nx_plugin_1 = require("../utils/nx-plugin");
23
23
  const schema_utils_1 = require("../config/schema-utils");
24
24
  async function createBuilderContext(builderInfo, context) {
25
25
  require('./compat');
@@ -146,7 +146,7 @@ function createNodeModulesEngineHost(resolvePaths, projects) {
146
146
  collectionFilePath = require.resolve(name, { paths });
147
147
  }
148
148
  else {
149
- const { json: { generators, schematics }, path: packageJsonPath, } = (0, plugins_1.readPluginPackageJson)(name, projects, paths);
149
+ const { json: { generators, schematics }, path: packageJsonPath, } = (0, nx_plugin_1.readPluginPackageJson)(name, projects, paths);
150
150
  if (!schematics && !generators) {
151
151
  throw new Error(`The "${name}" package does not support Nx generators or Angular Devkit schematics.`);
152
152
  }
@@ -802,7 +802,7 @@ async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, proj
802
802
  };
803
803
  }
804
804
  readExecutorsJson(nodeModule, builder) {
805
- const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(nodeModule, this.projects, this.root ? [this.root, __dirname] : [__dirname]);
805
+ const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.projects, this.root ? [this.root, __dirname] : [__dirname]);
806
806
  const executorsFile = packageJson.executors ?? packageJson.builders;
807
807
  if (!executorsFile) {
808
808
  throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
@@ -4,7 +4,7 @@ exports.readGeneratorsJson = exports.getGeneratorInformation = void 0;
4
4
  const path_1 = require("path");
5
5
  const schema_utils_1 = require("../../config/schema-utils");
6
6
  const fileutils_1 = require("../../utils/fileutils");
7
- const plugins_1 = require("../../project-graph/plugins");
7
+ const nx_plugin_1 = require("../../utils/nx-plugin");
8
8
  function getGeneratorInformation(collectionName, generatorName, root, projects) {
9
9
  try {
10
10
  const { generatorsFilePath, generatorsJson, resolvedCollectionName, normalizedGeneratorName, } = readGeneratorsJson(collectionName, generatorName, root, projects);
@@ -48,7 +48,7 @@ function readGeneratorsJson(collectionName, generator, root, projects) {
48
48
  });
49
49
  }
50
50
  else {
51
- const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(collectionName, projects, root ? [root, __dirname] : [__dirname]);
51
+ const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(collectionName, projects, root ? [root, __dirname] : [__dirname]);
52
52
  const generatorsFile = packageJson.generators ?? packageJson.schematics;
53
53
  if (!generatorsFile) {
54
54
  throw new Error(`The "${collectionName}" package does not support Nx generators.`);
@@ -73,12 +73,12 @@ async function addNxToNest(options, packageJson) {
73
73
  ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
74
74
  : false);
75
75
  }
76
- (0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], {});
76
+ (0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], scriptOutputs);
77
77
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
78
78
  (0, utils_1.updateGitIgnore)(repoRoot);
79
79
  (0, utils_1.addDepsToPackageJson)(repoRoot);
80
80
  addNestPluginToPackageJson(repoRoot);
81
- (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, scriptOutputs, pmc);
81
+ (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, pmc);
82
82
  createProjectJson(repoRoot, packageJson, nestCLIConfiguration);
83
83
  removeFile(repoRoot, 'nest-cli.json');
84
84
  updatePackageJsonScripts(repoRoot, isJS);
@@ -48,11 +48,11 @@ async function addNxToNpmRepo(options) {
48
48
  ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
49
49
  : false);
50
50
  }
51
- (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, {});
51
+ (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, scriptOutputs);
52
52
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
53
53
  (0, utils_1.updateGitIgnore)(repoRoot);
54
54
  (0, utils_1.addDepsToPackageJson)(repoRoot);
55
- (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, scriptOutputs, pmc);
55
+ (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, pmc);
56
56
  output_1.output.log({ title: '📦 Installing dependencies' });
57
57
  (0, utils_1.runInstall)(repoRoot, pmc);
58
58
  if (useNxCloud) {
@@ -8,9 +8,7 @@ export declare function updateGitIgnore(root: string): void;
8
8
  export declare function runInstall(repoRoot: string, pmc?: PackageManagerCommands): void;
9
9
  export declare function initCloud(repoRoot: string, installationSource: 'nx-init-angular' | 'nx-init-cra' | 'nx-init-monorepo' | 'nx-init-nest' | 'nx-init-npm-repo'): void;
10
10
  export declare function addVsCodeRecommendedExtensions(repoRoot: string, extensions: string[]): void;
11
- export declare function markRootPackageJsonAsNxProject(repoRoot: string, cacheableScripts: string[], scriptOutputs: {
12
- [script: string]: string;
13
- }, pmc: PackageManagerCommands): void;
11
+ export declare function markRootPackageJsonAsNxProject(repoRoot: string, cacheableScripts: string[], pmc: PackageManagerCommands): void;
14
12
  export declare function printFinalMessage({ learnMoreLink, bodyLines, }: {
15
13
  learnMoreLink?: string;
16
14
  bodyLines?: string[];
@@ -25,14 +25,14 @@ function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scr
25
25
  nxJson.targetDefaults[scriptName] ??= {};
26
26
  nxJson.targetDefaults[scriptName] = { dependsOn: [`^${scriptName}`] };
27
27
  }
28
- for (const [scriptName, output] of Object.entries(scriptOutputs)) {
29
- if (!output) {
30
- // eslint-disable-next-line no-continue
31
- continue;
32
- }
33
- nxJson.targetDefaults[scriptName] ??= {};
34
- nxJson.targetDefaults[scriptName].outputs = [`{projectRoot}/${output}`];
28
+ }
29
+ for (const [scriptName, output] of Object.entries(scriptOutputs)) {
30
+ if (!output) {
31
+ // eslint-disable-next-line no-continue
32
+ continue;
35
33
  }
34
+ nxJson.targetDefaults[scriptName] ??= {};
35
+ nxJson.targetDefaults[scriptName].outputs = [`{projectRoot}/${output}`];
36
36
  }
37
37
  for (const target of cacheableOperations) {
38
38
  nxJson.targetDefaults[target] ??= {};
@@ -134,16 +134,9 @@ function addVsCodeRecommendedExtensions(repoRoot, extensions) {
134
134
  }
135
135
  }
136
136
  exports.addVsCodeRecommendedExtensions = addVsCodeRecommendedExtensions;
137
- function markRootPackageJsonAsNxProject(repoRoot, cacheableScripts, scriptOutputs, pmc) {
137
+ function markRootPackageJsonAsNxProject(repoRoot, cacheableScripts, pmc) {
138
138
  const json = (0, fileutils_1.readJsonFile)((0, path_2.joinPathFragments)(repoRoot, `package.json`));
139
- json.nx = { targets: {} };
140
- for (let script of Object.keys(scriptOutputs)) {
141
- if (scriptOutputs[script]) {
142
- json.nx.targets[script] = {
143
- outputs: [`{projectRoot}/${scriptOutputs[script]}`],
144
- };
145
- }
146
- }
139
+ json.nx = {};
147
140
  for (let script of cacheableScripts) {
148
141
  const scriptDefinition = json.scripts[script];
149
142
  if (!scriptDefinition) {
@@ -19,6 +19,7 @@ const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
19
19
  const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
20
20
  const path_1 = require("path");
21
21
  async function initHandler(options) {
22
+ process.env.NX_RUNNING_NX_INIT = 'true';
22
23
  const version = process.env.NX_VERSION ?? ((0, semver_1.prerelease)(versions_1.nxVersion) ? 'next' : 'latest');
23
24
  if (process.env.NX_VERSION) {
24
25
  output_1.output.log({ title: `Using version ${process.env.NX_VERSION}` });
@@ -32,7 +33,7 @@ async function initHandler(options) {
32
33
  }
33
34
  (0, add_nx_scripts_1.generateDotNxSetup)(version);
34
35
  // invokes the wrapper, thus invoking the initial installation process
35
- (0, child_process_1.runNxSync)('');
36
+ (0, child_process_1.runNxSync)('--version', { stdio: 'ignore' });
36
37
  return;
37
38
  }
38
39
  // TODO(jack): Remove this Angular logic once `@nx/angular` is compatible with inferred targets.
@@ -80,7 +81,7 @@ async function initHandler(options) {
80
81
  if (!detectPluginsResponse.updatePackageScripts) {
81
82
  const rootPackageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
82
83
  const json = (0, fileutils_1.readJsonFile)(rootPackageJsonPath);
83
- json.nx = {};
84
+ json.nx = { includedScripts: [] };
84
85
  (0, fileutils_1.writeJsonFile)(rootPackageJsonPath, json);
85
86
  }
86
87
  if (useNxCloud) {
@@ -9,6 +9,7 @@ const tmp_1 = require("tmp");
9
9
  const nx_json_1 = require("../../config/nx-json");
10
10
  const tree_1 = require("../../generators/tree");
11
11
  const register_1 = require("../../plugins/js/utils/register");
12
+ const file_map_utils_1 = require("../../project-graph/file-map-utils");
12
13
  const project_graph_1 = require("../../project-graph/project-graph");
13
14
  const utils_1 = require("../../tasks-runner/utils");
14
15
  const is_ci_1 = require("../../utils/is-ci");
@@ -40,7 +41,7 @@ async function releaseChangelog(args) {
40
41
  process.env.NX_VERBOSE_LOGGING = 'true';
41
42
  }
42
43
  // Apply default configuration to any optional user configuration
43
- const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, nxJson.release);
44
+ const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
44
45
  if (configError) {
45
46
  return await (0, config_1.handleNxReleaseConfigError)(configError);
46
47
  }
@@ -129,7 +130,7 @@ async function releaseChangelog(args) {
129
130
  }
130
131
  // Make sure that the fromRef is actually resolvable
131
132
  const workspaceChangelogFromSHA = await (0, git_1.getCommitHash)(workspaceChangelogFromRef);
132
- const workspaceChangelogCommits = await getCommits(workspaceChangelogFromSHA, toSHA);
133
+ const workspaceChangelogCommits = await getCommits(workspaceChangelogFromSHA, toSHA, nxReleaseConfig.conventionalCommits);
133
134
  const workspaceChangelog = await generateChangelogForWorkspace(tree, args, projectGraph, nxReleaseConfig, workspaceChangelogVersion, workspaceChangelogCommits);
134
135
  if (workspaceChangelog &&
135
136
  shouldCreateGitHubRelease(nxReleaseConfig.changelog.workspaceChangelog, args.createRelease)) {
@@ -171,7 +172,7 @@ async function releaseChangelog(args) {
171
172
  let commits = null;
172
173
  if (!fromRef && useAutomaticFromRef) {
173
174
  const firstCommit = await (0, git_1.getFirstGitCommit)();
174
- const allCommits = await getCommits(firstCommit, toSHA);
175
+ const allCommits = await getCommits(firstCommit, toSHA, nxReleaseConfig.conventionalCommits);
175
176
  const commitsForProject = allCommits.filter((c) => c.affectedFiles.find((f) => f.startsWith(project.data.root)));
176
177
  fromRef = commitsForProject[0]?.shortHash;
177
178
  if (args.verbose) {
@@ -183,9 +184,9 @@ async function releaseChangelog(args) {
183
184
  throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
184
185
  }
185
186
  if (!commits) {
186
- commits = await getCommits(fromRef, toSHA);
187
+ commits = await getCommits(fromRef, toSHA, nxReleaseConfig.conventionalCommits);
187
188
  }
188
- const projectChangelogs = await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, postGitTasks, releaseGroup, [project]);
189
+ const projectChangelogs = await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, releaseGroup, [project], nxReleaseConfig);
189
190
  let hasPushed = false;
190
191
  for (const [projectName, projectChangelog] of Object.entries(projectChangelogs)) {
191
192
  if (projectChangelogs &&
@@ -217,8 +218,8 @@ async function releaseChangelog(args) {
217
218
  }
218
219
  // Make sure that the fromRef is actually resolvable
219
220
  const fromSHA = await (0, git_1.getCommitHash)(fromRef);
220
- const commits = await getCommits(fromSHA, toSHA);
221
- const projectChangelogs = await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, postGitTasks, releaseGroup, projectNodes);
221
+ const commits = await getCommits(fromSHA, toSHA, nxReleaseConfig.conventionalCommits);
222
+ const projectChangelogs = await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, releaseGroup, projectNodes, nxReleaseConfig);
222
223
  let hasPushed = false;
223
224
  for (const [projectName, projectChangelog] of Object.entries(projectChangelogs)) {
224
225
  if (projectChangelogs &&
@@ -448,6 +449,7 @@ async function generateChangelogForWorkspace(tree, args, projectGraph, nxRelease
448
449
  repoSlug: githubRepoSlug,
449
450
  entryWhenNoChanges: config.entryWhenNoChanges,
450
451
  changelogRenderOptions: config.renderOptions,
452
+ conventionalCommitsConfig: nxReleaseConfig.conventionalCommits,
451
453
  });
452
454
  /**
453
455
  * If interactive mode, make the changelog contents available for the user to modify in their editor of choice,
@@ -490,7 +492,7 @@ async function generateChangelogForWorkspace(tree, args, projectGraph, nxRelease
490
492
  contents,
491
493
  };
492
494
  }
493
- async function generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, postGitTasks, releaseGroup, projects) {
495
+ async function generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, releaseGroup, projects, nxReleaseConfig) {
494
496
  const config = releaseGroup.changelog;
495
497
  // The entire feature is disabled at the release group level, exit early
496
498
  if (config === false) {
@@ -546,6 +548,7 @@ async function generateChangelogForProjects(tree, args, projectGraph, commits, p
546
548
  })
547
549
  : false,
548
550
  changelogRenderOptions: config.renderOptions,
551
+ conventionalCommitsConfig: nxReleaseConfig.conventionalCommits,
549
552
  });
550
553
  /**
551
554
  * If interactive mode, make the changelog contents available for the user to modify in their editor of choice,
@@ -604,17 +607,17 @@ function checkChangelogFilesEnabled(nxReleaseConfig) {
604
607
  }
605
608
  return false;
606
609
  }
607
- async function getCommits(fromSHA, toSHA) {
610
+ async function getCommits(fromSHA, toSHA, conventionalCommitsConfig) {
608
611
  const rawCommits = await (0, git_1.getGitDiff)(fromSHA, toSHA);
609
612
  // Parse as conventional commits
610
613
  return (0, git_1.parseCommits)(rawCommits).filter((c) => {
611
614
  const type = c.type;
612
- // Always ignore non user-facing commits for now
613
- // TODO: allow this filter to be configurable via config in a future release
614
- if (type === 'feat' || type === 'fix' || type === 'perf') {
615
- return true;
615
+ const typeConfig = conventionalCommitsConfig.types[type];
616
+ if (!typeConfig) {
617
+ // don't include commits with unknown types
618
+ return false;
616
619
  }
617
- return false;
620
+ return !typeConfig.changelog.hidden;
618
621
  });
619
622
  }
620
623
  function shouldCreateGitHubRelease(changelogConfig, createReleaseArg = undefined) {
@@ -21,6 +21,7 @@ export type VersionOptions = NxReleaseArgs & GitCommitAndTagOptions & {
21
21
  specifier?: string;
22
22
  preid?: string;
23
23
  stageChanges?: boolean;
24
+ generatorOptionsOverrides?: Record<string, unknown>;
24
25
  };
25
26
  export type ChangelogOptions = NxReleaseArgs & GitCommitAndTagOptions & {
26
27
  version?: string | null;
@@ -1,18 +1,5 @@
1
- /**
2
- * `nx release` is a powerful feature which spans many possible use cases. The possible variations
3
- * of configuration are therefore quite complex, particularly when you consider release groups.
4
- *
5
- * We want to provide the best possible DX for users so that they can harness the power of `nx release`
6
- * most effectively, therefore we need to both provide sensible defaults for common scenarios (to avoid
7
- * verbose nx.json files wherever possible), and proactively handle potential sources of config issues
8
- * in more complex use-cases.
9
- *
10
- * This file is the source of truth for all `nx release` configuration reconciliation, including sensible
11
- * defaults and user overrides, as well as handling common errors, up front to produce a single, consistent,
12
- * and easy to consume config object for all the `nx release` command implementations.
13
- */
14
1
  import { NxJsonConfiguration } from '../../../config/nx-json';
15
- import { type ProjectGraph } from '../../../devkit-exports';
2
+ import { ProjectFileMap, ProjectGraph } from '../../../config/project-graph';
16
3
  type DeepRequired<T> = Required<{
17
4
  [K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
18
5
  }>;
@@ -30,6 +17,13 @@ type RemoveTrueFromProperties<T, K extends keyof T> = {
30
17
  type RemoveTrueFromPropertiesOnEach<T, K extends keyof T[keyof T]> = {
31
18
  [U in keyof T]: RemoveTrueFromProperties<T[U], K>;
32
19
  };
20
+ type RemoveBooleanFromType<T> = T extends boolean ? never : T;
21
+ type RemoveBooleanFromProperties<T, K extends keyof T> = {
22
+ [P in keyof T]: P extends K ? RemoveBooleanFromType<T[P]> : T[P];
23
+ };
24
+ type RemoveBooleanFromPropertiesOnEach<T, K extends keyof T[keyof T]> = {
25
+ [U in keyof T]: RemoveBooleanFromProperties<T[U], K>;
26
+ };
33
27
  export declare const IMPLICIT_DEFAULT_RELEASE_GROUP = "__default__";
34
28
  /**
35
29
  * Our source of truth is a deeply required variant of the user-facing config interface, so that command
@@ -43,12 +37,15 @@ export declare const IMPLICIT_DEFAULT_RELEASE_GROUP = "__default__";
43
37
  export type NxReleaseConfig = Omit<DeepRequired<NxJsonConfiguration['release'] & {
44
38
  groups: DeepRequired<RemoveTrueFromPropertiesOnEach<EnsureProjectsArray<NxJsonConfiguration['release']['groups']>, 'changelog'>>;
45
39
  changelog: RemoveTrueFromProperties<DeepRequired<NxJsonConfiguration['release']['changelog']>, 'workspaceChangelog' | 'projectChangelogs'>;
40
+ conventionalCommits: {
41
+ types: RemoveBooleanFromPropertiesOnEach<DeepRequired<RemoveBooleanFromProperties<DeepRequired<NxJsonConfiguration['release']['conventionalCommits']['types']>, string>>, 'changelog'>;
42
+ };
46
43
  }>, 'projects'>;
47
44
  export interface CreateNxReleaseConfigError {
48
45
  code: 'PROJECTS_AND_GROUPS_DEFINED' | 'RELEASE_GROUP_MATCHES_NO_PROJECTS' | 'RELEASE_GROUP_RELEASE_TAG_PATTERN_VERSION_PLACEHOLDER_MISSING_OR_EXCESSIVE' | 'PROJECT_MATCHES_MULTIPLE_GROUPS' | 'CONVENTIONAL_COMMITS_SHORTHAND_MIXED_WITH_OVERLAPPING_GENERATOR_OPTIONS' | 'GLOBAL_GIT_CONFIG_MIXED_WITH_GRANULAR_GIT_CONFIG';
49
46
  data: Record<string, string | string[]>;
50
47
  }
51
- export declare function createNxReleaseConfig(projectGraph: ProjectGraph, userConfig?: NxJsonConfiguration['release']): Promise<{
48
+ export declare function createNxReleaseConfig(projectGraph: ProjectGraph, projectFileMap: ProjectFileMap, userConfig?: NxJsonConfiguration['release']): Promise<{
52
49
  error: null | CreateNxReleaseConfigError;
53
50
  nxReleaseConfig: NxReleaseConfig | null;
54
51
  }>;