nx 17.2.0-beta.10 → 17.2.0-beta.12

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.
@@ -1,5 +1,6 @@
1
1
  import type { GitCommit } from '../src/command-line/release/utils/git';
2
2
  import { RepoSlug } from '../src/command-line/release/utils/github';
3
+ import type { ProjectGraph } from '../src/config/project-graph';
3
4
  /**
4
5
  * The ChangelogRenderOptions are specific to each ChangelogRenderer implementation, and are taken
5
6
  * from the user's nx.json configuration and passed as is into the ChangelogRenderer function.
@@ -10,6 +11,7 @@ export type ChangelogRenderOptions = Record<string, unknown>;
10
11
  * and returns a string, or a Promise of a string of changelog contents (usually markdown).
11
12
  *
12
13
  * @param {Object} config The configuration object for the ChangelogRenderer
14
+ * @param {ProjectGraph} config.projectGraph The project graph for the workspace
13
15
  * @param {GitCommit[]} config.commits The collection of extracted commits to generate a changelog for
14
16
  * @param {string} config.releaseVersion The version that is being released
15
17
  * @param {string | null} config.project The name of specific project to generate a changelog for, or `null` if the overall workspace changelog
@@ -17,6 +19,7 @@ export type ChangelogRenderOptions = Record<string, unknown>;
17
19
  * @param {ChangelogRenderOptions} config.changelogRenderOptions The options specific to the ChangelogRenderer implementation
18
20
  */
