nx 17.2.0-beta.1 → 17.2.0-beta.11

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 (60) hide show
  1. package/bin/nx.js +0 -16
  2. package/changelog-renderer/index.d.ts +3 -0
  3. package/changelog-renderer/index.js +8 -7
  4. package/package.json +12 -13
  5. package/schemas/nx-schema.json +3 -6
  6. package/src/adapter/ngcli-adapter.js +24 -2
  7. package/src/command-line/affected/print-affected.js +10 -1
  8. package/src/command-line/graph/graph.js +2 -2
  9. package/src/command-line/init/implementation/add-nx-to-nest.js +1 -1
  10. package/src/command-line/release/changelog.d.ts +7 -1
  11. package/src/command-line/release/changelog.js +171 -102
  12. package/src/command-line/release/command-object.d.ts +9 -4
  13. package/src/command-line/release/command-object.js +14 -3
  14. package/src/command-line/release/config/config.d.ts +10 -2
  15. package/src/command-line/release/config/config.js +24 -3
  16. package/src/command-line/release/index.d.ts +12 -0
  17. package/src/command-line/release/index.js +18 -0
  18. package/src/command-line/release/publish.d.ts +7 -3
  19. package/src/command-line/release/publish.js +23 -8
  20. package/src/command-line/release/utils/git.js +1 -1
  21. package/src/command-line/release/utils/github.js +14 -1
  22. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -4
  23. package/src/command-line/release/utils/shared.d.ts +3 -0
  24. package/src/command-line/release/utils/shared.js +15 -1
  25. package/src/command-line/release/version.d.ts +22 -1
  26. package/src/command-line/release/version.js +46 -7
  27. package/src/command-line/yargs-utils/shared-options.d.ts +3 -1
  28. package/src/command-line/yargs-utils/shared-options.js +14 -8
  29. package/src/config/nx-json.d.ts +22 -4
  30. package/src/daemon/server/handle-hash-tasks.js +2 -2
  31. package/src/daemon/server/project-graph-incremental-recomputation.d.ts +4 -0
  32. package/src/daemon/server/project-graph-incremental-recomputation.js +23 -18
  33. package/src/executors/run-commands/run-commands.impl.d.ts +1 -0
  34. package/src/executors/run-commands/run-commands.impl.js +9 -8
  35. package/src/executors/run-commands/schema.json +7 -0
  36. package/src/executors/utils/convert-nx-executor.js +1 -1
  37. package/src/hasher/hash-task.js +6 -0
  38. package/src/hasher/native-task-hasher-impl.d.ts +19 -0
  39. package/src/hasher/native-task-hasher-impl.js +35 -0
  40. package/src/hasher/node-task-hasher-impl.d.ts +49 -0
  41. package/src/hasher/node-task-hasher-impl.js +431 -0
  42. package/src/hasher/task-hasher.d.ts +29 -17
  43. package/src/hasher/task-hasher.js +28 -426
  44. package/src/native/index.d.ts +42 -6
  45. package/src/native/index.js +3 -2
  46. package/src/native/transform-objects.js +2 -0
  47. package/src/plugins/js/package-json/create-package-json.js +1 -1
  48. package/src/project-graph/build-project-graph.d.ts +3 -1
  49. package/src/project-graph/build-project-graph.js +5 -1
  50. package/src/project-graph/file-map-utils.d.ts +9 -5
  51. package/src/project-graph/file-map-utils.js +16 -63
  52. package/src/project-graph/project-graph.js +3 -2
  53. package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
  54. package/src/project-graph/utils/build-all-workspace-files.js +15 -0
  55. package/src/project-graph/utils/retrieve-workspace-files.d.ts +13 -22
  56. package/src/project-graph/utils/retrieve-workspace-files.js +17 -55
  57. package/src/tasks-runner/run-command.js +2 -6
  58. package/src/utils/nx-plugin.js +12 -2
  59. package/src/utils/workspace-context.d.ts +3 -2
  60. package/src/utils/workspace-context.js +7 -8
package/bin/nx.js CHANGED
@@ -38,22 +38,6 @@ function main() {
38
38
  require('nx/src/command-line/nx-commands').commandsObject.argv;
39
39
  }
40
40
  else {
41
- // v8-compile-cache doesn't support ESM. Attempting to import ESM
42
- // with it enabled results in an error that reads "Invalid host options".
43
- //
44
- // Angular CLI, and prettier both use ESM so we need to disable it in these cases.
45
- if (workspace &&
46
- workspace.type === 'nx' &&
47
- ![
48
- 'format',
49
- 'format:check',
50
- 'format:write',
51
- 'g',
52
- 'generate',
53
- 'release',
54
- ].some((cmd) => process.argv[2] === cmd)) {
55
- require('v8-compile-cache');
56
- }
57
41
  if (!client_1.daemonClient.enabled() && workspace !== null) {
58
42
  (0, workspace_context_1.setupWorkspaceContext)(workspace.dir);
59
43
  }
@@ -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.1",
3
+ "version": "17.2.0-beta.11",
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": {
@@ -63,11 +63,10 @@
63
63
  "tmp": "~0.2.1",
64
64
  "tsconfig-paths": "^4.1.2",
65
65
  "tslib": "^2.3.0",
66
- "v8-compile-cache": "2.3.0",
67
66
  "yargs": "^17.6.2",
68
67
  "yargs-parser": "21.1.1",
69
68
  "node-machine-id": "1.1.12",
70
- "@nrwl/tao": "17.2.0-beta.1"
69
+ "@nrwl/tao": "17.2.0-beta.11"
71
70
  },
