nx 19.4.0-beta.1 → 19.4.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/package.json +14 -14
  2. package/release/changelog-renderer/index.d.ts +6 -0
  3. package/release/changelog-renderer/index.js +1 -1
  4. package/src/command-line/connect/connect-to-nx-cloud.d.ts +1 -1
  5. package/src/command-line/connect/connect-to-nx-cloud.js +16 -25
  6. package/src/command-line/graph/graph.d.ts +1 -0
  7. package/src/command-line/graph/graph.js +12 -1
  8. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -6
  9. package/src/command-line/release/changelog.js +6 -1
  10. package/src/command-line/release/config/config.js +3 -0
  11. package/src/command-line/run/command-object.js +2 -1
  12. package/src/config/workspace-json-project-json.d.ts +2 -0
  13. package/src/core/graph/main.js +1 -1
  14. package/src/core/graph/styles.css +1 -1
  15. package/src/daemon/client/client.d.ts +5 -0
  16. package/src/daemon/client/client.js +14 -0
  17. package/src/daemon/message-types/task-history.d.ts +13 -0
  18. package/src/daemon/message-types/task-history.js +19 -0
  19. package/src/daemon/server/handle-get-task-history.d.ts +4 -0
  20. package/src/daemon/server/handle-get-task-history.js +12 -0
  21. package/src/daemon/server/handle-write-task-runs-to-history.d.ts +5 -0
  22. package/src/daemon/server/handle-write-task-runs-to-history.js +12 -0
  23. package/src/daemon/server/plugins.js +12 -2
  24. package/src/daemon/server/server.js +9 -0
  25. package/src/daemon/socket-utils.d.ts +1 -0
  26. package/src/daemon/socket-utils.js +6 -1
  27. package/src/executors/run-commands/run-commands.impl.js +29 -20
  28. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
  29. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +68 -33
  30. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +5 -0
  31. package/src/nx-cloud/utilities/url-shorten.d.ts +2 -1
  32. package/src/nx-cloud/utilities/url-shorten.js +47 -11
  33. package/src/plugins/package-json-workspaces/create-nodes.js +1 -0
  34. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +10 -2
  35. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +5 -0
  36. package/src/project-graph/plugins/internal-api.js +1 -1
  37. package/src/project-graph/plugins/isolation/index.d.ts +1 -1
  38. package/src/project-graph/plugins/isolation/index.js +8 -13
  39. package/src/project-graph/plugins/isolation/messaging.d.ts +6 -3
  40. package/src/project-graph/plugins/isolation/messaging.js +9 -3
  41. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  42. package/src/project-graph/plugins/isolation/plugin-pool.js +123 -43
  43. package/src/project-graph/plugins/isolation/plugin-worker.js +128 -107
  44. package/src/project-graph/project-graph.js +7 -1
  45. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -5
  46. package/src/project-graph/utils/normalize-project-nodes.js +2 -17
  47. package/src/project-graph/utils/project-configuration-utils.js +14 -3
  48. package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
  49. package/src/tasks-runner/default-tasks-runner.js +2 -2
  50. package/src/tasks-runner/life-cycle.d.ts +10 -10
  51. package/src/tasks-runner/life-cycle.js +10 -10
  52. package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +9 -0
  53. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +54 -0
  54. package/src/tasks-runner/run-command.js +6 -0
  55. package/src/tasks-runner/task-env.d.ts +13 -0
  56. package/src/tasks-runner/task-env.js +41 -26
  57. package/src/tasks-runner/task-orchestrator.js +4 -4
  58. package/src/utils/git-utils.d.ts +1 -1
  59. package/src/utils/git-utils.js +13 -2
  60. package/src/utils/nx-cloud-utils.d.ts +1 -1
  61. package/src/utils/nx-cloud-utils.js +1 -1
  62. package/src/utils/package-json.d.ts +3 -0
  63. package/src/utils/package-json.js +15 -3
  64. package/src/utils/serialize-target.d.ts +1 -0
  65. package/src/utils/serialize-target.js +7 -0
  66. package/src/utils/task-history.d.ts +8 -0
  67. package/src/utils/task-history.js +97 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.4.0-beta.1",
3
+ "version": "19.4.0-beta.2",
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": {
@@ -45,8 +45,8 @@
45
45
  "cli-cursor": "3.1.0",
46
46
  "cli-spinners": "2.6.1",
47
47
  "cliui": "^8.0.1",