19
21
  export type ChangelogRenderer = (config: {
22
+ projectGraph: ProjectGraph;
20
23
  commits: GitCommit[];
21
24
  releaseVersion: string;
22
25
  project: string | null;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const github_1 = require("../src/command-line/release/utils/github");
4
+ const shared_1 = require("../src/command-line/release/utils/shared");
4
5
  // axios types and values don't seem to match
5
6
  const _axios = require("axios");
6
7
  const axios = _axios;
@@ -8,7 +9,7 @@ const axios = _axios;
8
9
  * The default ChangelogRenderer implementation that nx exports for the common case of generating markdown
9
10
  * from the given commits and other metadata.
10
11
  */
11
- const defaultChangelogRenderer = async ({ commits, releaseVersion, project, entryWhenNoChanges, changelogRenderOptions, repoSlug, }) => {
12
+ const defaultChangelogRenderer = async ({ projectGraph, commits, releaseVersion, project, entryWhenNoChanges, changelogRenderOptions, repoSlug, }) => {
12
13
  const markdownLines = [];
13
14
  const breakingChanges = [];
14
15
  const commitTypes = {
@@ -64,18 +65,18 @@ const defaultChangelogRenderer = async ({ commits, releaseVersion, project, entr
64
65
  }
65
66
  else {
66
67
  // project level changelog
67
- const scopeGroups = groupBy(commits, 'scope');
68
- // Treat unscoped commits as "global", and therefore also relevant to include in the project level changelog
69
- const unscopedCommits = scopeGroups[''] || [];
70
- // Generating for a named project, but that project has no changes in the current set of commits, exit early
71
- if (!scopeGroups[project] && unscopedCommits.length === 0) {
68
+ const relevantCommits = await (0, shared_1.getCommitsRelevantToProjects)(projectGraph, commits, [project]);
69
+ // Generating for a named project, but that project has no relevant changes in the current set of commits, exit early
70
+ if (relevantCommits.length === 0) {
72
71
  if (entryWhenNoChanges) {
73
72
  markdownLines.push('', `## ${releaseVersion}\n\n${entryWhenNoChanges}`, '');
74
73
  }
75
74
  return markdownLines.join('\n').trim();
76
75
  }
77
76
  markdownLines.push('', `## ${releaseVersion}`, '');
78
- const typeGroups = groupBy([...(scopeGroups[project] || []), ...unscopedCommits], 'type');
77
+ const typeGroups = groupBy(
78
+ // Sort the relevant commits to have the unscoped commits first, before grouping by type
79
+ relevantCommits.sort((a, b) => (b.scope ? 1 : 0) - (a.scope ? 1 : 0)), 'type');
79
80
  for (const type of Object.keys(commitTypes)) {
80
81
  const group = typeGroups[type];
81
82
  if (!group || group.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "17.2.0-beta.10",
3
+ "version": "17.2.0-beta.12",
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": "^17.6.2",
67
67
  "yargs-parser": "21.1.1",
68
68
  "node-machine-id": "1.1.12",
69
- "@nrwl/tao": "17.2.0-beta.10"
69
+ "@nrwl/tao": "17.2.0-beta.12"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.6.7",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "17.2.0-beta.10",
85
- "@nx/nx-darwin-arm64": "17.2.0-beta.10",
86
- "@nx/nx-linux-x64-gnu": "17.2.0-beta.10",
87
- "@nx/nx-linux-x64-musl": "17.2.0-beta.10",
88
- "@nx/nx-win32-x64-msvc": "17.2.0-beta.10",
89
- "@nx/nx-linux-arm64-gnu": "17.2.0-beta.10",
90
- "@nx/nx-linux-arm64-musl": "17.2.0-beta.10",
91
- "@nx/nx-linux-arm-gnueabihf": "17.2.0-beta.10",
92
- "@nx/nx-win32-arm64-msvc": "17.2.0-beta.10",
93
- "@nx/nx-freebsd-x64": "17.2.0-beta.10"
84
+ "@nx/nx-darwin-x64": "17.2.0-beta.12",
85
+ "@nx/nx-darwin-arm64": "17.2.0-beta.12",
86
+ "@nx/nx-linux-x64-gnu": "17.2.0-beta.12",
87
+ "@nx/nx-linux-x64-musl": "17.2.0-beta.12",
88
+ "@nx/nx-win32-x64-msvc": "17.2.0-beta.12",
89
+ "@nx/nx-linux-arm64-gnu": "17.2.0-beta.12",
90
+ "@nx/nx-linux-arm64-musl": "17.2.0-beta.12",
91
+ "@nx/nx-linux-arm-gnueabihf": "17.2.0-beta.12",
92
+ "@nx/nx-win32-arm64-msvc": "17.2.0-beta.12",
93
+ "@nx/nx-freebsd-x64": "17.2.0-beta.12"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -146,8 +146,7 @@
146
146
  "$ref": "#/definitions/NxReleaseChangelogConfiguration"
147
147
  },
148
148
  {
149
- "type": "boolean",
150
- "enum": [false]
149
+ "type": "boolean"
151
150
  }
152
151
  ]
153
152
  },
@@ -167,8 +166,7 @@
167
166
  "$ref": "#/definitions/NxReleaseChangelogConfiguration"
168
167
  },
169
168
  {
170
- "type": "boolean",
171
- "enum": [false]
169
+ "type": "boolean"
172
170
  }
173
171
  ]
174
172
  },
@@ -178,8 +176,7 @@
178
176
  "$ref": "#/definitions/NxReleaseChangelogConfiguration"
179
177
  },
180
178
  {
181
- "type": "boolean",
182
- "enum": [false]
179
+ "type": "boolean"
183
180
  }
184
181
  ]
185
182
  }
@@ -22,9 +22,12 @@ const executor_utils_1 = require("../command-line/run/executor-utils");
22
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
- require('nx/src/adapter/compat');
25
+ require('./compat');
26
26
  const fsHost = new NxScopedHost(context.root);
27
- const { workspace } = await core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));
27
+ // the top level import is not patched because it is imported before the
28
+ // patching happens so we require it here to use the patched version below
29
+ const { workspaces } = require('@angular-devkit/core');
30
+ const { workspace } = await workspaces.readWorkspace('angular.json', workspaces.createWorkspaceHost(fsHost));
28
31
  const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root, context.projectsConfigurations.projects);
29
32
  const registry = new core_1.schema.CoreSchemaRegistry();
30
33
  registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
@@ -41,6 +44,28 @@ async function createBuilderContext(builderInfo, context) {
41
44
  options,
42
45
  ]).output);
43
46
  const getProjectMetadata = (target) => toPromise(architect['_scheduler'].schedule('..getProjectMetadata', target).output);