72
71
  "peerDependencies": {
73
72
  "@swc-node/register": "^1.6.7",
@@ -82,16 +81,16 @@
82
81
  }
83
82
  },
84
83
  "optionalDependencies": {
85
- "@nx/nx-darwin-x64": "17.2.0-beta.1",
86
- "@nx/nx-darwin-arm64": "17.2.0-beta.1",
87
- "@nx/nx-linux-x64-gnu": "17.2.0-beta.1",
88
- "@nx/nx-linux-x64-musl": "17.2.0-beta.1",
89
- "@nx/nx-win32-x64-msvc": "17.2.0-beta.1",
90
- "@nx/nx-linux-arm64-gnu": "17.2.0-beta.1",
91
- "@nx/nx-linux-arm64-musl": "17.2.0-beta.1",
92
- "@nx/nx-linux-arm-gnueabihf": "17.2.0-beta.1",
93
- "@nx/nx-win32-arm64-msvc": "17.2.0-beta.1",
94
- "@nx/nx-freebsd-x64": "17.2.0-beta.1"
84
+ "@nx/nx-darwin-x64": "17.2.0-beta.11",
85
+ "@nx/nx-darwin-arm64": "17.2.0-beta.11",
86
+ "@nx/nx-linux-x64-gnu": "17.2.0-beta.11",
87
+ "@nx/nx-linux-x64-musl": "17.2.0-beta.11",
88
+ "@nx/nx-win32-x64-msvc": "17.2.0-beta.11",
89
+ "@nx/nx-linux-arm64-gnu": "17.2.0-beta.11",
90
+ "@nx/nx-linux-arm64-musl": "17.2.0-beta.11",
91
+ "@nx/nx-linux-arm-gnueabihf": "17.2.0-beta.11",
92
+ "@nx/nx-win32-arm64-msvc": "17.2.0-beta.11",
93
+ "@nx/nx-freebsd-x64": "17.2.0-beta.11"
95
94
  },
96
95
  "nx-migrations": {
97
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
  }
@@ -41,6 +41,28 @@ async function createBuilderContext(builderInfo, context) {
41
41
  options,
42
42
  ]).output);
43
43
  const getProjectMetadata = (target) => toPromise(architect['_scheduler'].schedule('..getProjectMetadata', target).output);