48
- "dotenv": "~16.3.1",
49
- "dotenv-expand": "~10.0.0",
48
+ "dotenv": "~16.4.5",
49
+ "dotenv-expand": "~11.0.6",
50
50
  "enquirer": "~2.3.6",
51
51
  "figures": "3.2.0",
52
52
  "flat": "^5.0.2",
@@ -70,7 +70,7 @@
70
70
  "yargs-parser": "21.1.1",
71
71
  "node-machine-id": "1.1.12",
72
72
  "ora": "5.3.0",
73
- "@nrwl/tao": "19.4.0-beta.1"
73
+ "@nrwl/tao": "19.4.0-beta.2"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@swc-node/register": "^1.8.0",
@@ -85,16 +85,16 @@
85
85
  }
86
86
  },
87
87
  "optionalDependencies": {
88
- "@nx/nx-darwin-x64": "19.4.0-beta.1",
89
- "@nx/nx-darwin-arm64": "19.4.0-beta.1",
90
- "@nx/nx-linux-x64-gnu": "19.4.0-beta.1",
91
- "@nx/nx-linux-x64-musl": "19.4.0-beta.1",
92
- "@nx/nx-win32-x64-msvc": "19.4.0-beta.1",
93
- "@nx/nx-linux-arm64-gnu": "19.4.0-beta.1",
94
- "@nx/nx-linux-arm64-musl": "19.4.0-beta.1",
95
- "@nx/nx-linux-arm-gnueabihf": "19.4.0-beta.1",
96
- "@nx/nx-win32-arm64-msvc": "19.4.0-beta.1",
97
- "@nx/nx-freebsd-x64": "19.4.0-beta.1"
88
+ "@nx/nx-darwin-x64": "19.4.0-beta.2",
89
+ "@nx/nx-darwin-arm64": "19.4.0-beta.2",
90
+ "@nx/nx-linux-x64-gnu": "19.4.0-beta.2",
91
+ "@nx/nx-linux-x64-musl": "19.4.0-beta.2",
92
+ "@nx/nx-win32-x64-msvc": "19.4.0-beta.2",
93
+ "@nx/nx-linux-arm64-gnu": "19.4.0-beta.2",
94
+ "@nx/nx-linux-arm64-musl": "19.4.0-beta.2",
95
+ "@nx/nx-linux-arm-gnueabihf": "19.4.0-beta.2",
96
+ "@nx/nx-win32-arm64-msvc": "19.4.0-beta.2",
97
+ "@nx/nx-freebsd-x64": "19.4.0-beta.2"
98
98
  },