47
+ const getBuilderNameForTarget = (target) => {
48
+ if (typeof target === 'string') {
49
+ return Promise.resolve(context.projectGraph.nodes[context.projectName].data.targets[target]
50
+ .executor);
51
+ }
52
+ return Promise.resolve(context.projectGraph.nodes[target.project].data.targets[target.target]
53
+ .executor);
54
+ };
55
+ const getTargetOptions = (target) => {
56
+ if (typeof target === 'string') {
57
+ return Promise.resolve({
58
+ ...context.projectGraph.nodes[context.projectName].data.targets[target]
59
+ .options,
60
+ });
61
+ }
62
+ return Promise.resolve({
63
+ ...context.projectGraph.nodes[target.project].data.targets[target.target]
64
+ .options,
65
+ ...context.projectGraph.nodes[target.project].data.targets[target.target]
66
+ .configurations[target.configuration],
67
+ });
68
+ };
44
69
  const builderContext = {
45
70
  workspaceRoot: context.root,
46
71
  target: {
@@ -55,9 +80,7 @@ async function createBuilderContext(builderInfo, context) {
55
80
  id: 1,
56
81
  currentDirectory: process.cwd(),
57
82
  scheduleTarget: architect.scheduleTarget,
58
- getBuilderNameForTarget: architectHost.getBuilderNameForTarget,
59
83
  scheduleBuilder: architect.scheduleBuilder,
60
- getTargetOptions: architectHost.getOptionsForTarget,
61
84
  addTeardown(teardown) {
62
85
  // No-op as Nx doesn't require an implementation of this function
63
86
  return;
@@ -74,8 +97,10 @@ async function createBuilderContext(builderInfo, context) {
74
97
  // No-op as Nx doesn't require an implementation of this function
75
98
  return;
76
99
  },
100
+ getBuilderNameForTarget,
77
101
  getProjectMetadata,
78
102
  validateOptions,
103
+ getTargetOptions,
79
104
  };
80
105
  return builderContext;
81
106
  }
@@ -100,14 +100,14 @@ async function releaseChangelog(args) {
100
100
  : [];
101
101
  (0, shared_1.handleDuplicateGitTags)(gitTagValues);
102
102
  const postGitTasks = [];
103
- await generateChangelogForWorkspace(tree, args, nxReleaseConfig, workspaceChangelogVersion, commits, postGitTasks);
103
+ await generateChangelogForWorkspace(tree, args, projectGraph, nxReleaseConfig, workspaceChangelogVersion, commits, postGitTasks);
104
104
  if (args.projects?.length) {
105
105
  /**
106
106
  * Run changelog generation for all remaining release groups and filtered projects within them
107
107
  */
108
108
  for (const releaseGroup of releaseGroups) {
109
109
  const projectNodes = Array.from(releaseGroupToFilteredProjects.get(releaseGroup)).map((name) => projectGraph.nodes[name]);
110
- await generateChangelogForProjects(tree, args, commits, projectsVersionData, postGitTasks, releaseGroup, projectNodes);
110
+ await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, postGitTasks, releaseGroup, projectNodes);
111
111
  }
112
112
  return await applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues);
113
113
  }
@@ -116,7 +116,7 @@ async function releaseChangelog(args) {
116
116
  */
117
117
  for (const releaseGroup of releaseGroups) {
118
118
  const projectNodes = releaseGroup.projects.map((name) => projectGraph.nodes[name]);
119
- await generateChangelogForProjects(tree, args, commits, projectsVersionData, postGitTasks, releaseGroup, projectNodes);
119
+ await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, postGitTasks, releaseGroup, projectNodes);
120
120
  }
121
121
  return await applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues);
122
122
  }
@@ -220,7 +220,7 @@ function resolveChangelogRenderer(changelogRendererPath) {
220
220
  }
221
221
  return changelogRenderer;
222
222
  }