44
+ const getBuilderNameForTarget = (target) => {
45
+ if (typeof target === 'string') {
46
+ return Promise.resolve(context.projectGraph.nodes[context.projectName].data.targets[target]
47
+ .executor);
48
+ }
49
+ return Promise.resolve(context.projectGraph.nodes[target.project].data.targets[target.target]
50
+ .executor);
51
+ };
52
+ const getTargetOptions = (target) => {
53
+ if (typeof target === 'string') {
54
+ return Promise.resolve({
55
+ ...context.projectGraph.nodes[context.projectName].data.targets[target]
56
+ .options,
57
+ });
58
+ }
59
+ return Promise.resolve({
60
+ ...context.projectGraph.nodes[target.project].data.targets[target.target]
61
+ .options,
62
+ ...context.projectGraph.nodes[target.project].data.targets[target.target]
63
+ .configurations[target.configuration],
64
+ });
65
+ };
44
66
  const builderContext = {
45
67
  workspaceRoot: context.root,
46
68
  target: {
@@ -55,9 +77,7 @@ async function createBuilderContext(builderInfo, context) {
55
77
  id: 1,
56
78
  currentDirectory: process.cwd(),
57
79
  scheduleTarget: architect.scheduleTarget,
58
- getBuilderNameForTarget: architectHost.getBuilderNameForTarget,
59
80
  scheduleBuilder: architect.scheduleBuilder,
60
- getTargetOptions: architectHost.getOptionsForTarget,
61
81
  addTeardown(teardown) {
62
82
  // No-op as Nx doesn't require an implementation of this function
63
83
  return;
@@ -74,8 +94,10 @@ async function createBuilderContext(builderInfo, context) {
74
94
  // No-op as Nx doesn't require an implementation of this function
75
95
  return;
76
96
  },
97
+ getBuilderNameForTarget,
77
98
  getProjectMetadata,
78
99
  validateOptions,
100
+ getTargetOptions,
79
101
  };
80
102
  return builderContext;
81
103
  }
@@ -9,6 +9,8 @@ const package_manager_1 = require("../../utils/package-manager");
9
9
  const command_object_1 = require("./command-object");
10
10
  const logger_1 = require("../../utils/logger");
11
11
  const task_env_1 = require("../../tasks-runner/task-env");
12
+ const build_project_graph_1 = require("../../project-graph/build-project-graph");
13
+ const client_1 = require("../../daemon/client/client");
12
14
  /**
13
15
  * @deprecated Use showProjectsHandler, generateGraph, or affected (without the print-affected mode) instead.
14
16
  */
@@ -35,7 +37,14 @@ exports.printAffected = printAffected;
35
37
  async function createTasks(affectedProjectsWithTargetAndConfig, projectGraph, nxArgs, nxJson, overrides) {
36
38
  const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
37
39
  const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, defaultDependencyConfigs, affectedProjectsWithTargetAndConfig.map((p) => p.name), nxArgs.targets, nxArgs.configuration, overrides);
38
- const hasher = new task_hasher_1.InProcessTaskHasher({}, [], projectGraph, nxJson, {});
40
+ let hasher;
41
+ if (client_1.daemonClient.enabled()) {
42
+ hasher = new task_hasher_1.DaemonBasedTaskHasher(client_1.daemonClient, {});
43
+ }
44
+ else {
45
+ const { fileMap, allWorkspaceFiles, rustReferences } = (0, build_project_graph_1.getFileMap)();
46
+ hasher = new task_hasher_1.InProcessTaskHasher(fileMap?.projectFileMap, allWorkspaceFiles, projectGraph, nxJson, rustReferences, {});
47
+ }
39
48
  const execCommand = (0, package_manager_1.getPackageManagerCommand)().exec;
40
49
  const tasks = Object.values(taskGraph.tasks);
41
50
  await Promise.all(tasks.map((t) => (0, hash_task_1.hashTask)(hasher, projectGraph, taskGraph, t,
@@ -15,7 +15,6 @@ const fileutils_1 = require("../../utils/fileutils");
15
15
  const output_1 = require("../../utils/output");
16
16
  const workspace_root_1 = require("../../utils/workspace-root");
17
17
  const client_1 = require("../../daemon/client/client");
18
- const task_hasher_1 = require("../../hasher/task-hasher");
19
18
  const typescript_1 = require("../../plugins/js/utils/typescript");
20
19
  const operators_1 = require("../../project-graph/operators");
21
20
  const project_graph_1 = require("../../project-graph/project-graph");
@@ -26,6 +25,7 @@ const native_1 = require("../../native");
26
25
  const transform_objects_1 = require("../../native/transform-objects");
27
26
  const affected_1 = require("../affected/affected");
28
27
  const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
28
+ const task_hasher_1 = require("../../hasher/task-hasher");
29
29
  // maps file extention to MIME types
30
30
  const mimeType = {
31
31
  '.ico': 'image/x-icon',
@@ -435,7 +435,7 @@ async function createTaskGraphClientResponse(pruneExternal = false) {
435
435
  perf_hooks_1.performance.mark('task graph generation:start');
436
436
  const taskGraphs = getAllTaskGraphsForWorkspace(nxJson, graph);
437
437
  perf_hooks_1.performance.mark('task graph generation:end');
438
- const planner = new native_1.HashPlanner(workspace_root_1.workspaceRoot, nxJson, (0, transform_objects_1.transformProjectGraphForRust)(graph));
438
+ const planner = new native_1.HashPlanner(nxJson, (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(graph)));
439
439
  perf_hooks_1.performance.mark('task hash plan generation:start');
440
440
  const plans = {};
441
441
  for (const individualTaskGraph of Object.values(taskGraphs.taskGraphs)) {
@@ -173,7 +173,7 @@ function createProjectJson(repoRoot, packageJson, nestCLIOptions) {
173
173
  executor: '@nx/eslint:lint',
174
174
  outputs: ['{options.outputFile}'],
175
175
  options: {
176
- lintFilePatterns: ['src/**/*.ts', 'test/**/*.ts'],
176
+ lintFilePatterns: ['./src', './test'],
177
177
  },
178
178
  };
179
179
  // test and e2e
@@ -1,2 +1,8 @@
1
1
  import { ChangelogOptions } from './command-object';
2
- export declare function changelogHandler(args: ChangelogOptions): Promise<number>;
2
+ export declare const releaseChangelogCLIHandler: (args: ChangelogOptions) => Promise<any>;
3
+ /**
4
+ * NOTE: This function is also exported for programmatic usage and forms part of the public API
5
+ * of Nx. We intentionally do not wrap the implementation with handleErrors because users need
6
+ * to have control over their own error handling when using the API.
7
+ */
8
+ export declare function releaseChangelog(args: ChangelogOptions): Promise<number>;