99
99
  "nx-migrations": {
100
100
  "migrations": "./migrations.json",
@@ -53,6 +53,12 @@ export interface DefaultChangelogRenderOptions extends ChangelogRenderOptions {
53
53
  * section. Defaults to true.
54
54
  */
55
55
  authors?: boolean;
56
+ /**
57
+ * If authors is enabled, controls whether or not to try to map the authors to their GitHub usernames
58
+ * using https://ungh.cc (from https://github.com/unjs/ungh) and the email addresses found in the commits.
59
+ * Defaults to true.
60
+ */
61
+ mapAuthorsToGitHubUsernames?: boolean;
56
62
  /**
57
63
  * Whether or not the commit references (such as commit and/or PR links) should be included in the changelog.
58
64
  * Defaults to true.
@@ -145,7 +145,7 @@ const defaultChangelogRenderer = async ({ projectGraph, changes, releaseVersion,
145
145
  }
146
146
  }
147
147
  // Try to map authors to github usernames
148
- if (repoSlug) {
148
+ if (repoSlug && changelogRenderOptions.mapAuthorsToGitHubUsernames) {
149
149
  await Promise.all([..._authors.keys()].map(async (authorName) => {
150
150
  const meta = _authors.get(authorName);
151
151
  for (const email of meta.email) {
@@ -3,6 +3,6 @@ import { NxArgs } from '../../utils/command-line-utils';
3
3
  import { MessageKey } from '../../utils/ab-testing';
4
4
  export declare function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration): boolean;
5
5
  export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise<void>;
6
- export declare function connectToNxCloudCommand(): Promise<boolean>;
6
+ export declare function connectToNxCloudCommand(command?: string): Promise<boolean>;
7
7
  export declare function connectToNxCloudWithPrompt(command: string): Promise<void>;
8
8
  export declare function connectExistingRepoToNxCloudPrompt(key?: MessageKey): Promise<boolean>;
@@ -41,38 +41,29 @@ async function connectToNxCloudIfExplicitlyAsked(opts) {
41
41
  }
42
42
  }
43
43
  exports.connectToNxCloudIfExplicitlyAsked = connectToNxCloudIfExplicitlyAsked;
44
- async function connectToNxCloudCommand() {
44
+ async function connectToNxCloudCommand(command) {
45
45
  const nxJson = (0, configuration_1.readNxJson)();
46
46
  if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
47
- if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') {
48
- output_1.output.log({
49
- title: '✔ This workspace already has Nx Cloud set up',
50
- bodyLines: [
51
- 'If you have not done so already, connect your workspace to your Nx Cloud account:',
52
- `- Login at ${(0, nx_cloud_utils_1.getNxCloudUrl)(nxJson)} to connect your repository`,
53
- ],
54
- });
47
+ const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken;
48
+ if (!token) {
49
+ throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
55
50
  }
56
- else {
57
- const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken;
58
- if (!token) {
59
- throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
60
- }
61
- const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)('nx-connect', token);
62
- output_1.output.log({
63
- title: '✔ This workspace already has Nx Cloud set up',
64
- bodyLines: [
65
- 'If you have not done so already, connect your workspace to your Nx Cloud account:',
66
- `- Connect with Nx Cloud at:
51
+ const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)('nx-connect', token);
52
+ output_1.output.log({
53
+ title: '✔ This workspace already has Nx Cloud set up',
54
+ bodyLines: [
55
+ 'If you have not done so already, connect your workspace to your Nx Cloud account:',
56
+ `- Connect with Nx Cloud at:
67
57
 
68
58
  ${connectCloudUrl}`,
69
- ],
70
- });
71
- }
59
+ ],
60
+ });
72
61
  return false;
73
62
  }
74
63
  const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, false, 'connect-to-nx-cloud');
75
- const callback = await (0, connect_to_nx_cloud_1.connectToNxCloud)(tree, {});
64
+ const callback = await (0, connect_to_nx_cloud_1.connectToNxCloud)(tree, {
65
+ installationSource: command ?? 'nx-connect',
66
+ });
76
67
  tree.lock();
77
68
  (0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, tree.listChanges());
78
69
  await callback();
@@ -81,7 +72,7 @@ async function connectToNxCloudCommand() {
81
72
  exports.connectToNxCloudCommand = connectToNxCloudCommand;
82
73
  async function connectToNxCloudWithPrompt(command) {
83
74
  const setNxCloud = await nxCloudPrompt('setupNxCloud');
84
- const useCloud = setNxCloud === 'yes' ? await connectToNxCloudCommand() : false;
75
+ const useCloud = setNxCloud === 'yes' ? await connectToNxCloudCommand(command) : false;
85
76
  await (0, ab_testing_1.recordStat)({
86
77
  command,
87
78
  nxVersion: versions_1.nxVersion,
@@ -23,6 +23,7 @@ export interface ProjectGraphClientResponse {
23
23
  exclude: string[];
24
24
  isPartial: boolean;
25
25
  errors?: GraphError[];
26
+ connectedToCloud?: boolean;
26
27
  }
27
28
  export interface TaskGraphClientResponse {
28
29
  taskGraphs: Record<string, TaskGraph>;
@@ -28,6 +28,7 @@ const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
28
28
  const create_task_hasher_1 = require("../../hasher/create-task-hasher");
29
29
  const task_hasher_1 = require("../../hasher/task-hasher");
30
30
  const error_types_1 = require("../../project-graph/error-types");
31
+ const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
31
32
  // maps file extention to MIME types
32
33
  const mimeType = {
33
34
  '.ico': 'image/x-icon',
@@ -478,10 +479,12 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
478
479
  let sourceMaps;
479
480
  let isPartial = false;
480
481
  let errors;
482
+ let connectedToCloud;
481
483
  try {
482
484
  const projectGraphAndSourceMaps = await (0, project_graph_1.createProjectGraphAndSourceMapsAsync)({ exitOnError: false });
483
485
  projectGraph = projectGraphAndSourceMaps.projectGraph;
484
486
  sourceMaps = projectGraphAndSourceMaps.sourceMaps;
487
+ connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, configuration_1.readNxJson)());
485
488
  }
486
489
  catch (e) {
487
490
  if (e instanceof error_types_1.ProjectGraphError) {
@@ -509,7 +512,14 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
509
512
  const projects = Object.values(graph.nodes);
510
513
  const dependencies = graph.dependencies;
511
514
  const hasher = (0, crypto_1.createHash)('sha256');
512
- hasher.update(JSON.stringify({ layout, projects, dependencies, sourceMaps, errors }));
515
+ hasher.update(JSON.stringify({
516
+ layout,
517
+ projects,
518
+ dependencies,
519
+ sourceMaps,
520
+ errors,
521
+ connectedToCloud,
522
+ }));
513
523
  const hash = hasher.digest('hex');
514
524
  perf_hooks_1.performance.mark('project graph response generation:end');
515
525
  perf_hooks_1.performance.measure('project graph watch calculation', 'project graph watch calculation:start', 'project graph watch calculation:end');
@@ -525,6 +535,7 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
525
535
  fileMap,
526
536
  isPartial,
527
537
  errors,
538
+ connectedToCloud,
528
539
  },
529
540
  sourceMapResponse: sourceMaps,
530
541
  };
@@ -74,12 +74,11 @@ function writeMinimalNxJson(host, version) {
74
74
  exports.writeMinimalNxJson = writeMinimalNxJson;
75
75
  function updateGitIgnore(host) {
76
76
  let contents = host.read('.gitignore', 'utf-8') ?? '';
77
- if (!contents.includes('.nx/installation')) {
78
- contents = [contents, '.nx/installation'].join('\n');
79
- }
80
- if (!contents.includes('.nx/cache')) {
81
- contents = [contents, '.nx/cache'].join('\n');
82
- }
77
+ ['.nx/installation', '.nx/cache', '.nx/workspace-data'].forEach((file) => {
78
+ if (!contents.includes(file)) {
79
+ contents = [contents, file].join('\n');
80
+ }
81
+ });
83
82
  host.write('.gitignore', contents);
84
83
  }
85
84
  exports.updateGitIgnore = updateGitIgnore;
@@ -222,7 +222,12 @@ async function releaseChangelog(args) {
222
222
  continue;
223
223
  }
224
224
  for (const project of releaseGroup.projects) {
225
- const dependentProjects = (projectsVersionData[project]?.dependentProjects || [])
225
+ // If the project does not have any changes, do not process its dependents
226
+ if (!projectsVersionData[project] ||
227
+ projectsVersionData[project].newVersion === null) {
228
+ continue;
229
+ }
230
+ const dependentProjects = (projectsVersionData[project].dependentProjects || [])
226
231
  .map((dep) => {
227
232
  return {
228
233
  dependencyName: dep.source,
@@ -110,6 +110,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
110
110
  renderer: defaultRendererPath,
111
111
  renderOptions: {
112
112
  authors: true,
113
+ mapAuthorsToGitHubUsernames: true,
113
114
  commitReferences: true,
114
115
  versionTitleDate: true,
115
116
  },
@@ -123,6 +124,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
123
124
  renderer: defaultRendererPath,
124
125
  renderOptions: {
125
126
  authors: true,
127
+ mapAuthorsToGitHubUsernames: true,
126
128
  commitReferences: true,
127
129
  versionTitleDate: true,
128
130
  },
@@ -153,6 +155,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
153
155
  renderer: defaultRendererPath,
154
156
  renderOptions: {
155
157
  authors: true,
158
+ mapAuthorsToGitHubUsernames: true,
156
159
  commitReferences: true,
157
160
  versionTitleDate: true,
158
161
  },
@@ -28,8 +28,9 @@ exports.yargsNxInfixCommand = {
28
28
  command: '$0 <target> [project] [_..]',
29
29
  describe: 'Run a target for a project',
30
30
  handler: async (args) => {
31
- await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
31
+ const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
32
32
  return (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0));
33
33
  });
34
+ process.exit(exitCode);
34
35
  },
35
36
  };
@@ -105,6 +105,7 @@ export interface ProjectConfiguration {
105
105
  metadata?: ProjectMetadata;
106
106
  }
107
107
  export interface ProjectMetadata {
108
+ description?: string;
108
109
  technologies?: string[];
109
110
  targetGroups?: Record<string, string[]>;
110
111
  }
@@ -112,6 +113,7 @@ export interface TargetMetadata {
112
113
  [k: string]: any;
113
114
  description?: string;
114
115
  technologies?: string[];
116
+ nonAtomizedTarget?: string;
115
117
  }
116
118
  export interface TargetDependencyConfig {
117
119
  /**