223
- async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, workspaceChangelogVersion, commits, postGitTasks) {
223
+ async function generateChangelogForWorkspace(tree, args, projectGraph, nxReleaseConfig, workspaceChangelogVersion, commits, postGitTasks) {
224
224
  const config = nxReleaseConfig.changelog.workspaceChangelog;
225
225
  // The entire feature is disabled at the workspace level, exit early
226
226
  if (config === false) {
@@ -250,17 +250,17 @@ async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, worksp
250
250
  version: workspaceChangelogVersion,
251
251
  releaseTagPattern: nxReleaseConfig.releaseTagPattern,
252
252
  });
253
- // We are either creating/previewing a changelog file, a Github release, or both
253
+ // We are either creating/previewing a changelog file, a GitHub release, or both
254
254
  let logTitle = dryRun ? 'Previewing a' : 'Generating a';
255
255
  switch (true) {
256
256
  case interpolatedTreePath && config.createRelease === 'github':
257
- logTitle += ` Github release and an entry in ${interpolatedTreePath} for ${chalk.white(releaseVersion.gitTag)}`;
257
+ logTitle += ` GitHub release and an entry in ${interpolatedTreePath} for ${chalk.white(releaseVersion.gitTag)}`;
258
258
  break;
259
259
  case !!interpolatedTreePath:
260
260
  logTitle += `n entry in ${interpolatedTreePath} for ${chalk.white(releaseVersion.gitTag)}`;
261
261
  break;
262
262
  case config.createRelease === 'github':
263
- logTitle += ` Github release for ${chalk.white(releaseVersion.gitTag)}`;
263
+ logTitle += ` GitHub release for ${chalk.white(releaseVersion.gitTag)}`;
264
264
  }
265
265
  output_1.output.log({
266
266
  title: logTitle,
@@ -269,6 +269,7 @@ async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, worksp
269
269
  ? (0, github_1.getGitHubRepoSlug)(gitRemote)
270
270
  : undefined;
271
271
  let contents = await changelogRenderer({
272
+ projectGraph,
272
273
  commits,
273
274
  releaseVersion: releaseVersion.rawVersion,
274
275
  project: null,
@@ -291,7 +292,7 @@ async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, worksp
291
292
  }
292
293
  /**
293
294
  * The exact logic we use for printing the summary/diff to the user is dependent upon whether they are creating
294
- * a changelog file, a Github release, or both.
295
+ * a changelog file, a GitHub release, or both.
295
296
  */
296
297
  let printSummary = () => { };
297
298
  const noDiffInChangelogMessage = chalk.yellow(`NOTE: There was no diff detected for the changelog entry. Maybe you intended to pass alternative git references via --from and --to?`);
@@ -321,9 +322,9 @@ async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, worksp
321
322
  if (config.createRelease === 'github') {
322
323
  if (!githubRepoSlug) {
323
324
  output_1.output.error({
324
- title: `Unable to create a Github release because the Github repo slug could not be determined.`,
325
+ title: `Unable to create a GitHub release because the GitHub repo slug could not be determined.`,
325
326
  bodyLines: [
326
- `Please ensure you have a valid Github remote configured. You can run \`git remote -v\` to list your current remotes.`,
327
+ `Please ensure you have a valid GitHub remote configured. You can run \`git remote -v\` to list your current remotes.`,
327
328
  ],
328
329
  });
329
330
  process.exit(1);
@@ -340,9 +341,9 @@ async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, worksp
340
341
  catch (err) {
341
342
  if (err.response?.status === 401) {
342
343
  output_1.output.error({
343
- title: `Unable to resolve data via the Github API. You can use any of the following options to resolve this:`,
344
+ title: `Unable to resolve data via the GitHub API. You can use any of the following options to resolve this:`,
344
345
  bodyLines: [
345
- '- Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a valid Github token with `repo` scope',
346
+ '- Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a valid GitHub token with `repo` scope',
346
347
  '- Have an active session via the official gh CLI tool (https://cli.github.com) in your current terminal',
347
348
  ],
348
349
  });
@@ -390,7 +391,7 @@ async function generateChangelogForWorkspace(tree, args, nxReleaseConfig, worksp
390
391
  }
391
392
  printSummary();
392
393
  }
393
- async function generateChangelogForProjects(tree, args, commits, projectsVersionData, postGitTasks, releaseGroup, projects) {
394
+ async function generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, postGitTasks, releaseGroup, projects) {
394
395
  const config = releaseGroup.changelog;
395
396
  // The entire feature is disabled at the release group level, exit early
396
397
  if (config === false) {
@@ -422,17 +423,17 @@ async function generateChangelogForProjects(tree, args, commits, projectsVersion
422
423
  releaseTagPattern: releaseGroup.releaseTagPattern,
423
424
  projectName: project.name,
424
425
  });
425
- // We are either creating/previewing a changelog file, a Github release, or both
426
+ // We are either creating/previewing a changelog file, a GitHub release, or both
426
427
  let logTitle = dryRun ? 'Previewing a' : 'Generating a';
427
428
  switch (true) {
428
429
  case interpolatedTreePath && config.createRelease === 'github':
429
- logTitle += ` Github release and an entry in ${interpolatedTreePath} for ${chalk.white(releaseVersion.gitTag)}`;
430
+ logTitle += ` GitHub release and an entry in ${interpolatedTreePath} for ${chalk.white(releaseVersion.gitTag)}`;
430
431
  break;
431
432
  case !!interpolatedTreePath:
432
433
  logTitle += `n entry in ${interpolatedTreePath} for ${chalk.white(releaseVersion.gitTag)}`;
433
434
  break;
434
435
  case config.createRelease === 'github':
435
- logTitle += ` Github release for ${chalk.white(releaseVersion.gitTag)}`;
436
+ logTitle += ` GitHub release for ${chalk.white(releaseVersion.gitTag)}`;
436
437
  }
437
438
  output_1.output.log({
438
439
  title: logTitle,
@@ -441,6 +442,7 @@ async function generateChangelogForProjects(tree, args, commits, projectsVersion
441
442
  ? (0, github_1.getGitHubRepoSlug)(gitRemote)
442
443
  : undefined;
443
444
  let contents = await changelogRenderer({
445
+ projectGraph,
444
446
  commits,
445
447
  releaseVersion: releaseVersion.rawVersion,
446
448
  project: project.name,
@@ -469,7 +471,7 @@ async function generateChangelogForProjects(tree, args, commits, projectsVersion
469
471
  }
470
472
  /**
471
473
  * The exact logic we use for printing the summary/diff to the user is dependent upon whether they are creating
472
- * a changelog file, a Github release, or both.
474
+ * a changelog file, a GitHub release, or both.
473
475
  */
474
476
  let printSummary = () => { };
475
477
  const noDiffInChangelogMessage = chalk.yellow(`NOTE: There was no diff detected for the changelog entry. Maybe you intended to pass alternative git references via --from and --to?`);
@@ -501,9 +503,9 @@ async function generateChangelogForProjects(tree, args, commits, projectsVersion
501
503
  if (config.createRelease === 'github') {
502
504
  if (!githubRepoSlug) {
503
505
  output_1.output.error({
504
- title: `Unable to create a Github release because the Github repo slug could not be determined.`,
506
+ title: `Unable to create a GitHub release because the GitHub repo slug could not be determined.`,
505
507
  bodyLines: [
506
- `Please ensure you have a valid Github remote configured. You can run \`git remote -v\` to list your current remotes.`,
508
+ `Please ensure you have a valid GitHub remote configured. You can run \`git remote -v\` to list your current remotes.`,
507
509
  ],
508
510
  });
509
511
  process.exit(1);
@@ -520,9 +522,9 @@ async function generateChangelogForProjects(tree, args, commits, projectsVersion
520
522
  catch (err) {
521
523
  if (err.response?.status === 401) {
522
524
  output_1.output.error({
523
- title: `Unable to resolve data via the Github API. You can use any of the following options to resolve this:`,
525
+ title: `Unable to resolve data via the GitHub API. You can use any of the following options to resolve this:`,
524
526
  bodyLines: [
525
- '- Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a valid Github token with `repo` scope',
527
+ '- Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a valid GitHub token with `repo` scope',
526
528
  '- Have an active session via the official gh CLI tool (https://cli.github.com) in your current terminal',
527
529
  ],
528
530
  });
@@ -94,7 +94,20 @@ async function resolveGithubToken() {
94
94
  const yamlContents = await node_fs_1.promises.readFile(ghCLIPath, 'utf8');
95
95
  const { load } = require('@zkochan/js-yaml');
96
96
  const ghCLIConfig = load(yamlContents);
97
- return ghCLIConfig['github.com'].oauth_token;
97
+ if (ghCLIConfig['github.com']) {
98
+ // Web based session (the token is already embedded in the config)
99
+ if (ghCLIConfig['github.com'].oauth_token) {
100
+ return ghCLIConfig['github.com'].oauth_token;
101
+ }
102
+ // SSH based session (we need to dynamically resolve a token using the CLI)
103
+ if (ghCLIConfig['github.com'].user &&
104
+ ghCLIConfig['github.com'].git_protocol === 'ssh') {
105
+ return (0, node_child_process_1.execSync)(`gh auth token`, {
106
+ encoding: 'utf8',
107
+ stdio: 'pipe',
108
+ }).trim();
109
+ }
110
+ }
98
111
  }
99
112
  return null;
100
113
  }
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveSemverSpecifierFromPrompt = exports.resolveSemverSpecifierFromConventionalCommits = void 0;
4
4
  const enquirer_1 = require("enquirer");
5
5
  const semver_1 = require("semver");
6
- const file_map_utils_1 = require("../../../project-graph/file-map-utils");
7
6
  const git_1 = require("./git");
8
7
  const semver_2 = require("./semver");
8
+ const shared_1 = require("./shared");
9
9
  // TODO: Extract config to nx.json configuration when adding changelog customization
10
10
  const CONVENTIONAL_COMMITS_CONFIG = {
11
11
  types: {
@@ -20,16 +20,7 @@ const CONVENTIONAL_COMMITS_CONFIG = {
20
20
  async function resolveSemverSpecifierFromConventionalCommits(from, projectGraph, projectNames) {
21
21
  const commits = await (0, git_1.getGitDiff)(from);
22
22
  const parsedCommits = (0, git_1.parseCommits)(commits);
23
- const { fileMap } = await (0, file_map_utils_1.createFileMapUsingProjectGraph)(projectGraph);
24
- const filesInReleaseGroup = new Set(projectNames.reduce((files, p) => [...files, ...fileMap.projectFileMap[p].map((f) => f.file)], []));
25
- /**
26
- * The relevant commits are those that either:
27
- * - touch project files which are contained within the release group directly
28
- * - touch non-project files and the commit is not scoped
29
- */
30
- const relevantCommits = parsedCommits.filter((c) => c.affectedFiles.some((f) => filesInReleaseGroup.has(f) ||
31
- (!c.scope &&
32
- fileMap.nonProjectFiles.some((nonProjectFile) => nonProjectFile.file === f))));
23
+ const relevantCommits = await (0, shared_1.getCommitsRelevantToProjects)(projectGraph, parsedCommits, projectNames);
33
24
  return (0, semver_2.determineSemverChange)(relevantCommits, CONVENTIONAL_COMMITS_CONFIG);
34
25
  }
35
26
  exports.resolveSemverSpecifierFromConventionalCommits = resolveSemverSpecifierFromConventionalCommits;
@@ -1,4 +1,6 @@
1
+ import { ProjectGraph } from '../../../config/project-graph';
1
2
  import type { ReleaseGroupWithName } from '../config/filter-release-groups';
3
+ import { GitCommit } from './git';
2
4
  export type VersionData = Record<string, {
3
5
  newVersion: string;
4
6
  currentVersion: string;
@@ -20,3 +22,4 @@ export declare function commitChanges(changedFiles: string[], isDryRun: boolean,
20
22
  export declare function createCommitMessageValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData, userCommitMessage?: string): string[];
21
23
  export declare function createGitTagValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData): string[];
22
24
  export declare function handleDuplicateGitTags(gitTagValues: string[]): void;
25
+ export declare function getCommitsRelevantToProjects(projectGraph: ProjectGraph, commits: GitCommit[], projects: string[]): Promise<GitCommit[]>;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleDuplicateGitTags = exports.createGitTagValues = exports.createCommitMessageValues = exports.commitChanges = exports.ReleaseVersion = void 0;
3
+ exports.getCommitsRelevantToProjects = exports.handleDuplicateGitTags = exports.createGitTagValues = exports.createCommitMessageValues = exports.commitChanges = exports.ReleaseVersion = void 0;
4
4
  const semver_1 = require("semver");
5
+ const file_map_utils_1 = require("../../../project-graph/file-map-utils");
5
6
  const utils_1 = require("../../../tasks-runner/utils");
6
7
  const output_1 = require("../../../utils/output");
7
8
  const git_1 = require("./git");
@@ -156,3 +157,16 @@ function handleDuplicateGitTags(gitTagValues) {
156
157
  }
157
158
  }
158
159
  exports.handleDuplicateGitTags = handleDuplicateGitTags;
160
+ async function getCommitsRelevantToProjects(projectGraph, commits, projects) {
161
+ const { fileMap } = await (0, file_map_utils_1.createFileMapUsingProjectGraph)(projectGraph);
162
+ const filesInReleaseGroup = new Set(projects.reduce((files, p) => [...files, ...fileMap.projectFileMap[p].map((f) => f.file)], []));
163
+ /**
164
+ * The relevant commits are those that either:
165
+ * - touch project files which are contained within the list of projects directly
166
+ * - touch non-project files and the commit is not scoped
167
+ */
168
+ return commits.filter((c) => c.affectedFiles.some((f) => filesInReleaseGroup.has(f) ||
169
+ (!c.scope &&
170
+ fileMap.nonProjectFiles.some((nonProjectFile) => nonProjectFile.file === f))));
171
+ }
172
+ exports.getCommitsRelevantToProjects = getCommitsRelevantToProjects;
@@ -38,4 +38,4 @@ export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
38
38
  export default function (options: RunCommandsOptions, context: ExecutorContext): Promise<{
39
39
  success: boolean;
40
40
  }>;
41
- export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'parsedArgs' | '__unparsed__'>, forwardAllArgs: boolean): string;
41
+ export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__'>, forwardAllArgs: boolean): string;
@@ -185,7 +185,7 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
185
185
  return command.replace(regex, (_, group) => opts.parsedArgs[group] !== undefined ? opts.parsedArgs[group] : '');
186
186
  }
187
187
  else if (forwardAllArgs) {
188
- return `${command}${opts.__unparsed__.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
188
+ return `${command}${opts.args ? ' ' + opts.args : ''}${opts.__unparsed__.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
189
189
  }
190
190
  else {
191
191
  return command;
@@ -169,7 +169,7 @@ export class Watcher {
169
169
  }
170
170
  export class WorkspaceContext {
171
171
  workspaceRoot: string
172
- constructor(workspaceRoot: string)
172
+ constructor(workspaceRoot: string, cacheDir: string)
173
173
  getWorkspaceFiles(projectRootMap: Record<string, string>): NxWorkspaceFiles
174
174
  glob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<string>
175
175
  hashFilesMatchingGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): string
@@ -68,10 +68,16 @@ function readProjectsConfigurationFromProjectGraph(projectGraph) {
68
68
  exports.readProjectsConfigurationFromProjectGraph = readProjectsConfigurationFromProjectGraph;
69
69
  async function buildProjectGraphWithoutDaemon() {
70
70
  const nxJson = (0, nx_json_1.readNxJson)();
71
+ perf_hooks_1.performance.mark('retrieve-project-configurations:start');
71
72
  const { projects, externalNodes, sourceMaps, projectRootMap } = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
73
+ perf_hooks_1.performance.mark('retrieve-project-configurations:end');
74
+ perf_hooks_1.performance.mark('retrieve-workspace-files:start');
72
75
  const { allWorkspaceFiles, fileMap, rustReferences } = await (0, retrieve_workspace_files_1.retrieveWorkspaceFiles)(workspace_root_1.workspaceRoot, projectRootMap);
76
+ perf_hooks_1.performance.mark('retrieve-workspace-files:end');
73
77
  const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
78
+ perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:start');
74
79
  const projectGraph = (await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, cacheEnabled)).projectGraph;
80
+ perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
75
81
  (0, source_maps_1.writeSourceMaps)(sourceMaps);
76
82
  (0, nx_plugin_1.unregisterPluginTSTranspiler)();
77
83
  return projectGraph;
@@ -122,6 +128,9 @@ async function createProjectGraphAsync(opts = {
122
128
  if (!client_1.daemonClient.enabled()) {
123
129
  try {
124
130
  const res = await buildProjectGraphWithoutDaemon();
131
+ perf_hooks_1.performance.measure('create-project-graph-async >> retrieve-project-configurations', 'retrieve-project-configurations:start', 'retrieve-project-configurations:end');
132
+ perf_hooks_1.performance.measure('create-project-graph-async >> retrieve-workspace-files', 'retrieve-workspace-files:start', 'retrieve-workspace-files:end');
133
+ perf_hooks_1.performance.measure('create-project-graph-async >> build-project-graph-using-project-file-map', 'build-project-graph-using-project-file-map:start', 'build-project-graph-using-project-file-map:end');
125
134
  perf_hooks_1.performance.mark('create-project-graph-async:end');
126
135
  perf_hooks_1.performance.measure('create-project-graph-async', 'create-project-graph-async:start', 'create-project-graph-async:end');
127
136
  return res;
@@ -2,4 +2,5 @@
2
2
  * Path to the directory where Nx stores its cache and daemon-related files.
3
3
  */
4
4
  export declare const cacheDir: string;
5
+ export declare function cacheDirectoryForWorkspace(workspaceRoot: string): string;
5
6
  export declare const projectGraphCacheDirectory: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectGraphCacheDirectory = exports.cacheDir = void 0;
3
+ exports.projectGraphCacheDirectory = exports.cacheDirectoryForWorkspace = exports.cacheDir = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const fileutils_1 = require("./fileutils");
@@ -52,5 +52,9 @@ function defaultCacheDirectory(root) {
52
52
  * Path to the directory where Nx stores its cache and daemon-related files.
53
53
  */
54
54
  exports.cacheDir = cacheDirectory(workspace_root_1.workspaceRoot, readCacheDirectoryProperty(workspace_root_1.workspaceRoot));
55
+ function cacheDirectoryForWorkspace(workspaceRoot) {
56
+ return cacheDirectory(workspaceRoot, readCacheDirectoryProperty(workspaceRoot));
57
+ }
58
+ exports.cacheDirectoryForWorkspace = cacheDirectoryForWorkspace;
55
59
  exports.projectGraphCacheDirectory = absolutePath(workspace_root_1.workspaceRoot, process.env.NX_PROJECT_GRAPH_CACHE_DIRECTORY ??
56
60
  defaultCacheDirectory(workspace_root_1.workspaceRoot));
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resetWorkspaceContext = exports.updateProjectFiles = exports.getAllFileDataInContext = exports.updateFilesInContext = exports.hashWithWorkspaceContext = exports.globWithWorkspaceContext = exports.getNxWorkspaceFilesFromContext = exports.setupWorkspaceContext = void 0;
4
4
  const perf_hooks_1 = require("perf_hooks");
5
+ const cache_directory_1 = require("./cache-directory");
5
6
  let workspaceContext;
6
7
  function setupWorkspaceContext(workspaceRoot) {
7
8
  const { WorkspaceContext } = require('../native');
8
9
  perf_hooks_1.performance.mark('workspace-context');
9
- workspaceContext = new WorkspaceContext(workspaceRoot);
10
+ workspaceContext = new WorkspaceContext(workspaceRoot, (0, cache_directory_1.cacheDirectoryForWorkspace)(workspaceRoot));
10
11
  perf_hooks_1.performance.mark('workspace-context:end');
11
12
  perf_hooks_1.performance.measure('workspace context init', 'workspace-context', 'workspace-context:end');
12
13
  }